InsPlyIncomeServiceImpl.java 68 KB

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