Пример #1
0
        public ActionResult PlatStoreDescriptionRichText(int id = 0)
        {
            //string token = AccessTokenContainer.GetAccessToken(AccessTokenContainer.GetFirstOrDefaultAppId());
            string token = WxHelper.GetToken(webview_appid, webview_appsecret, false);

            ViewBag.appid     = AccessTokenContainer.GetFirstOrDefaultAppId();
            ViewBag.ticket    = JsApiTicketContainer.GetJsApiTicket(JsApiTicketContainer.GetFirstOrDefaultAppId());
            ViewBag.timestamp = JSSDKHelper.GetTimestamp();
            ViewBag.nonceStr  = JSSDKHelper.GetNoncestr();
            ViewBag.signature = JSSDKHelper.GetSignature(ViewBag.ticket, ViewBag.nonceStr, ViewBag.timestamp, GetPageUrl());
            log4net.LogHelper.WriteInfo(this.GetType(), $"token={token};appid={ViewBag.appid};ticket={ViewBag.ticket};timestamp={ ViewBag.timestamp};nonceStr={ViewBag.nonceStr};signature={ViewBag.signature};pageUrl={GetPageUrl()}");

            if (id == 0)
            {
                // string temp = RedisUtil.Get<string>("temp_psd_description_0");
                ViewBag.description = "";//temp ?? "";
            }
            else
            {
                PlatStore platStore = PlatStoreBLL.SingleModel.GetModel(id);
                if (platStore == null || platStore.State == -1)
                {
                    ViewBag.description = "";
                    return(Content("店铺不存在或已删除"));
                }
                ViewBag.description = platStore.StoreDescription;
            }
            return(View());
        }
Пример #2
0
        // GET:
        public ActionResult Index()
        {
            int aid = Context.GetRequestInt("appId", 0);

            if (aid <= 0)
            {
                aid = Context.GetRequestInt("aid", 0);
            }
            PlatStore  store  = PlatStoreBLL.SingleModel.GetModelByAId(aid);
            PlatMyCard myCard = PlatMyCardBLL.SingleModel.GetModel(store.MyCardId);

            if (myCard == null)
            {
                return(Redirect("/base/PageError?type=2"));
            }
            PlatUserCash model = PlatUserCashBLL.SingleModel.GetModelByUserId(myCard.AId, myCard.UserId);

            if (model == null)
            {
                model            = new PlatUserCash();
                model.AddTime    = DateTime.Now;
                model.UpdateTime = DateTime.Now;
                model.UserId     = myCard.UserId;
                model.AId        = myCard.AId;
                model.Id         = Convert.ToInt32(PlatUserCashBLL.SingleModel.Add(model));
            }
            string nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            RedisUtil.Set <string>(string.Format(PlatStatisticalFlowBLL._redis_PlatVisiteTimeKey, aid), nowTime);
            return(View());
        }
Пример #3
0
        /// <summary>
        /// 平台上获取订单信息列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPlatOrderList()
        {
            returnObj = new Return_Msg_APP();
            int userId    = Context.GetRequestInt("userid", 0);
            int state     = Context.GetRequestInt("state", 0);
            int pageIndex = Context.GetRequestInt("pageindex", 1);
            int pageSize  = Context.GetRequestInt("pagesize", 10);

            if (userId <= 0)
            {
                returnObj.Msg = "用户ID不能为0";
                return(Json(returnObj));
            }
            C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(userId);

            if (userInfo == null)
            {
                returnObj.Msg = "找不到用户";
                return(Json(returnObj));
            }

            XcxAppAccountRelation xcxrelation = _xcxAppAccountRelationBLL.GetModelByAppid(userInfo.appId);

            if (xcxrelation == null)
            {
                returnObj.Msg = "无效模板";
                return(Json(returnObj));
            }

            string           userIds   = userId.ToString();
            List <PlatStore> storeList = PlatStoreBLL.SingleModel.GetXcxRelationAppids(xcxrelation.Id);

            if (storeList != null && storeList.Count > 0)
            {
                string            appids       = "'" + string.Join("','", storeList.Select(s => s.AppId)) + "'";
                List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByAppIds(userInfo.TelePhone, appids);
                if (userInfoList != null && userInfoList.Count > 0)
                {
                    userIds += "," + string.Join(",", userInfoList.Select(s => s.Id));
                }
            }

            int count = 0;
            List <PlatChildGoodsOrder> list = PlatChildGoodsOrderBLL.SingleModel.GetList_Api(state, 0, 0, pageSize, pageIndex, ref count, 0, 0, 0, userIds);

            if (count > 0)
            {
                string           storeIds  = string.Join(",", list.Select(s => s.StoreId).Distinct());
                List <PlatStore> allStores = PlatStoreBLL.SingleModel.GetListByIds(storeIds);
                foreach (PlatChildGoodsOrder item in list)
                {
                    PlatStore storeModel = allStores?.FirstOrDefault(f => f.Id == item.StoreId);
                    item.StoreName = storeModel?.Name;
                }
            }

            returnObj.isok    = true;
            returnObj.dataObj = new { count = count, list = list };
            return(Json(returnObj));
        }
Пример #4
0
        /// <summary>
        /// 获取订单信息
        /// </summary>
        /// <returns></returns>
        public ActionResult GetOrderInfo()
        {
            returnObj = new Return_Msg_APP();
            int userId = Context.GetRequestInt("userid", 0);
            int id     = Context.GetRequestInt("id", 0);

            if (userId <= 0)
            {
                returnObj.Msg = "用户ID不能为0";
                return(Json(returnObj));
            }

            PlatChildGoodsOrder model = PlatChildGoodsOrderBLL.SingleModel.GetModel_Api(id);

            if (model != null)
            {
                PlatStore store = PlatStoreBLL.SingleModel.GetModel(model.StoreId);
                if (store != null)
                {
                    model.StorePhone = store.Phone;
                }
                model.DeliveryInfo = DeliveryFeedbackBLL.SingleModel.GetOrderFeed(orderId: model.Id, orderType: DeliveryOrderType.独立小程序订单商家发货);
            }

            returnObj.dataObj = model;
            returnObj.isok    = true;
            return(Json(returnObj));
        }
Пример #5
0
        public ActionResult Index()
        {
            int aid = Context.GetRequestInt("aid", 0);

            ViewBag.appId = aid;
            PlatStore  store  = PlatStoreBLL.SingleModel.GetModelByAId(aid);
            PlatMyCard myCard = PlatMyCardBLL.SingleModel.GetModel(store.MyCardId);

            if (myCard == null)
            {
                return(Redirect("/base/PageError?type=2"));
            }
            //用户提现账户
            PlatUserCash model = PlatUserCashBLL.SingleModel.GetModelByUserId(myCard.AId, myCard.UserId);

            if (model == null)
            {
                return(Redirect("/base/PageError?type=2"));
            }
            //平台提现设置
            PlatDrawConfig drawConfig = PlatDrawConfigBLL.SingleModel.GetModelByAId(myCard.AId);

            if (drawConfig == null)
            {
                drawConfig = new PlatDrawConfig();
            }
            model.Fee = drawConfig.Fee;
            if (string.IsNullOrEmpty(model.Name))
            {
                model.Name = "未绑定";
            }
            return(View(model));
        }
Пример #6
0
        /// <summary>
        /// 获取订单信息列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetOrderList()
        {
            returnObj = new Return_Msg_APP();
            int userId    = Context.GetRequestInt("userid", 0);
            int state     = Context.GetRequestInt("state", 0);
            int pageIndex = Context.GetRequestInt("pageindex", 1);
            int pageSize  = Context.GetRequestInt("pagesize", 10);

            if (userId <= 0)
            {
                returnObj.Msg = "用户ID不能为0";
                return(Json(returnObj));
            }
            C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(userId);

            if (userInfo == null)
            {
                returnObj.Msg = "找不到用户";
                return(Json(returnObj));
            }

            XcxAppAccountRelation xcxrelation = _xcxAppAccountRelationBLL.GetModelByAppid(userInfo.appId);

            if (xcxrelation == null)
            {
                returnObj.Msg = "无效模板";
                return(Json(returnObj));
            }

            PlatStore store = PlatStoreBLL.SingleModel.GetModelByAId(xcxrelation.Id);

            if (store == null)
            {
                returnObj.Msg = "无效店铺";
                return(Json(returnObj));
            }

            int platUserId = 0;
            XcxAppAccountRelation platXcxRelation = _xcxAppAccountRelationBLL.GetModel(store.BindPlatAid);

            if (platXcxRelation != null)
            {
                //平台上的用户ID
                List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByAppIds(userInfo.TelePhone, $"'{platXcxRelation.AppId}'");
                if (userInfoList != null && userInfoList.Count > 0)
                {
                    platUserId = userInfoList[0].Id;
                }
            }

            int count = 0;
            List <PlatChildGoodsOrder> list = PlatChildGoodsOrderBLL.SingleModel.GetList_Api(state, xcxrelation.Id, userId, pageSize, pageIndex, ref count, store.Id, store.BindPlatAid, platUserId);

            returnObj.isok    = true;
            returnObj.dataObj = new { count = count, list = list };
            return(Json(returnObj));
        }
Пример #7
0
        public PlatMyCard GetMyCardData(int cardid, int aid)
        {
            PlatMyCard model = base.GetModel(cardid);

            if (model == null)
            {
                return(new PlatMyCard());
            }


            PlatPostUserMsgCountViewMolde msgmodel = PlatPostUserBLL.SingleModel.GetCountViewModel(model.Id);

            if (msgmodel != null)
            {
                model.MsgCount = msgmodel.PostMsgCount;
            }

            model.ContentCount = PlatMsgCommentBLL.SingleModel.GetUserContentCount(model.UserId);
            model.MsgDzCount   = PlatUserFavoriteMsgBLL.SingleModel.GetMyMsgCount(model.UserId, (int)PointsActionType.点赞, (int)PointsDataType.帖子);
            PlatMsgviewFavoriteShare smodel = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(aid, model.Id, (int)PointsDataType.片);

            if (smodel != null)
            {
                model.FollowCount   = smodel.FollowCount;
                model.FavoriteCount = smodel.FavoriteCount;
                model.DzCount       = smodel.DzCount;
                model.ViewCount     = smodel.ViewCount;
                model.SiXinCount    = smodel.SiXinCount;
                model.NewData       = GetRedisCach(model.Id);
            }

            //行业
            PlatIndustry industrymodel = PlatIndustryBLL.SingleModel.GetModel(model.IndustryId);

            model.IndustryName = industrymodel?.Name;

            //店铺
            PlatStore store = PlatStoreBLL.SingleModel.GetModelBycardid(model.AId, model.Id);

            if (store != null)
            {
                smodel = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(aid, store.Id, (int)PointsDataType.店铺);
                if (smodel != null)
                {
                    model.StoreFavoriteCount = smodel.FavoriteCount;
                    model.StoreViewCount     = store.StorePV + store.StoreVirtualPV;
                    model.StoreVistorCount   = PlatUserFavoriteMsgBLL.SingleModel.GetUserMsgCount(model.AId, store.Id, (int)PointsActionType.过, (int)PointsDataType.店铺);
                }
            }

            return(model);
        }
Пример #8
0
        /// <summary>
        /// 获取平台独立小程序用户消费记录
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public int GetPlatChildGoodsVipPriceSum(int userId)
        {
            int        sum      = 0;
            C_UserInfo userinfo = C_UserInfoBLL.SingleModel.GetModel(userId);

            if (userinfo == null)
            {
                return(sum);
            }
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModelByAppid(userinfo.appId);

            if (xcxrelation == null)
            {
                return(sum);
            }
            PlatStore store = PlatStoreBLL.SingleModel.GetModelByAId(xcxrelation.Id);

            if (store == null)
            {
                return(sum);
            }
            xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(store.BindPlatAid);

            if (xcxrelation == null)
            {
                return(sum);
            }
            userinfo = C_UserInfoBLL.SingleModel.GetModelByTelephone_appid(userinfo.TelePhone, xcxrelation.AppId);
            int puserId = 0;

            if (userinfo != null)
            {
                puserId = userinfo.Id;
            }

            string sql    = $"select sum(buyprice) as count from PlatChildGoodsOrder where ((USERID = {userId} and templatetype ={(int)TmpType.小未平台子模版}) or (userid={puserId} and storeid={store.Id} and templatetype={(int)TmpType.小未平台})) and State = {(int)PlatChildOrderState.已完成}";//购物消费总额  已收货才确定计算为消费
            var    result = SqlMySql.ExecuteScalar(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, sql);

            if (DBNull.Value != result)
            {
                sum += Convert.ToInt32(result);
            }

            //sum += GetBargainAndGroupPriceSum(userid);
            sum += GetStoredvaluePaySum(userId);
            sum += GetEditSaveMoney(userId);
            return(sum);
        }
Пример #9
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            if (filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true))
            {
                return;
            }
            int aid      = Context.GetRequestInt("appId", 0);
            int fromPlat = Context.GetRequestInt("fromPlat", 0);

            if (aid <= 0)
            {
                aid = Context.GetRequestInt("aid", 0);
                if (aid <= 0)
                {
                    filterContext.Result = new RedirectResult("/base/PageError?type=5");
                    return;
                }
            }

            string AccountId  = Core.MiniApp.Utils.GetBuildCookieId("dz_UserCookieNew").ToString();
            Guid   _accountid = Guid.Empty;

            Guid.TryParse(AccountId, out _accountid);
            if (aid == 0 || _accountid == Guid.Empty)
            {
                filterContext.Result = new RedirectResult("/base/PageError?type=1");
                return;
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(aid, _accountid.ToString());

            if (xcxrelation == null)
            {
                filterContext.Result = new RedirectResult("/base/PageError?type=2");
                return;
            }
            if (fromPlat == 0)//表示直接从平台店铺列表添加店铺 没有主人的店铺
            {
                PlatStore store = PlatStoreBLL.SingleModel.GetModelByAId(aid);
                if (store == null)
                {
                    filterContext.Result = new RedirectResult("/base/PageError?type=2");
                    return;
                }
            }
        }
Пример #10
0
        /// <summary>
        /// 获取店铺产品类别配置 来进行样式的显示
        /// </summary>
        /// <returns></returns>
        public ActionResult GetGoodsCategoryLevel()
        {
            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";
            string appId = Context.GetRequest("appId", string.Empty);

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

            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

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

            PlatStore platStore = PlatStoreBLL.SingleModel.GetPlatStore(r.Id, 2);

            if (platStore == null)
            {
                returnObj.Msg = "店铺不存在";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }
            PlatStoreSwitchModel switchModel = new PlatStoreSwitchModel();
            int productCategoryLevel         = 1;

            if (!string.IsNullOrEmpty(platStore.SwitchConfig))
            {
                switchModel          = Newtonsoft.Json.JsonConvert.DeserializeObject <PlatStoreSwitchModel>(platStore.SwitchConfig);
                productCategoryLevel = switchModel.ProductCategoryLevel;
            }

            returnObj.dataObj = new { Level = productCategoryLevel };
            returnObj.isok    = true;
            returnObj.Msg     = "获取成功";
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
Пример #11
0
        /// <summary>
        /// 申请独立小程序
        /// </summary>
        /// <returns></returns>
        public ActionResult ApplyStoreApp()
        {
            returnObj = new Return_Msg_APP();
            int userid = Context.GetRequestInt("userid", 0);

            if (userid <= 0)
            {
                returnObj.Msg = "userid不能为0";
            }
            PlatMyCard mycard = PlatMyCardBLL.SingleModel.GetModelByUserId(userid);

            if (mycard == null)
            {
                returnObj.Msg = "名片已过期";
                return(Json(returnObj));
            }
            PlatStore store = PlatStoreBLL.SingleModel.GetModelBycardid(mycard.AId, mycard.Id);

            if (store == null)
            {
                returnObj.Msg = "店铺已过期";
                return(Json(returnObj));
            }

            PlatApplyApp model = new PlatApplyApp();

            model.AddTime      = DateTime.Now;
            model.BindAId      = mycard.AId;
            model.CustomerName = mycard.Name;
            model.MycardId     = mycard.Id;
            model.OpenState    = 0;
            model.StoreId      = store.Id;
            model.UpdateTime   = DateTime.Now;
            model.Id           = Convert.ToInt32(PlatApplyAppBLL.SingleModel.Add(model));
            returnObj.isok     = model.Id > 0;
            returnObj.Msg      = returnObj.isok ? "提交成功,正在审核中" : "提交失败";

            return(Json(returnObj));
        }
Пример #12
0
        /// <summary>
        /// 关闭或开启同步
        /// </summary>
        /// <returns></returns>
        public ActionResult SaveXcxState()
        {
            _returnData = new Return_Msg();
            int id    = Context.GetRequestInt("id", 0);
            int state = Context.GetRequestInt("state", 0);

            if (id <= 0)
            {
                _returnData.Msg = "参数错误";
                return(Json(_returnData));
            }

            PlatApplyApp model = PlatApplyAppBLL.SingleModel.GetModel(id);

            if (model == null)
            {
                _returnData.Msg = "数据过期,请刷新重试";
                return(Json(_returnData));
            }
            PlatStore store = PlatStoreBLL.SingleModel.GetModel(model.StoreId);

            if (store == null)
            {
                _returnData.Msg = "店铺数据过期,请刷新重试";
                return(Json(_returnData));
            }
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(store.Aid);

            if (xcxrelation == null)
            {
                _returnData.Msg = "店铺数据过期,请刷新重试";
                return(Json(_returnData));
            }
            xcxrelation.State = state;
            _returnData.isok  = XcxAppAccountRelationBLL.SingleModel.Update(xcxrelation, "state");
            _returnData.Msg   = _returnData.isok ? "保存成功" : "保存失败";

            return(Json(_returnData));
        }
Пример #13
0
        public ActionResult OpenDistribution(int aid = 0, int isOpen = 0)
        {
            Return_Msg            returnData  = new Return_Msg();
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxrelation == null)
            {
                returnData.Msg = "无效模板";
                return(Json(returnData));
            }
            PlatStore store = PlatStoreBLL.SingleModel.GetModelByAId(aid);

            if (store == null)
            {
                returnData.Msg = "无效店铺";
                return(Json(returnData));
            }
            PlatMyCard myCard = PlatMyCardBLL.SingleModel.GetModel(store.MyCardId);

            if (myCard == null)
            {
                returnData.Msg = "无效用户数据";
                return(Json(returnData));
            }
            PlatUserCash userCash = PlatUserCashBLL.SingleModel.GetModelByUserId(store.BindPlatAid, myCard.UserId);

            if (userCash == null)
            {
                returnData.Msg = "无效账号";
                return(Json(returnData));
            }
            userCash.IsOpenDistribution = isOpen;
            userCash.UpdateTime         = DateTime.Now;
            returnData.isok             = PlatUserCashBLL.SingleModel.Update(userCash, "IsOpenDistribution,UpdateTime");
            returnData.Msg = returnData.isok ? "保存成功" : "保存失败";

            return(Json(returnData));
        }
Пример #14
0
        public ActionResult SavePlatStoreDescriptionRichText(int id, string content)
        {
            if (id > 0)
            {
                PlatStore platStore = PlatStoreBLL.SingleModel.GetModel(id);
                if (platStore == null || platStore.State == -1)
                {
                    return(Json(new { isok = false, msg = "店铺不存在或已删除" }));
                }
                if (content.Trim() == "")
                {
                    return(Json(new { isok = false, msg = "店铺描述不能为空" }));
                }

                platStore.StoreDescription = content;
                if (PlatStoreBLL.SingleModel.Update(platStore, "StoreDescription"))
                {
                    return(Json(new { isok = true, msg = "保存成功!" }));
                }
                else
                {
                    return(Json(new { isok = false, msg = "保存失败!" }));
                }
            }
            else
            {
                //如果是新增的产品 没有id用一个缓存来保存
                if (RedisUtil.Set <string>("temp_psd_description_0", content))
                {
                    return(Json(new { isok = true, msg = "保存成功!" }));
                }
                else
                {
                    return(Json(new { isok = false, msg = "保存失败!" }));
                }
            }
        }
Пример #15
0
        /// <summary>
        /// 查看店铺详情
        /// </summary>
        /// <returns></returns>
        public ActionResult StoreDetail()
        {
            int appId           = Utility.IO.Context.GetRequestInt("aid", 0);
            int storeRelationId = Utility.IO.Context.GetRequestInt("storeRelationId", 0);

            if (appId <= 0)
            {
                return(View("PageError", new PlatReturnMsg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }

            PlatStoreRelation platStoreRelation = PlatStoreRelationBLL.SingleModel.GetModel(storeRelationId);

            if (platStoreRelation == null)
            {
                return(View("PageError", new PlatReturnMsg()
                {
                    Msg = "数据异常!", code = "404"
                }));
            }

            PlatStore platStore = PlatStoreBLL.SingleModel.GetModel(platStoreRelation.StoreId);

            if (platStore == null)
            {
                return(View("PageError", new PlatReturnMsg()
                {
                    Msg = "店铺不存在!", code = "404"
                }));
            }


            return(View(platStore));
        }
Пример #16
0
        /// <summary>
        /// 开通独立小程序
        /// </summary>
        /// <param name="platApplyAppModel"></param>
        /// <param name="accountid"></param>
        /// <param name="uselength"></param>
        /// <param name="tid"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool OpenStore(PlatApplyApp platApplyAppModel, string accountid, int uselength, int tid, ref string msg)
        {
            DateTime         nowtime = DateTime.Now;
            TransactionModel tran    = new TransactionModel();


            bool success = false;

            if (platApplyAppModel == null)
            {
                msg = "申请记录为空";
                return(false);
            }

            //用户基础数据,获取普通预存款

            AccountRelation accountrelation = AccountRelationBLL.SingleModel.GetModelByAccountId(accountid);

            Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(accountid);

            #region 模板跟模板价格
            XcxTemplate tempinfo = XcxTemplateBLL.SingleModel.GetModelByType((int)TmpType.小未平台子模版);
            if (tempinfo != null && agentinfo != null)
            {
                List <XcxTemplate> xcxlist = XcxTemplateBLL.SingleModel.GetRealPriceTemplateList($" id in ({tempinfo.Id})", agentinfo.id);
                if (xcxlist != null && xcxlist.Count > 0)
                {
                    //代理过期检验
                    AgentinfoBLL.SingleModel.CheckOutTime(ref xcxlist, agentinfo, 0, ref msg);
                    tempinfo = xcxlist[0];
                }
            }
            if (tempinfo == null)
            {
                msg = "模板数据为空";
                return(false);
            }
            #endregion

            #region 扣费
            //扣除总费用
            int sum = tempinfo.Price * uselength;
            //变更前金额
            int deposit = 0;
            //变更后的金额
            int afterdeposit = 0;
            //扣除代理费用
            if (agentinfo != null)
            {
                //首次开通免费
                if (AgentdepositLogBLL.SingleModel.IsFirstOpen(agentinfo.id, 2, 0))
                {
                    sum       = 0;
                    uselength = 1;
                }
                //变更前金额
                deposit = agentinfo.deposit;
                //判断余额是否满足扣费
                if (deposit + accountrelation.Deposit < sum)
                {
                    msg = "余额不足";
                    return(false);
                }

                //变更后金额,先扣除普通用户账号预存款
                if (accountrelation.Deposit > 0)
                {
                    if (accountrelation.Deposit >= sum)
                    {
                        afterdeposit = accountrelation.Deposit - sum;
                        tran.Add($"UPDATE AccountRelation set deposit={afterdeposit} ,updatetime='{nowtime}' where id={accountrelation.Id}");
                    }
                    else
                    {
                        //先扣除普通用户预存,再扣除代理商预存
                        afterdeposit = agentinfo.deposit - (sum - accountrelation.Deposit);
                        tran.Add($"UPDATE Agentinfo set deposit={afterdeposit} ,updateitme='{nowtime}' where id={agentinfo.id}");
                        tran.Add($"UPDATE AccountRelation set deposit=0 ,updatetime='{nowtime}' where id={accountrelation.Id}");
                    }
                }
                else
                {
                    afterdeposit = deposit - sum;
                    tran.Add($"UPDATE Agentinfo set deposit={afterdeposit} ,updateitme='{nowtime}' where id={agentinfo.id}");
                }
            }
            //扣除普通账号预存款
            else
            {
                //首次开通免费
                if (AgentdepositLogBLL.SingleModel.IsFirstOpen(0, 13, accountrelation.Id))
                {
                    sum = 0;
                }
                else
                {
                    sum = 100 * uselength;
                }
                //变更前金额
                deposit = accountrelation.Deposit;
                //判断余额是否满足扣费
                if (deposit < sum)
                {
                    msg = "余额不足";
                    return(false);
                }
                //变更后金额
                afterdeposit = deposit - sum;
                tran.Add($"UPDATE AccountRelation set deposit={afterdeposit} ,updatetime='{nowtime}' where id={accountrelation.Id}");
            }
            #endregion

            //名片管理登陆账号

            PlatMyCard mycardmodel = PlatMyCardBLL.SingleModel.GetModel(platApplyAppModel.MycardId);
            if (mycardmodel == null)
            {
                msg = "名片过期";
                return(false);
            }
            //判断是否已开通
            if (!string.IsNullOrEmpty(mycardmodel.LoginId))
            {
                msg = "该用户已开通过,请刷新看看";
                return(false);
            }

            //开通后台账号
            Account account = AccountBLL.SingleModel.WeiXinRegister("", 0, "", true, "", "", "小未平台开通独立小程序");
            if (account == null)
            {
                msg = "注册后台账号失败";
                return(false);
            }

            mycardmodel.LoginId    = account.LoginId;
            mycardmodel.UpdateTime = nowtime;
            tran.Add(PlatMyCardBLL.SingleModel.BuildUpdateSql(mycardmodel, "LoginId,UpdateTime"));

            //申请开通记录
            platApplyAppModel.UserId     = mycardmodel.UserId;
            platApplyAppModel.OpenState  = 1;
            platApplyAppModel.OpenTime   = nowtime;
            platApplyAppModel.UpdateTime = nowtime;
            tran.Add(base.BuildUpdateSql(platApplyAppModel, "OpenState,OpenTime,UpdateTime,UserId"));

            //开通独立小程序模板
            tran.Add($@"insert into XcxAppAccountRelation(TId,AccountId,AddTime,Url,price,outtime,agentid) 
            values({tempinfo.Id}, '{account.Id}', '{nowtime}', '{tempinfo.Link}', {tempinfo.Price}, '{nowtime.AddYears(uselength)}',{(agentinfo != null ? agentinfo.id : 0)})");

            //绑定店铺

            PlatStore platstoremodel = PlatStoreBLL.SingleModel.GetModel(platApplyAppModel.StoreId);
            if (platstoremodel == null)
            {
                msg = "店铺已过期,请刷新重试";
                return(false);
            }
            tran.Add($"update PlatStore set aid=(select last_insert_id()),UpdateTime='{nowtime}' where id={platstoremodel.Id}");

            #region 开通流水
            AgentdepositLog agentLog = new AgentdepositLog();
            agentLog.agentid       = agentinfo != null ? agentinfo.id : 0;
            agentLog.addtime       = nowtime;
            agentLog.templateCount = 1;
            agentLog.customerid    = account.Id.ToString();
            agentLog.tid           = tempinfo.Id;
            agentLog.type          = agentinfo != null ? (int)AgentDepositLogType.开通客户模板 : (int)AgentDepositLogType.普通用户开通模板;
            agentLog.templateCount = 1;
            agentLog.beforeDeposit = deposit;
            agentLog.cost          = sum;
            agentLog.Rid           = platApplyAppModel.BindAId;
            agentLog.acid          = agentinfo != null ? 0 : accountrelation.Id;
            agentLog.afterDeposit  = afterdeposit;
            string desc = $"客户:{mycardmodel.Name}  开通模板:{tempinfo.TName} 开通数量:1";
            agentLog.costdetail = desc;
            tran.Add(AgentdepositLogBLL.SingleModel.BuildAddSql(agentLog));
            #endregion

            //执行事务
            success = base.ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray);

            return(success);
        }
Пример #17
0
        public ActionResult GetData()
        {
            Return_Msg returnData = new Return_Msg();
            int        aid        = Context.GetRequestInt("aid", 0);

            if (aid <= 0)
            {
                returnData.Msg = "参数错误";
                return(Json(returnData));
            }
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid);

            if (xcxrelation == null)
            {
                returnData.Msg = "无效模板";
                return(Json(returnData));
            }
            PlatStore store = PlatStoreBLL.SingleModel.GetModelByAId(aid);

            if (store == null)
            {
                returnData.Msg = "无效店铺";
                return(Json(returnData));
            }
            PlatMyCard myCard = PlatMyCardBLL.SingleModel.GetModel(store.MyCardId);

            if (myCard == null)
            {
                returnData.Msg = "无效用户数据";
                return(Json(returnData));
            }
            PlatUserCash userCash = PlatUserCashBLL.SingleModel.GetModelByUserId(store.BindPlatAid, myCard.UserId);

            if (userCash == null)
            {
                return(Redirect("/base/PageError?type=2"));
            }
            PlatDrawConfig platDrawConfig = PlatDrawConfigBLL.SingleModel.GetModelByAId(store.BindPlatAid);

            if (platDrawConfig == null)
            {
                platDrawConfig = new PlatDrawConfig();
            }

            //总访问量
            int sumPV = PlatStatisticalFlowBLL.SingleModel.GetPVCount(aid);
            //店铺概况
            //当天订单
            int newOrderCount = PlatChildGoodsOrderBLL.SingleModel.GetTodayOrderCount(aid);
            //总订单
            int orderCount = PlatChildGoodsOrderBLL.SingleModel.GetOrderSum(aid);
            //会员人数
            int userCount = C_UserInfoBLL.SingleModel.GetCountByAppid(xcxrelation.AppId);
            //领券人数
            int couponCount = CouponLogBLL.SingleModel.GetUserCount(aid);
            //上次访问时间
            string visiteTime = RedisUtil.Get <string>(string.Format(PlatStatisticalFlowBLL._redis_PlatVisiteTimeKey, aid));
            //平台订单数
            int platOrderNum = PlatChildGoodsOrderBLL.SingleModel.GetPlatOrderNum(store.BindPlatAid, store.Id);
            //平台交易总额
            int platSumPrice = PlatChildGoodsOrderBLL.SingleModel.GetPlatOrderSumPrice(store.BindPlatAid, store.Id);
            //已提现金额
            int drawedCashPrice = userCash.UseCashTotal;
            //可提现金额
            int canDrawCashPrice = userCash.UseCash;
            //提现手续费
            int drawCashServer = platDrawConfig.Fee;

            DateTime nowTime = DateTime.Now;
            //访问量(PV)
            //当天,昨天,近七天,近30天,总累计
            int todayPV     = 0;
            int yeastodayPV = PlatStatisticalFlowBLL.SingleModel.GetPVCount(aid, "", nowTime.AddDays(-1).ToString("yyyy-MM-dd"), nowTime.ToString("yyyy-MM-dd"));
            int sevenDayPV  = PlatStatisticalFlowBLL.SingleModel.GetPVCount(aid, "", nowTime.AddDays(-7).ToString("yyyy-MM-dd"), nowTime.ToString("yyyy-MM-dd"));
            int thirthDayPV = PlatStatisticalFlowBLL.SingleModel.GetPVCount(aid, "", nowTime.AddDays(-30).ToString("yyyy-MM-dd"), nowTime.ToString("yyyy-MM-dd"));
            //近30天访问趋势统计
            List <PlatStatisticalFlow> list = PlatStatisticalFlowBLL.SingleModel.GetListByAid(aid, nowTime.AddDays(-30).ToString("yyyy-MM-dd"), nowTime.ToString("yyyy-MM-dd"));
            List <string> labels            = new List <string>();
            List <int>    datas             = new List <int>();

            if (list != null && list.Count > 0)
            {
                foreach (PlatStatisticalFlow item in list)
                {
                    labels.Add(item.RefDate);
                    datas.Add(item.VisitPV);
                }
            }

            returnData.dataObj = new
            {
                sumpv         = sumPV,
                newordercount = newOrderCount,
                usercount     = userCount,
                ordercount    = orderCount,
                couponcount   = couponCount,
                todaypv       = todayPV,
                yeastodaypv   = yeastodayPV,
                sevendaypv    = sevenDayPV,
                thirthdaypv   = thirthDayPV,
                labels        = labels,
                datas         = datas,
                visitetime    = visiteTime,

                platordernum       = platOrderNum,
                platsumprice       = (platSumPrice * 0.01).ToString("0.00"),
                drawedcashprice    = (drawedCashPrice * 0.01).ToString("0.00"),
                candrawcashprice   = (canDrawCashPrice * 0.01).ToString("0.00"),
                isopendistribution = userCash.IsOpenDistribution,
                drawcashserver     = (drawCashServer * 0.01) + "%",
            };

            return(Json(returnData));
        }
Пример #18
0
        /// <summary>
        /// 获取对应的配置
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="totalCount"></param>
        /// <param name="configType">配置类别 0 广告图 1推荐商家 2置顶商家</param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="orderWhere"></param>
        /// <returns></returns>
        public List <PlatConfig> getListByaid(int aid, out int totalCount, int configType = 0, int pageSize = 10, int pageIndex = 1, string orderWhere = "sortNumber desc,addTime desc")
        {
            string strWhere = $"aid={aid} and state<>-1 and configType={configType} ";

            totalCount = base.GetCount(strWhere);
            List <PlatConfig> list = base.GetListByParam(strWhere, null, pageSize, pageIndex, "*", orderWhere);

            list.ForEach(x => {
                switch (configType)
                {
                case 0:
                    //表示广告图跳转到目标为帖子
                    if (x.ADImgType == 1)
                    {
                        PlatMsg platMsg = PlatMsgBLL.SingleModel.GetModel(x.ObjId);
                        if (platMsg != null && platMsg.MsgDetail.Length > 0)
                        {
                            x.ObjName = platMsg.MsgDetail.Substring(0, platMsg.MsgDetail.Length > 20 ? 20 : platMsg.MsgDetail.Length);
                        }
                    }
                    else if (x.ADImgType == 0)
                    {
                        PlatStore platStoreMsg = PlatStoreBLL.SingleModel.GetPlatStore(x.ObjId, x.isStoreID == 0 ? 1 : 0);
                        if (platStoreMsg != null)
                        {
                            x.ObjName = platStoreMsg.Name;
                        }
                    }
                    else if (x.ADImgType == 2)
                    {
                        //跳转小程序appid
                        x.ObjName = x.Name;
                    }
                    else
                    {
                        x.ObjName = "不跳转";
                    }
                    break;

                case 4:
                    break;

                default:
                    //置顶商家跟推荐商家没有上传轮播图 使用店铺轮播图第一张
                    PlatStore platStore = PlatStoreBLL.SingleModel.GetPlatStore(x.ObjId, x.isStoreID == 0 ? 1 : 0);
                    if (platStore != null)
                    {
                        x.storeId = platStore.Id;
                        x.ObjName = platStore.Name;

                        string[] imgs = platStore.Banners.Split(',');
                        if (imgs != null && imgs.Length > 0)
                        {
                            x.ADImg = imgs.FirstOrDefault();
                        }
                    }
                    break;
                }
            });

            return(list);
        }
Пример #19
0
        /// <summary>
        /// 续期
        /// </summary>
        /// <param name="platApplyAppModel"></param>
        /// <param name="accountid"></param>
        /// <param name="uselength"></param>
        /// <param name="tid"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool AddTimeLength(PlatApplyApp platApplyAppModel, string accountid, int uselength, int tid, ref string msg)
        {
            DateTime         nowtime = DateTime.Now;
            TransactionModel tran    = new TransactionModel();

            #region 基础验证
            bool success = false;
            if (platApplyAppModel == null)
            {
                msg = "申请记录为空";
                return(false);
            }
            //名片管理登陆账号

            PlatMyCard mycardmodel = PlatMyCardBLL.SingleModel.GetModel(platApplyAppModel.MycardId);
            if (mycardmodel == null)
            {
                msg = "名片过期";
                return(false);
            }
            //判断是否已开通
            if (string.IsNullOrEmpty(mycardmodel.LoginId))
            {
                msg = "该用户还没开通小程序";
                return(false);
            }

            //店铺数据

            PlatStore platStore = PlatStoreBLL.SingleModel.GetModel(platApplyAppModel.StoreId);
            if (platStore == null)
            {
                msg = "店铺过期,请刷新重试";
                return(false);
            }
            #endregion

            #region 使用中的模板数据
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(platStore.Aid);
            if (xcxrelation == null)
            {
                msg = "模板数据过期";
                return(false);
            }
            if (xcxrelation.outtime < nowtime)
            {
                xcxrelation.outtime = nowtime.AddYears(uselength);
            }
            else
            {
                xcxrelation.outtime = xcxrelation.outtime.AddYears(uselength);
            }
            tran.Add($"update XcxAppAccountRelation set outtime='{xcxrelation.outtime}',state=1 where id={xcxrelation.Id}");
            #endregion

            //用户基础数据,获取普通预存款

            AccountRelation accountrelation = AccountRelationBLL.SingleModel.GetModelByAccountId(accountid);

            //代理数据
            Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(accountid);

            #region 模板跟模板价格
            XcxTemplate tempinfo = XcxTemplateBLL.SingleModel.GetModelByType((int)TmpType.小未平台子模版);
            if (tempinfo != null && agentinfo != null)
            {
                List <XcxTemplate> xcxlist = XcxTemplateBLL.SingleModel.GetRealPriceTemplateList($" id in ({tempinfo.Id})", agentinfo.id);
                if (xcxlist != null && xcxlist.Count > 0)
                {
                    //代理过期检验
                    AgentinfoBLL.SingleModel.CheckOutTime(ref xcxlist, agentinfo, 0, ref msg);
                    tempinfo = xcxlist[0];
                }
            }
            if (tempinfo == null)
            {
                msg = "模板数据为空";
                return(false);
            }
            #endregion

            #region 扣费
            //扣除总费用
            int sum = tempinfo.Price * uselength;
            //变更前金额
            int deposit = 0;
            //变更后的金额
            int afterdeposit = 0;
            //扣除代理费用
            if (agentinfo != null)
            {
                //变更前金额
                deposit = agentinfo.deposit;
                //判断余额是否满足扣费
                if (deposit + accountrelation.Deposit < sum)
                {
                    msg = "余额不足";
                    return(false);
                }
                //变更后金额
                if (deposit >= sum)
                {
                    afterdeposit = deposit - sum;
                    tran.Add($"UPDATE Agentinfo set deposit={afterdeposit} ,updateitme='{nowtime}' where id={agentinfo.id}");
                }
                else if (accountrelation.Deposit >= sum)
                {
                    afterdeposit = accountrelation.Deposit - sum;
                    tran.Add($"UPDATE AccountRelation set deposit={afterdeposit} ,updatetime='{nowtime}' where id={accountrelation.Id}");
                }
                else
                {
                    //先扣除普通用户预存,再扣除代理商预存
                    afterdeposit = agentinfo.deposit - (sum - accountrelation.Deposit);
                    tran.Add($"UPDATE Agentinfo set deposit={afterdeposit} ,updateitme='{nowtime}' where id={agentinfo.id}");
                    tran.Add($"UPDATE AccountRelation set deposit=0 ,updatetime='{nowtime}' where id={accountrelation.Id}");
                }
            }
            //扣除普通账号预存款
            else
            {
                sum = 100 * uselength;
                //变更前金额
                deposit = accountrelation.Deposit;
                //判断余额是否满足扣费
                if (deposit < sum)
                {
                    msg = "余额不足";
                    return(false);
                }
                //变更后金额
                afterdeposit = deposit - sum;
                tran.Add($"UPDATE AccountRelation set deposit={afterdeposit} ,updatetime='{nowtime}' where id={accountrelation.Id}");
            }
            #endregion

            #region 开通流水

            AgentdepositLog agentLog = new AgentdepositLog();
            agentLog.agentid       = agentinfo != null ? agentinfo.id : 0;
            agentLog.addtime       = nowtime;
            agentLog.templateCount = 1;
            agentLog.customerid    = xcxrelation.AccountId.ToString();
            agentLog.tid           = tempinfo.Id;
            agentLog.type          = agentinfo != null ? (int)AgentDepositLogType.代理商续费 : (int)AgentDepositLogType.普通用户续费模板;
            agentLog.templateCount = 1;
            agentLog.beforeDeposit = deposit;
            agentLog.cost          = sum;
            agentLog.acid          = agentinfo != null ? 0 : accountrelation.Id;
            agentLog.Rid           = platApplyAppModel.BindAId;
            agentLog.afterDeposit  = afterdeposit;
            string desc = $"客户:{mycardmodel.Name}  续期模板:{tempinfo.TName} 续期年限:{uselength}年";
            agentLog.costdetail = desc;
            tran.Add(AgentdepositLogBLL.SingleModel.BuildAddSql(agentLog));
            #endregion

            success = base.ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray);

            //清除缓存
            XcxAppAccountRelationBLL.SingleModel.RemoveRedis(xcxrelation.Id);
            return(success);
        }
Пример #20
0
        public ActionResult AddStore()
        {
            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";
            string appId       = Context.GetRequest("appId", string.Empty);
            int    userId      = Context.GetRequestInt("myCardId", 0);
            int    agentInfoId = Context.GetRequestInt("agentInfoId", 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, JsonRequestBehavior.AllowGet));
            }

            Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(r.AccountId.ToString());
            //if (agentinfo == null)//本平台代理信息
            //{
            //    returnObj.Msg = "入驻异常";
            //    return Json(returnObj, JsonRequestBehavior.AllowGet);
            //}

            string banners = Context.GetRequest("banners", string.Empty);

            if (string.IsNullOrEmpty(banners) || banners.Split(',').Length <= 0)
            {
                returnObj.Msg = "轮播图至少一张";
                return(Json(returnObj));
            }
            string storeName = Context.GetRequest("storeName", string.Empty);

            if (string.IsNullOrEmpty(storeName) || storeName.Length >= 20)
            {
                returnObj.Msg = "店铺名称不能为空并且不能超过20字符";
                return(Json(returnObj));
            }

            string lngStr = Context.GetRequest("lng", string.Empty);
            string latStr = Context.GetRequest("lat", string.Empty);
            double lng    = 0.00;
            double lat    = 0.00;

            if (!double.TryParse(lngStr, out lng) || !double.TryParse(latStr, out lat))
            {
                returnObj.Msg = "地址坐标错误";
                return(Json(returnObj));
            }

            string location = Context.GetRequest("location", string.Empty);

            if (string.IsNullOrEmpty(location))
            {
                returnObj.Msg = "地址不能为空";
                return(Json(returnObj));
            }

            string storeService = Context.GetRequest("storeService", string.Empty);
            //if (string.IsNullOrEmpty(storeService) || storeService.Split(',').Length <= 0)
            //{
            //    returnObj.Msg = "提供服务不能为空";
            //    return Json(returnObj);
            //}

            string openTime = Context.GetRequest("openTime", string.Empty);
            //if (string.IsNullOrEmpty(openTime))
            //{
            //    returnObj.Msg = "营业时间不能为空";
            //    return Json(returnObj);
            //}
            //TODO 需要验证手机+电话
            string phone = Context.GetRequest("phone", string.Empty);

            if (string.IsNullOrEmpty(phone))
            {
                returnObj.Msg = "请填写正确的号码";
                return(Json(returnObj));
            }

            string businessDescription = Context.GetRequest("businessDescription", string.Empty);

            if (string.IsNullOrEmpty(businessDescription))
            {
                returnObj.Msg = "业务简述不能为空";
                return(Json(returnObj));
            }

            string storeDescription = Context.GetRequest("storeDescription", string.Empty);
            string storeImgs        = Context.GetRequest("storeImgs", string.Empty);
            int    category         = Context.GetRequestInt("category", 0);//店铺类别

            if (PlatStoreCategoryBLL.SingleModel.GetModel(category) == null)
            {
                returnObj.Msg = "类别选择错误!";
                return(Json(returnObj));
            }

            PlatStore platStore = PlatStoreBLL.SingleModel.GetPlatStore(userId, 1);

            if (platStore == null)
            {
                platStore = new PlatStore();
            }

            AddressApi addressinfo = AddressHelper.GetAddressByApi(lngStr, latStr);

            if (addressinfo == null || addressinfo.result == null || addressinfo.result.address_component == null)
            {
                returnObj.Msg = "地址出错!";
                return(Json(returnObj));
            }

            if (!storeService.Contains("ServiceState"))
            {
                //表示旧版本的数据,设施服务给初始化新值
                List <StoreServiceModel> list = new List <StoreServiceModel>();
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "WIFI"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "停车位"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "支付宝支付"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "微信支付"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "刷卡支付"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "空调雅座"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "付费停车"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "接送服务"
                });
                storeService = Newtonsoft.Json.JsonConvert.SerializeObject(list);
            }


            string storeRemark = Context.GetRequest("storeRemark", string.Empty);

            platStore.StoreRemark = storeRemark;

            string provinceName = addressinfo.result.address_component.province;
            string cityName     = addressinfo.result.address_component.city;
            string countryName  = addressinfo.result.address_component.district;

            platStore.ProvinceCode        = C_AreaBLL.SingleModel.GetCodeByName(provinceName);
            platStore.CityCode            = C_AreaBLL.SingleModel.GetCodeByName(cityName);
            platStore.CountryCode         = C_AreaBLL.SingleModel.GetCodeByName(countryName);
            platStore.AddTime             = DateTime.Now;
            platStore.Banners             = banners;
            platStore.BindPlatAid         = r.Id;
            platStore.BusinessDescription = businessDescription;
            platStore.Category            = category;
            platStore.Lat              = lat;
            platStore.Lng              = lng;
            platStore.Location         = location;
            platStore.MyCardId         = userId;
            platStore.Name             = storeName;
            platStore.OpenTime         = openTime;
            platStore.Phone            = phone;
            platStore.StoreDescription = storeDescription;
            platStore.StoreImgs        = storeImgs;
            platStore.StoreService     = storeService;
            platStore.UpdateTime       = DateTime.Now;
            TransactionModel TranModel = new TransactionModel();

            if (platStore.Id > 0)
            {
                //表示更新

                TranModel.Add(PlatStoreBLL.SingleModel.BuildUpdateSql(platStore));
                PlatStoreRelation platStoreRelation = PlatStoreRelationBLL.SingleModel.GetPlatStoreRelationOwner(r.Id, platStore.Id);
                if (platStoreRelation == null)
                {
                    returnObj.Msg = "更新异常(店铺关系找不到数据)";
                    return(Json(returnObj));
                }
                platStoreRelation.Category   = platStore.Category;
                platStoreRelation.UpdateTime = DateTime.Now;
                TranModel.Add(PlatStoreRelationBLL.SingleModel.BuildUpdateSql(platStoreRelation, "Category,UpdateTime"));

                //2.查找上级代理
                #region  步代理商店铺 暂时先屏蔽
                //AgentDistributionRelation agentDistributionRelationFirst = new AgentDistributionRelationBLL().GetModel(agentinfo.id);
                //if (agentDistributionRelationFirst != null)
                //{
                //    Agentinfo agentinfoFirst = _agentinfoBll.GetModel(agentDistributionRelationFirst.ParentAgentId);
                //    if (agentinfoFirst != null)
                //    {
                //        XcxAppAccountRelation xcxAppAccountRelationFirst = _xcxappaccountrelationBll.GetModelByaccountidAndTid(agentinfoFirst.useraccountid, (int)TmpType.小未平台);
                //        if (xcxAppAccountRelationFirst != null)
                //        {
                //            PlatStoreRelation platStoreRelationFist = _platStoreRelationBLL.GetPlatStoreRelationOwner(xcxAppAccountRelationFirst.Id, platStore.Id, agentinfo.id);
                //            if (platStoreRelationFist != null)
                //            {
                //                platStoreRelationFist.Category = platStore.Category;
                //                platStoreRelationFist.UpdateTime = DateTime.Now;
                //                TranModel.Add(_platStoreRelationBLL.BuildUpdateSql(platStoreRelationFist, "Category,UpdateTime"));
                //            }


                //            //3.查找上级的上级代理
                //            AgentDistributionRelation agentDistributionRelationSecond = new AgentDistributionRelationBLL().GetModel(agentinfoFirst.id);
                //            if (agentDistributionRelationSecond != null)
                //            {
                //                Agentinfo agentinfoSecond = _agentinfoBll.GetModel(agentDistributionRelationSecond.ParentAgentId);
                //                if (agentinfoSecond != null)
                //                {
                //                    XcxAppAccountRelation xcxAppAccountRelationSecond = _xcxappaccountrelationBll.GetModelByaccountidAndTid(agentinfoSecond.useraccountid, (int)TmpType.小未平台);
                //                    if (xcxAppAccountRelationSecond != null)
                //                    {
                //                        PlatStoreRelation platStoreRelationSecond = _platStoreRelationBLL.GetPlatStoreRelationOwner(xcxAppAccountRelationSecond.Id, platStore.Id, agentinfo.id);

                //                        platStoreRelationSecond.Category = platStore.Category;
                //                        platStoreRelationSecond.UpdateTime = DateTime.Now;
                //                        TranModel.Add(_platStoreRelationBLL.BuildUpdateSql(platStoreRelationSecond, "Category,UpdateTime"));
                //                    }
                //                }
                //            }
                //        }
                //    }
                //}
                #endregion


                if (TranModel.sqlArray != null && TranModel.sqlArray.Length > 0 && PlatStoreRelationBLL.SingleModel.ExecuteTransactionDataCorect(TranModel.sqlArray))
                {
                    returnObj.isok = true;
                    returnObj.Msg  = "操作成功";
                    return(Json(returnObj));
                }
                else
                {
                    returnObj.Msg = "更新失败";
                    return(Json(returnObj));
                }
            }
            else
            {
                //平台入驻模式
                PlatStoreAddSetting platStoreAddSetting = PlatStoreAddSettingBLL.SingleModel.GetPlatStoreAddSetting(r.Id);
                int addWay             = platStoreAddSetting != null ? platStoreAddSetting.AddWay : 0;
                PlatStoreAddRules rule = new PlatStoreAddRules();
                if (addWay == 1)
                {
                    platStore.State = -1;
                    int ruleId = Context.GetRequestInt("ruleId", 0);
                    rule = PlatStoreAddRulesBLL.SingleModel.getRule(r.Id, ruleId);
                    if (rule == null)
                    {
                        returnObj.Msg = "入驻套餐不存在!";
                        return(Json(returnObj));
                    }

                    platStore.YearCount = rule.YearCount;
                    platStore.CostPrice = rule.CostPrice;
                }

                //表示入驻平台 需要将该入驻店铺同步到平台的1 2级代理商
                int storeId = Convert.ToInt32(PlatStoreBLL.SingleModel.Add(platStore));

                if (storeId > 0)
                {
                    #region 数据同步

                    //插入关系表  才算成功 店铺数据都是从关系表获取才算有效的
                    //1.先将入驻到平台的插入
                    PlatStoreRelation platStoreRelation = new PlatStoreRelation();
                    platStoreRelation.StoreId    = storeId;
                    platStoreRelation.State      = 1;
                    platStoreRelation.FromType   = 0;
                    platStoreRelation.Aid        = r.Id;
                    platStoreRelation.Category   = platStore.Category;
                    platStoreRelation.AgentId    = agentinfo != null ? agentinfo.id : agentInfoId;
                    platStoreRelation.AddTime    = DateTime.Now;
                    platStoreRelation.UpdateTime = DateTime.Now;
                    TranModel.Add(PlatStoreRelationBLL.SingleModel.BuildAddSql(platStoreRelation));
                    //2.查找上级代理
                    #region 暂时先屏蔽
                    //AgentDistributionRelation agentDistributionRelationFirst = new AgentDistributionRelationBLL().GetModel(agentinfo.id);
                    //if (agentDistributionRelationFirst != null)
                    //{
                    //    Agentinfo agentinfoFirst = _agentinfoBll.GetModel(agentDistributionRelationFirst.ParentAgentId);
                    //    if (agentinfoFirst != null)
                    //    {
                    //        XcxAppAccountRelation xcxAppAccountRelationFirst = _xcxappaccountrelationBll.GetModelByaccountidAndTid(agentinfoFirst.useraccountid, (int)TmpType.小未平台);
                    //        if (xcxAppAccountRelationFirst != null)
                    //        {
                    //            PlatStoreRelation platStoreRelationFist = new PlatStoreRelation();
                    //            platStoreRelationFist.StoreId = storeId;
                    //            platStoreRelationFist.State = 0;
                    //            platStoreRelationFist.FromType = 1;
                    //            platStoreRelationFist.Aid = xcxAppAccountRelationFirst.Id;
                    //            platStoreRelationFist.Category = platStore.Category;
                    //            platStoreRelationFist.AgentId = agentinfo.id;
                    //            platStoreRelationFist.AddTime = DateTime.Now;
                    //            platStoreRelationFist.UpdateTime = DateTime.Now;
                    //            TranModel.Add(_platStoreRelationBLL.BuildAddSql(platStoreRelationFist));

                    //            //3.查找上级的上级代理
                    //            AgentDistributionRelation agentDistributionRelationSecond = new AgentDistributionRelationBLL().GetModel(agentinfoFirst.id);
                    //            if (agentDistributionRelationSecond != null)
                    //            {
                    //                Agentinfo agentinfoSecond = _agentinfoBll.GetModel(agentDistributionRelationSecond.ParentAgentId);
                    //                if (agentinfoSecond != null)
                    //                {
                    //                    XcxAppAccountRelation xcxAppAccountRelationSecond = _xcxappaccountrelationBll.GetModelByaccountidAndTid(agentinfoSecond.useraccountid, (int)TmpType.小未平台);
                    //                    if (xcxAppAccountRelationSecond != null)
                    //                    {
                    //                        PlatStoreRelation platStoreRelationSecond = new PlatStoreRelation();
                    //                        platStoreRelationSecond.StoreId = storeId;
                    //                        platStoreRelationSecond.State = 0;
                    //                        platStoreRelationSecond.FromType = 1;
                    //                        platStoreRelationSecond.Aid = xcxAppAccountRelationSecond.Id;
                    //                        platStoreRelationSecond.Category = platStore.Category;
                    //                        platStoreRelationSecond.AgentId = agentinfo.id;
                    //                        platStoreRelationSecond.AddTime = DateTime.Now;
                    //                        platStoreRelationSecond.UpdateTime = DateTime.Now;
                    //                        TranModel.Add(_platStoreRelationBLL.BuildAddSql(platStoreRelationSecond));
                    //                    }

                    //                }
                    //            }


                    //        }
                    //    }
                    //}
                    #endregion



                    #endregion
                    int orderid = 0;
                    if (addWay == 1)
                    {
                        CityMorders order = new CityMorders()
                        {
                            FuserId        = storeId,
                            Fusername      = storeName,
                            TuserId        = 0,
                            OrderType      = (int)ArticleTypeEnum.PlatAddStorePay,
                            ActionType     = (int)miniAppBuyMode.微信支付,
                            Addtime        = DateTime.Now,
                            Percent        = 99,//不收取服务费
                            userip         = WebHelper.GetIP(),
                            payment_status = 0,
                            Status         = 0,
                            CitySubId      = 0,//无分销,默认为0
                            PayRate        = 1,
                            appid          = appId,
                            Articleid      = rule.Id,
                            CommentId      = platStore.YearCount,
                            MinisnsId      = r.Id,
                            payment_free   = platStore.CostPrice,
                            ShowNote       = $"平台版店铺入驻收费付款{platStore.CostPrice * 0.01}元"
                        };
                        string no = WxPayApi.GenerateOutTradeNo();
                        order.orderno  = no;
                        order.trade_no = no;

                        orderid = Convert.ToInt32(_cityMordersBLL.Add(order));
                    }



                    if (TranModel.sqlArray != null && TranModel.sqlArray.Length > 0)
                    {
                        if (PlatStoreRelationBLL.SingleModel.ExecuteTransactionDataCorect(TranModel.sqlArray))
                        {
                            if (orderid <= 0 && addWay == 1)
                            {
                                returnObj.Msg = "入驻失败(订单生成失败)";
                                return(Json(returnObj));
                            }

                            returnObj.dataObj = new { storeId = storeId, orderid = orderid };
                            returnObj.isok    = true;
                            returnObj.Msg     = "入驻成功";
                            return(Json(returnObj));
                        }
                        else
                        {
                            platStore.State      = -1;
                            platStore.UpdateTime = DateTime.Now;
                            PlatStoreBLL.SingleModel.Update(platStore, "State,UpdateTime");
                            returnObj.Msg = "入驻失败";
                            return(Json(returnObj));
                        }
                    }
                    else
                    {
                        returnObj.dataObj = storeId;
                        returnObj.isok    = true;
                        returnObj.Msg     = "入驻成功";
                        return(Json(returnObj));
                    }
                }
                else
                {
                    returnObj.Msg = "入驻失败(请联系客服)";
                    return(Json(returnObj));
                }
            }
        }
Пример #21
0
        public ActionResult GetGoodInfo()
        {
            int pid    = Context.GetRequestInt("pid", 0);
            int userId = Context.GetRequestInt("userId", 0);

            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";

            if (pid == 0)
            {
                returnObj.Msg = "请选择产品";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            PlatChildGoods goodModel = PlatChildGoodsBLL.SingleModel.GetModel(pid);

            if (goodModel == null || goodModel.State == 0)
            {
                returnObj.Msg = "产品不存在或已删除";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            PlatStore platStore = PlatStoreBLL.SingleModel.GetModelByAId(goodModel.AId);

            if (platStore == null)
            {
                returnObj.Msg = "店铺不存在";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            if (!string.IsNullOrEmpty(goodModel.Plabels))
            {
                //goodModel.plabelstr = DAL.Base.SqlMySql.ExecuteScalar(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, $"SELECT group_concat(name order by sort desc) from entgoodlabel where id in ({goodModel.plabels})").ToString();
                goodModel.PlabelStr      = PlatChildGoodsLabelBLL.SingleModel.GetEntGoodsLabelStr(goodModel.Plabels);
                goodModel.PlabelStr_Arry = goodModel.PlabelStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            }

            #region 会员折扣显示
            //获取会员信息
            VipRelation vipInfo   = VipRelationBLL.SingleModel.GetModelByUserid(userId);
            VipLevel    levelinfo = vipInfo != null?VipLevelBLL.SingleModel.GetModel(vipInfo.levelid) : null;

            List <PlatChildGoods> list = new List <PlatChildGoods>();
            list.Add(goodModel);
            //  _miniappVipLevelBll.GetVipDiscount(ref list, vipInfo, levelinfo, userId, "Discount", "Price");
            goodModel = list.FirstOrDefault();

            #endregion 会员折扣显示

            //#region 会员打折
            List <PlatChildGoodsCart> carlist = new List <PlatChildGoodsCart>()
            {
                new PlatChildGoodsCart()
                {
                    GoodsId = goodModel.Id
                }
            };
            carlist.ForEach(g => g.OriginalPrice = g.Price);
            VipLevelBLL.SingleModel.GetVipDiscount(ref carlist, vipInfo, levelinfo, userId, "Discount", "Price");
            goodModel.Discount = carlist[0].Discount;
            //#endregion 会员打折

            if (!string.IsNullOrEmpty(goodModel.Img))
            {
                goodModel.Img = goodModel.Img.Replace("http://vzan-img.oss-cn-hangzhou.aliyuncs.com", "https://i.vzan.cc/");
            }

            List <GoodsSpecDetail> listGoodsSpecDetail = Newtonsoft.Json.JsonConvert.DeserializeObject <List <GoodsSpecDetail> >(goodModel.SpecDetail);
            listGoodsSpecDetail.ForEach(x =>
            {
                if (x.Discount == 100)
                {
                    x.DiscountPrice = x.Price;
                }
            });

            goodModel.SpecDetail = JsonConvert.SerializeObject(listGoodsSpecDetail);
            goodModel.storeModel = new StoreModel()
            {
                StoreId = platStore.Id,
                Name    = platStore.Name,
                Img     = platStore.StoreHeaderImg,
                Loction = platStore.Location,
                Lng     = platStore.Lng,
                Lat     = platStore.Lat
            };

            PlatMyCard platMyCard = PlatMyCardBLL.SingleModel.GetModel(platStore.MyCardId);
            if (platMyCard != null)
            {
                goodModel.storeOwner = new StoreOwner()
                {
                    UserId = platMyCard.UserId,
                    Name   = platMyCard.Name,
                    Avatar = platMyCard.ImgUrl
                };

                PlatUserCash userCash = PlatUserCashBLL.SingleModel.GetModelByUserId(platMyCard.AId, platMyCard.UserId);
                if (userCash != null)
                {
                    goodModel.storeOwner.IsOpenDistribution = userCash.IsOpenDistribution;
                }
            }

            returnObj.isok    = true;
            returnObj.dataObj = goodModel;
            returnObj.Msg     = "获取成功";
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
Пример #22
0
        public ActionResult AddStoreTime()
        {
            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";
            string appId   = Context.GetRequest("appId", string.Empty);
            int    storeId = Context.GetRequestInt("storeId", 0);
            int    ruleId  = Context.GetRequestInt("ruleId", 0);

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

            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

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

            PlatStore platStore = PlatStoreBLL.SingleModel.GetModel(storeId);

            if (platStore == null)
            {
                returnObj.Msg = "店铺不存在";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            if (platStore.State == -1)
            {
                returnObj.Msg = "店铺不可用";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            PlatStoreAddRules rule = PlatStoreAddRulesBLL.SingleModel.getRule(r.Id, ruleId);

            if (rule == null)
            {
                returnObj.Msg = "续费套餐不存在";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            CityMorders order = new CityMorders()
            {
                FuserId        = platStore.Id,
                Fusername      = platStore.Name,
                TuserId        = 0,
                OrderType      = (int)ArticleTypeEnum.PlatStoreAddTimePay,
                ActionType     = (int)miniAppBuyMode.微信支付,
                Addtime        = DateTime.Now,
                Percent        = 99,//不收取服务费
                userip         = WebHelper.GetIP(),
                payment_status = 0,
                Status         = 0,
                CitySubId      = 0,//无分销,默认为0
                PayRate        = 1,
                appid          = appId,
                Articleid      = rule.Id,
                CommentId      = rule.YearCount,
                MinisnsId      = r.Id,
                payment_free   = rule.CostPrice,
                ShowNote       = $"平台版店铺续期{rule.YearCount}月收费付款{rule.CostPrice * 0.01}元"
            };
            string no = WxPayApi.GenerateOutTradeNo();

            order.orderno  = no;
            order.trade_no = no;

            int orderid = Convert.ToInt32(_cityMordersBLL.Add(order));

            if (orderid <= 0)
            {
                returnObj.Msg = "续费失败(生成订单失败)";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }
            returnObj.dataObj = orderid;
            returnObj.isok    = true;
            returnObj.Msg     = "续费成功";
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
Пример #23
0
        /// <summary>
        /// 获取平台指定店铺详情
        /// </summary>
        /// <returns></returns>
        public ActionResult GetStoreDetail()
        {
            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";
            string appId   = Context.GetRequest("appId", string.Empty);
            int    userId  = Context.GetRequestInt("userId", 0);
            int    storeId = Context.GetRequestInt("storeId", 0);
            int    type    = Context.GetRequestInt("type", 0);

            if (string.IsNullOrEmpty(appId))
            {
                returnObj.Msg = "参数错误";
                return(Json(returnObj));
            }
            List <string>         listPlatMyCardIds = new List <string>();
            int                   myCardId          = Context.GetRequestInt("myCardId", 0);
            int                   isStoreID         = Context.GetRequestInt("isStoreID", 0);//如果是1 表示myCardId为店铺Id 这里是轮播图处理兼容旧数据
            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

            if (r == null)
            {
                returnObj.Msg = "小程序未授权";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }
            PlatStore platStore = new PlatStore();

            if (type == 1 && isStoreID == 0)
            {
                //表示从我的店铺名片进来
                if (myCardId <= 0)
                {
                    platStore = null;
                }
                else
                {
                    platStore = PlatStoreBLL.SingleModel.GetPlatStore(myCardId, type);
                }
            }
            else if (type == 2)
            {
                //表示独立小程序进来的
                platStore = PlatStoreBLL.SingleModel.GetPlatStore(r.Id, type);
                r         = _xcxAppAccountRelationBLL.GetModel(platStore.BindPlatAid);//查找所属平台
                if (r != null)
                {
                    listPlatMyCardIds = PlatMyCardBLL.SingleModel.GetCardIds(r.Id, r.AppId).Split(',').ToList();
                    if (!listPlatMyCardIds.Contains(platStore.MyCardId.ToString()))
                    {
                        returnObj.Msg = "店铺不存在(平台换绑了小程序,请重新入驻)";
                        return(Json(returnObj, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            else
            {
                //平台轮播图 置顶商家 进入店铺会带上isStoreID

                if (isStoreID > 0)
                {
                    type      = 0;
                    platStore = PlatStoreBLL.SingleModel.GetPlatStore(myCardId, type);
                }
                else
                {
                    platStore = PlatStoreBLL.SingleModel.GetPlatStore(storeId, type);
                }
            }

            if (platStore == null)
            {
                returnObj.Msg = "店铺不存在";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }
            if (platStore.State == -1)
            {
                returnObj.Msg = "店铺无效(未支付)";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }



            if (type != 2)
            {
                //这里的appID是平台的
                listPlatMyCardIds = PlatMyCardBLL.SingleModel.GetCardIds(r.Id, appId).Split(',').ToList();
                if (!listPlatMyCardIds.Contains(platStore.MyCardId.ToString()))
                {
                    returnObj.Msg = "店铺不存在(平台换绑了小程序,请重新入驻绑定)";
                    return(Json(returnObj, JsonRequestBehavior.AllowGet));
                }
            }



            //店铺关联的权限表数据
            XcxAppAccountRelation storexcxrelation = _xcxAppAccountRelationBLL.GetModel(platStore.Aid);

            if (storexcxrelation != null)
            {
                platStore.AppId = storexcxrelation.AppId;
            }

            //TODO 后续流量大了再放入redis然后定时去更新
            platStore.StorePV++;
            //访客人数
            platStore.StoreUV       = PlatUserFavoriteMsgBLL.SingleModel.GetVisitorCount(platStore.MyCardId, platStore.BindPlatAid, (int)PointsDataType.店铺, "", "");
            platStore.FavoriteCount = PlatUserFavoriteMsgBLL.SingleModel.GetStoreFavoriteCount(r.Id, platStore.Id);

            PlatUserFavoriteMsg platUserFavoriteMsg = PlatUserFavoriteMsgBLL.SingleModel.GetUserFavoriteMsg(r.Id, platStore.Id, userId, (int)PointsActionType.收藏, (int)PointsDataType.店铺);

            platStore.Favorited = (platUserFavoriteMsg != null && platUserFavoriteMsg.State != -1 ? 1 : 0);

            platStore.CategoryName = PlatStoreCategoryBLL.SingleModel.GetModel(platStore.Category).Name;

            int tjCount = 0;

            List <PlatChildGoods> listTjGoods = listTjGoods = PlatChildGoodsBLL.SingleModel.GetListByRedis(platStore.Aid, ref tjCount, string.Empty, 0, 0, 1, 1, 4, "TopState desc,VirtualSalesCount+SalesCount desc,sort desc");

            //if (type == 0)
            //{

            //    listTjGoods = _platChildGoodsBLL.GetListByRedis(platStore.Aid, ref tjCount, string.Empty, 0, 0, 1, 1, 4, "TopState desc,VirtualSalesCount+SalesCount desc,sort desc");
            //}
            //else
            //{
            //    listTjGoods = _platChildGoodsBLL.GetListByRedis(r.Id, ref tjCount, string.Empty, 0, 0, 1, 1, 4, "TopState desc,VirtualSalesCount+SalesCount desc,sort desc");
            //}
            if (listTjGoods != null && listTjGoods.Count > 0)
            {
                listTjGoods.ForEach(x =>
                {
                    platStore.TjGoods.Add(new TjGoods()
                    {
                        Aid       = x.AId,
                        Id        = x.Id,
                        Name      = x.Name,
                        Img       = x.Img,
                        PriceStr  = (x.PriceFen * 0.01).ToString("0.00"),
                        SaleCount = (x.SalesCount + x.VirtualSalesCount),
                        TopState  = x.TopState
                    });
                });
            }

            PlatApplyApp platApplyApp = PlatApplyAppBLL.SingleModel.GetPlatApplyAppByStoreId(platStore.Id);

            if (platApplyApp != null)
            {
                platStore.AppState = platApplyApp.OpenState;
            }

            if (!PlatStoreBLL.SingleModel.Update(platStore, "StorePV"))
            {
                returnObj.Msg = "更新店铺浏览量异常";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }
            //PlatMsgviewFavoriteShare msgview = _platMsgviewFavoriteShareBLL.GetModelByMsgId(platStore.BindPlatAid, platStore.Id,(int)PointsDataType.店铺);
            //if(msgview!=null)
            //{
            //    platStore.StorePV = msgview.ViewCount;
            //}

            PlatMyCard platMyCard = PlatMyCardBLL.SingleModel.GetModel(platStore.MyCardId);

            if (platMyCard != null)
            {
                platStore.storeOwner = new StoreOwner()
                {
                    UserId = platMyCard.UserId,
                    Name   = platMyCard.Name,
                    Avatar = platMyCard.ImgUrl,
                    State  = platMyCard.State,
                };
            }

            if (!string.IsNullOrEmpty(platStore.StoreService))
            {
                platStore.StoreServiceModelList = Newtonsoft.Json.JsonConvert.DeserializeObject <List <StoreServiceModel> >(platStore.StoreService);
            }
            else
            {
                List <StoreServiceModel> list = new List <StoreServiceModel>();
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "WIFI"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "停车位"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "支付宝支付"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "微信支付"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "刷卡支付"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "空调雅座"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "付费停车"
                });
                list.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "接送服务"
                });
                platStore.StoreServiceModelList = list;
            }

            if (!string.IsNullOrEmpty(platStore.SwitchConfig))
            {
                platStore.SwitchModel = Newtonsoft.Json.JsonConvert.DeserializeObject <PlatStoreSwitchModel>(platStore.SwitchConfig);
            }
            else
            {
                platStore.SwitchModel = new PlatStoreSwitchModel();
            }

            platStore.StorePV += platStore.StoreVirtualPV;
            returnObj.dataObj  = new
            {
                platStore = platStore
            };
            returnObj.isok = true;
            returnObj.Msg  = "获取成功";
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
Пример #24
0
        /// <summary>
        /// 获取运费信息
        /// </summary>
        /// <returns></returns>
        public ActionResult GetFreightFee(string appId = null, string openId = null)
        {
            returnObj = new Return_Msg_APP();
            int    userId      = Context.GetRequestInt("userid", 0);
            int    storeId     = Context.GetRequestInt("storeid", 0);
            string province    = Context.GetRequest("province", "");
            string city        = Context.GetRequest("city", "");
            string goodCartIds = Context.GetRequest("goodcartids", "");

            if (userId <= 0)
            {
                returnObj.Msg = "参数错误";
                return(Json(returnObj));
            }
            if (string.IsNullOrWhiteSpace(goodCartIds))
            {
                returnObj.Msg = "购物车参数出错";
                return(Json(returnObj));
            }
            C_UserInfo usrInfo = C_UserInfoBLL.SingleModel.GetModel(userId);

            if (usrInfo == null)
            {
                returnObj.Msg = "无效用户";
                return(Json(returnObj));
            }
            XcxAppAccountRelation model = _xcxAppAccountRelationBLL.GetModelByAppid(usrInfo.appId);

            if (model == null)
            {
                returnObj.Msg = "无效模板";
                return(Json(returnObj));
            }

            PlatStore platStore = new PlatStore();

            if (storeId > 0)
            {
                platStore = PlatStoreBLL.SingleModel.GetModel(storeId);
            }
            else
            {
                platStore = PlatStoreBLL.SingleModel.GetModelByAId(model.Id);
            }
            if (platStore == null)
            {
                returnObj.Msg = "没有找到店铺";
                return(Json(returnObj));
            }
            string            errorMsg       = "";
            DeliveryFeeResult deliueryResult = DeliveryTemplateBLL.SingleModel.GetPlatFee(goodCartIds, platStore.Aid, province, city, ref errorMsg);

            if (errorMsg.Length > 0)
            {
                returnObj.Msg = errorMsg;
                return(Json(returnObj));
            }

            returnObj.Msg     = "获取成功";
            returnObj.isok    = true;
            returnObj.dataObj = new { deliueryResult = deliueryResult, storeaddress = platStore.Location };
            return(Json(returnObj));
        }
Пример #25
0
        /// <summary>
        /// 数据雷达
        /// </summary>
        /// <returns></returns>
        public ActionResult GetRadarData()
        {
            PlatRadarReportModel radar = new PlatRadarReportModel();

            returnObj = new Return_Msg_APP();
            int userId = Context.GetRequestInt("userid", 0);
            int aid    = Context.GetRequestInt("aid", 0);
            int type   = Context.GetRequestInt("type", 0);//-1:统计,0:本月,1:上个月

            if (userId <= 0)
            {
                returnObj.Msg = "userid不能为0";
                return(Json(returnObj));
            }
            PlatMyCard myCard = PlatMyCardBLL.SingleModel.GetModelByUserId(userId);

            if (myCard == null)
            {
                returnObj.Msg = "名片已过期";
                return(Json(returnObj));
            }

            string startTime = "";
            string endTime   = "";

            switch (type)
            {
            case -1: break;

            case 0:
                startTime = DateTime.Now.ToString("yyyy-MM") + "-1";
                endTime   = DateTime.Now.AddMonths(1).ToString("yyyy-MM") + "-1";
                break;

            case 1:
                startTime = DateTime.Now.AddMonths(1).ToString("yyyy-MM") + "-1";
                endTime   = DateTime.Now.AddMonths(2).ToString("yyyy-MM") + "-1";
                break;
            }

            #region  片数据分析
            //浏览量
            //点赞量
            //关注量
            //与多少人私信
            //转发量
            PlatMsgviewFavoriteShare reportData = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(aid, myCard.Id, (int)PointsDataType.片);
            radar.MyCardViewCount = myCard.FictitiousCount;
            if (reportData != null)
            {
                radar.MyCardDzCount     = reportData.DzCount;
                radar.MyCardViewCount  += reportData.ViewCount;
                radar.MyCardFollowCount = reportData.FollowCount;
                radar.MyCardShareCount  = reportData.ShareCount;
            }
            radar.MyCardSiXinCount = ImMessageBLL.SingleModel.GetCountByTuesrId(userId);

            //访客人数
            int visitorCount = PlatUserFavoriteMsgBLL.SingleModel.GetVisitorCount(myCard.Id, myCard.AId, (int)PointsDataType.片, startTime, endTime);
            radar.MyCardVisitorCount = visitorCount;
            #endregion

            #region 人脉关系统计
            //已关注人数
            int myFavoriteCount = PlatUserFavoriteMsgBLL.SingleModel.GetUserMsgCount(aid, 0, (int)PointsActionType.关注, (int)PointsDataType.片, userId);
            radar.FollowCount = myFavoriteCount;

            //粉丝人数
            int fanCount = PlatUserFavoriteMsgBLL.SingleModel.GetUserMsgCount(aid, myCard.Id, (int)PointsActionType.关注, (int)PointsDataType.片, 0);
            radar.FanCount = fanCount;

            //相互关注人数
            radar.MutualFollowCount = PlatUserFavoriteMsgBLL.SingleModel.GetMutualFollowCount(aid, userId);
            #endregion

            #region 平台入驻店铺数据统计
            PlatStore storeModel = PlatStoreBLL.SingleModel.GetPlatStore(myCard.Id, 1);
            if (storeModel != null)
            {
                //浏览量
                radar.StoreViewCount = storeModel.StorePV + storeModel.StoreVirtualPV;
                //收藏数
                List <PlatUserFavoriteMsg> storelist = PlatUserFavoriteMsgBLL.SingleModel.GetReportData(storeModel.Id, myCard.AId, (int)PointsDataType.店铺, startTime, endTime);
                if (storelist != null && storelist.Count > 0)
                {
                    PlatUserFavoriteMsg tempmodel = storelist.Where(w => w.ActionType == (int)PointsActionType.收藏).FirstOrDefault();
                    radar.StoreFavoriteCount = tempmodel == null ? 0 : tempmodel.Count;
                }

                //访客人数
                int storeVisitorCount = PlatUserFavoriteMsgBLL.SingleModel.GetVisitorCount(storeModel.Id, myCard.AId, (int)PointsDataType.店铺, startTime, endTime);
                radar.StoreVisitorCount = storeVisitorCount;
            }
            #endregion

            returnObj.isok    = true;
            returnObj.dataObj = radar;
            return(Json(returnObj));
        }
Пример #26
0
        /// <summary>
        /// 添加商品至购物车
        /// </summary>
        /// <returns></returns>
        public ActionResult AddGoodsCarData()
        {
            returnObj = new Return_Msg_APP();
            string attrSpacStr = Context.GetRequest("attrspacstr", "");
            //商品规格(格式):规格1:属性1 规格2:属性2 如:(颜色:白色 尺码:M)
            string specInfo = Context.GetRequest("specinfo", "");
            string specImg  = Context.GetRequest("specimg", "");
            int    goodId   = Context.GetRequestInt("goodid", 0);
            int    userId   = Context.GetRequestInt("userid", 0);
            int    qty      = Context.GetRequestInt("qty", 0);
            //立即购买,1:立即购买,0:添加到购物车
            int gotoBuy = Context.GetRequestInt("gotobuy", 2);

            if (qty <= 0)
            {
                returnObj.Msg = "数量必须大于0";
                return(Json(returnObj));
            }

            PlatChildGoods good = PlatChildGoodsBLL.SingleModel.GetModel(goodId);

            if (good == null)
            {
                returnObj.Msg = "未找到该商品";
                return(Json(returnObj));
            }
            PlatStore store = PlatStoreBLL.SingleModel.GetModelByAId(good.AId);

            if (store == null)
            {
                returnObj.Msg = "店铺已关闭";
                return(Json(returnObj));
            }
            if (!string.IsNullOrWhiteSpace(attrSpacStr))
            {
                //log4net.LogHelper.WriteInfo(this.GetType(),$"{JsonConvert.SerializeObject(good.GASDetailList)},{attrSpacStr}");
                if (!good.GASDetailList.Any(x => x.Id.Equals(attrSpacStr)))
                {
                    returnObj.Msg = "商品已过期";
                    return(Json(returnObj));
                }
            }
            if (!(good.State == 1 && good.Tag == 1))
            {
                returnObj.Msg = "无法添加失效商品";
                return(Json(returnObj));
            }
            C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(userId);

            if (userInfo == null)
            {
                returnObj.Msg = "用户不存在";
                return(Json(returnObj));
            }

            PlatChildGoodsCart car = PlatChildGoodsCartBLL.SingleModel.GetModelBySpec(userInfo.Id, goodId, attrSpacStr, 0);
            //商品价格
            int price = Convert.ToInt32(good.Price * 100);

            price = Convert.ToInt32(!string.IsNullOrWhiteSpace(attrSpacStr) ? good.GASDetailList.First(x => x.Id.Equals(attrSpacStr)).Price * 100 : good.Price * 100);

            if (car == null || gotoBuy == 1)
            {
                car = new PlatChildGoodsCart
                {
                    //FoodId = store.Id,
                    StoreId   = store.Id,
                    GoodsName = good.Name,
                    GoodsId   = good.Id,
                    SpecIds   = attrSpacStr,
                    Count     = qty,
                    Price     = price,
                    SpecInfo  = specInfo,
                    SpecImg   = specImg,//规格图片
                    UserId    = userInfo.Id,
                    AddTime   = DateTime.Now,
                    State     = 0,
                    GoToBuy   = gotoBuy,
                    AId       = good.AId,
                };

                //加入购物车
                int id = Convert.ToInt32(PlatChildGoodsCartBLL.SingleModel.Add(car));
                if (id > 0)
                {
                    int cartcount = PlatChildGoodsCartBLL.SingleModel.GetCartGoodsCountByUserId(userInfo.Id);
                    returnObj.Msg     = "成功";
                    returnObj.dataObj = new { id = id, count = cartcount };
                    returnObj.isok    = true;
                    return(Json(returnObj));
                }
            }
            else
            {
                car.Count += qty;
                if (PlatChildGoodsCartBLL.SingleModel.Update(car, "Count"))
                {
                    int cartcount = PlatChildGoodsCartBLL.SingleModel.GetCartGoodsCountByUserId(userInfo.Id);
                    returnObj.dataObj = new { id = car.Id, count = cartcount };
                    returnObj.Msg     = "成功";
                    returnObj.isok    = true;
                    return(Json(returnObj));
                }
            }

            returnObj.Msg = "失败";
            return(Json(returnObj));
        }
Пример #27
0
        /// <summary>
        /// 同步产品到 店铺所属平台 以及 所属平台的一级 二级代理商平台
        /// </summary>
        /// <param name="id"></param>
        /// <param name="platStore"></param>
        /// <param name="agentinfo"></param>
        /// <returns></returns>
        public bool SyncProduct(int id, PlatStore platStore, Agentinfo agentinfo)
        {
            TransactionModel tramModelGoodsRelation = new TransactionModel();

            #region 当前新增产品插入关系表
            PlatGoodsRelation platGoodsRelation = new PlatGoodsRelation();
            platGoodsRelation.AddTime = DateTime.Now;
            platGoodsRelation.Aid     = platStore.BindPlatAid;
            platGoodsRelation.GoodsId = id;
            PlatStoreCategoryConfig platStoreCategoryConfig = PlatStoreCategoryConfigBLL.SingleModel.GetModelByAid(platStore.BindPlatAid);
            if (platStoreCategoryConfig != null)
            {
                platGoodsRelation.Synchronized = platStoreCategoryConfig.SyncSwitch;
            }
            tramModelGoodsRelation.Add(PlatGoodsRelationBLL.SingleModel.BuildAddSql(platGoodsRelation));
            #endregion



            #region  //2.查找上级代理 暂时先屏蔽
            //AgentDistributionRelation agentDistributionRelationFirst = new AgentDistributionRelationBLL().GetModel(agentinfo.id);
            //if (agentDistributionRelationFirst != null)
            //{
            //    Agentinfo agentinfoFirst = _agentinfoBll.GetModel(agentDistributionRelationFirst.ParentAgentId);
            //    if (agentinfoFirst != null)
            //    {
            //        XcxAppAccountRelation xcxAppAccountRelationFirst = _xcxappaccountrelationBll.GetModelByaccountidAndTid(agentinfoFirst.useraccountid, (int)TmpType.小未平台);
            //        if (xcxAppAccountRelationFirst != null)
            //        {
            //            PlatGoodsRelation platGoodsRelationFist = new PlatGoodsRelation();
            //            platGoodsRelationFist.GoodsId = id;
            //            platGoodsRelationFist.AddTime = DateTime.Now;
            //            platGoodsRelationFist.Aid = xcxAppAccountRelationFirst.Id;
            //            PlatStoreCategoryConfig platStoreCategoryConfigFist = _platStoreCategoryConfigBLL.GetModelByAid(xcxAppAccountRelationFirst.Id);
            //            if (platStoreCategoryConfigFist != null)
            //            {
            //                platGoodsRelationFist.Synchronized = platStoreCategoryConfigFist.SyncSwitch;
            //            }
            //            tramModelGoodsRelation.Add(_platGoodsRelationBLL.BuildAddSql(platGoodsRelationFist));



            //            //3.查找上级的上级代理
            //            AgentDistributionRelation agentDistributionRelationSecond = new AgentDistributionRelationBLL().GetModel(agentinfoFirst.id);
            //            if (agentDistributionRelationSecond != null)
            //            {
            //                Agentinfo agentinfoSecond = _agentinfoBll.GetModel(agentDistributionRelationSecond.ParentAgentId);
            //                if (agentinfoSecond != null)
            //                {
            //                    XcxAppAccountRelation xcxAppAccountRelationSecond = _xcxappaccountrelationBll.GetModelByaccountidAndTid(agentinfoSecond.useraccountid, (int)TmpType.小未平台);
            //                    if (xcxAppAccountRelationSecond != null)
            //                    {
            //                        PlatGoodsRelation platGoodsRelationSecond = new PlatGoodsRelation();
            //                        platGoodsRelationSecond.GoodsId = id;
            //                        platGoodsRelationSecond.AddTime = DateTime.Now;
            //                        platGoodsRelationSecond.Aid = xcxAppAccountRelationSecond.Id;
            //                        PlatStoreCategoryConfig platStoreCategoryConfigSecond = _platStoreCategoryConfigBLL.GetModelByAid(xcxAppAccountRelationSecond.Id);
            //                        if (platStoreCategoryConfigSecond != null)
            //                        {
            //                            platGoodsRelationSecond.Synchronized = platStoreCategoryConfigSecond.SyncSwitch;
            //                        }
            //                        tramModelGoodsRelation.Add(_platGoodsRelationBLL.BuildAddSql(platGoodsRelationSecond));
            //                    }


            //                }
            //            }


            //        }
            //    }
            //}
            #endregion

            return(base.ExecuteTransactionDataCorect(tramModelGoodsRelation.sqlArray));
        }
Пример #28
0
        /// <summary>
        /// 小未平台独立模板运费
        /// </summary>
        /// <param name="goodcartids"></param>
        /// <param name="aid"></param>
        /// <param name="province"></param>
        /// <param name="city"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public DeliveryFeeResult GetPlatFee(string goodcartids, int aid, string province, string city, ref string msg)
        {
            DeliveryFeeResult deliueryResult = new DeliveryFeeResult();

            //购物车
            List <PlatChildGoodsCart> cartlist = PlatChildGoodsCartBLL.SingleModel.GetListByIds(goodcartids);

            if (cartlist == null || cartlist.Count <= 0)
            {
                msg = "运费:购物车数据为空";
                return(deliueryResult);
            }

            //商品
            string goodsid = string.Join(",", cartlist.Select(s => s.GoodsId));
            List <PlatChildGoods> goodslist = PlatChildGoodsBLL.SingleModel.GetListByIds(goodsid);

            if (goodslist == null || goodslist.Count <= 0)
            {
                msg = "运费:找不到商品数据";
                return(deliueryResult);
            }
            PlatStore store = PlatStoreBLL.SingleModel.GetModelByAId(aid);

            if (store == null)
            {
                msg = "运费:无效店铺";
                return(deliueryResult);
            }
            DeliveryFeeSumMethond sumMethod;
            PlatStoreSwitchModel  config = string.IsNullOrWhiteSpace(store.SwitchConfig) ? new PlatStoreSwitchModel() : JsonConvert.DeserializeObject <PlatStoreSwitchModel>(store.SwitchConfig);

            if (config.enableDeliveryTemplate)
            {
                if (!Enum.TryParse(config.deliveryFeeSumMethond.ToString(), out sumMethod))
                {
                    msg = "运费:无效运费模板";
                    return(deliueryResult);
                }

                List <DeliveryProduct> productInfo = new List <DeliveryProduct>();
                foreach (PlatChildGoods gooditem in goodslist)
                {
                    List <PlatChildGoodsCart> tempcartlist = cartlist.Where(w => w.GoodsId == gooditem.Id).ToList();
                    if (tempcartlist == null || tempcartlist.Count <= 0)
                    {
                        msg = "运费:无效购物车数据";
                        return(deliueryResult);
                    }
                    productInfo.Add(new DeliveryProduct
                    {
                        TemplateId = gooditem.TemplateId,
                        Name       = gooditem.Name,
                        Count      = tempcartlist.Sum(s => s.Count),
                    });
                }
                deliueryResult = GetDeliveryFeeCommon(productInfo, province, city, sumMethod);
            }

            if (deliueryResult == null)
            {
                msg = "运费:无效运费模板";
            }
            else if (!deliueryResult.InRange)
            {
                msg = string.IsNullOrEmpty(deliueryResult.Message) ? "不在配送范围内" : deliueryResult.Message;
            }

            return(deliueryResult);
        }
Пример #29
0
        /// <summary>
        /// 在平台店铺列表里新增没有主人的店铺
        /// </summary>
        /// <returns></returns>
        public ActionResult CreateStore(int aid = 0)
        {
            int storeId = Utility.IO.Context.GetRequestInt("storeId", 0);
            PlatStoreCategoryConfig platStoreCategoryConfig = PlatStoreCategoryConfigBLL.SingleModel.GetModelByAid(aid);

            if (platStoreCategoryConfig == null)
            {
                platStoreCategoryConfig = new PlatStoreCategoryConfig()
                {
                    Aid        = aid,
                    AddTime    = DateTime.Now,
                    Level      = 1,
                    SyncSwitch = 0
                };
                int id = Convert.ToInt32(PlatStoreCategoryConfigBLL.SingleModel.Add(platStoreCategoryConfig));
                if (id <= 0)
                {
                    return(View("PageError", new PlatReturnMsg()
                    {
                        Msg = "初始化数据异常!", code = "500"
                    }));
                }
            }

            List <PlatStoreCategory> list = new List <PlatStoreCategory>();

            list.Add(new PlatStoreCategory()
            {
                Id   = 0,
                Name = "请选择"
            });
            int totalCount = 0;

            ViewBag.firstCategoryId = 0;
            ViewBag.appId           = aid;
            list.AddRange(PlatStoreCategoryBLL.SingleModel.getListByaid(aid, out totalCount, platStoreCategoryConfig.Level == 1 ? 2 : 1, 100, 1));
            ViewBag.CategoryList  = list;
            ViewBag.CategoryLevel = platStoreCategoryConfig.Level;
            Agentinfo agentinfo = AgentinfoBLL.SingleModel.GetModelByAccoundId(dzuserId.ToString());

            ViewBag.AgentinfoId = agentinfo == null ? 0 : agentinfo.id;
            PlatStore platStore = PlatStoreBLL.SingleModel.GetModel(storeId);
            bool      isHave    = false;

            if (platStore == null)
            {
                platStore             = new PlatStore();
                platStore.BindPlatAid = aid;
                isHave = true;
            }
            else
            {
                PlatStoreCategory platStoreCategory = PlatStoreCategoryBLL.SingleModel.GetModel(platStore.Category);
                if (platStoreCategory != null)
                {
                    ViewBag.firstCategoryId = platStoreCategory.ParentId;
                }

                if (!string.IsNullOrEmpty(platStore.StoreService))
                {
                    platStore.StoreServiceModelList = JsonConvert.DeserializeObject <List <StoreServiceModel> >(platStore.StoreService);
                }
                else
                {
                    isHave = true;
                }
            }

            if (isHave)
            {
                List <StoreServiceModel> listService = new List <StoreServiceModel>();
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "WIFI"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "停车位"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "支付宝支付"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "微信支付"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "刷卡支付"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "空调雅座"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "付费停车"
                });
                listService.Add(new StoreServiceModel()
                {
                    ServiceState = true, ServiceName = "接送服务"
                });
                platStore.StoreServiceModelList = listService;
            }

            if (!string.IsNullOrEmpty(platStore.SwitchConfig))
            {
                platStore.SwitchModel = Newtonsoft.Json.JsonConvert.DeserializeObject <PlatStoreSwitchModel>(platStore.SwitchConfig);
            }
            else
            {
                platStore.SwitchModel = new PlatStoreSwitchModel();
            }


            return(View(platStore));
        }
Пример #30
0
        /// <summary>
        /// 更改店铺在平台的显示类别
        /// </summary>
        /// <returns></returns>
        public ActionResult UpdateStoreRelationCategory()
        {
            result = new PlatReturnMsg();
            int appId           = Utility.IO.Context.GetRequestInt("appId", 0);
            int storeRelationId = Utility.IO.Context.GetRequestInt("storeRelationId", 0);
            int categoryId      = Utility.IO.Context.GetRequestInt("Id", 0);

            if (appId <= 0 || storeRelationId <= 0 || categoryId <= 0)
            {
                result.Msg = "参数错误";
                return(Json(result, JsonRequestBehavior.AllowGet));
            }

            PlatStoreRelation platStoreRelation = PlatStoreRelationBLL.SingleModel.GetModel(storeRelationId);

            if (platStoreRelation == null || platStoreRelation.Aid != appId)
            {
                result.Msg = "操作异常";
                return(Json(result, JsonRequestBehavior.AllowGet));
            }

            TransactionModel tranModel = new TransactionModel();

            platStoreRelation.Category   = categoryId;
            platStoreRelation.UpdateTime = DateTime.Now;
            tranModel.Add(PlatStoreRelationBLL.SingleModel.BuildUpdateSql(platStoreRelation, "Category,UpdateTime"));
            if (platStoreRelation.FromType == 0)
            {
                //表示店铺入驻过来的,也就是本平台的 还需要更改店铺类别
                //否则没有权限更改店铺里的类别 只能更改在本平台显示的店铺类别 因为是同步其它代理商的
                PlatStore platStore = PlatStoreBLL.SingleModel.GetModel(platStoreRelation.StoreId);
                if (platStore == null && platStore.BindPlatAid != appId)
                {
                    result.Msg = "暂无权限操作";
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                platStore.Category   = categoryId;
                platStore.UpdateTime = DateTime.Now;
                tranModel.Add(PlatStoreBLL.SingleModel.BuildUpdateSql(platStore, "Category,UpdateTime"));
            }

            if (tranModel.sqlArray != null && tranModel.sqlArray.Length > 0)
            {
                if (PlatStoreRelationBLL.SingleModel.ExecuteTransactionDataCorect(tranModel.sqlArray))
                {
                    result.isok = true;
                    result.Msg  = "操作成功";
                    return(Json(result));
                }
                else
                {
                    result.Msg = "操作失败";
                    return(Json(result));
                }
            }
            else
            {
                result.Msg = "没有需要更新的数据";
                return(Json(result));
            }
        }