Browse Source

积分兑换记录顺序、积分事件增加积分单位判断

dev_shibei_match
wangchao 5 years ago
parent
commit
ade7ae96b2
  1. 3
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/UserPointActionLogDao.java
  2. 5
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointVerificationLogServiceImpl.java
  3. 20
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointActionLogServiceImpl.java
  4. 20
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/utils/ModuleConstant.java
  5. 3
      epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/UserPointActionLogDao.xml

3
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/UserPointActionLogDao.java

@ -23,6 +23,7 @@ import com.epmet.entity.UserPointActionLogEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -50,5 +51,5 @@ public interface UserPointActionLogDao extends BaseDao<UserPointActionLogEntity>
* @author wangc * @author wangc
* @date 2020.07.31 15:11 * @date 2020.07.31 15:11
**/ **/
Integer selectSumByEvent(@Param("userId") String userId,@Param("eventId") String eventId, @Param("sourceId") String sourceId,@Param("customerId") String customerId); Integer selectSumByEvent(@Param("userId") String userId, @Param("eventId") String eventId, @Param("sourceId") String sourceId, @Param("customerId") String customerId, @Param("dateCheck") Date dateCheck);
} }

5
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointVerificationLogServiceImpl.java

@ -156,7 +156,7 @@ public class PointVerificationLogServiceImpl extends BaseServiceImpl<PointVerifi
Map<String, List<ResiPointLogPeriodResultDTO>> sortedMap = Maps.newLinkedHashMap(); Map<String, List<ResiPointLogPeriodResultDTO>> sortedMap = Maps.newLinkedHashMap();
map.entrySet().stream().sorted(Map.Entry.<String, List<ResiPointLogPeriodResultDTO>>comparingByKey().reversed()) map.entrySet().stream().sorted(Map.Entry.<String, List<ResiPointLogPeriodResultDTO>>comparingByKey().reversed())
.forEachOrdered(e -> sortedMap.put(e.getKey(), e.getValue())); .forEachOrdered(e -> sortedMap.put(e.getKey(), e.getValue()));
map.entrySet().forEach(e -> { sortedMap.entrySet().forEach(e -> {
ResiPointLogListResultDTO o = new ResiPointLogListResultDTO(); ResiPointLogListResultDTO o = new ResiPointLogListResultDTO();
o.setDate(e.getKey()); o.setDate(e.getKey());
o.setDailyList(e.getValue()); o.setDailyList(e.getValue());
@ -243,9 +243,10 @@ public class PointVerificationLogServiceImpl extends BaseServiceImpl<PointVerifi
if(StringUtils.isNotBlank(decodedUserId)){ if(StringUtils.isNotBlank(decodedUserId)){
verificationParam.setUserId(decodedUserId); verificationParam.setUserId(decodedUserId);
}else{ }else{
logger.error(String.format("用户二维码失效,参数详情 -> 【】", JSON.toJSON(verificationParam))); logger.error(String.format("用户二维码失效,参数详情 -> 【%s】", JSON.toJSON(verificationParam)));
result.setSuccessFlag(false); result.setSuccessFlag(false);
result.setFailureReason(ModuleConstant.INVALID_USER_QRCDDE); result.setFailureReason(ModuleConstant.INVALID_USER_QRCDDE);
return result;
} }
DimIdGenerator.DimIdBean dim = DimIdGenerator.getDimIdBean(new Date()); DimIdGenerator.DimIdBean dim = DimIdGenerator.getDimIdBean(new Date());

20
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointActionLogServiceImpl.java

@ -196,11 +196,27 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi
PointRuleEntity ruleInfo = pointRuleService.getByEventCodeAndCustomerId(event.getCustomerId(),eventCode); PointRuleEntity ruleInfo = pointRuleService.getByEventCodeAndCustomerId(event.getCustomerId(),eventCode);
if(null != ruleInfo && StringUtils.equals(NumConstant.ONE_STR,ruleInfo.getEnabledFlag())){ if(null != ruleInfo && StringUtils.equals(NumConstant.ONE_STR,ruleInfo.getEnabledFlag())){
Date dateCheck = null;
//判断积分规则的积分单位 次、天、分钟、小时 //判断积分规则的积分单位 次、天、分钟、小时
if(StringUtils.equals(ModuleConstant.POINT_UNIT_TIME,ruleInfo.getPointUnit())){
//次
}else if(StringUtils.equals(ModuleConstant.POINT_UNIT_DAY,ruleInfo.getPointUnit())){
//天
//在selectSumByEvent时要校验时间区间
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO);
calendar.set(Calendar.MINUTE, NumConstant.ZERO);
calendar.set(Calendar.SECOND, NumConstant.ZERO);
dateCheck = calendar.getTime();
}else{
//其余积分单位
//TODO..
logger.warn(String.format("当前规则属于按%s计分,系统尚不支持响应此类积分规则的事件"),ruleInfo.getPointUnit());
}
//校验是否达到上限 //校验是否达到上限
if(ruleInfo.getUpLimit() > NumConstant.ZERO){ if(ruleInfo.getUpLimit() > NumConstant.ZERO){
Integer sum = baseDao.selectSumByEvent(event.getUserId(),eventCode,event.getSourceId(),event.getCustomerId()); Integer sum = baseDao.selectSumByEvent(event.getUserId(),eventCode,event.getSourceId(),event.getCustomerId(),dateCheck);
if(null == sum) sum = NumConstant.ZERO; if(null == sum) sum = NumConstant.ZERO;
if(StringUtils.equals(ModuleConstant.OPERATION_TYPE_PLUS,ruleInfo.getOperateType())){ if(StringUtils.equals(ModuleConstant.OPERATION_TYPE_PLUS,ruleInfo.getOperateType())){
sum += ruleInfo.getPoint(); sum += ruleInfo.getPoint();

20
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/utils/ModuleConstant.java

@ -94,4 +94,24 @@ public interface ModuleConstant extends Constant {
String CREATED_BY_SYSTEM = "SYSTEM"; String CREATED_BY_SYSTEM = "SYSTEM";
String INVALID_USER_QRCDDE = "用户二维码失效"; String INVALID_USER_QRCDDE = "用户二维码失效";
/**
* 积分单位
* */
String POINT_UNIT_TIME = "time";
/**
* 积分单位
* */
String POINT_UNIT_DAY = "day";
/**
* 积分单位分钟
* */
String POINT_UNIT_MINUTE = "minute";
/**
* 积分单位小时
* */
String POINT_UNIT_HOUR = "hour";
} }

3
epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/UserPointActionLogDao.xml

@ -56,6 +56,9 @@
<if test='null != sourceId and "" != sourceId'> <if test='null != sourceId and "" != sourceId'>
AND SOURCE_ID = #{sourceId} AND SOURCE_ID = #{sourceId}
</if> </if>
<if test="null != dateCheck">
AND CREATED_TIME <![CDATA[ >= ]]> #{dateCheck}
</if>
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save