示例#1
0
        /// <summary>
        /// 获取优惠券信息
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetCouponDetail(string openId, int couponId = 0)
        {
            if (couponId <= 0)
            {
                return(Json(ErrorResult <dynamic>("参数错误")));
            }
            CouponInfo coupon = CouponApplication.GetCouponInfo(couponId);

            if (coupon == null)
            {
                return(Json(ErrorResult <dynamic>("错误的优惠券编号")));
            }
            else
            {
                return(JsonResult <dynamic>(new
                {
                    CouponId = coupon.Id,
                    CouponName = coupon.CouponName,
                    Price = coupon.Price,
                    SendCount = coupon.Num,
                    UserLimitCount = coupon.PerMax,
                    OrderUseLimit = Math.Round(coupon.OrderAmount, 2),
                    StartTime = coupon.StartTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    ClosingTime = coupon.EndTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    CanUseProducts = "",
                    ObtainWay = coupon.ReceiveType,
                    NeedPoint = coupon.NeedIntegral,
                    UseWithGroup = false,
                    UseWithPanicBuying = false,
                    UseWithFireGroup = false,
                    Remark = coupon.Remark,
                    UseArea = coupon.UseArea
                }));
            }
        }
示例#2
0
        public JsonResult GetWXCardData(long id)
        {
            WXJSCardModel    wXJSCardModel    = new WXJSCardModel();
            bool             flag             = true;
            ICouponService   couponService    = ServiceHelper.Create <ICouponService>();
            CouponRecordInfo couponRecordById = null;

            if (flag)
            {
                couponRecordById = couponService.GetCouponRecordById(id);
                if (couponRecordById == null)
                {
                    flag = false;
                }
            }
            CouponInfo couponInfo = null;

            if (flag)
            {
                couponInfo = couponService.GetCouponInfo(couponRecordById.ShopId, couponRecordById.CouponId);
                if (couponInfo == null)
                {
                    flag = false;
                }
            }
            if (flag && couponInfo.IsSyncWeiXin == 1 && base.PlatformType == ChemCloud.Core.PlatformType.WeiXin)
            {
                wXJSCardModel = ser_wxcard.GetJSWeiXinCard(couponRecordById.CouponId, couponRecordById.Id, ThisCouponType);
            }
            return(Json(wXJSCardModel));
        }
示例#3
0
        private void CanAddOrEditCoupon(CouponInfo info)
        {
            List <long> list = (
                from a in context.CouponInfo
                where (a.EndTime > DateTime.Now) && a.ShopId == info.ShopId && (int)a.ReceiveType != 1 && (int)a.ReceiveType != 2
                select a.Id).ToList();
            List <CouponSettingInfo> couponSettingInfos = (
                from a in context.CouponSettingInfo
                where list.Contains(a.CouponID)
                select a).ToList();

            if (info.Himall_CouponSetting != null && info.Himall_CouponSetting.Count > 0)
            {
                if (couponSettingInfos.Count((CouponSettingInfo a) => a.PlatForm == PlatformType.Wap) >= 5)
                {
                    if (!list.Any((long d) => d == info.Id))
                    {
                        throw new HimallException("最多添加5个移动端优惠券");
                    }
                }
                if (couponSettingInfos.Count((CouponSettingInfo a) => a.PlatForm == PlatformType.PC) >= 5)
                {
                    if (!list.Any((long d) => d == info.Id))
                    {
                        throw new HimallException("最多添加5个PC端个优惠券");
                    }
                }
            }
        }
示例#4
0
 public static CouponInfo UseCoupon(decimal orderAmount, string claimCode)
 {
     if (!string.IsNullOrEmpty(claimCode))
     {
         CouponInfo coupon = GetCoupon(claimCode);
         if (coupon != null)
         {
             decimal?amount;
             if (coupon.Amount.HasValue)
             {
                 amount = coupon.Amount;
                 if (!((amount.GetValueOrDefault() > 0M) && amount.HasValue) || (orderAmount < coupon.Amount.Value))
                 {
                 }
             }
             if ((coupon.Amount.HasValue && (!(((amount = coupon.Amount).GetValueOrDefault() == 0M) && amount.HasValue) || (orderAmount <= coupon.DiscountValue))))
             {
                 return(coupon);
             }
             if (coupon.Amount == 0M && orderAmount >= coupon.DiscountValue)
             {
                 return(coupon);
             }
         }
     }
     return(null);
 }
示例#5
0
        /// <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.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);
        }
示例#6
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);
                }
            }
        }
示例#7
0
        /// <summary>
        /// 验证优惠劵编号
        /// </summary>
        /// <returns></returns>
        public ActionResult VerifyCouponSN()
        {
            string couponSN = WebHelper.GetQueryString("couponSN");//优惠劵编号

            if (couponSN.Length == 0)
            {
                return(AjaxResult("emptycouponsn", "请输入优惠劵编号"));
            }
            else if (couponSN.Length != 16)
            {
                return(AjaxResult("errorcouponsn", "优惠劵编号不正确"));
            }

            CouponInfo couponInfo = Coupons.GetCouponByCouponSN(couponSN);

            if (couponInfo == null)//不存在
            {
                return(AjaxResult("noexist", "优惠劵不存在"));
            }
            else if (couponInfo.Oid > 0)//已使用
            {
                return(AjaxResult("used", "优惠劵已使用"));
            }
            else if (couponInfo.Uid > 0)//已激活
            {
                return(AjaxResult("activated", "优惠劵已激活"));
            }
            else//未激活
            {
                return(AjaxResult("nonactivated", "优惠劵未激活"));
            }
        }
示例#8
0
        /// <summary>
        /// 新增状态下的数据保存
        /// </summary>
        /// <returns></returns>
        public override bool SaveAddNew()
        {
            CouponInfo info = new CouponInfo();//必须使用存在的局部变量,因为部分信息可能被附件使用

            SetInfo(info);
            try
            {
                #region 新增数据

                bool succeed = BLLFactory <Coupon> .Instance.Insert(info);

                if (succeed)
                {
                    //可添加其他关联操作

                    return(true);
                }
                #endregion
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmGenerateCoupon));
                MessageDxUtil.ShowError(ex.Message);
            }
            return(false);
        }
示例#9
0
        /// <summary>
        /// 编辑状态下的数据保存
        /// </summary>
        /// <returns></returns>
        public override bool SaveUpdated()
        {
            CouponInfo info = BLLFactory <Coupon> .Instance.FindByID(ID);

            if (info != null)
            {
                SetInfo(info);

                try
                {
                    #region 更新数据
                    bool succeed = BLLFactory <Coupon> .Instance.Update(info, info.ID);

                    if (succeed)
                    {
                        //可添加其他关联操作

                        return(true);
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmGenerateCoupon));
                    MessageDxUtil.ShowError(ex.Message);
                }
            }
            return(false);
        }
示例#10
0
        /// <summary>
        /// 数据显示的函数
        /// </summary>
        public override void DisplayData()
        {
            InitDictItem();//数据字典加载(公用)

            if (!string.IsNullOrEmpty(ID))
            {
                #region 显示信息
                CouponInfo info = BLLFactory <Coupon> .Instance.FindByID(ID);

                if (info != null)
                {
                    txtID.Text = ID;
                    CouponCategoryInfo info2 = BLLFactory <CouponCategory> .Instance.FindByID(info.CouponCategory_ID);

                    if (info2 != null)
                    {
                        txtCategory.SelectedText = info2.HandNo + "-" + info2.Name;
                    }
                    txtMobilePhone.Text      = info.MobilePhone;
                    txtLoginName.Text        = info.LoginName;
                    txtEndTime.DateTime      = info.EndTime;
                    txtStartTime.DateTime    = info.StartTime;
                    txtEnabled.SelectedIndex = info.DELETED;
                    txtCreator.Text          = info.Creator;
                    txtCreateTime.SetDateTime(info.CreateTime);
                }
                #endregion
            }
            else
            {
                txtCreator.Text        = Portal.gc.UserInfo.LoginName; //默认为当前登录用户
                txtCreateTime.DateTime = DateTime.Now;                 //默认当前时间
                txtID.Text             = Guid.NewGuid().ToString();
            }
        }
示例#11
0
        /// <summary>
        /// 编辑或者保存状态下取值函数
        /// </summary>
        /// <param name="info"></param>
        private void SetInfo(CouponInfo info)
        {
            info.ID = txtID.Text.Trim();
            if (string.IsNullOrEmpty(ID))
            {
                info.Creator    = Portal.gc.UserInfo.LoginName;
                info.Creator_ID = Portal.gc.UserInfo.ID.ToString();
                info.CreateTime = DateTime.Now;
            }
            info.CouponCategory_ID = (txtCategory.SelectedItem as CListItem).Value;
            CouponCategoryInfo couponCategoryInfo = BLLFactory <CouponCategory> .Instance.FindByID(info.CouponCategory_ID);

            if (couponCategoryInfo != null)
            {
                info.CouponCategory_Name = couponCategoryInfo.Name;
                info.Company_ID          = couponCategoryInfo.BelongCompanys;
                OUInfo ouInfo = BLLFactory <OU> .Instance.FindByID(info.Company_ID);

                info.Company_Name = ouInfo.Name;
            }

            info.MobilePhone = txtMobilePhone.Text;
            info.LoginName   = txtLoginName.Text;
            info.StartTime   = txtStartTime.DateTime;
            info.EndTime     = txtEndTime.DateTime;
            info.DELETED     = txtEnabled.SelectedIndex;
        }
示例#12
0
 public bool AddCouponProducts(int couponId, bool IsAllProduct, IList <string> productIDs)
 {
     try
     {
         CouponInfo couponDetails = this.GetCouponDetails(couponId);
         if (couponDetails != null)
         {
             if (IsAllProduct)
             {
                 couponDetails.IsAllProduct  = true;
                 couponDetails.ProductNumber = 0;
             }
             else
             {
                 couponDetails.IsAllProduct  = false;
                 couponDetails.ProductNumber = productIDs.Count;
             }
             if (IsAllProduct)
             {
                 DbCommand command = this.database.GetSqlStringCommand("update Hishop_Coupon_Coupons set IsAllProduct=@IsAllProduct , ProductNumber=@ProductNumber WHERE CouponId = @CouponId");
                 this.database.AddInParameter(command, "CouponId", DbType.Int32, couponId);
                 this.database.AddInParameter(command, "ProductNumber", DbType.Int32, couponDetails.ProductNumber);
                 this.database.AddInParameter(command, "IsAllProduct", DbType.Boolean, couponDetails.IsAllProduct);
                 this.database.ExecuteNonQuery(command);
                 command = this.database.GetSqlStringCommand("Delete from  Hishop_Coupon_Products WHERE CouponId = @CouponId");
                 this.database.AddInParameter(command, "CouponId", DbType.Int32, couponId);
                 this.database.ExecuteNonQuery(command);
                 return(true);
             }
             string str = "";
             if (productIDs.Count > 0)
             {
                 foreach (string str2 in productIDs)
                 {
                     str = str + "," + str2;
                 }
             }
             str = str.Substring(1);
             DbCommand sqlStringCommand = this.database.GetSqlStringCommand(string.Format("Delete from  Hishop_Coupon_Products WHERE CouponId ={0} and ProductId in ( {1} )", couponId, str));
             this.database.ExecuteNonQuery(sqlStringCommand);
             StringBuilder builder = new StringBuilder();
             foreach (string str3 in productIDs)
             {
                 builder.AppendFormat(" insert into Hishop_Coupon_Products(couponId , ProductId) values({0} , {1}) ", couponDetails.CouponId, str3);
             }
             sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());
             this.database.ExecuteNonQuery(sqlStringCommand);
             sqlStringCommand = this.database.GetSqlStringCommand("update Hishop_Coupon_Coupons set IsAllProduct=@IsAllProduct , ProductNumber=(select count(productId) from Hishop_Coupon_Products  where CouponId = @CouponId) WHERE CouponId = @CouponId");
             this.database.AddInParameter(sqlStringCommand, "CouponId", DbType.Int32, couponId);
             this.database.AddInParameter(sqlStringCommand, "IsAllProduct", DbType.Boolean, couponDetails.IsAllProduct);
             this.database.ExecuteNonQuery(sqlStringCommand);
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
 }
示例#13
0
        public void Update(CouponInfo couponInfo)
        {
            IDataParameter[] parms = null;
            var SQL_UPDATE         = BaiRongDataProvider.TableStructureDao.GetUpdateSqlString(couponInfo.ToNameValueCollection(), ConnectionString, TABLE_NAME, out parms);

            ExecuteNonQuery(SQL_UPDATE, parms);
        }
示例#14
0
        public int Insert(CouponInfo couponInfo)
        {
            var couponID = 0;

            IDataParameter[] parms = null;

            var SQL_INSERT = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(couponInfo.ToNameValueCollection(), ConnectionString, TABLE_NAME, out parms);


            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        ExecuteNonQuery(trans, SQL_INSERT, parms);

                        couponID = BaiRongDataProvider.DatabaseDao.GetSequence(trans, TABLE_NAME);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(couponID);
        }
示例#15
0
        public bool AddCouponProducts(int couponId, int productID)
        {
            bool result;

            try
            {
                CouponInfo couponDetails = this.GetCouponDetails(couponId);
                if (couponDetails != null)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendFormat(" insert into Hishop_Coupon_Products(couponId , ProductId) values({0} , {1}) ", couponDetails.CouponId, productID);
                    System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand(stringBuilder.ToString());
                    this.database.ExecuteNonQuery(sqlStringCommand);
                    sqlStringCommand = this.database.GetSqlStringCommand("update Hishop_Coupon_Coupons set IsAllProduct=0 , ProductNumber=(select count(productId) from Hishop_Coupon_Products  where CouponId = @CouponId) WHERE CouponId = @CouponId");
                    this.database.AddInParameter(sqlStringCommand, "CouponId", System.Data.DbType.Int32, couponId);
                    this.database.ExecuteNonQuery(sqlStringCommand);
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            catch (Exception)
            {
                result = false;
            }
            return(result);
        }
示例#16
0
        public int Insert(CouponInfo couponInfo)
        {
            var couponId = 0;

            IDataParameter[] parms = null;

            var sqlInsert = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(couponInfo.ToNameValueCollection(), ConnectionString, TableName, out parms);


            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        couponId = ExecuteNonQueryAndReturnId(trans, sqlInsert, parms);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(couponId);
        }
示例#17
0
        private void GetCouponInfo(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            StringBuilder builder = new StringBuilder("{");
            int           result  = 0;

            if (!int.TryParse(context.Request["id"], out result))
            {
                builder.Append("\"Status\":\"0\"}");
                context.Response.Write(builder.ToString());
            }
            CouponInfo coupon = CouponHelper.GetCoupon(result);

            if (coupon == null)
            {
                builder.Append("\"Status\":\"1\"}");
                context.Response.Write(builder.ToString());
            }
            else
            {
                var type = new {
                    Status    = 2,
                    Count     = coupon.StockNum - coupon.ReceiveNum,
                    BeginTime = coupon.BeginDate,
                    EndTime   = coupon.EndDate
                };
                IsoDateTimeConverter converter = new IsoDateTimeConverter {
                    DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
                };
                context.Response.Write(JsonConvert.SerializeObject(type, Formatting.Indented, new JsonConverter[] { converter }));
            }
        }
示例#18
0
        public void Update(CouponInfo couponInfo)
        {
            IDataParameter[] parms = null;
            var sqlUpdate          = BaiRongDataProvider.TableStructureDao.GetUpdateSqlString(couponInfo.ToNameValueCollection(), ConnectionString, TableName, out parms);

            ExecuteNonQuery(sqlUpdate, parms);
        }
示例#19
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);
            }
        }
示例#20
0
        public string GetPrizeType(PrizeTypes PrizeType, int PrizeValue)
        {
            string result = string.Empty;

            switch (PrizeType)
            {
            case PrizeTypes.Integral:
                result = PrizeValue + "积分; ";
                break;

            case PrizeTypes.Coupou:
            {
                CouponInfo coupon = CouponHelper.GetCoupon(PrizeValue);
                result = ((coupon == null) ? " " : ((!(coupon.ClosingTime > coupon.StartTime)) ? (coupon.Price + "元优惠券<font style='color:red;'>(已失效)</font>; ") : (coupon.Price + "元优惠券; ")));
                break;
            }

            case PrizeTypes.Gift:
            {
                GiftInfo giftDetails = GiftHelper.GetGiftDetails(PrizeValue);
                result = ((giftDetails == null) ? " " : (giftDetails.Name + "; "));
                break;
            }
            }
            return(result);
        }
示例#21
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            CouponInfo coupon = new CouponInfo();

            coupon.ID           = RequestHelper.GetQueryString <int>("ID");
            coupon.Name         = this.Name.Text;
            coupon.Money        = Convert.ToDecimal(this.Money.Text);
            coupon.UseMinAmount = Convert.ToDecimal(this.UseMinAmount.Text);
            coupon.UseStartDate = Convert.ToDateTime(this.UseStartDate.Text);
            coupon.UseEndDate   = Convert.ToDateTime(this.UseEndDate.Text).AddDays(1.0).AddSeconds(-1.0);
            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            if (coupon.ID == -2147483648)
            {
                base.CheckAdminPower("AddCoupon", PowerCheckType.Single);
                coupon.ID = CouponBLL.AddCoupon(coupon);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Coupon"), coupon.ID);
            }
            else
            {
                base.CheckAdminPower("UpdateCoupon", PowerCheckType.Single);
                CouponBLL.UpdateCoupon(coupon);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Coupon"), coupon.ID);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
            }
            AdminBasePage.Alert(alertMessage, RequestHelper.RawUrl);
        }
示例#22
0
        public bool SendCouponToMemebers(int couponId, List <int> userIds)
        {
            int           num     = userIds.Count <int>();
            StringBuilder builder = new StringBuilder();

            builder.Append("Insert into Hishop_Coupon_MemberCoupons(CouponId,MemberId,ReceiveDate,[Status],CouponName,ConditionValue,BeginDate,EndDate,CouponValue) values ");
            CouponInfo couponDetails = this.GetCouponDetails(couponId);

            for (int i = 0; i < num; i++)
            {
                builder.AppendFormat("({0},{1},GETDATE(),0,'{2}',{3},'{4}','{5}',{6})", new object[] { couponId, userIds[i], couponDetails.CouponName, couponDetails.ConditionValue, couponDetails.BeginDate, couponDetails.EndDate, couponDetails.CouponValue });
                if (i != (num - 1))
                {
                    builder.Append(",");
                }
                else
                {
                    builder.Append(";");
                }
            }
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());
            int       num3             = this.database.ExecuteNonQuery(sqlStringCommand);

            if (num3 > 0)
            {
                sqlStringCommand = this.database.GetSqlStringCommand(string.Format("Update Hishop_Coupon_Coupons set ReceiveNum=ReceiveNum+{0} where CouponId={1}; ", num3, couponId));
                this.database.ExecuteNonQuery(sqlStringCommand);
                return(true);
            }
            return(false);
        }
示例#23
0
        /// <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);

            BrnShop.Core.BSPCache.Insert(CacheKeys.SHOP_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.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);
        }
示例#24
0
        public ActionResult Add()
        {
            CouponInfo model     = new CouponInfo();
            long       shopId    = CurrentSellerManager.ShopId;
            var        couponser = _iCouponService;

            model             = new CouponInfo();
            model.StartTime   = DateTime.Now;
            model.EndTime     = model.StartTime.AddMonths(1);
            model.ReceiveType = CouponInfo.CouponReceiveType.ShopIndex;

            model.CanVshopIndex = CurrentSellerManager.VShopId > 0;
            model.Himall_CouponSetting.Clear();
            if (model.CanVshopIndex)
            {
                model.Himall_CouponSetting.Add(new CouponSettingInfo()
                {
                    Display = 1, PlatForm = Himall.Core.PlatformType.Wap
                });
            }
            model.Himall_CouponSetting.Add(new CouponSettingInfo()
            {
                Display = 1, PlatForm = Himall.Core.PlatformType.PC
            });
            model.FormIsSyncWeiXin       = false;
            model.ShopId                 = shopId;
            ViewBag.EndTime              = _iMarketService.GetMarketService(CurrentSellerManager.ShopId, MarketType.Coupon).MarketServiceRecordInfo.Max(item => item.EndTime).ToString("yyyy-MM-dd");
            ViewBag.CanAddIntegralCoupon = couponser.CanAddIntegralCoupon(shopId);
            return(View(model));
        }
        protected void dlCouponList_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            CouponInfo couponItem = e.Item.DataItem as CouponInfo;

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                ITextControl lblTitle        = e.Item.FindControl("lblTitle") as ITextControl;
                ITextControl lblStatus       = e.Item.FindControl("lblStatus") as ITextControl;
                ITextControl lblDiscount     = e.Item.FindControl("lblDiscount") as ITextControl;
                ITextControl lblDiscountType = e.Item.FindControl("lblDiscountType") as ITextControl;
                ITextControl lblTotalAmount  = e.Item.FindControl("lblTotalAmount") as ITextControl;
                LinkButton   lbRemove        = e.Item.FindControl("lbRemove") as LinkButton;
                HyperLink    hlEditLink      = e.Item.FindControl("hlEditLink") as HyperLink;
                lblTitle.Text = couponItem.Title;

                lblTotalAmount.Text = String.Format("{0:C}", couponItem.TotalAmount);
                lblStatus.Text      = couponItem.Active ? "Active" : "Inactive";
                if ((int)couponItem.DiscountType == 1)
                {
                    lblDiscountType.Text = "%";
                    lblDiscount.Text     = String.Format("{0:0.##}%", Math.Round(couponItem.Discount, 2));
                }
                else
                {
                    lblDiscountType.Text = "$";
                    lblDiscount.Text     = String.Format("{0:C}", couponItem.Discount);
                }
                hlEditLink.NavigateUrl = "CouponItem.aspx?cId=" + couponItem.CouponId;
            }
        }
示例#26
0
        public bool Add(CouponInfo couponInfo)
        {
            couponInfo.CouponId = GetNextId();
            Parameters cmdParams = GetParameters(couponInfo);

            return(DBHelper.ExecuteSql("INSERT INTO PE_Coupon (CouponID, CouponName, CouponNumPattern, Money, State, UserGroup, BeginDate, EndDate, LimitNum, ProductLimitType, ProductLimitContent, CouponCreateType, CouponCreateContent, OrderTotalMoney, UseEndDate) VALUES (@CouponID, @CouponName, @CouponNumPattern, @Money, @State, @UserGroup, @BeginDate, @EndDate, @LimitNum, @ProductLimitType, @ProductLimitContent, @CouponCreateType, @CouponCreateContent, @OrderTotalMoney, @UseEndDate)", cmdParams));
        }
示例#27
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     if (!int.TryParse(this.Page.Request.QueryString["couponId"], out this.couponId))
     {
         base.GotoResourceNotFound();
         return;
     }
     this.btnEditCoupons.Click += new System.EventHandler(this.btnEditCoupons_Click);
     if (!this.Page.IsPostBack)
     {
         CouponInfo coupon = CouponHelper.GetCoupon(this.couponId);
         if (coupon == null)
         {
             base.GotoResourceNotFound();
             return;
         }
         if (coupon.ClosingTime.CompareTo(System.DateTime.Now) < 0)
         {
             this.ShowMsg("该优惠券已经结束!", false);
             return;
         }
         Globals.EntityCoding(coupon, false);
         this.lblEditCouponId.Text = coupon.CouponId.ToString();
         this.txtCouponName.Text   = coupon.Name;
         if (coupon.Amount.HasValue)
         {
             this.txtAmount.Text = string.Format("{0:F2}", coupon.Amount);
         }
         this.txtDiscountValue.Text          = coupon.DiscountValue.ToString("F2");
         this.calendarEndDate.SelectedDate   = new System.DateTime?(coupon.ClosingTime);
         this.calendarStartDate.SelectedDate = new System.DateTime?(coupon.StartTime);
         this.txtNeedPoint.Text = coupon.NeedPoint.ToString();
     }
 }
示例#28
0
        private void GetCouponInfo(System.Web.HttpContext context)
        {
            context.Response.ContentType = "application/json";
            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder("{");
            int couponId = 0;

            if (!int.TryParse(context.Request["id"], out couponId))
            {
                stringBuilder.Append("\"Status\":\"0\"}");
                context.Response.Write(stringBuilder.ToString());
            }
            CouponInfo coupon = CouponHelper.GetCoupon(couponId);

            if (coupon == null)
            {
                stringBuilder.Append("\"Status\":\"1\"}");
                context.Response.Write(stringBuilder.ToString());
                return;
            }
            var value = new
            {
                Status    = 2,
                Count     = coupon.StockNum - coupon.ReceiveNum,
                BeginTime = coupon.BeginDate,
                EndTime   = coupon.EndDate
            };
            IsoDateTimeConverter isoDateTimeConverter = new IsoDateTimeConverter();

            isoDateTimeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            context.Response.Write(JsonConvert.SerializeObject(value, Formatting.Indented, new JsonConverter[]
            {
                isoDateTimeConverter
            }));
        }
示例#29
0
        public void SaveCover(CouponInfo model)
        {
            string integralCover = model.IntegralCover;

            if (!string.IsNullOrWhiteSpace(integralCover) && integralCover.IndexOf("temp", StringComparison.InvariantCultureIgnoreCase) > -1)
            {
                string mapPath = IOHelper.GetMapPath(model.IntegralCover);
                if (!File.Exists(mapPath))
                {
                    model.IntegralCover = "";
                }
                else
                {
                    FileInfo fileInfo = new FileInfo(mapPath);
                    string   str      = string.Format("/Storage/Shop/{0}/Coupon/", model.ShopId);
                    string   mapPath1 = IOHelper.GetMapPath(str);
                    long     id       = model.Id;
                    string   str1     = string.Concat(id.ToString(), fileInfo.Extension);
                    Directory.CreateDirectory(mapPath1);
                    IOHelper.CopyFile(mapPath, mapPath1, true, str1);
                    str = Path.Combine(str, str1);
                    model.IntegralCover = str;
                }
                context.SaveChanges();
            }
        }
示例#30
0
文件: FrmCoupon.cs 项目: yyan/winform
        /// <summary>
        /// 查询数据操作
        /// </summary>
        private void btnSearch_Click(object sender, EventArgs e)
        {
            couponInfo = null;

            if (this.txtID.Text.Length == 0)
            {
                MessageDxUtil.ShowTips("请输入兑换码");
                this.txtID.Focus();
                return;
            }
            else if (this.txtFullName.Text.Length == 0)
            {
                MessageDxUtil.ShowTips("请输入联系人");
                this.txtFullName.Focus();
                return;
            }
            else if (this.txtMobilePhone.Text.Length == 0)
            {
                MessageDxUtil.ShowTips("请输入联系方式");
                this.txtMobilePhone.Focus();
                return;
            }

            BindData();

            CheckCoupon();
        }