|
|
|
|
|
|
|
|
|
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<EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>3<EFBFBD>գ<EFBFBD>С<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>10Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֳ<EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>ѻ<EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
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<EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>3<EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>100<EFBFBD>Ŀ<EFBFBD>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<EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>3<EFBFBD>գ<EFBFBD>С<EFBFBD><EFBFBD>100<EFBFBD>Ŀ<EFBFBD>10;'
|
|
|
|
|
FROM TMemberCard_100 AS A
|