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.
sql-tools/Import/颜艺/颜艺术.sql

279 lines
9.8 KiB

1 year ago
SELECT * FROM TMemberCourseImportEx
WHERE FCardTypeId IS NULL
AND FItemId IS NULL
SELECT * FROM TMemberCourseImportEx
WHERE FCardTypeId IS NULL
AND FCourseId IS NULL
INSERT TMemberCourseImportEx
SELECT * FROM Sheet1$
DROP TABLE TMemberCourseImportEx
delete TMemberCourseImportEx WHERE BMMC00 = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>'
delete TMemberImport
SELECT * FROM TMemberImport
SELECT <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FROM TMemberCourseImportEx GROUP BY <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
INSERT TItem(FId,FNo,FNoOfPad,FName,FAbbr,FTypeId,FBriefCode,FDescription,FPriceMode,FIsService,FReturnInterval,FCustom1,FCustom2,FCustom3,FEnabled,FPrice,FVipPrice,FTime,FDctId,FPointMode,FPointValue,FDeptId,FAllowBooking)
SELECT dbo.FNNewId(),'L' + LXMC00,'L' + LXMC00,LXMC00,LXMC00,0,dbo.FNGetFirstPinYin(LXMC00),
'',1,1,0,'','','',1,0,0,0,0,0,0,0,0
FROM TMemberCourseImportEx
WHERE FItemId IS NULL
GROUP BY LXMC00
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
VALUES(dbo.FNNewId(),A.FNo + 'L1',A.FName + 'L1',@IBriefCode,@IItemId,@IPackId,@ISequence,@ITypeId,@ITimes,@IFreeTimes,@IDurable,@IValidityPeriodUnit,@IValidityPeriod,@ICreateDate,@IExpiredDate,@IDescription,@IEnabled,@IPrice,@IAmount,@ICalcMode)
SELECT * FROM TItem
UPDATE TItem SET FTypeId = 4769343797855259478 WHERE FTypeId = 0
ALTER TABLE TMemberCourseImportEx ADD FCompId BIGINT
ALTER TABLE TMemberCourseImportEx ADD FCardId BIGINT
ALTER TABLE TMemberCourseImportEx ADD FMemId BIGINT
ALTER TABLE TMemberCourseImportEx ADD FMemCourseId BIGINT
ALTER TABLE TMemberCourseImportEx ADD FItemId BIGINT
ALTER TABLE TMemberCourseImportEx ADD FCourseId BIGINT
ALTER TABLE TMemberCourseImportEx ADD FCardTypeId BIGINT
ALTER TABLE TMemberCourseImportEx ADD FCardNo VARCHAR(30)
ALTER TABLE TMemberCourseImportEx ADD FName VARCHAR(30)
ALTER TABLE TMemberCourseImportEx ADD FMobilePhone VARCHAR(30)
ALTER TABLE TMemberCourseImportEx ADD FGender INT
ALTER TABLE TMemberCOurseImportEx ADD FCreateDate DATETIME
ALTER TABLE TMemberCOurseImportEx ADD FRemainTimes DECIMAL(18,6)
ALTER TABLE TMemberCOurseImportEx ADD FRemainAmount DECIMAL(18,6)
ALTER TABLE TMemberCOurseImportEx ADD FAdjustPrice DECIMAL(18,6)
ALTER TABLE TMemberCOurseImportEx ADD FBalance DECIMAL(18,6)
SELECT * FROM TMemberImport
UPDATE TMemberCourseImportEx SET FMemCourseId = dbo.FNNewId()
UPDATE TMemberCourseImportEx SET FCardId = dbo.FNNewId()
UPDATE TMemberCourseImportEx SET FRemainTimes = CS,FRemainAMount = CSJE
UPDATE TMemberCourseImportEx SET FAdjustPrice = FRemainAMount / FRemainTimes
WHERE FRemainTimes != 0
UPDATE TMemberCourseImportEx
SET FName = KHXM00,
FCardNo = VIPKH00,
FMobilePhone = CAST(CAST(KHSJ00 AS VARCHAR(111)) AS VARCHAR(111)) ,
FGender = CASE WHEN KHXB00 = 'M' THEN 1 ELSE 0 END,
FCreateDate = VIPDJRQ,
FBalance = VIPKNYE
UPDATE TMemberCourseImportEx SET FMobilePhone = '' WHERE FMobilePhone IS NULL
SELECT CAST(CAST(<EFBFBD> AS bigint) AS VARCHAR(111)) FROM TMemberCourseImportEx
UPDATE TMemberCourseImportEx SET FCompId = CASE WHEN BMBH00 = '00150' THEN 5764583237144501932
WHEN BMBH00 = '00151' THEN 5146190082460629410
WHEN BMBH00 = '00235' THEN 5146190082460629410 ELSE 0 END
SELECT FName,sum(1) FROM TItem
GROUP BY FName
order by sum(1) desc
UPDATE TMemberCourseImportEx SET FItemId = NULL,FCardTypeId = NULL,FCourseId = NULL
UPDATE TMemberCourseImportEx SET FItemId = (SELECT FId FROM TItem WHERE FName =LXMC00 )
UPDATE TMemberCourseImportEx SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE LXMC00 LIKE FName )
UPDATE A SET FCourseId = (SELECT FId FROM TCOurse AS B WHERE A.FItemId = B.FItemId)
FROM TMemberCourseImportEx AS A
DELETE TMemberImport
INSERT INTO TMemberImport(FId,FCompId,FMemId,FMemNo,FCardId,FCardNo,FName,FGender,FMobilePhone,FCreateDate,FExpiredDate,FCardTypeId,FAcctId,FBalance,FAcctId2,FBalance2)
SELECT dbo.FNNewId(),FCompId,dbo.FNNewId(),MIN(FCardNo),dbo.FNNewId(),MIN(FCardNo),ISNULL(FName,''), 0 ,ISNULL(FMobilePhone,''),MIN(FCreateDate), Dateadd(yy,100,MIN(FCreateDate)),
0,0,0,0,0
FROM TMemberCourseImportEx
WHERE FCardNo NOT IN(select FNo FROM TMember)
GROUP BY ISNULL(FName,''),FMobilePhone,FCompId
UPDATE A
SET A.FMemId = B.FMemId
FROM TMemberCourseImportEx AS A,TMemberImport AS B
WHERE ISNULL(A.FName,'') = B.FName
AND ISNULL(A.FMobilePhone,'') = B.FMobilePhone
AND A.FCompId = B.FCompId
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,FCompId,ISNULL(FRemainTimes,0),CASE WHEN ISNULL(FRemainTimes,0) = 0 THEN 0 ELSE FRemainAmount END,0,0,FCreateDate,dateadd(yy,1,FCreateDate),'DR.Import',0,0,0,'',1,ISNULL(FAdjustPrice,0)
--SELECT *
FROM TMemberCourseImportEx
WHERE FCourseId IS NOT NULL
AND LXMC00 LIKE '%<EFBFBD>걦%'
AND ISNULL(FRemainTimes,0) = 0
AND FCourseId != 0
INSERT INTO TMember(
FId,
FNo,
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 FId,
FMemNo AS FNo,
FName AS FName,
FBriefCode AS FBriefCode,
0 AS FTypeId,
FCompId AS FCompId,
FCreateDate AS FCreateDate,
FGender AS FGender,
FBirthdayType AS FBirthdayType,
FBirthday AS FBirthday,
FTelephone AS FTelephone,
FMobilePhone AS FMobilePhone,
'' AS FQQ,
'' AS FWeChat,
'' AS FIdCard,
'' AS FEmail,
'' AS FAddress,
0 AS FProId,
FPW AS FCPW,
'' AS FQPW,
0 AS FChargeEmpId,
0 AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
'' AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TMemberImport
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(),ISNULL(FRemainTimes,0),FFreeTimes = 0,0,0,
FPurAmount = CASE WHEN ISNULL(FRemainTimes,0) = 0 THEN 0 ELSE FRemainAmount END,0,0,0,FCompId,
'DR','Import',0,'',0
FROM TMemberCourseImportEx
WHERE 1=1-- FRemainTimes > 0
AND FCourseId IS NOT NULL
AND LXMC00 LIKE '%<EFBFBD>걦%'
AND ISNULL(FRemainTimes,0) = 0
AND FCourseId != 0
SELECT * FROM TMemberCourseImportEx WHERE KHXM00 = '<EFBFBD><EFBFBD>Ф<EFBFBD><EFBFBD>' AND KHSJ00 = '13583340686'
UPDATE A SET A.FPurchaseDate = B.FCreateDate,
A.FExpiredDate = dateadd(yy,1,b.FCreateDate)
FROM TMemberCourseImportEx AS B,TMemberCourse AS A
WHERE A.FId = B.FMemCourseId
UPDATE TMemberCourse SET FCalcMode = 2 WHERE FPurTimes = 0
SELECT * FROM TMemberCourseImportEx where FMobilePhone = '13706430299'
DELETE TMemberCourse
DELETE TMemberCourseHist
DELETE TMemberCourseImportEx WHERE FRemainTimes <
SELECT * FROM TMember
UPDATE A SET A.FCompID = B.FCompId
FROM TMemberCOurse as A,TMemberCourseImportEx AS B
WHERE A.FMemId = B.FMemId
--<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
FCardId AS FId,
FCardNo AS FNo,
FCardNo 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(yy,100,FCreateDate) AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FCompId AS FSaleCompId,
0 AS FSaleBillId,
'' AS FMemo
FROM TMemberCourseImportEx
WHERE FCardTypeId != 0
DELETE TMemberCard WHERE FCardId > 0 AND FCardId != 5291573899875837995
SELECT * FROM TMemberCardAccount
INSERT TMemberCardAccount(FId,FMemId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT dbo.FNNewId(),FMemId,FCardId AS FCardId,3,FBalance,FBalance,0,FCreateDate,Dateadd(yy,100,FCreateDate),''
FROM TMemberCourseImportEx
WHERE FCardTypeId != 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.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),''
from TMemberCourseImportEx AS A
WHERE FCardTypeId != 0
DELETE TMemberCourse WHERE FRemainPurTimes = 0
SELECT * FROM TConsumeBill
update TConsumeBill SET FCustQuantity = 1
SELECT
SELECT FName,FMobilePhone,SUM(1)
FROM TMember GROUP BY FName,FMobilePhone ORDER BY SUM(1) DESC
UPDATE A
SET A.FMemId = B.FMemId
FROM TMemberCourse AS A,TMemberCourseImportEx AS B
WHERE A.FId = B.FMemCourseId
UPDATE A
SET A.FMemId = B.FMemId
FROM TMemberCard AS A,TMemberCourseImportEx AS B
WHERE A.FCardId = B.FCardId