Пример #1
0
        /// <summary>
        /// 后台批量生成优惠劵
        /// </summary>
        /// <param name="couponTypeId">优惠劵类型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 money, int count, int sendUid, DateTime sendTime, string sendIP)
        {
            if (count > 100)
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(AdminGenerateCoupon), new object[6] { couponTypeId, 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.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);
                }
            }
        }
Пример #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("@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
 /// <summary>
 /// 创建优惠劵
 /// </summary>
 /// <param name="couponInfo">优惠劵信息</param>
 public static void CreateCoupon(CouponInfo couponInfo)
 {
     BrnShop.Core.BSPData.RDBS.CreateCoupon(couponInfo);
 }
Пример #4
0
        /// <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.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;
        }
Пример #5
0
        /// <summary>
        /// 后台生成优惠劵
        /// </summary>
        /// <param name="o">参数对象</param>
        private static void AdminGenerateCoupon(object o)
        {
            object[] parms = (object[])o;

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

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

                couponInfo.CouponSN = Coupons.GenerateCouponSN();
                couponInfo.Uid = 0;
                couponInfo.CouponTypeId = couponTypeId;
                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);
            }
        }
Пример #6
0
        /// <summary>
        /// 后台发放优惠劵给用户
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <param name="couponTypeId">优惠劵类型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 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.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);
            }
        }