SysUserAccountServiceImpl.java 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496
  1. package com.ydtech.modules.admin.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  6. import com.ydtech.core.page.HttpResult;
  7. import com.ydtech.core.page.PageRequest;
  8. import com.ydtech.exception.SystemException;
  9. import com.ydtech.modules.admin.constants.MoneyAttrConstants;
  10. import com.ydtech.modules.admin.constants.WithdrawTypeConstants;
  11. import com.ydtech.modules.admin.dao.SysUserAccountMapper;
  12. import com.ydtech.modules.admin.dao.SysUserMapper;
  13. import com.ydtech.modules.admin.model.SysDept;
  14. import com.ydtech.modules.admin.model.SysUser;
  15. import com.ydtech.modules.admin.model.dto.*;
  16. import com.ydtech.modules.admin.model.po.*;
  17. import com.ydtech.modules.admin.model.vo.SubOrder;
  18. import com.ydtech.modules.admin.model.vo.SysUserAccountVo;
  19. import com.ydtech.modules.admin.model.vo.SysUserBaseVO;
  20. import com.ydtech.modules.admin.service.*;
  21. import com.ydtech.modules.admin.utils.SliceUpDateUtil;
  22. import com.ydtech.modules.base.controller.BaseController;
  23. import com.ydtech.modules.esm.service.EsmUserReferrerService;
  24. import com.ydtech.modules.message.constants.MessageTypeConstants;
  25. import com.ydtech.modules.message.service.MessageSecretaryService;
  26. import com.ydtech.modules.order.dao.InsAreaCompanyMapper;
  27. import com.ydtech.modules.order.dao.InsOrdersMapper;
  28. import com.ydtech.modules.order.dao.InsUploadFilesMapper;
  29. import com.ydtech.modules.order.entity.BasePageResult;
  30. import com.ydtech.modules.order.entity.InsOrders;
  31. import com.ydtech.modules.order.service.InsAreaCompanyService;
  32. import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
  33. import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
  34. import org.apache.commons.lang3.ObjectUtils;
  35. import org.apache.commons.lang3.StringUtils;
  36. import org.springframework.beans.BeanUtils;
  37. import org.springframework.beans.factory.annotation.Autowired;
  38. import org.springframework.stereotype.Service;
  39. import org.springframework.transaction.annotation.Transactional;
  40. import org.springframework.util.CollectionUtils;
  41. import java.math.BigDecimal;
  42. import java.text.SimpleDateFormat;
  43. import java.util.*;
  44. import java.util.stream.Collectors;
  45. /**
  46. * @author Administrator
  47. * @description 针对表【sys_user_account(用户账户表)】的数据库操作Service实现
  48. * @createDate 2024-03-05 11:52:30
  49. */
  50. @Service
  51. public class SysUserAccountServiceImpl extends ServiceImpl<SysUserAccountMapper, SysUserAccount> implements SysUserAccountService {
  52. @Autowired
  53. private SysUserAccountHistoryService sysUserAccountHistoryService;
  54. @Autowired
  55. private SysUserAccountService sysUserAccountService;
  56. @Autowired
  57. private EsmUserReferrerService esmUserReferrerService;
  58. @Autowired
  59. private SysAmountAuditingService sysAmountAuditingService;
  60. @Autowired
  61. private SysUserBankCardService sysUserBankCardService;
  62. @Autowired
  63. private InsAreaCompanyService insAreaCompanyService;
  64. @Autowired
  65. private InsFeeOrderNewService insFeeOrderNewService;
  66. @Autowired
  67. private InsOrdersMapper insOrdersMapper;
  68. @Autowired
  69. private MessageSecretaryService messageSecretaryService;
  70. @Autowired
  71. private InsAreaCompanyMapper insAreaCompanyMapper;
  72. @Autowired
  73. private SysUserService sysUserService;
  74. @Autowired
  75. private SysAmountAuditingHistoryService sysAmountAuditingHistoryService;
  76. @Autowired
  77. private SysUserMapper sysUserMapper;
  78. @Autowired
  79. private InsUploadFilesMapper insUploadFilesMapper;
  80. @Autowired
  81. private SysDeptService sysDeptService;
  82. @Override
  83. @Transactional
  84. public void addOrUpdate(SysUserAccount sysUserAccount) {
  85. //SysUserAccount newSysAccount = baseMapper.getById(sysUserAccount.getUserId());
  86. // 初始化
  87. if (sysUserAccount.getHandlingFee() == null) {
  88. sysUserAccount.setHandlingFee(BigDecimal.ZERO);
  89. }
  90. if (sysUserAccount.getDocumentary() == null) {
  91. sysUserAccount.setDocumentary(BigDecimal.ZERO);
  92. }
  93. if (sysUserAccount.getPromotion() == null) {
  94. sysUserAccount.setPromotion(BigDecimal.ZERO);
  95. }
  96. //添加总金额 = 手续费+跟单费+推广费
  97. BigDecimal sumAmount=BigDecimal.ZERO;
  98. sumAmount= sumAmount.add(sysUserAccount.getHandlingFee()==null?BigDecimal.ZERO:sysUserAccount.getHandlingFee())
  99. .add(sysUserAccount.getDocumentary()==null?BigDecimal.ZERO:sysUserAccount.getDocumentary())
  100. .add(sysUserAccount.getPromotion()==null?BigDecimal.ZERO:sysUserAccount.getPromotion());
  101. // 如果用户id有值则累加 没有则 新增
  102. String userId = sysUserAccount.getUserId();
  103. SysUserAccount sysUserAccountEntity = baseMapper.getById(userId);
  104. //SysUserAccount newAccount = new SysUserAccount();
  105. if (ObjectUtils.isNotEmpty(sysUserAccountEntity)) {
  106. sysUserAccountEntity.setHandlingFee(sysUserAccount.getHandlingFee().add(sysUserAccountEntity.getHandlingFee()));
  107. sysUserAccountEntity.setDocumentary(sysUserAccount.getDocumentary().add(sysUserAccountEntity.getDocumentary()));
  108. sysUserAccountEntity.setPromotion(sysUserAccount.getPromotion().add(sysUserAccountEntity.getPromotion()));
  109. if (StringUtils.isNotEmpty(sysUserAccount.getDocumentaryStatus())) {
  110. sysUserAccountEntity.setDocumentaryStatus(sysUserAccount.getDocumentaryStatus());
  111. }
  112. // add by hxl 2024-06-18 插入总金额
  113. sysUserAccountEntity.setSumAmount((sysUserAccountEntity.getSumAmount()==null?BigDecimal.ZERO:sysUserAccountEntity.getSumAmount()).add(sumAmount));
  114. baseMapper.updateById(sysUserAccountEntity);
  115. } else {
  116. sysUserAccountEntity = new SysUserAccount();
  117. sysUserAccountEntity.setUserId(userId);
  118. sysUserAccountEntity.setDocumentary(sysUserAccount.getDocumentary());
  119. sysUserAccountEntity.setPromotion(sysUserAccount.getPromotion());
  120. sysUserAccountEntity.setHandlingFee(sysUserAccount.getHandlingFee());
  121. BigDecimal zero = BigDecimal.ZERO;
  122. sysUserAccountEntity.setHandlingAmountAccount(zero);
  123. sysUserAccountEntity.setHandlingAmountWithdrawal(zero);
  124. sysUserAccountEntity.setHandlingAmountPayment(zero);
  125. sysUserAccountEntity.setDocumentaryAmountAccount(zero);
  126. sysUserAccountEntity.setDocumentaryAmountWithdrawal(zero);
  127. sysUserAccountEntity.setDocumentaryAmountpayment(zero);
  128. sysUserAccountEntity.setPromotionAmountWithdrawal(zero);
  129. sysUserAccountEntity.setPromotionAmountAccount(zero);
  130. sysUserAccountEntity.setPromotionAmountPayment(zero);
  131. sysUserAccountEntity.setSumAmount(zero);
  132. sysUserAccountEntity.setSumAmountWithdrawal(zero);
  133. sysUserAccountEntity.setSumAmountAccount(zero);
  134. sysUserAccountEntity.setSumAmountPayment(zero);
  135. sysUserAccountEntity.setCreateTime(new Date());
  136. if (StringUtils.isNotEmpty(sysUserAccount.getDocumentaryStatus())) {
  137. sysUserAccountEntity.setDocumentaryStatus(sysUserAccount.getDocumentaryStatus());
  138. }
  139. // add by hxl 2024-06-18 插入总金额
  140. sysUserAccountEntity.setSumAmount((sysUserAccountEntity.getSumAmount()==null?BigDecimal.ZERO:sysUserAccountEntity.getSumAmount()).add(sumAmount));
  141. baseMapper.insert(sysUserAccountEntity);
  142. }
  143. StringBuilder commissionMessage = new StringBuilder();
  144. BigDecimal beforeAmount;
  145. BigDecimal afterAmount;
  146. if (StringUtils.isNotEmpty(sysUserAccount.getDocumentaryStatus())) {
  147. //提现前的金额
  148. beforeAmount = sysUserAccountEntity.getSumAmount()==null?BigDecimal.ZERO:sysUserAccountEntity.getSumAmount();
  149. // 判断是否是一级二级三级
  150. SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory();
  151. sysUserAccountHistory.setUserId(sysUserAccount.getUserId());
  152. sysUserAccountHistory.setDocumentary(Integer.valueOf(sysUserAccount.getDocumentaryStatus()));
  153. sysUserAccountHistory.setSuborder(sysUserAccount.getSuborderId());
  154. sysUserAccountHistory.setCreateTime(new Date());
  155. //跟单费
  156. if (sysUserAccount.getDocumentary() != null && sysUserAccount.getDocumentary().compareTo(BigDecimal.ZERO) != 0) {
  157. sysUserAccountHistory.setAmount(sysUserAccount.getDocumentary());
  158. sysUserAccountHistory.setProperty(MoneyAttrConstants.M_2.getCode());
  159. commissionMessage.append(MoneyAttrConstants.M_2.getDesc() + ":" + sysUserAccount.getDocumentary() + "元 ");
  160. if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
  161. sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getDocumentary());
  162. }
  163. sysUserAccountHistory.setBusinessSegmentsType(1);
  164. sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
  165. }
  166. //手续费
  167. if (sysUserAccount.getHandlingFee() != null && sysUserAccount.getHandlingFee().compareTo(BigDecimal.ZERO) != 0) {
  168. sysUserAccountHistory.setId(null);
  169. sysUserAccountHistory.setAmount(sysUserAccount.getHandlingFee());
  170. sysUserAccountHistory.setProperty(MoneyAttrConstants.M_1.getCode());
  171. commissionMessage.append(MoneyAttrConstants.M_1.getDesc() + ":" + sysUserAccount.getHandlingFee() + "元 ");
  172. if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
  173. sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getHandlingFee());
  174. }
  175. sysUserAccountHistory.setBusinessSegmentsType(1);
  176. sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
  177. }
  178. //推广费
  179. if (sysUserAccount.getPromotion() != null && sysUserAccount.getPromotion().compareTo(BigDecimal.ZERO) != 0) {
  180. sysUserAccountHistory.setId(null);
  181. sysUserAccountHistory.setAmount(sysUserAccount.getPromotion());
  182. sysUserAccountHistory.setProperty(MoneyAttrConstants.M_3.getCode());
  183. commissionMessage.append(MoneyAttrConstants.M_3.getDesc() + ":" + sysUserAccount.getPromotion() + "元 ");
  184. if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
  185. //提现后的金额
  186. afterAmount = beforeAmount.subtract(sysUserAccount.getPromotion());
  187. sysUserAccountHistory.setSurplusAmount(afterAmount); //改变后金额
  188. sysUserAccountHistory.setUserAmount(beforeAmount); //改变前金额
  189. }
  190. sysUserAccountHistory.setBusinessSegmentsType(1);
  191. sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
  192. }
  193. //手续费+跟单费用
  194. BigDecimal amount_SX_GD=BigDecimal.ZERO;
  195. amount_SX_GD= amount_SX_GD.add(sysUserAccount.getHandlingFee()==null?BigDecimal.ZERO:sysUserAccount.getHandlingFee())
  196. .add(sysUserAccount.getDocumentary()==null?BigDecimal.ZERO:sysUserAccount.getDocumentary());
  197. //历史记录表添加手续费+跟单费用 add by hxl 2024-06-18
  198. if(amount_SX_GD.compareTo(BigDecimal.ZERO) != 0){
  199. sysUserAccountHistory.setId(null);
  200. sysUserAccountHistory.setAmount(amount_SX_GD);
  201. sysUserAccountHistory.setProperty(MoneyAttrConstants.M_4.getCode());
  202. if (WithdrawTypeConstants.WT_2.getCode().equals(sysUserAccount.getDocumentaryStatus())) { // 收入 相加
  203. afterAmount = beforeAmount.subtract(amount_SX_GD);
  204. sysUserAccountHistory.setSurplusAmount(afterAmount); //改变后金额
  205. sysUserAccountHistory.setUserAmount(beforeAmount); //改变前金额
  206. sysUserAccountHistory.setSurplusAmount(sysUserAccountEntity.getSumAmount());
  207. sysUserAccountHistory.setBusinessSegmentsType(1);
  208. sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
  209. }
  210. }
  211. }
  212. //添加佣金消息
  213. messageSecretaryService.addMessage(MessageTypeConstants.M_5,sysUserAccount.getUserId(),"你有一条佣金消息," + commissionMessage.toString());
  214. }
  215. @Override
  216. public BasePageResult<SysUserAccount> queryByVo(SysUserAccountVo sysUserAccountVo) {
  217. Page<SysUserAccount> page = new Page<>(sysUserAccountVo.getPageNum(), sysUserAccountVo.getPageSize());
  218. Page<SysUserAccount> sysUserAccountHistoryPage = baseMapper.queryPageOrder(sysUserAccountVo, page);
  219. return new BasePageResult<>(sysUserAccountVo.getPageNum(), page.getSize(), sysUserAccountHistoryPage.getTotal(), page.getPages(),
  220. sysUserAccountHistoryPage.getRecords());
  221. }
  222. //
  223. @Override
  224. public IPage<SysUserAccount> queryByVo1(SysUserAccountVo sysUserAccountVo) {
  225. PageRequest pageRequest = new PageRequest();
  226. pageRequest.setPageNum(sysUserAccountVo.getPageNum());
  227. pageRequest.setPageSize(sysUserAccountVo.getPageSize());
  228. List<SysUserAccount> sysUserAccountHistoryPage = baseMapper.queryPageOrder1(sysUserAccountVo);
  229. IPage ipage = PageRequest.buildPageRequest(pageRequest);
  230. ipage.setRecords(sysUserAccountHistoryPage.stream().skip((sysUserAccountVo.getPageNum() - 1) * sysUserAccountVo.getPageSize()).limit(sysUserAccountVo.getPageSize()).
  231. collect(Collectors.toList()));
  232. ipage.setTotal(sysUserAccountHistoryPage.size());
  233. return ipage;
  234. }
  235. @Override
  236. @Transactional
  237. public HttpResult<Object> inert(SysUserAccountVo sysUserAccountVo) {
  238. String userId = BaseController.getUser().getId();
  239. BigDecimal zero = BigDecimal.ZERO;
  240. BigDecimal beforeAmount;
  241. BigDecimal afterAmount;
  242. // 用户当前金额
  243. BigDecimal amount = sysUserAccountVo.getAmount();
  244. SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory(); // 记录
  245. sysUserAccountHistory.setDocumentary(1); // 1提现
  246. sysUserAccountHistory.setUserId(userId);
  247. sysUserAccountHistory.setProperty(6);
  248. sysUserAccountHistory.setBusinessSegmentsType(1);
  249. SysAmountAuditingEntity sysAmountAuditingEntity = new SysAmountAuditingEntity();//审核记录表
  250. sysAmountAuditingEntity.setUserId(userId);
  251. sysAmountAuditingEntity.setAmount(sysUserAccountVo.getAmount());
  252. sysUserAccountHistory.setCreateTime(new Date());
  253. // SysAmountAuditingEntity judge = sysAmountAuditingService.getByUserId(userId, sysUserAccountVo.getAmountStatus());
  254. // if (ObjectUtils.isNotEmpty(judge)) {
  255. // return HttpResult.ok("有未提现审核单据, 请审核完成之后再提现");
  256. // }
  257. // 通过银行卡id 查询卡包
  258. String fromBankCardId = sysUserAccountVo.getFromBankCardId();
  259. if (fromBankCardId != null) {
  260. // SysUserBankCard byId = sysUserBankCardService.getById(fromBankCardId);
  261. SysUserBankCard byId = sysUserBankCardService.getByBankNumber(fromBankCardId, userId);
  262. if (byId == null) {
  263. throw new SystemException("该卡未绑定此账号,或输入卡号错误,或该账号尚未审核通过,请检查");
  264. }
  265. byId.setIsDefault(1);
  266. sysAmountAuditingEntity.setBankNumber(byId.getBankNumber());
  267. sysUserAccountHistory.setFromBankCard(byId.getBankNumber());
  268. sysUserBankCardService.updateById(byId);
  269. }
  270. if (StringUtils.isNotEmpty(userId)) {
  271. SysUserAccount sysUserAccount = baseMapper.getById(userId);
  272. //if (StringUtils.isNotEmpty(sysUserAccountVo.getAmountStatus())) {
  273. //sysUserAccountHistory.setProperty(Integer.valueOf(sysUserAccountVo.getAmountStatus())); //金额类型
  274. /**
  275. if ("1".equals(sysUserAccountVo.getAmountStatus())) {
  276. // 用户当前费用金
  277. beforeAmount = sysUserAccount.getHandlingFee();
  278. afterAmount = beforeAmount.subtract(amount);
  279. sysUserAccount.setHandlingFee(afterAmount);
  280. sysUserAccount.setHandlingAmountPayment(sysUserAccount.getHandlingAmountPayment().add(amount));
  281. sysUserAccount.setHandlingAmountWithdrawal(sysUserAccount.getHandlingAmountWithdrawal().add(amount));
  282. } else if ("2".equals(sysUserAccountVo.getAmountStatus())) {
  283. // 用户当前 非跟单佣金
  284. beforeAmount = sysUserAccount.getDocumentary();
  285. afterAmount = beforeAmount.subtract(amount);
  286. sysUserAccount.setDocumentary(afterAmount);
  287. sysUserAccount.setDocumentaryAmountpayment(sysUserAccount.getDocumentaryAmountpayment().add(amount));
  288. sysUserAccount.setDocumentaryAmountWithdrawal(sysUserAccount.getDocumentaryAmountWithdrawal().add(amount));
  289. } else {
  290. beforeAmount = sysUserAccount.getPromotion();
  291. afterAmount = beforeAmount.subtract(amount);
  292. sysUserAccount.setPromotion(afterAmount);
  293. sysUserAccount.setPromotionAmountPayment(sysUserAccount.getPromotionAmountPayment().add(amount));
  294. sysUserAccount.setPromotionAmountWithdrawal(sysUserAccount.getPromotionAmountWithdrawal().add(amount));
  295. }
  296. **/
  297. //提现前的金额
  298. beforeAmount = sysUserAccount.getSumAmount()==null?BigDecimal.ZERO:sysUserAccount.getSumAmount();
  299. //提现后的金额
  300. afterAmount = beforeAmount.subtract(amount);
  301. sysUserAccount.setSumAmount(afterAmount);
  302. //支付中总金额 = 原先的支付金额 + 提现的金额
  303. sysUserAccount.setSumAmountPayment((sysUserAccount.getSumAmountPayment()==null?BigDecimal.ZERO:sysUserAccount.getSumAmountPayment()).add(amount));
  304. //提现的总金额 = 原先的提现总金额 + 提现的金额
  305. sysUserAccount.setSumAmountWithdrawal((sysUserAccount.getSumAmountWithdrawal()==null?BigDecimal.ZERO:sysUserAccount.getSumAmountWithdrawal().add(amount)));
  306. // 用户相差
  307. if (beforeAmount.compareTo(zero) == 0 || afterAmount.compareTo(zero) < 0) {
  308. return HttpResult.ok("余额不足");
  309. }
  310. sysUserAccountHistory.setAmount(amount); // 金额
  311. sysUserAccountHistory.setSurplusAmount(afterAmount); // 剩余金额
  312. sysUserAccountHistory.setUserAmount(beforeAmount); // 用户剩余金额
  313. sysAmountAuditingEntity.setCreateTime(new Date());
  314. sysAmountAuditingEntity.setAuditingStatus("2"); // 2 为待审核 3 审核通过
  315. // sysAmountAuditingEntity.setAmountStatus(sysUserAccountVo.getAmountStatus());
  316. // 新增金额记录
  317. sysAmountAuditingService.save(sysAmountAuditingEntity);
  318. sysUserAccountHistory.setAuditiingId(sysAmountAuditingEntity.getId());
  319. sysUserAccountService.updateById(sysUserAccount);
  320. sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
  321. // }
  322. // 提现审核插入轨迹表 待审核数据 和审核处理中的数据
  323. // Calendar calendar = Calendar.getInstance();
  324. Date date = new Date();
  325. //calendar.add(Calendar.MINUTE, 1);
  326. // Date afterDate = calendar.getTime();
  327. SysAmountAuditingHistory sysAmountAuditingHistory =new SysAmountAuditingHistory(null, sysAmountAuditingEntity.getId(), amount, userId,date,"1", "1",sysUserAccountHistory.getId());
  328. SysAmountAuditingHistory sysAmountAuditingHistoryTwo =new SysAmountAuditingHistory(null, sysAmountAuditingEntity.getId(), amount, userId,date, "2", "1",sysUserAccountHistory.getId());
  329. sysAmountAuditingHistoryService.save(sysAmountAuditingHistory);
  330. sysAmountAuditingHistoryService.save(sysAmountAuditingHistoryTwo);
  331. }
  332. return HttpResult.ok("提现成功,等待审核");
  333. }
  334. /**
  335. * @version
  336. * @author: hxl
  337. * @Date: 2024/6/18 17:30
  338. * @Description: 提现修改为总金额
  339. */
  340. @Override
  341. @Transactional
  342. public HttpResult withdraw(SysUserAccountVo sysUserAccountVo) {
  343. String userId = sysUserAccountVo.getUserId();
  344. BigDecimal zero = BigDecimal.ZERO;
  345. BigDecimal beforeAmount;
  346. BigDecimal afterAmount;
  347. // 用户当前金额
  348. BigDecimal amount = sysUserAccountVo.getAmount();
  349. SysUserAccountHistory sysUserAccountHistory = new SysUserAccountHistory(); // 记录
  350. sysUserAccountHistory.setDocumentary(1); // 1支出
  351. sysUserAccountHistory.setUserId(userId);
  352. sysUserAccountHistory.setProperty(6); //3提现
  353. sysUserAccountHistory.setBusinessSegmentsType(1);
  354. SysAmountAuditingEntity sysAmountAuditingEntity = new SysAmountAuditingEntity();//审核记录表
  355. sysAmountAuditingEntity.setUserId(userId);
  356. sysAmountAuditingEntity.setAmount(sysUserAccountVo.getAmount());
  357. sysUserAccountHistory.setCreateTime(new Date());
  358. // SysAmountAuditingEntity judge = sysAmountAuditingService.getByUserId(userId, sysUserAccountVo.getAmountStatus());
  359. // if (ObjectUtils.isNotEmpty(judge)) {
  360. // throw new SystemException("有未提现审核单据, 请审核完成之后再提现");
  361. // }
  362. // 通过银行卡id 查询卡包
  363. String fromBankCardId = sysUserAccountVo.getFromBankCardId();
  364. SysUserBankCard byId = sysUserBankCardService.getByBankNumber(fromBankCardId, userId);
  365. if (byId == null) {
  366. throw new SystemException("该卡未绑定此账号,或输入卡号错误,或该账号尚未审核通过,请检查");
  367. }
  368. if (fromBankCardId != null && byId.getUserId().equals(userId)) {
  369. byId.setIsDefault(1);
  370. sysAmountAuditingEntity.setBankNumber(byId.getBankNumber());
  371. sysUserAccountHistory.setFromBankCard(byId.getBankNumber());
  372. sysUserBankCardService.updateById(byId);
  373. }
  374. if (StringUtils.isNotEmpty(userId)) {
  375. SysUserAccount sysUserAccount = baseMapper.getById(userId);
  376. //if (StringUtils.isNotEmpty(sysUserAccountVo.getAmountStatus())) {
  377. //sysUserAccountHistory.setProperty(Integer.valueOf(sysUserAccountVo.getAmountStatus())); //金额类型
  378. //注释掉类型提现,直接提现总金额
  379. /**
  380. if ("1".equals(sysUserAccountVo.getAmountStatus())) {
  381. // 用户当前费用金
  382. beforeAmount = sysUserAccount.getHandlingFee();
  383. afterAmount = beforeAmount.subtract(amount);
  384. sysUserAccount.setHandlingFee(afterAmount);
  385. sysUserAccount.setHandlingAmountPayment(sysUserAccount.getHandlingAmountPayment().add(amount));
  386. sysUserAccount.setHandlingAmountWithdrawal(sysUserAccount.getHandlingAmountWithdrawal().add(amount));
  387. } else if ("2".equals(sysUserAccountVo.getAmountStatus())) {
  388. // 用户当前 非跟单佣金
  389. beforeAmount = sysUserAccount.getDocumentary();
  390. afterAmount = beforeAmount.subtract(amount);
  391. sysUserAccount.setDocumentary(afterAmount);
  392. sysUserAccount.setDocumentaryAmountpayment(sysUserAccount.getDocumentaryAmountpayment().add(amount));
  393. sysUserAccount.setDocumentaryAmountWithdrawal(sysUserAccount.getDocumentaryAmountWithdrawal().add(amount));
  394. } else {
  395. beforeAmount = sysUserAccount.getPromotion();
  396. afterAmount = beforeAmount.subtract(amount);
  397. sysUserAccount.setPromotion(afterAmount);
  398. sysUserAccount.setPromotionAmountPayment(sysUserAccount.getPromotionAmountPayment().add(amount));
  399. sysUserAccount.setPromotionAmountWithdrawal(sysUserAccount.getPromotionAmountWithdrawal().add(amount));
  400. }
  401. **/
  402. //提现前的金额
  403. beforeAmount = sysUserAccount.getSumAmount()==null?BigDecimal.ZERO:sysUserAccount.getSumAmount();
  404. //提现后的金额
  405. afterAmount = beforeAmount.subtract(amount);
  406. sysUserAccount.setSumAmount(afterAmount);
  407. //支付中总金额 = 原先的支付金额 + 提现的金额
  408. sysUserAccount.setSumAmountPayment((sysUserAccount.getSumAmountPayment()==null?BigDecimal.ZERO:sysUserAccount.getSumAmountPayment()).add(amount));
  409. //提现的总金额 = 原先的提现总金额 + 提现的金额
  410. sysUserAccount.setSumAmountWithdrawal((sysUserAccount.getSumAmountWithdrawal()==null?BigDecimal.ZERO:sysUserAccount.getSumAmountWithdrawal().add(amount)));
  411. // 用户相差
  412. if (beforeAmount.compareTo(zero) == 0 || afterAmount.compareTo(zero) < 0) {
  413. return HttpResult.error("余额不足");
  414. }
  415. sysUserAccountHistory.setAmount(amount); // 金额
  416. sysUserAccountHistory.setSurplusAmount(afterAmount); // 剩余金额
  417. sysUserAccountHistory.setUserAmount(beforeAmount); // 用户剩余金额
  418. sysAmountAuditingEntity.setCreateTime(new Date());
  419. sysAmountAuditingEntity.setAuditingStatus("2"); // 2 为待审核 3 审核通过
  420. sysAmountAuditingEntity.setAmountStatus(sysUserAccountVo.getAmountStatus());
  421. // 新增金额记录
  422. sysAmountAuditingService.save(sysAmountAuditingEntity);
  423. sysUserAccountHistory.setAuditiingId(sysAmountAuditingEntity.getId());
  424. sysUserAccountService.updateById(sysUserAccount);
  425. sysUserAccountHistoryService.updayteByUserAccount(sysUserAccountHistory);
  426. //}
  427. // 提现审核插入轨迹表 待审核数据 和审核处理中的数据
  428. Calendar calendar = Calendar.getInstance();
  429. Date date = calendar.getTime();
  430. calendar.add(Calendar.MINUTE, 1);
  431. Date afterDate = calendar.getTime();
  432. SysAmountAuditingHistory sysAmountAuditingHistory =new SysAmountAuditingHistory(null, sysAmountAuditingEntity.getId(), amount, userId,date,"1", "1",sysUserAccountHistory.getId());
  433. SysAmountAuditingHistory sysAmountAuditingHistoryTwo =new SysAmountAuditingHistory(null, sysAmountAuditingEntity.getId(), amount, userId,afterDate, "2", "1",sysUserAccountHistory.getId());
  434. sysAmountAuditingHistoryService.save(sysAmountAuditingHistory);
  435. sysAmountAuditingHistoryService.save(sysAmountAuditingHistoryTwo);
  436. }
  437. return HttpResult.ok("提现成功,等待审核");
  438. }
  439. @Override
  440. public SysUserAccount getSysUserAmount(String userid) {
  441. SysUserAccount sysUserAccount = baseMapper.getById(userid);
  442. return sysUserAccount;
  443. }
  444. /**
  445. * @version
  446. * @author: hxl
  447. * @Date: 2024/6/11 16:05
  448. * @Description: 注释掉实收的总金额提升查询效率
  449. */
  450. @Override
  451. public SysUserAccountVo getSysAllAmount(String userId) {
  452. SysUserAccountVo sysUserAccountVo = new SysUserAccountVo();
  453. SysUserAccount sysUserAccount = baseMapper.getById(userId);
  454. // 验证账户信息是否有值
  455. if (ObjectUtils.isEmpty(sysUserAccount)) {
  456. return sysUserAccountVo;
  457. }
  458. BeanUtils.copyProperties(sysUserAccount, sysUserAccountVo);
  459. BigDecimal willHalding = BigDecimal.ZERO; //预收手续费佣金
  460. BigDecimal willDocumentary = BigDecimal.ZERO; //预收 非跟单佣金
  461. BigDecimal willPromotion = BigDecimal.ZERO; //预收 推广
  462. //BigDecimal receivedWillHalding = BigDecimal.ZERO; //实收手续费佣金
  463. // BigDecimal receivedWillDocumentary = BigDecimal.ZERO; //实收非跟单佣金
  464. // BigDecimal receivedWillPromotion = BigDecimal.ZERO; //实收推广费
  465. // 预收手续费佣金
  466. willPromotion = this.willPromotionAll(willPromotion, userId,"1");
  467. // 实收手续费佣金
  468. //receivedWillPromotion = this.willPromotionAll(willPromotion, userId,"2");
  469. // add by hxl 修改sql 添加承保状态和不在审核表中的条件 begin ===============
  470. List<InsFeeOrderNew> willList = insFeeOrderNewService.getByUserIdAndOrderStatusAndNoCheckType(userId,"1");
  471. //List<InsFeeOrderNew> willListnew = insFeeOrderNewService.getByUserIdAndOrderStatusAndNoCheckType(userId,"2");
  472. if (!CollectionUtils.isEmpty(willList)) {
  473. for (InsFeeOrderNew item : willList) {
  474. if (ObjectUtils.isNotEmpty(item)) {
  475. //1.预收手续费佣金 2. 预收非跟单佣金
  476. willHalding = willHalding.add(this.willAmountNew(item,1));
  477. willDocumentary = willDocumentary.add(this.willAmountNew(item,2));
  478. }
  479. }
  480. }
  481. /**
  482. if (!CollectionUtils.isEmpty(willListnew)) {
  483. for (InsFeeOrderNew item : willListnew) {
  484. if (ObjectUtils.isNotEmpty(item)) {
  485. //1.实收手续费佣金 2. 实收非跟单佣金
  486. receivedWillHalding = willHalding.add(this.willAmountNew(item,1));
  487. receivedWillDocumentary = willDocumentary.add(this.willAmountNew(item,2));
  488. }
  489. }
  490. }
  491. **/
  492. //预收手续费佣金
  493. sysUserAccountVo.setWillHalding(willHalding);
  494. //预收非跟单佣金
  495. sysUserAccountVo.setWillDocumentary(willDocumentary);
  496. //实收手续费佣金
  497. //sysUserAccountVo.setReceivedWillHalding(receivedWillHalding);
  498. //实收非跟单佣金
  499. //sysUserAccountVo.setReceivedWillDocumentary(receivedWillDocumentary);
  500. //提现现中 手续费、非跟单、推广费
  501. HashMap<String, Object> params = new HashMap<>();
  502. params.put("auditingStatus", "2"); // 待审核
  503. params.put("userId", userId);
  504. List<SysAmountAuditingEntity> sysAmountAuditingProgressIng = sysAmountAuditingService.getProgressIng(params);
  505. this.judge(sysAmountAuditingProgressIng, sysUserAccountVo);
  506. params.clear();
  507. params.put("auditingStatus", "3"); // 已审核审核
  508. params.put("userId", userId);
  509. //已提现 手续费、非跟单、推广费
  510. List<SysAmountAuditingEntity> sysAmountAuditingApproved = sysAmountAuditingService.getProgressIng(params);
  511. this.judgeSysAmountAuditing(sysAmountAuditingApproved, sysUserAccountVo);
  512. //预收手续费佣金
  513. sysUserAccountVo.setWillPromotion(willPromotion);
  514. //实收手续费佣金
  515. // sysUserAccountVo.setReceivedWillPromotion(receivedWillPromotion);
  516. return sysUserAccountVo;
  517. }
  518. @Override
  519. public SysUserAccountVo getInsOrders(SysUserAccountVo sysUserAccountVo) {
  520. ArrayList<InsFeeOrderNew> resultList = new ArrayList<>();
  521. HashMap<String, Object> params = new HashMap<>();
  522. params.put("userId", BaseController.getUser().getId());
  523. //日期
  524. params.put("timeFiltering", sysUserAccountVo.getTimeFiltering());
  525. //1预收2.实收
  526. params.put("type",sysUserAccountVo.getSearchType());
  527. sysUserAccountVo.setInsFeeOrderNewList(null);
  528. //金额类型 1. 手续费金额 2. 跟单金额 3. 推广金额
  529. if ("3".equals(sysUserAccountVo.getAmountType())) {
  530. List<InsFeeOrderNew> sumWillAmountGeneralization = insFeeOrderNewService.getSumWillAmountGeneralizationNew(params);
  531. sysUserAccountVo.setInsFeeOrderNewList(sumWillAmountGeneralization);
  532. } else {
  533. List<InsFeeOrderNew> resultInsFeeOrderNew = insFeeOrderNewService.getSumWillAmountNew(params);
  534. if (resultInsFeeOrderNew!=null && resultInsFeeOrderNew.size()>0) {
  535. for (InsFeeOrderNew item : resultInsFeeOrderNew) {
  536. BigDecimal willPromotion = BigDecimal.ZERO;
  537. if ("1".equals(sysUserAccountVo.getAmountType())) {
  538. //手续费出口预收
  539. willPromotion = willPromotion.add(item.getJqExportSuperviseCostsPremiums()).add(item.getSyExportSuperviseCostsPremiums()).add(item.getNoExportSuperviseCostsPremiums());
  540. } else if ("2".equals(sysUserAccountVo.getAmountType())) {
  541. willPromotion = willPromotion.add(item.getJqExportOtherCostsPremiums()).add(item.getSyExportOtherCostsPremiums()).add(item.getNoExportOtherCostsPremiums());
  542. }
  543. item.setWillAmount(willPromotion);
  544. if (willPromotion.compareTo(BigDecimal.ZERO) != 0) {
  545. resultList.add(item);
  546. }
  547. }
  548. sysUserAccountVo.setInsFeeOrderNewList(resultList);
  549. }
  550. }
  551. return sysUserAccountVo;
  552. }
  553. private void getWillAmount(InsFeeOrderNew insFeeOrderNew) {
  554. if (ObjectUtils.isNotEmpty(insFeeOrderNew)) {
  555. //交强手续费出口比例
  556. BigDecimal jqExportProceduresFee =
  557. insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqSuperviseCostsProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
  558. //商业手续费出口比例
  559. BigDecimal syExportProceduresFee =
  560. insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSySuperviseCostsProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
  561. //非车手续费出口比例
  562. BigDecimal noExportProceduresFee =
  563. insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoSuperviseCostsProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
  564. //非车出口比例
  565. //总机构 交强管理比例
  566. BigDecimal sumJqDeptProportion = insFeeOrderNew.getJqDeptProportionLevel1()
  567. .add(insFeeOrderNew.getJqDeptProportionLevel2())
  568. .add(insFeeOrderNew.getJqDeptProportionLevel3())
  569. .add(insFeeOrderNew.getJqDeptProportionLevel4())
  570. .add(insFeeOrderNew.getJqDeptProportionLevel5());
  571. //总机构 商业管理比例
  572. BigDecimal sumSyDeptProportion = insFeeOrderNew.getSyDeptProportionLevel1()
  573. .add(insFeeOrderNew.getSyDeptProportionLevel2())
  574. .add(insFeeOrderNew.getSyDeptProportionLevel3())
  575. .add(insFeeOrderNew.getSyDeptProportionLevel4())
  576. .add(insFeeOrderNew.getSyDeptProportionLevel5());
  577. //总机构 非车管理比例
  578. BigDecimal sumNoDeptProportion = insFeeOrderNew.getNoDeptProportionLevel1()
  579. .add(insFeeOrderNew.getNoDeptProportionLevel2())
  580. .add(insFeeOrderNew.getNoDeptProportionLevel3())
  581. .add(insFeeOrderNew.getNoDeptProportionLevel4())
  582. .add(insFeeOrderNew.getNoDeptProportionLevel5());
  583. BigDecimal noExportProceduresProportion = new BigDecimal(0);
  584. //总分销比例
  585. BigDecimal sumRetail =
  586. insFeeOrderNew.getFirstDetailProportion().add(insFeeOrderNew.getSecondDetailProportion()).add(insFeeOrderNew.getThirdDetailProportion());
  587. if (insFeeOrderNew.getNoCostsProportion().compareTo(sumNoDeptProportion.add(sumRetail)) > 0) {
  588. noExportProceduresProportion = insFeeOrderNew.getNoCostsProportion().subtract(sumNoDeptProportion).subtract(sumRetail);
  589. }
  590. //商业出口比例
  591. BigDecimal syExportProceduresProportion = new BigDecimal(0);
  592. if (insFeeOrderNew.getSyCostsProportion().compareTo(sumSyDeptProportion.add(sumRetail)) > 0) {
  593. syExportProceduresProportion = insFeeOrderNew.getSyCostsProportion().subtract(sumSyDeptProportion).subtract(sumRetail);
  594. }
  595. //交强出口比例
  596. BigDecimal jqExportProceduresProportion = new BigDecimal(0);
  597. if (insFeeOrderNew.getJqCostsProportion().compareTo(sumJqDeptProportion.add(sumRetail)) > 0) {
  598. jqExportProceduresProportion = insFeeOrderNew.getJqCostsProportion().subtract(sumJqDeptProportion).subtract(sumRetail);
  599. }
  600. //交强跟单出口费用
  601. BigDecimal jqExportOtherFee = insFeeOrderNew.getJqPremium()
  602. .multiply(jqExportProceduresProportion
  603. .subtract(insFeeOrderNew.getJqSuperviseCostsProportion()).divide(new BigDecimal(100))).setScale(2,
  604. BigDecimal.ROUND_DOWN);
  605. //商业跟单出口比例
  606. BigDecimal syExportOtherFee = insFeeOrderNew.getSyPremium()
  607. .multiply(syExportProceduresProportion
  608. .subtract(insFeeOrderNew.getSySuperviseCostsProportion()).divide(new BigDecimal(100))).setScale(2,
  609. BigDecimal.ROUND_DOWN);
  610. //非车跟单出口比例
  611. BigDecimal noExportOtherFee = insFeeOrderNew.getNoPremium()
  612. .multiply(noExportProceduresProportion
  613. .subtract(insFeeOrderNew.getNoSuperviseCostsProportion()).divide(new BigDecimal(100))).setScale(2,
  614. BigDecimal.ROUND_DOWN);
  615. if (StringUtils.isNotEmpty(insFeeOrderNew.getAmountType())) {
  616. if ("1".equals(insFeeOrderNew.getAmountType())) {
  617. //用户出口手续费
  618. insFeeOrderNew.setWillAmount(jqExportProceduresFee.add(syExportProceduresFee).add(noExportProceduresFee));
  619. }
  620. if ("2".equals(insFeeOrderNew.getAmountType())) {
  621. //用户出口跟单费
  622. insFeeOrderNew.setWillAmount(jqExportOtherFee.add(syExportOtherFee).add(noExportOtherFee));
  623. }
  624. }
  625. }
  626. }
  627. private BigDecimal getWillPromotion(InsFeeOrderNew insFeeOrderNew, BigDecimal willPromotion) {
  628. InsOrders InsOrders = insAreaCompanyService.selectByInFeeOrderNew(insFeeOrderNew);
  629. if (ObjectUtils.isNotEmpty(InsOrders)) {
  630. BigDecimal willFirstPremiums = ObjectUtils.defaultIfNull(InsOrders.getWillFirstPremiums(), BigDecimal.ZERO);
  631. // 累加保费
  632. willPromotion = willPromotion.add(willFirstPremiums);
  633. }
  634. return willPromotion;
  635. }
  636. private void judgeSysAmountAuditing(List<SysAmountAuditingEntity> sysAmountAuditingApproved, SysUserAccountVo sysUserAccountVo) {
  637. if (!CollectionUtils.isEmpty(sysAmountAuditingApproved)) {
  638. for (SysAmountAuditingEntity item : sysAmountAuditingApproved) {
  639. if ("1".equals(item.getAmountStatus())) { //手续费
  640. BigDecimal amount = item.getAmount();
  641. sysUserAccountVo.setApprovedHalding(amount);
  642. }
  643. if ("2".equals(item.getAmountStatus())) { //非跟单
  644. BigDecimal amount = item.getAmount();
  645. sysUserAccountVo.setApprovedDocumentary(amount);
  646. }
  647. if ("3".equals(item.getAmountStatus())) { //推广费
  648. BigDecimal amount = item.getAmount();
  649. sysUserAccountVo.setApprovedPromotion(amount);
  650. }
  651. }
  652. }
  653. }
  654. private void judge(List<SysAmountAuditingEntity> sysAmountAuditingProgressIng, SysUserAccountVo sysUserAccountVo) {
  655. if (!CollectionUtils.isEmpty(sysAmountAuditingProgressIng)) {
  656. for (SysAmountAuditingEntity item : sysAmountAuditingProgressIng) {
  657. if ("1".equals(item.getAmountStatus())) { //手续费
  658. BigDecimal amount = item.getAmount();
  659. sysUserAccountVo.setWithdrawalHalding(amount);
  660. }
  661. if ("2".equals(item.getAmountStatus())) { //非跟单
  662. BigDecimal amount = item.getAmount();
  663. sysUserAccountVo.setWithdrawalDocumentary(amount);
  664. }
  665. if ("3".equals(item.getAmountStatus())) { //推广费
  666. BigDecimal amount = item.getAmount();
  667. sysUserAccountVo.setWithdrawalPromotion(amount);
  668. }
  669. }
  670. }
  671. }
  672. private BigDecimal willPromotion(BigDecimal willPromotion, String userId) {
  673. InsFeeOrderNew insFeeOrderNew = new InsFeeOrderNew();
  674. insFeeOrderNew.setUserId(userId);
  675. InsOrders InsOrders = insAreaCompanyService.selectByInFeeOrderNew(insFeeOrderNew);
  676. if (ObjectUtils.isNotEmpty(InsOrders)) {
  677. BigDecimal willFirstPremiums = ObjectUtils.defaultIfNull(InsOrders.getWillFirstPremiums(), BigDecimal.ZERO);
  678. // 累加保费
  679. willPromotion = willPromotion.add(willFirstPremiums);
  680. }
  681. return willPromotion;
  682. }
  683. private void willAmount(InsFeeOrderNew insFeeOrderNew, BigDecimal willHalding, BigDecimal willDocumentary,
  684. SysUserAccountVo sysUserAccountVo) {
  685. if (ObjectUtils.isNotEmpty(insFeeOrderNew)) {
  686. //交强手续费
  687. BigDecimal jqExportProceduresFee = insFeeOrderNew.getJqExportSuperviseCostsPremiums();
  688. //商业手续费
  689. BigDecimal syExportProceduresFee = insFeeOrderNew.getSyExportSuperviseCostsPremiums();
  690. //非车手续费
  691. BigDecimal noExportProceduresFee = insFeeOrderNew.getNoExportSuperviseCostsPremiums();
  692. if (sysUserAccountVo.getWillHalding() == null) {
  693. sysUserAccountVo.setWillHalding(BigDecimal.ZERO);
  694. }
  695. sysUserAccountVo.setWillHalding(sysUserAccountVo.getWillHalding().add(jqExportProceduresFee).add(syExportProceduresFee).add(noExportProceduresFee));
  696. //交强跟单出口费用
  697. BigDecimal jqExportOtherCostsPremiums = insFeeOrderNew.getJqExportOtherCostsPremiums();
  698. //商业跟单出口费用
  699. BigDecimal syExportOtherCostsPremiums = insFeeOrderNew.getSyExportOtherCostsPremiums();
  700. //非车跟单出口费用
  701. BigDecimal noExportOtherCostsPremiums = insFeeOrderNew.getNoExportOtherCostsPremiums();
  702. //用户出口跟单费
  703. if (sysUserAccountVo.getWillDocumentary() == null) {
  704. sysUserAccountVo.setWillDocumentary(BigDecimal.ZERO);
  705. }
  706. sysUserAccountVo.setWillDocumentary(sysUserAccountVo.getWillDocumentary().add(jqExportOtherCostsPremiums).add(syExportOtherCostsPremiums).add(noExportOtherCostsPremiums));
  707. }
  708. }
  709. /**
  710. * @version
  711. * @author: hxl
  712. * @Date: 2024/6/3 11:20
  713. * @Description: 通过类型查询预收、实收的金额
  714. */
  715. private BigDecimal willPromotionAll(BigDecimal willPromotion, String userId,String type) {
  716. InsFeeOrderNew insFeeOrderNew = new InsFeeOrderNew();
  717. insFeeOrderNew.setUserId(userId);
  718. InsOrders InsOrders = insAreaCompanyService.selectByInFeeOrderNewByType(insFeeOrderNew,type);
  719. if (ObjectUtils.isNotEmpty(InsOrders)) {
  720. BigDecimal willFirstPremiums = ObjectUtils.defaultIfNull(InsOrders.getWillFirstPremiums(), BigDecimal.ZERO);
  721. // 累加保费
  722. willPromotion = willPromotion.add(willFirstPremiums);
  723. }
  724. return willPromotion;
  725. }
  726. /**
  727. * @version
  728. * @author: hxl
  729. * @Date: 2024/6/4 11:51
  730. * @Description: 获取费用
  731. */
  732. private BigDecimal willAmountNew(InsFeeOrderNew insFeeOrderNew, int type) {
  733. BigDecimal val= BigDecimal.ZERO;
  734. if (ObjectUtils.isNotEmpty(insFeeOrderNew)) {
  735. if(type==1){
  736. // 交强手续费+商业手续费+非车手续费
  737. val= val.add(insFeeOrderNew.getJqExportSuperviseCostsPremiums()).add(insFeeOrderNew.getSyExportSuperviseCostsPremiums()).add(insFeeOrderNew.getNoExportSuperviseCostsPremiums());
  738. }else{
  739. // 交强跟单出口费用+商业跟单出口费用+非车跟单出口费用
  740. val= val.add(insFeeOrderNew.getJqExportOtherCostsPremiums()).add(insFeeOrderNew.getSyExportOtherCostsPremiums()).add(insFeeOrderNew.getNoExportOtherCostsPremiums());
  741. }
  742. }
  743. return val;
  744. }
  745. /**
  746. * @version
  747. * @author: hxl
  748. * @Date: 2024/6/3 15:16
  749. * @Description: 查询子订单的详细信息
  750. */
  751. @Override
  752. public SubOrder getSubOrderDetails(String subOrderId, String userId) {
  753. SubOrder subOrder=insAreaCompanyMapper.getSubOrderDetails(subOrderId);
  754. subOrder.setAgentName(this.getUserName(subOrder.getUserId()));
  755. subOrder.setAgentLevel("");
  756. //根据用户id查询分销等级
  757. InsFeeOrderNew insFeeOrderNew = insFeeOrderNewService.getOne(new LambdaQueryWrapper<InsFeeOrderNew>()
  758. .eq(InsFeeOrderNew::getInsOrderNo, subOrder.getSubOrderId()));
  759. if(userId.equals(insFeeOrderNew.getFirstLevelUserId())){
  760. //subOrder.setAgentName(this.getUserName(insFeeOrderNew.getFirstLevelUserId()));
  761. subOrder.setAgentLevel("一级分销代理");
  762. }
  763. if(userId.equals(insFeeOrderNew.getTwoLevelUserId())){
  764. //subOrder.setAgentName(this.getUserName(insFeeOrderNew.getTwoLevelUserId()));
  765. subOrder.setAgentLevel("二级分销代理");
  766. }
  767. if(userId.equals(insFeeOrderNew.getThreeLevelUserId())){
  768. //subOrder.setAgentName(this.getUserName(insFeeOrderNew.getThreeLevelUserId()));
  769. subOrder.setAgentLevel("三级分销代理");
  770. }
  771. return subOrder;
  772. }
  773. /**
  774. * @version
  775. * @author: hxl
  776. * @Date: 2024/6/3 16:34
  777. * @Description: 查询分销人名称
  778. */
  779. private String getUserName(String userId) {
  780. if(StringUtils.isNotEmpty(userId)){
  781. SysUser sysUser = sysUserService.getBaseMapper().selectById(userId);
  782. if(ObjectUtils.isNotEmpty(sysUser)){
  783. return sysUser.getName();
  784. }
  785. }
  786. return "";
  787. }
  788. /**
  789. * @version
  790. * @author: hxl
  791. * @Date: 2024/6/19 9:04
  792. * @Description: 查询我的账户总金额
  793. */
  794. @Override
  795. public BigDecimal getUserSumAmountByUserId(String userId) {
  796. if(StringUtils.isBlank(userId)){
  797. throw new SystemException("用户id-userId不能为空");
  798. }
  799. //通过用户id查询用户账户的总金额
  800. LambdaQueryWrapper<SysUserAccount> queryWrapper = new LambdaQueryWrapper<>();
  801. queryWrapper.eq(SysUserAccount::getUserId, userId);
  802. SysUserAccount sysUserAccount = sysUserAccountService.getOne(queryWrapper);
  803. if(sysUserAccount==null){
  804. return BigDecimal.ZERO;
  805. }
  806. return sysUserAccount.getSumAmount()==null?BigDecimal.ZERO:sysUserAccount.getSumAmount();
  807. }
  808. /**
  809. * @version
  810. * @author: hxl
  811. * @Date: 2024/6/19 11:04
  812. * @Description: 查询预收数据明细
  813. */
  814. @Override
  815. public MyCollectInAdvanceAllDto findMyCollectInAdvanceByUserId(MyCollectInAdvanceQueryDto myCollectInAdvanceQueryDto) {
  816. if(StringUtils.isBlank(myCollectInAdvanceQueryDto.getUserId())){
  817. throw new SystemException("用户id-userId不能为空");
  818. }
  819. BigDecimal sumAmount=BigDecimal.ZERO;
  820. //判断时间类型 1.一周内 2. 一月内 3. 三月内 4. 三月内
  821. HashMap<String, String> dateMap = getDateMapByType(myCollectInAdvanceQueryDto.getDateQueryType(),myCollectInAdvanceQueryDto.getStartDate(),myCollectInAdvanceQueryDto.getEndDate());
  822. myCollectInAdvanceQueryDto.setStartDate(dateMap.get("startDate"));
  823. myCollectInAdvanceQueryDto.setEndDate(dateMap.get("endDate"));
  824. if(myCollectInAdvanceQueryDto.getBusinessSegmentsType()==null || "".equals(myCollectInAdvanceQueryDto.getBusinessSegmentsType())){
  825. myCollectInAdvanceQueryDto.setBusinessSegmentsType("1");
  826. }
  827. if(myCollectInAdvanceQueryDto.getTransactionType()==null || "".equals(myCollectInAdvanceQueryDto.getTransactionType())){
  828. myCollectInAdvanceQueryDto.setTransactionType("1");
  829. }
  830. if(StringUtils.isEmpty(myCollectInAdvanceQueryDto.getAuditstatus())){
  831. myCollectInAdvanceQueryDto.setAuditstatus("0");
  832. }
  833. Page<MyCollectInAdvanceDto> page = new Page<>(myCollectInAdvanceQueryDto.getPageNum(), myCollectInAdvanceQueryDto.getPageSize());
  834. // page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
  835. Page<MyCollectInAdvanceDto> orderVoPage = new Page<>();
  836. // 1为车险板块
  837. if ("1".equals(myCollectInAdvanceQueryDto.getBusinessSegmentsType())) {
  838. //金额类型 1. 手续费金额 +跟单金额 2. 推广金额
  839. if("2".equals(myCollectInAdvanceQueryDto.getTransactionType())){
  840. orderVoPage = insFeeOrderNewService.findMyCollectInAdvanceWillAmountByUserId(page,myCollectInAdvanceQueryDto);
  841. // Long total=insFeeOrderNewService.findMyCollectInAdvanceWillAmountByUserIdCount(myCollectInAdvanceQueryDto);
  842. // orderVoPage.setTotal(total);
  843. sumAmount = insFeeOrderNewService.findSumWillAmount(myCollectInAdvanceQueryDto);
  844. }else{
  845. orderVoPage = insFeeOrderNewService.findMyCollectInAdvanceSumByUserId(page,myCollectInAdvanceQueryDto);
  846. // Long total=insFeeOrderNewService.findMyCollectInAdvanceSumByUserIdCount(myCollectInAdvanceQueryDto);
  847. // orderVoPage.setTotal(total);
  848. sumAmount = insFeeOrderNewService.findSumAmount(myCollectInAdvanceQueryDto);
  849. }
  850. } else {
  851. //其他板块预留逻辑处理
  852. }
  853. List<MyCollectInAdvanceDto> recordsNew =new ArrayList<>();
  854. if(orderVoPage.getRecords()!=null && orderVoPage.getRecords().size()>0){
  855. for(MyCollectInAdvanceDto dto :orderVoPage.getRecords()) {
  856. //车险的显示且收入
  857. if ("1".equals(dto.getBusinessSegmentsType())) {
  858. if ("4".equals(dto.getTransactionType())) {
  859. dto.setTransactionType("1");
  860. } else if ("3".equals(dto.getTransactionType())) {
  861. dto.setTransactionType("2");
  862. }
  863. }
  864. recordsNew.add(dto);
  865. }
  866. }
  867. orderVoPage.setRecords(recordsNew);
  868. BasePageResult<MyCollectInAdvanceDto> myCollectInAdvanceDtoBasePageResult = new BasePageResult<>(myCollectInAdvanceQueryDto.getPageNum(), myCollectInAdvanceQueryDto.getPageSize(), orderVoPage.getTotal(),
  869. orderVoPage.getPages()
  870. , orderVoPage.getRecords());
  871. return new MyCollectInAdvanceAllDto(sumAmount,myCollectInAdvanceDtoBasePageResult);
  872. }
  873. /**
  874. * @version
  875. * @author: hxl
  876. * @Date: 2024/6/19 11:57
  877. * @Description: 通过时间类型判断
  878. */
  879. private static HashMap<String,String> getDateMapByType(String type,String startDate,String endDate) {
  880. HashMap<String,String> map =new HashMap<>();
  881. String startDateStr="";
  882. String endDateStr="";
  883. if(StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)){
  884. startDateStr= StringUtils.isNotBlank(startDate)?startDate+" 00:00:00":null;
  885. endDateStr= StringUtils.isNotBlank(endDate)?endDate+" 23:59:59":null;
  886. }else{
  887. if("0".equals(type)){
  888. //全部
  889. startDateStr=null;
  890. endDateStr=null;
  891. }else if("1".equals(type)){
  892. // 一周内
  893. startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),1)+" 00:00:00";
  894. endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
  895. }else if("2".equals(type)){
  896. // 一月内
  897. startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),2)+" 00:00:00";
  898. endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
  899. }else if("3".equals(type)){
  900. // 三月内
  901. startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),3)+" 00:00:00";
  902. endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
  903. }else if("4".equals(type)){
  904. // 三月内
  905. startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),4)+" 00:00:00";
  906. endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
  907. }else{
  908. startDateStr= StringUtils.isNotBlank(startDate)?startDate+" 00:00:00":null;
  909. endDateStr= StringUtils.isNotBlank(endDate)?endDate+" 23:59:59":null;
  910. }
  911. }
  912. map.put("startDate",startDateStr);
  913. map.put("endDate",endDateStr);
  914. return map;
  915. }
  916. /**
  917. * @version
  918. * @author: hxl
  919. * @Date: 2024/6/19 11:04
  920. * @Description: 查询收支数据明细
  921. */
  922. @Override
  923. public MyCollectInAdvanceAllDto findIncomeAndExpensesByUserId(MyIncomeAndExpensesQueryDto myIncomeAndExpensesQueryDto) {
  924. if (StringUtils.isBlank(myIncomeAndExpensesQueryDto.getUserId())) {
  925. throw new SystemException("用户id-userId不能为空");
  926. }
  927. BigDecimal sumAmountSR = BigDecimal.ZERO;
  928. BigDecimal sumAmountZC = BigDecimal.ZERO;
  929. BasePageResult<MyCollectInAdvanceDto> myCollectInAdvanceDtoBasePageResult = new BasePageResult<MyCollectInAdvanceDto>();
  930. //判断时间类型 1.一周内 2. 一月内 3. 三月内 4. 三月内
  931. HashMap<String, String> dateMap = getDateMapByType(myIncomeAndExpensesQueryDto.getDateQueryType(), myIncomeAndExpensesQueryDto.getStartDate(), myIncomeAndExpensesQueryDto.getEndDate());
  932. myIncomeAndExpensesQueryDto.setStartDate(dateMap.get("startDate"));
  933. myIncomeAndExpensesQueryDto.setEndDate(dateMap.get("endDate"));
  934. Page<MyCollectInAdvanceDto> page = new Page<>(myIncomeAndExpensesQueryDto.getPageNum(), myIncomeAndExpensesQueryDto.getPageSize());
  935. //page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
  936. Page<MyCollectInAdvanceDto> orderVoPage = new Page<>();
  937. if ("0".equals(myIncomeAndExpensesQueryDto.getBusinessSegmentsType())) {
  938. myIncomeAndExpensesQueryDto.setBusinessSegmentsType(null);
  939. }
  940. if ("0".equals(myIncomeAndExpensesQueryDto.getTransactionType())) {
  941. myIncomeAndExpensesQueryDto.setTransactionType(null);
  942. }
  943. if ("0".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())) {
  944. myIncomeAndExpensesQueryDto.setIncomeAndExpensesType(null);
  945. }
  946. // 1为车险板块 1 收入时
  947. if ( StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getBusinessSegmentsType()) && StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType()) &&"1".equals(myIncomeAndExpensesQueryDto.getBusinessSegmentsType()) &&"1".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())) {
  948. //判断收入类型 1 收入
  949. if(StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) && "3".equals(myIncomeAndExpensesQueryDto.getTransactionType())){
  950. throw new SystemException("收入类型不能选择提现类型");
  951. }
  952. }
  953. if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType()) &&"2".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())) {
  954. //判断支出类型
  955. if(StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) && !"3".equals(myIncomeAndExpensesQueryDto.getTransactionType())){
  956. throw new SystemException("支出类型不能选择(手续+跟单)或者手续费、退款类型");
  957. }
  958. }
  959. if ( (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getBusinessSegmentsType()) && StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType()) && "2".equals(myIncomeAndExpensesQueryDto.getBusinessSegmentsType()) &&"1".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType()))
  960. ||
  961. (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType()) && ("2".equals(myIncomeAndExpensesQueryDto.getBusinessSegmentsType())))){
  962. //判断退款类型
  963. if(StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) &&!"4".equals(myIncomeAndExpensesQueryDto.getTransactionType())){
  964. throw new SystemException("退款板块只能选择退款类型");
  965. }
  966. }
  967. //处理 手续费+跟单、推广费类型转换
  968. if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) && "2".equals(myIncomeAndExpensesQueryDto.getTransactionType())) {
  969. myIncomeAndExpensesQueryDto.setTransactionType("3");
  970. } else if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) &&"1".equals(myIncomeAndExpensesQueryDto.getTransactionType())) {
  971. myIncomeAndExpensesQueryDto.setTransactionType("4");
  972. } else if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) &&"4".equals(myIncomeAndExpensesQueryDto.getTransactionType())) {
  973. myIncomeAndExpensesQueryDto.setTransactionType("5");
  974. } else if (StringUtils.isNotBlank(myIncomeAndExpensesQueryDto.getTransactionType()) &&"3".equals(myIncomeAndExpensesQueryDto.getTransactionType())) {
  975. myIncomeAndExpensesQueryDto.setTransactionType("6");
  976. }
  977. //处理收入和支出类型转换
  978. if (myIncomeAndExpensesQueryDto.getIncomeAndExpensesType() != null && "0".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())) {
  979. myIncomeAndExpensesQueryDto.setIncomeAndExpensesType(null);
  980. } else if (myIncomeAndExpensesQueryDto.getIncomeAndExpensesType() != null && "1".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())) {
  981. myIncomeAndExpensesQueryDto.setIncomeAndExpensesType("2");
  982. } else if (myIncomeAndExpensesQueryDto.getIncomeAndExpensesType() != null && "2".equals(myIncomeAndExpensesQueryDto.getIncomeAndExpensesType())){
  983. myIncomeAndExpensesQueryDto.setIncomeAndExpensesType("1");
  984. }
  985. orderVoPage = sysUserAccountHistoryService.findMyIncomeAndExpensesAmountByUserId(page,myIncomeAndExpensesQueryDto);
  986. // Long total=sysUserAccountHistoryService.findMyIncomeAndExpensesAmountByUserIdCount(myIncomeAndExpensesQueryDto);
  987. // orderVoPage.setTotal(total);
  988. List<MyCollectInAdvanceDto> recordsNew =new ArrayList<>();
  989. if(orderVoPage.getRecords()!=null && orderVoPage.getRecords().size()>0){
  990. for(MyCollectInAdvanceDto dto :orderVoPage.getRecords()) {
  991. //车险的显示且收入
  992. if ("1".equals(dto.getBusinessSegmentsType()) && "2".equals(dto.getIncomeAndExpensesType())) {
  993. if ("4".equals(dto.getTransactionType())) {
  994. dto.setTransactionType("1");
  995. } else if ("3".equals(dto.getTransactionType())) {
  996. dto.setTransactionType("2");
  997. }
  998. dto.setIncomeAndExpensesType("1");
  999. //退款 且退款
  1000. } else if ("2".equals(dto.getBusinessSegmentsType()) && "2".equals(dto.getIncomeAndExpensesType())){
  1001. dto.setIncomeAndExpensesType("1");
  1002. dto.setTransactionType("4");
  1003. //退款设置为空
  1004. dto.setAuditingStatus("");
  1005. //提现
  1006. }else if("6".equals(dto.getTransactionType()) && "1".equals(dto.getIncomeAndExpensesType())){
  1007. dto.setIncomeAndExpensesType("2");
  1008. dto.setTransactionType("3");
  1009. }
  1010. recordsNew.add(dto);
  1011. }
  1012. }
  1013. orderVoPage.setRecords(recordsNew);
  1014. myCollectInAdvanceDtoBasePageResult = new BasePageResult<>(myIncomeAndExpensesQueryDto.getPageNum(), myIncomeAndExpensesQueryDto.getPageSize(), orderVoPage.getTotal(),
  1015. orderVoPage.getPages()
  1016. , orderVoPage.getRecords());
  1017. //
  1018. sumAmountSR=sysUserAccountHistoryService.findSumAmountByUserId(myIncomeAndExpensesQueryDto.getUserId(),"2");
  1019. sumAmountZC=sysUserAccountHistoryService.findSumAmountByUserId(myIncomeAndExpensesQueryDto.getUserId(),"1");
  1020. return new MyCollectInAdvanceAllDto(sumAmountSR,sumAmountZC,myCollectInAdvanceDtoBasePageResult);
  1021. }
  1022. /**
  1023. * @version
  1024. * @author: hxl
  1025. * @Date: 2024/6/20 13:48
  1026. * @Description: 提现详情
  1027. */
  1028. @Override
  1029. public WithdrawalDetalsDto findDetailById(String id) {
  1030. //id为历史表的id
  1031. //通过历史记录表查询数据
  1032. SysUserAccountHistory his = sysUserAccountHistoryService.getById(id);
  1033. LambdaQueryWrapper<SysAmountAuditingHistory> lqw = new LambdaQueryWrapper<>();
  1034. lqw.eq(SysAmountAuditingHistory::getHistoryId, id);
  1035. lqw.orderByAsc(SysAmountAuditingHistory::getCreateTime);
  1036. List<SysAmountAuditingHistory> listAll = sysAmountAuditingHistoryService.list(lqw);
  1037. SysAmountAuditingEntity audi = sysAmountAuditingService.getById(his.getAuditiingId());
  1038. WithdrawalDetalsDto withdrawalDetalsDto=new WithdrawalDetalsDto();
  1039. if(audi!=null){
  1040. withdrawalDetalsDto.setBankNumber(audi.getBankNumber());
  1041. withdrawalDetalsDto.setTransactionNumber(audi.getId());
  1042. withdrawalDetalsDto.setWithdrawalAmount(audi.getAmount());
  1043. withdrawalDetalsDto.setBankAccount(audi.getBankAccount());
  1044. }
  1045. List<WithdrawalDetalsRecordDto> recordList =new ArrayList<WithdrawalDetalsRecordDto>();
  1046. if(listAll!=null && listAll.size()>0){
  1047. SysAmountAuditingHistory first = listAll.get(0);
  1048. SysAmountAuditingHistory last = listAll.get(listAll.size() - 1);
  1049. //申请时间
  1050. Date createTime = first.getCreateTime();
  1051. withdrawalDetalsDto.setApplicationDate(createTime);
  1052. String auditingStatus = last.getAuditingStatus();
  1053. withdrawalDetalsDto.setWithdrawalStatus(auditingStatus);
  1054. String auditingStatusName="";
  1055. if("1".equals(auditingStatus)){
  1056. auditingStatusName="提现申请";
  1057. }else if("2".equals(auditingStatus)){
  1058. auditingStatusName="处理中";
  1059. }else if("3".equals(auditingStatus)){
  1060. auditingStatusName="提现失败";
  1061. }else if("4".equals(auditingStatus)){
  1062. auditingStatusName="提现成功";
  1063. withdrawalDetalsDto.setPaymentDate(last.getCreateTime());
  1064. }
  1065. withdrawalDetalsDto.setWithdrawalStatusName(auditingStatusName);
  1066. WithdrawalDetalsRecordDto dto1 = new WithdrawalDetalsRecordDto("1", false, "提现申请", null);
  1067. WithdrawalDetalsRecordDto dto2 = new WithdrawalDetalsRecordDto("2", false, "处理中", null);
  1068. WithdrawalDetalsRecordDto dto3 = null;
  1069. WithdrawalDetalsRecordDto dto4 = new WithdrawalDetalsRecordDto("4", false, "提现成功", null);
  1070. for(SysAmountAuditingHistory sysAmountAuditingHistory:listAll){
  1071. if("1".equals(sysAmountAuditingHistory.getAuditingStatus())){
  1072. dto1.setProcessingStatusFlag(true);
  1073. dto1.setProcessingDate(sysAmountAuditingHistory.getCreateTime());
  1074. }else if("2".equals(sysAmountAuditingHistory.getAuditingStatus())){
  1075. dto2.setProcessingStatusFlag(true);
  1076. dto2.setProcessingDate(sysAmountAuditingHistory.getCreateTime());
  1077. }else if("3".equals(sysAmountAuditingHistory.getAuditingStatus())){
  1078. dto3 =new WithdrawalDetalsRecordDto("3", true, "提现失败", sysAmountAuditingHistory.getCreateTime());
  1079. }else if("4".equals(sysAmountAuditingHistory.getAuditingStatus())){
  1080. dto4.setProcessingStatusFlag(true);
  1081. dto4.setProcessingDate(sysAmountAuditingHistory.getCreateTime());
  1082. }
  1083. }
  1084. recordList.add(dto1);
  1085. recordList.add(dto2);
  1086. if(dto3!=null){
  1087. recordList.add(dto3);
  1088. withdrawalDetalsDto.setRejectReason(audi.getRejectReason()==null?"":audi.getRejectReason());
  1089. }else{
  1090. //add by hxl 2024-07-09 添加银行回单的路径
  1091. if(audi!=null && StringUtils.isNotBlank(audi.getPicId())){
  1092. //add by hxl 2024-08-15 屏蔽银行回单的路径
  1093. // InsUploadFiles insUploadFiles = insUploadFilesMapper.selectById(audi.getPicId());
  1094. // withdrawalDetalsDto.setBankReceipt(insUploadFiles==null?"":insUploadFiles.getUrl());
  1095. }
  1096. recordList.add(dto4);
  1097. }
  1098. withdrawalDetalsDto.setRecord(recordList);
  1099. }
  1100. return withdrawalDetalsDto;
  1101. }
  1102. @Override
  1103. public OrderDetalsDto findOrderDetailById(String subOrderId) {
  1104. return null;
  1105. }
  1106. /**
  1107. * @version
  1108. * @author: hxl
  1109. * @Date: 2024/6/21 18:27
  1110. * @Description: 查看退款详情
  1111. */
  1112. @Override
  1113. public RefundDetalsDto findRefundDetailById(String id) {
  1114. //id为历史表的id
  1115. //通过历史记录表查询数据
  1116. SysUserAccountHistory his = sysUserAccountHistoryService.getById(id);
  1117. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1118. String dateStr = sdf.format(his.getCreateTime());
  1119. return new RefundDetalsDto(dateStr,his.getAmount(),his.getAuditiingId());
  1120. }
  1121. /**
  1122. * @version
  1123. * @author: hxl
  1124. * @Date: 2024/6/30 15:28
  1125. * @Description: 查询车险明细
  1126. */
  1127. @Override
  1128. public BasePageResult<ExportExpenditureTypeDetalsDto> findMyInsuranceByUserId(MyInsuranceQueryDto myInsuranceQueryDto) {
  1129. Page<ExportExpenditureTypeDetalsDto> page = new Page<>(myInsuranceQueryDto.getPageNum(),
  1130. myInsuranceQueryDto.getPageSize());
  1131. List<String> userList = getStrings(myInsuranceQueryDto);
  1132. //赋值开始和结束时间
  1133. if(StringUtils.isNotBlank(myInsuranceQueryDto.getStartDate())){
  1134. myInsuranceQueryDto.setStartDate(myInsuranceQueryDto.getStartDate()+" 00:00:00");
  1135. }
  1136. if(StringUtils.isNotBlank(myInsuranceQueryDto.getEndDate())){
  1137. myInsuranceQueryDto.setEndDate(myInsuranceQueryDto.getEndDate()+" 23:59:59");
  1138. }
  1139. Page<ExportExpenditureTypeDetalsDto> pageList=insFeeOrderNewService.findMyInsuranceByUserId(page,myInsuranceQueryDto,userList);
  1140. BasePageResult<ExportExpenditureTypeDetalsDto> result = new BasePageResult<>(myInsuranceQueryDto.getPageNum(), myInsuranceQueryDto.getPageSize(), pageList.getTotal(),
  1141. pageList.getPages()
  1142. , pageList.getRecords());
  1143. return result;
  1144. }
  1145. /**
  1146. * @version
  1147. * @author: hxl
  1148. * @Date: 2024/6/30 17:59
  1149. * @Description: 获取渠道团队长管理的下级人
  1150. */
  1151. private List<String> getStrings(MyInsuranceQueryDto myInsuranceQueryDto) {
  1152. //查询当前管理的代理人信息
  1153. LambdaQueryWrapper<SysUser> lqw = new LambdaQueryWrapper<>();
  1154. lqw.eq(SysUser::getStatus, 1);
  1155. lqw.eq(SysUser::getOperatorCode, myInsuranceQueryDto.getUserId());
  1156. List<SysUser> users= sysUserMapper.selectList(lqw);
  1157. List<String> userList=new ArrayList<>();
  1158. if(users!=null && users.size()>0){
  1159. for(SysUser user: users){
  1160. userList.add(user.getId());
  1161. }
  1162. }
  1163. return userList;
  1164. }
  1165. /**
  1166. * @version
  1167. * @author: hxl
  1168. * @Date: 2024/6/30 18:05
  1169. * @Description: 查询推广费分页
  1170. */
  1171. @Override
  1172. public BasePageResult<ExportExpenditureTypeDetalsTGDto> findMyInsuranceTGByUserId(MyInsuranceTgQueryDto myInsuranceTgQueryDto) {
  1173. Page<ExportExpenditureTypeDetalsTGDto> page = new Page<>(myInsuranceTgQueryDto.getPageNum(),
  1174. myInsuranceTgQueryDto.getPageSize());
  1175. //赋值开始和结束时间
  1176. if(StringUtils.isNotBlank(myInsuranceTgQueryDto.getStartDate())){
  1177. myInsuranceTgQueryDto.setStartDate(myInsuranceTgQueryDto.getStartDate()+" 00:00:00");
  1178. }
  1179. if(StringUtils.isNotBlank(myInsuranceTgQueryDto.getEndDate())){
  1180. myInsuranceTgQueryDto.setEndDate(myInsuranceTgQueryDto.getEndDate()+" 23:59:59");
  1181. }
  1182. Page<ExportExpenditureTypeDetalsTGDto> pageList=insFeeOrderNewService.findMyInsuranceTGByUserId(page,myInsuranceTgQueryDto);
  1183. BasePageResult<ExportExpenditureTypeDetalsTGDto> result = new BasePageResult<>(myInsuranceTgQueryDto.getPageNum(), myInsuranceTgQueryDto.getPageSize(), pageList.getTotal(),
  1184. pageList.getPages()
  1185. , pageList.getRecords());
  1186. return result;
  1187. }
  1188. /**
  1189. * @version
  1190. * @author: hxl
  1191. * @Date: 2024/6/30 18:05
  1192. * @Description: 查询车险导出数据
  1193. */
  1194. @Override
  1195. public List<ExportExpenditureTypeDetalsDto> exportMyInsuranceByUserId(MyInsuranceQueryDto myInsuranceQueryDto) {
  1196. List<String> userList = getStrings(myInsuranceQueryDto);
  1197. //赋值开始和结束时间
  1198. if(StringUtils.isNotBlank(myInsuranceQueryDto.getStartDate())){
  1199. myInsuranceQueryDto.setStartDate(myInsuranceQueryDto.getStartDate()+" 00:00:00");
  1200. }
  1201. if(StringUtils.isNotBlank(myInsuranceQueryDto.getEndDate())){
  1202. myInsuranceQueryDto.setEndDate(myInsuranceQueryDto.getEndDate()+" 23:59:59");
  1203. }
  1204. return insFeeOrderNewService.exportMyInsuranceByUserId(myInsuranceQueryDto,userList);
  1205. }
  1206. /**
  1207. * @version
  1208. * @author: hxl
  1209. * @Date: 2024/6/30 18:05
  1210. * @Description: 查询推广导出数据
  1211. */
  1212. @Override
  1213. public List<ExportExpenditureTypeDetalsTGDto> exportMyInsuranceTGByUserId(MyInsuranceTgQueryDto myInsuranceTgQueryDto) {
  1214. //赋值开始和结束时间
  1215. if(StringUtils.isNotBlank(myInsuranceTgQueryDto.getStartDate())){
  1216. myInsuranceTgQueryDto.setStartDate(myInsuranceTgQueryDto.getStartDate()+" 00:00:00");
  1217. }
  1218. if(StringUtils.isNotBlank(myInsuranceTgQueryDto.getEndDate())){
  1219. myInsuranceTgQueryDto.setEndDate(myInsuranceTgQueryDto.getEndDate()+" 23:59:59");
  1220. }
  1221. return insFeeOrderNewService.exportMyInsuranceTGByUserId(myInsuranceTgQueryDto);
  1222. }
  1223. /**
  1224. * @version
  1225. * @author: hxl
  1226. * @Date: 2024/7/1 9:02
  1227. * @Description: 查询收支明细数据
  1228. */
  1229. @Override
  1230. public BasePageResult<ExportExpenditureTypeDetalsSZDto> findMyIncomeAndExpensesNewByUserId(MyCollectInAdvanceQueryNewDto myCollectInAdvanceQueryNewDto) {
  1231. //校验数据
  1232. myCollectInAdvanceQueryNewDto = checkData(myCollectInAdvanceQueryNewDto);
  1233. Page<ExportExpenditureTypeDetalsSZDto> page = new Page<>(myCollectInAdvanceQueryNewDto.getPageNum(), myCollectInAdvanceQueryNewDto.getPageSize());
  1234. Page<ExportExpenditureTypeDetalsSZDto> orderVoPage = sysUserAccountHistoryService.findMyIncomeAndExpensesAmountNewByUserId(page,myCollectInAdvanceQueryNewDto);
  1235. List<ExportExpenditureTypeDetalsSZDto> recordsNew =new ArrayList<>();
  1236. //格式化数据
  1237. if(orderVoPage.getRecords()!=null && orderVoPage.getRecords().size()>0){
  1238. for(ExportExpenditureTypeDetalsSZDto dto :orderVoPage.getRecords()) {
  1239. //车险的显示且收入
  1240. if ("1".equals(dto.getBusinessSegmentsType()) && "2".equals(dto.getIncomeAndExpensesType())) {
  1241. if ("4".equals(dto.getTransactionType())) {
  1242. dto.setTransactionType("1");
  1243. } else if ("3".equals(dto.getTransactionType())) {
  1244. dto.setTransactionType("2");
  1245. }
  1246. dto.setIncomeAndExpensesType("1");
  1247. //退款 且退款
  1248. } else if ("2".equals(dto.getBusinessSegmentsType()) && "2".equals(dto.getIncomeAndExpensesType())){
  1249. dto.setIncomeAndExpensesType("1");
  1250. dto.setTransactionType("4");
  1251. //退款设置为空
  1252. dto.setAuditingStatus("");
  1253. //提现
  1254. }else if("6".equals(dto.getTransactionType()) && "1".equals(dto.getIncomeAndExpensesType())){
  1255. dto.setIncomeAndExpensesType("2");
  1256. dto.setTransactionType("3");
  1257. }
  1258. recordsNew.add(dto);
  1259. }
  1260. }
  1261. orderVoPage.setRecords(recordsNew);
  1262. return new BasePageResult<>(myCollectInAdvanceQueryNewDto.getPageNum(), myCollectInAdvanceQueryNewDto.getPageSize(), orderVoPage.getTotal(),
  1263. orderVoPage.getPages()
  1264. , orderVoPage.getRecords());
  1265. }
  1266. /**
  1267. * @version
  1268. * @author: hxl
  1269. * @Date: 2024/7/1 9:06
  1270. * @Description: 校验数据
  1271. */
  1272. private static MyCollectInAdvanceQueryNewDto checkData(MyCollectInAdvanceQueryNewDto myCollectInAdvanceQueryNewDto) {
  1273. if (StringUtils.isBlank(myCollectInAdvanceQueryNewDto.getUserId())) {
  1274. throw new SystemException("用户id-userId不能为空");
  1275. }
  1276. //判断时间类型 1.一周内 2. 一月内 3. 三月内 4. 三月内
  1277. HashMap<String, String> dateMap = getDateMapByType(myCollectInAdvanceQueryNewDto.getDateQueryType(), myCollectInAdvanceQueryNewDto.getStartDate(), myCollectInAdvanceQueryNewDto.getEndDate());
  1278. myCollectInAdvanceQueryNewDto.setStartDate(dateMap.get("startDate"));
  1279. myCollectInAdvanceQueryNewDto.setEndDate(dateMap.get("endDate"));
  1280. if ("0".equals(myCollectInAdvanceQueryNewDto.getBusinessSegmentsType())) {
  1281. myCollectInAdvanceQueryNewDto.setBusinessSegmentsType(null);
  1282. }
  1283. if ("0".equals(myCollectInAdvanceQueryNewDto.getTransactionType())) {
  1284. myCollectInAdvanceQueryNewDto.setTransactionType(null);
  1285. }
  1286. if ("0".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType())) {
  1287. myCollectInAdvanceQueryNewDto.setIncomeAndExpensesType(null);
  1288. }
  1289. // 1为车险板块 1 收入时
  1290. if ( StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getBusinessSegmentsType()) && StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType()) &&"1".equals(myCollectInAdvanceQueryNewDto.getBusinessSegmentsType()) &&"1".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType())) {
  1291. //判断收入类型 1 收入
  1292. if(StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) && "3".equals(myCollectInAdvanceQueryNewDto.getTransactionType())){
  1293. throw new SystemException("收入类型不能选择提现类型");
  1294. }
  1295. }
  1296. if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType()) &&"2".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType())) {
  1297. //判断支出类型
  1298. if(StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) && !"3".equals(myCollectInAdvanceQueryNewDto.getTransactionType())){
  1299. throw new SystemException("支出类型不能选择(手续+跟单)或者手续费、退款类型");
  1300. }
  1301. }
  1302. if ( (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getBusinessSegmentsType()) && StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType()) && "2".equals(myCollectInAdvanceQueryNewDto.getBusinessSegmentsType()) &&"1".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType()))
  1303. ||
  1304. (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType()) && ("2".equals(myCollectInAdvanceQueryNewDto.getBusinessSegmentsType())))){
  1305. //判断退款类型
  1306. if(StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) &&!"4".equals(myCollectInAdvanceQueryNewDto.getTransactionType())){
  1307. throw new SystemException("退款板块只能选择退款类型");
  1308. }
  1309. }
  1310. //处理 手续费+跟单、推广费类型转换
  1311. if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) && "2".equals(myCollectInAdvanceQueryNewDto.getTransactionType())) {
  1312. myCollectInAdvanceQueryNewDto.setTransactionType("3");
  1313. } else if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) &&"1".equals(myCollectInAdvanceQueryNewDto.getTransactionType())) {
  1314. myCollectInAdvanceQueryNewDto.setTransactionType("4");
  1315. } else if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) &&"4".equals(myCollectInAdvanceQueryNewDto.getTransactionType())) {
  1316. myCollectInAdvanceQueryNewDto.setTransactionType("5");
  1317. } else if (StringUtils.isNotBlank(myCollectInAdvanceQueryNewDto.getTransactionType()) &&"3".equals(myCollectInAdvanceQueryNewDto.getTransactionType())) {
  1318. myCollectInAdvanceQueryNewDto.setTransactionType("6");
  1319. }
  1320. //处理收入和支出类型转换
  1321. if (myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType() != null && "0".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType())) {
  1322. myCollectInAdvanceQueryNewDto.setIncomeAndExpensesType(null);
  1323. } else if (myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType() != null && "1".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType())) {
  1324. myCollectInAdvanceQueryNewDto.setIncomeAndExpensesType("2");
  1325. } else if (myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType() != null && "2".equals(myCollectInAdvanceQueryNewDto.getIncomeAndExpensesType())){
  1326. myCollectInAdvanceQueryNewDto.setIncomeAndExpensesType("1");
  1327. }
  1328. return myCollectInAdvanceQueryNewDto;
  1329. }
  1330. /**
  1331. * @version
  1332. * @author: hxl
  1333. * @Date: 2024/7/1 9:03
  1334. * @Description: 查询导出收支明细
  1335. */
  1336. @Override
  1337. public List<ExportExpenditureTypeDetalsSZDto> exportMyIncomeAndExpensesNewByUserId(MyCollectInAdvanceQueryNewDto myCollectInAdvanceQueryNewDto) {
  1338. //校验数据
  1339. myCollectInAdvanceQueryNewDto = checkData(myCollectInAdvanceQueryNewDto);
  1340. //查询数据
  1341. List<ExportExpenditureTypeDetalsSZDto> list = sysUserAccountHistoryService.exportMyIncomeAndExpensesAmountNewByUserId(myCollectInAdvanceQueryNewDto);
  1342. List<ExportExpenditureTypeDetalsSZDto> recordsNew =new ArrayList<>();
  1343. //格式化数据
  1344. if(list!=null && list.size()>0){
  1345. for(ExportExpenditureTypeDetalsSZDto dto :list) {
  1346. //车险的显示且收入
  1347. if ("1".equals(dto.getBusinessSegmentsType()) && "2".equals(dto.getIncomeAndExpensesType())) {
  1348. if ("4".equals(dto.getTransactionType())) {
  1349. dto.setTransactionType("手续费+跟单");
  1350. } else if ("3".equals(dto.getTransactionType())) {
  1351. dto.setTransactionType("推广");
  1352. }
  1353. dto.setIncomeAndExpensesType("收入");
  1354. dto.setBusinessSegmentsType("车险");
  1355. //退款 且退款
  1356. } else if ("2".equals(dto.getBusinessSegmentsType()) && "2".equals(dto.getIncomeAndExpensesType())){
  1357. dto.setIncomeAndExpensesType("收入");
  1358. dto.setTransactionType("退款");
  1359. //退款设置为空
  1360. dto.setAuditingStatus("");
  1361. dto.setBusinessSegmentsType("退款");
  1362. //提现
  1363. }else if("6".equals(dto.getTransactionType()) && "1".equals(dto.getIncomeAndExpensesType())){
  1364. dto.setIncomeAndExpensesType("收入");
  1365. dto.setTransactionType("提现");
  1366. dto.setBusinessSegmentsType("车险");
  1367. }
  1368. recordsNew.add(dto);
  1369. }
  1370. }
  1371. return recordsNew;
  1372. }
  1373. /**
  1374. * @version
  1375. * @author: hxl
  1376. * @Date: 2024/6/30 18:55
  1377. * @Description: 查询页面总金额
  1378. */
  1379. @Override
  1380. public MySumAmountDto findMyAmount(MySumAmountQueryDto mySumAmountQueryDto) {
  1381. //赋值开始和结束时间
  1382. if(StringUtils.isNotBlank(mySumAmountQueryDto.getStartDate())){
  1383. mySumAmountQueryDto.setStartDate(mySumAmountQueryDto.getStartDate()+" 00:00:00");
  1384. }
  1385. if(StringUtils.isNotBlank(mySumAmountQueryDto.getEndDate())){
  1386. mySumAmountQueryDto.setEndDate(mySumAmountQueryDto.getEndDate()+" 23:59:59");
  1387. }
  1388. String userId = mySumAmountQueryDto.getUserId();
  1389. //添加预收明细 如果是渠道团队长查询管理下级的出单员
  1390. SysUserBaseVO sysUserBaseVO = sysUserService.selectUserById(userId);
  1391. SysUser user = sysUserService.getById(userId);
  1392. SysDept dept = sysDeptService.getById(user.getDeptId());
  1393. String deptId="";
  1394. //出单员是19 且是渠道的话,给渠道团队长
  1395. if ("21".equals(sysUserBaseVO.getRoleId()) && "1".equals(dept.getManagementSource())) {
  1396. deptId = dept.getId();
  1397. mySumAmountQueryDto.setDeptId(deptId);
  1398. }
  1399. //查询预收和实收的总金额
  1400. mySumAmountQueryDto.setAuditstatus("0");
  1401. BigDecimal ysAmount= insFeeOrderNewService.findMyAmountYSOrSSCXAmount(mySumAmountQueryDto);
  1402. mySumAmountQueryDto.setAuditstatus("1");
  1403. BigDecimal ssAmount= insFeeOrderNewService.findMyAmountYSOrSSCXAmount(mySumAmountQueryDto);
  1404. BigDecimal ysAndSsAmount=ysAmount.add(ssAmount);
  1405. mySumAmountQueryDto.setAuditstatus("0");
  1406. BigDecimal ysTGAmount= insFeeOrderNewService.findMyAmountYSOrSSTGAmount(mySumAmountQueryDto);
  1407. mySumAmountQueryDto.setAuditstatus("1");
  1408. BigDecimal ssTGAmount= insFeeOrderNewService.findMyAmountYSOrSSTGAmount(mySumAmountQueryDto);
  1409. BigDecimal ysAndSsTGAmount=ysTGAmount.add(ssTGAmount);
  1410. // 已提现金额 查询历史表中的审核状态为3的数据
  1411. BigDecimal ysTXAmount= insFeeOrderNewService.findMyAmountYTXmount(mySumAmountQueryDto.getUserId(),"3");
  1412. // 可提现金额 查询账户的钱
  1413. mySumAmountQueryDto.setAuditstatus("1");
  1414. SysUserAccount sysUserAccountEntity = baseMapper.getById(mySumAmountQueryDto.getUserId());
  1415. BigDecimal txzTXAmount= insFeeOrderNewService.findMyAmountYTXmount(mySumAmountQueryDto.getUserId(),"2");
  1416. BigDecimal ssKTAmount =BigDecimal.ZERO;
  1417. if(sysUserAccountEntity!=null){
  1418. ssKTAmount = sysUserAccountEntity.getSumAmount()==null?BigDecimal.ZERO: sysUserAccountEntity.getSumAmount();
  1419. }
  1420. BigDecimal sumAmount=ysTXAmount.add(ssKTAmount).add(txzTXAmount);
  1421. return new MySumAmountDto(ysAmount,ssAmount,ysAndSsAmount,ysTGAmount,ssTGAmount,ysAndSsTGAmount,ysTXAmount,ssKTAmount,sumAmount,txzTXAmount);
  1422. }
  1423. }