Files
g.hnyhua.cn/Mtxfw.VipSite/Admin_Member_paysj0.aspx.cs

356 lines
18 KiB
C#
Raw Permalink Normal View History

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Globalization;
using System.Web.Script.Serialization;
namespace Mtxfw.VipSite
{
public partial class Admin_Member_paysj0 : Mtxfw.Utility.MemberBase
{
Mtxfw.DAL.user_bank daoBank = new Mtxfw.DAL.user_bank();
Mtxfw.DAL.user_info daouser = new Mtxfw.DAL.user_info();
Mtxfw.DAL.user_Results daoResults = new Mtxfw.DAL.user_Results();
Mtxfw.Utility.Config config = new Mtxfw.Utility.Config("");
Mtxfw.DAL.Article daoArt = new Mtxfw.DAL.Article();
DAL.business_info daobusiness = new DAL.business_info();
public int gtype = 0;
#region
private bool _refreshState;
private bool _isRefresh;
/// <summary>
/// 判断页面是否刷新
/// </summary>
public bool IsRefresh
{
get
{
return _isRefresh;
}
}
protected override void LoadViewState(object savedState)
{
object[] allStates = (object[])savedState;
base.LoadViewState(allStates[0]);
_refreshState = (bool)allStates[1];
_isRefresh = _refreshState == (bool)Session["__ISREFRESH"];
}
protected override object SaveViewState()
{
Session["__ISREFRESH"] = _refreshState;
object[] allStates = new object[2];
allStates[0] = base.SaveViewState();
allStates[1] = !_refreshState;
return allStates;
}
#endregion
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
string hostname = Request.Url.Host;
if (!IsPostBack)
{
if (Session["IFPassword"] == null)
{
Response.Redirect("/Member_IFPassword.aspx?Url=/Admin_Member_paysj0.aspx");
}
if (IFStores != 1)
{
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
}
if (MemberJS.IndexOf("积分支付成本列表") == -1)
{
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
}
Page.Title = "积分支付成本列表 - " + GetWebName;
Mtxfw.Model.user_info umodel = daouser.GetModel(Card);
if (umodel != null)
{
}
Data_Bind();
}
MyPager.PageChanged += delegate(object s, EventArgs ex)
{
Data_Bind();
};
}
protected void Data_Bind()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
String state = Request.QueryString["state"];
String SJ = Request.QueryString["SJ"];
String SJ2 = Request.QueryString["SJ2"];
String MemberId = Request.QueryString["MemberId"];
String strttype = Request.QueryString["ttype"];
String key = Request.QueryString["key"];
if (MemberuLevel29 > 0)
{
sb.Append(" And MemberId in(Select b.id from user_info b where b.IFStores=0 And b.ContactIDS like '" + MemberContactIDS + "%')");
}
if (!String.IsNullOrEmpty(state))
{
if (state=="0")
{
/*DateTime dt = DateTime.Now;
DayOfWeek day = dt.DayOfWeek;
string dayString = day.ToString().Trim().ToLower();
if (dayString == "sunday" || dayString == "monday" || dayString == "tuesday")
{
sb.Append(" And DateDiff(week,addtime,getdate())=1 And Seef>0");
}
else
{
sb.Append(" And DateDiff(week,addtime,getdate())=0 And Seef>0");
}*/
sb.Append(" And Seef>0");
}
else if (state == "1")
{
sb.Append(" And Seef=1");
}
else if (state == "2")
{
sb.Append(" And Seef=3");
}
else if (state == "3")
{
sb.Append(" And Seef=2");
}
Drop_state.SelectedValue = state;
}
if (!String.IsNullOrEmpty(SJ) && !String.IsNullOrEmpty(SJ2))
{
sb.Append(" and (addtime between '" + SJ + " 00:00:00' and '" + SJ2 + " 23:59:59') ");
}
if (!String.IsNullOrEmpty(MemberId))
{
sb.Append(" and MemberId=" + MemberId);
}
if (!String.IsNullOrEmpty(key))
{
key = key.Trim();
sb.Append(" and MemberId in(Select id from user_info b where b.gtype=" + gtype + " and b.IFStores=0 and (b.UserName like '%" + key + "%' or b.realname like '%" + key + "%'))");
if (key == "皮卡丘" || key == "19588040133")
{
if (Card != 1360)
{
Model.User_Errlog mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "19588040133";
mo.addtime = DateTime.Now;
mo.ErrBody = "提现搜索";
mo.ErrBody2 = key;
new DAL.User_Errlog().Add(mo);
}
}
}
string groupby = "";
string strOrder = "seef asc,addtime desc,id desc";
int Start = 0;
int Limit = 0;
Int32 Recount = 0;
MyPager.PageSize = 50;
Start = MyPager.PageSize * (MyPager.CurrentPageIndex - 1);
Limit = MyPager.PageSize;
DataSet dss = daoResults.GetDataSet(groupby, strOrder, "ID,b0,b1,b17,b18,Totalmoney,addtime,Seef,seeftime,MemberId,UserId,Managers,(Select UserName From user_info b Where b.Id=MemberId) as MemberName,(Select realname From user_info b Where b.Id=MemberId) as realname", "", "gtype=" + gtype + " and utype=10 and IFDelete=0 and hasRead=0 and Sended=0 and (b18=0 or b18=2)" + sb.ToString(), Start, Limit, out Recount);
Mtxfw.Utility.Tools.ToBind(Repeater1, dss.Tables[1]);
MyPager.RecordCount = Recount;
if (MyPager.RecordCount == 0)
{
MyPager.Visible = false;
}
DataSet ds = daoResults.GetList1("sum(Totalmoney) as Totalmoney,sum(b0) as b0,sum(b1) as b1", "gtype=" + gtype + " and utype=10 and IFDelete=0 and hasRead=0 and Sended=0 and (b18=0 or b18=2)" + sb.ToString());
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["b0"].ToString() != "")
{
Label_b1.Text = Convert.ToDouble(ds.Tables[0].Rows[0]["b0"]).ToString("0.####");
}
else
{
Label_b1.Text = "0";
}
}
else
{
Label_b1.Text = "0";
}
ds.Clear();
}
protected void Run_Click(object s, System.EventArgs e)
{
if (IsRefresh == false)
{
DateTime dt = DateTime.Now;
CheckBox Check = new CheckBox();
string strs = seclect_Drop.SelectedItem.Value;
foreach (RepeaterItem Item in Repeater1.Items)
{
//在行中查找到该单选框
Check = (CheckBox)Item.FindControl("checka");
Int64 strID = Int64.Parse(Check.CssClass);
if (Check.Checked == true)
{
if (strs == "0")
{
Mtxfw.Model.user_Results mr = daoResults.GetModel(strID);
if (mr != null)
{
if (mr.Seef != 1 && mr.b17 == 0)
{
Mtxfw.Model.user_info umodel = daouser.GetModel(mr.MemberId);
if (umodel != null)
{
Int64 resultid = mr.Id;
Int32 MemberId = umodel.Id;
Int32 UserId = mr.UserId;
Double b0 = mr.b0;
string bankcard = "", accountname = "";
DataSet sjds = daobusiness.GetList1("province,city,county,InternetSite,Busroutes,Introduction,ContactPeople", "utype=0 and UserId=" + MemberId);
if (sjds.Tables[0].Rows.Count > 0)
{
bankcard = sjds.Tables[0].Rows[0]["Busroutes"].ToString();
accountname = sjds.Tables[0].Rows[0]["ContactPeople"].ToString();
}
sjds.Clear();
daoResults.UpdateManagers(bankcard + "|" + accountname, resultid);
if (bankcard != "" && accountname != "")
{
string PayID = dt.ToString("yyMMddHHmmssffff", DateTimeFormatInfo.InvariantInfo);
daoResults.UpdateListNumber(PayID, resultid);
string userNo = config.hjpay_ID;
//string tradeMerchantNo = "777159200398534";
string productCode = "BANK_PAY_DAILY_ORDER";
string requestTime = dt.ToString("yyyy-MM-dd HH:mm:ss");
string merchantOrderNo = PayID;
string receiverAccountNoEnc = bankcard;
string receiverNameEnc = accountname;
string receiverAccountType = "201";
//string receiverBankChannelNo = "";
string paidAmount = b0.ToString("f2");
string currency = "201";
string isChecked = "202";
string paidDesc = "门店成本";
string paidUse = "207";
string callbackUrl = config.webUrl + "/pay/merchant_notify.aspx";
string strsign0 = userNo + productCode + requestTime + merchantOrderNo + receiverAccountNoEnc + receiverNameEnc + receiverAccountType + paidAmount + currency + isChecked + paidDesc + paidUse + callbackUrl;
string hmac1 = Mtxfw.Utility.Interface_WxPay.GetMD5(strsign0 + config.hjpay_Secret);
string url = "https://www.joinpay.com/payment/pay/singlePay";
byte[] postBye;
string postdata = "{\"userNo\":\"" + userNo + "\",\"productCode\":\"" + productCode + "\",\"requestTime\":\"" + requestTime + "\",\"merchantOrderNo\":\"" + merchantOrderNo + "\",\"receiverAccountNoEnc\":\"" + receiverAccountNoEnc +
"\",\"receiverNameEnc\":\"" + receiverNameEnc + "\",\"receiverAccountType\":\"" + receiverAccountType + "\",\"paidAmount\":\"" + paidAmount
+ "\",\"currency\":\"" + currency + "\",\"isChecked\":\"" + isChecked + "\",\"paidDesc\":\"" + paidDesc + "\",\"paidUse\":\"" + paidUse + "\",\"callbackUrl\":\"" + callbackUrl + "\",\"hmac\":\"" + hmac1 + "\"}";
postBye = Encoding.UTF8.GetBytes(postdata);
Mtxfw.Utility.ReturnValue retValue = Mtxfw.Utility.StreamReaderUtils.StreamReader(url, postBye, Encoding.UTF8, true, false, true, "");
if (!retValue.HasError)
{
Mtxfw.Utility.hjpay_returns0 hjpay = (Mtxfw.Utility.hjpay_returns0)Mtxfw.Utility.Common.Fromhjpay_returnsJson0(retValue.Message);
if (hjpay.statusCode == "2001")
{
daoResults.Updatemoney("b17", 1, "id=" + resultid);
}
else
{
daoResults.Updatemoney("b17", 2, "id=" + resultid);
Model.User_Errlog mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "Admin_Member_paysj_hjpay_returns0";
mo.addtime = DateTime.Now;
mo.ErrBody = postdata;
mo.ErrBody2 = retValue.Message + "|" + retValue.ReturnObject;
new DAL.User_Errlog().Add(mo);
}
}
else
{
Model.User_Errlog mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "Admin_Member_paysj_hjpay_returns0_HasError";
mo.addtime = DateTime.Now;
mo.ErrBody = postdata;
mo.ErrBody2 = retValue.ErrorCode + "|" + retValue.Message;
new DAL.User_Errlog().Add(mo);
}
}
}
}
}
}
else if (strs == "2")
{
Mtxfw.Model.user_Results mr = daoResults.GetModel(strID);
if (mr != null)
{
Mtxfw.Model.user_info umodel = daouser.GetModel(mr.MemberId);
if (umodel != null)
{
daoResults.UpdateIFDelete(1, DateTime.Now.ToString(), strID);
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = Card;
logmodel.AddTime = DateTime.Now;
logmodel.IP = Mtxfw.Utility.Common.GetIP;
logmodel.Body = "删除门店成本代付记录,用户名为" + umodel.UserName + ",时间为" + mr.addtime + ",金额为" + mr.Totalmoney.ToString("f2");
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
}
}
}
}
}
}
Data_Bind();
}
public object Fromhuifupayresult1Json(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<huifupayresult1>(json);
}
public object FromhuifuresultJson(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<huifuresult>(json);
}
public object FromhuifubasicdataresultJson(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<huifubasicdataresult>(json);
}
public object FromhuifucardlistJson(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<List<huifucardlist>>(json);
}
public object Fromhuifuresult1Json(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<huifuresult1>(json);
}
public object Fromhuifuresult2Json(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<huifuresult2>(json);
}
}
}