提交 c3953714 authored 作者: 吕本才's avatar 吕本才

1、增加模拟添加动态接口

2、增加全国经销商结果
上级 2694dbf4
......@@ -87,4 +87,6 @@ public class DealerBaseInfoController extends BaseController {
public AjaxResult remove(@PathVariable Long[] dealerBaseInfoIds) {
return toAjax(dealerBaseInfoService.removeByIds(Arrays.asList(dealerBaseInfoIds)));
}
}
package com.ruoyi.web.controller.dealer;
import cn.hutool.core.io.FileUtil;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dealer.domain.dto.*;
import com.ruoyi.dealer.service.DealerRoundInfoService;
import com.ruoyi.dealer.service.IDealerBaseInfoService;
import com.ruoyi.dealer.service.IDealerRoundResultService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
......@@ -93,6 +92,11 @@ public class DealerBigScreenController extends BaseController {
return success(res);
}
@GetMapping("/result/quanguoResult")
public AjaxResult quanguoResult() {
DealerBigScreenTotalResultRes res = resultService.totalResult();
return success(res);
}
@GetMapping("/download/zip")
......@@ -133,4 +137,10 @@ public class DealerBigScreenController extends BaseController {
}
@Log(title = "模拟添加数据", businessType = BusinessType.UPDATE)
@PostMapping("/mockAdd")
public AjaxResult mockAdd(String phone,Integer pamentTllNew) {
return toAjax(dealerRoundInfoService.mockAdd(phone,pamentTllNew));
}
}
......@@ -43,4 +43,7 @@ public class DealerRoundController extends BaseController {
return toAjax(resultService.initRoundInfo());
}
}
......@@ -66,4 +66,7 @@ public class DealerRoundInfo {
private LocalDateTime updateTime;
private Integer repetition;
private String paymentPercentage;
}
package com.ruoyi.dealer.domain.dto;
import com.ruoyi.common.annotation.Sensitive;
import com.ruoyi.common.enums.DesensitizedType;
import lombok.Data;
@Data
......@@ -17,7 +15,7 @@ public class DealerBigScreenDynamicRes {
* 经销商名称(非空)
* 脱敏经销商名称
*/
@Sensitive(desensitizedType = DesensitizedType.DEALER_NAME)
// @Sensitive(desensitizedType = DesensitizedType.DEALER_NAME)
private String dealerName;
/**
......@@ -36,7 +34,7 @@ public class DealerBigScreenDynamicRes {
*/
private String paymentPercentage;
@Sensitive(desensitizedType = DesensitizedType.PHONE)
// @Sensitive(desensitizedType = DesensitizedType.PHONE)
private String phone;
/**
* 预付款变化 up down
......
package com.ruoyi.dealer.domain.dto;
import com.ruoyi.common.annotation.Sensitive;
import com.ruoyi.common.enums.DesensitizedType;
import lombok.Data;
@Data
......@@ -9,10 +7,10 @@ public class DealerBigScreenGroupListRes {
private Integer roundTime;
private String groupName;
private String dealerCategory;
@Sensitive(desensitizedType = DesensitizedType.PHONE)
// @Sensitive(desensitizedType = DesensitizedType.PHONE)
private String phone;
@Sensitive(desensitizedType = DesensitizedType.DEALER_NAME)
// @Sensitive(desensitizedType = DesensitizedType.DEALER_NAME)
private String dealerName;
private Long dealerId;
/**
......
......@@ -21,4 +21,6 @@ public interface DealerRoundInfoService extends IService<DealerRoundInfo> {
List<DealerBigScreenDynamicRes> dynamicList(Integer roundId);
List<SysConfig> turnRoundInfo(TurnRoundInfoReq turnRoundInfoReq);
int mockAdd(String phone, Integer pamentTllNew);
}
......@@ -28,4 +28,4 @@ public interface IDealerRoundResultService extends IService<DealerRoundResult> {
void downloadExcel(HttpServletResponse response, String group);
List<DealerBigScreenRewardResultRes> getRewardList(String groupType, Integer ranking, String groupName);
}
}
......@@ -46,7 +46,7 @@ public class DealerRoundInfoServiceImpl extends ServiceImpl<DealerRoundInfoMappe
private IDealerBaseInfoService dealerBaseInfoService;
@Autowired
private IDealerResultService resultService;
private IDealerResultService regionResultService;
@Override
......@@ -55,7 +55,7 @@ public class DealerRoundInfoServiceImpl extends ServiceImpl<DealerRoundInfoMappe
String config = configService.selectConfigByKeyFromDb(Constants.DEALER_ROUND_OVER);
Boolean roundOver = Boolean.parseBoolean(config);
if (roundOver) {
throw new ServiceException("当前轮次活动已经结束");
throw new ServiceException("当前活动已经结束,不能认购");
}
Long userId = SecurityUtils.getUserId();
String dealerName = SecurityUtils.getLoginUser().getUsername();
......@@ -190,11 +190,109 @@ public class DealerRoundInfoServiceImpl extends ServiceImpl<DealerRoundInfoMappe
return item;
}).collect(Collectors.toList());
resultService.saveOrUpdateBatch(resultList);
regionResultService.saveOrUpdateBatch(resultList);
}
return list;
}
@Override
public int mockAdd(String phone, Integer pamentTllNew) {
// 获取当前的手机号的用户,通过查询用户结果信息,填写当前信息
DealerBaseInfo dealer = dealerBaseInfoService.getOne(new LambdaQueryWrapper<DealerBaseInfo>()
.like(DealerBaseInfo::getPhone, phone));
WechatDealerRoundInfoReq dealerRoundInfoReq = new WechatDealerRoundInfoReq();
dealerRoundInfoReq.setDealerId(dealer.getDealerId());
dealerRoundInfoReq.setDealerName(dealer.getDealerName());
dealerRoundInfoReq.setRoundTime(1);
// 增加后的预付款
dealerRoundInfoReq.setPaymentTtlNew(pamentTllNew);
// 结果
DealerRoundResult roundResult = roundResultService.getOne(new LambdaQueryWrapper<DealerRoundResult>()
.eq(DealerRoundResult::getDealerId, dealer.getDealerId())
.eq(DealerRoundResult::getRoundTime, 1));
if(ObjectUtil.isNotEmpty(roundResult)){
dealerRoundInfoReq.setPaymentTtl(roundResult.getPaymentTtl());
}else{
// 起始值为0
dealerRoundInfoReq.setPaymentTtl(0);
}
dealerRoundInfoReq.setDealerType(dealer.getDealerType());
dealerRoundInfoReq.setSalesRegion(dealer.getSalesRegion());
dealerRoundInfoReq.setSalesTheater(dealer.getSalesTheater());
dealerRoundInfoReq.setDealerCategory(dealer.getDealerCategory());
dealerRoundInfoReq.setGoalTtlAct(dealer.getGoalTtlAct());
dealerRoundInfoReq.setGroupName(dealer.getGroupName());
// 记录当前轮次的填写情况
DealerRoundInfo dealerRoundInfo = new DealerRoundInfo();
Long userId = dealer.getDealerId();
String dealerName = dealer.getDealerName();
dealerRoundInfo.setDealerId(userId);
dealerRoundInfo.setDealerName(dealerName);
dealerRoundInfo.setPhone(phone);
dealerRoundInfo.setRoundTime(dealerRoundInfoReq.getRoundTime());
dealerRoundInfo.setGoalTtlAct(dealerRoundInfoReq.getGoalTtlAct());
dealerRoundInfo.setPaymentTtlNew(dealerRoundInfoReq.getPaymentTtlNew());
dealerRoundInfo.setPaymentTtlPre(dealerRoundInfoReq.getPaymentTtl());
// 如果数据存在,则为1 未存在,则为0
List<DealerRoundInfo> list = this.list(new LambdaQueryWrapper<DealerRoundInfo>()
.eq(DealerRoundInfo::getDealerId, userId)
.gt(DealerRoundInfo::getPaymentTtlNew, dealerRoundInfoReq.getPaymentTtlNew())
);
// 有超过当前金额的记录 则为1不出特效 ,标识已有更大的预付款,并且出过特效 否则为0 没有出过特效
Integer repetition = list.size() > 0 ? 1 : 0;
dealerRoundInfo.setRepetition(repetition);
this.save(dealerRoundInfo);
//更新结果表数据
DealerRoundResult resultInfo = new DealerRoundResult();
resultInfo.setDealerId(userId);
resultInfo.setDealerName(dealerRoundInfoReq.getDealerName());
// 手机号传输 是脱敏手机号
resultInfo.setPhone(dealerRoundInfoReq.getPhone());
resultInfo.setRoundTime(dealerRoundInfoReq.getRoundTime());
resultInfo.setPaymentTtlPre(dealerRoundInfoReq.getPaymentTtl());
resultInfo.setPaymentTtl(dealerRoundInfoReq.getPaymentTtlNew());
resultInfo.setGoalTtlAct(dealerRoundInfoReq.getGoalTtlAct());
resultInfo.setDealerCategory(dealerRoundInfoReq.getDealerCategory());
resultInfo.setGroupName(dealerRoundInfoReq.getGroupName());
// 查询
DealerBaseInfo baseInfo = dealerBaseInfoService.getById(userId);
resultInfo.setSalesRegionGroupName(baseInfo.getSalesRegionGroupName());
resultInfo.setPaymentPercentage(getPercentage(dealerRoundInfoReq.getPaymentTtlNew(), dealerRoundInfoReq.getGoalTtlAct(),4));
// 查询当前经销商的结果
DealerRoundResult existResult = roundResultService.getOne(new LambdaQueryWrapper<DealerRoundResult>()
.eq(DealerRoundResult::getDealerId, userId)
.eq(DealerRoundResult::getRoundTime, 1)
);
if (ObjectUtil.isNotEmpty(existResult)) {
// 修改结果表数据
resultInfo.setResultId(existResult.getResultId());
resultInfo.setVersion(existResult.getVersion() + 1);
} else {
// 第一次只能新增 新增结果表数据
resultInfo.setVersion(1);
}
roundResultService.saveOrUpdate(resultInfo);
return 1;
}
private String getPercentage(Integer paymentTtl, Integer goalTtlAct,Integer scale) {
return new BigDecimal(paymentTtl)
.multiply(new BigDecimal(100))
......
......@@ -12,7 +12,9 @@ import com.ruoyi.dealer.domain.DealerBaseInfo;
import com.ruoyi.dealer.domain.DealerResult;
import com.ruoyi.dealer.domain.DealerRoundResult;
import com.ruoyi.dealer.domain.dto.*;
import com.ruoyi.dealer.domain.dto.DealerRoundInfo;
import com.ruoyi.dealer.mapper.DealerRoundResultMapper;
import com.ruoyi.dealer.service.DealerRoundInfoService;
import com.ruoyi.dealer.service.IDealerBaseInfoService;
import com.ruoyi.dealer.service.IDealerResultService;
import com.ruoyi.dealer.service.IDealerRoundResultService;
......@@ -26,6 +28,7 @@ import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -40,6 +43,8 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM
private IDealerBaseInfoService dealerBaseInfoService;
@Autowired
private IDealerResultService resultService;
@Autowired
private DealerRoundInfoService roundInfoService;
/**
* 大屏 个人分组查询
......@@ -140,12 +145,37 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM
if (round1Results.size() > 0) {
throw new RuntimeException("轮次数据已存在");
}
// 获取所有经销商信息
List<DealerBaseInfo> resultList = dealerBaseInfoService.list();
List<DealerBaseInfo> baseInfos = dealerBaseInfoService.list();
List<DealerRoundInfo> items = new ArrayList<>();
// 生成动态数据
baseInfos.forEach(baseInfo -> {
if(baseInfo.getPaymentTtl()>0){
DealerRoundInfo item = new DealerRoundInfo();
item.setDealerId(baseInfo.getDealerId());
item.setDealerName(baseInfo.getDealerName());
item.setRoundTime(1);
item.setPaymentTtlNew(baseInfo.getPaymentTtl());
item.setGoalTtlAct(baseInfo.getGoalTtlAct());
item.setPaymentTtlPre(baseInfo.getPaymentTtl());
item.setPaymentPercentage(baseInfo.getPaymentPercentage() );
item.setPhone(baseInfo.getPhone());
item.setCreateTime(LocalDateTime.now());
items.add(item);
}
});
roundInfoService.saveBatch(items);
// 复制所有数据
List<DealerRoundResult> roundResults = new ArrayList<>();
// 先清空id
resultList.forEach(baseInfo -> {
baseInfos.forEach(baseInfo -> {
DealerRoundResult item = new DealerRoundResult();
item.setRoundTime(1);
item.setDealerCategory(baseInfo.getDealerCategory());
......@@ -164,7 +194,7 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM
roundResults.add(item);
});
this.saveOrUpdateBatch(roundResults);
return resultList.size();
return baseInfos.size();
}
@Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论