Lemesh

download_order

Apr 1st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 7.41 KB | None | 0 0
  1.    <!-- Выгрузка заказа из ERP. Для типа '700' создаем заказ, отправку(shipment) и поток заказов(wave). Для остальных типов только заказ+отправка. -->  
  2.    <download name="download_order" no_confirm="yes" checking_script="check_order_action()" processing_script="test">
  3.         <field name="order_id" type="string"/>
  4.         <field name="client_id" type="string" default="0" checking_script="get_id_by_field( 'client', 'sdid' )"/>
  5.         <field name="type" type="string" checking_script="convert_order_type()"/>
  6.         <field name="date_to_ship" type="string" checking_script="date_utils_date2ctime()"/>
  7.         <field name="shipping_address" type="string" default=""/>
  8.         <field name="shipment_id" type="string" default="0"/>
  9.         <field name="ship_seq" type="string" default="0"/>
  10.         <field name="responsible" type="string" default=""/>
  11.         <field name="comments" type="string" default=""/>
  12.         <action type="db" action_on="insert">
  13.             insert into orders (id, sdid, status, client_id,
  14.             type, date_to_ship, shipping_address, shipment, ship_seq,
  15.             responsible,
  16.             comments, created_by)
  17.             values (
  18.             $_internal_id,
  19.             '$order_id',
  20.             'R',
  21.             '$client_id',
  22.             '$type',
  23.             $date_to_ship,
  24.             '$shipping_address',
  25.             '$shipment_id',
  26.             '$ship_seq',
  27.             '$responsible',
  28.             '$comments',
  29.             'GATEWAY')
  30.         </action>
  31.         <action type="db" action_on="insert_shipment">
  32.             begin
  33.             insert into shipment (shipment_id, id, date_to_ship, sdid, created_by)
  34.             values (
  35.             $_internal_id_s,
  36.             '$shipment_id',
  37.             $date_to_ship,
  38.             '$shipment_id',
  39.             'GATEWAY');
  40.            
  41.             insert into orders (id, sdid, status, client_id,
  42.             type, date_to_ship, shipping_address, shipment, ship_seq,
  43.             responsible,
  44.             comments, created_by)
  45.             values (
  46.             $_internal_id,
  47.             '$order_id',
  48.             'R',
  49.             '$client_id',
  50.             '$type',
  51.             $date_to_ship,
  52.             '$shipping_address',
  53.             '$shipment_id',
  54.             '$ship_seq',
  55.             '$responsible',
  56.             '$comments',
  57.             'GATEWAY');
  58.             end;
  59.         </action>
  60.         <action type="db" action_on="insert_shipment_wave">
  61.             begin
  62.             insert into shipment (shipment_id, id, date_to_ship, sdid, created_by)
  63.             values (
  64.             $_internal_id_s,
  65.             '$shipment_id',
  66.             $date_to_ship,
  67.             '$shipment_id',
  68.             'GATEWAY');
  69.  
  70.             insert into wave (id, status, type, drop_place, shipment_id, created_by)
  71.             values (
  72.             $_internal_id_s,
  73.             'O',
  74.             'q',
  75.             0,
  76.             '$shipment_id',
  77.             'GATEWAY');
  78.  
  79.             insert into orders (id, sdid, status, client_id,
  80.             type, date_to_ship, shipping_address, shipment, ship_seq, wave_id,
  81.             responsible,
  82.             comments, created_by)
  83.             values (
  84.             $_internal_id,
  85.             '$order_id',
  86.             'R',
  87.             '$client_id',
  88.             '$type',
  89.             $date_to_ship,
  90.             '$shipping_address',
  91.             '$shipment_id',
  92.             '$ship_seq',
  93.             $_internal_id_s,
  94.             '$responsible',
  95.             '$comments',
  96.             'GATEWAY');
  97.             end;
  98.         </action>
  99.         <action type="db" action_on="insert_wave">
  100.             begin
  101.             insert into orders (id, sdid, status, client_id,
  102.             type, date_to_ship, shipping_address, shipment, ship_seq, wave_id,
  103.             responsible,
  104.             comments, created_by)
  105.             values (
  106.             $_internal_id,
  107.             '$order_id',
  108.             'R',
  109.             '$client_id',
  110.             '$type',
  111.             $date_to_ship,
  112.             '$shipping_address',
  113.             '$shipment_id',
  114.             '$ship_seq',
  115.             (select id from wave where shipment_id='$shipment_id'),
  116.             '$responsible',
  117.             '$comments',
  118.             'GATEWAY');
  119.             end;
  120.         </action>
  121.         <action type="db" action_on="insert_only_shipment_wave">
  122.             begin
  123.             insert into shipment (shipment_id, id, date_to_ship, sdid, created_by)
  124.             values (
  125.             $_internal_id_s,
  126.             '$shipment_id',
  127.             $date_to_ship,
  128.             '$shipment_id',
  129.             'GATEWAY');
  130.  
  131.             insert into wave (id, status, type, drop_place, shipment_id, created_by)
  132.             values (
  133.             $_internal_id_s,
  134.             'O',
  135.             'q',
  136.             0,
  137.             '$shipment_id',
  138.             'GATEWAY');
  139.             end;
  140.         </action>
  141.         <action type="db" action_on="update">
  142.             begin
  143.             update orders set
  144.             client_id='$client_id',
  145.             type='$type',
  146.             date_to_ship=$date_to_ship,
  147.             shipping_address='$shipping_address',
  148.             comments='$comments',
  149.             modified=sysdate,
  150.             modified_by='GATEWAY'
  151.             where id=$_internal_id;
  152.             delete from order_details where order_id = $_internal_id;
  153.             end;
  154.         </action>
  155.         <action type="db" action_on="update_shipment">
  156.             begin
  157.             update orders set
  158.             shipping_address='$shipping_address',
  159.             shipment='$shipment_id',
  160.             ship_seq='$ship_seq',
  161.             modified=sysdate,
  162.             modified_by='GATEWAY'
  163.             where id=$_internal_id;
  164.             delete from order_details where order_id = $_internal_id;
  165.             end;
  166.         </action>    
  167.         <action type="db" action_on="update_wave">
  168.             begin
  169.             update orders set
  170.             shipping_address='$shipping_address',
  171.             shipment='$shipment_id',
  172.             ship_seq='$ship_seq',
  173.             wave_id=(select id from wave where shipment_id='$shipment_id'),
  174.             modified=sysdate,
  175.             modified_by='GATEWAY'
  176.             where id=$_internal_id;
  177.             delete from order_details where order_id = $_internal_id;
  178.             end;
  179.         </action>
  180.         <action type="db" action_on="delete">
  181.             begin
  182.             delete from order_details where order_id = $_internal_id;
  183.             delete from orders where id = $_internal_id;
  184.             end;
  185.         </action>
  186.         <post-action type="db" action_on="insert_only_shipment_wave">
  187.             begin            
  188.             update orders set
  189.             shipping_address='$shipping_address',
  190.             shipment='$shipment_id',
  191.             ship_seq='$ship_seq',
  192.             wave_id=(select id from wave where shipment_id='$shipment_id'),
  193.             modified=sysdate,
  194.             modified_by='GATEWAY'
  195.             where id=$_internal_id;
  196.             delete from order_details where order_id = $_internal_id;
  197.             end;
  198.         </post-action>
  199.         <post-action type="pl-send" action_on="insert">
  200.             order_new( $_internal_id, [ autor( gateway ) ] ).
  201.         </post-action>
  202.         <post-action type="pl-send" action_on="update">
  203.             order_new( $_internal_id, [ autor( gateway ) ] ).
  204.         </post-action>
  205.     </download>
Add Comment
Please, Sign In to add comment