|
|
use jinan_at_old
|
|
|
|
|
|
|
|
|
--SELECT member_type.type_id, member_type.type_name, member_type.type_comment, member_type.type_no , '['+ rtrim(member_type.type_no) +']'+ member_type.type_name as name1 FROM member_type
|
|
|
|
|
|
|
|
|
SELECT clients.client_id, clients.client_code, clients.client_no, clients.client_name, clients.sex, clients.birthday, datediff(yy,clients.birthday,getdate()) as olds, clients.service_employeeid, clients.visit_times, clients.first_visit, clients.last_visit, clients.home_phone, clients.work_phone, clients.mobil_phone, clients.email, clients.zip, clients.address, clients.member_mark, clients.refer_name, clients.member_no, clients.annremender_mark, clients.active_status, clients.salon_code, clients.salon_name , clients.service_assistantid, clients.remain_amount, isnull(clients.cent,0) as cent, isnull(refer_cent,0) as refer_cent, isnull(clients.cent,0)+isnull(refer_cent,0) as total_cent, isnull(clients.tmtail_amount,0) + isnull(clients.cdtail_amount,0) + isnull(clients.giftcard_amount ,0) as tail_amount, clients.member_typeid, member_type.type_no, member_type.type_name, isnull(member_type.ceiling_mark,'N') as ceiling_mark, clients.checker_id, clients.create_date, clients.client_comment, clients.begin_category, clients.dep_id, clients.exit_date, clients.checker_name, clients.check_date as check_date, isnull(clients.discount_code,0) as discount_code, clients.check_date as stop_date, isnull(DATEDIFF ( dd , getdate() , clients.check_date),null) as remain_days, isnull(clients.service_assistantname,'Y') as service_assistantname, 0 as rest_times, 0.00 as rest_amount, 0 as rest_times1, 0.00 as rest_amount1
|
|
|
FROM clients, member_type WHERE ( clients.member_typeid *= member_type.type_id)
|
|
|
|
|
|
AND clients.active_status = 'Y'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT client_no FROM clients
|
|
|
GROUP BY client_no
|
|
|
|
|
|
SELECT member_typeid FROM clients
|
|
|
|
|
|
|
|
|
DROP TABLE TImpMemberCourse
|
|
|
|
|
|
SELECT clients.begin_category, clients.dep_id, clients.client_id, clients.client_no, clients.client_name, clients.sex, clients.active_status, clients.member_typeid, clients.mobil_phone, clients.home_phone, clients.work_phone, clients.client_code, clients.service_employeeid, clients.service_assistantid, member_times.member_no, member_times.times, member_times.rest_times, inventory.ps_name, inventory.normal_price, member_times.interval_days, member_times.last_used, member_times.ps_price, member_times.ps_price*member_times.rest_times as reset_amount, member_times.alert_times, member_times.id, member_times.ps_seq, inventory.ps_id, member_times.normal_price as member_normal_price, member_times.ticket_id, member_times.ps_id as member_times_ps_id, member_times.detail_id, member_times.sale_date, member_times.mt_comment
|
|
|
INTO TImpMemberCourse
|
|
|
|
|
|
FROM member_times, clients, inventory WHERE ( member_times.client_id = clients.client_id ) and ( member_times.ps_seq = inventory.ps_seq ) and ( ( member_times.rest_times )>0 )
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCourse
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>Ա
|
|
|
ALTER TABLE clients ADD FMemId BIGINT NOT NULL DEFAULT 0
|
|
|
ALTER TABLE clients ADD FMemNo VARCHAR(50) NOT NULL DEFAULT ''
|
|
|
ALTER TABLE clients ADD FName VARCHAR(50) NOT NULL DEFAULT ''
|
|
|
ALTER TABLE clients ADD FGender INT NOT NULL DEFAULT 0
|
|
|
ALTER TABLE clients ADD FMobile VARCHAR(50) NOT NULL DEFAULT ''
|
|
|
ALTER TABLE clients ADD FMemo VARCHAR(1000) DEFAULT ''
|
|
|
ALTER TABLE clients ADD FArrear DECIMAL(18,6) DEFAULT 0
|
|
|
ALTER TABLE clients ADD FPoint DECIMAL(18,6) DEFAULT 0
|
|
|
ALTER TABLE clients ADD FBirthday DATETIME
|
|
|
ALTER TABLE clients ADD FBirthdayType CHAR NOT NULL DEFAULT ''
|
|
|
ALTER TABLE clients ADD FCreateDate DATETIME
|
|
|
ALTER TABLE clients ADD FExpiredDate DATETIME
|
|
|
ALTER TABLE clients ADD FCompId BIGINT DEFAULT 0
|
|
|
ALTER TABLE clients ADD FDeleted BIT NOT NULL DEFAULT 0
|
|
|
ALTER TABLE clients ADD FPassword VARCHAR(1000) DEFAULT ''
|
|
|
|
|
|
|
|
|
ALTER TABLE clients ADD FCardNo VARCHAR(50) NOT NULL DEFAULT ''
|
|
|
ALTER TABLE clients ADD FCardTypeId BIGINT NOT NULL DEFAULT 0
|
|
|
ALTER TABLE clients ADD FBalance DECIMAL(18,6) NOT NULL DEFAULT 0
|
|
|
ALTER TABLE clients ADD FRemainTimes INT NOT NULL DEFAULT 0
|
|
|
ALTER TABLE clients ADD FCardId BIGINT NOT NULL DEFAULT 0
|
|
|
ALTER TABLE clients ADD FCardMemo VARCHAR(1000) NOT NULL DEFAULT ''
|
|
|
ALTER TABLE clients ADD FCardState INT NOT NULL DEFAULT 0
|
|
|
|
|
|
|
|
|
select * from member_type
|
|
|
|
|
|
set IDENTITY_INSERT member_type on
|
|
|
|
|
|
insert member_type(type_id,type_no,type_name)
|
|
|
|
|
|
SELECT member_typeid,member_typeid,'<EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD>ʧ<EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' FROM clients WHERE FCardTypeId NOT IN(SELECT FId FROM jinan_at..TMemberCardType)
|
|
|
group by member_typeid,member_typeid
|
|
|
|
|
|
|
|
|
---<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
INSERT jinan_at..TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FValidityPeriod,FValidityPeriodUnit,FAllowSale,FAllowRchg,FEnabled,FOrder,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue)
|
|
|
SELECT type_id = 30000+type_id,
|
|
|
type_name = 'LY' + cast(type_id as varchar),
|
|
|
type_name = type_name,
|
|
|
1 AS FValueType,
|
|
|
2 AS FMaterial,
|
|
|
0 AS FPrice,
|
|
|
3 AS FAcctId,
|
|
|
0 AS FDeposit,
|
|
|
0 as FAcctId2,
|
|
|
0 AS FDeposit2,
|
|
|
0 AS FAcctId3,
|
|
|
0 AS FDeposit3,
|
|
|
0 AS FTimes,
|
|
|
0 AS FAlertBalance,
|
|
|
0 AS FMinRchgAmt,
|
|
|
100 AS FValidityPeriod,
|
|
|
1 AS FValidityPeriodUnit,
|
|
|
1 AS FAllowSale,
|
|
|
1 AS FAllowRchg,
|
|
|
1,
|
|
|
1,
|
|
|
0 AS FSalePointMode,
|
|
|
0 AS FSalePointValue,
|
|
|
0 AS FRchgPointMode,
|
|
|
0 AS FRchgPointValue
|
|
|
FROM member_type
|
|
|
WHERE type_id IN(SELECT member_typeid FROM clients)
|
|
|
AND 30000+type_id NOT IN(SELECT FId FROM jinan_at..TMemberCardType)
|
|
|
|
|
|
|
|
|
INSERT INTO jinan_at..TMemberCardTypeSub(FId,FCompId,FCardTypeId,FAllowSale,FAllowRchg,FEnabled)
|
|
|
SELECT jinan_at.dbo.FNNewId(),C.FId,I.FId,FAllowSale,FAllowRchg,FEnabled
|
|
|
FROM jinan_at..TMemberCardType AS I,jinan_at..TCompany AS C
|
|
|
WHERE I.FId > 1
|
|
|
AND C.FId != 0
|
|
|
|
|
|
AND NOT EXISTS(SELECT TOP 1 1 FROM jinan_at..TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId)
|
|
|
AND I.FNo LIKE 'LY%'
|
|
|
|
|
|
SELECT * FROM jinan_at..TCompany
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊɾ<EFBFBD><EFBFBD>
|
|
|
UPDATE clients SET FDeleted = 0
|
|
|
UPDATE clients SET FDeleted = 1
|
|
|
WHERE isnull(member_typeid,0) = 0
|
|
|
AND client_id NOT IN(SELECT client_id FROM TImpMemberCourse)
|
|
|
AND active_status != 'Y'
|
|
|
|
|
|
UPDATE clients SET FDeleted = 1 WHERE client_name LIKE '%<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%'
|
|
|
UPDATE clients SET FDeleted = 1 WHERE client_name LIKE 'ɢ<EFBFBD><EFBFBD>'
|
|
|
|
|
|
SELECT * FROM clients WHERE FDeleted = 1
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM clients
|
|
|
|
|
|
|
|
|
UPDATE clients SET FCardTypeId = 30000 + member_typeid
|
|
|
WHERE member_typeid IS NOT NULL
|
|
|
|
|
|
DELETE jinan_at..TMemberCardTypeSub WHERE FCardTypeId IN(SELECT FId FROM jinan_at..TMemberCardType WHERE FNo LIKE 'LYN%')
|
|
|
|
|
|
SELECT * FROM jinan_at..TMemberCardType
|
|
|
|
|
|
|
|
|
UPDATE jinan_at..TMemberCardType SET FId = 30001 WHERE FId = 5427852751335447669
|
|
|
UPDATE jinan_at..TMemberCardType SET FId = 30002 WHERE FId = 5107380376443262628
|
|
|
UPDATE jinan_at..TMemberCardType SET FId = 30003 WHERE FId = 5425099468147510004
|
|
|
UPDATE jinan_at..TMemberCardType SET FId = 30006 WHERE FId = 4780699925238361494
|
|
|
|
|
|
|
|
|
SELECT *INTO #type FROM member_type WHERE type_id = 25
|
|
|
|
|
|
|
|
|
UPDATE #type SET [type_id] = 25 ,type_name = '<EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵĿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
|
select * from #type
|
|
|
|
|
|
SELECT * FROM member_
|
|
|
|
|
|
SELECT * FROM clients
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>ŵ<EFBFBD>
|
|
|
|
|
|
SELECT salon_code FROM clients
|
|
|
GROUP BY salon_code
|
|
|
|
|
|
|
|
|
UPDATE clients SET FCompId = jinan_at.dbo.FNCompId('001')
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ԱID<EFBFBD><EFBFBD><EFBFBD><EFBFBD>100000
|
|
|
UPDATE clients SET FMemId = jinan_at.dbo.FNNewId() WHERE ISNULL(FMemId,0) = 0
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
UPDATE clients SET FName = ISNULL(ISNULL(client_name,mobil_phone),client_id)
|
|
|
|
|
|
--<EFBFBD>绰
|
|
|
UPDATE clients SET FMobile = ISNULL(mobil_phone,'')
|
|
|
--<EFBFBD>Ա<EFBFBD>
|
|
|
UPDATE clients SET FGender = CASE WHEN sex = 'M' THEN 1 ELSE 0 END
|
|
|
--CreateDate
|
|
|
--<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ID
|
|
|
UPDATE clients SET FCardId = abs( CAST( CAST(newid() AS BINARY(16)) AS BIGINT))
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
UPDATE clients SET FCardNO = client_no
|
|
|
UPDATE clients SET FCardNo = FMobile WHERE FCardNo = ''
|
|
|
UPDATE clients SET FCardNo = FName WHERE FCardNo = ''
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
UPDATE clients SET FBalance = ISNULL(remain_amount,0)
|
|
|
|
|
|
UPDATE clients SET FMemNo = client_no
|
|
|
|
|
|
SELECT * FROM clients WHERE remain_amount > 0 AND client_no = ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
--UPDATE clients SET FPoint = CardPoint
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
UPDATE clients SET FCreateDate = create_date
|
|
|
--<EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>
|
|
|
UPDATE clients SET FExpiredDate = dateadd(year,100,create_date)
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
--UPDATE clients SET FPassword = ISNULL(CardPsw,'')
|
|
|
--<EFBFBD><EFBFBD>ע
|
|
|
UPDATE clients SET FCardMemo = isnull(client_comment,'')
|
|
|
|
|
|
|
|
|
UPDATE clients SET FCardState = 1
|
|
|
UPDATE clients set FCardState = 4 WHERE state != 1
|
|
|
|
|
|
SELECT * FROM jinan_at..TMember
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE #Card
|
|
|
|
|
|
SELECT FCardNo into #Card
|
|
|
FROM clients
|
|
|
WHERE FDeleted = 0
|
|
|
GROUP BY FCardNo
|
|
|
HAVING(SUM(1)) > 1
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE clients ADD FIndex INT
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FIndex = 1+(SELECT COUNT(1) FROM clients AS B WHERE A.FCardNo = B.FCardNo AND (A.FCreateDate > B.FCreateDate OR (A.FCreateDate = B.FCreateDate AND (A.client_id > B.client_id) )))
|
|
|
FROM clients AS A
|
|
|
WHERE FDeleted = 0
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE clients SET FCardNo = FCardNo + '.' + CAST(FIndex AS VARCHAR)
|
|
|
WHERE FCardNo IN( SELECT FCardNo FROM #Card)
|
|
|
AND FDeleted = 0
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE clients SET FMemNo = FCardNo
|
|
|
|
|
|
|
|
|
SELECT * FROM clients WHERE FMemNO = '13853130206'
|
|
|
|
|
|
|
|
|
select FMemNO FROM clients
|
|
|
WHERE FDeleted = 0
|
|
|
GROUP BY FMemNO
|
|
|
HAVING SUM(1) > 1
|
|
|
|
|
|
|
|
|
DELETE jinan_at..TMember WHERE FMemId IN(SELECT FMemId FROM clients)
|
|
|
|
|
|
INSERT INTO jinan_at..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,
|
|
|
jinan_at.dbo.FNGetFirstPinYin(FName) as fcode,
|
|
|
0 AS FTypeId,
|
|
|
FCompId AS FCompId,
|
|
|
FCreateDate ,
|
|
|
FGender AS FGender,
|
|
|
'G' AS FBirthdayType,
|
|
|
FBirthday AS FBirthday,
|
|
|
'' AS FTelephone,
|
|
|
ISNULL(FMobile,'') AS FMobilePhone,
|
|
|
'' AS FQQ,
|
|
|
'' AS FWeChat,
|
|
|
'' AS FIdCard,
|
|
|
'' AS FEmail,
|
|
|
'' AS FAddress,
|
|
|
0 AS FProId,
|
|
|
ISNULL('','') 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
|
|
|
-- into #t
|
|
|
from clients
|
|
|
WHERE FDeleted = 0
|
|
|
AND client_id!=0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FMemo = B.FCardMemo
|
|
|
FROM jinan_at..TMember AS A,clients AS B
|
|
|
WHERE A.FMemId = B.FMemId
|
|
|
AND B.FCardMemo != ''
|
|
|
|
|
|
SELECT * FROM
|
|
|
|
|
|
SELECT * FROM clients WHERE FCardTypeId NOT IN(SELECT FId FROM jinan_at..TMemberCardType)
|
|
|
|
|
|
|
|
|
SELECT * FROM member_type
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.member_typename = b.type_name
|
|
|
FROM clients AS A,member_type AS B
|
|
|
WHERE A.member_typeId = b.type_id
|
|
|
|
|
|
|
|
|
SELECT * FROM jinan_at..TMemberCardType
|
|
|
|
|
|
|
|
|
INSERT INTO jinan_at..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 jinan_at..TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
|
|
|
FCompId AS FCompId,
|
|
|
FMemId AS FMemId,
|
|
|
1 AS FState,
|
|
|
FExpiredDate AS FCreateDate,
|
|
|
FExpiredDate,
|
|
|
0 AS FTotalTimes,
|
|
|
0 AS FUsedTimes,
|
|
|
FCompId AS FSaleCompId,
|
|
|
0 AS FSaleBillId,
|
|
|
'' AS FMemo
|
|
|
FROM clients
|
|
|
WHERE FDeleted = 0
|
|
|
AND FCardTypeId != 0
|
|
|
AND client_id!=0
|
|
|
|
|
|
|
|
|
UPDATE Clients SET FDeleted = 0
|
|
|
|
|
|
|
|
|
INSERT jinan_at..TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
|
|
|
SELECT FMemId,jinan_at.dbo.FNNewId(),FCardId AS FCardId,3,FBalance,FBalance,0,FCreateDate,null AS FExpiredDate,''
|
|
|
FROM clients AS A
|
|
|
WHERE FDeleted = 0
|
|
|
AND FCardTypeId != 0
|
|
|
AND client_id!=0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT jinan_at..TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
|
|
|
select jinan_at.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><EFBFBD><EFBFBD>'
|
|
|
FROM clients AS A
|
|
|
WHERE FDeleted = 0
|
|
|
AND FCardTypeId != 0
|
|
|
AND client_id!=0
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ŀ
|
|
|
CREATE TABLE TImpItem
|
|
|
(
|
|
|
FItemId BIGINT,
|
|
|
FCourseId BIGINT,
|
|
|
FNo VARCHAR(200),
|
|
|
FName VARCHAR(200)
|
|
|
)
|
|
|
INSERT TImpItem(FItemId,FCourseId,FNo,FName)
|
|
|
SELECT abs( CAST( CAST(newid() AS BINARY(16)) AS BIGINT)),abs( CAST( CAST(newid() AS BINARY(16)) AS BIGINT)),ps_id,ps_name
|
|
|
FROM TImpMemberCourse
|
|
|
GROUP BY ps_id,ps_name
|
|
|
|
|
|
|
|
|
INSERT jinan_at..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,FNo,FNo,FName,FName,0,jinan_at.dbo.FNGetFirstPinYin(FName),'',1,1,1,'','','',1,0,0,0,0,1,0,0,1,1
|
|
|
FROM TImpItem
|
|
|
|
|
|
|
|
|
INSERT jinan_at..TItemSub(FId,FCompId,FItemId,FPrice,FVipPrice,FTime,FDctId,FPointMode,FPointValue,FDeptId,FAllowBooking,FEnabled)
|
|
|
SELECT jinan_at.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 jinan_at..TItem AS I,jinan_at..TCompany AS C
|
|
|
WHERE I.FId != 0
|
|
|
AND C.FId != 0
|
|
|
AND I.FId IN(SELECT FItemId FROM TImpItem)
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO jinan_at.. TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
|
|
|
SELECT FCourseId,
|
|
|
FNo + '',
|
|
|
FName ,
|
|
|
jinan_at.dbo.FNGetFirstPinyin(FNo) AS FBriefCode,
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FCardTypeId BIGINT
|
|
|
ALTER TABLE TImpMemberCourse ADD FItemId BIGINT
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FRemainTimes INT
|
|
|
ALTER TABLE TImpMemberCourse ADD FPurTimes INT
|
|
|
ALTER TABLE TImpMemberCourse ADD FUsedTimes INT
|
|
|
ALTER TABLE TImpMemberCourse ADD FPurAmount DECIMAL(18,6)
|
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FCreateDate DATETIME
|
|
|
ALTER TABLE TImpMemberCourse ADD FExpiredDate DATETIME
|
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FCompId BIGINT
|
|
|
ALTER TABLE TImpMemberCourse ADD FCardId BIGINT
|
|
|
ALTER TABLE TImpMemberCourse ADD FMemId BIGINT
|
|
|
ALTER TABLE TImpMemberCourse ADD FMemo VARCHAR(1000)
|
|
|
|
|
|
UPDATE TImpMemberCourse SET FCardId = jinan_at.dbo.FNNewId(),FPurAmount = 0 WHERE FCardId IS NULL
|
|
|
|
|
|
UPDATE TImpMemberCourse SET FMemo =ISNULL( mt_comment,'')
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FMemId = B.FMemId
|
|
|
FROM TImpMemberCourse AS A,clients AS B
|
|
|
WHERE A.client_id = B.client_id
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FCardTypeId = B.FId,
|
|
|
A.FItemId = B.FItemId
|
|
|
FROM TImpMemberCourse AS A,jinan_at..TCourse AS B
|
|
|
WHERE a.ps_name = b.FName
|
|
|
|
|
|
select * from TImpMemberCourse
|
|
|
|
|
|
select * from TImpItem WHERE FName NOT IN(SELECT FName FROM jinan_at..TCourse)
|
|
|
|
|
|
UPDATE TImpMemberCourse SET FPurTimes = times
|
|
|
UPDATE TImpMemberCourse SET FUsedTimes = times - rest_times
|
|
|
UPDATE TImpMemberCourse SET FPurAmount = (reset_amount / rest_times) * times
|
|
|
UPDATE TImpMemberCourse SET FPurAmount = 0 WHERE FPurAmount IS NULL
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCourse SET FCompId = jinan_at.dbo.FNCompId('001')
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCourse WHERE FPurTimes IS NULL
|
|
|
|
|
|
UPDATE TImpMemberCourse SET FCreateDate = sale_date,FExpiredDate = null
|
|
|
|
|
|
|
|
|
|
|
|
INSERT jinan_at..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,0
|
|
|
FROM TImpMemberCourse AS A
|
|
|
WHERE FMemId IN(SELECT FMemId FROM jinan_at..TMember)
|
|
|
|
|
|
SELECT * FROM TImpMemberCourse WHERE FCardTypeId NOT IN(SELECT FId FROM jinan_at..TCourse)
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO jinan_at..TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,FCompId,FBillType,FBizType,FBillId,FBillNo,FBillDetailId,FRecordTime)
|
|
|
SELECT jinan_at.dbo.FNNewId(),FMemId,A.FCardId AS FCardId,0, ISNULL(FCardTypeId,0),getdate(),FPurTimes,0,FUsedTimes,0,FCompId,'DR','Import',0,'',0,getdate()
|
|
|
FROM TImpMemberCourse AS A
|
|
|
|
|
|
|
|
|
SELECT * FROM jinan_at..TMemberCardTypeCross
|
|
|
WHERE FCompId = jinan_at.dbo.FNCompId('006')
|
|
|
|
|
|
|
|
|
|
|
|
SELECT salon_code FROM history
|
|
|
group by salon_code
|
|
|
|
|
|
|
|
|
SELECT * FROM history_detail
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ʷ
|
|
|
ALTER TABLE history ADD FMemId BIGINT
|
|
|
ALTER TABLE history ADD FCompId BIGINT
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FMemId = B.FMemId
|
|
|
FROM clients AS B,history AS A
|
|
|
WHERE B.client_id = A.client_id
|
|
|
|
|
|
INSERT jinan_at.dbo.TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
|
|
|
SELECT jinan_at.dbo.FNNewId(),A.FMemId,A.app_date,0,A.FCompId,'DR','Import',a.ticket_id,ps_name,b.amount,1,b.amount,'',isnull(employee_name,'') + ',' + isnull(assistant_name,'') + ',' + isnull(employee3_name,''),''
|
|
|
FROM history AS A ,history_detail AS B
|
|
|
WHERE a.ticket_id = b.ticket_id
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE tickets ADD FMemId BIGINT
|
|
|
ALTER TABLE tickets ADD FCompId BIGINT
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FMemId = B.FMemId,
|
|
|
a.FCOMPID = B.FCompId
|
|
|
FROM clients AS B,tickets AS A
|
|
|
WHERE B.client_id = A.client_id
|
|
|
|
|
|
INSERT jinan_at.dbo.TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
|
|
|
SELECT jinan_at.dbo.FNNewId(),A.FMemId,A.app_date,0,A.FCompId,'DR','Import',a.ticket_id,ps_name,b.amount,1,b.amount,'',isnull(employee_name,'') + ',' + isnull(assistant_name,'') + ',' + isnull(employee3_name,''),''
|
|
|
FROM tickets AS A ,tickets_detail AS B
|
|
|
WHERE a.ticket_id = b.ticket_id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--Ƿ<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>˻<EFBFBD>Ƿ<EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
SELECT tickets.client_id,
|
|
|
tickets_detail.detail_id,
|
|
|
tickets_detail.ticket_id,
|
|
|
tickets_detail.amount,
|
|
|
tickets_detail.tail_amount,
|
|
|
tickets_detail.return_tailamount,
|
|
|
tickets_detail.return_tail,
|
|
|
tickets_detail.ps_seq,
|
|
|
tickets_detail.ps_id,
|
|
|
tickets_detail.ps_name,
|
|
|
tickets_detail.ps_type ,
|
|
|
tickets.category_id
|
|
|
INTO TImpArrear_Card
|
|
|
FROM tickets_detail,
|
|
|
tickets
|
|
|
WHERE ( tickets_detail.ticket_id = tickets.ticket_id ) and
|
|
|
( ( tickets.client_id = tickets.client_id ) AND
|
|
|
( tickets.status = 'F' ) AND
|
|
|
( tickets.pay_mark = 'Y' ) AND
|
|
|
( tickets_detail.ps_type = 'Z' ) AND
|
|
|
( (tickets_detail.tail_amount - tickets_detail.return_tailamount) > 0 ) )
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpArrear_Card ADD
|
|
|
FMemId BIGINT,
|
|
|
FCardId BIGINT,
|
|
|
FCompId BIGINT,
|
|
|
FAcctId BIGINT,
|
|
|
FArrear DECIMAL(18,6)
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FMemId = B.FMemId,
|
|
|
A.FCardId = B.FCardId,
|
|
|
A.FCompId = B.FCompId,
|
|
|
A.FAcctId = 3,
|
|
|
A.FArrear = A.tail_amount
|
|
|
FROM TImpArrear_Card AS A,clients AS B
|
|
|
WHERE A.client_id = B.client_Id
|
|
|
|
|
|
INSERT jinan_at..TMemberArrear(FId,FMemId,FTime,FCompId,FContentType,FCardId,FBillType,FBizType,FTransId,FTransNo,FTransDetailId,FContentId,FArrear,FEmpId,FRepaid,FAcctArrear)
|
|
|
SELECT jinan_at.dbo.FNNewId(),A.FMemId,getdate(),A.FCompId,'Account',A.FCardId,'DR_KK','DR_CardSale',0,'',0,A.FAcctId,A.FArrear,0,0,0
|
|
|
FROM TImpArrear_Card AS A
|
|
|
WHERE FMemId IN(SELECT FMemId from jinan_at..TMember)
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƷǷ<EFBFBD><EFBFBD>
|
|
|
SELECT tickets.client_id ,
|
|
|
tickets_detail.detail_id,
|
|
|
tickets_detail.ticket_id,
|
|
|
tickets_detail.amount,
|
|
|
tickets_detail.tail_amount,
|
|
|
tickets_detail.return_tailamount,
|
|
|
tickets_detail.return_tail,
|
|
|
tickets_detail.ps_seq,
|
|
|
tickets_detail.ps_id,
|
|
|
(case when abs(tickets_detail.num)=1 then tickets_detail.ps_name else tickets_detail.ps_name+'<EFBFBD>ο<EFBFBD>' end) as ps_name,
|
|
|
tickets_detail.ps_type,
|
|
|
tickets.category_id
|
|
|
INTO TImpArrear_Item
|
|
|
FROM tickets_detail,
|
|
|
tickets
|
|
|
WHERE ( tickets_detail.ticket_id = tickets.ticket_id ) and
|
|
|
( ( tickets.client_id = tickets.client_id ) AND
|
|
|
( tickets.status = 'F' ) AND
|
|
|
( tickets.pay_mark = 'Y' ) AND
|
|
|
( tickets_detail.ps_type = 'S' ) AND
|
|
|
( (tickets_detail.tail_amount - tickets_detail.return_tailamount )> 0 ) )
|
|
|
|
|
|
|
|
|
SELECT tickets.client_id,
|
|
|
tickets_detail.detail_id,
|
|
|
tickets_detail.ticket_id,
|
|
|
tickets_detail.amount,
|
|
|
tickets_detail.tail_amount,
|
|
|
tickets_detail.return_tailamount,
|
|
|
tickets_detail.return_tail,
|
|
|
tickets_detail.ps_seq,
|
|
|
tickets_detail.ps_id,
|
|
|
tickets_detail.ps_name,
|
|
|
tickets_detail.ps_type,
|
|
|
tickets.category_id
|
|
|
INTO TImpArrear_Goods
|
|
|
FROM tickets_detail,
|
|
|
tickets
|
|
|
WHERE ( tickets_detail.ticket_id = tickets.ticket_id ) and
|
|
|
( ( tickets.client_id = tickets.client_id ) AND
|
|
|
( tickets.status = 'F' ) AND
|
|
|
( tickets.pay_mark = 'Y' ) AND
|
|
|
( tickets_detail.ps_type = 'P' ) AND
|
|
|
( (tickets_detail.tail_amount - tickets_detail.return_tailamount )> 0 ) )
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpArrear_Item ADD
|
|
|
FMemId BIGINT,
|
|
|
FCardId BIGINT,
|
|
|
FCompId BIGINT,
|
|
|
FArrear DECIMAL(18,6)
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FMemId = B.FMemId,
|
|
|
A.FCardId = B.FCardId,
|
|
|
A.FCompId = B.FCompId,
|
|
|
A.FArrear = A.tail_amount
|
|
|
FROM TImpArrear_Item AS A,clients AS B
|
|
|
WHERE A.client_id = B.client_Id
|
|
|
|
|
|
INSERT jinan_at.dbo.TMemberArrear(FId,FMemId,FTime,FCompId,FContentType,FCardId,FBillType,FBizType,FTransId,FTransNo,FTransDetailId,FContentId,FArrear,FEmpId,FRepaid)
|
|
|
SELECT jinan_at.dbo.FNNewId(),A.FMemId,getdate(),A.FCompId,'DR_ItemGoods',A.FCardId,'DR_XF','DR_Consume',0,'',0,0,A.FArrear,0,0
|
|
|
FROM TImpArrear_Item AS A
|
|
|
WHERE FMemId IN(SELECT FMemId from jinan_at..TMember)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpArrear_Goods ADD
|
|
|
FMemId BIGINT,
|
|
|
FCardId BIGINT,
|
|
|
FCompId BIGINT,
|
|
|
FArrear DECIMAL(18,6)
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
SET A.FMemId = B.FMemId,
|
|
|
A.FCardId = B.FCardId,
|
|
|
A.FCompId = B.FCompId,
|
|
|
A.FArrear = A.tail_amount
|
|
|
FROM TImpArrear_Goods AS A,clients AS B
|
|
|
WHERE A.client_id = B.client_Id
|
|
|
|
|
|
INSERT jinan_at.dbo.TMemberArrear(FId,FMemId,FTime,FCompId,FContentType,FCardId,FBillType,FBizType,FTransId,FTransNo,FTransDetailId,FContentId,FArrear,FEmpId,FRepaid)
|
|
|
SELECT jinan_at.dbo.FNNewId(),A.FMemId,getdate(),A.FCompId,'DR_ItemGoods',A.FCardId,'DR_XF','DR_Consume',0,'',0,0,A.FArrear,0,0
|
|
|
FROM TImpArrear_Goods AS A
|
|
|
WHERE FMemId IN(SELECT FMemId from jinan_at..TMember)
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpArrear_Item
|
|
|
|
|
|
SELECT * FROM clients WHERE client_id = 3079
|
|
|
|