Ejemplo n.º 1
0
        public bool CommissionToAmount(MemberAmountDetailedInfo amountinfo, int userid, decimal amount)
        {
            bool flag = this.CreatAmount(amountinfo);

            if (flag)
            {
                flag = this.UpdateMember(amountinfo);
                if (flag)
                {
                    flag = new DistributorsDao().UpdateBalanceDistributors(userid, amount);
                    if (flag)
                    {
                        BalanceDrawRequestInfo balanceDrawRequestInfo = new BalanceDrawRequestInfo();
                        MemberInfo             member = new MemberDao().GetMember(userid);
                        balanceDrawRequestInfo.UserId       = member.UserId;
                        balanceDrawRequestInfo.RequestType  = 4;
                        balanceDrawRequestInfo.UserName     = member.UserName;
                        balanceDrawRequestInfo.RequestTime  = DateTime.Now;
                        balanceDrawRequestInfo.Amount       = amount;
                        balanceDrawRequestInfo.AccountName  = (string.IsNullOrEmpty(member.RealName) ? member.UserName : member.RealName);
                        balanceDrawRequestInfo.BankName     = "";
                        balanceDrawRequestInfo.MerchantCode = "佣金转余额";
                        balanceDrawRequestInfo.Remark       = "";
                        balanceDrawRequestInfo.CheckTime    = DateTime.Now;
                        balanceDrawRequestInfo.CellPhone    = (string.IsNullOrEmpty(member.CellPhone) ? "" : member.CellPhone);
                        balanceDrawRequestInfo.IsCheck      = "2";
                        flag = this.AddBalanceDrawRequest(balanceDrawRequestInfo);
                    }
                }
            }
            return(flag);
        }
Ejemplo n.º 2
0
 public static IList<string> BatchCreateMembers(IList<string> distributornames, int referruserId, string createtype = "1")
 {
     string str = string.Empty;
     string referralPath = string.Empty;
     IList<string> list = new List<string>();
     if (referruserId > 0)
     {
         referralPath = new DistributorsDao().GetDistributorInfo(referruserId).ReferralPath;
         if (string.IsNullOrEmpty(referralPath))
         {
             referralPath = referruserId.ToString();
         }
         else if (referralPath.Contains("|"))
         {
             referralPath = referralPath.Split(new char[] { '|' })[1];
         }
         else
         {
             referralPath = referralPath + "|" + referruserId.ToString();
         }
     }
     foreach (string str3 in distributornames)
     {
         MemberInfo member = new MemberInfo();
         string generateId = Globals.GetGenerateId();
         member.GradeId = new MemberGradeDao().GetDefaultMemberGrade();
         member.UserName = str3;
         member.CreateDate = DateTime.Now;
         member.SessionId = generateId;
         member.SessionEndTime = DateTime.Now.AddYears(10);
         member.Password = HiCryptographer.Md5Encrypt("888888");
         if ((new MemberDao().GetusernameMember(str3) == null) && new MemberDao().CreateMember(member))
         {
             DistributorsInfo distributor = new DistributorsInfo {
                 UserId = new MemberDao().GetusernameMember(str3).UserId,
                 RequestAccount = str3,
                 StoreName = str3,
                 StoreDescription = str3,
                 BackImage = "/Storage/data/DistributorBackgroundPic/default.jpg",
                 Logo = "/Utility/pics/headLogo.jpg"
             };
             str = distributor.UserId.ToString();
             distributor.ReferralPath = referralPath;
             distributor.DistributorGradeId = (referralPath.Split(new char[] { '|' }).Length == 1) ? DistributorGrade.TowDistributor : DistributorGrade.ThreeDistributor;
             distributor.ParentUserId = new int?(Convert.ToInt32((referralPath.Split(new char[] { '|' }).Length == 1) ? referralPath : referralPath.Split(new char[] { '|' })[1].ToString()));
             if (new DistributorsDao().CreateDistributor(distributor) && (createtype == "1"))
             {
                 list.Add(str3);
             }
         }
         else if (createtype == "2")
         {
             list.Add(str3);
         }
     }
     return list;
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 public static DistributorsInfo GetCurrentDistributors(int userId)
 {
     DistributorsInfo distributorInfo = HiCache.Get(string.Format("DataCache-Distributor-{0}", userId)) as DistributorsInfo;
     if ((distributorInfo == null) || (distributorInfo.UserId == 0))
     {
         distributorInfo = new DistributorsDao().GetDistributorInfo(userId);
         HiCache.Insert(string.Format("DataCache-Distributor-{0}", userId), distributorInfo, 360, CacheItemPriority.Normal);
     }
     return distributorInfo;
 }
Ejemplo n.º 5
0
 public static string GetAllDistributorsName(string keysearch)
 {
     string str = "";
     DataTable allDistributorsName = new DistributorsDao().GetAllDistributorsName(keysearch);
     foreach (DataRow row in allDistributorsName.Rows)
     {
         string str3 = str;
         str = str3 + "{\"title\":\"" + Globals.HtmlEncode(row[0].ToString()) + "\",\"result\":\"" + row[1].ToString() + "\"},";
     }
     if (!string.IsNullOrEmpty(str))
     {
         str = str.Substring(0, str.Length - 1);
     }
     return str;
 }