示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string active_time   = Request.Form["active_time"];
        string sign          = Request.Form["sign"];
        string bill_month    = Request.Form["bill_month"];
        string last_order_id = Request.Form["last_order_id"];

        #region 检查超时
        string msg = "";
        if (!Cps360Utils.checkActiveTime(long.Parse(active_time), out msg))
        {
            Response.Write(msg);
        }
        #endregion

        #region 检查签名
        if (!Cps360Utils.checkSign(active_time, sign, out msg))
        {
            Response.Write(msg);
        }
        #endregion

        #region 根据账单月获取对账数据
        Cps360Model cpsModel = new Cps360Model();

        List <IDictionary> order_list = cpsModel.getCheckedList(bill_month, last_order_id, Cps360Config.MAX_NUM);

        //xml数据字段
        string[] xml_fields = new string[] {
            "bid",
            "qid",
            "qihoo_id",
            "order_id",
            "order_time",
            "order_updtime",
            "server_price",
            "order_price",
            "coupon",
            "total_price",
            "total_comm",
            "commission",
            "p_info",
            "ext",
            "status"
        };
        string xml = Cps360Utils.getXml(xml_fields, order_list);

        Response.Write(xml);
        #endregion
    }
示例#2
0
    /// <summary>
    /// 检查签名
    /// </summary>
    /// <param name="active_time">请求时间的UNIX时间戳</param>
    /// <param name="sign">POST中的sign</param>
    /// <param name="msg">输出的信息</param>
    /// <returns></returns>
    public static bool checkSign(string active_time, string sign, out string msg)
    {
        string s_sign = String.Join("#", new string[] { Cps360Config.BID, active_time, Cps360Config.CP_KEY });

        s_sign = Cps360Utils.getMd5Hash(s_sign);

        if (String.Compare(s_sign, sign) != 0)
        {
            msg = "签名失败";
            return(false);
        }
        msg = "成功";
        return(true);
    }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string active_time   = Request.Form["active_time"];
        string sign          = Request.Form["sign"];
        string order_ids     = Request.Form["order_ids"]; //以逗号分割多个订单
        string start_time    = Request.Form["start_time"];
        string end_time      = Request.Form["end_time"];
        string last_order_id = Request.Form["last_order_id"];
        string updstart_time = Request.Form["updstart_time"];
        string updend_time   = Request.Form["updend_time"];

        #region 检查超时
        string msg = "";
        if (!Cps360Utils.checkActiveTime(long.Parse(active_time), out msg))
        {
            Response.Write(msg);
        }
        #endregion

        #region 检查签名
        if (!Cps360Utils.checkSign(active_time, sign, out msg))
        {
            Response.Write(msg);
        }
        #endregion

        #region 通过订单号批量查询
        Cps360Model        cpsModel   = new Cps360Model();
        List <IDictionary> order_list = new List <IDictionary>();
        if (!String.IsNullOrEmpty(order_ids))
        {
            string[] orderid_arr = order_ids.Split(new char[] { ',' });
            order_list = cpsModel.getOrdersByIds(orderid_arr, Cps360Config.MAX_NUM);
        }
        else if (!String.IsNullOrEmpty(start_time) && !String.IsNullOrEmpty(end_time))
        {
            DateTime s_time = DateTime.Parse(start_time);
            DateTime e_time = DateTime.Parse(end_time);
            order_list = cpsModel.getOrdersByTime(s_time, e_time, last_order_id, Cps360Config.MAX_NUM);
        }
        else if (!String.IsNullOrEmpty(updstart_time) && !String.IsNullOrEmpty(updend_time))
        {
            DateTime s_time = DateTime.Parse(updstart_time);
            DateTime e_time = DateTime.Parse(updend_time);
            order_list = cpsModel.getOrdersByUpdtime(s_time, e_time, last_order_id, Cps360Config.MAX_NUM);
        }

        //xml数据字段
        string[] xml_fields = new string[] {
            "bid",
            "qid",
            "qihoo_id",
            "order_id",
            "order_time",
            "order_updtime",
            "server_price",
            "order_price",
            "coupon",
            "total_price",
            "total_comm",
            "commission",
            "p_info",
            "ext",
            "status"
        };
        string xml = Cps360Utils.getXml(xml_fields, order_list);

        Response.Write(xml);
        #endregion
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 获取POST数据
        string bid         = Request.Form["bid"];
        string qihoo_id    = Request.Form["qihoo_id"];
        string url         = Request.Form["url"];
        string from_url    = Request.Form["from_url"];
        string active_time = Request.Form["active_time"];   //请求时间的时间戳
        string ext         = Request.Form["ext"];
        string qid         = Request.Form["qid"];
        string qmail       = Request.Form["qmail"];
        string qname       = Request.Form["qname"];
        string sign        = Request.Form["sign"];
        #endregion

        #region 设置cookie信息
        HttpCookie cookie = new HttpCookie("cpsinfo");
        cookie.Values.Add("id", "360cps");
        cookie.Values.Add("qihoo_id", qihoo_id);
        cookie.Values.Add("ext", ext);
        cookie.Values.Add("qid", qid);
        cookie.Values.Add("qmail", qmail);
        cookie.Values.Add("qname", qname);
        cookie.Expires = DateTime.Now.AddDays(Cps360Config.COOKIE_RD);
        cookie.Domain  = Cps360Config.COOKIE_DOMAIN;
        cookie.Path    = "/";
        Response.Cookies.Add(cookie);
        #endregion

        #region 构造签名
        string sign_check = String.Join("#", new string[] { bid, active_time, Cps360Config.CP_KEY, qid, qmail, qname });
        sign_check = Cps360Utils.getMd5Hash(sign_check);
        #endregion


        long   currentTime = Cps360Utils.getCurrentTimestamp();
        string msg         = "";
        //检查超时时间和签名,如果失败,向360发送一个错误通知
        if (!Cps360Utils.checkActiveTime(long.Parse(active_time), out msg) || sign_check != sign)
        {
            string from_ip = Page.Request.UserHostAddress;

            ASCIIEncoding encoding = new ASCIIEncoding();

            string t_sign   = Cps360Utils.getMd5Hash(String.Join("#", new string[] { Cps360Config.BID, currentTime.ToString(), Cps360Config.CP_KEY }));
            string postData = String.Join("&", new string[] { "bid=" + Cps360Config.BID,
                                                              "active_time=" + currentTime,
                                                              "sign=" + t_sign,
                                                              "pre_bid=" + bid,
                                                              "pre_active_time=" + active_time,
                                                              "pre_sign=" + sign,
                                                              "qid=" + qid,
                                                              "qname=" + qname,
                                                              "qmail=" + qmail,
                                                              "from_url=" + from_url,
                                                              "from_ip=" + from_ip });

            byte[] data = encoding.GetBytes(postData);

            Cps360Utils.postRequest(Cps360Config.FAILED_URL, data);
        }
        else
        {
            if (!String.IsNullOrEmpty(qid))
            {
                //实现自动登录
                Cps360Model cpsModel = new Cps360Model();
                cpsModel.autoLogin(qid, qname, qmail);
            }
        }

        #region 完成跳转
        if (String.IsNullOrEmpty(url))
        {
            url = Cps360Config.DEFAULT_GO_URL;
        }
        Response.Redirect(url);
        #endregion
    }