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.
603 lines
18 KiB
603 lines
18 KiB
|
|
use KunMing_DingSi
|
|
use lijiang_weimeisisong
|
|
|
|
SELECT * FROM imp_member WHERE FMobile = '13097447666'
|
|
|
|
SELECT * FROM imp_member_1 WHERE FMobile = '13097447666'
|
|
|
|
|
|
SELECT count(1) FROM imp_member_card
|
|
|
|
SELECT * FROM imp_member_card_1 WHERE 会员卡号 ='13097447666'
|
|
|
|
|
|
|
|
delete imp_member
|
|
|
|
--删除多导入的重复的
|
|
SELECT 会员卡号,SUM(1)
|
|
FROM imp_member
|
|
GROUP BY 会员卡号
|
|
HAVING SUM(1) > 1
|
|
|
|
|
|
SELECT COUNT(1) FROM imp_member WHERE 登记门店 = 6161
|
|
|
|
ALTER TABLE imp_member ADD FIndex INT IDENTITY(1,1)
|
|
|
|
SELECT * FROM imp_member
|
|
|
|
SELECT SUM(CAST(卡内余额 AS FLOAT))
|
|
FROM imp_member
|
|
|
|
select count(1) from imp_member WHERE isnull (卡,'') =''
|
|
|
|
|
|
|
|
DELETE A
|
|
FROM imp_member AS A,(
|
|
SELECT 会员姓名,会员卡号,性别,生日,电话手机,卡类型,登记门店,卡内余额,目前积分,累计充值,MAX(FIndex) AS FIndex
|
|
FROM imp_member
|
|
GROUP BY 会员姓名,会员卡号,性别,生日,电话手机,卡类型,登记门店,卡内余额,目前积分,累计充值) AS B
|
|
WHERE A.会员姓名 = B.会员姓名
|
|
AND A.会员卡号 = B.会员卡号
|
|
AND A.性别 = B.性别
|
|
AND A.生日 = B.生日
|
|
AND A.电话手机 = B.电话手机
|
|
AND A.卡类型 = B.卡类型
|
|
AND A.登记门店 = B.登记门店
|
|
AND A.卡内余额 = B.卡内余额
|
|
AND A.目前积分 = B.目前积分
|
|
AND A.累计充值 = B.累计充值
|
|
AND A.FIndex != B.FIndex
|
|
|
|
|
|
--添加没有的
|
|
insert imp_member_card(会员卡号,卡内余额,卡类型)
|
|
SELECT 会员卡号,卡内余额,卡类型 FROM imp_member WHERE ISNULL(卡,'') = ''
|
|
AND 会员卡号 NOT IN(SELECT 会员卡号 FROM imp_member_card)
|
|
|
|
|
|
ALTER TABLE imp_member_card ADD FCardKind VARCHAR(100)
|
|
|
|
UPDATE imp_member_card SET FCardKind = 'Money'
|
|
WHERE (卡内余额 NOT LIKE '%天%' AND 卡内余额 NOT LIKE '%次%' AND 卡内余额 LIKE '%元%')
|
|
OR (卡内余额 NOT LIKE '%天%' AND 卡内余额 NOT LIKE '%次%' AND 卡内余额 NOT LIKE '%元%')
|
|
|
|
|
|
UPDATE imp_member_card SET FCardKind = 'Course' WHERE FCardKind IS NULL
|
|
|
|
|
|
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 =dbo.FNNewId(), FCardTypeName,FCardTypeName,1,FMaterial = 2,0,FCardFeeAmt = 0,FAcctId = 3,FDeposit = 0,FAcctId2 = 0,FDeposit2 = 0 ,FAcctId3 = 0,FDeposit3 = 0,
|
|
FTimes = 0,FAlertBalance = 0,FMinRchgAmt = 0,FSalePointMode = 0,FSalePointValue = 0 ,FRchgPointMode = 0,FRchgPointValue = 0,FPaySmsFee = 0,FTimeCard = 0,FValidityPeriod = 100,FValidityPeriodUnit = 1,
|
|
FExpiredDate = NULL,FDefaultMemo = '',FCreateTime = GETDATE(),1,1,FDeptId = 0,FEnabled =1,FOrder = 1
|
|
FROM (
|
|
SELECT 卡类型 AS FCardTypeName FROM imp_member_card
|
|
WHERE FCardKind = 'Money'
|
|
) AS A
|
|
WHERE FCardTypeName NOT IN(SELECT FNo FROM TMemberCardType)
|
|
GROUP BY FCardTypeName
|
|
|
|
|
|
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 C.FNo = '009'
|
|
AND NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId)
|
|
|
|
|
|
|
|
INSERT INTO TMemberCardTypeSub(FId,FCompId,FCardTypeId,FAllowSale,FAllowRchg,FEnabled)
|
|
SELECT FId,dbo.FNCompId('001'),I.FId,1,1,1
|
|
FROM TMemberCardType AS I
|
|
WHERE FId NOT IN(SELECT FCardTypeId FROM TMemberCardTypeSub)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_member ADD FCardTypeName VARCHAR(100)
|
|
ALTER TABLE imp_member ADD FMemId BIGINT
|
|
ALTER TABLE imp_member ADD FMemNo VARCHAR(50)
|
|
ALTER TABLE imp_member ADD FCardNo VARCHAR(50)
|
|
ALTER TABLE imp_member ADD FName VARCHAR(50)
|
|
ALTER TABLE imp_member ADD FGender INT
|
|
ALTER TABLE imp_member ADD FCardState INT
|
|
ALTER TABLE imp_member ADD FMobile VARCHAR(50)
|
|
ALTER TABLE imp_member ADD FCardTypeId BIGINT
|
|
ALTER TABLE imp_member ADD FCourseId BIGINT
|
|
ALTER TABLE imp_member ADD FBalance DECIMAL(18,6)
|
|
ALTER TABLE imp_member ADD FBalance2 DECIMAL(18,6)
|
|
ALTER TABLE imp_member ADD FRemainTimes INT
|
|
ALTER TABLE imp_member ADD FPurTimes INT
|
|
ALTER TABLE imp_member ADD FPurAmount DECIMAL(18,6)
|
|
ALTER TABLE imp_member ADD FItemId BIGINT
|
|
ALTER TABLE imp_member ADD FCreateDate DATETIME
|
|
ALTER TABLE imp_member ADD FExpiredDate DATETIME
|
|
ALTER TABLE imp_member ADD FCompId BIGINT
|
|
ALTER TABLE imp_member ADD FCardId BIGINT
|
|
ALTER TABLE imp_member ADD FMemo VARCHAR(1000)
|
|
ALTER TABLE imp_member ADD FArrear DECIMAL(18,6)
|
|
ALTER TABLE imp_member ADD FPoint DECIMAL(18,6)
|
|
ALTER TABLE imp_member ADD FState INT
|
|
ALTER TABLE imp_member ADD FDeleted BIT
|
|
ALTER TABLE imp_member ADD FBirthday DATETIME
|
|
ALTER TABLE imp_member ADD FBirthdayType CHAR
|
|
|
|
UPDATE imp_member_card SET FCompId = 1
|
|
|
|
SELECT * FROM TCompany
|
|
|
|
UPDATE A
|
|
SET A.FCompId = B.FId
|
|
FROM imp_member AS A,TCompany AS B
|
|
WHERE A.登记门店 = B.FWebsite
|
|
|
|
SELECT * FROM imp_member WHERE FCompId IS NULL
|
|
|
|
UPDATE imp_member_card SET FCompId = 1
|
|
|
|
SELECT * FROM TCompany
|
|
|
|
|
|
UPDATE imp_member SET FMemId = dbo.FNNewId() WHERE FMemId IS NULL
|
|
UPDATE imp_member SET FCardid = dbo.FNNewId() WHERE FCardid IS NULL
|
|
UPDATE imp_member SET FMemNo = 会员卡号
|
|
UPDATE imp_member SET FCardNo = 会员卡号
|
|
UPDATE imp_member SET FCreateDate = 登记时间
|
|
UPDATE imp_member SET FExpiredDate = DATEADD(YEAR,100,登记时间)
|
|
|
|
|
|
UPDATE imp_member SET FBalance = CAST(REPLACE(卡内余额,',','') AS FLOAT)
|
|
|
|
SELECT 卡内余额 FROM imp_member
|
|
|
|
|
|
|
|
UPDATE imp_member SET FMobile = 电话手机
|
|
UPDATE imp_member SET FName = 会员姓名
|
|
UPDATE imp_member SET FGender = CASE WHEN 性别= '男' THEN 1 ELSE 0 END
|
|
UPDATE imp_member SET FBirthdayType = 'G'
|
|
UPDATE imp_member SET FState = 1
|
|
UPDATE imp_member SET FState = 4 WHERE 备注 like '%卡已注销%'
|
|
UPDATE imp_member SET Fpoint = REPLACE(目前积分,',','')
|
|
UPDATE imp_member SET FMemo = 备注
|
|
UPDATE imp_member SET FCompId = dbo.FNCompID('001')
|
|
UPDATE imp_member SET FDeleted = 0
|
|
|
|
|
|
|
|
ALTER TABLE imp_member_card ADD FCardNo VARCHAR(50)
|
|
ALTER TABLE imp_member_card ADD FCardId BIGINT
|
|
ALTER TABLE imp_member_card ADD FCompId BIGINT
|
|
ALTER TABLE imp_member_card ADD FMemId BIGINT
|
|
ALTER TABLE imp_member_card ADD FCardTypeId BIGINT
|
|
ALTER TABLE imp_member_card ADD FDeleted BIT
|
|
ALTER TABLE imp_member_card ADD FCreateDate DATETIME
|
|
ALTER TABLE imp_member_card ADD FExpiredDate DATETIME
|
|
ALTER TABLE imp_member_card ADD FBalance DECIMAL(18,6)
|
|
ALTER TABLE imp_member_card ADD FRemainTimes DECIMAL(18,6)
|
|
ALTER TABLE imp_member_card ADD FCardTypeName VARCHAR(50)
|
|
|
|
UPDATE imp_member_card SET FCardTypeName =卡类型
|
|
UPDATE imp_member_card SET FDeleted =0
|
|
|
|
|
|
ALTER TABLE imp_member ALTER COLUMN 会员卡号 VARCHAR(100)
|
|
ALTER TABLE imp_member_card ALTER COLUMN 会员卡号 VARCHAR(100)
|
|
|
|
CREATE INDEX IX_IMPMEMBER_NO ON imp_member (会员卡号)
|
|
CREATE INDEX IX_IMPMEMBER_CARD_NO ON imp_member_card (会员卡号)
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE #Card
|
|
|
|
SELECT * FROM #Card
|
|
|
|
|
|
--卡类别
|
|
UPDATE A
|
|
SET A.FCardTypeID = B.FId
|
|
FROM imp_member_card AS A,TMemberCardType AS B
|
|
WHERE A.FCardTypeName = B.FName
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_card WHERE FCardTypeId IS NULL
|
|
|
|
--卡ID
|
|
UPDATE imp_member_card SET FCardId = dbo.FNNewId() WHERE FCardid is null
|
|
|
|
|
|
--会员ID
|
|
UPDATE A
|
|
SET A.FMemId = B.FMemId
|
|
FROM imp_member_card AS A,imp_member AS B
|
|
WHERE A.会员卡号 = B.会员卡号
|
|
|
|
--门店
|
|
UPDATE A
|
|
SET A.FCompId = B.FCompId
|
|
FROM imp_member_card AS A,imp_member AS B
|
|
WHERE B.FMemId = A.FMemId
|
|
|
|
UPDATE imp_member_card SET FCreateDate = 登记日期,FExpiredDate = 有效日期
|
|
UPDATE A
|
|
SET A.FCreateDate = B.FCreateDate,
|
|
a.FExpiredDate = dateadd(year,100,B.FCreateDate)
|
|
FROM imp_member_card AS A,imp_member AS B
|
|
WHERE A.FMemId= B.FMemId
|
|
AND A.FCreateDate IS NULL
|
|
|
|
|
|
--余额
|
|
UPDATE imp_member_card SET FBalance = 0
|
|
|
|
UPDATE imp_member_card SET FBalance = CAST(REPLACE(REPLACE(卡内余额,'元',''),',','') AS FLOAT)
|
|
WHERE FCardKind = 'Money'
|
|
|
|
|
|
UPDATE imp_member_card SET FRemainTimes = CAST(REPLACE(卡内余额,'次','') AS FLOAT)
|
|
WHERE 卡内余额 LIKE '%次%'
|
|
|
|
UPDATE imp_member_card SET FRemainTimes = 0
|
|
WHERE 卡内余额 LIKE '%天%'
|
|
|
|
|
|
UPDATE imp_member_card SET fcompid=1
|
|
|
|
update imp_member_card SET FCardNo = 会员卡号
|
|
|
|
--卡类型相同,设置为主卡
|
|
ALTER TABLE imp_member_card ADD FIsMaster BIT
|
|
UPDATE imp_member_card SET FIsMaster = 0
|
|
|
|
UPDATE A
|
|
SET A.FIsMaster = 1
|
|
FROM imp_member_card AS A,imp_member AS B
|
|
WHERE A.会员卡号 = B.会员卡号
|
|
and A.卡类型 = B.卡类型
|
|
|
|
|
|
|
|
DROP TABLE #Card
|
|
|
|
|
|
SELECT FCardNo
|
|
INTO #Card
|
|
FROM imp_member_card
|
|
WHERE FDeleted = 0
|
|
GROUP BY fcardNo
|
|
HAVING(SUM(1)) > 1
|
|
|
|
ALTER TABLE imp_member_card ADD FSeq INT IDENTITY(1,1)
|
|
ALTER TABLE imp_member_card ADD FCardIndex INT
|
|
|
|
CREATE INDEX IDX_imp_member_card_SEQ ON imp_member_card(FSeq)
|
|
|
|
UPDATE imp_member_card SET FCardIndex = 0
|
|
|
|
UPDATE A
|
|
SET A.FCardIndex = 1+ (SELECT COUNT(1) FROM imp_member_card AS B WHERE B.会员卡号 = A.会员卡号 AND (B.FIsMaster > A.FIsMaster OR B.FSeq > A.FSeq) )
|
|
FROM imp_member_card AS A
|
|
WHERE FCardNo IN(SELECT FCardNo FROM #Card)
|
|
AND A.FIsMaster = 0
|
|
|
|
|
|
update imp_member_card SET FCardNo = FCardNo + '.' + CAST(FCardINdex as varchar)
|
|
WHERE FCardNo IN(SELECT FCardNo FROM #Card)
|
|
AND FIsMaster = 0
|
|
|
|
|
|
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,
|
|
FBirthdayType 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,
|
|
FPoint AS FPoint,
|
|
1 AS FRecvConsSMS,
|
|
1 AS FRecvBulkSMS,
|
|
ISNULL(FMemo,'') AS FMemo,
|
|
'从博妍入' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
|
|
from imp_member
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
|
|
|
|
INSERT INTO TMemberCard(
|
|
FCardId,
|
|
FCardNo,
|
|
|
|
FTypeId,
|
|
FValueType,
|
|
FCompId,
|
|
FMemId,
|
|
FState,
|
|
FCreateDate,
|
|
FExpiredDate,
|
|
FTotalTimes,
|
|
FUsedTimes,
|
|
FSaleCompId,
|
|
FSaleBillId,
|
|
FMemo)
|
|
SELECT
|
|
FCardId AS FId,
|
|
FCardNo AS FNo,
|
|
|
|
FCardTypeId AS FTypeId,
|
|
(SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
|
|
FCompId AS FCompId,
|
|
FMemId AS FMemId,
|
|
1 AS FState,
|
|
FCreateDate AS FCreateDate,
|
|
FExpiredDate AS FExpiredDate,
|
|
0 AS FTotalTimes,
|
|
0 AS FUsedTimes,
|
|
FCompId AS FSaleCompId,
|
|
0 AS FSaleBillId,
|
|
ISNULL('','') AS FMemo
|
|
FROM imp_member_card
|
|
WHERE FDeleted = 0
|
|
AND FCardKind = 'Money'
|
|
AND FCardId NOT IN(SELECT FCardId FROM TMemberCard)
|
|
|
|
|
|
|
|
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
|
|
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,3,CAST(FBalance AS FLOAT),CAST(FBalance AS FLOAT),0,FCreateDate,NULL AS FExpiredDate,''
|
|
FROM imp_member_card AS A
|
|
WHERE FCardKind = 'Money'
|
|
and FDeleted = 0
|
|
AND FCardId NOT IN(SELECT FCardId FROM TMemberCardAccount)
|
|
|
|
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,'',CAST(FBalance AS FLOAT),0,CAST(FBalance AS FLOAT),0,getdate(),'从博妍中导入'
|
|
FROM imp_member_card AS A
|
|
WHERE FCardKind = 'Money'
|
|
and FDeleted = 0
|
|
AND FCardId NOT IN(SELECT FCardId FROM TMemberCardAcctHist)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,'',FPoint,0,FPoint,'',getdate()
|
|
FROM imp_member AS A WHERE FPoint != 0
|
|
|
|
|
|
|
|
--交易历史
|
|
|
|
ALTER TABLE imp_member_rchg_hist ADD FMemId BIGINT
|
|
ALTER TABLE imp_member_rchg_hist ADD FCardId BIGINT
|
|
ALTER TABLE imp_member_rchg_hist ADD FCompId BIGINT
|
|
|
|
ALTER TABLE imp_member_cons_hist ADD FMemId BIGINT
|
|
ALTER TABLE imp_member_cons_hist ADD FCardId BIGINT
|
|
ALTER TABLE imp_member_cons_hist ADD FCompId BIGINT
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FMemId,
|
|
A.FCardId = B.FCardId,
|
|
A.FCompId = B.FCompId
|
|
FROM imp_member_rchg_hist AS A,imp_member AS B
|
|
WHERE A.会员卡号= B.会员卡号
|
|
|
|
UPDATE A
|
|
SET A.FMemId = B.FMemId,
|
|
A.FCardId = B.FCardId,
|
|
A.FCompId = B.FCompId
|
|
FROM imp_member_cons_hist AS A,imp_member AS B
|
|
WHERE A.会员卡号= B.会员卡号
|
|
|
|
|
|
TRUNCATE TABLE imp_member_cons_hist
|
|
TRUNCATE TABLE imp_member_rchg_hist
|
|
|
|
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
|
|
SELECT DBO.FNNewId(),A.FMemId,A.充值时间,A.FCardId,A.FCompId,'DR','充值','','[充值]' +卡类型,充值金额,1,充值金额,充值方式,'',''
|
|
FROM imp_member_rchg_hist AS A
|
|
WHERE ISNULL(FMemId,0) != 0
|
|
|
|
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
|
|
SELECT DBO.FNNewId(),A.FMemId,A.登记时间,A.FCardId,A.FCompId,'DR','消费',流水单号,'[消费]' + 消费项目,消费金额,1,消费金额,消费方式,'',''
|
|
FROM imp_member_cons_hist AS A
|
|
WHERE ISNULL(FMemId,0) != 0
|
|
|
|
UPDATE TMemberOldTransHist SET FContent = '['+FBizType+']' + FContent WHERE FMemId IN(SELECT FMemId FROM imp_member)
|
|
|
|
|
|
DELETE A
|
|
FROM imp_member_cons_hist AS A,(SELECT 消费项目,会员卡号,流水单号,登记时间,MIN(FSeq)
|
|
FROM imp_member_cons_hist
|
|
GROUP BY 消费项目,会员卡号,流水单号,登记时间 ) AS B
|
|
WHERE A.会员卡号 = B.会员卡号
|
|
AND A.消费项目 = B.消费项目
|
|
AND A.流水单号 = B.流水单号
|
|
AND A.登记时间 = B.登记时间
|
|
AND A.FSeq != B.FSeq
|
|
|
|
UPDATE T
|
|
|
|
ALTER TABLE imp_member_cons_hist ALTER COLUMN 会员卡号 VARCHAR(100) NOT NULL
|
|
ALTER TABLE imp_member_rchg_hist ALTER COLUMN 会员卡号 VARCHAR(100) NOT NULL
|
|
|
|
|
|
ALTER TABLE imp_member_cons_hist ADD FSeq INT IDENTITY(1,1)
|
|
ALTER TABLE imp_member_rchg_hist ADD FSeq INT IDENTITY(1,1)
|
|
|
|
DELETE TMemberOldTransHist WHERE FMemId IN(SELECT FMemId FROM imp_member)
|
|
|
|
CREATE INDEX IX_imp_memberRchgHist_CardNo ON imp_member_rchg_hist(会员卡号)
|
|
CREATE INDEX IX_imp_memberConsHist_CardNo ON imp_member_cons_hist(会员卡号)
|
|
|
|
--疗程
|
|
SELECT dbo.FNNewId() AS FId,dbo.FNNewId() AS FCourseId,FNo,FName
|
|
|
|
CREATE TABLE TImpItem
|
|
(
|
|
FId BIGINT,
|
|
FCourseId BIGINT,
|
|
FNo VARCHAR(MAX),
|
|
FName VARCHAR(MAX)
|
|
)
|
|
INSERT INTO TImpItem(FId,FCourseId,FNo,FName)
|
|
SELECT dbo.FNNewId() AS FId,dbo.FNNewId() AS FCourseId,FNo,FName
|
|
|
|
FROM (
|
|
select 卡类型 AS FNo, 卡类型 AS FName
|
|
from imp_member_card
|
|
WHERE ISNULL(FCardKind,'') = 'Course'
|
|
AND 卡类型 NOT IN(SELECT FName FROM TCourse)
|
|
GROUP BY 卡类型
|
|
|
|
) AS A
|
|
GROUP BY FNo,FName
|
|
|
|
|
|
select 卡类型 AS FNo, 卡类型 AS FName
|
|
from imp_member_card
|
|
WHERE 卡内余额 LIKE '%次%'
|
|
AND 卡类型 NOT IN(SELECT FName FROM TCourse)
|
|
GROUP BY 卡类型
|
|
|
|
|
|
|
|
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
|
|
WHERE FId NOT IN(SELECT FId FROM TItem)
|
|
|
|
|
|
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
|
|
SELECT FCourseId AS FId,
|
|
A.FNo + 'L1',
|
|
A.FName AS FName,
|
|
'' AS FBriefCode,
|
|
A.FId AS FItemId,
|
|
0 AS FPackId,
|
|
1 AS FSequence,
|
|
(SELECT TOP 1 FId FROM TBasicType WHERE FKey = 'CourseType') AS FTypeId,
|
|
1 AS FTimes,
|
|
0 AS FFreeTimes,
|
|
0 AS FDurable,
|
|
0 AS FValidityPeriodUnit,
|
|
0 AS FValidityPeriod,
|
|
getdate() AS FCreateDate,
|
|
NULL AS FExpiredDate,
|
|
'' AS FDescription,
|
|
1 AS FEnabled,
|
|
0 AS FPrice,
|
|
0 AS FAmount,
|
|
1 AS FCalcMode
|
|
FROM TImpItem AS A
|
|
WHERE FId NOT IN(SELECT FItemId FROM TCourse)
|
|
|
|
|
|
ALTER TABLE imp_member_card ADD FItemId BIGINT
|
|
|
|
UPDATE A
|
|
SET A.FItemId = B.FId,
|
|
A.FCardTypeId = B.FCourseId
|
|
FROM TImpItem AS B,imp_member_card AS A
|
|
WHERE B.FNo = A.卡类型
|
|
AND A.FCardKind = 'Course'
|
|
|
|
|
|
SELECT * FROM imp_member_card
|
|
|
|
ALTER TABLE imp_member_card ADD FMemo VARCHAR(1000)
|
|
|
|
update imp_member_card SET FMemo = ''
|
|
|
|
update imp_member_card SET FMemo = 卡内余额 WHERE 卡内余额 LIKE '%天%'
|
|
|
|
|
|
--疗程
|
|
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,FRemainTimes,0,0,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,FMemo,1,0
|
|
FROM imp_member_card AS A
|
|
WHERE FCardKind = 'Course'
|
|
|
|
|
|
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(),FRemainTimes,0,0,0,FCompId,'DR','Import',0,'',0,getdate()
|
|
FROM imp_member_card AS A
|
|
WHERE FCardKind = 'Course'
|
|
|
|
|
|
DELETE TMemberCardType WHERE FName NO
|
|
|
|
SELECT * FROM imp_memberConsHist_1
|
|
|
|
SELECT * FROM imp_member_card
|
|
|
|
|
|
use KunMing_ALa_TuQiaoDian
|
|
|
|
|
|
|
|
|
|
select replace('bc 06 88 d7 30 dd de 85 bc 71 d8 86 1d 5d 8b c7 22 14 dd ae',' ','')
|
|
|
|
|
|
|
|
DELETE TMember WHERE FMemId IN(SELECT FMemId FROM imp_member)
|
|
|
|
DELETE TMemberCardAccount WHERE FMemId IN(SELECT FMemId FROM imp_member)
|
|
|
|
DELETE TMemberOldTransHist WHERE FMemId IN(SELECT FMemId FROM imp_member)
|
|
|
|
DELETE TItem WHERE FId IN(SELECT FId FROM TImpItem)
|
|
DELETE TItemSub WHERE FItemId IN(SELECT FId FROM TImpItem)
|
|
DELETE TCourse WHERE FItemId IN(SELECT FId FROM TImpItem)
|
|
|
|
DELETE TMemberCardType WHERE FId > 9
|
|
|
|
DELETE TMemberCardTypesUB
|
|
|
|
|
|
DROP TABLE imp_member_cons_hist
|
|
|
|
DELETE TImpItem
|
|
|
|
SELECT * FROM sysobjects WHERE name like 'TImp%'
|
|
|