// +---------------------------------------------------------------------- declare (strict_types = 1); namespace app\store\controller\members; use app\common\enum\member\Action; use app\common\enum\member\AuditStatus; use app\store\controller\Controller; use app\store\model\member\DeductionManual as DeductionManualModel; use app\store\model\member\MemberCardsAction as MemberCardsActionModel; /** * 金米粒手工扣减管理 * Class Refund * @package app\store\controller\member */ class DeductionManual extends Controller { /** * 列表 * @return array * @throws \think\db\exception\DbException * @author: zjwhust * @Time: 2022/5/25 14:56 */ public function list() { $model = new DeductionManualModel; $list = $model->getList($this->request->param()); return $this->renderSuccess(compact('list')); } /** * 新增 * @return array * @author: zjwhust * @Time: 2022/5/25 14:56 */ public function add() { $model = new DeductionManualModel; $postData = $this->postForm(); $postData['number'] = 'KJ'.date('YmdHis').rand(100,999); $postData['audit_user'] = $this->store['user']['real_name']?:''; $postData['audit_admin_id'] = $this->store['user']['store_user_id']?:''; if(!$model->add($postData)){ return $this->renderError($model->getError() ?: '新增失败'); } return $this->renderSuccess([], '新增成功'); } /** * 编辑 * @return array * @author: zjwhust * @Time: 2022/5/25 14:56 */ public function edit() { $postData = $this->postForm(); $model = DeductionManualModel::find($postData['id']); $postData['audit_status'] = AuditStatus::AUDIT_WAIT; $postData['audit_user'] = $this->store['user']['real_name']?:''; $postData['audit_admin_id'] = $this->store['user']['store_user_id']?:''; if(!$model->edit($postData)){ return $this->renderError($model->getError() ?: '编辑失败'); } return $this->renderSuccess([], '编辑成功'); } /** * 审核 * @return array * @author: zjwhust * @Time: 2022/5/25 14:56 */ public function audit() { $postData = $this->postForm(); $model = DeductionManualModel::find($postData['id']); $postData['audit_user'] = $this->store['user']['real_name']?:''; $postData['audit_admin_id'] = $this->store['user']['store_user_id']?:''; if(!$model->audit($postData)){ return $this->renderError($model->getError() ?: '审核失败'); } return $this->renderSuccess([], '审核成功'); } /** * 撤销并关闭 * @return array * @author: zjwhust * @Time: 2022/5/25 14:59 */ public function revoke() { $postData = $this->postForm(); $model = DeductionManualModel::find($postData['id']); $postData['audit_user'] = $this->store['user']['real_name']?:''; $postData['audit_admin_id'] = $this->store['user']['store_user_id']?:''; if($model->audit($postData)){ return $this->renderError($model->getError() ?: '撤销失败'); } return $this->renderSuccess([], '撤销成功'); } /** * 详情 * @param int $id * @return array; * @author: zjwhust * @Time: 2022/5/25 14:58 */ public function detail(int $id){ $detail = DeductionManualModel::detail($id,['user']); //获取行为日志列表 // $action = (new MemberCardsActionModel)->getLists($id,Action::DEDUCTION_MANUAL,0); return $this->renderSuccess(compact('detail')); } }