예제 #1
0
 public ResponseModel DeleteCouponList(CC_Coupon request)
 {
     base.Remote.Action  = "DeleteCouponList";
     base.Remote.Content = request.JsonSerialize();
     _JSON = base.Remote.GetRemoteData();
     return(_JSON.JsonDeserialize <ResponseModel>());
 }
예제 #2
0
        public void RedisSetSingleCoupon(CC_Coupon coupon)
        {
            int intLimt  = 1000;
            int intTotal = coupon.CouponLenth;

            if (coupon != null && coupon.CouponLenth > 0)
            {
                //while (intTotal >0)
                //{

                if (intTotal > intLimt)
                {
                    coupon.CouponLenth = intLimt;
                }
                else
                {
                    coupon.CouponLenth = intTotal;
                }

                RedisOpenAPI.Instance.SetTimeOut(60).SetRetryCount(1).CCCoupon().SetCouponList(coupon);
                intTotal = intTotal - intLimt;
                Thread.Sleep(1000);
                //}
            }
        }
예제 #3
0
 public ResponseModel <long> GetCouponListLength(CC_Coupon request)
 {
     this.Remote.Action  = "GetCouponListLength";
     this.Remote.Content = request.JsonSerialize();
     _JSON = this.Remote.GetRemoteData();
     return(_JSON.JsonDeserialize <ResponseModel <long> >());
 }
예제 #4
0
 /// <summary>
 /// 种植 更新优惠券
 /// </summary>
 public ResponseModel SetCouponList(CC_Coupon request)
 {
     this.Remote.Action  = "SetCouponList";
     this.Remote.Content = request.JsonSerialize();
     _JSON = this.Remote.GetRemoteData();
     return(_JSON.JsonDeserialize <ResponseModel>());
 }
예제 #5
0
        public HttpResponseMessage SetCouponList([FromBody] CC_Coupon couponData)
        {
            try
            {
                var db  = new RedisOperation(_RedisDB);
                var key = RedisKeys.CCCouponKey(couponData.CustomerId, couponData.CouponTypeId);
                //
                var coupons = new List <CC_Coupon>();
                for (var i = 0; i < couponData.CouponLenth; i++)
                {
                    coupons.Add(couponData.DeepClone());
                }
                //
                var total = couponData.CouponLenth;
                var limit = 100;
                var start = 0;

                //
                do
                {
                    //
                    var models = coupons.Skip(start).Take(limit).ToList();

                    //
                    db.InsertListQueueBatch <CC_Coupon>(key, models);

                    //
                    if (start < (total - limit))
                    {
                        start = start + limit;
                    }
                    else
                    {
                        start = total;
                    }
                }while (start < total);
                return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel
                {
                    Code = ResponseCode.Success,
                    Message = "success"
                }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel
                {
                    Code = ResponseCode.Fail,
                    Message = "fail:" + ex.Message
                }));
            }
        }
예제 #6
0
 public HttpResponseMessage DeleteCouponList([FromBody] CC_Coupon couponData)
 {
     try
     {
         var db     = new RedisOperation(_RedisDB);
         var key    = RedisKeys.CCCouponKey(couponData.CustomerId, couponData.CouponTypeId);
         var result = db.Delete(key);
         return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel
         {
             Code = ResponseCode.Success,
             Message = "success"
         }));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel
         {
             Code = ResponseCode.Fail,
             Message = "fail:" + ex.Message
         }));
     }
 }
        public void InsertDataBase(string strCustomerId, string strVipId, string strObjectId, string strSource, CC_Coupon coupon)
        {
            try
            {
                string customerCon = GetCustomerConn(strCustomerId);

                LoggingSessionInfo loggingSessionInfo    = new LoggingSessionInfo();
                LoggingManager     CurrentLoggingManager = new LoggingManager();
                loggingSessionInfo.ClientID                = strCustomerId;
                CurrentLoggingManager.Connection_String    = customerCon;
                loggingSessionInfo.CurrentLoggingManager   = CurrentLoggingManager;
                loggingSessionInfo.CurrentUser             = new BS.Entity.User.UserInfo();
                loggingSessionInfo.CurrentUser.customer_id = strCustomerId;

                DataTable dtCoupon = new DataTable();
                dtCoupon.Columns.Add("CouponID", typeof(string));
                dtCoupon.Columns.Add("CouponCode", typeof(string));
                dtCoupon.Columns.Add("CouponDesc", typeof(string));
                dtCoupon.Columns.Add("BeginDate", typeof(DateTime));
                dtCoupon.Columns.Add("EndDate", typeof(DateTime));
                dtCoupon.Columns.Add("CouponUrl", typeof(string));
                dtCoupon.Columns.Add("ImageUrl", typeof(string));
                dtCoupon.Columns.Add("Status", typeof(Int32));
                dtCoupon.Columns.Add("CreateTime", typeof(DateTime));
                dtCoupon.Columns.Add("CreateBy", typeof(string));
                dtCoupon.Columns.Add("LastUpdateTime", typeof(DateTime));
                dtCoupon.Columns.Add("LastUpdateBy", typeof(string));
                dtCoupon.Columns.Add("IsDelete", typeof(Int32));
                dtCoupon.Columns.Add("CouponTypeID", typeof(string));
                dtCoupon.Columns.Add("CoupnName", typeof(string));
                dtCoupon.Columns.Add("DoorID", typeof(string));
                dtCoupon.Columns.Add("CouponPwd", typeof(string));
                dtCoupon.Columns.Add("CollarCardMode", typeof(string));
                dtCoupon.Columns.Add("CustomerID", typeof(string));
                DataTable dtVipCoupon = new DataTable();
                dtVipCoupon.Columns.Add("VipCouponMapping", typeof(string));
                dtVipCoupon.Columns.Add("VIPID", typeof(string));
                dtVipCoupon.Columns.Add("CouponID", typeof(string));
                dtVipCoupon.Columns.Add("UrlInfo", typeof(string));
                dtVipCoupon.Columns.Add("IsDelete", typeof(Int32));
                dtVipCoupon.Columns.Add("LastUpdateBy", typeof(string));
                dtVipCoupon.Columns.Add("LastUpdateTime", typeof(DateTime));
                dtVipCoupon.Columns.Add("CreateBy", typeof(string));
                dtVipCoupon.Columns.Add("CreateTime", typeof(DateTime));
                dtVipCoupon.Columns.Add("FromVipId", typeof(string));
                dtVipCoupon.Columns.Add("ObjectId", typeof(string));
                dtVipCoupon.Columns.Add("CouponSourceId", typeof(string));

                RedisCouponBLL redisCouponBLL = new RedisCouponBLL();
                var            response       = redisCouponBLL.RedisGetCoupon(coupon);


                if (response.Code == ResponseCode.Success && response.Result.CouponTypeId != null)
                {
                    //String uperStr = StringUtil.GetRandomUperStr(4);
                    //String strInt = StringUtil.GetRandomStrInt(8);
                    //string strCouponCode = uperStr + "-" + strInt;
                    string strCouponCode = string.Empty;
                    strCouponCode = GetCouponNum(loggingSessionInfo, strCustomerId);
                    string strCouponId = Guid.NewGuid().ToString();

                    DataRow dr_Coupon = dtCoupon.NewRow();
                    dr_Coupon["CouponID"]   = strCouponId;
                    dr_Coupon["CouponCode"] = strCouponCode;
                    dr_Coupon["CouponDesc"] = response.Result.CouponTypeDesc;
                    if (response.Result.ServiceLife > 0)
                    {
                        dr_Coupon["BeginDate"] = DateTime.Now;
                        dr_Coupon["EndDate"]   = DateTime.Now.Date.AddDays(response.Result.ServiceLife - 1).ToShortDateString() + " 23:59:59.998";
                    }
                    else
                    {
                        dr_Coupon["BeginDate"] = response.Result.BeginTime;
                        dr_Coupon["EndDate"]   = response.Result.EndTime;
                    }
                    dr_Coupon["CouponUrl"]      = "";
                    dr_Coupon["ImageUrl"]       = "";
                    dr_Coupon["Status"]         = 2;
                    dr_Coupon["CreateTime"]     = DateTime.Now;
                    dr_Coupon["CreateBy"]       = "Redis";
                    dr_Coupon["LastUpdateTime"] = DateTime.Now;
                    dr_Coupon["LastUpdateBy"]   = "Redis";
                    dr_Coupon["IsDelete"]       = 0;
                    dr_Coupon["CouponTypeID"]   = response.Result.CouponTypeId;
                    dr_Coupon["CoupnName"]      = response.Result.CouponTypeName;
                    dr_Coupon["DoorID"]         = "";
                    dr_Coupon["CouponPwd"]      = "";
                    dr_Coupon["CollarCardMode"] = "";
                    dr_Coupon["CustomerID"]     = strCustomerId;
                    dtCoupon.Rows.Add(dr_Coupon);

                    DataRow dr_VipCoupon = dtVipCoupon.NewRow();
                    dr_VipCoupon["VipCouponMapping"] = Guid.NewGuid().ToString().Replace("-", "");
                    dr_VipCoupon["VIPID"]            = strVipId;
                    dr_VipCoupon["CouponID"]         = strCouponId;
                    dr_VipCoupon["UrlInfo"]          = "";
                    dr_VipCoupon["IsDelete"]         = 0;
                    dr_VipCoupon["LastUpdateBy"]     = "Redis";
                    dr_VipCoupon["LastUpdateTime"]   = DateTime.Now;
                    dr_VipCoupon["CreateBy"]         = "Redis";
                    dr_VipCoupon["CreateTime"]       = DateTime.Now;
                    dr_VipCoupon["FromVipId"]        = "";
                    dr_VipCoupon["ObjectId"]         = strObjectId;
                    dr_VipCoupon["CouponSourceId"]   = GetSourceId(strSource);


                    dtVipCoupon.Rows.Add(dr_VipCoupon);
                    if (strSource != "Activity")
                    {
                        try
                        {
                            ///优惠券到账通知
                            var CommonBLL = new CommonBLL();
                            var bllVip    = new VipBLL(loggingSessionInfo);
                            var vip       = bllVip.GetByID(strVipId);

                            string strValidityData = Convert.ToDateTime(dr_Coupon["BeginDate"].ToString()).ToShortDateString() + "-" + Convert.ToDateTime(dr_Coupon["EndDate"].ToString()).ToShortDateString();
                            CommonBLL.CouponsArrivalMessage(response.Result.CouponCode, response.Result.CouponTypeName, strValidityData, response.Result.CouponCategory == null ? "" : response.Result.CouponCategory, vip.WeiXinUserId, loggingSessionInfo);
                        }
                        catch (Exception ex)
                        {
                            BaseService.WriteLog("优惠券到账通知异常:" + ex.Message);
                        }
                    }
                }

                if (dtCoupon != null && dtCoupon.Rows.Count > 0)
                {
                    SqlBulkCopy(customerCon, dtCoupon, "Coupon");

                    var bllCouponType = new CouponTypeBLL(loggingSessionInfo);
                    bllCouponType.UpdateCouponTypeIsVoucher(strCustomerId);
                }
                if (dtVipCoupon != null && dtVipCoupon.Rows.Count > 0)
                {
                    SqlBulkCopy(customerCon, dtVipCoupon, "VipCouponMapping");
                }
            }
            catch (Exception ex)
            {
                BaseService.WriteLog("vip绑定优惠券异常" + ex.Message);
            }
            BaseService.WriteLog("---------------------------vip绑定优惠券结束---------------------------");
        }
        /// <summary>
        /// vip绑定coupon入队列
        /// </summary>
        /// <param name="coupon"></param>
        /// <param name="strObjectId"></param>
        /// <param name="strVipId"></param>
        /// <param name="strSource"></param>
        public void SetVipMappingCoupon(CC_Coupon coupon, string strObjectId, string strVipId, string strSource)
        {
            LoggingSessionInfo _loggingSessionInfo   = new LoggingSessionInfo();
            LoggingManager     CurrentLoggingManager = new LoggingManager();
            string             strCon = string.Empty;

            var connection = new RedisConnectionBLL().GetConnection(coupon.CustomerId);

            //如果缓存获取不到数据,从数据库读取数据库连接字符串
            if (connection.CustomerID == null)
            {
                connection.ConnectionStr = GetCustomerConn(coupon.CustomerId);
            }

            CurrentLoggingManager.Connection_String = connection.ConnectionStr;

            _loggingSessionInfo.ClientID = coupon.CustomerId;
            _loggingSessionInfo.CurrentLoggingManager = CurrentLoggingManager;

            RedisCouponBLL redisCouponBLL = new RedisCouponBLL();
            //获取优惠券数量
            var count = RedisOpenAPI.Instance.CCCoupon().GetCouponListLength(coupon);

            if (count.Code == ResponseCode.Success)
            {
                if (count.Result == 0)
                {
                    var bllCouponType = new CouponTypeBLL(_loggingSessionInfo);

                    var couponType = bllCouponType.QueryByEntity(new CouponTypeEntity()
                    {
                        CustomerId = coupon.CustomerId, CouponTypeID = new Guid(coupon.CouponTypeId), IsDelete = 0
                    }, null).SingleOrDefault();
                    if (couponType != null)
                    {
                        //计算剩余的优惠券数量
                        int intCouponLenth = Convert.ToInt32(couponType.IssuedQty) - Convert.ToInt32(couponType.IsVoucher);
                        if (intCouponLenth <= 0)
                        {
                            intCouponLenth = 1000;
                            //重置优惠券数量为1000
                            bllCouponType.UpdateCouponTypeIssuedQty(coupon.CouponTypeId, intCouponLenth);
                        }

                        //这里可能是重置 Redis 缓存中该类型优惠券数据数量
                        RedisOpenAPI.Instance.CCCoupon().SetCouponList(new CC_Coupon()
                        {
                            CustomerId     = couponType.CustomerId,
                            CouponTypeId   = couponType.CouponTypeID.ToString(),
                            CouponTypeDesc = couponType.CouponTypeDesc,
                            CouponTypeName = couponType.CouponTypeName,
                            BeginTime      = couponType.BeginTime.ToString(),
                            EndTime        = couponType.EndTime.ToString(),
                            ServiceLife    = couponType.ServiceLife ?? 0,
                            CouponLenth    = intCouponLenth,
                            CouponCategory = couponType.CouponCategory
                        });
                    }
                }
                //从 Redis 中重新获取优惠券信息
                var response = redisCouponBLL.RedisGetCoupon(coupon);
                if (response.Code == ResponseCode.Success && response.Result.CouponTypeId != null && response.Result.CouponTypeId.Length > 0)
                {
                    string strCouponCode = string.Empty;
                    //从数据库中读取优惠券编码
                    strCouponCode = GetCouponNum(_loggingSessionInfo, response.Result.CustomerId);
                    var _coupon = new CC_Coupon()
                    {
                        CustomerId     = response.Result.CustomerId,
                        CouponTypeId   = response.Result.CouponTypeId,
                        CouponTypeDesc = response.Result.CouponTypeDesc,
                        CouponTypeName = response.Result.CouponTypeName,
                        CouponCode     = strCouponCode,
                        BeginTime      = response.Result.BeginTime,
                        EndTime        = response.Result.EndTime,
                        ServiceLife    = response.Result.ServiceLife,
                        CouponCategory = response.Result.CouponCategory,
                        CouponId       = Guid.NewGuid().ToString()
                    };
                    BaseService.WriteLog("---------------------------入vip绑定优惠券队列---------------------------");
                    //将优惠券推送到 Redis 缓存中
                    RedisOpenAPI.Instance.CCVipMappingCoupon().SetVipMappingCoupon(new CC_VipMappingCoupon()
                    {
                        CustomerId = coupon.CustomerId,
                        ObjectId   = strObjectId,
                        VipId      = strVipId,
                        Source     = strSource,
                        Coupon     = _coupon
                    });
                }
            }
        }
        /// <summary>
        /// 虚拟商品发优惠券
        /// </summary>
        /// <param name="lstCoupon"></param>
        /// <param name="strObjectId"></param>
        /// <param name="strVipId"></param>
        /// <param name="strSource"></param>
        public void SetVipMappingCoupon(List <CouponTypeEntity> lstCoupon, string strObjectId, string strVipId, string strSource)
        {
            BaseService.WriteLog("---------------------------入vip绑定优惠券队列开始---------------------------");

            LoggingSessionInfo _loggingSessionInfo   = new LoggingSessionInfo();
            LoggingManager     CurrentLoggingManager = new LoggingManager();
            string             strCon = string.Empty;
            var coupon = lstCoupon.FirstOrDefault();

            try
            {
                var connection = new RedisConnectionBLL().GetConnection(coupon.CustomerId);
                //如果缓存获取不到数据,从数据库读取数据库连接字符串
                if (connection.CustomerID == null)
                {
                    connection.ConnectionStr = GetCustomerConn(coupon.CustomerId);
                }

                CurrentLoggingManager.Connection_String = connection.ConnectionStr;

                _loggingSessionInfo.ClientID = coupon.CustomerId;
                _loggingSessionInfo.CurrentLoggingManager = CurrentLoggingManager;

                RedisCouponBLL redisCouponBLL = new RedisCouponBLL();

                //从 Redis 中重新获取优惠券信息
                foreach (var itemCoupon in lstCoupon)  //按照优惠券类型进行依次发送
                {
                    //下面这段话是不是应该放在下面的for循环里面??
                    //获取Redis中当前 CouponTypeID 类型的优惠券数量
                    var count = RedisOpenAPI.Instance.CCCoupon().GetCouponListLength(new CC_Coupon()
                    {
                        CustomerId   = itemCoupon.CustomerId,
                        CouponTypeId = itemCoupon.CouponTypeID.ToString()
                    });

                    if (count.Code != ResponseCode.Success)
                    {
                        BaseService.WriteLog("请求Redist失败,请求函数 GetCouponListLength ,参数 CustomerId:" + itemCoupon.CustomerId + ", CouponTypeId:" + itemCoupon.CouponTypeID.ToString());
                        continue;
                    }

                    //如果 Redis 该类型优惠券已用完
                    if (count.Result == 0)
                    {
                        CheckRedisCouponNum(_loggingSessionInfo, itemCoupon);
                    }

                    int sendRedistCount = 0;
                    //根据虚拟商品中配置的商品数量,插入到 Redist 中
                    for (int i = 0; i < itemCoupon.Item_Count; i++)
                    {
                        //获取优惠券类型数据
                        var response = redisCouponBLL.RedisGetCoupon(new CC_Coupon()
                        {
                            CustomerId   = itemCoupon.CustomerId,
                            CouponTypeId = itemCoupon.CouponTypeID.ToString()
                        });
                        #region  发送一张优惠券
                        if (response.Code == ResponseCode.Success && response.Result.CouponTypeId != null && response.Result.CouponTypeId.Length > 0)
                        {
                            string strCouponCode = string.Empty;
                            //从数据库中读取优惠券编码
                            strCouponCode = GetCouponNum(_loggingSessionInfo, response.Result.CustomerId);
                            var _coupon = new CC_Coupon()
                            {
                                CustomerId     = response.Result.CustomerId,
                                CouponTypeId   = response.Result.CouponTypeId,
                                CouponTypeDesc = response.Result.CouponTypeDesc,
                                CouponTypeName = response.Result.CouponTypeName,
                                CouponCode     = strCouponCode, //优惠券code
                                BeginTime      = response.Result.BeginTime,
                                EndTime        = response.Result.EndTime,
                                ServiceLife    = response.Result.ServiceLife,
                                CouponCategory = response.Result.CouponCategory,
                                CouponId       = Guid.NewGuid().ToString()
                            };

                            //将优惠券推送到 Redis 缓存中
                            RedisOpenAPI.Instance.CCVipMappingCoupon().SetVipMappingCoupon(new CC_VipMappingCoupon()
                            {
                                CustomerId = itemCoupon.CustomerId,
                                ObjectId   = strObjectId,
                                VipId      = strVipId,
                                Source     = strSource,
                                Coupon     = _coupon
                            });

                            sendRedistCount++;
                        } //if数量
                        #endregion
                    }     //里面的for

                    //针对每一种类型的优惠券,发送一个通知
                    DateTime?BeginDate = null;
                    string   EndDate   = null;
                    if (itemCoupon.ServiceLife > 0)
                    {
                        BeginDate = DateTime.Now;
                        EndDate   = DateTime.Now.Date.AddDays((int)itemCoupon.ServiceLife - 1).ToShortDateString() + " 23:59:59.998";
                    }
                    else
                    {
                        BeginDate = itemCoupon.BeginTime;
                        EndDate   = itemCoupon.EndTime.ToString();
                    }
                    string strValidityData = Convert.ToDateTime(BeginDate.ToString()).ToShortDateString() + "-" + Convert.ToDateTime(EndDate.ToString()).ToShortDateString();
//写入到缓存
                    new SendCouponNoticeBLL().CouponsArrivalMessage(itemCoupon.CouponTypeName, itemCoupon.CouponTypeName, strValidityData, itemCoupon.CouponCategory == null ? "" : itemCoupon.CouponCategory, itemCoupon.WeiXinUserId, _loggingSessionInfo, itemCoupon.Item_Count.ToString());//存入到缓存j


                    BaseService.WriteLog(string.Format("---------------------------入vip绑定优惠券队列数量{0}---------------------------", sendRedistCount));
                } //foreach
            }     //try
            catch (Exception ex)
            {
                BaseService.WriteLog("向Redis发送优惠券时发生异常,异常信息:" + ex.Message);
                BaseService.WriteLog("向Redis发送优惠券时发生异常,异常堆栈信息:" + ex.StackTrace);
            }
        }
예제 #10
0
        /// <summary>
        /// 下载二维码
        /// </summary>
        /// <param name="coupon"></param>
        /// <param name="strCon"></param>
        /// <returns></returns>
        public DataTable DownloadCoupon(CC_Coupon coupon, string strCustomerid, int downLoadNum, int intIsNotLimitQty)
        {
            var                count              = RedisOpenAPI.Instance.CCCoupon().GetCouponListLength(coupon);
            DataTable          dtCoupon           = new DataTable();
            LoggingSessionInfo loggingSessionInfo = CustomerBLL.Instance.GetBSLoggingSession(strCustomerid, "RedisSystem");


            dtCoupon.Columns.Add("CouponID", typeof(string));
            dtCoupon.Columns.Add("CouponCode", typeof(string));
            dtCoupon.Columns.Add("CouponDesc", typeof(string));
            dtCoupon.Columns.Add("BeginDate", typeof(DateTime));
            dtCoupon.Columns.Add("EndDate", typeof(DateTime));
            dtCoupon.Columns.Add("CouponUrl", typeof(string));
            dtCoupon.Columns.Add("ImageUrl", typeof(string));
            dtCoupon.Columns.Add("Status", typeof(Int32));
            dtCoupon.Columns.Add("CreateTime", typeof(DateTime));
            dtCoupon.Columns.Add("CreateBy", typeof(string));
            dtCoupon.Columns.Add("LastUpdateTime", typeof(DateTime));
            dtCoupon.Columns.Add("LastUpdateBy", typeof(string));
            dtCoupon.Columns.Add("IsDelete", typeof(Int32));
            dtCoupon.Columns.Add("CouponTypeID", typeof(string));
            dtCoupon.Columns.Add("CoupnName", typeof(string));
            dtCoupon.Columns.Add("DoorID", typeof(string));
            dtCoupon.Columns.Add("CouponPwd", typeof(string));
            dtCoupon.Columns.Add("CollarCardMode", typeof(string));
            dtCoupon.Columns.Add("CustomerID", typeof(string));

            DataTable dtCouponExport = new DataTable();

            dtCouponExport.Columns.Add("CouponCode", typeof(string));
            CC_Connection connection = new CC_Connection();
            string        strCon     = string.Empty;

            if (count.Code == ResponseCode.Success)
            {
                if (count.Result > 0)
                {
                    connection = new RedisConnectionBLL().GetConnection(strCustomerid);
                    if (connection.ConnectionStr == null)
                    {
                        strCon = GetCustomerConn(strCustomerid);
                    }
                    else
                    {
                        strCon = connection.ConnectionStr;
                    }

                    long num = 0;
                    if (downLoadNum > count.Result)
                    {
                        if (intIsNotLimitQty == 1)
                        {
                            var bllCouponType = new CouponTypeBLL(loggingSessionInfo);
                            bllCouponType.UpdateCouponTypeIssuedQty(coupon.CouponTypeId, downLoadNum);
                            coupon.CouponLenth = downLoadNum;
                            RedisOpenAPI.Instance.CCCoupon().SetCouponList(coupon);
                            num = downLoadNum;
                        }
                        else
                        {
                            num = count.Result;
                        }
                    }
                    else
                    {
                        num = downLoadNum;
                    }

                    for (int i = 0; i < num; i++)
                    {
                        var response = RedisGetCoupon(coupon);
                        if (response.Code == ResponseCode.Success)
                        {
                            String uperStr       = StringUtil.GetRandomUperStr(4);
                            String strInt        = StringUtil.GetRandomStrInt(8);
                            string strCouponCode = uperStr + "-" + strInt;

                            DataRow dr_Coupon = dtCoupon.NewRow();
                            dr_Coupon["CouponID"]   = Guid.NewGuid().ToString();
                            dr_Coupon["CouponCode"] = strCouponCode;
                            dr_Coupon["CouponDesc"] = response.Result.CouponTypeDesc;
                            if (response.Result.ServiceLife > 0)
                            {
                                dr_Coupon["BeginDate"] = DateTime.Now;
                                dr_Coupon["EndDate"]   = DateTime.Now.Date.AddDays(response.Result.ServiceLife - 1).ToShortDateString() + " 23:59:59.998";
                            }
                            else
                            {
                                dr_Coupon["BeginDate"] = response.Result.BeginTime;
                                dr_Coupon["EndDate"]   = response.Result.EndTime;
                            }
                            dr_Coupon["CouponUrl"]      = "";
                            dr_Coupon["ImageUrl"]       = "";
                            dr_Coupon["Status"]         = 0;
                            dr_Coupon["CreateTime"]     = DateTime.Now;
                            dr_Coupon["CreateBy"]       = "Redis";
                            dr_Coupon["LastUpdateTime"] = DateTime.Now;
                            dr_Coupon["LastUpdateBy"]   = "Redis";
                            dr_Coupon["IsDelete"]       = 0;
                            dr_Coupon["CouponTypeID"]   = response.Result.CouponTypeId;
                            dr_Coupon["CoupnName"]      = response.Result.CouponTypeName;
                            dr_Coupon["DoorID"]         = "";
                            dr_Coupon["CouponPwd"]      = "";
                            dr_Coupon["CollarCardMode"] = "";
                            dr_Coupon["CustomerID"]     = coupon.CustomerId;
                            dtCoupon.Rows.Add(dr_Coupon);

                            DataRow dr_CouponExport = dtCouponExport.NewRow();
                            dr_CouponExport["CouponCode"] = strCouponCode;
                            dtCouponExport.Rows.Add(dr_CouponExport);
                        }
                    }
                    if (dtCoupon != null && dtCoupon.Rows.Count > 0)
                    {
                        SqlBulkCopy(strCon, dtCoupon, "Coupon");
                        var bllCouponType = new CouponTypeBLL(loggingSessionInfo);
                        bllCouponType.UpdateCouponTypeIsVoucher(strCustomerid);
                    }
                }
            }
            return(dtCouponExport);
        }
예제 #11
0
        public long GetCouponListLength(CC_Coupon coupon)
        {
            var count = RedisOpenAPI.Instance.CCCoupon().GetCouponListLength(coupon);

            return(count.Result);
        }
예제 #12
0
 public ResponseModel <CC_Coupon> RedisGetCoupon(CC_Coupon coupon)
 {
     return(RedisOpenAPI.Instance.CCCoupon().GetCoupon(coupon));
 }