public static bool UpdateCalculationCommission(OrderInfo order)
 {
     DistributorsInfo userIdDistributors = GetUserIdDistributors(order.ReferralUserId);
     bool flag = false;
     if (userIdDistributors != null)
     {
         Dictionary<string, LineItemInfo> lineItems = order.LineItems;
         LineItemInfo info2 = new LineItemInfo();
         DataView defaultView = CategoryBrowser.GetAllCategories().DefaultView;
         string str2 = null;
         string str3 = null;
         string str4 = null;
         decimal subTotal = 0M;
         foreach (KeyValuePair<string, LineItemInfo> pair in lineItems)
         {
             string key = pair.Key;
             info2 = pair.Value;
             DataTable productCategories = ProductBrowser.GetProductCategories(info2.ProductId);
             if ((productCategories.Rows.Count > 0) && (productCategories.Rows[0][0].ToString() != "0"))
             {
                 defaultView.RowFilter = " CategoryId=" + productCategories.Rows[0][0];
                 str2 = defaultView[0]["FirstCommission"].ToString();
                 str3 = defaultView[0]["SecondCommission"].ToString();
                 str4 = defaultView[0]["ThirdCommission"].ToString();
                 if ((!string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str3)) && !string.IsNullOrEmpty(str4))
                 {
                     ArrayList referralBlanceList = new ArrayList();
                     ArrayList userIdList = new ArrayList();
                     ArrayList ordersTotalList = new ArrayList();
                     subTotal = info2.GetSubTotal();
                     if (string.IsNullOrEmpty(userIdDistributors.ReferralPath))
                     {
                         referralBlanceList.Add((decimal.Parse(str2.Split(new char[] { '|' })[0]) / 100M) * info2.GetSubTotal());
                         userIdList.Add(order.ReferralUserId);
                         ordersTotalList.Add(subTotal);
                     }
                     else
                     {
                         string[] strArray = userIdDistributors.ReferralPath.Split(new char[] { '|' });
                         if (strArray.Length == 1)
                         {
                             referralBlanceList.Add((decimal.Parse(str2.Split(new char[] { '|' })[1]) / 100M) * info2.GetSubTotal());
                             userIdList.Add(strArray[0]);
                             ordersTotalList.Add(subTotal);
                             referralBlanceList.Add((decimal.Parse(str3.Split(new char[] { '|' })[0]) / 100M) * info2.GetSubTotal());
                             userIdList.Add(order.ReferralUserId);
                             ordersTotalList.Add(subTotal);
                         }
                         if (strArray.Length == 2)
                         {
                             referralBlanceList.Add((decimal.Parse(str2.Split(new char[] { '|' })[2]) / 100M) * info2.GetSubTotal());
                             userIdList.Add(strArray[0]);
                             ordersTotalList.Add(subTotal);
                             referralBlanceList.Add((decimal.Parse(str3.Split(new char[] { '|' })[1]) / 100M) * info2.GetSubTotal());
                             userIdList.Add(strArray[1]);
                             ordersTotalList.Add(subTotal);
                             referralBlanceList.Add((decimal.Parse(str4.Split(new char[] { '|' })[0]) / 100M) * info2.GetSubTotal());
                             userIdList.Add(order.ReferralUserId);
                             ordersTotalList.Add(subTotal);
                         }
                     }
                     flag = new DistributorsDao().UpdateCalculationCommission(userIdList, referralBlanceList, order.OrderId, ordersTotalList, order.UserId.ToString());
                 }
             }
         }
         flag = new DistributorsDao().UpdateDistributorsOrderNum(order.ReferralUserId.ToString(), order.GetTotal().ToString());
         RemoveDistributorCache(userIdDistributors.UserId);
     }
     return flag;
 }
Exemple #2
0
 public bool UpdateLineItem(string orderId, LineItemInfo lineItem, DbTransaction dbTran)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Hishop_OrderItems SET ShipmentQuantity=@ShipmentQuantity,ItemAdjustedPrice=@ItemAdjustedPrice,Quantity=@Quantity, PromotionId = NULL, PromotionName = NULL WHERE OrderId=@OrderId AND SkuId=@SkuId");
     this.database.AddInParameter(sqlStringCommand, "OrderId", DbType.String, orderId);
     this.database.AddInParameter(sqlStringCommand, "SkuId", DbType.String, lineItem.SkuId);
     this.database.AddInParameter(sqlStringCommand, "ShipmentQuantity", DbType.Int32, lineItem.ShipmentQuantity);
     this.database.AddInParameter(sqlStringCommand, "ItemAdjustedPrice", DbType.Currency, lineItem.ItemAdjustedPrice);
     this.database.AddInParameter(sqlStringCommand, "Quantity", DbType.Int32, lineItem.Quantity);
     if (dbTran != null)
     {
         return (this.database.ExecuteNonQuery(sqlStringCommand, dbTran) == 1);
     }
     return (this.database.ExecuteNonQuery(sqlStringCommand) == 1);
 }