InsPlyIncomeServiceImpl.java 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545
  1. package com.ydtech.modules.fnc.service.impl;
  2. import cn.afterturn.easypoi.excel.entity.ExportParams;
  3. import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
  4. import cn.hutool.core.bean.BeanUtil;
  5. import cn.hutool.core.text.StrBuilder;
  6. import com.alibaba.fastjson.JSONArray;
  7. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  8. import com.fasterxml.jackson.core.JsonProcessingException;
  9. import com.fasterxml.jackson.databind.JsonNode;
  10. import com.fasterxml.jackson.databind.ObjectMapper;
  11. import com.github.pagehelper.PageHelper;
  12. import com.github.pagehelper.PageInfo;
  13. import com.ydtech.constants.enums.dict.agreement.ProductsType;
  14. import com.ydtech.core.page.HttpResult;
  15. import com.ydtech.exception.SystemException;
  16. import com.ydtech.modules.esm.model.EsmInsCompany;
  17. import com.ydtech.modules.esm.service.EsmInsCompanyService;
  18. import com.ydtech.modules.fnc.entity.InsAreaCompany;
  19. import com.ydtech.modules.fnc.entity.InsPlyIncome;
  20. import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
  21. import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity;
  22. import com.ydtech.modules.fnc.entity.SettlementDocumentaryLogEntity;
  23. import com.ydtech.modules.fnc.service.InsPlyIncomeService;
  24. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  25. import com.ydtech.modules.fnc.service.SettlementDocumentaryFeesService;
  26. import com.ydtech.modules.fnc.service.SettlementDocumentaryLogService;
  27. import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
  28. import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesVo;
  29. import com.ydtech.modules.ins.model.vo.res.*;
  30. import com.ydtech.modules.inv.model.InvChannelsExternalBillsDetails;
  31. import com.ydtech.modules.inv.model.dto.InsBxNoPlyIncomeExcelDto;
  32. import com.ydtech.modules.inv.model.dto.InsBxPlyIncomeExcelDto;
  33. import com.ydtech.modules.inv.model.dto.InsPlyIncomeExcelDto;
  34. import com.ydtech.modules.inv.model.dto.InvChannelExcelDto;
  35. import com.ydtech.modules.inv.model.excel.InvDisburseExcel;
  36. import com.ydtech.modules.inv.utils.EasyExcelUtils;
  37. import com.ydtech.modules.order.entity.BasePageResult;
  38. import com.ydtech.modules.order.entity.InsOrders;
  39. import com.ydtech.modules.order.service.InsAreaCompanyService;
  40. import com.ydtech.modules.order.service.InsOrdersService;
  41. import com.ydtech.modules.protocol.entity.po.PtlAgreement;
  42. import com.ydtech.modules.protocol.entity.vo.PtlAgreementQueryVo;
  43. import com.ydtech.modules.protocol.service.PtlAgreementService;
  44. import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
  45. import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
  46. import com.ydtech.utils.BigDecimalUtils;
  47. import com.ydtech.utils.SnowFlakeUtil;
  48. import com.ydtech.utils.excel.ExcelEasypoiUtils;
  49. import com.ydtech.utils.excel.ExcelStyleUtil;
  50. import com.ydtech.utils.excel.ExcelUtils2;
  51. import lombok.extern.slf4j.Slf4j;
  52. import org.apache.commons.lang3.ObjectUtils;
  53. import org.apache.commons.lang3.StringUtils;
  54. import org.apache.poi.ss.formula.functions.Now;
  55. import org.springframework.beans.BeanUtils;
  56. import org.springframework.beans.factory.annotation.Autowired;
  57. import org.springframework.beans.factory.annotation.Value;
  58. import org.springframework.context.annotation.Lazy;
  59. import org.springframework.stereotype.Service;
  60. import org.springframework.transaction.annotation.Transactional;
  61. import org.springframework.util.CollectionUtils;
  62. import org.springframework.web.multipart.MultipartFile;
  63. import redis.clients.jedis.params.Params;
  64. import javax.servlet.http.HttpServletRequest;
  65. import javax.servlet.http.HttpServletResponse;
  66. import java.awt.image.BandedSampleModel;
  67. import java.io.IOException;
  68. import java.math.BigDecimal;
  69. import java.nio.file.Files;
  70. import java.nio.file.Path;
  71. import java.nio.file.Paths;
  72. import java.time.LocalDate;
  73. import java.time.LocalDateTime;
  74. import java.util.*;
  75. import java.util.stream.Collectors;
  76. /**
  77. * <p>
  78. * 保司结算手续费 服务实现类
  79. * </p>
  80. *
  81. * @author gws
  82. * @since 2024-01-05
  83. */
  84. @Slf4j
  85. @Service
  86. public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, InsPlyIncome> implements InsPlyIncomeService {
  87. @Autowired
  88. @Lazy
  89. private InsOrdersService insOrdersService;
  90. @Autowired
  91. private InsAreaCompanyService insAreaCompanyService;
  92. @Autowired
  93. private InsFeeOrderNewService insFeeOrderNewService;
  94. @Autowired
  95. private SettlementDocumentaryFeesService settlementDocumentaryFeesService;
  96. @Autowired
  97. private SettlementDocumentaryLogService settlementDocumentaryLogService;
  98. @Autowired
  99. private PtlAgreementService ptlAgreementService;
  100. @Autowired
  101. private EsmInsCompanyService EsmInsCompanyService;
  102. @Value("${upload.file.path}")
  103. private String uploadPath;
  104. @Value("${upload.file.url}")
  105. private String uploadUrl;
  106. public HttpResult<BasePageResult<InsPlyIncome>> queryplyIncome(InsPlyIncomeVo insPlyIncomeVo){
  107. try{
  108. Page<InsOrders> page = new Page<>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize());
  109. PageInfo<List<InsPlyIncome>> pageHelper = null;
  110. PageHelper.startPage(insPlyIncomeVo.getPageNum(),insPlyIncomeVo.getPageSize());
  111. List<InsPlyIncome> list= this.baseMapper.selectByCondition(insPlyIncomeVo);
  112. pageHelper=new PageInfo(list);
  113. BasePageResult<InsPlyIncome> pageResult=new BasePageResult<InsPlyIncome>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
  114. return HttpResult.ok(pageResult);
  115. }catch (Exception e){
  116. e.printStackTrace();
  117. return HttpResult.error("查询异常");
  118. }
  119. }
  120. @Override
  121. public void saveBalanceNew(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
  122. if (ObjectUtils.isEmpty(order) || ObjectUtils.isEmpty(insFeeOrderNew) || ObjectUtils.isEmpty(insAreaCompany)) {
  123. return;
  124. }
  125. String agreeType = this.judgeAgreeType(insAreaCompany.getAgreementId());
  126. if (StringUtils.isNotEmpty(agreeType)) {
  127. // 判断协议类型 平台 保险
  128. if ("1".equals(agreeType)) {
  129. this.savePinTai(order,insFeeOrderNew,insAreaCompany); //手续费不分非车不非车 跟单也不分
  130. }else { // 保险 逻辑: 手续费生成一条 跟单费生成一条 非车手续费一条 非车跟单费一条
  131. if (((insFeeOrderNew.getJqSuperviseCostsPremiums() != null && insFeeOrderNew.getJqSuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0)) || (insFeeOrderNew.getSySuperviseCostsPremiums() != null && insFeeOrderNew.getSySuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0)) { //手续费
  132. this.saveInsuranceProcedures(order,insFeeOrderNew,insAreaCompany);
  133. }
  134. if(insFeeOrderNew.getJqOtherCostsPremiums()!=null && insFeeOrderNew.getJqOtherCostsPremiums().compareTo(BigDecimal.ZERO) != 0){ //跟单费
  135. this.saveOtherAmount(order,insFeeOrderNew,insAreaCompany);
  136. }
  137. if(insFeeOrderNew.getNoSuperviseCostsPremiums() !=null && insFeeOrderNew.getNoSuperviseCostsPremiums().compareTo(BigDecimal.ZERO) != 0) { // 非车手续费
  138. this.saveNoSupervise(order,insFeeOrderNew,insAreaCompany);
  139. }
  140. if(insFeeOrderNew.getNoOtherCostsPremiums() !=null && insFeeOrderNew.getNoOtherCostsPremiums().compareTo(BigDecimal.ZERO) != 0){ // 非车跟单费
  141. this.saveNoOtherAmount(order,insFeeOrderNew,insAreaCompany);
  142. }
  143. }
  144. }
  145. }
  146. private void saveNoOtherAmount(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
  147. InsPlyIncome insPlyIncome = new InsPlyIncome();
  148. insPlyIncome.setOrderno(insFeeOrderNew.getId()); // 子订单号
  149. String noPolicyno = this.setNoPolicyno(insAreaCompany);
  150. if(StringUtils.isNotEmpty(noPolicyno)){
  151. insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
  152. }
  153. insPlyIncome.setOtherFeevalue(insFeeOrderNew.getNoOtherCostsPremiums()); //非车跟单费
  154. insPlyIncome.setOtherFeerate(insFeeOrderNew.getNoOtherCostsProportion()); //非车跟单费用比例
  155. insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
  156. this.saveRiskCode(order.getProductid(),insPlyIncome);
  157. insPlyIncome.setPayDate(insAreaCompany.getPayDate());
  158. insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
  159. insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
  160. insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
  161. insPlyIncome.setLicenseno(order.getLicenseno());
  162. insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
  163. insPlyIncome.setCreateTime(LocalDate.now());
  164. insPlyIncome.setDocumentaryFeesStatus("0");
  165. insPlyIncome.setHandlingFeesStatus("0");
  166. insPlyIncome.setNoNoTaxPremium(insPlyIncome.getNoNoTaxPremium());
  167. insPlyIncome.setNoPremium(insPlyIncome.getNoPremium());
  168. insPlyIncome.setIsNotCar("1");
  169. insPlyIncome.setIsNotDocumentary("1");
  170. insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoOtherCostsPremiums());
  171. this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
  172. baseMapper.insert(insPlyIncome);
  173. }
  174. private void saveNoSupervise(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
  175. InsPlyIncome insPlyIncome = new InsPlyIncome();
  176. insPlyIncome.setOrderno(insFeeOrderNew.getId()); // 子订单号
  177. insPlyIncome.setCommissionFeevalue(insFeeOrderNew.getNoSuperviseCostsPremiums());// 非车手续费
  178. insPlyIncome.setCommissionFeerate(insFeeOrderNew.getNoSuperviseCostsProportion());// 非车手续费比例
  179. String noPolicyno = this.setNoPolicyno(insAreaCompany);
  180. if(StringUtils.isNotEmpty(noPolicyno)){
  181. insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
  182. }
  183. insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
  184. this.saveRiskCode(order.getProductid(),insPlyIncome);
  185. insPlyIncome.setPayDate(insAreaCompany.getPayDate());
  186. insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
  187. insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
  188. insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
  189. insPlyIncome.setLicenseno(order.getLicenseno());
  190. insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
  191. insPlyIncome.setCreateTime(LocalDate.now());
  192. insPlyIncome.setDocumentaryFeesStatus("0");
  193. insPlyIncome.setHandlingFeesStatus("0");
  194. insPlyIncome.setIsNotCar("1");
  195. insPlyIncome.setIsNotDocumentary("0");
  196. insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoSuperviseCostsPremiums());
  197. insPlyIncome.setUserId(insFeeOrderNew.getUserId());
  198. insPlyIncome.setInsuredName(order.getInsuredname());
  199. insPlyIncome.setNoPremium(insFeeOrderNew.getNoPremium()); //非车保费
  200. insPlyIncome.setNoNoTaxPremium(insFeeOrderNew.getNoNoTaxPremium()); //非车不含税保费
  201. this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
  202. baseMapper.insert(insPlyIncome);
  203. }
  204. private void saveRiskCode(String productid,InsPlyIncome insPlyIncome) {
  205. if(ProductsType.PT_0330.getCode().equals(productid)){
  206. insPlyIncome.setRiskcode(ProductsType.PT_0330.getDesc());
  207. }
  208. if(ProductsType.PT_034001.getCode().equals(productid)){
  209. insPlyIncome.setRiskcode(ProductsType.PT_034001.getDesc());
  210. }
  211. if(ProductsType.PT_034002.getCode().equals(productid)){
  212. insPlyIncome.setRiskcode(ProductsType.PT_034002.getDesc());
  213. }
  214. if(ProductsType.PT_0330034002.getCode().equals(productid)){
  215. insPlyIncome.setRiskcode(ProductsType.PT_0330034002.getDesc());
  216. }
  217. if(ProductsType.PT_0330034001.getCode().equals(productid)){
  218. insPlyIncome.setRiskcode(ProductsType.PT_0330034001.getDesc());
  219. }
  220. }
  221. private void saveOtherAmount(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
  222. BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums(),null);
  223. BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion(),null);
  224. BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), null); //交强不含税保费
  225. BigDecimal allPremium = this.calculateTotal(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), null);// 总保费
  226. InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getId(),insAreaCompany.getJqpolicyno(),insAreaCompany.getSypolicyno(),null,null,insFeeOrderNew.getDeptId(),null,order.getProductid(),insAreaCompany.getPayDate(),insAreaCompany.getSigningTime(),insAreaCompany.getCompanyId(),null,insFeeOrderNew.getAgreementId(),order.getLicenseno(),insAreaCompany.getTaxamount(),
  227. allNoTaxPremium,null,otherProportion,null,otherAmount,otherAmount,null,null,LocalDate.now(),null,null,null,"0","0","0","1");
  228. this.saveRiskCode(order.getProductid(),insPlyIncome);
  229. insPlyIncome.setTaxPremium(allPremium);
  230. insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
  231. insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
  232. insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
  233. insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
  234. insPlyIncome.setJqOtherCostsProportion(insFeeOrderNew.getJqOtherCostsProportion()); //交强跟单费比例
  235. insPlyIncome.setSyOtherCostsProportion(insFeeOrderNew.getSyOtherCostsProportion()); //商业跟单费比例
  236. insPlyIncome.setSyOtherCostsPremium(insFeeOrderNew.getSyOtherCostsPremiums());
  237. insPlyIncome.setJqOtherCostsPremium(insFeeOrderNew.getJqOtherCostsPremiums());
  238. insPlyIncome.setUserId(insFeeOrderNew.getUserId());
  239. insPlyIncome.setInsuredName(order.getInsuredname());
  240. this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
  241. baseMapper.insert(insPlyIncome);
  242. }
  243. private void saveInsuranceProcedures(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
  244. // 保险手续费
  245. BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums(),null);
  246. BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion(),null);
  247. BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), null);//不含税保费
  248. InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getId(),insAreaCompany.getJqpolicyno(),insAreaCompany.getSypolicyno(),null,null,insFeeOrderNew.getDeptId(),null,order.getProductid(),insAreaCompany.getPayDate(),insAreaCompany.getSigningTime(),insAreaCompany.getCompanyId(),null,insFeeOrderNew.getAgreementId(),order.getLicenseno(),insAreaCompany.getTaxamount()
  249. ,allNoTaxPremium,handlingProportion,null,handlingAmount,null,handlingAmount,null,null,LocalDate.now(),null,null,null,"0","0","0","0");
  250. BigDecimal allTaxPremium = this.calculateTotal(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), null);
  251. insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
  252. insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
  253. insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
  254. insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
  255. insPlyIncome.setJqSuperviseCostsProportion(insFeeOrderNew.getJqSuperviseCostsProportion());
  256. insPlyIncome.setJqSuperviseCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums());
  257. insPlyIncome.setSySuperviseCostsProportion(insFeeOrderNew.getSySuperviseCostsProportion());
  258. insPlyIncome.setSySuperviseCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums());
  259. this.saveRiskCode(order.getProductid(),insPlyIncome);
  260. insPlyIncome.setTaxPremium(allTaxPremium);
  261. insPlyIncome.setUserId(insFeeOrderNew.getUserId());
  262. insPlyIncome.setInsuredName(order.getInsuredname());
  263. this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
  264. baseMapper.insert(insPlyIncome);
  265. }
  266. private String setNoPolicyno(com.ydtech.modules.fnc.entity.InsAreaCompany insAreaCompany) {
  267. String crossInsurance = insAreaCompany.getCrossInsurance();
  268. if (StringUtils.isEmpty(crossInsurance)) {
  269. return null;
  270. }
  271. try {
  272. ObjectMapper objJson = new ObjectMapper();
  273. JsonNode jsonArryNode = objJson.readTree(crossInsurance);
  274. if (jsonArryNode.isArray() && jsonArryNode.size() > 0) {
  275. JsonNode firstNode = jsonArryNode.get(0);
  276. JsonNode policyNumberNode = firstNode.get("policyNumber");
  277. if (policyNumberNode != null) {
  278. return policyNumberNode.asText();
  279. } else {
  280. return firstNode.get("policy").asText();
  281. }
  282. }
  283. } catch (IOException e) {
  284. e.printStackTrace(); // 可以打印异常信息
  285. }
  286. return null;
  287. }
  288. private void savePinTai(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
  289. BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums(),insFeeOrderNew.getNoSuperviseCostsPremiums()); //手续费
  290. BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion(),insFeeOrderNew.getNoSuperviseCostsProportion());//手续费比例
  291. BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums(),insFeeOrderNew.getNoOtherCostsPremiums());//跟单费
  292. BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion(),insFeeOrderNew.getNoOtherCostsProportion()); //跟单费比例
  293. // 不含税保费
  294. BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), insFeeOrderNew.getNoNoTaxPremium());
  295. BigDecimal allAmount = this.calculateTotal(otherAmount, handlingAmount, null);
  296. BigDecimal jqReceivableProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getNoSuperviseCostsProportion(), null);// 交强应收 比例
  297. BigDecimal syReceivableProportion = this.calculateTotal(insFeeOrderNew.getSySuperviseCostsProportion(), insFeeOrderNew.getSyOtherCostsProportion(), null);//商业应收比例
  298. BigDecimal noReceivableProportion = this.calculateTotal(insFeeOrderNew.getNoSuperviseCostsProportion(), insFeeOrderNew.getNoOtherCostsProportion(), null);
  299. String noPolicyno = this.setNoPolicyno(insAreaCompany);
  300. InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getId(),insAreaCompany.getJqpolicyno(),insAreaCompany.getSypolicyno(),
  301. noPolicyno,null,insFeeOrderNew.getDeptId(), null,order.getProductid(),insAreaCompany.getPayDate(),insAreaCompany.getSigningTime(),insAreaCompany.getCompanyId(),
  302. null,insFeeOrderNew.getAgreementId(),order.getLicenseno(),insAreaCompany.getTaxamount(),allNoTaxPremium,handlingProportion,
  303. otherProportion,handlingAmount,otherAmount,allAmount,null,null,LocalDate.now(),null,null,null,"0","0","0","0");
  304. insPlyIncome.setJqReceivableProportion(jqReceivableProportion);
  305. insPlyIncome.setSyReceivableProportion(syReceivableProportion);
  306. insPlyIncome.setNoReceivableProportion(noReceivableProportion);
  307. // 应收金额 = 商业手续费+商业跟单 + 交强手续费 +交强跟单费 + 非车手续费 + 非车跟单费 = allAmount
  308. insPlyIncome.setJqSuperviseCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums()); // 交强手续费
  309. insPlyIncome.setSySuperviseCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums()); // 商业手续费
  310. insPlyIncome.setNoSuperviseCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums()); // 非车手续费
  311. insPlyIncome.setJqSuperviseCostsProportion(insFeeOrderNew.getJqSuperviseCostsProportion()); //交强手续费 比例
  312. insPlyIncome.setSySuperviseCostsProportion(insFeeOrderNew.getSySuperviseCostsProportion()); // 商业手续费 比例
  313. insPlyIncome.setNoSuperviseCostsProportion(insFeeOrderNew.getNoSuperviseCostsProportion());// 非车手续费 比例
  314. insPlyIncome.setJqOtherCostsProportion(insFeeOrderNew.getJqOtherCostsProportion()); //交强跟单费比例
  315. insPlyIncome.setSyOtherCostsProportion(insFeeOrderNew.getSyOtherCostsProportion()); //商业跟单费比例
  316. insPlyIncome.setNoOtherCostsProportion(insFeeOrderNew.getNoOtherCostsProportion()); //非车跟单费比例
  317. insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
  318. insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
  319. insPlyIncome.setNoPremium(insFeeOrderNew.getNoPremium());
  320. insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
  321. insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
  322. insPlyIncome.setNoNoTaxPremium(insFeeOrderNew.getNoNoTaxPremium());
  323. insPlyIncome.setUserId(insFeeOrderNew.getUserId());
  324. this.saveRiskCode(order.getProductid(),insPlyIncome);
  325. insPlyIncome.setInsuredName(order.getInsuredname());
  326. this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
  327. baseMapper.insert(insPlyIncome);
  328. }
  329. private void saveByCompanyId(InsFeeOrderNew insFeeOrderNew,String companyId, InsPlyIncome insPlyIncome) {
  330. PtlAgreement ptlAgreementQueryVo = this.ptlAgreementService.getByAgreementIdNew(insFeeOrderNew.getAgreementId());
  331. if(ObjectUtils.isNotEmpty(ptlAgreementQueryVo)){
  332. if(StringUtils.isNotEmpty(ptlAgreementQueryVo.getPartnerCompaniesId())){
  333. // 合作公司id
  334. String partnerCompaniesId = ptlAgreementQueryVo.getPartnerCompaniesId();
  335. insPlyIncome.setPartnerCompaniesId(partnerCompaniesId);
  336. EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(partnerCompaniesId);
  337. String name = esmInsCompany.getName(); //合作名称
  338. insPlyIncome.setPartnerCompaniesName(name);
  339. insPlyIncome.setPartnerCompaniesId(ptlAgreementQueryVo.getPartnerCompaniesId());
  340. }
  341. if(StringUtils.isNotEmpty(ptlAgreementQueryVo.getInsuranceCompanyId())){
  342. String insuranceCompanyId = ptlAgreementQueryVo.getInsuranceCompanyId();
  343. EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(insuranceCompanyId);
  344. String name = esmInsCompany.getNamesimple(); //保险公司名称 简称
  345. insPlyIncome.setCompanyName(name);
  346. }
  347. }
  348. }
  349. private BigDecimal calculateTotal(BigDecimal value1, BigDecimal value2, BigDecimal value3) {
  350. BigDecimal total = BigDecimal.ZERO;
  351. if (value1 != null) {
  352. total = total.add(value1);
  353. }
  354. if (value2 != null) {
  355. total = total.add(value2);
  356. }
  357. if (value3 != null) {
  358. total = total.add(value3);
  359. }
  360. return total;
  361. }
  362. private String judgeAgreeType(Long agreementId) {
  363. if (agreementId == null) {
  364. return null;
  365. }
  366. HttpResult<PtlAgreementQueryVo> byAgreementId = ptlAgreementService.getByAgreementId(agreementId.toString());
  367. if (byAgreementId != null && ObjectUtils.isNotEmpty(byAgreementId.getData())) {
  368. PtlAgreement agreement = byAgreementId.getData().getAgreement();
  369. String agreementType = agreement.getAgreementType();
  370. if (StringUtils.isNotEmpty(agreementType)) {
  371. return agreementType;
  372. }
  373. }
  374. return null;
  375. }
  376. public HttpResult<BasePageResult<InsPlyIncome>> queryNew(InsPlyIncomeVo insPlyIncomeVo){
  377. try{
  378. HashMap<String, Object> params = new HashMap<>();
  379. PageInfo<List<InsPlyIncome>> pageHelper = null;
  380. PageHelper.startPage(insPlyIncomeVo.getPageNum(),insPlyIncomeVo.getPageSize());
  381. params.put("pageNum",insPlyIncomeVo.getPageNum());
  382. params.put("pageSize",insPlyIncomeVo.getPageSize());
  383. params =this.saveParams(insPlyIncomeVo,params);
  384. List<InsPlyIncome> list= this.baseMapper.queryNew(params);
  385. pageHelper=new PageInfo(list);
  386. BasePageResult<InsPlyIncome> pageResult=new BasePageResult<InsPlyIncome>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
  387. return HttpResult.ok(pageResult);
  388. }catch (Exception e){
  389. e.printStackTrace();
  390. return HttpResult.error("查询异常");
  391. }
  392. }
  393. @Override
  394. public HashMap<String,Object> totalAmount(List<String> selectIds) {
  395. HashMap<String, Object> params = new HashMap<>();
  396. params.put("selectIds",selectIds);
  397. HashMap<String,Object> resultMap =baseMapper.totalAmount(params);
  398. return resultMap;
  399. }
  400. @Override
  401. @Transactional
  402. public HttpResult<Object> batchPinBalance(InsPlyIncomeVo insPlyIncomeVo) {
  403. if(!CollectionUtils.isEmpty(insPlyIncomeVo.getSelectIds())){
  404. List<String> selectIds = insPlyIncomeVo.getSelectIds();
  405. for(String id: selectIds){
  406. InsPlyIncome insPlyIncome = new InsPlyIncome();
  407. insPlyIncome.setHandlingFeesStatus("1");
  408. insPlyIncome.setSettlementTime(LocalDate.now());
  409. insPlyIncome.setId(id);
  410. baseMapper.updateById(insPlyIncome);
  411. }
  412. }
  413. SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
  414. settlementDocumentaryLogEntity.setIds(insPlyIncomeVo.getIds());
  415. // settlementDocumentaryLogEntity.setCompanyId(insPlyIncomeVo.getCompanyId());
  416. settlementDocumentaryLogEntity.setAmount(insPlyIncomeVo.getOtherFeevalue()); //跟单费金额
  417. settlementDocumentaryLogEntity.setHandingAmount(insPlyIncomeVo.getCommissionFeevalue()); //手续费金额
  418. settlementDocumentaryLogEntity.setCreateTime(new Date());
  419. settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
  420. return HttpResult.ok();
  421. }
  422. @Override
  423. public List<InsPlyIncome> totalPinAmount(InsPlyIncomeVo insPlyIncomeVo) {
  424. HashMap<String, Object> params = new HashMap<>();
  425. params = this.saveParams(insPlyIncomeVo,params);
  426. List<InsPlyIncome> result=baseMapper.totalPinAmount(params);
  427. return result;
  428. }
  429. private HashMap<String, Object> saveParams(InsPlyIncomeVo insPlyIncomeVo, HashMap<String, Object> params) {
  430. if(ObjectUtils.isNotEmpty(insPlyIncomeVo.getStartDate())){
  431. params.put("startDate",insPlyIncomeVo.getStartDate().toString());
  432. }
  433. if(ObjectUtils.isNotEmpty(insPlyIncomeVo.getEndDate())){
  434. params.put("endDate",insPlyIncomeVo.getEndDate().toString());
  435. }
  436. if(StringUtils.isNotEmpty(insPlyIncomeVo.getOrderno())){
  437. params.put("orderno",insPlyIncomeVo.getOrderno());
  438. }
  439. if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())){
  440. params.put("isOther",insPlyIncomeVo.getIsNotDocumentary());
  441. }
  442. if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
  443. params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
  444. }
  445. if(StringUtils.isNotEmpty(insPlyIncomeVo.getAgreementType())){
  446. params.put("agreementType",insPlyIncomeVo.getAgreementType());
  447. }
  448. if(StringUtils.isNotEmpty(insPlyIncomeVo.getLicenseno())){
  449. params.put("licenseno", insPlyIncomeVo.getLicenseno());
  450. }
  451. if(StringUtils.isNotEmpty(insPlyIncomeVo.getUserId())){
  452. params.put("userId",insPlyIncomeVo.getUserId());
  453. }
  454. if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
  455. params.put("companyId",insPlyIncomeVo.getCompanyId());
  456. }
  457. if(StringUtils.isNotEmpty(insPlyIncomeVo.getRiskcode())){
  458. params.put("riskcode",insPlyIncomeVo.getRiskcode());
  459. }
  460. if(StringUtils.isNotEmpty(insPlyIncomeVo.getPolicyno())){
  461. params.put("policyno",insPlyIncomeVo.getPolicyno());
  462. }
  463. if(StringUtils.isNotEmpty(insPlyIncomeVo.getSyPolicyno())){
  464. params.put("syPolicyno",insPlyIncomeVo.getSyPolicyno());
  465. }
  466. if(StringUtils.isNotEmpty(insPlyIncomeVo.getNoPolicyno())){
  467. params.put("noPolicyno",insPlyIncomeVo.getNoPolicyno());
  468. }
  469. if(insPlyIncomeVo.getCreateTime()!=null){
  470. params.put("createTime",insPlyIncomeVo.getCreateTime().toString());
  471. }
  472. if(insPlyIncomeVo.getSettlementTime()!=null){
  473. params.put("settlementTime",insPlyIncomeVo.getSettlementTime().toString());
  474. }
  475. if(StringUtils.isNotEmpty(insPlyIncomeVo.getHandlingFeesStatus())){
  476. params.put("handlingFeesStatus",insPlyIncomeVo.getHandlingFeesStatus());
  477. }
  478. if(StringUtils.isNotEmpty(insPlyIncomeVo.getPartnerCompaniesId())){
  479. params.put("partnerCompaniesId",insPlyIncomeVo.getPartnerCompaniesId());
  480. }
  481. if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
  482. params.put("year",insPlyIncomeVo.getYear());
  483. }
  484. if(StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())){
  485. params.put("month",insPlyIncomeVo.getMonth());
  486. }
  487. if(StringUtils.isNotEmpty(insPlyIncomeVo.getDay())){
  488. params.put("day",insPlyIncomeVo.getDay());
  489. }
  490. if(StringUtils.isNotEmpty(insPlyIncomeVo.getSignDateEnd())){
  491. params.put("signDateEnd",insPlyIncomeVo.getSignDateEnd());
  492. }
  493. if(StringUtils.isNotEmpty(insPlyIncomeVo.getSignDateStart())){
  494. params.put("signDateStart",insPlyIncomeVo.getSignDateStart());
  495. }
  496. if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyName())){
  497. params.put("companyName",insPlyIncomeVo.getCompanyName());
  498. }
  499. if(StringUtils.isNotEmpty(insPlyIncomeVo.getInsuredName())){
  500. params.put("insuredName",insPlyIncomeVo.getInsuredName());
  501. }
  502. if(StringUtils.isNotEmpty(insPlyIncomeVo.getPartnerCompaniesName())){
  503. params.put("partnerCompaniesName",insPlyIncomeVo.getPartnerCompaniesName());
  504. }
  505. if(StringUtils.isNotEmpty(insPlyIncomeVo.getDockingPerson())){
  506. params.put("dockingPerson",insPlyIncomeVo.getDockingPerson());
  507. }
  508. return params;
  509. }
  510. @Override
  511. public HttpResult<BasePageResult<InsPlyIncome>> nonSettlementQuery(InsPlyIncomeVo insPlyIncomeVo) {
  512. try{
  513. HashMap<String, Object> params = new HashMap<>();
  514. PageInfo<List<InsPlyIncome>> pageHelper = null;
  515. PageHelper.startPage(insPlyIncomeVo.getPageNum(),insPlyIncomeVo.getPageSize());
  516. params.put("pageNum",insPlyIncomeVo.getPageNum());
  517. params.put("pageSize",insPlyIncomeVo.getPageSize());
  518. if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
  519. params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
  520. }
  521. if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())){
  522. params.put("isOther",insPlyIncomeVo.getIsNotDocumentary());
  523. }
  524. if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
  525. params.put("year",insPlyIncomeVo.getYear());
  526. }
  527. if(StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())){
  528. params.put("month",insPlyIncomeVo.getMonth());
  529. }
  530. if(StringUtils.isNotEmpty(insPlyIncomeVo.getDocumentaryFeesStatus())){
  531. params.put("documentaryFeesStatus",insPlyIncomeVo.getDocumentaryFeesStatus());
  532. }
  533. List<InsPlyIncome> list= this.baseMapper.NonSettlementQuery(params);
  534. pageHelper=new PageInfo(list);
  535. BasePageResult<InsPlyIncome> pageResult=new BasePageResult<InsPlyIncome>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list);
  536. return HttpResult.ok(pageResult);
  537. }catch (Exception e){
  538. e.printStackTrace();
  539. return HttpResult.error("查询异常");
  540. }
  541. }
  542. @Override
  543. public HttpResult<List<InsPlyIncome>> nonSettldetail(InsPlyIncomeVo insPlyIncomeVo) {
  544. try {
  545. String ids = insPlyIncomeVo.getIds();
  546. ArrayList<InsPlyIncome> resultList = new ArrayList<>();
  547. if (ObjectUtils.isNotEmpty(ids)) {
  548. String[] split = ids.split(",");
  549. for (int i =0; i <split.length ; i++) {
  550. String id = split[i];
  551. resultList.add(this.baseMapper.getById(id));
  552. }
  553. }
  554. return HttpResult.ok(resultList);
  555. } catch (Exception e) {
  556. e.printStackTrace();
  557. return HttpResult.error("查询异常");
  558. }
  559. }
  560. /**
  561. *
  562. * @param multipartFile
  563. * @return totalAmount 总金额
  564. * totalHandingAmount 总手续费金额
  565. * totalOtherAmount 总跟单费金额
  566. * resultHashMap 返回 ids 已经上面的金额
  567. * resultNoSelect 未匹配的车牌号
  568. */
  569. @Override
  570. public HashMap<String, Object> importData(MultipartFile multipartFile) {
  571. BigDecimal totalAmount=BigDecimal.ZERO;
  572. BigDecimal totalHandingAmount=BigDecimal.ZERO;
  573. BigDecimal totalOtherAmount=BigDecimal.ZERO;
  574. HashMap<String, Object> params = new HashMap<>();
  575. HashMap<String, Object> resultHashMap = new HashMap<>();
  576. ArrayList<HashMap<String,Object>> resultNoSelect = new ArrayList<>();
  577. StringBuffer strBuilder = new StringBuffer();
  578. try {
  579. List<InsPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsPlyIncomeExcelDto.class, 0, 1, 1);
  580. for (InsPlyIncomeExcelDto excelItem : dtoList) {
  581. params.clear();
  582. if(StringUtils.isNotEmpty(excelItem.getLicenseno())){
  583. params.put("licenseno",excelItem.getLicenseno());//车牌号
  584. }
  585. if(StringUtils.isNotEmpty(excelItem.getPolicyno())){
  586. params.put("policyno",excelItem.getPolicyno()); //交强保单号
  587. }
  588. if(StringUtils.isNotEmpty(excelItem.getSyPolicyno())){
  589. params.put("syPolicyno", excelItem.getSyPolicyno());//商业保单号
  590. }
  591. if(StringUtils.isNotEmpty(excelItem.getNoPolicyno())){
  592. params.put("noPolicyno",excelItem.getNoPolicyno()); //非车保单号
  593. }
  594. InsPlyIncome insPlyIncome=baseMapper.findByLicenseno(params);
  595. if(ObjectUtils.isNotEmpty(insPlyIncome)){
  596. strBuilder.append(insPlyIncome.getId()).append(",");
  597. if(insPlyIncome.getAllFeeValue()!=null && insPlyIncome.getAllFeeValue().compareTo(BigDecimal.ZERO)!=0){
  598. totalAmount = totalAmount.add(insPlyIncome.getAllFeeValue()); //总金额
  599. }
  600. if(insPlyIncome.getCommissionFeevalue()!=null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO)!=0){
  601. totalHandingAmount=totalHandingAmount.add(insPlyIncome.getCommissionFeevalue()); //总手续费
  602. }
  603. if(insPlyIncome.getOtherFeevalue()!=null && insPlyIncome.getOtherFeevalue().compareTo(BigDecimal.ZERO)!=0){
  604. totalOtherAmount=totalOtherAmount.add(insPlyIncome.getOtherFeevalue()); //总跟单费
  605. }
  606. }else {
  607. resultNoSelect.add(params); // 添加未匹配的车牌号
  608. }
  609. }
  610. if(strBuilder.length() >0){
  611. String ids = strBuilder.deleteCharAt(strBuilder.length() - 1).toString();
  612. resultHashMap.put("ids",ids);
  613. }
  614. resultHashMap.put("totalAmount",totalAmount);
  615. resultHashMap.put("totalHandingAmount",totalHandingAmount);
  616. resultHashMap.put("totalOtherAmount",totalOtherAmount);
  617. resultHashMap.put("resultList",resultNoSelect);
  618. return resultHashMap;
  619. } catch (IOException e) {
  620. throw new SystemException("导入失败!");
  621. }
  622. }
  623. /**
  624. *
  625. * @param multipartFile
  626. * @return resultList 包含总金额 还有 未匹配表中的数据
  627. */
  628. @Override
  629. public HashMap<String, Object> bxImportData(MultipartFile multipartFile,String isNotCar) {
  630. BigDecimal totalAmount=BigDecimal.ZERO;
  631. HashMap<String, Object> params = new HashMap<>();
  632. ArrayList<HashMap<String, Object>> resultList = new ArrayList<>();
  633. HashMap<String, Object> resultMap = new HashMap<>();
  634. try {
  635. List<InsBxPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsBxPlyIncomeExcelDto.class, 0, 1, 1);
  636. Integer i=0;
  637. if(!CollectionUtils.isEmpty(dtoList)){
  638. for (InsBxPlyIncomeExcelDto excelItem : dtoList) {
  639. i=i+1;
  640. params.clear();
  641. if(StringUtils.isNotEmpty(excelItem.getLicenseno())){
  642. String licenseno = excelItem.getLicenseno();//车牌号
  643. params.put("licenseno",licenseno);
  644. }
  645. if(StringUtils.isNotEmpty(excelItem.getPolicyno())){
  646. String policyno = excelItem.getPolicyno(); //交强保单号
  647. params.put("policyno",policyno);
  648. }
  649. if(StringUtils.isNotEmpty(excelItem.getSyPolicyno())){
  650. String syPolicyno = excelItem.getSyPolicyno(); //商业保单号
  651. params.put("syPolicyno",syPolicyno);
  652. }
  653. // 只查手续费
  654. params.put("isOther","0");
  655. params.put("isNotCar",isNotCar);
  656. InsPlyIncome insPlyIncome = baseMapper.findByBxLicenseno(params);
  657. if(i==dtoList.size()){
  658. resultMap.put("companyId",insPlyIncome.getCompanyId()); // 保险公司id
  659. resultMap.put("partnerCompaniesId",insPlyIncome.getPartnerCompaniesId()); //合作公司id
  660. resultMap.put("agreementId",insPlyIncome.getAgreementId()); //协议id
  661. }
  662. if(ObjectUtils.isNotEmpty(insPlyIncome)){ // 比配上汇总金额 未匹配则返回到数据当中
  663. if( insPlyIncome.getCommissionFeevalue()!=null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO)!=0){
  664. totalAmount = totalAmount.add(insPlyIncome.getCommissionFeevalue()); //添加总手续费
  665. }
  666. }else {
  667. HashMap<String, Object> noMatching = new HashMap<>();
  668. if(StringUtils.isNotEmpty(excelItem.getLicenseno())){
  669. noMatching.put("licenseno",excelItem.getLicenseno());
  670. }
  671. if(StringUtils.isNotEmpty(excelItem.getPolicyno())){
  672. noMatching.put("policyno",excelItem.getPolicyno());
  673. }
  674. if(StringUtils.isNotEmpty(excelItem.getSyPolicyno())){
  675. noMatching.put("syPolicyno",excelItem.getSyPolicyno());
  676. }
  677. resultList.add(noMatching);
  678. }
  679. }
  680. }
  681. resultMap.put("totalAmount",totalAmount);
  682. resultMap.put("resultList",resultList);
  683. return resultMap;
  684. } catch (IOException e) {
  685. throw new SystemException("导入失败!");
  686. }
  687. }
  688. @Override
  689. public HashMap<String, Object> bxImportNoData(MultipartFile multipartFile,String isNotCar) {
  690. BigDecimal totalAmount=BigDecimal.ZERO;
  691. HashMap<String, Object> params = new HashMap<>();
  692. HashMap<String, Object> resultMap = new HashMap<>();
  693. ArrayList<HashMap<String, Object>> resultList = new ArrayList<>();
  694. String ids="";
  695. try {
  696. Integer i=0;
  697. List<InsBxNoPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(multipartFile, InsBxNoPlyIncomeExcelDto.class, 0, 1, 1);
  698. if(!CollectionUtils.isEmpty(dtoList)){
  699. for (InsBxNoPlyIncomeExcelDto excelItem : dtoList) {
  700. i=i+1;
  701. params.clear();
  702. if(StringUtils.isNotEmpty(excelItem.getLicenseno())){
  703. String licenseno = excelItem.getLicenseno();//车牌号
  704. params.put("licenseno",licenseno);
  705. }
  706. if(StringUtils.isNotEmpty(excelItem.getNoPolicyno())){
  707. String policyno = excelItem.getNoPolicyno(); //非车保单号
  708. params.put("NoPolicyno",policyno);
  709. }
  710. // 只查手续费
  711. params.put("isOther","0");
  712. params.put("isNotCar",isNotCar);
  713. InsPlyIncome insPlyIncome = baseMapper.findByBxLicenseno(params);
  714. if(i==dtoList.size()){
  715. resultMap.put("companyId",insPlyIncome.getCompanyId()); // 保险公司id
  716. resultMap.put("partnerCompaniesId",insPlyIncome.getPartnerCompaniesId()); //合作公司id
  717. resultMap.put("agreementId",insPlyIncome.getAgreementId()); //协议id
  718. }
  719. if(ObjectUtils.isNotEmpty(insPlyIncome)){ // 比配上汇总金额 未匹配则返回到数据当中
  720. if( insPlyIncome.getCommissionFeevalue()!=null && insPlyIncome.getCommissionFeevalue().compareTo(BigDecimal.ZERO)!=0){
  721. totalAmount = totalAmount.add(insPlyIncome.getCommissionFeevalue()); //添加总手续费
  722. }
  723. }else {
  724. HashMap<String, Object> noMatching = new HashMap<>();
  725. if(StringUtils.isNotEmpty(excelItem.getLicenseno())){
  726. noMatching.put("licenseno",excelItem.getLicenseno());
  727. }
  728. if(StringUtils.isNotEmpty(excelItem.getNoPolicyno())){
  729. noMatching.put("NoPolicyno",excelItem.getNoPolicyno());
  730. }
  731. resultList.add(noMatching);
  732. }
  733. }
  734. resultMap.put("totalAmount",totalAmount);
  735. resultMap.put("resultList",resultList);
  736. }
  737. return resultMap;
  738. } catch (IOException e) {
  739. throw new SystemException("导入失败!");
  740. }
  741. }
  742. @Override
  743. public HttpResult bxOtherDetailsExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
  744. HashMap<String, Object> params = new HashMap<>();
  745. params =this.saveParams(insPlyIncomeVo,params);
  746. List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
  747. ExportParams exportParams = new ExportParams("保险跟单明细导出", null, ExcelType.HSSF);
  748. exportParams.setStyle(ExcelStyleUtil.class);
  749. List<BxOtherDetailsExcel> resultList = new ArrayList<>();
  750. for (InsPlyIncome item :insPlyIncomes){
  751. BxOtherDetailsExcel bxOtherDetailsExcel = new BxOtherDetailsExcel();
  752. BeanUtils.copyProperties(item, bxOtherDetailsExcel);
  753. resultList.add(bxOtherDetailsExcel);
  754. }
  755. String uploadPath = this.uploadPath + "/excel/";
  756. Path path = Paths.get(uploadPath);
  757. if (!Files.exists(path)) {
  758. try {
  759. Files.createDirectories(path);
  760. } catch (IOException e) {
  761. e.printStackTrace();
  762. }
  763. }
  764. String fileName = EasyExcelUtils.downExcel(uploadPath, "保险跟单明细导出", BxOtherDetailsExcel.class, resultList);
  765. return HttpResult.ok("",uploadUrl + "excel/" + fileName);
  766. }
  767. /**
  768. *
  769. * @param insPlyIncomeVo 传参字段
  770. * ids 通过ids中的id进行开票分组
  771. *
  772. * @return
  773. */
  774. @Override
  775. public HttpResult<List<HashMap<String,Object>>> invicdetail(InsPlyIncomeVo insPlyIncomeVo) {
  776. HashMap<String, Object> params = new HashMap<>();
  777. params =this.saveParams(insPlyIncomeVo,params);
  778. List<HashMap<String, Object>> resultList = settlementDocumentaryFeesService.getOtherSettldetail(params);
  779. if (resultList.size() > 0) {
  780. return HttpResult.ok(resultList);
  781. }
  782. return HttpResult.ok();
  783. }
  784. /***
  785. *
  786. * @param insPlyIncomeVo
  787. * @param request
  788. * @param response
  789. * @return 保险非车跟单明细导出
  790. */
  791. @Override
  792. public HttpResult bxNoOtherDetailsExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
  793. HashMap<String, Object> params = new HashMap<>();
  794. params =this.saveParams(insPlyIncomeVo,params);
  795. List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
  796. ExportParams exportParams = new ExportParams("保险非车跟单明细导出", null, ExcelType.HSSF);
  797. exportParams.setStyle(ExcelStyleUtil.class);
  798. List<BxNoOtherDetailsExcel> resultList = new ArrayList<>();
  799. for (InsPlyIncome item :insPlyIncomes){
  800. BxNoOtherDetailsExcel bxNoOtherDetailsExcel = new BxNoOtherDetailsExcel();
  801. BeanUtils.copyProperties(item, bxNoOtherDetailsExcel);
  802. resultList.add(bxNoOtherDetailsExcel);
  803. }
  804. String uploadPath = this.uploadPath + "/excel/";
  805. Path path = Paths.get(uploadPath);
  806. if (!Files.exists(path)) {
  807. try {
  808. Files.createDirectories(path);
  809. } catch (IOException e) {
  810. e.printStackTrace();
  811. }
  812. }
  813. String fileName = EasyExcelUtils.downExcel(uploadPath, "保险非车跟单明细导出", BxNoOtherDetailsExcel.class, resultList);
  814. return HttpResult.ok("",uploadUrl + "excel/" + fileName);
  815. }
  816. /**
  817. *
  818. * @param insPlyIncomeVo 开票ids
  819. * @return 返回开票号 开票金额 开票时间
  820. */
  821. @Override
  822. public HttpResult<List<HashMap<String, Object>>> otherSettldetail(InsPlyIncomeVo insPlyIncomeVo) {
  823. HashMap<String, Object> params = new HashMap<>();
  824. params =this.saveParams(insPlyIncomeVo,params);
  825. List<HashMap<String, Object>> resultList = settlementDocumentaryFeesService.getOtherSettldetail(params);
  826. if (resultList.size() > 0) {
  827. return HttpResult.ok(resultList);
  828. }
  829. return HttpResult.ok();
  830. }
  831. @Override
  832. public InsPlyIncome getEntityById(String id) {
  833. return baseMapper.getEntityById(id);
  834. }
  835. @Override
  836. @Transactional
  837. public void updateByEntity(InsPlyIncomeVo insPlyIncomeVo) {
  838. // 根据协议 如果是含增值税结算 用保费 * 如果是 不含税保费
  839. InsPlyIncome insPlyIncome = new InsPlyIncome();
  840. BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
  841. this.amountCalculate(insPlyIncomeVo,insPlyIncome);
  842. baseMapper.updateById(insPlyIncome);
  843. insPlyIncomeVo.setCrudStatus("2");
  844. this.saveLog(insPlyIncomeVo);
  845. }
  846. /**
  847. *
  848. * @param insPlyIncomeVo
  849. * @param insPlyIncome
  850. *
  851. * 重新计算金额 通过比例
  852. * 计算逻辑 交强不含税保费* 交强跟单比例 = 交强跟单金额
  853. */
  854. private void amountCalculate(InsPlyIncomeVo insPlyIncomeVo,InsPlyIncome insPlyIncome) {
  855. if("1".equals(insPlyIncomeVo.getAgreementType())){ //平台
  856. // 平台 手续费 +跟单费 = 应收 手续费 = 手续费比例*保费 应收比例=手续费比例 + 跟单比例
  857. BigDecimal jqSuperviseCostsProportion = initializationBigdecimal(insPlyIncomeVo.getJqSuperviseCostsProportion());//交强手续费比例
  858. BigDecimal sySuperviseCostsProportion = initializationBigdecimal(insPlyIncomeVo.getSySuperviseCostsProportion()); //商业手续费比例
  859. BigDecimal noSuperviseCostsProportion = initializationBigdecimal(insPlyIncomeVo.getNoSuperviseCostsProportion()); //非车手续费比例
  860. BigDecimal jqOtherCostsProportion = initializationBigdecimal(insPlyIncomeVo.getJqOtherCostsProportion()); //交强跟单比例
  861. BigDecimal syOtherCostsProportion = initializationBigdecimal(insPlyIncomeVo.getSyOtherCostsProportion()); //商业跟单比例
  862. BigDecimal noOtherCostsProportion = initializationBigdecimal(insPlyIncomeVo.getNoOtherCostsProportion()); //非车跟单比例
  863. BigDecimal jqPremium = initializationBigdecimal(insPlyIncomeVo.getJqPremium()); //交强保费
  864. BigDecimal syPremium = initializationBigdecimal(insPlyIncomeVo.getSyPremium()); //商业保费
  865. BigDecimal noPremium = initializationBigdecimal(insPlyIncomeVo.getNoPremium()); //非车保费
  866. //手续费比例
  867. insPlyIncome.setCommissionFeerate(this.calculateTotal(jqSuperviseCostsProportion,sySuperviseCostsProportion,noSuperviseCostsProportion)); //手续费比例 = 商业手续费比例 + 交强手续费比例 + 非车手续费比例
  868. if(jqSuperviseCostsProportion !=null && jqPremium!=null ){
  869. insPlyIncome.setJqSuperviseCostsPremiums(this.algorithmAmount(jqPremium,jqSuperviseCostsProportion)); //交强手续费
  870. }
  871. if(sySuperviseCostsProportion !=null && syPremium !=null){
  872. insPlyIncome.setSySuperviseCostsPremiums(this.algorithmAmount(syPremium,sySuperviseCostsProportion)); //商业手续费
  873. }
  874. if(noSuperviseCostsProportion !=null && noPremium!=null){
  875. insPlyIncome.setNoSuperviseCostsPremiums(this.algorithmAmount(noPremium,noSuperviseCostsProportion)); //非车手续费
  876. }
  877. if(jqOtherCostsProportion !=null && jqPremium!=null ){
  878. insPlyIncome.setJqOtherCostsPremium(this.algorithmAmount(jqPremium,jqOtherCostsProportion)); //交强跟单费
  879. }
  880. if(syOtherCostsProportion !=null && syPremium !=null ){
  881. insPlyIncome.setSyOtherCostsPremium(this.algorithmAmount(syPremium,syOtherCostsProportion)); //商业跟单费
  882. }
  883. if(noOtherCostsProportion !=null && noPremium !=null){
  884. insPlyIncome.setNoOtherCostsPremium(this.algorithmAmount(noPremium,noOtherCostsProportion)); //非车跟单费
  885. }
  886. insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(),insPlyIncome.getSySuperviseCostsPremiums(),insPlyIncome.getNoSuperviseCostsPremiums())); //手续费
  887. insPlyIncome.setCommissionFeerate(this.calculateTotal(jqSuperviseCostsProportion,sySuperviseCostsProportion,noSuperviseCostsProportion)); //手续费比例
  888. insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(),insPlyIncome.getSyOtherCostsPremium(),insPlyIncome.getNoOtherCostsPremium())); //跟单费金额
  889. insPlyIncome.setOtherFeerate(this.calculateTotal(jqOtherCostsProportion,syOtherCostsProportion,noOtherCostsProportion)); //跟单费比例
  890. insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(),insPlyIncome.getOtherFeevalue(),null)); // 总费用 = 手续费+跟单费
  891. //应收比例 交强应收比例=交强手续费比例+交强非跟单比例
  892. insPlyIncome.setJqReceivableProportion(this.calculateTotal(jqSuperviseCostsProportion,jqOtherCostsProportion,null)); //交强应收
  893. insPlyIncome.setSyReceivableProportion(this.calculateTotal(sySuperviseCostsProportion,syOtherCostsProportion,null)); //商业应收
  894. insPlyIncome.setNoReceivableProportion(this.calculateTotal(noSuperviseCostsProportion,noOtherCostsProportion,null)); //非车应收
  895. }else {
  896. BigDecimal jqNoTaxPremium = insPlyIncomeVo.getJqNoTaxPremium();// 交强手续费 按照思路 交强不含税保费* 交强手续费比例 =交强手续费
  897. BigDecimal syNoTaxPremium = insPlyIncomeVo.getSyNoTaxPremium();// 商业手续费 按照思路 商业不含税保费* 商业手续费比例 =商业手续费
  898. BigDecimal noNoTaxPremium = insPlyIncomeVo.getNoNoTaxPremium();// 非车手续费 按照思路 非车不含税保费* 非车手续费比例 =非车手续费
  899. if(insPlyIncomeVo.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0){
  900. BigDecimal jqhandingFee = jqNoTaxPremium.multiply(insPlyIncomeVo.getJqSuperviseCostsProportion().divide(new BigDecimal(100)));
  901. insPlyIncome.setJqSuperviseCostsPremiums(jqhandingFee);
  902. }
  903. if(insPlyIncomeVo.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0){
  904. BigDecimal syhandingFee = syNoTaxPremium.multiply(insPlyIncomeVo.getSySuperviseCostsProportion().divide(new BigDecimal(100)));
  905. insPlyIncome.setSySuperviseCostsPremiums(syhandingFee);
  906. }
  907. if(insPlyIncomeVo.getNoSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0){
  908. BigDecimal nohandingFee = noNoTaxPremium.multiply(insPlyIncomeVo.getNoSuperviseCostsProportion().divide(new BigDecimal(100)));
  909. insPlyIncome.setNoSuperviseCostsPremiums(nohandingFee);
  910. }
  911. if(insPlyIncomeVo.getJqOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0){
  912. BigDecimal jqother = jqNoTaxPremium.multiply(insPlyIncomeVo.getJqOtherCostsProportion().divide(new BigDecimal(100)));//交强跟单费 按照思路 交强不含税保费* 交强跟单比例 = 交强跟单金额
  913. insPlyIncome.setJqOtherCostsPremium(jqother);
  914. }
  915. if(insPlyIncomeVo.getSyOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0){
  916. BigDecimal syother = syNoTaxPremium.multiply(insPlyIncomeVo.getSyOtherCostsProportion().divide(new BigDecimal(100)));//交强跟单费 按照思路 交强不含税保费* 交强跟单比例 = 交强跟单金额
  917. insPlyIncome.setSyOtherCostsPremium(syother);
  918. }
  919. if(insPlyIncomeVo.getNoOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0){
  920. BigDecimal syother = syNoTaxPremium.multiply(insPlyIncomeVo.getNoOtherCostsProportion().divide(new BigDecimal(100)));//非车跟单费 按照思路 非车不含税保费* 非车跟单比例 = 非车跟单金额
  921. insPlyIncome.setNoOtherCostsPremium(syother);
  922. }
  923. if("0".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())){ //保险 手续费 =不含税保费* 手续费比例
  924. insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getJqSuperviseCostsPremiums(),insPlyIncome.getSySuperviseCostsPremiums(),null)); // 手续费
  925. insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getJqSuperviseCostsProportion(),insPlyIncome.getSySuperviseCostsProportion(),null));//手续费比例
  926. insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(),null,null));//总金额
  927. }else if ("1".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())){ //保险跟单费 交强跟单+商业跟单
  928. insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getJqOtherCostsPremium(),insPlyIncome.getSyOtherCostsPremium(),null));
  929. insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getJqOtherCostsProportion(),insPlyIncome.getSyOtherCostsProportion(),null));
  930. insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getOtherFeevalue(),null,null));//总金额
  931. }
  932. if("0".equals(insPlyIncomeVo.getIsNotDocumentary()) && "1".equals(insPlyIncomeVo.getIsNotCar())){// 非车
  933. insPlyIncome.setCommissionFeevalue(this.calculateTotal(insPlyIncome.getNoSuperviseCostsPremiums(),null,null)); // 非车手续费
  934. insPlyIncome.setCommissionFeerate(this.calculateTotal(insPlyIncome.getNoSuperviseCostsProportion(),null,null)); //非车比例
  935. insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getCommissionFeevalue(),null,null));//总金额
  936. }else if ("1".equals(insPlyIncomeVo.getIsNotDocumentary()) && "1".equals(insPlyIncomeVo.getIsNotCar())){ //非车跟单
  937. insPlyIncome.setOtherFeevalue(this.calculateTotal(insPlyIncome.getNoOtherCostsPremium(),null,null)); //非车跟单金额
  938. insPlyIncome.setOtherFeerate(this.calculateTotal(insPlyIncome.getNoOtherCostsProportion(),null,null)); // 非车跟单比例
  939. insPlyIncome.setAllFeeValue(this.calculateTotal(insPlyIncome.getOtherFeevalue(),null,null));//总金额
  940. }
  941. }
  942. }
  943. /**
  944. *
  945. * @param value1 保费
  946. * @param value2 比例
  947. * @return 费用
  948. */
  949. private BigDecimal algorithmAmount(BigDecimal value1, BigDecimal value2) {
  950. return value1.multiply(value2.divide(new BigDecimal(100)));
  951. }
  952. private BigDecimal initializationBigdecimal(BigDecimal value) {
  953. return value != null ? value : BigDecimal.ZERO;
  954. }
  955. private void saveLog(InsPlyIncomeVo insPlyIncomeVo) {
  956. // 添加记录
  957. SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
  958. settlementDocumentaryLogEntity.setCrudStatus(insPlyIncomeVo.getCrudStatus());
  959. settlementDocumentaryLogEntity.setAmount(insPlyIncomeVo.getOtherFeevalue());
  960. settlementDocumentaryLogEntity.setSettlementDocumentaryId(insPlyIncomeVo.getId());
  961. settlementDocumentaryLogEntity.setAmountType("2");
  962. settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
  963. }
  964. @Override
  965. @Transactional
  966. public HttpResult<InsPlyIncome> insertByEntity(InsPlyIncomeVo insPlyIncomeVo) {
  967. Long id = new SnowFlakeUtil().nextId();
  968. InsPlyIncome insPlyIncome = new InsPlyIncome();
  969. insPlyIncomeVo.setOrderno(id.toString());
  970. BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
  971. insPlyIncome.setDocumentaryFeesStatus("0");
  972. insPlyIncome.setHandlingFeesStatus("0");
  973. insPlyIncome.setIsNotCar("0");
  974. insPlyIncome.setIsNotDocumentary("1");
  975. baseMapper.insert(insPlyIncome);
  976. insPlyIncomeVo.setId(insPlyIncome.getId());
  977. insPlyIncomeVo.setCrudStatus("1");
  978. this.saveLog(insPlyIncomeVo); //添加日志
  979. HashMap<String, Object> params = new HashMap<>();
  980. if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
  981. params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
  982. }
  983. params.put("isOther","1");
  984. if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
  985. params.put("year",insPlyIncomeVo.getYear());
  986. }
  987. if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
  988. params.put("companyId",insPlyIncomeVo.getCompanyId());
  989. }
  990. List<InsPlyIncome> list= this.baseMapper.NonSettlementQuery(params);
  991. if(!CollectionUtils.isEmpty(list)){
  992. for (InsPlyIncome item :list){
  993. return HttpResult.ok(item.getIds());
  994. }
  995. }
  996. return null;
  997. }
  998. @Override
  999. @Transactional
  1000. public HttpResult<InsPlyIncome> deleteById(InsPlyIncomeVo insPlyIncomeVo) {
  1001. HashMap<String, Object> params = new HashMap<>();
  1002. if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
  1003. params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
  1004. }
  1005. params.put("isOther","1");
  1006. if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
  1007. params.put("year",insPlyIncomeVo.getYear());
  1008. }
  1009. if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
  1010. params.put("companyId",insPlyIncomeVo.getCompanyId());
  1011. }
  1012. baseMapper.deleteById(insPlyIncomeVo.getId());
  1013. insPlyIncomeVo.setCrudStatus("3");
  1014. this.saveLog(insPlyIncomeVo);
  1015. List<InsPlyIncome> list = this.baseMapper.NonSettlementQuery(params);
  1016. if (!CollectionUtils.isEmpty(list)) {
  1017. for (InsPlyIncome item : list) {
  1018. return HttpResult.ok(item.getIds());
  1019. }
  1020. } else {
  1021. return HttpResult.ok(null);
  1022. }
  1023. return HttpResult.ok("删除成功");
  1024. }
  1025. @Override
  1026. @Transactional
  1027. public void uodateBalance(InsPlyIncomeVo insPlyIncomeVo) {
  1028. InsPlyIncome insPlyIncome = new InsPlyIncome();
  1029. insPlyIncomeVo.setHandlingFeesStatus("1");
  1030. insPlyIncomeVo.setSettlementTime(LocalDate.now());
  1031. BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
  1032. baseMapper.updateById(insPlyIncome);
  1033. // 生成记录
  1034. SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
  1035. if(StringUtils.isNotEmpty(insPlyIncomeVo.getAgreementType()) && "1".equals(insPlyIncomeVo.getAgreementType())){
  1036. // 只有平台协议 才会跟单费一笔结算
  1037. settlementDocumentaryLogEntity.setAmount(insPlyIncomeVo.getOtherFeevalue()); // 跟单费金额
  1038. }
  1039. settlementDocumentaryLogEntity.setHandingAmount(insPlyIncomeVo.getCommissionFeevalue()); // 手续费金额
  1040. settlementDocumentaryLogEntity.setSettlementDocumentaryId(insPlyIncomeVo.getId()); // 关联id
  1041. settlementDocumentaryLogEntity.setAmountType("1"); //手续费结算
  1042. settlementDocumentaryLogEntity.setCreateTime(new Date());
  1043. settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
  1044. }
  1045. @Override
  1046. @Transactional
  1047. public HttpResult<BasePageResult<InsPlyIncome>> totalQuery(InsPlyIncomeVo insPlyIncomeVo) {
  1048. HashMap<String, Object> params = new HashMap<>();
  1049. PageInfo<List<InsPlyIncome>> pageHelper = null;
  1050. if(insPlyIncomeVo.getStartDate()!=null){
  1051. params.put("startDate",insPlyIncomeVo.getStartDate().toString());
  1052. }
  1053. if(insPlyIncomeVo.getEndDate()!=null){
  1054. params.put("endDate",insPlyIncomeVo.getEndDate().toString());
  1055. }
  1056. if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
  1057. params.put("year",insPlyIncomeVo.getYear());
  1058. }
  1059. if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
  1060. params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
  1061. }
  1062. if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())){
  1063. params.put("isOther",insPlyIncomeVo.getIsNotDocumentary());
  1064. }
  1065. if(StringUtils.isNotEmpty(insPlyIncomeVo.getDocumentaryFeesStatus())){
  1066. params.put("documentaryFeesStatus",insPlyIncomeVo.getDocumentaryFeesStatus());
  1067. }
  1068. if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
  1069. params.put("companyId",insPlyIncomeVo.getCompanyId());
  1070. }
  1071. params.put("pageNum",insPlyIncomeVo.getPageNum());
  1072. params.put("pageSize",insPlyIncomeVo.getPageSize());
  1073. List<InsPlyIncome> list= this.baseMapper.totalQuery(params);
  1074. pageHelper=new PageInfo(list);
  1075. return HttpResult.ok(new BasePageResult<>(insPlyIncomeVo.getPageNum(), insPlyIncomeVo.getPageSize(), pageHelper.getTotal(), pageHelper.getPages(), list));
  1076. }
  1077. /**
  1078. *
  1079. * @param insPlyIncomeVo ids ins_ply_income 这个表的ids incomeIds settlement_documentary_fees 这个表的ids
  1080. * @return
  1081. */
  1082. /**
  1083. * 跟单费结算 有分批结算的情况
  1084. * @param insPlyIncomeVo
  1085. * @return
  1086. */
  1087. @Override
  1088. @Transactional
  1089. public HttpResult batchBalance(InsPlyIncomeVo insPlyIncomeVo) {
  1090. // 通过ids 查出跟单非结算单
  1091. BigDecimal allAmount = BigDecimal.ZERO;
  1092. // 分批结算
  1093. SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();
  1094. if ("0".equals(insPlyIncomeVo.getInvoicingMethod())) {
  1095. allAmount =insPlyIncomeVo.getInvoicCommissionFeevalue().multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100))));
  1096. settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getInvoicCommissionFeevalue().multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
  1097. settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount()); //进账金额
  1098. } else {
  1099. settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount()); //进账金额
  1100. }
  1101. settlementDocumentaryFeesVo.setInvoiceId(insPlyIncomeVo.getInvoicId()); //开票号
  1102. settlementDocumentaryFeesVo.setSettlementTime(insPlyIncomeVo.getSettlementTime()); //结算时间
  1103. settlementDocumentaryFeesVo.setSettlementStatus("2"); //2为结算状态
  1104. settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId()); // 保险公司id
  1105. settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId()); //合作公司id
  1106. settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算金额
  1107. settlementDocumentaryFeesVo.setIsNotCar(insPlyIncomeVo.getIsNotCar()); // 是否是非车
  1108. settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod()); //开票方式
  1109. settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints()); //税点
  1110. settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getExpendAmount()); //税点支出
  1111. settlementDocumentaryFeesVo.setHandlingFeesStatus(insPlyIncomeVo.getHandlingFeesStatus());
  1112. settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getInvoicCommissionFeevalue());
  1113. settlementDocumentaryFeesVo.setCreateTime(LocalDate.now());
  1114. settlementDocumentaryFeesVo.setParentId(insPlyIncomeVo.getId());
  1115. settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
  1116. return HttpResult.ok();
  1117. }
  1118. /**
  1119. *
  1120. * @param insPlyIncomeVo
  1121. * @return
  1122. */
  1123. @Override
  1124. public List<InsPlyIncome> totalBxAmount(InsPlyIncomeVo insPlyIncomeVo) {
  1125. HashMap<String, Object> params = new HashMap<>();
  1126. params=this.saveParams(insPlyIncomeVo,params);
  1127. params.remove("handlingFeesStatus");
  1128. List<InsPlyIncome> resultList = baseMapper.totalBxAmount(params);
  1129. // 数据库数据太多是 用sql拼接id会丢失 所以只能逻辑拼接
  1130. List<InsPlyIncome> idList=baseMapper.getIncomeIdList(params);
  1131. if(!CollectionUtils.isEmpty(idList) && !CollectionUtils.isEmpty(resultList)){
  1132. this.splicingIds(idList,resultList);
  1133. }
  1134. return resultList;
  1135. }
  1136. /**
  1137. *
  1138. * @param idList 要开票的数据集合
  1139. * @param resultList 总返回数据
  1140. */
  1141. private void splicingIds(List<InsPlyIncome> idList, List<InsPlyIncome> resultList) {
  1142. // 使用Map来存储agreementId到其id列表的映射
  1143. Map<String, List<String>> idMap = new HashMap<>();
  1144. for (InsPlyIncome idItem : idList) {
  1145. String partnerCompaniesId = idItem.getPartnerCompaniesId();
  1146. idMap.computeIfAbsent(partnerCompaniesId, k -> new ArrayList<>()).add(idItem.getId());
  1147. }
  1148. for (InsPlyIncome resultItem : resultList) {
  1149. List<String> ids = idMap.getOrDefault(resultItem.getPartnerCompaniesId(), Collections.emptyList());
  1150. String idsString = String.join(",", ids);
  1151. resultItem.setIds(idsString);
  1152. }
  1153. }
  1154. /**
  1155. *
  1156. * @param insPlyIncomeVo
  1157. * @return 保险手续费改成多次结算
  1158. */
  1159. @Override
  1160. @Transactional
  1161. public HttpResult<Object> batchInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
  1162. insPlyIncomeVo.setNoInvoicCommissionFeevalue(insPlyIncomeVo.getTotalAmount());
  1163. insPlyIncomeVo.setOtherFeevalue(insPlyIncomeVo.getTotalAmount());
  1164. insPlyIncomeVo.setHandlingFeesStatus("0"); // 0手续费 1 跟单费
  1165. insPlyIncomeVo.setIsNotCar(insPlyIncomeVo.getIsNotCar());
  1166. insPlyIncomeVo.setSettlementAmount(insPlyIncomeVo.getTotalAmount());
  1167. insPlyIncomeVo.setContractId(insPlyIncomeVo.getInvoicId());
  1168. this.batchInvoic(insPlyIncomeVo);
  1169. return HttpResult.ok();
  1170. }
  1171. @Override
  1172. public HttpResult<InsPlyIncome> queryInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
  1173. HashMap<String, Object> params = new HashMap<>();
  1174. params = this.saveParams(insPlyIncomeVo, params);
  1175. InsPlyIncome result= baseMapper.queryInvoicing(params); //总金额
  1176. params.put("handlingFeesStatus","0");
  1177. InsPlyIncome noResult= baseMapper.queryInvoicing(params); //未结算金额
  1178. result.setReadyCommissionFeevalue(noResult.getCommissionFeevalue());
  1179. return HttpResult.ok(result);
  1180. }
  1181. @Override
  1182. public HttpResult<Object> batchBxBalance(InsPlyIncomeVo insPlyIncomeVo) {
  1183. // 分批结算
  1184. SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();
  1185. if ("0".equals(insPlyIncomeVo.getInvoicingMethod())) {
  1186. settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getInvoicCommissionFeevalue().multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
  1187. settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount()); //进账金额
  1188. } else {
  1189. settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount()); //进账金额
  1190. }
  1191. settlementDocumentaryFeesVo.setInvoiceId(insPlyIncomeVo.getInvoicId()); //开票号
  1192. settlementDocumentaryFeesVo.setSettlementTime(insPlyIncomeVo.getSettlementTime()); //结算时间
  1193. settlementDocumentaryFeesVo.setSettlementStatus("2"); //2为结算状态
  1194. settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId()); // 保险公司id
  1195. settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId()); //合作公司id
  1196. settlementDocumentaryFeesVo.setIsNotCar(insPlyIncomeVo.getIsNotCar()); // 是否是非车
  1197. settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod()); //开票方式
  1198. settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints()); //税点
  1199. settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getExpendAmount()); //税点支出
  1200. settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getInvoicCommissionFeevalue());
  1201. settlementDocumentaryFeesVo.setHandlingFeesStatus("0");
  1202. settlementDocumentaryFeesVo.setParentId(insPlyIncomeVo.getId());
  1203. settlementDocumentaryFeesVo.setCreateTime(LocalDate.now());
  1204. settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
  1205. return HttpResult.ok();
  1206. }
  1207. @Override
  1208. public HttpResult<InsPlyIncome> querySettInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
  1209. HashMap<String, Object> params = new HashMap<>();
  1210. params = this.saveParams(insPlyIncomeVo, params);
  1211. InsPlyIncome insPlyIncome = baseMapper.queryInvoicing(params); //已经开票
  1212. return HttpResult.ok(insPlyIncome);
  1213. }
  1214. /**
  1215. *
  1216. * @param insPlyIncomeVo
  1217. * @return
  1218. */
  1219. @Override
  1220. public HttpResult<List<InsPlyIncome>> allOtherAmount(InsPlyIncomeVo insPlyIncomeVo) {
  1221. HashMap<String, Object> params = new HashMap<>();
  1222. params = this.saveParams(insPlyIncomeVo, params);
  1223. List<InsPlyIncome> result = baseMapper.allOtherAmount(params);
  1224. List<HashMap<String, Object>> otherIds = baseMapper.getOtherIds(params);
  1225. List<HashMap<String, Object>> invoicIds = settlementDocumentaryFeesService.getInvoicIds(params);
  1226. this.splicingOtherIds(result,otherIds,invoicIds );
  1227. return HttpResult.ok(result);
  1228. }
  1229. /**
  1230. *
  1231. * @param result 返回的数据
  1232. * @param otherIds ins_ply_income 跟单费
  1233. * @param invoicIds settlement_documentary_fees 开票ids
  1234. */
  1235. private void splicingOtherIds(List<InsPlyIncome> result, List<HashMap<String, Object>> otherIds, List<HashMap<String, Object>> invoicIds) {
  1236. // 创建两个映射来分别存储companyId到ids和setIncomeIds的映射
  1237. Map<String, List<String>> companyIdToIdsMap = new HashMap<>();
  1238. Map<String, List<String>> companyIdToSetIncomeIdsMap = new HashMap<>();
  1239. // 处理otherIds,填充companyId到ids的映射
  1240. for (HashMap<String, Object> idMap : otherIds) {
  1241. String partnerCompaniesId = (String) idMap.get("partnerCompaniesId");
  1242. String id = idMap.get("id").toString(); // 假设id是一个String,而不是List<String>
  1243. if (partnerCompaniesId != null && id != null) {
  1244. companyIdToIdsMap.computeIfAbsent(partnerCompaniesId, k -> new ArrayList<>()).add(id); // 将id添加到列表中
  1245. }
  1246. }
  1247. // 处理invoicIds,填充companyId到setIncomeIds的映射(假设结构相同)
  1248. for (HashMap<String, Object> idMap : invoicIds) {
  1249. String partnerCompaniesId = (String) idMap.get("partnerCompaniesId");
  1250. String setIncomeId = idMap.get("id").toString(); // 假设这里也是单个id,键名可能不同,例如"setIncomeId"
  1251. if (partnerCompaniesId != null && setIncomeId != null) {
  1252. companyIdToSetIncomeIdsMap.computeIfAbsent(partnerCompaniesId, k -> new ArrayList<>()).add(setIncomeId);
  1253. }
  1254. }
  1255. // 遍历result列表,为每个InsPlyIncome对象设置拼接后的ids和incomeIds
  1256. for (InsPlyIncome resultItem : result) {
  1257. String partnerCompaniesId = resultItem.getPartnerCompaniesId();
  1258. List<String> ids = companyIdToIdsMap.getOrDefault(partnerCompaniesId, Collections.emptyList());
  1259. List<String> setIncomeIds = companyIdToSetIncomeIdsMap.getOrDefault(partnerCompaniesId, Collections.emptyList());
  1260. // 合并ids和setIncomeIds(如果需要,可以先去重),但在此处我们直接拼接
  1261. String idsString = String.join(",", ids);
  1262. String incomeIdsString = String.join(",", setIncomeIds);
  1263. // 设置拼接后的ids和incomeIds到InsPlyIncome对象中
  1264. resultItem.setIds(idsString);
  1265. resultItem.setIncomeIds(incomeIdsString); // 假设InsPlyIncome有这个方法
  1266. }
  1267. }
  1268. @Override
  1269. @Transactional
  1270. public HttpResult<Object> batchInvoic(InsPlyIncomeVo insPlyIncomeVo) {
  1271. // 通过ids 查出跟单非结算单
  1272. String ids = insPlyIncomeVo.getIds();
  1273. // if(StringUtils.isNotEmpty(ids)){
  1274. // String[] split = ids.split(",");
  1275. // for (int i =0; i <split.length ; i++) {
  1276. // String id = split[i];
  1277. // InsPlyIncome insPlyIncome = baseMapper.selectById(id);
  1278. // insPlyIncome.setInvoicId(insPlyIncomeVo.getContractId()); // 开票号
  1279. // insPlyIncome.setContractFileId(insPlyIncomeVo.getContractFileId());
  1280. // insPlyIncome.setVoucherNumber(insPlyIncomeVo.getVoucherNumber());
  1281. // insPlyIncome.setSettlementTime(LocalDate.now());
  1282. // baseMapper.updateById(insPlyIncome);
  1283. // }
  1284. // }
  1285. SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo(); // 生成跟单费结算表
  1286. if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
  1287. settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
  1288. }
  1289. if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
  1290. settlementDocumentaryFeesVo.setYear(insPlyIncomeVo.getYear());
  1291. }
  1292. if(StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())){
  1293. settlementDocumentaryFeesVo.setMonth(insPlyIncomeVo.getMonth());
  1294. }
  1295. if(StringUtils.isNotEmpty(insPlyIncomeVo.getDay())){
  1296. settlementDocumentaryFeesVo.setDay(insPlyIncomeVo.getDay());
  1297. }
  1298. settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
  1299. settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId()); //合作公司id
  1300. settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getOtherFeevalue()); //其他费用金额
  1301. settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getNoInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算
  1302. settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());//已经开票
  1303. settlementDocumentaryFeesVo.setCreateTime(LocalDate.now());
  1304. settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIncomeIds());
  1305. settlementDocumentaryFeesVo.setSettlementStatus("1");
  1306. settlementDocumentaryFeesVo.setIsNotCar(insPlyIncomeVo.getIsNotCar());
  1307. if(StringUtils.isNotEmpty(insPlyIncomeVo.getContractId())){
  1308. settlementDocumentaryFeesVo.setInvoiceId(insPlyIncomeVo.getContractId()); //开票号
  1309. }
  1310. settlementDocumentaryFeesVo.setHandlingFeesStatus(insPlyIncomeVo.getHandlingFeesStatus());
  1311. settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod()); //开票方式
  1312. settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints()); //税点
  1313. // 税点支出
  1314. if(BigDecimalUtils.nullToZero(insPlyIncomeVo.getTaxPoints()) !=null && BigDecimalUtils.nullToZero(insPlyIncomeVo.getSettlementAmount()) !=null){
  1315. BigDecimal settlementAmount = insPlyIncomeVo.getSettlementAmount();
  1316. settlementDocumentaryFeesVo.setExpendAmount(settlementAmount.multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
  1317. }
  1318. return settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
  1319. }
  1320. @Override
  1321. public HttpResult pinHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
  1322. HashMap<String, Object> params = new HashMap<>();
  1323. params =this.saveParams(insPlyIncomeVo,params);
  1324. List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
  1325. ExportParams exportParams = new ExportParams("平台手续费", null, ExcelType.HSSF);
  1326. exportParams.setStyle(ExcelStyleUtil.class);
  1327. List<SettlementFeesExcel> resultList = new ArrayList<>();
  1328. for (InsPlyIncome item :insPlyIncomes){
  1329. SettlementFeesExcel bxSettlementFeesExcel = new SettlementFeesExcel();
  1330. BeanUtils.copyProperties(item, bxSettlementFeesExcel);
  1331. if("1".equals(item.getHandlingFeesStatus())){
  1332. bxSettlementFeesExcel.setHandlingFeesStatus("已结算");
  1333. }else {
  1334. bxSettlementFeesExcel.setHandlingFeesStatus("未结算");
  1335. }
  1336. resultList.add(bxSettlementFeesExcel);
  1337. }
  1338. String uploadPath = this.uploadPath + "/excel/";
  1339. Path path = Paths.get(uploadPath);
  1340. if (!Files.exists(path)) {
  1341. try {
  1342. Files.createDirectories(path);
  1343. } catch (IOException e) {
  1344. e.printStackTrace();
  1345. }
  1346. }
  1347. String fileName = EasyExcelUtils.downExcel(uploadPath, "平台手续费导出", SettlementFeesExcel.class, resultList);
  1348. return HttpResult.ok("",uploadUrl + "excel/" + fileName);
  1349. }
  1350. @Override
  1351. public HttpResult bxHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
  1352. HashMap<String, Object> params = new HashMap<>();
  1353. params =this.saveParams(insPlyIncomeVo,params);
  1354. List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
  1355. ExportParams exportParams = new ExportParams("保险手续费", null, ExcelType.HSSF);
  1356. exportParams.setStyle(ExcelStyleUtil.class);
  1357. List<BxSettlementFeesExcel> resultList = new ArrayList<>();
  1358. for (InsPlyIncome item :insPlyIncomes){
  1359. BxSettlementFeesExcel bxSettlementFeesExcel = new BxSettlementFeesExcel();
  1360. LocalDateTime signDate = item.getSignDate();
  1361. BeanUtils.copyProperties(item, bxSettlementFeesExcel);
  1362. resultList.add(bxSettlementFeesExcel);
  1363. }
  1364. String uploadPath = this.uploadPath + "/excel/";
  1365. Path path = Paths.get(uploadPath);
  1366. if (!Files.exists(path)) {
  1367. try {
  1368. Files.createDirectories(path);
  1369. } catch (IOException e) {
  1370. e.printStackTrace();
  1371. }
  1372. }
  1373. String fileName = EasyExcelUtils.downExcel(uploadPath, "保险手续费导出", BxSettlementFeesExcel.class, resultList);
  1374. return HttpResult.ok("",uploadUrl + "excel/" + fileName);
  1375. }
  1376. @Override
  1377. public HttpResult bxOtherExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
  1378. HashMap<String, Object> params = new HashMap<>();
  1379. params =this.saveParams(insPlyIncomeVo,params);
  1380. params.put("agreementType","2");
  1381. params.put("isOther","1");
  1382. params.put("isNotCar","0");
  1383. List<InsPlyIncome> insPlyIncomes = baseMapper.allOtherAmount(params);
  1384. ExportParams exportParams = new ExportParams("跟单费导出", null, ExcelType.HSSF);
  1385. exportParams.setStyle(ExcelStyleUtil.class);
  1386. List<BxOtherExcel> resultList = new ArrayList<>();
  1387. for (InsPlyIncome item :insPlyIncomes){
  1388. BxOtherExcel bxSettlementFeesExcel = new BxOtherExcel();
  1389. BeanUtils.copyProperties(item, bxSettlementFeesExcel);
  1390. resultList.add(bxSettlementFeesExcel);
  1391. }
  1392. String uploadPath = this.uploadPath + "/excel/";
  1393. Path path = Paths.get(uploadPath);
  1394. if (!Files.exists(path)) {
  1395. try {
  1396. Files.createDirectories(path);
  1397. } catch (IOException e) {
  1398. e.printStackTrace();
  1399. }
  1400. }
  1401. String fileName = EasyExcelUtils.downExcel(uploadPath, "跟单费导出", BxOtherExcel.class, resultList);
  1402. return HttpResult.ok("",uploadUrl + "excel/" + fileName);
  1403. }
  1404. @Override
  1405. public InsPlyIncome bxTotalAmount(InsPlyIncomeVo insPlyIncomeVo) {
  1406. HashMap<String, Object> params = new HashMap<>();
  1407. params = this.saveParams(insPlyIncomeVo, params);
  1408. InsPlyIncome totalledAmount =baseMapper.bxTotalAmount(params); //总金额
  1409. return totalledAmount;
  1410. }
  1411. }