huangsijun
2025-12-11 097a5f9e524acd965fa2abcfd18db30fc3f00ddb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?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);
    }
 
}