Exemple #1
0
        /// <summary>
        /// 获取店铺信息
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="storeid"></param>
        /// <param name="temptype"></param>
        /// <returns></returns>
        public ShopInfo GetStoreAddressPoint(int aid, int storeid, int temptype)
        {
            ShopInfo shopinfo = new ShopInfo();

            switch (temptype)
            {
            case (int)TmpType.小程序餐饮模板:
                shopinfo = FoodBLL.SingleModel.GetAddressPoint(aid); break;

            case (int)TmpType.智慧餐厅:
                shopinfo = DishStoreBLL.SingleModel.GetAddressPoint(storeid); break;
            }

            if (shopinfo != null)
            {
                //请求腾讯地图,获取城市和区域
                AddressApi addressInfo = AddressHelper.GetAddressByApi(shopinfo.Lng, shopinfo.Lat);
                if (addressInfo == null || addressInfo.result == null || addressInfo.result.address_component == null)
                {
                    log4net.LogHelper.WriteInfo(this.GetType(), "UU配送调用腾讯地图获取店铺地址异常:" + JsonConvert.SerializeObject(addressInfo));
                    return(shopinfo);
                }

                shopinfo.CityName   = addressInfo.result.address_component.city;
                shopinfo.CountyName = addressInfo.result.address_component.district;
            }

            return(shopinfo);
        }
Exemple #2
0
        /// <summary>
        /// 获取首页轮播图以及推荐商家
        /// </summary>
        /// <returns></returns>
        public ActionResult GetConfig()
        {
            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";
            string appId = Context.GetRequest("appId", string.Empty);

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

            int pageIndexAdImg   = Context.GetRequestInt("pageIndexAdImg", 1);
            int pageSizeAdImg    = Context.GetRequestInt("pageSizeAdImg", 10);
            int pageIndexTjStore = Context.GetRequestInt("pageIndexTjStore", 1);
            int pageSizeTjStore  = Context.GetRequestInt("pageSizeTjStore", 20);

            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

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

            string appname = "";
            OpenAuthorizerConfig openonfigmodel = OpenAuthorizerConfigBLL.SingleModel.GetModelByAppids(r.AppId);

            if (openonfigmodel != null)
            {
                appname = openonfigmodel.nick_name;
            }
            else
            {
                UserXcxTemplate userXcxModel = UserXcxTemplateBLL.SingleModel.GetModelByAppId(r.AppId);
                appname = userXcxModel?.Name;
            }
            int adImgCount, tjStoreCount = 0;
            List <PlatConfig> listADImg   = PlatConfigBLL.SingleModel.getListByaid(r.Id, out adImgCount, 0, pageSizeAdImg, pageIndexAdImg);
            List <PlatConfig> listTjStore = PlatConfigBLL.SingleModel.getListByaid(r.Id, out tjStoreCount, 1, pageSizeTjStore, pageIndexTjStore);

            string lngStr      = Context.GetRequest("lng", string.Empty);
            string latStr      = Context.GetRequest("lat", string.Empty);
            double lng         = 0.00;
            double lat         = 0.00;
            string curLocation = "未知城市";
            int    curCityCode = 0;

            if (!double.TryParse(lngStr, out lng) || !double.TryParse(latStr, out lat))
            {
                string IP = WebHelper.GetIP();

                IPToPoint iPToPoint = CommondHelper.GetLoctionByIP(IP);
                if (iPToPoint != null)
                {
                    lat    = iPToPoint.result.location.lat;
                    lng    = iPToPoint.result.location.lng;
                    lngStr = lng.ToString();
                    latStr = lat.ToString();
                    //log4net.LogHelper.WriteInfo(this.GetType(), $"IP={IP};{lat},{lng}");
                }
            }
            AddressApi addressinfo = AddressHelper.GetAddressByApi(lngStr, latStr);

            // log4net.LogHelper.WriteInfo(this.GetType(), Newtonsoft.Json.JsonConvert.SerializeObject(addressinfo));
            if (addressinfo != null && addressinfo.result != null && addressinfo.result.address_component != null)
            {
                curLocation = addressinfo.result.address_component.city;
                curCityCode = C_AreaBLL.SingleModel.GetCodeByName(curLocation);
            }


            listTjStore.ForEach(x =>
            {
                x.ObjName = x.ObjName.Length > 6 ? (x.ObjName.Substring(0, 5) + "...") : x.ObjName;
            });

            PlatConfig platConfigRemark = PlatConfigBLL.SingleModel.GetPlatConfig(r.Id, 3);
            var        remarkObj        = new { haveRemark = false, remark = string.Empty, remarkOpenFrm = false };

            if (platConfigRemark != null && !string.IsNullOrEmpty(platConfigRemark.ADImg))
            {
                remarkObj = new { haveRemark = true, remark = platConfigRemark.ADImg, remarkOpenFrm = platConfigRemark.ObjId == 0 };
            }

            PlatConfig platOther = PlatConfigBLL.SingleModel.GetPlatConfig(r.Id, 5);//获取平台其它设置

            if (platOther == null)
            {
                platOther = new PlatConfig()
                {
                    Aid = r.Id, AddTime = DateTime.Now, ConfigType = 5
                };
            }
            PlatOtherConfig platOtherConfig = new PlatOtherConfig();

            platOtherConfig.VirtualPV           = platOther.ADImgType;
            platOtherConfig.VirtualPlatMsgCount = platOther.ObjId;
            platOtherConfig.PlatMsgCount        = PlatMsgBLL.SingleModel.GetCountByAId(r.Id);
            platOtherConfig.PV = PlatStatisticalFlowBLL.SingleModel.GetPVCount(r.Id);

            int totalPV      = platOtherConfig.VirtualPV + platOtherConfig.PV;
            int totalMsgCout = platOtherConfig.PlatMsgCount + platOtherConfig.VirtualPlatMsgCount;

            PlatConfig platOfficialAccount = PlatConfigBLL.SingleModel.GetPlatConfig(r.Id, 6);//获取关注公众号设置

            if (platOfficialAccount == null)
            {
                platOfficialAccount = new PlatConfig()
                {
                    Aid = r.Id, AddTime = DateTime.Now, ConfigType = 6
                };
            }


            returnObj.dataObj = new
            {
                appname             = appname,
                ADImgs              = new { totalCount = adImgCount, list = listADImg },
                TjStores            = new { totalCount = tjStoreCount, list = listTjStore },
                Location            = new { curLocation = curLocation, curCityCode = curCityCode },
                platConfigRemark    = remarkObj,
                platOtherConfig     = new { TotalPV = totalPV > 100000?Convert.ToInt32(totalPV * 0.0001).ToString() + "万+": totalPV.ToString(), TotalMsgCount = totalMsgCout > 100000? Convert.ToInt32(totalMsgCout * 0.0001).ToString() + "万+": totalMsgCout.ToString() },
                platOfficialAccount = platOfficialAccount
            };
            returnObj.isok = true;
            returnObj.Msg  = "获取成功";
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        /// <summary>
        /// 创建名片
        /// </summary>
        /// <returns></returns>
        public ActionResult AddMyCard()
        {
            returnObj = new Return_Msg_APP();
            string imgUrl      = Context.GetRequest("imgurl", "");
            string companyName = Context.GetRequest("companyname", "");
            int    userId      = Context.GetRequestInt("userid", 0);
            int    jobType     = Context.GetRequestInt("jobtype", 0);
            string lat         = Context.GetRequest("lat", "0");
            string lng         = Context.GetRequest("lng", "0");
            string name        = Context.GetRequest("name", "");
            string address     = Context.GetRequest("address", "");
            string job         = Context.GetRequest("job", "");
            string department  = Context.GetRequest("department", "");
            string desc        = Context.GetRequest("desc", "");
            int    industryIid = Context.GetRequestInt("industryid", 0);
            int    hiddenPhone = Context.GetRequestInt("hiddenphone", 0);
            int    type        = Context.GetRequestInt("type", 0);

            if (userId <= 0)
            {
                returnObj.Msg = "userid不能小于0";
                return(Json(returnObj));
            }
            if (type == 1)
            {
                if (string.IsNullOrEmpty(lat))
                {
                    returnObj.Msg = "lat不能小于0";
                    return(Json(returnObj));
                }
                if (string.IsNullOrEmpty(lng))
                {
                    returnObj.Msg = "lng不能为空";
                    return(Json(returnObj));
                }
                if (string.IsNullOrEmpty(address))
                {
                    returnObj.Msg = "地址不能为空";
                    return(Json(returnObj));
                }
                if (string.IsNullOrEmpty(name))
                {
                    returnObj.Msg = "姓名不能为空";
                    return(Json(returnObj));
                }
                if (industryIid <= 0)
                {
                    returnObj.Msg = "请选择行业";
                    return(Json(returnObj));
                }
            }

            C_UserInfo userinfo = C_UserInfoBLL.SingleModel.GetModel(userId);

            if (userinfo == null)
            {
                returnObj.Msg = "用户已失效";
                return(Json(returnObj));
            }
            XcxAppAccountRelation xcxrelatiion = _xcxAppAccountRelationBLL.GetModelByAppid(userinfo.appId);

            if (xcxrelatiion == null)
            {
                returnObj.Msg = "模板已失效";
                return(Json(returnObj));
            }
            int aid = xcxrelatiion.Id;

            PlatMyCard platMyCardModel = PlatMyCardBLL.SingleModel.GetModelByUserId(userId, aid);

            //地址
            if (!string.IsNullOrEmpty(lng) && lng != "0" && !string.IsNullOrEmpty(lat) && lat != "0")
            {
                AddressApi addressinfo = AddressHelper.GetAddressByApi(lng, lat);
                if (addressinfo != null && addressinfo.result != null && addressinfo.result.address_component != null)
                {
                    string provinceName          = addressinfo.result.address_component.province;
                    string cityName              = addressinfo.result.address_component.city;
                    string countryName           = addressinfo.result.address_component.district;
                    Dictionary <string, int> dic = C_AreaBLL.SingleModel.GetAddressCode(provinceName, cityName, countryName);
                    if (platMyCardModel == null)
                    {
                        platMyCardModel = new PlatMyCard();
                    }
                    platMyCardModel.ProvinceCode = dic["provincename"];
                    platMyCardModel.ProvinceCode = dic["cityname"];
                    platMyCardModel.ProvinceCode = dic["countryName"];
                }
            }
            imgUrl = string.IsNullOrEmpty(imgUrl) ? userinfo.HeadImgUrl : imgUrl;
            //获取服务器商的图片路径
            bool isreload = false;

            imgUrl = WxUploadHelper.GetMyServerImgUrl(imgUrl, ref isreload);

            if (platMyCardModel == null || platMyCardModel.Id <= 0)
            {
                platMyCardModel             = new PlatMyCard();
                platMyCardModel.AddTime     = DateTime.Now;
                platMyCardModel.Address     = address;
                platMyCardModel.AId         = aid;
                platMyCardModel.CompanyName = companyName;
                platMyCardModel.Desc        = desc;
                platMyCardModel.ImgUrl      = imgUrl;
                platMyCardModel.JobType     = jobType;
                platMyCardModel.Lat         = Convert.ToDouble(lat);
                platMyCardModel.Lng         = Convert.ToDouble(lng);
                platMyCardModel.Name        = name;
                platMyCardModel.NickName    = userinfo.NickName;
                platMyCardModel.Phone       = userinfo.TelePhone;
                platMyCardModel.UpdateTime  = DateTime.Now;
                platMyCardModel.UserId      = userId;
                platMyCardModel.Job         = job;
                platMyCardModel.Department  = department;
                platMyCardModel.IndustryId  = industryIid;
                platMyCardModel.HiddenPhone = hiddenPhone;
                platMyCardModel.AppId       = userinfo.appId;
                platMyCardModel.Id          = Convert.ToInt32(PlatMyCardBLL.SingleModel.Add(platMyCardModel));
                returnObj.isok = platMyCardModel.Id > 0;
            }
            else
            {
                platMyCardModel.AddTime     = DateTime.Now;
                platMyCardModel.Address     = address;
                platMyCardModel.AId         = aid;
                platMyCardModel.CompanyName = companyName;
                platMyCardModel.Desc        = "";
                platMyCardModel.ImgUrl      = imgUrl;
                platMyCardModel.JobType     = jobType;
                platMyCardModel.Lat         = Convert.ToDouble(lat);
                platMyCardModel.Lng         = Convert.ToDouble(lng);
                platMyCardModel.Name        = name;
                platMyCardModel.NickName    = userinfo.NickName;
                platMyCardModel.Phone       = userinfo.TelePhone;
                platMyCardModel.UpdateTime  = DateTime.Now;
                platMyCardModel.UserId      = userId;
                platMyCardModel.IndustryId  = industryIid;
                platMyCardModel.HiddenPhone = hiddenPhone;
                if (!string.IsNullOrEmpty(job))
                {
                    platMyCardModel.Job = job;
                }
                if (!string.IsNullOrEmpty(department))
                {
                    platMyCardModel.Department = department;
                }
                if (!string.IsNullOrEmpty(companyName))
                {
                    platMyCardModel.CompanyName = companyName;
                }
                if (!string.IsNullOrEmpty(desc))
                {
                    platMyCardModel.Desc = desc;
                }
                returnObj.isok = PlatMyCardBLL.SingleModel.Update(platMyCardModel);
            }
            returnObj.Msg     = returnObj.isok ? "保存成功" : "保存失败";
            returnObj.dataObj = platMyCardModel;
            return(Json(returnObj));
        }
        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));
                }
            }
        }