Join.Class.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * 加盟管理Controller
  4. * Created by PhpStorm.
  5. * User: 小威
  6. * Date: 2020/03/25
  7. * Time: 16:16
  8. */
  9. namespace JinDouYun\Controller\Manage;
  10. use Mall\Framework\Core\ErrorCode;
  11. use Mall\Framework\Core\StatusCode;
  12. use JinDouYun\Controller\BaseController;
  13. use JinDouYun\Model\Manage\MJoin;
  14. class Join extends BaseController
  15. {
  16. private $objMJoin;
  17. public function __construct($isCheckAcl = false, $isMustLogin = false, $checkToken = false)
  18. {
  19. parent::__construct($isCheckAcl, $isMustLogin, $checkToken);
  20. $this->objMJoin = new MJoin();
  21. }
  22. /**
  23. * 获取所有加盟列表
  24. * @throws \Exception
  25. */
  26. public function getAllJoin()
  27. {
  28. $result = $this->objMJoin->getAllJoin();
  29. if ($result->isSuccess()) {
  30. parent::sendOutput($result->getData());
  31. } else {
  32. parent::sendOutput($result->getData(), ErrorCode::$dberror);
  33. }
  34. }
  35. /**
  36. * 加盟添加
  37. */
  38. public function addJoin()
  39. {
  40. $params = $this->request->getRawJson();
  41. $data = [
  42. 'name' => isset($params['name']) ? $params['name'] : '',
  43. 'enterpriseName' => isset($params['enterpriseName']) ? $params['enterpriseName'] : '',
  44. 'position' => isset($params['position']) ? $params['position'] : '',
  45. 'mobile' => isset($params['mobile']) ? $params['mobile'] : '',
  46. 'provinceCode' => isset($params['provinceCode']) ? $params['provinceCode'] : '',
  47. 'cityCode' => isset($params['cityCode']) ? $params['cityCode'] : '',
  48. 'districtCode' => isset($params['districtCode']) ? $params['districtCode'] : '',
  49. 'address' => isset($params['address']) ? $params['address'] : '',
  50. 'createTime' => time(),
  51. 'updateTime' => time(),
  52. ];
  53. foreach($data as $key => $value){
  54. if(empty($value)){
  55. parent::sendOutput($key.'参数错误', ErrorCode::$paramError);
  56. }
  57. }
  58. $modelResult = $this->objMJoin->addJoin($data);
  59. if(!$modelResult->isSuccess()){
  60. parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
  61. }
  62. parent::sendOutput($modelResult->getData());
  63. }
  64. /**
  65. * 预约列表
  66. * @throws \Exception
  67. */
  68. public function getAllReservation()
  69. {
  70. $result = $this->objMJoin->getAllReservation();
  71. if ($result->isSuccess()) {
  72. parent::sendOutput($result->getData());
  73. } else {
  74. parent::sendOutput($result->getData(), ErrorCode::$dberror);
  75. }
  76. }
  77. /**
  78. * 预约添加
  79. */
  80. public function addReservation()
  81. {
  82. $params = $this->request->getRawJson();
  83. $data = [
  84. 'mobile' => isset($params['mobile']) ? $params['mobile'] : '',
  85. 'createTime' => time(),
  86. ];
  87. foreach($data as $key => $value){
  88. if(empty($value)){
  89. parent::sendOutput($key.'参数错误', ErrorCode::$paramError);
  90. }
  91. }
  92. $modelResult = $this->objMJoin->addReservation($data);
  93. if(!$modelResult->isSuccess()){
  94. parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode());
  95. }
  96. parent::sendOutput($modelResult->getData());
  97. }
  98. }