OaCheckAgentController.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace api\oa\controller;
  3. use think\Db;
  4. class OaCheckAgentController extends OacallbackController {
  5. function _initialize() {
  6. parent::_initialize();
  7. $this->checkLegion();
  8. if (isset($this->param['agent_name'])) {
  9. $this->checkAgentname();
  10. $this->checkAgentByAgentNameAndLegionName($this->param['legion_name'], $this->param['agent_name']);
  11. } else {
  12. $this->checkAgentByAgentName($this->param['legion_name']);
  13. }
  14. }
  15. /**
  16. * @return $this
  17. */
  18. function checkAgentname() {
  19. if (empty($this->param['agent_name'])) {
  20. return $this->oa_class->hs_api_responce('410', '推广员名称为空');
  21. }
  22. }
  23. /**
  24. * @return $this
  25. */
  26. function checkLegion() {
  27. if (empty($this->param['legion_name'])) {
  28. return $this->oa_class->hs_api_responce('411', '军团长名称为空');
  29. }
  30. }
  31. /**
  32. * 检测军团长
  33. *
  34. * @param $legion_name
  35. *
  36. * @return $this
  37. */
  38. function checkAgentByAgentName($legion_name) {
  39. $_oa_agent_class = new \huolib\oa\OaAgent();
  40. $_oa_agent_class->checkAgentByAgentName($legion_name);
  41. }
  42. /**
  43. * 检测军团长和推广员是否存在并且关系正确
  44. *
  45. * @param string $legion_name
  46. * @param string $agent_name
  47. *
  48. */
  49. function checkAgentByAgentnameAndLegionname($legion_name = '', $agent_name = '') {
  50. $_oa_agent_class = new \huolib\oa\OaAgent();
  51. $_oa_agent_class->checkAgentByAgentNameAndLegionName($legion_name, $agent_name);
  52. }
  53. }