public void UpdateStatus(ECouponStatus status, List <int> snIdList) { string sqlString = $"UPDATE {TableName} SET {CouponSnAttribute.Status} = '{ECouponStatusUtils.GetValue(status)}' WHERE ID IN ({TranslateUtils.ToSqlInStringWithoutQuote(snIdList)})"; if (status == ECouponStatus.Cash) { sqlString = $"UPDATE {TableName} SET {CouponSnAttribute.Status} = '{ECouponStatusUtils.GetValue(status)}', {CouponSnAttribute.HoldDate} = getdate(), {CouponSnAttribute.CashDate} = getdate() WHERE ID IN ({TranslateUtils.ToSqlInStringWithoutQuote(snIdList)})"; } else if (status == ECouponStatus.Hold) { sqlString = $"UPDATE {TableName} SET {CouponSnAttribute.Status} = '{ECouponStatusUtils.GetValue(status)}', {CouponSnAttribute.HoldDate} = getdate() WHERE ID IN ({TranslateUtils.ToSqlInStringWithoutQuote(snIdList)})"; } ExecuteNonQuery(sqlString); }
public static int AddApplication(int publishmentSystemID, int actID, string uniqueID, string realName, string mobile, string email, string address) { try { var couponInfoList = DataProviderWX.CouponDAO.GetCouponInfoList(publishmentSystemID, actID); var snID = 0; var couponID = 0; var cookieSN = WeiXinManager.GetCookieSN(); snID = DataProviderWX.CouponSNDAO.Hold(publishmentSystemID, actID, cookieSN); var newCouponSNInfo = DataProviderWX.CouponSNDAO.GetSNInfo(snID); couponID = newCouponSNInfo.CouponID; var couponSNInfo = new CouponSNInfo(); couponSNInfo.PublishmentSystemID = publishmentSystemID; couponSNInfo.CookieSN = cookieSN; couponSNInfo.CouponID = couponID; couponSNInfo.ID = snID; couponSNInfo.HoldDate = DateTime.Now; couponSNInfo.HoldRealName = realName; couponSNInfo.HoldMobile = mobile; couponSNInfo.HoldEmail = email; couponSNInfo.HoldAddress = address; couponSNInfo.CashDate = DateTime.Now; couponSNInfo.Status = ECouponStatusUtils.GetValue(ECouponStatus.Hold); couponSNInfo.WXOpenID = uniqueID; if (newCouponSNInfo.Status == ECouponStatusUtils.GetValue(ECouponStatus.Cash)) { couponSNInfo.Status = ECouponStatusUtils.GetValue(ECouponStatus.Cash); } DataProviderWX.CouponSNDAO.Update(couponSNInfo); return(newCouponSNInfo.ID); } catch (Exception ex) { return(0); } }
public int Hold(int publishmentSystemId, int actId, string cookieSn) { var snId = 0; string sqlString = $@"SELECT ID FROM wx_CouponSN WHERE PublishmentSystemID = {publishmentSystemId} AND CookieSN = '{cookieSn}' AND Status <> '{ECouponStatusUtils.GetValue(ECouponStatus.Unused)}' AND CouponID IN (SELECT ID FROM wx_Coupon WHERE ActID = {actId})"; using (var rdr = ExecuteReader(sqlString)) { if (rdr.Read()) { snId = rdr.GetInt32(0); } rdr.Close(); } if (snId == 0) { sqlString = $@"SELECT TOP 1 ID FROM wx_CouponSN WHERE PublishmentSystemID = {publishmentSystemId} AND Status = '{ECouponStatusUtils.GetValue(ECouponStatus.Unused)}' AND CouponID IN (SELECT ID FROM wx_Coupon WHERE ActID = {actId}) ORDER BY ID"; using (var rdr = ExecuteReader(sqlString)) { if (rdr.Read()) { snId = rdr.GetInt32(0); } rdr.Close(); } } return(snId); }
public void Insert(int publishmentSystemId, int couponId, List <string> snList) { foreach (var sn in snList) { if (!string.IsNullOrEmpty(sn)) { string sqlString = $"INSERT INTO {TableName} (PublishmentSystemID, CouponID, SN, Status) VALUES ({publishmentSystemId}, {couponId}, '{sn}', '{ECouponStatusUtils.GetValue(ECouponStatus.Unused)}')"; ExecuteNonQuery(sqlString); } } DataProviderWx.CouponDao.UpdateTotalNum(couponId, DataProviderWx.CouponSnDao.GetTotalNum(publishmentSystemId, couponId)); }
public void Insert(int publishmentSystemId, int couponId, int totalNum) { var couponSnList = CouponManager.GetCouponSN(totalNum); foreach (var sn in couponSnList) { string sqlString = $"INSERT INTO {TableName} (PublishmentSystemID, CouponID, SN, Status) VALUES ({publishmentSystemId}, {couponId}, '{sn}', '{ECouponStatusUtils.GetValue(ECouponStatus.Unused)}')"; ExecuteNonQuery(sqlString); } DataProviderWx.CouponDao.UpdateTotalNum(couponId, DataProviderWx.CouponSnDao.GetTotalNum(publishmentSystemId, couponId)); }
public int GetCashNum(int publishmentSystemId, int couponId) { string sqlString = $"SELECT COUNT(*) FROM {TableName} WHERE {CouponSnAttribute.PublishmentSystemId} = {publishmentSystemId} AND {CouponSnAttribute.CouponId} = {couponId} AND {CouponSnAttribute.Status} = '{ECouponStatusUtils.GetValue(ECouponStatus.Cash)}'"; return(BaiRongDataProvider.DatabaseDao.GetIntResult(sqlString)); }
public int GetHoldNum(int publishmentSystemID, int couponID) { string sqlString = $"SELECT COUNT(*) FROM {TABLE_NAME} WHERE {CouponSNAttribute.PublishmentSystemID} = {publishmentSystemID} AND {CouponSNAttribute.CouponID} = {couponID} AND ({CouponSNAttribute.Status} = '{ECouponStatusUtils.GetValue(ECouponStatus.Hold)}')"; return(BaiRongDataProvider.DatabaseDao.GetIntResult(sqlString)); }