예제 #1
0
        //private async Task<JsonData> DadaHandler(Order order)
        //{
        //    var result = new JsonData();
        //    var helper = HttpContext.RequestServices.GetService<DadaHelper>();
        //    var back = await helper.SendOrderAsync(order, Business);
        //    // 发送订单未成功
        //    if (!back.IsSuccess())
        //    {
        //        result.Msg = back.msg;
        //        order.ErrorReason = back.msg;
        //        Service.Commit();
        //        return result;
        //    }
        //    result.Success = Service.SendSuccess(order, back);
        //    result.Msg = result.Success ? "配送成功" : "接单异常或者已经接单";
        //    result.Data = new
        //    {
        //        Mode = DeliveryMode.Third,
        //        Logistics = LogisticsType.Dada,
        //        order.Status
        //    };
        //    return result;
        //}
        //private async Task<JsonData> DwdHandler(Order order)
        //{
        //    var result = new JsonData();
        //    var helper = HttpContext.RequestServices.GetService<DwdHelper>();
        //    var shop = GetDwdShop();
        //    if (shop == null)
        //    {
        //        result.Msg = "尚未创建点我达商户,请进入[第三方外卖管理->点我达设置]完成初始化操作";
        //        return result;
        //    }
        //    var back = await helper.SendOrderAsync(order, Business);
        //    // 发送订单未成功
        //    if (!back.success)
        //    {
        //        if(back.message == "服务不可用")
        //        {
        //            back.message = "账户余额不足,请充值,充值方法:第三方外卖管理->点我达设置->充值";
        //        }
        //        result.Msg = back.message;
        //        order.ErrorReason = back.message;
        //        Service.Commit();
        //        return result;
        //    }
        //    // 订单发送成功后,调用接口获取当前订单的配送费,并写入订单信息中
        //    var priceResult = await helper.GetOrderPrice(helper.GetOrderCode(order));
        //    if (priceResult.success)
        //    {
        //        order.CallbackCost = priceResult.result.receivable_price / 100;
        //    }
        //    result.Success = Service.SendDwdSuccess(order, back);
        //    result.Msg = result.Success ? "配送成功" : "接单异常或者已经接单";
        //    result.Data = new
        //    {
        //        Mode = order.DeliveryMode,
        //        Logistics = order.LogisticsType,
        //        order.Status,
        //        flow = order.DistributionFlow
        //    };
        //    return result;
        //}

        /// <summary>
        /// 配送完成,自己配送的订单,需要在管理页面点击完成按钮
        /// </summary>
        /// <returns></returns>
        public IActionResult Achieve(int id)
        {
            var result = new JsonData
            {
                Success = Service.Achieve(id)
            };

            result.Msg  = result.Success ? "配送完成" : "订单不存在";
            result.Data = OrderStatus.Achieve;
            return(Json(result));
        }