Browse Source

fix:代理商身份

super-yimizi 2 days ago
parent
commit
4a94692d64

+ 151 - 0
application/admin/controller/commission/Apply.php

@@ -0,0 +1,151 @@
+<?php
+
+namespace app\admin\controller\commission;
+
+use app\common\controller\Backend;
+use app\common\model\commission\Apply as ApplyModel;
+use app\common\model\commission\Identity as IdentityModel;
+use app\common\Service\commission\AgentApply as AgentApplyService;
+use think\Db;
+use think\Exception;
+
+class Apply extends Backend
+{
+    protected $model = null;
+    protected $searchFields = 'id,user.nickname,real_name,company_name,status';
+    protected $relationSearch = true;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new ApplyModel();
+    }
+
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        if (!$this->request->isAjax()) {
+            return $this->view->fetch();
+        }
+        
+        if ($this->request->request('keyField')) {
+            return $this->selectpage();
+        }
+        
+        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
+        
+        $list = $this->model
+            ->with(['user', 'identity', 'province', 'city', 'district', 'admin'])
+            ->where($where)
+            ->order($sort, $order)
+            ->paginate($limit);
+        
+        $result = ['total' => $list->total(), 'rows' => $list->items()];
+        return json($result);
+    }
+
+    /**
+     * 详情
+     */
+    public function detail($ids = null)
+    {
+        $row = $this->model->get($ids);
+        if (!$row) {
+            $this->error(__('No Results were found'));
+        }
+        
+        $row->load(['user', 'identity', 'province', 'city', 'district', 'admin']);
+        $this->view->assign('row', $row);
+        return $this->view->fetch();
+    }
+
+    /**
+     * 审核通过
+     */
+    public function approve($ids = null)
+    {
+        if (!$this->request->isPost()) {
+            $this->error(__('Invalid parameters'));
+        }
+        
+        $row = $this->model->get($ids);
+        if (!$row) {
+            $this->error(__('No Results were found'));
+        }
+        
+        if ($row->status != ApplyModel::STATUS_PENDING) {
+            $this->error('该申请已经处理过了');
+        }
+        
+        Db::transaction(function () use ($row) {
+            $service = new AgentApplyService();
+            $service->approveApply($row, $this->auth->id);
+        });
+        
+        $this->success('审核通过成功');
+    }
+
+    /**
+     * 审核拒绝
+     */
+    public function reject($ids = null)
+    {
+        if (!$this->request->isPost()) {
+            $this->error(__('Invalid parameters'));
+        }
+        
+        $row = $this->model->get($ids);
+        if (!$row) {
+            $this->error(__('No Results were found'));
+        }
+        
+        if ($row->status != ApplyModel::STATUS_PENDING) {
+            $this->error('该申请已经处理过了');
+        }
+        
+        $reason = $this->request->post('reason', '');
+        if (empty($reason)) {
+            $this->error('请填写拒绝原因');
+        }
+        
+        $service = new AgentApplyService();
+        $service->rejectApply($row, $reason, $this->auth->id);
+        
+        $this->success('审核拒绝成功');
+    }
+
+    /**
+     * 批量审核通过
+     */
+    public function multi($ids = null)
+    {
+        if (!$this->request->isPost()) {
+            $this->error(__('Invalid parameters'));
+        }
+        
+        $action = $this->request->post('action');
+        if ($action != 'approve') {
+            return parent::multi($ids);
+        }
+        
+        if (!$ids) {
+            $this->error(__('Parameter %s can not be empty', 'ids'));
+        }
+        
+        $ids = explode(',', $ids);
+        $service = new AgentApplyService();
+        
+        Db::transaction(function () use ($ids, $service) {
+            foreach ($ids as $id) {
+                $row = $this->model->get($id);
+                if ($row && $row->status == ApplyModel::STATUS_PENDING) {
+                    $service->approveApply($row, $this->auth->id);
+                }
+            }
+        });
+        
+        $this->success('批量审核成功');
+    }
+}

+ 39 - 0
application/admin/controller/commission/Identity.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace app\admin\controller\commission;
+
+use app\common\controller\Backend;
+use app\common\model\commission\Identity as IdentityModel;
+
+class Identity extends Backend
+{
+    protected $model = null;
+    protected $searchFields = 'id,name';
+    
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new IdentityModel();
+    }
+
+    public function index()
+    {
+        if (!$this->request->isAjax()) {
+            return $this->view->fetch();
+        }
+        
+        if ($this->request->request('keyField')) {
+            return $this->selectpage();
+        }
+        
+        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
+        
+        $list = $this->model
+            ->where($where)
+            ->order($sort, $order)
+            ->paginate($limit);
+        
+        $result = ['total' => $list->total(), 'rows' => $list->items()];
+        return json($result);
+    }
+}

+ 287 - 0
application/admin/view/commission/apply/detail.html

@@ -0,0 +1,287 @@
+<div class="panel panel-default panel-intro">
+    <div class="panel-heading">
+        <div class="panel-lead"><em>{:__('Apply details')}</em></div>
+        <ul class="nav nav-tabs">
+            <li class="active"><a href="#one" data-toggle="tab">{:__('Apply info')}</a></li>
+        </ul>
+    </div>
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="form-horizontal">
+                    
+                    <!-- 基本信息 -->
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">申请用户:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">{$row.user.nickname|default='-'} (ID: {$row.user_id})</p>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">申请类型:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">
+                                <span class="label label-{:$row.apply_type == 'personal' ? 'primary' : 'info'}">
+                                    {$row.apply_type_text}
+                                </span>
+                            </p>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">代理商身份:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">{$row.identity.name|default='-'}</p>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">申请地区:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">
+                                {$row.province_name} - {$row.city_name} - {$row.district_name}
+                            </p>
+                        </div>
+                    </div>
+
+                    <!-- 个人申请信息 -->
+                    {if condition="$row.apply_type == 'personal'"}
+                    <hr>
+                    <h4>个人申请信息</h4>
+                    
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">真实姓名:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">{$row.real_name}</p>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">身份证号:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">{$row.id_card}</p>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">手机号码:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">{$row.mobile}</p>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">身份证正面:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            {if condition="$row.id_card_front"}
+                            <a href="{$row.id_card_front|cdnurl}" target="_blank">
+                                <img src="{$row.id_card_front|cdnurl}" style="max-width:200px;max-height:200px;" />
+                            </a>
+                            {else /}
+                            <p class="form-control-static text-muted">未上传</p>
+                            {/if}
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">身份证反面:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            {if condition="$row.id_card_back"}
+                            <a href="{$row.id_card_back|cdnurl}" target="_blank">
+                                <img src="{$row.id_card_back|cdnurl}" style="max-width:200px;max-height:200px;" />
+                            </a>
+                            {else /}
+                            <p class="form-control-static text-muted">未上传</p>
+                            {/if}
+                        </div>
+                    </div>
+                    {/if}
+
+                    <!-- 企业申请信息 -->
+                    {if condition="$row.apply_type == 'company'"}
+                    <hr>
+                    <h4>企业申请信息</h4>
+                    
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">企业名称:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">{$row.company_name}</p>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">法人姓名:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">{$row.legal_person}</p>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">法人手机:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">{$row.legal_mobile}</p>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">法人身份证:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">{$row.legal_id_card}</p>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">法人身份证正面:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            {if condition="$row.legal_id_front"}
+                            <a href="{$row.legal_id_front|cdnurl}" target="_blank">
+                                <img src="{$row.legal_id_front|cdnurl}" style="max-width:200px;max-height:200px;" />
+                            </a>
+                            {else /}
+                            <p class="form-control-static text-muted">未上传</p>
+                            {/if}
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">法人身份证反面:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            {if condition="$row.legal_id_back"}
+                            <a href="{$row.legal_id_back|cdnurl}" target="_blank">
+                                <img src="{$row.legal_id_back|cdnurl}" style="max-width:200px;max-height:200px;" />
+                            </a>
+                            {else /}
+                            <p class="form-control-static text-muted">未上传</p>
+                            {/if}
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">营业执照:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            {if condition="$row.business_license"}
+                            <a href="{$row.business_license|cdnurl}" target="_blank">
+                                <img src="{$row.business_license|cdnurl}" style="max-width:200px;max-height:200px;" />
+                            </a>
+                            {else /}
+                            <p class="form-control-static text-muted">未上传</p>
+                            {/if}
+                        </div>
+                    </div>
+                    {/if}
+
+                    <!-- 申请状态信息 -->
+                    <hr>
+                    <h4>申请状态</h4>
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">申请状态:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">
+                                {switch name="$row.status"}
+                                {case value="pending"}<span class="label label-warning">待审核</span>{/case}
+                                {case value="approved"}<span class="label label-success">已通过</span>{/case}
+                                {case value="rejected"}<span class="label label-danger">已拒绝</span>{/case}
+                                {/switch}
+                            </p>
+                        </div>
+                    </div>
+
+                    {if condition="$row.reject_reason"}
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">拒绝原因:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static text-danger">{$row.reject_reason}</p>
+                        </div>
+                    </div>
+                    {/if}
+
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">申请时间:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">{$row.createtime|datetime}</p>
+                        </div>
+                    </div>
+
+                    {if condition="$row.audit_time"}
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">审核时间:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">{$row.audit_time|datetime}</p>
+                        </div>
+                    </div>
+                    {/if}
+
+                    {if condition="$row.admin"}
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2">审核管理员:</label>
+                        <div class="col-xs-12 col-sm-8">
+                            <p class="form-control-static">{$row.admin.username}</p>
+                        </div>
+                    </div>
+                    {/if}
+
+                    <!-- 操作按钮 -->
+                    {if condition="$row.status == 'pending'"}
+                    <div class="form-group">
+                        <label class="control-label col-xs-12 col-sm-2"></label>
+                        <div class="col-xs-12 col-sm-8">
+                            {if condition="$auth->check('commission/apply/approve')"}
+                            <button type="button" class="btn btn-success btn-approve-single" data-id="{$row.id}">
+                                <i class="fa fa-check"></i> 审核通过
+                            </button>
+                            {/if}
+                            {if condition="$auth->check('commission/apply/reject')"}
+                            <button type="button" class="btn btn-danger btn-reject-single" data-id="{$row.id}">
+                                <i class="fa fa-times"></i> 审核拒绝
+                            </button>
+                            {/if}
+                        </div>
+                    </div>
+                    {/if}
+                    
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+<script>
+$(function() {
+    // 单个通过按钮
+    $(document).on('click', '.btn-approve-single', function() {
+        var id = $(this).data('id');
+        Layer.confirm('确定要通过该申请吗?', {title: '提示'}, function(index) {
+            Fast.api.ajax({
+                url: 'commission/apply/approve',
+                data: {ids: id}
+            }, function() {
+                Layer.close(index);
+                location.reload();
+            });
+        });
+    });
+    
+    // 单个拒绝按钮
+    $(document).on('click', '.btn-reject-single', function() {
+        var id = $(this).data('id');
+        Layer.prompt({
+            title: '请输入拒绝原因',
+            formType: 2
+        }, function(value, index) {
+            if (!value || !value.trim()) {
+                Layer.msg('请输入拒绝原因');
+                return false;
+            }
+            Fast.api.ajax({
+                url: 'commission/apply/reject',
+                data: {ids: id, reason: value}
+            }, function() {
+                Layer.close(index);
+                location.reload();
+            });
+        });
+    });
+});
+</script>

+ 26 - 0
application/admin/view/commission/apply/index.html

@@ -0,0 +1,26 @@
+<div class="panel panel-default panel-intro">
+    <div class="panel-heading">
+        <ul class="nav nav-tabs">
+            <li class="active"><a href="#t-all" data-toggle="tab">{:__('All')}</a></li>
+        </ul>
+    </div>
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="t-all">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                        <a href="javascript:;" class="btn btn-success btn-approve btn-disabled disabled {:$auth->check('commission/apply/approve')?'':'hide'}" title="{:__('Approve')}" ><i class="fa fa-check-circle-o"></i> {:__('Approve')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-reject btn-disabled disabled {:$auth->check('commission/apply/reject')?'':'hide'}" title="{:__('Reject')}" ><i class="fa fa-times-circle-o"></i> {:__('Reject')}</a>
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-approve="{:$auth->check('commission/apply/approve')}"
+                           data-operate-reject="{:$auth->check('commission/apply/reject')}"
+                           data-operate-detail="{:$auth->check('commission/apply/detail')}"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>

+ 43 - 0
application/admin/view/commission/identity/add.html

@@ -0,0 +1,43 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+    
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-name" class="form-control" name="row[name]" type="text" data-rule="required">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Level')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-level" class="form-control" name="row[level]" type="number" value="1" data-rule="required">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Description')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-description" class="form-control" name="row[description]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class="radio">
+                <label for="row[status]-1"><input id="row[status]-1" name="row[status]" type="radio" value="1" checked> {:__('Shown')}</label> 
+                <label for="row[status]-0"><input id="row[status]-0" name="row[status]" type="radio" value="0"> {:__('Hidden')}</label> 
+            </div>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 43 - 0
application/admin/view/commission/identity/edit.html

@@ -0,0 +1,43 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+    
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}" data-rule="required">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Level')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-level" class="form-control" name="row[level]" type="number" value="{$row.level}" data-rule="required">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Description')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-description" class="form-control" name="row[description]" type="text" value="{$row.description|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class="radio">
+                <label for="row[status]-1"><input id="row[status]-1" name="row[status]" type="radio" value="1" {if condition="$row.status == 1"}checked{/if}> {:__('Shown')}</label> 
+                <label for="row[status]-0"><input id="row[status]-0" name="row[status]" type="radio" value="0" {if condition="$row.status == 0"}checked{/if}> {:__('Hidden')}</label> 
+            </div>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh}">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 28 - 0
application/admin/view/commission/identity/index.html

@@ -0,0 +1,28 @@
+<div class="panel panel-default panel-intro">
+    <div class="panel-heading">
+        <ul class="nav nav-tabs">
+            <li class="active"><a href="#t-all" data-toggle="tab">{:__('All')}</a></li>
+        </ul>
+    </div>
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="t-all">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('commission/identity/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('commission/identity/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('commission/identity/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('commission/identity/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-add="{:$auth->check('commission/identity/add')}"
+                           data-operate-edit="{:$auth->check('commission/identity/edit')}"
+                           data-operate-del="{:$auth->check('commission/identity/del')}"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>

+ 35 - 20
application/api/controller/User.php

@@ -68,35 +68,50 @@ class User extends Base
     {
     {
         $user = $this->auth->getUser();
         $user = $this->auth->getUser();
         $params = $this->request->param();
         $params = $this->request->param();
-        // 字段不传就报错 所以默认给值
-        $username = $params['username'] ?? '';
-        $avatar   = $params['avatar'] ?? '';
-        $nickname = $params['nickname'] ?? '';
-        $bio      = $params['bio'] ?? '';
-        $age = $params['age'] ?? '';
-        $gender = $params['gender'] ?? '';
+        
+        // 定义允许修改的字段
+        $allowedFields = ['username', 'avatar', 'nickname', 'bio', 'age', 'gender'];
+        $updateData = [];
+        
+        // 只处理前端实际传递的参数
+        foreach ($allowedFields as $field) {
+            if (isset($params[$field])) {
+                $updateData[$field] = $params[$field];
+            }
+        }
+        
+        // 如果没有任何要更新的字段
+        if (empty($updateData)) {
+            $this->error('请至少提供一个要修改的字段');
+        }
+        
+        // 处理头像URL(如果传递了avatar字段)
+        if (isset($updateData['avatar'])) {
+            $updateData['avatar'] = str_replace(cdnurl('', true), '', $updateData['avatar']);
+            $params['avatar'] = $updateData['avatar'];
+        }
+        
         // 验证器
         // 验证器
-        //  替换有域名的头像
-        $avatar = str_replace(cdnurl('', true), '', $avatar);
-        $params['avatar'] = $avatar;
         $validate = new \app\api\validate\User();
         $validate = new \app\api\validate\User();
         if (!$validate->check($params, [], 'profile')) {
         if (!$validate->check($params, [], 'profile')) {
             $this->error($validate->getError());
             $this->error($validate->getError());
         }
         }
-        // username 不传,则不修改
-        if ($username) {
-            $user->username = $username;
-            $exists = \app\common\model\User::where('username', $username)->where('id', '<>', $this->auth->id)->find();
+        
+        // 检查用户名是否重复(如果传递了username字段)
+        if (isset($updateData['username']) && !empty($updateData['username'])) {
+            $exists = \app\common\model\User::where('username', $updateData['username'])
+                ->where('id', '<>', $this->auth->id)
+                ->find();
             if ($exists) {
             if ($exists) {
                 $this->error(__('Username already exists'));
                 $this->error(__('Username already exists'));
             }
             }
         }
         }
-        $user->bio = $bio;        
-        $user->nickname = $nickname;
-        $user->username = $username;
-        $user->avatar = $avatar;
-        $user->age = $age;
-        $user->gender = $gender;
+        
+        // 只更新传递的字段
+        foreach ($updateData as $field => $value) {
+            $user->$field = $value;
+        }
+        
         $user->save();
         $user->save();
 
 
         $this->success('修改成功!');
         $this->success('修改成功!');

+ 90 - 0
application/api/controller/commission/AgentApply.php

@@ -0,0 +1,90 @@
+<?php
+
+namespace app\api\controller\commission;
+
+use app\common\Service\commission\AgentApply as AgentApplyService;
+use app\common\model\commission\Apply as ApplyModel;
+use think\Exception;
+use app\api\controller\Base;
+class AgentApply extends Base
+{
+    protected $noNeedLogin = ['identities', 'areas'];
+    protected $noNeedRight = ['*'];
+
+    /**
+     * 获取代理商身份列表
+     */
+    public function identities()
+    {
+        try {
+            $service = new AgentApplyService();
+            $identities = $service->getIdentityList();
+            $this->success('获取成功', $identities);
+        } catch (Exception $e) {
+            $this->error($e->getMessage());
+        }
+    }
+
+    /**
+     * 提交代理商申请
+     */
+    public function apply()
+    {
+        try {
+            $user = auth_user();
+            $data = $this->request->param();
+            
+            // 验证必要参数
+            $this->validateApplyParams($data);
+            
+            $service = new AgentApplyService();
+            $apply = $service->submitApply($user->id, $data);
+            
+            if ($apply->status == ApplyModel::STATUS_APPROVED) {
+                $this->success('申请提交成功,您已成为代理商!', $apply);
+            } else {
+                $this->success('申请提交成功,请等待审核!', $apply);
+            }
+        } catch (Exception $e) {
+            $this->error($e->getMessage());
+        }
+    }
+
+    /**
+     * 获取申请状态
+     */
+    public function status()
+    {
+        try {
+            $user = auth_user();
+            $service = new AgentApplyService();
+            $apply = $service->getUserApply($user->id);
+            
+            if (!$apply) {
+                $this->success('未找到申请记录', null);
+            }
+            
+            $this->success('获取成功', $apply);
+        } catch (Exception $e) {
+            $this->error($e->getMessage());
+        }
+    }
+
+    /**
+     * 验证申请参数
+     */
+    private function validateApplyParams($data)
+    {
+        $requiredFields = ['apply_type', 'agent_identity_id', 'province_id', 'city_id', 'district_id'];
+        
+        foreach ($requiredFields as $field) {
+            if (!isset($data[$field]) || $data[$field] === '') {
+                throw new Exception('参数' . $field . '不能为空');
+            }
+        }
+        
+        if (!in_array($data['apply_type'], [ApplyModel::APPLY_TYPE_PERSONAL, ApplyModel::APPLY_TYPE_COMPANY])) {
+            throw new Exception('申请类型不正确');
+        }
+    }
+}

+ 1 - 54
application/api/controller/commission/Commission.php

@@ -8,8 +8,6 @@ use app\common\Service\ShopConfigService;
 use app\api\controller\Base;
 use app\api\controller\Base;
 class Commission extends Base
 class Commission extends Base
 {
 {
-    protected $noNeedLogin = ['config'];
-    protected $noNeedRight = ['*'];
     protected AgentService $service;
     protected AgentService $service;
 
 
     public function _initialize()
     public function _initialize()
@@ -30,58 +28,7 @@ class Commission extends Base
         }
         }
     }
     }
 
 
-     /**
-     * 获取分销配置
-     * 
-     * @return void
-     */
-    public function config()
-    {
-        try {
-            // 获取分销配置
-            $commissionConfig = ShopConfigService::getConfigs('shop.commission');
-            
-            // 处理become_agent字段(如果是JSON字符串需要解析)
-            if (isset($commissionConfig['become_agent']) && is_string($commissionConfig['become_agent'])) {
-                $commissionConfig['become_agent'] = json_decode($commissionConfig['become_agent'], true) ?: ['type' => 'apply', 'value' => ''];
-            }
-            
-            // 构建返回的配置数据
-            $config = [
-                // 基础配置
-                'level' => intval($commissionConfig['level'] ?? 2),
-                'self_buy' => intval($commissionConfig['self_buy'] ?? 0),
-                'invite_lock' => $commissionConfig['invite_lock'] ?? 'share',
-                'agent_check' => intval($commissionConfig['agent_check'] ?? 0),
-                'upgrade_jump' => intval($commissionConfig['upgrade_jump'] ?? 1),
-                'upgrade_check' => intval($commissionConfig['upgrade_check'] ?? 0),
-                
-                // 成为分销商条件
-                'become_agent' => $commissionConfig['become_agent'] ?? ['type' => 'apply', 'value' => ''],
-                'need_form' => intval($commissionConfig['need_form'] ?? 0),
-                'background_image' => !empty($commissionConfig['background_image']) ? cdnurl($commissionConfig['background_image'], true) : '',
-                'show_protocol' => intval($commissionConfig['show_protocol'] ?? 1),
-                'apply_protocol' => $commissionConfig['apply_protocol'] ?? '申请协议',
-                
-                // 结算配置
-                'reward_type' => $commissionConfig['reward_type'] ?? 'pay_price',
-                'reward_event' => $commissionConfig['reward_event'] ?? 'paid',
-                'refund_commission_reward' => intval($commissionConfig['refund_commission_reward'] ?? 1),
-                'refund_commission_order' => intval($commissionConfig['refund_commission_order'] ?? 1),
-                
-                // 分享配置
-                'share_title' => $commissionConfig['share_title'] ?? '我发现了一个好商品',
-                'share_description' => $commissionConfig['share_description'] ?? '快来看看这个优质商品,价格优惠,质量保证!',
-                'share_image' => !empty($commissionConfig['share_image']) ? cdnurl($commissionConfig['share_image'], true) : '',
-            ];
-            
-            $this->success('获取成功', $config);
-            
-        } catch (\Exception $e) {
-            $this->error('获取配置失败: ' . $e->getMessage());
-        }
-    }
-
+  
 
 
    
    
 }
 }

+ 253 - 0
application/common/Service/Commission/AgentApply.php

@@ -0,0 +1,253 @@
+<?php
+
+namespace app\common\Service\commission;
+
+use app\common\model\commission\Apply as ApplyModel;
+use app\common\model\commission\Identity as IdentityModel;
+use app\common\model\commission\Agent as AgentModel;
+use app\common\model\Area;
+use app\common\Service\ShopConfigService;
+use think\Db;
+use think\Exception;
+
+class AgentApply
+{
+    /**
+     * 获取可用的代理商身份列表
+     */
+    public function getIdentityList()
+    {
+        return IdentityModel::getEnabledList();
+    }
+
+    /**
+     * 获取地区树形结构
+     */
+    public function getAreaTree($pid = 0, $level = 1, $maxLevel = 3)
+    {
+        if ($level > $maxLevel) {
+            return [];
+        }
+
+        $list = Area::where('pid', $pid)
+                   ->where('level', $level)
+                   ->field('id,pid,name,level')
+                   ->order('weigh desc,id asc')
+                   ->select();
+
+        $tree = [];
+        foreach ($list as $item) {
+            $node = $item->toArray();
+            if ($level < $maxLevel) {
+                $node['children'] = $this->getAreaTree($item['id'], $level + 1, $maxLevel);
+            }
+            $tree[] = $node;
+        }
+
+        return $tree;
+    }
+
+    /**
+     * 提交代理商申请
+     */
+    public function submitApply($userId, $data)
+    {
+        // 验证用户是否已经有申请记录
+        $existApply = ApplyModel::where('user_id', $userId)
+                                ->where('status', 'in', ['pending', 'approved'])
+                                ->find();
+        
+        if ($existApply) {
+            if ($existApply->status == 'approved') {
+                throw new Exception('您已经是代理商,无需重复申请');
+            } else {
+                throw new Exception('您已有待审核的申请,请等待审核结果');
+            }
+        }
+
+        // 验证身份是否存在
+        $identity = IdentityModel::where('id', $data['agent_identity_id'])
+                                 ->where('status', IdentityModel::STATUS_ENABLED)
+                                 ->find();
+        if (!$identity) {
+            throw new Exception('选择的代理商身份不存在或已禁用');
+        }
+
+        // 验证地区信息
+        $this->validateArea($data);
+
+        // 根据申请类型验证必要字段
+        $this->validateApplyData($data);
+
+        return Db::transaction(function () use ($userId, $data) {
+            // 创建申请记录
+            $apply = new ApplyModel();
+            $apply->user_id = $userId;
+            $apply->apply_type = $data['apply_type'];
+            $apply->agent_identity_id = $data['agent_identity_id'];
+            
+            // 地区信息
+            $apply->province_id = $data['province_id'];
+            $apply->city_id = $data['city_id'];
+            $apply->district_id = $data['district_id'];
+            $apply->province_name = $data['province_name'] ?? '';
+            $apply->city_name = $data['city_name'] ?? '';
+            $apply->district_name = $data['district_name'] ?? '';
+
+            // 根据申请类型填充对应字段
+            if ($data['apply_type'] == ApplyModel::APPLY_TYPE_PERSONAL) {
+                $apply->real_name = $data['real_name'];
+                $apply->id_card = $data['id_card'];
+                $apply->id_card_front = $data['id_card_front'];
+                $apply->id_card_back = $data['id_card_back'];
+                $apply->mobile = $data['mobile'];
+            } else {
+                $apply->company_name = $data['company_name'];
+                $apply->legal_person = $data['legal_person'];
+                $apply->legal_mobile = $data['legal_mobile'];
+                $apply->legal_id_card = $data['legal_id_card'];
+                $apply->legal_id_front = $data['legal_id_front'];
+                $apply->legal_id_back = $data['legal_id_back'];
+                $apply->business_license = $data['business_license'];
+            }
+
+            $apply->save();
+
+            // 检查是否需要审核
+            $needCheck = ShopConfigService::getConfigField('shop.commission.agent_apply_check');
+            
+            if (!$needCheck) {
+                // 不需要审核,直接通过
+                $this->approveApply($apply);
+            }
+
+            return $apply;
+        });
+    }
+
+    /**
+     * 验证地区信息
+     */
+    private function validateArea($data)
+    {
+        $requiredFields = ['province_id', 'city_id', 'district_id'];
+        foreach ($requiredFields as $field) {
+            if (empty($data[$field])) {
+                throw new Exception('请选择完整的省市区信息');
+            }
+        }
+
+        // 验证地区ID是否存在
+        $province = Area::where('id', $data['province_id'])->where('level', 1)->find();
+        $city = Area::where('id', $data['city_id'])->where('level', 2)->find();
+        $district = Area::where('id', $data['district_id'])->where('level', 3)->find();
+
+        if (!$province || !$city || !$district) {
+            throw new Exception('选择的地区信息不正确');
+        }
+    }
+
+    /**
+     * 验证申请数据
+     */
+    private function validateApplyData($data)
+    {
+        if ($data['apply_type'] == ApplyModel::APPLY_TYPE_PERSONAL) {
+            $requiredFields = ['real_name', 'id_card', 'id_card_front', 'id_card_back', 'mobile'];
+            foreach ($requiredFields as $field) {
+                if (empty($data[$field])) {
+                    throw new Exception('个人申请信息不完整');
+                }
+            }
+            
+            // 验证身份证格式
+            if (!$this->validateIdCard($data['id_card'])) {
+                throw new Exception('身份证号格式不正确');
+            }
+        } else {
+            $requiredFields = ['company_name', 'legal_person', 'legal_mobile', 'legal_id_card', 'legal_id_front', 'legal_id_back', 'business_license'];
+            foreach ($requiredFields as $field) {
+                if (empty($data[$field])) {
+                    throw new Exception('企业申请信息不完整');
+                }
+            }
+            
+            // 验证法人身份证格式
+            if (!$this->validateIdCard($data['legal_id_card'])) {
+                throw new Exception('法人身份证号格式不正确');
+            }
+        }
+    }
+
+    /**
+     * 验证身份证号格式
+     */
+    private function validateIdCard($idCard)
+    {
+        return preg_match('/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/', $idCard);
+    }
+
+    /**
+     * 审核通过申请
+     */
+    public function approveApply(ApplyModel $apply, $adminId = null)
+    {
+        return Db::transaction(function () use ($apply, $adminId) {
+            // 更新申请状态
+            $apply->status = ApplyModel::STATUS_APPROVED;
+            $apply->admin_id = $adminId;
+            $apply->audit_time = time();
+            $apply->save();
+
+            // 创建代理商记录
+            $this->createAgentFromApply($apply);
+
+            return $apply;
+        });
+    }
+
+    /**
+     * 审核拒绝申请
+     */
+    public function rejectApply(ApplyModel $apply, $reason, $adminId = null)
+    {
+        $apply->status = ApplyModel::STATUS_REJECTED;
+        $apply->reject_reason = $reason;
+        $apply->admin_id = $adminId;
+        $apply->audit_time = time();
+        return $apply->save();
+    }
+
+    /**
+     * 根据申请信息创建代理商
+     */
+    private function createAgentFromApply(ApplyModel $apply)
+    {
+        // 检查用户是否已经是分销商
+        $existAgent = AgentModel::where('user_id', $apply->user_id)->find();
+        if ($existAgent) {
+            return $existAgent;
+        }
+
+        // 创建分销商记录
+        $agent = new AgentModel();
+        $agent->user_id = $apply->user_id;
+        $agent->level = 1; // 默认等级
+        $agent->status = AgentModel::AGENT_STATUS_NORMAL;
+        $agent->become_time = time();
+        $agent->save();
+
+        return $agent;
+    }
+
+    /**
+     * 获取用户的申请记录
+     */
+    public function getUserApply($userId)
+    {
+        return ApplyModel::where('user_id', $userId)
+                         ->with(['identity', 'province', 'city', 'district'])
+                         ->order('id desc')
+                         ->find();
+    }
+}

+ 111 - 0
application/common/model/commission/Apply.php

@@ -0,0 +1,111 @@
+<?php
+
+namespace app\common\model\commission;
+
+use think\Model;
+
+class Apply extends Model
+{
+    protected $name = 'shopro_commission_apply';
+    
+    // 开启自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+    
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+
+    // 追加属性
+    protected $append = [
+        'apply_type_text',
+        'status_text'
+    ];
+
+    // 申请类型
+    const APPLY_TYPE_PERSONAL = 'personal';
+    const APPLY_TYPE_COMPANY = 'company';
+
+    // 申请状态
+    const STATUS_PENDING = 'pending';
+    const STATUS_APPROVED = 'approved';
+    const STATUS_REJECTED = 'rejected';
+
+    public function getApplyTypeList()
+    {
+        return [
+            self::APPLY_TYPE_PERSONAL => '个人申请',
+            self::APPLY_TYPE_COMPANY => '企业申请'
+        ];
+    }
+
+    public function getStatusList()
+    {
+        return [
+            self::STATUS_PENDING => '待审核',
+            self::STATUS_APPROVED => '已通过',
+            self::STATUS_REJECTED => '已拒绝'
+        ];
+    }
+
+    public function getApplyTypeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['apply_type']) ? $data['apply_type'] : '');
+        $list = $this->getApplyTypeList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+    public function getStatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+        $list = $this->getStatusList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+    /**
+     * 关联用户模型
+     */
+    public function user()
+    {
+        return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT');
+    }
+
+    /**
+     * 关联代理商身份
+     */
+    public function identity()
+    {
+        return $this->belongsTo('app\common\model\commission\Identity', 'agent_identity_id', 'id', [], 'LEFT');
+    }
+
+    /**
+     * 关联省份
+     */
+    public function province()
+    {
+        return $this->belongsTo('app\common\model\Area', 'province_id', 'id', [], 'LEFT');
+    }
+
+    /**
+     * 关联城市
+     */
+    public function city()
+    {
+        return $this->belongsTo('app\common\model\Area', 'city_id', 'id', [], 'LEFT');
+    }
+
+    /**
+     * 关联区域
+     */
+    public function district()
+    {
+        return $this->belongsTo('app\common\model\Area', 'district_id', 'id', [], 'LEFT');
+    }
+
+    /**
+     * 关联审核管理员
+     */
+    public function admin()
+    {
+        return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT');
+    }
+}

+ 51 - 0
application/common/model/commission/Identity.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace app\common\model\commission;
+
+use think\Model;
+
+class Identity extends Model
+{
+    protected $name = 'shopro_commission_identity';
+    
+    // 开启自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+    
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+
+    // 追加属性
+    protected $append = [
+        'status_text'
+    ];
+
+    // 状态
+    const STATUS_DISABLED = 0;
+    const STATUS_ENABLED = 1;
+
+    public function getStatusList()
+    {
+        return [
+            self::STATUS_DISABLED => '禁用',
+            self::STATUS_ENABLED => '启用'
+        ];
+    }
+
+    public function getStatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+        $list = $this->getStatusList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+    /**
+     * 获取启用的身份列表
+     */
+    public static function getEnabledList()
+    {
+        return self::where('status', self::STATUS_ENABLED)
+                   ->order('weigh asc, id asc')
+                   ->select();
+    }
+}

+ 141 - 0
public/assets/js/backend/commission/apply.js

@@ -0,0 +1,141 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数
+            Table.api.init({
+                extend: {
+                    index_url: 'commission/apply/index',
+                    detail_url: 'commission/apply/detail',
+                    approve_url: 'commission/apply/approve',
+                    reject_url: 'commission/apply/reject',
+                    table: 'shopro_commission_apply',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                sortOrder: 'desc',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id'), sortable: true},
+                        {field: 'user.nickname', title: __('User'), operate: 'LIKE', formatter: Table.api.formatter.search},
+                        {field: 'apply_type_text', title: __('Apply type'), searchList: {"personal": "个人申请", "company": "企业申请"}, formatter: function(value, row, index) {
+                            if (row.apply_type === 'personal') {
+                                return '<span class="label label-primary">' + value + '</span>';
+                            } else {
+                                return '<span class="label label-info">' + value + '</span>';
+                            }
+                        }},
+                        {field: 'identity.name', title: __('Identity'), operate: false},
+                        {field: 'real_name', title: __('Real name'), visible: false},
+                        {field: 'company_name', title: __('Company name'), visible: false},
+                        {field: 'province_name', title: __('Area'), operate: false, formatter: function(value, row, index) {
+                            return (row.province_name || '') + '-' + (row.city_name || '') + '-' + (row.district_name || '');
+                        }},
+                        {field: 'status_text', title: __('Status'), searchList: {"pending": "待审核", "approved": "已通过", "rejected": "已拒绝"}, formatter: function(value, row, index) {
+                            var colorMap = {
+                                'pending': 'warning',
+                                'approved': 'success', 
+                                'rejected': 'danger'
+                            };
+                            var color = colorMap[row.status] || 'default';
+                            return '<span class="label label-' + color + '">' + value + '</span>';
+                        }},
+                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, 
+                         formatter: function (value, row, index) {
+                            var html = [];
+                            
+                            // 详情按钮
+                            if (Table.api.checkAuth('detail')) {
+                                html.push('<a href="' + Fast.api.fixurl("commission/apply/detail/ids/" + row.id) + '" class="btn btn-xs btn-info btn-dialog" data-area=\'["80%","80%"]\' title="' + __('Detail') + '"><i class="fa fa-list"></i></a>');
+                            }
+                            
+                            // 审核按钮
+                            if (row.status === 'pending') {
+                                if (Table.api.checkAuth('approve')) {
+                                    html.push('<a href="javascript:;" class="btn btn-xs btn-success btn-approve-one" data-id="' + row.id + '" title="' + __('Approve') + '"><i class="fa fa-check"></i></a>');
+                                }
+                                if (Table.api.checkAuth('reject')) {
+                                    html.push('<a href="javascript:;" class="btn btn-xs btn-danger btn-reject-one" data-id="' + row.id + '" title="' + __('Reject') + '"><i class="fa fa-times"></i></a>');
+                                }
+                            }
+                            
+                            return html.join(' ');
+                         }}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+            
+            // 批量审核按钮
+            $(document).on('click', '.btn-approve', function () {
+                var ids = Table.api.selectedids(table);
+                if (ids.length === 0) {
+                    Toastr.warning("请至少选择一条记录");
+                    return false;
+                }
+                Layer.confirm(__('Are you sure you want to approve %s selected item?', ids.length), {
+                    icon: 3,
+                    title: __('Warning'),
+                    shadeClose: true,
+                }, function (index) {
+                    Table.api.multi("approve", ids, table, this);
+                    Layer.close(index);
+                });
+            });
+            
+            // 单个审核通过
+            $(document).on('click', '.btn-approve-one', function () {
+                var id = $(this).data('id');
+                Layer.confirm('确定要通过该申请吗?', {title: '提示'}, function(index) {
+                    Fast.api.ajax({
+                        url: 'commission/apply/approve',
+                        data: {ids: id}
+                    }, function(data, ret) {
+                        Layer.close(index);
+                        table.bootstrapTable('refresh');
+                        Toastr.success(ret.msg || '操作成功');
+                    });
+                });
+            });
+            
+            // 单个审核拒绝
+            $(document).on('click', '.btn-reject-one', function () {
+                var id = $(this).data('id');
+                Layer.prompt({
+                    title: '请输入拒绝原因',
+                    formType: 2
+                }, function(value, index) {
+                    if (!value || !value.trim()) {
+                        Layer.msg('请输入拒绝原因');
+                        return false;
+                    }
+                    Fast.api.ajax({
+                        url: 'commission/apply/reject',
+                        data: {ids: id, reason: value}
+                    }, function(data, ret) {
+                        Layer.close(index);
+                        table.bootstrapTable('refresh');
+                        Toastr.success(ret.msg || '操作成功');
+                    });
+                });
+            });
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});

+ 56 - 0
public/assets/js/backend/commission/identity.js

@@ -0,0 +1,56 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数
+            Table.api.init({
+                extend: {
+                    index_url: 'commission/identity/index',
+                    add_url: 'commission/identity/add',
+                    edit_url: 'commission/identity/edit',
+                    del_url: 'commission/identity/del',
+                    multi_url: 'commission/identity/multi',
+                    table: 'shopro_commission_identity',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'weigh',
+                sortOrder: 'asc',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id'), sortable: true},
+                        {field: 'name', title: __('Name'), operate: 'LIKE', formatter: Table.api.formatter.search},
+                        {field: 'level', title: __('Level'), sortable: true},
+                        {field: 'description', title: __('Description'), operate: 'LIKE'},
+                        {field: 'status', title: __('Status'), searchList: {"0": __('Hidden'), "1": __('Shown')}, formatter: Table.api.formatter.status},
+                        {field: 'weigh', title: __('Weigh'), sortable: true, operate: false},
+                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});