InvoiceInfo.php 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\model;
  4. use think\Model;
  5. /**
  6. * @mixin \think\Model
  7. */
  8. class InvoiceInfo extends Model
  9. {
  10. public static function OnAfterWrite(Model $model){
  11. if($model->status==1 && !empty($model->item)){
  12. (new InvoiceItem)->saveAll(array_map(function ($item)use($model) {
  13. return [
  14. 'invoice_code'=>$model->hpNo,
  15. 'order_type'=>2,
  16. 'good_name'=>$item['name'],
  17. 'unit'=>$item['unit'],
  18. 'num'=>$item['quantity'],
  19. 'unit_price'=>$item['unit_price'],
  20. 'amount'=>$item['amount'],
  21. 'tax_amount'=>$item['tax'],
  22. 'tax'=>$item['tax_rate'],
  23. 'cat_code'=>$item['license_plate_number'],
  24. 'total_amount'=>bcadd($item['amount'],$item['tax'],2),
  25. 'balance_amount'=>bcadd($item['amount'],$item['tax'],2),
  26. ];
  27. },$model->item));
  28. }
  29. }
  30. }