Commit 4c543c47 by 吕明尚

增加次卡,月卡的消费逻辑

parent 10adbc0b
......@@ -14,7 +14,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dianping.openapi.sdk.api.oauth.entity.CustomerRefreshTokenResponse;
import com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptGetConsumedReponseEntity;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.val;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -33,7 +32,6 @@ import share.system.domain.vo.MqttxVo;
import share.system.service.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
......@@ -116,6 +114,12 @@ public class RedisTask {
@Autowired
private EquityFundExcessService equityFundExcessService;
@Autowired
private ConsumerMonthlyCardService consumerMonthlyCardService;
@Autowired
private ConsumerSecondaryCardService consumerSecondaryCardService;
//15分钟的常量
final long FIFTEEN_MINUTES = 60 * 15;
......@@ -780,4 +784,42 @@ public class RedisTask {
});
logger.debug("AutoUpdateOpenid:自动更新用户unionid结束");
}
@XxlJob("AutomaticallyMonthlyCard")
public void AutomaticallyMonthlyCard() {
logger.debug("AutomaticallyMonthlyCard:自动结束月卡开始");
Set<String> keys = redisTemplate.keys(ReceiptRdeisEnum.MONTHLY_CARD.getValue() + "*");
if (keys.size() == 0) return;
keys.stream().forEach(key -> {
String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value);
Date expirationTime = jsonObject.getDate("expirationTime");
Long consumerMonthlyCardId = jsonObject.getLong("consumerMonthlyCardId");
if (expirationTime.getTime() < new Date().getTime()) {
consumerMonthlyCardService.removeById(consumerMonthlyCardId);
redisUtil.delete(key);
}
});
logger.debug("AutomaticallyMonthlyCard:自动结束月卡结束");
}
@XxlJob("AutomaticallySecondaryCard")
public void AutomaticallySecondaryCard() {
logger.debug("AutomaticallySecondaryCard:自动结束次卡开始");
Set<String> keys = redisTemplate.keys(ReceiptRdeisEnum.SECONDARY_CARD.getValue() + "*");
if (keys.size() == 0) return;
keys.stream().forEach(key -> {
String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value);
Date expirationTime = jsonObject.getDate("expirationTime");
Long consumerSecondaryCardId = jsonObject.getLong("consumerSecondaryCardId");
if (expirationTime.getTime() < new Date().getTime()) {
consumerSecondaryCardService.removeById(consumerSecondaryCardId);
redisUtil.delete(key);
}
});
logger.debug("AutomaticallySecondaryCard:自动结束次卡结束");
}
}
......@@ -3,6 +3,7 @@ package share.system.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -10,6 +11,7 @@ import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
import java.math.BigDecimal;
import java.util.Date;
/**
* 月卡使用记录对象 s_monthly_card_log
......@@ -58,6 +60,20 @@ public class MonthlyCardLog extends BaseEntity {
private BigDecimal residueDuration;
/**
* 操作类型
*/
@Excel(name = "操作类型")
private Integer operationType;
/**
* 操作时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date operationTime;
/**
* 删除标记:1-删除,0-正常
*/
//逻辑删除注解(0 未删除 1 已删除)
......
......@@ -3,12 +3,15 @@ package share.system.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
import java.util.Date;
/**
* 次卡使用记录对象 s_secondary_card_log
*
......@@ -62,6 +65,20 @@ public class SecondaryCardLog extends BaseEntity {
private Long residueCount;
/**
* 操作类型
*/
@Excel(name = "操作类型")
private Integer operationType;
/**
* 操作时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date operationTime;
/**
* 删除标记:1-删除,0-正常
*/
//逻辑删除注解(0 未删除 1 已删除)
......
......@@ -15,6 +15,8 @@
<result property="phone" column="phone"/>
<result property="useDuration" column="use_duration"/>
<result property="residueDuration" column="residue_duration"/>
<result property="operationType" column="operation_type"/>
<result property="operationTime" column="operation_time"/>
<result property="isDelete" column="is_delete"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
......@@ -30,6 +32,8 @@
phone,
use_duration,
residue_duration,
operation_type,
operation_time,
is_delete,
create_by,
create_time,
......@@ -50,6 +54,8 @@
l.phone,
l.use_duration,
l.residue_duration,
l.operation_type,
l.operation_time,
l.is_delete,
l.create_by,
l.create_time,
......@@ -65,6 +71,7 @@
<if test="phone != null and phone != ''">and l.phone = #{phone}</if>
<if test="useDuration != null ">and l.use_duration = #{useDuration}</if>
<if test="residueDuration != null ">and l.residue_duration = #{residueDuration}</if>
order by l.create_time
</select>
<select id="selectMonthlyCardLogById" parameterType="Long" resultMap="MonthlyCardLogResult">
......@@ -86,6 +93,8 @@
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="operationType != null">operation_type,</if>
<if test="operationTime != null">operation_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="consumerMonthlyCardId != null">#{consumerMonthlyCardId},</if>
......@@ -99,6 +108,8 @@
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="operationType != null">#{operationType},</if>
<if test="operationTime != null">#{operationTime},</if>
</trim>
</insert>
......@@ -116,6 +127,8 @@
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="operationType != null">operation_type = #{operationType},</if>
<if test="operationTime != null">operation_time = #{operationTime},</if>
</trim>
where id = #{id}
</update>
......
......@@ -18,6 +18,8 @@
<result property="packPrice" column="pack_price"/>
<result property="usageCount" column="usage_count"/>
<result property="residueCount" column="residue_count"/>
<result property="operationType" column="operation_type"/>
<result property="operationTime" column="operation_time"/>
<result property="isDelete" column="is_delete"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
......@@ -34,6 +36,8 @@
pack_id,
usage_count,
residue_count,
operation_type,
operation_time,
is_delete,
create_by,
create_time,
......@@ -57,6 +61,8 @@
p.price as 'pack_price',
l.usage_count,
l.residue_count,
l.operation_type,
l.operation_time,
l.is_delete,
l.create_by,
l.create_time,
......@@ -74,6 +80,7 @@
<if test="packId != null ">and l.pack_id = #{packId}</if>
<if test="usageCount != null ">and l.usage_count = #{usageCount}</if>
<if test="residueCount != null ">and l.residue_count = #{residueCount}</if>
order by l.create_time
</select>
<select id="selectSecondaryCardLogById" parameterType="Long" resultMap="SecondaryCardLogResult">
......@@ -96,6 +103,8 @@
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="operationType != null">operation_type,</if>
<if test="operationTime != null">operation_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="consumerSecondaryCardId != null">#{consumerSecondaryCardId},</if>
......@@ -110,6 +119,8 @@
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="operationType != null">#{operationType},</if>
<if test="operationTime != null">#{operationTime},</if>
</trim>
</insert>
......@@ -128,6 +139,8 @@
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="operationType != null">operation_type = #{operationType},</if>
<if test="operationTime != null">operation_time = #{operationTime},</if>
</trim>
where id = #{id}
</update>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment