<?php
|
|
namespace app\api\model\user;
|
|
use app\common\model\user\UserAuth as UserAuthModel;
|
use app\common\exception\BaseException;
|
use app\common\library\fbpay\FbPay;
|
|
/**
|
* 用户收货地址模型
|
*/
|
class UserAuth extends UserAuthModel
|
{
|
/**
|
* 隐藏字段
|
*/
|
protected $hidden = [
|
'app_id',
|
'create_time',
|
'update_time'
|
];
|
|
/**
|
* 认证信息详情
|
*/
|
public static function detail($user_id)
|
{
|
$where = ['user_id' => $user_id];
|
return (new static())->where($where)->with(['idCardFrontPhoto','idCardBackPhoto','licensePhoto','settlementIdCardFrontPhoto','settlementIdCardBackPhoto','bankCardPhoto','storeFrontPhoto','storeCashPhoto','storeEnvPhoto',])->find();
|
}
|
|
public static function authStatus($user_id)
|
{
|
$detail = self::detail($user_id);
|
return !empty($detail) ? $detail['auth_status'] : '-1';
|
}
|
|
/**
|
* 创建记录
|
*/
|
public function add($data,$app_id)
|
{
|
$order_no = $this->orderNo();
|
$data["merchant_order_sn"] = $order_no;
|
$this->startTrans();
|
try {
|
$this->save($data);
|
|
//如果是付呗接口,配置参数 by yj
|
$app = FbPay::getFbPayApp($app_id, 'wx');
|
$FbPay = new FbPay($app);
|
$account_id = $FbPay->subaccount($data);
|
if(empty($account_id)){
|
$this->error = '实名认证失败';
|
return false;
|
}
|
|
$update_data = [
|
'account_id' => $account_id,
|
];
|
$this->save($update_data);
|
|
$this->commit();
|
} catch (\Exception $e) {
|
$this->rollback();
|
throw new BaseException(['msg' => $e->getMessage()]);
|
}
|
|
return $order_no;
|
}
|
|
/**
|
* 修改记录
|
*/
|
public function edit($data)
|
{
|
$data['update_time'] = time();
|
return $this->save($data);
|
}
|
|
}
|