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/美约/yexin.sql

222 lines
7.9 KiB

1 year ago
use jinan_meiyue
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ALTER TABLE TImpCardType_Y ADD FId AS 20000 + id
ALTER TABLE TImpCardType_Y ADD FNo AS 'Y_' + kaleixing
ALTER TABLE TImpCardType_Y ADD FName AS 'Y_' + kaleixing
SELECT * FROM TImpMember_Y
--<EFBFBD><EFBFBD>Ա
ALTER TABLE TImpMember_Y ADD FMemId BIGINT
ALTER TABLE TImpMember_Y ADD FCardId BIGINT
ALTER TABLE TImpMember_Y ADD FCardTypeName VARCHAR(100)
ALTER TABLE TImpMember_Y ADD FMemNo VARCHAR(50)
ALTER TABLE TImpMember_Y ADD FCardNo VARCHAR(50)
ALTER TABLE TImpMember_Y ADD FName VARCHAR(50)
ALTER TABLE TImpMember_Y ADD FGender INT
ALTER TABLE TImpMember_Y ADD FMobile VARCHAR(50)
ALTER TABLE TImpMember_Y ADD FBirthdayType VARCHAR(50)
ALTER TABLE TImpMember_Y ADD FBirthday DATETIME
ALTER TABLE TImpMember_Y ADD FCompId BIGINT
ALTER TABLE TImpMember_Y ADD FCardState INT
ALTER TABLE TImpMember_Y ADD FCardTypeId BIGINT
ALTER TABLE TImpMember_Y ADD FCreateDate DATETIME
ALTER TABLE TImpMember_Y ADD FExpiredDate DATETIME
ALTER TABLE TImpMember_Y ADD FMemo VARCHAR(MAX)
ALTER TABLE TImpMember_Y ADD FBalance DECIMAL(18,6)
ALTER TABLE TImpMember_Y ADD FBalance2 DECIMAL(18,6)
ALTER TABLE TImpMember_Y ADD FDeleted BIT
ALTER TABLE TImpMember_Y ADD FPoint DECIMAL(18,6)
UPDATE TImpMember_Y SET FMemId = 20000 + id
UPDATE TImpMember_Y SET FCardId = 30000 + id
UPDATE TImpMember_Y SET FMemNo = cardno
UPDATE TImpMember_Y SET FCardNo = cardno
UPDATE TImpMember_Y SET FName = mingcheng
UPDATE TImpMember_Y SET FMobile = dianhua
UPDATE TImpMember_Y SET FMemo = area
UPDATE TImpMember_Y SET FGender = CASE WHEN personsex = '<EFBFBD><EFBFBD>' THEN 1 ELSE 0 END
UPDATE TImpMember_Y SET FBalance = ye
UPDATE TImpMember_Y SET FBirthdayType = 'G'
SELECT * FROM TImpMember_Y WHERE FCardTypeId IS NULL
UPDATE TImpMember_Y SET FPoint = jifen
UPDATE TImpMember_Y SET FCreateDate = buyfirst
UPDATE TImpMember_Y SET FExpiredDate = yxriqi
UPDATE TImpMember_Y SET FCardState = 1
UPDATE TImpMember_Y SET FCompId = dbo.FNCompId('004')
SELECT * FROM TCompany
UPDATE A
SET A.FCardTypeId = B.FId
FROM TImpMember_Y AS A,TImpCardType_Y AS B
WHERE A.cardkind = B.kaleixing
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 , 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_y
INSERT INTO TMemberCardTypeSub(FId,FCompId,FCardTypeId,FAllowSale,FAllowRchg,FEnabled)
SELECT dbo.FNNewId(),C.FId,I.FId,FAllowSale,FAllowRchg,FEnabled
FROM TMemberCardType AS I,TCompany AS C
WHERE I.FId > 1
AND C.FId = dbo.FNCompId('004')
AND I.FId IN(SELECT FId FROM TImpCardType_Y)
UPDATE TImpMember_Y SET FCardNO = 'Y' + FCardNo WHERE FCardNo IN(SELECT FCardNo FROM TImpMember)
UPDATE TImpMember_Y SET FMemNo= FCardNo
SELECT * FROM TImpMember_Y WHERE FCardNo IN(SELECT FCardNo FROM TImpMember)
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 ,GETDATE()) 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,
0 AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
'' AS FMemo,
'ҵ<EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD>' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TImpMember_Y
WHERE FCardTypeId IS NOT NULL
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
FCardId AS FId,
FMemNo AS FNo,
FCardTypeId AS FTypeId,
(SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
FCompId AS FCompId,
FMemId AS FMemId,
FCardState AS FState,
FCreateDate AS FCreateDate,
FExpiredDate = ISNULL(FExpiredDate,DATEADD(YEAR,100,FCreateDate)),
0 AS FTotalTimes,
0 AS FUsedTimes,
FCompId AS FSaleCompId,
0 AS FSaleBillId,
ISNULL(FMemo,'') AS FMemo
FROM TImpMember_Y
WHERE FCardTypeId IS NOT NULL
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 TImpMember_Y
WHERE FCardTypeId 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.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 TImpMember_Y AS A
WHERE FCardTypeId IS NOT NULL
SELECT * FROM TImpMemberTransHist_Y
SELECT * FROM TImpMemberInfo
DROP TABLE TImpMemberINfo
ALTER TABLE TImpMemberTransHist ALTER COLUMN M_TotalPayment VARCHAR(7000)
drop table TImpMemberTransHist
select * from tcompany
SELECT * FROM TImpMemberTransHist_Y
SELECT LEN('<Item><C_Name><EFBFBD>߼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ů<EFBFBD><EFBFBD></C_Name><I_TreatmentID>0</I_TreatmentID><I_ItemID>31</I_ItemID><I_AccountType>-1</I_AccountType><M_Price>0.0000</M_Price><M_BasePrice>0.0000</M_BasePrice><I_AccountID>0</I_AccountID><yj>150.0000</yj><DetailID>75545</DetailID><I_StepID>0</I_StepID><M_RealPrice>150.0000</M_RealPrice><Detail><CutID>156990</CutID><c_num>111</c_num><I_Assign>0</I_Assign><ygxm><EFBFBD><EFBFBD><EFBFBD><EFBFBD></ygxm><C_RuleName><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʦ</C_RuleName><C_Assign><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD></C_Assign><ygyj>150.0000</ygyj><tc>8.0000</tc><sg>0.0000</sg><I_WorkerID>237</I_WorkerID><I_LevelID>1</I_LevelID><I_RuleID>2</I_RuleID><M_CardAchievement>0.0000</M_CardAchievement><M_MoneyAchievement>150.0000</M_MoneyAchievement></Detail></Item>')
DROP TABLE TImpMemberTransHist_Y
ALTER TABLE TImpMemberTransHist_Y ADD FMemId BIGINT
ALTER TABLE TImpMemberTransHist_Y ADD FBizType VARCHAR(30)
ALTER TABLE TImpMemberTransHist_Y ADD FAmount DECIMAL(18,6)
ALTER TABLE TImpMemberTransHist_Y ADD FCompId BIGINT
ALTER TABLE TImpMemberTransHist_Y ADD FTime DATETIME
UPDATE TImpMemberTransHist_Y SET FCompId = dbo.FNCompId('004')
UPDATE TImpMemberTransHist_Y SET FBizType = jzlx
UPDATE TImpMemberTransHist_Y SET FAmount = jine
UPDATE TImpMemberTransHist_Y SET FTime = buyriqi
UPDATE A
SET A.FMemId = B.FMemId
FROM TImpMemberTransHist_Y AS A,TImpMember_Y AS B
WHERE A.hycardno = B.FCardNo
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT ID,A.FMemId,A.FTime,0,A.FCompId,'DR','Import','','',FAmount,1,FAmount,'','',''
FROM TImpMemberTransHist_Y AS A
WHERE ISNULL(FMemId,0) != 0