|
@@ -10,7 +10,9 @@ import com.fdkankan.agent.entity.UserIncrement;
|
|
|
import com.fdkankan.agent.exception.BusinessException;
|
|
|
import com.fdkankan.agent.mapper.IUserIncrementMapper;
|
|
|
import com.fdkankan.agent.request.IncrementParam;
|
|
|
+import com.fdkankan.agent.response.AgentNewVo;
|
|
|
import com.fdkankan.agent.response.UserIncrementVo;
|
|
|
+import com.fdkankan.agent.service.IAgentNewService;
|
|
|
import com.fdkankan.agent.service.IIncrementTypeService;
|
|
|
import com.fdkankan.agent.service.IUserIncrementService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -40,6 +42,8 @@ public class UserIncrementServiceImpl extends ServiceImpl<IUserIncrementMapper,
|
|
|
IUserService userService;
|
|
|
@Autowired
|
|
|
IIncrementTypeService incrementTypeService;
|
|
|
+ @Autowired
|
|
|
+ IAgentNewService agentNewService;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -68,11 +72,25 @@ public class UserIncrementServiceImpl extends ServiceImpl<IUserIncrementMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void addIncrement(IncrementParam param) {
|
|
|
+ public void addIncrement(IncrementParam param, AgentNewVo agentNewVo) {
|
|
|
if(StringUtils.isBlank(param.getUserName()) || param.getIncrementTypeId() == null
|
|
|
|| param.getCount() == null || StringUtils.isEmpty(param.getIncrementEndTime())){
|
|
|
throw new BusinessException(ResultCode.PARAM_MISS);
|
|
|
}
|
|
|
+ IncrementType incrementType = incrementTypeService.getById(param.getIncrementTypeId());
|
|
|
+ if(incrementType == null){
|
|
|
+ throw new BusinessException(ResultCode.INCREMENT_TYPE_EMPTY);
|
|
|
+ }
|
|
|
+ if (incrementType.getValidTimeType() == 0) {
|
|
|
+ if(agentNewVo.getMajorSubNum() <=0){
|
|
|
+ throw new BusinessException(ResultCode.INCREMENT_NUM_EMPTY);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (incrementType.getValidTimeType() == 1) {
|
|
|
+ if(agentNewVo.getHighSubNum() <=0){
|
|
|
+ throw new BusinessException(ResultCode.INCREMENT_NUM_EMPTY);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
User user = userService.getByUserName(param.getUserName());
|
|
|
if(user == null){
|
|
@@ -96,12 +114,47 @@ public class UserIncrementServiceImpl extends ServiceImpl<IUserIncrementMapper,
|
|
|
|
|
|
if(userIncrementList.size() >0){
|
|
|
this.saveBatch(userIncrementList);
|
|
|
- IncrementType incrementType = incrementTypeService.getById(param.getIncrementTypeId());
|
|
|
- if(incrementType == null){
|
|
|
- throw new BusinessException(ResultCode.INCREMENT_TYPE_EMPTY);
|
|
|
- }
|
|
|
user.setDownloadNumTotal(user.getDownloadNumTotal() + param.getCount() * incrementType.getDownloadNum());
|
|
|
userService.updateById(user);
|
|
|
+ agentNewService.subNum(agentNewVo,user.getId(),incrementType,param.getCount(),0);
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void renew(IncrementParam param, AgentNewVo agentNewVo) {
|
|
|
+ if(param.getId() == null || StringUtils.isEmpty(param.getIncrementEndTime())){
|
|
|
+ throw new BusinessException(ResultCode.PARAM_MISS);
|
|
|
+ }
|
|
|
+ UserIncrement userIncrement = this.getById(param.getId());
|
|
|
+ if(userIncrement == null){
|
|
|
+ throw new BusinessException(ResultCode.INCREMENT_EMPTY);
|
|
|
+ }
|
|
|
+ IncrementType incrementType = incrementTypeService.getById(userIncrement.getIncrementTypeId());
|
|
|
+ if(incrementType == null){
|
|
|
+ throw new BusinessException(ResultCode.INCREMENT_TYPE_EMPTY);
|
|
|
+ }
|
|
|
+ if (incrementType.getValidTimeType() == 0) {
|
|
|
+ if(agentNewVo.getMajorSubNum() <=0){
|
|
|
+ throw new BusinessException(ResultCode.INCREMENT_NUM_EMPTY);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (incrementType.getValidTimeType() == 1) {
|
|
|
+ if(agentNewVo.getHighSubNum() <=0){
|
|
|
+ throw new BusinessException(ResultCode.INCREMENT_NUM_EMPTY);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userIncrement.setIsExpired(0);
|
|
|
+ userIncrement.setIncrementEndTime(param.getIncrementEndTime());
|
|
|
+ userIncrement.setUpdateTime(null);
|
|
|
+ this.updateById(userIncrement);
|
|
|
+
|
|
|
+ User user = userService.getById(userIncrement.getUserId());
|
|
|
+
|
|
|
+ user.setDownloadNumTotal(user.getDownloadNumTotal() + param.getCount() * incrementType.getDownloadNum());
|
|
|
+ userService.updateById(user);
|
|
|
+ agentNewService.subNum(agentNewVo,user.getId(),incrementType,1,1);
|
|
|
+
|
|
|
}
|
|
|
}
|