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.

94 lines
3.9 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.service.cash.CashCollectionService;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Service;
  9. import java.util.UUID;
  10. /**
  11. * @program: gold-java
  12. * @ClassName cashCollectionServiceImpl
  13. * @description:
  14. * @author: Ethan
  15. * @create: 202509-26 11:23
  16. * @Version 1.0
  17. **/
  18. @Service
  19. public class CashCollectionServiceImpl implements CashCollectionService {
  20. @Autowired
  21. private CashCollectionMapper cashCollectionMapper;
  22. //新增收款订单
  23. @Override
  24. public Result add(CashCollection cashCollection) {
  25. if (cashCollection.getJwcode()==null){
  26. return Result.error("精网号不能为空");
  27. }
  28. if(cashCollection.getJwcode()<10000000||cashCollection.getJwcode()>99999999){
  29. return Result.error("精网号必须为8位");
  30. }
  31. if(cashCollection.getName()== null){
  32. return Result.error("客户姓名不能为空");
  33. }
  34. if(cashCollection.getActivity()== null){
  35. return Result.error("活动不能为空");
  36. }
  37. if(cashCollection.getGoodsName()== null){
  38. return Result.error("商品名不能为空");
  39. }
  40. if(cashCollection.getGoodsNum()== null){
  41. return Result.error("商品数量不能为空");
  42. }
  43. if(cashCollection.getPaymentCurrency()== null){
  44. return Result.error("支付币种不能为空");
  45. }
  46. if(cashCollection.getPaymentAmount()== null){
  47. return Result.error("支付金额不能为空");
  48. }
  49. if (cashCollection.getPayType()== null){
  50. return Result.error("支付方式不能为空");
  51. }
  52. if (cashCollection.getReceivedMarket()== null){
  53. return Result.error("到账地区不能为空");
  54. }
  55. if(cashCollection.getPayTime()== null){
  56. return Result.error("付款时间不能为空");
  57. }
  58. if (cashCollection.getVoucher()== null){
  59. return Result.error("转账凭证不能为空");
  60. }
  61. if (cashCollection.getRemark()==null){
  62. return Result.error("备注不能为空");
  63. }
  64. //生成订单号后半部分
  65. String orderNumber = UUID.randomUUID().toString().replaceAll("-", "");
  66. CashRecord cashRecord = new CashRecord();
  67. //构建订单信息
  68. cashRecord.setOrderCode("XJ_" + orderNumber); //订单号
  69. cashRecord.setJwcode(cashCollection.getJwcode()); //精网号
  70. cashRecord.setName(cashCollection.getName()); //客户姓名
  71. cashRecord.setActivity(cashCollection.getActivity()); // 活动
  72. cashRecord.setGoodsName(cashCollection.getGoodsName()); //商品名称
  73. cashRecord.setGoodNum(cashCollection.getGoodsNum()); //商品数量
  74. cashRecord.setPaymentCurrency(cashCollection.getPaymentCurrency()); //付款币种
  75. cashRecord.setPaymentAmount(cashCollection.getPaymentAmount()); //付款金额
  76. cashRecord.setReceivedMarket(cashCollection.getReceivedMarket()); //到账地区
  77. cashRecord.setPayType(cashCollection.getPayType()); //支付方式
  78. cashRecord.setPayTime(cashCollection.getPayTime()); //付款时间
  79. cashRecord.setVoucher(cashCollection.getVoucher()); //转账凭证
  80. cashRecord.setRemark(cashCollection.getRemark()); //备注
  81. cashRecord.setStatus(0); //订单状态:付款线下财务待审核
  82. cashRecord.setSubmitterId(cashCollection.getSubmitterId()); //提交人ID
  83. cashRecord.setOrderType(1); //订单类型:1-收款
  84. //插入新收款订单
  85. cashCollectionMapper.add(cashRecord);
  86. return Result.success("添加成功");
  87. }
  88. }