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

873 lines
28 KiB

use QingDao_YouYouJiangZi
UPDATE A
SET A.FAdjustPrice = B.FPrice
FROM TMemberCourse AS A,TItem AS B
WHERE A.FItemId = B.FId
SELECT * FROM TImpItem
ORDER BY code
SELECT * FROM TItem
{\"page\":1,\"size\":10,\"query\":[{\"field\":\"merchantId\",\"value\":1910279418984325}],\"sort\":[{\"field\":\"lastModifyDate\",\"sort\":\"desc\"}]}
SELECT * FROM TIMPCardType
SELECT * FROM TImpMemberFreeItem
SELECT * FROM TImpMember WHERE name like '%ÁõÑÇéª%'
SELECT * FROM TImpMemberCardFreeItem WHERE cardId = 2111521573577963
SELECT * FROM TImpMemberCardFreeItem WHERE cardId IN(1412177749656781,
2312540063848093,
2312975554089828)
SELECT * FROM TImpMemberCard WHERE memberId = 2111029626325444
IF NOT EXISTS(SELECT 1 FROM syscolumns WHERE name = 'FStartDate' AND id = object_id('TMemberCourse'))
BEGIN
ALTER TABLE TMemberCourse ADD FStartDate DATETIME NULL
END
GO
IF NOT EXISTS(SELECT 1 FROM syscolumns WHERE name = 'FStartDate' AND id = object_id('TCourse'))
BEGIN
ALTER TABLE TCourse ADD FStartDate DATETIME NULL
END
GO
IF NOT EXISTS(SELECT 1 FROM syscolumns WHERE name = 'FStartDateMode' AND id = object_id('TCourse'))
BEGIN
ALTER TABLE TCourse ADD FStartDateMode INT NOT NULL DEFAULT 1
END
GO
ALTER TABLE TImpItem ADD FId BIGINT
ALTER TABLE TImpItem ADD FNo VARCHAR(30)
ALTER TABLE TImpItem ADD FName VARCHAR(30)
ALTER TABLE TImpItem ADD FTypeId BIGINT
ALTER TABLE TImpItem ADD FPrice DECIMAL(18,6)
UPDATE TImpItem SET FName = name
UPDATE TImpItem SET FId = id
UPDATE TImpItem SET FNo = code
UPDATE TImpItem SET FTypeId = 0
UPDATE TImpItem SET FPrice = cast(sellingPrice as decimal(18,6))/ 100.0
UPDATE TItem SET FVipPrice = cast(FVipPrice as decimal(18,6))/ 100.0
UPDATE A
SET A.FTypeId = B.id
FROM TImpItem AS A,TImpItemType AS B
WHERE A.categoryLevel = B.code
UPDATE A
SET A.FTypeId = b.id
FROM TImpItem AS A,TImpItemType AS B,TImpItemKind AS C
WHERE A.categoryLevel = c.code
AND c.code = b.parentCode
AND A.FTypeId = 0
SELECT * FROM TImpItemType
ALTER TABLE TImpItem ADD FCourseId BIGINT
UPDATE TImpItem SET FCourseId = right(id,len(id)-1)
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)
SELECT id,FNo,FNo,FName,FName,FTypeId,FBriefCode = dbo.FNGetFirstPinYin(FName),
FDescription = '',FPriceMode = 0,FIsService = 1,FStatTimes = 1,FCustom1 = '',FCustom2 = '',
FCustom3 = '',FEnabled = 1,FPrice ,FVipPrice = Fprice ,FTime = 0,FDctId = 0 ,FDisplayTypeId = 0,
FPointMode = 0,FPointValue = 0,FDeptId = 0,FAllowBooking = 1
FROM TImpItem
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 = '009'
AND NOT EXISTS(SELECT TOP 1 1 FROM TItemSub AS B WHERE B.FCompId = C.FId AND B.FItemId = I.FId)
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT FCourseId AS FId,
I.FNo + 'L1',
I.FName ,
'' AS FBriefCode,
I.FId AS FItemId,
0 AS FPackId,
1 AS FSequence,
(SELECT TOP 1 FId FROM TBasicType WHERE FKey = 'CourseType') 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 AS I
ALTER TABLE TImpCardTypeItem ADD FId BIGINT
UPDATE TImpCardTypeItem SET FId = dbo.FNNewId()
--·Ö´Î¿¨¶¼µ¼³ÉÌײÍ
INSERT INTO TCoursePack(FId,FNo,FName,FBriefCode,FItemTimes,FGoodsQuantity,FValidityPeriod,FValidityPeriodUnit,FCreateDate,FBeginDate,FExpiredDate,FDescription,FPrice,FDeptId,FAcctId,FDeposit,FAcctId2,FDeposit2,FEnabled)
SELECT id,cardNo,name,'',0,0,1,1,getdate(),getdate(),null,'',price / 100,0,0,0,0,0,1
FROM TImpCardType WHERE type != 2
--·Ö´Î¿¨
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT dbo.FNNewId() AS FId,
dbo.FNNewId(),
'' ,
'' AS FBriefCode,
i.typeId AS FItemId,
cardTypeId AS FPackId,
1 AS FSequence,
(SELECT TOP 1 FId FROM TBasicType WHERE FKey = 'CourseType') AS FTypeId,
i.amount 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,
i. price / 100 AS FPrice,
0 AS FAmount,
1 AS FCalcMode
FROM TImpCardTypeItem AS I ,TImpCardType AS B
WHERE I.cardTypeId = B.id
AND B.type = 5
--×ܴο¨,Ïȵ¼Ò»¸ö, ÆäËûµÄµ¼³ÉÌæ»»ÏîÄ¿
drop table #TotalTimesItem
select FId,cardTypeId
INTO #TotalTimesItem
FROM (
select fid,cardTypeId,
row_number() over(partition by t.cardTypeId order by typeId ) rn
from TImpCardTypeItem t WHERE cardTypeId IN(SELECT id FROM TImpCardType WHERE type = 4)
) AS T
WHERE rn < 2
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT FId AS FId,
dbo.FNNewId(),
'' ,
'' AS FBriefCode,
i.typeId AS FItemId,
cardTypeId AS FPackId,
1 AS FSequence,
(SELECT TOP 1 FId FROM TBasicType WHERE FKey = 'CourseType') AS FTypeId,
b.deposit 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,
i. price / 100 AS FPrice,
0 AS FAmount,
1 AS FCalcMode
FROM TImpCardTypeItem AS I ,TImpCardType AS B
WHERE I.cardTypeId = B.id
AND B.type = 4
--ÕâÊÇ×ܴ卑ÄÖ÷ÏîÄ¿
AND FId IN
(
SELECT FID FROM #TotalTimesItem
)
--×ܴ卑ÄÌæ»»ÏîÄ¿
INSERT INTO TCourseContainItem(FId,FCourseId,FItemId)
SELECT dbo.FNNewId(),A.FId,B.typeId
FROM #TotalTimesItem AS A,TImpCardTypeItem AS B
WHERE A.cardTypeId = B.CardTypeId
AND a.fid != b.fid
--ʱ¶Î¿¨
drop table #TimeRangeItem
select FId,cardTypeId
INTO #TimeRangeItem
FROM (
select fid,cardTypeId,
row_number() over(partition by t.cardTypeId order by typeId ) rn
from TImpCardTypeItem t WHERE cardTypeId IN(SELECT id FROM TImpCardType WHERE type = 3)
AND type = 3
) AS T
WHERE rn < 2
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT FId AS FId,
dbo.FNNewId(),
'' ,
'' AS FBriefCode,
i.typeId AS FItemId,
cardTypeId AS FPackId,
1 AS FSequence,
(SELECT TOP 1 FId FROM TBasicType WHERE FKey = 'CourseType') AS FTypeId,
b.deposit 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,
i. price / 100 AS FPrice,
0 AS FAmount,
2 AS FCalcMode
FROM TImpCardTypeItem AS I ,TImpCardType AS B
WHERE I.cardTypeId = B.id
AND B.type = 3
AND I.type = 3
--ÕâÊÇ×ܴ卑ÄÖ÷ÏîÄ¿
AND FId IN
(
SELECT FID FROM #TimeRangeItem
)
--×ܴ卑ÄÌæ»»ÏîÄ¿
INSERT INTO TCourseContainItem(FId,FCourseId,FItemId)
SELECT dbo.FNNewId(),A.FId,B.typeId
FROM #TimeRangeItem AS A,TImpCardTypeItem AS B
WHERE A.cardTypeId = B.CardTypeId
AND a.fid != b.fid
AND B.type = 3
---
INSERT TBasicTypeSub(FBasicTypeId,FCompId)
SELECT A.FId,C.FId
FROM TBasicType AS A,TCompany AS C
WHERE A.FId > 0
AND C.FId > 0
--AND C.FNo = '009'
AND NOT EXISTS(SELECT TOP 1 1 FROM TBasicTypeSub AS B WHERE B.FCompId = C.FId AND B.FBasicTypeId = A.FId)
DELETE TItem WHERE FId > 0
DELETE TCourse WHERE FId > 0
SELECT* FROM TImpItemType
SELECT* FROM TImpItemKind
INSERT TBasicType(FId,FKey,FNo,FName,FParentId,FDescription,FImage,FCustom,FOrder,FAllowEdit,FENabled)
SELECT a.id,'ItemType',a.CODE,a.name,b.id,'','','',0,-1,1
FROM TImpItemType AS A ,TImpItemKind AS B
WHERE a.parentCode = b.code
INSERT TBasicType(FId,FKey,FNo,FName,FParentId,FDescription,FImage,FCustom,FOrder,FAllowEdit,FENabled)
SELECT id,'ItemKind',CODE,name,0,'','','',0,-1,1
FROM TImpItemKind
SELECT* FROM TBasicType
DELETE TBasicTypeSub WHERE FBasicTypeId IN(SELECT FId FROM TBasicType WHERE FKey = 'ItemType')
DELETE TBasicType WHERE FKey = 'ItemType'
DROP TABLE TImpItemType
SELECT* FROM TImpCardType WHERE type = 3
UPDATE TImpCardType SET FAllowRchg = 0 WHERE FAllowRchg IS NULL
UPDATE TImpCardType SET FAllowRchg = 1 WHERE FAllowRchg = '¡Ì'
UPDATE TImpCardType SET FAllowSale = 0 WHERE FAllowSale IS NULL
UPDATE TImpCardType SET FAllowSale = 1 WHERE FAllowSale = '¡Ì'
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 id,cardNo,name,1,FMaterial = 2,price,FCardFeeAmt = 0,FAcctId = 3,FDeposit = deposit,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,1 ,FEnabled =1,FOrder = 1
FROM TImpCardType
WHERE type = 2
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.FNo = '009'
AND NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId)
select * from TIMPmEMBER
select * from TIMPmEMBERCard
SELECT * FROM TImpMemberCardItem
SELECT * FROM TImpMemberCardFreeItem
SELECT * FROM TIMPmEMBERCard
WHERE id IN(SELECT cardId FROM TImpMemberCardItem
WHERE supportType = 3)
AND type = 2
SELECT * FROM TImpMemberCardItem
WHERE supportTypeName NOT IN ('ËùÓвúÆ·','ËùÓÐÏîÄ¿')
SELECT supportType FROM TImpMemberCardItem
GROUP BY supportType
SELECT * FROM TImpMemberCardItem
WHERE supportType = 3
SELECT * FROM TImpCardType WHERE type = 5
SELECT * FROM TImpMemberCard
WHERE type = 5
select cardId from TImpMemberCardItem
WHERE cardId IN(SELECT id FROM TImpMemberCard WHERE type = 4)
AND supportTypeId = '1910331938033877'
GROUP BY cardId
HAVING SUM(1) > 1
SELECT * FROM TImpMemberCard
WHERE id = 1411408875944420
SELECT * FROM TImpMember
WHERE memberId IN(SELECT memberId FROM TImpMemberCard WHERE type = 4)
SELECT * FROM TImpMemberCardItem WHERE cardId IN(SELECT cardId FROM TImpMemberCard WHERE type = 4)
AND supportTypeId NOT IN('2110416597201800','2','1411141759340759','1910331938033877')
select * from TImpMemberCardItem WHERE memberId = 1412128050701173
select memberId from TImpMemberCardItem WHERE cardId = 1411840692256303
select * from TIMPmEMBER WHERE memberId = 2312584342215214
WHERE memberId nOT IN(SELECT memberId FROM TIMPmEMBERCard)
delete TIMPmEMBER
delete TIMPmEMBERCard
SELECT* FROM TImpCardType WHERE name = 'ÊÖ±ÛÍÑëÄ꿨'
SELECT * FROM TImpMemberCard WHERE cardDefineId = 2111271370260445
SELECT * FROM TImpMemberCardItem WHERE cardId IN(
SELECT id FROM TImpMemberCard WHERE cardDefineId = 2111271370260445
)
ORDER BY supportTypeName
SELECT * FROM TImpMemberCardItem WHERE id = 1410331737178513
SELECT * INTO TImpMemberCardItem_6 FROM TImpMemberCardItem WHERE supportType = 6
SELECT * FROM TImpMemberCardItem_6
delete TImpMemberCardItem where supportType = 9
SELECT cardId,supportTypeName FROM TImpMemberCardItem
WHERE cardId IN(
SELECT id FROM TImpMemberCard
WHERE type = 2)
ORDER BY cardId
--»áÔ±
ALTER TABLE TImpMember ADD FMemId BIGINT
ALTER TABLE TImpMember ADD FMemNo 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 FMemo VARCHAR(MAX)
ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6)
ALTER TABLE TImpMember ADD FCreateDate DATETIME
SELECT * FROM TImpMember
UPDATE TImpMember SET FMemId = memberId
UPDATE TImpMember SET FName = name
UPDATE TImpMember SET FMemNo = memberNo
UPDATE TImpMember SET FMobile = mobile
UPDATE TImpMember SET FGender = Case WHEN gender = 1 THEN 1 ELSE 0 END
UPDATE TImpMember SET FCreateDate = registerDate
UPDATE TImpMember SET FBirthdayType = 'G'
UPDATE TImpMember SET FBirthday = NULL
UPDATE TImpMember SET FCompId = dbo.FNCompID('001')
SELECT * FROM TImpMemberCard WHERE type = 4
ALTER TABLE TImpMemberCard ADD FBalance DECIMAL(18,6)
ALTER TABLE TImpMemberCard ADD FCardId BIGINT
ALTER TABLE TImpMemberCard ADD FMemId BIGINT
ALTER TABLE TImpMemberCard ADD FCardTypeId BIGINT
ALTER TABLE TImpMemberCard ADD FCompId BIGINT
ALTER TABLE TImpMemberCard ADD FCardNo VARCHAR(100)
ALTER TABLE TImpMemberCard ADD FCreateDate DATETIME
ALTER TABLE TImpMemberCard ADD FExpiredDate DATETIME
ALTER TABLE TImpMemberCard ADD FMemo VARCHAR(1000)
UPDATE TImpMemberCard SET FCardNo = CardNo
UPDATE TImpMemberCard SET FCardId = id
UPDATE TImpMemberCard SET FMemId = memberId
UPDATE TImpMemberCard SET FBalance = CAST(balance AS DECIMAL(18,2)) / 100.00
UPDATE TImpMemberCard SET FMemo = orderMark
UPDATE TImpMemberCard SET FCardTypeId = cardDefineId
UPDATE TImpMemberCard SET FCreateDate = createTime
UPDATE TImpMemberCard SET FExpiredDate = endTime
UPDATE TImpMemberCard SET FExpiredDate = dateadd(year,100,createTime) WHERE FExpiredDate IS NULL OR FExpiredDate = '1900-01-01'
UPDATE TImpMemberCard SET FCompId = dbo.FNCompId('001')
sp_rename 'TImpMemberCard','TImpMemberCardList'
SELECT * FROM TImpCardType WHERE id = 1910331630130336
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,
FCardNo 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 TImpMemberCard
WHERE type = 2
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 TImpMemberCard
WHERE type = 2
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 TImpMemberCard AS A
WHERE type = 2
ALTER TABLE TImpMemberCardItem ADD FId BIGINT
ALTER TABLE TImpMemberCardItem ADD FItemId BIGINT
ALTER TABLE TImpMemberCardItem ADD FCourseId BIGINT
ALTER TABLE TImpMemberCardItem ADD FCreateDate DATETIME
ALTER TABLE TImpMemberCardItem ADD FExpiredDate BIGINT
ALTER TABLE TImpMemberCardItem ADD FPurTimes DECIMAL(18,6)
ALTER TABLE TImpMemberCardItem ADD FUsedPurTimes DECIMAL(18,6)
ALTER TABLE TImpMemberCardItem ADD FCalcMode INT
ALTER TABLE TImpMemberCardItem ADD FMemId BIGINT
ALTER TABLE TImpMemberCardItem ADD FCompId BIGINT
ALTER TABLE TImpMemberCardItem ADD FAdjustPrice DECIMAL(18,6)
UPDATE TImpMemberCardItem SET FId = dbo.FNNewId()
UPDATE TImpMemberCardItem SET FMemId = memberId
UPDATE TImpMemberCardItem SET FCreateDate = createTime
UPDATE TImpMemberCardItem SET FExpiredDate = endTime WHERE endTime != ''
UPDATE TImpMemberCardItem SET FPurTimes = 0
UPDATE TImpMemberCardItem SET FPurTimes = CAST(amount AS DECIMAL(18,6)) WHERE amount != ''
UPDATE TImpMemberCardItem SET FUsedPurTimes = 0
UPDATE TImpMemberCardItem SET FUsedPurTimes = FPurTimes - CAST(balance AS DECIMAL(18,6)) WHERE balance != ''
UPDATE TImpMemberCardItem SET FCalcMode = 1
UPDATE TImpMemberCardItem SET FCompId = dbo.FNCompId('001')
INSERT INTO TMemberCoursePack(FId,FMemId,FPackId,FCompId,FItemTimes,FItemUsedTimes,FGoodsQuantity,FGoodsUsedQuantity,FAmount,FArrear,FPurchaseDate,FExpiredDate,FBizType,FTransId,FUseUp,FMemo)
SELECT id,memberId,cardDefineId,FCompId,0,0,0,0,0,0,createTime,FExpiredDate,'DR.Import',0,0,''
FROM TImpMemberCard
WHERE type IN(3,4,5)
UPDATE TImpMemberCardItem SET FCalcMode = 2 WHERE cardId IN(SELECT id FROM TImpMemberCard WHERE type in (3))
--·Ö´Î
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FUsedPurTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT A.FId,A.FMemId,0,B.id,A.FItemId,A.FCompId,A.FPurTimes,0,0,A.FUsedPurTimes,0,A.FCreateDate,A.FExpiredDate,'DR.Import',0,0,0,'´ÓÀÏϵͳµ¼Èë',FCalcMode,ISNULL(FAdjustPrice,0)
FROM TImpMemberCard AS B,TImpMemberCardItem AS A
WHERE a.cardId = B.id
AND b.type IN(5)
AND A.supportType = 3
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,
FCompId,
FBillType,FBizType,FBillId,FBillNo,FBillDetailId)
SELECT dbo.FNNewId(),B.FMemId,A.FId,B.id,0,FTime = getdate(),FPurTimes,FUsedPurTimes,0,0,
B.FCompId,
'DR','Import',0,'',0
FROM TImpMemberCard AS B,TImpMemberCardItem AS A
WHERE a.cardId = B.id
AND b.type IN(5)
AND A.supportType = 3
ALTER TABLE TImpMemberCard ADD FId BIGINT
ALTER TABLE TImpMemberCard ADD FAdjustPrice DECIMAL(18,6)
UPDATE TImpMemberCard SET Fid = dbo.FNNewId()
UPDATE TImpMemberCard SET FAdjustPrice = price / 100
--×Ü´Î
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FUsedPurTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT B.FId,B.FMemId,0,B.id,A.FItemId,B.FCompId,cast(B.deposit as float),0,0,cast(B.deposit as float) - B.balance,0,B.FCreateDate,B.FExpiredDate,'DR.Import',0,0,0,'´ÓÀÏϵͳµ¼Èë',FCalcMode,ISNULL(FAdjustPrice,0)
FROM TImpMemberCard AS B,TCourse AS A
WHERE B.cardDefineId = A.FPackId
AND b.type IN(4)
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FItemId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,
FCompId,
FBillType,FBizType,FBillId,FBillNo,FBillDetailId)
SELECT dbo.FNNewId(),B.FMemId,A.FId,0,A.FItemId,0,FTime = getdate(),cast(B.deposit as float),cast(B.deposit as float) - B.balance,0,0,
B.FCompId,
'DR','Import',0,'',0
FROM TImpMemberCard AS B,TCourse AS A
WHERE B.cardDefineId = A.FPackId
AND b.type IN(4)
--ʱ¶Î
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FUsedPurTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT B.FId,B.FMemId,0,B.id,A.FItemId,B.FCompId,0,0,0,0,0,B.FCreateDate,B.FExpiredDate,'DR.Import',0,0,0,'´ÓÀÏϵͳµ¼Èë',FCalcMode,ISNULL(FAdjustPrice,0)
FROM TImpMemberCard AS B,TCourse AS A
WHERE B.cardDefineId = A.FPackId
AND b.type IN(3)
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FItemId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,
FCompId,
FBillType,FBizType,FBillId,FBillNo,FBillDetailId)
SELECT dbo.FNNewId(),B.FMemId,A.FId,0,A.FItemId,0,FTime = getdate(),0,0,0,0,
B.FCompId,
'DR','Import',0,'',0
FROM TImpMemberCard AS B,TCourse AS A
WHERE B.cardDefineId = A.FPackId
AND b.type IN(3)
SELECT * FROM TImpMemberCard WHERE type in (3,4,5)
--¿¨ÔùËÍ
ALTER TABLE TImpMemberCardFreeItem ADD FId BIGINT
ALTER TABLE TImpMemberCardFreeItem ADD FItemId BIGINT
ALTER TABLE TImpMemberCardFreeItem ADD FCourseId BIGINT
ALTER TABLE TImpMemberCardFreeItem ADD FCreateDate DATETIME
ALTER TABLE TImpMemberCardFreeItem ADD FExpiredDate BIGINT
ALTER TABLE TImpMemberCardFreeItem ADD FPurTimes DECIMAL(18,6)
ALTER TABLE TImpMemberCardFreeItem ADD FUsedPurTimes DECIMAL(18,6)
ALTER TABLE TImpMemberCardFreeItem ADD FCalcMode INT
ALTER TABLE TImpMemberCardFreeItem ADD FMemId BIGINT
ALTER TABLE TImpMemberCardFreeItem ADD FCompId BIGINT
ALTER TABLE TImpMemberCardFreeItem ADD FAdjustPrice DECIMAL(18,6)
UPDATE TImpMemberCardFreeItem SET FId = dbo.FNNewId()
UPDATE TImpMemberCardFreeItem SET FMemId = memberId
UPDATE TImpMemberCardFreeItem SET FCreateDate = createTime
UPDATE TImpMemberCardFreeItem SET FExpiredDate = endTime WHERE endTime != ''
UPDATE TImpMemberCardFreeItem SET FPurTimes = 0
UPDATE TImpMemberCardFreeItem SET FPurTimes = CAST(amount AS DECIMAL(18,6)) WHERE amount != ''
UPDATE TImpMemberCardFreeItem SET FUsedPurTimes = 0
UPDATE TImpMemberCardFreeItem SET FUsedPurTimes = FPurTimes - CAST(money AS DECIMAL(18,6)) WHERE money != ''
UPDATE TImpMemberCardFreeItem SET FCalcMode = 1
UPDATE TImpMemberCardFreeItem SET FCompId = dbo.FNCompId('001')
SELECT * FROM TImpMember WHERE memberId IN(
SELECT memberId FROM TImpMemberCardFreeItem
)
SELECT * FROM TImpMemberFreeItem WHERE memberId = 1411841201957192
SELECT * FROM TImpMemberFreeItem FROM TImpItem WHERE storeId IS NULL
--»áÔ±ÔùËÍ
--¿¨ÔùËÍ
ALTER TABLE TImpMemberFreeItem ADD FId BIGINT
ALTER TABLE TImpMemberFreeItem ADD FItemId BIGINT
ALTER TABLE TImpMemberFreeItem ADD FCourseId BIGINT
ALTER TABLE TImpMemberFreeItem ADD FCreateDate DATETIME
ALTER TABLE TImpMemberFreeItem ADD FExpiredDate BIGINT
ALTER TABLE TImpMemberFreeItem ADD FPurTimes DECIMAL(18,6)
ALTER TABLE TImpMemberFreeItem ADD FUsedPurTimes DECIMAL(18,6)
ALTER TABLE TImpMemberFreeItem ADD FCalcMode INT
ALTER TABLE TImpMemberFreeItem ADD FMemId BIGINT
ALTER TABLE TImpMemberFreeItem ADD FCompId BIGINT
ALTER TABLE TImpMemberFreeItem ADD FAdjustPrice DECIMAL(18,6)
UPDATE TImpMemberFreeItem SET FId = dbo.FNNewId()
UPDATE TImpMemberFreeItem SET FMemId = memberId
UPDATE TImpMemberFreeItem SET FCreateDate = £ðresent£Äate
UPDATE TImpMemberFreeItem SET FExpiredDate = endTime WHERE endTime != ''
UPDATE TImpMemberFreeItem SET FPurTimes = 0
UPDATE TImpMemberFreeItem SET FPurTimes = deposit
UPDATE TImpMemberFreeItem SET FUsedPurTimes = 0
UPDATE TImpMemberFreeItem SET FUsedPurTimes = CAST(deposit AS DECIMAL(18,6)) - cast(balance as decimal(18,6))
UPDATE TImpMemberFreeItem SET FCalcMode = 1
UPDATE TImpMemberFreeItem SET FCompId = dbo.FNCompId('001')
UPDATE TImpMemberFreeItem SET FCourseId = 0
SELECT * FROM TImpMemberFreeItem
SELECT * FROM TImpItem WHERE name like '%Ò¸ÏÂ%'
UPDATE A
SET A.FItemId = B.FId,
FROM TImpMemberFreeItem AS A,TItem AS B
WHERE A.presentType = 5
AND A.presentName = B.FName
SELECT * FROM TMemberCourse WHERE FId IN(SELECT FId FROM TImpMemberFreeItem)
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FUsedPurTimes,FUsedFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT A.FId,A.FMemId,0,0,A.FItemId,A.FCompId,0 AS PurTimes,0 AS PurAmount,A.FPurTimes,0,A.FUsedPurTimes,0,A.FCreateDate,A.FExpiredDate,'DR.Import',0,0,0,REMARK,FCalcMode,ISNULL(FAdjustPrice,0)
FROM TImpMemberFreeItem AS A
WHERE 1=1
AND A.presentType = 5
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FItemId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,
FCompId,
FBillType,FBizType,FBillId,FBillNo,FBillDetailId)
SELECT dbo.FNNewId(),A.FMemId,A.FId,0,0,FItemId,FTime = getdate(),0 as FPurTimes,0 as FUsedPurTimes,FPurTimes,FUsedPurTimes,
A.FCompId,
'DR','Import',0,'',0
FROM TImpMemberFreeItem AS A
WHERE A.presentType = 5
SELECT * FROM TItem WHERE FId = 1410382531978649
SELECT * FROM TImpItem WHERE name = 'Ë®¹â¼¡'
/*
--·Ö´Î¿¨
SELECT * FROM TImpItem
UPDATE A
SET A.FItemId = B.id,
A.FCourseId = B.FCourseId,
A.FAdjustPrice = B.FPrice
FROM TImpItem AS B,TImpMemberCardItem AS A
WHERE A.supportTypeId = B.id
AND supportType = 3
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FUsedPurTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT A.FId,A.FMemId,A.FCourseId,0,A.FItemId,A.FCompId,A.FPurTimes,0,0,A.FUsedPurTimes,0,A.FCreateDate,A.FExpiredDate,'DR.Import',0,0,0,'´ÓÀÏϵͳµ¼Èë',FCalcMode,ISNULL(FAdjustPrice,0)
FROM TImpMemberCard AS B,TImpMemberCardItem AS A
WHERE a.cardId = B.id
AND b.type = 5
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,
FCompId,
FBillType,FBizType,FBillId,FBillNo,FBillDetailId)
SELECT dbo.FNNewId(),A.FMemId,A.FId,0,A.FCourseId,FTime = getdate(),A.FPurTimes,A.FUsedPurTimes,0,0,
A.FCompId,
'DR','Import',0,'',0
FROM TImpMemberCard AS B,TImpMemberCardItem AS A
WHERE a.cardId = B.id
AND b.type = 5
--end of µ¥´Î¿¨
--²»¼Æ´Î¿¨
SELECT * FROM TImpMemberCardItem WHERE cardId IN(
SELECT id FROM TImpMemberCard WHERE type = 4
)
SELECT id,cardDefineId FROM TImpMemberCard WHERE type = 3
SELECT * FROM TImpMember WHERE memberId = 1411135401639686
SELECT * FROM TBasicType WHERE FKey = 'ItemType'
SELECT * FROM TItem WHERE FTypeId = 1910331634073467
SELECT * FROM TImpCardTypeItem
WHERE cardTypeId IN(SELECT id FROM TImpCardType WHERE type = 4)
SELECT * FROM TImpCardType WHERE type = 4
*/
SELECT * FROM TImpMemberTransHist
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT id,A.memberId,A.consumeTime,0,dbo.FNCompId('001'),'DR','Import',orderNo,content,consumeMOney / 100,1,consumeMOney / 100,payMethodType,isnull(employeeName,''),''
FROM TImpMemberTransHist AS A