/** * 更新粉丝备注. * * @param int $id 粉丝ID * * @return Response */ public function postRemark(UpdateRequest $request) { /* * 请求参数: * * id: 自增ID * remark: 新的备注名 */ return $this->fan->updateRemark($request); }
/** * 粉丝活跃度+1, 同时在fan_reports表中增加记录. * * @param int $accountId AccountID * @param string $openId OpenID * @param string $type 操作类型 * * @return bool */ public function setLiveness($accountId, $openId, $type) { /* * 1 粉丝活跃度+1 */ $this->fanRepository->updateLiveness(['account_id' => $accountId, 'openid' => $openId]); /* * 2 在fan_reports表中增加记录 */ $this->fanReportRepository->store(['account_id' => $accountId, 'openid' => $openId, 'type' => $type]); }
/** * 移动粉丝所属组[支持批量]. */ public function postMoveFans(MoveRequest $request) { /* * 请求参数: * * ids: 粉丝自增ID * to_group_id: 粉丝组group_id */ /* * 1 校验粉丝ID */ if (!is_array($request->ids)) { return '粉丝ID类型不正确'; } /* * 2 使用 to_group_id 查找分组是否存在 */ $group = $this->fanGroup->getGroupByGroupid($this->account->id, $request->to_group_id); if ($group) { $fan = new FanRepository(); /* * 2.1) 通过粉丝ID 获取粉丝原所在组group_id */ $groupIds = $fan->getFanGroupByfanIds($request->ids); /* * 2.2) 存在则移动 */ if ($fan->moveFanGroupByFansid($request->ids, $request->to_group_id)) { /* * 2.2.1) 更改粉丝组的 fan_count 值 */ $this->fanGroup->cutFanCount($this->account->id, $group->id, $groupIds, count($request->ids)); } } }
/** * 编辑备注表单. * * @param $id * * @return mixed */ public function getEditRemark($id) { //获取旧备注信息 $remark = $this->fanRepository->find($id)->remark; return user_view('fans.editremark')->with(['remark' => $remark]); }
/** * Delete. * * @param int $id 粉丝组自增ID * @param array $input Request */ public function delete($accountId, $id) { /* * 1 查找粉丝组数据 */ $model = $this->getGroupByid($accountId, $id); /* * 2 验证这个组能不能删除 */ if ($model && !$model->is_default) { /* * 2.1) 本地粉丝所属组更新为"默认组" */ $fanRepository = new FanRepository(); $fanRepository->moveFanGroupByGroupid($model->account_id, $model->group_id, 0); /* * 2.2) 软删除这个组 */ return $model->delete(); } }
/** * 根据ID删除. * * @param string $openId * @param int $accountId * * @return int */ public function deleteByOpenId($openId, $accountId) { return $this->fanRepository->deleteByOpenId($openId, $accountId); }