/// <summary> /// 批量生成优惠码 /// </summary> /// <param name="groupId"></param> /// <param name="createNum"></param> /// <returns></returns> public bool CreateCouponGroup(int groupId, int iCreateNum = 1) { int iCount = iCreateNum; if (iCreateNum > 1000) { return(false); } //获得需要生成概要信息 OrderCouponInfo couponInfo = T_Order_CouponInfoBLL.GetModel(groupId); //获得当前总生成条数 int couponListCount = couponInfo.produceNum; //新生成优惠码 List <string> couponCreateList = new List <string>(); //判断是否超出限制数量 if ((iCreateNum + couponListCount) > couponInfo.maxLimitNum) { iCount = couponInfo.maxLimitNum - couponListCount; } string couponCode = ""; string couponPre = ""; //前缀命名 if (couponInfo.couponType == 1) { couponPre = "DJ"; } else if (couponInfo.couponType == 2) { couponPre = "GN"; } while (iCount > 0) { //循环生成优惠券Code couponCode = couponPre + CreateNumber(); //Utility.Logger.Info(couponCode); if (!CheckCouponCode(couponCode)) { if (!(T_Order_CouponListBLL.CreateCouponGroup(couponInfo.id, couponCode, couponInfo.couponValue, couponInfo.endDate) > 0)) { return(false); } UpdateHtCouponList(0, couponCode); iCount--; if (iCount > 0) { Thread.Sleep(100); } } } return(true); }
public Hashtable GetAllCoupon() { Hashtable htCoupon = new Hashtable(); List <dynamic> list = T_Order_CouponListBLL.GetAllCoupon(); foreach (dynamic row in list) { if (row.couponId != null) { htCoupon.Add(row.couponId.ToString().Trim(), int.Parse(row.id.ToString().Trim())); } } return(htCoupon); }
/// <summary> /// 绑定优惠券 /// <para>{-1:处理错误,0:优惠券不存在,1:优惠券已使用或者已经作废,2:绑定成功}</para> /// </summary> /// <param name="accountid">店铺ID</param> /// <param name="CouponID">优惠券编号</param> /// <returns></returns> public static int BingingCoupon(int accountid, string CouponID) { int reVal = T_Order_CouponListBLL.BindingAccount(accountid, CouponID); //绑定成功推送消息提醒 if (reVal == 2) { var model = T_Order_CouponListBLL.GetCouponInfoByCode(CouponID); if (model != null) { try { #region Kafka Message 优惠券到账后 AfterBindCoupon cModel = new AfterBindCoupon(); cModel.EventId = 4; cModel.AccId = accountid; cModel.CouponDesc = model.couponDesc; cModel.EndDate = model.endDate; string specModel = CommonLib.Helper.JsonSerializeObject(cModel); KafkaMessage mSend = new KafkaMessage(); mSend.SendMsg(4, specModel); #endregion ////绑定礼金券 推送模板消息 //CommonLib.SystemAPI sysApi = new CommonLib.SystemAPI(); //sysApi.CouponBindingNotifyPushMessage(accId, couponListModel.CouponDesc, couponListModel.EndDate); } catch (Exception ex) { Logger.Error("绑定礼金券推送模板消息错误", ex); } } } return(reVal); }
/// <summary> /// 分页列表 /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="dapperWheres"></param> /// <param name="filedOrder"></param> /// <returns></returns> public static Dictionary <string, object> GetInfoList(int pageIndex, int pageSize, int groupId, int?couponStatus = null) { Dictionary <string, object> list = new Dictionary <string, object>(); List <DapperWhere> dapperWheres = new List <DapperWhere>(); dapperWheres.Add(new DapperWhere("groupId", groupId)); if (couponStatus != null) { dapperWheres.Add(new DapperWhere("couponStatus", couponStatus)); } if (pageSize < 1) { pageSize = 20; } int rowCount = 0; if (pageIndex == 1) { rowCount = BLL.Base.T_Order_CouponListBaseBLL.GetCount(dapperWheres); } int maxPage = 0; if (rowCount > 0) { maxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(rowCount) / pageSize)); } list["rowCount"] = rowCount; list["maxPage"] = maxPage; list["pageIndex"] = pageIndex; list["listData"] = T_Order_CouponListBLL.GetList(pageIndex, pageSize, dapperWheres, " id desc"); return(list); }
/// <summary> /// 得到店铺的优惠券列表 /// </summary> /// <param name="accid"></param> /// <returns></returns> public static List <ShopOrderCoupon> GetAccountCoupon(int accid) { return(T_Order_CouponListBLL.GetCouponByAccId(accid)); }