// +---------------------------------------------------------------------- declare (strict_types = 1); namespace app\api\model; use app\common\model\Receipt as ReceiptModel; /** * 发票记录表模型 * Class Store * @package app\store\model */ class Receipt extends ReceiptModel { public function add($data){ if (!isset($data['order_no']) || !$data['headup'] || !$data['email']){ return false; } $ftype = $data['ftype']??0; if (isset($data['order_no']) && $data['order_no']){ $check = self::where('order_no',$data['order_no'])->where('ftype',$ftype)->find(); if ($check){ return 201; } } $m = new self(); $m->receipt_type = $data['receipt_type']??10; $m->order_id = $data['order_id']??0; $m->order_no = $data['order_no']??''; $m->pay_money = $data['pay_money']??''; $m->headup_type = $data['headup_type']??10; $m->headup = $data['headup']??""; $m->email = $data['email']??''; $m->tax_no = $data['tax_no']??''; $m->account_bank = $data['account_bank']??''; $m->account_no = $data['account_no']??''; $m->ftype = $ftype; $m->save(); return true; } //是否开票 public static function ifApplyReceipt($id,$ftype=0){ $m = self::where('order_id',$id)->where("ftype",$ftype)->find(); return $m?$m->getAttr('status'):0; } }