/// <summary> /// 取网店配置信息 /// </summary> /// <param name="mconfigid"></param> /// <returns></returns> public static M_ConfigInfo GetMConfig(int mconfigid) { Yannyo.Cache.YannyoCache cache = Yannyo.Cache.YannyoCache.GetCacheService(); M_ConfigInfo x = cache.RetrieveObject("/Sys/GetMConfigList_" + mconfigid) as M_ConfigInfo; if (x == null) { x = M_Utils.GetM_ConfigInfoModel(mconfigid); x.m_APIURL = GeneralConfigs.GetConfig().Taobao_Api.Trim(); cache.AddObject("/Sys/GetMConfigList_" + mconfigid, x); } return(x); }
/// <summary> /// 得到一个对象实体 /// </summary> public M_ConfigInfo GetM_ConfigInfoModelByAppKey(string m_AppKey) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 m_ConfigInfoID,m_Name,m_AppKey,m_AppSecret,StoresID,(select sName from tbStoresInfo where StoresID=tb_M_ConfigInfo.StoresID) as StoresName,m_State,m_AppendTime,m_SessionKey,m_UpdateTime from tb_M_ConfigInfo "); strSql.Append(" where m_AppKey=@m_AppKey "); SqlParameter[] parameters = { new SqlParameter("@m_AppKey", SqlDbType.VarChar, 50) }; parameters[0].Value = m_AppKey; M_ConfigInfo model = new M_ConfigInfo(); DataSet ds = DbHelper.ExecuteDataset(CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["m_ConfigInfoID"].ToString() != "") { model.m_ConfigInfoID = int.Parse(ds.Tables[0].Rows[0]["m_ConfigInfoID"].ToString()); } model.m_Name = ds.Tables[0].Rows[0]["m_Name"].ToString(); model.m_AppKey = ds.Tables[0].Rows[0]["m_AppKey"].ToString(); model.m_AppSecret = ds.Tables[0].Rows[0]["m_AppSecret"].ToString(); if (ds.Tables[0].Rows[0]["StoresID"].ToString() != "") { model.StoresID = int.Parse(ds.Tables[0].Rows[0]["StoresID"].ToString()); } model.StoresName = ds.Tables[0].Rows[0]["StoresName"].ToString(); model.m_SessionKey = ds.Tables[0].Rows[0]["m_SessionKey"].ToString(); if (ds.Tables[0].Rows[0]["m_State"].ToString() != "") { model.m_State = int.Parse(ds.Tables[0].Rows[0]["m_State"].ToString()); } if (ds.Tables[0].Rows[0]["m_AppendTime"].ToString() != "") { model.m_AppendTime = DateTime.Parse(ds.Tables[0].Rows[0]["m_AppendTime"].ToString()); } if (ds.Tables[0].Rows[0]["m_UpdateTime"].ToString() != "") { model.m_UpdateTime = DateTime.Parse(ds.Tables[0].Rows[0]["m_UpdateTime"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int AddM_ConfigInfo(M_ConfigInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_M_ConfigInfo("); strSql.Append("m_Name,m_AppKey,m_AppSecret,StoresID,m_State,m_AppendTime,m_SessionKey,m_UpdateTime)"); strSql.Append(" values ("); strSql.Append("@m_Name,@m_AppKey,@m_AppSecret,@StoresID,@m_State,@m_AppendTime,@m_SessionKey,@m_UpdateTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@m_Name", SqlDbType.VarChar, 50), new SqlParameter("@m_AppKey", SqlDbType.VarChar, 50), new SqlParameter("@m_AppSecret", SqlDbType.VarChar, 50), new SqlParameter("@StoresID", SqlDbType.Int, 4), new SqlParameter("@m_State", SqlDbType.Int, 4), new SqlParameter("@m_AppendTime", SqlDbType.DateTime), new SqlParameter("@m_SessionKey", SqlDbType.VarChar, 50), new SqlParameter("@m_UpdateTime", SqlDbType.DateTime), }; parameters[0].Value = model.m_Name; parameters[1].Value = model.m_AppKey; parameters[2].Value = model.m_AppSecret; parameters[3].Value = model.StoresID; parameters[4].Value = model.m_State; parameters[5].Value = model.m_AppendTime; parameters[6].Value = model.m_SessionKey; parameters[7].Value = model.m_UpdateTime; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj == null) { return(-1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public void UpdateM_ConfigInfo(M_ConfigInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_M_ConfigInfo set "); strSql.Append("m_Name=@m_Name,"); strSql.Append("m_AppKey=@m_AppKey,"); strSql.Append("m_AppSecret=@m_AppSecret,"); strSql.Append("StoresID=@StoresID,"); strSql.Append("m_State=@m_State,"); strSql.Append("m_AppendTime=@m_AppendTime,"); strSql.Append("m_SessionKey=@m_SessionKey,"); strSql.Append("m_UpdateTime=@m_UpdateTime"); strSql.Append(" where m_ConfigInfoID=@m_ConfigInfoID "); SqlParameter[] parameters = { new SqlParameter("@m_ConfigInfoID", SqlDbType.Int, 4), new SqlParameter("@m_Name", SqlDbType.VarChar, 50), new SqlParameter("@m_AppKey", SqlDbType.VarChar, 50), new SqlParameter("@m_AppSecret", SqlDbType.VarChar, 50), new SqlParameter("@StoresID", SqlDbType.Int, 4), new SqlParameter("@m_State", SqlDbType.Int, 4), new SqlParameter("@m_AppendTime", SqlDbType.DateTime), new SqlParameter("@m_SessionKey", SqlDbType.VarChar, 50), new SqlParameter("@m_UpdateTime", SqlDbType.DateTime), }; parameters[0].Value = model.m_ConfigInfoID; parameters[1].Value = model.m_Name; parameters[2].Value = model.m_AppKey; parameters[3].Value = model.m_AppSecret; parameters[4].Value = model.StoresID; parameters[5].Value = model.m_State; parameters[6].Value = model.m_AppendTime; parameters[7].Value = model.m_SessionKey; parameters[8].Value = model.m_UpdateTime; DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters); }
protected void Page_Load(object sender, EventArgs e) { string ReStr = ""; //返回字符串 string ReType = (new string[] { "Buyer", "Seller", "Other", "request" })[HTTPRequest.GetInt("ReFormat", 1)]; //返回类型 string doAction = (new string[] { "top_appkey", "top_parameters", "top_session", "top_sign", "encode", "notify" })[HTTPRequest.GetInt("Act", 2)]; //动作类型,top_appkey,top_parameters,top_session,top_sign,encode ReStr = HTTPRequest.GetString(doAction); if (ReType != "request") { //获取SessionKey,更新配置信息 if (doAction == "top_session") { string AppKey = HTTPRequest.GetString("top_appkey"); M_ConfigInfo _mc = M_Utils.GetM_ConfigInfoModelByAppKey(AppKey); if (_mc != null) { _mc.m_SessionKey = HTTPRequest.GetString("top_session"); _mc.m_UpdateTime = DateTime.Now; try { M_Utils.UpdateM_ConfigInfo(_mc); Caches.ReSet();//重置缓存 AddMsgLine("鉴权成功,请关闭该页面!"); AddScript("window.setTimeout('window.parent.HidBox();',1000);"); } catch (Exception ex) { AddErrLine("系统内部错误:" + ex.Message); } } } } #region 通知 if (ReType == "request") { //返回通知 if (doAction == "notify") { string method = Utils.ChkSQL(HTTPRequest.GetString("method")); string timestamp = Utils.ChkSQL(HTTPRequest.GetString("timestamp")); string format = Utils.ChkSQL(HTTPRequest.GetString("format")); string app_key = Utils.ChkSQL(HTTPRequest.GetString("app_key")); string v = Utils.ChkSQL(HTTPRequest.GetString("v")); string sign = Utils.ChkSQL(HTTPRequest.GetString("sign")); string message = Utils.ChkSQL(HTTPRequest.GetString("message")); /* * 商品相关 * * 1) 新增商品(ItemAdd) :通过taobao.item.add 添加一个商品 * * 2) 上架商品(ItemUpshelf):通过taobao.item.update.listing 进行一口价商品上架 * * 3) 下架商品ItemDownshelf :通过taobao.item.update.delisting 使商品下架 * * 4) 删除商品(ItemDelete):通过taobao.item.delete 删除了单条商品 * * 5) 更新商品(ItemUpdate):通过taobao.item.update 更新了商品信息 * * 6) 取消橱窗推荐商品(temRecommendDelete):通过调用taobao.item.recommend.delete 取消橱窗推荐一个商品 * * 7) 橱窗推荐商品(ItemRecommendAdd):通过taobao.item.recommend.add 橱窗推荐一个商品 * * 8) 商品卖空(ItemZeroStock):架上数量为0的时候 * * 9) 小二删除商品 (ItemPunishDelete):由于商品违规等原因被小二删除 * * 交易相关 * 1) 创建交易TradeCreate:买家点击了购买,交易状态为创建交易 * * 2) 修改交易费用TradeModifyFee:在买家未付款之前,卖家根据实际情况能修改交易费用 * * 3) 关闭或修改子订单TradeCloseAndModifyDetailOrder:在买家未付款之前,卖家可以关闭或者修改子订单信息 * * 4) 关闭交易TradeClose:在买家未付款之前,卖家或买家关闭这笔交易 * * 5) 买家付款TradeBuyerPay:买家以支付宝等形式进行付款 * * 6) 卖家发货TradeSellerShip:买家付款后,卖家进行发货操作 * * 7) 延长收货时间TradeDelayConfirmPay:买家延长收货的时间 * * 8) 子订单退款成功TradePartlyRefund:买家对一笔交易中的子订单中的商品不满意,申请退款,卖家同意后进行退款 * * 9) 子订单打款成功TradePartlyConfirmPay 买家对交易中的子订单付款成功 * * 10) 交易成功TradeSuccess * * 11) 交易超时提醒TradeTimeoutRemind * * 12) 交易评价变更TradeRated:买家改变原先的评价 * * 13) 交易备注修改TradeMemoModified:在交易创建后,买家或者卖家修改交易备注 * * 14) 修改交易收货地址TradeLogisticsAddressChanged * * 15) 修改订单信息(SKU等)TradeChanged:买家未付款之前,卖家修改sku等信息 * * 退款相关 * 1) 退款成功RefundSuccess * * 2) 退款关闭RefundClosed:退款申请未成功然后退款关闭 * * 3) 退款创建RefundCreated:买家收到货,不满意可以进入“我的淘宝”—“我是买家”—“已买到的宝贝”页面找到对应交易订单,点击“申请退款” * * 4) 卖家同意退款协议RefundSellerAgreeAgreement:卖家收到退款申请,点击同意退款协议 * * 5) 卖家拒绝退款协议RefundSellerRefuseAgreement:卖家收到退款申请,点击拒绝退款协议 * * 6) 买家修改退款协议RefundBuyerModifyAgreement:如果买家开始是拒绝退款协议,修改成了同意,订阅后返回买家修改退款协议信息 * * 7) 买家退货给卖家RefundBuyerReturnGoods:买家收到货不满意申请退货 * * 8) 发表退款留言RefundCreateMessage:在退款协议中发表留言 * * 9) 屏蔽退款留言RefundBlockMessage * * 10) 退款超时提醒RefundTimeoutRemind:根据退款超时规则,超过规则中的期限。 */ if (app_key.Trim() != "") { try { M_ConfigInfo mc = new M_ConfigInfo(); mc = M_Utils.GetM_ConfigInfoModelByAppKey(app_key.Trim()); if (mc != null) { switch (method) { case "TradeCreate": case "TradeModifyFee": case "TradeCloseAndModifyDetailOrder": case "TradeClose": case "TradeBuyerPay": case "TradeSellerShip": case "TradeDelayConfirmPay": case "TradePartlyRefund": case "TradePartlyConfirmPay": case "TradeSuccess": case "TradeTimeoutRemind": case "TradeMemoModified": case "TradeLogisticsAddressChanged": case "TradeChanged": case "TradeRated": GetTrades(mc); break; } } } catch { } } } Response.Charset = "utf-8"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8"); Response.ContentType = "text/html"; Response.Write("true"); Response.End(); } #endregion }
public void GetTrades(M_ConfigInfo mc) { PublicReMSG reValue = new PublicReMSG(); DataTable dList = new DataTable(); try { reValue = TopApiUtils.GetTradesList(mc, DateTime.Now.AddMonths(-2).ToString(), DateTime.Now.ToString(), null, null, null, null, null, 1, 100); if (reValue.reCode == 0) { dList = reValue.reObj as DataTable; if (dList != null) { foreach (DataRow dr in dList.Rows) { reValue = TopApiUtils.GetTradesFullInfo(mc, long.Parse(dr["tid"].ToString())); try { if (reValue.reCode == 0) { M_TradeInfo mTrade = new M_TradeInfo(); try { mTrade = reValue.reObj as M_TradeInfo; if (mTrade != null) { int m_TradeInfoID = M_Utils.ExistsM_TradeInfoAndReID(mc.m_ConfigInfoID, long.Parse(dr["tid"].ToString())); if (m_TradeInfoID > 0) { mTrade.m_TradeInfoID = m_TradeInfoID; mTrade.m_ConfigInfoID = mc.m_ConfigInfoID; M_Utils.UpdateM_TradeInfo(mTrade); } else { mTrade.m_ConfigInfoID = mc.m_ConfigInfoID; M_Utils.AddM_TradeInfo(mTrade); } } } finally { mTrade = null; } } } catch (Exception ex) { } finally { reValue = null; } } } } } finally { dList = null; reValue = null; } }
/// <summary> /// BasePage类构造函数 /// </summary> public PageBase() { System.Web.HttpContext.Current.Response.ClearContent(); System.Web.HttpContext.Current.Response.Buffer = true; System.Web.HttpContext.Current.Response.ExpiresAbsolute = System.DateTime.Now.AddYears(-1); System.Web.HttpContext.Current.Response.Expires = 0; //清理缓存 if (HTTPRequest.GetInt("CachesClear", 0) == 1) { Caches.ReSet(); System.Web.HttpContext.Current.Response.End(); } string cookietag = GeneralConfigs.GetConfig().CookieTag.Trim(); config = GeneralConfigs.GetConfig(); MConfigList = Caches.GetMConfigList();//网店列表 //取当前网店信息 int mconfigid = HTTPRequest.GetInt("mconfigid", 0); if (mconfigid > 0) { M_Config = Caches.GetMConfig(mconfigid); //是否沙箱模式 if (config.Taobao_SandBox == 1) { //SessioKey是否超过30分钟 if (DateTime.Now.Subtract(M_Config.m_UpdateTime).TotalMinutes >= 30) { ShowMSign = true;//弹出授权框 } } } if (CheckUser()) { userinfo = Yannyo.BLL.tbUserInfo.GetUserInfoModel(userid); userpopedom = userinfo.uPermissions; username = userinfo.uName; } //清空当前页面查询统计 Yannyo.Data.DbHelper.QueryCount = 0; #if NET1 #else #if DEBUG Yannyo.Data.DbHelper.QueryDetail = ""; #endif #endif AddMetaInfo(config.Seokeywords, config.Seodescription, config.Seohead); System.Web.HttpContext.Current.Response.BufferOutput = false; System.Web.HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1); System.Web.HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddDays(-1)); System.Web.HttpContext.Current.Response.Expires = 0; System.Web.HttpContext.Current.Response.CacheControl = "no-cache"; System.Web.HttpContext.Current.Response.Cache.SetNoStore(); try { oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout); } catch { System.Threading.Thread.Sleep(2000); oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout); } olid = oluserinfo.olID; if (config.Onlinetimeout > 0 && userid != -1) { onlineusercount = OnlineUsers.GetOnlineAllUserCount(); } else { onlineusercount = OnlineUsers.GetCacheOnlineAllUserCount(); } if (userid != -1) { //更新用户在线时长 OnlineUsers.UpdateOnlineTime(config.Oltimespan, userid); string ignore = HTTPRequest.GetString("ignore"); } templateid = 1; templatepath = Templates.GetTemplateItem(templateid).Directory; nowdate = Utils.GetDate(); nowtime = Utils.GetTime(); nowdatetime = Utils.GetDateTime(); ispost = HTTPRequest.IsPost(); isget = HTTPRequest.IsGet(); link = ""; script = ""; m_starttick = DateTime.Now; ShowPage(); //m_processtime = //(System.Environment.TickCount - m_starttick) / 1000; m_processtime = DateTime.Now.Subtract(m_starttick).TotalMilliseconds / 1000; querycount = Yannyo.Data.DbHelper.QueryCount; Yannyo.Data.DbHelper.QueryCount = 0; #if NET1 #else #if DEBUG querydetail = Yannyo.Data.DbHelper.QueryDetail; Yannyo.Data.DbHelper.QueryDetail = ""; #endif #endif }
protected virtual void Page_Load(object sender, EventArgs e) { if (this.userid > 0) { if (CheckUserPopedoms("X")) { Act = HTTPRequest.GetString("Act"); format = HTTPRequest.GetString("format"); if (Act == "Edit" || Act == "State") { m_ConfigInfoID = Utils.StrToInt(HTTPRequest.GetString("mid"), 0); mc = M_Utils.GetM_ConfigInfoModel(m_ConfigInfoID); } if (ispost) { int StoresID = Utils.StrToInt(HTTPRequest.GetString("StoresID"), 0); string m_Name = Utils.ChkSQL(HTTPRequest.GetString("m_Name")); string m_AppKey = Utils.ChkSQL(HTTPRequest.GetString("m_AppKey")); string m_AppSecret = Utils.ChkSQL(HTTPRequest.GetString("m_AppSecret")); int m_State = Utils.StrToInt(HTTPRequest.GetString("m_State"), 0); if (StoresID > 0) { mc.m_AppKey = m_AppKey; mc.m_AppSecret = m_AppSecret; mc.StoresID = StoresID; mc.m_State = m_State; if (Act == "Add") { if (!M_Utils.ExistsM_ConfigInfo(m_Name)) { mc.m_Name = m_Name; mc.m_AppendTime = DateTime.Now; mc.m_UpdateTime = DateTime.Now; try { if (M_Utils.AddM_ConfigInfo(mc) > 0) { Logs.AddEventLog(this.userid, "新增网店配置." + mc.m_Name); AddMsgLine("添加成功!"); AddScript("window.setTimeout('window.parent.HidBox();',1000);"); } else { AddErrLine("添加失败,请重试!"); AddScript("window.setTimeout('history.back(1);',2000);"); } } catch (Exception ex) { AddErrLine("系统错误:" + ex.Message); } } else { AddErrLine("名称重复!"); AddScript("window.setTimeout('history.back(1);',2000);"); } } if (Act == "Edit") { if (mc.m_Name != m_Name && M_Utils.ExistsM_ConfigInfo(m_Name)) { AddErrLine("名称重复!"); AddScript("window.setTimeout('history.back(1);',2000);"); } else { try { mc.m_Name = m_Name; M_Utils.UpdateM_ConfigInfo(mc); Logs.AddEventLog(this.userid, "修改网店配置." + mc.m_Name); AddMsgLine("修改成功!"); AddScript("window.setTimeout('window.parent.HidBox();',1000);"); } catch (Exception ex) { AddErrLine("系统错误:" + ex.Message); } } } } else { AddErrLine("请选择客户!"); AddScript("window.setTimeout('history.back(1);',2000);"); } Caches.ReSet();//重置缓存 } else { if (Act == "State") { mc.m_State = mc.m_State == 0 ? 1 : 0; try { M_Utils.UpdateM_ConfigInfo(mc); Logs.AddEventLog(this.userid, "修改网店状态." + mc.m_Name); tJson = ",\"idStr\":\"" + m_ConfigInfoID + "\",\"state\":\"" + mc.m_State + "\""; AddMsgLine("修改成功!"); } catch (Exception ex) { AddErrLine("系统错误:" + ex.Message); } } Caches.ReSet();//重置缓存 } } else { AddErrLine("权限不足!"); AddScript("window.parent.HidBox();"); } } else { AddErrLine("请先登录!"); SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer())); SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer())); } if (format == "json") { Response.ClearContent(); Response.Buffer = true; Response.ExpiresAbsolute = System.DateTime.Now.AddYears(-1); Response.Expires = 0; Response.Charset = "utf-8"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8"); Response.ContentType = "application/json"; string Json_Str = "{\"results\": {\"msg\":\"" + this.msgbox_text + "\",\"state\":\"" + (!IsErr()).ToString() + "\"" + tJson + "}}"; Response.Write(Json_Str); Response.End(); } }