public APIResult TestOfx() { var OpenOfx = BaiduMapUtil.GetBdToGd(113.76031219944932, 23.012808108215836); var thirddshopaddmodel = new ThirdShopAddOrderModel() { ShopId = 11, origin_id = DateTime.Now.Ticks + CommonUtil.CreateNoncestr(5),// //shop_no = "11047059",//测试 shop_no = "9896-126130", cargo_type = -1, cargo_price = 10, city_code = "0769", is_prepay = 0, origin_mark = "HCHH", origin_mark_no = DateTime.Now.Ticks + CommonUtil.CreateNoncestr(5), receiver_lng = 113.7538969583704, receiver_lat = 23.00648851131533, receiver_phone = "15812808736", receiver_address = "百安中心", receiver_name = "万", callback = thirdConfig.CallBackUrl, }; var result = DbExtention.ThirdAmountFinish(shopDb, thirdConfig, new BLL.Third.CThirdShopRechargeQueryModel() { ShopId = 11, category = 1 }).Result; var preresult = new ThirdServer(shopDb, thirdConfig).PreThirdAddOrder(thirddshopaddmodel); return(Success()); }
public async Task <APIResult> ThirdShopAdd([FromBody] ThirdShopArgs model) { if (model.ThirdShopModel == null) { throw new Exception("请输入门店信息"); } double lat = model.ThirdShopModel.FirstOrDefault().lat; double lng = model.ThirdShopModel.FirstOrDefault().lng; var converResult = BaiduMapUtil.GetBdToGd(model.ThirdShopModel.FirstOrDefault().lng, model.ThirdShopModel.FirstOrDefault().lat); model.ThirdShopModel.FirstOrDefault().lng = converResult.x; model.ThirdShopModel.FirstOrDefault().lat = converResult.y; var thirdshopcount = shopDb.ThirdShop.Where(r => r.ShopId == model.ShopId && r.Status == ThirdShop.ShopStatus.门店激活).Count(); if (thirdshopcount > 0) { throw new Exception("暂不支持多门店"); } var parametermodel = new ThirdPartyDistributionParameterModel(); parametermodel.source_id = GetMerchant(model.ShopId).DaDaShopId.ToString(); //"73753";// var Data = JsonConvert.SerializeObject(model.ThirdShopModel); parametermodel.body = Data; var data = parameter.ExThirdPartyDistributionParameterAction(parametermodel); var result = await httpClient.Post <ThirdShopResultModel>($"{thirdConfig.Url}/api/shop/add", data); if (result.code != 0 || result.status != "success") { throw new Exception(result.msg + "错误信息:" + result.result.failedList.FirstOrDefault().msg); } foreach (var item in model.ThirdShopModel) { shopDb.ThirdShop.Add(new ThirdShop() { ShopId = model.ShopId, AreaName = item.area_name, Business = item.business, CityName = item.city_name, ContactName = item.contact_name, IdCard = item.id_card, Lat = lat, Lng = lng, OriginShopId = item.origin_shop_id == null ? result.result.successList.FirstOrDefault().originShopId : item.origin_shop_id, Phone = item.phone, StationAddress = item.station_address, StationName = item.station_name, PassWord = item.password, UserName = item.username, Status = ThirdShop.ShopStatus.门店激活 }); shopDb.SaveChanges(); } return(Success(result)); }
public async Task <APIResult> ThirdShopUpdate([FromBody] ThirdShopUpdateModel model) { double lat = model.lat; double lng = model.lng; var converResult = BaiduMapUtil.GetBdToGd(model.lng, model.lat); var parametermodel = new ThirdPartyDistributionParameterModel(); parametermodel.source_id = GetMerchant(model.ShopId).DaDaShopId.ToString(); model.lng = converResult.x; model.lat = converResult.y; var Data = JsonConvert.SerializeObject(model); parametermodel.body = Data; var data = parameter.ExThirdPartyDistributionParameterAction(parametermodel); var result = await httpClient.Post <ThirdResultModel>($"{thirdConfig.Url}/api/shop/update", data); if (result.errorCode != 0 || result.status != "success") { throw new Exception(result.msg); } var thirdshop = shopDb.ThirdShop.FirstOrDefault(r => r.OriginShopId == model.origin_shop_id); if (thirdshop == null) { throw new Exception("找不到该门店"); } thirdshop.ShopId = model.ShopId; thirdshop.AreaName = model.area_name; thirdshop.Business = model.business; thirdshop.CityName = model.city_name; thirdshop.ContactName = model.contact_name; thirdshop.Lat = lat; thirdshop.Lng = lng; thirdshop.OriginShopId = model.new_shop_id == null ? model.origin_shop_id : model.new_shop_id; thirdshop.Phone = model.phone; thirdshop.StationAddress = model.station_address; thirdshop.StationName = model.station_name; // thirdshop.Status = model.status; shopDb.SaveChanges(); return(Success(result)); }
private APIResult CheckThird(ShopOrder shopOrder, int ShopId) { try { if (shopOrder.ShopPartId.HasValue || shopOrder.ShopOrderSelfHelpId.HasValue) { return(Success()); } var shopordertakeoutinfo = shopDb.ShopOrderTakeouts.FirstOrDefault(r => r.ShopOrderId == shopOrder.Id && !r.IsDel); if (shopordertakeoutinfo.TakeWay != TakeWay.送货上门) { return(Success()); } var shoptakeoutinfo = shopDb.ShopTakeOutInfo.FirstOrDefault(r => r.ShopId == ShopId && !r.IsDel); if (shoptakeoutinfo.TakeDistributionType == TakeDistributionType.商家配送) { return(Success()); } var thirdshop = shopDb.ThirdShop.FirstOrDefault(r => r.ShopId == ShopId); if (thirdshop == null || thirdshop.Status != Data.ThirdShop.ShopStatus.门店激活) { return(Error("配送门店状态不正常")); } var converResult = BaiduMapUtil.GetBdToGd(shopordertakeoutinfo.Longitude.Value, shopordertakeoutinfo.Latitude.Value); var thirddshopaddmodel = new ThirdShopAddOrderModel() { ShopId = shopOrder.ShopId, origin_id = shopOrder.OrderNumber, //DateTime.Now.Ticks + CommonUtil.CreateNoncestr(5),// //shop_no = "11047059",//测试 shop_no = thirdshop.OriginShopId, cargo_type = -1, cargo_price = shopOrder.Amount, city_code = "0769", is_prepay = 0, origin_mark = "HCHH", origin_mark_no = shopOrder.OrderNumber, receiver_lng = converResult.x, receiver_lat = converResult.y, receiver_phone = shopordertakeoutinfo.Phone, receiver_address = shopordertakeoutinfo.Address, receiver_name = shopordertakeoutinfo.Name, callback = thirdConfig.CallBackUrl, }; var result = DbExtention.ThirdAmountFinish(shopDb, thirdConfig, new BLL.Third.CThirdShopRechargeQueryModel() { ShopId = shopOrder.ShopId, category = 1 }).Result; var preresult = new ThirdServer(shopDb, thirdConfig).PreThirdAddOrder(thirddshopaddmodel); if (result.result.deliverBalance < preresult.result.fee) { return(Error("商家配送帐号余额不足")); } } catch (Exception ex) { throw new Exception($"出现错误:{ex.Message}{ex.StackTrace}"); } return(Success()); }