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.
238 lines
10 KiB
238 lines
10 KiB
use qsf
|
|
|
|
|
|
select a.Auto_ID as [No],a.Auto_ID,a.MemberNo,a.CardNumber,a.ConsumerPWD,a.MemberName,a.Sex,convert(varchar(10),convert(datetime,a.Birthday),120) as birthday
|
|
,a.LunarSolar,a.Age,a.Origin,f.DataName AS DataNameF,a.Education,g.DataName AS DataNameG,a.ContactPhone,a.Telephone,a.Address,a.QQMSN,a.Email,a.DocumentTypes,h.DataName AS DataNameH,a.DocumentNum,a.PhotoName,a.PhotoPath,a.MemberSource,k.DataName AS DataNameK,z.CardNumber as CardNumberZ,a.LowerIncentive,a.LowerBonus,a.LowerNum,a.CardStatus_Sign,'' as Changed_CardNumber,b.Surplus_Amount,b.Consumer_Amount,b.Arrears_Amount,b.Grants_Surplus_Amount,b.Grants_Consumer_Amount,a.Membership_Card_ID,c.Membership_Card_Name,c.ItemDiscount,c.DiscountMerchandise,d.Surplus_Points,d.Used_Points,
|
|
convert(varchar(10),a.For_Date) For_Date,a.MemberID,m.Staff_Name,a.Member_Modes,a.SelNumber
|
|
INTO TImpMember
|
|
from JiNan_PiaoSiFang_Old..DB_B02 a
|
|
left join JiNan_PiaoSiFang_Old..DB_A05_2 f on a.Origin=f.DataID and f.DataTypeID='0032' and f.V_DeleteFlg='0'
|
|
left join JiNan_PiaoSiFang_Old..DB_A05_2 g on a.Education=g.DataID and g.DataTypeID='0024' and g.V_DeleteFlg='0'
|
|
left join JiNan_PiaoSiFang_Old..DB_A05_2 h on a.DocumentTypes=h.DataID and h.DataTypeID='0033' and h.V_DeleteFlg='0'
|
|
left join JiNan_PiaoSiFang_Old..DB_A05_2 k on a.MemberSource=k.DataID and k.DataTypeID='0038' and k.V_DeleteFlg='0'
|
|
left join JiNan_PiaoSiFang_Old..DB_B04 b on a.MemberNo=b.MemberNo and b.V_DeleteFlg='0'
|
|
left join JiNan_PiaoSiFang_Old..DB_B00 c on a.Membership_Card_ID=c.Membership_Card_ID and c.V_DeleteFlg='0'
|
|
left join JiNan_PiaoSiFang_Old..DB_B06 d on a.MemberNo=d.MemberNo and d.V_DeleteFlg='0'
|
|
left join JiNan_PiaoSiFang_Old..DB_D01 m on a.MemberID=m.MemberID and m.V_DeleteFlg='0' and m.Work_Status='00000002'
|
|
left join JiNan_PiaoSiFang_Old..DB_B02 z on a.SuperiorNum=z.MemberNo and z.V_DeleteFlg='0'
|
|
where 1=1
|
|
order by a.Auto_ID desc
|
|
|
|
|
|
|
|
|
|
--»áÔ±
|
|
ALTER TABLE TImpMember ADD FMemId BIGINT
|
|
ALTER TABLE TImpMember ADD FCardId BIGINT
|
|
ALTER TABLE TImpMember ADD FCardTypeName VARCHAR(100)
|
|
ALTER TABLE TImpMember ADD FMemNo VARCHAR(50)
|
|
ALTER TABLE TImpMember ADD FCardNo VARCHAR(50)
|
|
ALTER TABLE TImpMember ADD FName VARCHAR(50)
|
|
ALTER TABLE TImpMember ADD FGender INT
|
|
ALTER TABLE TImpMember ADD FMobile VARCHAR(50)
|
|
ALTER TABLE TImpMember ADD FBirthdayType VARCHAR(50)
|
|
ALTER TABLE TImpMember ADD FBirthday DATETIME
|
|
ALTER TABLE TImpMember ADD FCompId BIGINT
|
|
ALTER TABLE TImpMember ADD FCardTypeId BIGINT
|
|
ALTER TABLE TImpMember ADD FMemo VARCHAR(MAX)
|
|
ALTER TABLE TImpMember ADD FBalance DECIMAL(18,6)
|
|
ALTER TABLE TImpMember ADD FBalance2 DECIMAL(18,6)
|
|
ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6)
|
|
ALTER TABLE TImpMember ADD FCreateDate DATETIME
|
|
ALTER TABLE TImpMember ADD FExpiredDate DATETIME
|
|
|
|
|
|
|
|
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 =CAST('1' + Membership_Card_Id AS BIGINT), Membership_Card_Name,Membership_Card_Name as 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 TImpMember
|
|
group BY Membership_Card_Id,Membership_Card_Name
|
|
|
|
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 > 0
|
|
AND C.FDeleted = 0
|
|
|
|
SELECT * FROM TImpMember WHERE cardnumber = '015729'
|
|
|
|
UPDATE TImpMember SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
|
|
UPDATE TImpMember SET FMemId = dbo.FNNewId() WHERE FMemId IS NULL
|
|
|
|
|
|
UPDATE TImpMember SET FName = MemberName
|
|
UPDATE TImpMember SET FMobile = ContactPhone
|
|
UPDATE TImpMember SET FMemNO = CardNumber
|
|
UPDATE TImpMember SET FCardNo = CardNumber
|
|
UPDATE TImpMember SET FCompId = 1
|
|
UPDATE TImpMember SET FGender = CASE WHEN sex != 2 THEN 1 ELSE 0 END
|
|
UPDATE TImpMember SET FMemo = ISNULL(remark,'')
|
|
UPDATE TImpMember SET FMemo = '' WHERE FMemo IS NULL
|
|
UPDATE TImpMember SET FPoint = Surplus_Points
|
|
UPDATE TImpMember SET FBirthday = birthday,FBirthdayType = 'G'
|
|
|
|
|
|
UPDATE TImpMember SET FBalance = Surplus_Amount
|
|
UPDATE TImpMember SET FBalance2 = Grants_Surplus_Amount
|
|
|
|
|
|
|
|
UPDATE TImpMember SET FExpiredDate = dateadd(year,100,FCreateDate) where FExpiredDate IS NULL
|
|
|
|
UPDATE TImpMember SET FCreateDate = For_Date
|
|
UPDATE TImpMember SET FExpiredDate = DATEADD(YEAR,100,For_Date)
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
SET A.FCardTypeId = CAST('1' + Membership_Card_Id AS BIGINT)
|
|
FROM TImpMember AS A
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
FCreateDate 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,
|
|
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
|
|
from TImpMember
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
1 AS FState,
|
|
FCreateDate AS FCreateDate,
|
|
FExpiredDate AS FExpiredDate,
|
|
0 AS FTotalTimes,
|
|
0 AS FUsedTimes,
|
|
FCompId AS FSaleCompId,
|
|
0 AS FSaleBillId,
|
|
FMemo AS FMemo
|
|
FROM TImpMember
|
|
WHERE FName IS 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
|
|
|
|
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(),'´ÓÀÏϵͳÖе¼Èë'
|
|
FROM TImpMember AS A
|
|
WHERE FCardTypeId IS NOT NULL
|
|
|
|
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 TImpMember
|
|
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(),'´ÓÀÏϵͳÖе¼Èë'
|
|
FROM TImpMember AS A
|
|
WHERE FBalance2 > 0
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember
|
|
--ÀúÊ·
|
|
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,
|
|
FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
|
|
select a.Auto_ID as FId,M.FMemId,a.For_Date,M.FCardId,1 AS FCompId,'DR','', a.Consumer_Doc_No,
|
|
CASE WHEN a.Consumer_Type='1' THEN 'ÉÌÆ·' WHEN a.Consumer_Type='2' and a.Consumer_sign='1' THEN 'ÏîÄ¿' WHEN a.Consumer_Type='2' and a.Consumer_sign='2' THEN 'ÁƳÌ' WHEN a.Consumer_Type='2' and a.Consumer_sign='3' THEN 'ÁƳÌ' WHEN a.Consumer_Type='2' and a.Consumer_sign='4' THEN 'ÏîÄ¿' WHEN a.Consumer_Type='3' THEN '°ìÀí' WHEN a.Consumer_Type='4' THEN '³äÖµ' ElSE '' END AS MC_Type,
|
|
Actual_Payment_Amount,1,Actual_Payment_Amount,'','',''
|
|
/*
|
|
a.MemberNo,a.CardNumber,b.MemberName,a.Consumer_Type,a.Consumer_sign,
|
|
a.Product_Item_ID,'' as ProName,a.Should_Payment_Amount,a.Actual_Payment_Amount,a.Actual_Arrears_Amount,a.Item_Discount_Number,a.Actual_Cash_Amount,a.Actual_CreditCard_Amount,a.Actual_Points,a.Actual_MortgageValue,a.Actual_Free_Amount,a.MemberID_List,'' as MemberID1,'' as MemberID2,'' as MemberID3,'' as MemberID4
|
|
*/
|
|
from JiNan_PiaoSiFang_Old..DB_E02 a
|
|
left join JiNan_PiaoSiFang_Old..DB_B02 b on a.MemberNo=b.MemberNo and b.V_DeleteFlg='0' and b.CardStatus_Sign='0'
|
|
INNER JOIN TImpMember AS M ON M.MemberNo = A.MemberNo
|
|
where a.V_DeleteFlg='0' and a.MX_Checkout_Sign='4'
|
|
--and a.CardNumber='015729'
|
|
order by a.Auto_ID desc
|
|
|
|
|
|
|
|
--Ïû·ÑÀúÊ·
|
|
ALTER TABLE TImpMemberTransHist ADD FCompId BIGINT
|
|
ALTER TABLE TImpMemberTransHist ADD FMemId BIGINT
|
|
ALTER TABLE TImpMemberTransHist ADD FCardId BIGINT
|
|
|
|
|
|
UPDATE A
|
|
SET A.FCompId = B.FCompId
|
|
FROM TMemberOldTransHist AS A,TImpMember AS B
|
|
WHERE A.MemId = B.Id
|
|
|
|
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
|
|
SELECT dbo.FNNewId(),20000+MemId,LEFT(A.CreateTime,4) + '-' + SUBSTRING(CreateTime,5,2) + '-' + SUBSTRING(CreateTime,7,2),30000+MemId,A.FCompId,
|
|
'DR','Import',ISNULL(A.OrderCode,''), B.GoodsName,B.Price,B.Number,B.DiscountPrice,B.DiscountPrice,'',''
|
|
FROM OrderLog AS A,OrderDetail AS B
|
|
WHERE A.OrderCode = B.OrderCode
|
|
|
|
|