| | |
| | | use app\api\service\branch\MemberService; |
| | | use app\api\model\branch\ActivityUser as ActivityUserModel; |
| | | use app\api\model\branch\Member as MemberModel; |
| | | use app\branch\model\position\Position as PositionModel; |
| | | use app\common\model\settings\Region as RegionModel; |
| | | |
| | | /** |
| | | * 会员数据控制器 |
| | |
| | | $list = $model->getUserRankList($date, $this->branch['branch_id']); |
| | | return $this->renderSuccess('', compact('list')); |
| | | } |
| | | |
| | | /** |
| | | * 新增股东 |
| | | */ |
| | | public function add() |
| | | { |
| | | if ($this->request->isGet()) { |
| | | $positionList = PositionModel::getAll(); |
| | | $regionData = RegionModel::getRegionForApi(); |
| | | return $this->renderSuccess('', compact('positionList', 'regionData')); |
| | | } |
| | | $model = new MemberModel; |
| | | // 新增记录 |
| | | $data = json_decode($this->request->post('formData', '', null), true); |
| | | $data['branch_id'] = $this->branch['branch_id']; |
| | | if ($model->add($data)) { |
| | | return $this->renderSuccess('添加成功'); |
| | | } |
| | | return $this->renderError($model->getError() ?: '添加失败'); |
| | | } |
| | | |
| | | /** |
| | | * 编辑成员 |
| | | */ |
| | | public function edit($user_id) |
| | | { |
| | | $model = MemberModel::detail($user_id, ['user', 'supplier', 'position']); |
| | | if ($this->request->isGet()) { |
| | | $positionList = PositionModel::getAll(); |
| | | $regionData = RegionModel::getRegionForApi(); |
| | | return $this->renderSuccess('', compact('positionList', 'regionData', 'model')); |
| | | } |
| | | $data = json_decode($this->request->post('formData', '', null), true); |
| | | if ($model->edit($data)) { |
| | | return $this->renderSuccess('更新成功'); |
| | | } |
| | | return $this->renderError($model->getError() ?: '更新失败'); |
| | | } |
| | | |
| | | /** |
| | | * 软删除成员 |
| | | */ |
| | | public function delete($user_id) |
| | | { |
| | | $model = MemberModel::detail($user_id); |
| | | if (!$model->setDelete()) { |
| | | return $this->renderError('删除失败'); |
| | | } |
| | | return $this->renderSuccess('删除成功'); |
| | | } |
| | | } |