public static bool UpdateCalculationCommission(OrderInfo order) { new MemberDao().SetOrderDate(order.UserId, 2); DistributorsInfo userIdDistributors = DistributorsBrower.GetUserIdDistributors(order.ReferralUserId); SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); bool result = false; if (userIdDistributors != null) { result = DistributorsBrower.setCommission(order, userIdDistributors); if (!string.IsNullOrEmpty(order.ReferralPath)) { ArrayList arrayList = new ArrayList(); decimal num = 0m; ArrayList arrayList2 = new ArrayList(); string referralUserId = order.ReferralUserId.ToString(); string orderId = order.OrderId; ArrayList arrayList3 = new ArrayList(); decimal d = 0m; ArrayList arrayList4 = new ArrayList(); string[] array = order.ReferralPath.Split(new char[] { '|' }); if (array.Length == 1) { DistributorsInfo userIdDistributors2 = DistributorsBrower.GetUserIdDistributors(int.Parse(array[0])); if (userIdDistributors2 != null) { foreach (LineItemInfo current in order.LineItems.Values) { if (current.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { num += current.SecondItemsCommission; d += current.GetSubTotal(); } } arrayList.Add(num); arrayList3.Add(d + order.AdjustedFreight); arrayList2.Add(userIdDistributors2.UserId); try { if (order != null && num > 0m) { string userOpenIdByUserId = MemberProcessor.GetUserOpenIdByUserId(userIdDistributors2.UserId); string aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(userIdDistributors2.UserId); Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num); } } catch (Exception var_16_1FA) { } int notDescDistributorGrades = DistributorsBrower.GetNotDescDistributorGrades(userIdDistributors2.UserId.ToString()); if (userIdDistributors2.DistriGradeId != notDescDistributorGrades) { DistributorsBrower.DistributorGradeChange(userIdDistributors2, order.OrderId, notDescDistributorGrades); } } } if (array.Length == 2) { DistributorsInfo userIdDistributors3 = DistributorsBrower.GetUserIdDistributors(int.Parse(array[0])); foreach (LineItemInfo current in order.LineItems.Values) { if (current.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { num += current.ThirdItemsCommission; d += current.GetSubTotal(); } } arrayList.Add(num); arrayList3.Add(d + order.AdjustedFreight); arrayList2.Add(userIdDistributors3.UserId); try { if (order != null && num > 0m) { string userOpenIdByUserId = MemberProcessor.GetUserOpenIdByUserId(userIdDistributors3.UserId); string aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(userIdDistributors3.UserId); Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num); } } catch (Exception var_16_1FA) { } int notDescDistributorGrades = DistributorsBrower.GetNotDescDistributorGrades(userIdDistributors3.UserId.ToString()); if (userIdDistributors3.DistriGradeId != notDescDistributorGrades) { DistributorsBrower.DistributorGradeChange(userIdDistributors3, order.OrderId, notDescDistributorGrades); } DistributorsInfo userIdDistributors4 = DistributorsBrower.GetUserIdDistributors(int.Parse(array[1])); num = 0m; d = 0m; foreach (LineItemInfo current in order.LineItems.Values) { if (current.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { num += current.SecondItemsCommission; d += current.GetSubTotal(); } } arrayList.Add(num); arrayList3.Add(d + order.AdjustedFreight); arrayList2.Add(userIdDistributors4.UserId); try { if (order != null && num > 0m) { string userOpenIdByUserId = MemberProcessor.GetUserOpenIdByUserId(userIdDistributors4.UserId); string aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(userIdDistributors4.UserId); Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num); } } catch (Exception var_16_1FA) { } int notDescDistributorGrades2 = DistributorsBrower.GetNotDescDistributorGrades(userIdDistributors4.UserId.ToString()); if (userIdDistributors4.DistriGradeId != notDescDistributorGrades2) { DistributorsBrower.DistributorGradeChange(userIdDistributors4, order.OrderId, notDescDistributorGrades2); } } result = new DistributorsDao().UpdateTwoCalculationCommission(arrayList2, referralUserId, orderId, arrayList3, arrayList); for (int i = 0; i < arrayList2.Count; i++) { int notDescDistributorGrades3 = DistributorsBrower.GetNotDescDistributorGrades(arrayList2[i].ToString()); arrayList4.Add(notDescDistributorGrades3); } result = new DistributorsDao().UpdateGradeId(arrayList4, arrayList2); } DistributorsBrower.RemoveDistributorCache(userIdDistributors.UserId); } OrderRedPagerBrower.CreateOrderRedPager(order.OrderId, order.GetTotal(), order.UserId); int num2 = Globals.IsNumeric(order.ActivitiesId) ? Globals.ToNum(order.ActivitiesId) : 0; if (num2 > 0) { Hidistro.SqlDal.VShop.ActivityDao activityDao = new Hidistro.SqlDal.VShop.ActivityDao(); ActivityDetailInfo activityDetailInfo = activityDao.GetActivityDetailInfo(num2); if (activityDetailInfo != null) { int couponId = activityDetailInfo.CouponId; int integral = activityDetailInfo.Integral; if (couponId > 0) { CouponInfo coupon = ShoppingProcessor.GetCoupon(couponId.ToString()); if (coupon != null) { CouponDao couponDao = new CouponDao(); SendCouponResult sendCouponResult = couponDao.SendCouponToMember(couponId, order.UserId); try { if (order != null) { Messenger.SendWeiXinMsg_OrderGetCoupon(order); } } catch (Exception var_16_1FA) { } } } if (integral > 0) { new OrderDao().AddMemberPointNumber(integral, order, null); try { if (order != null) { Messenger.SendWeiXinMsg_OrderGetPoint(order, integral); } } catch (Exception var_16_1FA) { } } } } MemberProcessor.UpdateUserAccount(order); try { string text = ""; DateTime orderDate = order.OrderDate; DateTime?payDate = order.PayDate; if (order.Gateway == "hishop.plugins.payment.podrequest") { payDate = new DateTime?(orderDate); } if (payDate.HasValue && payDate.Value.ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd")) { bool flag = new ShopStatisticDao().StatisticsOrdersByRecDate(payDate.Value, UpdateAction.AllUpdate, 0, out text); } } catch { } return(result); }
public static bool setCommission(OrderInfo order, DistributorsInfo DisInfo) { bool result = false; decimal num = 0m; decimal num2 = 0m; string text = order.ReferralUserId.ToString(); string orderId = order.OrderId; decimal d = 0m; ArrayList arrayList = new ArrayList(); ArrayList arrayList2 = new ArrayList(); foreach (LineItemInfo current in order.LineItems.Values) { if (current.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { num2 += current.ItemsCommission; if (!string.IsNullOrEmpty(current.ItemAdjustedCommssion.ToString()) && current.ItemAdjustedCommssion > 0m) { if (!current.IsAdminModify) { num += current.ItemAdjustedCommssion; } } d += current.GetSubTotal() - current.DiscountAverage - current.ItemAdjustedCommssion; } } d -= order.AdjustedFreight; bool flag = false; decimal num3; if (flag) { num3 = num2; } else { num3 = num2 - num; if (num3 < 0m) { num3 = 0m; } } result = new DistributorsDao().UpdateCalculationCommission(text, text, orderId, d + order.AdjustedFreight, num3); try { if (order != null && num3 > 0m) { string userOpenIdByUserId = MemberProcessor.GetUserOpenIdByUserId(DisInfo.UserId); string aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(DisInfo.UserId); Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num3); } } catch (Exception ex) { Globals.Debuglog("分佣问题:" + ex.Message, "_Debuglog.txt"); } int notDescDistributorGrades = DistributorsBrower.GetNotDescDistributorGrades(text); if (notDescDistributorGrades > 0) { arrayList.Add(notDescDistributorGrades); arrayList2.Add(text); result = new DistributorsDao().UpdateGradeId(arrayList, arrayList2); if (DisInfo.DistriGradeId != notDescDistributorGrades) { DistributorsBrower.DistributorGradeChange(DisInfo, order.OrderId, notDescDistributorGrades); } } return(result); }
public static bool setCommission(OrderInfo order, DistributorsInfo DisInfo) { bool flag = false; decimal num = 0M; decimal num2 = 0M; decimal resultCommTatal = 0M; string userId = order.ReferralUserId.ToString(); string orderId = order.OrderId; decimal num4 = 0M; ArrayList gradeIdList = new ArrayList(); ArrayList referralUserIdList = new ArrayList(); foreach (LineItemInfo info in order.LineItems.Values) { if (info.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { num2 += info.ItemsCommission; if ((!string.IsNullOrEmpty(info.ItemAdjustedCommssion.ToString()) && (info.ItemAdjustedCommssion > 0M)) && !info.IsAdminModify) { num += info.ItemAdjustedCommssion; } num4 += (info.GetSubTotal() - info.DiscountAverage) - info.ItemAdjustedCommssion; } } num4 -= order.AdjustedFreight; if (false) { resultCommTatal = num2; } else { resultCommTatal = num2 - num; if (resultCommTatal < 0M) { resultCommTatal = 0M; } } flag = new DistributorsDao().UpdateCalculationCommission(userId, userId, orderId, num4 + order.AdjustedFreight, resultCommTatal); try { if ((order != null) && (resultCommTatal > 0M)) { string userOpenIdByUserId = MemberProcessor.GetUserOpenIdByUserId(DisInfo.UserId); string aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(DisInfo.UserId); Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, resultCommTatal); } } catch (Exception exception) { Globals.Debuglog("分佣问题:" + exception.Message, "_Debuglog.txt"); } int notDescDistributorGrades = GetNotDescDistributorGrades(userId); if (notDescDistributorGrades > 0) { gradeIdList.Add(notDescDistributorGrades); referralUserIdList.Add(userId); flag = new DistributorsDao().UpdateGradeId(gradeIdList, referralUserIdList); if (DisInfo.DistriGradeId != notDescDistributorGrades) { DistributorGradeChange(DisInfo, order.OrderId, notDescDistributorGrades); } } return(flag); }
public static bool UpdateCalculationCommission(OrderInfo order) { Exception exception; new MemberDao().SetOrderDate(order.UserId, 2); DistributorsInfo userIdDistributors = GetUserIdDistributors(order.ReferralUserId); SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); bool flag = false; if (userIdDistributors != null) { flag = setCommission(order, userIdDistributors); if (!string.IsNullOrEmpty(order.ReferralPath)) { string userOpenIdByUserId; string aliUserOpenIdByUserId; int notDescDistributorGrades; ArrayList commTatalList = new ArrayList(); decimal num = 0M; ArrayList userIdList = new ArrayList(); string referralUserId = order.ReferralUserId.ToString(); string orderId = order.OrderId; ArrayList orderTotalList = new ArrayList(); decimal num2 = 0M; ArrayList gradeIdList = new ArrayList(); string[] strArray = order.ReferralPath.Split(new char[] { '|' }); if (strArray.Length == 1) { DistributorsInfo distributor = GetUserIdDistributors(int.Parse(strArray[0])); if (distributor != null) { foreach (LineItemInfo info3 in order.LineItems.Values) { if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { num += info3.SecondItemsCommission; num2 += info3.GetSubTotal(); } } commTatalList.Add(num); orderTotalList.Add(num2 + order.AdjustedFreight); userIdList.Add(distributor.UserId); try { if ((order != null) && (num > 0M)) { userOpenIdByUserId = MemberProcessor.GetUserOpenIdByUserId(distributor.UserId); aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(distributor.UserId); Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num); } } catch (Exception exception1) { exception = exception1; } notDescDistributorGrades = GetNotDescDistributorGrades(distributor.UserId.ToString()); if (distributor.DistriGradeId != notDescDistributorGrades) { DistributorGradeChange(distributor, order.OrderId, notDescDistributorGrades); } } } if (strArray.Length == 2) { DistributorsInfo info4 = GetUserIdDistributors(int.Parse(strArray[0])); foreach (LineItemInfo info3 in order.LineItems.Values) { if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { num += info3.ThirdItemsCommission; num2 += info3.GetSubTotal(); } } commTatalList.Add(num); orderTotalList.Add(num2 + order.AdjustedFreight); userIdList.Add(info4.UserId); try { if ((order != null) && (num > 0M)) { userOpenIdByUserId = MemberProcessor.GetUserOpenIdByUserId(info4.UserId); aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(info4.UserId); Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num); } } catch (Exception exception2) { exception = exception2; } notDescDistributorGrades = GetNotDescDistributorGrades(info4.UserId.ToString()); if (info4.DistriGradeId != notDescDistributorGrades) { DistributorGradeChange(info4, order.OrderId, notDescDistributorGrades); } DistributorsInfo info5 = GetUserIdDistributors(int.Parse(strArray[1])); num = 0M; num2 = 0M; foreach (LineItemInfo info3 in order.LineItems.Values) { if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { num += info3.SecondItemsCommission; num2 += info3.GetSubTotal(); } } commTatalList.Add(num); orderTotalList.Add(num2 + order.AdjustedFreight); userIdList.Add(info5.UserId); try { if ((order != null) && (num > 0M)) { userOpenIdByUserId = MemberProcessor.GetUserOpenIdByUserId(info5.UserId); aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(info5.UserId); Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num); } } catch (Exception exception3) { exception = exception3; } int newDistributorGradeid = GetNotDescDistributorGrades(info5.UserId.ToString()); if (info5.DistriGradeId != newDistributorGradeid) { DistributorGradeChange(info5, order.OrderId, newDistributorGradeid); } } flag = new DistributorsDao().UpdateTwoCalculationCommission(userIdList, referralUserId, orderId, orderTotalList, commTatalList); for (int i = 0; i < userIdList.Count; i++) { int num6 = GetNotDescDistributorGrades(userIdList[i].ToString()); gradeIdList.Add(num6); } flag = new DistributorsDao().UpdateGradeId(gradeIdList, userIdList); } RemoveDistributorCache(userIdDistributors.UserId); } OrderRedPagerBrower.CreateOrderRedPager(order.OrderId, order.GetTotal(), order.UserId); int id = Globals.IsNumeric(order.ActivitiesId) ? Globals.ToNum(order.ActivitiesId) : 0; if (id > 0) { ActivityDetailInfo activityDetailInfo = new Hidistro.SqlDal.VShop.ActivityDao().GetActivityDetailInfo(id); if (activityDetailInfo != null) { OrderInfo info8; int couponId = activityDetailInfo.CouponId; int integral = activityDetailInfo.Integral; if ((couponId > 0) && (ShoppingProcessor.GetCoupon(couponId.ToString()) != null)) { SendCouponResult result = new CouponDao().SendCouponToMember(couponId, order.UserId); try { info8 = order; if (info8 != null) { Messenger.SendWeiXinMsg_OrderGetCoupon(info8); } } catch (Exception exception4) { exception = exception4; } } if (integral > 0) { new OrderDao().AddMemberPointNumber(integral, order, null); try { info8 = order; if (info8 != null) { Messenger.SendWeiXinMsg_OrderGetPoint(info8, integral); } } catch (Exception exception5) { exception = exception5; } } } } MemberProcessor.UpdateUserAccount(order); try { string retInfo = ""; DateTime orderDate = order.OrderDate; DateTime?payDate = order.PayDate; if (order.Gateway == "hishop.plugins.payment.podrequest") { payDate = new DateTime?(orderDate); } if (payDate.HasValue && (payDate.Value.ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd"))) { bool flag2 = new ShopStatisticDao().StatisticsOrdersByRecDate(payDate.Value, UpdateAction.AllUpdate, 0, out retInfo); } } catch { } return(flag); }
public static bool UpdateCalculationCommission(OrderInfo order) { new MemberDao().SetOrderDate(order.UserId, 2); DistributorsInfo userIdDistributors = GetUserIdDistributors(order.ReferralUserId); SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); bool flag = false; if (userIdDistributors != null) { flag = setCommission(order, userIdDistributors, masterSettings); if (!string.IsNullOrEmpty(order.ReferralPath)) { ArrayList commTatalList = new ArrayList(); decimal num = 0M; ArrayList userIdList = new ArrayList(); string referralUserId = order.ReferralUserId.ToString(); string orderId = order.OrderId; ArrayList orderTotalList = new ArrayList(); decimal num2 = 0M; ArrayList gradeIdList = new ArrayList(); string[] strArray = order.ReferralPath.Split(new char[] { '|' }); if (strArray.Length == 1) { DistributorsInfo distributor = GetUserIdDistributors(int.Parse(strArray[0])); if (distributor != null) { foreach (LineItemInfo info3 in order.LineItems.Values) { if (info3.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { num += Math.Round(info3.SecondItemsCommission, 2); num2 += info3.GetSubTotal(); } } commTatalList.Add(num); orderTotalList.Add(num2); userIdList.Add(distributor.UserId); try { if ((order != null) && (num > 0M)) { string userOpenIdByUserId = MemberProcessor.GetUserOpenIdByUserId(distributor.UserId); string aliUserOpenIdByUserId = MemberProcessor.GetAliUserOpenIdByUserId(distributor.UserId); Messenger.SendWeiXinMsg_OrderGetCommission(order, userOpenIdByUserId, aliUserOpenIdByUserId, num); } } catch (Exception) { } int notDescDistributorGrades = GetNotDescDistributorGrades(distributor.UserId.ToString()); if (distributor.DistriGradeId != notDescDistributorGrades) { DistributorGradeChange(distributor, order.OrderId, notDescDistributorGrades, true); } } } if (strArray.Length == 2) { DistributorsInfo info4 = GetUserIdDistributors(int.Parse(strArray[0])); foreach (LineItemInfo info5 in order.LineItems.Values) { if (info5.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { num += Math.Round(info5.ThirdItemsCommission, 2); num2 += info5.GetSubTotal(); } } commTatalList.Add(num); orderTotalList.Add(num2); userIdList.Add(info4.UserId); try { if ((order != null) && (num > 0M)) { string wxOpenId = MemberProcessor.GetUserOpenIdByUserId(info4.UserId); string aliOpneid = MemberProcessor.GetAliUserOpenIdByUserId(info4.UserId); Messenger.SendWeiXinMsg_OrderGetCommission(order, wxOpenId, aliOpneid, num); } } catch (Exception) { } int newDistributorGradeid = GetNotDescDistributorGrades(info4.UserId.ToString()); if (info4.DistriGradeId != newDistributorGradeid) { DistributorGradeChange(info4, order.OrderId, newDistributorGradeid, true); } DistributorsInfo info6 = GetUserIdDistributors(int.Parse(strArray[1])); num = 0M; num2 = 0M; foreach (LineItemInfo info7 in order.LineItems.Values) { if (info7.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { num += Math.Round(info7.SecondItemsCommission, 2); num2 += info7.GetSubTotal(); } } commTatalList.Add(num); orderTotalList.Add(num2); userIdList.Add(info6.UserId); try { if ((order != null) && (num > 0M)) { string str7 = MemberProcessor.GetUserOpenIdByUserId(info6.UserId); string str8 = MemberProcessor.GetAliUserOpenIdByUserId(info6.UserId); Messenger.SendWeiXinMsg_OrderGetCommission(order, str7, str8, num); } } catch (Exception) { } int num5 = GetNotDescDistributorGrades(info6.UserId.ToString()); if (info6.DistriGradeId != num5) { DistributorGradeChange(info6, order.OrderId, num5, true); } } if (new DistributorsDao().UpdateTwoCalculationCommission(userIdList, referralUserId, orderId, orderTotalList, commTatalList)) { for (int j = 0; j < userIdList.Count; j++) { CommissionAutoToBalance(Globals.ToNum(userIdList[j]), masterSettings, decimal.Parse(commTatalList[j].ToString())); } } for (int i = 0; i < userIdList.Count; i++) { int num8 = GetNotDescDistributorGrades(userIdList[i].ToString()); gradeIdList.Add(num8); } flag = new DistributorsDao().UpdateGradeId(gradeIdList, userIdList); } RemoveDistributorCache(userIdDistributors.UserId); } OrderRedPagerBrower.CreateOrderRedPager(order.OrderId, order.GetTotal(), order.UserId); string[] strArray2 = !string.IsNullOrEmpty(order.ActivitiesId) ? order.ActivitiesId.Split(new char[] { ',' }) : null; if ((strArray2 != null) && (strArray2.Length > 0)) { int pointNumber = 0; foreach (string str9 in strArray2) { int id = Globals.IsNumeric(str9) ? Globals.ToNum(str9) : 0; if (id > 0) { ActivityDetailInfo activityDetailInfo = new Hidistro.SqlDal.VShop.ActivityDao().GetActivityDetailInfo(id); if (activityDetailInfo != null) { int couponId = activityDetailInfo.CouponId; pointNumber += activityDetailInfo.Integral; if ((couponId > 0) && (ShoppingProcessor.GetCoupon(couponId.ToString()) != null)) { new CouponDao().SendCouponToMember(couponId, order.UserId); try { OrderInfo info10 = order; if (info10 != null) { Messenger.SendWeiXinMsg_OrderGetCoupon(info10); } } catch (Exception) { } } } } } if (pointNumber > 0) { new OrderDao().AddMemberPointNumber(pointNumber, order, null); try { OrderInfo info11 = order; if (info11 != null) { Messenger.SendWeiXinMsg_OrderGetPoint(info11, pointNumber); } } catch (Exception) { } } } MemberProcessor.UpdateUserAccount(order); try { string retInfo = ""; DateTime orderDate = order.OrderDate; DateTime?payDate = order.PayDate; if (order.Gateway == "hishop.plugins.payment.podrequest") { payDate = new DateTime?(orderDate); } if (payDate.HasValue && (payDate.Value.ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd"))) { new ShopStatisticDao().StatisticsOrdersByRecDate(payDate.Value, UpdateAction.AllUpdate, 0, out retInfo); } } catch { } return(flag); }