Browse Source

股东卡优先级优化

lihong 8 months ago
parent
commit
d96586e070

+ 18 - 0
src/main/java/cn/hnthyy/thmz/controller/mz/MzPatientMiController.java

@@ -864,6 +864,24 @@ public class MzPatientMiController {
         return R.ok();
     }
 
+    @PostMapping("/updateDiscountLv")
+    public R updateDiscountLv(@RequestBody Map<String,Object> params){
+        String patientId = Convert.toStr(params.get("patientId"));
+        String discountLv = Convert.toStr(params.get("discountLv"));
+        AssertUtil.isNotBlank(patientId,"门诊号不能为空");
+        AssertUtil.isNotBlank(discountLv,"优惠优先级不能为空");
+        shareholderCardService.updateDiscountLvByPatientId(patientId, discountLv);
+        return R.ok();
+    }
+    @PostMapping("/queryDiscountLv")
+    public R queryDiscountLv(@RequestBody Map<String,Object> params){
+        String patientId = Convert.toStr(params.get("patientId"));
+        AssertUtil.isNotBlank(patientId,"门诊号不能为空");
+        String data = shareholderCardService.queryDiscountLvByPatientId(patientId);
+        return R.ok().put("data",Convert.toStr(data,"0"));
+    }
+
+
     //@GetMapping("/insertNewGdkPatientInfo")
     //public R insertNewGdkPatientInfo(){
     //    shareholderCardService.insertNewGdkPatientInfo();

+ 12 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/mz/ShareholderCardMapper.java

@@ -6,6 +6,7 @@ import cn.hnthyy.thmz.entity.his.zd.ZdChargeItem;
 import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 
 import java.util.Date;
 import java.util.List;
@@ -126,4 +127,15 @@ public interface ShareholderCardMapper {
     List<MzPatientMi> getNewPatientInfo();
     @Delete(" delete from  zd_visit_type_user where patient_id =#{patientId} ")
     int deleteShareholderCard(String patientId);
+    /**
+     * @description: 查询优惠优先级 0 或 null 套餐优先 1 股东卡优先
+     * @author: lihong
+     * @date: 2024/12/10 10:29
+     * @param: patientId
+     * @return: java.lang.String
+     **/
+    @Select(" select discount_lv from zd_visit_type_user where patient_id=#{patientId} ")
+    String selectDiscountLvByPatientId(String patientId);
+    @Update(" update  zd_visit_type_user set discount_lv = #{discountLv} where patient_id = #{patientId} ")
+    int updateDiscountLvByPatientId(@Param("patientId") String patientId,@Param("discountLv") String discountLv);
 }

+ 16 - 0
src/main/java/cn/hnthyy/thmz/service/his/mz/ShareholderCardService.java

@@ -74,4 +74,20 @@ public interface ShareholderCardService {
      * @return: null
      **/
    boolean checMzTckByPatientAndTimes(String patientId,Integer times,Integer mztczf);
+    /**
+     * @description: 查询优惠优先级 0 或 null 套餐优先 1 股东卡优先
+     * @author: lihong
+     * @date: 2024/12/10 10:31
+     * @param: patientId
+     * @return: java.lang.String
+     **/
+    String queryDiscountLvByPatientId(String patientId);
+    /**
+     * @description: 修改 优惠优先级
+     * @author: lihong
+     * @date: 2024/12/10 10:32
+     * @param: patientId
+     * @return: int
+     **/
+    int updateDiscountLvByPatientId(String patientId,String discountLv);
 }

+ 35 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzChargeDetailServiceImpl.java

@@ -6151,6 +6151,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
             }
         }
         if (mzChargeDetailList != null && !mzChargeDetailList.isEmpty()) {
+            String discountLv = shareholderCardService.queryDiscountLvByPatientId(mzChargeDetailList.get(0).getPatientId());
             if(needDiscount){
                String zyDiscountGroup = dictDataService.queryDictVlaue("2.0","zy_discount_group","81");
                 List<String> zyDiscountGroups = CollUtil.newArrayList(zyDiscountGroup.split(","));
@@ -6177,7 +6178,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
                     if(mzChargeDetail.getOrigPrice()!=null && mzChargeDetail.getOrigPrice().compareTo(mzChargeDetail.getUnitPrice())==0){
                         mzChargeDetail.setOrigPrice(unitPrice);
                     }
-                    if(CollUtil.isNotEmpty(zdDiscountDetailMap)){
+                    // 0 套餐优惠优先   1 股东卡优先
+                    String disLv = getDisocuntLv(zdDiscountDetailMap,chargeItemCodes,mzChargeDetail.getWarnDept(),mzChargeDetail.getChargeItemCode(),discountLv);
+                    if(NumberEnum.ONE.getCode().equals(disLv)){
                             ZdDiscountDetail zdDiscountDetail;
                             if("1".equals(Convert.toStr(mzChargeDetail.getReqYj(),"0")) && CollUtil.isNotEmpty(ReqNoGroup) && mzChargeDetail.getReqNo() != null && CollUtil.isNotEmpty(ReqNoGroup.get(mzChargeDetail.getReqNo()))){
 
@@ -6256,6 +6259,37 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
         return totalPayable.setScale(2, BigDecimal.ROUND_HALF_UP);
     }
 
+    private String getDisocuntLv(Map<String, ZdDiscountDetail> zdDiscountDetailMap, List<String> chargeItemCodes, String warnDept, String chargeItemCode,String disocuntLv) {
+        String disLv = NumberEnum.ZERO.getCode();
+        boolean tcDiscount = false;
+        Map<String, BigDecimal> discountMap = discountService.getTcDiscountRate(2, null, chargeItemCodes);
+        if(CollUtil.isEmpty(discountMap) && StrUtil.isNotBlank(warnDept)){
+            discountMap = discountService.getTcDiscountRate(0, warnDept, chargeItemCodes);
+        }
+        if(CollUtil.isNotEmpty(discountMap)){
+            tcDiscount = true;
+        }else {
+            Discount discount ;
+            discount = discountService.getDiscountRate(2, null, chargeItemCode);
+            if (discount ==null && StringUtils.isNotBlank(warnDept)) {
+                discount = discountService.getDiscountRate(YesNoEnum.NO.code, warnDept, chargeItemCode);
+            }
+            if(discount != null){
+                tcDiscount = true;
+            }
+        }
+        //同时又股东卡优惠 和套餐优惠 根据优先级判断
+        if(CollUtil.isNotEmpty(zdDiscountDetailMap) && tcDiscount){
+            if(NumberEnum.ONE.getCode().equals(Convert.toStr(disocuntLv,"0"))){
+                disLv = NumberEnum.ONE.getCode();
+            }
+        }else if (CollUtil.isNotEmpty(zdDiscountDetailMap)){
+            disLv = NumberEnum.ONE.getCode();
+        }
+        return disLv;
+    }
+
+
     private void setChargeCodes(List<MzChargeDetail> mzChargeDetailList, List<String> chargeItemCodes, List<MzYjReq> tempMzYjReq) {
         List<Integer> collect = tempMzYjReq.stream().map(item -> item.getReqNo()).collect(Collectors.toList());
         Map<Integer, List<MzYjReq>> ReqNoGroup = tempMzYjReq.stream().collect(Collectors.groupingBy(item -> item.getReqNo()));

+ 24 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/ShareholderCardServiceImpl.java

@@ -246,4 +246,28 @@ public class ShareholderCardServiceImpl implements ShareholderCardService {
         if(CollUtil.isNotEmpty(clinicList) && clinicList.stream().anyMatch(item->Convert.toInt(item.getZgmztczf(),0)==1)) return true;
         return false;
     }
+
+    /**
+     * @description: 查询优惠优先级 0 或 null 套餐优先 1 股东卡优先
+     * @author: lihong
+     * @date: 2024/12/10 10:31
+     * @param: patientId
+     * @return: java.lang.String
+     */
+    @Override
+    public String queryDiscountLvByPatientId(String patientId) {
+        return dao.selectDiscountLvByPatientId(patientId);
+    }
+
+    /**
+     * @description: 修改 优惠优先级
+     * @author: lihong
+     * @date: 2024/12/10 10:32
+     * @param: patientId
+     * @return: int
+     */
+    @Override
+    public int updateDiscountLvByPatientId(String patientId,String discountLv) {
+        return dao.updateDiscountLvByPatientId(patientId,discountLv);
+    }
 }

+ 33 - 0
src/main/resources/static/js/mz/clinic.js

@@ -1537,6 +1537,7 @@ function clearUser(flag) {
     $("#crbMainCard").css("display", "none");
     $("#editUser").css("display", "none");
     $("#clearUser").css("display", "none");
+    $("#discountLvCard").css("display", "none");
     // $("#fetchSpcSlwinfo").css("display", "none");
     $("#patientPhone").html("");
     $("#patientPhoneLabel").hide();
@@ -2058,6 +2059,9 @@ function setVisitTypeName(patientId) {
     postAjaxJsonHttpRequst("/thmz/queryVisitTypeName",{patientId:patientId},true,function (res) {
         if(res.code ==0){
             $("#patientVisitType").text(res.data);
+            if(!stringIsBlank(res.data)){
+                $("#discountLvCard").css("display", "inline-block");
+            }
         }
         $("#crmType").text(res.crmTypeName);
     })
@@ -14086,6 +14090,35 @@ function openJcJyPacsModal() {
 
 }
 
+
+function openDiscountLv() {
+    $("#discountLvModal").modal();
+    postAjaxJsonHttpRequst("/thmz/queryDiscountLv",{patientId: $("#patientId").text()},true,function (res) {
+        if(res.code == 0){
+            if(res.data != null){
+                $("#discountLv").val(res.data)
+                $('#discountLv').selectpicker('refresh');
+            }
+        }else {
+            errorMesage(res)
+        }
+    })
+
+}
+
+//保存股东卡优先级
+function saveDiscountLv() {
+       postAjaxJsonHttpRequst("/thmz/updateDiscountLv",{patientId: $("#patientId").text(),discountLv : $("#discountLv").val()},true,function (res) {
+            if(res.code == 0){
+                successMesageSimaple("修改成功")
+                $("#discountLvModal").modal("hide");
+            }else {
+                errorMesage(res)
+            }
+       })
+}
+
+
 //打开医技预约
 function openYjYyModal() {
     getAjaxRequst("/thmz/getYjYyUrl",{},true,function (res) {

+ 37 - 0
src/main/resources/templates/mz/clinic.html

@@ -403,6 +403,9 @@
                         <a style="cursor: pointer;font-size: 14px;color: #2e69eb!important;margin-right: 10px;display: none"
                            onclick="crbMainCard()" id="crbMainCard"><i
                                 class="fa fa-file-word-o">&nbsp;&nbsp;传染病上报</i></a>
+                        <a style="cursor: pointer;font-size: 14px;color: #2e69eb!important;margin-right: 10px;display: none"
+                           onclick="openDiscountLv()" id="discountLvCard"><i
+                                class="fa fa-edit">&nbsp;&nbsp;修改优惠优先级</i></a>
                         <a style="cursor: pointer;font-size: 14px;color: #2e69eb!important;margin-right: 10px;display: inline-block"
                            onclick="openFetchSpcSlwinfoModal()" id="fetchSpcSlwinfo"><i
                                 class="fa fa-eye">&nbsp;&nbsp;查询特门</i></a>
@@ -3423,6 +3426,40 @@
 </div>
 <!--特门详情列表弹窗结尾-->
 
+<!--股东卡优惠优先级-->
+<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true" id="discountLvModal">
+    <div class="modal-dialog modal-lg">
+        <div class="modal-content" style="width: 600px;max-height: 300px;overflow-y: auto;">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span>
+                </button>
+                <h4 class="modal-title modal-title-thmz">股东卡优惠优先级</h4>
+            </div>
+            <div class="modal-body">
+                <form class="form-horizontal form-label-left" novalidate>
+                    <div class="item form-group">
+                        <label class="col-md-6 col-sm-6 col-xs-12">股东卡优惠优先级
+                        </label>
+                        <label class="col-md-6 col-sm-6 col-xs-12" for="discountLv">
+                            <select class="form-control selectpicker show-tick"
+                                    id="discountLv"   title="请选择">
+                                    <option value="0">优先套餐优惠</option>
+                                    <option value="1">优先股东卡优惠</option>
+                            </select>
+                        </label>
+                    </div>
+                </form>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-primary" onclick="saveDiscountLv()" >保存</button>
+                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
+            </div>
+        </div>
+    </div>
+</div>
+
+
+
 
 <!--检查检验报告弹窗开始-->
 <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true" id="previewYjReqModal">