|
|
@@ -3,6 +3,7 @@ package com.uas.platform.b2c.fa.payment.service.impl;
|
|
|
import com.uas.platform.b2c.core.constant.Status;
|
|
|
import com.uas.platform.b2c.core.constant.Type;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
+import com.uas.platform.b2c.core.utils.NumberUtil;
|
|
|
import com.uas.platform.b2c.fa.payment.dao.InstallmentDao;
|
|
|
import com.uas.platform.b2c.fa.payment.dao.InstallmentDetailDao;
|
|
|
import com.uas.platform.b2c.fa.payment.dao.InstallmentStoreDao;
|
|
|
@@ -11,8 +12,10 @@ import com.uas.platform.b2c.fa.payment.service.BankInfoService;
|
|
|
import com.uas.platform.b2c.fa.payment.service.InstallmentService;
|
|
|
import com.uas.platform.b2c.trade.order.dao.OrderDao;
|
|
|
import com.uas.platform.b2c.trade.order.dao.PurchaseDao;
|
|
|
+import com.uas.platform.b2c.trade.order.dao.PurchaseDetailDao;
|
|
|
import com.uas.platform.b2c.trade.order.model.Order;
|
|
|
import com.uas.platform.b2c.trade.order.model.Purchase;
|
|
|
+import com.uas.platform.b2c.trade.order.model.PurchaseDetail;
|
|
|
import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -42,14 +45,17 @@ public class InstallmentServiceImpl implements InstallmentService{
|
|
|
|
|
|
private final InstallmentDetailDao installmentDetailDao;
|
|
|
|
|
|
+ private final PurchaseDetailDao purchaseDetailDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
- public InstallmentServiceImpl(InstallmentStoreDao installmentStoreDao, PurchaseDao purchaseDao, OrderDao orderDao, InstallmentDao installmentDao, BankInfoService bankInfoService, InstallmentDetailDao installmentDetailDao) {
|
|
|
+ public InstallmentServiceImpl(InstallmentStoreDao installmentStoreDao, PurchaseDao purchaseDao, OrderDao orderDao, InstallmentDao installmentDao, BankInfoService bankInfoService, InstallmentDetailDao installmentDetailDao, PurchaseDetailDao purchaseDetailDao) {
|
|
|
this.installmentStoreDao = installmentStoreDao;
|
|
|
this.purchaseDao = purchaseDao;
|
|
|
this.orderDao = orderDao;
|
|
|
this.installmentDao = installmentDao;
|
|
|
this.bankInfoService = bankInfoService;
|
|
|
this.installmentDetailDao = installmentDetailDao;
|
|
|
+ this.purchaseDetailDao = purchaseDetailDao;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -201,6 +207,48 @@ public class InstallmentServiceImpl implements InstallmentService{
|
|
|
installmentDao.delete(installment.getId());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Installment updateAfterModifyPurchasePrice(String purchaseDetailId) {
|
|
|
+ PurchaseDetail purchaseDetail = purchaseDetailDao.findByDetailid(purchaseDetailId);
|
|
|
+ if (purchaseDetail == null)
|
|
|
+ throw new IllegalOperatorException("订单改价明细数据不存在,请重新确认订单信息");
|
|
|
+ Purchase purchase = purchaseDetail.getPurchase();
|
|
|
+
|
|
|
+ if (purchase != null && purchase.getInstallmentId() != null)
|
|
|
+ validationEnableInstallment(purchase.getId());
|
|
|
+
|
|
|
+ Installment installment = installmentDao.findByPurchaseId(purchase.getId());
|
|
|
+
|
|
|
+ Double total = purchase.getPrice();
|
|
|
+ Double installTotal = installment.getPrice();
|
|
|
+ Double dvalue = 0d;
|
|
|
+
|
|
|
+ if (NumberUtil.compare(total, installTotal) != 0) {
|
|
|
+ for (short i = 1; i < installment.getCount(); i++) {
|
|
|
+ InstallmentDetail installmentDetail = installmentDetailDao.findByInstallmentIdAndDetno(installment.getId(), i);
|
|
|
+ if (installmentDetail == null) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ dvalue = total - installmentDetail.getPrice();
|
|
|
+
|
|
|
+ if (dvalue <= 0) {
|
|
|
+ installmentDetail.setPrice(total);
|
|
|
+ installmentDetailDao.save(installmentDetail);
|
|
|
+ installmentDetailDao.deleteGtDetno(installment.getId(), i);
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ total = dvalue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ installment.setPrice(purchase.getPrice());
|
|
|
+ installment.setCount(installment.getInstallmentDetails().size());
|
|
|
+
|
|
|
+ return installmentDao.save(installment);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public String validationEnableInstallment(Long purchaseId) {
|
|
|
validatePurchase(purchaseId);// 验证采购单、订单信息
|