public void OrderDelivering(MessageModel message) { IOrderService orderService = new OrderService(); var model = JsonConvert.DeserializeObject <Delivering>(message.message); var entity = orderService.GetByOrderId(model.orderId); if (entity == null) { return; } if (string.IsNullOrWhiteSpace(model.phone)) { return; } entity.DispatcherName = model.name; entity.DispatcherMobile = model.phone; //骑手已经取餐&开启自动生成销售单 if (message.type == 55) { var shopConfig = _shopConfigService.GetAsync(entity.UserId, entity.ShopNo).Result; if (shopConfig.AutoSale == 1) { if (entity.OrderType == 0) //现购 { Bak365Service.CreateBakOrder(entity, "Sale"); entity.BuyState = 1; } else if (entity.OrderType == 1) //预定 { Bak365Service.FinPreOrder(entity.UserId, entity.OrderId); entity.BuyState = 3; } } } orderService.Update(entity); }
public void HandlePush(string type, string userId, string res) { if (string.IsNullOrEmpty(res)) { return; } var isSpecial = type == "OrderCanceled"; var obj = StringAnaly(res, isSpecial); if (obj == null || obj.Count <= 1) { return; //处理心跳 } var order = _orderService.GetByOrderId(obj["order_id"].ToString()); var fields = new List <string>(); switch (type) { case "OrderFinished": if (order is null) { OrderPayed(userId, res); return; } fields.Add("State"); order.State = 4; break; case "OrderCanceled": if (order is null) { return; } order.CancelCode = obj["reason_code"].ToString(); order.CancelReason = obj["reason"].ToString(); order.State = 2; fields.Add("CancelCode"); fields.Add("CancelReason"); fields.Add("State"); Bak365Service.SendBakNotice(obj[nameof(userId)].ToString(), obj["order_id"]?.ToString(), order.ShopNo, 1); break; case "OrderDeliveringStatus": if (order is null) { return; } var logisticsStatus = (MeituanEnum.LogisticsStatus)Enum.Parse(typeof(MeituanEnum.LogisticsStatus), obj["logistics_status"].ToString()); if (logisticsStatus != MeituanEnum.LogisticsStatus.F) { order.State = logisticsStatus.GetOrder(); fields.Add("State"); if (!string.IsNullOrWhiteSpace(obj["dispatcher_mobile"].ToString())) { order.DispatcherName = obj["dispatcher_name"].ToString(); order.DispatcherMobile = obj["dispatcher_mobile"].ToString(); fields.Add("DispatcherName"); fields.Add("DispatcherMobile"); } } //骑手已经取餐&开启自动生成销售单 if (logisticsStatus == MeituanEnum.LogisticsStatus.D) { var shopConfig = _shopConfigService.GetAsync(order.UserId, order.ShopNo).Result; if (shopConfig.AutoSale == 1) { if (order.OrderType == 0) //现购 { Bak365Service.CreateBakOrder(order, "Sale"); order.BuyState = 1; fields.Add("BuyState"); } else if (order.OrderType == 1) //预定 { Bak365Service.FinPreOrder(order.UserId, order.OrderId); order.BuyState = 3; fields.Add("BuyState"); } } } break; } _orderService.UpdateEntityFields(order, fields); }