package com.example.demo.serviceImpl.cash; import com.example.demo.domain.entity.CashRecord; import com.example.demo.domain.vo.cash.CashCollection; import com.example.demo.domain.vo.coin.Result; import com.example.demo.mapper.cash.CashCollectionMapper; import com.example.demo.service.cash.CashCollectionService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.UUID; /** * @program: gold-java * @ClassName cashCollectionServiceImpl * @description: * @author: Ethan * @create: 2025−09-26 11:23 * @Version 1.0 **/ @Service public class CashCollectionServiceImpl implements CashCollectionService { @Autowired private CashCollectionMapper cashCollectionMapper; //新增收款订单 @Override public Result add(CashCollection cashCollection) { if (cashCollection.getJwcode()==null){ return Result.error("精网号不能为空"); } if(cashCollection.getJwcode()<10000000||cashCollection.getJwcode()>99999999){ return Result.error("精网号必须为8位"); } if(cashCollection.getName()== null){ return Result.error("客户姓名不能为空"); } if(cashCollection.getActivity()== null){ return Result.error("活动不能为空"); } if(cashCollection.getGoodsName()== null){ return Result.error("商品名不能为空"); } if(cashCollection.getGoodsNum()== null){ return Result.error("商品数量不能为空"); } if(cashCollection.getPaymentCurrency()== null){ return Result.error("支付币种不能为空"); } if(cashCollection.getPaymentAmount()== null){ return Result.error("支付金额不能为空"); } if (cashCollection.getPayType()== null){ return Result.error("支付方式不能为空"); } if (cashCollection.getReceivedMarket()== null){ return Result.error("到账地区不能为空"); } if(cashCollection.getPayTime()== null){ return Result.error("付款时间不能为空"); } if (cashCollection.getVoucher()== null){ return Result.error("转账凭证不能为空"); } if (cashCollection.getRemark()==null){ return Result.error("备注不能为空"); } //生成订单号后半部分 String orderNumber = UUID.randomUUID().toString().replaceAll("-", ""); CashRecord cashRecord = new CashRecord(); //构建订单信息 cashRecord.setOrderCode("XJ_" + orderNumber); //订单号 cashRecord.setJwcode(cashCollection.getJwcode()); //精网号 cashRecord.setName(cashCollection.getName()); //客户姓名 cashRecord.setActivity(cashCollection.getActivity()); // 活动 cashRecord.setGoodsName(cashCollection.getGoodsName()); //商品名称 cashRecord.setGoodNum(cashCollection.getGoodsNum()); //商品数量 cashRecord.setPaymentCurrency(cashCollection.getPaymentCurrency()); //付款币种 cashRecord.setPaymentAmount(cashCollection.getPaymentAmount()); //付款金额 cashRecord.setReceivedMarket(cashCollection.getReceivedMarket()); //到账地区 cashRecord.setPayType(cashCollection.getPayType()); //支付方式 cashRecord.setPayTime(cashCollection.getPayTime()); //付款时间 cashRecord.setVoucher(cashCollection.getVoucher()); //转账凭证 cashRecord.setRemark(cashCollection.getRemark()); //备注 cashRecord.setStatus(0); //订单状态:付款线下财务待审核 cashRecord.setSubmitterId(cashCollection.getSubmitterId()); //提交人ID cashRecord.setOrderType(1); //订单类型:1-收款 //插入新收款订单 cashCollectionMapper.add(cashRecord); return Result.success("添加成功"); } }