Browse Source

优化优惠价问题

hurugang 4 years ago
parent
commit
c852f3f701

+ 5 - 6
src/main/java/cn/hnthyy/thmz/service/impl/his/MzChargeDetailServiceImpl.java

@@ -328,7 +328,8 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
                 }
             }
         }
-        formatPriceRoundDetail(mzChargeDetail, mzChargeDetails, mzPatientMi, mzChargeDetailList, maxOrderNo, itemNo, receiptNo,true);
+        //预览的时候获取费用明细,需要打折,不是预览而是入库的时候不打折,因为入库后会有一次重新计算
+        formatPriceRoundDetail(mzChargeDetail, mzChargeDetails, mzPatientMi, mzChargeDetailList, maxOrderNo, itemNo, receiptNo,YesNoEnum.YES.equals(yesNo)?true:false);
         //yes 预览需要将原数据库中已存在的明细与临时生成的一起返回
         if (YesNoEnum.YES.equals(yesNo)) {
             for (MzChargeDetail mcd : mzChargeDetailList) {
@@ -439,7 +440,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
         //所有应收费用的明细 将所有费用按照类型归类
         Map<String, BigDecimal> feeMap = new HashMap<>();
         //实际应付金额
-        BigDecimal totalPayable = getTotalPayable(mzChargeDetailList, feeMap,false);
+        BigDecimal totalPayable = getTotalPayable(mzChargeDetailList, feeMap,true);
         //实际应付金额  四舍五入后的值 收费员收的钱小数点后只有一位有效值
         BigDecimal totalPayableRound = totalPayable.setScale(1, BigDecimal.ROUND_HALF_UP);
         //单病种收费不设置金额,所以自动设置金额
@@ -668,8 +669,8 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
                 if (mzChargeDetail.getAmount() != null) {
                     mzChargeDetail.setAmount(mzChargeDetail.getAmount().setScale(1, BigDecimal.ROUND_HALF_UP));
                     if(mzChargeDetail.getNotDiscountAmount()!=null){
-                        mzChargeDetail.setDiscountAmount(mzChargeDetail.getNotDiscountAmount().subtract(mzChargeDetail.getAmount()).setScale(1, BigDecimal.ROUND_HALF_UP));
                         mzChargeDetail.setNotDiscountAmount(mzChargeDetail.getNotDiscountAmount().setScale(1, BigDecimal.ROUND_HALF_UP));
+                        mzChargeDetail.setDiscountAmount(mzChargeDetail.getNotDiscountAmount().subtract(mzChargeDetail.getAmount()).setScale(1, BigDecimal.ROUND_HALF_UP));
                     }
                 }
             }
@@ -2094,11 +2095,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
                     unitPrice = BigDecimal.valueOf(0.01D);
                     mzChargeDetail.setUnitPrice(unitPrice);
                 }
-                if(mzChargeDetail.getOrigPrice()==null){
-                    mzChargeDetail.setOrigPrice(unitPrice);
-                }
                 //进行营销折扣计算并写入库 优先申请科室的折扣率  医生系统做完移走开始
                 if(needDiscount){
+                    mzChargeDetail.setOrigPrice(unitPrice);
                     Discount discount=null;
                     if(StringUtils.isNotBlank(mzChargeDetail.getWarnDept())){
                         discount= discountService.getDiscountRate(YesNoEnum.NO.code,mzChargeDetail.getWarnDept(),mzChargeDetail.getChargeItemCode());