Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string code      = "";
                string companyID = "";
                if (Request.QueryString["code"] != null && Request.QueryString["code"] != "")
                {
                    code = Request.QueryString["code"].ToString();

                    string str = Request.QueryString["req"].ToString();
                    string req = PwdHelper.DecodeDES(str, "bingoseller");

                    companyID = req.Split('&')[2].Split('=')[1];
                    string    sql2 = "select * from asm_company where id=" + companyID;
                    DataTable d1   = DbHelperSQL.Query(sql2).Tables[0];

                    if (d1.Rows.Count > 0)
                    {
                        appid     = d1.Rows[0]["appId"].ToString();
                        appsecret = d1.Rows[0]["wx_appsecret"].ToString();
                    }

                    OAuth_Token Model           = Get_token(code, companyID);
                    OAuthUser   OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid);
                    if (OAuthUser_Model.openid != null && OAuthUser_Model.openid != "") //已获取得openid及其他信息
                    {
                        tupian = OAuthUser_Model.headimgurl.ToString();                 //头像图片
                        name   = OAuthUser_Model.nickname;                              //昵称
                        id     = OAuthUser_Model.openid;                                //opendid
                        string unionID  = OAuthUser_Model.unionid;
                        string country  = OAuthUser_Model.country;
                        string province = OAuthUser_Model.province;
                        string city     = OAuthUser_Model.city;
                        OperUtil.setCooki("vshop_openID", id);

                        string    sql = "select * from asm_member where openID='" + id + "' and companyID=" + companyID;
                        DataTable dt  = DbHelperSQL.Query(sql).Tables[0];
                        if (dt.Rows.Count <= 0)
                        {
                            //添加会员 会员不一定必须绑定机器  只有会员有订购产品的时候才必须绑定机器
                            string sql1 = "INSERT INTO [dbo].[asm_member]"
                                          + " ([name],[phone],[QQ],[province],[city],[country],[addres],[AvailableMoney],[sumConsume],[sumRecharge],[createDate],[mechineID],[companyID],[age],[LastTime],[memberBH],[consumeCount],[openID],[brithday],[headurl],[nickname],unionID)"
                                          + " VALUES('" + name + "','','','" + province + "','" + city + "','','',0,0,0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','','" + companyID + "','0','','',0,'" + id + "','','" + tupian + "','" + name + "','" + unionID + "')";
                            DbHelperSQL.ExecuteSql(sql1);
                            wxHelper wx   = new wxHelper(companyID);
                            string   data = TemplateMessage.Member_ZC(id, OperUtil.getMessageID(companyID, "OPENTM203347141"), "恭喜您注册成为会员!", name, "恭喜您注册成为会员,您将享受到会员所有权利!");
                            TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(companyID), data);
                        }
                        else
                        {
                            string update = "update asm_member set unionID='" + unionID + "',name='" + name + "',nickname='" + name + "',headurl='" + tupian + "' where openID='" + id + "'";
                            Util.Debuglog("Update=" + update, "更新会员信息.txt");
                        }

                        Response.Redirect("paypage.aspx?req=" + str);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static string yzPwd(string openID, string pwd, string money, string trxid, string companyID)
        {
            Util.Debuglog("openID=" + openID + ";pwd=" + pwd + ";money=" + money + ";trxid=" + trxid + ";companyID=" + companyID, "_余额支付.txt");
            //验证密码是否正确
            string    sql = "select * from asm_member where openID='" + openID + "' and pwd='" + pwd + "'";
            DataTable dd  = DbHelperSQL.Query(sql).Tables[0];

            if (dd.Rows.Count <= 0)
            {
                return("1");//支付密码不正确
            }
            //判断该订单支付状态
            string    sql1 = "select * from asm_pay_info where trxid='" + trxid + "'";
            DataTable d1   = DbHelperSQL.Query(sql1).Tables[0];

            if (d1.Rows.Count > 0 && d1.Rows[0]["statu"].ToString() == "1")
            {
                return("4");//已经支付完成无需重复支付
            }
            //判断余额
            if (double.Parse(dd.Rows[0]["AvailableMoney"].ToString()) < double.Parse(money))
            {
                return("2");//余额不足
            }
            //更新余额
            string update = "update asm_member set AvailableMoney=AvailableMoney-" + money + ",sumConsume=sumConsume+" + money + ",LastTime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where openID='" + openID + "'";

            DbHelperSQL.ExecuteSql(update);
            string    sqlM    = "select addres from asm_mechine where id in(select mechineID from asm_member where openID='" + openID + "')";
            DataTable dM      = DbHelperSQL.Query(sqlM).Tables[0];
            string    address = "";

            if (dM.Rows.Count > 0)
            {
                address = dM.Rows[0]["addres"].ToString();
            }
            //发送消息模板
            wxHelper wx   = new wxHelper(companyID);
            string   data = TemplateMessage.money_bd(openID, OperUtil.getMessageID(companyID, "OPENTM403148135"), "余额变动提醒", "购买产品", money, (double.Parse(dd.Rows[0]["AvailableMoney"].ToString()) - double.Parse(money)).ToString(), address, "支付时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(companyID), data);
            //插入记录
            Util.insertNotice(dd.Rows[0]["id"].ToString(), "余额变动提醒", "您于" + DateTime.Now.ToString("yyyy/MM/dd HH:mm") + "购物消费:" + money + "元;余额:" + (double.Parse(dd.Rows[0]["AvailableMoney"].ToString()) - double.Parse(money)), "");
            Util.moneyChange(dd.Rows[0]["id"].ToString(), money, (double.Parse(dd.Rows[0]["AvailableMoney"].ToString()) - double.Parse(money)).ToString(), "会员消费", "2", "");
            //接着更新订单的状态
            string update1 = "update asm_pay_info set statu=1,paytime='" + DateTime.Now.ToString("yyyyMMddHHmmss") + "',acct='" + openID + "' where trxid='" + trxid + "'";

            DbHelperSQL.ExecuteSql(update1);
            return("3");
        }
Ejemplo n.º 3
0
        public static string yzPwd(string memberID, string money, string pwd, string companyID, string trxid)
        {
            //验证密码是否正确
            string    sql = "select * from asm_member where id='" + memberID + "' and pwd='" + pwd + "'";
            DataTable dd  = DbHelperSQL.Query(sql).Tables[0];

            if (dd.Rows.Count <= 0)
            {
                return("1");//支付密码不正确
            }
            //判断余额
            if (double.Parse(dd.Rows[0]["AvailableMoney"].ToString()) < double.Parse(money))
            {
                return("2");//余额不足
            }
            //更新余额
            string update = "update asm_member set AvailableMoney=AvailableMoney-" + money + " where id='" + memberID + "'";

            DbHelperSQL.ExecuteSql(update);
            string    sqlM    = "select addres from asm_mechine where id in(select mechineID from asm_member where id=" + memberID + ")";
            DataTable dM      = DbHelperSQL.Query(sqlM).Tables[0];
            string    address = "";

            if (dM.Rows.Count > 0)
            {
                address = dM.Rows[0]["addres"].ToString();
            }
            //发送消息模板
            wxHelper wx   = new wxHelper(companyID);
            string   data = TemplateMessage.money_bd(dd.Rows[0]["openID"].ToString(), OperUtil.getMessageID(companyID, "OPENTM403148135"), "余额变动提醒", "购买产品", money, (double.Parse(dd.Rows[0]["AvailableMoney"].ToString()) - double.Parse(money)).ToString(), address, "支付时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(companyID), data);
            //插入记录
            Util.insertNotice(dd.Rows[0]["id"].ToString(), "余额变动提醒", "您于" + DateTime.Now.ToString("yyyy/MM/dd HH:mm") + "购物消费:" + money + "元;余额:" + (double.Parse(dd.Rows[0]["AvailableMoney"].ToString()) - double.Parse(money)), "");
            Util.moneyChange(dd.Rows[0]["id"].ToString(), money, dd.Rows[0]["AvailableMoney"].ToString(), "会员消费", "2", "");
            string insertSQL = @"insert into asm_pay_info(trxid,acct,statu,type,payType,trxamt,paytime)
                                            values('" + trxid + "','" + memberID + "',1,2,4," + (double.Parse(money) * 100) + ",'" + DateTime.Now.ToString("yyyyMMddHHmmss") + "')";

            DbHelperSQL.ExecuteSql(insertSQL);
            return("3");
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Dictionary <String, String> reqParams = new Dictionary <String, String>();

            /**
             * 此处注意,因为通联收银宝以后可能增加字段,所以,这里一定要动态遍历获取所有的请求参数
             *
             * */
            for (int i = 0; i < Request.Form.Count; i++)
            {
                reqParams.Add(Request.Form.Keys[i], Request.Form[i].ToString());
            }
            if (!reqParams.ContainsKey("sign"))//如果不包含sign,则不进行处理
            {
                Response.Write("error");
                return;
            }
            if (reqParams.ContainsKey("trxid"))
            {
                string  json = (new JavaScriptSerializer()).Serialize(reqParams);
                JObject jo   = (JObject)JsonConvert.DeserializeObject(json);
                string  sql  = "select p.trxid,p.activityID,o.productID,p.unionID,p.companyID,o.activityID acID,o.psMode,o.startTime,o.mechineID,o.memberID,o.orderNO,o.companyID,o.totalNum,o.source  from asm_pay_info p left join asm_orderlist o on p.trxid=o.trxid"
                               + " where p.trxid = '" + jo["trxid"] + "' and o.trxid = '" + jo["trxid"] + "' and statu = 0";
                DataTable dtInfo = DbHelperSQL.Query(sql).Tables[0];
                if (dtInfo.Rows.Count > 0)
                {
                    string    sql111          = "select top 1 * from asm_duihuan  where newOrderNo='" + dtInfo.Rows[0]["orderNO"].ToString() + "'    order by dhTime desc ";
                    DataTable asm_duihuanInfo = DbHelperSQL.Query(sql111).Tables[0];
                    if (asm_duihuanInfo.Rows.Count > 0 && (!string.IsNullOrEmpty(asm_duihuanInfo.Rows[0]["oldOrderNo"].ToString())))
                    {
                        Util.Debuglog("sql111=" + sql111, "dhProduct.txt");
                        List <string> list = new List <string>();
                        string        sql2 = "update asm_orderlist set orderZT=4 where orderNO='" + asm_duihuanInfo.Rows[0]["oldOrderNo"].ToString() + "'";
                        string        sql3 = "update asm_orderlistDetail set zt=7 where  zt=5 and orderNO='" + asm_duihuanInfo.Rows[0]["oldOrderNo"].ToString() + "'";
                        list.Add(sql2);
                        list.Add(sql3);
                        Util.Debuglog("list=" + sql2 + sql3, "dhProduct.txt");
                        int a = DbHelperSQL.ExecuteSqlTran(list);
                    }
                    string trxdate   = Request.Form["trxdate"];
                    string paytime   = Request.Form["paytime"];
                    string acct      = Request.Form["acct"];
                    string chnltrxid = Request.Form["chnltrxid"];
                    double trxamtY   = double.Parse(Request.Form["trxamt"]) / 100;
                    //更新asm_pay_info asm_orderlist支付状态
                    string update1 = "update asm_pay_info set statu=1,paytime='" + paytime + "',productID='" + dtInfo.Rows[0]["productID"].ToString() + "',mechineID='" + dtInfo.Rows[0]["mechineID"].ToString() + "' where trxid='" + jo["trxid"].ToString() + "'";
                    DbHelperSQL.ExecuteSql(update1);
                    string update2 = "update asm_orderlist set fkzt=1  where trxid='" + jo["trxid"].ToString() + "'";
                    DbHelperSQL.ExecuteSql(update2);
                    //需要更新会员的消费信息
                    string update = "update asm_member set sumConsume=sumConsume+" + trxamtY + ",LastTime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',mechineID='" + dtInfo.Rows[0]["mechineID"].ToString() + "' where minOpenID='" + acct + "'";
                    DbHelperSQL.ExecuteSql(update);

                    string sqlActivity = "select * from asm_activity where status=1 and id=" + dtInfo.Rows[0]["activityID"].ToString();
                    //DataTable dactivity = DbHelperSQL.Query(sqlActivity).Tables[0];



                    string[] selDate = OperUtil.getSelDate(dtInfo.Rows[0]["totalNum"].ToString(), dtInfo.Rows[0]["psMode"].ToString(), dtInfo.Rows[0]["startTime"].ToString()).Split(',');
                    if (selDate.Length > 0)
                    {
                        DataTable dtNew;
                        for (int j = 0; j < dtInfo.Rows.Count; j++)
                        {
                            string sql14 = "select * from asm_orderlistDetail where id=0";
                            dtNew = DbHelperSQL.Query(sql14).Tables[0];

                            for (int i = 0; i < selDate.Length; i++)
                            {
                                int code = new Random(Guid.NewGuid().GetHashCode()).Next(100000, 999999);
                                //zt   1-已完成;2-已失效;3-已转售;4-待取货;5-待配送
                                DataRow dr = dtNew.NewRow();
                                dr["mechineID"]  = dtInfo.Rows[j]["mechineID"].ToString(); //通过索引赋值
                                dr["productID"]  = dtInfo.Rows[j]["productID"].ToString();
                                dr["createTime"] = delTime(selDate[i]);                    //
                                //dr["code"] = code;//
                                dr["memberID"] = dtInfo.Rows[j]["memberID"].ToString();    //通过索引赋值
                                if (delTime(selDate[i]) == DateTime.Now.ToString("yyyy-MM-dd"))
                                {
                                    dr["zt"]   = "4";
                                    dr["code"] = code;//
                                }
                                else
                                {
                                    dr["zt"] = "5";
                                }

                                dr["ldNO"]      = "";                                   //
                                dr["orderNO"]   = dtInfo.Rows[j]["orderNO"].ToString(); //
                                dr["statu"]     = "0";                                  //通过索引赋值
                                dr["sellPrice"] = 0.0;
                                dr["sellTime"]  = "";
                                dr["bz"]        = "";
                                dr["companyID"] = dtInfo.Rows[j]["companyID"].ToString();
                                dtNew.Rows.Add(dr);
                            }
                            DbHelperSQL.BatchInsertBySqlBulkCopy(dtNew, "[dbo].[asm_orderlistDetail]");
                            string    sql1 = "select * from asm_orderlistDetail where orderNO in ('" + dtInfo.Rows[j]["orderNO"].ToString() + "') ORDER BY createTime DESC ";
                            DataTable d1   = DbHelperSQL.Query(sql1).Tables[0];
                            if (d1.Rows.Count > 0)
                            {
                                string update12 = "UPDATE asm_orderlist set endTime='" + d1.Rows[0]["createTime"].ToString() + "' WHERE orderNO in ('" + dtInfo.Rows[j]["orderNO"].ToString() + "')";
                                DbHelperSQL.ExecuteSql(update12);
                            }
                            if (dtInfo.Rows[j]["startTime"].ToString() == DateTime.Now.ToString("yyyy-MM-dd"))
                            {
                                string updagte = "UPDATE asm_orderlist set orderzt=1 where orderno='" + dtInfo.Rows[j]["orderNO"].ToString() + "'";
                                DbHelperSQL.ExecuteSql(updagte);
                            }
                        }
                    }


                    if (dtInfo.Rows[0]["source"].ToString() != "1")
                    {
                        Util.growUpMemberBYDG(acct, int.Parse(dtInfo.Rows[0]["totalNum"].ToString()) * dtInfo.Rows.Count, dtInfo.Rows[0]["companyID"].ToString());
                    }

                    //发送模板消息
                    string    sqlM = "select * from asm_member where minOpenID='" + acct + "'";
                    DataTable dM   = DbHelperSQL.Query(sqlM).Tables[0];
                    //插入参加的活动记录
                    string activityID = dtInfo.Rows[0]["activityID"].ToString();
                    //兑换的产品不在继续参加活动source!=1
                    if (!string.IsNullOrEmpty(activityID) && dtInfo.Rows[0]["source"].ToString() != "1")
                    {
                        string    sqlAc = "select * from asm_activity where statu=1 and id='" + activityID + "'";
                        DataTable dac   = DbHelperSQL.Query(sqlAc).Tables[0];
                        if (dac.Rows.Count > 0)
                        {
                            string status = "1";
                            if (dac.Rows[0]["type"].ToString() == "3")
                            {
                                status = "0";
                            }
                            else
                            {
                                try
                                {
                                    //发通知
                                    if (!string.IsNullOrEmpty(dM.Rows[0]["openID"].ToString()))
                                    {
                                        string   companyID = dM.Rows[0]["companyID"].ToString();
                                        string   openID    = dM.Rows[0]["openID"].ToString();
                                        wxHelper wx        = new wxHelper(companyID);
                                        string   data      = TemplateMessage.getPrize(openID, "hPFDCcfuANnDAGaIaAjsAnDKfgFXK-Y0SYGK12iIsAM", "活动奖励通知", dac.Rows[0]["payName"].ToString(), dac.Rows[0]["tag"].ToString(), "请尽快到小程序查看奖励");
                                        TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(dM.Rows[0]["companyID"].ToString()), data);
                                    }
                                }
                                catch { }
                            }
                            string zsType        = dac.Rows[0]["type"].ToString();
                            string sqlActivityIn = "insert into asm_partActivity(memberID,partTime,type,activityContent,companyID,zsType,status,activityName,totalMoney) values('" + dtInfo.Rows[0]["memberID"].ToString() + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',1,'" + dac.Rows[0]["activitytag"].ToString() + "','" + dac.Rows[0]["companyID"].ToString() + "'," + zsType + "," + status + ",'" + dac.Rows[0]["activityname"].ToString() + "'," + trxamtY + ")";
                            DbHelperSQL.ExecuteSql(sqlActivityIn);
                        }
                    }

                    if (dM.Rows.Count > 0)
                    {
                        if (!string.IsNullOrEmpty(dM.Rows[0]["openID"].ToString()))
                        {
                            string    openID    = dM.Rows[0]["openID"].ToString();
                            string    companyID = dM.Rows[0]["companyID"].ToString();
                            string    sqlp      = "select o.*,p.proName from asm_orderlist o left join asm_product p on o.productID=p.productID where trxid='" + jo["trxid"].ToString() + "'";
                            DataTable dp        = DbHelperSQL.Query(sqlp).Tables[0];
                            wxHelper  wx        = new wxHelper(companyID);
                            string    data      = TemplateMessage.comsume(openID, OperUtil.getMessageID(companyID, "OPENTM401313503"), "亲,你的购买的商品信息如下",
                                                                          "" + dp.Rows[0]["proName"].ToString() + "", dp.Rows[0]["totalMoney"].ToString(), dp.Rows[0]["orderNO"].ToString(), dp.Rows[0]["mechineName"].ToString(), "“生鲜时逐”订奶订单已生成,鲜活即将配送到家");
                            TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(OperUtil.getCooki("companyID")), data);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public static string yzPwd(string unionID, string money, string companyID, string productID, string mechineID, string type, string dgOrderDetailID, string sftj, string reqsn)
        {
            string ldno = Util.getLDNO(mechineID, productID);

            if (string.IsNullOrEmpty(ldno))
            {
                return("5");//当前机器库存不足,请等待配送员上货
            }
            Random    rd        = new Random();
            int       rand      = rd.Next(10000, 99999);
            string    sql2      = "select * from asm_company where id='" + companyID + "'";
            DataTable d2        = DbHelperSQL.Query(sql2).Tables[0];
            string    trxid     = ConvertDateTimeToInt(DateTime.Now).ToString() + rand;
            string    insertSQL = "insert into asm_pay_info(reqsn,trxid,statu,type,payType,trxamt,createTime,appid,unionID,mechineID,productID,companyID,orderType,dgOrderDetailID,sftj) values('" + reqsn + ",'" + trxid + "',0,2,4," + double.Parse(money) * 100 + ",'" + DateTime.Now + "','" + d2.Rows[0]["tl_APPID"].ToString() + "','" + unionID + "','" + mechineID + "','" + productID + "','" + companyID + "','" + type + "','" + dgOrderDetailID + "','" + sftj + "')";

            Util.Debuglog("insertSQL=" + insertSQL, "余额支付.txt");
            int a = DbHelperSQL.ExecuteSql(insertSQL);


            //验证密码是否正确
            string sql = "select * from asm_member where unionID='" + unionID + "'";

            Util.Debuglog("sql=" + sql, "余额支付.txt");
            DataTable dd = DbHelperSQL.Query(sql).Tables[0];


            string openID = dd.Rows[0]["openID"].ToString();
            //判断该订单支付状态
            string sql1 = "select * from asm_pay_info where trxid='" + trxid + "'";

            Util.Debuglog("sql1=" + sql1, "余额支付.txt");
            DataTable d1 = DbHelperSQL.Query(sql1).Tables[0];

            if (d1.Rows.Count > 0 && d1.Rows[0]["statu"].ToString() == "1")
            {
                return("4");//已经支付完成无需重复支付
            }
            //判断余额
            if (double.Parse(dd.Rows[0]["AvailableMoney"].ToString()) - double.Parse(money) < 0)
            {
                return("2");//余额不足
            }
            //更新余额
            string update = "update asm_member set AvailableMoney=AvailableMoney-" + money + ",consumeCount=consumeCount+1,sumConsume=sumConsume+" + money + ",LastTime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where openID='" + openID + "'";

            Util.Debuglog("update=" + update, "余额支付.txt");
            DbHelperSQL.ExecuteSql(update);
            string sqlM = "select addres,id,mechineName from asm_mechine where id in(" + mechineID + ")";

            Util.Debuglog("sqlM=" + sqlM, "余额支付.txt");
            DataTable dM      = DbHelperSQL.Query(sqlM).Tables[0];
            string    address = "";

            if (dM.Rows.Count > 0)
            {
                address = dM.Rows[0]["addres"].ToString();
            }
            //发送消息模板

            ////插入记录
            //Util.insertNotice(dd.Rows[0]["id"].ToString(),"余额变动提醒", "您于"+DateTime.Now.ToString("yyyy/MM/dd HH:mm")+"购物消费:"+money+"元;余额:"+ (double.Parse(dd.Rows[0]["AvailableMoney"].ToString())-double.Parse(money)));
            //Util.moneyChange(dd.Rows[0]["id"].ToString(),money,(double.Parse(dd.Rows[0]["AvailableMoney"].ToString()) - double.Parse(money)).ToString(), "会员消费", "2", "");
            //接着更新订单的状态

            string update1 = "update asm_pay_info set chLdNo='" + ldno + "', trxdate='" + DateTime.Now.ToString("yyyyMMdd") + "',statu=1,paytime='" + DateTime.Now.ToString("yyyyMMddHHmmss") + "',acct='" + openID + "',afterMoney=" + (double.Parse(dd.Rows[0]["AvailableMoney"].ToString()) - double.Parse(money)) + " where trxid='" + trxid + "' and unionID='" + unionID + "'";

            Util.Debuglog("update1=" + update1 + ";料道编号=" + ldno, "余额支付.txt");
            DbHelperSQL.ExecuteSql(update1);
            Util.ch(ldno, dM.Rows[0]["id"].ToString(), trxid, "3", productID, money);
            string sqlP = "SELECT * FROM asm_product where productID=" + productID;

            Util.Debuglog("sqlP=" + sqlP + ";料道编号=" + ldno, "余额支付.txt");
            DataTable dp      = DbHelperSQL.Query(sqlP).Tables[0];
            string    updateM = "update asm_member set mechineID=" + dM.Rows[0]["id"].ToString() + " where id=" + dd.Rows[0]["id"].ToString();

            DbHelperSQL.ExecuteSql(updateM);
            Util.chgMoney(dd.Rows[0]["id"].ToString(), money, "会员消费", "购买" + dp.Rows[0]["proName"].ToString(), "2");
            Util.Debuglog("111111", "余额支付.txt");

            wxHelper wx   = new wxHelper(companyID);
            string   data = TemplateMessage.comsume(openID, OperUtil.getMessageID(companyID, "OPENTM401313503"), "亲,你的购买的商品信息如下",
                                                    "" + dp.Rows[0]["proName"].ToString() + "", money, trxid, dM.Rows[0]["mechineName"].ToString(), "“机器已出货,请尽快推开机器左下方推板取出奶品,超过1分钟未取视为丢弃奶品,推板将关闭");

            TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(companyID), data);
            return("3");
        }
Ejemplo n.º 6
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)
            {
                //获取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 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.ch(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];

                    //此处判断如果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 && dtM.Rows.Count > 0)
                        {
                            string id        = dt.Rows[0]["dgOrderDetailID"].ToString();
                            string memberID  = dtM.Rows[0]["id"].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];
                                double    price        = double.Parse(dpro.Rows[0]["price0"].ToString()) / 2;
                                string    updateMember = "update asm_member set AvailableMoney=AvailableMoney+" + price + " where id=" + memberID;
                                DbHelperSQL.ExecuteSql(updateMember);
                                Util.chgMoney(memberID, price.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");
        }
Ejemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string code = "";
         if (Request.QueryString["code"] != null && Request.QueryString["code"] != "")
         {
             code = Request.QueryString["code"].ToString();
             Util.Debuglog("code=" + code, "_获取会员信息.txt");
             string    companyID = Request.QueryString["companyID"].ToString();
             string    sql2      = "select * from asm_company where id=" + companyID;
             DataTable d1        = DbHelperSQL.Query(sql2).Tables[0];
             if (d1.Rows.Count > 0)
             {
                 appid     = d1.Rows[0]["appId"].ToString();
                 appsecret = d1.Rows[0]["wx_appsecret"].ToString();
             }
             OAuth_Token Model           = Get_token(code, companyID);
             OAuthUser   OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid);
             //OAuthUser OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid);
             if (OAuthUser_Model.openid != null && OAuthUser_Model.openid != "") //已获取得openid及其他信息
             {
                 tupian  = OAuthUser_Model.headimgurl.ToString();                //头像图片
                 name    = OAuthUser_Model.nickname;                             //昵称
                 id      = OAuthUser_Model.openid;                               //opendid
                 unionID = OAuthUser_Model.unionid;
                 string country  = OAuthUser_Model.country;
                 string province = OAuthUser_Model.province;
                 string city     = OAuthUser_Model.city;
                 Util.Debuglog("unionid=" + OAuthUser_Model.unionid, "_获取会员信息.txt");
                 OperUtil.setCooki("vshop_openID", id);
                 string    sql = "select * from asm_member where openID='" + id + "'or unionID='" + unionID + "' and companyID=" + companyID;
                 DataTable dt  = DbHelperSQL.Query(sql).Tables[0];
                 wxHelper  wx  = new wxHelper(companyID);
                 wx.Get_UserInfo(id);
                 if (dt.Rows.Count <= 0)
                 {
                     //name= System.Web.HttpUtility.UrlEncode(name, System.Text.Encoding.UTF8);
                     //添加会员 会员不一定必须绑定机器  只有会员有订购产品的时候才必须绑定机器
                     string sql1 = "INSERT INTO [dbo].[asm_member]"
                                   + " ([name],[phone],[QQ],[province],[city],[country],[addres],[AvailableMoney],[sumConsume],[sumRecharge],[createDate],[mechineID],[companyID],[age],[LastTime],[memberBH],[consumeCount],[openID],[brithday],[headurl],[nickname],[pwd],[utfName],unionID)"
                                   + " VALUES(N'" + name + "','','','" + province + "','" + city + "','','',0,0,0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','','" + companyID + "','0','','',0,'" + id + "','','" + tupian + "',N'" + name + "','000000','" + System.Web.HttpUtility.UrlEncode(name, System.Text.Encoding.UTF8) + "','" + unionID + "')";
                     DbHelperSQL.ExecuteSql(sql1);
                     Util.Debuglog("sql1=" + sql1 + ";会员注册", "首页_.txt");
                     string data = TemplateMessage.Member_ZC(id, OperUtil.getMessageID(companyID, "OPENTM203347141"), "恭喜您注册成为会员!", name, "恭喜您注册成为会员,您将享受到会员所有权利!交易密码默认为000000,请前往会员中心修改");
                     TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(companyID), data);
                     //跳转领取红包判断系统是否开启
                     if (d1.Rows[0]["p4"].ToString() != "" && d1.Rows[0]["p4"].ToString() != null && d1.Rows[0]["p4"].ToString() != "0")
                     {
                         Response.Write("<script>top.location.href='accethb.aspx?companyID=" + companyID + "&openID=" + id + "';</script>");
                     }
                     else
                     {
                         Response.Write("<script>top.location.href='homeIndex.aspx?companyID=" + companyID + "';</script>");
                     }
                 }
                 else
                 {
                     //更新会员信息
                     string sqlupdate = string.Format("update asm_member set name=N'{0}',headurl='{1}',utfName='{3}',unionID='" + unionID + "' where openID='{2}'", name, tupian, id, System.Web.HttpUtility.UrlEncode(name, System.Text.Encoding.UTF8));
                     DbHelperSQL.ExecuteSql(sqlupdate);
                     Response.Write("<script>top.location.href='homeIndex.aspx?companyID=" + companyID + "';</script>");
                 }
             }
         }
     }
 }
Ejemplo n.º 8
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");
        }
Ejemplo n.º 9
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() + ",sumConsume=sumConsume-" + 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());

                                        if (!string.IsNullOrEmpty(dt.Rows[0]["openID"].ToString()))
                                        {
                                            try
                                            {
                                                string   company = Util.getCompany(dt.Rows[0]["companyID"].ToString());
                                                wxHelper wx      = new wxHelper(dt.Rows[0]["companyID"].ToString());
                                                string   data    = TemplateMessage.tk(dt.Rows[0]["openID"].ToString(), OperUtil.getMessageID(dt.Rows[0]["companyID"].ToString(), "OPENTM410089600"), "退款通知", dd.Rows[0]["totalMoney"].ToString(), "您购买的商品没有出货成功,钱已退还到账户");
                                                TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(dt.Rows[0]["companyID"].ToString()), data);
                                            }
                                            catch (Exception e)
                                            {
                                                Util.Debuglog("e=" + e.Message, "会员等级消息模板.txt");
                                            }
                                        }
                                        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() == "出货失败")
                            {
                                Util.Debuglog("billno=" + billno, "_手动退款.txt");
                                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() + ",sumConsume=sumConsume-" + 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("oldtrxid=" + oldtrxid + ";微信支付链接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")
                                        {
                                            try
                                            {
                                                string msg = jo["errmsg"].ToString();
                                                return(new { result = 0, msg = msg });
                                            }
                                            catch
                                            {
                                            }
                                            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);
                                                string update1 = "update asm_member set  sumConsume=sumConsume-" + (double.Parse(dd.Rows[0]["trxamt"].ToString()) / 100) + " where openID='" + dd.Rows[0]["acct"].ToString() + "'";
                                                int    a       = DbHelperSQL.ExecuteSql(update1);

                                                string    sqlm = "select * from asm_member where openID='" + dd.Rows[0]["acct"].ToString() + "'";
                                                DataTable dt   = DbHelperSQL.Query(sqlm).Tables[0];
                                                if (!string.IsNullOrEmpty(dt.Rows[0]["openID"].ToString()))
                                                {
                                                    try
                                                    {
                                                        string    sqlPayInfo = "select * from asm_pay_info where trxid='" + billno + "'";
                                                        DataTable ddpayInfo  = DbHelperSQL.Query(sqlPayInfo).Tables[0];
                                                        string    company    = Util.getCompany(dt.Rows[0]["companyID"].ToString());
                                                        wxHelper  wx         = new wxHelper(dt.Rows[0]["companyID"].ToString());
                                                        data = TemplateMessage.tk(dt.Rows[0]["openID"].ToString(), OperUtil.getMessageID(dt.Rows[0]["companyID"].ToString(), "OPENTM410089600"), "退款通知", (double.Parse(ddpayInfo.Rows[0]["trxamt"].ToString()) / 100).ToString("f2"), "您购买的商品没有出货成功,钱已退还到账户");
                                                        TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(dt.Rows[0]["companyID"].ToString()), data);
                                                    }
                                                    catch (Exception e)
                                                    {
                                                        Util.Debuglog("e=" + e.Message, "会员等级消息模板.txt");
                                                    }
                                                }
                                                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 = "退款失败" });
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string code = "";
                if (Request.QueryString["code"] != null && Request.QueryString["code"] != "")
                {
                    code = Request.QueryString["code"].ToString();
                    Util.Debuglog("code=" + code + ";state=" + Request.QueryString["state"], "获取参数.txt");
                    string[] param = Request.QueryString["state"].ToString().Split('|');
                    if (param.Length != 4)
                    {
                        //Response.Write("<span style='color:#FF0000;font-size:20px'>" + "参数不全请重试" + "</span>");
                    }
                    //9|14|43|334|0|1
                    string    money           = param[0]; //9
                    string    companyID       = param[1]; //14
                    string    mechineID       = param[2]; //43
                    string    productID       = param[3]; //334
                    string    dgOrderDetailID = param[4]; //0
                    string    type            = param[5]; //1
                    string    sftj            = param[6]; //1 是特价
                    string    sql2            = "select * from asm_company where id=" + companyID;
                    DataTable d1 = DbHelperSQL.Query(sql2).Tables[0];
                    if (d1.Rows.Count > 0)
                    {
                        appid     = d1.Rows[0]["appId"].ToString();
                        appsecret = d1.Rows[0]["wx_appsecret"].ToString();
                    }

                    OAuth_Token Model           = Get_token(code, companyID);
                    OAuthUser   OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid);
                    if (OAuthUser_Model.openid != null && OAuthUser_Model.openid != "") //已获取得openid及其他信息
                    {
                        headImg = OAuthUser_Model.headimgurl.ToString();                //头像图片
                        name    = OAuthUser_Model.nickname;                             //昵称
                        id      = OAuthUser_Model.openid;                               //opendid
                        unionID = OAuthUser_Model.unionid;
                        string province = OAuthUser_Model.province;
                        string city     = OAuthUser_Model.city;
                        string country  = OAuthUser_Model.city;
                        string gender   = OAuthUser_Model.sex == "1" ? "男" : "女";
                        // Util.SetSession("_openID", id);
                        Util.Debuglog("id=" + id, "获取token.txt");//o1_mf1aL2bduKZnTzG1irrfvN0x8
                        string sql = "select * from asm_member where unionID='" + unionID + "'";
                        Util.Debuglog("sql=" + sql, "零售支付用户注册.txt");
                        DataTable dt   = DbHelperSQL.Query(sql).Tables[0];
                        string    sql3 = "select * from asm_tqlist where companyID=" + companyID;
                        Util.Debuglog("sql3=" + sql3, "零售支付用户注册.txt");
                        DataTable d3 = DbHelperSQL.Query(sql3).Tables[0];
                        if (d3.Rows.Count > 0 && d3.Rows[0]["memberprice"].ToString() == "1" && dt.Rows.Count > 0)
                        {
                            //查询该产品是否限时特价

                            money = Util.getNewProductPrice(productID, mechineID, dt.Rows[0]["dj"].ToString());
                        }
                        else
                        {
                            string    sql1 = "select * from asm_product where productID=" + productID;
                            DataTable dt1  = DbHelperSQL.Query(sql1).Tables[0];
                            money = dt1.Rows[0]["price0"].ToString();
                        }
                        //判断限购次数



                        if (dt.Rows.Count <= 0)
                        {
                            string insert = "insert into asm_member(name,phone,province,city,country,AvailableMoney,sumConsume,sumRecharge,createDate,companyID,headurl,nickname,sex,unionID,openID,consumeCount)"
                                            + " values(N'" + name + "','','" + province + "','" + city + "','" + country + "',0,0,0,'" + DateTime.Now + "','" + companyID + "','" + headImg + "',N'" + name + "','" + gender + "','" + unionID + "','" + id + "',0)";
                            Util.Debuglog(insert, "零售支付用户注册.txt");
                            DbHelperSQL.ExecuteSql(insert);
                            //发送注册成为会员模板消息
                            wxHelper wx   = new wxHelper(companyID);
                            string   data = TemplateMessage.Member_ZC(id, OperUtil.getMessageID(companyID, "OPENTM203347141"), "恭喜您注册成为会员!", name, "恭喜您注册成为会员,您将享受到会员所有权利!");
                            TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(companyID), data);
                        }
                        else
                        {
                            //更新
                            string update = "update asm_member set openID='" + id + "' where unionID='" + unionID + "'";
                            Util.Debuglog("更新" + update, "是否限购.txt");
                            DbHelperSQL.ExecuteSql(update);
                            //限购判断
                            if (!Util.xgCount(productID, dt.Rows[0]["id"].ToString(), mechineID))
                            {
                                Util.Debuglog("限购" + unionID, "是否限购.txt");
                                string url13 = "https://wx.bingoseller.com/main/xg.aspx";
                                //限购不让购买
                                Response.Write("<script>window.location.href='" + url13 + "';</script>");
                                return;
                            }
                            if (unionID == "owhCR0esai2hPXH4lYkeLMAcccuE" || unionID == "owhCR0XLU0NM_GauIWydxGogmHfk")
                            {
                                string url1 = "https://wx.bingoseller.com/main/wxorbalanceceshi.aspx?companyID=" + companyID + "&mechineID=" + mechineID + "&money=" + money + "&unionID=" + unionID + "&openID=" + id + "&productID=" + productID + "&dgOrderDetailID=" + dgOrderDetailID + "&type=" + type + "&sftj=" + sftj;
                                Util.Debuglog("url1=" + url1, "微信+余额.txt");
                                Response.Write("<script>window.location.href='" + url1 + "';</script>");
                                return;
                            }


                            if (dt.Rows.Count > 0 && double.Parse(dt.Rows[0]["AvailableMoney"].ToString()) >= double.Parse(money))
                            {
                                string url1 = "https://wx.bingoseller.com/main/wxorbalance.aspx?companyID=" + companyID + "&mechineID=" + mechineID + "&money=" + money + "&unionID=" + unionID + "&openID=" + id + "&productID=" + productID + "&dgOrderDetailID=" + dgOrderDetailID + "&type=" + type + "&sftj=" + sftj;
                                Util.Debuglog("url1=" + url1, "微信+余额.txt");
                                Response.Write("<script>window.location.href='" + url1 + "';</script>");
                                return;
                            }
                        }
                        string url12 = "https://wx.bingoseller.com/main/wxorbalance.aspx?companyID=" + companyID + "&mechineID=" + mechineID + "&money=" + money + "&unionID=" + unionID + "&openID=" + id + "&productID=" + productID + "&dgOrderDetailID=" + dgOrderDetailID + "&type=" + type + "&sftj=" + sftj;
                        Util.Debuglog("url12=" + url12, "微信+余额.txt");
                        Response.Write("<script>window.location.href='" + url12 + "';</script>");
                        return;
                    }
                }
            }
        }
Ejemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string code = "";
                if (Request.QueryString["code"] != null && Request.QueryString["code"] != "")
                {
                    code = Request.QueryString["code"].ToString();
                    Util.Debuglog("code=" + code + ";state=" + Request.QueryString["state"], "获取参数.txt");
                    string[] param = Request.QueryString["state"].ToString().Split('|');
                    if (param.Length != 4)
                    {
                        //Response.Write("<span style='color:#FF0000;font-size:20px'>" + "参数不全请重试" + "</span>");
                    }
                    //9|14|43|334|0|1
                    //string money = param[0];//9
                    string companyID = param[0];//14
                    //string mechineID = param[2];//43
                    // string productID = param[3];//334
                    // string dgOrderDetailID = param[4];//0
                    // string type = param[5];//1
                    //string sftj = param[6];//1 是特价
                    string reqsn = param[1];
                    //reqsn= reqsn.Replace("reqsn", "");
                    string    productID           = "";  //334
                    string    mechineID           = "";  //334
                    string    dgOrderDetailID     = "0"; //0
                    string    type                = "2"; //1
                    string    sftj                = "0"; //1 是特价
                    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)
                    {
                        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();
                        sftj            = asm_product_pickdt.Rows[0]["sftj"].ToString();
                    }
                    else
                    {
                        return;
                    }
                    string    sql2 = "select * from asm_company where id=" + companyID;
                    DataTable d1   = DbHelperSQL.Query(sql2).Tables[0];
                    if (d1.Rows.Count > 0)
                    {
                        appid     = d1.Rows[0]["appId"].ToString();
                        appsecret = d1.Rows[0]["wx_appsecret"].ToString();
                    }

                    OAuth_Token Model           = Get_token(code, companyID);
                    OAuthUser   OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid);
                    if (OAuthUser_Model.openid != null && OAuthUser_Model.openid != "") //已获取得openid及其他信息
                    {
                        headImg = OAuthUser_Model.headimgurl.ToString();                //头像图片
                        name    = OAuthUser_Model.nickname;                             //昵称
                        id      = OAuthUser_Model.openid;                               //opendid
                        unionID = OAuthUser_Model.unionid;
                        string province = OAuthUser_Model.province;
                        string city     = OAuthUser_Model.city;
                        string country  = OAuthUser_Model.city;
                        string gender   = OAuthUser_Model.sex == "1" ? "男" : "女";
                        // Util.SetSession("_openID", id);
                        Util.Debuglog("id=" + id, "获取token.txt");//o1_mf1aL2bduKZnTzG1irrfvN0x8
                        string sql = "select * from asm_member where unionID='" + unionID + "'";
                        Util.Debuglog("sql=" + sql, "零售支付用户注册.txt");
                        DataTable dt = DbHelperSQL.Query(sql).Tables[0];

                        //判断限购次数
                        if (dt.Rows.Count <= 0)
                        {
                            string insert = "insert into asm_member(name,phone,province,city,country,AvailableMoney,sumConsume,sumRecharge,createDate,companyID,headurl,nickname,sex,unionID,openID,consumeCount)"
                                            + " values(N'" + name + "','','" + province + "','" + city + "','" + country + "',0,0,0,'" + DateTime.Now + "','" + companyID + "','" + headImg + "',N'" + name + "','" + gender + "','" + unionID + "','" + id + "',0);select @@IDENTITY";
                            Util.Debuglog(insert, "零售支付用户注册.txt");
                            object obj = DbHelperSQL.GetSingle(insert);
                            if (obj == null)
                            {
                            }
                            else
                            {
                                string pickupdate = "update  asm_product_pick set memberID=" + Convert.ToInt32(obj).ToString() + " where reqsnNo='" + reqsn + "' ";
                                Util.Debuglog("sqlInsert=" + pickupdate, "获取预生成订单号.txt");
                                DbHelperSQL.ExecuteSql(pickupdate);
                            }

                            //发送注册成为会员模板消息
                            wxHelper wx   = new wxHelper(companyID);
                            string   data = TemplateMessage.Member_ZC(id, OperUtil.getMessageID(companyID, "OPENTM203347141"), "恭喜您注册成为会员!", name, "恭喜您注册成为会员,您将享受到会员所有权利!");
                            TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(companyID), data);
                        }
                        else
                        {
                            string pickupdate = "update  asm_product_pick set memberID=" + dt.Rows[0]["id"].ToString() + " where reqsnNo='" + reqsn + "' ";
                            Util.Debuglog("sqlInsert=" + pickupdate, "获取预生成订单号.txt");
                            DbHelperSQL.ExecuteSql(pickupdate);
                            //更新
                            string update = "update asm_member set openID='" + id + "' where unionID='" + unionID + "'";
                            Util.Debuglog("更新" + update, "是否限购.txt");
                            DbHelperSQL.ExecuteSql(update);
                            //限购判断
                            if (!Util.xgCount(productID, dt.Rows[0]["id"].ToString(), mechineID))
                            {
                                Util.Debuglog("限购" + unionID, "是否限购.txt");
                                string url13 = "https://wx.bingoseller.com/main/xg.aspx";
                                //限购不让购买
                                Response.Write("<script>window.location.href='" + url13 + "';</script>");
                                return;
                            }
                            if (unionID == "owhCR0esai2hPXH4lYkeLMAcccuE" || unionID == "owhCR0XLU0NM_GauIWydxGogmHfk" || unionID == "owhCR0bslgzXtWBLHv-ll7W1Me4c" || unionID == "owhCR0UPVXSCxYyPhkNy3wejNjNs" || unionID == "owhCR0dm8yPqHIYZhMnjti_PvA3U")
                            {
                                string url1 = "https://wx.bingoseller.com/main/wxorbalanceNew.aspx?companyID=" + companyID + "&mechineID=" + mechineID + "&unionID=" + unionID + "&openID=" + id + "&productID=" + productID + "&dgOrderDetailID=" + dgOrderDetailID + "&type=" + type + "&sftj=" + sftj + "&reqsn=" + reqsn;
                                Util.Debuglog("url1=" + url1, "微信+余额.txt");
                                Response.Write("<script>window.location.href='" + url1 + "';</script>");
                                return;
                            }
                        }
                        string url12 = "https://wx.bingoseller.com/main/wxorbalance.aspx?companyID=" + companyID + "&mechineID=" + mechineID + "&unionID=" + unionID + "&openID=" + id + "&productID=" + productID + "&dgOrderDetailID=" + dgOrderDetailID + "&type=" + type + "&sftj=" + sftj;
                        Util.Debuglog("url12=" + url12, "微信+余额.txt");
                        Response.Write("<script>window.location.href='" + url12 + "';</script>");
                        return;
                    }
                }
            }
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Dictionary <String, String> reqParams = new Dictionary <String, String>();

            /**
             * 此处注意,因为通联收银宝以后可能增加字段,所以,这里一定要动态遍历获取所有的请求参数
             *
             * */
            for (int i = 0; i < Request.Form.Count; i++)
            {
                reqParams.Add(Request.Form.Keys[i], Request.Form[i].ToString());
                Util.Debuglog("key=" + Request.Form.Keys[i] + ";param=" + Request.Form[i].ToString(), "_充值日志.txt");
            }
            if (!reqParams.ContainsKey("sign"))//如果不包含sign,则不进行处理
            {
                Response.Write("error");
                return;
            }
            if (reqParams.ContainsKey("trxid"))
            {
                string  json = (new JavaScriptSerializer()).Serialize(reqParams);
                JObject jo   = (JObject)JsonConvert.DeserializeObject(json);
                string  sql  = "select * from asm_pay_info where trxid='" + jo["trxid"].ToString() + "'";
                Util.Debuglog("支付信息sql=" + sql, "_充值日志.txt");
                DataTable dt = DbHelperSQL.Query(sql).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    //获取openid查询这个openid的companyID 的appkey
                    string sql12 = "select * from asm_member where openID='" + dt.Rows[0]["acct"].ToString() + "'";

                    DataTable d1   = DbHelperSQL.Query(sql12).Tables[0];
                    string    sql2 = "select * from asm_company where id=" + d1.Rows[0]["companyID"].ToString();

                    DataTable d2 = DbHelperSQL.Query(sql2).Tables[0];
                    //AppUtil.validSign(reqParams, d2.Rows[0]["tl_APPKEY"].ToString(),d1.Rows[0]["companyID"].ToString())
                    Util.Debuglog("支付信息状态=" + dt.Rows[0]["statu"].ToString(), "_充值日志.txt");
                    if (1 == 1 && dt.Rows[0]["statu"].ToString() == "0")//验签成功
                    {
                        //验签成功后,进行业务处理,处理完毕返回成功
                        string trxdate   = Request.Form["trxdate"];
                        string paytime   = Request.Form["paytime"];
                        string acct      = Request.Form["acct"];
                        string chnltrxid = Request.Form["chnltrxid"];
                        double trxamtY   = double.Parse(Request.Form["trxamt"]) / 100;
                        trxamtY = double.Parse(dt.Rows[0]["trxamt"].ToString()) / 100;
                        //支付成功向asm_pay 表 更新记录
                        string updateSQL = "update asm_pay_info set paytime='" + paytime + "',statu='1',trxdate='" + trxdate + "',chnltrxid='" + chnltrxid + "' where trxid='" + jo["trxid"].ToString() + "'";
                        int    a         = DbHelperSQL.ExecuteSql(updateSQL);

                        if (a > 0)
                        {
                            ////更新会员余额
                            //string update = "update asm_member set AvailableMoney=AvailableMoney+" + dt.Rows[0]["dzMoney"].ToString() + ",sumRecharge=sumRecharge+" + dt.Rows[0]["dzMoney"].ToString() + ",point=point+" + trxamtY + " where openID='" + dt.Rows[0]["acct"].ToString() + "'";
                            //Util.Debuglog("充值更新sql" + update, "_充值日志.txt");
                            //DbHelperSQL.ExecuteSql(update);
                            //string sql12 = "select * from asm_member where openID='" + dt.Rows[0]["acct"].ToString() + "'";
                            //DataTable dd = DbHelperSQL.Query(sql12).Tables[0];
                            //wxHelper wx = new wxHelper(d1.Rows[0]["companyID"].ToString());
                            //string data = TemplateMessage.success_cz(dt.Rows[0]["acct"].ToString(), OperUtil.getMessageID(d1.Rows[0]["companyID"].ToString(), "OPENTM410481462"), "充值成功通知", dt.Rows[0]["dzMoney"].ToString(), dd.Rows[0]["AvailableMoney"].ToString(), "充值时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                            //TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(d1.Rows[0]["companyID"].ToString()), data);
                            ////插入记录
                            //Util.insertNotice(dd.Rows[0]["id"].ToString(), "充值成功通知", "您于" + DateTime.Now.ToString("yyyy/MM/dd HH:mm") + "充值金额:" + trxamtY + ";到账金额:" + dt.Rows[0]["dzMoney"].ToString());
                            //Util.moneyChange(dd.Rows[0]["id"].ToString(), trxamtY.ToString(), dd.Rows[0]["AvailableMoney"].ToString(), "会员充值", "1", "");
                            //Util.moneyChange(dd.Rows[0]["id"].ToString(), trxamtY.ToString(), dd.Rows[0]["point"].ToString(), "积分变动", "5", "");


                            //更新会员余额
                            string update = "update asm_member set AvailableMoney=AvailableMoney+" + dt.Rows[0]["dzMoney"].ToString() + ",sumRecharge=sumRecharge+" + dt.Rows[0]["dzMoney"].ToString() + ",point=point+" + trxamtY + " where openID='" + dt.Rows[0]["acct"].ToString() + "'";
                            Util.Debuglog("充值更新update1" + update, "_充值日志.txt");
                            DbHelperSQL.ExecuteSql(update);
                            string sql1           = "select * from asm_member where openID='" + dt.Rows[0]["acct"].ToString() + "'";
                            string shouchongMoney = "0";
                            Util.Debuglog("充值更新sql1" + sql1, "_充值日志.txt");
                            DataTable dd = DbHelperSQL.Query(sql1).Tables[0];
                            shouchongMoney = dd.Rows[0]["hongbaoF"].ToString();
                            //判断系统是否开启首次充值赠送金额活动0不开启
                            string sqlC = "select * from asm_company where id=" + d1.Rows[0]["companyID"].ToString();
                            Util.Debuglog("充值更新sqlC" + sqlC + ";shouchongMoney=" + shouchongMoney, "_充值日志.txt");
                            DataTable dc = DbHelperSQL.Query(sqlC).Tables[0];
                            if (dc.Rows.Count > 0)
                            {
                                if (dc.Rows[0]["p4"].ToString() != "" && dc.Rows[0]["p4"].ToString() != null && dc.Rows[0]["p4"].ToString() != "0")
                                {
                                    //判断是否是在时间段内
                                    DateTime ze = Convert.ToDateTime(dd.Rows[0]["createDate"].ToString());
                                    if (ze.AddDays(int.Parse(dc.Rows[0]["p12"].ToString())) > DateTime.Now)
                                    {
                                        Util.Debuglog("p11" + dc.Rows[0]["p11"].ToString() + ";trxamtY" + trxamtY, "_充值日志.txt");
                                        //并且大于激活下限
                                        if (double.Parse(shouchongMoney) > 0 && double.Parse(dc.Rows[0]["p11"].ToString()) <= trxamtY)
                                        {
                                            //给发红包
                                            string update1 = "update asm_member set AvailableMoney=AvailableMoney+" + shouchongMoney + ",hongbaoF=0 where openID='" + dt.Rows[0]["acct"].ToString() + "'";
                                            Util.Debuglog("充值更新update" + update1, "_充值日志.txt");
                                            DbHelperSQL.ExecuteSql(update1);
                                            dd = DbHelperSQL.Query(sql1).Tables[0];
                                            Util.moneyChange(dd.Rows[0]["id"].ToString(), shouchongMoney, dd.Rows[0]["AvailableMoney"].ToString(), "首冲红包", "7", "");
                                        }
                                    }
                                }
                            }
                            wxHelper wx   = new wxHelper(d1.Rows[0]["companyID"].ToString());
                            string   data = TemplateMessage.success_cz(dt.Rows[0]["acct"].ToString(), OperUtil.getMessageID(d1.Rows[0]["companyID"].ToString(), "OPENTM410481462"), "充值成功通知", trxamtY.ToString(), dd.Rows[0]["AvailableMoney"].ToString(), "充值时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                            TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(d1.Rows[0]["companyID"].ToString()), data);
                            //插入记录
                            Util.insertNotice(dd.Rows[0]["id"].ToString(), "充值成功通知", "您于" + DateTime.Now.ToString("yyyy/MM/dd HH:mm") + "充值金额:" + trxamtY + ";到账金额:" + dt.Rows[0]["dzMoney"].ToString(), "");
                            Util.moneyChange(dd.Rows[0]["id"].ToString(), trxamtY.ToString(), dd.Rows[0]["AvailableMoney"].ToString(), "会员充值", "1", "");
                            Util.moneyChange(dd.Rows[0]["id"].ToString(), trxamtY.ToString(), dd.Rows[0]["point"].ToString(), "积分变动", "5", "");
                        }
                    }
                }
                else
                {
                    Response.Write("error");
                    return;
                }
            }
            else
            {
                Response.Write("error");
                return;
            }
        }
Ejemplo n.º 13
0
        public static string save(string memberID, string yzm, string newpwd, string companyID)
        {
            string    sql = "select * from asm_member where id=" + memberID + "";
            DataTable dt  = DbHelperSQL.Query(sql).Tables[0];

            if (dt.Rows.Count <= 0)
            {
                return("2");
            }
            string update = "update asm_member set pwd='" + newpwd + "' where id=" + memberID;
            int    a      = DbHelperSQL.ExecuteSql(update);

            if (a > 0)
            {
                try
                {
                    wxHelper wx   = new wxHelper(companyID);
                    string   data = TemplateMessage.modify_pwd(dt.Rows[0]["openID"].ToString(), OperUtil.getMessageID(dt.Rows[0]["companyID"].ToString(), "OPENTM406259604"), " 尊敬的会员,您通过手机端修改了【交易密码】", "会员昵称:" + dt.Rows[0]["nickname"].ToString(), "会员姓名:" + dt.Rows[0]["name"].ToString(), "重置密码:1006201");
                    TemplateMessage.SendTemplateMsg(wx.IsExistAccess_Token(companyID), data);
                }
                catch {
                }
                return("1");
            }
            else
            {
                return("4");
            }
        }