Explorar el Código

Merge remote-tracking branch 'upstream/dev-1.1.4' into dev-1.1.4

hsh hace 2 años
padre
commit
83acaf91a3

+ 6 - 0
src/main/java/cn/hnthyy/thmz/controller/mz/DiscountController.java

@@ -211,6 +211,11 @@ public class DiscountController {
                 resultMap.put("message", "套餐优惠模板不能为空");
                 return resultMap;
             }
+            if(discount.getDiscountType()==2 && discount.getDescription()==null){
+                resultMap.put("code", -1);
+                resultMap.put("message", "套餐描述不能为空");
+                return resultMap;
+            }
             if(!Arrays.asList(YesNoEnum.YES.code,YesNoEnum.NO.code,2).contains(discount.getDiscountType())){
                 resultMap.put("code", -1);
                 resultMap.put("message", "优惠类型值超出范围");
@@ -239,6 +244,7 @@ public class DiscountController {
                 discount.setChargeItemCodes("");
             }else {
                 discount.setTemplateId(null);
+                discount.setDescription("");
             }
             if(discount.getId()==null){
                 discount.setCreateId(tokenUser.getUserIdCode());

+ 8 - 0
src/main/java/cn/hnthyy/thmz/entity/thmz/Discount.java

@@ -101,6 +101,14 @@ public class Discount extends PageBean implements Serializable {
      * 模板id
      */
     private Long templateId;
+    /**
+     * 套餐描述
+     */
+    private String description;
+    /**
+     * 套餐金额
+     */
+    private BigDecimal tcFee;
 
 
 }

+ 6 - 3
src/main/java/cn/hnthyy/thmz/mapper/thmz/DiscountMapper.java

@@ -12,8 +12,8 @@ public interface DiscountMapper {
      * @param discount
      * @return
      */
-    @Insert("INSERT INTO t_discount(name,dept_type,dept_no,discount_begin_time,discount_end_time,charge_item_codes,discount_type,discount_rate,discount_price,delete_flag,create_id,create_time,update_id,update_time,template_id) VALUES" +
-            "(#{name},#{deptType},#{deptNo},#{discountBeginTime},#{discountEndTime},#{chargeItemCodes},#{discountType},#{discountRate,jdbcType=DECIMAL},#{discountPrice,jdbcType=DECIMAL},#{deleteFlag},#{createId},#{createTime},#{updateId},#{updateTime},#{templateId})")
+    @Insert("INSERT INTO t_discount(name,dept_type,dept_no,discount_begin_time,discount_end_time,charge_item_codes,discount_type,discount_rate,discount_price,delete_flag,create_id,create_time,update_id,update_time,template_id,description) VALUES" +
+            "(#{name},#{deptType},#{deptNo},#{discountBeginTime},#{discountEndTime},#{chargeItemCodes},#{discountType},#{discountRate,jdbcType=DECIMAL},#{discountPrice,jdbcType=DECIMAL},#{deleteFlag},#{createId},#{createTime},#{updateId},#{updateTime},#{templateId},#{description})")
     int insert(Discount discount);
 
     /**
@@ -62,6 +62,9 @@ public interface DiscountMapper {
             ",discount_end_time =#{discountEndTime}",
             "</when>",
             ",template_id =#{templateId}",
+            "<when test='description!=null'>",
+            ",description =#{description}",
+            "</when>",
             "</trim>",
             "</script>"})
     int update(Discount discount);
@@ -219,7 +222,7 @@ public interface DiscountMapper {
      */
     @Delete("delete  from t_discount where id =#{id} ")
     int deleteById(@Param("id") Long id);
-    @Select("  select t1.template_id, t1.name,t1.dept_type,t1.dept_no" +
+    @Select("  select t1.template_id, t1.name,t1.dept_type,t1.dept_no,t1.description,t1.discount_rate" +
             " from t_discount t1" +
             "         join t_template t2 on t1.template_id = t2.id" +
             " where t1.delete_flag = 0  and t1.discount_begin_time <=now() and t1.discount_end_time>=now()")

+ 58 - 6
src/main/java/cn/hnthyy/thmz/service/impl/thmz/DiscountServiceImpl.java

@@ -3,6 +3,9 @@ package cn.hnthyy.thmz.service.impl.thmz;
 import cn.hnthyy.thmz.Utils.AssertUtil;
 import cn.hnthyy.thmz.Utils.HttpUtil;
 import cn.hnthyy.thmz.Utils.JsonUtil;
+import cn.hnthyy.thmz.common.Constants;
+import cn.hnthyy.thmz.common.exception.BizException;
+import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.his.mz.JcJyItemCharge;
 import cn.hnthyy.thmz.entity.his.mz.MzChargeDetail;
 import cn.hnthyy.thmz.entity.his.mz.MzYjReq;
@@ -52,6 +55,9 @@ public class DiscountServiceImpl implements DiscountService {
     @SuppressWarnings("all")
     @Autowired
     private ZdUnitCodeService zdUnitCodeService;
+    @SuppressWarnings("all")
+    @Autowired
+    private JcJyItemChargeService jcJyItemChargeService;
 
     /**
      * 缓存
@@ -121,7 +127,13 @@ public class DiscountServiceImpl implements DiscountService {
 
     @Override
     public List<Discount> queryDiscountWithPage(Discount discount) {
-        return discountMapper.selectDiscountWithPage(discount);
+        List<Discount> discounts = discountMapper.selectDiscountWithPage(discount);
+        for(Discount item :discounts){
+            if (item.getTemplateId() != null) {
+                item.setTcFee(getTcFee(item.getTemplateId(),item.getDiscountRate()));
+            }
+        }
+        return discounts;
     }
 
     @Override
@@ -352,14 +364,19 @@ public class DiscountServiceImpl implements DiscountService {
      */
     @Override
     public List<Discount> queryTcByDeptCode(Discount discount) {
-        AssertUtil.isNotBlank(discount.getDeptType(),"科室类型不能为空");
+        AssertUtil.isNotBlank(discount.getDeptType(), "科室类型不能为空");
         List<Discount> discounts = discountMapper.queryTcDiscunt();
         if (CollUtil.isEmpty(discounts)) return discounts;
         if (discount.getDeptType() == 2) {
-          return discounts.stream().filter(item -> item.getDeptType() == 2).collect(Collectors.toList());
-        }else {
-            AssertUtil.isNotBlank(discount.getDeptNo(),"科室编码不能为空");
-            return discounts.stream().filter(item -> (item.getDeptType() == 0 || item.getDeptType() == 1) && equalsDeptNo(item.getDeptNo(), discount.getDeptNo())).collect(Collectors.toList());
+            List<Discount> collect = discounts.stream().filter(item -> item.getDeptType() == 2).collect(Collectors.toList());
+            collect.forEach(item -> item.setTcFee(getTcFee(item.getTemplateId(), item.getDiscountRate())));
+            return collect;
+
+        } else {
+            AssertUtil.isNotBlank(discount.getDeptNo(), "科室编码不能为空");
+            List<Discount> collect = discounts.stream().filter(item -> (item.getDeptType() == 0 || item.getDeptType() == 1) && equalsDeptNo(item.getDeptNo(), discount.getDeptNo())).collect(Collectors.toList());
+            collect.forEach(item -> item.setTcFee(getTcFee(item.getTemplateId(), item.getDiscountRate())));
+            return collect;
         }
     }
 
@@ -373,6 +390,41 @@ public class DiscountServiceImpl implements DiscountService {
         return false;
     }
 
+
+    public BigDecimal getTcFee(Long templateId,BigDecimal discountRate) {
+        BigDecimal yjTotalFee = BigDecimal.ZERO;
+        BigDecimal xmTotalFee = BigDecimal.ZERO;
+        Template template = templateService.queryById(templateId);
+        if (template != null && StrUtil.isNotBlank(template.getTemplateData())) {
+            MzPrescriptionVo mzPrescriptionVo = (MzPrescriptionVo) JsonUtil.jsontoObject(template.getTemplateData(), MzPrescriptionVo.class);
+            if(CollUtil.isNotEmpty(mzPrescriptionVo.getMzYjReqList())){
+                for(MzYjReq mzYjReq :mzPrescriptionVo.getMzYjReqList()){
+                    List<ZdChargeItem> zdChargeItems = null;
+                    try {
+                         zdChargeItems = jcJyItemChargeService.queryJcJyItemChargeByCode(mzYjReq.getOrderCode(), Integer.valueOf(Convert.toInt(mzYjReq.getReqType())-1));
+                        if(CollUtil.isNotEmpty(zdChargeItems)){
+                            yjTotalFee = zdChargeItems.stream().map(item -> item.getTotalAmount().multiply(discountRate)).reduce(BigDecimal.ZERO, BigDecimal::add);
+                        }
+                    }catch (MzException e){
+                        throw new  BizException(e.getMessage(),e);
+                    }
+                }
+            }
+
+            if(CollUtil.isNotEmpty(mzPrescriptionVo.getMzChargeDetailList())){
+                for(MzChargeDetail mzChargeDetail : mzPrescriptionVo.getMzChargeDetailList()){
+                    if(mzChargeDetail.getBillItemCode().equals(Constants.TC)){
+                        continue;
+                    }
+                    BigDecimal unitPrice = mzChargeDetail.getUnitPrice().multiply(discountRate);
+                     xmTotalFee = unitPrice.multiply(BigDecimal.valueOf(mzChargeDetail.getQuantity()).multiply(BigDecimal.valueOf(mzChargeDetail.getDrugWin())));
+                }
+            }
+        }
+        BigDecimal totalFee = yjTotalFee.add(xmTotalFee);
+        return totalFee.setScale(2, BigDecimal.ROUND_HALF_UP);
+    }
+
     /**
      * @param templateId
      * @description:根据模板id 查询项目明细

+ 1 - 0
src/main/java/cn/hnthyy/thmz/service/thmz/DiscountService.java

@@ -1,5 +1,6 @@
 package cn.hnthyy.thmz.service.thmz;
 
+import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.thmz.Discount;
 
 import java.math.BigDecimal;

+ 14 - 0
src/main/resources/static/js/charge/discount.js

@@ -206,6 +206,16 @@ function initDiscountList() {
                         }
                     }
                 }
+            },{
+                field: 'description',
+                title: '套餐描述',
+                align: "center",
+                valign: 'middle'
+            },{
+                field: 'tcFee',
+                title: '套餐总金额',
+                align: "center",
+                valign: 'middle'
             },{
                 field: 'discountType',
                 title: '优惠类型',
@@ -391,17 +401,20 @@ function discountTypeChange(discountType) {
         $("#discountPriceDiv").removeClass("hide");
         $("#chargeItemDiv").removeClass("hide");
         $("#tcTemplateDiv").addClass("hide");
+        $("#tcDescriptionDiv").addClass("hide");
     } else if(discountTypeParams == 1) {
         $("#discountPriceDiv").addClass("hide");
         $("#discountRateDiv").removeClass("hide");
         $("#chargeItemDiv").removeClass("hide");
         $("#tcTemplateDiv").addClass("hide");
+        $("#tcDescriptionDiv").addClass("hide");
     }else {
     //    套餐优惠
         $("#chargeItemDiv").addClass("hide");
         $("#discountPriceDiv").addClass("hide");
         $("#discountRateDiv").removeClass("hide");
         $("#tcTemplateDiv").removeClass("hide");
+        $("#tcDescriptionDiv").removeClass("hide");
     }
 }
 
@@ -642,6 +655,7 @@ $('#save').click(function () {
             "discountEndTime": $("#discountEndTime").val(),
             "chargeItemCodes": chargeItemCodesStr,
             "templateId": $("#tcTemplateParams").val(),
+            "description": $("#descriptionParams").val(),
             "discountType": $("#discountTypeParams").val(),
             "discountPrice": $("#discountPrice").val(),
             "discountRate": $("#discountRate").val(),

+ 8 - 1
src/main/resources/templates/charge/discount.html

@@ -147,7 +147,14 @@
                                     </select>
                                 </div>
                             </div>
-
+                            <div class="item form-group" id="tcDescriptionDiv">
+                                <label class="control-label col-md-3 col-sm-3 col-xs-12" for="descriptionParams">套餐描述
+                                </label>
+                                <div class="col-md-6 col-sm-6 col-xs-12">
+                                    <input  id="descriptionParams"
+                                           class="form-control col-md-7 col-xs-12">
+                                </div>
+                            </div>
                             <div class="item form-group">
                                 <label class="control-label col-md-3 col-sm-3 col-xs-12" for="discountTypeParams">优惠类型 <span
                                         class="required">*</span>

+ 4 - 4
src/main/resources/templates/mz/clinic.html

@@ -2540,7 +2540,7 @@
     <div id="report_table_1">
         <div style="position: relative;">
             <div style="float: left;height: 20px;margin-top: -5px">
-                <svg id="cfBarcode" height="20px;"></svg>
+                <svg id="cfBarcode" height="20"></svg>
             </div>
             <div style="text-align:left;font-weight: 700;margin-left: 160px">长沙泰和医院</div>
             <div style="float: right;color: red;margin-right: 30px;border: 1px solid red;width: 60px;text-align: center;position: absolute;top: 0px;right: 0px;"
@@ -2703,7 +2703,7 @@
     <div style="width: 100%;">
         <div style="width: 100%;">
             <div style="float: left;height: 20px;">
-                <svg id="JcBarcode" height="20px;"></svg>
+                <svg id="JcBarcode" height="20"></svg>
             </div>
             <div style="position: relative;width: 100%;margin-left: -110px;">
                 <div style="text-align: center;font-weight: 700;">长沙泰和医院</div>
@@ -2794,7 +2794,7 @@
     <div style="width: 100%;">
         <div style="width: 100%;">
             <div style="float: left;height: 20px;">
-                <svg id="JyBarcode" height="20px;"></svg>
+                <svg id="JyBarcode" height="20"></svg>
             </div>
             <div style="position: relative;width: 100%;margin-left: -110px;">
                 <div style="text-align:center;font-weight: 700;">长沙泰和医院</div>
@@ -3166,7 +3166,7 @@
     <div style="width: 100%;">
         <div style="width: 100%;">
             <div style="float: left;height: 29px;">
-                <svg id="JcBarcode" height="29px;"></svg>
+                <svg id="JcBarcode" height="29"></svg>
             </div>
             <div style="position: relative;width: 100%;margin-left: -110px;font-size: 20px">
                 <div style="text-align: center;font-weight: 700;">长沙泰和医院</div>