public override OpRes doQuery(object param, GMUser user)
    {
        m_result.Clear();
        ParamRealTimeOrder p    = (ParamRealTimeOrder)param;
        string             cond = "";
        OpRes res = getQueryCond(p, user, ref cond);

        if (res != OpRes.opres_success)
        {
            return(res);
        }

        string cmd = string.Format(SQL_QUERY_REAL_TIME_ORDER,
                                   TableName.PLAYER_ORDER_COMPLETE,
                                   cond,
                                   (p.m_curPage - 1) * p.m_countEachPage,
                                   p.m_countEachPage);

        // 查看满足条件的记当个数
        user.totalRecord = user.sqlDb.getRecordCountNoWhere(TableName.PLAYER_ORDER_COMPLETE,
                                                            cond, user.getMySqlServerID(), MySqlDbName.DB_XIANXIA);

        List <Dictionary <string, object> > dataList = user.sqlDb.queryList(cmd,
                                                                            user.getMySqlServerID(), MySqlDbName.DB_XIANXIA);

        if (dataList == null)
        {
            return(OpRes.op_res_failed);
        }

        for (int i = 0; i < dataList.Count; i++)
        {
            OrderInfoItem info = new OrderInfoItem();
            m_result.Add(info);

            Dictionary <string, object> data = dataList[i];
            info.m_orderId    = Convert.ToString(data["orderId"]);
            info.m_apiOrderId = Convert.ToString(data["apiOrderId"]);
            info.m_genTime    = Convert.ToDateTime(data["genTime"]);
            info.m_finishTime = Convert.ToDateTime(data["finishTime"]);
            info.m_gmAcc      = Convert.ToString(data["gmAcc"]);
            info.m_playerAcc  = Convert.ToString(data["playerAcc"]);
            info.m_orderType  = Convert.ToInt32(data["orderType"]);
            info.m_money      = Convert.ToInt64(data["money"]);
            info.m_orderState = Convert.ToInt32(data["orderState"]);
            info.m_failReason = Convert.ToInt32(data["failReason"]);
        }

        return(OpRes.opres_success);
    }
Example #2
0
        public OrderInfoOutput RetrieveOrderItemsByOrderId([FromBody] OrderInfoInput input)
        {
            OrderInfoOutput output = new OrderInfoOutput();

            if (input == null)
            {
                output.Result = "INPUT_IS_NULL";
            }
            else
            {
                Order order = _db.Orders.Where(e => e.Id.Equals(input.OrderId) && e.Deleted == false).FirstOrDefault();

                if (order == null)
                {
                    output.Result = "ORDER_NOT_EXIST";
                }
                else
                {
                    List <OrderInfoItem> newItems = new List <OrderInfoItem>();
                    foreach (OrderItem item in order.OrderItems.Where(e => e.Deleted == false).ToList())
                    {
                        OrderInfoItem checkItem = newItems.Where(e => e.OrderItemId.Equals(item.Id)).FirstOrDefault();
                        if (checkItem != null)
                        {
                            checkItem.Quantity += item.Quantity;
                        }
                        else
                        {
                            OrderInfoItem newItem = new OrderInfoItem()
                            {
                                Name               = item.MenuItem.Name,
                                OrderItemId        = item.Id,
                                MenuItemId         = item.MenuItem.Id,
                                OrderItemUnitPrice = item.UnitPrice,
                                Quantity           = item.Quantity,
                                Status             = 2
                            };
                            newItems.Add(newItem);
                        }
                    }

                    output.Items  = newItems;
                    output.Result = "OK";
                }
            }

            return(output);
        }
Example #3
0
        public OrderInfoOutput GetActiveOrderById([FromBody] OrderInfoInput input)
        {
            OrderInfoOutput output = new OrderInfoOutput();

            if (input == null)
            {
                output.Result = "INPUT_IS_NULL";
            }
            else
            {
                Order order = _db.Orders.Where(e => e.Id.Equals(input.OrderId) && e.Deleted == false && e.Status == 1).FirstOrDefault();
                if (order == null)
                {
                    output.Result = "ORDER_NOT_EXIST";
                }
                else
                {
                    List <OrderInfoItem> orderInfoItems = new List <OrderInfoItem>();
                    foreach (OrderItem item in order.OrderItems.ToList())
                    {
                        if (item.QuantityPaid > 0)
                        {
                            OrderInfoItem newItem = new OrderInfoItem()
                            {
                                Name               = item.MenuItem.Name,
                                OrderItemId        = item.Id,
                                OrderItemUnitPrice = item.MenuItem.Price,
                                Quantity           = item.QuantityPaid,
                                Status             = 2
                            };

                            orderInfoItems.Add(newItem);

                            if (item.Quantity - item.QuantityPaid > 0)
                            {
                                OrderInfoItem newItem2 = new OrderInfoItem()
                                {
                                    Name               = item.MenuItem.Name,
                                    OrderItemId        = item.Id,
                                    OrderItemUnitPrice = item.MenuItem.Price,
                                    Quantity           = item.Quantity - item.QuantityPaid,
                                    Status             = 1
                                };

                                orderInfoItems.Add(newItem2);
                            }
                        }
                        else
                        {
                            OrderInfoItem newItem = new OrderInfoItem()
                            {
                                Name               = item.MenuItem.Name,
                                OrderItemId        = item.Id,
                                OrderItemUnitPrice = item.MenuItem.Price,
                                Quantity           = item.Quantity,
                                Status             = item.Status
                            };

                            orderInfoItems.Add(newItem);
                        }
                    }

                    output.Result = "OK";
                    output.Items  = orderInfoItems.OrderBy(e => e.Status).ToList();
                }
            }
            return(output);
        }
Example #4
0
        private List <OrderInfoItem> OrderItems(int orderId, QueryWithSettings qs)
        {
            List <OrderInfoItem> result = new List <OrderInfoItem>();
            int f_OrderItemID = -1, f_Id = -1, f_Articul = -1, f_PartNumber = -1, f_Name = -1, f_BrandCode = -1;
            int f_Qty = -1, f_CartPrice = -1, f_CartAmount = -1, f_CartDeliveryAmount = -1, f_CartVatAmount = -1, f_CartVatTotalAmount = -1;

            int f_StatusID = -1, f_StatusCode = -1, f_StatusDescr = -1;
            int f_StatusTypeID = -1, f_StatusTypeCode = -1, f_StatusTypeDescr = -1;

            AppSettings.Query.GlobalParts.Execute(@"Account\[r_OrderItemGet]", new SqlParameter[]
            {
                new SqlParameter()
                {
                    ParameterName = "@LocaleLanguageID", Value = qs.languageId
                },
                new SqlParameter()
                {
                    ParameterName = "@OrderHeaderID", Value = orderId
                },
            }
                                                  , onExecute: (reader) =>
            {
                string fname;
                for (int i = 0, icount = reader.FieldCount; i < icount; i++)
                {
                    fname = reader.GetName(i);
                    if (fname == "OrderItemID")
                    {
                        f_OrderItemID = i;
                    }
                    else if (fname == "GoodsID")
                    {
                        f_Id = i;
                    }
                    else if (fname == "Articul")
                    {
                        f_Articul = i; f_PartNumber = i;
                    }
                    else if (fname == "Descr")
                    {
                        f_Name = i;
                    }
                    else if (fname == "Brand")
                    {
                        f_BrandCode = i;
                    }
                    else if (fname == "Qty")
                    {
                        f_Qty = i;
                    }

                    else if (fname == "CartPrice")
                    {
                        f_CartPrice = i;
                    }
                    else if (fname == "CartAmount")
                    {
                        f_CartAmount = i;
                    }
                    else if (fname == "CartDeliveryAmount")
                    {
                        f_CartDeliveryAmount = i;
                    }
                    else if (fname == "CartVatAmount")
                    {
                        f_CartVatAmount = i;
                    }
                    else if (fname == "CartVatTotalAmount")
                    {
                        f_CartVatTotalAmount = i;
                    }

                    else if (fname == "StatusID")
                    {
                        f_StatusID = i;
                    }
                    else if (fname == "StatusCode")
                    {
                        f_StatusCode = i;
                    }
                    else if (fname == "StatusDescr")
                    {
                        f_StatusDescr = i;
                    }

                    else if (fname == "StatusTypeID")
                    {
                        f_StatusTypeID = i;
                    }
                    else if (fname == "StatusTypeCode")
                    {
                        f_StatusTypeCode = i;
                    }
                    else if (fname == "StatusTypeDescr")
                    {
                        f_StatusTypeDescr = i;
                    }
                }
            }
                                                  , (values) =>
            {
                int id = 0;
                if (f_OrderItemID > -1)
                {
                    id = values[f_OrderItemID].ToInt();
                }
                else
                {
                    return;
                }


                OrderInfoItem item = new OrderInfoItem()
                {
                    OrderItemID = id, Brand = new Brand(), Status = new Status(), StatusType = new StatusType()
                };
                result.Add(item);

                if (f_Id > -1)
                {
                    item.Id = values[f_Id].ToInt();
                }
                if (f_PartNumber > -1)
                {
                    item.PartNumber = values[f_PartNumber].ToStr();
                }
                if (f_Name > -1)
                {
                    item.Name = values[f_Name].ToStr();
                }
                if (f_Articul > -1)
                {
                    item.Articul = values[f_Articul].ToStr();
                }
                if (f_BrandCode > -1)
                {
                    item.Brand.Code = values[f_BrandCode].ToStr();
                }

                if (f_Qty > -1)
                {
                    item.Qty = values[f_Qty].ToDecimal();
                }
                if (f_CartPrice > -1)
                {
                    item.Price = values[f_CartPrice].ToDecimal();
                }

                if (f_CartAmount > -1)
                {
                    item.Amount = values[f_CartAmount].ToDecimal();
                }
                if (f_CartDeliveryAmount > -1)
                {
                    item.DeliveryAmount = values[f_CartDeliveryAmount].ToDecimal();
                }
                if (f_CartVatAmount > -1)
                {
                    item.VatAmount = values[f_CartVatAmount].ToDecimal();
                }
                if (f_CartVatTotalAmount > -1)
                {
                    item.TotalAmount = values[f_CartVatTotalAmount].ToDecimal();
                }

                if (f_StatusID > -1)
                {
                    item.Status.Id = values[f_StatusID].ToInt();
                }
                if (f_StatusCode > -1)
                {
                    item.Status.Code = values[f_StatusCode].ToStr();
                }
                if (f_StatusDescr > -1)
                {
                    item.Status.Name = values[f_StatusDescr].ToStr();
                }

                if (f_StatusTypeID > -1)
                {
                    item.StatusType.Id = values[f_StatusTypeID].ToInt();
                }
                if (f_StatusTypeCode > -1)
                {
                    item.StatusType.Code = values[f_StatusTypeCode].ToStr();
                }
                if (f_StatusTypeDescr > -1)
                {
                    item.StatusType.Name = values[f_StatusTypeDescr].ToStr();
                }
            });

            return(result);
        }