zhengjie 1 年間 前
コミット
8edd7a958d
2 ファイル変更165 行追加81 行削除
  1. 149 80
      Business/MobilePay.cs
  2. 16 1
      InsuBusiness.cs

+ 149 - 80
Business/MobilePay.cs

@@ -17,7 +17,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;//定点医疗服务机构编码
@@ -159,29 +159,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"));
@@ -217,7 +194,6 @@ namespace PTMedicalInsurance.Business
             outPar = "";
             try
             {
-                //EncryptHelper eh = new EncryptHelper();
                 //6301查询具体明细信息
                 if (Get6301Inpar(out errMsg) != 0)
                 {
@@ -232,9 +208,10 @@ namespace PTMedicalInsurance.Business
                     return -1;
                 }
                 JObject joEncData = JObject.Parse((errMsg));
-                Global.writeLog(JsonHelper.Compress(joEncData));
+                JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.SETLINFO"));
                 //设置
-                setSettlementsBy6301Rtn(joEncData);
+                setSettlementsBy6301Rtn(joSettlInfo);
+
                 MSettl.confirmFlag = 1;
                 //存入MI 结算表
                 if (updateSettlement(out errMsg) != 0)
@@ -258,26 +235,104 @@ namespace PTMedicalInsurance.Business
         }
         public int MobilePayCancelSettlement(out string outPar)
         {
-            string inParam, errMsg;
+            string errMsg, YH6203Inpar;
             outPar = "";
             try
             {
+                if (MSettl.onlineYBFalg != "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
+            {
+                dynamic jo = new JObject();
+                jo.mdtrt_cert_type = "01";
+                jo.cardtype = "";
+                jo.businesstype = "01301";
+                jo.operatorId = Global.user.ID;
+                jo.operatorName = Global.user.ID;
+                jo.officeId = Global.user.officeID;
+                jo.officeName = Global.user.officeName;
+
+                JObject joData = new JObject();
+                joData.Add("data", jo);
+                JObject jo1191Rtn = invoker.invokeCenterService("1191", JsonHelper.setCenterInpar("1191", joData.ToString()));
+                if (JsonHelper.parseCenterRtnValue(jo1191Rtn, out errMsg) != 0)
+                {
+                    outPar = errMsg;
+                    return -1;
+                }
+                else
+                {
+                    JObject joOutput = JObject.Parse(JsonHelper.getDestValue(jo1191Rtn, "output"));
+                    outPar = joOutput.ToString();
+                    setPatientByEc(joOutput);
+                    return 0;
+                }
 
-                //撤销医保平台结算数据
-                return cancleSettlement(MPat.settlID, out outPar);
             }
             catch (Exception ex)
             {
@@ -286,6 +341,22 @@ 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()
         {
@@ -358,6 +429,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");
@@ -386,53 +458,48 @@ 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.settlID = JsonHelper.getDestValue(jo, "setlId");
-            MPat.psn_no = JsonHelper.getDestValue(jo, "psnNo");
+            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, "psnName");
+            //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, "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");
-
+            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, "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.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, "acctMulaidPay");
+            MSettl.accountMutualAidAmount = getDecimalFee(jo, "acct_mulaid_pay");
         }
 
         public void setSettlementsByInPar()
@@ -694,19 +761,21 @@ namespace PTMedicalInsurance.Business
                     return -1;
                 }
                 JObject joRtn = JObject.Parse(errMsg);
-                JObject joSettl = JObject.Parse(JsonHelper.getDestValue(joRtn, "data"));
+                JObject joSettl = JObject.Parse(JsonHelper.getDestValue(joRtn, "result.data[0]"));
 
+                MPat.settlID = JsonHelper.getDestValue(joSettl, "SettlementID");
+                //MPat.mdtrtID = JsonHelper.getDestValue(joSettl, "MdtrtID");
                 //入参
-                joInpar.Add("payOrdId", JsonHelper.getDestValue(joSettl, "SettlementID"));//支付订单号
-                joInpar.Add("appRefdSn", JsonHelper.getDestValue(joSettl, ""));//应用退款流水号
-                joInpar.Add("appRefdTime", JsonHelper.getDestValue(joSettl, ""));//应用退费时间
+                joInpar.Add("payOrdId", JsonHelper.getDestValue(joSettl, "PayOrdID"));//支付订单号
+                joInpar.Add("appRefdSn", MPat.recordID);//应用退款流水号
+                joInpar.Add("appRefdTime", DateTime.Now.ToString("yyyyMMddHHmmss"));//应用退费时间
                 joInpar.Add("totlRefdAmt", JsonHelper.getDestValue(joSettl, "Sumamt"));//总退费金额
                 joInpar.Add("psnAcctRefdAmt", JsonHelper.getDestValue(joSettl, "AccountPaySumamt"));//医保个人账户支付
                 joInpar.Add("fundRefdAmt", JsonHelper.getDestValue(joSettl, "FundPaySumamt"));//基金支付
-                joInpar.Add("cashRefdAmt", JsonHelper.getDestValue(joInsuAdmObj, "PersonCashPay"));//现金退费金额
+                joInpar.Add("cashRefdAmt", JsonHelper.getDestValue(joSettl, "PersonCashPay"));//现金退费金额
                 joInpar.Add("ecToken", MPat.token);//电子凭证授权Token  前端传入
-                joInpar.Add("refdType", "ALL");//退费类型  前端传入
-                joInpar.Add("expData", "");//扩展数据  前端传入
+                joInpar.Add("refdType", "HI");//退费类型  前端传入
+                joInpar.Add("expContent", "");//扩展数据  前端传入
                 joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码  前端传入
 
                 //JObject joData = new JObject();
@@ -717,12 +786,12 @@ namespace PTMedicalInsurance.Business
             catch (Exception ex)
             {
 
-                outparam = "Get6203Inpar:" + ex.Message;
+                outparam = "GetYH6203Inpar:" + ex.Message;
                 return -1;
             }
             finally
             {
-                Global.writeLog("Get6203Inpar", "", outparam);
+                Global.writeLog("GetYH6203Inpar", "", outparam);
             }
         }
 

+ 16 - 1
InsuBusiness.cs

@@ -31,6 +31,8 @@ namespace PTMedicalInsurance
         private JArray jaParams;
         private JObject joParam;
         private JObject joInterface;
+        private JObject joInsuAdmObj;
+
 
         //设置业务实例
         CenterBusiness cBus = new CenterBusiness();
@@ -60,8 +62,10 @@ namespace PTMedicalInsurance
                 jaSession = JArray.Parse(JsonHelper.getDestValue(joInParam, "session"));
                 Global.curEvt.jaSession = jaSession;
                 jaParams = JArray.Parse(JsonHelper.getDestValue(joInParam, "params"));
-                joParam = JObject.FromObject(jaParams[0]);                
+                joParam = JObject.FromObject(jaParams[0]);
 
+                if (JsonHelper.getDestValue(joInParam, "insuAdmObj") != "")
+                    joInsuAdmObj = JObject.Parse(JsonHelper.getDestValue(joInParam, "insuAdmObj"));
                 joInterface = JObject.Parse(JsonHelper.getDestValue(joInParam, "interfaceinfo"));
 
                 businessType = JsonHelper.getDestValue(joInParam, "businessType");
@@ -1099,12 +1103,23 @@ 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.onlineYBFalg = "N";
+                            }
+                            else
+                            {
+                                mp.MSettl.onlineYBFalg = onlineYBFalg;
+                            }
+
                             if (mp.MobilePayCancelSettlement(out outParam) != 0)
                                 rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
                             else