예제 #1
0
파일: Coupons.cs 프로젝트: qq550723504/zone
        /// <summary>
        /// 通过IDataReader创建CouponInfo信息
        /// </summary>
        public static CouponInfo BuildCouponFromReader(IDataReader reader)
        {
            CouponInfo couponInfo = new CouponInfo();

            couponInfo.CouponId = TypeHelper.ObjectToInt(reader["couponid"]);
            couponInfo.CouponSN = reader["couponsn"].ToString();
            couponInfo.Uid = TypeHelper.ObjectToInt(reader["uid"]);
            couponInfo.CouponTypeId = TypeHelper.ObjectToInt(reader["coupontypeid"]);
            couponInfo.StoreId = TypeHelper.ObjectToInt(reader["storeid"]);
            couponInfo.Oid = TypeHelper.ObjectToInt(reader["oid"]);
            couponInfo.UseTime = TypeHelper.ObjectToDateTime(reader["usetime"]);
            couponInfo.UseIP = reader["useip"].ToString();
            couponInfo.Money = TypeHelper.ObjectToInt(reader["money"]);
            couponInfo.ActivateTime = TypeHelper.ObjectToDateTime(reader["activatetime"]);
            couponInfo.ActivateIP = reader["activateip"].ToString();
            couponInfo.CreateUid = TypeHelper.ObjectToInt(reader["createuid"]);
            couponInfo.CreateOid = TypeHelper.ObjectToInt(reader["createoid"]);
            couponInfo.CreateTime = TypeHelper.ObjectToDateTime(reader["createtime"]);
            couponInfo.CreateIP = reader["createip"].ToString();

            return couponInfo;
        }
예제 #2
0
 /// <summary>
 /// 创建优惠劵
 /// </summary>
 /// <param name="couponInfo">优惠劵信息</param>
 public void CreateCoupon(CouponInfo couponInfo)
 {
     DbParameter[] parms = {
                             GenerateInParam("@couponsn", SqlDbType.Char, 16, couponInfo.CouponSN),
                             GenerateInParam("@uid", SqlDbType.Int,4,couponInfo.Uid),
                             GenerateInParam("@coupontypeid", SqlDbType.Int,4,couponInfo.CouponTypeId),
                             GenerateInParam("@storeid", SqlDbType.Int,4,couponInfo.StoreId),
                             GenerateInParam("@oid", SqlDbType.Int,4,couponInfo.Oid),
                             GenerateInParam("@usetime", SqlDbType.DateTime,8,couponInfo.UseTime),
                             GenerateInParam("@useip", SqlDbType.Char,15,couponInfo.UseIP),
                             GenerateInParam("@money", SqlDbType.Int,4,couponInfo.Money),
                             GenerateInParam("@activatetime", SqlDbType.DateTime,8,couponInfo.ActivateTime),
                             GenerateInParam("@activateip", SqlDbType.Char,15,couponInfo.ActivateIP),
                             GenerateInParam("@createuid", SqlDbType.Int,4,couponInfo.CreateUid),
                             GenerateInParam("@createoid", SqlDbType.Int,4,couponInfo.CreateOid),
                             GenerateInParam("@createtime", SqlDbType.DateTime,8,couponInfo.CreateTime),
                             GenerateInParam("@createip", SqlDbType.Char,15,couponInfo.CreateIP)
                             };
     RDBSHelper.ExecuteNonQuery(CommandType.StoredProcedure,
                                string.Format("{0}createcoupon", RDBSHelper.RDBSTablePre),
                                parms);
 }
예제 #3
0
파일: Coupons.cs 프로젝트: qq550723504/zone
 /// <summary>
 /// 创建优惠劵
 /// </summary>
 /// <param name="couponInfo">优惠劵信息</param>
 public static void CreateCoupon(CouponInfo couponInfo)
 {
     BrnMall.Data.Coupons.CreateCoupon(couponInfo);
 }
예제 #4
0
파일: Coupons.cs 프로젝트: qq550723504/zone
        /// <summary>
        /// 发放单品促销活动优惠劵
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="couponTypeId">优惠劵类型id</param>
        /// <param name="orderInfo">订单信息</param>
        /// <param name="ip">ip</param>
        public static void SendSinglePromotionCoupon(PartUserInfo partUserInfo, int couponTypeId, OrderInfo orderInfo, string ip)
        {
            CouponTypeInfo couponTypeInfo = GetCouponTypeById(couponTypeId);
            if (couponTypeInfo == null || couponTypeInfo.State == 0 || couponTypeInfo.UserRankLower > partUserInfo.UserRid || couponTypeInfo.OrderAmountLower > orderInfo.OrderAmount)
                return;

            CouponInfo couponInfo = new CouponInfo();

            couponInfo.CouponSN = Coupons.GenerateCouponSN();
            couponInfo.Uid = partUserInfo.Uid;
            couponInfo.CouponTypeId = couponTypeId;
            couponInfo.StoreId = couponTypeInfo.StoreId;
            couponInfo.Oid = 0;
            couponInfo.UseTime = new DateTime(1900, 1, 1);
            couponInfo.UseIP = "";
            couponInfo.Money = couponTypeInfo.Money;
            couponInfo.ActivateTime = couponInfo.CreateTime = DateTime.Now;
            couponInfo.ActivateIP = couponInfo.CreateIP = ip;
            couponInfo.CreateUid = 0;
            couponInfo.CreateOid = orderInfo.Oid;

            CreateCoupon(couponInfo);
        }
예제 #5
0
파일: Coupons.cs 프로젝트: qq550723504/zone
        /// <summary>
        /// 领取优惠劵
        /// </summary>
        /// <param name="partUserInfo">用户信息</param>
        /// <param name="couponTypeInfo">优惠劵类型信息</param>
        /// <param name="pullTime">领取时间</param>
        /// <param name="pullIP">领取ip</param>
        /// <returns></returns>
        public static string PullCoupon(PartUserInfo partUserInfo, CouponTypeInfo couponTypeInfo, DateTime pullTime, string pullIP)
        {
            int sendCount = GetSendCouponCount(couponTypeInfo.CouponTypeId);
            BrnMall.Core.BMACache.Insert(CacheKeys.MALL_COUPONTYPE_SENDCOUNT + couponTypeInfo.CouponTypeId, sendCount + 1);

            string couponSN = GenerateCouponSN();

            CouponInfo couponInfo = new CouponInfo();

            couponInfo.CouponSN = couponSN;
            couponInfo.Uid = partUserInfo.Uid;
            couponInfo.CouponTypeId = couponTypeInfo.CouponTypeId;
            couponInfo.StoreId = couponTypeInfo.StoreId;
            couponInfo.Oid = 0;
            couponInfo.UseTime = new DateTime(1900, 1, 1);
            couponInfo.UseIP = "";
            couponInfo.Money = couponTypeInfo.Money;
            couponInfo.ActivateTime = pullTime;
            couponInfo.ActivateIP = pullIP;
            couponInfo.CreateUid = partUserInfo.Uid;
            couponInfo.CreateOid = 0;
            couponInfo.CreateTime = pullTime;
            couponInfo.CreateIP = pullIP;

            CreateCoupon(couponInfo);

            return couponSN;
        }
예제 #6
0
        /// <summary>
        /// 后台生成优惠劵
        /// </summary>
        /// <param name="o">参数对象</param>
        private static void AdminGenerateCoupon(object o)
        {
            object[] parms = (object[])o;

            int couponTypeId = (int)parms[0];
            int storeId = (int)parms[1];
            int money = (int)parms[2];
            int count = (int)parms[3];
            int sendUid = (int)parms[4];
            DateTime sendTime = (DateTime)parms[5];
            string sendIP = (string)parms[6];

            for (int i = 0; i < count; i++)
            {
                CouponInfo couponInfo = new CouponInfo();

                couponInfo.CouponSN = Coupons.GenerateCouponSN();
                couponInfo.Uid = 0;
                couponInfo.CouponTypeId = couponTypeId;
                couponInfo.StoreId = storeId;
                couponInfo.Oid = 0;
                couponInfo.UseTime = new DateTime(1900, 1, 1);
                couponInfo.UseIP = "";
                couponInfo.Money = money;
                couponInfo.ActivateTime = new DateTime(1900, 1, 1);
                couponInfo.ActivateIP = "";
                couponInfo.CreateUid = sendUid;
                couponInfo.CreateOid = 0;
                couponInfo.CreateTime = sendTime;
                couponInfo.CreateIP = sendIP;

                AdminCoupons.CreateCoupon(couponInfo);
            }
        }
예제 #7
0
        /// <summary>
        /// 后台批量生成优惠劵
        /// </summary>
        /// <param name="couponTypeId">优惠劵类型id</param>
        /// <param name="storeId">店铺id</param>
        /// <param name="money">优惠劵金额</param>
        /// <param name="count">数量</param>
        /// <param name="sendUid">发放人id</param>
        /// <param name="sendTime">发放时间</param>
        /// <param name="sendIP">发放ip</param>
        public static void AdminBatchGenerateCoupon(int couponTypeId, int storeId, int money, int count, int sendUid, DateTime sendTime, string sendIP)
        {
            if (count > 100)
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(AdminGenerateCoupon), new object[7] { couponTypeId, storeId, money, count, sendUid, sendTime, sendIP });
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    CouponInfo couponInfo = new CouponInfo();

                    couponInfo.CouponSN = Coupons.GenerateCouponSN();
                    couponInfo.Uid = 0;
                    couponInfo.CouponTypeId = couponTypeId;
                    couponInfo.StoreId = storeId;
                    couponInfo.Oid = 0;
                    couponInfo.UseTime = new DateTime(1900, 1, 1);
                    couponInfo.UseIP = "";
                    couponInfo.Money = money;
                    couponInfo.ActivateTime = new DateTime(1900, 1, 1);
                    couponInfo.ActivateIP = "";
                    couponInfo.CreateUid = sendUid;
                    couponInfo.CreateOid = 0;
                    couponInfo.CreateTime = sendTime;
                    couponInfo.CreateIP = sendIP;

                    CreateCoupon(couponInfo);
                }
            }
        }
예제 #8
0
        /// <summary>
        /// 后台发放优惠劵给用户
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <param name="couponTypeId">优惠劵类型id</param>
        /// <param name="storeId">店铺id</param>
        /// <param name="money">优惠劵金额</param>
        /// <param name="count">数量</param>
        /// <param name="sendUid">发放人id</param>
        /// <param name="sendTime">发放时间</param>
        /// <param name="sendIP">发放ip</param>
        public static void AdminSendCouponToUser(int uid, int couponTypeId, int storeId, int money, int count, int sendUid, DateTime sendTime, string sendIP)
        {
            for (int i = 0; i < count; i++)
            {
                CouponInfo couponInfo = new CouponInfo();

                couponInfo.CouponSN = GenerateCouponSN();
                couponInfo.Uid = uid;
                couponInfo.CouponTypeId = couponTypeId;
                couponInfo.StoreId = storeId;
                couponInfo.Oid = 0;
                couponInfo.UseTime = new DateTime(1900, 1, 1);
                couponInfo.UseIP = "";
                couponInfo.Money = money;
                couponInfo.ActivateTime = sendTime;
                couponInfo.ActivateIP = sendIP;
                couponInfo.CreateUid = sendUid;
                couponInfo.CreateOid = 0;
                couponInfo.CreateTime = sendTime;
                couponInfo.CreateIP = sendIP;

                CreateCoupon(couponInfo);
            }
        }
예제 #9
0
파일: Coupons.cs 프로젝트: qq550723504/zone
 /// <summary>
 /// 创建优惠劵
 /// </summary>
 /// <param name="couponInfo">优惠劵信息</param>
 public static void CreateCoupon(CouponInfo couponInfo)
 {
     BrnMall.Core.BMAData.RDBS.CreateCoupon(couponInfo);
 }