You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sql-tools/Import/0530shaxuan_info_guest.sql

177 lines
11 KiB

1 year ago
use heze_shaxuan_old
SELECT * FROM info_guest
SELECT * INTO info_cardtype FROM heze_shaxuan_old..info_cardtype
SELECT * INTO info_guest FROM heze_shaxuan_old..info_guest
SELECT * INTO vip_card FROM heze_shaxuan_old..vip_card
SELECT * INTO selled_total from heze_shaxuan_old..selled_total
select * from vip_card
SELECT info_guest.guest_name, info_guest.guest_sex, info_guest.guest_htel, vip_card.card_code, vip_card.card_type, vip_card.guest_code, vip_card.goods_vip, vip_card.server_vip, vip_card.bz, vip_card.card_nowmoney, info_guest.guest_jtel, info_guest.guest_wtel FROM info_guest, vip_card WHERE ( info_guest.guest_code = vip_card.guest_code ) and ( info_guest.guest_name = '' OR '' = '') AND ( info_guest.guest_sex = '' OR '' = '') AND (info_guest.guest_htel = '' OR '' = '') AND (vip_card.card_code = '' OR '' = '') ORDER BY info_guest.guest_code go SELECT selled_total.sell_date, selled_total.sell_time, selled_total.consume_kind, selled_total.consume_code, selled_total.consume_name, selled_total.seller_code, selled_total.consume_price_o, selled_total.consume_price_n, selled_total.amount, selled_total.guest_code, selled_total.amount * selled_total.consume_price_n as ss_money, selled_total.amount * (selled_total.consume_price_o - selled_total.consume_price_n) as vip_money FROM selled_total where guest_code='0326' ORDER BY selled_total.guest_code ASC go SELECT vip_card.card_code, vip_card.input_date, vip_card.input_user, vip_card.give_date, vip_card.give_user, vip_card.end_date, vip_card.card_data, vip_card.shop_code, vip_card.guest_code, vip_card.card_type, vip_card.bz, vip_card.pay_ment FROM vip_card WHERE vip_card.guest_code = '0326' go SELECT selled_total.sell_date, selled_total.sell_time, selled_total.consume_kind, selled_total.consume_code, selled_total.consume_name, selled_total.seller_code, selled_total.consume_price_o, selled_total.consume_price_n, selled_total.amount, selled_total.guest_code, selled_total.amount * selled_total.consume_price_n as ss_money, selled_total.amount * (selled_total.consume_price_o - selled_total.consume_price_n) as vip_money FROM selled_total where guest_code='0326' ORDER BY selled_total.guest_code ASC go SELECT data_cardhis.card_code , data_cardhis.guest_code , data_cardhis.guest_name , data_cardhis.do_date , data_cardhis.do_time , data_cardhis.do_kind , data_cardhis.remain , data_cardhis.trad_money , data_cardhis.vip_money , data_cardhis.yingshou , data_cardhis.yishou , data_cardhis.weishou , data_cardhis.keyong , data_cardhis.payment , data_cardhis.pay_ment , data_cardhis.bz , data_cardhis.ku_code FROM data_cardhis WHERE ( card_code = '0326' ) ORDER BY data_cardhis.do_date ASC, data_cardhis.do_time ASC go SELECT * FROM info_guest SELECT * FROM vip_card
ALTER TABLE info_guest ADD mem_id BIGINT
ALTER TABLE info_guest ADD mem_no VARCHAR(50)
ALTER TABLE info_guest ADD name VARCHAR(50)
ALTER TABLE info_guest ADD gender INT
ALTER TABLE info_guest ADD mobile VARCHAR(50)
ALTER TABLE info_guest ADD create_date DATETIME
ALTER TABLE info_guest ADD comp_id BIGINT
ALTER TABLE info_guest ADD memo VARCHAR(1000)
ALTER TABLE info_guest ADD point DECIMAL(18,6)
ALTER TABLE info_guest ADD birthday DATETIME
ALTER TABLE info_guest ADD birthday_Type CHAR
ALTER TABLE info_guest ADD deleted bit
update info_guest set mem_id = dbo.FNNewId() WHERE mem_Id is null update info_guest set mem_no = guest_code update info_guest set name = guest_name update info_guest set gender = case when isnull(guest_sex,'<EFBFBD><EFBFBD>') = '<EFBFBD><EFBFBD>' then 1 else 0 end update info_guest set birthday_type = 'G' update info_guest set birthday = guest_birthday update info_guest set mobile = isnull(guest_htel,guest_jtel) update info_guest set deleted = isnull(deleted_flag,0) delete info_guest where guest_code = '' and guest_name = '' UPDATE info_guest set comp_id = 1 update a set a.create_date = b.input_date from info_guest as a,( select guest_code ,min(input_date) as input_date from vip_card group by guest_code) as b where a.guest_code = b.guest_code select * from vip_card ALTER TABLE vip_card ADD mem_id BIGINT
ALTER TABLE vip_card ADD card_no VARCHAR(50)
ALTER TABLE vip_card ADD card_type_id BIGINT
ALTER TABLE vip_card ADD balance DECIMAL(18,6)
ALTER TABLE vip_card ADD balance2 DECIMAL(18,6)
ALTER TABLE vip_card ADD remain_times INT
ALTER TABLE vip_card ADD create_date DATETIME
ALTER TABLE vip_card ADD expire_date DATETIME
ALTER TABLE vip_card ADD comp_id BIGINT
ALTER TABLE vip_card ADD card_id BIGINT
ALTER TABLE vip_card ADD memo VARCHAR(1000)
alter table info_cardtype add id bigint
update info_cardtype set id = dbo.fnnewid()
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 =id,'L' + type_code,type_name,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 info_cardtype
update vip_card set card_id = dbo.fnnewid()
update vip_card set card_no = card_code
update a
set a.card_type_id = b.id
from vip_card as a,info_cardtype as b
where a.card_type = b.type_code
UPDATE A
set a.mem_id = b.mem_id
from vip_card as a,info_guest as b
where a.guest_code = b.guest_code
update vip_card set create_date = give_date
update vip_card set expire_date = dateadd(year,100,create_date)
update vip_card set balance = card_nowmoney
update vip_card set memo = isnull(bz,'')
update vip_card set comp_id = 1
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,
ISNULL(create_date ,'1900-01-01') 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,
ISNULL( point,0) AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
ISNULL(memo,'') AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from info_guest
where deleted = 0
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,
1 AS FState,
create_date AS FCreateDate,
expire_date AS FExpiredDate,
ISNULL(remain_times,0) AS FTotalTimes,
0 AS FUsedTimes,
comp_id AS FSaleCompId,
0 AS FSaleBillId,
ISNULL(memo,'' ) AS FMemo
FROM vip_card
where mem_id is not null
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT mem_id,dbo.FNNewId(),card_Id AS FCardId,3,balance,balance,0,create_date,NULL AS FExpiredDate,''
FROM vip_card AS A
WHERE mem_id is not null
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,3,getdate(),A.card_type_id,A.comp_id,'DR','Import',0,'',A.balance,0,A.balance,0,getdate(),'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
FROM vip_card AS A
WHERE mem_id is not null
SELECT * FROM vip_card where guest_code not in(select guest_code from info_guest)
SELECT selled_total.sell_date, selled_total.sell_time, selled_total.consume_kind, selled_total.consume_code, selled_total.consume_name, selled_total.seller_code, selled_total.consume_price_o, selled_total.consume_price_n, selled_total.amount, selled_total.guest_code, selled_total.amount * selled_total.consume_price_n as ss_money, selled_total.amount * (selled_total.consume_price_o - selled_total.consume_price_n) as vip_money FROM selled_total ORDER BY selled_total.guest_code ASC ALTER TABLE selled_total add comp_id bigint,mem_Id bigint UPDATE A SET A.comp_id = b.comp_id, a.mem_id = b.mem_Id from selled_total as a,info_guest as b where a.guest_code = b.guest_code INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT DBO.FNNewId(),A.mem_Id,sell_date +' ' + sell_time,0,A.comp_id,'DR','Import',sheet_code,consume_Name,consume_price_o,amount,consume_price_n,'',isnull('','') ,''
FROM selled_total AS A
where mem_id is not null
select * from selled_total