Beispiel #1
0
        public JsonResult Remark(DishStore store, int?orderId, string remark = null)
        {
            if (!orderId.HasValue)
            {
                return(ApiModel(message: "参数不能为空[orderId]"));
            }

            DishOrder         order     = DishOrderBLL.SingleModel.GetModel(orderId.Value);
            DishOrderAttrbute orderAttr = order.GetAttrbute();

            orderAttr.mark = remark;
            order.attrbute = JsonConvert.SerializeObject(orderAttr);

            bool success = DishOrderBLL.SingleModel.Update(order, "attrbute");

            return(ApiModel(isok: success, message: success ? "操作成功" : "操作失败"));
        }
Beispiel #2
0
        /// <summary>
        /// 订单资料
        /// </summary>
        /// <param name="order"></param>
        /// <param name="act"></param>
        /// <returns></returns>
        public ActionResult Info(DishOrder order, string act = "", int psy_id = 0, string printer = null, string orderMark = null)
        {
            if (order.id <= 0)
            {
                _result.code = 0;
                _result.msg  = "未找到有效的订单标识";
                return(Json(_result, JsonRequestBehavior.AllowGet));
            }


            if (string.IsNullOrWhiteSpace(act))
            {
                EditModel <DishOrder> model = new EditModel <DishOrder>();

                model.DataModel = DishOrderBLL.SingleModel.GetModel(order.id) ?? new DishOrder();
                if (model.DataModel.id > 0)
                {
                    model.DataModel.carts = DishShoppingCartBLL.SingleModel.GetCartsByOrderId(model.DataModel.id) ?? new List <DishShoppingCart>();
                }
                model.aId     = model.appId = order.aId;
                model.storeId = order.storeId;

                ViewBag.dishTransporters = DishTransporterBLL.SingleModel.GetTransportersByparams(model.aId, model.storeId, true) ?? new List <DishTransporter>();
                return(View(model));
            }
            else
            {
                bool      isSuccess = false;
                DishOrder dbOrder   = DishOrderBLL.SingleModel.GetModel(order.id);
                if (dbOrder == null)
                {
                    _result.code = 0;
                    _result.msg  = "未找到相关订单";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }

                if (act == "changeTable")
                {
                    DishTable table = DishTableBLL.SingleModel.GetModel(order.order_table_id_zhen);
                    if (table == null)
                    {
                        _result.code = 0;
                        _result.msg  = "未找到相关桌台";
                        return(Json(_result, JsonRequestBehavior.AllowGet));
                    }

                    dbOrder.order_table_id_zhen = table.id;
                    dbOrder.order_table_id      = table.table_name;

                    isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "order_table_id,order_table_id_zhen");

                    _result.code = isSuccess ? 1 : 0;
                    _result.msg  = isSuccess ? "操作成功" : "操作失败";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
                else if (act == "queren")
                {
                    dbOrder.peisong_status = (int)DishEnums.DeliveryState.待取货;
                    isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "peisong_status");

                    _result.code = isSuccess ? 1 : 0;
                    _result.msg  = isSuccess ? "操作成功" : "操作失败";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
                else if (act == "quxiao")
                {
                    dbOrder.peisong_status = (int)DishEnums.DeliveryState.已取消;
                    isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "peisong_status");

                    _result.code = isSuccess ? 1 : 0;
                    _result.msg  = isSuccess ? "操作成功" : "操作失败";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
                else if (act == "wancheng")
                {
                    dbOrder.peisong_status = (int)DishEnums.DeliveryState.已完成;
                    isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "peisong_status");

                    _result.code = isSuccess ? 1 : 0;
                    _result.msg  = isSuccess ? "操作成功" : "操作失败";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
                else if (act == "peisong")
                {
                    if (psy_id <= 0)
                    {
                        _result.code = 0;
                        _result.msg  = "配送员标识错误";
                        return(Json(_result, JsonRequestBehavior.AllowGet));
                    }
                    DishTransporter transporter = DishTransporterBLL.SingleModel.GetModel(psy_id);
                    if (transporter == null)
                    {
                        _result.code = 0;
                        _result.msg  = "未找到配送员资料";
                        return(Json(_result, JsonRequestBehavior.AllowGet));
                    }
                    dbOrder.peisong_open       = 1;
                    dbOrder.peisong_status     = (int)DishEnums.DeliveryState.配送中;
                    dbOrder.peisong_user_name  = transporter.dm_name;
                    dbOrder.peisong_user_phone = transporter.dm_mobile;

                    isSuccess = DishOrderBLL.SingleModel.Update(dbOrder, "peisong_open,peisong_status,peisong_user_name,peisong_user_phone");

                    _result.code = isSuccess ? 1 : 0;
                    _result.msg  = isSuccess ? "操作成功" : "操作失败";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
                else if (act == "print") //打印
                {
                    PrinterHelper.DishPrintOrderByPrintType(dbOrder, 0, printer);
                    _result.code = 1;
                    _result.msg  = "操作成功";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
                else if (act == "mark")
                {
                    DishOrderAttrbute orderAttr = dbOrder.GetAttrbute();
                    orderAttr.mark   = orderMark;
                    dbOrder.attrbute = JsonConvert.SerializeObject(orderAttr);
                    isSuccess        = DishOrderBLL.SingleModel.Update(dbOrder, "attrbute");
                    _result.code     = isSuccess ? 1 : 0;
                    _result.msg      = isSuccess ? "操作成功" : "操作失败";
                    return(Json(_result, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(_result, JsonRequestBehavior.AllowGet));
        }