/// <summary> /// 发送订单 /// </summary> /// <returns></returns> public async Task <string> Send(YcfkOrder order, string key = null, string secret = null) { var action = "SendOrderData"; var content = JsonConvert.SerializeObject(order); return(await Request(action, content, key, secret)); }
/// <summary> /// 一城飞客发单 /// </summary> /// <param name="order"></param> /// <returns></returns> private async Task YcfkHandlerAsync(ThirdOrder order) { var helper = YcfkHelper.GetHelper(); var ycfkOrder = new YcfkOrder { OrderId = $"{order.OrderId}_{UtilHelper.RandNum()}_{order.OrderSource}", Flag = order.OrderSource == 0 ? "美团" : "饿了么", ViewOrderId = order.OrderId, ShopId = order.Business.StoreId, ShopName = order.Business.Name, OrderUserName = order.RecipientName, OrderUserPhone = order.RecipientPhone, OrderUserAddress = order.RecipientAddress, OrderRemark = order.Caution, BoxFee = Convert.ToDecimal(order.PackageFee), Freight = Convert.ToDecimal(order.ShippingFee), ActivityMoney = Convert.ToDecimal(order.OriginalAmount - order.Amount), ReachTime = order.DeliveryTime?.ToString("yyyy-MM-dd HH:mm:ss"), UserGaodeCoordinate = order.Longitude + "|" + order.Latitude, DayIndex = order.DaySeq }; ycfkOrder.FoodList = order.ThirdOrderProducts.Select(a => new YcfkFoodItem { FoodName = a.Name, FoodPrice = Convert.ToDecimal(a.Price), FoodCount = Convert.ToInt32(a.Quantity) }).ToList(); var json = await helper.Send(ycfkOrder, order.Business.YcfkKey, order.Business.YcfkSecret); try { var jObj = JObject.Parse(json); var code = jObj["StateCode"].Value <int>(); if (code > 0) { order.Error = jObj["StateMsg"].Value <string>(); //Log.Debug("一城飞客配送异常:" + json); return; } } catch (Exception e) { throw new Exception("一城飞客自动发单异常:" + e.Message + $"。返回值:【{json}】"); } //Log.Debug("一城飞客配送成功:" + json); order.Status = OrderStatus.DistributorReceipt; order.LogisticsType = LogisticsType.Yichengfeike; order.Error = ""; order.Data1 = ycfkOrder.OrderId; }