예제 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_ucard_users GetStoreUserInfo(string oepnid, int sid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,wid,sid,openid,cardNo,pwd,degreeId,sex,birthday,wxName,realName,age,qq,regTime,regIp,telphone,mobile,email,addr,endDate,ttScore,qdScore,consumeScore,consumeMoney from wx_ucard_users ");
            strSql.Append(" where sid=@sid and openid=@openid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sid",    SqlDbType.Int,     4),
                new SqlParameter("@openid", SqlDbType.VarChar, 100)
            };
            parameters[0].Value = sid;
            parameters[1].Value = oepnid;
            MxWeiXinPF.Model.wx_ucard_users model = new MxWeiXinPF.Model.wx_ucard_users();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_ucard_users DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_ucard_users model=new MxWeiXinPF.Model.wx_ucard_users();
     if (row != null)
     {
         if(row["id"]!=null && row["id"].ToString()!="")
         {
             model.id=int.Parse(row["id"].ToString());
         }
         if(row["wid"]!=null && row["wid"].ToString()!="")
         {
             model.wid=int.Parse(row["wid"].ToString());
         }
         if(row["sid"]!=null && row["sid"].ToString()!="")
         {
             model.sid=int.Parse(row["sid"].ToString());
         }
         if(row["openid"]!=null)
         {
             model.openid=row["openid"].ToString();
         }
         if(row["cardNo"]!=null)
         {
             model.cardNo=row["cardNo"].ToString();
         }
         if(row["pwd"]!=null)
         {
             model.pwd=row["pwd"].ToString();
         }
         if(row["degreeId"]!=null && row["degreeId"].ToString()!="")
         {
             model.degreeId=int.Parse(row["degreeId"].ToString());
         }
         if(row["sex"]!=null && row["sex"].ToString()!="")
         {
             model.sex=int.Parse(row["sex"].ToString());
         }
         if(row["birthday"]!=null && row["birthday"].ToString()!="")
         {
             model.birthday=DateTime.Parse(row["birthday"].ToString());
         }
         if(row["wxName"]!=null)
         {
             model.wxName=row["wxName"].ToString();
         }
         if(row["realName"]!=null)
         {
             model.realName=row["realName"].ToString();
         }
         if(row["age"]!=null && row["age"].ToString()!="")
         {
             model.age=int.Parse(row["age"].ToString());
         }
         if(row["qq"]!=null)
         {
             model.qq=row["qq"].ToString();
         }
         if(row["regTime"]!=null && row["regTime"].ToString()!="")
         {
             model.regTime=DateTime.Parse(row["regTime"].ToString());
         }
         if(row["regIp"]!=null)
         {
             model.regIp=row["regIp"].ToString();
         }
         if(row["telphone"]!=null)
         {
             model.telphone=row["telphone"].ToString();
         }
         if(row["mobile"]!=null)
         {
             model.mobile=row["mobile"].ToString();
         }
         if(row["email"]!=null)
         {
             model.email=row["email"].ToString();
         }
         if(row["addr"]!=null)
         {
             model.addr=row["addr"].ToString();
         }
         if(row["endDate"]!=null && row["endDate"].ToString()!="")
         {
             model.endDate=DateTime.Parse(row["endDate"].ToString());
         }
         if(row["ttScore"]!=null && row["ttScore"].ToString()!="")
         {
             model.ttScore=int.Parse(row["ttScore"].ToString());
         }
         if(row["qdScore"]!=null && row["qdScore"].ToString()!="")
         {
             model.qdScore=int.Parse(row["qdScore"].ToString());
         }
         if(row["consumeScore"]!=null && row["consumeScore"].ToString()!="")
         {
             model.consumeScore=int.Parse(row["consumeScore"].ToString());
         }
         if(row["consumeMoney"]!=null && row["consumeMoney"].ToString()!="")
         {
             model.consumeMoney=decimal.Parse(row["consumeMoney"].ToString());
         }
     }
     return model;
 }
예제 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_ucard_users GetStoreUserInfo(string oepnid, int sid)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select  top 1 id,wid,sid,openid,cardNo,pwd,degreeId,sex,birthday,wxName,realName,age,qq,regTime,regIp,telphone,mobile,email,addr,endDate,ttScore,qdScore,consumeScore,consumeMoney from wx_ucard_users ");
     strSql.Append(" where sid=@sid and openid=@openid");
     SqlParameter[] parameters = {
             new SqlParameter("@sid", SqlDbType.Int,4),
             new SqlParameter("@openid", SqlDbType.VarChar,100)
     };
     parameters[0].Value = sid;
     parameters[1].Value = oepnid;
     MxWeiXinPF.Model.wx_ucard_users model = new MxWeiXinPF.Model.wx_ucard_users();
     DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
     if (ds.Tables[0].Rows.Count > 0)
     {
         return DataRowToModel(ds.Tables[0].Rows[0]);
     }
     else
     {
         return null;
     }
 }
예제 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MxWeiXinPF.Model.wx_ucard_users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_ucard_users set ");
            strSql.Append("wid=@wid,");
            strSql.Append("sid=@sid,");
            strSql.Append("openid=@openid,");
            strSql.Append("cardNo=@cardNo,");
            strSql.Append("pwd=@pwd,");
            strSql.Append("degreeId=@degreeId,");
            strSql.Append("sex=@sex,");
            strSql.Append("birthday=@birthday,");
            strSql.Append("wxName=@wxName,");
            strSql.Append("realName=@realName,");
            strSql.Append("age=@age,");
            strSql.Append("qq=@qq,");
            strSql.Append("regTime=@regTime,");
            strSql.Append("regIp=@regIp,");
            strSql.Append("telphone=@telphone,");
            strSql.Append("mobile=@mobile,");
            strSql.Append("email=@email,");
            strSql.Append("addr=@addr,");
            strSql.Append("endDate=@endDate,");
            strSql.Append("ttScore=@ttScore,");
            strSql.Append("qdScore=@qdScore,");
            strSql.Append("consumeScore=@consumeScore,");
            strSql.Append("consumeMoney=@consumeMoney");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",          SqlDbType.Int,         4),
                new SqlParameter("@sid",          SqlDbType.Int,         4),
                new SqlParameter("@openid",       SqlDbType.VarChar,   100),
                new SqlParameter("@cardNo",       SqlDbType.VarChar,    50),
                new SqlParameter("@pwd",          SqlDbType.VarChar,   100),
                new SqlParameter("@degreeId",     SqlDbType.Int,         4),
                new SqlParameter("@sex",          SqlDbType.Int,         4),
                new SqlParameter("@birthday",     SqlDbType.DateTime),
                new SqlParameter("@wxName",       SqlDbType.VarChar,   100),
                new SqlParameter("@realName",     SqlDbType.VarChar,    50),
                new SqlParameter("@age",          SqlDbType.Int,         4),
                new SqlParameter("@qq",           SqlDbType.VarChar,    20),
                new SqlParameter("@regTime",      SqlDbType.DateTime),
                new SqlParameter("@regIp",        SqlDbType.VarChar,    20),
                new SqlParameter("@telphone",     SqlDbType.VarChar,    50),
                new SqlParameter("@mobile",       SqlDbType.VarChar,    20),
                new SqlParameter("@email",        SqlDbType.VarChar,   100),
                new SqlParameter("@addr",         SqlDbType.VarChar,   300),
                new SqlParameter("@endDate",      SqlDbType.DateTime),
                new SqlParameter("@ttScore",      SqlDbType.Int,         4),
                new SqlParameter("@qdScore",      SqlDbType.Int,         4),
                new SqlParameter("@consumeScore", SqlDbType.Int,         4),
                new SqlParameter("@consumeMoney", SqlDbType.Float,       8),
                new SqlParameter("@id",           SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.wid;
            parameters[1].Value  = model.sid;
            parameters[2].Value  = model.openid;
            parameters[3].Value  = model.cardNo;
            parameters[4].Value  = model.pwd;
            parameters[5].Value  = model.degreeId;
            parameters[6].Value  = model.sex;
            parameters[7].Value  = model.birthday;
            parameters[8].Value  = model.wxName;
            parameters[9].Value  = model.realName;
            parameters[10].Value = model.age;
            parameters[11].Value = model.qq;
            parameters[12].Value = model.regTime;
            parameters[13].Value = model.regIp;
            parameters[14].Value = model.telphone;
            parameters[15].Value = model.mobile;
            parameters[16].Value = model.email;
            parameters[17].Value = model.addr;
            parameters[18].Value = model.endDate;

            parameters[19].Value = model.ttScore;
            parameters[20].Value = model.qdScore;
            parameters[21].Value = model.consumeScore;
            parameters[22].Value = model.consumeMoney;
            parameters[23].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MxWeiXinPF.Model.wx_ucard_users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_ucard_users(");
            strSql.Append("wid,sid,openid,cardNo,pwd,degreeId,sex,birthday,wxName,realName,age,qq,regTime,regIp,telphone,mobile,email,addr,endDate,ttScore,qdScore,consumeScore,consumeMoney)");
            strSql.Append(" values (");
            strSql.Append("@wid,@sid,@openid,dbo.ufn_ucard_maxCardNo(),@pwd,@degreeId,@sex,@birthday,@wxName,@realName,@age,@qq,@regTime,@regIp,@telphone,@mobile,@email,@addr,@endDate,@ttScore,@qdScore,@consumeScore,@consumeMoney)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",          SqlDbType.Int,         4),
                new SqlParameter("@sid",          SqlDbType.Int,         4),
                new SqlParameter("@openid",       SqlDbType.VarChar,   100),
                //new SqlParameter("@cardNo", SqlDbType.VarChar,50),
                new SqlParameter("@pwd",          SqlDbType.VarChar,   100),
                new SqlParameter("@degreeId",     SqlDbType.Int,         4),
                new SqlParameter("@sex",          SqlDbType.Int,         4),
                new SqlParameter("@birthday",     SqlDbType.DateTime),
                new SqlParameter("@wxName",       SqlDbType.VarChar,   100),
                new SqlParameter("@realName",     SqlDbType.VarChar,    50),
                new SqlParameter("@age",          SqlDbType.Int,         4),
                new SqlParameter("@qq",           SqlDbType.VarChar,    20),
                new SqlParameter("@regTime",      SqlDbType.DateTime),
                new SqlParameter("@regIp",        SqlDbType.VarChar,    20),
                new SqlParameter("@telphone",     SqlDbType.VarChar,    50),
                new SqlParameter("@mobile",       SqlDbType.VarChar,    20),
                new SqlParameter("@email",        SqlDbType.VarChar,   100),
                new SqlParameter("@addr",         SqlDbType.VarChar,   300),
                new SqlParameter("@endDate",      SqlDbType.DateTime),
                new SqlParameter("@ttScore",      SqlDbType.Int,         4),
                new SqlParameter("@qdScore",      SqlDbType.Int,         4),
                new SqlParameter("@consumeScore", SqlDbType.Int,         4),
                new SqlParameter("@consumeMoney", SqlDbType.Float, 8)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.sid;
            parameters[2].Value = model.openid;
            // parameters[3].Value = model.cardNo;
            parameters[3].Value  = model.pwd;
            parameters[4].Value  = model.degreeId;
            parameters[5].Value  = model.sex;
            parameters[6].Value  = model.birthday;
            parameters[7].Value  = model.wxName;
            parameters[8].Value  = model.realName;
            parameters[9].Value  = model.age;
            parameters[10].Value = model.qq;
            parameters[11].Value = model.regTime;
            parameters[12].Value = model.regIp;
            parameters[13].Value = model.telphone;
            parameters[14].Value = model.mobile;
            parameters[15].Value = model.email;
            parameters[16].Value = model.addr;
            parameters[17].Value = model.endDate;
            parameters[18].Value = model.ttScore;
            parameters[19].Value = model.qdScore;
            parameters[20].Value = model.consumeScore;
            parameters[21].Value = model.consumeMoney;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_ucard_users DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_ucard_users model = new MxWeiXinPF.Model.wx_ucard_users();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["wid"] != null && row["wid"].ToString() != "")
         {
             model.wid = int.Parse(row["wid"].ToString());
         }
         if (row["sid"] != null && row["sid"].ToString() != "")
         {
             model.sid = int.Parse(row["sid"].ToString());
         }
         if (row["openid"] != null)
         {
             model.openid = row["openid"].ToString();
         }
         if (row["cardNo"] != null)
         {
             model.cardNo = row["cardNo"].ToString();
         }
         if (row["pwd"] != null)
         {
             model.pwd = row["pwd"].ToString();
         }
         if (row["degreeId"] != null && row["degreeId"].ToString() != "")
         {
             model.degreeId = int.Parse(row["degreeId"].ToString());
         }
         if (row["sex"] != null && row["sex"].ToString() != "")
         {
             model.sex = int.Parse(row["sex"].ToString());
         }
         if (row["birthday"] != null && row["birthday"].ToString() != "")
         {
             model.birthday = DateTime.Parse(row["birthday"].ToString());
         }
         if (row["wxName"] != null)
         {
             model.wxName = row["wxName"].ToString();
         }
         if (row["realName"] != null)
         {
             model.realName = row["realName"].ToString();
         }
         if (row["age"] != null && row["age"].ToString() != "")
         {
             model.age = int.Parse(row["age"].ToString());
         }
         if (row["qq"] != null)
         {
             model.qq = row["qq"].ToString();
         }
         if (row["regTime"] != null && row["regTime"].ToString() != "")
         {
             model.regTime = DateTime.Parse(row["regTime"].ToString());
         }
         if (row["regIp"] != null)
         {
             model.regIp = row["regIp"].ToString();
         }
         if (row["telphone"] != null)
         {
             model.telphone = row["telphone"].ToString();
         }
         if (row["mobile"] != null)
         {
             model.mobile = row["mobile"].ToString();
         }
         if (row["email"] != null)
         {
             model.email = row["email"].ToString();
         }
         if (row["addr"] != null)
         {
             model.addr = row["addr"].ToString();
         }
         if (row["endDate"] != null && row["endDate"].ToString() != "")
         {
             model.endDate = DateTime.Parse(row["endDate"].ToString());
         }
         if (row["ttScore"] != null && row["ttScore"].ToString() != "")
         {
             model.ttScore = int.Parse(row["ttScore"].ToString());
         }
         if (row["qdScore"] != null && row["qdScore"].ToString() != "")
         {
             model.qdScore = int.Parse(row["qdScore"].ToString());
         }
         if (row["consumeScore"] != null && row["consumeScore"].ToString() != "")
         {
             model.consumeScore = int.Parse(row["consumeScore"].ToString());
         }
         if (row["consumeMoney"] != null && row["consumeMoney"].ToString() != "")
         {
             model.consumeMoney = decimal.Parse(row["consumeMoney"].ToString());
         }
     }
     return(model);
 }
예제 #7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            string _action = MyCommFun.QueryString("myact");
            string openid  = MyCommFun.RequestOpenid(); //得到微信用户的openid
            Dictionary <string, string> jsonDict = new Dictionary <string, string>();
            int sid = MyCommFun.RequestInt("sid");
            int uid = 0;

            BLL.wx_ucard_store               storeBll = new BLL.wx_ucard_store();
            BLL.wx_ucard_users_consumeinfo   conBll   = new BLL.wx_ucard_users_consumeinfo();
            BLL.wx_ucard_score               scoreBll = new BLL.wx_ucard_score();
            BLL.wx_ucard_users               userBll  = new BLL.wx_ucard_users();
            Model.wx_ucard_users_consumeinfo consume  = new Model.wx_ucard_users_consumeinfo();
            Model.wx_ucard_score             score    = new Model.wx_ucard_score();
            Model.wx_ucard_store             store    = storeBll.GetModel(sid);
            if (store == null)
            {
                jsonDict.Add("ret", "err");
                jsonDict.Add("msg", "店铺不存在");
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                return;
            }

            if (_action == "userreg")
            {
                #region //用户第一次领取卡
                jsonDict = new Dictionary <string, string>();

                if (sid == 0)
                {
                    jsonDict.Add("ret", "error");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                string tel      = MyCommFun.QueryString("tel");
                string realName = MyCommFun.QueryString("truename");

                MxWeiXinPF.Model.wx_ucard_users user = userBll.GetStoreUserInfo(openid, sid);
                if (user == null)
                { //第一次添加
                    user              = new Model.wx_ucard_users();
                    user.mobile       = tel;
                    user.realName     = realName;
                    user.regTime      = DateTime.Now;
                    user.sid          = sid;
                    user.openid       = openid;
                    user.ttScore      = 0;
                    user.consumeScore = 0;
                    user.qdScore      = 0;
                    user.consumeMoney = 0;
                    user.regIp        = MXRequest.GetIP();
                    int ret = userBll.Add(user);
                    if (ret > 0)
                    {
                        jsonDict.Add("ret", "succ");
                        context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    }
                    else
                    {
                        jsonDict.Add("ret", "err");
                        context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    }
                }
                else
                {
                    user.mobile   = tel;
                    user.realName = realName;
                    user.regTime  = DateTime.Now;
                    user.sid      = sid;
                    user.openid   = openid;
                    user.regIp    = MXRequest.GetIP();
                    bool ret = userBll.Update(user);
                    if (ret)
                    {
                        jsonDict.Add("ret", "succ");
                        context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    }
                    else
                    {
                        jsonDict.Add("ret", "err");
                        context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    }
                }

                context.Response.End();
                #endregion
            }
            else if (_action == "qiandao")
            {
                #region 签到
                jsonDict = new Dictionary <string, string>();
                sid      = MyCommFun.RequestInt("sid");
                uid      = MyCommFun.RequestInt("uid");
                if (sid == 0 || uid == 0)
                {
                    jsonDict.Add("ret", "error");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }

                bool hasqd    = conBll.hasDayQD(sid, uid, DateTime.Now);
                int  retScore = 0;
                if (!hasqd)
                {
                    //新增
                    //取签到积分策略
                    score = scoreBll.GetStoreModel(sid);
                    if (score != null)
                    {
                        //判断是否6天连续签到,并且6天内没有给额外的奖励

                        DateTime day6before = DateTime.Now.AddDays(-6);

                        int record = conBll.GetRecordCount("sId=" + sid + " and uid=" + uid + " and moduleType='签到' and addTime>='" + day6before.ToShortDateString() + "' and addTime<'" + DateTime.Now.ToShortDateString() + "' and  moduleActionId=6 ");

                        if (record >= 5)
                        {
                            consume                  = new Model.wx_ucard_users_consumeinfo();
                            consume.sId              = sid;
                            consume.uid              = uid;
                            consume.moduleType       = "签到";
                            consume.moduleActionName = "连续6天签到奖励";
                            consume.moduleActionId   = 6;
                            consume.score            = MyCommFun.Obj2Int(score.qiandao6Score) + score.qiandaoScore.Value;
                            conBll.AddJiFen(consume, 0);
                            retScore = MyCommFun.Obj2Int(score.qiandao6Score) + score.qiandaoScore.Value;
                        }
                        else
                        {
                            consume            = new Model.wx_ucard_users_consumeinfo();
                            consume.sId        = sid;
                            consume.uid        = uid;
                            consume.moduleType = "签到";
                            consume.score      = score.qiandaoScore.Value;
                            conBll.AddJiFen(consume, 0);
                            retScore = score.qiandaoScore.Value;
                        }
                    }
                }

                jsonDict.Add("ret", "succ");
                jsonDict.Add("msg", "+" + retScore + "分,明天继续");
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));

                #endregion
            }
            else if (_action == "tequan")
            {
                #region  //消费: 特权 ,注意,只有在新增这个的时候记录user表总积分,修改的时候 对user表的总积分和金额先减后加

                jsonDict = new Dictionary <string, string>();
                sid      = MyCommFun.RequestInt("sid"); //店铺id
                uid      = MyCommFun.RequestInt("uid"); //用户id
                string sn    = MyCommFun.QueryString("sncode");
                string pwd   = MyCommFun.QueryString("parssword");
                float  money = MyCommFun.RequestFloat("money", 0);
                int    pid   = MyCommFun.RequestInt("pid");   //特权主键id
                string type  = MyCommFun.QueryString("type"); //tequan:特权
                if (sid == 0 || uid == 0 || pid == 0)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "error");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                if (pwd != store.consumePwd)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "密码错误");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                int ssid = userBll.ExistsStoreAndUser(uid);
                if (ssid == 0 || sid != ssid)
                {  //验证,用户存在,店铺存在,并且用户属于这个店铺
                    return;
                }
                BLL.wx_ucard_privileges   privBll    = new BLL.wx_ucard_privileges();
                Model.wx_ucard_privileges privileges = privBll.GetModel(pid);
                if (privileges == null)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "特权不存在");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }

                //积分策略
                score = scoreBll.GetStoreModel(sid);
                int avgScore = score.consumeMoneyScore.Value / score.consumeMoney.Value;
                //1先添加消费明细,和修改用户的总积分和总消费金额
                //IList<Model.wx_ucard_users_consumeinfo> conlist = conBll.GetModelList("moduleType='特权' and moduleActionId=" + privileges.id + " and sid=" + sid + " and uid=" + uid);
                //if (conlist == null || conlist.Count <= 0 || conlist[0] == null)
                //{
                //新增
                consume = new Model.wx_ucard_users_consumeinfo();
                consume.moduleActionId   = 10;
                consume.moduleType       = "特权";
                consume.moduleActionId   = privileges.id;
                consume.moduleActionName = privileges.pName;
                consume.sId          = sid;
                consume.uid          = uid;
                consume.consumeMoney = (decimal)money;
                consume.addTime      = DateTime.Now;
                consume.sn           = sn;
                consume.pwd          = pwd;
                consume.cMoneyType   = 2;
                consume.score        = (int)(avgScore * money);
                consume.cScoreType   = 1;
                conBll.Add(consume, true);

                //}
                //else
                //{
                //    //修改
                //    consume = conlist[0];
                //    decimal oldMoney = MyCommFun.Obj2Decimal(consume.consumeMoney, 0);
                //    int oldScore = MyCommFun.Obj2Int(consume.score);


                //    consume.moduleActionName = privileges.pName;
                //    consume.consumeMoney = (decimal)money;
                //    consume.sn = sn;
                //    consume.pwd = pwd;
                //    consume.cMoneyType = 2;
                //    consume.score = (int)(avgScore * money);
                //    conBll.UpdateInfoAndUserTT(consume, oldMoney, oldScore);
                //}
                jsonDict.Add("ret", "succ");
                jsonDict.Add("msg", "获得" + consume.score.Value + "积分 ");
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));

                #endregion
            }
            else if (_action == "lq_yhq")
            {
                #region 领取优惠券

                jsonDict = new Dictionary <string, string>();
                sid      = MyCommFun.RequestInt("sid"); //店铺id
                uid      = MyCommFun.RequestInt("uid"); //用户id
                string sn       = MyCommFun.QueryString("sncode");
                string pwd      = MyCommFun.QueryString("parssword");
                float  money    = MyCommFun.RequestFloat("money", 0);
                int    ticketId = MyCommFun.RequestInt("cid");//优惠券主键id

                if (sid == 0 || uid == 0 || ticketId == 0)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "error");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                if (pwd != store.consumePwd)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "密码错误");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                int ssid = userBll.ExistsStoreAndUser(uid);
                if (ssid == 0 || sid != ssid)
                {  //验证,用户存在,店铺存在,并且用户属于这个店铺
                    return;
                }
                BLL.wx_ucard_ticket   ticketBll = new BLL.wx_ucard_ticket();
                Model.wx_ucard_ticket ticket    = ticketBll.GetModel(ticketId);
                if (ticket == null)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "优惠券不存在");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                int syTimes = ticketBll.getsyTimesByTicket(uid, ticketId);
                if (syTimes <= 0)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "已没有使用次数");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }

                //积分策略
                score = scoreBll.GetStoreModel(sid);
                int avgScore = score.consumeMoneyScore.Value / score.consumeMoney.Value;
                //1先添加消费明细,和修改用户的总积分和总消费金额

                //新增
                consume = new Model.wx_ucard_users_consumeinfo();
                consume.moduleActionId   = 10;
                consume.moduleType       = "优惠券";
                consume.moduleActionId   = ticket.id;
                consume.moduleActionName = ticket.tName;
                consume.sId          = sid;
                consume.uid          = uid;
                consume.consumeMoney = (decimal)money;
                consume.addTime      = DateTime.Now;
                consume.sn           = sn;
                consume.pwd          = pwd;
                consume.cMoneyType   = 2;
                consume.score        = (int)(avgScore * money);
                consume.cScoreType   = 1;
                conBll.Add(consume, true);
                syTimes -= 1;

                jsonDict.Add("ret", "succ");
                jsonDict.Add("msg", "获得" + consume.score.Value + "积分 ");
                jsonDict.Add("sy", syTimes.ToString());
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));


                #endregion
            }
            else if (_action == "gift")
            {
                #region 兑换礼品券

                jsonDict = new Dictionary <string, string>();
                sid      = MyCommFun.RequestInt("sid"); //店铺id
                uid      = MyCommFun.RequestInt("uid"); //用户id
                string sn     = MyCommFun.QueryString("sncode");
                string pwd    = MyCommFun.QueryString("parssword");
                float  money  = MyCommFun.RequestFloat("money", 0);
                int    giftId = MyCommFun.RequestInt("gid");//礼品主键id

                if (sid == 0 || uid == 0 || giftId == 0)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "error");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                if (pwd != store.consumePwd)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "密码错误");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                int ssid = userBll.ExistsStoreAndUser(uid);
                if (ssid == 0 || sid != ssid)
                {  //验证,用户存在,店铺存在,并且用户属于这个店铺
                    return;
                }
                BLL.wx_ucard_gift   giftBll = new BLL.wx_ucard_gift();
                Model.wx_ucard_gift gift    = giftBll.GetModel(giftId);
                if (gift == null)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "优惠券不存在");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }
                int userTTScore = userBll.GetUserJiFen(uid);
                if (userTTScore < gift.score.Value)
                {
                    jsonDict.Add("ret", "error");
                    jsonDict.Add("msg", "积分不够");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }

                //1先添加消费明细,和修改用户的总积分和总消费金额

                //新增
                consume = new Model.wx_ucard_users_consumeinfo();
                consume.moduleActionId   = 10;
                consume.moduleType       = "礼品券";
                consume.moduleActionId   = gift.id;
                consume.moduleActionName = gift.gName;
                consume.sId        = sid;
                consume.uid        = uid;
                consume.addTime    = DateTime.Now;
                consume.sn         = sn;
                consume.pwd        = pwd;
                consume.score      = -gift.score.Value;
                consume.cScoreType = 1;
                conBll.Add(consume, false);

                jsonDict.Add("ret", "succ");
                jsonDict.Add("msg", "成功兑换礼品扣除 " + gift.score.Value + " 积分 ");

                context.Response.Write(MyCommFun.getJsonStr(jsonDict));


                #endregion
            }
        }