Browse Source

pref: 移动支付更新为重庆版本

zhengjie 1 year ago
parent
commit
d645b19f30
1 changed files with 86 additions and 83 deletions
  1. 86 83
      Business/MobilePay.cs

+ 86 - 83
Business/MobilePay.cs

@@ -27,14 +27,14 @@ namespace PTMedicalInsurance.Business
         //前端传过来的入参,从这里面取值
         private JObject joParam;
         private JObject joInsuAdmObj;
-        
-        public   MobilePay(string inpar,out string errMsg)
+
+        public MobilePay(string inpar, out string errMsg)
         {
             errMsg = "";
             try
             {
                 JObject joInpar = JObject.Parse(inpar);
-                joParam = JObject.Parse(JsonHelper.getDestValue(joInpar,"params[0]"));
+                joParam = JObject.Parse(JsonHelper.getDestValue(joInpar, "params[0]"));
                 joInsuAdmObj = JObject.Parse(JsonHelper.getDestValue(joInpar, "insuAdmObj"));
                 setPatientByInPar();
                 setSettlementsByInPar();
@@ -51,7 +51,7 @@ namespace PTMedicalInsurance.Business
             string diagnoses;
             if (hIS.getPatDiagnoses(Global.pat, out diagnoses) != 0)
             {
-                return JsonHelper.setExceptionJson(-1,"挂号","获取诊断异常"+diagnoses);
+                return JsonHelper.setExceptionJson(-1, "挂号", "获取诊断异常" + diagnoses);
             }
             JObject joHisRtnInfo = JObject.Parse(diagnoses);
 
@@ -80,13 +80,14 @@ namespace PTMedicalInsurance.Business
             {
                 return JsonHelper.setExceptionJson(-1, "医保挂号", errMsg);
             }
-            else {
+            else
+            {
                 Global.pat.mdtrtID = JsonHelper.getDestValue(jo2201Rtn, "output.data.mdtrt_id");
             }
 
             return jo2201Rtn;
         }
-        public int   MobilePaySettlement(out string outPar)
+        public int MobilePaySettlement(out string outPar)
         {
             string errMsg, patInfo, M6201Inpar, M6202Inpar;
             //M6201Rtn, M6202Rtn,M6301Inpar,M6301Rtn;
@@ -109,7 +110,7 @@ namespace PTMedicalInsurance.Business
                 setPatientInsuInfo(jo1194Rtn);
 
                 //2201
-                JObject jo2201Rtn = OutpatientReg();
+                //JObject jo2201Rtn = OutpatientReg();
 
                 if (Get6201Inpar(out errMsg) != 0)
                 {
@@ -125,7 +126,7 @@ namespace PTMedicalInsurance.Business
                 }
                 JObject joEncData = JObject.Parse(errMsg);
 
-                Global.writeLog("返回值:"+errMsg);
+                Global.writeLog("返回值:" + errMsg);
                 //设置
                 setPatientBy6201Rtn(joEncData);
                 //存入MI 患者表,登记表,费用表
@@ -135,7 +136,7 @@ namespace PTMedicalInsurance.Business
                     return -1;
                 }
                 //M6202
-                if (Get6202Inpar(JObject.Parse(M6201Inpar),  out errMsg) != 0)
+                if (Get6202Inpar(JObject.Parse(M6201Inpar), out errMsg) != 0)
                 {
                     outPar = errMsg;
                     return -1;
@@ -153,7 +154,7 @@ namespace PTMedicalInsurance.Business
                 setSettlementsBy6202Rtn(joEncData);
                 MSettl.confirmFlag = 0;
                 //存入MI 结算表
-                if (saveSettlement (out errMsg) != 0)
+                if (saveSettlement(out errMsg) != 0)
                 {
                     outPar = errMsg;
                     return -1;
@@ -212,7 +213,7 @@ namespace PTMedicalInsurance.Business
         }
         public int MobilePayConfirmSettlement(out string outPar)
         {
-            string errMsg,  M6301Inpar;
+            string errMsg, M6301Inpar;
             outPar = "";
             try
             {
@@ -224,17 +225,16 @@ namespace PTMedicalInsurance.Business
                     return -1;
                 }
                 M6301Inpar = errMsg;
-                JObject joM6301Rtn = invoker.invokeMPService("6301",M6301Inpar);
+                JObject joM6301Rtn = invoker.invokeMPService("6301", M6301Inpar);
                 if (JsonHelper.parseMPRtnValue(joM6301Rtn, out errMsg) != 0)
                 {
                     outPar = errMsg;
                     return -1;
                 }
                 JObject joEncData = JObject.Parse((errMsg));
-                JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "output.data"));
                 Global.writeLog(JsonHelper.Compress(joEncData));
                 //设置
-                setSettlementsBy6301Rtn(joSettlInfo);
+                setSettlementsBy6301Rtn(joEncData);
                 MSettl.confirmFlag = 1;
                 //存入MI 结算表
                 if (updateSettlement(out errMsg) != 0)
@@ -245,10 +245,10 @@ namespace PTMedicalInsurance.Business
                 else
                 {
                     //返回给HIS前端
-                    outPar = JsonHelper.setExceptionJson(0,"云医保平台","确认成功!").ToString();
+                    outPar = JsonHelper.setExceptionJson(0, "云医保平台", "确认成功!").ToString();
                     return 0;
                 }
-                
+
             }
             catch (Exception ex)
             {
@@ -315,8 +315,8 @@ namespace PTMedicalInsurance.Business
             MPat.payAuthNo = JsonHelper.getDestValue(joInsuAdmObj, "payAuthNo");
             MPat.uldLatlnt = JsonHelper.getDestValue(joInsuAdmObj, "uldLatlnt");
             MPat.payOrdId = JsonHelper.getDestValue(joInsuAdmObj, "payOrdId");
-            MPat.settlID = MPat.payOrdId;
-            MPat.mdtrtID = JsonHelper.getDestValue(joInsuAdmObj, "mdtrtId");
+            MPat.mdtrtID = JsonHelper.getDestValue(joInsuAdmObj, "mdtrt_id");
+            MPat.settlID = JsonHelper.getDestValue(joInsuAdmObj, "setl_id");
             Global.pat.mdtrtID = MPat.mdtrtID;
         }
         public void setPatientBy6201Rtn(JObject jo)
@@ -380,7 +380,7 @@ namespace PTMedicalInsurance.Business
             MSettl.accountPaySumamt = getDecimalFee(jo, "psnAcctPay");
             MSettl.fundPaySumamt = getDecimalFee(jo, "fundPay");
             MSettl.deposit = getDecimalFee(jo, "deposit");
-            MSettl.clearingOrgan  = JsonHelper.getDestValue(jo, "extData.preSetl.clr_optins");
+            MSettl.clearingOrgan = JsonHelper.getDestValue(jo, "extData.preSetl.clr_optins");
             MSettl.clearingType = JsonHelper.getDestValue(jo, "extData.preSetl.clr_type");
             MSettl.clearingWay = JsonHelper.getDestValue(jo, "extData.preSetl.clr_way");
             MSettl.civilserviceAllowancePay = getDecimalFee(jo, "extData.preSetl.cvlserv_pay");
@@ -402,50 +402,53 @@ namespace PTMedicalInsurance.Business
             MSettl.accountMutualAidAmount = getDecimalFee(jo, "extData.preSetl.acct_mulaid_pay");
         }
 
-        public void setSettlementsBy6301Rtn(JObject jo)
+        public void setSettlementsBy6301Rtn(JObject joRtn)
         {
-            //MPat.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, "feeSumamt");
-            MSettl.personCashPay = getDecimalFee(jo, "ownPayAmt");
-            MSettl.accountPaySumamt = getDecimalFee(jo, "psnAcctPay");
-            MSettl.fundPaySumamt = getDecimalFee(jo, "fundPay");
+            JObject jo = JObject.Parse(JsonHelper.getDestValue(joRtn, "extData.setlinfo"));
+
+            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, "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");
+            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");
         }
 
         public void setSettlementsByInPar()
@@ -509,7 +512,7 @@ namespace PTMedicalInsurance.Business
                     return -1;
                 }
                 setPatientByHisBaseInfo(JObject.Parse(errMsg));
-                JObject joPatBaseInfo = JObject.Parse(JsonHelper.getDestValue(JObject.Parse(errMsg),"result"));
+                JObject joPatBaseInfo = JObject.Parse(JsonHelper.getDestValue(JObject.Parse(errMsg), "result"));
                 //获取诊断
                 if (getDiagnoses(out errMsg) != 0)
                 {
@@ -645,12 +648,12 @@ namespace PTMedicalInsurance.Business
             }
             finally
             {
-                Global.writeLog("Get6201Inpar","",outparam);
+                Global.writeLog("Get6201Inpar", "", outparam);
             }
         }
 
         //获取入参,入参基本为类局部变量
-        public int Get6202Inpar(JObject joM6201Inpar,  out string outparam)
+        public int Get6202Inpar(JObject joM6201Inpar, out string outparam)
         {
             outparam = "";
             try
@@ -742,7 +745,7 @@ namespace PTMedicalInsurance.Business
             {
                 string errMsg;
                 //查询登记信息
-                if (mIS.queryRegisterInfo(4,out errMsg) != 0)
+                if (mIS.queryRegisterInfo(4, out errMsg) != 0)
                 {
                     outparam = errMsg;
                     return -1;
@@ -819,7 +822,7 @@ namespace PTMedicalInsurance.Business
                 Global.writeLog("Get6203Inpar", "", outparam);
             }
         }
-       
+
         #endregion
 
         #region 诊断
@@ -875,7 +878,7 @@ namespace PTMedicalInsurance.Business
         #region 费用
         private int GetFee(out string outparam)
         {
-            string hisFee, chrgBchno ="";
+            string hisFee, chrgBchno = "";
             JObject jo = new JObject();
             JObject joRow = new JObject();
             JArray jaRow = new JArray();
@@ -891,11 +894,11 @@ namespace PTMedicalInsurance.Business
                 //处理
                 //调用医保平台转换HIS费用(转换医保编码等)
                 JObject joHisFee = JObject.Parse(hisFee);
-                if (mIS.convertHisFeeWithInsuCodeOfMobilePay(MPat,joHisFee, out outparam) != 0)
+                if (mIS.convertHisFeeWithInsuCodeOfMobilePay(MPat, joHisFee, out outparam) != 0)
                 {
                     return -1;
                 }
-                
+
                 JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outparam), "data"));
                 jaFee = (JArray)jaFeeDetail.DeepClone();
                 decimal sumFee = 0;
@@ -986,7 +989,7 @@ namespace PTMedicalInsurance.Business
                 ybAmt = 0; psnAcctAmt = 0; hospAmt = 0; psnCashAmt = 0; medFee = 0;
                 ybAmt = MSettl.fundPaySumamt;
                 psnAcctAmt = MSettl.accountPaySumamt;
-                psnCashAmt =MSettl.personCashPay;
+                psnCashAmt = MSettl.personCashPay;
                 hospAmt = MSettl.hospitalPartAmount;
                 medFee = MSettl.sumamt;
 
@@ -1084,14 +1087,14 @@ namespace PTMedicalInsurance.Business
                 }
                 else
                 {
-                    joSumFee.Add("payAuthNo",MPat.payAuthNo);
+                    joSumFee.Add("payAuthNo", MPat.payAuthNo);
                     joSumFee.Add("payOrdId", MPat.payOrdId);
                     joSumFee.Add("setlLatlnt", MPat.uldLatlnt);
                     joSumFee.Add("org_no", Global.inf.hospitalNO);
                     joSumFee.Add("medOrgOrd", MPat.recordID);
                     joSumFee.Add("mdtrtId", MPat.mdtrtID);
                     joSumFee.Add("gmt_out_create", MSettl.settlTime.ToString("yyyy-MM-dd HH:mm:ss"));
-                    joRtn["result"]= joSumFee;
+                    joRtn["result"] = joSumFee;
                     outParam = joRtn.ToString();
                     return 0;
                 }
@@ -1111,7 +1114,7 @@ namespace PTMedicalInsurance.Business
             try
             {
                 string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr=  " + Global.inf.hospitalDr;
-                sqlStr = sqlStr + " and AdmType = 3 and Adm_Dr= " + MPat.adm_Dr + " and SettlementID= '" + MPat.payOrdId + "'"; 
+                sqlStr = sqlStr + " and AdmType = 3 and Adm_Dr= " + MPat.adm_Dr + " and SettlementID= '" + MPat.payOrdId + "'";
                 JObject joSqlstr = new JObject();
                 joSqlstr.Add("sqlStr", sqlStr);
                 JObject joRtn = mIS.DynamicQuerySettlInfo(joSqlstr);
@@ -1142,7 +1145,7 @@ namespace PTMedicalInsurance.Business
         /// <param name="joIdetInfo"></param>
         /// <param name="outParam"></param>
         /// <returns></returns>
-        private int insertPatCurInsuInfo( out string outParam)
+        private int insertPatCurInsuInfo(out string outParam)
         {
             JObject joTmp = new JObject();
             string errMsg = "";
@@ -1224,7 +1227,7 @@ namespace PTMedicalInsurance.Business
                 joTmp.Add("CertificateType", MPat.certType);
                 joTmp.Add("CertificateNO", MPat.certNO);
                 joTmp.Add("MedicalType", MPat.medType);
-                joTmp.Add("AttendDoctorNO",MPat.admAttendDoctorNO);
+                joTmp.Add("AttendDoctorNO", MPat.admAttendDoctorNO);
                 joTmp.Add("ChiefPhyDocName", "");
                 joTmp.Add("AdmInDiagDesc", "");
                 joTmp.Add("AdmInDepCode", MPat.AdmInDepCode);
@@ -1289,7 +1292,7 @@ namespace PTMedicalInsurance.Business
                 joSetlinfo.Add("admID", MPat.adm_Dr);
                 joSetlinfo.Add("mdtrt_id", MPat.mdtrtID);
                 joSetlinfo.Add("setl_id", MSettl.settlID);//
-                joSetlinfo.Add("psn_no",MPat.psn_no);
+                joSetlinfo.Add("psn_no", MPat.psn_no);
                 joSetlinfo.Add("psn_name", MPat.name);
                 //joSetlinfo.Add("mdtrt_cert_type", JsonHelper.getDestValue(joRtnSetlinfo, "mdtrt_cert_type"));
                 joSetlinfo.Add("certno", MPat.certNO);
@@ -1327,7 +1330,7 @@ namespace PTMedicalInsurance.Business
                 joSetlinfo.Add("medins_setl_id", "");//医药机构结算ID
                 joSetlinfo.Add("clr_optins", MSettl.clearingOrgan);//清算经办机构
                 joSetlinfo.Add("clr_way", MSettl.clearingWay);//清算方式
-                joSetlinfo.Add("clr_type",MSettl.clearingType);//清算类别
+                joSetlinfo.Add("clr_type", MSettl.clearingType);//清算类别
                 joSetlinfo.Add("ValidFlag", 1);
                 joSetlinfo.Add("BillType", 1);
                 joSetlinfo.Add("ConfirmFlag", MSettl.confirmFlag);
@@ -1475,7 +1478,7 @@ namespace PTMedicalInsurance.Business
                 }
                 else
                 {
-                    outParam = JsonHelper.setExceptionJson(0, "云医保平台","取消结算成功").ToString();
+                    outParam = JsonHelper.setExceptionJson(0, "云医保平台", "取消结算成功").ToString();
                     return 0;
                 }
             }
@@ -1525,19 +1528,19 @@ namespace PTMedicalInsurance.Business
                 return -1;
             }
         }
-        private int saveToMi( out string errMsg)
+        private int saveToMi(out string errMsg)
         {
             errMsg = "";
             try
             {
                 //存储参保信息
 
-                if (insertPatCurInsuInfo( out errMsg) != 0)
+                if (insertPatCurInsuInfo(out errMsg) != 0)
                 {
                     return -1;
                 }
                 //存储登记信息
-                if (saveRegisterInfo( out errMsg) != 0)
+                if (saveRegisterInfo(out errMsg) != 0)
                 {
                     return -1;
                 }
@@ -1564,7 +1567,7 @@ namespace PTMedicalInsurance.Business
 
         #region  解析中心返回
         /// <summary>
-        /// 解析银海移动支付返参
+        /// 解析移动支付返参
         /// </summary>
         /// <param name="joRtn"></param>
         /// <param name="errorMsg"></param>
@@ -1573,12 +1576,12 @@ namespace PTMedicalInsurance.Business
         {
             try
             {
-                errorMsg =JsonHelper.getDestValue(joRtn, "message");
+                errorMsg = JsonHelper.getDestValue(joRtn, "message");
                 return int.Parse(JsonHelper.getDestValue(joRtn, "code")); //0 成功-1 失败
             }
             catch (Exception ex)
             {
-                errorMsg = "解析银海移动支付返参发生异常:" + ex.Message;
+                errorMsg = "解析移动支付返参发生异常:" + ex.Message;
                 return -1;
             }
         }