Receipt.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\api\model;
  13. use app\common\model\Receipt as ReceiptModel;
  14. /**
  15. * 发票记录表模型
  16. * Class Store
  17. * @package app\store\model
  18. */
  19. class Receipt extends ReceiptModel
  20. {
  21. public function add($data){
  22. if (!isset($data['order_no']) || !$data['headup'] || !$data['email']){
  23. return false;
  24. }
  25. $ftype = $data['ftype']??0;
  26. if (isset($data['order_no']) && $data['order_no']){
  27. $check = self::where('order_no',$data['order_no'])->where('ftype',$ftype)->find();
  28. if ($check){
  29. return 201;
  30. }
  31. }
  32. $m = new self();
  33. $m->receipt_type = $data['receipt_type']??10;
  34. $m->order_id = $data['order_id']??0;
  35. $m->order_no = $data['order_no']??'';
  36. $m->pay_money = $data['pay_money']??'';
  37. $m->headup_type = $data['headup_type']??10;
  38. $m->headup = $data['headup']??"";
  39. $m->email = $data['email']??'';
  40. $m->tax_no = $data['tax_no']??'';
  41. $m->account_bank = $data['account_bank']??'';
  42. $m->account_no = $data['account_no']??'';
  43. $m->ftype = $ftype;
  44. $m->save();
  45. return true;
  46. }
  47. //是否开票
  48. public static function ifApplyReceipt($id,$ftype=0){
  49. $m = self::where('order_id',$id)->where("ftype",$ftype)->find();
  50. return $m?$m->getAttr('status'):0;
  51. }
  52. }