public ActionResult DelRule() { result = new PlatReturnMsg(); int appId = Utility.IO.Context.GetRequestInt("appId", 0); int ruleId = Utility.IO.Context.GetRequestInt("ruleId", 0); if (appId <= 0 || ruleId <= 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)); } PlatStoreAddRules model = PlatStoreAddRulesBLL.SingleModel.getRule(appId, ruleId); if (model == null) { result.Msg = "数据不存在"; return(Json(result)); } model.State = -1; model.UpdateTime = DateTime.Now; if (!PlatStoreAddRulesBLL.SingleModel.Update(model, "State,UpdateTime")) { result.Msg = "删除异常"; return(Json(result)); } result.isok = true; result.Msg = "删除成功"; return(Json(result)); }
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)); }
public ActionResult SaveRule(PlatStoreAddRules rule) { result = new PlatReturnMsg(); if (rule == null) { result.Msg = "数据不能为空"; return(Json(result)); } if (rule.Aid <= 0) { result.Msg = "appId非法"; return(Json(result)); } if (dzaccount == null) { result.Msg = "登录信息超时"; return(Json(result)); } if (!Regex.IsMatch(rule.YearCount.ToString(), @"^\+?[1-9][0-9]*$")) { result.Msg = "使用期限必须为大于零的整数"; return(Json(result)); } if (!Regex.IsMatch(rule.CostPrice.ToString(), @"^\+?[0-9][0-9]*$")) { result.Msg = "金额不合法"; return(Json(result)); } if (PlatStoreAddRulesBLL.SingleModel.GetRuleByYearCount(rule.Aid, rule.YearCount, rule.Id) != null) { result.Msg = "已存在相同使用年限规则"; return(Json(result)); } int Id = rule.Id; if (Id == 0) { //表示新增 Id = Convert.ToInt32(PlatStoreAddRulesBLL.SingleModel.Add(new PlatStoreAddRules() { YearCount = rule.YearCount, CostPrice = rule.CostPrice, AddTime = DateTime.Now, UpdateTime = DateTime.Now, Aid = rule.Aid, State = 0 })); if (Id > 0) { result.isok = true; result.Msg = "新增成功"; return(Json(result)); } else { result.Msg = "新增失败"; return(Json(result)); } } else { //表示更新 PlatStoreAddRules model = PlatStoreAddRulesBLL.SingleModel.GetModel(Id); if (model == null) { result.Msg = "不存在数据库里"; return(Json(result)); } if (model.Aid != rule.Aid) { result.Msg = "权限不足"; return(Json(result)); } model.UpdateTime = DateTime.Now; model.YearCount = rule.YearCount; model.CostPrice = rule.CostPrice; if (PlatStoreAddRulesBLL.SingleModel.Update(model, "UpdateTime,YearCount,CostPrice")) { result.isok = true; result.Msg = "更新成功"; return(Json(result)); } else { result.Msg = "更新失败"; return(Json(result)); } } }
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)); } } }