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.
237 lines
7.6 KiB
237 lines
7.6 KiB
use TENGCHONG_FENGNIANG
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE TImpMemberCourse
|
|
|
|
SELECT * FROM TImpMemberCourse WHERE FMemNo
|
|
|
|
SELECT * FROM TItem WHERE FNo = '倒膜'
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FIsNew BIT
|
|
ALTER TABLE TImpMemberCourse ADD FId BIGINT
|
|
ALTER TABLE TImpMemberCourse ADD FMemId BIGINT
|
|
ALTER TABLE TImpMemberCourse ADD FCourseId BIGINT
|
|
ALTER TABLE TImpMemberCourse ADD FItemId BIGINT
|
|
ALTER TABLE TImpMemberCourse ADD FCompId BIGINT
|
|
ALTER TABLE TImpMemberCourse ADD FPurTimes DECIMAL(18,6)
|
|
ALTER TABLE TImpMemberCourse ADD FUsedTimes DECIMAL(18,6)
|
|
ALTER TABLE TImpMemberCourse ADD FCalcMode INT
|
|
ALTER TABLE TImpMemberCourse ADD FExpiredDate DateTime
|
|
ALTER TABLE TImpMemberCourse ADD FGender INT
|
|
ALTER TABLE TImpMemberCourse ADD FName VARCHAR(100)
|
|
ALTER TABLE TImpMemberCourse ADD FMobile VARCHAR(100)
|
|
ALTER TABLE TImpMemberCourse ADD FMemNo VARCHAR(100)
|
|
|
|
UPDATE TImpMemberCourse SET FMemNO = 卡号
|
|
UPDATE TImpMemberCourse SET FIsNew = 0
|
|
UPDATE TImpMemberCourse SET FName = 姓名
|
|
UPDATE TImpMemberCourse SET FMobile = 手机号
|
|
UPDATE TImpMemberCourse SET FGender = 0
|
|
UPDATE TImpMemberCourse SET FExpiredDate = 使用期限
|
|
UPDATE TImpMemberCourse SET FPurTimes = 剩余次数
|
|
UPDATE TImpMemberCourse SET FUsedTimes = 0
|
|
UPDATE TImpMemberCourse SET FCompId = 1
|
|
UPDATE TImpMemberCourse SET FCalcMode = 1
|
|
UPDATE TImpMemberCourse SET FId = dbo.FNNewId() WHERE FId IS NULL
|
|
|
|
|
|
|
|
UPDATE A
|
|
SET A.FItemId = B.FId
|
|
FROM TImpMemberCourse AS A,TItem AS B
|
|
WHERE A.项目编号 = B.FNo
|
|
|
|
UPDATE A
|
|
SET A.FCOurseId = B.FId
|
|
FROM TImpMemberCourse AS A,TCourse AS B
|
|
WHERE A.FItemId = B.FItemId
|
|
|
|
|
|
update TImpMemberCourse SET FIsNew = 1,FMemId = dbo.FNNewId() WHERE FMemId IS NULL
|
|
|
|
SELECT * FROM TImpMemberCourse WHERE FIsNew = 1 AND FMemNo IN(SELECT FMemNO FROM TMember)
|
|
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FMemID
|
|
FROM TImpMemberCourse AS A,TMember AS B
|
|
WHERE A.FMemNO = B.FMemNo
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FMemId
|
|
FROM TImpMemberCourse A ,(
|
|
SELECT FMemNO,MIN(FMemId) AS FMemId
|
|
FROM TImpMemberCourse
|
|
WHERE FIsNew = 1
|
|
GROUP BY FMemNO
|
|
HAVING(SUM(1) > 1)) AS B
|
|
WHERE A.FMemNo = B.FMemNO
|
|
|
|
|
|
SELECT * FROM TImpMemberCourse WHERE FMemNo = '80001897'
|
|
|
|
INSERT INTO TMember(
|
|
FMemId,
|
|
FMemNo,
|
|
FName,
|
|
FBriefCode,
|
|
FTypeId,
|
|
FCompId,
|
|
FCreateDate,
|
|
FGender,
|
|
FBirthdayType,
|
|
FBirthday,FTelephone,FMobilePhone,FQQ,FWeChat,FIdCard,FEmail,FAddress,FProId,FCPW,FQPW,
|
|
FChargeEmpId,FPoint,FRecvConsSMS,FRecvBulkSMS,FMemo,FCustom1,FCustom2,FCustom3,FCustom4,FCustom5)
|
|
SELECT FMemId AS FMemId,
|
|
FMemNo AS FMemNo,
|
|
FName AS FName,
|
|
dbo.FNGetFirstPinYin(FName),
|
|
0 AS FTypeId,
|
|
FCompId AS FCompId,
|
|
ISNULL(getdate() ,'1900-01-01') AS FCreateDate,
|
|
FGender AS FGender,
|
|
'g' AS FBirthdayType,
|
|
null AS FBirthday,
|
|
'' AS FTelephone,
|
|
ISNULL('','') AS FMobilePhone,
|
|
'' AS FQQ,
|
|
'' AS FWeChat,
|
|
'' AS FIdCard,
|
|
'' AS FEmail,
|
|
'' AS FAddress,
|
|
0 AS FProId,
|
|
'' AS FCPW,
|
|
'' AS FQPW,
|
|
0 AS FChargeEmpId,
|
|
ISNULL( 0,0) AS FPoint,
|
|
1 AS FRecvConsSMS,
|
|
1 AS FRecvBulkSMS,
|
|
ISNULL('','') AS FMemo,
|
|
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
|
|
from TImpMemberCourse
|
|
WHERE FIsNew = 1
|
|
GROUP BY FMemId,FMemNo,FName,FGender,FCompId
|
|
|
|
|
|
|
|
UPDATE TImpMemberCourse SET FCompId = 1
|
|
UPDATE TImpMemberCourse SET FId = dbo.FNNewId()
|
|
|
|
UPDATE TImpMemberCourse SET FCalcMode = CASE WHEN 购买次数 IN( '年卡','季卡') THEN 2 ELSE 1 END
|
|
|
|
UPDATE TCourse SET FCalcMode = 2 WHERE FId = 7883450327372601565
|
|
|
|
SELECT * FROM TCourse
|
|
|
|
UPDATE
|
|
|
|
SELECT 项目,购买次数
|
|
FROM TImpMemberCourse
|
|
GROUP BY 项目,购买次数
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FMemID
|
|
FROM TImpMemberCourse AS A,TMember AS B
|
|
WHERE A.卡号 = B.FMemNo
|
|
|
|
UPDATE A
|
|
SET A.FCourseId = B.FId,
|
|
A.FItemId = B.FItemId
|
|
FROM TImpMemberCourse AS A,TItem AS C,TCourse AS B
|
|
WHERE A.项目 = C.FNo
|
|
AND C.FId = B.FItemId
|
|
|
|
UPDATE A
|
|
SET A.FPurTimes = CAST(购买次数 AS FLOAT),
|
|
A.FUsedTimes = cast(购买次数 as float) - 剩余次数
|
|
FROM TImpMemberCourse AS A
|
|
|
|
WHERE 购买次数 NOT IN( '年卡','季卡')
|
|
|
|
UPDATE TImpMemberCourse SET FPurTimes = 0,FUsedTimes = 0
|
|
|
|
ALTER TABLE TImpMemberCourse ADD Times VARCHAR(100)
|
|
|
|
UPDATE TImpMemberCourse SET Times = 购买次数 WHERE 购买次数 NOT IN( '年卡','季卡')
|
|
|
|
|
|
select * from TImpMemberCourse WHERE Times = '季卡'
|
|
|
|
UPDATE TImpMember
|
|
|
|
UPDATE TImpMemberCourse SET FExpiredDate = DATEADD(DAY,cast(失效日期 as int),'1900-01-01')
|
|
FROM TImpMemberCourse
|
|
|
|
|
|
DELETE TCourse WHERE FName IN(SELECT 项目 FROM TImpMemberCourse)
|
|
|
|
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
|
|
SELECT FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode
|
|
FROM #Course
|
|
|
|
SELECT * INTO #Course FROM TCourse WHERE 1=0
|
|
|
|
SELECT * FROM #Course
|
|
|
|
UPDATE #Course SET FNo = FNo + '-年卡', FName = FName + '-年卡' WHERE FCalcMode = 2
|
|
|
|
|
|
DROP TABLE #Course
|
|
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode,
|
|
FPointMode,FPOintValue,FAcctId,FDeposit)
|
|
|
|
SELECT dbo.FNNewId() AS FId,
|
|
I.FNo ,
|
|
I.FName AS FName,
|
|
'' AS FBriefCode,
|
|
I.FId AS FItemId,
|
|
0 AS FPackId,
|
|
1 AS FSequence,
|
|
0 AS FTypeId,
|
|
1 AS FTimes,
|
|
0 AS FFreeTimes,
|
|
0 AS FDurable,
|
|
0 AS FValidityPeriodUnit,
|
|
0 AS FValidityPeriod,
|
|
getdate() AS FCreateDate,
|
|
NULL AS FExpiredDate,
|
|
'' AS FDescription,
|
|
1 AS FEnabled,
|
|
0 AS FPrice,
|
|
0 AS FAmount,
|
|
|
|
1 AS FCalcMode, 0 AS FPointMode,
|
|
0 AS FPointValue,0,0
|
|
FROM TItem AS I,TImpMemberCourse AS B
|
|
|
|
WHERE I.FId = B.FItemId
|
|
|
|
GROUP BY FNo,I.FName ,I.FId
|
|
|
|
|
|
|
|
SELECT * FROM TItem WHERE FNo IN(SELECT 项目 FROM TImpMemberCourse)
|
|
|
|
|
|
|
|
|
|
DROP TABLE TImpMemberCourse
|
|
|
|
|
|
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FUsedPurTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
|
|
SELECT FId,FMemId,FCourseId,0,FItemId,FCompId,FPurTimes,ISNULL(0,0) AS FPurAmount,0,
|
|
FUsedTimes,0,getdate() as FCreateDate,FExpiredDate,'DR.Import',0,0,0,'',1, ISNULL(0,0) as FAdjustPrice
|
|
FROM TImpMemberCourse
|
|
|
|
SELECT * FROM TImpMemberCourse WHERE FMemID is null
|
|
--WHERE FCourseId IS NOT NULL
|
|
|
|
|
|
AND FId NOT IN(SELECT FId FROM TMemberCourse)
|
|
|
|
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,FCompId,FBillType,FBizType,FBillId,FBillNo,FBillDetailId,FRecordTime)
|
|
SELECT dbo.FNNewId(),FMemId,A.FId AS FCardId,0, ISNULL(FCourseId,0),getdate(),FPurTimes + 0 ,0,FUsedTimes,0,FCompId,'DR','Import',0,'',0,getdate()
|
|
FROM TImpMemberCourse AS A |