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.

188 lines
7.8 KiB

  1. package com.example.demo.serviceImpl.cash;
  2. import com.example.demo.domain.entity.CashRecord;
  3. import com.example.demo.domain.vo.cash.CashCollection;
  4. import com.example.demo.domain.vo.coin.Result;
  5. import com.example.demo.mapper.cash.CashCollectionMapper;
  6. import com.example.demo.mapper.coin.MarketMapper;
  7. import com.example.demo.service.cash.CashCollectionService;
  8. import com.github.pagehelper.PageHelper;
  9. import com.github.pagehelper.PageInfo;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Service;
  12. import java.util.List;
  13. import java.util.UUID;
  14. /**
  15. * @program: gold-java
  16. * @ClassName cashCollectionServiceImpl
  17. * @description:
  18. * @author: Ethan
  19. * @create: 202509-26 11:23
  20. * @Version 1.0
  21. **/
  22. @Service
  23. public class CashCollectionServiceImpl implements CashCollectionService {
  24. @Autowired
  25. private CashCollectionMapper cashCollectionMapper;
  26. @Autowired
  27. private MarketMapper marketMapper;
  28. //新增收款订单
  29. @Override
  30. public Result add(CashCollection cashCollection) {
  31. if (cashCollection.getJwcode()==null){
  32. return Result.error("精网号不能为空");
  33. }
  34. if(cashCollection.getJwcode()<10000000||cashCollection.getJwcode()>99999999){
  35. return Result.error("精网号必须为8位");
  36. }
  37. if(cashCollection.getName()== null){
  38. return Result.error("客户姓名不能为空");
  39. }
  40. if(cashCollection.getActivity()== null){
  41. return Result.error("活动不能为空");
  42. }
  43. if(cashCollection.getGoodsName()== null){
  44. return Result.error("商品名不能为空");
  45. }
  46. if(cashCollection.getGoodNum()== null){
  47. return Result.error("商品数量不能为空");
  48. }
  49. if(cashCollection.getPaymentCurrency()== null){
  50. return Result.error("支付币种不能为空");
  51. }
  52. if(cashCollection.getPaymentAmount()== null){
  53. return Result.error("支付金额不能为空");
  54. }
  55. if (cashCollection.getPayType()== null){
  56. return Result.error("支付方式不能为空");
  57. }
  58. if (cashCollection.getReceivedMarket()== null){
  59. return Result.error("到账地区不能为空");
  60. }
  61. if(cashCollection.getPayTime()== null){
  62. return Result.error("付款时间不能为空");
  63. }
  64. if (cashCollection.getVoucher()== null){
  65. return Result.error("转账凭证不能为空");
  66. }
  67. if (cashCollection.getRemark()==null){
  68. return Result.error("备注不能为空");
  69. }
  70. //生成订单号后半部分
  71. String orderNumber = UUID.randomUUID().toString().replaceAll("-", "");
  72. CashRecord cashRecord = new CashRecord();
  73. //构建订单信息
  74. cashRecord.setOrderCode("XJ_" + orderNumber); //订单号
  75. cashRecord.setJwcode(cashCollection.getJwcode()); //精网号
  76. cashRecord.setName(cashCollection.getName()); //客户姓名
  77. cashRecord.setActivity(cashCollection.getActivity()); // 活动
  78. cashRecord.setGoodsName(cashCollection.getGoodsName()); //商品名称
  79. cashRecord.setGoodNum(cashCollection.getGoodNum()); //商品数量
  80. cashRecord.setPaymentCurrency(cashCollection.getPaymentCurrency()); //付款币种
  81. cashRecord.setPaymentAmount(cashCollection.getPaymentAmount()); //付款金额
  82. cashRecord.setReceivedMarket(cashCollection.getReceivedMarket()); //到账地区
  83. cashRecord.setPayType(cashCollection.getPayType()); //支付方式
  84. cashRecord.setPayTime(cashCollection.getPayTime()); //付款时间
  85. cashRecord.setVoucher(cashCollection.getVoucher()); //转账凭证
  86. cashRecord.setRemark(cashCollection.getRemark()); //备注
  87. cashRecord.setStatus(0); //订单状态:付款线下财务待审核
  88. cashRecord.setSubmitterId(cashCollection.getSubmitterId()); //提交人ID
  89. cashRecord.setOrderType(1); //订单类型:1-收款
  90. //地区,根据jwcode插入
  91. cashRecord.setMarket(cashCollectionMapper.getMarketByJwcode(cashRecord.getJwcode()));
  92. //插入新收款订单
  93. cashCollectionMapper.add(cashRecord);
  94. return Result.success("添加成功");
  95. }
  96. //撤回未审核的订单
  97. @Override
  98. public Result cancel(String orderCode) {
  99. CashRecord cashRecord = cashCollectionMapper.selectByOrderCode(orderCode);
  100. if (cashRecord == null) {
  101. return Result.error("订单不存在");
  102. }
  103. if (cashRecord.getStatus() != 0){
  104. return Result.error("订单状态不符合条件");
  105. }
  106. //修改订单状态
  107. int rows = cashCollectionMapper.updateStatus(orderCode, 5);
  108. return rows > 0 ? Result.success("撤回成功") : Result.error("撤回失败");
  109. }
  110. //编辑并重新提交收款订单
  111. @Override
  112. public Result reSubmit(CashRecord cashRecord) {
  113. if (cashRecord.getJwcode()==null){
  114. return Result.error("精网号不能为空");
  115. }
  116. if(cashRecord.getJwcode()<10000000||cashRecord.getJwcode()>99999999){
  117. return Result.error("精网号必须为8位");
  118. }
  119. if(cashRecord.getName()== null){
  120. return Result.error("客户姓名不能为空");
  121. }
  122. if(cashRecord.getActivity()== null){
  123. return Result.error("活动不能为空");
  124. }
  125. if(cashRecord.getGoodsName()== null){
  126. return Result.error("商品名不能为空");
  127. }
  128. if(cashRecord.getGoodNum()== null){
  129. return Result.error("商品数量不能为空");
  130. }
  131. if(cashRecord.getPaymentCurrency()== null){
  132. return Result.error("支付币种不能为空");
  133. }
  134. if(cashRecord.getPaymentAmount()== null){
  135. return Result.error("支付金额不能为空");
  136. }
  137. if (cashRecord.getPayType()== null){
  138. return Result.error("支付方式不能为空");
  139. }
  140. if (cashRecord.getReceivedMarket()== null){
  141. return Result.error("到账地区不能为空");
  142. }
  143. if(cashRecord.getPayTime()== null){
  144. return Result.error("付款时间不能为空");
  145. }
  146. if (cashRecord.getVoucher()== null){
  147. return Result.error("转账凭证不能为空");
  148. }
  149. if (cashRecord.getRemark()==null){
  150. return Result.error("备注不能为空");
  151. }
  152. CashRecord status=cashCollectionMapper.selectByOrderCode(cashRecord.getOrderCode());
  153. if (!status.getStatus().equals(5)){
  154. return Result.error("只允许编辑已撤回订单");
  155. }
  156. //地区,根据jwcode插入
  157. cashRecord.setMarket(cashCollectionMapper.getMarketByJwcode(cashRecord.getJwcode()));
  158. int rows = cashCollectionMapper.updateByOrderCode(cashRecord);
  159. return rows > 0 ? Result.success("重新提交成功") : Result.error("重新提交失败");
  160. }
  161. //多条件查询收款订单列表
  162. @Override
  163. public PageInfo<CashCollection> selectCollection(Integer pageNum, Integer pageSize, CashCollection cashCollection) {
  164. //将操作人的地区列表改为id
  165. List<String> markets = marketMapper.getMarketIds(cashCollection.getMarkets());
  166. if (markets.contains("9") || markets.contains("9999")){
  167. markets=null;
  168. }
  169. cashCollection.setMarkets(markets);
  170. PageHelper.startPage(pageNum, pageSize);
  171. List<CashCollection> cashCollections = cashCollectionMapper.selectCollection1(pageNum, pageSize, cashCollection);
  172. return new PageInfo<>(cashCollections);
  173. }
  174. //补全手续费等内容
  175. @Override
  176. public Result complete(CashRecord cashRecord) {
  177. int rows = cashCollectionMapper.complete(cashRecord);
  178. return rows > 0 ? Result.success("编辑成功") : Result.error("编辑失败");
  179. }
  180. }