Przeglądaj źródła

perf: 移动支付优化

zhengjie 1 rok temu
rodzic
commit
0967aa037a
6 zmienionych plików z 168 dodań i 96 usunięć
  1. 136 83
      Business/MobilePay.cs
  2. 12 11
      Forms/Clearing.cs
  3. 1 1
      Helper/InvokeHelper.cs
  4. 3 0
      Helper/JsonHelper.cs
  5. 13 1
      InsuBusiness.cs
  6. 3 0
      Variables/Struct.cs

+ 136 - 83
Business/MobilePay.cs

@@ -18,7 +18,7 @@ namespace PTMedicalInsurance.Business
         private CenterBusiness cBus = new CenterBusiness();
         private InvokeHelper invoker = new InvokeHelper();
         private Patients MPat;
-        private Settlements MSettl;
+        public Settlements MSettl;
         private JArray jaFee;
         //
         //private string fixmedins_code;//定点医疗服务机构编码
@@ -153,7 +153,6 @@ namespace PTMedicalInsurance.Business
                     return -1;
                 }
                 joEncData = JObject.Parse(errMsg);
-                Global.writeLog(JsonHelper.Compress(joEncData));
                 //设置
                 setSettlementsBy6202Rtn(joEncData);
                 MSettl.confirmFlag = 0;
@@ -163,29 +162,6 @@ namespace PTMedicalInsurance.Business
                     outPar = errMsg;
                     return -1;
                 }
-                //6301查询具体明细信息
-                //if (Get6301Inpar(out errMsg) != 0)
-                //{
-                //    outPar = errMsg;
-                //    return -1;
-                //}
-                //M6301Inpar = errMsg;
-                //JObject joM6301Rtn = invoker.invokeMPService("6301", eh.encrypt(M6301Inpar));
-                //if (JsonHelper.parseMPRtnValue(joM6301Rtn, out errMsg) != 0)
-                //{
-                //    outPar = errMsg;
-                //    return -1;
-                //}
-                //joEncData = JObject.Parse(eh.decrypt(errMsg));
-                //JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.SETLINFO"));
-                //Global.writeLog(JsonHelper.Compress(joEncData));
-                ////设置
-                //setSettlementsBy6301Rtn(joSettlInfo);
-                ////存入MI 结算表
-                //if (saveSettlement(out errMsg) != 0)
-                //{
-                //    outPar = errMsg;
-                //}
                 //返回给HIS后端 
                 JObject joPreSettl = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.preSetl"));
                 //JObject joTmp = JObject.Parse(JsonHelper.getDestValue(joM6201Rtn, "encData"));
@@ -236,9 +212,7 @@ namespace PTMedicalInsurance.Business
                     return -1;
                 }
                 JObject joEncData = JObject.Parse((errMsg));
-                Global.writeLog(JsonHelper.Compress(joEncData));
-
-                string setlInfo = JsonHelper.getDestValue(joEncData, "extData.setlinfo");
+                string setlInfo = JsonHelper.getDestValue(joEncData, "extData.SETLINFO");
                 if (string.IsNullOrEmpty(setlInfo))
                 {
                     //此时为异步返回结算内容
@@ -247,7 +221,7 @@ namespace PTMedicalInsurance.Business
                     return 0;
                 }
                 //设置
-                return ConfirmResult(joEncData, out outPar);
+                return ConfirmResult(JObject.Parse(setlInfo), out outPar);
 
             }
             catch (Exception ex)
@@ -278,26 +252,96 @@ namespace PTMedicalInsurance.Business
 
         public int MobilePayCancelSettlement(out string outPar)
         {
-            string inParam, errMsg;
+            string errMsg, YH6203Inpar;
             outPar = "";
             try
             {
+                if (MSettl.onlineYBFlag != "Y")
+                {
+                    //读电子凭证
+                    if (ReadEc(out errMsg) != 0)
+                    {
+                        outPar = errMsg;
+                        return -1;
+                    }
+                }
+
+                //获取6203入参
                 if (Get6203Inpar(out errMsg) != 0)
                 {
                     outPar = errMsg;
                     return -1;
                 }
-                inParam = errMsg;
-                JObject jo6203Rtn = invoker.invokeMPService("6203", inParam);
-                //M6202
+                YH6203Inpar = errMsg;
+                JObject jo6203Rtn = invoker.invokeMPService("6203", YH6203Inpar);
+                //YH6202
                 if (JsonHelper.parseMPRtnValue(jo6203Rtn, out errMsg) != 0)
                 {
                     outPar = errMsg;
                     return -1;
                 }
+                else
+                {
+                    JObject joEncData = JObject.Parse(errMsg);
+                    string newSettlID = JsonHelper.getDestValue(joEncData, "extData.setlInfo.setl_id");
+                    //处理撤销数据
+                    if (cancleSettlement(MPat.settlID, out errMsg) != 0)
+                    {
+                        outPar = errMsg;
+                        return -1;
+                    }
+                    //joParam.Add("mdtrt_id", MPat.mdtrtID);
+                    //joParam.Add("insuplc_admdvs", MPat.insuplc_admdvs);
+                    //joParam.Add("setl_id", MPat.settlID);
+                    joParam.Add("middleSettleFlag", "");
+                    //退HIS结算
+                    if (hIS.cancleSettlementInfo(joParam, out errMsg) != 0)
+                    {
+                        outPar = errMsg;
+                        return -1;
+                    }
+                    else
+                    {
+                        outPar = errMsg;
+                        return 0;
+                    }
+                }
+
+
+            }
+            catch (Exception ex)
+            {
+                Global.writeLog("MobilePayCancelSettlement:" + ex.Message);
+                outPar = ex.Message;
+                return -1;
+            }
+        }
+
+        #region 读卡
+        public int ReadEc(out string outPar)
+        {
+            outPar = "";
+            string errMsg = "";
+            try
+            {
+                Global.pat.mdtrtcertType = "01";
+                Global.businessType = "01301";
+                outPar = ECTokenReader.ECQuery("1");
+                JObject jo1161Rtn = JObject.Parse(outPar);
+
+                if (JsonHelper.parseCenterRtnValue(jo1161Rtn, out errMsg) != 0)
+                {
+                    outPar = errMsg;
+                    return -1;
+                }
+                else
+                {
+                    JObject joOutput = JObject.Parse(JsonHelper.getDestValue(jo1161Rtn, "output"));
+                    outPar = joOutput.ToString();
+                    setPatientByEc(joOutput);
+                    return 0;
+                }
 
-                //撤销医保平台结算数据
-                return cancleSettlement(MPat.settlID, out outPar);
             }
             catch (Exception ex)
             {
@@ -306,6 +350,21 @@ namespace PTMedicalInsurance.Business
             }
         }
 
+        public void setPatientByEc(JObject jo)
+        {
+            MPat.name = JsonHelper.getDestValue(jo, "userName");
+            MPat.IDNO = JsonHelper.getDestValue(jo, "idNo");
+            MPat.certType = JsonHelper.getDestValue(jo, "idType");
+            MPat.token = JsonHelper.getDestValue(jo, "ecToken");
+            MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuOrg");
+            MPat.payAuthNo = JsonHelper.getDestValue(jo, "authNo");
+            MPat.gend = JsonHelper.getDestValue(jo, "gender");
+            MPat.brdy = JsonHelper.getDestValue(jo, "birthday");
+            MPat.naty = JsonHelper.getDestValue(jo, "nationality");
+            MPat.payOrdId = "";
+        }
+        #endregion
+
         #region 赋值MPat,Msettle结构体
         public void setPatientByInPar()
         {
@@ -378,6 +437,7 @@ namespace PTMedicalInsurance.Business
         {
             MSettl.settlID = JsonHelper.getDestValue(jo, "payOrdId");
             MPat.payOrdId = MSettl.settlID;
+            MSettl.payOrdId = MSettl.settlID;
             MSettl.ordStas = JsonHelper.getDestValue(jo, "ordStas");
             MSettl.sumamt = getDecimalFee(jo, "feeSumamt");
             MSettl.personCashPay = getDecimalFee(jo, "ownPayAmt");
@@ -406,56 +466,49 @@ namespace PTMedicalInsurance.Business
             MSettl.accountMutualAidAmount = getDecimalFee(jo, "extData.preSetl.acct_mulaid_pay");
         }
 
-        public void setSettlementsBy6301Rtn(JObject joRtn)
+        public void setSettlementsBy6301Rtn(JObject jo)
         {
-                JObject jo = JObject.Parse(JsonHelper.getDestValue(joRtn, "extData.setlinfo"));
-
-                MPat.mdtrtID = JsonHelper.getDestValue(jo, "mdtrtId");
-                MPat.settlID = JsonHelper.getDestValue(jo, "setlId");
-                MPat.psn_no = JsonHelper.getDestValue(jo, "psnNo");
-                MPat.naty = JsonHelper.getDestValue(jo, "naty");
-                MPat.name = JsonHelper.getDestValue(jo, "psnName");
-                MPat.age = JsonHelper.getDestValue(jo, "age");
-                MPat.gend = JsonHelper.getDestValue(jo, "gend");
-                MPat.certNO = JsonHelper.getDestValue(jo, "certno");
-                MPat.brdy = JsonHelper.getDestValue(jo, "brdy");
-                MPat.insuType = JsonHelper.getDestValue(jo, "insutype");
-                MPat.psn_type = JsonHelper.getDestValue(jo, "psnType");
-                MPat.mdtrtcertType = JsonHelper.getDestValue(jo, "mdtrtCertType");
-                MPat.medType = JsonHelper.getDestValue(jo, "medType");
-                MPat.insuplc_admdvs = JsonHelper.getDestValue(joRtn, "extData.insuplcAdmdvs");
-
-                MPat.payOrdId = JsonHelper.getDestValue(joRtn, "payOrdId");
-                MSettl.ordStas = JsonHelper.getDestValue(joRtn, "ordStas");
-                MSettl.sumamt = getDecimalFee(joRtn, "feeSumamt");
-
-                MSettl.personCashPay = getDecimalFee(jo, "psnCashPay");
-                MSettl.accountPaySumamt = getDecimalFee(jo, "acctPay");
-                MSettl.fundPaySumamt = getDecimalFee(jo, "fundPaySumamt");
-
-                //MSettl.deposit = getDecimalFee(jo, "deposit");
-                MSettl.clearingOrgan = JsonHelper.getDestValue(jo, "clrOptins");
-                MSettl.clearingType = JsonHelper.getDestValue(jo, "clrType");
-                MSettl.clearingWay = JsonHelper.getDestValue(jo, "clrWay");
-                MSettl.civilserviceAllowancePay = getDecimalFee(jo, "cvlservPay");
-                MSettl.ownPayAmount = getDecimalFee(jo, "fulamtOwnpayAmt");
-                MSettl.overLimitAmountmt = getDecimalFee(jo, "overlmtSelfpay");
-                MSettl.preSelfPayAmount = getDecimalFee(jo, "preselfpayAmt");
-                MSettl.inPolicyRangeAmount = getDecimalFee(jo, "inscpScpAmt");
-                MSettl.actualPayDeductible = getDecimalFee(jo, "actPayDedc");
-                MSettl.healthInsurancePay = getDecimalFee(jo, "hifpPay");
-                MSettl.healthInsuranceRatio = getDecimalFee(jo, "poolPropSelfpay");
-                MSettl.enterpriseSupplementPay = getDecimalFee(jo, "hifesPay");
-                MSettl.seriousIllnessPay = getDecimalFee(jo, "hifmiPay");
-                MSettl.largeExpensesSupplementPay = getDecimalFee(jo, "hifobPay");
-                MSettl.medicalAssistPay = getDecimalFee(jo, "mafPay");
-                MSettl.hospitalPartAmount = getDecimalFee(jo, "hospPartAmt");
-                MSettl.otherPay = getDecimalFee(jo, "othPay");
-                MSettl.personPaySumamt = getDecimalFee(jo, "psnPartAmt");
-                MSettl.balance = getDecimalFee(jo, "balc");
-                MSettl.accountMutualAidAmount = getDecimalFee(jo, "acctMulaidPay");
+            MSettl.settlID = JsonHelper.getDestValue(jo, "setl_id");
+            MPat.psn_no = JsonHelper.getDestValue(jo, "psn_no");
+            MPat.naty = JsonHelper.getDestValue(jo, "naty");
+            //MPat.name = JsonHelper.getDestValue(jo, "name");
+            MPat.age = JsonHelper.getDestValue(jo, "age");
+            MPat.gend = JsonHelper.getDestValue(jo, "gend");
+            MPat.certNO = JsonHelper.getDestValue(jo, "certno");
+            MPat.brdy = JsonHelper.getDestValue(jo, "brdy");
+            MPat.insuType = JsonHelper.getDestValue(jo, "insutype");
+            MPat.psn_type = JsonHelper.getDestValue(jo, "psn_type");
+            MPat.mdtrtcertType = JsonHelper.getDestValue(jo, "mdtrt_cert_type");
+            MPat.medType = JsonHelper.getDestValue(jo, "med_type");
+            //MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuplc_admdvs");
+            //MPat.payOrdId = JsonHelper.getDestValue(jo, "payOrdId");
+            MSettl.ordStas = JsonHelper.getDestValue(jo, "ordStas");
+            MSettl.sumamt = getDecimalFee(jo, "medfee_sumamt");
+            MSettl.personCashPay = getDecimalFee(jo, "psn_cash_pay");
+            MSettl.accountPaySumamt = getDecimalFee(jo, "acct_pay");
+            MSettl.fundPaySumamt = getDecimalFee(jo, "fund_pay_sumamt");
+            //MSettl.deposit = getDecimalFee(jo, "deposit");
+            MSettl.clearingOrgan = JsonHelper.getDestValue(jo, "clr_optins");
+            MSettl.clearingType = JsonHelper.getDestValue(jo, "clr_type");
+            MSettl.clearingWay = JsonHelper.getDestValue(jo, "clr_way");
+            MSettl.civilserviceAllowancePay = getDecimalFee(jo, "cvlserv_pay");
+            MSettl.ownPayAmount = getDecimalFee(jo, "fulamt_ownpay_amt");
+            MSettl.overLimitAmountmt = getDecimalFee(jo, "overlmt_selfpay");
+            MSettl.preSelfPayAmount = getDecimalFee(jo, "preselfpay_amt");
+            MSettl.inPolicyRangeAmount = getDecimalFee(jo, "inscp_scp_amt");
+            MSettl.actualPayDeductible = getDecimalFee(jo, "act_pay_dedc");
+            MSettl.healthInsurancePay = getDecimalFee(jo, "hifp_pay");
+            MSettl.healthInsuranceRatio = getDecimalFee(jo, "pool_prop_selfpay");
+            MSettl.enterpriseSupplementPay = getDecimalFee(jo, "hifes_pay");
+            MSettl.seriousIllnessPay = getDecimalFee(jo, "hifmi_pay");
+            MSettl.largeExpensesSupplementPay = getDecimalFee(jo, "hifob_pay");
+            MSettl.medicalAssistPay = getDecimalFee(jo, "maf_pay");
+            MSettl.hospitalPartAmount = getDecimalFee(jo, "hosp_part_amt");
+            MSettl.otherPay = getDecimalFee(jo, "oth_pay");
+            MSettl.personPaySumamt = getDecimalFee(jo, "psn_part_amt");
+            MSettl.balance = getDecimalFee(jo, "balc");
+            MSettl.accountMutualAidAmount = getDecimalFee(jo, "acct_mulaid_pay");
         }
-
         public void setSettlementsByInPar()
         {
             MSettl.clearingWay = JsonHelper.getDestValue(joInsuAdmObj, "psnSetlway");

+ 12 - 11
Forms/Clearing.cs

@@ -598,26 +598,27 @@ namespace PTMedicalInsurance.Forms
                 int iCurRow = dgvSettlSummary.CurrentRow.Index;
 
                 //DataTable dtInteface = (DataTable)cbxInterface.DataSource;
-                if (cbgGroupSet.GetItemCheckState(0))
+                DataRow dr = dtSettlSummary.Rows[iCurRow];
+                if (cbgGroupSet.GetItemCheckState(0) && !string.IsNullOrEmpty(dr["Interface_dr"].ToString()))
                 {
-                    conditionStr = conditionStr + " and Interface_Dr ='" + dtSettlSummary.Rows[iCurRow]["Interface_dr"].ToString() + "'";
+                    conditionStr = conditionStr + " and Interface_Dr ='" + dr["Interface_dr"].ToString() + "'";
                 }
-                if (cbgGroupSet.GetItemCheckState(1))
+                if (cbgGroupSet.GetItemCheckState(1) && !string.IsNullOrEmpty(dr["insutype"].ToString()))
                 {
-                    conditionStr = conditionStr + " and InsuranceType ='" + dtSettlSummary.Rows[iCurRow]["insutype"].ToString() + "'";
+                    conditionStr = conditionStr + " and InsuranceType ='" + dr["insutype"].ToString() + "'";
                 }
-                if (cbgGroupSet.GetItemCheckState(2))
+                if (cbgGroupSet.GetItemCheckState(2) && !string.IsNullOrEmpty(dr["clr_type"].ToString()))
                 {
-                    conditionStr = conditionStr + " and ClearingType ='" + dtSettlSummary.Rows[iCurRow]["clr_type"].ToString() + "'";
+                    conditionStr = conditionStr + " and ClearingType ='" + dr["clr_type"].ToString() + "'";
                 }
-                if (cbgGroupSet.GetItemCheckState(3))
+                if (cbgGroupSet.GetItemCheckState(3) && !string.IsNullOrEmpty(dr["setl_optins"].ToString()))
                 {
-                    conditionStr = conditionStr + " and ClearingOrgan ='" + dtSettlSummary.Rows[iCurRow]["setl_optins"].ToString() + "'";
+                    conditionStr = conditionStr + " and ClearingOrgan ='" + dr["setl_optins"].ToString() + "'";
                 }
-                if (cbgGroupSet.GetItemCheckState(4))
+                if (cbgGroupSet.GetItemCheckState(4) && !string.IsNullOrEmpty(dr["BillType"].ToString()))
                 {
                     sqlStr = sqlStr + ",BillType";
-                    conditionStr = conditionStr + " and BillType ='" + dtSettlSummary.Rows[iCurRow]["BillType"].ToString() + "'";
+                    conditionStr = conditionStr + " and BillType ='" + dr["BillType"].ToString() + "'";
                 }
 
                 sqlStr = "select *  FROM  BS_MedInsuSettlement WHERE Hospital_Dr=" + dtInteface.Rows[i]["HospitalDr"].ToString();
@@ -1095,7 +1096,7 @@ namespace PTMedicalInsurance.Forms
                 joData.Add("data", joCheck);
                 InvokeHelper invoker = new InvokeHelper(); 
                 JObject jo3202Rtn = invoker.invokeCenterService("3202", JsonHelper.setCenterInpar("3202", joData.ToString()));
-                if (JsonHelper.parseCenterReturnJson(jo3202Rtn, out outParam) != 0)
+                if (JsonHelper.parseCenterRtnValue(jo3202Rtn, out outParam) != 0)
                 {
                     return -1;
                 }

+ 1 - 1
Helper/InvokeHelper.cs

@@ -327,7 +327,7 @@ namespace PTMedicalInsurance.Helper
                     Stream myResponseStream = res.GetResponseStream();
                     StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8);
                     string retString = myStreamReader.ReadToEnd();
-                    return JsonHelper.setExceptionJson(-99, "centerServeiceInvok中获得响应流异常", retString);
+                    return JsonHelper.setExceptionJson(-99, "获得响应流异常", retString);
 
                 }
                 postContent = getResponseData(response);

+ 3 - 0
Helper/JsonHelper.cs

@@ -276,6 +276,9 @@ namespace PTMedicalInsurance.Helper
             Jo.infno = infno;
             Global.curEvt.msgid = Global.inf.hospitalNO + DateTime.Now.ToString("yyyyMMddHHmmssffff");
             Jo.msgid = Global.curEvt.msgid;
+            if (string.IsNullOrEmpty(Global.inf.areaCode)) {
+                Global.inf.areaCode = "340100";
+            }
 
             if (string.IsNullOrEmpty(Global.pat.insuplc_admdvs))
             {

+ 13 - 1
InsuBusiness.cs

@@ -32,6 +32,7 @@ namespace PTMedicalInsurance
         private JArray jaParams;
         private JObject joParam;
         private JObject joInterface;
+        private JObject joInsuAdmObj;
 
         //设置业务实例
         CenterBusiness cBus = new CenterBusiness();
@@ -67,8 +68,10 @@ namespace PTMedicalInsurance
                 {
                     jaParams = JArray.Parse(JsonHelper.getDestValue(joInParam, "params"));
                     joParam = JObject.FromObject(jaParams[0]);
-                }                            
+                }
 
+                if (JsonHelper.getDestValue(joInParam, "insuAdmObj") != "")
+                    joInsuAdmObj = JObject.Parse(JsonHelper.getDestValue(joInParam, "insuAdmObj"));
                 joInterface = JObject.Parse(JsonHelper.getDestValue(joInParam, "interfaceinfo"));
 
                 
@@ -1172,12 +1175,21 @@ namespace PTMedicalInsurance
                         }
                     case "M6C"://门诊移动支付结算撤销
                         {
+                            string onlineYBFalg = JsonHelper.getDestValue(joInsuAdmObj, "onlineYBFalg");
                             MobilePay mp = new MobilePay(InParam, out errMsg);
                             if (errMsg != "")
                             {
                                 rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
                                 return rtnResult;
                             }
+                            if (String.IsNullOrEmpty(onlineYBFalg))
+                            {
+                                mp.MSettl.onlineYBFlag = "N";
+                            }
+                            else
+                            {
+                                mp.MSettl.onlineYBFlag = onlineYBFalg;
+                            }
                             if (mp.MobilePayCancelSettlement(out outParam) != 0)
                                 rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
                             else

+ 3 - 0
Variables/Struct.cs

@@ -197,6 +197,7 @@ namespace PTMedicalInsurance.Variables
         public string mdtrtID;
         public string settlID;
         public string billID;
+        public string payOrdId;
         public string recordID;
         public string clearingType;
         public string clearingWay;
@@ -232,6 +233,8 @@ namespace PTMedicalInsurance.Variables
         public decimal accountMutualAidAmount;//个人账户共济支付金额
         public decimal deposit;//住院押金
         public int confirmFlag; //确认标志
+
+        public string onlineYBFlag;
     }
 
     //当前环境实时信息