public async Task <ThirdAddOrderResult> ThirdAddOrder(ThirdShopAddOrderModel model, ShopOrder order) { try { var parametermodel = new ThirdPartyDistributionParameterModel(); parametermodel.source_id = GetMerchant(model.ShopId).DaDaShopId.ToString(); shopDb.ThirdApiData.Add(new ThirdApiData() { ShopId = model.ShopId, DaDaShopId = Convert.ToInt32(parametermodel.source_id), AddTime = DateTime.Now, JsonData = JsonConvert.SerializeObject(order), ResultData = "ThirdAddOrder-Info", OrderId = model.origin_id }); //parametermodel.source_id = "73753"; // model.origin_id = "THIRD" + DateTime.Now.Ticks + CommonUtil.CreateNoncestr(5); var Data = JsonConvert.SerializeObject(model); parametermodel.body = Data; var data = parameter.ExThirdPartyDistributionParameterAction(parametermodel); var result = await httpClient.Post <ThirdAddOrderResult>($"{thirdoptions.Url}/api/order/addOrder", data); if (result.errorCode == 0 || result.status == "success") { shopDb.ThirdOrder.Add(new Data.ThirdOrder() { OrderNumber = order.OrderNumber, ShopId = model.ShopId, ThirdType = ThirdType.达达配送, OrderStatus = OrderStatus.待接单 }); shopDb.ThirdMoneyReport.Add(new Data.ThirdMoneyReport() { ShopId = model.ShopId, OrderNumber = order.OrderNumber, Amount = result.result.fee, AddTime = DateTime.Now, ProduceType = ProduceType.发起订单 }); } shopDb.ThirdApiData.Add(new ThirdApiData() { ShopId = model.ShopId, DaDaShopId = Convert.ToInt32(parametermodel.source_id), AddTime = DateTime.Now, JsonData = Data, ResultData = JsonConvert.SerializeObject(result), OrderId = model.origin_id }); shopDb.SaveChanges(); return(result); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <APIResult> ThirdMerchantAdd([FromBody] MerchantModel model) { var shop = shopDb.Shops.FirstOrDefault(r => r.Id == model.ShopId && !r.IsDel); if (shop == null) { throw new Exception("未找到商户"); } var parametermodel = new ThirdPartyDistributionParameterModel(); parametermodel.source_id = ""; var Data = JsonConvert.SerializeObject(model); parametermodel.body = Data; var data = parameter.ExThirdPartyDistributionParameterAction(parametermodel); var result = await httpClient.Post <ThirdResultModel>($"{thirdConfig.Url}/merchantApi/merchant/add", data); if (result.errorCode != 0 || result.status != "success") { throw new Exception(result.msg); } Merchant merchant = new Merchant(); merchant.CityName = model.city_name; merchant.ContactName = model.contact_name; merchant.ContactPhone = model.contact_phone; merchant.DaDaShopId = result.result; merchant.Email = model.email; merchant.EnterpriseAddress = model.enterprise_address; merchant.EnterpriseName = model.enterprise_name; merchant.Mobile = model.mobile; merchant.ShopId = shop.Id; shopDb.Merchant.Add(merchant); shopDb.SaveChanges(); return(Success(result)); }