diff --git a/app/admin/controller/order/WithdrawOrder.php b/app/admin/controller/order/WithdrawOrder.php new file mode 100644 index 0000000..8d2709e --- /dev/null +++ b/app/admin/controller/order/WithdrawOrder.php @@ -0,0 +1,87 @@ + 'desc']; + + protected string|array $orderGuarantee = ['id' => 'desc']; + + protected array $withJoinTable = ['user', 'channel', 'reviewAdmin']; + + protected function initController(WebmanRequest $request): ?Response + { + $this->model = new \app\common\model\WithdrawOrder(); + return null; + } + + protected function _index(): Response + { + if ($this->request && $this->request->get('select')) { + return $this->select($this->request); + } + + list($where, $alias, $limit, $order) = $this->queryBuilder(); + $table = strtolower($this->model->getTable()); + $mainShort = $alias[$table] ?? ''; + if ($mainShort !== '' && $this->auth && !$this->auth->isSuperAdmin()) { + $channelIds = $this->getScopedChannelIdsForFilter(); + $where[] = [$mainShort . '.channel_id', 'in', $channelIds !== [] ? $channelIds : [0]]; + } + + $res = $this->model + ->withJoin($this->withJoinTable, $this->withJoinType) + ->with($this->withJoinTable) + ->visible([ + 'user' => ['username', 'phone'], + 'channel' => ['name'], + 'reviewAdmin' => ['username'], + ]) + ->alias($alias) + ->where($where) + ->order($order) + ->paginate($limit); + + return $this->success('', [ + 'list' => $res->items(), + 'total' => $res->total(), + 'remark' => get_route_remark(), + ]); + } + + /** + * @return int[] + */ + private function getScopedChannelIdsForFilter(): array + { + if (!$this->auth) { + return [0]; + } + if ($this->auth->isSuperAdmin()) { + return []; + } + $admin = Db::name('admin')->field(['id', 'channel_id'])->where('id', $this->auth->id)->find(); + $ids = []; + if ($admin && !empty($admin['channel_id'])) { + $ids[] = $admin['channel_id']; + } + $owned = Db::name('channel')->where('top_admin_id', $this->auth->id)->column('id'); + $created = Db::name('channel')->where('admin_id', $this->auth->id)->column('id'); + return array_values(array_unique(array_merge($ids, $owned, $created))); + } +} diff --git a/app/common/model/WithdrawOrder.php b/app/common/model/WithdrawOrder.php new file mode 100644 index 0000000..29efde5 --- /dev/null +++ b/app/common/model/WithdrawOrder.php @@ -0,0 +1,37 @@ + 'integer', + 'update_time' => 'integer', + 'review_time' => 'integer', + 'amount' => 'string', + 'fee' => 'string', + 'actual_amount' => 'string', + 'status' => 'integer', + ]; + + public function user(): \think\model\relation\BelongsTo + { + return $this->belongsTo(User::class, 'user_id', 'id'); + } + + public function channel(): \think\model\relation\BelongsTo + { + return $this->belongsTo(Channel::class, 'channel_id', 'id'); + } + + public function reviewAdmin(): \think\model\relation\BelongsTo + { + return $this->belongsTo(\app\admin\model\Admin::class, 'review_admin_id', 'id'); + } +} diff --git a/web/src/lang/backend/en/order/withdrawOrder.ts b/web/src/lang/backend/en/order/withdrawOrder.ts new file mode 100644 index 0000000..6377f77 --- /dev/null +++ b/web/src/lang/backend/en/order/withdrawOrder.ts @@ -0,0 +1,23 @@ +export default { + 'quick Search Fields': 'Order No./User ID', + id: 'ID', + order_no: 'Order No.', + user_id: 'User ID', + channel_id: 'Channel ID', + amount: 'Apply amount', + fee: 'Fee', + actual_amount: 'Actual amount', + status: 'Status', + 'status 0': 'Pending review', + 'status 1': 'Approved', + 'status 2': 'Rejected', + 'status 3': 'Paid', + review_admin_id: 'Reviewer', + review_time: 'Review time', + remark: 'Remark', + create_time: 'Created', + update_time: 'Updated', + user_username: 'Username', + channel_name: 'Channel', + review_admin_username: 'Reviewer', +} diff --git a/web/src/lang/backend/zh-cn/order/withdrawOrder.ts b/web/src/lang/backend/zh-cn/order/withdrawOrder.ts new file mode 100644 index 0000000..d4f8368 --- /dev/null +++ b/web/src/lang/backend/zh-cn/order/withdrawOrder.ts @@ -0,0 +1,23 @@ +export default { + 'quick Search Fields': '订单号/用户ID', + id: 'ID', + order_no: '订单号', + user_id: '用户ID', + channel_id: '渠道ID', + amount: '申请金额', + fee: '手续费', + actual_amount: '实际到账', + status: '状态', + 'status 0': '待审核', + 'status 1': '已通过', + 'status 2': '已拒绝', + 'status 3': '已打款', + review_admin_id: '审核管理员', + review_time: '审核时间', + remark: '备注', + create_time: '创建时间', + update_time: '更新时间', + user_username: '用户名', + channel_name: '渠道', + review_admin_username: '审核人', +} diff --git a/web/src/views/backend/order/withdrawOrder/index.vue b/web/src/views/backend/order/withdrawOrder/index.vue new file mode 100644 index 0000000..407aba6 --- /dev/null +++ b/web/src/views/backend/order/withdrawOrder/index.vue @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + diff --git a/web/src/views/backend/order/withdrawOrder/popupForm.vue b/web/src/views/backend/order/withdrawOrder/popupForm.vue new file mode 100644 index 0000000..e3c61ba --- /dev/null +++ b/web/src/views/backend/order/withdrawOrder/popupForm.vue @@ -0,0 +1,50 @@ + + + + {{ baTable.form.operate ? t(baTable.form.operate) : '' }} + + + + + + + + + + + + + + + + + + + + {{ t('Cancel') }} + {{ baTable.form.operateIds && baTable.form.operateIds.length > 1 ? t('Save and edit next item') : t('Save') }} + + + + + + + +