|
|
|
|
use WeiHai_Khair
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TCompany
|
|
|
|
|
|
|
|
|
|
select count(1) from imp_member_list
|
|
|
|
|
where memberid = '9fb4940f-c13a-4cd9-9e4a-aff800e99e3d'
|
|
|
|
|
|
|
|
|
|
select * from imp_member_list
|
|
|
|
|
where memberid = '9fb4940f-c13a-4cd9-9e4a-aff800e99e3d'
|
|
|
|
|
|
|
|
|
|
create table imp_member(Id VARCHAR(60) PRIMARY KEY)
|
|
|
|
|
|
|
|
|
|
delete imp_member_list
|
|
|
|
|
|
|
|
|
|
drop table imp_member_list
|
|
|
|
|
drop table imp_Member
|
|
|
|
|
drop table imp_Member_card
|
|
|
|
|
drop table imp_Member_card_account
|
|
|
|
|
drop table imp_Member_course
|
|
|
|
|
drop table imp_Member_course_detail
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select * from imp_member_list
|
|
|
|
|
|
|
|
|
|
delete imp_member
|
|
|
|
|
delete imp_member_card_account
|
|
|
|
|
|
|
|
|
|
select * from imp_member
|
|
|
|
|
select * from imp_member_card
|
|
|
|
|
select * from imp_member_card_account
|
|
|
|
|
select * from imp_member_card_account_money
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select ID FROM imp_member
|
|
|
|
|
GROUP BY ID
|
|
|
|
|
HAVING SUM(1) > 1
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member where id = '96e85759-6101-4c92-8111-acd9013daa01'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member WHERE Id = '96e85759-6101-4c92-8111-acd9013daa01'
|
|
|
|
|
--ɾ<EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
DELETE A
|
|
|
|
|
FROM imp_member AS A,(SELECT MIN([$id]) AS idx, ID FROM imp_member GROUP BY ID HAVING SUM(1 )> 1) AS B
|
|
|
|
|
WHERE A.Id = B.Id
|
|
|
|
|
AND A.[$id] != B.idx
|
|
|
|
|
|
|
|
|
|
--ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
delete imp_member_card WHERE MemberId = '00000000-0000-0000-0000-000000000000'
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_member_card ADD idx INT IDENTITY
|
|
|
|
|
|
|
|
|
|
DELETE A
|
|
|
|
|
FROM imp_member_card AS A,(SELECT MAX(idx) AS idx, ID FROM imp_member_card GROUP BY ID HAVING SUM(1 )> 1) AS B
|
|
|
|
|
WHERE A.Id = B.Id
|
|
|
|
|
AND A.idx != B.idx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_member alter column Id VARCHAR(100)
|
|
|
|
|
ALTER TABLE imp_member_card alter column id VARCHAR(100)
|
|
|
|
|
ALTER TABLE imp_member_course alter column id VARCHAR(100)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
create function fn_convert_id(@str varchar(100))
|
|
|
|
|
returns bigint
|
|
|
|
|
as
|
|
|
|
|
begin
|
|
|
|
|
return abs( CAST( CAST(cast(@str as uniqueidentifier ) AS BINARY(16)) AS BIGINT))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT abs( CAST( CAST(cast('dc114c05-6464-4824-8636-acac00c47486' as uniqueidentifier ) AS BINARY(16)) AS BIGINT))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
update a
|
|
|
|
|
set a.FCardTypeName = B.CategoryName
|
|
|
|
|
FROM imp_member_card AS A,imp_member_card_account as b
|
|
|
|
|
where a.Id = B.MemberCardId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
select * from TImpCardType
|
|
|
|
|
select * from TMemberCardType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 = dbo.fn_convert_id(Id)
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE imp_member_card SET FCardNo = CardCode
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member_card SET FCreateDate = CreateTime
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member_card SET FMemo = ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member_card SET FMemId = dbo.fn_convert_id(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_card SET FCompId = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- SELECT * FROM imp_member_card_account_money where MemberCardId = '8275b836-c394-42f5-a80a-ad0a0135a39f'
|
|
|
|
|
-- SELECT * FROM imp_member_card where Id = '8275b836-c394-42f5-a80a-ad0a0135a39f'
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE imp_member_card SET FBalance = (SELECT Balance FROM imp_member_card_account_money WHERE imp_member_card_account_money.MemberCardId = imp_member_card.ID and MoneyUseMode = 1)
|
|
|
|
|
UPDATE imp_member_card SET FBalance2 = (SELECT Balance FROM imp_member_card_account_money WHERE imp_member_card_account_money.MemberCardId = imp_member_card.ID and MoneyUseMode = 2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member_card SET FBalance = 0 WHERE FBalance IS NULL
|
|
|
|
|
UPDATE imp_member_card SET FBalance2 = 0 WHERE FBalance2 IS NULL
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member_card SET FCreateDate = CreateTime
|
|
|
|
|
UPDATE imp_member_card SET FExpiredDate = DATEADD(YEAR,100,FCreateDate)
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemNo = B.CardCode
|
|
|
|
|
FROM Imp_member AS A,imp_member_card AS B
|
|
|
|
|
WHERE A.Id = B.MemberId
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member SET FMemNo= MobilePhone WHERE FMemNo IS NULL
|
|
|
|
|
UPDATE imp_member SET FMemId= dbo.fn_convert_id(Id)
|
|
|
|
|
UPDATE imp_member SET FName = name
|
|
|
|
|
UPDATE imp_member SET FCompId = dbo.FNCompId('001')
|
|
|
|
|
UPDATE imp_member SET FMobile = MobilePhone
|
|
|
|
|
UPDATE imp_member SET FGender = Sex
|
|
|
|
|
UPDATE imp_member SET FCreateDate = CreateTime
|
|
|
|
|
UPDATE imp_member SET FBirthday = NULL
|
|
|
|
|
UPDATE imp_member SET FBirthdayType = 'G'
|
|
|
|
|
UPDATE imp_member SET FMemo = Remark
|
|
|
|
|
UPDATE imp_member SET FPoint = 0
|
|
|
|
|
|
|
|
|
|
select * from imp_member WHERE FMemNo IN(SELECT FMemNo FROM TMember)
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member SET FMemNo ='J' + FMemNo WHERE FMemNo IN(SELECT FMemNo FROM TMember UNION ALL SELECT FCardNo FROM imp_member_card)
|
|
|
|
|
UPDATE imp_member_card SET FCardNo ='J' + FCardNo WHERE FCardNo IN(SELECT FMemNo FROM TMember UNION ALL SELECT FCardNo FROM imp_member_card)
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_course
|
|
|
|
|
SELECT * FROM imp_member_course_detail
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member WHERE Id = 'f549eec6-639a-4b67-b31f-adc301374692'
|
|
|
|
|
SELECT * FROM imp_member_course WHERE MemberId = 'f549eec6-639a-4b67-b31f-adc301374692'
|
|
|
|
|
SELECT * FROM imp_member_course WHERE CountMode != 3
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member
|
|
|
|
|
|
|
|
|
|
--<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,AccountName AS name,AccountName AS no
|
|
|
|
|
INTO imp_item
|
|
|
|
|
FROM imp_member_course
|
|
|
|
|
GROUP BY AccountName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 item_id,no,name,name,name,0,dbo.FNGetFirstPinYin(name),'',1,1,1,'','','',1,0,0,0,0,0,0,0,1
|
|
|
|
|
FROM imp_item
|
|
|
|
|
ORDER BY no
|
|
|
|
|
|
|
|
|
|
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
|
|
|
|
|
SELECT course_id AS FId,
|
|
|
|
|
no + '',
|
|
|
|
|
A.name AS FName,
|
|
|
|
|
'' AS FBriefCode,
|
|
|
|
|
a.item_id 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,
|
|
|
|
|
calc_mode AS FCalcMode
|
|
|
|
|
FROM imp_item AS A
|
|
|
|
|
|
|
|
|
|
alter table imp_item add calc_mode int
|
|
|
|
|
|
|
|
|
|
update imp_item set calc_mode = 1
|
|
|
|
|
update a
|
|
|
|
|
set a.calc_mode = 2
|
|
|
|
|
FROM imp_item as a,imp_member_course as b
|
|
|
|
|
where a.Name = b.accountname
|
|
|
|
|
and b.calcmode = 3
|
|
|
|
|
|
|
|
|
|
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 item_id FROM imp_item)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
ALTER TABLE imp_member_course ADD FCalcMode INT
|
|
|
|
|
|
|
|
|
|
select * from imp_member_course
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member_course SET FMemo = Remark
|
|
|
|
|
UPDATE imp_member_course SET FPurTimes = SurplusCount
|
|
|
|
|
UPDATE imp_member_course SET FUsedTimes = 0
|
|
|
|
|
UPDATE imp_member_course SET FPurAmount = Balance
|
|
|
|
|
UPDATE imp_member_course SET FAdjustPrice = FPurAmount / SurplusCount WHERE SurplusCount != 0
|
|
|
|
|
UPDATE imp_member_course SET FAdjustPrice = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCardTypeId = B.course_id,
|
|
|
|
|
A.FItemId = B.item_id
|
|
|
|
|
FROM imp_member_course AS A,imp_item AS B
|
|
|
|
|
WHERE A.AccountName = b.name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member_course set FCardId = dbo.FNNewId(),FMemId = dbo.fn_convert_id(MemberId), FCompId = dbo.FNCompId('001')
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member_course SET FCalcMode = 1
|
|
|
|
|
UPDATE imp_member_course SET FCalcMode = 2 WHERE CalcMode = 3
|
|
|
|
|
UPDATE imp_member_course SET FCreateDate = CreateTime
|
|
|
|
|
UPDATE imp_member_course SET FExpiredDate = NULL
|
|
|
|
|
UPDATE imp_member_course SET FExpiredDate = LifeEnd WHERE LifeEnd!= ''
|
|
|
|
|
|
|
|
|
|
--<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,FCalcMode,FAdjustPrice
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
select * from imp_member_trans_hist
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
update imp_member_trans_hist set comp_id = dbo.fncompid('001')
|
|
|
|
|
update imp_member_trans_hist set mem_id = dbo.fn_convert_id(MemberId)
|
|
|
|
|
update imp_member_trans_hist set card_id = dbo.fn_convert_id(MemberCardId)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
|
|
|
|
|
SELECT DBO.FNNewId(),A.mem_id,AccountTime,0,A.comp_id,'DR','Import',A.SaleBillCode,a.saleItemName,SaleItemMoney,1,SaleItemMoney,'',a.saleman,''
|
|
|
|
|
FROM imp_member_trans_hist AS A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TPayACCOUNT
|
|
|
|
|
|