ÿþUSE [ECTEST]

GO

/****** Object:  StoredProcedure [dbo].[sp_EC_OrderExtend_Insert]    Script Date: 2021-09-16 9:29:34 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO





-- °eXibU\==========================================================================================

-- Entity Name:	sp_EC_OrderExtend_Insert

-- Author:	cyin

-- Create date:	2013/4/3 16:54:24

-- Description:	This stored procedure is intended for inserting values to EC_OrderExtend table

-- ==========================================================================================

ALTER Procedure [dbo].[sp_EC_OrderExtend_Insert]

	@Keyid int,

	@FileId int,

	@ProofreadWayId int,

	@ProofreadState int,

	@ProofreadFileId int,

	@PrintNum int,

	@ExigencyCaseId int,

	@BusinessManagerId int,

	@CustomerManagerId int,

	@CustomerLevelId int,

	@Contacts varchar(20),

	@ContactPhone varchar(50),

	@InvoiceId int,

	@SurplusPrintNum int,

	@Operate varchar(20),

	@Remark varchar(1000),

	@BookNum varchar(50),

	@BookPrice varchar(50),

	@NumPerBag varchar(50),

	@BagNum varchar(50),

	@DelayTime [datetime],

	@Productionprogress varchar(500) ,

	@PrintPackDeliveryRequir varchar(500),

	@printunit int

As

Begin

	Insert Into EC_OrderExtend

		([Keyid],[FileId],[ProofreadWayId],[ProofreadState],[ProofreadFileId],[PrintNum],[ExigencyCaseId],[BusinessManagerId],[CustomerManagerId],[CustomerLevelId],[Contacts],[ContactPhone],[InvoiceId],[SurplusPrintNum],[LastUpdateTime],[Operate],[Remark],

		 [BookNum],[BookPrice],[NumPerBag],[BagNum],[DelayTime],[Productionprogress],[PrintPackDeliveryRequir],printunit

		)

	Values

		(@Keyid,@FileId,@ProofreadWayId,@ProofreadState,@ProofreadFileId,@PrintNum,@ExigencyCaseId,@BusinessManagerId,@CustomerManagerId,@CustomerLevelId,@Contacts,@ContactPhone,@InvoiceId,@SurplusPrintNum,GETDATE(),@Operate,@Remark,@BookNum,@BookPrice,@NumPerBag,@BagNum,@DelayTime,@Productionprogress,@PrintPackDeliveryRequir,@printunit)



End







GO

---îO9eibU\==========================================================================================

/****** Object:  StoredProcedure [dbo].[sp_EC_OrderExtend_Update]    Script Date: 2021-09-16 11:14:33 ******/



ALTER Procedure [dbo].[sp_EC_OrderExtend_Update]    

 @Keyid int,    

 @ProofreadWayId int,    

 @ExigencyCaseId int,    

 @BusinessManagerId int,    

 @CustomerManagerId int,    

 @CustomerLevelId int,    

 @Contacts varchar(20),    

 @ContactPhone varchar(50),    

 @SurplusPrintNum int,    

 @UnitPrice money,--US÷N    

 @SumPrice money,--;`÷N    

 @Operate varchar(20),    

 @Remark varchar(1000),

 @BookNum varchar(50),

 @BookPrice varchar(50),

 @NumPerBag varchar(50),

 @BagNum varchar(50),

 @PrintPackDeliveryRequir varchar(500),

 @printunit int



As    

Begin    

    

 UPDATE EC_OrderExtend    

 Set    

  --[FileId] = @FileId,    

  [ProofreadWayId] = @ProofreadWayId,    

  [PrintNum] = @SurplusPrintNum,    

  [ExigencyCaseId] = @ExigencyCaseId,    

  [BusinessManagerId] = @BusinessManagerId,    

  [CustomerManagerId] = @CustomerManagerId,    

  [CustomerLevelId] = @CustomerLevelId,    

  [Contacts] = @Contacts,    

  [ContactPhone] = @ContactPhone,    

  --[InvoiceId] = @InvoiceId,    

  [SurplusPrintNum] = @SurplusPrintNum,    

  [LastUpdateTime] = GETDATE(),    

  [Operate] = @Operate,    

  [Remark] = @Remark,

  [BookNum] = @BookNum,

  [BookPrice] = @BookPrice,

  [NumPerBag] = @NumPerBag,

  [BagNum] = @BagNum,

  [PrintPackDeliveryRequir] = @PrintPackDeliveryRequir  ,

  printunit=@printunit



 Where      

  [Keyid] = @Keyid    

  Update Pay_TradingSingle Set TradingMoney=@SumPrice Where OrderId=@Keyid    

      

  Update EC_OrderBasic Set SumPrice=@SumPrice,UnitPrice=@UnitPrice,PayState=    

  CASE WHEN p_ts.PayedMoney>= @SumPrice Then -1 WHEN p_ts.PayedMoney=0 OR p_ts.PayedMoney IS NULL  THEN 0  WHEN p_ts.PayedMoney<@SumPrice THEN 1 ELSE PayState End    

  From (Select OrderId,PayedMoney From Pay_TradingSingle Where OrderId=@Keyid) as p_ts     

  Where Keyid=@Keyid And OrderId=@Keyid    

      

if(@@ERROR>0)return -1 Else return 1    

    

End    

  

  





