/// <summary> /// 账单明细 /// </summary> /// <param name="start">开始日期</param> /// <param name="end">介绍日期</param> /// <param name="type">=0 ,全部记录=1扣费记录 =2 充值记录</param> /// <returns></returns> public APIRst GetBillDetail(DateTime start, DateTime end, int type = 0) { APIRst rst = new APIRst(); List <object> data = new List <object>(); try { DataTable dt01 = null, dt02 = null; if (type == 0 || type == 1) { dt01 = bll.GetBillDetail_01(start, end); } if (type == 0 || type == 2) { dt02 = bll.GetBillDetail_02(start, end); } if (dt01 != null) { var res1 = from s1 in dt01.AsEnumerable() select new { Log_id = CommFunc.ConvertDBNullToLong(s1["Log_id"]), CDate = CommFunc.ConvertDBNullToDateTime(s1["CDate"]).ToString("yyyy-MM-dd"), WaterUseVal = CommFunc.ConvertDBNullToDecimal(s1["WaterUseVal"]).ToString("f2"), WaterPrice = CommFunc.ConvertDBNullToDecimal(s1["Price"]).ToString("f2"), WaterAmt = CommFunc.ConvertDBNullToDecimal(s1["LastAmt"]).ToString("f2"), EleUseVal = CommFunc.ConvertDBNullToDecimal(s1["EleUseVal"]).ToString("f2"), ElePrice = CommFunc.ConvertDBNullToDecimal(s1["ElePrice"]).ToString("f2"), EleUseAmt = CommFunc.ConvertDBNullToDecimal(s1["EleUseAmt"]).ToString("f2"), ChargAmt = CommFunc.ConvertDBNullToDecimal(s1["ChargVal"]).ToString("f2"), Status = CommFunc.ConvertDBNullToInt32(s1["Status"]), PayTime = CommFunc.ConvertDBNullToDateTime(s1["PayTime"]).ToString("yyyy-MM-dd HH:mm:ss"), SyAmt = CommFunc.ConvertDBNullToDecimal(s1["SyAmt"]).ToString("f2"), }; data.Add(res1.ToList()); } if (dt02 != null) { var res2 = from s1 in dt02.AsEnumerable() select new { Log_id = CommFunc.ConvertDBNullToLong(s1["Log_id"]), CDate = CommFunc.ConvertDBNullToDateTime(s1["CDate"]).ToString("yyyy-MM-dd"), PayAmt = CommFunc.ConvertDBNullToDecimal(s1["PayAmt"]).ToString("f2"), SyAmt = CommFunc.ConvertDBNullToDecimal(s1["SyAmt"]).ToString("f2"), PayTime = CommFunc.ConvertDBNullToDateTime(s1["PayTime"]).ToString("yyyy-MM-dd HH:mm:ss"), }; data.Add(res2.ToList()); } rst.data = data; } catch (Exception ex) { rst.rst = false; rst.err.code = (int)ResultCodeDefine.Error; rst.err.msg = ex.Message; FileLog.WriteLog("账单明细:" + ex.Message + ex.StackTrace); } return(rst); }
/// <summary> /// 账单 /// </summary> /// <returns></returns> public APIRst GetBill() { APIRst rst = new APIRst(); try { DataTable dtSource = bll.GetBill(); var res1 = from s1 in dtSource.AsEnumerable() select new { Log_id = CommFunc.ConvertDBNullToLong(s1["Log_id"]), CDate = CommFunc.ConvertDBNullToDateTime(s1["CDate"]).ToString("yyyy-MM-dd"), WaterUseVal = CommFunc.ConvertDBNullToDecimal(s1["WaterUseVal"]).ToString("f2"), WaterPrice = CommFunc.ConvertDBNullToDecimal(s1["Price"]).ToString("f2"), WaterAmt = CommFunc.ConvertDBNullToDecimal(s1["LastAmt"]).ToString("f2"), EleUseVal = CommFunc.ConvertDBNullToDecimal(s1["EleUseVal"]).ToString("f2"), ElePrice = CommFunc.ConvertDBNullToDecimal(s1["ElePrice"]).ToString("f2"), EleUseAmt = CommFunc.ConvertDBNullToDecimal(s1["EleUseAmt"]).ToString("f2"), ChargAmt = CommFunc.ConvertDBNullToDecimal(s1["ChargVal"]).ToString("f2"), Status = CommFunc.ConvertDBNullToInt32(s1["Status"]), PayTime = CommFunc.ConvertDBNullToDateTime(s1["PayTime"]).ToString("yyyy-MM-dd HH:mm:ss"), //LastTime = CommFunc.ConvertDBNullToDateTime(s1["LastTime"]).ToString("yyyy-MM-dd"), }; rst.data = res1.ToList(); } catch (Exception ex) { rst.rst = false; rst.err.code = (int)ResultCodeDefine.Error; rst.err.msg = ex.Message; FileLog.WriteLog("获取账单错误:" + ex.Message + ex.StackTrace); } return(rst); }
/// <summary> /// 购电记录 /// </summary> /// <returns></returns> public APIRst GetPayLog(DateTime startTime, DateTime endTime) { APIRst rst = new APIRst(); try { DataTable dtSource = bll.GetPayLog(user.Attach.mid, startTime, endTime); int total = dtSource.Rows.Count; decimal payAmt = CommFunc.ConvertDBNullToDecimal(dtSource.Compute("sum(PayAmt)", "true")); var res1 = from s1 in dtSource.AsEnumerable() select new { Log_id = CommFunc.ConvertDBNullToLong(s1["Log_id"]), Create_dt = CommFunc.ConvertDBNullToDateTime(s1["Create_dt"]), PayVal = CommFunc.ConvertDBNullToDecimal(s1["PayVal"]), PayAmt = CommFunc.ConvertDBNullToDecimal(s1["PayAmt"]), PayModel = CommFunc.ConvertDBNullToInt32(s1["IsPay"]) != 0 ? "微信支付" : "现金支付", }; rst.data = new { row = res1.ToList(), total = total, payAmt = payAmt }; rst.rst = true; } catch (Exception ex) { rst.rst = false; rst.err.code = (int)ResultCodeDefine.Error; rst.err.msg = ex.Message; FileLog.WriteLog("购电记录信息错误:" + ex.Message + ex.StackTrace); } return(rst); }
public long AddAlarm(v2_alarm_logVModel alarm) { object parmas01 = new { Ledger = this.Ledger, Module_id = alarm.Module_id, ModuleAddr = alarm.ModuleAddr, Fun_id = alarm.Fun_id, FunType = alarm.FunType, FunName = alarm.FunName, CollectTime = alarm.CollectTime, CollectValue = alarm.CollectValue, ErrCode = alarm.ErrCode, ErrTxt = alarm.ErrTxt, Content = alarm.Content, SysUid = this.SysUid, }; StringBuilder strSql = new StringBuilder(); long log_id = 0; strSql.Clear(); strSql.Append("insert into v2_alarm_log("); strSql.Append("CDate,Ledger,Co_id,Module_id,ModuleAddr,Fun_id,FunType,FunName,Content,Create_by,Create_dt,CollectTime,CollectValue,ErrCode,ErrTxt,Total)"); strSql.Append("select now(),@Ledger,a.Co_id,@Module_id,@ModuleAddr,@Fun_id,@FunType,@FunName,@Content,@SysUid,now(),@CollectTime,@CollectValue,@ErrCode,@ErrTxt,1"); strSql.Append(" from vp_mdinfo as a where a.Ledger=@Ledger and a.Module_id=@Module_id;"); strSql.Append("select last_insert_id();"); log_id = CommFunc.ConvertDBNullToLong(SQLHelper.ExecuteScalar(strSql.ToString(), parmas01)); return(log_id); }
/// <summary> /// 下发命令 /// </summary> /// <param name="module_id"></param> /// <param name="fun_id"></param> /// <param name="funType"></param> /// <param name="dataValue"></param> /// <returns></returns> public long YdToGwOfAddCmd(int module_id, int fun_id, string funType, string dataValue, int isRn) { object params01 = new { Ledger = this.Ledger, Module_id = module_id, Fun_id = fun_id, FunType = funType, DataValue = dataValue, IsRn = isRn, SysUid = this.SysUid, }; StringBuilder strSql = new StringBuilder(); strSql.Clear(); strSql.Append("insert into v2_command("); strSql.Append("CDate,Ledger,Co_id,Module_id,ModuleAddr,Fun_id,FunType,DataValue,Create_by,Create_dt,ErrCode,IsRn)"); strSql.Append("select now(),a.Ledger,a.Co_id,a.Module_id,a.ModuleAddr,@Fun_id,@FunType,@DataValue,@SysUid,now(),0,@IsRn"); strSql.Append(" from vp_mdinfo as a"); strSql.Append(" where a.Ledger=@Ledger and a.Module_id=@Module_id;"); strSql.Append("select last_insert_id();"); object obj = SQLHelper.ExecuteScalar(strSql.ToString(), params01); return(CommFunc.ConvertDBNullToLong(obj)); }
/// <summary> /// 下发命令 /// </summary> /// <param name="cmd"></param> /// <param name="errCode"></param> /// <param name="errTxt"></param> /// <returns></returns> //public long AddCmdLog(int module_id, int fun_id, string funType, DateTime collectTime, string dataValue, string descr, int errCode, string errTxt) public long AddCmdLog(CommandVModel cmd, int errCode, string errTxt) { object params01 = new { Ledger = this.Ledger, CDate = cmd.CollectTime, Co_id = cmd.Co_id, Module_id = cmd.Module_id, ModuleAddr = cmd.ModuleAddr, Fun_id = cmd.Fun_id, FunType = cmd.FunType, Action = cmd.Action, DataValue = cmd.DataValue, CollectTime = cmd.CollectTime, Descr = cmd.Descr, ErrCode = errCode, ErrTxt = errTxt, Create_by = cmd.Create_by, Create_dt = cmd.Create_dt, IsRn = cmd.IsRn, }; StringBuilder strSql = new StringBuilder(); strSql.Clear(); strSql.Append("insert into v2_command("); strSql.Append("CDate,Ledger,Co_id,Module_id,ModuleAddr,Fun_id,FunType,Action,DataValue,CollectTime,Create_by,Create_dt,ErrCode,ErrTxt,EndTime,Descr,IsRn)"); strSql.Append("values(@CDate,@Ledger,@Co_id,@Module_id,@ModuleAddr,@Fun_id,@FunType,@Action,@DataValue,@CollectTime,@Create_by,@Create_dt,@ErrCode,@ErrTxt,now(),@Descr,@IsRn);"); //strSql.Append(" from vp_mdinfo as a"); //strSql.Append(" where a.Ledger=@Ledger and a.Module_id=@Module_id;"); strSql.Append("select last_insert_id();"); object obj = SQLHelper.ExecuteScalar(strSql.ToString(), params01); return(CommFunc.ConvertDBNullToLong(obj)); }
/// <summary> /// 增加告警 /// </summary> public long AddAlarm(int co_id, int module_id, string moduleAddr, string aType, int fun_id, string content, int errCode, string errTxt, string collectValue, DateTime collectTime) { object parmas01 = new { CDate = collectTime.ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo), Ledger = this.Ledger, Co_id = co_id, Module_id = module_id, ModuleAddr = moduleAddr, AType = aType, Fun_id = fun_id, }; StringBuilder strSql = new StringBuilder(); strSql.Clear(); strSql.Append("select Log_id"); strSql.Append(" from v2_alarm_log"); strSql.Append(" where CDate=@CDate"); strSql.Append(" and Ledger=@Ledger and Co_id=@Co_id and Module_id=@Module_id and ModuleAddr=@ModuleAddr and AType=@AType and Fun_id=@Fun_id"); strSql.Append(" order by Log_id desc limit 1"); object obj = SQLHelper.ExecuteScalar(strSql.ToString(), parmas01); long log_id = CommFunc.ConvertDBNullToLong(obj); // object parmas02 = new { Log_id = log_id, CDate = collectTime.ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo), Ledger = this.Ledger, Co_id = co_id, Module_id = module_id, ModuleAddr = moduleAddr, AType = aType, Fun_id = fun_id, Content = content, CollectTime = collectTime, CollectValue = collectValue, ErrCode = errCode, ErrTxt = errTxt, }; // if (log_id == 0) { strSql.Clear(); strSql.Append("insert into v2_alarm_log("); strSql.Append("CDate,Ledger,Co_id,Module_id,ModuleAddr,AType,Fun_id,Content,CTime,CollectTime,CollectValue,ErrCode,ErrTxt,Total)"); strSql.Append(" values ("); strSql.Append("now(),@Ledger,@Co_id,@Module_id,@ModuleAddr,@AType,@Fun_id,@Content,now(),@CollectTime,@CollectValue,@ErrCode,@ErrTxt,1);"); strSql.Append("select last_insert_id();"); log_id = CommFunc.ConvertDBNullToLong(SQLHelper.ExecuteScalar(strSql.ToString(), parmas02)); } else { strSql.Clear(); strSql.Append("update v2_alarm_log set ErrCode=@ErrCode,ErrTxt=@ErrTxt,CollectTime=@CollectTime,CollectValue=@CollectValue,Total=Total+1 where Log_id=@Log_id"); SQLHelper.Execute(strSql.ToString(), parmas02); } return(log_id); }
public int AddAlarmOnCollect(int co_id, int module_id, string moduleAddr, string aType, int fun_id, string content, int errCode, string errTxt, DateTime collectTime) { object params01 = new { CDate = DateTime.Now.AddMonths(-3).ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo), Ledger = this.Ledger, Co_id = co_id, Module_id = module_id, ModuleAddr = moduleAddr, AType = aType, CollectTime = collectTime }; StringBuilder strSql = new StringBuilder(); strSql.Clear(); strSql.Append("select Log_id from v2_alarm_log"); strSql.Append(" where CDate>=@CDate and Ledger=@Ledger and Co_id=@Co_id and Module_id=@Module_id and ModuleAddr=@ModuleAddr and AType=@AType and CollectTime=@CollectTime order by Log_id limit 1");//CDate=@CDate and object obj = SQLHelper.ExecuteScalar(strSql.ToString(), params01); long log_id = CommFunc.ConvertDBNullToLong(obj); object params02 = new { Log_id = log_id, CDate = DateTime.Now.ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo), Ledger = this.Ledger, Co_id = co_id, Module_id = module_id, ModuleAddr = moduleAddr, AType = aType, CollectTime = collectTime, Fun_id = fun_id, Content = content, ErrCode = errCode, ErrTxt = errTxt, }; if (log_id == 0) { strSql.Clear(); strSql.Append("insert into v2_alarm_log("); strSql.Append("CDate,Ledger,Co_id,Module_id,ModuleAddr,AType,Fun_id,Content,CTime,CollectTime,ErrCode,ErrTxt)"); strSql.Append(" values ("); strSql.Append("@CDate,@Ledger,@Co_id,@Module_id,@ModuleAddr,@AType,@Fun_id,@Content,now(),@CollectTime,@ErrCode,@ErrTxt)"); return(SQLHelper.Execute(strSql.ToString(), params02)); } else { strSql.Clear(); strSql.Append("update v2_alarm_log set Content=@Content,ErrCode=@ErrCode,ErrTxt=@ErrTxt where Log_id=@Log_id"); return(SQLHelper.Execute(strSql.ToString(), params02)); } }
public long GetYdPayListResult(string out_trade_no) { object params01 = new { Ledger = Ledger, Trade_no = out_trade_no, }; StringBuilder strSql = new StringBuilder(); strSql.Append("select Log_id from v4_pay_log where Ledger=@Ledger and Trade_no=@Trade_no and ifnull(Trade_no,'')<>'' and ErrCode<>1"); object obj = SQLHelper.ExecuteScalar(strSql.ToString(), params01); return(CommFunc.ConvertDBNullToLong(obj)); }
/// <summary> /// 增加设备充值命令到数据库中 /// </summary> /// <param name="module_id"></param> /// <param name="moduleAddr"></param> /// <param name="payVal"></param> /// <returns></returns> public long AddPayCommmand(int module_id, string moduleAddr, decimal payVal, V0Fun funType) { StringBuilder strSql = new StringBuilder(); strSql.Clear(); strSql.Append("insert into v2_command("); strSql.Append("CDate,Ledger,Co_id,Module_id,ModuleAddr,Fun_id,FunType,DataValue,Create_by,Create_dt,ErrCode)"); strSql.Append("select now(),a.Ledger,a.Co_id,a.Module_id,a.ModuleAddr,ifnull(b.Fun_id,0),@FunType,@DataValue,@SysUid,now(),0"); strSql.Append(" from vp_mdinfo as a left join v0_fun as b on a.Ledger=b.Ledger and a.Mm_id=b.Mm_id and b.FunType=@FunType"); strSql.Append(" where a.Ledger=@Ledger and a.Module_id=@Module_id and a.ModuleAddr=@ModuleAddr;"); strSql.Append("select last_insert_id();"); object obj = SQLHelper.ExecuteScalar(strSql.ToString(), new { Ledger = this.Ledger, Module_id = module_id, ModuleAddr = moduleAddr, DataValue = Math.Abs(payVal).ToString(), FunType = funType.ToString(), SysUid = this.SysUid }); return(CommFunc.ConvertDBNullToLong(obj)); }
/// <summary> /// 增加记录log /// </summary> /// <param name="pay"></param> /// <returns></returns> public bool YdDbMidAddPayLog(v4_pay_logVModel pay, DateTime endatatime, long recno) { object params01 = new { Ledger = this.Ledger, CDate = DateTime.Now, Co_id = pay.Co_id, Module_id = pay.Module_id, ModuleAddr = pay.ModuleAddr, Fun_id = pay.Fun_id, PayVal = pay.PayVal, PayAmt = pay.PayAmt, PayType = pay.PayType, IsWrong = pay.IsWrong, IsPay = pay.IsPay, Trade_no = pay.Trade_no, PayStartTime = pay.PayStartTime, PayEndTime = pay.PayEndTime, IsCharg = pay.IsCharg, Price = pay.Price, ErrCode = pay.ErrCode, ErrTxt = pay.ErrTxt, SysUid = this.SysUid, Month = endatatime, Recno = recno, }; StringBuilder strSql = new StringBuilder(); // strSql.Clear(); strSql.Append("insert into v4_pay_log("); strSql.Append("Ledger,CDate,Co_id,Module_id,ModuleAddr,Fun_id,PayVal,PayAmt,PayType,IsWrong,Create_by,Create_dt,IsPay,Trade_no,PayStartTime,PayEndTime,IsCharg,Price,ErrCode,ErrTxt,Month,Recno)"); strSql.Append(" values ("); strSql.Append("@Ledger,@CDate,@Co_id,@Module_id,@ModuleAddr,@Fun_id,@PayVal,@PayAmt,@PayType,@IsWrong,@SysUid,now(),@IsPay,@Trade_no,@PayStartTime,@PayEndTime,@IsCharg,@Price,@ErrCode,@ErrTxt,UNIX_TIMESTAMP(@Month),@Recno);"); strSql.Append("select last_insert_id();"); object obj = SQLHelper.ExecuteScalar(strSql.ToString(), params01); pay.Log_id = CommFunc.ConvertDBNullToLong(obj); if (pay.Log_id > 0) { return(true); } else { return(false); } }
/// <summary> /// 汇出Excel(充值缴费--打印小票) /// </summary> /// <returns></returns> public APIRst GetYdPrePayInMdExcel(int Co_id, string PayAmt, int IsPay) { long Room_id = CommFunc.ConvertDBNullToLong(Co_id); //房间id PayAmt = CommFunc.ConvertDBNullToDecimal(PayAmt).ToString("f2"); //缴费金额 //int IsPay = CommFunc.ConvertDBNullToInt32(Request["IsPay"]);//缴费方式:=0现金充值,=10微信充值 APIRst rst = new APIRst(); try { DataTable dtSource = bll.GetPayList(Room_id, PayAmt, IsPay); //string path = GetYdPayLogOnExport(dtSource); //return Json(new { rst = true, msg = "", data = path }, JsonRequestBehavior.DenyGet); int total = dtSource.Rows.Count; var res1 = from s1 in dtSource.AsEnumerable() select new { CoStrcName = CommFunc.ConvertDBNullToString(s1["CoStrcName"]), CoName = CommFunc.ConvertDBNullToString(s1["CoName"]), Multiply = CommFunc.ConvertDBNullToDecimal(s1["Multiply"]), IsPayS = CommFunc.ConvertDBNullToString(s1["IsPayS"]), payTypeS = CommFunc.ConvertDBNullToString(s1["payTypeS"]), PayVal = CommFunc.ConvertDBNullToDecimal(s1["PayVal"]).ToString("f2"), PayAmt = CommFunc.ConvertDBNullToDecimal(s1["PayAmt"]).ToString("f2"), Price = CommFunc.ConvertDBNullToDecimal(s1["Price"]).ToString("f3"), strAmt = CommFunc.ConvertDBNullToString(s1["strAmt"]), Create_by = CommFunc.ConvertDBNullToString(s1["Create_by"]), Create_dt = CommFunc.ConvertDBNullToString(s1["Create_dt"]), }; rst.data = res1.ToList(); //return Json(new { rst = true, msg = "", data = new { total = total, rows = res1.ToList() } }, JsonRequestBehavior.DenyGet); } catch (Exception ex) { rst.rst = false; rst.err.code = (int)ResultCodeDefine.Error; rst.err.msg = ex.Message; FileLog.WriteLog("GetYdPrePayInMdExcel:" + ex.Message + ex.StackTrace); } return(rst); }
public APIRst GetYdAlarmOfCmdList(string strcName, string coName, string startTime, string endTime) { APIRst rst = new APIRst(); try { DataTable dtSource = bll.GetYdAlarmOfCmdList(strcName, coName, CommFunc.ConvertDBNullToDateTime(startTime), CommFunc.ConvertDBNullToDateTime(endTime)); int total = dtSource.Rows.Count; var res1 = from s1 in dtSource.AsEnumerable() select new { RowId = CommFunc.ConvertDBNullToInt32(s1["RowId"]), Log_id = CommFunc.ConvertDBNullToLong(s1["Log_id"]), Co_id = CommFunc.ConvertDBNullToInt32(s1["Co_id"]), CoStrcName = CommFunc.ConvertDBNullToString(s1["CoStrcName"]), CoName = CommFunc.ConvertDBNullToString(s1["CoName"]), Module_id = CommFunc.ConvertDBNullToInt32(s1["Module_id"]), ModuleName = CommFunc.ConvertDBNullToString(s1["ModuleName"]), ModuleAddr = CommFunc.ConvertDBNullToString(s1["ModuleAddr"]), FunType = CommFunc.ConvertDBNullToString(s1["FunType"]), FunTypeS = CommFunc.ConvertDBNullToString(s1["FunTypeS"]), ErrTxt = CommFunc.ConvertDBNullToString(s1["ErrTxt"]), DataValue = CommFunc.ConvertDBNullToString(s1["DataValue"]), Create_by = CommFunc.ConvertDBNullToString(s1["Create_by"]), Create_dt = CommFunc.ConvertDBNullToDateTime(s1["Create_dt"]).ToString("yyyy-MM-dd HH:mm:ss"), }; object obj = new { total = total, rows = res1.ToList() }; rst.data = obj; } catch (Exception ex) { rst.rst = false; rst.err.code = (int)ResultCodeDefine.Error; rst.err.msg = ex.Message; FileLog.WriteLog("获取远程控制内容错误(GetYdAlarmOfCmdList)", ex.Message + ex.StackTrace); } return(rst); }
public static void UpV4_pay_charg(int ledger) { YDS6000.BLL.DataProcess.PayEstBLL bll = new YDS6000.BLL.DataProcess.PayEstBLL(ledger, Config.Uid); DataTable dtSource = bll.GetV4_pay_charg(); foreach (DataRow dr in dtSource.Rows) { long log_id = CommFunc.ConvertDBNullToLong(dr["Log_id"]); int co_id = CommFunc.ConvertDBNullToInt32(dr["Co_id"]); decimal firstVal = CommFunc.ConvertDBNullToDecimal(dr["FirstVal"]); decimal lastVal = CommFunc.ConvertDBNullToDecimal(dr["LastVal"]); decimal price = CommFunc.ConvertDBNullToDecimal(dr["Price"]); decimal chargVal = CommFunc.ConvertDBNullToDecimal(dr["ChargVal"]); decimal useAmt = Math.Round((lastVal - firstVal) * price, 2, MidpointRounding.AwayFromZero) + chargVal; DateTime firstTime = CommFunc.ConvertDBNullToDateTime(dr["FirstTime"]); DateTime lastTime = CommFunc.ConvertDBNullToDateTime(dr["LastTime"]); if (DateTime.Now < lastTime) { continue; } bll.UpV4_pay_charg(log_id, co_id, useAmt); } }
public void Pay(string out_trade_no) { DataTable dtSource = new YDS6000.BLL.IFSMgr.Monitor.MonitorBLL(this.ledger, this.uid).GetYdPayListResult(out_trade_no); int cnt = dtSource.Rows.Count; if (cnt == 0) { FileLog.WriteLog("微信支付回调数据库信息未找到,商户单号:", out_trade_no); return; } int ledger = CommFunc.ConvertDBNullToInt32(dtSource.Rows[0]["Ledger"]); long log_id = CommFunc.ConvertDBNullToLong(dtSource.Rows[0]["Log_id"]); int module_id = CommFunc.ConvertDBNullToInt32(dtSource.Rows[0]["Module_id"]); int uid = CommFunc.ConvertDBNullToInt32(dtSource.Rows[0]["Create_by"]); int co_id = CommFunc.ConvertDBNullToInt32(dtSource.Rows[0]["Co_id"]); this.ledger = ledger; this.uid = uid; gwBll = new YdToGw(ledger, uid); if (log_id == 0) { FileLog.WriteLog("微信支付回调数据库ID号未找到,商户单号:", out_trade_no); } else { if (module_id != 0) { Notify(log_id, module_id); } if (co_id != 0) { NotifyForPay(log_id, co_id); } //FileLog.WriteLog("微信支付回调数商户单号:", out_trade_no + "数据库ID号:" + log_id); } }
/// <summary> /// 首页获取首页最新告警 /// </summary> /// <returns></returns> public APIRst GetAlarmFisrt() { APIRst rst = new APIRst(); try { object obj = new { id = 0, Content = 0 }; DataTable dtSource = bll.GetAlarmFisrt(); if (dtSource.Rows.Count > 0) { obj = new { id = CommFunc.ConvertDBNullToLong(dtSource.Rows[0]["Log_id"]), Content = CommFunc.ConvertDBNullToString(dtSource.Rows[0]["Content"]) + ",地点:" + CommFunc.ConvertDBNullToString(dtSource.Rows[0]["MeterName"]) + ",当前值:" + CommFunc.ConvertDBNullToString(dtSource.Rows[0]["CollectValue"]) } } ; rst.data = obj; } catch (Exception ex) { rst.rst = false; rst.err.code = (int)ResultCodeDefine.Error; rst.err.msg = ex.Message; FileLog.WriteLog("首页获取首页最新告警:" + ex.Message + ex.StackTrace); } return(rst); }
/// <summary> /// 获取分项统计 /// </summary> /// <param name="co_id">支路ID号</param> /// <param name="time">时间</param> /// <param name="dataType">类型 日=day月=month年year</param> /// <returns></returns> public DataTable GetEnergyHisdata(int co_id, DateTime start, DateTime end, string moduleName, string funType) { DateTime dtFirst = new DateTime(start.Year, start.Month, start.Day, 0, 0, 0); DateTime dtLast = new DateTime(end.Year, end.Month, end.Day, 23, 59, 59); DataTable dtRst = new DataTable(); dtRst.Columns.Add("TagTime", typeof(System.DateTime)); dtRst.Columns.Add("Module_id", typeof(System.Int32)); dtRst.Columns.Add("Fun_id", typeof(System.Int32)); dtRst.Columns.Add("ModuleAddr", typeof(System.String)); dtRst.Columns.Add("ModuleName", typeof(System.String)); dtRst.Columns.Add("MeterNo", typeof(System.String)); dtRst.Columns.Add("LastVal", typeof(System.Decimal)); dtRst.Columns.Add("FunName", typeof(System.String)); dtRst.Columns.Add("CoName", typeof(System.String)); dtRst.PrimaryKey = new DataColumn[] { dtRst.Columns["TagTime"], dtRst.Columns["Module_id"], dtRst.Columns["Fun_id"] }; DataTable dtSource = dal.GetEnergyHisdata(co_id, moduleName, funType); dtSource.PrimaryKey = new DataColumn[] { dtSource.Columns["Module_id"], dtSource.Columns["Fun_id"] }; StringBuilder splitMdQuery = new StringBuilder(); StringBuilder splitTyQuery = new StringBuilder(); foreach (DataRow dr in dtSource.Rows) { if (!System.Text.RegularExpressions.Regex.IsMatch(string.Format("{0}{1}{2}", ",", splitMdQuery.ToString(), ","), string.Format("{0}{1}{2}", ",", CommFunc.ConvertDBNullToString(dr["Module_id"]), ","))) { if (!string.IsNullOrEmpty(splitMdQuery.ToString())) { splitMdQuery.Append(","); } splitMdQuery.Append(CommFunc.ConvertDBNullToString(dr["Module_id"])); } if (!System.Text.RegularExpressions.Regex.IsMatch(string.Format("{0}{1}{2}", ",", splitTyQuery.ToString(), ","), string.Format("{0}{1}{2}", ",", CommFunc.ConvertDBNullToString(dr["FunType"]), ","))) { if (!string.IsNullOrEmpty(splitTyQuery.ToString())) { splitTyQuery.Append(","); } splitTyQuery.Append(CommFunc.ConvertDBNullToString(dr["FunType"])); } } DateTime ucStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); long ucUnit = 10000000; #region 获取历史数据 DataTable dtUse = WholeBLL.GetCoreQueryData(this.Ledger, splitMdQuery.ToString(), dtFirst, dtLast, "hour", splitTyQuery.ToString()); foreach (DataRow dr in dtUse.Rows) { DataRow curDr = dtSource.Rows.Find(new object[] { dr["Module_id"], dr["Fun_id"] }); if (curDr == null) { continue; } int scale = CommFunc.ConvertDBNullToInt32(curDr["Scale"]); decimal multiply = CommFunc.ConvertDBNullToDecimal(curDr["Multiply"]); // DateTime tagtime = CommFunc.ConvertDBNullToDateTime(dr["TagTime"]); decimal firstVal = CommFunc.ConvertDBNullToDecimal(dr["FirstVal"]); decimal lastVal = CommFunc.ConvertDBNullToDecimal(dr["LastVal"]); //int interval = CommFunc.ConvertDBNullToInt32(dr["Interval"]); string dataCfg = CommFunc.ConvertDBNullToString(dr["DataCfg"]); dataCfg = string.IsNullOrEmpty(dataCfg) ? "0:0" : dataCfg; foreach (string s in dataCfg.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { string[] val = s.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (val.Length != 2) { continue; } long ticks = CommFunc.ConvertDBNullToLong(val[0]); decimal value = CommFunc.ConvertDBNullToDecimal(val[1]); if (CommFunc.ConvertDBNullToString(curDr["FunType"]).Equals(V0Fun.E.ToString()) || CommFunc.ConvertDBNullToString(curDr["FunType"]).Equals(V0Fun.EAnt.ToString()) || CommFunc.ConvertDBNullToInt32(curDr["IsChrg"]) == 1) { value = value + firstVal; } long ts = ticks + ((tagtime - ucStart).Ticks / 10000); TimeSpan toNow = new TimeSpan(ticks * ucUnit + ((tagtime - ucStart).Ticks)); DateTime tickTime = ucStart.Add(toNow); //tagtime.AddTicks(ticks); DataRow addDr = dtRst.Rows.Find(new object[] { tickTime, dr["Module_id"], dr["Fun_id"] }); if (addDr == null) { addDr = dtRst.NewRow(); addDr["TagTime"] = tickTime; addDr["Module_id"] = dr["Module_id"]; addDr["Fun_id"] = dr["Fun_id"]; addDr["ModuleAddr"] = curDr["ModuleAddr"]; addDr["ModuleName"] = curDr["ModuleName"]; addDr["FunName"] = curDr["FunName"]; addDr["CoName"] = curDr["CoName"]; addDr["MeterNo"] = curDr["MeterNo"]; dtRst.Rows.Add(addDr); } addDr["LastVal"] = value.ToString("f" + scale); } } #endregion return(dtRst); }
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); }
/// <summary> /// 更新 设备采集状况表 /// </summary> /// <param name="conn1"></param> /// <param name="trans"></param> /// <param name="Co_id"></param> /// <param name="Module_id"></param> /// <param name="ModuleAddr"></param> /// <param name="PayVal"></param> private long YdPrePayInMdOnChangeV2Info(IDbConnection conn1, IDbTransaction trans, int Co_id, int Module_id, string ModuleAddr, decimal PayVal, int payType) { object params01 = new { Ledger = this.Ledger, Co_id = Co_id, Module_id = Module_id, ModuleAddr = ModuleAddr, FunType = (payType == 1 ? V0Fun.Pay.ToString() : V0Fun.Refund.ToString()), SysUid = this.SysUid, Fun_id = 0, PayVal = (decimal)0, DataValue = (decimal)0, DebtTime = DBNull.Value, }; StringBuilder strSql = new StringBuilder(); DataTable dt = new DataTable(); decimal chrgVal = 0, rdVal = 0, multiply = 0; DateTime? debtTime = null; int fun_id = 0, isCharg = 0; strSql.Clear(); strSql.Append("select vf.Fun_id,b.ChrgVal,b.RdVal,b.DebtTime,a.Multiply,a.IsCharg"); //strSql.Append(" from vp_mdinfo as a left join vp_v2info as b on a.Ledger=b.Ledger and a.Co_id=b.Co_id and a.Module_id=b.Module_id and a.ModuleAddr=b.ModuleAddr and b.FunType='E'"); strSql.Append(" from vp_mdinfo as a inner join v0_fun as vf on a.Ledger=vf.Ledger and a.Mm_id=vf.Mm_id and vf.FunType='E'"); strSql.Append(" left join vp_v2info as b on a.Ledger=b.Ledger and a.Co_id=b.Co_id and a.Module_id=b.Module_id and a.ModuleAddr=b.ModuleAddr and vf.Fun_id=b.Fun_id"); strSql.Append(" where a.Ledger=@Ledger and a.Module_id=@Module_id"); dt = SQLHelper.Query(strSql.ToString(), params01); foreach (DataRow dr in dt.Rows) { fun_id = CommFunc.ConvertDBNullToInt32(dr["Fun_id"]); chrgVal = CommFunc.ConvertDBNullToDecimal(dr["ChrgVal"]); rdVal = CommFunc.ConvertDBNullToDecimal(dr["RdVal"]); multiply = CommFunc.ConvertDBNullToDecimal(dr["Multiply"]); isCharg = CommFunc.ConvertDBNullToInt32(dr["IsCharg"]); if (CommFunc.ConvertDBNullToDateTime(dr["DebtTime"]).Year != 1900) { debtTime = CommFunc.ConvertDBNullToDateTime(dr["DebtTime"]); } } // if (multiply == 0) { throw new Exception("倍率不能为零"); } decimal dataValue = PayVal / multiply; decimal payVal = payType == 1 ? dataValue : 0 - dataValue; // if (rdVal + payVal < 0) { debtTime = debtTime == null ? DateTime.Now : debtTime;/*这里可能需要修改,有逻辑错误*/ } else { debtTime = null; } // params01 = new { Ledger = this.Ledger, Co_id = Co_id, Module_id = Module_id, ModuleAddr = ModuleAddr, FunType = (payType == 1 ? V0Fun.Pay.ToString() : V0Fun.Refund.ToString()), SysUid = this.SysUid, Fun_id = fun_id, PayVal = payVal, DataValue = dataValue, DebtTime = debtTime, }; // strSql.Clear(); strSql.Append("INSERT INTO v2_info (Ledger, Co_id, Module_id, ModuleAddr, Fun_id, YT_id, BeginVal, FirstVal, LastVal, MinVal, MaxVal, FirstTime, LastTime, MinTime ,MaxTime,"); strSql.Append("Val1st,Val2nd,Val3rd,val4th,E4Time,ChrgVal,RdVal,MRdVal,DebtTime,Create_by, Create_dt, Update_by, Update_dt)"); strSql.Append("VALUES (@Ledger, @Co_id, @Module_id, @ModuleAddr, @Fun_id, 0, 0, 0, 0, 0, 0, '1900-01-01', '1900-01-01', '1900-01-01', '1900-01-01', "); strSql.Append("0, 0, 0, 0, null , case when @PayVal <=0 then 0 else @PayVal end, @PayVal , @PayVal ,null, @SysUid, NOW(), @SysUid, NOW())"); strSql.Append("ON DUPLICATE KEY UPDATE ChrgVal=case when ChrgVal+@PayVal<=0 then 0 else ChrgVal+@PayVal end,RdVal= RdVal+@PayVal,DebtTime=@DebtTime"); conn1.Execute(strSql.ToString(), params01, trans); // long cmd_log_id = 0; if (isCharg == 1) {/*充值命令*/ strSql.Clear(); strSql.Append("insert into v2_command("); strSql.Append("CDate,Ledger,Co_id,Module_id,ModuleAddr,Fun_id,FunType,DataValue,Create_by,Create_dt,ErrCode)"); strSql.Append("select now(),a.Ledger,@Co_id,a.Module_id,@ModuleAddr,ifnull(b.Fun_id,0),@FunType,@DataValue,@SysUid,now(),0"); strSql.Append(" from vp_mdinfo as a left join v0_fun as b on a.Ledger=b.Ledger and a.Mm_id=b.Mm_id and b.FunType=@FunType"); strSql.Append(" where a.Ledger=@Ledger and a.Module_id=@Module_id;"); strSql.Append("select last_insert_id();"); object obj = conn1.ExecuteScalar(strSql.ToString(), params01, trans); cmd_log_id = CommFunc.ConvertDBNullToLong(obj); } return(cmd_log_id); }
public int ToLeadCharg(ref DataTable dtSource) { StringBuilder strSql = new StringBuilder(); strSql.Clear(); strSql.Append("select Co_id,CoName from v1_cust where Ledger=@Ledger"); DataTable dtCo = SQLHelper.Query(strSql.ToString(), new { Ledger = this.Ledger }); //dtCo.PrimaryKey = new DataColumn[] { dtCo.Columns["Co_id"] }; foreach (DataRow dr in dtSource.Rows) { dr["ErrCode"] = 1; dr["ErrTxt"] = ""; DataRow[] co = dtCo.Select("CoName='" + CommFunc.ConvertDBNullToString(dr["CoName"]) + "'"); if (co.Count() != 1) { dr["ErrCode"] = -1; dr["ErrTxt"] = "房间号有错误"; continue; } int co_id = CommFunc.ConvertDBNullToInt32(co[0]["Co_id"]); decimal firstVal = CommFunc.ConvertDBNullToDecimal(dr["FirstVal"]); decimal lastVal = CommFunc.ConvertDBNullToDecimal(dr["LastVal"]); decimal chargVal = CommFunc.ConvertDBNullToDecimal(dr["ChargVal"]); decimal price = CommFunc.ConvertDBNullToDecimal(dr["Price"]); DateTime firstTime = CommFunc.ConvertDBNullToDateTime(CommFunc.ConvertDBNullToDateTime(dr["FirstTime"]).ToString("yyyy-MM-dd")); DateTime lastTime = CommFunc.ConvertDBNullToDateTime(CommFunc.ConvertDBNullToDateTime(dr["LastTime"]).ToString("yyyy-MM-dd")); #region if (firstVal < 0) { dr["ErrCode"] = -1; dr["ErrTxt"] = "上期计数小于零"; continue; } if (lastVal < 0) { dr["ErrCode"] = -1; dr["ErrTxt"] = "本期计数小于零"; continue; } if (firstVal > lastVal) { dr["ErrCode"] = -1; dr["ErrTxt"] = "上期计数大于本期计数"; continue; } if (price <= 0) { dr["ErrCode"] = -1; dr["ErrTxt"] = "水费单价小于零"; continue; } if (chargVal <= 0) { dr["ErrCode"] = -1; dr["ErrTxt"] = "物业费小于零"; continue; } if (firstTime.Year <= 2000) { dr["ErrCode"] = -1; dr["ErrTxt"] = "上期时间有异常"; continue; } if (lastTime.Year <= 2000) { dr["ErrCode"] = -1; dr["ErrTxt"] = "本期时间有异常"; continue; } if (firstTime > lastTime) { dr["ErrCode"] = -1; dr["ErrTxt"] = "上期时间大于本期时间"; continue; } #endregion if (CommFunc.ConvertDBNullToInt32(dr["Code"]) < 0) { continue; } // strSql.Clear(); strSql.Append("select RdAmt from v1_custinfo where Ledger=@Ledger and Co_id=@Co_id"); object obj = SQLHelper.ExecuteScalar(strSql.ToString(), new { Ledger = this.Ledger, Co_id = co_id }); decimal syAmt = CommFunc.ConvertDBNullToDecimal(obj); // strSql.Clear(); strSql.Append("select Log_id from v4_pay_charg where CDate=@CDate and Ledger=@Ledger and Co_id=@Co_id order by Log_id desc limit 1"); obj = SQLHelper.ExecuteScalar(strSql.ToString(), new { CDate = lastTime, Ledger = this.Ledger, Co_id = co_id }); long log_id = CommFunc.ConvertDBNullToLong(obj); // object param = new { Log_id = log_id, Ledger = this.Ledger, Co_id = co_id, FirstVal = firstVal, LastVal = lastVal, FirstTime = firstTime, LastTime = lastTime, Price = price, ChargVal = chargVal, SysUid = this.SysUid, SyAmt = syAmt }; if (log_id == 0) { strSql.Clear(); strSql.Append("insert into v4_pay_charg(CDate,Ledger,Co_id,FirstVal,LastVal,FirstTime,LastTime,Price,ChargVal,Cretae_by,Create_dt,Update_by,Update_dt,SyAmt)"); strSql.Append("values(@LastTime,@Ledger,@Co_id,@FirstVal,@LastVal,@FirstTime,@LastTime,@Price,@ChargVal,@SysUid,now(),@SysUid,now(),@SyAmt)"); return(SQLHelper.Execute(strSql.ToString(), param)); } else { strSql.Clear(); strSql.Append("update v4_pay_charg set CDate=@LastTime,FirstVal=@FirstVal,LastVal=@LastVal,FirstTime=@FirstTime,LastTime=@LastTime,Price=@Price,ChargVal=@ChargVal,Update_by=@SysUid,Update_dt=now() where Log_id=@Log_id"); return(SQLHelper.Execute(strSql.ToString(), param)); } } return(1); }
// 回调 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); }