/// <summary> /// 结清欠款回调 /// </summary> /// <returns></returns> public ViewResult ClearDebtCallback() { var bus = new Bus(this.DataSource); var notify = new Notify(this.Request); var res = notify.GetNotifyData(); string return_code = res.GetValue("return_code").ToString(); string result_code = res.GetValue("result_code").ToString(); WxPayData wres = new WxPayData(); if (return_code.iEquals("success") && return_code.iEquals("success")) { var openid = res.GetValue("openid").ToString(); var transaction_id = res.GetValue("transaction_id").ToString(); var out_trade_no = res.GetValue("out_trade_no").ToString(); //订单号 var attach = res.GetValue("attach").ToString(); //商家数据包,原样返回 var pay = new Tb_Wx_Pappay(); foreach (var trade_no in attach.Split(',')) { pay = bus.getPaypay(trade_no); if (pay != null) { pay.DataDriver = this.DataSource; if (pay.FldCleardebted == 0) { pay.FldCleardebted = 1; pay.Store(); } } } } wres.SetValue("return_code", "SUCCESS"); wres.SetValue("return_msg", "回调成功"); return(View("callback", wres)); }
public Tb_Wx_Pappay getPaypay(string out_trade_no) { var pay = new Tb_Wx_Pappay(); var dc = new Tb_Wx_Pappay(this.DataSource); string condition = string.Format("FLD_OUT_TRADE_NO='{0}'", out_trade_no); DateTime start = DateTime.Parse("2017-07-01"); TimeSpan ts = DateTime.Now - start; int Year = DateTime.Now.Year - start.Year; int Month = (DateTime.Now.Year - start.Year) * 12 + (DateTime.Now.Month - start.Month); for (int i = 0; i <= Month; i++) { DateTime temp = DateTime.Now.AddMonths(-i); dc.TableName = string.Format("tb_wx_pappay_{0}", temp.ToString("yyyyMM")); pay = dc.FindFirst <Tb_Wx_Pappay>(condition); if (pay != null) { break; } } return(pay); }
public List <Tb_Wx_Pappay> getPaypayRecord(string openid, string city, int state) { var list = new List <Tb_Wx_Pappay>(); var dc = new Tb_Wx_Pappay(this.DataSource); string condition = string.Format("FLD_OPENID='{0}' and FLD_APPLET_APPID='{1}' and FLD_STATE={2}", openid, WxPayConfig.APPID(city), state);// and FLD_MEMO='SUCCESS' if (state == 1) { condition = string.Format("FLD_OPENID='{0}' and FLD_APPLET_APPID='{1}' and FLD_STATE in(1,2)", openid, WxPayConfig.APPID(city)); } string orderby = " ORDER BY FLD_TRADE_TIME desc"; DateTime start = DateTime.Parse("2017-07-01"); TimeSpan ts = DateTime.Now - start; int Year = DateTime.Now.Year - start.Year; int Month = (DateTime.Now.Year - start.Year) * 12 + (DateTime.Now.Month - start.Month); if (state == 1) { Month = (Month > 2) ? 2 : Month;//乘车记录正常取三个月记录 } else { condition += " and fld_cleardebted=0";//未结清的取所有记录 } for (int i = 0; i <= Month; i++) { DateTime temp = DateTime.Now.AddMonths(-i); dc.TableName = string.Format("tb_wx_pappay_{0}", temp.ToString("yyyyMM")); var ilist = dc.findByCondition <Tb_Wx_Pappay>(condition + orderby); if (ilist.Count > 0) { list = list.Concat(ilist).ToList(); } } return(list); }