chengkun
2025-08-19 a4917f837e649e8288f37d386159005a6f415b85
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
 
namespace app\admin\controller;
 
use think\facade\Db;
use think\facade\Request;
use think\facade\View;
use think\Exception;
 
class SellerBaseInfo extends Common {
    /*
     * 品牌管理
     */
    public function index(){
        if (!Request::isPost()) {
            $other['title'] = '分销商实名认证审核';
            $guide['one']['text'] = '数据审核';
            $guide['two']['text'] = '分销商实名认证审核';
            View::assign('guide', $guide);
            View::assign('other', $other);
            return View::fetch('index');
        }
        else{
            try {
                $kw = input('kw');
                $condition['status'] = 2;//提交审核
                if (!empty($kw)) {
                    $condition[] = array('first_name|last_name|certificate_name', 'like', "%$kw%");
                }
                $p = input('page', 1);
                $_GET['p'] = $p;
                $other['page_size'] = input('page_size', 20);
                $order = 'id desc';
                $count = Db::name('seller_base_info')->where($condition)->count();
                $list = Db::name('seller_base_info')->field("*")->where($condition)->order($order)->page($p, $other['page_size'])->select()->toArray();
                $other['count'] = $count;
                if (!$list) {
                    $list = [];
                }
                else{
                    foreach ($list as &$item){
                        $item['main_area'] = $item['main_area'] ? array_map('intval', explode(',', $item['main_area'])) : [];
                        $item['main_dis_platform'] = $item['main_dis_platform'] ? array_map('intval', explode(',', $item['main_dis_platform'])) : [];
                        $item['cate_code'] = [$item['country_id'], $item['province_id'], $item['city_id']];
                    }
                }
                $result['code'] = 200;
                $result['list'] = $list;
                $result['other'] = $other;
                return $this->successResponse($result);
                
            } catch (\Exception $exc) {
                return $this->errorResponse($exc->getMessage());
            }
        }
    }
    /*
 * 获取国家-省份-城市列表
 */
    public function getCountryCodeList() {
        if (!Request::isPost()) {
            throw new Exception(lang('request_method_incorrect'));
        }
        try {
            $result['list'] = $this->getCountrychildrenids(0);
            return $this->successResponse($result);
        } catch (\Exception $exc) {
            return $this->errorResponse($exc->getMessage());
        }
        
    }
    
    protected function getCountrychildrenids($id) {
        $where['father_id'] = $id;
        $result = Db::name('country_code')->field('id as value,cate_name as label')->where($where)->cacheAlways(TRUE, 0, 'country_code')->order('order_id asc,id asc')->select()->toArray();
        if ($result) {
            foreach ($result as &$val) {
                $val['children'] = $this->getCountrychildrenids($val['value']); ////
            }
            return $result;
        }
    }
    
 
    /**
     * 分销商实名认证审核
     * @return array|int[]
     */
    public function reviewBaseInfo() {
        // 开始数据库事务
        Db::startTrans();
        try {
            if (!Request::isPost()) {
                throw new Exception(lang('request_method_incorrect'));
            }
            $base_info_id = input('post.base_info_id');
            if (is_numeric($base_info_id)) {
                $status = input('post.status');
                //更新数据
                $info = Db::name('seller_base_info')->field('id,status')->where('id', $base_info_id)->find();
                if (!$info) {
                    throw new Exception(lang('no_data_found'));
                }
                if ($info['status'] == 1) {
                    throw new Exception('该申请已审核通过,不能重复审核');
                }
                if ($status == 1) {
                    Db::name('seller_base_info')->where('id', $base_info_id)->update(['status' => 1]);
                    $message = '操作成功,审核通过';
                } else {
                    Db::name('seller_base_info')->where('id', $base_info_id)->update(['status' => 3]);
                    $message = '操作成功,审核不通过';
                }
                // 提交事务
                Db::commit();
                return $this->successResponse($message);
            } else {
                return $this->errorResponse(lang('request_method_incorrect'));
            }
        } catch (Exception $exc) {
            // 回滚事务
            Db::rollback();
            return $this->errorResponse($exc->getMessage());
        }
    }
    
}