|
@ -21,15 +21,19 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.epmet.common.enu.PointUnitEnum; |
|
|
import com.epmet.common.enu.PointUnitEnum; |
|
|
import com.epmet.common.enu.SysResponseEnum; |
|
|
import com.epmet.common.enu.SysResponseEnum; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
|
|
import com.epmet.commons.rocketmq.messages.PointRuleChangedMQMsg; |
|
|
import com.epmet.commons.tools.constant.Constant; |
|
|
import com.epmet.commons.tools.constant.Constant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.enums.CommonOperateTypeEnum; |
|
|
import com.epmet.commons.tools.enums.CommonOperateTypeEnum; |
|
|
import com.epmet.commons.tools.enums.EventEnum; |
|
|
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.ExceptionUtils; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.IpUtils; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.SpringContextUtils; |
|
|
import com.epmet.commons.tools.utils.SpringContextUtils; |
|
|
import com.epmet.dao.PointRuleDao; |
|
|
import com.epmet.dao.PointRuleDao; |
|
@ -38,17 +42,16 @@ import com.epmet.dao.RuleOperateLogDao; |
|
|
import com.epmet.dto.CustomerDTO; |
|
|
import com.epmet.dto.CustomerDTO; |
|
|
import com.epmet.dto.CustomerStaffDTO; |
|
|
import com.epmet.dto.CustomerStaffDTO; |
|
|
import com.epmet.dto.InitPointRuleResultDTO; |
|
|
import com.epmet.dto.InitPointRuleResultDTO; |
|
|
import com.epmet.dto.form.CustomerFunctionListFormDTO; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.form.PointDetailFormDTO; |
|
|
|
|
|
import com.epmet.dto.form.PointRuleFormDTO; |
|
|
|
|
|
import com.epmet.dto.form.PointRuleListFormDTO; |
|
|
|
|
|
import com.epmet.dto.result.*; |
|
|
import com.epmet.dto.result.*; |
|
|
import com.epmet.entity.PointRuleDefaultEntity; |
|
|
import com.epmet.entity.PointRuleDefaultEntity; |
|
|
import com.epmet.entity.PointRuleEntity; |
|
|
import com.epmet.entity.PointRuleEntity; |
|
|
import com.epmet.entity.RuleOperateLogEntity; |
|
|
import com.epmet.entity.RuleOperateLogEntity; |
|
|
|
|
|
import com.epmet.feign.EpmetMessageOpenFeignClient; |
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
import com.epmet.feign.OperCrmOpenFeignClient; |
|
|
import com.epmet.feign.OperCrmOpenFeignClient; |
|
|
import com.epmet.feign.OperCustomizeOpenFeignClient; |
|
|
import com.epmet.feign.OperCustomizeOpenFeignClient; |
|
|
|
|
|
import com.epmet.send.SendMqMsgUtil; |
|
|
import com.epmet.service.PointRuleService; |
|
|
import com.epmet.service.PointRuleService; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
@ -56,7 +59,10 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
import org.springframework.web.context.request.RequestContextHolder; |
|
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.concurrent.ExecutorService; |
|
|
import java.util.concurrent.ExecutorService; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
@ -81,6 +87,10 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul |
|
|
private OperCrmOpenFeignClient operCrmOpenFeignClient; |
|
|
private OperCrmOpenFeignClient operCrmOpenFeignClient; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private PointRuleDefaultDao pointRuleDefaultDao; |
|
|
private PointRuleDefaultDao pointRuleDefaultDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private LoginUserUtil loginUserUtil; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<CustomerFunctionResultDTO> getFunctionList(String customerId) { |
|
|
public List<CustomerFunctionResultDTO> getFunctionList(String customerId) { |
|
@ -145,15 +155,31 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul |
|
|
return resultDTO; |
|
|
return resultDTO; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 积分规则修改 |
|
|
|
|
|
* @Param tokenDTO |
|
|
|
|
|
* @Param formDTO |
|
|
|
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void update(TokenDto tokenDTO, PointRuleFormDTO formDTO) { |
|
|
public void update(TokenDto tokenDTO, PointRuleFormDTO formDTO) { |
|
|
|
|
|
// 积分规则开启状态参数校验
|
|
|
validateEnableFlag(formDTO); |
|
|
validateEnableFlag(formDTO); |
|
|
PointRuleEntity entityDB = baseDao.selectById(formDTO.getRuleId()); |
|
|
PointRuleEntity entityDB = baseDao.selectById(formDTO.getRuleId()); |
|
|
//数据库不存在或者客户Id不相等 则抛出异常
|
|
|
//数据库不存在或者客户Id不相等 则抛出异常
|
|
|
if (entityDB == null || !entityDB.getCustomerId().equals(formDTO.getCustomerId())) { |
|
|
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()); |
|
|
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); |
|
|
PointRuleEntity entityNew = ConvertUtils.sourceToTarget(formDTO, PointRuleEntity.class); |
|
|
entityNew.setId(formDTO.getRuleId()); |
|
|
entityNew.setId(formDTO.getRuleId()); |
|
|
entityNew.setEnabledFlag(StrConstant.TRUE.equals(formDTO.getEnabledFlag()) ? "1" : "0"); |
|
|
entityNew.setEnabledFlag(StrConstant.TRUE.equals(formDTO.getEnabledFlag()) ? "1" : "0"); |
|
@ -163,6 +189,70 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul |
|
|
} |
|
|
} |
|
|
baseDao.updateByCustomerId(entityNew); |
|
|
baseDao.updateByCustomerId(entityNew); |
|
|
insertOperateRecord(tokenDTO, entityNew, entityDB, CommonOperateTypeEnum.EDIT.getCode()); |
|
|
insertOperateRecord(tokenDTO, entityNew, entityDB, CommonOperateTypeEnum.EDIT.getCode()); |
|
|
|
|
|
// 系统日志记录
|
|
|
|
|
|
String messages = disposeLog(formDTO, entityDB); |
|
|
|
|
|
log.info("要保存的日志========="+messages); |
|
|
|
|
|
if (StringUtils.isNotBlank(messages)){ |
|
|
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
|
|
|
|
|
PointRuleChangedMQMsg msg = new PointRuleChangedMQMsg(); |
|
|
|
|
|
msg.setFromApp(loginUserUtil.getLoginUserApp()); |
|
|
|
|
|
msg.setFromClient(loginUserUtil.getLoginUserClient()); |
|
|
|
|
|
msg.setIp(IpUtils.getIpAddr(request)); |
|
|
|
|
|
msg.setOperatingTime(new Date()); |
|
|
|
|
|
msg.setOperationBrief(messages); |
|
|
|
|
|
msg.setOperatorId(loginUserUtil.getLoginUserId()); |
|
|
|
|
|
msg.setRuleId(formDTO.getRuleId()); |
|
|
|
|
|
SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendPointRuleChangedMqMsg(msg); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 变更处理 |
|
|
|
|
|
* @Param f |
|
|
|
|
|
* @Param e |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
* @date 2021/6/18 3:14 下午 |
|
|
|
|
|
*/ |
|
|
|
|
|
private String disposeLog(PointRuleFormDTO f,PointRuleEntity e){ |
|
|
|
|
|
StringBuffer sb = new StringBuffer(); |
|
|
|
|
|
sb.append(String.format(StrConstant.POINT_CHANGE_HEAD,e.getRuleName())); |
|
|
|
|
|
Boolean appendStatus = false; |
|
|
|
|
|
// 单位积分
|
|
|
|
|
|
if (!e.getPoint().equals(f.getPoint())){ |
|
|
|
|
|
String s = String.format(StrConstant.POINT_CHANGE, "单位积分", f.getPoint()); |
|
|
|
|
|
sb.append(s).append(","); |
|
|
|
|
|
appendStatus = true; |
|
|
|
|
|
} |
|
|
|
|
|
// 积分上限
|
|
|
|
|
|
if (!e.getUpLimit().equals(f.getUpLimit())){ |
|
|
|
|
|
String s = String.format(StrConstant.POINT_CHANGE, "积分上限", f.getUpLimit()); |
|
|
|
|
|
sb.append(s).append(","); |
|
|
|
|
|
appendStatus = true; |
|
|
|
|
|
} |
|
|
|
|
|
// 积分说明
|
|
|
|
|
|
if (!e.getRuleDesc().equals(f.getRuleDesc())){ |
|
|
|
|
|
String s = String.format(StrConstant.POINT_CHANGE, "积分说明", f.getRuleDesc()); |
|
|
|
|
|
sb.append(s).append(","); |
|
|
|
|
|
appendStatus = true; |
|
|
|
|
|
} |
|
|
|
|
|
// 规则启用 是否启用 0-否,1-是
|
|
|
|
|
|
String webStatus = f.getEnabledFlag().equals("true") ? "启用" : "关闭"; |
|
|
|
|
|
String javaStatus = e.getEnabledFlag().equals(NumConstant.ONE_STR) ? "启用" : "关闭"; |
|
|
|
|
|
if(!webStatus.equals(javaStatus)){ |
|
|
|
|
|
String s = String.format(StrConstant.POINT_CHANGE, "规则启用", webStatus); |
|
|
|
|
|
sb.append(s).append(","); |
|
|
|
|
|
appendStatus = true; |
|
|
|
|
|
} |
|
|
|
|
|
// 积分事件
|
|
|
|
|
|
if (!e.getRuleName().equals(f.getRuleName())){ |
|
|
|
|
|
String s = String.format(StrConstant.POINT_CHANGE, "积分事件", f.getRuleName()); |
|
|
|
|
|
sb.append(s).append(","); |
|
|
|
|
|
appendStatus = true; |
|
|
|
|
|
} |
|
|
|
|
|
if (appendStatus.equals(false)){ |
|
|
|
|
|
return ""; |
|
|
|
|
|
} |
|
|
|
|
|
return sb.substring(NumConstant.ZERO,sb.length() - NumConstant.ONE); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void validateEnableFlag(PointRuleFormDTO formDTO) { |
|
|
private void validateEnableFlag(PointRuleFormDTO formDTO) { |
|
|