SysUserAccountServiceImpl.java 65 KB

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