Merchant.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/12/18
  6. */
  7. namespace app\wap\controller;
  8. use app\wap\model\user\UserEnter;
  9. use service\JsonService;
  10. use service\UtilService;
  11. use think\Cookie;
  12. use think\Db;
  13. use think\Request;
  14. use think\Url;
  15. class Merchant extends AuthController
  16. {
  17. public function agreement()
  18. {
  19. return $this->fetch();
  20. }
  21. public function apply()
  22. {
  23. if(UserEnter::be($this->userInfo['uid'],'uid')){
  24. $enterInfo = UserEnter::where('uid',$this->userInfo['uid'])->find()->toArray();
  25. if($enterInfo['status'] == 0) return $this->failed('正在审核中,请耐心等待!');
  26. if($enterInfo['status'] == 1) return $this->failed('审核已通过');
  27. }else{
  28. if(!Cookie::get('_mer_check_auth')) return $this->failed('请先同意入驻协议!',Url::build('agreement'));
  29. $enterInfo = [];
  30. }
  31. $this->assign(compact('enterInfo'));
  32. return $this->fetch();
  33. }
  34. public function submit(Request $request)
  35. {
  36. $data = UtilService::postMore([
  37. ['province',''],
  38. ['city',''],
  39. ['district',''],
  40. ['address',''],
  41. ['company_name','','','merchant_name'],
  42. ['link_user',''],
  43. ['link_tel',''],
  44. ['charter',[]],
  45. ['id',0]
  46. ],$request);
  47. if($data['id'] == 0 && UserEnter::be(['uid'=>$this->userInfo['uid']]))
  48. return JsonService::fail('已提交商户信息,请勿重复申请!');
  49. if(($data['id'] >0 && UserEnter::editEvent($data,$this->userInfo['uid'])) || UserEnter::setEnter($data,$this->userInfo['uid']))
  50. return JsonService::successful();
  51. else
  52. return JsonService::fail('提交失败!');
  53. }
  54. }