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.
 
 
 
 
 

347 lines
11 KiB

SELECT CardTypeName FROM TImpMember
WHERE CardTypeName NOT IN(SELECT FCardTypeName FROM TImpCardType)
GROUP BY CardTypeName
SELECT * FROM TCompany
SELECT count(*) FROM TImpMember WHERE ID NOT IN(SELECT FCardId FROM TImpMemberAcct)
SELECT * FROM TImpMemberAcct
WHERE 1=1
AND intAccountCate != 1
AND FCardId = 3257267
SELECT * FROM TImpMemberPack
WHERE FCardId = 3257267
--处理疗程
ALTER TABLE TImpMemberPack ADD FMemId BIGINT
ALTER TABLE TImpMemberPack ADD FCreateDate DATETIME
ALTER TABLE TImpMemberPack ADD FExpiredDate DATETIME
ALTER TABLE TImpMemberPack ADD FItemId BIGINT
ALTER TABLE TImpMemberPack ADD FCourseId BIGINT
ALTER TABLE TImpMemberPack ADD FMemCourseId BIGINT
UPDATE A
SET A.FCreateDate = dtmCreateTime,
A.FExpiredDate = dtmLimitDate
FROM TImpMemberPack AS A
UPDATE A
SET A.FMemCourseId = dbo.FNnewId()
FROM TImpMemberPack AS A
WHERE A.FMemCourseId IS NULL
UPDATE A
SET A.FMemId = B.FMemId
FROM TImpMemberPack AS A ,TImpMember AS B
WHERE A.FCardId = B.Id
UPDATE A
SET A.FItemId = B.FItemId,
A.FCourseId = B.FId
FROM TCourse AS B,TImpMemberPack AS A
WHERE B.FNo = '1001L1'
SELECT * FROM TImpMember WHERE Id = 2934498
SELECT * FROM TImpError
delete TImpError
SELECT * FROM TMemberCourse
DELETE TCourse WHERE FName NOT LIKE '%年卡%'
SELECT * INTO TMember_Exist FROM TMember WHERE FMemId IN(SELECT FMemId FROM TMember_Exist)
SELECT * INTO TMemberCard_Exist FROM TMemberCard WHERE FMemId IN(SELECT FMemId FROM TMember_Exist)
SELECT * INTO TMemberCardAccount_Exist FROM TMemberCardAccount WHERE FMemId IN(SELECT FMemId FROM TMember_Exist)
SELECT * INTO TMemberCardAcctHist_Exist FROM TMemberCardAcctHist WHERE FMemId IN(SELECT FMemId FROM TMember_Exist)
SELECT * INTO TMemberOldTransHist_Exist FROM TMemberOldTransHist WHERE FMemId IN(SELECT FMemId FROM TMember_Exist)
SELECT * INTO TMemberCardOldAcctHist_Exist FROM TMemberCardOldAcctHist WHERE FMemId IN(SELECT FMemId FROM TMember_Exist)
DROP TABLE TMemberCardOldAcctHist_Exist
DROP TABLE TMemberOldTransHist_Exist
DROP TABLE TMemberCardAccount_Exist
DROP TABLE TMemberOldTransHist_Exist
DELETE TMember WHERE FMemId IN(SELECT FMemId FROM TMember_Exist)
DELETE TMemberCard WHERE FMemId IN(SELECT FMemId FROM TMember_Exist)
DELETE TMemberCardAccount WHERE FMemId IN(SELECT FMemId FROM TMember_Exist)
DELETE TMemberCardAcctHist WHERE FMemId IN(SELECT FMemId FROM TMember_Exist)
DELETE TMemberOldTransHist WHERE FMemId IN(SELECT FMemId FROM TMember_Exist)
DELETE TMemberCardOldAcctHist WHERE FMemId IN(SELECT FMemId FROM TMember_Exist)
--把两个系统的会员ID搞一致
UPDATE A
SET A.FMemId = B.FMemId
FROM TMember_Exist AS B,TImpMember AS A
WHERE B.FMemNo = A.CardNo
UPDATE A
SET A.FCardId = B.FCardId
FROM TMemberCard_Exist AS B,TImpMember AS A
WHERE B.FCardNo = A.CardNo
SELECT *INTO TMember_Exist FROM TMember WHERE FMemNo IN(SELECT CardNo FROM TImpMember)
SELECT * FROM TImpMember WHERE Credit != 0
SELECT * FROM TUser
SELECT * FROM TImpMember WHERE CardNo = '800128'
CREATE TABLE TImpError
(
CardId BIGINT,
Error VARCHAR(7000)
)
ALTER TABLE TImpMember ADD FIsLoad BIT NOT NULL DEFAULT 0
ALTER TABLE TImpMember ADD FMemId BIGINT
ALTER TABLE TImpMember ADD FMemNo VARCHAR(50)
ALTER TABLE TImpMember ADD FName VARCHAR(50)
ALTER TABLE TImpMember ADD FGender INT
ALTER TABLE TImpMember ADD FMobile VARCHAR(50)
ALTER TABLE TImpMember ADD FCardTypeId BIGINT
ALTER TABLE TImpMember ADD FCourseId BIGINT
ALTER TABLE TImpMember ADD FBalance DECIMAL(18,6)
ALTER TABLE TImpMember ADD FRemainTimes INT
ALTER TABLE TImpMember ADD FPurTimes INT
ALTER TABLE TImpMember ADD FPurAmount DECIMAL(18,6)
ALTER TABLE TImpMember ADD FItemId BIGINT
ALTER TABLE TImpMember ADD FCreateDate DATETIME
ALTER TABLE TImpMember ADD FCompId BIGINT
ALTER TABLE TImpMember ADD FCardId BIGINT
ALTER TABLE TImpMember ADD FMemo VARCHAR(1000)
ALTER TABLE TImpMember ADD FArrear DECIMAL(18,6)
ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6)
UPDATE TImpMember SET FMemId = dbo.FNNewId() WHERE FMemid IS NULL
UPDATE TImpMember SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
UPDATE TImpMember SET FMemNo = CardNo
UPDATE TImpMember SET FName = MemberName
UPDATE TImpMember SET FMobile = MobilePhone
UPDATE TImpMember SET FGender = CASE WHEN Sex = '' THEN 1 ELSE '0' END
UPDATE TImpMember SET FBalance = Balance
UPDATE TImpMember SET FRemainTimes =
UPDATE TImpMember SET FPurTimes =
UPDATE TImpMember SET FPurAmount =
UPDATE TImpMember SET FCreateDate = CreateTime
UPDATE TImpMember SET FCompId = (SELECT FId FROM TCompany WHERE FNo = '003')
UPDATE TImpMember SET FArrear =
UPDATE TImpMember SET FMemo = remark
UPDATE TImpMember SET FPoint = cast(JF as float)
UPDATE A SET A.FCardTypeId = B.FCardTypeId
FROM TImpMember AS A,TImpCardType AS B
WHERE A.CardTypeName = B.FCardTypeName
CREATE TABLE TImpCardType
(
FCardTypeName VARCHAR(500),
FCardTypeNo VARCHAR(50),
FCardTypeId BIGINT
)
DELETE TImpCardType
INSERT TImpCardType(FCardTypeName,FCardTypeNo,FCardTypeId)
SELECT '钻石卡六折','1/6',0 UNION ALL
SELECT '宝石卡六折','06',0 UNION ALL
SELECT '金卡七折','05',0 UNION ALL
SELECT '宝石卡五折','07',0 UNION ALL
SELECT '300元八折卡','085',0 UNION ALL
SELECT '钻石卡','1/6',0 UNION ALL
SELECT '白金卡','1/6.5',0 UNION ALL
SELECT '金卡','1/7.5',0 UNION ALL
SELECT '水晶卡','1/7',0 UNION ALL
SELECT '金卡七五折','1/7.5',0 UNION ALL
SELECT '银卡八折','1/8',0 UNION ALL
SELECT A.CardTypeName,B.FNo,B.FId FROM TImpMember AS A,TMemberCardType AS B
WHERE A.CardTypeName NOT IN(SELECT FCardTypeName FROM TImpCardType)
AND A.CardTypeName = B.FName
GROUP BY A.CardTypeName,B.FNo,B.FId
UPDATE A
SET A.FCardTypeId = B.FId
FROM TImpCardType AS A,TMemberCardType AS B
WHERE A.FCardTypeNo = B.FNo
SELECT * FROM TMemberCardType WHERE FName LIKE '%银卡%'
SELECT * FROM TUser
--交易历史
SELECT * FROM TImpMemberLog
ALTER TABLE TImpMemberLog ADD FMemId BIGINT
ALTER TABLE TImpMemberLog ADD FBillNo VARCHAR(50)
ALTER TABLE TImpMemberLog ADD FBizType VARCHAR(50)
ALTER TABLE TImpMemberLog ADD FContent VARCHAR(1000)
ALTER TABLE TImpMemberLog ADD FAmount DECIMAL(18,6)
ALTER TABLE TImpMemberLog ADD FTime DATETIME
ALTER TABLE TImpMemberLog ADD FId VARCHAR(50)
ALTER TABLE TImpMemberLog ADD FEmployee VARCHAR(1000)
ALTER TABLE TImpMemberLog ADD FQuantity DECIMAL(18,6)
ALTER TABLE TImpMemberLog ADD FCompId BIGINT
UPDATE A
SET A.FMemId = M.FMemId
FROM TImpMemberLog AS A,TMember AS M
WHERE A. = M.FMemNo
SELECT * FROM TImpMemberLog
UPDATE TImpMemberLog SET FBillNo =
UPDATE TImpMemberLog SET FContent =
UPDATE TImpMemberLog SET FQuantity =
UPDATE TImpMemberLog SET FAmount =
UPDATE TImpMemberLog SET FEmployee = ISNULL(,'')
UPDATE TImpMemberLog SET FTime =
UPDATE TImpMemberLog SET FQuantity =
UPDATE TImpMemberLog SET FId = dbo.FNNewId()
UPDATE TImpMemberLog SET FCompId = (SELECT FId FROM TCompany WHERE FNo = '003')
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,
FCreateDate AS FCreateDate,
FGender AS FGender,
'G' AS FBirthdayType,
NULL AS FBirthday,
'' AS FTelephone,
ISNULL(FMobile,'') AS FMobilePhone,
'' AS FQQ,
'' AS FWeChat,
'' AS FIdCard,
'' AS FEmail,
'' AS FAddress,
0 AS FProId,
'' AS FCPW,
'' AS FQPW,
0 AS FChargeEmpId,
FPoint AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
FMemo AS FMemo,
'从旺点导入' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TImpMember
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
FCardId AS FId,
FMemno AS FNo,
FMemno AS FFaceNo,
FCardTypeId AS FTypeId,
(SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
FCompId AS FCompId,
FMemId AS FMemId,
1 AS FState,
FCreateDate AS FCreateDate,
DATEADD(year,1, FCreateDate) AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FCompId AS FSaleCompId,
0 AS FSaleBillId,
'' AS FMemo
FROM TImpMember
WHERE FCardTypeId IS NOT NULL
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,3,FBalance,FBalance,0,FCreateDate,DATEADD(year,1, FCreateDate) AS FExpiredDate,''
FROM TImpMember AS A
WHERE FCardTypeId IS NOT NULL
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.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),'从Excel中导入'
FROM TImpMember AS A
WHERE FCardTypeId IS NOT NULL
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT FMemCourseId,FMemId,FCourseId,0,FItemId,1,0,0,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'旺点导入',2,0
FROM TImpMemberPack AS A
UPDATE TMemberCourseImportEx SET FId = dbo.FNNewId()
INSERT INTO TMemberCourseHist(FId,FMemId,FMemCourseId,FPackId,FCourseId,FTime,FPurTimes,FFreeTimes,FUsePurTimes,FUseFreeTimes,
FPurAmount,FFreeAmount,FUsePurAmount,FUseFreeAmount,FCompId,
FBillType,FBizType,FTransId,FTransNo,FTransDetailId)
SELECT dbo.FNNewId(),FMemId,FMemCourseId,0,FCourseId,FTime = getdate(),0,0,0,0,
0,0,0,0,1,
'DR','Import',0,'',0
FROM TImpMemberPack AS A
SELECT * FROM TMember WHERE FMemId IN(SELECT FMemId FROM TMemberCOurse)
SELECT FMemId,MIN(FId) FROM TMemberCourse
GROUP BY FMemId
DELETE TMemberCOurse WHERE FId NOT IN( SELECT MIN(FId) FROM TMemberCourse
GROUP BY FMemId)
UPDATE TImpMember SET FIsLOAD = 0
SELECT * FROM TImpMemberLog
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT A.FId,A.FMemId,A.FTime,0,A.FCompId,'DR','Import',FBillNo,FContent,FAmount,FQuantity,FAmount,'',FEmployee,''
FROM TImpMemberLog AS A
WHERE ISNULL(FMemId,0) != 0
AND != ''
WHERE A.FNo = hykh