コード例 #1
0
        public ActionResult GetCityStoreUserPhone()
        {
            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";
            string appId  = Context.GetRequest("appId", string.Empty);
            int    userId = Context.GetRequestInt("userId", 0);

            if (string.IsNullOrEmpty(appId) || userId <= 0)
            {
                returnObj.Msg = "参数错误";
                return(Json(returnObj));
            }

            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

            if (r == null)
            {
                returnObj.Msg = "小程序未授权";
                return(Json(returnObj));
            }
            CityStoreUser model = CityStoreUserBLL.SingleModel.getCity_StoreUser(r.Id, userId);
            string        phone = string.Empty;

            if (model != null)
            {
                phone = model.phone;
            }
            returnObj.isok    = true;
            returnObj.Msg     = "操作成功";
            returnObj.dataObj = new { phone = phone };
            return(Json(returnObj));
        }
コード例 #2
0
        public ActionResult SaveCityStoreUser()
        {
            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";
            string appId  = Context.GetRequest("appId", string.Empty);
            int    userId = Context.GetRequestInt("userId", 0);

            if (string.IsNullOrEmpty(appId) || userId <= 0)
            {
                returnObj.Msg = "参数错误";
                return(Json(returnObj));
            }

            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

            if (r == null)
            {
                returnObj.Msg = "小程序未授权";
                return(Json(returnObj));
            }
            CityStoreUser model            = CityStoreUserBLL.SingleModel.getCity_StoreUser(r.Id, userId);
            int           city_storeUserId = 0;

            if (model == null)
            {
                //新增一条记录
                city_storeUserId = Convert.ToInt32(CityStoreUserBLL.SingleModel.Add(new CityStoreUser()
                {
                    aid        = r.Id,
                    userId     = userId,
                    addTime    = DateTime.Now,
                    updateTime = DateTime.Now,
                    state      = 0
                }));
                if (city_storeUserId <= 0)
                {
                    returnObj.Msg = "操作异常";
                    return(Json(returnObj));
                }
            }
            else
            {
                city_storeUserId = model.Id;
            }

            returnObj.isok    = true;
            returnObj.Msg     = "操作成功";
            returnObj.dataObj = new { id = city_storeUserId };
            return(Json(returnObj));
        }
コード例 #3
0
        public string saveMsg(string jsondata, int ordertype, int paytype, int aid, ref CityMorders order, int userId)
        {
            if (string.IsNullOrEmpty(jsondata))
            {
                return("json参数错误");
            }

            SaveCityMsgModel saveCityMsgModelJson = JsonConvert.DeserializeObject <SaveCityMsgModel>(jsondata);

            if (saveCityMsgModelJson == null)
            {
                return("null参数错误");
            }

            double lng = 0.00;
            double lat = 0.00;

            //校验手机号码
            //if (!Regex.IsMatch(saveCityMsgModelJson.phone, @"\d")|| saveCityMsgModelJson.phone.Length>11)
            //    return "联系号码不符合";

            if (string.IsNullOrEmpty(saveCityMsgModelJson.location))
            {
                return("请填写地址");
            }

            if (string.IsNullOrEmpty(saveCityMsgModelJson.msgDetail))
            {
                return("发布信息不能为空");
            }

            if (!double.TryParse(saveCityMsgModelJson.lng, out lng) || !double.TryParse(saveCityMsgModelJson.lat, out lat))
            {
                return("地址坐标错误");
            }

            if (saveCityMsgModelJson.msgType <= 0)
            {
                return("请选择信息类别");
            }

            CityStoreBanner storebanner = CityStoreBannerBLL.SingleModel.getModelByaid(aid);

            if (storebanner == null)
            {
                return("商家配置异常");
            }


            CityStoreUser cityStoreUser = CityStoreUserBLL.SingleModel.getCity_StoreUser(aid, userId);

            if (cityStoreUser != null && cityStoreUser.state != 0)
            {
                if (string.IsNullOrEmpty(storebanner.KeFuPhone))
                {
                    return("账户异常");
                }
                else
                {
                    return($"账户异常,请拨打电话({storebanner.KeFuPhone})联系客服");
                }
            }

            CityMsg city_Msg = new CityMsg();

            city_Msg.addTime   = DateTime.Now;
            city_Msg.aid       = aid;
            city_Msg.lat       = saveCityMsgModelJson.lat;
            city_Msg.lng       = saveCityMsgModelJson.lng;
            city_Msg.location  = saveCityMsgModelJson.location;
            city_Msg.msgDetail = HttpUtility.HtmlEncode(saveCityMsgModelJson.msgDetail);

            city_Msg.msgTypeId = saveCityMsgModelJson.msgType;
            city_Msg.phone     = saveCityMsgModelJson.phone;
            city_Msg.userId    = userId;
            city_Msg.imgs      = saveCityMsgModelJson.imgs;



            switch (storebanner.ReviewSetting)
            {
            case 0:    //不需要审核
                if (saveCityMsgModelJson.isTop == 0)
                {
                    //不置顶消息
                    city_Msg.state  = 1;
                    city_Msg.Review = 0;
                }
                else
                {
                    city_Msg.state  = 0;   //支付回成功调后再变更1
                    city_Msg.Review = 0;
                }
                break;

            case 1:                  //先审核后发布
                city_Msg.state  = 0; //审核通过后变为1
                city_Msg.Review = 1; //审核通过后变为2  审核不通过变为-1
                break;

            case 2:    //先发布后审核
                if (saveCityMsgModelJson.isTop == 0)
                {
                    //不置顶消息
                    city_Msg.state  = 1;
                    city_Msg.Review = 1;    //审核通过后变为2  审核不通过变为-1
                }
                else
                {
                    city_Msg.state  = 0;   //支付回成功调后再变更为1
                    city_Msg.Review = 1;   //审核通过后变为2  审核不通过变为-1
                }
                break;
            }

            if (saveCityMsgModelJson.isTop == 0)
            {
                //表示不置顶的消息
                city_Msg.topDay       = 0;
                city_Msg.topCostPrice = 0;

                int msgId = Convert.ToInt32(base.Add(city_Msg));
                if (msgId <= 0)
                {
                    return("发布信息异常");
                }
                else
                {
                    return(string.Empty);
                }
            }
            else
            {
                //表示置顶消息 需要 生成微信订单,然后微信支付,支付成功后回调将状态变为1可用
                if (saveCityMsgModelJson.ruleId <= 0)
                {
                    return("请选择置顶时间");
                }

                CityStoreMsgRules _city_StoreMsgRules = CityStoreMsgRulesBLL.SingleModel.getCity_StoreMsgRules(aid, saveCityMsgModelJson.ruleId);
                if (_city_StoreMsgRules == null)
                {
                    return("非法操作(置顶时间有误)");
                }

                city_Msg.topDay       = _city_StoreMsgRules.exptimeday;
                city_Msg.topCostPrice = _city_StoreMsgRules.price;

                int msgId = Convert.ToInt32(base.Add(city_Msg));
                if (msgId <= 0)
                {
                    return("发布信息异常");
                }
                else
                {
                    order.Articleid    = _city_StoreMsgRules.Id;
                    order.CommentId    = msgId;
                    order.MinisnsId    = aid;
                    order.payment_free = city_Msg.topCostPrice;
                    order.ShowNote     = $"小程序同城发布消息付款{order.payment_free * 0.01}元";
                    return(string.Empty);
                }
            }
        }
コード例 #4
0
        public ActionResult saveUserPhone()
        {
            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";
            string appId          = Context.GetRequest("appId", string.Empty);
            string phone          = Context.GetRequest("phone", string.Empty);
            string submitAuthCode = Context.GetRequest("submitAuthCode", string.Empty);
            int    userId         = Context.GetRequestInt("userId", 0);
            int    actionType     = Context.GetRequestInt("actionType", 0);//默认为0 表示微信授权获取到号码提交过来保存号码 1表示短信验证码过来绑定号码

            if (string.IsNullOrEmpty(appId) || userId <= 0 || string.IsNullOrEmpty(phone))
            {
                returnObj.Msg = "参数错误";
                return(Json(returnObj));
            }
            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

            if (r == null)
            {
                returnObj.Msg = "小程序未授权";
                return(Json(returnObj));
            }

            phone = phone.Trim();
            //校验手机号码
            if (!Regex.IsMatch(phone, @"\d") || phone.Length > 11)
            {
                returnObj.Msg = "请填写合法的手机号码";
                return(Json(returnObj));
            }

            if (actionType == 1)
            {
                //表示短信验证码过来绑定号码 需要验证短信验证码是否正确
                string codeKey  = string.Format(CITY_BINDPHONE, phone);
                string authCode = RedisUtil.Get <string>(codeKey);//获取缓存里的验证码与提交过来的验证码对比
                if (string.IsNullOrEmpty(authCode))
                {
                    returnObj.Msg = "验证码失效,请重新获取";
                    return(Json(returnObj));
                }
                if (string.IsNullOrEmpty(submitAuthCode))
                {
                    returnObj.Msg = "验证码不能为空!";
                    return(Json(returnObj));
                }

                if (authCode != submitAuthCode)
                {
                    returnObj.Msg = "验证码错误";
                    return(Json(returnObj));
                }
            }

            CityStoreUser _city_StoreUser = CityStoreUserBLL.SingleModel.getCity_StoreUser(r.Id, userId);

            if (_city_StoreUser == null)
            {
                _city_StoreUser = new CityStoreUser();
                //新增一条
                _city_StoreUser.userId     = userId;
                _city_StoreUser.addTime    = DateTime.Now;
                _city_StoreUser.aid        = r.Id;
                _city_StoreUser.phone      = phone;
                _city_StoreUser.updateTime = DateTime.Now;
                int id = Convert.ToInt32(CityStoreUserBLL.SingleModel.Add(_city_StoreUser));
                if (id <= 0)
                {
                    returnObj.Msg = "绑定失败";
                    return(Json(returnObj));
                }

                returnObj.isok = true;
                returnObj.Msg  = "绑定成功";
                return(Json(returnObj));
            }
            else
            {
                //更新手机号码
                _city_StoreUser.phone      = phone;
                _city_StoreUser.updateTime = DateTime.Now;
                if (!CityStoreUserBLL.SingleModel.Update(_city_StoreUser, "phone,updateTime"))
                {
                    returnObj.Msg = "更新失败";
                    return(Json(returnObj));
                }

                returnObj.isok = true;
                returnObj.Msg  = "更新成功";
                return(Json(returnObj));
            }
        }