366 lines
20 KiB
C#
366 lines
20 KiB
C#
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;
|
|
namespace Mtxfw.VipSite
|
|
{
|
|
public partial class Admin_Member_pay_tocash : 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_pay_tocash.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 (!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 = " group by MemberId,CONVERT(varchar(10),addtime,120)";
|
|
string strOrder = "CONVERT(varchar(10),addtime,120) 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, "b0,b17,addtime,Seef,MemberId,(Select UserName From user_info b Where b.Id=MemberId) as MemberName,(Select realname From user_info b Where b.Id=MemberId) as realname","sum(b0) as b0,max(b17) as b17,CONVERT(varchar(10),addtime,120) as addtime,max(Seef) as Seef,MemberId" , "gtype=" + gtype + " and utype=10 and IFDelete=0 and Sended=0 and (b18=0 or b18=2)" + sb.ToString(), Start, Limit, out Recount);
|
|
Mtxfw.Utility.Tools.ToBind(Repeater1, dss.Tables[1]);// and hasRead=0
|
|
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 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");
|
|
string[] stra = Check.CssClass.Split('|');
|
|
Int32 MemberId = Convert.ToInt32(stra[0]);
|
|
DateTime addtime = Convert.ToDateTime(stra[1]);
|
|
if (Check.Checked == true)
|
|
{
|
|
if (strs == "0")
|
|
{
|
|
|
|
|
|
Mtxfw.Model.user_info umodel = daouser.GetModel(MemberId);
|
|
if (umodel != null)
|
|
{
|
|
|
|
string mindt = addtime.ToString("yyyy-MM-dd") + " 00:00:00";
|
|
string maxdt = addtime.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00";
|
|
string mindt0 = dt.ToString("yyyy-MM-dd") + " 00:00:00";
|
|
string maxdt0 = dt.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00";
|
|
if (daoResults.GetCount("gtype=" + gtype + " and utype=10 and IFDelete=0 and MemberId=" + umodel.Id + " and hasRead=0 and Sended=1 And addtime>='" + mindt0 + "' and addtime<'" + maxdt0 + "'") == 0)
|
|
{
|
|
Double b0 = 0.00;
|
|
string strb0 = daoResults.Getzd("sum(b0)", "gtype=" + gtype + " and utype=10 and IFDelete=0 and MemberId=" + umodel.Id + " and hasRead=0 and Sended=0 and seef=0 and b17=0 and (b18=0 or b18=2) And addtime>='" + mindt + "' and addtime<'" + maxdt + "'").ToString();
|
|
if (strb0 != "")
|
|
{
|
|
b0 = Convert.ToDouble(Convert.ToDouble(strb0).ToString("0.##"));
|
|
}
|
|
if (Convert.ToDouble(b0.ToString("f2")) > 0.00)
|
|
{
|
|
string PayID = dt.ToString("yyMMddHHmmss", DateTimeFormatInfo.InvariantInfo) + umodel.Id;
|
|
Mtxfw.Model.user_Results ModelResults = new Mtxfw.Model.user_Results();
|
|
ModelResults.b0 = b0;
|
|
ModelResults.b1 = 0;
|
|
ModelResults.b2 = 0;
|
|
ModelResults.b3 = 0;
|
|
ModelResults.b4 = 0;
|
|
ModelResults.b5 = 0;
|
|
ModelResults.b6 = 0;
|
|
ModelResults.b7 = 0;
|
|
ModelResults.b8 = 0;
|
|
ModelResults.b9 = 0;
|
|
ModelResults.b10 = 0;
|
|
ModelResults.b11 = 0;
|
|
ModelResults.b12 = 0;
|
|
ModelResults.b13 = 0;
|
|
ModelResults.b14 = 0;
|
|
ModelResults.b15 = 0;
|
|
ModelResults.b16 = 0;
|
|
ModelResults.b17 = 0;
|
|
ModelResults.b18 = 0;
|
|
ModelResults.conent = "门店成本";
|
|
ModelResults.Totalmoney = b0;
|
|
ModelResults.MemberId = umodel.Id;
|
|
ModelResults.UserId = 0;
|
|
ModelResults.ListNumber = PayID;
|
|
ModelResults.Managers = addtime.ToString("yyyy-MM-dd");
|
|
ModelResults.Seef = 0;
|
|
ModelResults.hasRead = 0;//0银花优选1普民慧
|
|
ModelResults.Sended = 1;//0成本记录1成本结算记录
|
|
ModelResults.utype = "10";
|
|
ModelResults.addtime = dt;
|
|
ModelResults.gtype = gtype;
|
|
Int64 resultid = daoResults.Add(ModelResults);
|
|
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();
|
|
if (bankcard != "" && accountname != "")
|
|
{
|
|
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);
|
|
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 + ",数量:" + b0.ToString("f2");
|
|
logmodel.UType = 0;
|
|
logmodel.gtype = gtype;
|
|
new DAL.User_CZ_log().Add(logmodel);
|
|
}
|
|
else
|
|
{
|
|
daoResults.Updatemoney("b17", 2, "id=" + resultid);
|
|
Model.User_Errlog mo = new Model.User_Errlog();
|
|
|
|
mo.DLID = 0;
|
|
mo.ErrType = "Admin_Member_pay_tocash_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_pay_tocash_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")
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
Data_Bind();
|
|
}
|
|
protected string getbankdata(int id)
|
|
{
|
|
string bankdata = "";
|
|
string bankname = "", bankcard = "", bankaddress = "", accountname = "";
|
|
DataSet sjds = daobusiness.GetList1("id,province,city,county,Agentrading,InternetSite,Busroutes,Introduction,ContactPeople,huifu_uid,token_no0,paytype", "utype=0 and UserId=" + id);
|
|
if (sjds.Tables[0].Rows.Count > 0)
|
|
{
|
|
bankname = sjds.Tables[0].Rows[0]["InternetSite"].ToString();
|
|
bankcard = sjds.Tables[0].Rows[0]["Busroutes"].ToString();
|
|
bankaddress = sjds.Tables[0].Rows[0]["Introduction"].ToString();
|
|
accountname = sjds.Tables[0].Rows[0]["ContactPeople"].ToString();
|
|
}
|
|
sjds.Clear();
|
|
bankdata += bankname + "<br>" + bankcard + "<br>" + bankaddress + "<br>" + accountname;
|
|
return bankdata;
|
|
}
|
|
}
|
|
} |