public SendCouponResult IsCanSendCouponToMember(int couponId, int userId) { System.Data.Common.DbCommand storedProcCommand = this.database.GetStoredProcCommand("cp_MemberCanReceiveCoupon"); this.database.AddInParameter(storedProcCommand, "@CouponsId", System.Data.DbType.Int32, couponId); this.database.AddInParameter(storedProcCommand, "@UserId", System.Data.DbType.Int32, userId); this.database.AddOutParameter(storedProcCommand, "@Result", System.Data.DbType.Int32, 4); SendCouponResult result; try { this.database.ExecuteNonQuery(storedProcCommand); object value = storedProcCommand.Parameters["@Result"].Value; if (value != null && !string.IsNullOrEmpty(value.ToString())) { SendCouponResult sendCouponResult = (SendCouponResult)int.Parse(value.ToString()); result = sendCouponResult; return(result); } } catch (Exception) { throw; } result = SendCouponResult.其它错误; return(result); }
private void GetCouponToMember(System.Web.HttpContext context) { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder("{"); int couponId = 0; try { couponId = int.Parse(context.Request["couponId"]); } catch (System.Exception) { stringBuilder.Append("\"status\":\"0\",\"Desciption\":\"参数错误!\"}"); context.Response.Write(stringBuilder.ToString()); return; } int userId = 0; try { MemberInfo currentMember = MemberProcessor.GetCurrentMember(); userId = currentMember.UserId; } catch (System.Exception) { userId = 1; } try { SendCouponResult sendCouponResult = CouponHelper.SendCouponToMember(couponId, userId); if (sendCouponResult == SendCouponResult.正常领取) { stringBuilder.Append("\"status\":\"1\",\"Desciption\":\"领取成功!\"}"); context.Response.Write(stringBuilder.ToString()); } else { if (sendCouponResult == SendCouponResult.其它错误) { throw new System.Exception(); } stringBuilder.Append("\"status\":\"2\",\"Desciption\":\"" + sendCouponResult.ToString() + "!\"}"); context.Response.Write(stringBuilder.ToString()); } } catch (System.Exception) { stringBuilder.Append("\"status\":\"3\",\"Desciption\":\"领取失败!\"}"); context.Response.Write(stringBuilder.ToString()); } }
private void GetCouponToMember(HttpContext context) { StringBuilder builder = new StringBuilder("{"); int couponId = 0; try { couponId = int.Parse(context.Request["couponId"]); } catch (Exception) { builder.Append("\"status\":\"0\",\"Desciption\":\"参数错误!\"}"); context.Response.Write(builder.ToString()); return; } int userId = 0; try { userId = MemberProcessor.GetCurrentMember().UserId; } catch (Exception) { userId = 1; } try { SendCouponResult result = CouponHelper.SendCouponToMember(couponId, userId); switch (result) { case SendCouponResult.正常领取: builder.Append("\"status\":\"1\",\"Desciption\":\"领取成功!\"}"); context.Response.Write(builder.ToString()); return; case SendCouponResult.其它错误: throw new Exception(); } builder.Append("\"status\":\"2\",\"Desciption\":\"" + result.ToString() + "!\"}"); context.Response.Write(builder.ToString()); } catch (Exception) { builder.Append("\"status\":\"3\",\"Desciption\":\"领取失败!\"}"); context.Response.Write(builder.ToString()); } }
public static GamePrizeInfo UserPrize(int gameId, int useId) { int[] expr_07 = new int[] { 67, 112, 202, 292, 337 }; IList <GamePrizeInfo> gamePrizeListsByGameId = GameHelper.GetGamePrizeListsByGameId(gameId); int num = gamePrizeListsByGameId.Max((GamePrizeInfo p) => p.PrizeRate); GamePrizeInfo gamePrizeInfo = new GamePrizeInfo { PrizeId = 0, PrizeRate = (num >= 100) ? 0 : 100, PrizeGrade = PrizeGrade.未中奖 }; gamePrizeListsByGameId.Add(gamePrizeInfo); GamePrizeInfo gamePrizeInfo2 = GameHelper.ChouJiang(gamePrizeListsByGameId); if (gamePrizeInfo2.PrizeId != 0 && gamePrizeInfo2.PrizeCount <= 0) { gamePrizeInfo2 = gamePrizeInfo; } if (gamePrizeInfo2.PrizeId != 0 && gamePrizeInfo2.PrizeType == PrizeType.赠送优惠券) { SendCouponResult sendCouponResult = CouponHelper.IsCanSendCouponToMember(int.Parse(gamePrizeInfo2.GiveCouponId), useId); if (sendCouponResult != SendCouponResult.正常领取) { gamePrizeInfo2 = gamePrizeInfo; } } new PrizeResultDao().AddPrizeLog(new PrizeResultInfo { GameId = gameId, PrizeId = gamePrizeInfo2.PrizeId, UserId = useId }); return(gamePrizeInfo2); }
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); }