|
|
|
|
USE jining_dafuhao
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ա
|
|
|
|
|
ALTER TABLE TImpMember ADD FMemId BIGINT NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMember ADD FMemNo VARCHAR(50) NOT NULL DEFAULT ''
|
|
|
|
|
ALTER TABLE TImpMember ADD FName VARCHAR(50) NOT NULL DEFAULT ''
|
|
|
|
|
ALTER TABLE TImpMember ADD FGender INT NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMember ADD FMobile VARCHAR(50) NOT NULL DEFAULT ''
|
|
|
|
|
ALTER TABLE TImpMember ADD FMemo VARCHAR(1000) DEFAULT ''
|
|
|
|
|
ALTER TABLE TImpMember ADD FArrear DECIMAL(18,6) DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6) DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMember ADD FBirthday DATETIME
|
|
|
|
|
ALTER TABLE TImpMember ADD FBirthdayType CHAR NOT NULL DEFAULT ''
|
|
|
|
|
ALTER TABLE TImpMember ADD FCreateDate DATETIME
|
|
|
|
|
ALTER TABLE TImpMember ADD FExpiredDate DATETIME
|
|
|
|
|
ALTER TABLE TImpMember ADD FCompId BIGINT DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMember ADD FDeleted BIT NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMember ADD FPassword VARCHAR(1000) DEFAULT ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMember ADD FCardNo VARCHAR(50) NOT NULL DEFAULT ''
|
|
|
|
|
ALTER TABLE TImpMember ADD FCardTypeId BIGINT NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMember ADD FBalance DECIMAL(18,6) NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMember ADD FRemainTimes INT NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMember ADD FCardId BIGINT NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMember ADD FCardMemo VARCHAR(1000) NOT NULL DEFAULT ''
|
|
|
|
|
ALTER TABLE TImpMember ADD FCardState INT NOT NULL DEFAULT 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FCardTypeId = abs( CAST( CAST(CAST(CardTypeGUID AS UNIQUEIDENTIFIER) AS BINARY(16)) AS BIGINT))
|
|
|
|
|
|
|
|
|
|
---<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
INSERT 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 = FCardTypeId,
|
|
|
|
|
FNo = CardType,
|
|
|
|
|
FName = CardType,
|
|
|
|
|
1 AS FValueType,
|
|
|
|
|
2 AS FMaterial,
|
|
|
|
|
0 AS FPrice,
|
|
|
|
|
3 AS FAcctId,
|
|
|
|
|
0 AS FDeposit,
|
|
|
|
|
0 as FAcctId2,
|
|
|
|
|
0 AS FDeposit2,
|
|
|
|
|
0 AS FAcctId3,
|
|
|
|
|
0 AS FDeposit3,
|
|
|
|
|
0 AS FTimes,
|
|
|
|
|
0 AS FAlertBalance,
|
|
|
|
|
0 AS FMinRchgAmt,
|
|
|
|
|
0 AS FValidityPeriod,
|
|
|
|
|
0 AS FValidityPeriodUnit,
|
|
|
|
|
1 AS FAllowSale,
|
|
|
|
|
1 AS FAllowRchg,
|
|
|
|
|
1,
|
|
|
|
|
1,
|
|
|
|
|
0 AS FSalePointMode,
|
|
|
|
|
0 AS FSalePointValue,
|
|
|
|
|
0 AS FRchgPointMode,
|
|
|
|
|
0 AS FRchgPointValue
|
|
|
|
|
FROM TImpMember
|
|
|
|
|
GROUP BY CardType,FCardTypeId
|
|
|
|
|
|
|
|
|
|
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 > 1
|
|
|
|
|
AND C.FId != 0
|
|
|
|
|
AND NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId)
|
|
|
|
|
|
|
|
|
|
UPDATE TMemberCardType SET FAllowSale = 1,FAllowRchg = 1
|
|
|
|
|
SELECT * FROM TMemberCardType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
INSERT 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 = FCardTypeId,
|
|
|
|
|
FNo = CardType,
|
|
|
|
|
FName = CardType,
|
|
|
|
|
1 AS FValueType,
|
|
|
|
|
2 AS FMaterial,
|
|
|
|
|
0 AS FPrice,
|
|
|
|
|
3 AS FAcctId,
|
|
|
|
|
0 AS FDeposit,
|
|
|
|
|
0 as FAcctId2,
|
|
|
|
|
0 AS FDeposit2,
|
|
|
|
|
0 AS FAcctId3,
|
|
|
|
|
0 AS FDeposit3,
|
|
|
|
|
0 AS FTimes,
|
|
|
|
|
0 AS FAlertBalance,
|
|
|
|
|
0 AS FMinRchgAmt,
|
|
|
|
|
0 AS FValidityPeriod,
|
|
|
|
|
0 AS FValidityPeriodUnit,
|
|
|
|
|
1 AS FAllowSale,
|
|
|
|
|
1 AS FAllowRchg,
|
|
|
|
|
1,
|
|
|
|
|
1,
|
|
|
|
|
0 AS FSalePointMode,
|
|
|
|
|
0 AS FSalePointValue,
|
|
|
|
|
0 AS FRchgPointMode,
|
|
|
|
|
0 AS FRchgPointValue
|
|
|
|
|
FROM ( Select (SELECT T.Name FROM JiNing_DaFuHao_MeiShow..CardType AS T WHERE T.Id= TypeId) AS CardType, '10000' + CAST(TypeId AS VARCHAR) AS FCardTypeId
|
|
|
|
|
From JiNing_DaFuHao_MeiShow..Card
|
|
|
|
|
WHERE 1=1 And Deleted = 0 And bChain = 0 And IsSell = 1
|
|
|
|
|
GROUP BY TypeId) AS T
|
|
|
|
|
GROUP BY CardType,FCardTypeId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
SELECT * FROM TImpMember WHERE GuestName IS NULL
|
|
|
|
|
|
|
|
|
|
-- <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊɾ<EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FDeleted = 0
|
|
|
|
|
UPDATE TImpMember SET FDeleted = 1 WHERE IsDel = 'true'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>ŵ<EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FCompId = 1
|
|
|
|
|
--<EFBFBD><EFBFBD>ԱID<EFBFBD><EFBFBD><EFBFBD><EFBFBD>100000
|
|
|
|
|
UPDATE TImpMember SET FMemId = abs( CAST( CAST(CAST(GuestCode AS UNIQUEIDENTIFIER) AS BINARY(16)) AS BIGINT))
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FName = ISNULL(ISNULL(GuestName,Mobile),CARDNUM)
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>绰
|
|
|
|
|
UPDATE TImpMember SET FMobile = ISNULL(Mobile,'')
|
|
|
|
|
--<EFBFBD>Ա<EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FGender = CASE WHEN sex = 'true' THEN 1 ELSE 0 END
|
|
|
|
|
--CreateDate
|
|
|
|
|
--<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ID
|
|
|
|
|
UPDATE TImpMember SET FCardId = abs( CAST( CAST(CAST(CardCode AS UNIQUEIDENTIFIER) AS BINARY(16)) AS BIGINT))
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FCardNO = CardNum
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FBalance = Balance
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FPoint = CardPoint
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FCreateDate = AddDate
|
|
|
|
|
--<EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FExpiredDate = EndDate
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMember SET FPassword = ISNULL(CardPsw,'')
|
|
|
|
|
--<EFBFBD><EFBFBD>ע
|
|
|
|
|
UPDATE TImpMember SET FCardMemo = ISNULL(Remark,'') + '<EFBFBD><EFBFBD>' +ShopName+'<EFBFBD><EFBFBD>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FCardState = 1
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMember ADD Chain BIT
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET Chain = 1
|
|
|
|
|
|
|
|
|
|
SELECT top 1 * FROM TImpMember
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TImpMember(FMemId,CardNum,FMemNO,FName,FGender,FMobile,FMemo,FArrear,FPoint,FBirthdayType,FBirthday,FCreateDate,FExpiredDate,FCompId,FDeleted,FPassword,FCardNo,FCardTypeId,FBalance,FCardId,FCardMemo,FCardState,FIndex,Chain)
|
|
|
|
|
SELECT '10000' + CAST(GuestId AS VARCHAR),ContextId,ContextId,GuestName,Sex,PhoneNum,Remark,0,0,'G',NULL,AddDate,OutDate,1,0, Password,ContextId,'10000' + CAST(TypeId AS VARCHAR),Balance,'10000' + CAST(Id AS VARCHAR),ISNULL(Remark,''),1,0,0
|
|
|
|
|
FROM (
|
|
|
|
|
Select ID,(SELECT T.Name FROM JiNing_DaFuHao_MeiShow..CardType AS T WHERE T.Id= TypeId) AS CardType, TypeID, ShopID, CardPoint, ContextID, IsCard, Price, Balance, FactPrice, IsSell, Selling, Locked, Remark, AddDate, OutDate, ServerID, Deleted, GuestID, SellDate, Sellor, RandNum, ValidateNum, FixPrice,
|
|
|
|
|
(Select Top 1 TrueName From JiNing_DaFuHao_MeiShow..Guest Where ID=Card.GuestID) As GuestName,
|
|
|
|
|
(Select Top 1 Sex From JiNing_DaFuHao_MeiShow..Guest Where ID=Card.GuestID) As Sex,
|
|
|
|
|
(Select Top 1 PhoneNum From JiNing_DaFuHao_MeiShow..Guest Where ID=Card.GuestID) As PhoneNum,
|
|
|
|
|
Password, LastConsumeID, LastCashIntegrate, LastCardUsingIntegrate, StartDate, Seller, LastRechargeMoney, SellType, CardCode, bChain, VipNo, (Select Top 1 Coefficient From JiNing_DaFuHao_MeiShow..CardCoefficient Where Deleted = 0 And CardID = Card.ID And IsUse = 1 Order by ConsumeTime Desc,ID Desc) As CardCoeffi, (Select Name from Employee where ID = (Select top 1 designer from JiNing_DaFuHao_MeiShow..Sell where SellID = Card.ID And Type = 1)) as Employee1, (Select Name from Employee where ID = (Select top 1 assistor from JiNing_DaFuHao_MeiShow..Sell where SellID = Card.ID And Type = 1)) as Employee2, (Select Name from Employee where ID = (Select top 1 manager from JiNing_DaFuHao_MeiShow..Sell where SellID = JiNing_DaFuHao_MeiShow..Card.ID And Type = 1)) as Employee3
|
|
|
|
|
|
|
|
|
|
From JiNing_DaFuHao_MeiShow..Card
|
|
|
|
|
WHERE 1=1 And Deleted = 0 And bChain = 0 And IsSell = 1
|
|
|
|
|
|
|
|
|
|
) AS T
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Select ID,(SELECT T.Name FROM JiNing_DaFuHao_MeiShow..CardType AS T WHERE T.Id= TypeId) AS CardType, TypeID, ShopID, CardPoint, ContextID, IsCard, Price, Balance, FactPrice, IsSell, Selling, Locked, Remark, AddDate, OutDate, ServerID, Deleted, GuestID, SellDate, Sellor, RandNum, ValidateNum, FixPrice,
|
|
|
|
|
(Select Top 1 TrueName From JiNing_DaFuHao_MeiShow..Guest Where ID=Card.GuestID) As GuestName,
|
|
|
|
|
(Select Top 1 Sex From JiNing_DaFuHao_MeiShow..Guest Where ID=Card.GuestID) As Sex,
|
|
|
|
|
(Select Top 1 PhoneNum From JiNing_DaFuHao_MeiShow..Guest Where ID=Card.GuestID) As PhoneNum,
|
|
|
|
|
Password, LastConsumeID, LastCashIntegrate, LastCardUsingIntegrate, StartDate, Seller, LastRechargeMoney, SellType, CardCode, bChain, VipNo, (Select Top 1 Coefficient From JiNing_DaFuHao_MeiShow..CardCoefficient Where Deleted = 0 And CardID = Card.ID And IsUse = 1 Order by ConsumeTime Desc,ID Desc) As CardCoeffi, (Select Name from Employee where ID = (Select top 1 designer from JiNing_DaFuHao_MeiShow..Sell where SellID = Card.ID And Type = 1)) as Employee1, (Select Name from Employee where ID = (Select top 1 assistor from JiNing_DaFuHao_MeiShow..Sell where SellID = Card.ID And Type = 1)) as Employee2, (Select Name from Employee where ID = (Select top 1 manager from JiNing_DaFuHao_MeiShow..Sell where SellID = JiNing_DaFuHao_MeiShow..Card.ID And Type = 1)) as Employee3
|
|
|
|
|
|
|
|
|
|
From JiNing_DaFuHao_MeiShow..Card
|
|
|
|
|
WHERE 1=1 And Deleted = 0 And bChain = 0 And IsSell = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMember ADD FSeq INT IDENTITY
|
|
|
|
|
ALTER TABLE TImpMember ADD FIndex INT
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FIndex = 1+(SELECT COUNT(1) FROM TImpMember AS B WHERE A.FCardNo = B.FCardNo AND (A.FCreateDate > B.FCreateDate OR (A.FCreateDate = B.FCreateDate AND (A.FSeq > B.FSeq) )))
|
|
|
|
|
FROM TImpMember AS A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FCardNo = REPLACE(FCardNo,'.1','')
|
|
|
|
|
UPDATE TImpMember SET FCardNo = REPLACE(FCardNo,'.2','')
|
|
|
|
|
UPDATE TImpMember SET FCardNo = REPLACE(FCardNo,'.3','')
|
|
|
|
|
UPDATE TImpMember SET FCardNo = REPLACE(FCardNo,'.4','')
|
|
|
|
|
|
|
|
|
|
SELECT 1 AS FIndex,'A' AS FChar
|
|
|
|
|
INTO #Map
|
|
|
|
|
UNION ALL
|
|
|
|
|
SELECT 2 AS FIndex,'B' AS FChar
|
|
|
|
|
UNION ALL
|
|
|
|
|
SELECT 3 AS FIndex,'C' AS FChar
|
|
|
|
|
UNION ALL
|
|
|
|
|
SELECT 4 AS FIndex,'D' AS FChar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A SET FCardNo = (SELECT FChar FROM #Map WHERE #Map.Findex = A.FIndex) + FCardNo
|
|
|
|
|
FROM TImpMember AS A
|
|
|
|
|
WHERE FCardNo IN( SELECT FCardNo
|
|
|
|
|
FROM TImpMember AS A
|
|
|
|
|
GROUP BY FCardNo
|
|
|
|
|
HAVING(SUM(1) > 1))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>»<EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemNO = B.FCardNo
|
|
|
|
|
FROM TImpMember AS A,TImpMember AS B,(SELECT FMemId,MIN(FIndex) AS FIndex FROM TImpMEMBER GROUP BY FMemId) AS C
|
|
|
|
|
WHERE A.FMemId = B.FMemId
|
|
|
|
|
AND B.FMemId = C.FMemId
|
|
|
|
|
AND B.FIndex =C.FIndex
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE FMemNO = ''
|
|
|
|
|
SELECT * FROM TImpMember WHERE FCardNo = 'A'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT FMemId,SUM(1)
|
|
|
|
|
FROM TImpMember
|
|
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
GROUP BY FMemId
|
|
|
|
|
HAVING(SUM(1) > 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE FCardNo = ''
|
|
|
|
|
|
|
|
|
|
SELECT FMemNO,sum(1)
|
|
|
|
|
FROM TImpMember
|
|
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
GROUP BY FMemNo
|
|
|
|
|
HAVING(SUM(1) > 1)
|
|
|
|
|
|
|
|
|
|
SELECT A.FName,A.FMobile,* FROM Card AS B,Guest AS A
|
|
|
|
|
WHERE B.FCardNo in(
|
|
|
|
|
SELECT FCardNo
|
|
|
|
|
FROM Card
|
|
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
--AND bChain = 0
|
|
|
|
|
GROUP BY FCardNo
|
|
|
|
|
HAVING(SUM(1) > 1)
|
|
|
|
|
)
|
|
|
|
|
AND B.FDeleted = 0
|
|
|
|
|
AND A.FDeleted= 0
|
|
|
|
|
AND A.FMemId = B.FMemId
|
|
|
|
|
ORDER BY FCardNo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) as fcode,
|
|
|
|
|
0 AS FTypeId,
|
|
|
|
|
FCompId AS FCompId,
|
|
|
|
|
MIN(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,
|
|
|
|
|
ISNULL('','') AS FCPW,
|
|
|
|
|
'' AS FQPW,
|
|
|
|
|
0 AS FChargeEmpId,
|
|
|
|
|
SUM(ISNULL( FPoint,0) ) AS FPoint,
|
|
|
|
|
1 AS FRecvConsSMS,
|
|
|
|
|
1 AS FRecvBulkSMS,
|
|
|
|
|
ISNULL('','') AS FMemo,
|
|
|
|
|
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
|
|
|
|
|
--into #t
|
|
|
|
|
from TImpMember
|
|
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
GROUP BY FCompId,FMemId,FMemNo,FName,FMobile,FGender,FBirthdayType,FBirthday
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE #t
|
|
|
|
|
|
|
|
|
|
SELECT FMemNo,sum(1)
|
|
|
|
|
FROM #t
|
|
|
|
|
|
|
|
|
|
GROUP BY FMemNo
|
|
|
|
|
HAVING(SUM(1) > 1)
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember WHERE FMemId = 4632873443776940758
|
|
|
|
|
|
|
|
|
|
SELECT * FROM #T WHERE FMemNO = 'NO2YK20238'
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
FExpiredDate AS FCreateDate,
|
|
|
|
|
FExpiredDate,
|
|
|
|
|
0 AS FTotalTimes,
|
|
|
|
|
0 AS FUsedTimes,
|
|
|
|
|
FCompId AS FSaleCompId,
|
|
|
|
|
0 AS FSaleBillId,
|
|
|
|
|
FCardMemo AS FMemo
|
|
|
|
|
FROM TImpMember
|
|
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
AND FMemId IN(SELECT FMemId FROM TMember)
|
|
|
|
|
GROUP BY FCardNo,FCardTypeId,FCompId ,FMemId,FExpiredDate,FCreateDate,FCardId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemo = B.FMemo,
|
|
|
|
|
A.FExpiredDate = B.FExpiredDate
|
|
|
|
|
FROM TMemberCard AS A,Card AS B
|
|
|
|
|
WHERE A.FCardId = B.FCardId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update TMemberCardAccount SET FExpiredDate = null
|
|
|
|
|
|
|
|
|
|
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 FDeleted = 0
|
|
|
|
|
AND FMemId 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>Excel<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
FROM TImpMember AS A
|
|
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
AND FMemId IN(SELECT FMemId FROM TMember)
|
|
|
|
|
|
|
|
|
|
UPDATE TMemberCardAcctHist SET FMemo = ''
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpTransLog WHERE <EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = 'A020935'
|
|
|
|
|
|
|
|
|
|
update A
|
|
|
|
|
SET A.FMemId
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberCard WHERE FId = 5494058162892437466
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FExpiredDate = B.FExpiredDate
|
|
|
|
|
FROM TMemberCard AS A,TImpMember3 AS B
|
|
|
|
|
WHERE A.FCardId = B.FCardId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember3
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemo = B.Rem
|
|
|
|
|
FROM TMemberCard AS A,TImpMember3 AS B
|
|
|
|
|
WHERE A.FCardId = B.FCardId
|
|
|
|
|
AND B.Rem IS NOT NULL
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberCardType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TMemberCardType SET FId = FNo + 1000 WHERE FId > 0
|
|
|
|
|
|
|
|
|
|
UPDATE TMemberCard SET FTypeId = 0
|
|
|
|
|
|
|
|
|
|
DELETE TMemberCardTypeSUB
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FTypeId = B.CType + 1000
|
|
|
|
|
FROM TMemberCard AS A,TImpMember3 AS B
|
|
|
|
|
WHERE A.FCardId = B.FCardId
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember3 SET FCardTypeId = CType + 1000
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberCard WHERE FMemo != ''
|
|
|
|
|
|
|
|
|
|
delete TImpMember3 where CUSTNO IN(SELECT CUSTNO FROM TImpMember2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM fs.SaiDao_AppServer.dbo.TClient
|
|
|
|
|
|
|
|
|
|
SELECT * FROM card
|
|
|
|
|
WHERE GuestId = 273
|
|
|
|
|
|
|
|
|
|
SELECT GuestId ,SUM(1)
|
|
|
|
|
FROM card GROUP BY GuestId HAVING(SUM(1) > 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM CardType WHERE Deleted = 0
|
|
|
|
|
AND Id NOT IN(SELECT TypeId FROM card WHERE Deleted = 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DELETE TMemberOldTransHist
|
|
|
|
|
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
|
|
|
|
|
SELECT A.ID,M.FMemId,A.AddDate,0,1,'DR',CASE WHEN TypeId = 2 THEN '<EFBFBD><EFBFBD>ֵ' ELSE '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>' END,ContectId,'',0,0,FactTotalMoney,'','',''
|
|
|
|
|
FROM TangShan_FeiLin_MeiShow..ConsumeContext AS A ,
|
|
|
|
|
TangShan_FeiLin_MeiShow..Consume AS B,
|
|
|
|
|
Guest AS M
|
|
|
|
|
WHERE A.CustomerId = M.Id
|
|
|
|
|
AND A.ConsumeId = B.Id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM
|
|
|
|
|
TangShan_FeiLin_MeiShow..Consume
|
|
|
|
|
WHERE CustomerId = 2165
|
|
|
|
|
|
|
|
|
|
SELECT * FROM
|
|
|
|
|
TangShan_FeiLin_MeiShow..ConsumeContext
|
|
|
|
|
WHERE CustomerId = 2165
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberCard WHERE FMemo != ''
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FTypeId = B.FCardTypeId
|
|
|
|
|
FROM TImpMember AS B,TMemberCard AS A
|
|
|
|
|
WHERE A.FCardId = B.FCardId
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FCardMemo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMember WHERE FMemNo IN(SELECT FMemNo FROM JiNing_DaFuHao_FromBOKA.dbo.TMember)
|
|
|
|
|
SELECT * FROM TMember WHERE REPLACE(FMemNo,'A','') IN(SELECT FMemNo FROM JiNing_DaFuHao_FromBOKA.dbo.TMember)
|
|
|
|
|
SELECT * FROM TMember WHERE REPLACE(FMemNo,'B','') IN(SELECT FMemNo FROM JiNing_DaFuHao_FromBOKA.dbo.TMember)
|
|
|
|
|
|
|
|
|
|
EXEC PCopyTable 'TMember','JiNing_DaFuHao_FromBOKA.dbo.TMember',' AND FMemId > 0 and FMemNo NOT IN(SELECT FMemNo FROM TMember )'
|
|
|
|
|
EXEC PCopyTable 'TMemberCard','JiNing_DaFuHao_FromBOKA.dbo.TMemberCard',' AND FCardId > 0 AND FMemId IN(SELECT FMemId FROM TMEMBER) '
|
|
|
|
|
EXEC PCopyTable 'TMemberCardAccount','JiNing_DaFuHao_FromBOKA.dbo.TMemberCardAccount',' AND FCardId > 0 AND FMemId IN(SELECT FMemId FROM TMEMBER)'
|
|
|
|
|
EXEC PCopyTable 'TMemberCardAcctHist','JiNing_DaFuHao_FromBOKA.dbo.TMemberCardAcctHist',' AND FCardId > 0 AND FMemId IN(SELECT FMemId FROM TMEMBER)'
|
|
|
|
|
EXEC PCopyTable 'TMemberEmployee','JiNing_DaFuHao_FromBOKA.dbo.TMemberEmployee',' AND FMemId IN(SELECT FMemId FROM TMEMBER) '
|
|
|
|
|
EXEC PCopyTable 'TMemberPhoto','JiNing_DaFuHao_FromBOKA.dbo.TMemberPhoto',' AND FMemId IN(SELECT FMemId FROM TMEMBER) '
|
|
|
|
|
EXEC PCopyTable 'TMemberPointHist','JiNing_DaFuHao_FromBOKA.dbo.TMemberPointHist',' AND FMemId IN(SELECT FMemId FROM TMEMBER) '
|
|
|
|
|
EXEC PCopyTable 'TMemberTransHist','JiNing_DaFuHao_FromBOKA.dbo.TMemberTransHist',' AND FMemId IN(SELECT FMemId FROM TMEMBER) '
|
|
|
|
|
EXEC PCopyTable 'TMemberTransHistPayment','JiNing_DaFuHao_FromBOKA.dbo.TMemberTransHistPayment',' AND FMemId IN(SELECT FMemId FROM TMEMBER) '
|
|
|
|
|
|
|
|
|
|
EXEC PCopyTable 'TMemberOldTransHist','JiNing_DaFuHao_FromBOKA.dbo.TMemberOldTransHist',' AND FMemId IN(SELECT FMemId FROM TMEMBER) '
|
|
|
|
|
EXEC PCopyTable 'TMemberCardOldAcctHist','JiNing_DaFuHao_FromBOKA.dbo.TMemberCardOldAcctHist',' AND FCardId > 0 AND FMemId IN(SELECT FMemId FROM TMEMBER)'
|
|
|
|
|
|
|
|
|
|
EXEC PCopyTable 'TMemberArrear','JiNing_DaFuHao_FromBOKA.dbo.TMemberArrear',' AND FMemId IN(SELECT FMemId FROM TMEMBER) '
|
|
|
|
|
EXEC PCopyTable 'TMemberRepay','JiNing_DaFuHao_FromBOKA.dbo.TMemberRepay',' AND FMemId IN(SELECT FMemId FROM TMEMBER) '
|
|
|
|
|
EXEC PCopyTable 'TMemberArrearEmployee','JiNing_DaFuHao_FromBOKA.dbo.TMemberArrearEmployee',' AND FMemId IN(SELECT FMemId FROM TMEMBER) '
|
|
|
|
|
|