You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.4 KiB
76 lines
2.4 KiB
|
|
USE QingDao_SouYa
|
|
|
|
SELECT * FROM TMemberCardAccount WHERE FCardId IN
|
|
(
|
|
SELECT FCardId FROM TMemberCard
|
|
WHERE FCreateDate <= '2015-05-03'
|
|
AND FDeleted = 0
|
|
)
|
|
AND FBalance < 10
|
|
|
|
AND FBalance > 10
|
|
|
|
|
|
|
|
SELECT * FROM TMemberCourse
|
|
|
|
SELECT DATEADD(MONTH,-4,'2016-05-03')
|
|
|
|
SELECT A.*,B.FBalance INTO TMemberCard_100
|
|
FROM TMemberCard AS A,TMemberCardAccount AS B
|
|
WHERE A.FCardId = B.FCardId
|
|
AND A.FCreateDate <= '2015-05-03'
|
|
AND B.FBalance <= 100
|
|
AND B.FBalance > 10
|
|
AND B.FAcctId = 3
|
|
|
|
SELECT A.*,B.FBalance INTO TMemberCard_200
|
|
FROM TMemberCard AS A,TMemberCardAccount AS B
|
|
WHERE A.FCardId = B.FCardId
|
|
AND A.FCreateDate <= '2015-05-03'
|
|
AND B.FBalance > 100
|
|
AND B.FAcctId = 3
|
|
|
|
|
|
SELECT A.*,B.FBalance INTO TMemberCard_0
|
|
FROM TMemberCard AS A,TMemberCardAccount AS B
|
|
WHERE A.FCardId = B.FCardId
|
|
AND A.FMemId NOT IN(SELECT FMemId FROM TMemberTransHist WHERE FTime > '2016-01-03' UNION ALL SELECT FMemId FROM TMemberOldTransHist WHERE FTime > '2016-01-03')
|
|
AND B.FBalance <= 10
|
|
AND B.FBalance > 0
|
|
AND B.FAcctId = 3
|
|
|
|
|
|
UPDATE A
|
|
SET A.FBalance = 0
|
|
FROM TMemberCardAccount AS A
|
|
WHERE A.FCardId IN(SELECT FCardId FROM TMemberCard_0)
|
|
|
|
|
|
INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
|
|
select dbo.FNNewId(),A.FMemId,A.FCardId,3,getdate(),A.FTypeId,A.FCompId,'QT','Manual',0,'',0,A.FBalance,0,0,getdate(),'2016年5月3日,小于等于10元;而又超过4个月没来的,把会员卡的余额都清空'
|
|
FROM TMemberCard_0 AS A
|
|
|
|
|
|
UPDATE A
|
|
SET A.FBalance = A.FBalance - 20
|
|
FROM TMemberCardAccount AS A
|
|
WHERE A.FCardId IN(SELECT FCardId FROM TMemberCard_200)
|
|
|
|
|
|
INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
|
|
select dbo.FNNewId(),A.FMemId,A.FCardId,3,getdate(),A.FTypeId,A.FCompId,'QT','Manual',0,'',0,20,0,0,getdate(),'2016年5月3日,大于100的扣20;'
|
|
FROM TMemberCard_200 AS A
|
|
|
|
|
|
|
|
UPDATE A
|
|
SET A.FBalance = A.FBalance - 10
|
|
FROM TMemberCardAccount AS A
|
|
WHERE A.FCardId IN(SELECT FCardId FROM TMemberCard_100)
|
|
|
|
|
|
INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
|
|
select dbo.FNNewId(),A.FMemId,A.FCardId,3,getdate(),A.FTypeId,A.FCompId,'QT','Manual',0,'',0,10,0,0,getdate(),'2016年5月3日,小于100的扣10;'
|
|
FROM TMemberCard_100 AS A
|
|
|