Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         try
         {
             companyID       = Request.QueryString["companyID"].ToString();
             money           = Request.QueryString["money"].ToString();
             productID       = Request.QueryString["productID"].ToString();
             mechineID       = Request.QueryString["mechineID"].ToString();
             dgOrderDetailID = Request.QueryString["dgOrderDetailID"].ToString();
             type            = Request.QueryString["type"].ToString();
             // money = "1";
             Util.Debuglog("companyID=" + companyID + ";money=" + money + ";productID=" + productID + ";mechineID=" + mechineID + ";dgOrderDetailID=" + dgOrderDetailID + ";type=" + type, "_聚合支付支付宝.txt");
             SybWxPayService             sybService = new SybWxPayService(companyID);
             string                      url        = "https://wx.bingoseller.com/pay/JHNotify.aspx";
             string                      data       = "";
             string                      sql        = "select *from asm_product where productID=" + productID;
             DataTable                   dt         = DbHelperSQL.Query(sql).Tables[0];
             Dictionary <String, String> rsp        = sybService.pay(long.Parse((double.Parse(money) * 100).ToString()), DateTime.Now.ToFileTime().ToString(), "A01", dt.Rows[0]["proName"].ToString(), "商品消费", "", "", url, "");
             data = OperUtil.SerializeDictionaryToJsonString(rsp);
             string json = (new JavaScriptSerializer()).Serialize(rsp);
             Util.Debuglog("json=" + json, "_聚合支付支付宝.txt");
             JObject jo = (JObject)JsonConvert.DeserializeObject(json);
             if (jo["retcode"].ToString() == "SUCCESS")
             {
                 string appid      = jo["appid"].ToString();
                 string cusid      = jo["cusid"].ToString();
                 string trxid      = jo["trxid"].ToString();
                 string reqsn      = jo["reqsn"].ToString();
                 string payinfoUrl = jo["payinfo"].ToString();
                 Util.Debuglog("payinfoUrl=" + payinfoUrl, "_聚合支付支付宝.txt");
                 string insertSQL = @"insert into asm_pay_info(appid,cusid,trxid,statu,reqsn,type,payType,trxamt,createTime,mechineID,productID,companyID,dgOrderDetailID,orderType)
                                     values('" + appid + "','" + cusid + "','" + trxid + "','0','" + reqsn + "',2,2," + double.Parse(money) * 100 + ",'" + DateTime.Now + "','" + mechineID + "','" + productID + "','" + companyID + "','" + dgOrderDetailID + "','" + type + "')";
                 Util.Debuglog("insertSQL=" + insertSQL, "_聚合支付支付宝.txt");
                 DbHelperSQL.ExecuteSql(insertSQL);
                 Response.Write("<script>window.location.href='" + payinfoUrl + "';</script>");
                 // //插入预订单信息
             }
         }
         catch (Exception ex)
         {
             Util.Debuglog("Exception=" + ex.Message, "_聚合支付支付宝.txt");
         }
     }
 }
Пример #2
0
        public static Object ok(string billno, string pwd, string companyID)
        {
            //首先验证二级退款密码是否正确
            string    sql12 = "select * from asm_company where id=" + companyID;
            DataTable dd1   = DbHelperSQL.Query(sql12).Tables[0];

            if (dd1.Rows.Count > 0)
            {
                if (pwd == dd1.Rows[0]["pwd2"].ToString())
                {
                    //查询该笔订单信息
                    string    sql1 = "select * from asm_pay_info where trxid='" + billno + "'";
                    DataTable dt1  = DbHelperSQL.Query(sql1).Tables[0];
                    if (dt1.Rows.Count > 0)
                    {
                        //查询订单信息
                        string    sqlOrder = "select * from  asm_sellDetail where billno='" + billno + "'";
                        DataTable Dorder   = DbHelperSQL.Query(sqlOrder).Tables[0];
                        if (Dorder.Rows.Count <= 0)
                        {
                            return(new { result = 0, msg = "该笔订单查询失败" });
                        }
                        //判断出货状态如果是料道错误或者是交易序列号相同给退款 零售的怎么来怎么退 订购的退到钱包
                        if (!string.IsNullOrEmpty(Dorder.Rows[0]["code"].ToString()))
                        {
                            //订购的
                            if (Dorder.Rows[0]["bz"].ToString() == "料道错误" || Dorder.Rows[0]["bz"].ToString() == "交易序列号相同" || Dorder.Rows[0]["bz"].ToString() == "料道故障" || Dorder.Rows[0]["bz"].ToString() == "校验错误" || Dorder.Rows[0]["bz"].ToString() == "出货失败")
                            {
                                string    sql = "select * from asm_sellDetail where billno='" + billno + "'";
                                DataTable dd  = DbHelperSQL.Query(sql).Tables[0];
                                if (dd.Rows.Count > 0)
                                {
                                    //更新会员钱包 并插入资金变动记录
                                    string    update = "update asm_member set  AvailableMoney=AvailableMoney+" + dd.Rows[0]["totalMoney"].ToString() + " where id=" + dd.Rows[0]["memberID"].ToString();
                                    int       a      = DbHelperSQL.ExecuteSql(update);
                                    string    sqlm   = "select * from asm_member where id=" + dd.Rows[0]["memberID"].ToString();
                                    DataTable dt     = DbHelperSQL.Query(sqlm).Tables[0];
                                    if (a > 0)
                                    {
                                        string sqlu = "update asm_sellDetail set bz='退款成功' where billno='" + billno + "'";
                                        DbHelperSQL.ExecuteSql(sqlu);
                                        Util.insertNotice(dt.Rows[0]["id"].ToString(), "出货异常退款", "您于" + Dorder.Rows[0]["orderTime"].ToString() + "取货异常退还金额:" + dd.Rows[0]["totalMoney"].ToString() + ";请查收钱包");
                                        Util.moneyChange(dt.Rows[0]["id"].ToString(), dd.Rows[0]["totalMoney"].ToString(), dt.Rows[0]["AvailableMoney"].ToString(), "退款通知", "7", "", "取货异常退还金额:" + dd.Rows[0]["totalMoney"].ToString());
                                        return(new { result = 0, msg = "退款成功,成功到会员钱包中" });
                                    }
                                }
                            }
                        }
                        else
                        {
                            //零售的
                            if (Dorder.Rows[0]["bz"].ToString() == "料道错误" || Dorder.Rows[0]["bz"].ToString() == "交易序列号相同" || Dorder.Rows[0]["bz"].ToString() == "料道故障" || Dorder.Rows[0]["bz"].ToString() == "校验错误" || Dorder.Rows[0]["bz"].ToString() == "出货失败")
                            {
                                if (Dorder.Rows[0]["payType"].ToString() == "3")
                                {
                                    //退到钱包
                                    string    sql = "select * from asm_sellDetail where billno='" + billno + "'";
                                    DataTable dd  = DbHelperSQL.Query(sql).Tables[0];
                                    if (dd.Rows.Count > 0)
                                    {
                                        //更新会员钱包 并插入资金变动记录
                                        string    update = "update asm_member set  AvailableMoney=AvailableMoney+" + dd.Rows[0]["totalMoney"].ToString() + " where id=" + dd.Rows[0]["memberID"].ToString();
                                        int       a      = DbHelperSQL.ExecuteSql(update);
                                        string    sqlm   = "select * from asm_member where id=" + dd.Rows[0]["memberID"].ToString();
                                        DataTable dt     = DbHelperSQL.Query(sqlm).Tables[0];
                                        if (a > 0)
                                        {
                                            string update1 = "update asm_pay_info set statu=2,fintime='" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' where trxid='" + billno + "'";
                                            DbHelperSQL.ExecuteSql(update1);
                                            string sqlu = "update asm_sellDetail set bz='退款成功' where billno='" + billno + "'";
                                            DbHelperSQL.ExecuteSql(sqlu);
                                            Util.insertNotice(dt.Rows[0]["id"].ToString(), "出货异常退款", "您于" + Dorder.Rows[0]["orderTime"].ToString() + "购买商品出货异常退还金额:" + dd.Rows[0]["totalMoney"].ToString() + ";请查收钱包");
                                            Util.moneyChange(dt.Rows[0]["id"].ToString(), dd.Rows[0]["totalMoney"].ToString(), dt.Rows[0]["AvailableMoney"].ToString(), "退款通知", "7", "", "取货异常退还金额:" + dd.Rows[0]["totalMoney"].ToString());
                                            return(new { result = 0, msg = "退款成功,成功到会员钱包中" });
                                        }
                                    }
                                }
                                else if (Dorder.Rows[0]["payType"].ToString() == "1" || Dorder.Rows[0]["payType"].ToString() == "2")
                                {
                                    //退到1微信或者2支付宝
                                    string    sql = "select * from asm_pay_info where trxid='" + billno + "'";
                                    DataTable dd  = DbHelperSQL.Query(sql).Tables[0];
                                    if (dd.Rows.Count > 0 && dd.Rows[0]["statu"].ToString() == "1")
                                    {
                                        SybWxPayService             sybService = new SybWxPayService(Dorder.Rows[0]["mechineID"].ToString());
                                        long                        fen        = long.Parse(dd.Rows[0]["trxamt"].ToString());
                                        Random                      rd         = new Random();
                                        int                         rand       = rd.Next(10000, 99999);
                                        string                      reqsn      = ConvertDateTimeToInt(DateTime.Now).ToString() + rand;
                                        string                      oldtrxid   = dd.Rows[0]["trxid"].ToString();
                                        string                      oldreqsn   = dd.Rows[0]["reqsn"].ToString();
                                        Dictionary <String, String> rsp        = sybService.cancel(fen, reqsn, oldtrxid, oldreqsn);
                                        string                      data       = OperUtil.SerializeDictionaryToJsonString(rsp);
                                        Util.Debuglog("微信支付链接data=" + data, "_退款.txt");
                                        //插入预处理订单信息
                                        string json = (new JavaScriptSerializer()).Serialize(rsp);
                                        Util.Debuglog("微信支付链接json=" + json, "_退款.txt");
                                        JObject jo = (JObject)JsonConvert.DeserializeObject(json);
                                        if (jo["retcode"].ToString() == "SUCCESS")
                                        {
                                            string cusid     = jo["cusid"].ToString();     //商户号
                                            string trxid     = jo["trxid"].ToString();     //交易单号
                                            string fintime   = jo["fintime"].ToString();   //交易完成时间
                                            string reqsn1    = jo["reqsn"].ToString();     //商户订单号
                                            string trxstatus = jo["trxstatus"].ToString(); //交易状态
                                            //更新asm_pay_info
                                            if (trxstatus == "0000")
                                            {
                                                string update = "update asm_pay_info set statu=2,tkreqsn='" + reqsn1 + "',fintime='" + fintime + "',trxstatus='" + trxstatus + "',errmsg='' where trxid='" + oldtrxid + "'";
                                                DbHelperSQL.ExecuteSql(update);
                                                string sqlu = "update asm_sellDetail set bz='退款成功' where billno='" + billno + "'";
                                                DbHelperSQL.ExecuteSql(sqlu);
                                                return(new { result = 0, msg = "退款成功,已经退到会员的微信或支付宝" });
                                            }
                                            else
                                            {
                                                string errmsg = jo["errmsg"].ToString();//交易失败信息
                                                string update = "update asm_pay_info set tkreqsn='" + reqsn1 + "',fintime='" + fintime + "',trxstatus='" + trxstatus + "',errmsg='" + errmsg + "' where trxid='" + oldtrxid + "'";
                                                DbHelperSQL.ExecuteSql(update);
                                                if (trxstatus == "3008")
                                                {
                                                    return(new { result = 0, msg = errmsg });
                                                }
                                                else
                                                {
                                                    return(new { result = 0, msg = "退款失败" });
                                                }
                                            }
                                        }
                                        else
                                        {
                                            return(new { result = 0, msg = "退款失败" });
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        return(new { result = 0, msg = "该笔订单查询失败" });
                    }
                }
                else
                {
                    return(new { result = 0, msg = "退款密码错误" });//密码错误
                }
            }
            return(new { result = 0, msg = "退款失败" });
        }
Пример #3
0
        public static async System.Threading.Tasks.Task paycall(Dictionary <String, String> reqParams)
        {
            string  json = (new JavaScriptSerializer()).Serialize(reqParams);
            JObject jo   = (JObject)JsonConvert.DeserializeObject(json);

            string sql = "select * from asm_pay_info where statu=0 and trxid='" + jo["trxid"].ToString() + "'";

            Util.Debuglog("sql=" + sql, "出货信息.txt");
            DataTable dt = DbHelperSQL.Query(sql).Tables[0];

            if (dt.Rows.Count > 0)
            {
                string pickupdate = "update  asm_product_pick set payStatus=3,payTime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where reqsnNo='" + dt.Rows[0]["reqsn"].ToString() + "' ";
                Util.Debuglog("sqlInsert=" + pickupdate, "获取预生成订单号.txt");
                DbHelperSQL.ExecuteSql(pickupdate);

                //获取appid查询这个appid的 的appkey
                string sql2 = "select * from asm_company where tl_APPID='" + dt.Rows[0]["appid"].ToString() + "'";
                Util.Debuglog("sql2=" + sql2, "出货信息.txt");
                DataTable d2 = DbHelperSQL.Query(sql2).Tables[0];
                //AppUtil.validSign(reqParams, d2.Rows[0]["tl_APPKEY"].ToString(), d2.Rows[0]["id"].ToString())
                if (dt.Rows[0]["statu"].ToString() == "0")//验签成功
                {
                    string trxidInfo = RedisHelper.GetRedisModel <string>(jo["trxid"].ToString());
                    if (string.IsNullOrEmpty(trxidInfo))
                    {
                        //退到1微信或者2支付宝

                        SybWxPayService             sybService = new SybWxPayService(dt.Rows[0]["mechineID"].ToString());
                        long                        fen        = long.Parse(dt.Rows[0]["trxamt"].ToString());
                        Random                      rd         = new Random();
                        int                         rand       = rd.Next(10000, 99999);
                        string                      reqsn      = Util.ConvertDateTimeToInt(DateTime.Now).ToString() + rand;
                        string                      oldtrxid   = dt.Rows[0]["trxid"].ToString();
                        string                      oldreqsn   = dt.Rows[0]["reqsn"].ToString();
                        Dictionary <String, String> rsp        = sybService.cancel(fen, reqsn, oldtrxid, oldreqsn);
                        string                      data       = OperUtil.SerializeDictionaryToJsonString(rsp);

                        Util.Debuglog("微信支付链接data=" + data, "_退款.txt");
                        //插入预处理订单信息
                        string  returnJson = (new JavaScriptSerializer()).Serialize(rsp);
                        JObject returnjo   = (JObject)JsonConvert.DeserializeObject(returnJson);
                        if (returnjo["retcode"].ToString() == "SUCCESS")
                        {
                            string cusid     = returnjo["cusid"].ToString();     //商户号
                            string trxid     = returnjo["trxid"].ToString();     //交易单号
                            string fintime   = returnjo["fintime"].ToString();   //交易完成时间
                            string reqsn1    = returnjo["reqsn"].ToString();     //商户订单号
                            string trxstatus = returnjo["trxstatus"].ToString(); //交易状态
                            if (trxstatus == "0000")
                            {
                                //更新asm_pay_info
                                string update = "update asm_pay_info set statu=2,tkreqsn='" + reqsn1 + "',fintime='" + fintime + "',trxstatus='" + trxstatus + "' where trxid='" + oldtrxid + "'";
                                DbHelperSQL.ExecuteSql(update);

                                string    sqlm   = "select * from asm_member where openID='" + dt.Rows[0]["acct"].ToString() + "'";
                                DataTable sqlmdt = DbHelperSQL.Query(sqlm).Tables[0];
                                if (sqlmdt.Rows.Count > 0)
                                {
                                    Util.insertNotice(sqlmdt.Rows[0]["id"].ToString(), "出货异常退款", "您于" + dt.Rows[0]["createTime"].ToString() + "购买商品出货异常退还金额:" + double.Parse(dt.Rows[0]["trxamt"].ToString()) / 100 + ";请查收微信或支付宝", dt.Rows[0]["mechineID"].ToString());
                                    Util.moneyChange(sqlmdt.Rows[0]["id"].ToString(), (double.Parse(fen.ToString()) / 100).ToString("0.00"), sqlmdt.Rows[0]["AvailableMoney"].ToString(), "退款通知", "7", "");

                                    try
                                    {
                                        string   company = Util.getCompany(sqlmdt.Rows[0]["companyID"].ToString());
                                        wxHelper wx      = new wxHelper(sqlmdt.Rows[0]["companyID"].ToString());
                                        data = TemplateMessage.tk(sqlmdt.Rows[0]["openID"].ToString(), OperUtil.getMessageID(sqlmdt.Rows[0]["companyID"].ToString(), "OPENTM410089600"), "退款通知", (double.Parse(dt.Rows[0]["trxamt"].ToString()) / 100).ToString("f2"), "您购买的商品没有出货成功,钱已退还到账户");
                                        TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(sqlmdt.Rows[0]["companyID"].ToString()), data);
                                    }
                                    catch (Exception e)
                                    {
                                        Util.Debuglog("e=" + e.Message, "会员等级消息模板.txt");
                                    }
                                }
                            }
                            else
                            {
                                string errmsg = jo["errmsg"].ToString();//交易失败信息
                                string update = "update asm_pay_info set tkreqsn='" + reqsn1 + "',fintime='" + fintime + "',trxstatus='" + trxstatus + "',errmsg='" + errmsg + "' where trxid='" + oldtrxid + "'";
                                DbHelperSQL.ExecuteSql(update);
                            }
                        }

                        return;
                    }
                    //验签成功后,进行业务处理,处理完毕返回成功
                    string trxdate   = jo["trxdate"].ToString();
                    string paytime   = jo["paytime"].ToString();
                    string acct      = jo["acct"].ToString();
                    string chnltrxid = jo["chnltrxid"].ToString();
                    double trxamtY   = double.Parse(jo["trxamt"].ToString()) / 100;

                    //发送出货指令
                    string ldno = "";
                    //继续查找
                    bool b   = true;
                    int  num = 3;
                    while (b && num > 0)
                    {
                        num--;
                        ldno = Util.getLDNO(dt.Rows[0]["mechineID"].ToString(), dt.Rows[0]["productID"].ToString());
                        if (!string.IsNullOrEmpty(ldno))
                        {
                            b = false;
                        }
                        else
                        {
                            Thread.Sleep(1000);
                        }
                    }
                    Util.Debuglog("mechineID=" + dt.Rows[0]["mechineID"].ToString() + ";productID=" + dt.Rows[0]["productID"].ToString() + ";LDNO=" + ldno, "出货信息.txt");
                    if (!string.IsNullOrEmpty(ldno))
                    {
                        Util.chNew(ldno, dt.Rows[0]["mechineID"].ToString(), jo["trxid"].ToString(), dt.Rows[0]["payType"].ToString(), dt.Rows[0]["productID"].ToString(), trxamtY.ToString());
                    }

                    Util.Debuglog("出货指令发送完成mechineID=" + dt.Rows[0]["mechineID"].ToString() + ";productID=" + dt.Rows[0]["productID"].ToString() + ";LDNO=" + ldno, "出货信息.txt");

                    //支付成功向asm_pay 表 更新记录
                    if (dt.Rows[0]["payType"].ToString() == "2")
                    {
                        string updateSQL = "update asm_pay_info set chLdNo='" + ldno + "', acct='" + acct + "', paytime='" + paytime + "',statu='1',trxdate='" + trxdate + "',chnltrxid='" + chnltrxid + "' where trxid='" + jo["trxid"].ToString() + "'";
                        Util.Debuglog("updateSQL=" + updateSQL, "出货信息.txt");
                        DbHelperSQL.ExecuteSql(updateSQL);
                    }
                    else
                    {
                        string updateSQL = "update asm_pay_info set chLdNo='" + ldno + "', paytime='" + paytime + "',statu='1',trxdate='" + trxdate + "',chnltrxid='" + chnltrxid + "' where trxid='" + jo["trxid"].ToString() + "'";
                        Util.Debuglog("updateSQL=" + updateSQL, "出货信息.txt");
                        DbHelperSQL.ExecuteSql(updateSQL);
                    }

                    //需要更新会员的消费信息  此处如果是支付宝扫码的话没法更新
                    if (!string.IsNullOrEmpty(dt.Rows[0]["unionID"].ToString()))
                    {
                        string update = "update asm_member set sumConsume=sumConsume+" + trxamtY + ",consumeCount=consumeCount+1,LastTime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',point=point+" + trxamtY + ",mechineID='" + dt.Rows[0]["mechineID"].ToString() + "' where unionID='" + dt.Rows[0]["unionID"].ToString() + "'";
                        Util.Debuglog("update=" + update, "更新会员余额消费信息.txt");
                        DbHelperSQL.ExecuteSql(update);
                    }

                    string    sqlM = "select * from asm_member where unionID='" + dt.Rows[0]["unionID"].ToString() + "'";
                    DataTable dtM  = DbHelperSQL.Query(sqlM).Tables[0];

                    string    searchSql   = "select 1 from asm_firstPayRecord where mechineID=" + dt.Rows[0]["mechineID"].ToString() + " AND memberID='" + dtM.Rows[0]["id"].ToString() + "'";
                    DataTable searchSqldt = DbHelperSQL.Query(searchSql).Tables[0];
                    if (searchSqldt.Rows.Count > 0)
                    {
                    }
                    else
                    {
                        string insertsql = "insert into   asm_firstPayRecord(mechineID,memberID,firstinfo,firstbuyTime,type) values (" + dt.Rows[0]["mechineID"].ToString() + "," + dtM.Rows[0]["id"].ToString() + ",'" + jo["trxid"].ToString() + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "','" + 2 + "') ";
                        Util.Debuglog("sqlInsert=" + insertsql, "获取预生成订单号.txt");
                        DbHelperSQL.ExecuteSql(insertsql);
                    }
                    //此处判断如果orderType=3是半价的需要根据dgOrderDetailID修改zt为售卖完成 并且给出售人加余额
                    if (dt.Rows[0]["orderType"].ToString() == "3" && dt.Rows[0]["dgOrderDetailID"].ToString() != "0" && !string.IsNullOrEmpty(dt.Rows[0]["dgOrderDetailID"].ToString()))
                    {
                        string    sqlDetail = "select * from asm_orderlistDetail where id=" + dt.Rows[0]["dgOrderDetailID"].ToString();
                        DataTable dtDetail  = DbHelperSQL.Query(sqlDetail).Tables[0];
                        if (dtDetail.Rows.Count > 0)
                        {
                            string id        = dt.Rows[0]["dgOrderDetailID"].ToString();
                            string memberID  = dtDetail.Rows[0]["memberID"].ToString();
                            string productID = dt.Rows[0]["productID"].ToString();
                            string updateSql = "update asm_orderlistDetail set zt=6 where id=" + id;
                            int    a         = DbHelperSQL.ExecuteSql(updateSql);
                            if (a > 0)
                            {
                                RedisHelper.Remove(dt.Rows[0]["mechineID"].ToString() + "_SellOrderInfo");
                                //更新余额
                                string    sqlPro       = "select * from asm_product where productID=" + productID;
                                DataTable dpro         = DbHelperSQL.Query(sqlPro).Tables[0];
                                string    updateMember = "update asm_member set AvailableMoney=AvailableMoney+" + dtDetail.Rows[0]["sellPrice"].ToString() + " where id=" + memberID;
                                DbHelperSQL.ExecuteSql(updateMember);
                                Util.chgMoney(memberID, dtDetail.Rows[0]["sellPrice"].ToString(), "售卖", "出售" + dtDetail.Rows[0]["createTime"].ToString() + "日产品", "5");
                            }
                        }
                    }
                    //给会员升级
                    Util.growUpMember(dt.Rows[0]["unionID"].ToString(), "");
                    if (dtM.Rows.Count > 0)
                    {
                        if (!string.IsNullOrEmpty(dtM.Rows[0]["openID"].ToString()))
                        {
                            string    companyID  = dtM.Rows[0]["companyID"].ToString();
                            string    openID     = dtM.Rows[0]["openID"].ToString();
                            string    sqlp       = "select * from asm_product where productID=" + dt.Rows[0]["productID"].ToString();
                            DataTable dp         = DbHelperSQL.Query(sqlp).Tables[0];
                            string    sqlMechine = "select * from asm_mechine where id=" + dt.Rows[0]["mechineID"].ToString();
                            DataTable dMechine   = DbHelperSQL.Query(sqlMechine).Tables[0];
                            wxHelper  wx         = new wxHelper(companyID);
                            string    data       = TemplateMessage.comsume(openID, OperUtil.getMessageID(companyID, "OPENTM401313503"), "亲,你的购买的商品信息如下",
                                                                           "" + dp.Rows[0]["proName"].ToString() + "", trxamtY.ToString(), jo["trxid"].ToString(), dMechine.Rows[0]["mechineName"].ToString(), "“机器已出货,请尽快推开机器左下方推板取出奶品,超过1分钟未取视为丢弃奶品,推板将关闭");
                            TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(companyID), data);
                        }
                    }
                }
            }

            Util.Debuglog("keyif=回调结束", "_聚合支付回调参数.txt");
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    reqsn = Request.QueryString["reqsn"].ToString();

                    string    asm_pay_infosql = "select 1 from asm_pay_info  where reqsn='" + reqsn + "' ";
                    DataTable asm_pay_infodt  = DbHelperSQL.Query(asm_pay_infosql).Tables[0];
                    if (asm_pay_infodt.Rows.Count > 0)
                    {
                        return;
                    }
                    string    asm_product_picksql = "select * from asm_product_pick  where reqsnNo='" + reqsn + "' ";
                    DataTable asm_product_pickdt  = DbHelperSQL.Query(asm_product_picksql).Tables[0];
                    if (asm_product_pickdt.Rows.Count > 0)
                    {
                        companyID       = asm_product_pickdt.Rows[0]["companyID"].ToString();
                        productID       = asm_product_pickdt.Rows[0]["productID"].ToString();
                        mechineID       = asm_product_pickdt.Rows[0]["mechineID"].ToString();
                        dgOrderDetailID = asm_product_pickdt.Rows[0]["dgOrderDetailID"].ToString();
                        type            = asm_product_pickdt.Rows[0]["type"].ToString();
                        //转售金额固定
                    }

                    // money = "1";
                    Util.Debuglog("companyID=" + companyID + ";money=" + money + ";productID=" + productID + ";mechineID=" + mechineID + ";dgOrderDetailID=" + dgOrderDetailID + ";type=" + type, "_聚合支付支付宝.txt");
                    SybWxPayService sybService = new SybWxPayService(companyID);
                    string          url        = "https://wx.bingoseller.com/pay/JHNotifyNew.aspx";
                    string          data       = "";
                    string          sql        = "select *from asm_product where productID=" + productID;
                    DataTable       dt         = DbHelperSQL.Query(sql).Tables[0];

                    if (dgOrderDetailID != "0" && !string.IsNullOrEmpty(dgOrderDetailID))
                    {
                        string    sqlDetail = "select * from asm_orderlistDetail where id=" + dgOrderDetailID;
                        DataTable dtDetail  = DbHelperSQL.Query(sqlDetail).Tables[0];
                        if (dtDetail.Rows.Count > 0)
                        {
                            money = dtDetail.Rows[0]["sellPrice"].ToString();
                        }
                    }
                    else
                    {
                        money = Util.getNewProductPrice(productID, mechineID, "0");
                    }
                    Dictionary <String, String> rsp = sybService.pay(long.Parse((double.Parse(money) * 100).ToString()), reqsn, "A01", dt.Rows[0]["proName"].ToString(), "商品消费", "", "", url, "");
                    data = OperUtil.SerializeDictionaryToJsonString(rsp);
                    string json = (new JavaScriptSerializer()).Serialize(rsp);
                    Util.Debuglog("json=" + json, "_聚合支付支付宝.txt");
                    JObject jo = (JObject)JsonConvert.DeserializeObject(json);
                    if (jo["retcode"].ToString() == "SUCCESS")
                    {
                        string pickupdate = "update  asm_product_pick set payStatus=2,sacntype='2',paytype='2',startPayTime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where reqsnNo='" + reqsn + "' ";
                        Util.Debuglog("sqlInsert=" + pickupdate, "获取预生成订单号.txt");
                        DbHelperSQL.ExecuteSql(pickupdate);
                        string appid = jo["appid"].ToString();
                        string cusid = jo["cusid"].ToString();
                        string trxid = jo["trxid"].ToString();
                        RedisHelper.SetRedisModel <string>(trxid, trxid, new TimeSpan(0, 2, 0));
                        string reqsnNew   = jo["reqsn"].ToString();
                        string payinfoUrl = jo["payinfo"].ToString();
                        Util.Debuglog("payinfoUrl=" + payinfoUrl, "_聚合支付支付宝.txt");
                        string insertSQL = @"insert into asm_pay_info(appid,cusid,trxid,statu,reqsn,type,payType,trxamt,createTime,mechineID,productID,companyID,dgOrderDetailID,orderType)
                                            values('" + appid + "','" + cusid + "','" + trxid + "','0','" + reqsnNew + "',2,2," + double.Parse(money) * 100 + ",'" + DateTime.Now + "','" + mechineID + "','" + productID + "','" + companyID + "','" + dgOrderDetailID + "','" + type + "')";
                        Util.Debuglog("insertSQL=" + insertSQL, "_聚合支付支付宝.txt");
                        DbHelperSQL.ExecuteSql(insertSQL);
                        Response.Write("<script>window.location.href='" + payinfoUrl + "';</script>");
                        // //插入预订单信息
                    }
                }
                catch (Exception ex)
                {
                    Util.Debuglog("Exception=" + ex.Message, "_聚合支付支付宝.txt");
                }
            }
        }