Browse Source

Merge remote-tracking branch 'origin/dev_point_task' into develop

# Conflicts:
#	epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java
#	epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointActionLogService.java
#	epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointActionLogServiceImpl.java
#	epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/UserPointActionLogDao.xml
dev
yinzuomei 4 years ago
parent
commit
81d1c0a675
  1. 5
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java
  2. 5
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  3. 2
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java
  4. 9
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointRuleDao.java
  5. 1
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointActionLogService.java
  6. 52
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java
  7. 1
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointActionLogServiceImpl.java
  8. 15
      epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointRuleDao.xml
  9. 108
      epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/UserPointActionLogDao.xml

5
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java

@ -86,4 +86,9 @@ public interface StrConstant {
String SPECIAL_CUSTOMER = "150282ed25c14ff0785e7e06283b6283";
//平音客户
String PY_CUSTOMER = "6f203e30de1a65aab7e69c058826cd80";
/**
* 单位积分,积分上限积分说明积分事件
*/
String POINT_CHANGE = "修改了%s规则,将%s调整为%s";
}

5
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -184,7 +184,10 @@ public enum EpmetErrorCode {
SIGN_IN_TIME_PASSED(8912,"当前时间已超过签到时间"),
INVITATION_NOT_EXIST(8913,"链接不存在"),
NOTICE_EXPIRATION_TIME(8914,"通知过期时间不能早于当前时间"),
NOTICE_BE_OVERDUE(8915,"通知已过期不允许再次变更");
NOTICE_BE_OVERDUE(8915,"通知已过期不允许再次变更"),
SAME_RULE_NAME(8916,"该积分事件已存在,请重新调整保存"),
UP_LIMIT_POINT(8917,"积分上限需为单位积分倍数,请重新调整保存");
private int code;

2
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java

@ -163,7 +163,7 @@ public class ResiPointController {
* @param formDTO
* @author yinzuomei
* @description 积分任务列表
* @Date 2021/6/18 14:19
* @Date 2021/6/18 14:19
**/
@PostMapping("mytasklist")
public Result<List<MyPointTaskResultDTO>> queryMyPointTaskList(@LoginUser TokenDto tokenDto,@RequestBody MyPointTaskFormDTO formDTO){

9
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointRuleDao.java

@ -56,4 +56,13 @@ public interface PointRuleDao extends BaseDao<PointRuleEntity> {
List<String> selectCustomerIds();
/**
* @Description 校验重名的规则
* @Param ruleName
* @Param customerId
* @author zxc
* @date 2021/6/18 1:39 下午
*/
Integer checkSameName(@Param("ruleName")String ruleName,@Param("customerId") String customerId,@Param("ruleId")String ruleId);
}

1
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointActionLogService.java

@ -135,6 +135,7 @@ public interface UserPointActionLogService extends BaseService<UserPointActionLo
* @return java.lang.Integer
*/
Integer getIncrease(String type, String objectId);
/**
* 积分任务列表
*

52
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java

@ -27,6 +27,7 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.enums.CommonOperateTypeEnum;
import com.epmet.commons.tools.enums.EventEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
@ -146,15 +147,31 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul
return resultDTO;
}
/**
* @Description 积分规则修改
* @Param tokenDTO
* @Param formDTO
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TokenDto tokenDTO, PointRuleFormDTO formDTO) {
// 积分规则开启状态参数校验
validateEnableFlag(formDTO);
PointRuleEntity entityDB = baseDao.selectById(formDTO.getRuleId());
//数据库不存在或者客户Id不相等 则抛出异常
if (entityDB == null || !entityDB.getCustomerId().equals(formDTO.getCustomerId())) {
throw new RenException(SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getCode(), SysResponseEnum.POINT_RULE_IS_NOT_EXIST.getMsg());
}
// 校验规则是否有重复名字
Integer sameCount = baseDao.checkSameName(formDTO.getRuleName(), formDTO.getCustomerId(), formDTO.getRuleId());
if (sameCount > NumConstant.ZERO){
throw new RenException(EpmetErrorCode.SAME_RULE_NAME.getCode());
}
// 检验积分上限是不是单位积分的整数倍
Integer remainder = formDTO.getUpLimit() % formDTO.getPoint();
if (remainder > NumConstant.ZERO){
throw new RenException(EpmetErrorCode.UP_LIMIT_POINT.getCode());
}
PointRuleEntity entityNew = ConvertUtils.sourceToTarget(formDTO, PointRuleEntity.class);
entityNew.setId(formDTO.getRuleId());
entityNew.setEnabledFlag(StrConstant.TRUE.equals(formDTO.getEnabledFlag()) ? "1" : "0");
@ -164,6 +181,41 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul
}
baseDao.updateByCustomerId(entityNew);
insertOperateRecord(tokenDTO, entityNew, entityDB, CommonOperateTypeEnum.EDIT.getCode());
// 系统日志记录
List<String> messages = disposeLog(formDTO, entityDB);
// TODO add
}
/**
* @Description 变更处理
* @Param f
* @Param e
* @author zxc
* @date 2021/6/18 3:14 下午
*/
private List<String> disposeLog(PointRuleFormDTO f,PointRuleEntity e){
List<String> result = new ArrayList<>();
// 单位积分
if (!e.getPoint().equals(f.getPoint())){
String s = String.format(StrConstant.POINT_CHANGE, e.getRuleName(), e.getPoint(), f.getPoint());
result.add(s);
}
// 积分上限
if (!e.getUpLimit().equals(f.getUpLimit())){
String s = String.format(StrConstant.POINT_CHANGE, e.getRuleName(), e.getUpLimit(), f.getUpLimit());
result.add(s);
}
// 积分事件
if (!e.getRuleName().equals(f.getRuleName())){
String s = String.format(StrConstant.POINT_CHANGE, e.getRuleName(), e.getRuleName(), f.getRuleName());
result.add(s);
}
// 积分说明
if (!e.getRuleDesc().equals(f.getRuleDesc())){
String s = String.format(StrConstant.POINT_CHANGE, e.getRuleName(), e.getRuleDesc(), f.getRuleDesc());
result.add(s);
}
return result;
}
private void validateEnableFlag(PointRuleFormDTO formDTO) {

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

@ -517,7 +517,6 @@ public class UserPointActionLogServiceImpl extends BaseServiceImpl<UserPointActi
return plusTotal - minusTotal;
}
/**
* 积分任务列表
*

15
epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointRuleDao.xml

@ -40,7 +40,9 @@
SET
POINT = #{point,jdbcType=INTEGER},
ENABLED_FLAG = #{enabledFlag,jdbcType=VARCHAR},
UP_LIMIT = #{upLimit,jdbcType=INTEGER}
UP_LIMIT = #{upLimit,jdbcType=INTEGER},
RULE_NAME = #{ruleName},
RULE_DESC = #{ruleDesc}
WHERE id = #{id,jdbcType=VARCHAR} and CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
</update>
@ -55,4 +57,15 @@
<select id="selectCustomerIds" resultType="java.lang.String">
SELECT DISTINCT CUSTOMER_ID FROM point_rule WHERE DEL_FLAG = '0'
</select>
<!-- 校验重名的规则 -->
<select id="checkSameName" resultType="java.lang.Integer">
SELECT
COUNT( ID )
FROM point_rule
WHERE DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND RULE_NAME = #{ruleName}
AND ID != #{ruleId}
</select>
</mapper>

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

@ -75,60 +75,60 @@
</select>
<select id="queryMyPointTaskList" parameterType="map" resultType="com.epmet.dto.result.MyPointTaskResultDTO">
select
select
temp.*
from (
SELECT
pr.RULE_NAME AS ruleName,
pr.RULE_DESC AS ruleDesc,
(
CASE
WHEN pr.OPERATE_TYPE = 'plus' THEN
CONCAT( '积分+', pr.POINT )
WHEN pr.OPERATE_TYPE = 'minus' THEN
CONCAT( '积分-', pr.POINT )
else '未知'
END
) AS pointDesc,
'' AS finishTotalDesc,
'' AS finishFlag,
pr.LINK_PAGE AS linkPage,
pr.EVENT_CODE AS eventCode,
pr.OPERATE_TYPE AS operateType,
pr.UP_LIMIT AS upLimit,
pr.POINT AS point,
(
SELECT
count( 1 )
FROM
user_point_action_log u
WHERE
u.USER_ID = #{userId}
AND u.EVENT_ID = pr.EVENT_CODE
AND u.DEL_FLAG = '0'
AND u.CUSTOMER_ID = #{customerId}
AND DATE_FORMAT( u.CREATED_TIME, '%Y%m%d' ) =#{dateId}
) AS finishedCount,
(case when pr.UP_LIMIT='0' then '-1'
else CEIL(pr.UP_LIMIT/pr.point)
end
)as upLimitCount,
pr.sort
FROM
point_rule pr
WHERE
pr.DEL_FLAG = '0'
AND pr.CUSTOMER_ID = #{customerId}
AND pr.ENABLED_FLAG = '1'
)temp
where 1=1
<if test='null != type and "unfinished" == type'>
and temp.finishedCount=0
</if>
<if test='null != type and "finished" == type'>
and temp.upLimit !=0
and temp.finishedCount=temp.upLimitCount
</if>
ORDER BY temp.sort ASC
from (
SELECT
pr.RULE_NAME AS ruleName,
pr.RULE_DESC AS ruleDesc,
(
CASE
WHEN pr.OPERATE_TYPE = 'plus' THEN
CONCAT( '积分+', pr.POINT )
WHEN pr.OPERATE_TYPE = 'minus' THEN
CONCAT( '积分-', pr.POINT )
else '未知'
END
) AS pointDesc,
'' AS finishTotalDesc,
'' AS finishFlag,
pr.LINK_PAGE AS linkPage,
pr.EVENT_CODE AS eventCode,
pr.OPERATE_TYPE AS operateType,
pr.UP_LIMIT AS upLimit,
pr.POINT AS point,
(
SELECT
count( 1 )
FROM
user_point_action_log u
WHERE
u.USER_ID = #{userId}
AND u.EVENT_ID = pr.EVENT_CODE
AND u.DEL_FLAG = '0'
AND u.CUSTOMER_ID = #{customerId}
AND DATE_FORMAT( u.CREATED_TIME, '%Y%m%d' ) =#{dateId}
) AS finishedCount,
(case when pr.UP_LIMIT='0' then '-1'
else CEIL(pr.UP_LIMIT/pr.point)
end
)as upLimitCount,
pr.sort
FROM
point_rule pr
WHERE
pr.DEL_FLAG = '0'
AND pr.CUSTOMER_ID = #{customerId}
AND pr.ENABLED_FLAG = '1'
)temp
where 1=1
<if test='null != type and "unfinished" == type'>
and temp.finishedCount=0
</if>
<if test='null != type and "finished" == type'>
and temp.upLimit !=0
and temp.finishedCount=temp.upLimitCount
</if>
ORDER BY temp.sort ASC
</select>
</mapper>
Loading…
Cancel
Save