SysChannelGroupServiceImpl.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. package com.ydtech.modules.admin.service.impl;
  2. import cn.hutool.core.collection.CollUtil;
  3. import com.alibaba.fastjson.JSON;
  4. import com.alibaba.fastjson.JSONArray;
  5. import com.alibaba.fastjson.JSONObject;
  6. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  7. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  8. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  9. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  10. import com.google.gson.Gson;
  11. import com.ydtech.constants.InsuranceEnum;
  12. import com.ydtech.exception.SystemException;
  13. import com.ydtech.modules.admin.constants.EnabledEnum;
  14. import com.ydtech.modules.admin.constants.UserConstants;
  15. import com.ydtech.modules.admin.dao.SysChannelGroupMapper;
  16. import com.ydtech.modules.admin.model.SysUser;
  17. import com.ydtech.modules.admin.model.po.*;
  18. import com.ydtech.modules.admin.model.vo.AddSysChannelGroupVo;
  19. import com.ydtech.modules.admin.model.vo.CostSysChannelGroupVo;
  20. import com.ydtech.modules.admin.model.vo.SysChannelGroupPageVo;
  21. import com.ydtech.modules.admin.model.vo.SysChannelGroupVo;
  22. import com.ydtech.modules.admin.service.*;
  23. import com.ydtech.modules.esm.dao.EsmInsCompanyMapper;
  24. import com.ydtech.modules.esm.model.EsmInsCompany;
  25. import com.ydtech.modules.order.entity.InsAreaCompany;
  26. import com.ydtech.modules.order.entity.InsOrders;
  27. import com.ydtech.modules.order.entity.api.dajia.response.NVHLODR1001Response;
  28. import com.ydtech.modules.order.entity.api.zhongmei.response.SubmitResponse;
  29. import com.ydtech.modules.order.entity.crawler.response.CrawlerVerifyPaymentResponse;
  30. import com.ydtech.modules.order.entity.dto.DrivingInsuranceDto;
  31. import com.ydtech.modules.protocol.entity.constants.PtlApiType;
  32. import com.ydtech.modules.protocol.entity.po.PtlAgreement;
  33. import com.ydtech.modules.protocol.utils.AssertionUtils;
  34. import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
  35. import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsNew;
  36. import com.ydtech.modules.protocols.service.PtlAgreementProductCostsNewService;
  37. import org.apache.commons.lang3.ObjectUtils;
  38. import org.apache.commons.lang3.StringUtils;
  39. import org.springframework.beans.BeanUtils;
  40. import org.springframework.beans.factory.annotation.Autowired;
  41. import org.springframework.stereotype.Service;
  42. import org.springframework.transaction.annotation.Transactional;
  43. import java.math.BigDecimal;
  44. import java.time.LocalDateTime;
  45. import java.util.*;
  46. import java.util.stream.Collectors;
  47. /**
  48. * @author dongxin
  49. * @description 针对表【sys_channel_group(渠道分组)】的数据库操作Service实现
  50. * @createDate 2024-09-09 18:55:22
  51. */
  52. @Service
  53. public class SysChannelGroupServiceImpl extends ServiceImpl<SysChannelGroupMapper, SysChannelGroup>
  54. implements SysChannelGroupService {
  55. @Autowired
  56. private PtlAgreementProductCostsNewService ptlAgreementProductCostsNewService;
  57. @Autowired
  58. private SysChannelCostRelationService sysChannelCostRelationService;
  59. @Autowired
  60. private SysChannelGroupInfoService sysChannelGroupInfoService;
  61. @Autowired
  62. private SysChannelGroupService sysChannelGroupService;
  63. @Autowired
  64. private SysChannelCostService sysChannelCostService;
  65. @Autowired
  66. private SysCostOperateLogService sysCostOperateLogService;
  67. @Autowired
  68. private SysChannelGradeService sysChannelGradeService;
  69. @Autowired
  70. private EsmInsCompanyMapper esmInsCompanyMapper;
  71. @Override
  72. public Page<SysChannelGroup> queryPage(Page page, SysChannelGroupVo sysChannelGroupVo) {
  73. LambdaQueryWrapper<SysChannelGroup> wrapper = new LambdaQueryWrapper<>();
  74. wrapper.eq(!ObjectUtils.isEmpty(sysChannelGroupVo.getName()), SysChannelGroup::getName,
  75. sysChannelGroupVo.getName())
  76. .eq(!ObjectUtils.isEmpty(sysChannelGroupVo.getId()), SysChannelGroup::getId,
  77. sysChannelGroupVo.getId())
  78. .eq(!ObjectUtils.isEmpty(sysChannelGroupVo.getEnabled()), SysChannelGroup::getEnabled,
  79. sysChannelGroupVo.getEnabled());
  80. Page<SysChannelGroup> channelGroupPage = page(page, wrapper);
  81. return channelGroupPage;
  82. }
  83. @Override
  84. public String checkNameUnique(Long id, AddSysChannelGroupVo sysChannelGroup) {
  85. Long groupId = ObjectUtils.isEmpty(id) ? -1L: id;
  86. QueryWrapper<SysChannelGroup> qw = new QueryWrapper<>();
  87. qw.eq("name", sysChannelGroup.getName());
  88. SysChannelGroup info = this.baseMapper.selectOne(qw);
  89. if (!Objects.isNull(info) && info.getId() != groupId) {
  90. return UserConstants.NOT_UNIQUE;
  91. }
  92. return UserConstants.UNIQUE;
  93. }
  94. @Override
  95. @Transactional
  96. public void insert(String userName, AddSysChannelGroupVo addChannelGroupVo) {
  97. SysChannelGroup sysChannelGroup = new SysChannelGroup();
  98. BeanUtils.copyProperties(addChannelGroupVo, sysChannelGroup);
  99. sysChannelGroup.setCreateTime(LocalDateTime.now());
  100. sysChannelGroup.setCreateBy(userName);
  101. sysChannelGroupService.save(sysChannelGroup);
  102. List<SysChannelGroupInfo> infos = addChannelGroupVo.getInfos();
  103. if(CollUtil.isNotEmpty(infos)){
  104. for (SysChannelGroupInfo info : infos) {
  105. info.setChannelId(sysChannelGroup.getId());
  106. info.setCreateTime(LocalDateTime.now());
  107. info.setCreateBy(userName);
  108. }
  109. sysChannelGroupInfoService.saveBatch(infos);
  110. }
  111. }
  112. @Override
  113. @Transactional
  114. public void edit(Long id, String userName, AddSysChannelGroupVo addChannelGroupVo) {
  115. SysChannelGroup sysChannelGroup = new SysChannelGroup();
  116. BeanUtils.copyProperties(addChannelGroupVo, sysChannelGroup);
  117. sysChannelGroup.setId(id);
  118. sysChannelGroup.setUpdateTime(LocalDateTime.now());
  119. sysChannelGroup.setUpdateBy(userName);
  120. boolean modify = sysChannelGroupService.saveOrUpdate(sysChannelGroup);
  121. // 删除之前的比例
  122. QueryWrapper<SysChannelGroupInfo> wrapper2 = new QueryWrapper<>();
  123. wrapper2.eq("channel_id", id);
  124. sysChannelGroupInfoService.remove(wrapper2);
  125. List<SysChannelGroupInfo> infos = addChannelGroupVo.getInfos();
  126. if(CollUtil.isNotEmpty(infos)){
  127. for (SysChannelGroupInfo info : infos) {
  128. if(!StringUtils.isBlank(info.getJqCostsProportion())){
  129. BigDecimal jq = new BigDecimal(info.getJqCostsProportion());
  130. if(jq.compareTo(new BigDecimal("1")) > 0){
  131. throw new SystemException("交强加投比例不能大于1");
  132. }
  133. }
  134. if(!StringUtils.isBlank(info.getSyCostsProportion())){
  135. BigDecimal sy = new BigDecimal(info.getSyCostsProportion());
  136. if(sy.compareTo(new BigDecimal("1")) > 0){
  137. throw new SystemException("商业加投比例不能大于1");
  138. }
  139. }
  140. if(!StringUtils.isBlank(info.getNoCostsProportion())){
  141. BigDecimal no = new BigDecimal(info.getNoCostsProportion());
  142. if(no.compareTo(new BigDecimal("1")) > 0){
  143. throw new SystemException("非车加投比例不能大于1");
  144. }
  145. }
  146. info.setChannelId(sysChannelGroup.getId());
  147. info.setUpdateTime(LocalDateTime.now());
  148. info.setUpdateBy(userName);
  149. }
  150. sysChannelGroupInfoService.saveBatch(infos);
  151. }
  152. }
  153. @Override
  154. @Transactional
  155. public void delete(Long id) {
  156. // 删除所有关联费用
  157. QueryWrapper<SysChannelCostRelation> wrapper1 = new QueryWrapper<>();
  158. wrapper1.eq("channel_id", id);
  159. sysChannelCostRelationService.remove(wrapper1);
  160. // 删除渠道比例
  161. QueryWrapper<SysChannelGroupInfo> wrapper2 = new QueryWrapper<>();
  162. wrapper2.eq("channel_id", id);
  163. sysChannelGroupInfoService.remove(wrapper2);
  164. // 删除渠道分组
  165. sysChannelGroupService.removeById(id);
  166. }
  167. @Override
  168. @Transactional
  169. public void costSet(CostSysChannelGroupVo costSysChannelGroupVo) {
  170. // 删除之前所有的
  171. LambdaQueryWrapper<SysChannelCostRelation> wrapper = new LambdaQueryWrapper<>();
  172. wrapper.eq(SysChannelCostRelation::getChannelId, costSysChannelGroupVo.getId());
  173. sysChannelCostRelationService.remove(wrapper);
  174. List<Long> costIdList = costSysChannelGroupVo.getCostIdList();
  175. if(CollUtil.isNotEmpty(costIdList)){
  176. List<SysChannelCostRelation> relations = new ArrayList<>();
  177. for (Long costId : costIdList) {
  178. // 获取协议id
  179. PtlAgreementProductCostsNew productCostsNew = ptlAgreementProductCostsNewService.getById(costId);
  180. if (productCostsNew == null) {continue;}
  181. SysChannelCostRelation sysChannelCostRelation = new SysChannelCostRelation();
  182. sysChannelCostRelation.setChannelId(costSysChannelGroupVo.getId());
  183. sysChannelCostRelation.setAgreementId(Long.parseLong(productCostsNew.getAgreementId()));
  184. sysChannelCostRelation.setCostId(costId);
  185. relations.add(sysChannelCostRelation);
  186. }
  187. sysChannelCostRelationService.saveBatch(relations);
  188. }
  189. }
  190. @Override
  191. public void costCompute(InsFeeOrderNew insFeeOrderNew,
  192. PtlAgreement ptlAgreement,
  193. PtlAgreementProductCostsNew ptlAgreementProductCostsNew,
  194. SysUser sysUser,
  195. InsAreaCompany insAreaCompany,
  196. InsOrders insOrders) {
  197. /** 1.根据机构获取到分组级别*/
  198. /** 2.根据费用获取渠道分组*/
  199. SysChannelGroupInfo info = sysChannelGroupInfoService.queryProportion(
  200. ptlAgreementProductCostsNew.getId(),sysUser.getDeptId());
  201. EsmInsCompany insuranceCompany = new EsmInsCompany();
  202. if(!StringUtils.isBlank(ptlAgreement.getPartnerCompaniesId())){
  203. insuranceCompany = esmInsCompanyMapper.selectById(ptlAgreement.getPartnerCompaniesId());
  204. }
  205. if(ObjectUtils.isEmpty(info)){
  206. log.error("未查询到关联费用比例");
  207. return;
  208. }
  209. // 时间判断有没有失效 有没有禁用
  210. SysChannelGroup sysChannelGroup = sysChannelGroupService.getById(info.getChannelId());
  211. if(sysChannelGroup.getStartTime().isAfter(LocalDateTime.now())
  212. || sysChannelGroup.getEndTime().isBefore(LocalDateTime.now())
  213. || sysChannelGroup.getEnabled().equals(EnabledEnum.EE_0.getCode()) ){
  214. log.error("费用分组【"+sysChannelGroup.getName()+"】禁用或者失效!");
  215. return;
  216. }
  217. if(StringUtils.isBlank(info.getJqCostsProportion())
  218. && StringUtils.isBlank(info.getSyCostsProportion())
  219. && StringUtils.isBlank(info.getNoCostsProportion())){
  220. log.error("费用分组【"+sysChannelGroup.getName()+"】未设置加投费用!");
  221. return;
  222. }
  223. /** 3.分组级别匹配,计算加投金额 */
  224. BigDecimal jqpremium = insAreaCompany.getJqpremium(); // 交强保费
  225. BigDecimal sypremium = insAreaCompany.getSypremium(); // 商业保费
  226. BigDecimal jypremium = insAreaCompany.getJypremium(); // 非车保费
  227. // 计算加投金额
  228. BigDecimal jq = jqpremium.multiply(new BigDecimal(StringUtils.isBlank(info.getJqCostsProportion())? "0" : info.getJqCostsProportion()))
  229. .setScale(2, BigDecimal.ROUND_HALF_UP);
  230. BigDecimal sy = sypremium.multiply(new BigDecimal(StringUtils.isBlank(info.getSyCostsProportion())? "0": info.getSyCostsProportion()))
  231. .setScale(2, BigDecimal.ROUND_HALF_UP);
  232. BigDecimal no = jypremium.multiply(new BigDecimal(StringUtils.isBlank(info.getNoCostsProportion())? "0": info.getNoCostsProportion()))
  233. .setScale(2, BigDecimal.ROUND_HALF_UP);
  234. SysChannelCost cost = new SysChannelCost();
  235. cost.setOrderNo(insAreaCompany.getId());
  236. cost.setUserId(insOrders.getUserid());
  237. cost.setUserName(insOrders.getUsername());
  238. cost.setLeaderName(insOrders.getLeaderName());
  239. cost.setStatus(0);
  240. cost.setSettleStatus(0);
  241. cost.setLicenseNo(insOrders.getLicenseno());
  242. // 获取被保险人姓名 json 获取
  243. JSONObject insure = insOrders.getInsureinfo();
  244. cost.setInsuredName(insure.getString("name"));
  245. cost.setCompanyId(insAreaCompany.getCompanyId());
  246. cost.setInscompany(insAreaCompany.getInscompany());
  247. cost.setPartnerCompaniesId(ptlAgreement.getPartnerCompaniesId());
  248. cost.setPartnerCompaniesName(insuranceCompany.getNamesimple());
  249. cost.setProductId(ptlAgreementProductCostsNew.getProductId());
  250. cost.setProductName(ptlAgreementProductCostsNew.getProductName());
  251. cost.setDockingPerson(ptlAgreement.getDockingPerson());
  252. cost.setJqCostsProportion(info.getJqCostsProportion());
  253. cost.setSyCostsProportion(info.getSyCostsProportion());
  254. cost.setNoCostsProportion(info.getNoCostsProportion());
  255. cost.setSigningTime(insAreaCompany.getSigningTime());
  256. cost.setPayDate(insAreaCompany.getPayDate());
  257. cost.setJqPremium(jqpremium);
  258. cost.setSyPremium(sypremium);
  259. cost.setJyPremium(jypremium);
  260. cost.setCreateTime(LocalDateTime.now());
  261. cost.setCreateBy(insOrders.getUsername());
  262. cost.setJqPolicyNo(insAreaCompany.getJqpolicyno());
  263. String noPolicyno = this.setNoPolicyno(insAreaCompany);
  264. cost.setNoPolicyNo(noPolicyno);
  265. cost.setSyPolicyNo(insAreaCompany.getSypolicyno());
  266. cost.setTaxAmount(insAreaCompany.getTaxamount());
  267. cost.setJqJtPremium(jq);
  268. cost.setSyJtPremium(sy);
  269. cost.setJyJtPremium(no);
  270. cost.setJqCostsExportProportion(insFeeOrderNew.getJqCostsExportProportion().add(insFeeOrderNew.getJqOtherCostsProportion()));
  271. cost.setSyCostsExportProportion(insFeeOrderNew.getSyCostsExportProportion().add(insFeeOrderNew.getSyOtherCostsProportion()));
  272. cost.setJqCostsExportProportion(insFeeOrderNew.getNoCostsExportProportion().add(insFeeOrderNew.getNoOtherCostsProportion()));
  273. cost.setTotalPremium(jq.add(sy).add(no));
  274. // 交强手续费出口 加 商业手续费出口 加 非车手续费出口 + 交强跟单费出口 加 商业跟单费出口 加 非车跟单费出口
  275. BigDecimal settlementAmount = insFeeOrderNew.getJqExportSuperviseCostsPremiums()
  276. .add(insFeeOrderNew.getSyExportSuperviseCostsPremiums())
  277. .add(insFeeOrderNew.getNoExportSuperviseCostsPremiums())
  278. .add(insFeeOrderNew.getJqExportOtherCostsPremiums())
  279. .add(insFeeOrderNew.getSyExportOtherCostsPremiums())
  280. .add(insFeeOrderNew.getNoExportOtherCostsPremiums());
  281. cost.setSettlementAmount(settlementAmount);
  282. cost.setDeleted(0);
  283. sysChannelCostService.save(cost);
  284. // 日志新增
  285. SysChannelCost logEntity = new SysChannelCost();
  286. logEntity.setId(cost.getId());
  287. logEntity.setJqCostsProportion(cost.getJqCostsProportion());
  288. logEntity.setSyCostsProportion(cost.getSyCostsProportion());
  289. logEntity.setNoCostsProportion(cost.getNoCostsProportion());
  290. logEntity.setJqJtPremium(cost.getJqJtPremium());
  291. logEntity.setSyJtPremium(cost.getSyJtPremium());
  292. logEntity.setJyJtPremium(cost.getJyJtPremium());
  293. SysCostOperateLog sysCostOperateLog = new SysCostOperateLog();
  294. sysCostOperateLog.setOptId(cost.getId());
  295. sysCostOperateLog.setOptType(UserConstants.OPT_TYPE_0);
  296. sysCostOperateLog.setOptContent(JSON.toJSONString(logEntity));
  297. sysCostOperateLog.setCreateBy(cost.getCreateBy());
  298. sysCostOperateLog.setCreateTime(cost.getCreateTime());
  299. sysCostOperateLogService.save(sysCostOperateLog);
  300. }
  301. /**
  302. * 获取非车保单号
  303. * @param insAreaCompany
  304. * @return
  305. */
  306. private String setNoPolicyno(InsAreaCompany insAreaCompany) {
  307. if (insAreaCompany.getJypremium() == null || insAreaCompany.getJypremium().compareTo(BigDecimal.ZERO) == 0) { // 非车跟单费
  308. return null;
  309. }
  310. JSONArray crossInsurance = insAreaCompany.getCrossInsurance();
  311. if(ObjectUtils.isEmpty(crossInsurance)) {
  312. return null;
  313. }
  314. if (crossInsurance.isEmpty()) {
  315. return null;
  316. }
  317. if (ObjectUtils.isEmpty(insAreaCompany.getApiType()) || PtlApiType.PTL_API_2.getCode() == insAreaCompany.getApiType()) {
  318. List<CrawlerVerifyPaymentResponse.DrivingInsurancesDTO> drivingInsurancesDTOS = crossInsurance.toJavaList(CrawlerVerifyPaymentResponse.DrivingInsurancesDTO.class);
  319. return drivingInsurancesDTOS.get(0).getApplication();
  320. }
  321. // 永诚
  322. if(insAreaCompany.getCompanyId().contains(InsuranceEnum.AICS.getCode())){
  323. List<DrivingInsuranceDto> javaList = crossInsurance.toJavaList(DrivingInsuranceDto.class);
  324. return javaList.get(0).getPolicyNumber();
  325. }
  326. // 大家
  327. if(insAreaCompany.getCompanyId().contains(InsuranceEnum.DJPC.getCode())){
  328. List<NVHLODR1001Response.policyInfosDTO> javaList = crossInsurance.toJavaList(NVHLODR1001Response.policyInfosDTO.class);
  329. return javaList.get(0).getPlyNo();
  330. }
  331. // 国任
  332. if(insAreaCompany.getCompanyId().contains(InsuranceEnum.XDCX.getCode())){
  333. List<DrivingInsuranceDto> javaList = crossInsurance.toJavaList(DrivingInsuranceDto.class);
  334. return javaList.get(0).getPolicyNumber();
  335. }
  336. // 中煤
  337. if(insAreaCompany.getCompanyId().contains(InsuranceEnum.ZMBX.getCode())){
  338. List<SubmitResponse.AccidentNo> javaList = crossInsurance.toJavaList(SubmitResponse.AccidentNo.class);
  339. return javaList.get(0).getRideProposalNo();
  340. }
  341. // 紫金
  342. if(insAreaCompany.getCompanyId().contains(InsuranceEnum.ZKIC.getCode())){
  343. List<DrivingInsuranceDto> javaList = crossInsurance.toJavaList(DrivingInsuranceDto.class);
  344. return javaList.get(0).getPolicyNumber();
  345. }
  346. return null;
  347. }
  348. @Override
  349. public SysChannelGroup queryById(Long id) {
  350. LambdaQueryWrapper<SysChannelGroup> wrapper = new LambdaQueryWrapper<>();
  351. wrapper.eq(SysChannelGroup::getId, id);
  352. SysChannelGroup group = getOne(wrapper);
  353. // 查询费用关联数据
  354. LambdaQueryWrapper<SysChannelCostRelation> wrapper2 = new LambdaQueryWrapper<>();
  355. wrapper2.eq(!ObjectUtils.isEmpty(id),SysChannelCostRelation::getChannelId,id);
  356. List<SysChannelCostRelation> costRelations = sysChannelCostRelationService.list(wrapper2);
  357. group.setSysChannelCostRelations(costRelations);
  358. // 获取所有级别
  359. List<SysChannelGrade> grades = sysChannelGradeService.list();
  360. // 查询分组明细费用比例
  361. LambdaQueryWrapper<SysChannelGroupInfo> wrapper3 = new LambdaQueryWrapper<>();
  362. wrapper3.eq(!ObjectUtils.isEmpty(id),SysChannelGroupInfo::getChannelId,id);
  363. List<SysChannelGroupInfo> groupInfos = sysChannelGroupInfoService.list(wrapper3);
  364. Map<Long, String> gradeMap = new HashMap<Long, String>();
  365. if (CollUtil.isNotEmpty(groupInfos)) {
  366. gradeMap = groupInfos.stream().collect(Collectors.toMap(
  367. SysChannelGroupInfo::getGradeId, SysChannelGroupInfo::getGradeName));
  368. }
  369. if(CollUtil.isEmpty(grades)){
  370. group.setSysChannelGroupInfos(groupInfos);
  371. return group;
  372. }
  373. for (SysChannelGrade grade : grades) {
  374. if (!gradeMap.containsKey(grade.getId())){
  375. SysChannelGroupInfo sysChannelGroupInfo = new SysChannelGroupInfo();
  376. sysChannelGroupInfo.setGradeId(grade.getId());
  377. sysChannelGroupInfo.setGradeName(grade.getName());
  378. groupInfos.add(sysChannelGroupInfo);
  379. }
  380. }
  381. group.setSysChannelGroupInfos(groupInfos);
  382. return group;
  383. }
  384. @Override
  385. public void openOne(Long id) {
  386. SysChannelGroup sysChannelGroup = getByIdExist(id, "查询配置信息不存在");
  387. Integer enabled = sysChannelGroup.getEnabled();
  388. Integer i = Objects.equals(EnabledEnum.EE_1.getCode(), enabled) ? EnabledEnum.EE_0.getCode() : EnabledEnum.EE_1.getCode();
  389. boolean b = updateEnabled(i);
  390. sysChannelGroup.setEnabled(i);
  391. boolean b1 = updateById(sysChannelGroup);
  392. AssertionUtils.isSucceed(b1 && b, "成功");
  393. }
  394. @Override
  395. public void queryCostList(List<PtlAgreementProductCostsNew> costsNewList, SysChannelGroupPageVo sysChannelGroupPageVo) {
  396. if(CollUtil.isNotEmpty(costsNewList)){
  397. // 查询费用关联数据
  398. LambdaQueryWrapper<SysChannelCostRelation> wrapper= new LambdaQueryWrapper<>();
  399. wrapper.eq(!ObjectUtils.isEmpty(sysChannelGroupPageVo.getId()),SysChannelCostRelation::getChannelId,sysChannelGroupPageVo.getId());
  400. List<SysChannelCostRelation> costRelations = sysChannelCostRelationService.list(wrapper);
  401. List<Long> costIds = costRelations.stream().map(SysChannelCostRelation::getCostId).collect(Collectors.toList());
  402. for (PtlAgreementProductCostsNew productCostsNew : costsNewList) {
  403. if (costIds.contains(Long.parseLong(productCostsNew.getId()))){
  404. productCostsNew.setCheck(true);
  405. }else{
  406. productCostsNew.setCheck(false);
  407. }
  408. }
  409. }
  410. }
  411. @Override
  412. public List<SysChannelGroup> getProductList(Long id) {
  413. List<SysChannelGroup> groupList = this.baseMapper.getProductList(id);
  414. return groupList;
  415. }
  416. public static void main(String[] args) {
  417. // SysChannelCost logEntity = new SysChannelCost();
  418. // logEntity.setId(1l);
  419. // logEntity.setJqCostsProportion("1");
  420. // logEntity.setSyCostsProportion("1");
  421. // logEntity.setNoCostsProportion("1");
  422. // logEntity.setJqJtPremium(new BigDecimal(1));
  423. // logEntity.setSyJtPremium(new BigDecimal(1));
  424. // logEntity.setJyJtPremium(new BigDecimal(1));
  425. // System.out.println(JSON.toJSON(logEntity));
  426. }
  427. }