public static void GetAutoBatchOrdersIdList() { System.Data.DataSet autoBatchOrdersIdList = new OrderDao().GetAutoBatchOrdersIdList(); if (autoBatchOrdersIdList.Tables.Count == 2) { System.Data.DataTable dataTable = autoBatchOrdersIdList.Tables[0]; for (int i = 0; i < dataTable.Rows.Count; i++) { OrderInfo orderInfo = new OrderDao().GetOrderInfo(dataTable.Rows[i]["OrderID"].ToString()); LineItemInfo lineItemInfo = new LineItemInfo(); Dictionary <string, LineItemInfo> lineItems = orderInfo.LineItems; orderInfo.CloseReason = "到期自动关闭"; MemberProcessor.CancelOrder(orderInfo); } dataTable = autoBatchOrdersIdList.Tables[1]; for (int i = 0; i < dataTable.Rows.Count; i++) { OrderInfo orderInfo = new OrderDao().GetOrderInfo(dataTable.Rows[i]["OrderID"].ToString()); Dictionary <string, LineItemInfo> lineItems = orderInfo.LineItems; LineItemInfo lineItemInfo = new LineItemInfo(); orderInfo.CloseReason = "订单自动完成"; if (MemberProcessor.ConfirmOrderFinish(orderInfo)) { DistributorsBrower.UpdateCalculationCommission(orderInfo); foreach (LineItemInfo current in orderInfo.LineItems.Values) { if (current.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { ShoppingProcessor.UpdateOrderGoodStatu(orderInfo.OrderId, current.SkuId, 5, current.ID); } } } } } }
public static string UpdateAdjustCommssions(string orderId, string itemid, decimal commssionmoney, decimal adjustcommssion) { string text = string.Empty; Database database = DatabaseFactory.CreateDatabase(); string result; using (System.Data.Common.DbConnection dbConnection = database.CreateConnection()) { dbConnection.Open(); System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction(); try { OrderInfo orderInfo = ShoppingProcessor.GetOrderInfo(orderId); if (orderId == null) { result = "订单编号不合法"; return(result); } int userId = DistributorsBrower.GetCurrentDistributors(true).UserId; if (orderInfo.ReferralUserId != userId || orderInfo.OrderStatus != OrderStatus.WaitBuyerPay) { result = "不是您的订单"; return(result); } LineItemInfo lineItemInfo = orderInfo.LineItems[itemid]; if (lineItemInfo == null || lineItemInfo.ItemsCommission < adjustcommssion) { result = "修改金额过大"; return(result); } lineItemInfo.ItemAdjustedCommssion = adjustcommssion; lineItemInfo.IsAdminModify = false; if (!new LineItemDao().UpdateLineItem(orderId, lineItemInfo, dbTransaction)) { dbTransaction.Rollback(); } if (!new OrderDao().UpdateOrder(orderInfo, dbTransaction)) { dbTransaction.Rollback(); result = "更新订单信息失败"; return(result); } dbTransaction.Commit(); text = "1"; } catch (Exception ex) { text = ex.ToString(); dbTransaction.Rollback(); } finally { dbConnection.Close(); } result = text; } return(result); }
public static CouponInfo UseCoupon(decimal orderAmount, string claimCode) { CouponInfo result; if (string.IsNullOrEmpty(claimCode)) { result = null; } else { CouponInfo coupon = ShoppingProcessor.GetCoupon(claimCode); if (coupon.ConditionValue <= orderAmount) { result = coupon; } else { result = null; } } return(result); }
public static void GetAutoBatchOrdersIdList() { DataSet autoBatchOrdersIdList = new OrderDao().GetAutoBatchOrdersIdList(); if (autoBatchOrdersIdList.Tables.Count == 2) { DataTable table = autoBatchOrdersIdList.Tables[0]; OrderInfo order = null; for (int i = 0; i < table.Rows.Count; i++) { order = new OrderDao().GetOrderInfo(table.Rows[i]["OrderID"].ToString()); new LineItemInfo(); Dictionary <string, LineItemInfo> lineItems = order.LineItems; order.CloseReason = "到期自动关闭"; CancelOrder(order); } table = autoBatchOrdersIdList.Tables[1]; for (int j = 0; j < table.Rows.Count; j++) { order = new OrderDao().GetOrderInfo(table.Rows[j]["OrderID"].ToString()); Dictionary <string, LineItemInfo> dictionary2 = order.LineItems; new LineItemInfo(); order.CloseReason = "订单自动完成"; if (ConfirmOrderFinish(order)) { DistributorsBrower.UpdateCalculationCommission(order); foreach (LineItemInfo info2 in order.LineItems.Values) { if (info2.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { ShoppingProcessor.UpdateOrderGoodStatu(order.OrderId, info2.SkuId, 5, info2.ID); } } } } } }
public static bool UpdateCalculationCommission(OrderInfo order, string wid) { DistributorsInfo userIdDistributors = GetUserIdDistributors(order.ReferralUserId); SiteSettings masterSettings = SettingsManager.GetMasterSettings(false, wid); bool flag = false; if (userIdDistributors != null) { if (!masterSettings.EnableCommission) { if (userIdDistributors.ReferralStatus == 0) { flag = setCommission(order, userIdDistributors); } } else { if (userIdDistributors.ReferralStatus == 0) { flag = setCommission(order, userIdDistributors); } if (!string.IsNullOrEmpty(userIdDistributors.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 = userIdDistributors.ReferralPath.Split(new char[] { '|' }); if (strArray.Length == 1) { DistributorsInfo info2 = GetUserIdDistributors(int.Parse(strArray[0])); if (info2.ReferralStatus == 0) { 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); userIdList.Add(info2.UserId); } } if (strArray.Length == 2) { DistributorsInfo info4 = GetUserIdDistributors(int.Parse(strArray[0])); if (info4.ReferralStatus == 0) { foreach (LineItemInfo info5 in order.LineItems.Values) { if (info5.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { num += info5.ThirdItemsCommission; num2 += info5.GetSubTotal(); } } commTatalList.Add(num); orderTotalList.Add(num2); userIdList.Add(info4.UserId); } DistributorsInfo info6 = GetUserIdDistributors(int.Parse(strArray[1])); num = 0M; num2 = 0M; if (info6.ReferralStatus == 0) { foreach (LineItemInfo info7 in order.LineItems.Values) { if (info7.OrderItemsStatus.ToString() == OrderStatus.SellerAlreadySent.ToString()) { num += info7.SecondItemsCommission; num2 += info7.GetSubTotal(); } } commTatalList.Add(num); orderTotalList.Add(num2); userIdList.Add(info6.UserId); } } flag = new DistributorsDao().UpdateTwoCalculationCommission(userIdList, referralUserId, orderId, orderTotalList, commTatalList); for (int i = 0; i < userIdList.Count; i++) { int notDescDistributorGrades = GetNotDescDistributorGrades(userIdList[i].ToString()); gradeIdList.Add(notDescDistributorGrades); } 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) { int couponId = activityDetailInfo.CouponId; int integral = activityDetailInfo.Integral; if ((couponId > 0) && (ShoppingProcessor.GetCoupon(couponId.ToString()) != null)) { new CouponDao().SendCouponToMember(couponId, order.UserId); } if (integral > 0) { new OrderDao().AddMemberPointNumber(integral, order, null); } } } MemberProcessor.UpdateUserAccount(order, wid); return(flag); }
public static int CreatOrder(OrderInfo orderInfo, bool isUseBalance, decimal remainingMondy) { int num = 0; if (orderInfo.GetTotal() <= 0m) { orderInfo.OrderStatus = OrderStatus.BuyerAlreadyPaid; orderInfo.PayDate = new DateTime?(DateTime.Now); } if (orderInfo.PaymentType == null && orderInfo.PointExchange > 0) { orderInfo.PaymentType = "积分抵现"; orderInfo.Gateway = "hishop.plugins.payment.pointtocach"; orderInfo.PaymentTypeId = 77; } else if (orderInfo.PaymentType == null && orderInfo.RedPagerID.HasValue && orderInfo.RedPagerID.Value > 0) { orderInfo.PaymentType = "优惠券抵扣"; orderInfo.Gateway = "hishop.plugins.payment.coupontocach"; orderInfo.PaymentTypeId = 55; } MemberInfo currentMember = MemberProcessor.GetCurrentMember(); Database database = DatabaseFactory.CreateDatabase(); int quantity = orderInfo.LineItems.Sum((KeyValuePair <string, LineItemInfo> item) => item.Value.Quantity); int result; lock (ShoppingProcessor.createOrderLocker) { if (orderInfo.GroupBuyId > 0) { ShoppingProcessor.checkCanGroupBuy(quantity, orderInfo.GroupBuyId); } using (System.Data.Common.DbConnection dbConnection = database.CreateConnection()) { dbConnection.Open(); System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction(); try { orderInfo.ClientShortType = (ClientShortType)Globals.GetClientShortType(); if (!new OrderDao().CreatOrder(orderInfo, dbTransaction)) { dbTransaction.Rollback(); result = 0; return(result); } if (orderInfo.LineItems.Count > 0) { if (orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid) { foreach (LineItemInfo lineItemInfo in orderInfo.LineItems.Values) { lineItemInfo.OrderItemsStatus = OrderStatus.BuyerAlreadyPaid; } } if (!new LineItemDao().AddOrderLineItems(orderInfo.OrderId, orderInfo.LineItems.Values, dbTransaction)) { dbTransaction.Rollback(); result = 0; return(result); } } if (!string.IsNullOrEmpty(orderInfo.CouponCode)) { if (!new CouponDao().AddCouponUseRecord(orderInfo, dbTransaction)) { dbTransaction.Rollback(); result = 0; return(result); } } ICollection values = orderInfo.LineItems.Values; foreach (LineItemInfo lineItemInfo in values) { if (lineItemInfo.Type == 1) { if (lineItemInfo.ExchangeId > 0) { PointExchangeChangedInfo pointExchangeChangedInfo = new PointExchangeChangedInfo(); pointExchangeChangedInfo.exChangeId = lineItemInfo.ExchangeId; pointExchangeChangedInfo.exChangeName = new OrderDao().GetexChangeName(pointExchangeChangedInfo.exChangeId); pointExchangeChangedInfo.ProductId = lineItemInfo.ProductId; pointExchangeChangedInfo.PointNumber = lineItemInfo.PointNumber; pointExchangeChangedInfo.MemberID = orderInfo.UserId; pointExchangeChangedInfo.Date = DateTime.Now; pointExchangeChangedInfo.MemberGrades = currentMember.GradeId; if (!new OrderDao().InsertPointExchange_Changed(pointExchangeChangedInfo, dbTransaction, lineItemInfo.Quantity)) { dbTransaction.Rollback(); result = 0; return(result); } IntegralDetailInfo integralDetailInfo = new IntegralDetailInfo(); integralDetailInfo.IntegralChange = -lineItemInfo.PointNumber; integralDetailInfo.IntegralSource = "积分兑换商品-订单号:" + orderInfo.OrderMarking; integralDetailInfo.IntegralSourceType = 2; integralDetailInfo.Remark = "积分兑换商品"; integralDetailInfo.Userid = orderInfo.UserId; integralDetailInfo.GoToUrl = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId; integralDetailInfo.IntegralStatus = Convert.ToInt32(IntegralDetailStatus.IntegralExchange); if (!new IntegralDetailDao().AddIntegralDetail(integralDetailInfo, dbTransaction)) { dbTransaction.Rollback(); result = 0; return(result); } } } } if (orderInfo.PointExchange > 0) { IntegralDetailInfo integralDetailInfo = new IntegralDetailInfo(); integralDetailInfo.IntegralChange = -orderInfo.PointExchange; integralDetailInfo.IntegralSource = "积分抵现,订单号:" + orderInfo.OrderId; integralDetailInfo.IntegralSourceType = 2; integralDetailInfo.Remark = ""; integralDetailInfo.Userid = orderInfo.UserId; integralDetailInfo.GoToUrl = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId; integralDetailInfo.IntegralStatus = Convert.ToInt32(IntegralDetailStatus.NowArrived); if (!new IntegralDetailDao().AddIntegralDetail(integralDetailInfo, dbTransaction)) { dbTransaction.Rollback(); result = 0; return(result); } } if (orderInfo.RedPagerID > 0) { if (!new OrderDao().UpdateCoupon_MemberCoupons(orderInfo, dbTransaction)) { dbTransaction.Rollback(); result = 0; return(result); } } dbTransaction.Commit(); num = 1; if (orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid) { num = 2; } } catch { dbTransaction.Rollback(); throw; } finally { dbConnection.Close(); } } } if (isUseBalance && num == 1) { orderInfo = new OrderDao().GetOrderInfo(orderInfo.OrderId); lock (ShoppingProcessor.BalanceUpdateLock) { num = ShoppingProcessor.OrderBalanceUpdate(orderInfo, currentMember.UserId, remainingMondy); } } result = num; return(result); }
public static bool CreatOrder(OrderInfo orderInfo) { bool flag = false; if (orderInfo.GetTotal() == 0m) { orderInfo.OrderStatus = OrderStatus.BuyerAlreadyPaid; } Database database = DatabaseFactory.CreateDatabase(); int quantity = orderInfo.LineItems.Sum((KeyValuePair <string, LineItemInfo> item) => item.Value.Quantity); bool result; lock (ShoppingProcessor.createOrderLocker) { if (orderInfo.GroupBuyId > 0) { ShoppingProcessor.checkCanGroupBuy(quantity, orderInfo.GroupBuyId); } using (System.Data.Common.DbConnection dbConnection = database.CreateConnection()) { dbConnection.Open(); System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction(); try { orderInfo.ClientShortType = (ClientShortType)Globals.GetClientShortType(); if (!new OrderDao().CreatOrder(orderInfo, dbTransaction)) { dbTransaction.Rollback(); result = false; return(result); } if (orderInfo.LineItems.Count > 0) { if (!new LineItemDao().AddOrderLineItems(orderInfo.OrderId, orderInfo.LineItems.Values, dbTransaction)) { dbTransaction.Rollback(); result = false; return(result); } } if (!string.IsNullOrEmpty(orderInfo.CouponCode)) { if (!new CouponDao().AddCouponUseRecord(orderInfo, dbTransaction)) { dbTransaction.Rollback(); result = false; return(result); } } ICollection values = orderInfo.LineItems.Values; MemberInfo currentMember = MemberProcessor.GetCurrentMember(); foreach (LineItemInfo lineItemInfo in values) { if (lineItemInfo.Type == 1) { if (lineItemInfo.ExchangeId > 0) { PointExchangeChangedInfo pointExchangeChangedInfo = new PointExchangeChangedInfo(); pointExchangeChangedInfo.exChangeId = lineItemInfo.ExchangeId; pointExchangeChangedInfo.exChangeName = new OrderDao().GetexChangeName(pointExchangeChangedInfo.exChangeId); pointExchangeChangedInfo.ProductId = lineItemInfo.ProductId; pointExchangeChangedInfo.PointNumber = lineItemInfo.PointNumber; pointExchangeChangedInfo.MemberID = orderInfo.UserId; pointExchangeChangedInfo.Date = DateTime.Now; pointExchangeChangedInfo.MemberGrades = currentMember.GradeId; if (!new OrderDao().InsertPointExchange_Changed(pointExchangeChangedInfo, dbTransaction, lineItemInfo.Quantity)) { dbTransaction.Rollback(); result = false; return(result); } IntegralDetailInfo integralDetailInfo = new IntegralDetailInfo(); integralDetailInfo.IntegralChange = -lineItemInfo.PointNumber; integralDetailInfo.IntegralSource = "积分兑换商品-订单号:" + orderInfo.OrderMarking; integralDetailInfo.IntegralSourceType = 2; integralDetailInfo.Remark = "积分兑换商品"; integralDetailInfo.Userid = orderInfo.UserId; integralDetailInfo.GoToUrl = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId; integralDetailInfo.IntegralStatus = Convert.ToInt32(IntegralDetailStatus.IntegralExchange); if (!new IntegralDetailDao().AddIntegralDetail(integralDetailInfo, dbTransaction)) { dbTransaction.Rollback(); result = false; return(result); } } } } if (orderInfo.PointExchange > 0) { IntegralDetailInfo integralDetailInfo = new IntegralDetailInfo(); integralDetailInfo.IntegralChange = -orderInfo.PointExchange; integralDetailInfo.IntegralSource = "积分抵现-订单号:" + orderInfo.OrderMarking; integralDetailInfo.IntegralSourceType = 2; integralDetailInfo.Remark = "积分抵现"; integralDetailInfo.Userid = orderInfo.UserId; integralDetailInfo.GoToUrl = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId; integralDetailInfo.IntegralStatus = Convert.ToInt32(IntegralDetailStatus.NowArrived); if (!new IntegralDetailDao().AddIntegralDetail(integralDetailInfo, dbTransaction)) { dbTransaction.Rollback(); result = false; return(result); } } if (orderInfo.RedPagerID > 0) { if (!new OrderDao().UpdateCoupon_MemberCoupons(orderInfo, dbTransaction)) { dbTransaction.Rollback(); result = false; return(result); } } dbTransaction.Commit(); flag = true; } catch { dbTransaction.Rollback(); throw; } finally { dbConnection.Close(); } } } result = flag; return(result); }
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 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); }