Advertisement
Ruslan_Rayanov

pay page SQL

Oct 9th, 2023
1,878
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 2.67 KB | None | 0 0
  1. CREATE PROCEDURE [dbo].[pg_crumbs_pay]
  2.     @roles nvarchar(128),
  3.     @itemID nvarchar(128) = '',
  4.     @urlParameters CRUDFilterParameter READONLY
  5. AS
  6. BEGIN
  7.     declare @g uniqueidentifier = try_convert(uniqueidentifier, @itemID)
  8.    
  9.     declare @redirectUrl nvarchar(max) = iif(@g is null, '/', '')
  10.     declare @financeID int
  11.     declare @financeStatus nvarchar(max)
  12.     declare @sum float = 0    
  13.     declare @orderID int = 123
  14.     declare @orderDesc nvarchar(max) = ''
  15.     declare @fio nvarchar(max) = ''
  16.     declare @email nvarchar(max) = ''
  17.     declare @phone nvarchar(max) = ''
  18.    
  19.     select @financeID = f.id, @sum = f.[sum],@orderID = o.id,
  20.         @orderDesc = o.description,
  21.         @fio = isnull((select top 1 isnull(firstname, '') + ' ' + isnull(surname, '')  from ctr_contacts where contragentID = client.contragentID), ''),
  22.         @email = isnull((select top 1 email from ctr_contacts where contragentID = client.contragentID), ''),
  23.         @phone = isnull((select top 1 phone1 from ctr_contacts where contragentID = client.contragentID), ''),
  24.         @financeStatus = (select code from fin_financeStatuses where id = f.statusID)
  25.     from fin_finances f
  26.     inner join crm_orders o on f.relatedItemID = o.id
  27.     inner join crm_clients client on client.id = o.clientID  
  28.     where guid = @g and relatedTypeCode='order'
  29.    
  30.     declare @title nvarchar(max) = ''
  31.     declare @result TABLE (title nvarchar(256), link nvarchar(256), tooltip nvarchar(256),
  32.         ord int, [right] bit, customLink nvarchar(512))
  33.    
  34.     -- SELECT 1 Breadcrumbs
  35.     select * from @result order by ord
  36.    
  37.     -- SELECT 2 page settings
  38.     select @title Title, '' Description, '' Keywords, @redirectUrl RedirectUrl  
  39.    
  40.     declare @header nvarchar(max) = '<h2>Оплата по счету #'+isnull(cast(@financeID as nvarchar), '--' )+' на сумму '+isnull(try_cast(@sum as nvarchar) ,'')+' руб.</h2>
  41.             <p>Услуга - '+isnull(@orderDesc,'')+'</p>'
  42.    
  43.     declare @form nvarchar(max) = ''
  44.    
  45.         declare @yooShopID nvarchar(max) = dbo.as_setting('yookassa.payment_shopId', '')        
  46.         set @form = iif(isnull(@yooShopID, '') = '', '<div class="alert alert-warning">Не задан ключ Yookassa (publicID)</div>',
  47.                        '<div class="as-form" data-code="yookassapay" data-itemID="'+convert(nvarchar(128),@g)+'"></div>')
  48.    
  49.     -- SELECT 3
  50.     select  '<div class="as-panel mx-auto" style="max-width: 600px;">'+
  51.     @header+
  52.     iif(@financeStatus in ('done', 'hold', 'deleted'), '<div class="alert alert-warning">
  53.             По данному счету нельзя провести оплату (статус <b>'+@financeStatus+'</b>)</div>',  @form)+'
  54.    
  55.    </div>' text
  56.          
  57. END
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement