Exemplo n.º 1
0
        /// <summary>
        /// 完成订单
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public bool OrderComplete(OrderItemBase order)
        {
            /// bool= is overTime
            Action <int, bool> GenerateOrderStatistics = (i, b) =>
            {
                var time = PlayerManager.Instance.getCurrentTime();
                if (b)
                {
                    OrderStatisticsItem item = new OrderStatisticsItem(i, null, 1);
                    OrderStatisticsDic.Add(i, item);
                }
                else
                {
                    OrderStatisticsItem item = new OrderStatisticsItem(i, time);
                    OrderStatisticsDic.Add(i, item);
                }
            };

            if (!PlayerReceivedOrders.ContainsKey(order.dataModel.GUID))
            {
                ///首个订单超时
                if (order.orderState == OrderItemBase.OrderState.OverTime)
                {
                    GenerateOrderStatistics(order.OrderID, true);
                    return(true);
                }///首个订单完成
                else if (order.orderState == OrderItemBase.OrderState.Complete)
                {
                    AddOrderCompleteReward(order);
                    GenerateOrderStatistics(order.OrderID, false);
                    return(true);
                }
            }
            else///已有订单数据
            {
                var item = GetOrderStatisticsItem(order.OrderID);
                if (item == null)
                {
                    return(false);
                }
                if (order.orderState == OrderItemBase.OrderState.OverTime)
                {
                    item.OverTimeCount++;
                    return(true);
                }
                else if (order.orderState == OrderItemBase.OrderState.Complete)
                {
                    var time = PlayerManager.Instance.getCurrentTime();
                    AddOrderCompleteReward(order);
                    item.orderCompleteData.Add(new OrderStatisticsItem.OrderCompleteItem
                    {
                        completeID    = item.OrderCompleteCount + 1,
                        completeMonth = time.date.Month,
                        completeYear  = time.date.Year
                    });
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        public OrderStatisticsItem GetOrderStatisticsItem(int orderID)
        {
            OrderStatisticsItem item = null;

            OrderStatisticsDic.TryGetValue(orderID, out item);
            if (item == null)
            {
                Debug.LogError("orderStatistics Item get Error ,orderID=" + orderID);
            }
            return(item);
        }