|
|
|
|
use taiyuan_yihao
|
|
|
|
|
|
|
|
|
|
drop table TImpMember
|
|
|
|
|
drop table TImpMemberCard
|
|
|
|
|
|
|
|
|
|
SELECT COUNT(1) FROM TImpMemberCard
|
|
|
|
|
SELECT COUNT(1) FROM TImpMember
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember
|
|
|
|
|
SELECT * FROM TImpMemberCard
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>ŵ<EFBFBD>
|
|
|
|
|
SELECT * FROM TImpCompany
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpCompany ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE TImpCompany ADD FCompNo VARCHAR(20)
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FId,
|
|
|
|
|
A.FCompNo = B.FNo
|
|
|
|
|
FROM TIMpCompany AS A,TCompany AS B
|
|
|
|
|
WHERE ShopId = '74803'
|
|
|
|
|
AND B.FNo = '003'
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FCom
|
|
|
|
|
|
|
|
|
|
--UPDATE TImpCompany SET FCompId = dbo.FNCompId('002') WHERE ShopId = '74802'
|
|
|
|
|
--UPDATE TImpCompany SET FCompId = dbo.FNCompId('003') WHERE ShopId = '74803'
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET <EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD> = <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> = <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>= <EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
where <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> like '%<EFBFBD><EFBFBD>%'
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember where <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> like '%<EFBFBD><EFBFBD>%'
|
|
|
|
|
|
|
|
|
|
SELECT MemId,SUM(1)
|
|
|
|
|
FROM TImpMemberCard
|
|
|
|
|
GROUP BY MemId
|
|
|
|
|
HAVING(SUM(1)) > 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE TImpCardType
|
|
|
|
|
CREATE TABLE TImpCardType
|
|
|
|
|
(
|
|
|
|
|
FId BIGINT,
|
|
|
|
|
FNo VARCHAR(50),
|
|
|
|
|
FName VARCHAR(50),
|
|
|
|
|
FType VARCHAR(50),
|
|
|
|
|
FValueType INT
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FCardTypeName VARCHAR(100)
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMember ADD FMemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FMemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FCardNo VARCHAR(50)
|
|
|
|
|
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 FCreateDate DATETIME
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FCardTypeId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FCourseId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FBalance DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FBalance2 DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FRemainTimes INT
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FPurTimes INT
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FPurAmount DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FItemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FCreateDate DATETIME
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FExpiredDate DATETIME
|
|
|
|
|
ALTER TABLE TImpMember ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FCardId BIGINT
|
|
|
|
|
ALTER TABLE TImpMember ADD FArrear DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMember ADD FBirthday DATETIME
|
|
|
|
|
ALTER TABLE TImpMember ADD FBirthdayType CHAR
|
|
|
|
|
ALTER TABLE TImpMember ADD FCustom1 VARCHAR(100)
|
|
|
|
|
ALTER TABLE TImpMember ADD FPointText VARCHAR(100)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DELETE TImpMemberCard
|
|
|
|
|
|
|
|
|
|
SELECT COUNT(1) FROM TImpMemberCard
|
|
|
|
|
SELECT COUNT(1) FROM TImpMemberCard
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCoursePack ADD FCardTypeId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCoursePack ADD FItemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCoursePack ADD FRemainTimes INT
|
|
|
|
|
ALTER TABLE TImpMemberCoursePack ADD FPurTimes INT
|
|
|
|
|
ALTER TABLE TImpMemberCoursePack ADD FUsedTimes INT
|
|
|
|
|
ALTER TABLE TImpMemberCoursePack ADD FPurAmount DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMemberCoursePack ADD FCreateDate DATETIME
|
|
|
|
|
ALTER TABLE TImpMemberCoursePack ADD FExpiredDate DATETIME
|
|
|
|
|
ALTER TABLE TImpMemberCoursePack ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCoursePack ADD FCardId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCoursePack ADD FMemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCoursePack ADD FMemo VARCHAR(1000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FCardTypeId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FItemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FRemainTimes INT
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FPurTimes INT
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FUsedTimes INT
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FPurAmount DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FCreateDate DATETIME
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FExpiredDate DATETIME
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FCardId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FMemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FMemo VARCHAR(1000)
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FItemName VARCHAR(50)
|
|
|
|
|
ALTER TABLE TImpMemberYearCard ADD FCalcMode INT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
alter table TImpMemberCard alter column cardId VARCHAR(50)
|
|
|
|
|
alter table TImpMember alter column memId VARCHAR(50)
|
|
|
|
|
|
|
|
|
|
CREATE unique CLUSTERED INDEX IX_TImpMemberCard ON TImpMemberCard (cardId)
|
|
|
|
|
CREATE unique CLUSTERED INDEX IX_TImpMember ON TImpMember (memId)
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCard WHERE FMemo IS NULL
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCard SET FMemo = '' WHERE FMemo IS NULL
|
|
|
|
|
UPDATE TImpMember SET FMemo = '' WHERE FMemo IS NULL
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMemberCard SET FCardTYpeName = <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> + '[' + <EFBFBD>ۿ<EFBFBD> + '<EFBFBD><EFBFBD>]'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DELETE TImpCardType
|
|
|
|
|
INSERT TImpCardType(FId,FNo,FName,FValueType)
|
|
|
|
|
|
|
|
|
|
SELECT dbo.FNNewId() AS FId,FNo,FName,FValueType
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT FCardTYpeName AS FNo, FCardTYpeName AS FName ,CASE WHEN <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '<EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' THEN 3 ELSE 1 END AS FValueType
|
|
|
|
|
FROM TImpMemberCard
|
|
|
|
|
WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IS NOT NULL
|
|
|
|
|
AND <EFBFBD><EFBFBD><EFBFBD><EFBFBD> IS NOT NULL
|
|
|
|
|
GROUP BY FCardTYpeName ,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) AS A
|
|
|
|
|
GROUP BY FNo,FName,FValueType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ԱID
|
|
|
|
|
UPDATE TImpMember SET FMemId = MemId
|
|
|
|
|
UPDATE TImpMemberCard SET FMemId = MemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCard
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FCreateDate = ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCreateDate = B.FCreateDate
|
|
|
|
|
FROM TImpMemberCard AS A,TImpMember AS B
|
|
|
|
|
WHERE A.MemId = B.MemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER DATABASE TUser ADD FILEGROUP cache_mod CONTAINS MEMORY_OPTIMIZED_DATA
|
|
|
|
|
-- Important! In the path below, you specify a folder, not a file.
|
|
|
|
|
ALTER DATABASE TUser ADD FILE (name='cache_mod', filename='c:\Program Files\Microsoft Sql Server\MSSQL12.MSSQLSERVER\MSSQL\DATA') TO FILEGROUP cache_mod
|
|
|
|
|
ALTER DATABASE TUser SET MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT=ON
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCard SET FExpiredDate = ʧЧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
WHERE ʧЧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> != '0' AND ʧЧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> != ''
|
|
|
|
|
AND LEN(ʧЧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>) = 10
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCard SET FExpiredDate = DATEADD(YEAR,100,FCreateDate) WHERE FExpiredDate = '1900-01-01' OR FExpiredDate IS NULL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMemberCard SET FCardNo = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
DROP TABLE #Card
|
|
|
|
|
|
|
|
|
|
SELECT FCardNo into #Card
|
|
|
|
|
FROM TImpMemberCard
|
|
|
|
|
GROUP BY FCardNo
|
|
|
|
|
HAVING(SUM(1)) > 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FSeq INT IDENTITY
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FIndex INT
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FIndex = 1+(SELECT COUNT(1) FROM TImpMemberCard AS B WHERE A.FCardNo = B.FCardNo AND (A.FCreateDate > B.FCreateDate OR (A.FCreateDate = B.FCreateDate AND (A.FSeq > B.FSeq) )))
|
|
|
|
|
FROM TImpMemberCard AS A
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCard WHERE FCardNo IN(SELECT FCardNO FROM #Card)
|
|
|
|
|
AND FIndex > 0
|
|
|
|
|
|
|
|
|
|
order by FCardNo
|
|
|
|
|
|
|
|
|
|
--ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
DELETE A
|
|
|
|
|
FROM TImpMemberCard AS A,
|
|
|
|
|
(
|
|
|
|
|
SELECT MemId,CardId,MIN(FSeq) AS FSeq
|
|
|
|
|
FROM TImpMemberCard
|
|
|
|
|
WHERE FCardNO iN(SELECT FCardNo FROM #Card)
|
|
|
|
|
GROUP BY MemId,CardId
|
|
|
|
|
HAVING(SUM(1)>1)
|
|
|
|
|
) AS B
|
|
|
|
|
WHERE A.MemId = B.MemId
|
|
|
|
|
AND A.CardId = B.CardId
|
|
|
|
|
AND A.FSeq = B.FSeq
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCard SET FCardNo = FCardNo + '.' + CAST(FIndex AS VARCHAR)
|
|
|
|
|
WHERE FCardNo IN( SELECT FCardNo FROM #Card)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCardNo = B.FCardNo
|
|
|
|
|
FROM TImpMemberCard AS A,TImpMemberCard AS B
|
|
|
|
|
WHERE A.FMemId = B.FMemId
|
|
|
|
|
AND A.FIndex > 1
|
|
|
|
|
AND B.FIndex = 1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
SELECT FCardNo,SUM(1) AS Cnt FROM TImpMemberCard
|
|
|
|
|
GROUP BY FCardNo
|
|
|
|
|
ORDER BY SUM(1) DESC
|
|
|
|
|
|
|
|
|
|
SELECT FMemNo,FMobile,SUM(1) AS Cnt FROM TImpMember
|
|
|
|
|
GROUP BY FMemNo ,FMobile
|
|
|
|
|
ORDER BY SUM(1) DESC
|
|
|
|
|
|
|
|
|
|
SELECT FMemNo,SUM(1) AS Cnt FROM TImpMember
|
|
|
|
|
WHERE FMemId IN(SELECT FMemId FROM TImpMemberCard)
|
|
|
|
|
GROUP BY FMemNo
|
|
|
|
|
ORDER BY SUM(1) DESC
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCard SET FCardId = CardId
|
|
|
|
|
UPDATE TImpMemberCard SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemNo = B.FCardNo
|
|
|
|
|
FROM TImpMember AS A,TImpMemberCard AS B
|
|
|
|
|
WHERE A.MemId = B.MemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FMemNo = <EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD> WHERE ISNULL(FMemNo,'') = ''
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FName = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FMobile = <EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FGender = CASE WHEN <EFBFBD>Ա<EFBFBD> = '<EFBFBD><EFBFBD>' THEN 1 ELSE '0' END
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FMobile = '' WHERE FMobile IN(
|
|
|
|
|
'0'
|
|
|
|
|
, '00'
|
|
|
|
|
, '000'
|
|
|
|
|
, '0000'
|
|
|
|
|
, '00000'
|
|
|
|
|
, '000000'
|
|
|
|
|
, '0000000'
|
|
|
|
|
, '00000000'
|
|
|
|
|
, '000000000'
|
|
|
|
|
, '0000000000'
|
|
|
|
|
, '00000000000')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FPointText = replace(replace(replace(replace(<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'<EFBFBD><EFBFBD>',''),char(10),''),char(13),''),' ','')
|
|
|
|
|
UPDATE TImpMember SET FPoint = CAST(FPointText AS FLOAT)
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember where <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> like '%<EFBFBD><EFBFBD>%'
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>ŵ<EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FCompId = dbo.FNCompId('001')
|
|
|
|
|
UPDATE TImpMemberCard SET FCompId = dbo.FNCompId('002')
|
|
|
|
|
|
|
|
|
|
SELECT MemId,ShopId FROM TImpMemberCard WHERE 1=1 GROUP BY MemId,ShopId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT MemId,(SELECT TOP 1 ShopId FROM TImpMemberCard )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE FCardTypeID IS NULL
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCard
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCardTypeId = B.FId
|
|
|
|
|
FROM TImpMemberCard AS A,TImpCardType AS B
|
|
|
|
|
WHERE A.FCardTypeName= B.FName
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCard
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpCardType
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FBirthdayType = 'G'
|
|
|
|
|
UPDATE TImpMember SET FBirthdayType = 'L' WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%ũ<EFBFBD><EFBFBD>%'
|
|
|
|
|
UPDATE TImpMember SET FBirthday = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD> != ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>ŵ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCard WHERE CardId NOT IN(SELECT CardId FROM TImpTransHist)
|
|
|
|
|
|
|
|
|
|
SELECT FRemainTimes FROM TImpMemberCard WHERE FRemainTimes > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCard SET FRemainTimes = REPLACE(SUBSTRING(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,CHARINDEX('<EFBFBD><EFBFBD>:',<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) + 2,LEN(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)),'<EFBFBD><EFBFBD>','')
|
|
|
|
|
FROM TImpMember WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '<EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCard WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> not in( '<EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCard SET FBalance = CAST(
|
|
|
|
|
REPLACE( REPLACE(REPLACE(REPLACE(LEFT(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,CHARINDEX('Ԫ',<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)),'Ԫ',''),' ','') ,char(10),''),' ','')
|
|
|
|
|
AS float)
|
|
|
|
|
WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IS NOT NULL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FROM TImpMemberCard
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FBalance2Text VARCHAR(10)
|
|
|
|
|
UPDATE TImpMemberCard SET FBalance2Text = CAST(REPLACE( REPLACE(REPLACE(REPLACE(LEFT(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,CHARINDEX('Ԫ',<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) + 3),'Ԫ',''),' ','') ,char(10),''),' ','')
|
|
|
|
|
AS varchar)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCard SET FBalance2 = CAST(REPLACE( REPLACE(REPLACE(REPLACE(LEFT(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,CHARINDEX('Ԫ',<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) + 3),'Ԫ',''),' ','') ,char(10),''),' ','')
|
|
|
|
|
AS float)
|
|
|
|
|
--WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> NOT LIKE '%<EFBFBD>ײ<EFBFBD>%'
|
|
|
|
|
----------
|
|
|
|
|
|
|
|
|
|
SELECT SUM(CAST(REPLACE( REPLACE(REPLACE(REPLACE(LEFT(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,CHARINDEX('Ԫ',<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) + 3),'Ԫ',''),' ','') ,char(10),''),' ','')
|
|
|
|
|
AS float) ) FROM TImpMemberCard
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
delete TMemberCardType WHERE FId > 100
|
|
|
|
|
INSERT INTO TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FCardFeeAmt,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue,FPaySmsFee,FTimeCard,FValidityPeriod,FValidityPeriodUnit,FExpiredDate,FDefaultMemo,FCreateTime,FAllowSale,FAllowRchg,FDeptId,FEnabled,FOrder)
|
|
|
|
|
SELECT FId ,FNo,FName,FValueType,2,0,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
|
|
|
FROM TImpCardType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCard WHERE FCardTypeId NOT IN(SELECT FId FROM TMemberCardType)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ORDER BY FNo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TMemberCardType SET FAllowRchg = 1 WHERE FId IN(SELECT FId FROM TImpCardType)
|
|
|
|
|
UPDATE TMemberCardType SET FAllowSale = 1 WHERE FId IN(SELECT FId FROM TImpCardType)
|
|
|
|
|
UPDATE TMemberCardType SET FEnabled = 1 WHERE FId IN(SELECT FId FROM TImpCardType)
|
|
|
|
|
UPDATE TMemberCardType SET FValidityPeriod = 100 WHERE FId IN(SELECT FId FROM TImpCardType)
|
|
|
|
|
UPDATE TMemberCardType SET FValidityPerioduNIT = 1 WHERE FId IN(SELECT FId FROM TImpCardType)
|
|
|
|
|
UPDATE TMemberCardType SET FExpiredDate = null WHERE FId IN(SELECT FId FROM TImpCardType)
|
|
|
|
|
UPDATE TMemberCardType SET FDeposit = 0,FDefaultMemo = '' WHERE FId IN(SELECT FId FROM TImpCardType)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TMemberCardTypeSub(FId,FCompId,FCardTypeId,FAllowSale,FAllowRchg,FEnabled)
|
|
|
|
|
SELECT dbo.FNNewId(),C.FId,I.FId,FAllowSale,FAllowRchg,FEnabled
|
|
|
|
|
FROM TMemberCardType AS I,TCompany AS C
|
|
|
|
|
WHERE I. FId IN(SELECT FId FROM TImpCardType)
|
|
|
|
|
AND C.FId = dbo.FNCompId('001')
|
|
|
|
|
AND NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TMemberCardType SET FMaterial = 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FValueType = 3
|
|
|
|
|
FROM TMemberCardType AS A,TImpCardType AS B
|
|
|
|
|
WHERE A.FId = B.FId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>ײ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
SELECT dbo.FNNewId() AS FId,<EFBFBD><EFBFBD>Ŀ AS FName,<EFBFBD><EFBFBD>Ŀ AS FNo
|
|
|
|
|
INTO TImpItem
|
|
|
|
|
FROM TImpCourse
|
|
|
|
|
GROUP BY <EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpCourse
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpCourse ADD FId BIGINT,FItemId BIGINT,FTimes INT,
|
|
|
|
|
FPrice DECIMAL(18,6),FAmount DECIMAL(18,6),FValidityPeriod INT
|
|
|
|
|
ALTER TABLE TImpCourse ADD FName VARCHAR(100)
|
|
|
|
|
ALTER TABLE TImpCourse ADD FCalcMode INT
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpCourse
|
|
|
|
|
|
|
|
|
|
UPDATE TImpCourse SET FValidityPeriod = 0
|
|
|
|
|
UPDATE TImpCourse SET FValidityPeriod = 1 WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '365<EFBFBD><EFBFBD>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpCourse SET FId = dbo.FNNewId()
|
|
|
|
|
UPDATE TImpCourse SET FName = <EFBFBD><EFBFBD>Ŀ + '[' + <EFBFBD><EFBFBD><EFBFBD><EFBFBD> + ']' + '[' + <EFBFBD><EFBFBD><EFBFBD><EFBFBD> +']'
|
|
|
|
|
UPDATE TImpCourse SET FPrice = <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpCourse SET FAMount = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpCourse SET FTimes = <EFBFBD><EFBFBD><EFBFBD><EFBFBD> WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD> != '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
UPDATE TImpCourse SET FCalcMode = 1
|
|
|
|
|
UPDATE TImpCourse SET FCalcMode = 2 WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD> != '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FItemId = B.FId
|
|
|
|
|
FROM TImpCourse AS A,TImpItem AS B
|
|
|
|
|
WHERE A.FName = B.FName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberYearCard
|
|
|
|
|
SELECT * FROM TImpMemberCoursePack
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>꿨<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMemberYearCard SET FItemName = SUBSTRING(<EFBFBD>꿨<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, CHARINDEX(')',<EFBFBD>꿨<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>) + 1,LEN(<EFBFBD>꿨<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>))
|
|
|
|
|
|
|
|
|
|
DROP TABLE TImpItem
|
|
|
|
|
|
|
|
|
|
SELECT dbo.FNNewId() AS FId,dbo.FNNewId() AS FCourseId,FNo,FName
|
|
|
|
|
INTO TImpItem
|
|
|
|
|
FROM (
|
|
|
|
|
select 'SC_' + <EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FNo, <EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FName
|
|
|
|
|
from TImpMemberCoursePack
|
|
|
|
|
GROUP BY <EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
UNION ALL
|
|
|
|
|
select 'SC_' + FItemName AS FNo, FItemName AS FName
|
|
|
|
|
FROM TImpMemberYearCard
|
|
|
|
|
GROUP BY FItemName
|
|
|
|
|
*/
|
|
|
|
|
) AS A
|
|
|
|
|
GROUP BY FNo,FName
|
|
|
|
|
|
|
|
|
|
DELETE TItem WHERE FId IN(SELECT FId FROM TImpItem_2)
|
|
|
|
|
|
|
|
|
|
INSERT TItem(FId,FNo,FNoOfPad,FName,FAbbr,FTypeId,FBriefCode,FDescription,FPriceMode,FIsService,FStatTimes,FCustom1,FCustom2,FCustom3,FEnabled,FPrice,FVipPrice,FTime,FDctId,FPointMode,FPointValue,FDeptId,FAllowBooking)
|
|
|
|
|
SELECT FId,FNo,FName,FName,FName,0,dbo.FNGetFirstPinYin(FName),'''',1,1,1,'''','''','''',1,0,0,0,0,0,0,0,1
|
|
|
|
|
FROM TImpItem
|
|
|
|
|
ORDER BY FNo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 AS FId,
|
|
|
|
|
A.FName + '',
|
|
|
|
|
A.FName AS FName,
|
|
|
|
|
'' AS FBriefCode,
|
|
|
|
|
A.FItemId AS FItemId,
|
|
|
|
|
0 AS FPackId,
|
|
|
|
|
1 AS FSequence,
|
|
|
|
|
0,--(SELECT TOP 1 FId FROM TBasicType WHERE FKey = 'CourseType') AS FTypeId,
|
|
|
|
|
ISNULL(FTimes,0) AS FTimes,
|
|
|
|
|
0 AS FFreeTimes,
|
|
|
|
|
0 AS FDurable,
|
|
|
|
|
1 AS FValidityPeriodUnit,
|
|
|
|
|
FValidityPeriod AS FValidityPeriod,
|
|
|
|
|
getdate() AS FCreateDate,
|
|
|
|
|
NULL AS FExpiredDate,
|
|
|
|
|
'' AS FDescription,
|
|
|
|
|
1 AS FEnabled,
|
|
|
|
|
FPrice AS FPrice,
|
|
|
|
|
FAMount AS FAmount,
|
|
|
|
|
1 AS FCalcMode
|
|
|
|
|
FROM TImpCourse AS A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TItemSub(FId,FCompId,FItemId,FPrice,FVipPrice,FTime,FDctId,FPointMode,FPointValue,FDeptId,FAllowBooking,FEnabled)
|
|
|
|
|
SELECT dbo.FNNewId(),C.FId,I.FId,I.FPrice,I.FVipPrice,I.FTime,I.FDctId,I.FPointMode,I.FPointValue,I.FDeptId,I.FAllowBooking,I.FEnabled
|
|
|
|
|
FROM TItem AS I,TCompany AS C
|
|
|
|
|
WHERE I.FId != 0
|
|
|
|
|
AND C.FId != 0
|
|
|
|
|
AND C.FNo IN('001')
|
|
|
|
|
AND NOT EXISTS(SELECT TOP 1 1 FROM TItemSub AS B WHERE B.FCompId = C.FId AND B.FItemId = I.FId)
|
|
|
|
|
AND I.FId IN(SELECT FId FROM TImpItem)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCoursePack
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCoursePack SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
|
|
|
|
|
UPDATE TImpMemberCoursePack SET FExpiredDate = NULL
|
|
|
|
|
UPDATE TImpMemberCoursePack SET FExpiredDate = ʧЧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> WHERE ʧЧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> != ''
|
|
|
|
|
UPDATE TImpMemberCoursePack SET FMemo = ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FItemId = B.FItemId,
|
|
|
|
|
A.FCardTypeId = B.FId
|
|
|
|
|
FROM TImpMemberCoursePack AS A,TImpCourse AS B
|
|
|
|
|
WHERE A.<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.name
|
|
|
|
|
AND REPLACE(<EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD>,'<EFBFBD><EFBFBD>','') = REPLACE(B.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'<EFBFBD><EFBFBD>','')
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FItemId = B.FItemId,
|
|
|
|
|
A.FCardTypeId = B.FId
|
|
|
|
|
FROM TImpMemberCoursePack AS A,TCourse AS B
|
|
|
|
|
WHERE A.<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.Fname
|
|
|
|
|
AND A.FItemId = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCoursePack
|
|
|
|
|
WHERE replace(<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,' ','')
|
|
|
|
|
NOT IN(
|
|
|
|
|
|
|
|
|
|
SELECT name FROM TImpCourse AS B
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpCourse ADD name VARCHAR(100)
|
|
|
|
|
|
|
|
|
|
UPDATE TImpCourse SET <EFBFBD><EFBFBD>Ŀ = replace(<EFBFBD><EFBFBD>Ŀ,' ','')
|
|
|
|
|
UPDATE TImpCourse SET <EFBFBD><EFBFBD>Ŀ = replace(<EFBFBD><EFBFBD>Ŀ,' ','')
|
|
|
|
|
|
|
|
|
|
UPDATE TImpCourse SET name = SUBSTRING(<EFBFBD><EFBFBD>Ŀ,6,LEn(<EFBFBD><EFBFBD>Ŀ) - 5)
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD>ͨ
|
|
|
|
|
SELECT * FROM TImpCourse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpCourse WHERE <EFBFBD><EFBFBD>Ŀ LIKE '%<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCoursePack
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCoursePack SET FItemId = 0,FCardTypeId = 0
|
|
|
|
|
SELECT * FROM TImpCourse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCoursePack
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TCourse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCoursePack SET FRemainTimes = ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMemberCoursePack SET FPurTimes = REPLACE(<EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD>,'<EFBFBD><EFBFBD>','')
|
|
|
|
|
UPDATE TImpMemberCoursePack SET FPurAmount = <EFBFBD><EFBFBD>ֵ<EFBFBD>ܶ<EFBFBD>
|
|
|
|
|
UPDATE TImpMemberCoursePack SET FUsedTimes = FPurTimes - FRemainTimes
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCreateDate = B.FCreateDate,
|
|
|
|
|
A.FMemId = B.FNewMemId
|
|
|
|
|
FROM TImpMemberCoursePack AS A,TImpMember AS B
|
|
|
|
|
WHERE A.MemId = B.FMemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCoursePack SET FCompId = dbo.FNCompId('001')
|
|
|
|
|
UPDATE TImpMemberCoursePack SET FMemId = MemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>꿨
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberYearCard SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
|
|
|
|
|
UPDATE TImpMemberYearCard SET FExpiredDate = NULL
|
|
|
|
|
UPDATE TImpMemberYearCard SET FExpiredDate = ʧЧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> WHERE ʧЧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> != ''
|
|
|
|
|
UPDATE TImpMemberYearCard SET FMemo = ''
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
SELECT * FROM TImpMemberYearCard
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FItemId = B.FItemId,
|
|
|
|
|
A.FCardTypeId = B.FId
|
|
|
|
|
FROM TImpMemberYearCard AS A,TCourse AS B
|
|
|
|
|
WHERE FItemName = B.FName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberYearCard SET FRemainTimes = ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMemberYearCard SET FPurTimes = REPLACE(<EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD>,'<EFBFBD><EFBFBD>','')
|
|
|
|
|
UPDATE TImpMemberYearCard SET FPurAmount = 0
|
|
|
|
|
UPDATE TImpMemberYearCard SET FUsedTimes = FPurTimes - FRemainTimes
|
|
|
|
|
UPDATE TImpMemberYearCard SET FCalcMode = 2
|
|
|
|
|
UPDATE TImpMemberYearCard SET FCalcMode = 1 WHERE <EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD> > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCreateDate = B.FCreateDate,
|
|
|
|
|
A.FMemId = B.FMemId
|
|
|
|
|
FROM TImpMemberYearCard AS A,TImpMemberCard AS B
|
|
|
|
|
WHERE A.CardId = B.CardId
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberYearCard SET FCompId = dbo.FNCompId('001')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FMemNO = 'MH' + FMemNo
|
|
|
|
|
WHERE FMemNo IN(SELECT FMemNO FROM TMember)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCard SET FCardNo = 'MH' + FCardNo
|
|
|
|
|
WHERE FCardNo IN(SELECT FCardNo FROM TMember)
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>ϲ<EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMember ADD FNewPoint DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE TImpMember ADD FNewMemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FNewMemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMember ADD FMemIndex INT IDENTITY NOT NULL
|
|
|
|
|
ALTER TABLE TImpMemberCoursePack ADD FNewMemId BIGINT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FNewMemId = FMemId
|
|
|
|
|
UPDATE TImpMember SET FNewPoint = FPoint
|
|
|
|
|
UPDATE TImpMemberCard SET FNewMemId = FMemId
|
|
|
|
|
UPDATE TImpMemberCoursePack SET FNewMemId = FMemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FNewMemId = B.FMemId,A.FNewPoint = B.FNewPoint
|
|
|
|
|
FROM TImpMember AS A,TImpMember AS B,(
|
|
|
|
|
SELECT FMobile,FName ,SUM(FPoint) AS FNewPoint,MIN(DATEADD(MINUTE,D.FMemIndex, FCreateDate)) AS FCreateDate,SUM(1) AS FCount
|
|
|
|
|
FROM TImpMember D
|
|
|
|
|
WHERE FMobile != ''
|
|
|
|
|
AND LEN(FMobile) = 11
|
|
|
|
|
GROUP BY FMobile,FName
|
|
|
|
|
HAVING(SUM(1) > 1) ) AS C
|
|
|
|
|
WHERE C.FCreateDate = DATEADD(MINUTE,B.FMemIndex, b.FCreateDate)
|
|
|
|
|
AND C.FMobile = B.FMobile
|
|
|
|
|
AND C.FName = B.FName
|
|
|
|
|
AND A.FMobile = B.FMobile
|
|
|
|
|
AND A.FName = B.FName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update TIMpMember SET FNewMemId = FMemId WHERE FNewMemId IS NULL
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FNewMemId = B.FNewMemId
|
|
|
|
|
FROM TImpMember AS B,TImpMemberCard AS A
|
|
|
|
|
WHERE A.FMemId = B.FMemId
|
|
|
|
|
AND B.FMemId != B.FNewMemId
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FNewMemId = B.FNewMemId
|
|
|
|
|
FROM TImpMember AS B,TImpMemberCoursePack AS A
|
|
|
|
|
WHERE A.FMemId = B.FMemId
|
|
|
|
|
AND B.FMemId != B.FNewMemId
|
|
|
|
|
|
|
|
|
|
SELECT * FROM
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE FNewMemId != FMemId AND FMemo != ''
|
|
|
|
|
|
|
|
|
|
DELETE TMember WHERE FMemId IN(SELECT FNewMemId FROM TImpMember)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 FNewMemId AS FMemId,
|
|
|
|
|
FMemNo AS FMemNo,
|
|
|
|
|
FName AS FName,
|
|
|
|
|
dbo.FNGetFirstPinYin(FName),
|
|
|
|
|
0 AS FTypeId,
|
|
|
|
|
FCompId AS FCompId,
|
|
|
|
|
ISNULL(FCreateDate ,'1900-01-01') AS FCreateDate,
|
|
|
|
|
FGender AS FGender,
|
|
|
|
|
'G' AS FBirthdayType,
|
|
|
|
|
FBirthday 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,
|
|
|
|
|
ISNULL( FNewPoint,0) AS FPoint,
|
|
|
|
|
1 AS FRecvConsSMS,
|
|
|
|
|
1 AS FRecvBulkSMS,
|
|
|
|
|
ISNULL(FMemo,'') AS FMemo,
|
|
|
|
|
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
|
|
|
|
|
from TImpMember
|
|
|
|
|
WHERE FNewMemId IN(SELECT FNewMemId FROM TImpMemberCard)
|
|
|
|
|
AND FMemId = FNewMemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE FNewMemId = 76564036
|
|
|
|
|
SELECT * FROM TImpMemberCard WHERE FNewMemId = 76564036
|
|
|
|
|
|
|
|
|
|
AND FMemId = 76564036
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE FMobile = '13969098625'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AND FMemo NOT LIKE '%ע<EFBFBD><EFBFBD>%'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DELETE TMember WHERE FMemId IN(SELECT FNewMemId FROM TImpMember)
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMember
|
|
|
|
|
|
|
|
|
|
INSERT 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,'',FNewPoint,0,FNewPoint,'',getdate()
|
|
|
|
|
FROM TImpMember AS A
|
|
|
|
|
WHERE FNewPoint != 0
|
|
|
|
|
AND A.FNewMemId = A.FMemId
|
|
|
|
|
AND FMemo NOT LIKE '%ע<EFBFBD><EFBFBD>%'
|
|
|
|
|
|
|
|
|
|
DELETE TMemberPointHist WHERE FMemId IN(SELECT FNewMemId FROM TImpMember)
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE FMemId != FNewMemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SELECT * FROM TImpMember
|
|
|
|
|
WHERE FMemId IN(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT FMemId,FMemNo,FName,FMobile,FGender,FCompId ,FBirthdayType ,FBirthday,FCreateDate,FPoint
|
|
|
|
|
INTO #Temp
|
|
|
|
|
FROM TImpMember
|
|
|
|
|
GROUP BY FMemId,FMemNo,FName,FMobile,FGender,FCompId ,FBirthdayType ,FBirthday,FCreateDate,FPoint
|
|
|
|
|
ORDER BY SUM(1) DESC
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
SELECT FMemNO,SUM(1)
|
|
|
|
|
FROM TIMpmember
|
|
|
|
|
WHERE FMemId = FNewMemId
|
|
|
|
|
GROUP BY FMemNO
|
|
|
|
|
HAVING(SUM(1) > 1)
|
|
|
|
|
|
|
|
|
|
SELECT FMemId
|
|
|
|
|
FROM #Temp
|
|
|
|
|
GROUP BY FMemId
|
|
|
|
|
HAVING(SUM(1)) > 1
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpmEMBER WHERE FMobile = '18765015301'
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FMemNo = '0000330' WHERE FMemId = 25463627
|
|
|
|
|
UPDATE TImpMember SET FMemNo = '0000055' WHERE FMemId = 25006217
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
SELECT count(1) FROM TImpMemberCard WHERE FMemo IS NULL
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
1 AS FValueType,
|
|
|
|
|
FCompId AS FCompId,
|
|
|
|
|
FNewMemId AS FMemId,
|
|
|
|
|
1 AS FState,
|
|
|
|
|
FCreateDate AS FCreateDate,
|
|
|
|
|
FExpiredDate AS FExpiredDate,
|
|
|
|
|
ISNULL(FRemainTimes,0) AS FTotalTimes,
|
|
|
|
|
0 AS FUsedTimes,
|
|
|
|
|
FCompId AS FSaleCompId,
|
|
|
|
|
0 AS FSaleBillId,
|
|
|
|
|
FMemo AS FMemo
|
|
|
|
|
FROM TImpMemberCard
|
|
|
|
|
WHERE FNewMemId IN(SELECT FNewMemId FROM TImpMember)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE FNewMemId = 76564036
|
|
|
|
|
SELECT * FROM TMember WHERE FMemId = 76564036
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE FCardId IS NULL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WHERE CardNo 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,NULL AS FExpiredDate,''
|
|
|
|
|
FROM TImpMemberCard AS A
|
|
|
|
|
WHERE FNewMemId IN(SELECT FMemId FROM TMember)
|
|
|
|
|
|
|
|
|
|
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(),'<EFBFBD><EFBFBD>ʢ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
FROM TImpMemberCard AS A
|
|
|
|
|
WHERE FNewMemId IN(SELECT FMemId FROM TMember)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
|
|
|
|
|
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,10,FBalance2,FBalance2,0,FCreateDate,NULL AS FExpiredDate,''
|
|
|
|
|
FROM TImpMemberCard AS A
|
|
|
|
|
WHERE FBalance2 != 0
|
|
|
|
|
AND FNewMemId IN(SELECT FMemId FROM TMember)
|
|
|
|
|
|
|
|
|
|
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,10,getdate(),A.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance2,0,A.FBalance2,0,getdate(),'<EFBFBD><EFBFBD>ʢ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
FROM TImpMemberCard AS A
|
|
|
|
|
WHERE FBalance2 != 0
|
|
|
|
|
AND FNewMemId IN(SELECT FMemId FROM TMember)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>Ƴ<EFBFBD>
|
|
|
|
|
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
|
|
|
|
|
SELECT FCardId,FMemId,FCardTypeId,0,FItemId,FCompId,FPurTimes,FPurTimes-FRemainTimes,FPurAmount,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'<EFBFBD><EFBFBD>ʢ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>',1,0
|
|
|
|
|
FROM TImpMemberCoursePack AS A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.FCardId AS FCardId,0, ISNULL(FCardTypeId,0),getdate(),FPurTimes,0,FPurTimes-FRemainTimes,0,FCompId,'DR','Import',0,'',0,getdate()
|
|
|
|
|
FROM TImpMemberCoursePack AS A
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>꿨
|
|
|
|
|
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
|
|
|
|
|
SELECT FCardId,FMemId,FCardTypeId,0,FItemId,FCompId,FPurTimes,FPurTimes-FRemainTimes,FPurAmount,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'<EFBFBD><EFBFBD>ʢ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>',FCalcMode,0
|
|
|
|
|
FROM TImpMemberYearCard AS A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.FCardId AS FCardId,0, ISNULL(FCardTypeId,0),getdate(),FPurTimes,0,FPurTimes-FRemainTimes,0,FCompId,'DR','Import',0,'',0,getdate()
|
|
|
|
|
FROM TImpMemberYearCard AS A
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCalcMode = 2
|
|
|
|
|
FROM TCourse AS A
|
|
|
|
|
WHERE A.FId IN(SELECT FCourseId FROM TMemberCourse WHERE FCalcMode = 2)
|
|
|
|
|
|
|
|
|
|
--Ƿ<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberArrear ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberArrear ADD FMemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberArrear ADD FCardId BIGINT
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = MemId
|
|
|
|
|
FROM TImpMemberArrear AS A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCardId = B.FCardId
|
|
|
|
|
FROM TImpMemberArrear AS A,TImpMemberCard AS B
|
|
|
|
|
WHERE A.MemID = B.MemId
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberArrear SET FCompId = dbo.FNCOmpId('006')
|
|
|
|
|
|
|
|
|
|
INSERT 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,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0,3,CAST(A.δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) ,0,0,0
|
|
|
|
|
FROM TImpMemberArrear AS A
|
|
|
|
|
WHERE CAST(A.δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ʷ
|
|
|
|
|
SELECT * FROM TIMpMember
|
|
|
|
|
WHERE MemId NOT IN(SELECT MemId FROM TImpMemberTransHist)
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberTransHist
|
|
|
|
|
SELECT * FROM TImpMemberTransHistDetail
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DELETE TImpMemberTransHist
|
|
|
|
|
DELETE TImpMemberTransHistDetail
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberTransHist ADD FCompId BIGINT
|
|
|
|
|
UPDATE TImpMemberTransHist SET FCompID = DBO.FNCompId('001')
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FCompId
|
|
|
|
|
FROM TImpMemberTransHist as a,TIMpMember AS B
|
|
|
|
|
WHERE A.MemId = B.memId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberOldTransHist(FId,FCompId,FMemId,FTime,FCardId,FBIllType,FBizType,FTransNo,FCOntent,FPrice,FQuantity,FAmount,FPayment,Femployee,FMemo)
|
|
|
|
|
SELECT dbo.FNNewId(),C.FCompId,C.FNewMemId,REPLACE(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>',''),CardId,'',LEFT(A.<EFBFBD><EFBFBD><EFBFBD>ѽ<EFBFBD><EFBFBD><EFBFBD>,4),A.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|
|
|
|
ISNULL(B.<EFBFBD><EFBFBD>Ŀ,''),0,1,A.ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,SUBSTRING(A.<EFBFBD><EFBFBD><EFBFBD>ѽ<EFBFBD><EFBFBD><EFBFBD>,5,len(<EFBFBD><EFBFBD><EFBFBD>ѽ<EFBFBD><EFBFBD><EFBFBD>)),B.Ա<EFBFBD><EFBFBD>, '' AS FMemo
|
|
|
|
|
FROM TImpMemberTransHistDetail AS B,TImpMemberTransHist AS A,TImpMember AS C
|
|
|
|
|
WHERE A.TransId = B.TransId
|
|
|
|
|
AND A.MemId = C.MemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberTransHistDetail
|
|
|
|
|
|
|
|
|
|
update TMemberOldTransHist SET FEmployee = REPLACE(FEmployee,']','<EFBFBD><EFBFBD>')
|
|
|
|
|
SELECT * FROM TMemberOldTransHist
|
|
|
|
|
update TMemberOldTransHist SET FEmployee = REPLACE(FEmployee,'[','<EFBFBD><EFBFBD>')
|
|
|
|
|
SELECT * FROM TMemberOldTransHist
|
|
|
|
|
|
|
|
|
|
UPDATE TMemberOldTransHist SET FEmployee = '.' + FEmployee
|
|
|
|
|
WHERE REPLACE(FEmployee,' ','') LIKE '[%'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT count(1) FROM TImpMember WHERE FAvatar IS NULL
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCard WHERE Cardid = 230729900
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FAvatar = REPLACE(FAvatar,'\_2','')
|
|
|
|
|
WHERE FAvatar LIKE '%\_2%'
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE FAvatar LIKE '%_2%'
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberPhoto
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberPhoto(FMemId,FType,FImage,FImagePath,FChangeId)
|
|
|
|
|
SELECT FMemId,1,NULL,REPLACE(FAvatar,'http://files.sentree.com.cn/photo/850621/',''),1
|
|
|
|
|
FROM TImpMember
|
|
|
|
|
WHERE ISNULL(FAvatar,'') != ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--Ա<EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpEmployee ADD FPosId BIGINT
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpEmployee
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpEmployee ADD FPosName VARCHAR(100)
|
|
|
|
|
ALTER TABLE TImpEmployee ADD FNo VARCHAR(20)
|
|
|
|
|
ALTER TABLE TImpEmployee ADD FId BIGINT
|
|
|
|
|
|
|
|
|
|
UPDATE TImpEmployee SET FId = dbo.FNNewId()
|
|
|
|
|
|
|
|
|
|
UPDATE TImpEmployee SET FPosName = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'1',''),'2',''),'3',''),'<EFBFBD><EFBFBD><EFBFBD>Ӵ˹<EFBFBD>λ',''),'<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>',''),'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>',''),'<EFBFBD><EFBFBD>ְ',''),' ',''),'<EFBFBD><EFBFBD>ְ','')
|
|
|
|
|
|
|
|
|
|
INSERT TBasicType(FId,FNo,FKey,FName)
|
|
|
|
|
SELECT dbo.FNNewId(),FPosName,'Position',FPosName FROM TImpEmployee
|
|
|
|
|
GROUP BY FPosName
|
|
|
|
|
|
|
|
|
|
INSERT TBasicTypeSub(FBasicTypeId,FCompId)
|
|
|
|
|
SELECT A.FId,C.FId
|
|
|
|
|
FROM TBasicType AS A,TCompany AS C
|
|
|
|
|
WHERE A.FKey = 'Position'
|
|
|
|
|
AND C.FId > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FPosId = B.FId
|
|
|
|
|
FROM TImpEmployee AS A,TBasicType AS B
|
|
|
|
|
WHERE A.FPosName = B.FName
|
|
|
|
|
AND B.FKey = 'Position'
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FNo = B.FCompNo + A.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
FROM TImpEmployee AS A,TImpCompany AS B
|
|
|
|
|
WHERE A.shopId = B.shopId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TEmployee(FId,FNo,FName,FEnLname,FEnFname,FNickname,FDeptId,FPosId,FTechTypeId,FBriefCode,FGender,FStature,FWeight,FNationPlace,FNation,FEducation,FMarital,FAddress,FTelephone,FMobilePhone,FQQ,FEmail,FIdCard,FBirthdayType,FBirthday,FCardNo,FPW,FBank,FBankCardNo,FSSNo,FHCNo,FLinkMan,FLinkManTel,FLinkManAddr,FIsManager,FAllowBooking,FContractType,FState,FCreatorId,FCreateDate,FEntryDate,FExpiredDate,FLeaveDate,FPrice,FTags)
|
|
|
|
|
SELECT FId,FNo,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,FEnLname = '',FEnFname = '',FNickname = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>,FDeptId = 0,
|
|
|
|
|
FPosId,FTechTypeId = 0,FBriefCode = DBO.FNGetFirstPinYin(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>),FGender = CASE WHEN <EFBFBD>Ա<EFBFBD> = '<EFBFBD><EFBFBD>' THEN 1 ELSE 0 END,
|
|
|
|
|
FStature = 0,FWeight = 0,FNationPlace = 0,FNation = 0,FEducation = '',FMarital = '',FAddress = '',
|
|
|
|
|
FTelephone = '',FMobilePhone = <EFBFBD>ֻ<EFBFBD>,FQQ = '',FEmail = '',FIdCard = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD>,FBirthdayType = CASE WHEN <EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE 'ũ<EFBFBD><EFBFBD>' THEN 'L' ELSE 'G' END,
|
|
|
|
|
FBirthday = RIGHT(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,10),
|
|
|
|
|
FCardNo = '',FPW ='',FBank = '',FBankCardNo = '',FSSNo = '',FHCNo ='',FLinkMan = '',
|
|
|
|
|
FLinkManTel = '',FLinkManAddr = '' ,FAllowSign = 0,FAllowBooking = 1,FContractType = '',
|
|
|
|
|
FState = 1,FCreatorId = 0,FCreateDate = GETDATE(),FEntryDate = <EFBFBD><EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,FExpiredDate = null,FLeaveDate = null,
|
|
|
|
|
FPrice = 0,FTags = ''
|
|
|
|
|
FROM TImpEmployee
|
|
|
|
|
WHERE ״̬ = '<EFBFBD><EFBFBD>ְ'
|
|
|
|
|
|
|
|
|
|
UPDATE TEmployee SET FBirthday = null where FBirthday = '1900-01-01'
|
|
|
|
|
|
|
|
|
|
INSERT TEmployeeSub(FCompId,FEmpId,FSerialNo)
|
|
|
|
|
SELECT C.FCompId,A.FId,A.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
FROM TImpEmployee AS A,TImpCompany AS C
|
|
|
|
|
WHERE A.ShopId = C.ShopId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ʒ
|
|
|
|
|
ALTER TABLE TImpGoods ADD FId BIGINT
|
|
|
|
|
ALTER TABLE TImpGoods ADD FNo VARCHAR(50)
|
|
|
|
|
ALTER TABLE TImpGoods ADD FUnitId BIGINT
|
|
|
|
|
|
|
|
|
|
UPDATE TIMpGoods SET FNo = no
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TBasicType(FId,FNo,FKey,FName)
|
|
|
|
|
SELECT dbo.FNNewId(),unit,'GoodsUnit',unit
|
|
|
|
|
FROM TImpGoods
|
|
|
|
|
WHERE unit NOT IN(SELECT FName FROM TBasicType WHERE FKey = 'GoodsUnit')
|
|
|
|
|
AND Unit != ''
|
|
|
|
|
GROUP BY unit
|
|
|
|
|
|
|
|
|
|
UPDATE TImpGoods SET unit = 'ƿ' WHERE unit = ''
|
|
|
|
|
|
|
|
|
|
INSERT TBasicTypeSub(FBasicTypeId,FCompId)
|
|
|
|
|
SELECT A.FId,C.FId
|
|
|
|
|
FROM TBasicType AS A,TCompany AS C
|
|
|
|
|
WHERE A.FKey = 'GoodsUnit'
|
|
|
|
|
AND C.FId > 0
|
|
|
|
|
AND A.FId NOT IN(SELECT FBasicTypeId FROM TBasicTypeSub)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FUnitId = B.FId
|
|
|
|
|
FROM TImpGoods AS A,TBasicType AS B
|
|
|
|
|
WHERE A.unit = B.FName
|
|
|
|
|
AND B.FKey = 'GoodsUnit'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FNo = B.FCompNo + A.no
|
|
|
|
|
FROM TIMpGoods AS A,TImpCompany AS B
|
|
|
|
|
WHERE A.shopId = B.shopId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpGoods SET FNo = name
|
|
|
|
|
WHERE FNo In(
|
|
|
|
|
SELECT FNo FROM TImpGoods
|
|
|
|
|
WHERE status = 1
|
|
|
|
|
GROUP BY FNo
|
|
|
|
|
HAVING(SUM(1) > 1)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TGoods(FId,FNo,FName,FNoOfPad,FTypeId,FBriefCode,FUnitId,FSalePrice,FPurCostPrice,FSaleCostPrice,FConsCostPrice,FValuationMode,FBarCode,FEnabled,FSpecification,FPurUnitId,FConsUnitId,FSupplierId,FStoreId,FConsStoreId,FSaleStoreId,FMaxStock,FMinStock,FPeriodEnabled,FShelfLife,FDctId,FPointMode,FPointValue,FDeptId,FIsSale,FUnitLock,FDescription,FCustom1,FCustom2,FCustom3)
|
|
|
|
|
SELECT id,FNo,name,FNo,FTypeId = 0,dbo.FNGetFirstPinYin(name),
|
|
|
|
|
FUnitId,FSalePrice = cast(salePrice as float),FPurCostPrice = cast(inprice as float),FSaleCostPrice = 0,FConsCostPrice = 0,
|
|
|
|
|
FValuationMode = 0,FBarCode = 0,FEnabled = 1,FSpecification = '',
|
|
|
|
|
FPurUnitId = 0,FConsUnitId = 0,FSupplierId = 0,FStoreId = 0,FConsStoreId= 0,FSaleStoreId= 0,
|
|
|
|
|
FMaxStock= 0,FMinStock= 0,FPeriodEnabled= 0,FShelfLife= 0,FDctId= 0,FPointMode= 0,FPointValue= 0,
|
|
|
|
|
FDeptId= 0,FIsSale = 1,FUnitLock= 0,FDescription= '',FCustom1 = '',FCustom2 = '',FCustom3 = ''
|
|
|
|
|
FROM TImpGoods
|
|
|
|
|
WHERE status = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TGoodsMultiUnit(FId,FGoodsId,FUnitType,FUnitId,FSequence,FConvDir,FConvRate,FSalePrice,FPurCostPrice,FSaleCostPrice,FConsCostPrice,FBarCode,FUnitLock)
|
|
|
|
|
SELECT dbo.FNNewId(),FId,1,FUnitId,1,1,1,FSalePrice,FPurCostPrice,FSaleCostPrice,FConsCostPrice,FBarCode,FUnitLock
|
|
|
|
|
FROM TGoods
|
|
|
|
|
DELETE TGoodsMultiUnit
|
|
|
|
|
|
|
|
|
|
INSERT TGoodsSub(FId,FGoodsId,FCompId)
|
|
|
|
|
SELECT dbo.FNNewId(),A.ID,C.FCompId
|
|
|
|
|
FROM TImpGoods AS A,TImpCompany AS C
|
|
|
|
|
WHERE A.shopId = c.shopId
|
|
|
|
|
AND status = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE #Inventory
|
|
|
|
|
(
|
|
|
|
|
FGoodsId BIGINT,
|
|
|
|
|
FGoodsNo VARCHAR(100),
|
|
|
|
|
FQuantity DECIMAL(18,6)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
INSERT #Inventory(FGoodsNo,FQuantity)
|
|
|
|
|
|
|
|
|
|
UPDATE #Inventory SET FGoodsNO = replace(FGoodsNo,' ','')
|
|
|
|
|
|
|
|
|
|
SELECT * FROM #Inventory
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FGoodsId = B.FId
|
|
|
|
|
FROM #Inventory AS A,TGoods AS B
|
|
|
|
|
WHERE A.FGoodsNo = B.FName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM #Inventory
|
|
|
|
|
TInventory
|
|
|
|
|
INSERT INTO TInventory(FId,FCompId,FGoodsId,FStoreId,FBatchNo,FProdDate,FPeriodDate,FQuantity)
|
|
|
|
|
SELECT dbo.FNNewId(),1,FGoodsId,21001,'','','',FQuantity
|
|
|
|
|
FROM #Inventory
|
|
|
|
|
|
|
|
|
|
INSERT INTO TInventoryLog(FId,FCompId,FGoodsId,FStoreId,FBatchNo,FTime,FBillType,FBizType,FIOType,FBillId,FBillDetailId,FBillNo,FUnitId,FInQuantity,FOutQuantity,FInStdQuantity,FOutStdQuantity,FPrice,FAmount,FBalance,FOperatorId,FMemo)
|
|
|
|
|
SELECT dbo.FNnewId(),1,A.FId,21001,'',getdate(),'DR','Import',22001,0,0,'',A.FUnitId,B.FQuantity,0,B.FQuantity,0,0,0,B.FQuantity,1,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
FROM TGoods AS A,#Inventory AS B
|
|
|
|
|
WHERE A.FId = B.FGoodsId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpItem
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--ԤԼ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT barberName FROM TImpBooking
|
|
|
|
|
GROUP BY barberName
|
|
|
|
|
|
|
|
|
|
--Ա<EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpBooking ADD FEmpId BIGINT
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FEmpId = B.FId
|
|
|
|
|
FROM TImpBooking AS A,TEmployee AS B
|
|
|
|
|
WHERE A.barberName = B.FName
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
ALTER TABLE TImpBooking ADD FItems VARCHAR(1000)
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FItems = B.FId
|
|
|
|
|
FROM TImpBooking AS A,TBasicType AS B
|
|
|
|
|
WHERE B.FKey = 'BookingItem'
|
|
|
|
|
AND REPLACE(categoryName,'<EFBFBD><EFBFBD>','') = B.FName
|
|
|
|
|
OR(categoryName = 'ϴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>' AND B.FName = 'ϴ<EFBFBD><EFBFBD>')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpBooking WHERE FItems IS NULL AND ISNULL(categoryName,'') != ''
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TBasicType WHERE FKey = 'BookingItem'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpBooking
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ա
|
|
|
|
|
ALTER TABLE TImpBooking ADD FCustName VARCHAR(1000),FCustMobile VARCHAR(1000),FCustGender INT
|
|
|
|
|
|
|
|
|
|
UPDATE TImpBooking SET FCustName = custName,FCustMobile = memmobile,FCustGender = case when sex = 'M' then 1 else 0 end
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>ŵ<EFBFBD>
|
|
|
|
|
ALTER TABLE TImpBooking ADD FCompId BIGINT
|
|
|
|
|
UPDATE TImpBooking SET FCompId = 1
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
ALTER TABLE TImpBooking ADD FSource VARCHAR(100)
|
|
|
|
|
UPDATE TImpBooking SET FSource = 'WeChat' WHERE channel = 1
|
|
|
|
|
UPDATE TImpBooking SET FSource = 'Manual' WHERE channel != 1
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpBooking ADD FStatus INT
|
|
|
|
|
UPDATE TImpBooking SET FStatus = 2
|
|
|
|
|
|
|
|
|
|
INSERT INTO TBooking(FId,FCompId,FCreationTime,FBookingTime,FDuration,FEmpId,FCustName,FCustGender,FCustMobile,FItems,FMemo,FSource,FStatus,FReason,FRemindStep,FUnifiedRemind,FConfirmTime,FFinishTime,FCreatorId)
|
|
|
|
|
SELECT id,FCompId,FCreateTime,FBookingTime,0,FEmpId,FCustName,FCustGender,FCustMobile,ISNULL(FItems,''),'',FSource,FStatus,'',0,0,FCreateTime,NULL,1
|
|
|
|
|
FROM TImpBooking
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|