瀏覽代碼

解决缴费失败的异常

hurugang 3 年之前
父節點
當前提交
bd192f5a1b

+ 10 - 0
src/main/java/cn/hnthyy/thmz/mapper/thmz/ClinicMapper.java

@@ -107,6 +107,16 @@ public interface ClinicMapper {
     @Select("select * from t_clinic where patient_id = #{patientId}  and times=#{times} and receipt_no=#{receiptNo}")
     Clinic selectByPatientIdAndTimesAndReceiptNo(@Param("patientId") String patientId, @Param("times") Integer times, @Param("receiptNo") Integer receiptNo);
 
+    /**
+     * 根据当前患者的id和次数查询所有的就诊记录
+     * @param patientId
+     * @param times
+     * @return
+     */
+    @Select("select * from t_clinic where patient_id = #{patientId}  and times=#{times} order by receipt_no desc")
+    List<Clinic> selectByPatientIdAndTimes(@Param("patientId") String patientId, @Param("times") Integer times);
+
+
     /**
      * 查询符合条件的总数
      *

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

@@ -41,6 +41,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Lazy;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Propagation;
@@ -720,7 +721,19 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
         clinic.setTimes(mzDepositFileVo.getTimes());
         clinic.setReceiptNo(receiptNo);
         clinic.setClinicStatus(ClinicStatusEnum.CHARGED.code);
-        clinicMapper.updateClinicByPatientIdAndTimes(clinic);
+        try{
+            clinicMapper.updateClinicByPatientIdAndTimes(clinic);
+        }catch (DuplicateKeyException e){
+            //可能会有同一就诊次数不同缴费次数的数据,老医生系统产生,导致更新的时候索引重复,无法缴费
+            List<Clinic> clinicList=clinicMapper.selectByPatientIdAndTimes(mzDepositFileVo.getPatientId(),mzDepositFileVo.getTimes());
+            if(clinicList!=null && clinicList.size()>0){
+                clinicMapper.deleteById(clinicList.get(0).getId());
+                clinicMapper.updateClinicByPatientIdAndTimes(clinic);
+            }
+            e.printStackTrace();
+            log.error(e.getLocalizedMessage());
+        }
+
         //发送缴费成功MQ
         orderStatusChangeService.orderStatusChange(mzDepositFileVo.getPatientId() + "_" + mzDepositFileVo.getTimes() + "_" + receiptNo + "," + OrderStatusEnum.SUCCESSFUL_PRESCRIPTION_PAYMENT.code);
         return receiptNo;

+ 20 - 0
src/main/resources/static/js/mz/client_price.js

@@ -18,6 +18,26 @@ $(function (){
             }
         }
     });
+
+
+    // setInterval(function () {
+    //     //生成语音
+    //     var message="刘阳女士,您好!您本次就诊,应付金额为580.00元, 实际支付金额为600.00元,应找零金额为20.00元。";
+    //     $.ajax({
+    //         type: "GET",
+    //         url: '/thmz/callNumberAudio?message='+message,
+    //         contentType: "application/json;charset=UTF-8",
+    //         dataType: "json",
+    //         headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
+    //         success: function (res) {
+    //             if (res.code == 0) {
+    //                 //播放后台生成的叫号语音
+    //                 var mp3 = new Audio(res.data);
+    //                 mp3.play();
+    //             }
+    //         }
+    //     });
+    // }, 10000);
 });