소스 검색

处理改价的bug.

yujia 7 년 전
부모
커밋
7e19fd1c90
1개의 변경된 파일9개의 추가작업 그리고 13개의 파일을 삭제
  1. 9 13
      src/main/java/com/uas/platform/b2c/fa/payment/service/impl/InstallmentServiceImpl.java

+ 9 - 13
src/main/java/com/uas/platform/b2c/fa/payment/service/impl/InstallmentServiceImpl.java

@@ -278,7 +278,7 @@ public class InstallmentServiceImpl implements InstallmentService{
         Double total = purchase.getEnsurePrice();
         Double installTotal = installment.getPrice();
         Double dvalue = 0d;
-
+        installment.setPrice(purchase.getEnsurePrice());
         if (NumberUtil.compare(total, installTotal) == 1) {
             InstallmentDetail installmentDetail = installmentDetailDao.findByInstallmentIdAndDetno(installment.getId(), installment.getCount().shortValue());
             if (installmentDetail != null) {
@@ -287,20 +287,17 @@ public class InstallmentServiceImpl implements InstallmentService{
                 installmentDetail.setPrice(NumberUtil.pricesScaleTwo(result));
                 installmentDetailDao.save(installmentDetail);
             }
-        }
-
-
-
-        if (NumberUtil.compare(total, installTotal) == -1) {
+            return installmentDao.save(installment);
+        } else if (NumberUtil.compare(total, installTotal) == -1) {
             for (short i = 1; i < installment.getCount() + 1; i++) {
                 InstallmentDetail installmentDetail = installmentDetailDao.findByInstallmentIdAndDetno(installment.getId(), i);
                 if (installmentDetail == null) {
                     break;
                 }
 
-                dvalue = total - installmentDetail.getPrice();
+                dvalue = NumberUtil.sub(total, installmentDetail.getPrice());
 
-                if (dvalue <= 0) {
+                if (NumberUtil.compare(dvalue, 0.0d) <= 0) {
                     installmentDetail.setPrice(NumberUtil.pricesScaleTwo(total));
                     installmentDetailDao.save(installmentDetail);
                     installmentDetailDao.deleteGtDetno(installment.getId(), i);
@@ -318,12 +315,11 @@ public class InstallmentServiceImpl implements InstallmentService{
                     total = dvalue;
                 }
             }
+            installment.setCount(installment.getInstallmentDetails().size());
+            return installmentDao.save(installment);
+        } else {
+            return installment;
         }
-
-        installment.setPrice(purchase.getEnsurePrice());
-        installment.setCount(installment.getInstallmentDetails().size());
-
-        return installmentDao.save(installment);
     }
 
     @Override