OwnerController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\admin\controller\member;
  3. use app\admin\service\member\MemberService;
  4. use app\admin\service\member\OwnerService;
  5. use app\admin\validate\member\MemberValidate;
  6. use support\Db;
  7. use support\Request;
  8. class OwnerController
  9. {
  10. public function selectList(Request $request)
  11. {
  12. $keywords = $request->get('keywords');
  13. if (!$keywords) {
  14. return json_fail("查询错误");
  15. }
  16. $res = Db::table('member')
  17. ->join('member_cert', 'member.member_id', '=', 'member_cert.join_cert_member_id')
  18. ->select('member.member_id', 'member.member_mobile', 'member_cert.member_cert_name')
  19. ->where('member.member_is_owner','Y')
  20. ->where(function ($query) use ($keywords) {
  21. $query->where('member.member_mobile', 'like', '%' . $keywords . '%')
  22. ->orWhere("member.member_id", 'like', '%' . $keywords . '%')
  23. ->orWhere("member_cert.member_cert_name", 'like', '%' . $keywords . '%');
  24. })->get();
  25. $data = [];
  26. foreach ($res as $item) {
  27. $data[] = [
  28. 'key'=>$item->member_id,
  29. 'value'=>!empty($item->member_cert_name) ? $item->member_cert_name : $item->member_mobile,
  30. ];
  31. }
  32. return json_success('',$data);
  33. }
  34. public function list(Request $request)
  35. {
  36. return OwnerService::list($request);
  37. }
  38. /**
  39. * @Desc 添加会员
  40. * @Author Gorden
  41. * @Date 2024/3/25 13:40
  42. *
  43. * @param Request $request
  44. * @return \support\Response
  45. */
  46. public function add(Request $request)
  47. {
  48. $validate = new MemberValidate();
  49. if (!$validate->scene('add')->check($request->post())) {
  50. return json_fail($validate->getError());
  51. }
  52. return OwnerService::add($request->post());
  53. }
  54. }