コード例 #1
0
ファイル: StoreController.cs プロジェクト: soon14/vzan
        public ActionResult AddSetting(int aid = 0)
        {
            if (aid <= 0)
            {
                return(View("PageError", new PlatReturnMsg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }

            PlatStoreAddSetting platStoreAddSetting = PlatStoreAddSettingBLL.SingleModel.GetPlatStoreAddSetting(aid);

            if (platStoreAddSetting == null)
            {
                platStoreAddSetting = new PlatStoreAddSetting()
                {
                    Aid        = aid,
                    AddWay     = 0,
                    AddTime    = DateTime.Now,
                    UpdateTime = DateTime.Now
                };
                int id = Convert.ToInt32(PlatStoreAddSettingBLL.SingleModel.Add(platStoreAddSetting));
            }
            else
            {
                if (platStoreAddSetting.AddWay == 1 && PlatStoreAddRulesBLL.SingleModel.GetRuleCount(aid) <= 0)
                {
                    platStoreAddSetting.AddWay     = 0;
                    platStoreAddSetting.UpdateTime = DateTime.Now;
                    if (!PlatStoreAddSettingBLL.SingleModel.Update(platStoreAddSetting, "AddWay,UpdateTime"))
                    {
                        return(View("PageError", new PlatReturnMsg()
                        {
                            Msg = "初始化异常!", code = "500"
                        }));
                    }
                }
            }
            ViewBag.AddWay  = platStoreAddSetting.AddWay;
            ViewBag.AddRule = new PlatStoreAddRules()
            {
                Aid        = aid,
                AddTime    = DateTime.Now,
                YearCount  = 1,
                CostPrice  = 1000,
                UpdateTime = DateTime.Now
            };
            ViewBag.appId = aid;
            return(View());
        }
コード例 #2
0
ファイル: StoreController.cs プロジェクト: soon14/vzan
        public ActionResult SaveAddSetting()
        {
            result = new PlatReturnMsg();
            int appId  = Utility.IO.Context.GetRequestInt("appId", 0);
            int addWay = Utility.IO.Context.GetRequestInt("addWay", 0);

            if (appId <= 0 || addWay < 0)
            {
                result.Msg = "参数错误";
                return(Json(result));
            }

            if (dzaccount == null)
            {
                result.Msg = "登录信息超时";
                return(Json(result));
            }

            XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

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

            PlatStoreAddSetting platStoreAddSetting = PlatStoreAddSettingBLL.SingleModel.GetPlatStoreAddSetting(appId);

            if (platStoreAddSetting == null)
            {
                result.Msg = "数据不存在";
                return(Json(result));
            }


            platStoreAddSetting.AddWay     = addWay;
            platStoreAddSetting.UpdateTime = DateTime.Now;
            if (!PlatStoreAddSettingBLL.SingleModel.Update(platStoreAddSetting, "AddWay,UpdateTime"))
            {
                result.Msg = "设置异常";
                return(Json(result));
            }

            result.isok = true;
            result.Msg  = "设置成功";
            return(Json(result));
        }
コード例 #3
0
        /// <summary>
        /// 获取平台入驻模式配置
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="configType"></param>
        /// <returns></returns>
        public ActionResult GetAddStoreConfig(int aid = 0)
        {
            returnObj = new Return_Msg_APP();
            if (aid <= 0)
            {
                returnObj.Msg = "参数错误";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            int totalCount = 0;
            List <PlatStoreAddRules> list = PlatStoreAddRulesBLL.SingleModel.getListByaid(aid, out totalCount, 1000, 1);
            PlatStoreAddSetting      platStoreAddSetting = PlatStoreAddSettingBLL.SingleModel.GetPlatStoreAddSetting(aid);

            returnObj.dataObj = new { AddWay = (platStoreAddSetting != null? platStoreAddSetting.AddWay:0), rules = list };
            returnObj.isok    = true;
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
ファイル: apiPlatStoreController.cs プロジェクト: soon14/vzan
        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));
                }
            }
        }