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.
757 lines
22 KiB
757 lines
22 KiB
use xianning_xinghaian
|
|
use kunming_gejiuwenfeng
|
|
|
|
drop table imp_member
|
|
drop table imp_member_card
|
|
|
|
SELECT COUNT(1) FROM imp_member_card
|
|
SELECT COUNT(1) FROM imp_member
|
|
|
|
SELECT * FROM imp_member
|
|
SELECT * FROM imp_member_card
|
|
|
|
UPDATE imp_member SET 消费次数 = 当前积分,当前积分 = 最后消费日,最后消费日= 卡账户信息
|
|
where 当前积分 like '%次%'
|
|
|
|
SELECT * FROM imp_member where 当前积分 like '%次%'
|
|
|
|
SELECT MemId,SUM(1)
|
|
FROM imp_member_card
|
|
GROUP BY MemId
|
|
HAVING(SUM(1)) > 1
|
|
|
|
|
|
DROP TABLE imp_card_type
|
|
CREATE TABLE imp_card_type
|
|
(
|
|
FId BIGINT,
|
|
FNo VARCHAR(50),
|
|
FName VARCHAR(50),
|
|
FType VARCHAR(50),
|
|
FValueType INT
|
|
)
|
|
|
|
ALTER TABLE imp_member_card ADD FCardTypeName VARCHAR(100)
|
|
|
|
ALTER TABLE imp_member ADD FMemId BIGINT
|
|
ALTER TABLE imp_member_card ADD FMemId BIGINT
|
|
ALTER TABLE imp_member_card ADD FCardNo VARCHAR(50)
|
|
ALTER TABLE imp_member ADD FMemNo VARCHAR(50)
|
|
ALTER TABLE imp_member ADD FName VARCHAR(50)
|
|
ALTER TABLE imp_member ADD FGender INT
|
|
ALTER TABLE imp_member ADD FMobile VARCHAR(50)
|
|
ALTER TABLE imp_member ADD FCreateDate DATETIME
|
|
|
|
ALTER TABLE imp_member_card ADD FCardTypeId BIGINT
|
|
ALTER TABLE imp_member_card ADD FCourseId BIGINT
|
|
ALTER TABLE imp_member_card ADD FBalance DECIMAL(18,6)
|
|
ALTER TABLE imp_member_card ADD FBalance2 DECIMAL(18,6)
|
|
ALTER TABLE imp_member_card ADD FRemainTimes INT
|
|
ALTER TABLE imp_member_card ADD FPurTimes INT
|
|
ALTER TABLE imp_member_card ADD FPurAmount DECIMAL(18,6)
|
|
ALTER TABLE imp_member_card ADD FItemId BIGINT
|
|
ALTER TABLE imp_member_card ADD FCreateDate DATETIME
|
|
ALTER TABLE imp_member_card ADD FExpiredDate DATETIME
|
|
ALTER TABLE imp_member ADD FCompId BIGINT
|
|
ALTER TABLE imp_member_card ADD FCompId BIGINT
|
|
ALTER TABLE imp_member_card ADD FCardId BIGINT
|
|
ALTER TABLE imp_member ADD FMemo VARCHAR(1000)
|
|
ALTER TABLE imp_member_card 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 FBirthday DATETIME
|
|
ALTER TABLE imp_member ADD FBirthdayType CHAR
|
|
ALTER TABLE imp_member ADD FCustom1 VARCHAR(100)
|
|
ALTER TABLE imp_member ADD FPointText VARCHAR(100)
|
|
ALTER TABLE imp_member ADD FDeleted Bit
|
|
ALTER TABLE imp_member_card ADD FDeleted Bit
|
|
|
|
ALTER TABLE imp_memberCourseDetail ADD FCardTypeId BIGINT
|
|
ALTER TABLE imp_memberCourseDetail ADD FItemId BIGINT
|
|
|
|
|
|
ALTER TABLE imp_memberCourseDetail ADD FRemainTimes INT
|
|
ALTER TABLE imp_memberCourseDetail ADD FPurTimes INT
|
|
ALTER TABLE imp_memberCourseDetail ADD FUsedTimes INT
|
|
ALTER TABLE imp_memberCourseDetail ADD FPurAmount DECIMAL(18,6)
|
|
ALTER TABLE imp_memberCourseDetail ADD FAdjustPrice DECIMAL(18,6)
|
|
|
|
ALTER TABLE imp_memberCourseDetail ADD FCreateDate DATETIME
|
|
ALTER TABLE imp_memberCourseDetail ADD FExpiredDate DATETIME
|
|
|
|
ALTER TABLE imp_memberCourseDetail ADD FCompId BIGINT
|
|
ALTER TABLE imp_memberCourseDetail ADD FCardId BIGINT
|
|
ALTER TABLE imp_memberCourseDetail ADD FMemId BIGINT
|
|
ALTER TABLE imp_memberCourseDetail ADD FMemo VARCHAR(1000)
|
|
ALTER TABLE imp_memberCourseDetail ADD FDeleted BIT
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_card
|
|
WHERE storeName LIKE '%白鹭%' OR storeName LIKE '%北门店%'
|
|
|
|
SELECT storeId,storeName FROM imp_member_card
|
|
GROUP BY storeId,storeName
|
|
|
|
DELETE imp_member_card WHERE storeId = 3752
|
|
|
|
|
|
--初始化卡类别
|
|
UPDATE imp_member_card SET FCardTYpeName = memberLevelName + '[' + projectDiscount + '折]'
|
|
|
|
SELECT * FROM imp_Member_course
|
|
|
|
DELETE imp_card_type
|
|
INSERT imp_card_type(FId,FNo,FName,FValueType)
|
|
SELECT dbo.FNNewId(),FCardTYpeName,FCardTYpeName , 1
|
|
FROM imp_member_card
|
|
WHERE FCardTYpeName IS NOT NULL
|
|
AND FCardTYpeName NOT IN(SELECT FName FROM imp_card_type)
|
|
GROUP BY FCardTYpeName
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member SET FDeleted = 0
|
|
UPDATE imp_member_card SET FDeleted = 0
|
|
UPDATE imp_member_card SET FDeleted = 1 WHERE deleted = 1
|
|
UPDATE imp_member SET FDeleted = 1 WHERE deleted = 1
|
|
|
|
|
|
SELECT * FROM imp_member_card WHERE FMemo IS NULL
|
|
|
|
|
|
|
|
-- INSERT INTO TCompany(FId,FNo,FName,FAbbr,FAddress,FTelephone,FEmail,FWebSite,FWeChatNo,FWeChatQRCode,FIntroduction,FAdmin,FIsCenter,FParentId)
|
|
SELECT storeId,storeId,storeName,storeName,'','','','','','','','',0,1
|
|
FROM imp_member_card
|
|
GROUP BY storeId,storeName
|
|
|
|
|
|
--门店
|
|
SELECT * FROM TCompany
|
|
|
|
|
|
UPDATE imp_member_card SET FCompId = dbo.FNCompId('010')
|
|
|
|
UPDATE imp_member SET FCompId = dbo.FNCompId('002') WHERE storeName LIKE '%文峰美容美发中山店%'
|
|
UPDATE imp_member_card SET FCompId = dbo.FNCompId('002') WHERE storeName LIKE '%文峰美容美发中山店%'
|
|
|
|
UPDATE imp_member SET FCompId = dbo.FNCompId('001') WHERE storeName LIKE '%文峰美容美发精致店%'
|
|
UPDATE imp_member_card SET FCompId = dbo.FNCompId('001') WHERE storeName LIKE '%文峰美容美发精致店%'
|
|
|
|
UPDATE imp_member SET FCompId = dbo.FNCompId('001') WHERE storeName LIKE '%优美造型美容%'
|
|
UPDATE imp_member_card SET FCompId = dbo.FNCompId('001') WHERE storeName LIKE '%优美造型美容%'
|
|
|
|
select * from imp_memberCourseDetail WHERE recordId = 128622
|
|
select * from imp_member_Course WHERE recordId = 128622
|
|
|
|
ALTER TABLE imp_memberCourseDetail ADD storeId BIGINT
|
|
UPDATE A
|
|
SET A.storeId = B.storeId
|
|
FROM imp_memberCourseDetail AS A,imp_memberCourse AS B
|
|
WHERE A.recordId = B.recordId
|
|
|
|
|
|
UPDATE imp_memberCourseDetail SET FCompId = dbo.FNCompId('002') WHERE storeId = '3024'
|
|
UPDATE imp_memberCourseDetail SET FCompId = dbo.FNCompId('001') WHERE storeId = '3023'
|
|
UPDATE imp_memberCourseDetail SET FCompId = dbo.FNCompId('001') WHERE storeId = '3027'
|
|
|
|
|
|
UPDATE imp_member SET FDeleted = 1 WHERE FCompId IS NULL
|
|
UPDATE imp_member_card SET FDeleted = 1 WHERE FCompId IS NULL
|
|
|
|
|
|
--会员ID
|
|
UPDATE imp_member SET FMemId = id
|
|
UPDATE imp_member_card SET FMemId = memberId
|
|
|
|
|
|
--积分
|
|
UPDATE imp_member SET FPoint = balanceIntegral
|
|
|
|
select * from imp_member_card
|
|
--开卡日期
|
|
UPDATE imp_member SET FCreateDate = createTime
|
|
|
|
UPDATE imp_member_card SET FCreateDate = createTime
|
|
|
|
UPDATE imp_member_card SET endDate = REPLACE(endDate,'-02-29','-02-28')
|
|
WHERE endDate LIKE '%02-29'
|
|
|
|
UPDATE imp_member_card SET FExpiredDate = endDate WHERE endDate != '' AND endDate < '9'
|
|
|
|
|
|
UPDATE imp_member_card SET FExpiredDate = DATEADD(YEAR,100,FCreateDate) WHERE FExpiredDate IS NULL
|
|
|
|
SELECT * FROM imp_member_card WHERE FDeleted = 0 AND FCardNo = ''
|
|
|
|
--处理卡号
|
|
UPDATE imp_member_card SET FCardNo = cardNo
|
|
|
|
|
|
--空卡号
|
|
UPDATE A
|
|
SET A.FCardNo = B.Phone
|
|
FROM imp_member_card AS A,imp_member AS B
|
|
WHERE A.MemberId = B.memberId
|
|
AND A.FDeleted = 0
|
|
AND B.FDeleted = 0
|
|
AND A.FCardNo = ''
|
|
|
|
|
|
--处理重复卡号
|
|
DROP TABLE #Card
|
|
|
|
SELECT FCardNo into #Card
|
|
FROM imp_member_card
|
|
WHERE FDeleted= 0
|
|
GROUP BY FCardNo
|
|
HAVING(SUM(1)) > 1
|
|
|
|
SELECT * FROM imp_member_card WHERE FCardNo = '8882200992'
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_member_card ADD FSeq INT IDENTITY
|
|
ALTER TABLE imp_member_card ADD FIndex INT
|
|
|
|
SELECT * FROM #Card
|
|
|
|
|
|
|
|
UPDATE A
|
|
SET A.FIndex = 1+(SELECT COUNT(1) FROM imp_member_card AS B WHERE A.FCardNo = B.FCardNo AND (A.FCreateDate > B.FCreateDate OR (A.FCreateDate = B.FCreateDate AND (A.FSeq > B.FSeq) )))
|
|
FROM imp_member_card AS A
|
|
|
|
SELECT * FROM imp_member_card WHERE FCardNo IN(SELECT FCardNO FROM #Card)
|
|
AND FIndex > 0
|
|
|
|
order by FCardNo
|
|
|
|
--删除完全一样的
|
|
|
|
|
|
UPDATE imp_member_card SET FCardNo = FCardNo + '.' + CAST(FIndex AS VARCHAR)
|
|
WHERE FCardNo IN( SELECT FCardNo FROM #Card)
|
|
AND FDeleted = 0
|
|
|
|
|
|
SELECT FCardNo,SUM(1) AS Cnt FROM imp_member_card
|
|
WHERE FDeleted = 0
|
|
GROUP BY FCardNo
|
|
ORDER BY SUM(1) DESC
|
|
|
|
SELECT FMemNo,FMobile,SUM(1) AS Cnt FROM imp_member
|
|
GROUP BY FMemNo ,FMobile
|
|
ORDER BY SUM(1) DESC
|
|
|
|
SELECT FMemNo,SUM(1) AS Cnt FROM imp_member
|
|
WHERE FMemId IN(SELECT FMemId FROM imp_member_card)
|
|
GROUP BY FMemNo
|
|
ORDER BY SUM(1) DESC
|
|
|
|
|
|
SELECT * FROM imp_member WHERE FMemNo = '15103405980'
|
|
SELECT * FROM imp_member_card WHERE FMemId = '45294303'
|
|
|
|
|
|
SELECT * FROM imp_member_card
|
|
|
|
UPDATE imp_member_card SET FCardId = id
|
|
UPDATE imp_member_card SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
|
|
|
|
|
|
--会员编号
|
|
UPDATE A
|
|
SET A.FMemNo = B.FCardNo
|
|
FROM imp_member AS A,imp_member_card AS B
|
|
WHERE A.id = B.memberId
|
|
AND A.FDeleted = 0
|
|
|
|
|
|
UPDATE imp_member SET FMemNo = phone WHERE ISNULL(FMemNo,'') = ''
|
|
|
|
UPDATE imp_member SET FName = name
|
|
UPDATE imp_member SET FMobile = phone
|
|
UPDATE imp_member SET FGender = CASE WHEN sex = 'M' THEN 1 ELSE '0' END
|
|
UPDATE imp_member SET FName = FMobile WHERE FName = ''
|
|
UPDATE imp_member SET FName = FMemNo WHERE FName = ''
|
|
|
|
|
|
|
|
UPDATE imp_member SET FArrear = 0
|
|
UPDATE imp_member SET FMemo = remark
|
|
|
|
|
|
|
|
--门店
|
|
|
|
SELECT * FROM imp_member_card WHERE FCardTypeID IS NULL
|
|
|
|
SELECT * FROM imp_card_type
|
|
|
|
--卡类别
|
|
UPDATE A
|
|
SET A.FCardTypeId = B.FId
|
|
FROM imp_member_card AS A,imp_card_type AS B
|
|
WHERE A.FCardTypeName= B.FName
|
|
|
|
SELECT * FROM imp_member_card
|
|
|
|
|
|
|
|
UPDATE imp_member SET FBirthdayType = 'G'
|
|
|
|
|
|
SELECT * FROM imp_member_card WHERE FMemo IS NULL
|
|
|
|
--门店
|
|
UPDATE imp_member SET FCompId = dbo.FNCompId('010')
|
|
|
|
SELECT * FROM imp_member_card
|
|
--备注
|
|
update imp_member_card SET FMemo = REMARK
|
|
|
|
--余额
|
|
UPDATE imp_member_card SET FBalance = balanceAmount
|
|
UPDATE imp_member_card SET FBalance2 = balanceGiftmoneyAmount
|
|
|
|
SELECT * FROM imp_member_card WHERE FBalance2 != 0 AND FDeleted = 0
|
|
|
|
|
|
--
|
|
UPDATE imp_member SET FMemno = 'JY' + FMemNO,FCardNo = 'JY' + FCardnO
|
|
|
|
SELECT * FROM imp_member_card WHERE FCardTypeId IS NULL
|
|
|
|
SELECT * FROM imp_member WHERE FMemno = '10839'
|
|
|
|
SELECT count(1) FROM imp_member_card WHERE remarks is null
|
|
|
|
SELECT * FROM imp_memberCourse
|
|
|
|
|
|
|
|
|
|
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 imp_card_type
|
|
WHERE FId NOT IN(SELECT FId FROM TMemberCardType)
|
|
ORDER BY FNo
|
|
|
|
SELECT * FROM imp_card_type
|
|
|
|
|
|
UPDATE TMemberCardType SET FAllowRchg = 1 WHERE FId IN(SELECT FId FROM imp_card_type)
|
|
UPDATE TMemberCardType SET FAllowSale = 1 WHERE FId IN(SELECT FId FROM imp_card_type)
|
|
UPDATE TMemberCardType SET FEnabled = 1 WHERE FId IN(SELECT FId FROM imp_card_type)
|
|
UPDATE TMemberCardType SET FValidityPeriod = 100 WHERE FId IN(SELECT FId FROM imp_card_type)
|
|
UPDATE TMemberCardType SET FValidityPerioduNIT = 1 WHERE FId IN(SELECT FId FROM imp_card_type)
|
|
|
|
|
|
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 imp_card_type)
|
|
--AND C.FId = dbo.FNCompId('002')
|
|
AND NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId)
|
|
|
|
|
|
UPDATE A
|
|
SET A.FValueType = 3
|
|
FROM TMemberCardType AS A,imp_card_type AS B
|
|
WHERE A.FId = B.FId
|
|
|
|
|
|
--疗程
|
|
drop table TImpItem
|
|
CREATE TABLE TImpItem
|
|
(
|
|
FItemId BIGINT,
|
|
FCourseId BIGINT,
|
|
FItemName VARCHAR(100),
|
|
)
|
|
INSERT TImpItem(FItemId,FCourseId,FItemName)
|
|
SELECT dbo.FNNewId(),dbo.FNNewId(),projectName
|
|
FROM imp_memberCourseDetail
|
|
WHERE projectName NOT IN(SELECT FItemName FROM TImpItem)
|
|
GROUP BY projectName
|
|
|
|
|
|
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,FDisplay)
|
|
SELECT FItemId,'L' + FItemName,'',FItemName,FItemName,0,dbo.FNGetFirstPinYin(FItemName),'',1,1,1,'','','',1,0,0,0,0,1,0,0,1,1
|
|
FROM TImpItem
|
|
WHERE FItemId NOT IN(SELECT FId FROM TItem)
|
|
|
|
|
|
DELETE TCourse WHERE FItemId IN(SELECT FItemId FROM TImpiTEM)
|
|
|
|
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,
|
|
I.FItemName + 'L1',
|
|
I.FItemName ,
|
|
dbo.FNGetFirstPinyin(FItemName) AS FBriefCode,
|
|
I.FItemId AS FItemId,
|
|
0 AS FPackId,
|
|
1 AS FSequence,
|
|
0 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 I
|
|
WHERE FItemId NOT IN(SELECT FItemId FROM TCourse)
|
|
|
|
|
|
SELECT projectName FROM imp_memberCourseDetail
|
|
GROUP BY projectName
|
|
|
|
UPDATE A
|
|
SET A.FDeleted = B.FDeleted
|
|
FROM imp_member AS B,imp_memberCourseDetail AS A
|
|
WHERE A.memberId = B.memberId
|
|
|
|
SELECT * FROM imp_memberCourseDetail
|
|
|
|
|
|
|
|
|
|
UPDATE imp_memberCourseDetail SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
|
|
UPDATE imp_memberCourseDetail SET FExpiredDate = NULL
|
|
UPDATE imp_memberCourseDetail SET FMemo = ''
|
|
|
|
|
|
UPDATE A
|
|
SET A.FItemId = B.FItemId,
|
|
A.FCardTypeId = B.FCourseId
|
|
FROM imp_memberCourseDetail AS A,TImpItem AS B
|
|
WHERE A.projectName = B.FItemName
|
|
|
|
SELECT * FROM imp_memberCourseDetail
|
|
|
|
UPDATE imp_memberCourseDetail SET FRemainTimes = remainingCount
|
|
UPDATE imp_memberCourseDetail SET FPurTimes = projectCount
|
|
|
|
UPDATE imp_memberCourseDetail SET FPurAmount = projectCount * cast(singlecomboprice as float)
|
|
UPDATE imp_memberCourseDetail SET FAdjustPrice = cast(singlecomboprice as float)
|
|
UPDATE imp_memberCourseDetail SET FUsedTimes = FPurTimes - FRemainTimes
|
|
UPDATE imp_memberCourseDetail SET FCreateDate = createTime
|
|
UPDATE imp_memberCourseDetail SET FMemId = memberId
|
|
UPDATE imp_memberCourseDetail SET FCardId = detailId
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_memberCourseDetail WHERE FCardTYPEID IS NULL
|
|
|
|
SELECT * FROM imp_memberCourseDetail WHERE memberId NOT IN(SELECT memberId FROM imp_member)
|
|
SELECT * FROM imp_member2 WHERE memberId NOT IN(SELECT memberId FROM imp_member)
|
|
|
|
INSERT imp_member(memberId,name,sex,phone)
|
|
SELECT memberId,name,sex,phone FROM imp_member2
|
|
WHERE memberId NOT IN(SELECT memberId FROM imp_member)
|
|
|
|
|
|
|
|
UPDATE imp_memberCourseDetail SET FCompId = dbo.FNCompId('001')
|
|
|
|
|
|
DROP TABLE imp_memberCourseDetail
|
|
|
|
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,
|
|
ISNULL(FCreateDate ,'1900-01-01') 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,
|
|
ISNULL( FPoint,0) AS FPoint,
|
|
1 AS FRecvConsSMS,
|
|
1 AS FRecvBulkSMS,
|
|
ISNULL('','') AS FMemo,
|
|
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
|
|
from imp_member
|
|
WHERE FDeleted = 0
|
|
|
|
SELECT * FROM imp_member WHERE FMemId IN(SELECT FMemId FROM TMember)
|
|
|
|
|
|
--chongfu
|
|
alter table imp_member add idx int identity
|
|
|
|
delete a
|
|
from imp_Member as a,(select id,max(idx) as idx from imp_member group by id) as b
|
|
where a.id = b.id
|
|
and a.idx != b.idx
|
|
|
|
|
|
delete a
|
|
from imp_Member_card as a,(select id,max(Fseq) as Fseq from imp_Member_card group by id) as b
|
|
where a.id = b.id
|
|
and a.Fseq != b.Fseq
|
|
|
|
SELECT * FROM imp_member WHERE id = 1355016045898596353
|
|
|
|
|
|
SELECT * FROM imp_member WHERE FMemNO iN(SELECT FMemNO FROM TMember)
|
|
SELECT * FROM imp_member WHERE fmemid is null
|
|
|
|
|
|
|
|
SELECT * FROM imp_member WHERE FMemId = 3347836
|
|
|
|
/*
|
|
SELECT * FROM imp_member
|
|
WHERE FMemId IN(
|
|
|
|
|
|
SELECT FMemId,FMemNo,FName,FMobile,FGender,FCompId ,FBirthdayType ,FBirthday,FCreateDate,FPoint
|
|
INTO #Temp
|
|
FROM imp_member
|
|
GROUP BY FMemId,FMemNo,FName,FMobile,FGender,FCompId ,FBirthdayType ,FBirthday,FCreateDate,FPoint
|
|
ORDER BY SUM(1) DESC
|
|
)
|
|
|
|
SELECT FMemId
|
|
FROM #Temp
|
|
GROUP BY FMemId
|
|
HAVING(SUM(1)) > 1
|
|
|
|
SELECT * FROM imp_member WHERE FMemId = 25006217
|
|
|
|
UPDATE imp_member SET FMemNo = '0000330' WHERE FMemId = 25463627
|
|
UPDATE imp_member SET FMemNo = '0000055' WHERE FMemId = 25006217
|
|
|
|
*/
|
|
INSERT INTO TMemberCard(
|
|
FCardId,
|
|
FCardNo,
|
|
FCardFaceNo,
|
|
FTypeId,
|
|
FValueType,
|
|
FCompId,
|
|
FMemId,
|
|
FState,
|
|
FCreateDate,
|
|
FExpiredDate,
|
|
FTotalTimes,
|
|
FUsedTimes,
|
|
FSaleCompId,
|
|
FSaleBillId,
|
|
FMemo)
|
|
SELECT
|
|
FCardId AS FId,
|
|
FCardNo AS FNo,
|
|
FCardNo AS FFaceNo,
|
|
FCardTypeId AS FTypeId,
|
|
(SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
|
|
FCompId AS FCompId,
|
|
FMemId AS FMemId,
|
|
1 AS FState,
|
|
FCreateDate AS FCreateDate,
|
|
FExpiredDate AS FExpiredDate,
|
|
ISNULL(FRemainTimes,0) AS FTotalTimes,
|
|
0 AS FUsedTimes,
|
|
FCompId AS FSaleCompId,
|
|
0 AS FSaleBillId,
|
|
ISNULL(FMemo,'') AS FMemo
|
|
FROM imp_member_card
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member 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 imp_member_card AS A
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
|
|
select dbo.FNNewId(),A.FMemId,A.FCardId,3,getdate(),A.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),'从盛传中导入'
|
|
FROM imp_member_card AS A
|
|
WHERE FDeleted = 0
|
|
|
|
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 imp_member_card AS A
|
|
WHERE FBalance2 != 0
|
|
AND FDeleted = 0
|
|
|
|
INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
|
|
select dbo.FNNewId(),A.FMemId,A.FCardId,10,getdate(),A.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance2,0,A.FBalance2,0,getdate(),'从盛传中导入'
|
|
FROM imp_member_card AS A
|
|
WHERE FBalance2 != 0
|
|
AND FDeleted = 0
|
|
|
|
--疗程
|
|
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,'从智放中导入',1,FAdjustPrice
|
|
FROM imp_memberCourseDetail AS A
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
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 imp_memberCourseDetail AS A
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
SELECT * FROM imp_member WHERE FBalance2!= 0
|
|
|
|
SELECT * FROM imp_member AS A
|
|
WHERE FBalance2 != 0
|
|
|
|
SELECT * FROM TImpTransHist
|
|
|
|
ALTER TABLE TImpTransHist ADD FCompId BIGINT
|
|
ALTER TABLE TImpTransHist ADD FTime DATETIME
|
|
|
|
UPDATE TImpTransHIst SET FtIME = REPLACE(Time,'消费日期:','')
|
|
UPDATE TImpTransHist SET FCompID = DBO.FNCompId('011')
|
|
|
|
UPDATE
|
|
SELECT * FROM TImpTransHist
|
|
|
|
INSERT TMemberOldTransHist(FId,FCompId,FMemId,FTime,FCardId,FBIllType,FBizType,FTransNo,FCOntent,FPrice,FQuantity,FAmount,FPayment,Femployee,FMemo)
|
|
SELECT dbo.FNNewId(),FCompId,MemId,FTime,CardId,'',BizType,BillNo,
|
|
ISNULL(Content,''),0,1,0,Amount,Employee, Memo AS FMemo
|
|
FROM TImpTransHist
|
|
|
|
WHERE FMemId IS NOT NULL
|
|
AND FMemId IN(SELECT FMemId FROM imp_member3)
|
|
|
|
|
|
SELECT * FROM TCompany
|
|
|
|
|
|
SELECT * FROM TMemberCard WHERE FMemo != ''
|
|
|
|
SELECT * FROM imp_member where isnull(FMemo,'') != ''
|
|
|
|
ALTER TABLE imp_member ADD ShopId
|
|
|
|
USE MAIN
|
|
|
|
SELECT * FROM TClientInfo WHERE FClientName LIKE '%海岸%'
|
|
|
|
SELECT * FROM imp_memberTransHist
|
|
|
|
SELECT * FROM imp_member
|
|
|
|
UPDATE A
|
|
SET A.FCompId = B.FCompID
|
|
FROM TMember AS A,imp_member AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
|
|
|
|
UPDATE A
|
|
SET A.FCompId = B.FCompID
|
|
FROM TMemberCard AS A,imp_member_card AS B
|
|
WHERE A.FCardId = B.FCardId
|
|
|
|
UPDATE A
|
|
SET A.FCompId = B.FCompID
|
|
FROM TMemberCourse AS A,imp_member AS B
|
|
WHERE A.FMemId = B.FMemId
|
|
|
|
|
|
SELECT * FROM imp_member WHERE FMemNo = '07150001607856'
|
|
SELECT * FROM imp_member_card WHERE FCardNo = '07150001607856'
|
|
SELECT * FROM TMember WHERE FMemNo = '07150001607856'
|
|
|
|
SELECT * FROM imp_member_card WHERE subAccountId = 3348635
|
|
|
|
UPDATE imp_member_card SET remarks = NULL WHERE remarks = ''
|
|
|
|
SELECT * FROM imp_member_card WHERE remarks IS NOT NULL AND FDeleted = 0
|
|
|
|
SELECT COUNT(*) FROM imp_member_card WHERE remarks IS NULL
|
|
AND FDeleted = 0
|
|
|
|
UPDATE imp_member_card SET FMemo = remarks
|
|
|
|
|
|
|
|
UPDATE A
|
|
SET A.FPoint = B.balanceIntegral
|
|
FROM imp_member AS B,TMember AS A
|
|
WHERE A.FMemId = B.FMemId
|
|
|
|
SELECT * FROM TMember WHERE FPoint != 0
|
|
|
|
|
|
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 TMember AS A WHERE FPoint != 0
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberCard
|
|
WHERE FCardNo like '%.%'
|
|
AND FCardId IN(SELECT FCardId FROM TMemberCardAccount WHERE FBalance > 0)
|
|
|
|
SELECT * FROM TMemberCard WHERE FCardNo = '0021.2'
|
|
SELECT * FROM TMemberCard WHERE FCardNo = '0021.1'
|
|
|
|
SELECT
|
|
|
|
|
|
SELECT * FROM TMemberCard
|
|
|
|
UPDATE TMemberCardType SET FExpiredDate = null
|
|
|
|
DELETE TMemberCardTypeSub WHERE FCompId = 0
|
|
|
|
|
|
UPDATE TMemberCardType SET FValueType = 1
|
|
|
|
UPDATE TMemberCard SET FValueType = 1
|
|
|
|
SELECT * FROM imp_member
|
|
|
|
|
|
|