| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- package com.ydtech.modules.fnc.service.impl;
- import cn.dev33.satoken.stp.StpUtil;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.ydtech.core.page.HttpResult;
- import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
- import com.ydtech.modules.fnc.dao.InsPlySettleDetailMapper;
- import com.ydtech.modules.fnc.entity.InsPlyIncome;
- import com.ydtech.modules.fnc.entity.InsPlySettle;
- import com.ydtech.modules.fnc.dao.InsPlySettleMapper;
- import com.ydtech.modules.fnc.entity.InsPlySettleDetail;
- import com.ydtech.modules.fnc.entity.InsPlySettleHx;
- import com.ydtech.modules.fnc.service.InsPlySettleService;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
- import com.ydtech.modules.fnc.vo.InsPlySettleVo;
- import com.ydtech.modules.order.entity.BasePageResult;
- import com.ydtech.modules.order.entity.InsOrders;
- import com.ydtech.utils.DateUtil;
- import com.ydtech.utils.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.math.BigDecimal;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.time.YearMonth;
- import java.util.Date;
- import java.util.List;
- /**
- * <p>
- * 月度结算单汇总表 服务实现类
- * </p>
- *
- * @author gws
- * @since 2024-01-10
- */
- @Service
- public class InsPlySettleServiceImpl extends ServiceImpl<InsPlySettleMapper, InsPlySettle> implements InsPlySettleService {
- @Autowired
- private InsPlySettleDetailMapper insPlySettleDetailMapper;
- @Autowired
- private InsPlyIncomeMapper insPlyIncomeMapper;
- @Override
- @Transactional
- public HttpResult generateSettleAndDetail(List<InsPlyIncome> plyList) {
- String settleno = "";
- BigDecimal commissionFeevalue=new BigDecimal(0);
- BigDecimal otherFeevalue=new BigDecimal(0);
- BigDecimal allFeeValue=new BigDecimal(0);
- // 生成结算单号
- settleno = plyList.get(0).getCompanyId()+ DateUtil.yyyyMMddHHmmss(new Date());
- for(InsPlyIncome insPlyIncome:plyList){
- InsPlySettleDetail insPlySettleDetail =new InsPlySettleDetail();
- insPlySettleDetail.setSettleno(settleno);
- insPlySettleDetail.setOrderno(insPlyIncome.getOrderno());
- insPlySettleDetail.setPolicyno(insPlyIncome.getPolicyno());
- insPlySettleDetail.setDeptId(insPlyIncome.getDeptId());
- insPlySettleDetail.setCommissionFeevalue(insPlyIncome.getCommissionFeevalue());
- insPlySettleDetail.setOtherFeevalue(insPlyIncome.getOtherFeevalue());
- insPlySettleDetail.setAllFeeValue(insPlyIncome.getAllFeeValue());
- insPlySettleDetail.setCreateTime(LocalDateTime.now());
- insPlySettleDetailMapper.insert(insPlySettleDetail);
- //修改ins_ply_income
- insPlyIncome.setDoingFeeValue(insPlyIncome.getAllFeeValue());
- insPlyIncomeMapper.updateById(insPlyIncome);
- commissionFeevalue=commissionFeevalue.add(insPlyIncome.getCommissionFeevalue());
- otherFeevalue=otherFeevalue.add(insPlyIncome.getOtherFeevalue());
- allFeeValue=allFeeValue.add(insPlyIncome.getAllFeeValue());
- }
- InsPlySettle insPlySettle =new InsPlySettle();
- insPlySettle.setSettleno(settleno);
- insPlySettle.setCompanyId(plyList.get(0).getCompanyId());
- insPlySettle.setDeptId(plyList.get(0).getDeptId());
- insPlySettle.setSettleMonth(YearMonth.from(plyList.get(0).getPayDate()).toString());
- String settleBatch =this.baseMapper.getMaxBatch(insPlySettle);
- if(StringUtils.isNullOrEmpty(settleBatch)){
- settleBatch="1";
- }else{
- settleBatch=String.valueOf(Integer.parseInt(settleBatch)+1);
- }
- insPlySettle.setSettleBatch(settleBatch);
- insPlySettle.setCommissionFeevalue(commissionFeevalue);
- insPlySettle.setOtherFeevalue(otherFeevalue);
- insPlySettle.setAllFeeValue(allFeeValue);
- insPlySettle.setOperator(StpUtil.getLoginId().toString());
- insPlySettle.setCreateTime(LocalDateTime.now());
- insPlySettle.setStatus("0");
- this.baseMapper.insert(insPlySettle);
- return HttpResult.ok(settleno);
- }
- @Override
- public HttpResult<BasePageResult<InsPlySettle>> selectSettle(InsPlySettleVo insPlySettleVo) {
- try{
- Page<InsOrders> page = new Page<>(insPlySettleVo.getPageNum(), insPlySettleVo.getPageSize());
- PageInfo<List<InsPlyIncome>> pageHelper = null;
- PageHelper.startPage(insPlySettleVo.getPageNum(),insPlySettleVo.getPageSize());
- List<InsPlySettle> list= this.baseMapper.selectByCondition(insPlySettleVo);
- pageHelper=new PageInfo(list);
- BasePageResult<InsPlySettle> pageResult=new BasePageResult<InsPlySettle>(insPlySettleVo.getPageNum(), insPlySettleVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
- return HttpResult.ok(pageResult);
- }catch (Exception e){
- e.printStackTrace();
- return HttpResult.error("查询异常");
- }
- }
- @Override
- public HttpResult<BasePageResult<InsPlyIncome>> selectSettleDetail(InsPlySettleVo insPlySettleVo) {
- try{
- Page<InsOrders> page = new Page<>(insPlySettleVo.getPageNum(), insPlySettleVo.getPageSize());
- PageInfo<List<InsPlyIncome>> pageHelper = null;
- PageHelper.startPage(insPlySettleVo.getPageNum(),insPlySettleVo.getPageSize());
- List<InsPlyIncome> list= insPlyIncomeMapper.selectSettleByCondition(insPlySettleVo);
- pageHelper=new PageInfo(list);
- BasePageResult<InsPlyIncome> pageResult=new BasePageResult(insPlySettleVo.getPageNum(), insPlySettleVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
- return HttpResult.ok(pageResult);
- }catch (Exception e){
- e.printStackTrace();
- return HttpResult.error("查询异常");
- }
- }
- @Override
- public HttpResult enterSettle(InsPlySettleHx insPlySettle) {
- return null;
- }
- }
|