3 changed files with 92 additions and 3 deletions
@ -0,0 +1,37 @@ |
|||
<?php |
|||
|
|||
namespace app\model; |
|||
|
|||
use think\Model; |
|||
|
|||
class InvoiceHead extends Model |
|||
{ |
|||
|
|||
public static function createHead($wechat_user_id, $data) |
|||
{ |
|||
|
|||
$param = [ |
|||
'type' => $data['type'], |
|||
'title' => $data['title'], |
|||
'tax_number' => $data['tax_number'], |
|||
'wechat_user_id' => $wechat_user_id |
|||
]; |
|||
|
|||
$id = self::where($param)->value('id'); |
|||
if ($id) { |
|||
return $id; |
|||
} |
|||
|
|||
$param['address'] = $data['address'] ?? ''; |
|||
$param['telephone'] = $data['telephone'] ?? ''; |
|||
$param['bank_name'] = $data['bank_name'] ?? ''; |
|||
$param['bank_account'] = $data['bank_account'] ?? ''; |
|||
$param['create_time'] = time(); |
|||
|
|||
|
|||
$model = self::create($param); |
|||
|
|||
return $model->where($param)->value('id'); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
<?php |
|||
|
|||
namespace app\validate; |
|||
|
|||
use think\Validate; |
|||
|
|||
class InvoiceHeadValidate extends Validate |
|||
{ |
|||
|
|||
|
|||
/** |
|||
* 验证规则. |
|||
*/ |
|||
protected $rule = [ |
|||
'type|抬头类型' => 'require|in:1,2', |
|||
'title|抬头名称' => 'require', |
|||
'tax_number|税号' => 'require|alphaNum|length:18', |
|||
'address|地址' => 'require', |
|||
'telephone|电话' => 'require|alphaDash', |
|||
'bank_name|开户行' => 'require', |
|||
'bank_account|账户' => 'require' |
|||
]; |
|||
|
|||
/** |
|||
* 提示消息. |
|||
*/ |
|||
protected $message = [ |
|||
]; |
|||
|
|||
/** |
|||
* 字段描述. |
|||
*/ |
|||
protected $field = [ |
|||
]; |
|||
|
|||
/** |
|||
* 验证场景. |
|||
*/ |
|||
protected $scene = [ |
|||
'type1' => ['title','tax_number','address','telephone','bank_name','bank_account'], |
|||
'type2' => ['title','tax_number'], |
|||
'type' => ['type'] |
|||
]; |
|||
|
|||
} |
|||
Loading…
Reference in new issue