|
@@ -34,6 +34,7 @@ import com.fjhx.paymentgoods.service.IPaymentGoodsService;
|
|
|
import com.fjhx.purchase.entity.PurchaseContract;
|
|
|
import com.fjhx.purchase.service.IPurchaseContractService;
|
|
|
import com.fjhx.subscribe.enums.SubscribeStatusEnum;
|
|
|
+import com.fjhx.utils.Assert;
|
|
|
import com.fjhx.utils.ExampleAbstract;
|
|
|
import com.fjhx.utils.ExampleResult;
|
|
|
import com.fjhx.utils.FlowConstructor;
|
|
@@ -45,7 +46,6 @@ import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.core.tool.utils.id.IdUtils;
|
|
|
-import org.springblade.system.attachment.entity.Attachment;
|
|
|
import org.springblade.system.constant.RoleConstant;
|
|
|
import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
@@ -55,10 +55,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.time.LocalDate;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -158,7 +156,7 @@ public class PaymentGoodsFlowServiceImpl implements IPaymentGoodsFlowService {
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
@Override
|
|
|
public boolean deleteLogic(String flowLinkNo) {
|
|
|
- //旧数据做伪删除
|
|
|
+ // 旧数据做伪删除
|
|
|
return iPaymentGoodsService.deleteLogic(flowLinkNo);
|
|
|
}
|
|
|
}
|
|
@@ -173,22 +171,36 @@ public class PaymentGoodsFlowServiceImpl implements IPaymentGoodsFlowService {
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
@Override
|
|
|
public void start(PaymentGoods entity) {
|
|
|
- //提交时候检查 付款金额+已付款金额是否大于合同金额 大于不让提交
|
|
|
+ // 提交时候检查 付款金额+已付款金额是否大于合同金额 大于不让提交
|
|
|
List<PaymentGoodsDetails> details = entity.getDetails();
|
|
|
- for (PaymentGoodsDetails paymentGoodsDetails : details) {
|
|
|
- PurchaseContract purchaseContract = iPurchaseContractService.lambdaQuery().eq(PurchaseContract::getId, paymentGoodsDetails.getPurchaseContractId()).one();
|
|
|
- BigDecimal money = paymentGoodsDetails.getMoney();//付款金额
|
|
|
- BigDecimal purchasePrice = purchaseContract.getPurchasePrice();//合同金额
|
|
|
|
|
|
- QueryWrapper wrapper = new QueryWrapper();
|
|
|
+ for (PaymentGoodsDetails paymentGoodsDetailsItem : details) {
|
|
|
+
|
|
|
+ // 付款金额
|
|
|
+ BigDecimal money = paymentGoodsDetailsItem.getMoney();
|
|
|
+ Assert.notEmpty(money, "付款金额不能为空");
|
|
|
+
|
|
|
+ // 合同id
|
|
|
+ String purchaseContractId = paymentGoodsDetailsItem.getPurchaseContractId();
|
|
|
+ Assert.notEmpty(purchaseContractId, "合同id不能为空");
|
|
|
+
|
|
|
+ // 获取合同金额
|
|
|
+ PurchaseContract purchaseContract = iPurchaseContractService.getById(purchaseContractId);
|
|
|
+ Assert.notEmpty(purchaseContract, "没有找到对应合同");
|
|
|
+ BigDecimal purchasePrice = purchaseContract.getPurchasePrice();
|
|
|
+
|
|
|
+ // 查询已付金额
|
|
|
+ QueryWrapper<PaymentGoodsDetails> wrapper = new QueryWrapper<>();
|
|
|
wrapper.select("sum(money) as money");
|
|
|
- wrapper.eq("purchase_contract_id", paymentGoodsDetails.getPurchaseContractId());
|
|
|
- PaymentGoodsDetails paymentGoodsDetails0 = paymentGoodsDetailsService.getOne(wrapper);
|
|
|
- BigDecimal payMoney = paymentGoodsDetails0.getMoney();//已付款金额
|
|
|
+ wrapper.lambda().eq(PaymentGoodsDetails::getPurchaseContractId, purchaseContractId);
|
|
|
+ PaymentGoodsDetails paymentGoodsDetails = paymentGoodsDetailsService.getOne(wrapper);
|
|
|
+ BigDecimal payMoney = paymentGoodsDetails == null ? BigDecimal.ZERO : paymentGoodsDetails.getMoney();
|
|
|
|
|
|
+ // 判断合同金额不能大于总付款金额
|
|
|
if (payMoney.add(money).compareTo(purchasePrice) > 0) {
|
|
|
- throw new ServiceException("总付款金额大于合同金额");
|
|
|
+ throw new ServiceException("总付款金额不能大于合同金额");
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//初始化业务数据ID
|