Apply.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\api\controller\supplier;
  3. use app\api\controller\Controller;
  4. use app\api\model\supplier\Apply as ApplyModel;
  5. use app\common\model\settings\Setting;
  6. use app\api\model\supplier\Category as CategoryModel;
  7. use app\common\model\user\Sms as SmsModel;
  8. /**
  9. * 商户申请
  10. */
  11. class Apply extends Controller
  12. {
  13. protected $user;
  14. /**
  15. * 构造方法
  16. */
  17. public function initialize()
  18. {
  19. $this->user = $this->getUser();
  20. }
  21. //店铺分类
  22. public function category(){
  23. $list = CategoryModel::getALL();
  24. //是否需要短信验证
  25. $sms_open = Setting::getItem('store')['sms_open'];
  26. return $this->renderSuccess('', compact('list', 'sms_open'));
  27. }
  28. /**
  29. * 申请开店
  30. */
  31. public function index()
  32. {
  33. $data = $this->request->post();
  34. $data['user_id'] = $this->user['user_id'];
  35. $model = new ApplyModel;
  36. // 新增记录
  37. if ($model->add($data)) {
  38. return $this->renderSuccess('申请成功,请等待平台审核', []);
  39. }
  40. return $this->renderError($model->getError() ?: '申请失败');
  41. }
  42. //获取申请状态
  43. public function detail(){
  44. $detail = ApplyModel::getLastDetail($this->user['user_id']);
  45. return $this->renderSuccess('', compact('detail'));
  46. }
  47. /**
  48. * 发送短信
  49. */
  50. public function sendCode($mobile)
  51. {
  52. $model = new SmsModel();
  53. if($model->send($mobile, 'apply')){
  54. return $this->renderSuccess();
  55. }
  56. return $this->renderError($model->getError() ?:'发送失败');
  57. }
  58. }