Ejemplo n.º 1
0
 /// <summary>
 /// 添加礼券
 /// </summary>
 /// <param name="model">礼券信息</param>
 /// <returns></returns>
 public int AddCoupon(CouponInfoModel model)
 {
     const string sql = @"INSERT INTO coupon_card
                         (innerid,shopid, title, titlesub, amount,buyprice, costprice, logourl, vtype, vstart, vend, value1, value2, maxcount, count,cardtype, codetype,needpoint,usedesc, createdtime, modifiedtime, isenabled)
                         VALUES
                         (@innerid,@shopid,@title,@titlesub,@amount,@buyprice, @costprice,@logourl,@vtype,@vstart,@vend,@value1,@value2,@maxcount,@count,@cardtype,@codetype,@needpoint,@usedesc,@createdtime,@modifiedtime,@isenabled);";
     using (var conn = Helper.GetConnection())
     {
         var tran = conn.BeginTransaction();
         try
         {
             conn.Execute(sql, model, tran);
             tran.Commit();
             return 1;
         }
         catch (Exception ex)
         {
             tran.Rollback();
             return 0;
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 修改礼券库存
 /// </summary>
 /// <param name="model">礼券信息</param>
 /// <returns></returns>
 public int UpdateStock(CouponInfoModel model)
 {
     const string sql =
         "update coupon_card set maxcount=maxcount+@count,count=count+@count where innerid=@innerid";
     using (var conn = Helper.GetConnection())
     {
         var tran = conn.BeginTransaction();
         try
         {
             conn.Execute(sql, new { innerid = model.Innerid, count = model.Count }, tran);
             tran.Commit();
             return 1;
         }
         catch (Exception ex)
         {
             tran.Rollback();
             return 0;
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 修改礼券有效期
 /// </summary>
 /// <param name="model">礼券信息</param>
 /// <returns></returns>
 public int UpdateValidity(CouponInfoModel model)
 {
     try
     {
         if (model.Vtype == 1)
         {
             const string sql = "update coupon_card set vstart=@vstart,vend=@vend where innerid=@innerid";
             Helper.Execute(sql, new
             {
                 innerid = model.Innerid,
                 vstart = model.Vstart,
                 vend = model.Vend
             });
         }
         else
         {
             const string sql = "update coupon_card set value1=@value1,value2=@value2 where innerid=@innerid";
             Helper.Execute(sql, new
             {
                 innerid = model.Innerid,
                 value1 = model.Value1,
                 value2 = model.Value2
             });
         }
         return 1;
     }
     catch (Exception ex)
     {
         return 0;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 修改礼券
 /// </summary>
 /// <param name="model">礼券信息</param>
 /// <returns></returns>
 public int UpdateCoupon(CouponInfoModel model)
 {
     //var sql = "update coupon_card set title=@title,titlesub=@titlesub,amount=@amount,logourl=@logourl, where innerid = @innerid";
     var sqlStr = new StringBuilder("update coupon_card set ");
     sqlStr.Append(Helper.CreateField(model).Trim().TrimEnd(','));
     sqlStr.Append(" where innerid = @innerid");
     using (var conn = Helper.GetConnection())
     {
         var tran = conn.BeginTransaction();
         try
         {
             conn.Execute(sqlStr.ToString(), model, tran);
             tran.Commit();
             return 1;
         }
         catch (Exception ex)
         {
             tran.Rollback();
             return 0;
         }
     }
 }