public ExpParameterHelper() { user = WebConfig.GetSession(); bll = new YDS6000.BLL.Exp.Syscont.ParameterBLL(user.Ledger, user.Uid); WebConfig.GetSysConfig(); }
// 回调 public APIRst YdPrepPayInMdRecallPay(int pId, int pMid, string pTrade_no) { long log_id = CommFunc.ConvertDBNullToLong(pId); int module_id = CommFunc.ConvertDBNullToInt32(pMid); string out_trade_no = CommFunc.ConvertDBNullToString(pTrade_no); APIRst rst = new APIRst(); string msg = ""; string status = ""; bool result = false; bool pass = true; bool upSb = true; bool upDb = false; DateTime dtNow = DateTime.Now; long cmd_log_id = 0; #region 检查支付结果并更新数据库 System.Threading.Thread.Sleep(1000);/*一秒检查一次*/ object row = ""; object osObj = new { upSb = false, upDb = false, msg = "" }; try { if (string.IsNullOrEmpty(out_trade_no)) { result = bll.YdPrePayInMdOnRecallPay(log_id, 1, "", out msg, out cmd_log_id); } else { lock (ObjLock) {/*每次只能单独运行,目的是防止重复更新数据库的充值信息(重要事情)*/ pass = new WxPayAPI.WxPay().GetResult(out_trade_no, out status); if (pass == true) { result = bll.YdPrePayInMdOnRecallPay(log_id, 1, "", out msg, out cmd_log_id); } } } // if (result == true) { string msg2 = ""; if (cmd_log_id != 0) //立刻发送命令到网关 { /*充值命令*/ upSb = false; upSb = new YdToGw(user.Ledger, user.Uid).YdToGwAgain(cmd_log_id, out upDb, out msg2); } else { upDb = true;/*是否下发命令网关*/ } //#region 发送命令到网关(这款用于河北工业大学的SB设备,特殊定制化) //DataTable cmdPay = bll.GetGwPayData(module_id); //foreach (DataRow dr in cmdPay.Rows) //{ // decimal sbRdVal = CommFunc.ConvertDBNullToDecimal(dr["RdVal"]); // decimal sbSyZsVal = CommFunc.ConvertDBNullToDecimal(dr["SyZsVal"]); // CommandVModel cmd = ModelHandler<CommandVModel>.FillModel(dr); // cmd.Fun_id = 0; // cmd.FunType = "PaySb1"; // cmd.FunName = "充电"; // cmd.DataValue = (sbRdVal - sbSyZsVal).ToString("f2"); // cmd.Descr = "充电"; // cmd.IsUI = true; // cmd.IsNDb = true; // new YdToGw(user.Ledger, user.Uid).SendCmd(cmd); // // // cmd = ModelHandler<CommandVModel>.FillModel(dr); // cmd.Fun_id = 0; // cmd.FunType = "PaySb2"; // cmd.FunName = "增电"; // cmd.DataValue = sbSyZsVal.ToString("f2"); // cmd.Descr = "增电"; // cmd.IsUI = true; // cmd.IsNDb = true; // new YdToGw(user.Ledger, user.Uid).SendCmd(cmd); //} //#endregion //#region 发送短信 //bll.SendSms(log_id); //#endregion v4_pay_logVModel vpay = bll.GetV4_pay_log(log_id); osObj = new { upSb = upSb, upDb = upDb, msg = msg2 }; decimal chrgVal = 0, useVal = 0, rdVal = 0, syZsVal = 0; DataTable dtSource = bll.GetYdPostPayInMdOnList(module_id); if (dtSource.Rows.Count > 0) { chrgVal = CommFunc.ConvertDBNullToDecimal(dtSource.Rows[0]["ChrgVal"]); useVal = CommFunc.ConvertDBNullToDecimal(dtSource.Rows[0]["UseVal"]); rdVal = CommFunc.ConvertDBNullToDecimal(dtSource.Rows[0]["RdVal"]); syZsVal = CommFunc.ConvertDBNullToDecimal(dtSource.Rows[0]["SyZsVal"]); } row = new { ChrgVal = chrgVal.ToString("f2"), UseVal = useVal.ToString("f2"), RdVal = rdVal.ToString("f2"), SyVal = (rdVal - syZsVal).ToString("f2"), SyZsVal = syZsVal.ToString("f2") }; //判断是否拉闸 YDS6000.BLL.Exp.Syscont.ParameterBLL sysBll = new YDS6000.BLL.Exp.Syscont.ParameterBLL(user.Ledger, user.Uid); var dt = sysBll.GetAlarmCfg(); if (dt != null && dt.Rows.Count > 0) { decimal odValue = CommFunc.ConvertDBNullToDecimal(dt.Rows[0]["CfValue"]); int isClosed = CommFunc.ConvertDBNullToInt32(dt.Rows[0]["Rule"]); if (isClosed == 1) { if (rdVal <= odValue) { if (!YdBatchControlOfSsr("Ssr", "1", module_id.ToString())) { FileLog.WriteLog("拉闸失败(YdPrepPayInMdRecallPay)", "拉闸失败"); } } else { if (vpay.PayType == (int)PayType.pay) {/*充值动作才能合闸*/ if (!YdBatchControlOfSsr("Ssr", "0", module_id.ToString())) { FileLog.WriteLog("合闸失败(YdPrepPayInMdRecallPay)", "合闸失败"); } } } } } } object obj = new { pass = pass, row = row, osObj = osObj }; rst.rst = result; rst.data = obj; rst.err.msg = msg; } catch (Exception ex) { rst.rst = false; rst.err.code = (int)ResultCodeDefine.Error; rst.err.msg = ex.Message; FileLog.WriteLog("预付费错误(YdPrepPayInMdRecallPay)", ex.Message + ex.StackTrace); } #endregion return(rst); }
private bool YdDbMidRun() { DataTable dtSource = bll.GetDk_buy(); if (dtSource == null) { return(false); } foreach (DataRow dr in dtSource.Rows) { long recno = CommFunc.ConvertDBNullToLong(dr["recno"]); int co_id = CommFunc.ConvertDBNullToInt32(dr["FJID"]); decimal payAmt = CommFunc.ConvertDBNullToDecimal(dr["tranamt"]) / 100; DateTime endatatime = CommFunc.ConvertDBNullToDateTime(dr["endatatime"]); if (co_id == 0) { FileLog.WriteLog("中间库房间ID号为空"); continue; } if (payAmt == 0) { FileLog.WriteLog("中间库充值金额为0"); continue; } DataTable dtPay = bll.GetPayInfo(co_id); if (dtPay.Rows.Count == 0) { FileLog.WriteLog("中间库的房间ID:" + co_id + "没有表信息存在"); continue; } if (dtPay.Rows.Count > 1) { FileLog.WriteLog("中间库的房间ID:" + co_id + "存在多个表"); continue; } decimal price = CommFunc.ConvertDBNullToDecimal(dtPay.Rows[0]["Price"]); if (price == 0) { FileLog.WriteLog("中间库的房间ID:" + co_id + "单价不能为零"); continue; } v4_pay_logVModel pay = new v4_pay_logVModel(); pay.Co_id = CommFunc.ConvertDBNullToInt32(dtPay.Rows[0]["Co_id"]); pay.Module_id = CommFunc.ConvertDBNullToInt32(dtPay.Rows[0]["Module_id"]); pay.ModuleAddr = CommFunc.ConvertDBNullToString(dtPay.Rows[0]["ModuleAddr"]);; // CommFunc.ConvertDBNullToString(Request["ModuleAddr"]); pay.Fun_id = CommFunc.ConvertDBNullToInt32(dtPay.Rows[0]["Fun_id"]); pay.PayAmt = payAmt; pay.PayVal = Math.Round(pay.PayAmt / price, 2, MidpointRounding.AwayFromZero); pay.PayType = 1; pay.IsWrong = 0; pay.IsPay = 30; pay.PayStartTime = DateTime.Now; pay.PayEndTime = DateTime.Now; pay.Price = price; bll.YdDbMidAddPayLog(pay, endatatime, recno); string msg = ""; long cmd_log_id = 0; bll.PayVal(pay.Log_id, recno, 1, "", out msg, out cmd_log_id); if (cmd_log_id != 0)//立刻发送命令到网关 { CommandVModel cmd = bll.GetYdToGwOfSendCmd(cmd_log_id); DataProcess.YdDrive.Collection.CollectionHelper.Instance(cmd); } DataTable dtMM = bll.GetYdPostPayInMdOnList(pay.Module_id); decimal chrgVal = 0, useVal = 0, rdVal = 0, syZsVal = 0; if (dtMM.Rows.Count > 0) { chrgVal = CommFunc.ConvertDBNullToDecimal(dtMM.Rows[0]["ChrgVal"]); useVal = CommFunc.ConvertDBNullToDecimal(dtMM.Rows[0]["UseVal"]); rdVal = CommFunc.ConvertDBNullToDecimal(dtMM.Rows[0]["RdVal"]); syZsVal = CommFunc.ConvertDBNullToDecimal(dtMM.Rows[0]["SyZsVal"]); } //判断是否拉闸 YDS6000.BLL.Exp.Syscont.ParameterBLL sysBll = new YDS6000.BLL.Exp.Syscont.ParameterBLL(0, 1); var dt = sysBll.GetAlarmCfg(); if (dt != null && dt.Rows.Count > 0) { decimal odValue = CommFunc.ConvertDBNullToDecimal(dt.Rows[0]["CfValue"]); int isClosed = CommFunc.ConvertDBNullToInt32(dt.Rows[0]["Rule"]); if (isClosed == 1) { if (rdVal <= odValue) { this.YdBatchControlOfSsr(pay.Module_id, "Ssr", "1", 30); } else { this.YdBatchControlOfSsr(pay.Module_id, "Ssr", "0", 30); } } } } return(true); }