Ejemplo n.º 1
0
        public static dynamic GetCash(DataSource ds, long parent)
        {
            Distributor dis = GetById(ds, parent);

            int level = dis.Level;

            long[]      temp;
            List <long> all = new List <long>();

            all.Add(parent);
            Dictionary <int, long[]> dict = new Dictionary <int, long[]>();

            dict.Add(level, new long[] { parent });

            while (++level < 5)
            {
                if (dict.TryGetValue(level - 1, out temp) && temp != null && temp.Length > 0)
                {
                    temp = Db <Distributor> .Query(ds)
                           .Select(S("UserId"))
                           .Where(W("ParentId", temp, DbWhereType.In) & W("State", -1, DbWhereType.NotEqual))
                           .ToArray <long>();

                    if (temp != null && temp.Length > 0)
                    {
                        all.AddRange(temp);
                        dict.Add(level, temp);
                    }
                }
            }

            double               value;
            double               total  = 0;
            double               money  = 0;
            DateTime             now    = DateTime.Now.AddDays(-7);
            IList <ProductOrder> orders = Db <ProductOrder> .Query(ds)
                                          .Select(S("ShopId"), S("TotalMoney"), S("FreightMoney"), S("ReceiptDate"))
                                          .Where(W("ShopId", all, DbWhereType.In) & (/*W("State", OrderState.Evaluation) | */ W("State", OrderState.Finished)))
                                          .ToList <ProductOrder>();

            foreach (ProductOrder order in orders)
            {
                value  = dis.GetRoyalty(order);
                total += value;
                if (order.ReceiptDate <= now)
                {
                    money += value;
                }
            }

            return(new
            {
                Total = total,
                Money = money
            });
        }
Ejemplo n.º 2
0
 public static DataStatus UpdateConsignee(DataSource ds, Distributor distributor)
 {
     if (Db <Distributor> .Query(ds).Update().Set("Consignee", distributor.Consignee).Set("Mobile", distributor.Mobile)
         .Set("Address", distributor.Address).Execute() > 0)
     {
         return(DataStatus.Success);
     }
     else
     {
         return(DataStatus.Failed);
     }
 }
Ejemplo n.º 3
0
        public dynamic GetSaleArea(DataSource ds)
        {
            Distributor dis = Db <Distributor> .Query(ds).Select().Where(W("UserId", Subjection)).First <Distributor>();

            return(new { Province = dis.Province, City = dis.City, County = dis.County });
        }