|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TBKMember# WHERE FMemNo = '259079'
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMember WHERE FMemNo = '259079'
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMember
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberCard WHERE FMemId = 5584532119645354115
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberCourse WHERE FMemId = 5584532119645354115
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TBKAccount# WHERE FMemId = 7247041615073293144
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImportConfig#
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TUser
|
|
|
|
|
|
|
|
|
|
SELECT * FROM db108.s3_qd_8BAOBEIMENG6ky.dbo.gcm01 where FMemId = 7247041615073293144
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberOldTransHist WHERE FMemId = 7247041615073293144
|
|
|
|
|
|
|
|
|
|
DECLARE @NewMemId BIGINT
|
|
|
|
|
DECLARE @OldMemId BIGINT
|
|
|
|
|
|
|
|
|
|
SELECT @NewMemId = 5584532119645354115
|
|
|
|
|
SELECT @OldMemId = 7247041615073293144
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = @NewMemId
|
|
|
|
|
FROM TBKMember# AS A
|
|
|
|
|
WHERE A.FMemId = @OldMemId
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = @NewMemId
|
|
|
|
|
FROM TBKAccount# AS A
|
|
|
|
|
WHERE A.FMemId = @OldMemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = @NewMemId
|
|
|
|
|
FROM db108.s3_qd_8BAOBEIMENG6ky.dbo.gcm01 AS A
|
|
|
|
|
WHERE A.FMemID = @OldMemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = @NewMemId
|
|
|
|
|
FROM db108.s3_qd_8BAOBEIMENG6ky.dbo.gcm03 AS A
|
|
|
|
|
WHERE A.FMemID = @OldMemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = @NewMemId
|
|
|
|
|
FROM db108.s3_qd_8BAOBEIMENG6ky.dbo.gcm04 AS A
|
|
|
|
|
WHERE A.FMemID = @OldMemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = @NewMemId
|
|
|
|
|
FROM db108.s3_qd_8BAOBEIMENG6ky.dbo.gcm06 AS A
|
|
|
|
|
WHERE A.FMemID = @OldMemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = @NewMemId
|
|
|
|
|
FROM db108.s3_qd_8BAOBEIMENG6ky.dbo.gcm20 AS A
|
|
|
|
|
WHERE A.FMemID = @OldMemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberCard(FCardId,FCardNo,FCardFaceNo,FTypeId,FValueType,FCompId,FMemId,FState,FCreateDate,FExpiredDate,FTotalTimes,FUsedTimes,FSaleCompId,FSaleBillId,FMemo)
|
|
|
|
|
SELECT FCardId,FCardNo,FCardNo AS FFaceNo,FTypeId,ISNULL(FValueType,0),FCompId,FMemId,FState,FCreateDate,FExpiredDate,FTotalTimes,FUsedTimes,FCompId AS FSaleCompId,0 AS FSaleBillId,FMemo
|
|
|
|
|
FROM TBKMember#
|
|
|
|
|
WHERE FMemId = 5584532119645354115
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberCardType WHERE FNo = '124'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXEC PExecImportSQL '
|
|
|
|
|
SELECT dbo.FNBKID(upper(gak01c)) AS FId , --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ISNULL(gak01c,'''') AS FNo, --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ISNULL(gak02c,'''') AS FName, --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ISNULL(gak03i,'''') AS FValueType , --<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(1-<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>, 2- <EFBFBD>ʸ<EFBFBD><EFBFBD><EFBFBD>,3-<EFBFBD>ƴο<EFBFBD>,4-<EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD>)
|
|
|
|
|
ISNULL(gak07f,'''') AS FValidityPeriod, --<EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ISNULL(gak08c,0) AS FValidityPeriodUnit , --<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|
|
|
|
ISNULL(gak09f,'''') AS FPrice, --<EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD>
|
|
|
|
|
ISNULL((SELECT TOP 1 FId FROM TPayAccount WHERE FBKAcctId = gak14i),0) AS FAcctId , --Ĭ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ISNULL(gak16f,'''') AS FDeposit, --<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,Added by WUXM, 2004/02/16
|
|
|
|
|
ISNULL(gak06i,'''') AS FTimes,
|
|
|
|
|
CASE gak29i WHEN 1 THEN 1
|
|
|
|
|
WHEN 0 THEN 2
|
|
|
|
|
WHEN 3 THEN 3
|
|
|
|
|
ELSE 0 END AS FMaterial, --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0<EFBFBD>ſ<EFBFBD> 1IC<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2 <EFBFBD><EFBFBD><EFBFBD>Ӵſ<EFBFBD> 3 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>IC<EFBFBD><EFBFBD>
|
|
|
|
|
ISNULL((SELECT TOP 1 FId FROM TPayAccount WHERE FBKAcctId = gak35i),0) AS FAcctId2 , --<EFBFBD>ڶ<EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ISNULL(gak36f,'''') AS FDeposit2 , --<EFBFBD>ڶ<EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ISNULL((SELECT TOP 1 FId FROM TPayAccount WHERE FBKAcctId = gak37i),0) AS FAcctId3 , --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ISNULL(gak38f,'''') AS FDeposit3 , --<EFBFBD>ڶ<EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CASE WHEN gak41i = 1 THEN 0 ELSE 1 END AS FAllowSale, --ֹͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1ֹͣ
|
|
|
|
|
CASE WHEN gak42i = 1 THEN 0 ELSE 1 END AS FAllowRchg, --ֹͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1ֹͣ
|
|
|
|
|
ISNULL(gak43f,'''') AS FAlertBalance, --<EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> Add by maql 2010/03/24
|
|
|
|
|
ISNULL(gak40f,'''') AS FMinRchgAmt,
|
|
|
|
|
dbo.FNBKPointMode(gak30i) AS FSalePointMode,
|
|
|
|
|
dbo.FNBKPointMode(gak30i) AS FRchgPointMode,
|
|
|
|
|
ISNULL(CASE WHEN ISNULL(gak30i,0) NOT IN(0,1) THEN ISNULL(gak31i,0) / 100 ELSE gak31i END,0) AS FSalePointValue,
|
|
|
|
|
ISNULL(CASE WHEN ISNULL(gak30i,0) NOT IN(0,1) THEN ISNULL(gak31i,0) / 100 ELSE gak31i END,0) AS FRchgPointValue,
|
|
|
|
|
ISNULL(gak22f,0) AS FItemTurnoverRate ,
|
|
|
|
|
ISNULL(gak24f,0) AS FGoodsTurnoverRate,
|
|
|
|
|
ISNULL(gak33f,0) AS FItemPointRate,
|
|
|
|
|
ISNULL(gak34f,0) AS FGoodsPointRate
|
|
|
|
|
INTO #CardType
|
|
|
|
|
FROM {FDB}.gam10
|
|
|
|
|
WHERE gak00c = ''001''
|
|
|
|
|
AND gak01c = ''124''
|
|
|
|
|
|
|
|
|
|
INSERT {TDB}.TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FValidityPeriod,FValidityPeriodUnit,FAllowSale,FAllowRchg,FEnabled,FOrder,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue)
|
|
|
|
|
SELECT FId,FNo,FName,FValueType,FMaterial,FPrice,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FValidityPeriod,FValidityPeriodUnit,FAllowSale,FAllowRchg,1,1,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue
|
|
|
|
|
FROM #CardType '
|
|
|
|
|
|
|
|
|
|
-- SELECT * FROM TPayAccount ORDER BY FBKAcctId
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMem
|
|
|
|
|
--д<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>
|
|
|
|
|
EXEC PExecImportSQL '
|
|
|
|
|
INSERT INTO {TDB}.TMemberCardAccount(FId,FMemId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
|
|
|
|
|
SELECT dbo.FNNewId(),FMemId,FCardId,FAcctId,FBalance,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo
|
|
|
|
|
FROM TBKAccount#
|
|
|
|
|
WHERE FBKAcctId NOT IN(3,4,888,999,889)
|
|
|
|
|
--TODO
|
|
|
|
|
AND FCardId IN(SELECT FCardId FROM TBKMember#)
|
|
|
|
|
AND FMemId = 5584532119645354115'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--delete Temp_Account_# WHERE FCardId = 7583214202515789572
|
|
|
|
|
--SELECT * FROM Temp_Account_# WHERE FAcctId IS NULL AND FCardId = 7714057480398863723
|
|
|
|
|
|
|
|
|
|
--д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
EXEC PExecImportSQL '
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FPoint = B.FBalance
|
|
|
|
|
FROM {TDB}.TMember AS A,TBKAccount# AS B
|
|
|
|
|
WHERE A.FMemId = B.FMemId
|
|
|
|
|
AND B.FBKAcctId = 3 ' --<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ
|
|
|
|
|
EXEC PExecImportSQL '
|
|
|
|
|
DELETE {TDB}.TMemberPointHist WHERE FBillType = ''DR''
|
|
|
|
|
INSERT {TDB}.TMemberPointHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FMemo,FRecordTime)
|
|
|
|
|
SELECT dbo.FNNewId(),A.FMemId,getdate(),0,1,''DR'',''Import'',0,'''',FPoint,0,FPoint,'''',getdate()
|
|
|
|
|
FROM {TDB}.TMember AS A WHERE FPoint != 0 '
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>˻<EFBFBD>Ƿ<EFBFBD><EFBFBD>
|
|
|
|
|
EXEC PExecImportSQL '
|
|
|
|
|
INSERT {TDB}.TMemberArrear(FId,FMemId,FTime,FCompId,FContentType,FCardId,FBillType,FBizType,FTransId,FTransNo,FTransDetailId,FContentId,FArrear,FEmpId,FRepaid,FAcctArrear)
|
|
|
|
|
SELECT dbo.FNNewId(),A.FMemId,getdate(),A.FCompId,''Account'',A.FCardId,''DR_KK'',''DR_CardSale'',0,'''',0,A.FAcctId,A.FArrear,0,0,A.FArrear
|
|
|
|
|
FROM TBKAccount# AS A
|
|
|
|
|
WHERE A.FArrear > 0
|
|
|
|
|
AND A.FAcctId IS NOT NULL
|
|
|
|
|
AND FBKAcctId NOT IN(3,4,888,999,889)
|
|
|
|
|
AND A.FMemId = 5584532119645354115
|
|
|
|
|
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
|
|
|
|
|
EXEC PExecImportSQL '
|
|
|
|
|
INSERT INTO {TDB}.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,A.FAcctId,getdate(),A.FCardTypeId,A.FCompId,''DR'',''Import'',0,'''',A.FBalance,0,A.FBalance,A.FArrear,getdate(),''''
|
|
|
|
|
FROM TBKAccount# AS A
|
|
|
|
|
WHERE (A.FBalance > 0 OR A.FArrear > 0)
|
|
|
|
|
AND FBKAcctId NOT IN(3,888,999,889)
|
|
|
|
|
AND FMemId = 5584532119645354115
|
|
|
|
|
-- AND A.FAcctId NOT NULL'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>Ƴ<EFBFBD>
|
|
|
|
|
EXEC PExecImportSQL '
|
|
|
|
|
SELECT FId AS FId,
|
|
|
|
|
gca01c AS FMemNo,
|
|
|
|
|
dbo.FNBkCompId(gcf00c) AS FCompId,
|
|
|
|
|
M.FMemId AS FMemId,
|
|
|
|
|
FItemId AS FItemId,
|
|
|
|
|
FCourseId AS FCourseId,
|
|
|
|
|
0 AS FPackId,
|
|
|
|
|
0 AS FMemPackId,
|
|
|
|
|
(SELECT TOP 1 FId FROM {TDB}.TBasicType WHERE FKey=''CourseType'') AS FTypeId,
|
|
|
|
|
CASE WHEN ISNULL(gcf07f,0) > ISNULL(gcf05f,0) THEN ISNULL(gcf07f,0) ELSE ISNULL(gcf05f,0) END AS FPurTimes,
|
|
|
|
|
CASE WHEN ISNULL(gcf07f,0) > ISNULL(gcf05f,0) THEN 0 ELSE ISNULL(gcf05f,0) - ISNULL(gcf07f,0) END AS FUsedPurTimes,
|
|
|
|
|
-- CASE WHEN ISNULL(gcf10f,0) > ISNULL(gcf08f,0) THEN ISNULL(gcf10f,0) ELSE ISNULL(gcf08f,0) END AS FPurAmount,
|
|
|
|
|
CAST (0 AS DECIMAL(18,6)) AS FPurAmount,
|
|
|
|
|
gcf10f,
|
|
|
|
|
ISNULL(dbo.FNBKDate(gcf11d),getdate()) AS FPurchaseDate,
|
|
|
|
|
dbo.FNBKDate(gcf12d) AS FExpiredDate,
|
|
|
|
|
''DR.Import'' AS FBizType,
|
|
|
|
|
0 AS FTransId,
|
|
|
|
|
0 AS FArrear,
|
|
|
|
|
0 AS FDurable,
|
|
|
|
|
'''' AS FMemo,
|
|
|
|
|
CASE WHEN ISNULL(gcf22i,0) = 1 THEN 2 ELSE 1 END AS FCalcMode,
|
|
|
|
|
0 AS FFreeTimes,
|
|
|
|
|
0 AS FUsedFreeTimes,
|
|
|
|
|
CAST(0 AS DECIMAL(18,6)) AS FAdjustPrice
|
|
|
|
|
INTO TBKCourse#
|
|
|
|
|
FROM {FDB}.gcm06,{FDB}.gcm01, {TDB}.TBKMember# AS M
|
|
|
|
|
WHERE gcf00c = gca00c
|
|
|
|
|
AND gca00c = gca13d
|
|
|
|
|
AND gca01c = gcf01c
|
|
|
|
|
AND gca01c = M.FCardNo
|
|
|
|
|
AND gcf02c != ''''
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>Ƴ̽<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TBKCourse#
|
|
|
|
|
SET FPurAmount = FPurTimes * (ISNULL(gcf10f,0) / (FPurTimes - FUsedPurTimes))
|
|
|
|
|
WHERE FPurTimes - FUsedPurTimes > 0
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>㵥<EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TBKCourse#
|
|
|
|
|
SET FAdjustPrice = FPurAmount / FPurTimes
|
|
|
|
|
WHERE FPurTimes != 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--select * from #Course WHERE FCourseId NOT IN (SELECT FId FROM {TDB}.TCourse)
|
|
|
|
|
INSERT {TDB}.TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FUsedPurTimes, FPurAmount,FFreeTimes,FUsedFreeTimes,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
|
|
|
|
|
SELECT FId,FMemId,ISNULL(FCourseId,0),FMemPackId,ISNULL(FItemId,0),FCompId,FPurTimes,FUsedPurTimes, FPurAmount,FFreeTimes,FUsedFreeTimes,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice
|
|
|
|
|
FROM TBKCourse# '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXEC PExecImportSQL '
|
|
|
|
|
INSERT INTO {TDB}.TMemberCourseHist(FId,FMemId,FMemCourseId,FPackId,FCourseId,FTime,FPurTimes,FFreeTimes,FUsePurTimes,FUseFreeTimes,FPurAmount,FFreeAmount,FUsePurAmount,FUseFreeAmount,FCompId,FBillType,FBizType,FTransId,FTransNo,FTransDetailId,FRecordTime)
|
|
|
|
|
SELECT dbo.FNNewId(),FMemId,A.FId AS FMemCourseId,0, ISNULL(FCourseId,0),getdate(),FPurTimes,FFreeTimes,0,0,FPurAmount,FFreeAmount,0,0,FCompId,''DR'',''Import'',0,'''',0,getdate()
|
|
|
|
|
FROM {TDB}.TMemberCourse AS A '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƷǷ<EFBFBD><EFBFBD>
|
|
|
|
|
EXEC PExecImportSQL '
|
|
|
|
|
INSERT {TDB}.TMemberArrear(FId,FMemId,FTime,FCompId,FContentType,FCardId,FBillType,FBizType,FTransId,FTransNo,FTransDetailId,FContentId,FArrear,FEmpId,FRepaid)
|
|
|
|
|
SELECT dbo.FNNewId(),A.FMemId,getdate(),A.FCompId,''DR_ItemGoods'',A.FCardId,''DR_XF'',''DR_Consume'',0,'''',0,0,A.FArrear,0,0
|
|
|
|
|
FROM TBKAccount# AS A
|
|
|
|
|
WHERE A.FArrear > 0
|
|
|
|
|
AND A.FBKAcctId = 888'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>Ƴ<EFBFBD>Ƿ<EFBFBD><EFBFBD>
|
|
|
|
|
EXEC PExecImportSQL '
|
|
|
|
|
INSERT {TDB}.TMemberArrear(FId,FMemId,FTime,FCompId,FContentType,FCardId,FBillType,FBizType,FTransId,FTransNo,FTransDetailId,FContentId,FArrear,FEmpId,FRepaid,FAcctArrear)
|
|
|
|
|
SELECT dbo.FNNewId(),A.FMemId,getdate(),A.FCompId,''DR_Course'',0,''DR_KK'',''DR_CardSale'',0,'''',0,A.FAcctId,A.FArrear,0,0,0
|
|
|
|
|
FROM TBKAccount# AS A
|
|
|
|
|
WHERE A.FArrear > 0
|
|
|
|
|
AND A.FAcctId IS NOT NULL
|
|
|
|
|
AND FBKAcctId IN(4) '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- EXEC PExecImportSQL ' SELECT * FROM {FDB}.gcm04 WHERE NOT EXISTS(SELECT 1 FROM {TDB}.TPayAccount WHERE FBKAcctId = gcd02i) '
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ϵͳ<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
|
|
|
|
|
EXEC PExecImportSQL '
|
|
|
|
|
SELECT dbo.FNNewId() AS FId,
|
|
|
|
|
C.FCardId AS FCardId,
|
|
|
|
|
C.FMemId AS FMemId,
|
|
|
|
|
C.FTypeId AS FCardTypeId,
|
|
|
|
|
dbo.FNBKCompId(gcd00c) AS FCompId,
|
|
|
|
|
(SELECT FId FROM TPayAccount WHERE FBKAcctId = gcd02i) AS FAcctId,
|
|
|
|
|
dbo.FNBKAcctOper(gcd05i) AS FBizType,
|
|
|
|
|
'''' AS FBillType,
|
|
|
|
|
0 AS FTransId,
|
|
|
|
|
gcd08c AS FTransNo,
|
|
|
|
|
gcd05i ,
|
|
|
|
|
gcd06f,gcd10f,
|
|
|
|
|
CASE WHEN gcd05i IN(0,6) THEN ISNULL(gcd06f,0) ELSE 0 END AS FInAmount,
|
|
|
|
|
CASE WHEN gcd05i NOT IN(0,6) THEN ISNULL(gcd06f,0) ELSE 0 END AS FOutAmount,
|
|
|
|
|
CASE WHEN gcd05i IN(0,6) THEN ISNULL(gcd06f,0) + ISNULL(gcd10f,0) ELSE ISNULL(gcd10f,0) - ISNULL(gcd06f,0) END AS FBalance,
|
|
|
|
|
dbo.FNBKTime(gcd09d,gcd13t) AS FTime,
|
|
|
|
|
ISNULL(dbo.FNBKTime(gcd11c,gcd13t),''1753-01-01'') AS FRecordTime,
|
|
|
|
|
'''' AS FMemo,
|
|
|
|
|
0 AS FArrear
|
|
|
|
|
|
|
|
|
|
INTO #AcctHist
|
|
|
|
|
FROM {FDB}.gcm04 AS A, {TDB}.TBKMember# AS C
|
|
|
|
|
WHERE A.gcd01c = C.FCardNo
|
|
|
|
|
AND A.gcd02i NOT IN(4,888,999,889)
|
|
|
|
|
AND C.FMemId = 5584532119645354115
|
|
|
|
|
|
|
|
|
|
INSERT INTO {TDB}.TMemberCardOldAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBizType,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
|
|
|
|
|
SELECT FId,FMemId,FCardId,FAcctId,ISNULL(FTime,''1753-01-01''),FCardTypeId,FCompId,FBizType,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo
|
|
|
|
|
FROM #AcctHist'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
|
|
|
|
|
/*SELECT * FROM s3_qd_NISIKA8HyvUt6pYGo..gcm04
|
|
|
|
|
SELECT C.FId AS FCardId,
|
|
|
|
|
C.FMemId AS FMemId,*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
----<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ
|
|
|
|
|
--select * from TMemberOldTransHist
|
|
|
|
|
--SELECT * FROM s3_qd_NISIKA8HyvUt6pYGo..gcm20
|
|
|
|
|
|
|
|
|
|
EXEC PExecImportSQL '
|
|
|
|
|
SELECT C.FCardId AS FCardId,
|
|
|
|
|
C.FMemId AS FMemId,
|
|
|
|
|
dbo.FNBKTime(gct04d,gct19t) AS FTime,
|
|
|
|
|
dbo.FNBKCompId(gct00c) AS FCompId,
|
|
|
|
|
CASE WHEN gct13c IN (''gn'',''gz'') THEN ''DR.KK'' WHEN gct13c =''gx'' THEN ''DR.XF'' ELSE ''DR'' END AS FBillType,
|
|
|
|
|
dbo.FNBKTransBizType(gct06c) AS FBizType,
|
|
|
|
|
gct14c AS FTransNo,
|
|
|
|
|
isnull(gct07c,'''') + isnull(gct08c,'''') AS FContent,
|
|
|
|
|
isnull(gct10f,0) AS FPrice, --<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
isnull(gct11f,0) AS FQuantity, --<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
isnull( gct12f,0) AS FAmount, --<EFBFBD>۸<EFBFBD>
|
|
|
|
|
CASE WHEN ISNULL(gct20c,'''') != '''' THEN (SELECT FName FROM {TDB}.TPayAccount WHERE FBKPayNo=gct20c) ELSE '''' END AS FPayment,
|
|
|
|
|
CASE WHEN ISNULL(gct15c,'''') != '''' THEN ISNULL(gct15c,'''') + ''-'' + ISNULL((SELECT TOP 1 haa02c FROM {FDB}.ham01 WHERE haa00c = gct00c AND haa01c = gct15c),'''') + '','' ELSE '','' END
|
|
|
|
|
+CASE WHEN ISNULL(gct16c,'''') != '''' THEN ISNULL(gct16c,'''') + ''-'' + ISNULL((SELECT TOP 1 haa02c FROM {FDB}.ham01 WHERE haa00c = gct00c AND haa01c = gct16c),'''') + '','' ELSE '','' END
|
|
|
|
|
+CASE WHEN ISNULL(gct17c,'''') != '''' THEN ISNULL(gct17c,'''') + ''-'' + ISNULL((SELECT TOP 1 haa02c FROM {FDB}.ham01 WHERE haa00c = gct00c AND haa01c = gct17c),'''') + '','' ELSE '','' END
|
|
|
|
|
+CASE WHEN ISNULL(gct18c,'''') != '''' THEN ISNULL(gct18c,'''') + ''-'' + ISNULL((SELECT TOP 1 haa02c FROM {FDB}.ham01 WHERE haa00c = gct00c AND haa01c = gct18c),'''') + '','' ELSE '','' END
|
|
|
|
|
AS FEmployee
|
|
|
|
|
INTO #TransHist
|
|
|
|
|
FROM {FDB}.gcm20, {TDB}.TBKMember# AS C
|
|
|
|
|
WHERE C.FCardNo = gct02c
|
|
|
|
|
AND C.FMemId = 5584532119645354115
|
|
|
|
|
|
|
|
|
|
-- Truncate TABLE {TDB}.TMemberOldTransHist
|
|
|
|
|
|
|
|
|
|
INSERT {TDB}.TMemberOldTransHist(FId,FCompId,FMemId,FTime,FCardId,FBIllType,FBizType,FTransNo,FCOntent,FPrice,FQuantity,FAmount,FPayment,Femployee,FMemo)
|
|
|
|
|
SELECT dbo.FNNewId(),FCompId,FMemId,ISNULL(FTime,''1753-01-01''),FCardId,FBIllType,FBizType,FTransNo AS FTransNo,FCOntent,FPrice,FQuantity,FAmount,ISNULL(FPayment,''''),Femployee, '''' AS FMemo
|
|
|
|
|
FROM #TransHist'
|
|
|
|
|
|
|
|
|
|
--select * from TUser
|
|
|
|
|
|