|
|
|
|
Use LiJiang_WeiMeiSiSong
|
|
|
|
|
|
|
|
|
|
select * from TImpMembercard
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMembercard DROP COLUMN FMemo
|
|
|
|
|
ALTER TABLE TImpMembercard DROP COLUMN FBalance
|
|
|
|
|
ALTER TABLE TImpMembercard DROP COLUMN FArrear
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FCardId BIGINT DEFAULT abs( CAST( CAST(newid() AS BINARY(16)) AS BIGINT)) NOT NULL
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FCardNo AS <EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FCardTypeId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FCreateDate AS <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FExpiredDate AS <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FAcctMemo AS <EFBFBD><EFBFBD>ֵ<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ע
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FMemo AS <EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FArrear AS <EFBFBD><EFBFBD>ֵ<EFBFBD>˻<EFBFBD>Ƿ<EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FBalance AS <EFBFBD><EFBFBD>ֵ<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FRemainTimes AS ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMemberCard ADD FMemNo AS <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMember ADD FMemId BIGINT DEFAULT abs( CAST( CAST(newid() AS BINARY(16)) AS BIGINT)) NOT NULL
|
|
|
|
|
ALTER TABLE TImpMember ADD FMemNo AS <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMember ADD FName AS <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMember ADD FGender AS CASE WHEN <EFBFBD>Ա<EFBFBD> = '<EFBFBD><EFBFBD>' THEN 1 ELSE 0 END
|
|
|
|
|
ALTER TABLE TImpMember ADD FMobile AS <EFBFBD>ֻ<EFBFBD>
|
|
|
|
|
exec('ALTER TABLE TImpMember ADD FAddress AS <EFBFBD><EFBFBD>ַ')
|
|
|
|
|
ALTER TABLE TImpMember ADD FCreateDate AS <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMember ADD FExpiredDate AS <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMember ADD FCompId BIGINT
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMember ADD FPoint AS <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMember ADD FBirthday AS REPLACE(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'0000-','9999-')
|
|
|
|
|
ALTER TABLE TImpMember ADD FBirthdayType AS CASE WHEN <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = 'ũ<EFBFBD><EFBFBD>' THEN 'L' ELSE 'G' END
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FCompId BIGINT
|
|
|
|
|
ALTER TABLE TImpMember ADD FAddress VARCHAR NOT NULL DEFAULT ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FId
|
|
|
|
|
FROM TImpMember AS A,TCompany AS B
|
|
|
|
|
WHERE A.<EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.FNo
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FId
|
|
|
|
|
FROM TImpMemberCard AS A,TCompany AS B
|
|
|
|
|
WHERE A.<EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.FNo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FId
|
|
|
|
|
FROM TImpMemberCourse AS A,TCompany AS B
|
|
|
|
|
WHERE A.<EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.FNo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCardTypeId = B.FId
|
|
|
|
|
FROM TImpMemberCard AS A,TMemberCardType AS B
|
|
|
|
|
WHERE A.<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.FNo
|
|
|
|
|
OR A.<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.FName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ,'1900-01-01') 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,
|
|
|
|
|
FAddress AS FAddress,
|
|
|
|
|
0 AS FProId,
|
|
|
|
|
'' AS FCPW,
|
|
|
|
|
'' AS FQPW,
|
|
|
|
|
0 AS FChargeEmpId,
|
|
|
|
|
ISNULL( FPoint,0) AS FPoint,
|
|
|
|
|
1 AS FRecvConsSMS,
|
|
|
|
|
1 AS FRecvBulkSMS,
|
|
|
|
|
'' AS FMemo,
|
|
|
|
|
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
|
|
|
|
|
from TImpMember
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = B.FMemId
|
|
|
|
|
FROM TImpMemberCard AS A,TImpMember AS B
|
|
|
|
|
WHERE A.FMemNO =B.FMemNO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TMemberCard(
|
|
|
|
|
FCardId,
|
|
|
|
|
FCardNo,
|
|
|
|
|
FCardFaceNo,
|
|
|
|
|
FTypeId,
|
|
|
|
|
FValueType,
|
|
|
|
|
FCompId,
|
|
|
|
|
FMemId,
|
|
|
|
|
FState,
|
|
|
|
|
FCreateDate,
|
|
|
|
|
FExpiredDate,
|
|
|
|
|
FTotalTimes,
|
|
|
|
|
FUsedTimes,
|
|
|
|
|
FSaleCompId,
|
|
|
|
|
FSaleBillId,
|
|
|
|
|
FMemo)
|
|
|
|
|
SELECT
|
|
|
|
|
FCardId AS FId,
|
|
|
|
|
fnewcard AS FNo,
|
|
|
|
|
FCardNo AS FFaceNo,
|
|
|
|
|
FCardTypeId AS FTypeId,
|
|
|
|
|
(SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
|
|
|
|
|
FCompId AS FCompId,
|
|
|
|
|
FMemId AS FMemId,
|
|
|
|
|
1 AS FState,
|
|
|
|
|
ISNULL(FCreateDate,1900) AS FCreateDate,
|
|
|
|
|
FExpiredDate,
|
|
|
|
|
ISNULL(FRemainTimes,0) AS FTotalTimes,
|
|
|
|
|
0 AS FUsedTimes,
|
|
|
|
|
FCompId AS FSaleCompId,
|
|
|
|
|
0 AS FSaleBillId,
|
|
|
|
|
FMemo AS FMemo
|
|
|
|
|
FROM TImpMemberCard
|
|
|
|
|
|
|
|
|
|
alter table TImpMemberCard add fnewcard varchar(100)
|
|
|
|
|
update timpmembercard set fnewcard = fcardno
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCard SET fnewcard = FCARDNo + '_' + cast(fcardid as varchar)
|
|
|
|
|
where fcardno in(
|
|
|
|
|
SELECT FCardNo FROM TImpMemberCard
|
|
|
|
|
GROUP BY FCardNo
|
|
|
|
|
HAVING SUM(1)>1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCard WHERE FCardNo = '13187799188'
|
|
|
|
|
|
|
|
|
|
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
|
|
|
|
|
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,3,cast(FBalance as float),cast(FBalance as float),0,FCreateDate,NULL,FAcctMemo
|
|
|
|
|
FROM TImpMemberCard AS A
|
|
|
|
|
|
|
|
|
|
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,'',cast(A.FBalance as float),0,cast(A.FBalance as float),0,getdate(),'<EFBFBD><EFBFBD>Excel<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
FROM TImpMemberCard AS A
|
|
|
|
|
|
|
|
|
|
DECLARE @NewName VARCHAR(100)
|
|
|
|
|
SELECT @NewName ='TImpMember_'+ REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR,GETDATE(),20),'-',''),':',''),' ','')
|
|
|
|
|
EXEC sp_rename 'TImpMember',@NewName
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * from TimpMember WHERE FMemNO IN(SELECT FMemNO FROM TMember)
|
|
|
|
|
|
|
|
|
|
SELECT FMemNO FROM TImpMember
|
|
|
|
|
GROUP BY FMemNO
|
|
|
|
|
having sum(1) > 1
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMEMBER WHERE FMemNO = '15770469937'
|
|
|
|
|
|
|
|
|
|
DELETE TImpMember where fmemid = 5234809082376277325
|
|
|
|
|
|
|
|
|
|
drop table TImpMemberCourse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FId BIGINT NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FMemId BIGINT NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FCompId BIGINT NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FCourseId BIGINT NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FItemId BIGINT NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FCalcMode AS CASE WHEN <EFBFBD><EFBFBD><EFBFBD>㷽ʽ ='<EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD>' THEN 2 ELSE 1 END
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FPurTimes DECIMAL(18,6) NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FPurAmount DECIMAL(18,6) NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FUsedPurTimes DECIMAL(18,6) NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FRemainPurTimes AS CAST(ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS DECIMAL(18,6))
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FFreeTimes DECIMAL(18,6) NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FFreeAmount DECIMAL(18,6) NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FUsedFreeTimes DECIMAL(18,6) NOT NULL DEFAULT 0
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FRemainFreeTimes AS CAST(ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD> AS DECIMAL(18,6))
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FAdjustPrice AS <EFBFBD><EFBFBD><EFBFBD>㵥<EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FMemo AS <EFBFBD>Ƴ̿<EFBFBD><EFBFBD><EFBFBD>ע
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FCreateDate AS <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FExpiredDate AS CASE WHEN <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '' THEN NULL ELSE <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select * from TImpMemberCourse
|
|
|
|
|
|
|
|
|
|
alter table TImpMemberCourse add <EFBFBD><EFBFBD><EFBFBD>㷽ʽ varchar not Null default ''
|
|
|
|
|
|
|
|
|
|
alter table TImpMemberCourse DROP COLUMN <EFBFBD><EFBFBD><EFBFBD>㷽ʽ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DECLARE @Error VARCHAR(1000);
|
|
|
|
|
UPDATE TImpMemberCourse SET FId = dbo.FNNewId();
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = B.FMemId
|
|
|
|
|
FROM TImpMemberCourse AS A,TMember AS B
|
|
|
|
|
WHERE A.<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD> =B.FMemNo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DECLARE @MemNo VARCHAR(100)
|
|
|
|
|
SELECT @MemNo = <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD> FROM TImpMemberCourse WHERE ISNULL(FMemId,0) = 0
|
|
|
|
|
IF ISNULL(@MemNo,'') != ''
|
|
|
|
|
BEGIN
|
|
|
|
|
SELECT @Error = '<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>' + @MemNo + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|
|
|
|
RAISERROR(@Error,16,1)
|
|
|
|
|
RETURN
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FId
|
|
|
|
|
FROM TImpMemberCourse AS A,TCompany AS B
|
|
|
|
|
WHERE A.<EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> =B.FNo
|
|
|
|
|
|
|
|
|
|
DECLARE @CompNo VARCHAR(100)
|
|
|
|
|
SELECT @CompNo = <EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FROM TImpMemberCourse WHERE ISNULL(FCompId,0) = 0
|
|
|
|
|
IF ISNULL(@CompNo,'') != ''
|
|
|
|
|
BEGIN
|
|
|
|
|
SELECT @Error = '<EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' + @CompNo + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|
|
|
|
RAISERROR(@Error,16,1)
|
|
|
|
|
RETURN
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCourseId = B.FId,
|
|
|
|
|
A.FItemId = B.FItemId
|
|
|
|
|
FROM TImpMemberCourse AS A,TCourse AS B
|
|
|
|
|
WHERE A.<EFBFBD>Ƴ̱<EFBFBD><EFBFBD><EFBFBD> =B.FNo
|
|
|
|
|
OR A.<EFBFBD>Ƴ̱<EFBFBD><EFBFBD><EFBFBD> = B.FName
|
|
|
|
|
|
|
|
|
|
DECLARE @CourseNo VARCHAR(100)
|
|
|
|
|
SELECT @CourseNo = <EFBFBD>Ƴ̱<EFBFBD><EFBFBD><EFBFBD> FROM TImpMemberCourse WHERE ISNULL(FCourseId,0) = 0
|
|
|
|
|
IF ISNULL(@CourseNo,'') != ''
|
|
|
|
|
BEGIN
|
|
|
|
|
SELECT @Error = '<EFBFBD>Ƴ̱<EFBFBD><EFBFBD><EFBFBD>' + @CourseNo + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|
|
|
|
RAISERROR(@Error,16,1)
|
|
|
|
|
RETURN
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD>㹺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE TImpMemberCourse SET FPurTimes = CAST(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS DECIMAL(18,6))
|
|
|
|
|
UPDATE TImpMemberCourse SET FPurTimes = FRemainPurTimes WHERE FPurTimes < FRemainPurTimes
|
|
|
|
|
UPDATE TImpMemberCourse SET FUsedPurTimes = 0
|
|
|
|
|
FPurTimes - FRemainPurTimes
|
|
|
|
|
UPDATE TImpMemberCourse SET FPurAmount = (CAST(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS DECIMAL(18,6)) / FPurTimes) * FPurTimes WHERE FPurTimes > 0
|
|
|
|
|
select * from TImpMemberCourse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCourse SET FFreeTimes = CAST(<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD> AS DECIMAL(18,6))
|
|
|
|
|
UPDATE TImpMemberCourse SET FFreeTimes = FRemainFreeTimes WHERE FFreeTimes < FRemainFreeTimes
|
|
|
|
|
UPDATE TImpMemberCourse SET FUsedFreeTimes = FFreeTimes - FRemainFreeTimes
|
|
|
|
|
UPDATE TImpMemberCourse SET FFreeAmount = 0
|
|
|
|
|
(CAST(<EFBFBD><EFBFBD><EFBFBD>ͽ<EFBFBD><EFBFBD><EFBFBD> AS DECIMAL(18,6)) / FRemainFreeTimes) * FFreeTimes WHERE FRemainFreeTimes > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCourse
|
|
|
|
|
|
|
|
|
|
UPDATE TImpMemberCourse SET FId = dbo.FNNewId()
|
|
|
|
|
|
|
|
|
|
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FUsedFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
|
|
|
|
|
SELECT FId,FMemId,FCourseId,0,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FUsedFreeTimes,FFreeAmount,FCreateDate,FExpiredDate,'DR.Import',0,0,0,FMemo,FCalcMode,ISNULL(FAdjustPrice,0)
|
|
|
|
|
FROM TImpMemberCourse
|
|
|
|
|
|
|
|
|
|
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,
|
|
|
|
|
FCompId,
|
|
|
|
|
FBillType,FBizType,FBillId,FBillNo,FBillDetailId)
|
|
|
|
|
|
|
|
|
|
SELECT dbo.FNNewId(),FMemId,FId,0,FCourseId,FTime = getdate(),FPurTimes,FUsedPurTimes,FFreeTimes,FUsedFreeTimes,
|
|
|
|
|
FCompId,
|
|
|
|
|
'DR','Import',0,'',0
|
|
|
|
|
FROM TImpMemberCourse
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember where fpoint > 0
|