You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
8.6 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. package com.example.demo.serviceImpl.cash;
  2. import com.example.demo.Util.GoldTistV2;
  3. import com.example.demo.domain.entity.UserGoldRecord;
  4. import com.example.demo.domain.vo.cash.CashRecordDone;
  5. import com.example.demo.domain.vo.coin.Result;
  6. import com.example.demo.mapper.cash.CashRefundMapper;
  7. import com.example.demo.mapper.coin.AuditMapper;
  8. import com.example.demo.mapper.coin.RefundMapper;
  9. import com.example.demo.service.cash.RefundService;
  10. import com.github.pagehelper.PageHelper;
  11. import com.github.pagehelper.PageInfo;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import java.time.LocalDate;
  15. import java.util.List;
  16. import java.util.UUID;
  17. import static org.apache.commons.lang3.StringUtils.substring;
  18. /**
  19. * @program: GOLD
  20. * @ClassName CashRefundServiceImpl
  21. * @description:
  22. * @author: huangqizhen
  23. * @create: 202509-28 15:02
  24. * @Version 1.0
  25. **/
  26. @Service
  27. public class CashRefundServiceImpl implements RefundService {
  28. @Autowired
  29. private CashRefundMapper cashRefundMapper;
  30. @Autowired
  31. private RefundMapper refundMapper;
  32. @Autowired
  33. private AuditMapper auditMapper;
  34. @Override
  35. public PageInfo<CashRecordDone> select(Integer pageNum, Integer pageSize, CashRecordDone cashRecordDone) {
  36. PageHelper.startPage(pageNum, pageSize);
  37. // System.out.println(goldDetail.getMarkets());
  38. List<CashRecordDone> list = cashRefundMapper.select(cashRecordDone);
  39. return new PageInfo<>(list);
  40. }
  41. @Override
  42. public int add(CashRecordDone cashRecordDone) throws Exception {
  43. if(cashRecordDone.getHandlingCharge()== null){
  44. throw new Exception("未输入手续费") ;
  45. }
  46. if(cashRecordDone.getJwcode()==null){
  47. throw new Exception("未输入精网号") ;
  48. }
  49. if(cashRecordDone.getPaymentAmount()== null){
  50. throw new Exception("未输入付款金额") ;
  51. }
  52. if(cashRecordDone.getPaymentCurrency()== null){
  53. throw new Exception("未输入付款币种") ;
  54. }
  55. if(cashRecordDone.getRefundModel()== null){
  56. throw new Exception("请填充退款类型") ;
  57. }
  58. if(cashRecordDone.getRefundReason()== null){
  59. throw new Exception("请填写退款理由") ;
  60. }
  61. CashRecordDone cashRecordDonetwo = new CashRecordDone();
  62. cashRecordDonetwo.setAreaServise(cashRecordDone.getAreaServise());
  63. cashRefundMapper.addAudit(cashRecordDonetwo);
  64. cashRecordDone.setAuditId(cashRecordDonetwo.getId());
  65. cashRecordDone.setOrderType(2);
  66. cashRecordDone.setStatus(10);
  67. //生成订单号后半部分
  68. String orderNumber = cashRecordDone.getOrderCode();
  69. //构建订单信息
  70. cashRecordDone.setOrderCode("TK_" + orderNumber); //订单号
  71. cashRefundMapper.insert(cashRecordDone);
  72. CashRecordDone cashRecordDone1 = new CashRecordDone();
  73. cashRecordDone1.setId(cashRecordDone.getId());
  74. cashRecordDone1.setStatus(6);
  75. return cashRefundMapper.updateStatus(cashRecordDone1);
  76. }
  77. @Override
  78. public int update(CashRecordDone cashRecordDone) {
  79. if (cashRecordDone.getJwcode()== null) {
  80. throw new RuntimeException("未输入精网号");
  81. }
  82. if (cashRecordDone.getPaymentAmount()== null) {
  83. throw new RuntimeException("未输入付款金额");
  84. }
  85. if (cashRecordDone.getPaymentCurrency()== null){
  86. throw new RuntimeException("未输入付款币种");
  87. }
  88. if (cashRecordDone.getRefundModel()== null) {
  89. throw new RuntimeException("请填写退款类型");
  90. }
  91. if (cashRecordDone.getRefundReason()== null) {
  92. throw new RuntimeException("请填写退款理由");
  93. }
  94. int result = cashRefundMapper.update(cashRecordDone);
  95. return (result > 0 ? Result.success("提交成功") : Result.error("提交失败")).getCode();
  96. }
  97. @Override
  98. public int withdraw(CashRecordDone cashRecordDone) {
  99. return cashRefundMapper.withdraw(cashRecordDone.getId());
  100. }
  101. @Override
  102. public int review(CashRecordDone cashRecordDone) {
  103. if(cashRecordDone.getStatus()== 12|| cashRecordDone.getStatus()== 22){
  104. CashRecordDone cashRecordDone1 = new CashRecordDone();
  105. cashRecordDone1.setOrderCode(cashRecordDone.getOrderCode().substring(2));
  106. cashRecordDone1.setStatus(4);
  107. cashRefundMapper.updateStatus(cashRecordDone1);
  108. }
  109. cashRefundMapper.updateAudit(cashRecordDone);
  110. int result = cashRefundMapper.review(cashRecordDone);
  111. return (result > 0 ? Result.success("提交成功") : Result.error("提交失败")).getCode();
  112. }
  113. @Override
  114. public int executor(CashRecordDone cashRecordDone) {
  115. if(cashRecordDone.getRefundVoucher()== null){
  116. throw new RuntimeException("未输入退款凭证");
  117. }
  118. if(cashRecordDone.getRefundTime()== null){
  119. throw new RuntimeException("未输入退款时间");
  120. }
  121. if(cashRecordDone.getRefundRemark()== null){
  122. throw new RuntimeException("未输入退款备注");
  123. }
  124. if(cashRecordDone.getRefundChannels()== null){
  125. throw new RuntimeException("未输入退款途径");
  126. }
  127. if(cashRecordDone.getRefundCurrency()== null){
  128. throw new RuntimeException("未输入退款币种");
  129. }
  130. if(cashRecordDone.getRefundAmount()== null){
  131. throw new RuntimeException("未输入退款金额");
  132. }
  133. int result = cashRefundMapper.executor(cashRecordDone);
  134. return (result > 0 ? Result.success("提交成功") : Result.error("提交失败")).getCode();
  135. }
  136. @Override
  137. public int updateStatus(CashRecordDone cashRecordDone) {
  138. return cashRefundMapper.updateStatus(cashRecordDone);
  139. }
  140. @Override
  141. public int finalreview(CashRecordDone cashRecordDone) {
  142. if(cashRecordDone.getStatus()== 32){
  143. CashRecordDone cashRecordDone1 = new CashRecordDone();
  144. cashRecordDone1.setOrderCode(cashRecordDone.getOrderCode().substring(2));
  145. cashRecordDone1.setStatus(4);
  146. cashRefundMapper.updateStatus(cashRecordDone1);
  147. }
  148. if (cashRecordDone.getGoodsName() != null &&
  149. (cashRecordDone.getGoodsName().equals("金币充值") ||
  150. cashRecordDone.getGoodsName().contains("金币充值"))) {
  151. UserGoldRecord userGoldRecord = new UserGoldRecord();
  152. userGoldRecord.setOrderCode(cashRecordDone.getOrderCode());
  153. userGoldRecord.setType((byte) 2);
  154. userGoldRecord.setIsRefund((byte) 1);
  155. userGoldRecord.setRefundType("金币退款");
  156. userGoldRecord.setCrefundModel(cashRecordDone.getRefundModel());
  157. userGoldRecord.setJwcode(cashRecordDone.getJwcode());
  158. userGoldRecord.setSumGold(cashRecordDone.getPermanentGold()+cashRecordDone.getFreeGold());
  159. userGoldRecord.setPermanentGold(cashRecordDone.getPermanentGold());
  160. int currentMonth = LocalDate.now().getMonthValue();
  161. if (currentMonth >= 1 && currentMonth <= 6) {
  162. // 1-6月:设置12月额度,6月保持默认值
  163. userGoldRecord.setFreeJune(0);
  164. userGoldRecord.setFreeDecember(cashRecordDone.getFreeGold());
  165. } else {
  166. // 7-12月:设置6月额度,12月保持默认值
  167. userGoldRecord.setFreeJune(cashRecordDone.getFreeGold());
  168. userGoldRecord.setFreeDecember(0);
  169. }
  170. userGoldRecord.setGoodsName(cashRecordDone.getGoodsName());
  171. userGoldRecord.setPayPlatform("金币系统");
  172. userGoldRecord.setRemark(cashRecordDone.getRemark());
  173. userGoldRecord.setAdminId(cashRecordDone.getAuditId());
  174. userGoldRecord.setAuditStatus(1);
  175. String auditName = auditMapper.getName(cashRecordDone.getAuditId());
  176. refundMapper.add(userGoldRecord);
  177. GoldTistV2.addCoinNew(userGoldRecord.getJwcode().toString(), 58, //退款免费+永久金币-充值
  178. (double) (userGoldRecord.getFreeDecember()+userGoldRecord.getFreeJune()+userGoldRecord.getPermanentGold() ) /100,
  179. userGoldRecord.getRemark(),(double) userGoldRecord.getPermanentGold() / 100, auditName, "退款金币充值");}
  180. cashRefundMapper.updateAudit(cashRecordDone);
  181. int result = cashRefundMapper.review(cashRecordDone);
  182. return (result > 0 ? Result.success("提交成功") : Result.error("提交失败")).getCode();
  183. }
  184. }