User.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\index\controller;
  15. use library\Controller;
  16. use think\Db;
  17. use app\index\controller\Api;
  18. /**
  19. * 用户信息
  20. * Class User
  21. * @package app\index\controller
  22. */
  23. class User extends Api
  24. {
  25. /**
  26. * 施工照片
  27. */
  28. public function userImage()
  29. {
  30. $user = $this->geiUserInfo();
  31. $data = Db::name('user_image')->where('uid',$user['id'])->select();
  32. if (!$data) return $this->success();
  33. foreach ($data as &$v) {
  34. $v['image'] = explode('|',$v['image']);
  35. }
  36. return $this->success('',$data);
  37. }
  38. /**
  39. * 线上预约
  40. * name 姓名
  41. * phone 手机号
  42. * address 城市
  43. * address_info 详细地址
  44. */
  45. public function appinotment()
  46. {
  47. $data = $this->request->post();
  48. if (!isset($data['name']) || empty($data['name'])) return $this->error('请输入姓名');
  49. if (!isset($data['phone']) || empty($data['phone'])) return $this->error('请输入手机号');
  50. if (!isset($data['address']) || empty($data['address'])) return $this->error('请输入所造地区');
  51. if (!isset($data['address_info']) || empty($data['address_info'])) return $this->error('请输入详细地址');
  52. if(strlen($data['name'])<3 || strlen($data['name'])>12) return $this->error('姓名长度为3-12位');
  53. if(!preg_match("/^1[34578]\d{9}$/", $data['phone'])) return $this->error('手机号格式不正确');
  54. $user = $this->geiUserInfo();
  55. $data['uid'] = $user['id'];
  56. $data['number'] = date('Y',time()).date('m',time()).date('d',time()).date('H',time()).date('i',time()).rand(100000,999999);
  57. $data['create_time'] = date('Y-m-d H:i',time());
  58. $save = Db::name('user_appointment')->insert($data);
  59. if ($save) {
  60. return $this->success('提交成功');
  61. } else {
  62. return $this->error('提交失败');
  63. }
  64. }
  65. /**
  66. * 跟进反馈
  67. * content 文字
  68. * image 图片
  69. */
  70. public function feedback()
  71. {
  72. $data = $this->request->post();
  73. if (!isset($data['content']) && empty($data['image'])) return $this->error('请输入有效信息');
  74. $user = $this->geiUserInfo();
  75. $data['uid'] = $user['id'];
  76. $data['create_time'] = date('Y-m-d H:i',time());
  77. $save = Db::name('user_feedback')->insert($data);
  78. if ($save) {
  79. return $this->success('提交成功');
  80. } else {
  81. return $this->error('提交失败');
  82. }
  83. }
  84. /**
  85. * 施工订单
  86. * type 1进行中2已完成
  87. */
  88. public function order()
  89. {
  90. $type = $this->request->get('type');
  91. $user = $this->geiUserInfo();
  92. $data = Db::name('user_appointment')->where('status',$type)->where('uid',$user['id'])->select();
  93. return $this->success('',$data);
  94. }
  95. /**
  96. * 维修和报备
  97. * name 姓名
  98. * phone 手机号
  99. * address 城市
  100. * address_info 详细地址
  101. * type 1维修2报备
  102. */
  103. public function weixiuBaobei()
  104. {
  105. $data = $this->request->post();
  106. if (!isset($data['name']) || empty($data['name'])) return $this->error('请输入姓名');
  107. if (!isset($data['phone']) || empty($data['phone'])) return $this->error('请输入手机号');
  108. if (!isset($data['address']) || empty($data['address'])) return $this->error('请输入所造地区');
  109. if (!isset($data['address_info']) || empty($data['address_info'])) return $this->error('请输入详细地址');
  110. if(strlen($data['name'])<3 || strlen($data['name'])>12) return $this->error('姓名长度为3-12位');
  111. if(!preg_match("/^1[34578]\d{9}$/", $data['phone'])) return $this->error('手机号格式不正确');
  112. $user = $this->geiUserInfo();
  113. $data['uid'] = $user['id'];
  114. $data['number'] = date('Y',time()).date('m',time()).date('d',time()).date('H',time()).date('i',time()).rand(100000,999999);
  115. $data['create_time'] = date('Y-m-d H:i',time());
  116. $save = Db::name('user_weixiu_baobei')->insert($data);
  117. if ($save) {
  118. return $this->success('提交成功');
  119. } else {
  120. return $this->error('提交失败');
  121. }
  122. }
  123. /**
  124. * 积分明细
  125. */
  126. public function integral()
  127. {
  128. $user = $this->geiUserInfo();
  129. $data = Db::name('user_integral_history')->where('uid',$user['id'])->select();
  130. return $this->success('',$data);
  131. }
  132. /**
  133. * 服务订单
  134. */
  135. public function fuwuOrder()
  136. {
  137. $user = $this->geiUserInfo();
  138. $data = Db::name('user_order')->where('uid',$user['id'])->select();
  139. return $this->success('',$data);
  140. }
  141. }