|
|
ALTER TABLE imp_member alter column id bigint
|
|
|
ALTER TABLE imp_member_card alter column id bigint
|
|
|
ALTER TABLE imp_member_course alter column id bigint
|
|
|
|
|
|
CREATE unique CLUSTERED INDEX IX_imp_member_card ON imp_member_card(id)
|
|
|
CREATE unique CLUSTERED INDEX IX_TImpMember ON imp_member (id)
|
|
|
CREATE unique CLUSTERED INDEX IX_imp_member_course ON imp_member_course (id)
|
|
|
|
|
|
delete a
|
|
|
from imp_member_course as a,(
|
|
|
|
|
|
select id,max(idx) as idx from imp_member_course
|
|
|
group by id
|
|
|
having sum(1) > 1
|
|
|
|
|
|
) as b
|
|
|
where a.id = b.id
|
|
|
and a.idx != b.idx
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_course WHERE id = 12967854
|
|
|
|
|
|
ALTER TABLE imp_member_course ADD idx int IDENTITY
|
|
|
|
|
|
|
|
|
|
|
|
use XingTai_YiHaoDian
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_member ADD FMemId BIGINT
|
|
|
ALTER TABLE imp_member 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 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 FBirthday DATETIME
|
|
|
ALTER TABLE imp_member ADD FBirthdayType CHAR
|
|
|
ALTER TABLE imp_member ADD FCustom1 VARCHAR(100)
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_member_card ADD FMemId BIGINT
|
|
|
ALTER TABLE imp_member_card ADD FCardNo VARCHAR(50)
|
|
|
ALTER TABLE imp_member_card ADD FMemNo VARCHAR(50)
|
|
|
ALTER TABLE imp_member_card ADD FName VARCHAR(50)
|
|
|
ALTER TABLE imp_member_card ADD FGender INT
|
|
|
ALTER TABLE imp_member_card ADD FMobile VARCHAR(50)
|
|
|
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_card ADD FCompId BIGINT
|
|
|
ALTER TABLE imp_member_card ADD FCardId BIGINT
|
|
|
ALTER TABLE imp_member_card ADD FMemo VARCHAR(1000)
|
|
|
ALTER TABLE imp_member_card ADD FArrear DECIMAL(18,6)
|
|
|
ALTER TABLE imp_member_card ADD FPoint DECIMAL(18,6)
|
|
|
ALTER TABLE imp_member_card ADD FBirthday DATETIME
|
|
|
ALTER TABLE imp_member_card ADD FBirthdayType CHAR
|
|
|
ALTER TABLE imp_member_card ADD FCustom1 VARCHAR(100)
|
|
|
ALTER TABLE imp_member_card ADD FCardTYpeName VARCHAR(100)
|
|
|
|
|
|
SELECT * FROM imp_member_card
|
|
|
|
|
|
SELECT * FROM TMemberCardType
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
UPDATE imp_member_card SET FCardTYpeName = cardtypename + '[' + discount + '<EFBFBD><EFBFBD>]' where cast(discount as float) != 0.0
|
|
|
UPDATE imp_member_card SET FCardTYpeName = cardtypename where cast(discount as float) = 0
|
|
|
|
|
|
DROP TABLE TImpCardType
|
|
|
CREATE TABLE TImpCardType
|
|
|
(
|
|
|
FId BIGINT,
|
|
|
FNo VARCHAR(50),
|
|
|
FName VARCHAR(50),
|
|
|
FType VARCHAR(50),
|
|
|
FValueType INT
|
|
|
)
|
|
|
INSERT TImpCardType(FId,FNo,FName,FValueType)
|
|
|
|
|
|
SELECT dbo.FNNewId() AS FId,FNo,FName,1
|
|
|
FROM (
|
|
|
SELECT FCardTypeName AS FNo, FCardTYpeName AS FName ,1 AS FValueType
|
|
|
FROM imp_member_card
|
|
|
WHERE 1=1
|
|
|
GROUP BY FCardTYpeName ) AS A
|
|
|
GROUP BY FNo,FName
|
|
|
|
|
|
|
|
|
|
|
|
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 =FId,FNo,FName,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 TImpCardType
|
|
|
|
|
|
update imp_member_card SET FCardId = id WHERE FCardId IS NULL
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
UPDATE imp_member_card SET FCardNo = cardId
|
|
|
|
|
|
UPDATE imp_member_card SET FCreateDate = DATEADD(second,cast(1529942400000 as bigint) / 1000,'1970-01-01 00:00:00')
|
|
|
|
|
|
UPDATE imp_member_card SET FMemo = cardRemark
|
|
|
|
|
|
UPDATE imp_member_card SET FMemId = memberId
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FCardTypeId = B.FId
|
|
|
FROM imp_member_card AS A,TImpCardType AS B
|
|
|
WHERE A.FCardTypeName= B.FName
|
|
|
|
|
|
|
|
|
--<EFBFBD>ظ<EFBFBD>
|
|
|
SELECT FCardNo
|
|
|
into #Card
|
|
|
FROM imp_member_card
|
|
|
GROUP BY FCardNo
|
|
|
HAVING(SUM(1)) > 1
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_member_card ADD FSeq INT IDENTITY
|
|
|
ALTER TABLE imp_member_card ADD FIndex INT
|
|
|
|
|
|
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
|
|
|
|
|
|
UPDATE imp_member_card SET FCardNo = FCardNo + '.' + CAST(FIndex AS VARCHAR)
|
|
|
WHERE FCardNo IN( SELECT FCardNo FROM #Card)
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>
|
|
|
UPDATE imp_member SET FCompId = 1
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FCompId = B.FCompID
|
|
|
FROM imp_member_card AS A,TImpCompany AS B
|
|
|
WHERE A.cardshopId = B.shopId
|
|
|
|
|
|
SELECT * FROM imp_member_card WHERE FCompId IS NULL
|
|
|
UPDATE imp_member_card SET FCompId = 1 WHERE cardshopid = 1156034
|
|
|
UPDATE imp_member SET FCompId = 1 WHERE shopId = 1156034
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
UPDATE imp_member_card SET FBalance = cardfee
|
|
|
UPDATE imp_member_card SET FBalance2 = presentfee
|
|
|
|
|
|
|
|
|
UPDATE imp_member_card SET FCreateDate = DATEADD(second,cast(opendate as bigint) / 1000,'1970-01-01 00:00:00')
|
|
|
UPDATE imp_member_card SET FExpiredDate = DATEADD(YEAR,100,FCreateDate)
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FExpiredDate = DATEADD(minute,s ,'1970-01-01 00:00:00')
|
|
|
FROM imp_member_card AS A,(
|
|
|
SELECT id,(cast(invaliddate as bigint) / cast(1000 as bigint)) / 60 as s
|
|
|
FROM imp_member_card
|
|
|
where invaliddate != ''
|
|
|
) AS B
|
|
|
WHERE A.id = B.id
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_card WHERE cast(presentfee as float)> 0.0
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
UPDATE A
|
|
|
SET A.FMemNo = B.FCardNo
|
|
|
FROM imp_member AS A,imp_member_card AS B
|
|
|
WHERE A.Id = b.memberid
|
|
|
|
|
|
--shopId
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FCompId = B.FCompID
|
|
|
FROM imp_member AS A,TImpCompany AS B
|
|
|
WHERE A.shopId = B.shopId
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member SET FMemNo= mobile WHERE ISNULL(FMemNo,'') =''
|
|
|
UPDATE imp_member SET FMemId= id WHERE FMemId Is null
|
|
|
UPDATE imp_member SET FName = name
|
|
|
UPDATE imp_member SET FCompId = 1
|
|
|
UPDATE imp_member SET FMobile = mobile
|
|
|
UPDATE imp_member SET FGender = case when sex = 'F' then 0 else 1 end
|
|
|
UPDATE imp_member SET FCreateDate = DATEADD(second,cast(registdate as bigint) / 1000,'1970-01-01 00:00:00')
|
|
|
UPDATE imp_member SET FBirthday = birthday
|
|
|
UPDATE imp_member SET FBirthdayType = 'G'
|
|
|
UPDATE imp_member SET FMemo = page
|
|
|
UPDATE imp_member SET FPoint = currpoint
|
|
|
|
|
|
|
|
|
|
|
|
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(FMemo,'') AS FMemo,
|
|
|
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
|
|
|
from imp_member
|
|
|
WHERE FMemId IN(SELECT FMemId FROM imp_member_card)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 timeflag != 1
|
|
|
|
|
|
|
|
|
|
|
|
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 timeflag != 1
|
|
|
|
|
|
|
|
|
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 imp_member_card AS A
|
|
|
WHERE timeflag != 1
|
|
|
|
|
|
|
|
|
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 timeflag != 1
|
|
|
|
|
|
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 imp_member_card AS A
|
|
|
WHERE FBalance2 > 0
|
|
|
AND timeflag != 1
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_card WHERE timeflag =3
|
|
|
|
|
|
--<EFBFBD>Ƴ<EFBFBD>
|
|
|
--<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ̿<EFBFBD>
|
|
|
SELECT dbo.FNNewId() AS item_id,dbo.FNNewId() AS course_id,cardtypename AS name,cardtypename AS no
|
|
|
INTO imp_item
|
|
|
FROM imp_member_card
|
|
|
WHERE timeflag = 1
|
|
|
GROUP BY cardtypename,cardtypename
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.ITEM_ID = b.FItemId,
|
|
|
a.course_id = b.fid
|
|
|
FROM imp_item AS A,TCourse AS B,TItem AS C
|
|
|
WHERE a.name = 'ͷƤ<EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD>'
|
|
|
AND c.FName = 'ͷƤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
AND C.FId = B.FItemId
|
|
|
|
|
|
SELECT * FROM imp_item
|
|
|
|
|
|
SELECT * FROM TItem WHERE FName = 'ͷƤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_member_card ADD FItemId BIGINT
|
|
|
ALTER TABLE imp_member_card ADD FRemainTimes INT
|
|
|
ALTER TABLE imp_member_card ADD FPurTimes INT
|
|
|
ALTER TABLE imp_member_card ADD FUsedTimes INT
|
|
|
ALTER TABLE imp_member_card ADD FPurAmount DECIMAL(18,6)
|
|
|
ALTER TABLE imp_member_card ADD FAdjustPrice DECIMAL(18,6)
|
|
|
ALTER TABLE imp_member_card ADD FCreateDate DATETIME
|
|
|
ALTER TABLE imp_member_card ADD FExpiredDate DATETIME
|
|
|
ALTER TABLE imp_member_card ADD FCompId BIGINT
|
|
|
ALTER TABLE imp_member_card ADD FCardId BIGINT
|
|
|
ALTER TABLE imp_member_card ADD FMemId BIGINT
|
|
|
ALTER TABLE imp_member_card ADD FMemo VARCHAR(1000)
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_card
|
|
|
|
|
|
UPDATE imp_member_card SET FMemo = ''
|
|
|
UPDATE imp_member_card SET FPurTimes = cardtimes
|
|
|
UPDATE imp_member_card SET FUsedTimes = 0
|
|
|
UPDATE imp_member_card SET FPurAmount = cardfee
|
|
|
UPDATE imp_member_card SET FAdjustPrice = cast(timefee as float)
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FCardTypeId = B.course_id,
|
|
|
A.FItemId = B.item_id
|
|
|
FROM imp_member_card AS A,imp_item AS B
|
|
|
WHERE A.cardtypename = b.name
|
|
|
AND timeflag = 1
|
|
|
|
|
|
|
|
|
--<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,FUsedTimes,FPurAmount,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,FMemo,1,FAdjustPrice
|
|
|
FROM imp_member_card AS A
|
|
|
WHERE timeflag = 1
|
|
|
|
|
|
|
|
|
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,FUsedTimes,0,FCompId,'DR','Import',0,'',0,getdate()
|
|
|
FROM imp_member_card AS A
|
|
|
WHERE timeflag = 1
|
|
|
|
|
|
SELECT * FROM imp_member_card
|
|
|
WHERE FBalance2 > 0
|
|
|
AND timeflag = 1
|
|
|
|
|
|
SELECT fmemno FROM imp_member WHERE fmemid = 100358766
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TMemberCard(
|
|
|
FCardId,
|
|
|
FCardNo,
|
|
|
FCardFaceNo,
|
|
|
FTypeId,
|
|
|
FValueType,
|
|
|
FCompId,
|
|
|
FMemId,
|
|
|
FState,
|
|
|
FCreateDate,
|
|
|
FExpiredDate,
|
|
|
FTotalTimes,
|
|
|
FUsedTimes,
|
|
|
FSaleCompId,
|
|
|
FSaleBillId,
|
|
|
FMemo)
|
|
|
SELECT
|
|
|
1000000000 + FCardId AS FId,
|
|
|
FCardNo AS FNo,
|
|
|
FCardNo AS FFaceNo,
|
|
|
6 AS FTypeId,
|
|
|
(SELECT FValueType FROM TMemberCardType WHERE FId = 6) 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 timeflag = 1
|
|
|
and fbalance2 > 0
|
|
|
|
|
|
|
|
|
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
|
|
|
SELECT FMemId,dbo.FNNewId(),1000000000 + FCardId AS FCardId,10,FBalance2,FBalance2,0,FCreateDate,NULL AS FExpiredDate,''
|
|
|
FROM imp_member_card AS A
|
|
|
WHERE FBalance2 > 0
|
|
|
AND timeflag = 1
|
|
|
and fbalance2 > 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,1000000000 + 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 imp_member_card AS A
|
|
|
WHERE FBalance2 > 0
|
|
|
AND timeflag = 1
|
|
|
and fbalance2 > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TMemberCard(
|
|
|
FCardId,
|
|
|
FCardNo,
|
|
|
FCardFaceNo,
|
|
|
FTypeId,
|
|
|
FValueType,
|
|
|
FCompId,
|
|
|
FMemId,
|
|
|
FState,
|
|
|
FCreateDate,
|
|
|
FExpiredDate,
|
|
|
FTotalTimes,
|
|
|
FUsedTimes,
|
|
|
FSaleCompId,
|
|
|
FSaleBillId,
|
|
|
FMemo)
|
|
|
SELECT
|
|
|
1000000000 + FCardId AS FId,
|
|
|
FCardNo AS FNo,
|
|
|
FCardNo AS FFaceNo,
|
|
|
6 AS FTypeId,
|
|
|
(SELECT FValueType FROM TMemberCardType WHERE FId = 6) 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 timeflag = 1
|
|
|
and FPurAmount > 0
|
|
|
AND FPurTimes = 0
|
|
|
|
|
|
|
|
|
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
|
|
|
SELECT FMemId,dbo.FNNewId(),1000000000 + FCardId AS FCardId,3,FBalance,FBalance,0,FCreateDate,NULL AS FExpiredDate,''
|
|
|
FROM imp_member_card AS A
|
|
|
WHERE 1=1
|
|
|
AND timeflag = 1
|
|
|
and FPurAmount > 0
|
|
|
AND FPurTimes = 0
|
|
|
|
|
|
DELETE TMemberCardAcctHist
|
|
|
|
|
|
|
|
|
INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
|
|
|
select dbo.FNNewId(),A.FMemId,1000000000 + 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 imp_member_card AS A
|
|
|
WHERE 1=1
|
|
|
AND timeflag = 1
|
|
|
and FPurAmount > 0
|
|
|
AND FPurTimes = 0
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN TRAN
|
|
|
|
|
|
DECLARE @Id BIGINT
|
|
|
DECLARE @memId BIGINT
|
|
|
DECLARE @Memo VARCHAR(1000)
|
|
|
DECLARE list CURSOR FOR SELECT FId,fmEMiD,FMemo FROM TMemberCourse
|
|
|
WHERE FMemo != ''
|
|
|
OPEN LIST
|
|
|
FETCH LIST INTO @ID,@memId,@Memo
|
|
|
WHILE @@FETCH_STATUS = 0
|
|
|
BEGIN
|
|
|
|
|
|
UPDATE TMember SET FMemo = FMemo + (CASE WHEN FMemo != '' THEN ',' ELSE '' END) + @Memo
|
|
|
WHERE FMemId = @memid
|
|
|
UPDATE TMemberCourse SET FMEMO = '' WHERE FId = @id
|
|
|
|
|
|
FETCH LIST INTO @ID,@memId,@Memo
|
|
|
END
|
|
|
|
|
|
COMMIT TRAN
|
|
|
|
|
|
SELECT * FROM TMemberCourse WHERE FMemo != ''
|
|
|
|
|
|
SELECT * FROM TMember WHERE FMemNo = '001181'
|
|
|
|
|
|
---<EFBFBD>ײ<EFBFBD><EFBFBD>Ƴ<EFBFBD>
|
|
|
|
|
|
SELECT dbo.FNNewId() AS FId,dbo.FNNewId() AS FCourseId,itemname AS FName,itemno AS FNo
|
|
|
INTO TImpItem
|
|
|
FROM imp_member_course
|
|
|
GROUP BY itemname,itemno
|
|
|
|
|
|
|
|
|
SELECT cardtypeid,cardtypename,timeflag from imp_member_card
|
|
|
group by cardtypeid,cardtypename,timeflag
|
|
|
|
|
|
|
|
|
SELECT * FROM syscolumns where id = object_id('imp_member_card')
|
|
|
and name like '%time%'
|
|
|
|
|
|
ALTER TABLE imp_member_course ADD FCardTypeId BIGINT
|
|
|
ALTER TABLE imp_member_course ADD FItemId BIGINT
|
|
|
ALTER TABLE imp_member_course ADD FRemainTimes INT
|
|
|
ALTER TABLE imp_member_course ADD FPurTimes INT
|
|
|
ALTER TABLE imp_member_course ADD FUsedTimes INT
|
|
|
ALTER TABLE imp_member_course ADD FPurAmount DECIMAL(18,6)
|
|
|
ALTER TABLE imp_member_course ADD FAdjustPrice DECIMAL(18,6)
|
|
|
ALTER TABLE imp_member_course ADD FCreateDate DATETIME
|
|
|
ALTER TABLE imp_member_course ADD FExpiredDate DATETIME
|
|
|
ALTER TABLE imp_member_course ADD FCompId BIGINT
|
|
|
ALTER TABLE imp_member_course ADD FCardId BIGINT
|
|
|
ALTER TABLE imp_member_course ADD FMemId BIGINT
|
|
|
ALTER TABLE imp_member_course ADD FMemo VARCHAR(1000)
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FCardTypeId = B.FCourseId,
|
|
|
A.FItemId = B.FId
|
|
|
FROM imp_member_course AS A,TImpItem AS B
|
|
|
WHERE A.itemName = b.fname
|
|
|
AND A.itemno = b.fno
|
|
|
|
|
|
|
|
|
|
|
|
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,'MGJ'+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 FCourseId AS FId,
|
|
|
'MGJ' + A.FNo + '',
|
|
|
A.FName AS FName,
|
|
|
'' AS FBriefCode,
|
|
|
A.FId AS FItemId,
|
|
|
0 AS FPackId,
|
|
|
1 AS FSequence,
|
|
|
0,--(SELECT TOP 1 FId FROM TBasicType WHERE FKey = 'CourseType') AS FTypeId,
|
|
|
ISNULL(0,0) AS FTimes,
|
|
|
0 AS FFreeTimes,
|
|
|
0 AS FDurable,
|
|
|
1 AS FValidityPeriodUnit,
|
|
|
100 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
|
|
|
|
|
|
|
|
|
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 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)
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FCompId = B.FCompID
|
|
|
FROM imp_member_course AS A,TImpCompany AS B
|
|
|
WHERE A.shopId = B.shopId
|
|
|
|
|
|
SELECT SUM(FBalance) FROM TMemberCardAccount
|
|
|
WHERE FAcctId = 3
|
|
|
|
|
|
SELECT SUM(FRemainPurAmount) FROM TMemberCourse
|
|
|
SELECT SUM(FPurAmount) FROM TMemberCourse
|
|
|
|
|
|
SELECT SUM( cast(cardfee as float)) FROM imp_member_card
|
|
|
WHERE timeflag != 1
|
|
|
|
|
|
SELECT
|
|
|
109247.660000 + 359466.26
|
|
|
SELECT * FROM TMemberCourse WHERE FPurAmount != FRemainPurAmount
|
|
|
|
|
|
SELECT * FROM TMember WHERE FMemId = 73009694
|
|
|
|
|
|
SELECT * FROM TMemberCourse
|
|
|
WHERE FMemId NOT IN(SELECT FMemId FROM TMember)
|
|
|
|
|
|
UPDATE imp_member_course SET FCardId = ID WHERE FCardId IS NULL
|
|
|
UPDATE imp_member_course SET FMemId = memberId WHERE FMemId IS NULL
|
|
|
UPDATE imp_member_course SET FCreateDate = DATEADD(second,cast(buydate as bigint) / 1000,'1970-01-01 00:00:00')
|
|
|
UPDATE imp_member_course SET FExpiredDate = null;
|
|
|
UPDATE imp_member_course SET FExpiredDate = DATEADD(second,cast(validdate as bigint) / 1000,'1970-01-01 00:00:00')
|
|
|
UPDATE imp_member_course SET FMemo = ''
|
|
|
UPDATE imp_member_course SET FPurTimes = sumtimes
|
|
|
UPDATE imp_member_course SET FUsedTimes = sumtimes - cast(leaveTimes as float)
|
|
|
UPDATE imp_member_course SET FPurAmount = SUMMONEY
|
|
|
UPDATE imp_member_course SET FAdjustPrice = oncemoney
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_course
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<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,FUsedTimes,FPurAmount,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>',1,0
|
|
|
FROM imp_member_course 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,FUsedTimes,0,FCompId,'DR','Import',0,'',0,getdate()
|
|
|
FROM imp_member_course AS A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_member_trans_hist ADD mem_id BIGINT,comp_id bigint,card_id bigint
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.mem_id = B.FMemId,
|
|
|
A.comp_id = B.FCompId,
|
|
|
A.card_id = B.FCardId
|
|
|
FROM imp_member_trans_hist AS A,imp_member_card AS B
|
|
|
WHERE A.custid = B.memberid
|
|
|
|
|
|
|
|
|
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
|
|
|
SELECT DBO.FNNewId(),A.mem_id,dateadd(second,cast(createDate as bigint)/1000,'1970-01-01'),0,A.comp_id,'DR','Import',A.billno,B.serviceItemName,consumefee,1,consumefee,'',b.employee,''
|
|
|
FROM imp_member_trans_hist AS A ,imp_member_trans_hist_item as b
|
|
|
where a.id = b.billid
|
|
|
order by createDate,mem_id,a.billno
|
|
|
|