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.
54 lines
2.7 KiB
54 lines
2.7 KiB
use taiyuan_shinkalife
|
|
|
|
/*
|
|
DROP TABLE #Card
|
|
SELECT FCardId,A.FMemId,A.FTypeId AS FCardTypeId,A.FCardNo,B.FMemNo INTO #Card FROM TMemberCard AS A,TMember AS B
|
|
WHERE A.FDeleted = 0 AND A.FState = 1
|
|
AND A.FMemId = B.FMemId
|
|
*/
|
|
DECLARE @CardId BIGINT
|
|
DECLARE @CardTypeId BIGINT
|
|
DECLARE @MemId BIGINT
|
|
DECLARE @MemNO VARCHAR(100)
|
|
DECLARE @CardNo VARCHAR(100)
|
|
|
|
|
|
DECLARE List CURSOR FOR SELECT FCardId,FMemId,FCardTypeId,FCardNO,FMemNo FROM #Card
|
|
OPEN LIST
|
|
FETCH LIST INTO @CardId,@MemId,@CardTypeId,@CardNo,@MemNO
|
|
WHILE @@FETCH_STATUS = 0
|
|
BEGIN
|
|
DECLARE @BillId BIGINT
|
|
DECLARE @BillNo VARCHAR(30)
|
|
DECLARE @Id1 BIGINT
|
|
DECLARE @Id2 BIGINT
|
|
DECLARE @Time DATETIME
|
|
DECLARE @WorkDate VARCHAR(100)
|
|
DECLARE @EmpId BIGINT
|
|
DECLARE @DeptId BIGINT
|
|
|
|
SELECT @Time = getdate()
|
|
SELECT @BillId = dbo.FNNewId()
|
|
SELECT @Id1 = dbo.FNNewId()
|
|
SELECT @Id2 = dbo.FNNewId()
|
|
SELECT @EmpId = FId,@DeptId = FDeptId FROM TEmployee WHERE FNo = ''
|
|
|
|
EXEC PGetWorkDate 1,@time,@WorkDate OUTPUT
|
|
EXEC PGetNewBillNo 1,'2018-01-09','TMemberSaleBill','Company+YYMMDD+9999','',@BillNo OUTPUT
|
|
|
|
PRINT @CardId
|
|
PRINT @CardNo
|
|
PRINT @BillNo
|
|
print @WorkDate
|
|
|
|
-- EXEC PInsertMemberSaleBill @BillId=@BillId,@CompId=1,@BillTime=@Time,@BillNo=@BillNo,@SerialNo='',@BizType='CardRchg',@CustSourceId=0,@MemId=@MemId,@MemNo=@MemNo,@MemState=2,@PayCardId=0,@PayCardTypeId=0,@PayCardNo='',@Dues=0,@NeedPoint=1,@Point=0,@InvoiceNo='',@OrderBillId=0,@RegBillId=0,@BillMemo='',@CreateTime=@Time,@CreatorId=1,@State=0,@AuditTime=@Time,@AuditorId=1,@InvalidTime=NULL,@InvaliderId=0,@ModifiedFlag=0,@WorkDate=@WorkDate
|
|
-- EXEC PInsertMemberSaleCard @BillId=@BillId,@CardId=@CardId,@CardNo=@CardNo,@CardTypeId=@CardTypeId,@CardValueType=1,@OrigPrice=0,@CardFee=0,@SalePrice=200,@AcctId=3,@Deposit=200,@AcctId2=0,@Deposit2=0,@Times=0,@Memo='',@ExpiredDate='2118/1/8 0:00:00',@AcctExpiredDate=NULL,@AcctExpiredDate2=NULL,@OldExpiredDate=NULL,@OldAcctExpiredDate=NULL,@OldAcctExpiredDate2=NULL,@IsUpgrade=0,@NewCardTypeId=0,@NewCardValueType=1,@NewCardNo='',@OldCardNo='',@DeptId=@DeptId
|
|
-- EXEC PInsertMemberSaleEmployee @IId=@Id1,@IBillId=@BillId,@IDetailId=0,@IWorkType=12001,@IDeptId=@DeptId,@IEmpId=@EmpId,@IShareRate=1,@IPerf=0,@IComm=0
|
|
-- EXEC PInsertMemberSalePayment @IId=@Id2,@IBillId=@BillId,@IPayTypeId=20,@IPayAmt=200,@IMemo=''
|
|
-- EXEC PAuditMemberSaleBill @IBillId = @BillId,@IOperation = 1,@IUserId = 1
|
|
|
|
FETCH LIST INTO @CardId,@MemId,@CardTypeId,@CardNo,@MemNO
|
|
END
|
|
|
|
CLOSE LIST
|
|
DEALLOCATE LIST |