UserEnterController.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\api\controller\user;
  3. use app\models\user\UserEnter;
  4. use app\Request;
  5. use crmeb\services\GroupDataService;
  6. use crmeb\services\QrcodeService;
  7. use crmeb\services\SystemConfigService;
  8. use crmeb\services\UtilService;
  9. use crmeb\services\upload\Upload;
  10. use think\facade\Db;
  11. use think\facade\Validate;
  12. /**
  13. * 商户表
  14. * Class UserBillController
  15. * @package app\api\controller\user
  16. */
  17. class UserEnterController
  18. {
  19. /**
  20. * 申请商户记录
  21. * @param Request $request
  22. * @return mixed
  23. */
  24. public function list(Request $request)
  25. {
  26. $where = UtilService::getMore([
  27. ['page', 1],
  28. ['limit', 10],
  29. ]);
  30. $where['uid'] = $request->uid();
  31. $list = UserEnter::list($where);
  32. return app('json')->success($list);
  33. }
  34. public function apply(Request $request)
  35. {
  36. if ($request->user()['is_merchant'] == 1) return app('json')->fail('已是商户');
  37. $data = UtilService::postMore([
  38. ['province', ''],
  39. ['city', ''],
  40. ['district', ''],
  41. ['address', ''],
  42. ['merchant_name', ''],
  43. ['link_user', ''],
  44. ['link_tel', ''],
  45. ['charter', ''],
  46. ]);
  47. $validate = Validate::rule(['province' => 'require', 'city' => 'require', 'district' => 'require', 'address' => 'require', 'merchant_name' => 'require', 'link_user' => 'require', 'link_tel' => 'require', 'charter' => 'require',]);
  48. $validate->message([
  49. 'province.require' => '请填写所在省',
  50. 'city.require' => '请填写所在市',
  51. 'district.require' => '请填写所在区',
  52. 'address.require' => '请填写详细地址',
  53. 'merchant_name.require' => '请填写商户名称',
  54. 'link_user.require' => '请填写商户姓名',
  55. 'link_tel.require' => '请填写商户电话',
  56. 'charter.require' => '请填写商户证书',
  57. ]);
  58. $data['uid'] = $request->uid();
  59. if (!$validate->check($data)) return app('json')->fail($validate->getError());
  60. $res = UserEnter::create($data);
  61. if ($res) return app('json')->success('提交成功');
  62. return app('json')->fail('提交失败');
  63. }
  64. }