InsPlySettleServiceImpl.java 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package com.ydtech.modules.fnc.service.impl;
  2. import cn.dev33.satoken.stp.StpUtil;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.github.pagehelper.PageHelper;
  5. import com.github.pagehelper.PageInfo;
  6. import com.ydtech.core.page.HttpResult;
  7. import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
  8. import com.ydtech.modules.fnc.dao.InsPlySettleDetailMapper;
  9. import com.ydtech.modules.fnc.entity.InsPlyIncome;
  10. import com.ydtech.modules.fnc.entity.InsPlySettle;
  11. import com.ydtech.modules.fnc.dao.InsPlySettleMapper;
  12. import com.ydtech.modules.fnc.entity.InsPlySettleDetail;
  13. import com.ydtech.modules.fnc.entity.InsPlySettleHx;
  14. import com.ydtech.modules.fnc.service.InsPlySettleService;
  15. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  16. import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
  17. import com.ydtech.modules.fnc.vo.InsPlySettleVo;
  18. import com.ydtech.modules.order.entity.BasePageResult;
  19. import com.ydtech.modules.order.entity.InsOrders;
  20. import com.ydtech.utils.DateUtil;
  21. import com.ydtech.utils.StringUtils;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.stereotype.Service;
  24. import org.springframework.transaction.annotation.Transactional;
  25. import java.math.BigDecimal;
  26. import java.time.LocalDate;
  27. import java.time.LocalDateTime;
  28. import java.time.YearMonth;
  29. import java.util.Date;
  30. import java.util.List;
  31. /**
  32. * <p>
  33. * 月度结算单汇总表 服务实现类
  34. * </p>
  35. *
  36. * @author gws
  37. * @since 2024-01-10
  38. */
  39. @Service
  40. public class InsPlySettleServiceImpl extends ServiceImpl<InsPlySettleMapper, InsPlySettle> implements InsPlySettleService {
  41. @Autowired
  42. private InsPlySettleDetailMapper insPlySettleDetailMapper;
  43. @Autowired
  44. private InsPlyIncomeMapper insPlyIncomeMapper;
  45. @Override
  46. @Transactional
  47. public HttpResult generateSettleAndDetail(List<InsPlyIncome> plyList) {
  48. String settleno = "";
  49. BigDecimal commissionFeevalue=new BigDecimal(0);
  50. BigDecimal otherFeevalue=new BigDecimal(0);
  51. BigDecimal allFeeValue=new BigDecimal(0);
  52. // 生成结算单号
  53. settleno = plyList.get(0).getCompanyId()+ DateUtil.yyyyMMddHHmmss(new Date());
  54. for(InsPlyIncome insPlyIncome:plyList){
  55. InsPlySettleDetail insPlySettleDetail =new InsPlySettleDetail();
  56. insPlySettleDetail.setSettleno(settleno);
  57. insPlySettleDetail.setOrderno(insPlyIncome.getOrderno());
  58. insPlySettleDetail.setPolicyno(insPlyIncome.getPolicyno());
  59. insPlySettleDetail.setDeptId(insPlyIncome.getDeptId());
  60. insPlySettleDetail.setCommissionFeevalue(insPlyIncome.getCommissionFeevalue());
  61. insPlySettleDetail.setOtherFeevalue(insPlyIncome.getOtherFeevalue());
  62. insPlySettleDetail.setAllFeeValue(insPlyIncome.getAllFeeValue());
  63. insPlySettleDetail.setCreateTime(LocalDateTime.now());
  64. insPlySettleDetailMapper.insert(insPlySettleDetail);
  65. //修改ins_ply_income
  66. insPlyIncome.setDoingFeeValue(insPlyIncome.getAllFeeValue());
  67. insPlyIncomeMapper.updateById(insPlyIncome);
  68. commissionFeevalue=commissionFeevalue.add(insPlyIncome.getCommissionFeevalue());
  69. otherFeevalue=otherFeevalue.add(insPlyIncome.getOtherFeevalue());
  70. allFeeValue=allFeeValue.add(insPlyIncome.getAllFeeValue());
  71. }
  72. InsPlySettle insPlySettle =new InsPlySettle();
  73. insPlySettle.setSettleno(settleno);
  74. insPlySettle.setCompanyId(plyList.get(0).getCompanyId());
  75. insPlySettle.setDeptId(plyList.get(0).getDeptId());
  76. insPlySettle.setSettleMonth(YearMonth.from(plyList.get(0).getPayDate()).toString());
  77. String settleBatch =this.baseMapper.getMaxBatch(insPlySettle);
  78. if(StringUtils.isNullOrEmpty(settleBatch)){
  79. settleBatch="1";
  80. }else{
  81. settleBatch=String.valueOf(Integer.parseInt(settleBatch)+1);
  82. }
  83. insPlySettle.setSettleBatch(settleBatch);
  84. insPlySettle.setCommissionFeevalue(commissionFeevalue);
  85. insPlySettle.setOtherFeevalue(otherFeevalue);
  86. insPlySettle.setAllFeeValue(allFeeValue);
  87. insPlySettle.setOperator(StpUtil.getLoginId().toString());
  88. insPlySettle.setCreateTime(LocalDateTime.now());
  89. insPlySettle.setStatus("0");
  90. this.baseMapper.insert(insPlySettle);
  91. return HttpResult.ok(settleno);
  92. }
  93. @Override
  94. public HttpResult<BasePageResult<InsPlySettle>> selectSettle(InsPlySettleVo insPlySettleVo) {
  95. try{
  96. Page<InsOrders> page = new Page<>(insPlySettleVo.getPageNum(), insPlySettleVo.getPageSize());
  97. PageInfo<List<InsPlyIncome>> pageHelper = null;
  98. PageHelper.startPage(insPlySettleVo.getPageNum(),insPlySettleVo.getPageSize());
  99. List<InsPlySettle> list= this.baseMapper.selectByCondition(insPlySettleVo);
  100. pageHelper=new PageInfo(list);
  101. BasePageResult<InsPlySettle> pageResult=new BasePageResult<InsPlySettle>(insPlySettleVo.getPageNum(), insPlySettleVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
  102. return HttpResult.ok(pageResult);
  103. }catch (Exception e){
  104. e.printStackTrace();
  105. return HttpResult.error("查询异常");
  106. }
  107. }
  108. @Override
  109. public HttpResult<BasePageResult<InsPlyIncome>> selectSettleDetail(InsPlySettleVo insPlySettleVo) {
  110. try{
  111. Page<InsOrders> page = new Page<>(insPlySettleVo.getPageNum(), insPlySettleVo.getPageSize());
  112. PageInfo<List<InsPlyIncome>> pageHelper = null;
  113. PageHelper.startPage(insPlySettleVo.getPageNum(),insPlySettleVo.getPageSize());
  114. List<InsPlyIncome> list= insPlyIncomeMapper.selectSettleByCondition(insPlySettleVo);
  115. pageHelper=new PageInfo(list);
  116. BasePageResult<InsPlyIncome> pageResult=new BasePageResult(insPlySettleVo.getPageNum(), insPlySettleVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
  117. return HttpResult.ok(pageResult);
  118. }catch (Exception e){
  119. e.printStackTrace();
  120. return HttpResult.error("查询异常");
  121. }
  122. }
  123. @Override
  124. public HttpResult enterSettle(InsPlySettleHx insPlySettle) {
  125. return null;
  126. }
  127. }