|
|
|
|
use KunMing_JuHao_ErJiLu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMember
|
|
|
|
|
WHERE FMemNo = '7537'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ
|
|
|
|
|
select b.SV_ID bId,b.SV_NO,isnull(b.attaNo,'') attaNo,b.SV_ID,b.bill_status,b.BALANCE_DATE,b.ISCANCEL,b.OUT_DATE,b.BALANCE_AMT,b.AR_AMT,b.CASH_STRIKE_AMT,b.BANK_STRIKE_AMT,b.CARD_STRIKE_AMT,b.JF_STRIKE_AMT,b.DBQ_STRIKE_AMT,isnull(a.ASSOCIATORL_NO,'') ASSOCIATORL_NO,d.DEPT_NAME,c.CUST_NAME,c.HOME_TEL,c.MOBILE_TEL, itemDetail.sv_item_name itemName,itemDetail.amount itemAmt from MS_SVMASTER b left join MS_Associatorl a on (a.ASSOCIATORL_ID = b.ASSOCIATORL_ID) left join MS_CUSTOMER c on (c.CUST_ID = b.OBJ_ID )left join MS_Dept d on (b.DEPT_ID = d.DEPT_ID) left join ms_svitemdetail itemDetail on (itemDetail.sv_id = b.SV_ID) where b.bill_status = 6 and d.DEPT_CODE like '0%' and c.CUST_NO = '000150' and b.dept_id in (select dept_id from ms_dept where dept_code like '0%') and b.ar_amt >= 0.0 union all select b.SV_ID bId,b.SV_NO,isnull(b.attaNo,'') attaNo,b.SV_ID,b.bill_status,b.BALANCE_DATE,b.ISCANCEL,b.OUT_DATE,b.BALANCE_AMT,b.AR_AMT,b.CASH_STRIKE_AMT,b.BANK_STRIKE_AMT,b.CARD_STRIKE_AMT,b.JF_STRIKE_AMT,b.DBQ_STRIKE_AMT,isnull(a.ASSOCIATORL_NO,'') ASSOCIATORL_NO,d.DEPT_NAME,c.CUST_NAME,c.HOME_TEL,c.MOBILE_TEL, invb.item_name itemName ,invb.amount itemAmt from MS_SVMASTER b left join MS_Associatorl a on (a.ASSOCIATORL_ID = b.ASSOCIATORL_ID) left join MS_CUSTOMER c on (c.CUST_ID = b.OBJ_ID )left join MS_Dept d on (b.DEPT_ID = d.DEPT_ID) left join MS_INVBillDetail invb on (b.OUT_MATERIAL_ID = invb.bill_id) where b.bill_status = 6 and d.DEPT_CODE like '0%' and c.CUST_NO = '000150' and b.dept_id in (select dept_id from ms_dept where dept_code like '0%')
|
|
|
|
|
and b.ar_amt >= 0.0
|
|
|
|
|
order by b.SV_ID desc
|
|
|
|
|
|
|
|
|
|
--<EFBFBD>Ƴ<EFBFBD>
|
|
|
|
|
SELECT I.SERVICEITEM_NO AS FItemNo,
|
|
|
|
|
I.SERVICEITEM_NAME AS FItemName,
|
|
|
|
|
M.ASSOCIATORL_NO AS FMemNo,
|
|
|
|
|
c.used_times + c.CANU_TIMES AS FPurTimes,
|
|
|
|
|
c.USED_TIMES AS FUsedPurTimes,
|
|
|
|
|
C.REMARK AS FMemo,
|
|
|
|
|
C.STD_JG AS FAdjustPrice,
|
|
|
|
|
C.BEGIN_DATE AS FCreateDate,
|
|
|
|
|
C.END_DATE AS FExpiredDate
|
|
|
|
|
INTO TImpMemberCourse
|
|
|
|
|
FROM MS_ServiceItem AS I,
|
|
|
|
|
MS_Associatorl AS M,
|
|
|
|
|
MS_AssociatorlDetail AS C
|
|
|
|
|
WHERE M.ASSOCIATORL_ID = C.ASSOCIATORL_ID
|
|
|
|
|
AND CANU_TIMES > 0
|
|
|
|
|
AND C.SERVICEITEM_ID = I.SERVICEITEM_ID
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCourse
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FMemId bigint,FCompId BIGINT,FId BIGINT
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FMemId = B.FMemId,
|
|
|
|
|
A.FCompId = B.FCompId,
|
|
|
|
|
A.FId = dbo.FNNewId()
|
|
|
|
|
FROM TImpMemberCourse AS A,TImpMember AS B
|
|
|
|
|
|
|
|
|
|
WHERE A.FMemNO = B.FMemNo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FItemId BIGINT
|
|
|
|
|
ALTER TABLE TImpMemberCourse ADD FCourseId BIGINT
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FItemId = B.FItemId,
|
|
|
|
|
A.FCourseId = B.FId
|
|
|
|
|
FROM TImpMemberCourse AS A,TCourse AS B,TItem AS I
|
|
|
|
|
WHERE A.FItemName = I.FName
|
|
|
|
|
AND I.FId = B.FItemId
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TImpMemberCourse WHERE FItemid IS NULL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT FItemName FROM TImpMemberCourse
|
|
|
|
|
GROUP BY FItemName
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TItem WHERE FName = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۿ۽η<EFBFBD><EFBFBD><EFBFBD>ʦ'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TItem
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE TImpMemberCourse
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TCourse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice,FState)
|
|
|
|
|
SELECT FId,FMemId,FCourseId,0,FItemId,FCompId,FPurTimes,FUsedPurTimes,0,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,FMemo,1,FAdjustPrice,1
|
|
|
|
|
FROM TImpMemberCourse AS A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FCourseId,FItemId,FPackId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,FRemainPurTimes,FRemainFreeTimes,FCompId,FBillType,FBizType,FBillId,FBillNo,FBillDetailId,FRecordTime,FMemo)
|
|
|
|
|
SELECT Id = FId,MemId = FMemId,CardId = 0,CourseId = FCourseId,ItemId = FItemId,PackId = 0,Time = getdate(),InPurTimes = FPurTimes,InFreeTimes =0,
|
|
|
|
|
OutPurTimes = FUsedPurTimes,OutFreeTimes = 0,RemainPurTimes = FPurTimes - FUsedPurTimes,RemainFreeTimes = 0,CompId = FCompId ,BillType = 'DR',BizType = 'Import',BillId = 0,BillNo = '',BillDetailId = 0,RecordTime = getdate(),Memo = '<EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
FROM TImpMemberCourse AS A
|