|
|
|
|
use WuHan_MuXiang
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpCompany
|
|
|
|
|
SELECT * FROM TCompany
|
|
|
|
|
--<EFBFBD>ŵ<EFBFBD>
|
|
|
|
|
ALTER TABLE TImpCompany ADD FCompId BIGINT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_common ADD new_id BIGINT
|
|
|
|
|
UPDATE imp_common SET new_id =dbo.FNNewId()
|
|
|
|
|
|
|
|
|
|
INSERT INTO TBasicType(FId,FKey,FNo,FName,FParentId,FDescription,FImage,FCustom,FOrder,FAllowEdit,FEnabled)
|
|
|
|
|
SELECT new_id,'ItemType',title,title,0,'','','',0,-1,1
|
|
|
|
|
FROM imp_common
|
|
|
|
|
WHERE tid = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select * from imp_item
|
|
|
|
|
--<EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
ALTER TABLE imp_item ADD new_id BIGINT
|
|
|
|
|
ALTER TABLE imp_item ADD course_id BIGINT
|
|
|
|
|
ALTER TABLE imp_item ADD item_type_id BIGINT
|
|
|
|
|
|
|
|
|
|
UPDATE imp_item SET course_id = dbo.FNNewId()
|
|
|
|
|
UPDATE imp_item SET new_id = dbo.FNNewId()
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.item_type_id = b.new_id
|
|
|
|
|
FROM imp_item as a,imp_common as b
|
|
|
|
|
where a.itemtype = b.id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TItem(FId,FNo,FNoOfPad,FName,FAbbr,FTypeId,FBriefCode,FDescription,FPriceMode,FIsService,FStatTimes,FCustom1,FCustom2,FCustom3,FEnabled,FPrice,FVipPrice,FTime,FDctId,FDisplayTypeId,FPointMode,FPointValue,FDeptId,FAllowBooking,FDisplay)
|
|
|
|
|
SELECT new_id,goodssn,goodssn,title,title,item_type_id,FBriefCode = dbo.FNGetFirstPinYin(title),
|
|
|
|
|
FDescription = '',FPriceMode = 0,FIsService = 1,FStatTimes = 1,FCustom1 = '',FCustom2 = '',
|
|
|
|
|
FCustom3 = '',FEnabled = 1,productprice ,FVipPrice = marketprice ,FTime = 0,FDctId = 0 ,FDisplayTypeId = 0,
|
|
|
|
|
FPointMode = 0,FPointValue = 0,FDeptId = 0,FAllowBooking = 1,FDisplay = 1
|
|
|
|
|
FROM imp_item
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
I.goodssn + '',
|
|
|
|
|
I.title ,
|
|
|
|
|
dbo.FNGetFirstPinyin(title) AS FBriefCode,
|
|
|
|
|
I.new_id 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 imp_item AS I
|
|
|
|
|
WHERE id IN(SELECT goodsid from imp_member_course)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
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 C.FNo = '000'
|
|
|
|
|
AND NOT EXISTS(SELECT TOP 1 1 FROM TItemSub AS B WHERE B.FCompId = C.FId AND B.FItemId = I.FId)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TItemSub(FId,FCompId,FItemId,FPrice,FVipPrice,FTime,FDctId,FPointMode,FPointValue,FDeptId,FAllowBooking,FEnabled)
|
|
|
|
|
SELECT dbo.FNNewId(),C.FCompId,I.FId,I.FPrice,I.FVipPrice,I.FTime,I.FDctId,I.FPointMode,I.FPointValue,I.FDeptId,I.FAllowBooking,I.FEnabled
|
|
|
|
|
from TItem AS I,TImpItemSub AS B,TImpCompany AS C
|
|
|
|
|
WHERE I.FId= B.FItemId
|
|
|
|
|
AND C.FCompId > 1
|
|
|
|
|
AND C.id = B.compId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_cardtype ADD card_type_id BIGINT
|
|
|
|
|
UPDATE imp_cardtype SET card_type_id = dbo.FNNewId() WHERE card_type_id 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 card_type_id =card_type_id, cardcode,levelname,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 imp_cardtype
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TMemberCardTypeSub(FId,FCompId,FCardTypeId,FAllowSale,FAllowRchg,FEnabled)
|
|
|
|
|
SELECT dbo.FNNewId(),1,I.card_type_id,1,1,1
|
|
|
|
|
FROM imp_cardtype AS I
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ա
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_memberCourse WHERE MemId = '5a350f84c9e77c0007a24d4a'
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpBaseType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use XiAn_ChaoYeDao
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use ShiYan_KaMan
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_member ADD card_type_name VARCHAR(100)
|
|
|
|
|
ALTER TABLE imp_member ADD mem_id BIGINT
|
|
|
|
|
ALTER TABLE imp_member ADD mem_no VARCHAR(50)
|
|
|
|
|
ALTER TABLE imp_member ADD name VARCHAR(50)
|
|
|
|
|
ALTER TABLE imp_member ADD gender INT
|
|
|
|
|
ALTER TABLE imp_member ADD card_state INT
|
|
|
|
|
ALTER TABLE imp_member ADD mobile VARCHAR(50)
|
|
|
|
|
ALTER TABLE imp_member ADD card_type_id BIGINT
|
|
|
|
|
ALTER TABLE imp_member ADD remain_times INT
|
|
|
|
|
ALTER TABLE imp_member ADD pur_times INT
|
|
|
|
|
ALTER TABLE imp_member ADD create_date DATETIME
|
|
|
|
|
ALTER TABLE imp_member ADD expire_date DATETIME
|
|
|
|
|
ALTER TABLE imp_member ADD comp_id BIGINT
|
|
|
|
|
ALTER TABLE imp_member ADD memo VARCHAR(1000)
|
|
|
|
|
ALTER TABLE imp_member ADD point DECIMAL(18,6)
|
|
|
|
|
ALTER TABLE imp_member ADD Birthday DATETIME
|
|
|
|
|
ALTER TABLE imp_member ADD Birthday_Type CHAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM IMP_mEMBER
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member SET mem_id = memId WHERE isnull(memId,'') != ''
|
|
|
|
|
UPDATE imp_member SET mem_id = dbo.FNNewId() WHERE isnull(mem_id,'') = ''
|
|
|
|
|
UPDATE imp_member SET name = realName
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member SET create_date = createtime
|
|
|
|
|
UPDATE imp_member SET Birthday_Type = 'G'
|
|
|
|
|
UPDATE imp_member SET Birthday_Type = 'L' WHERE birthtype = 0
|
|
|
|
|
UPDATE imp_member set comp_id = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_card
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER table imp_member_card add idx int identity
|
|
|
|
|
|
|
|
|
|
DELETE A
|
|
|
|
|
FROM imp_member_card AS A,(SELECT cid,max(idx) as idx FROM imp_member_card GROUP by cid having sum(1) > 1 ) as b
|
|
|
|
|
WHERE a.cid = b.cid
|
|
|
|
|
and a.idx != b.idx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 having sum(1) > 1 ) as b
|
|
|
|
|
WHERE a.id = b.id
|
|
|
|
|
and a.idx != b.idx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.mem_no = B.membercardno
|
|
|
|
|
FROM imp_member_card AS B,imp_member AS A
|
|
|
|
|
WHERE A.id = B.memberid
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FCompId
|
|
|
|
|
FROM imp_member AS A,imp_comp_all AS B
|
|
|
|
|
WHERE A.compId = b.id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member WHERE FMemNo IS NULL
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member SET FIsLoad = 0 WHERE
|
|
|
|
|
FMemNo IS NULL
|
|
|
|
|
|
|
|
|
|
SELECT memberid FROM imp_member_card
|
|
|
|
|
GROUP BY memberid
|
|
|
|
|
HAVING SUM(1) > 1
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_card WHERE id = 558
|
|
|
|
|
|
|
|
|
|
SELECT * INTO _TransHiST from TMemberTransHist
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_member_card ADD card_type_id BIGINT
|
|
|
|
|
ALTER TABLE imp_member_card ADD create_date DATETIME
|
|
|
|
|
ALTER TABLE imp_member_card ADD expire_date DATETIME
|
|
|
|
|
ALTER TABLE imp_member_card ADD comp_id BIGINT
|
|
|
|
|
ALTER TABLE imp_member_card ADD card_id BIGINT
|
|
|
|
|
ALTER TABLE imp_member_card ADD mem_Id BIGINT
|
|
|
|
|
ALTER TABLE imp_member_card ADD memo VARCHAR(1000)
|
|
|
|
|
ALTER TABLE imp_member_card ADD card_state int
|
|
|
|
|
ALTER TABLE imp_member_card ADD card_no VARCHAR(1000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_card WHERE FMobile = '17633496668'
|
|
|
|
|
|
|
|
|
|
select * from imp_cardtype
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.card_type_id = B.card_type_id
|
|
|
|
|
FROM imp_member_card AS A,imp_cardtype AS B
|
|
|
|
|
WHERE A.levelid = B.id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ԱID
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.mem_id = B.mem_id
|
|
|
|
|
FROM imp_member_card AS A,imp_member AS B
|
|
|
|
|
WHERE A.memberid = B.id
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member_card SET card_id = dbo.FNNewId() WHERE card_id IS NULL
|
|
|
|
|
UPDATE imp_member_card SET card_no = membercardno
|
|
|
|
|
UPDATE imp_member_card SET comp_id = dbo.FNCompId('001')
|
|
|
|
|
UPDATE imp_member_card SET create_date = buytime
|
|
|
|
|
UPDATE imp_member_card SET expire_date = card_timelimit
|
|
|
|
|
UPDATE imp_member_card SET memo = remark
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member_card SET card_state = 1
|
|
|
|
|
UPDATE imp_member_card SET card_state = 4 WHERE card_status != 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FCompId
|
|
|
|
|
FROM imp_member_card AS A,imp_comp_all AS B
|
|
|
|
|
WHERE A.compId = b.id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_card WHERE status != 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_member_card_account ADD card_id bigint
|
|
|
|
|
ALTER TABLE imp_member_card_account ADD mem_id bigint
|
|
|
|
|
ALTER TABLE imp_member_card_account ADD acct_id bigint
|
|
|
|
|
ALTER TABLE imp_member_card_account ADD balance decimal(18,6)
|
|
|
|
|
ALTER TABLE imp_member_card_account ADD arrear decimal(18,6)
|
|
|
|
|
ALTER TABLE imp_member_card_account ADD create_date datetime
|
|
|
|
|
ALTER TABLE imp_member_card_account ADD card_type_id bigint
|
|
|
|
|
ALTER TABLE imp_member_card_account ADD comp_id bigint
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_card_account where acct_name != 6
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.mem_id = b.mem_id,
|
|
|
|
|
A.card_id = b.card_id,
|
|
|
|
|
a.create_date = b.create_date,
|
|
|
|
|
a.card_type_id = b.card_type_id,
|
|
|
|
|
a.comp_id = b.comp_id
|
|
|
|
|
FROM imp_member_card_account AS A,imp_member_card AS B
|
|
|
|
|
WHERE A.cid = b.cid
|
|
|
|
|
|
|
|
|
|
select * from imp_member_card
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member_card_account SET balance = acct_balance
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_common where tid = 23
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_common ADD acct_id BIGINT
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.acct_id = B.FId
|
|
|
|
|
FROM imp_common AS A,TPayAccount AS B
|
|
|
|
|
WHERE A.title = b.FName
|
|
|
|
|
and a.tid = 23
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.acct_id = B.acct_id
|
|
|
|
|
FROM imp_member_card_account AS A,imp_common AS B
|
|
|
|
|
where a.account = b.id
|
|
|
|
|
|
|
|
|
|
UPDATE imp_member_card_account set arrear = 0
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.arrear = B.arrear_amt
|
|
|
|
|
FROM imp_member_card_account AS A,imp_member_card AS B
|
|
|
|
|
where a.cid = b.cid
|
|
|
|
|
and a.acct_id = 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>Ƴ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_memberCourse ADD card_type_id BIGINT
|
|
|
|
|
ALTER TABLE imp_memberCourse ADD item_id BIGINT
|
|
|
|
|
ALTER TABLE imp_memberCourse ADD course_id BIGINT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_memberCourse ADD FRemainTimes INT
|
|
|
|
|
ALTER TABLE imp_memberCourse ADD FPurTimes INT
|
|
|
|
|
ALTER TABLE imp_memberCourse ADD FUsedTimes INT
|
|
|
|
|
ALTER TABLE imp_memberCourse ADD FPurAmount DECIMAL(18,6)
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_memberCourse ADD FCreateDate DATETIME
|
|
|
|
|
ALTER TABLE imp_memberCourse ADD FExpiredDate DATETIME
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_memberCourse ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE imp_memberCourse ADD FCardId BIGINT
|
|
|
|
|
ALTER TABLE imp_memberCourse ADD FMemId BIGINT
|
|
|
|
|
ALTER TABLE imp_memberCourse ADD FMemo VARCHAR(1000)
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_memberCourse
|
|
|
|
|
|
|
|
|
|
UPDATE imp_memberCourse SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = B.FMemId
|
|
|
|
|
FROM imp_memberCourse AS A,imp_member_card AS B
|
|
|
|
|
WHERE b.memId = a.memId
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>Կ<EFBFBD>Ϊ
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = B.FMemId
|
|
|
|
|
FROM imp_memberCourse AS A,imp_member_card AS B
|
|
|
|
|
WHERE b.memId = a.memId
|
|
|
|
|
AND b.cardNo = A.cardNo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_card WHERE
|
|
|
|
|
|
|
|
|
|
UPDATE imp_memberCourse
|
|
|
|
|
SET FCreateDate = CREATEDATE,
|
|
|
|
|
FExpiredDate = ExpireDate,
|
|
|
|
|
FPurTimes = times,
|
|
|
|
|
FPurAmount = saleAmount,
|
|
|
|
|
FUsedTimes = cast(times as float) - remainTimes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FCompId
|
|
|
|
|
FROM imp_memberCourse AS A,TImpCompany AS B
|
|
|
|
|
WHERE A.compId = b.id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpCardType
|
|
|
|
|
|
|
|
|
|
UPDATE imp_memberCourse SET FCompId = dbo.FNCompID('001')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FItemId = B.FId
|
|
|
|
|
FROM imp_memberCourse AS A,TImpItem AS B
|
|
|
|
|
WHERE A.projectId = B.id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpItem WHERE name = '<EFBFBD>ӷ<EFBFBD>ϴ<EFBFBD><EFBFBD>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCardTypeId = B.FId
|
|
|
|
|
FROM imp_memberCourse AS A,TCourse AS B
|
|
|
|
|
WHERE A.FItemId = B.FItemId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select * from imp_member where fmemno is null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 mem_Id AS FMemId,
|
|
|
|
|
mem_no AS FMemNo,
|
|
|
|
|
name AS FName,
|
|
|
|
|
dbo.FNGetFirstPinYin(name),
|
|
|
|
|
0 AS FTypeId,
|
|
|
|
|
comp_id AS FCompId,
|
|
|
|
|
create_date AS FCreateDate,
|
|
|
|
|
gender AS FGender,
|
|
|
|
|
Birthday_Type AS FBirthdayType,
|
|
|
|
|
Birthday AS FBirthday,
|
|
|
|
|
'' AS FTelephone,
|
|
|
|
|
ISNULL(Mobile,'') AS FMobilePhone,
|
|
|
|
|
'' AS FQQ,
|
|
|
|
|
'' AS FWeChat,
|
|
|
|
|
'' AS FIdCard,
|
|
|
|
|
'' AS FEmail,
|
|
|
|
|
'' AS FAddress,
|
|
|
|
|
0 AS FProId,
|
|
|
|
|
'' AS FCPW,
|
|
|
|
|
'' AS FQPW,
|
|
|
|
|
0 AS FChargeEmpId,
|
|
|
|
|
0 AS FPoint,
|
|
|
|
|
1 AS FRecvConsSMS,
|
|
|
|
|
1 AS FRecvBulkSMS,
|
|
|
|
|
'' 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
|
|
|
|
|
card_Id AS FId,
|
|
|
|
|
card_no AS FNo,
|
|
|
|
|
card_no AS FFaceNo,
|
|
|
|
|
card_type_id AS FTypeId,
|
|
|
|
|
(SELECT FValueType FROM TMemberCardType WHERE FId = card_type_id) AS FValueType,
|
|
|
|
|
comp_id AS FCompId,
|
|
|
|
|
mem_id AS FMemId,
|
|
|
|
|
card_state AS FState,
|
|
|
|
|
create_date AS FCreateDate,
|
|
|
|
|
ISNULL(expire_date,DATEADD(YEAR,100,create_date)) AS FExpiredDate,
|
|
|
|
|
0 AS FTotalTimes,
|
|
|
|
|
0 AS FUsedTimes,
|
|
|
|
|
comp_id AS FSaleCompId,
|
|
|
|
|
0 AS FSaleBillId,
|
|
|
|
|
ISNULL(memo,'') AS FMemo
|
|
|
|
|
FROM imp_member_card
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delete a
|
|
|
|
|
from imp_member_card_account as a,(
|
|
|
|
|
|
|
|
|
|
select card_id,acct_id,max(idx) as idx from imp_member_card_account
|
|
|
|
|
group by card_id,acct_id
|
|
|
|
|
having sum(1) > 1) as b
|
|
|
|
|
where a.card_id = b.card_id
|
|
|
|
|
and a.acct_id = b.acct_id
|
|
|
|
|
and a.idx != b.idx
|
|
|
|
|
|
|
|
|
|
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
|
|
|
|
|
SELECT mem_id,dbo.FNNewId(),card_id AS FCardId,acct_id,balance,balance,A.arrear,create_date,NULL AS FExpiredDate,''
|
|
|
|
|
FROM imp_member_card_account 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.mem_id,A.card_id,acct_id,getdate(),A.card_type_id,A.comp_id,'DR','Import',0,'',A.balance,0,A.balance,A.arrear,getdate(),'<EFBFBD>Ӻ<EFBFBD>ά<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
FROM imp_member_card_account AS A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ƿ<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberArrear(FId,FMemId,FTime,FCompId,FContentType,FCardId,FBillType,FBizType,FTransId,FTransNo,FTransDetailId,FContentId,FArrear,FEmpId,FRepaid,FAcctArrear)
|
|
|
|
|
SELECT dbo.FNNewId(),A.mem_id,getdate(),A.comp_id,'Account',A.card_id,'DR_KK','DR_CardSale',0,'',0,a.acct_id,A.arrear,0,0,A.arrear
|
|
|
|
|
FROM imp_member_card_account AS A
|
|
|
|
|
WHERE A.arrear > 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,FUsedTimes,FPurAmount,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'<EFBFBD>Ӻ<EFBFBD>ά<EFBFBD><EFBFBD><EFBFBD><EFBFBD>',1,0
|
|
|
|
|
FROM imp_memberCourse 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_memberCourse AS A
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_memberTransHist ADD FIndex BIGINT
|
|
|
|
|
UPDATE imp_memberTransHist SET FIndex = dbo.FNNewId()
|
|
|
|
|
|
|
|
|
|
DELETE A
|
|
|
|
|
FROM imp_memberTransHist AS A,
|
|
|
|
|
(
|
|
|
|
|
SELECT transId,projectId,empId,min(FIndex) as FIndex FROM imp_memberTransHist
|
|
|
|
|
GROUP BY transId,projectId,empId
|
|
|
|
|
HAVING SUM(1) > 1
|
|
|
|
|
) AS B
|
|
|
|
|
WHERE A.transId = B.transId AND A.projectId = B.projectId AND A.empId = B.empId
|
|
|
|
|
AND A.FIndex != B.FIndex
|
|
|
|
|
|
|
|
|
|
SELECT transId,projectId,empId FROM imp_memberTransHist
|
|
|
|
|
GROUP BY transId,projectId,empId
|
|
|
|
|
HAVING SUM(1) > 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_memberTransHist WHERE transId = '1586426316645339'
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_memberAcctHist ADD FMemId BIGINT
|
|
|
|
|
ALTER TABLE imp_memberAcctHist ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE imp_memberAcctHist ADD FCardId BIGINT
|
|
|
|
|
ALTER TABLE imp_memberAcctHist ADD FCardTypeId BIGINT
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = B.FMemId,
|
|
|
|
|
A.FCompId = B.FCompId,
|
|
|
|
|
A.FCardId = B.FCardId,
|
|
|
|
|
A.FCardTypeId = B.FCardTypeId
|
|
|
|
|
FROM imp_memberAcctHist AS A,imp_member_card AS B
|
|
|
|
|
WHERE A.cardId = B.id
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_card
|
|
|
|
|
WHERE id NOT IN(
|
|
|
|
|
SELECT cardId FROM imp_memberAcctHist WITH(NOLOCK)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
DELETE imp_member_card
|
|
|
|
|
WHERE FCardId NOT IN(SELECT FCardId FROM TMemberCard)
|
|
|
|
|
AND id IN(
|
|
|
|
|
SELECT id FROM imp_member_card
|
|
|
|
|
GROUP BY id HAVING SUM(1) > 1
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sp_rename 'imp_memberTransHist','imp_memberAcctHist'
|
|
|
|
|
|
|
|
|
|
INSERT INTO TMemberCardOldAcctHist(FId,FMemId,FCardId,FAcctId,
|
|
|
|
|
FTime,FCardTypeId,FCompId,FBizType,FTransNo,FInAmount,
|
|
|
|
|
FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
|
|
|
|
|
|
|
|
|
|
INSERT INTO TMemberCardOldAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBizType,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
|
|
|
|
|
SELECT dbo.FNNewId(),FMemId,FCardId,3,ISNULL(createDate,'1753-01-01'),FCardTypeId,ISNULL(FCompId,0),'[' + typeName + ']',isnull( smallNo,''),cast(rechargeAmount as float),case when type = 0 then cast(amount as float) else 0 end,isnull(balance,0),0,getdate(),remark
|
|
|
|
|
FROM imp_memberAcctHist
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_memberAcctHist
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_memberTransHist
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_memberTradeHist ADD FMemId BIGINT
|
|
|
|
|
ALTER TABLE imp_memberTradeHist ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE imp_memberTradeHist ADD FCardId BIGINT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = B.FMemId,
|
|
|
|
|
A.FCompId = B.FCompId,
|
|
|
|
|
A.FCardId = B.FCardId
|
|
|
|
|
FROM imp_memberTradeHist AS A,imp_member_card AS B
|
|
|
|
|
WHERE A.cardId = B.id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
|
|
|
|
|
SELECT DBO.FNNewId(),A.FMemId,createDate,0,A.FCompId,'DR','Import','',remark,amount,1,amount,isnull(payName,''),isnull('','') + ',' + isnull('','') + ',' + isnull('',''),''
|
|
|
|
|
FROM imp_memberTradeHist AS A
|
|
|
|
|
where type = 1
|
|
|
|
|
|
|
|
|
|
SELECT * FROM imp_member_trans_hist where type = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE imp_member_trans_hist ADD mem_id BIGINT
|
|
|
|
|
ALTER TABLE imp_member_trans_hist ADD comp_id BIGINT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.mem_id = B.mem_id,
|
|
|
|
|
A.comp_id = B.comp_id
|
|
|
|
|
FROM imp_member_trans_hist AS A,imp_member_card AS B
|
|
|
|
|
WHERE A.membercardno = b.membercardno
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
|
|
|
|
|
SELECT DBO.FNNewId(),A.mem_id,createtime,0,A.comp_id,'DR','Import',billno,typename + ':' + remark,price,total,realprice,'','',''
|
|
|
|
|
FROM imp_member_trans_hist AS A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
|
|
|
|
|
SELECT FId,A.FMemId,FTime,0,A.FCompId,FBillType,FBizType,FTransNo,FContentText,FOrigPrice,FQuantity,FDctPrice,FPayment,isnull(FEmployee,'') ,FMemo
|
|
|
|
|
FROM _transhist AS A
|