/// <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); }
public GetAddesssApi(ApiKey apiKey, AdminKey adminKey, HttpClient httpClient = null) { _client = httpClient ?? new HttpClient { BaseAddress = _baseAddress }; _client.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); AdminKey = adminKey; ApiKey = apiKey; DomainWhitelist = new DomainWhitelistApi(AdminKey, this); IpAddressWhitelist = new IpAddressWhitelistApi(AdminKey, this); PrivateAddress = new PrivateAddressApi(AdminKey, this); Usage = new UsageApi(AdminKey, this); BillingAddress = new BillingAddressApi(AdminKey, this); Address = new AddressApi(ApiKey, this); FirstLimitReachedWebhook = new FirstLimitReachedWebhookApi(AdminKey, this); Subscription = new SubscriptionApi(adminKey, this); ApiKeyApi = new ApiKeyApi(adminKey, this); }
/// <summary> /// 生成快跑者配送订单 /// </summary> /// <param name="rid">权限表ID</param> /// <param name="userinfo">用户信息</param> /// <param name="orderid">订单ID</param> /// <param name="price">订单价格</param> /// <param name="receviename">收货人姓名</param> /// <param name="receviephone">收货人电话</param> /// <param name="address">收货人地址</param> /// <param name="lat">纬度</param> /// <param name="lnt">经度</param> /// <param name="ordertype">看枚举TmpType</param> /// <returns></returns> public string AddKPZOrder(DistributionApiModel model) { string msg = ""; KPZStoreRelation storerelation = KPZStoreRelationBLL.SingleModel.GetModelBySidAndAid(model.aid, model.storeid); if (storerelation == null) { msg = "请先配置快跑者配送"; return(msg); } //再请求一次腾讯地图,获取准确的坐标 AddressApi addressModel = AddressHelper.GetLngAndLatByAddress(model.address); if (addressModel != null && addressModel.result != null && addressModel.result.location != null) { model.lnt = addressModel.result.location.lng; model.lat = addressModel.result.location.lat; } TransactionModel tran = new TransactionModel(); string orderno = CommonCore.GetOrderNumByUserId(model.userid.ToString()); float buyprice = model.buyprice / 100.0f; float payfee = model.fee / 100.0f; int paystatus = 0; //店铺信息 ShopInfo shopinfo = GetStoreAddressPoint(storerelation.AId, storerelation.StoreId, model.temptype); //生成订单实体类对象 KPZOrder data = new KPZOrder(storerelation.Id, shopinfo.ShopName, storerelation.TelePhone, shopinfo.ShopAddress, shopinfo.ShopTag, model.ordercontent, model.remark, orderno, model.accepterName, model.accepterTelePhone, model.address, model.lnt + "," + model.lat, buyprice, buyprice, paystatus, payfee, model.orderid, model.aid, model.temptype, model.storeid); tran.Add(base.BuildAddSql(data)); if (!ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray)) { msg = "添加快跑者配送订单出错"; } return(msg); }
/// <summary> /// 达达运费 /// </summary> /// <param name="cityName"></param> /// <param name="appid"></param> /// <param name="openid"></param> /// <param name="lat"></param> /// <param name="lnt"></param> /// <param name="accepterName"></param> /// <param name="accepterPhone"></param> /// <param name="address"></param> /// <param name="msg"></param> /// <returns></returns> public int GetDadaFee(string cityName, string appid, string openid, string accepterName, string accepterPhone, string address, string lat, string lnt, ref string msg) { if (string.IsNullOrEmpty(appid)) { msg = "appid不能为空"; return(0); } if (!string.IsNullOrEmpty(address)) { //再请求一次腾讯地图,获取准确的坐标 AddressApi addressModel = AddressHelper.GetLngAndLatByAddress(address); if (addressModel != null && addressModel.result != null && addressModel.result.location != null) { lnt = addressModel.result.location.lng.ToString(); lat = addressModel.result.location.lat.ToString(); } else { msg = "达达配送:获取腾讯地址失败"; return(0); } } XcxAppAccountRelation umodel = XcxAppAccountRelationBLL.SingleModel.GetModelByAppid(appid); if (umodel == null) { msg = "达达配送:权限模板不能为空"; return(0); } C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModelByAppId_OpenId(appid, openid); if (userInfo == null) { msg = "达达配送:用户不存在"; return(0); } if (accepterName == null || accepterName.Length == 0) { msg = "达达配送:收货人姓名不能为空"; return(0); } if (accepterPhone == null || accepterPhone.Length == 0) { msg = "达达配送:收货人手机号不能为空"; return(0); } if (address == null || address.Length == 0) { msg = "达达配送:收货人地址不能为空"; return(0); } DadaMerchant merchant = DadaMerchantBLL.SingleModel.GetModelByRId(umodel.Id); if (merchant == null || merchant.id <= 0) { msg = "达达配送:商户还没开通达达配送"; return(0); } try { DadaOrder dadaOrderModel = GetDadaOrderModel(merchant.id, userInfo.Id, 0, cityName, 0, accepterName, accepterPhone, address, Convert.ToDouble(lat), Convert.ToDouble(lnt), "", ref msg); if (dadaOrderModel == null || !string.IsNullOrEmpty(msg)) { msg = $"达达配送:获取物流运费失败:" + msg; return(0); } DadaApiReponseModel <ResultReponseModel> postData = AddOrder(dadaOrderModel, merchant.sourceid, 2); if (postData != null && postData.result != null) { return(Convert.ToInt32(postData.result.deliverFee * 100)); } log4net.LogHelper.WriteInfo(this.GetType(), "达达运费出错:" + JsonConvert.SerializeObject(postData) + ",请求参数=" + JsonConvert.SerializeObject(dadaOrderModel)); msg = "获取运费出错"; } catch (Exception ex) { msg = ex.Message + ",msg" + msg; } return(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)); }
/// <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)); } } }
public void Init() { instance = new AddressApi(); }
/// <summary> /// 获取运费 /// </summary> /// <param name="storeid"></param> /// <param name="aid"></param> /// <param name="lat"></param> /// <param name="lnt"></param> /// <param name="orderprice"></param> /// <returns></returns> public int GetKPZFee(int storeid, int aid, string address, string lat, string lnt, int orderprice, ref string msg) { int fee = 0; KPZResult <KPZFee> result = new KPZResult <KPZFee>(); if (!string.IsNullOrEmpty(address)) { //再请求一次腾讯地图,获取准确的坐标 AddressApi addressModel = AddressHelper.GetLngAndLatByAddress(address); if (addressModel != null && addressModel.result != null && addressModel.result.location != null) { lnt = addressModel.result.location.lng.ToString(); lat = addressModel.result.location.lat.ToString(); } else { msg = "快跑者配送:获取腾讯地址失败"; return(0); } } XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aid); if (xcxrelation == null) { msg = "快跑者配送:权限模板不存在"; return(fee); } XcxTemplate xcxtemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId); if (xcxtemplate == null) { msg = "快跑者配送:小程序模板不存在"; return(fee); } KPZStoreRelation storerelation = KPZStoreRelationBLL.SingleModel.GetModelBySidAndAid(aid, storeid); if (storerelation == null) { msg = "快跑者配送:未设置快跑者配送配置"; return(fee); } int shopid = storerelation.Id; string sendtag = lnt + "," + lat; //店铺信息 ShopInfo shopinfo = GetStoreAddressPoint(storerelation.AId, storerelation.StoreId, xcxtemplate.Type); string payfee = "0"; if (shopinfo.ShopTag.Length <= 0) { msg = "快跑者配送:店铺经纬不能为空"; return(fee); } if (sendtag.Length <= 1) { msg = "快跑者配送:取货经纬不能为空"; return(fee); } result = KPZApi.GetFee(shopid, sendtag, shopinfo.ShopTag, (orderprice * 0.01).ToString("0.00"), payfee, storerelation.TeamToken); if (result == null) { log4net.LogHelper.WriteInfo(this.GetType(), "快跑者配送:返回结果为null,"); return(fee); } if (result.data == null) { log4net.LogHelper.WriteInfo(this.GetType(), "快跑者配送:返回运费为null,"); return(fee); } if (result.code == 200) { fee = Convert.ToInt32(result.data.pay_fee); return(fee); } else { msg = result.message; } if (result == null) { result = new KPZResult <KPZFee>(); result.code = 204; } //msg = "获取运费出错"; log4net.LogHelper.WriteInfo(this.GetType(), $"快跑者配送:请求参数,shopid【{shopid}】sendtag【{sendtag}】gettag【{shopinfo.ShopTag}】orderprice【{orderprice}】payfee【{payfee}】" + JsonConvert.SerializeObject(result)); return(fee); }
protected override void Page_Load(object sender, System.EventArgs e) { base.Page_Load(sender, e); if (!Ektron.Cms.DataIO.LicenseManager.LicenseManager.IsFeatureEnable(m_refContentApi.RequestInformationRef, Ektron.Cms.DataIO.LicenseManager.Feature.eCommerce)) { Utilities.ShowError(m_refContentApi.EkMsgRef.GetMessage("feature locked error")); } RegisterResources(); AppPath = m_refContentApi.ApplicationPath; try { if (!Utilities.ValidateUserLogin()) { return; } CommerceLibrary.CheckCommerceAdminAccess(); System.Web.HttpCookie siteCookie = CommonApiBase.GetEcmCookie(); Ektron.Cms.Commerce.CurrencyApi m_refCurrencyApi = new Ektron.Cms.Commerce.CurrencyApi(); defaultCurrency = (new CurrencyApi()).GetItem(m_refContentApi.RequestInformationRef.CommerceSettings.DefaultCurrencyId); if (siteCookie["SiteCurrency"] != defaultCurrency.Id.ToString()) { defaultCurrency.Id = Convert.ToInt32(siteCookie["SiteCurrency"]); defaultCurrency = m_refCurrencyApi.GetItem(defaultCurrency.Id); } if (!string.IsNullOrEmpty(Request.QueryString["customerid"])) { m_iCustomerId = Convert.ToInt64(Request.QueryString["customerid"]); } defaultCurrency = (new CurrencyApi()).GetItem(m_refContentApi.RequestInformationRef.CommerceSettings.DefaultCurrencyId); CustomerManager = new CustomerApi(); AddressManager = new AddressApi(); if (siteCookie["SiteCurrency"] != defaultCurrency.Id.ToString()) { defaultCurrency.Id = Convert.ToInt32(siteCookie["SiteCurrency"]); defaultCurrency = m_refCurrencyApi.GetItem(defaultCurrency.Id); } switch (base.m_sPageAction) { case "addeditaddress": RegionManager = new RegionApi(); CountryManager = new CountryApi(); if (Page.IsPostBack) { if (Request.Form[isCPostData.UniqueID] == "") { Process_ViewAddress(); } } else { Display_ViewAddress(true); } break; case "viewaddress": RegionManager = new RegionApi(); CountryManager = new CountryApi(); Display_ViewAddress(false); break; case "viewbasket": Display_ViewBaskets(false); break; case "view": Display_View(); break; case "deleteaddress": Process_AddressDelete(); break; case "deletebasket": Process_BasketDelete(); break; default: // "viewall" if (Page.IsPostBack == false) { Display_View_All(); } break; } Util_SetLabels(); Util_SetJS(); } catch (Exception ex) { Utilities.ShowError(ex.Message); } }