コード例 #1
0
        /// <summary>
        /// 添加结算记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AddSettLog(SettlementLogModel model)
        {
            const string sql = "insert into coupon_settlement (innerid, shopid, orderid, setttime, setttotal, settcyclestart, settcycleend, settserialnum, settaccount,pictures) values (@innerid, @shopid, @orderid, @setttime, @setttotal, @settcyclestart, @settcycleend, @settserialnum, @settaccount,@pictures);";
            const string sqlRecord = @"insert into coupon_settcoderecord (innerid,shopid,cardid, settid, `code`, createdtime, creater)

                                        select uuid(), @shopid, cardid, @settid,`code`, @nowtime, ''
                                        from coupon_code where isused = 1 and usedtime > @starttime and usedtime < @endtime
                                        and cardid in (select innerid from coupon_card where shopid = @shopid)
                                        and `code` not in (select `code` from coupon_settcoderecord where shopid = @shopid); ";

            using (var conn = Helper.GetConnection())
            {
                var tran = conn.BeginTransaction();
                try
                {
                    conn.Execute(sql, model, tran);
                    conn.Execute(sqlRecord, new
                    {
                        shopid = model.Shopid,
                        settid = model.Innerid,
                        nowtime = DateTime.Now,
                        starttime = model.SettCycleStart?.ToString("yyyy-MM-dd 00:00:00"),
                        endtime = model.SettCycleEnd?.ToString("yyyy-MM-dd 23:59:59")
                    }, tran);
                    tran.Commit();
                    return 1;
                }
                catch (Exception ex)
                {
                    LoggerFactories.CreateLogger().Write("add结算记录异常:", TraceEventType.Error, ex);
                    tran.Rollback();
                    return 0;
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// 修改结算记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int UpdateSettLog(SettlementLogModel model)
 {
     var sqlStr = new StringBuilder("update coupon_settlement 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)
         {
             LoggerFactories.CreateLogger().Write("更新结算记录异常:", TraceEventType.Error, ex);
             tran.Rollback();
             return 0;
         }
     }
 }