浏览代码

fix:代理商身份

super-yimizi 1 天之前
父节点
当前提交
a4f3886f9a

+ 52 - 12
application/admin/controller/commission/Apply.php

@@ -117,35 +117,75 @@ class Apply extends Backend
     }
 
     /**
-     * 批量审核通过
+     * 删除
      */
-    public function multi($ids = null)
+    public function del($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();
+        $deleteCount = 0;
         
-        Db::transaction(function () use ($ids, $service) {
+        Db::transaction(function () use ($ids, &$deleteCount) {
             foreach ($ids as $id) {
                 $row = $this->model->get($id);
-                if ($row && $row->status == ApplyModel::STATUS_PENDING) {
-                    $service->approveApply($row, $this->auth->id);
+                if ($row) {
+                    // 只允许删除待审核和已拒绝的申请
+                    //if (in_array($row->status, [ApplyModel::STATUS_PENDING, ApplyModel::STATUS_REJECTED])) {
+                        $row->delete();
+                        $deleteCount++;
+                    //}
                 }
             }
         });
         
-        $this->success('批量审核成功');
+        if ($deleteCount > 0) {
+            $this->success("成功删除 {$deleteCount} 条申请记录");
+        } else {
+            $this->error('没有可删除的记录(只能删除待审核和已拒绝的申请)');
+        }
+    }
+
+    /**
+     * 批量审核通过
+     */
+    public function multi($ids = null)
+    {
+        if (!$this->request->isPost()) {
+            $this->error(__('Invalid parameters'));
+        }
+        
+        $action = $this->request->post('action');
+        if ($action == 'approve') {
+            // 批量审核通过
+            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('批量审核成功');
+        } elseif ($action == 'del') {
+            // 批量删除
+            return $this->del($ids);
+        } else {
+            return parent::multi($ids);
+        }
     }
 }

+ 11 - 3
application/admin/view/commission/apply/index.html

@@ -9,14 +9,22 @@
             <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>
+                        {:build_toolbar('refresh')}
+                        <!-- <div class="dropdown btn-group {:$auth->check('commission/apply/approve')?'':'hide'}">
+                            <a class="btn btn-success btn-approve btn-disabled disabled" href="javascript:;"><i class="fa fa-check"></i> 批量审核通过</a>
+                        </div> -->
+                        <div class="dropdown btn-group {:$auth->check('commission/apply/del')?'':'hide'}">
+                            <a class="btn btn-danger btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
+                            <ul class="dropdown-menu text-left" role="menu">
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="action=del"><i class="fa fa-trash"></i> {:__('Delete')}</a></li>
+                            </ul>
+                        </div>
                     </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')}"
+                           data-operate-del="{:$auth->check('commission/apply/del')}"
                            width="100%">
                     </table>
                 </div>

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

@@ -9,6 +9,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     detail_url: 'commission/apply/detail',
                     approve_url: 'commission/apply/approve',
                     reject_url: 'commission/apply/reject',
+                    del_url: 'commission/apply/del',
                     table: 'shop_commission_apply',
                 }
             });
@@ -72,6 +73,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                 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>');
                             }
                             
+                            // 删除按钮 - 只允许删除待审核和已拒绝的申请
+                            if (row.status === 'pending' || row.status === 'rejected') {
+                                html.push('<a href="javascript:;" class="btn btn-xs btn-warning btn-delone" data-id="' + row.id + '" title="' + __('Del') + '"><i class="fa fa-trash"></i></a>');
+                            }
+                            
                             return html.join(' ');
                          }}
                     ]
@@ -134,6 +140,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     });
                 });
             });
+            
+            // 单个删除
+            $(document).on('click', '.btn-delone', function () {
+                var id = $(this).data('id');
+                Layer.confirm('确定要删除该申请记录吗?删除后不可恢复!', {
+                    icon: 3,
+                    title: '提示'
+                }, function(index) {
+                    Fast.api.ajax({
+                        url: 'commission/apply/del',
+                        data: {ids: id}
+                    }, function(data, ret) {
+                        Layer.close(index);
+                        table.bootstrapTable('refresh');
+                        Toastr.success(ret.msg || '删除成功');
+                    });
+                });
+            });
         },
         api: {
             bindevent: function () {