public ActivityDetailInfo GetActivityDetailInfo(int Id) { ActivityDetailInfo result = null; System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_Activities_Detail WHERE ID = @ID"); this.database.AddInParameter(sqlStringCommand, "ID", System.Data.DbType.Int32, Id); using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand)) { result = ReaderConvert.ReaderToModel <ActivityDetailInfo>(dataReader); } return(result); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string str = Globals.RequestFormStr("action"); if (!string.IsNullOrEmpty(str)) { if (str == "End") { int aid = Globals.RequestFormNum("delId"); if (aid > 0) { if (ActivityHelper.EndAct(aid)) { context.Response.Write("{\"state\":\"true\",\"msg\":\"活动成功结束\"}"); } else { context.Response.Write("{\"state\":\"false\",\"msg\":\"活动结束失败\"}"); } } else { context.Response.Write("{\"state\":\"false\",\"msg\":\"参数不正确\"}"); } } } else { try { int id = int.Parse(context.Request["id"].ToString()); string str2 = context.Request["name"].ToString(); string val = context.Request["begin"].ToString(); string str4 = context.Request["end"].ToString(); string str5 = context.Request["memberlvl"].ToString(); string str6 = context.Request["defualtGroup"].ToString(); string str7 = context.Request["customGroup"].ToString(); string str8 = context.Request["maxNum"].ToString(); string str9 = context.Request["type"].ToString(); string str10 = context.Request["attendType"].ToString(); string str11 = context.Request["meetType"].ToString(); int i = 0; int num4 = 0; DateTime now = DateTime.Now; DateTime time2 = DateTime.Now; int num5 = 0; int num6 = 0; if (str2.Length > 30) { context.Response.Write("{\"type\":\"error\",\"data\":\"活动名称不能超过30个字符\"}"); } else if (!val.bDate(ref now)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的开始时间\"}"); } else if (!str4.bDate(ref time2)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的结束时间\"}"); } else if (time2 < now) { context.Response.Write("{\"type\":\"error\",\"data\":\"结束时间不能早于开始时间\"}"); } else if ((string.IsNullOrEmpty(str5) && string.IsNullOrEmpty(str6)) && string.IsNullOrEmpty(str7)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请选择适用会员等级\"}"); } else if (!str8.bInt(ref num5)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请选择参与次数\"}"); } else if (!str9.bInt(ref num6)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请选择参与商品类型\"}"); } else if (!str10.bInt(ref i)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请选择优惠类型\"}"); } else if (!str11.bInt(ref num4)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请选择优惠条件\"}"); } else { List <ActivityDetailInfo> list = new List <ActivityDetailInfo>(); JArray array = (JArray)JsonConvert.DeserializeObject(context.Request.Form["stk"].ToString()); if (array.Count > 1) { for (int j = 0; j < (array.Count - 1); j++) { JToken token = array[j]["meet"]; for (int k = j + 1; k < array.Count; k++) { if (array[k]["meet"] == token) { context.Response.Write("{\"type\":\"error\",\"data\":\"多级优惠的各级满足金额不能相同\"}"); return; } } } } if (array.Count > 0) { for (int m = 0; m < array.Count; m++) { ActivityDetailInfo item = new ActivityDetailInfo(); string str12 = array[m]["meet"].ToString(); string str13 = array[m]["meetNumber"].ToString(); string str14 = array[m]["redus"].ToString(); string str15 = array[m]["free"].ToString(); string str16 = array[m]["point"].ToString(); string str17 = array[m]["coupon"].ToString(); decimal num10 = 0M; int num11 = 0; decimal num12 = 0M; bool flag = false; int num13 = 0; int num14 = 0; int num15 = 0; if (!str13.bInt(ref num11)) { int num17 = m + 1; context.Response.Write("{\"type\":\"error\",\"data\":\"第" + num17.ToString() + "级优惠满足次数输入错误!\"}"); return; } if (!str12.bDecimal(ref num10)) { int num18 = m + 1; context.Response.Write("{\"type\":\"error\",\"data\":\"第" + num18.ToString() + "级优惠满足金额输入错误!\"}"); return; } if (!str14.bDecimal(ref num12)) { int num19 = m + 1; context.Response.Write("{\"type\":\"error\",\"data\":\"第" + num19.ToString() + "级优惠减免金额输入错误!\"}"); return; } if (!str15.bInt(ref num15)) { int num20 = m + 1; context.Response.Write("{\"type\":\"error\",\"data\":\"第" + num20.ToString() + "级优惠免邮选择错误!\"}"); return; } flag = num15 != 0; if (!str16.bInt(ref num13)) { int num21 = m + 1; context.Response.Write("{\"type\":\"error\",\"data\":\"第" + num21.ToString() + "级优惠积分输入错误!\"}"); return; } if (!str16.bInt(ref num13)) { int num22 = m + 1; context.Response.Write("{\"type\":\"error\",\"data\":\"第" + num22.ToString() + "级优惠积分输入错误!\"}"); return; } if (!str17.bInt(ref num14)) { int num23 = m + 1; context.Response.Write("{\"type\":\"error\",\"data\":\"第" + num23.ToString() + "级优惠优惠券选择错误!\"}"); return; } if ((num11 == 0) && (num12 > num10)) { int num24 = m + 1; context.Response.Write("{\"type\":\"error\",\"data\":\"第" + num24.ToString() + "级优惠减免金额不能大于满足金额!\"}"); return; } item.ActivitiesId = 0; item.bFreeShipping = flag; item.CouponId = num14; item.MeetMoney = num10; item.MeetNumber = num11; item.ReductionMoney = num12; item.Integral = num13; list.Add(item); } } ActivityInfo act = new ActivityInfo(); if (id != 0) { act = ActivityHelper.GetAct(id); if (act == null) { context.Response.Write("{\"type\":\"error\",\"data\":\"没有找到这个活动\"}"); return; } } act.ActivitiesName = str2; act.EndTime = time2.Date.AddDays(1.0).AddSeconds(-1.0); act.StartTime = now.Date; act.attendTime = num5; act.attendType = i; act.isAllProduct = num6 == 0; act.MemberGrades = str5; act.DefualtGroup = str6; act.CustomGroup = str7; act.Type = 0; act.MeetMoney = 0M; act.ReductionMoney = 0M; act.Details = list; act.MeetType = num4; string msg = ""; int activitiesId = 0; if (id == 0) { activitiesId = ActivityHelper.Create(act, ref msg); } else { activitiesId = act.ActivitiesId; if (!ActivityHelper.Update(act, ref msg)) { activitiesId = 0; } } if (activitiesId > 0) { context.Response.Write("{\"type\":\"success\",\"data\":\"" + activitiesId.ToString() + "\"}"); } else { context.Response.Write("{\"type\":\"error\",\"data\":\"" + msg + "\"}"); } } } catch (Exception exception) { context.Response.Write("{\"type\":\"error\",\"data\":\"" + exception.Message + "\"}"); } } }
public void ProcessRequest(System.Web.HttpContext context) { context.Response.ContentType = "text/plain"; string text = Globals.RequestFormStr("action"); if (!string.IsNullOrEmpty(text)) { if (text == "End") { int num = Globals.RequestFormNum("delId"); if (num > 0) { if (ActivityHelper.EndAct(num)) { context.Response.Write("{\"state\":\"true\",\"msg\":\"活动成功结束\"}"); return; } context.Response.Write("{\"state\":\"false\",\"msg\":\"活动结束失败\"}"); return; } else { context.Response.Write("{\"state\":\"false\",\"msg\":\"参数不正确\"}"); } } return; } try { int num2 = int.Parse(context.Request["id"].ToString()); string text2 = context.Request["name"].ToString(); string val = context.Request["begin"].ToString(); string val2 = context.Request["end"].ToString(); string text3 = context.Request["memberlvl"].ToString(); string text4 = context.Request["defualtGroup"].ToString(); string text5 = context.Request["customGroup"].ToString(); string val3 = context.Request["maxNum"].ToString(); string val4 = context.Request["type"].ToString(); string val5 = context.Request["attendType"].ToString(); string val6 = context.Request["meetType"].ToString(); int attendType = 0; int meetType = 0; System.DateTime now = System.DateTime.Now; System.DateTime now2 = System.DateTime.Now; int attendTime = 0; int num3 = 0; if (text2.Length > 30) { context.Response.Write("{\"type\":\"error\",\"data\":\"活动名称不能超过30个字符\"}"); } else if (!val.bDate(ref now)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的开始时间\"}"); } else if (!val2.bDate(ref now2)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请输入正确的结束时间\"}"); } else if (now2 < now) { context.Response.Write("{\"type\":\"error\",\"data\":\"结束时间不能早于开始时间\"}"); } else if (string.IsNullOrEmpty(text3) && string.IsNullOrEmpty(text4) && string.IsNullOrEmpty(text5)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请选择适用会员等级\"}"); } else if (!val3.bInt(ref attendTime)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请选择参与次数\"}"); } else if (!val4.bInt(ref num3)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请选择参与商品类型\"}"); } else if (!val5.bInt(ref attendType)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请选择优惠类型\"}"); } else if (!val6.bInt(ref meetType)) { context.Response.Write("{\"type\":\"error\",\"data\":\"请选择优惠条件\"}"); } else { System.Collections.Generic.List <ActivityDetailInfo> list = new System.Collections.Generic.List <ActivityDetailInfo>(); JArray jArray = (JArray)JsonConvert.DeserializeObject(context.Request.Form["stk"].ToString()); if (jArray.Count > 1) { for (int i = 0; i < jArray.Count - 1; i++) { JToken jToken = jArray[i]["meet"]; for (int j = i + 1; j < jArray.Count; j++) { if (jArray[j]["meet"] == jToken) { context.Response.Write("{\"type\":\"error\",\"data\":\"多级优惠的各级满足金额不能相同\"}"); return; } } } } if (jArray.Count > 0) { for (int k = 0; k < jArray.Count; k++) { ActivityDetailInfo activityDetailInfo = new ActivityDetailInfo(); string val7 = jArray[k]["meet"].ToString(); string val8 = jArray[k]["meetNumber"].ToString(); string val9 = jArray[k]["redus"].ToString(); string val10 = jArray[k]["free"].ToString(); string val11 = jArray[k]["point"].ToString(); string val12 = jArray[k]["coupon"].ToString(); decimal num4 = 0m; int num5 = 0; decimal num6 = 0m; int integral = 0; int couponId = 0; int num7 = 0; if (!val8.bInt(ref num5)) { context.Response.Write("{\"type\":\"error\",\"data\":\"第" + (k + 1).ToString() + "级优惠满足次数输入错误!\"}"); return; } if (!val7.bDecimal(ref num4)) { context.Response.Write("{\"type\":\"error\",\"data\":\"第" + (k + 1).ToString() + "级优惠满足金额输入错误!\"}"); return; } if (!val9.bDecimal(ref num6)) { context.Response.Write("{\"type\":\"error\",\"data\":\"第" + (k + 1).ToString() + "级优惠减免金额输入错误!\"}"); return; } if (!val10.bInt(ref num7)) { context.Response.Write("{\"type\":\"error\",\"data\":\"第" + (k + 1).ToString() + "级优惠免邮选择错误!\"}"); return; } bool bFreeShipping = num7 != 0; if (!val11.bInt(ref integral)) { context.Response.Write("{\"type\":\"error\",\"data\":\"第" + (k + 1).ToString() + "级优惠积分输入错误!\"}"); return; } if (!val11.bInt(ref integral)) { context.Response.Write("{\"type\":\"error\",\"data\":\"第" + (k + 1).ToString() + "级优惠积分输入错误!\"}"); return; } if (!val12.bInt(ref couponId)) { context.Response.Write("{\"type\":\"error\",\"data\":\"第" + (k + 1).ToString() + "级优惠优惠券选择错误!\"}"); return; } if (num5 == 0 && num6 > num4) { context.Response.Write("{\"type\":\"error\",\"data\":\"第" + (k + 1).ToString() + "级优惠减免金额不能大于满足金额!\"}"); return; } activityDetailInfo.ActivitiesId = 0; activityDetailInfo.bFreeShipping = bFreeShipping; activityDetailInfo.CouponId = couponId; activityDetailInfo.MeetMoney = num4; activityDetailInfo.MeetNumber = num5; activityDetailInfo.ReductionMoney = num6; activityDetailInfo.Integral = integral; list.Add(activityDetailInfo); } } ActivityInfo activityInfo = new ActivityInfo(); if (num2 != 0) { activityInfo = ActivityHelper.GetAct(num2); if (activityInfo == null) { context.Response.Write("{\"type\":\"error\",\"data\":\"没有找到这个活动\"}"); return; } } activityInfo.ActivitiesName = text2; activityInfo.EndTime = now2.Date.AddDays(1.0).AddSeconds(-1.0); activityInfo.StartTime = now.Date; activityInfo.attendTime = attendTime; activityInfo.attendType = attendType; activityInfo.isAllProduct = (num3 == 0); activityInfo.MemberGrades = text3; activityInfo.DefualtGroup = text4; activityInfo.CustomGroup = text5; activityInfo.Type = new int?(0); activityInfo.MeetMoney = 0m; activityInfo.ReductionMoney = 0m; activityInfo.Details = list; activityInfo.MeetType = meetType; string str = ""; int num8; if (num2 == 0) { num8 = ActivityHelper.Create(activityInfo, ref str); } else { num8 = activityInfo.ActivitiesId; if (!ActivityHelper.Update(activityInfo, ref str)) { num8 = 0; } } if (num8 > 0) { context.Response.Write("{\"type\":\"success\",\"data\":\"" + num8.ToString() + "\"}"); } else { context.Response.Write("{\"type\":\"error\",\"data\":\"" + str + "\"}"); } } } catch (System.Exception ex) { context.Response.Write("{\"type\":\"error\",\"data\":\"" + ex.Message + "\"}"); } }
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); }