User.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\library\Common;
  4. use think\Console;
  5. use think\Db;
  6. use think\Request;
  7. use app\common\model\User as Users;
  8. use think\facade\Validate;
  9. use app\common\controller\Api;
  10. /**
  11. * @title 个人中心
  12. * @controller User
  13. * @group user
  14. */
  15. class User extends Api
  16. {
  17. /**
  18. * @title 获取用户信息
  19. * @desc 获取用户信息
  20. * @url /api/User/userinfo
  21. * @method POST
  22. * @tag 基础
  23. * @header name:Authorization require:1 default: desc:验证token
  24. */
  25. public function userinfo(){
  26. $user_id = $this->check_login();
  27. $userinfo = Users::getUserInfo($user_id);
  28. $this->success('成功',$userinfo);
  29. }
  30. /**
  31. * @title 收货地址列表
  32. * @desc 我的收货地址
  33. * @url /api/User/my_address
  34. * @method POST
  35. * @tag 基础
  36. * @header name:Authorization require:1 default: desc:验证token
  37. * @param name:page type:int require:0 default:1 desc:
  38. * @param name:limit type:int require:0 default:10 desc:
  39. */
  40. public function my_address(){
  41. $user_id = $this->check_login();
  42. $Nowpage = input('page',1);
  43. $limits = input("limit",10);
  44. $result = Users::MyAddress($user_id,$Nowpage,$limits);
  45. $this->success('成功',$result['data']);
  46. }
  47. /**
  48. * @title 添加、修改收货地址
  49. * @desc 添加、修改收货地址
  50. * @url /api/User/add_edit_address
  51. * @method POST
  52. * @tag 基础
  53. * @header name:Authorization require:1 default: desc:验证token
  54. * @param name:name type:string require:1 default: desc:收货人姓名
  55. * @param name:phone type:string require:1 default: desc:手机号
  56. * @param name:province type:string require:1 default: desc:省
  57. * @param name:city type:string require:1 default: desc:市
  58. * @param name:area type:string require:1 default: desc:区
  59. * @param name:address type:string require:1 default: desc:具体地址
  60. * @param name:is_default type:int require:0 default:0 desc:默认地址1:默认0:否
  61. * @param name:jd type:string require:0 default:0 desc:经度
  62. * @param name:wd type:string require:0 default:0 desc:纬度
  63. * @param name:address_id type:int require:0 default:0 desc:收货地址ID,有则修改,无则添加
  64. */
  65. public function add_edit_address(){
  66. $user_id = $this->check_login();
  67. $data['name'] = input('name'); //收货人姓名
  68. $data['phone'] = input('phone'); //手机号
  69. $data['province'] = input('province'); //省
  70. $data['city'] = input('city'); //市
  71. $data['area'] = input('area'); //区
  72. $data['address'] = input('address'); //具体地址
  73. $data['is_default'] = input('is_default',0); //默认地址 1:默认
  74. $data['jd'] = input('jd'); //经度
  75. $data['wd'] = input('wd'); //纬度
  76. $address_id = intval(input('address_id')); //收货地址ID 有则修改,无则添加
  77. if (!$data['name'] || !$data['phone'] || !$data['province'] || !$data['city'] || !$data['area'] || !$data['address']) $this->error('参数错误');
  78. if (!Validate::regex($data['phone'], "^1\d{10}$")) $this->error('手机号格式错误');
  79. $result = Users::AddEditAddress($user_id,$data,$address_id);
  80. if ($result['code']){
  81. $this->success($result['msg']);
  82. }else{
  83. $this->error($result['msg']);
  84. }
  85. }
  86. /**
  87. * @title 设为默认地址
  88. * @desc 设为默认地址
  89. * @url /api/User/set_address_default
  90. * @method POST
  91. * @tag 基础
  92. * @header name:Authorization require:1 default: desc:验证token
  93. * @param name:address_id type:int require:1 default:1 desc:地址ID
  94. */
  95. public function set_address_default(){
  96. $user_id = $this->check_login();
  97. $address_id = intval(input('address_id')); //地址ID
  98. if (!$address_id) $this->error('地址ID为空');
  99. $result = Users::SetAddressDefault($user_id,$address_id);
  100. if ($result['code']){
  101. $this->success($result['msg']);
  102. }else{
  103. $this->error($result['msg']);
  104. }
  105. }
  106. /**
  107. * @title 删除地址
  108. * @desc 删除地址
  109. * @url /api/User/del_address
  110. * @method POST
  111. * @tag 基础
  112. * @header name:Authorization require:1 default: desc:验证token
  113. * @param name:address_id type:int require:1 default:1 desc:地址ID
  114. */
  115. public function del_address(){
  116. $user_id = $this->check_login();
  117. $address_id = intval(input('address_id')); //地址ID
  118. if (!$address_id) $this->error('地址ID为空');
  119. $result = Users::DelAddress($user_id,$address_id);
  120. if ($result['code']){
  121. $this->success($result['msg']);
  122. }else{
  123. $this->error($result['msg']);
  124. }
  125. }
  126. /**
  127. * @title 修改个人资料
  128. * @desc 修改个人资料
  129. * @url /api/User/edit_user_info
  130. * @method POST
  131. * @tag 基础
  132. * @header name:Authorization require:1 default: desc:验证token
  133. * @param name:headimg type:string require:0 default:1 desc:头像
  134. * @param name:nickname type:string require:0 default:1 desc:昵称
  135. * @param name:signature type:string require:0 default:1 desc:个性签名
  136. */
  137. public function edit_user_info(){
  138. $user_id = $this->check_login();
  139. $data = input();
  140. $result = Users::EditUserInfo($user_id,$data);
  141. if ($result['code']){
  142. $this->success($result['msg']);
  143. }else{
  144. $this->error($result['msg']);
  145. }
  146. }
  147. /**
  148. * @title 修改密码
  149. * @desc 修改密码
  150. * @url /api/User/change_password
  151. * @method POST
  152. * @tag 基础
  153. * @header name:Authorization require:1 default: desc:验证token
  154. *
  155. * @param name:password type:string require:0 desc:密码
  156. * @param name:confirm_password type:string require:0 desc:确认密码
  157. * @param name:ver_code type:string require:0 desc:验证码
  158. */
  159. public function change_password(){
  160. $user_id = $this->check_login();
  161. $password = input('password'); //密码
  162. $confirm_password = input('confirm_password'); //确认密码
  163. $ver_code = input('ver_code'); //验证码
  164. if (!$password || !$ver_code || !$confirm_password){
  165. $this->error('参数错误');
  166. }
  167. if ($password!=$confirm_password){
  168. $this->error('密码与确认密码不一致');
  169. }
  170. $result = Users::changePassword($user_id,$password,$ver_code);
  171. if ($result['code']){
  172. $this->success($result['msg']);
  173. }else{
  174. $this->error($result['msg']);
  175. }
  176. }
  177. /**
  178. * @title 申请成为设计师
  179. * @desc 申请成为设计师
  180. * @url /api/User/apply_designer
  181. * @method POST
  182. * @tag 基础
  183. * @header name:Authorization require:1 default: desc:验证token
  184. *
  185. * @param name:name type:string require:1 desc:姓名
  186. * @param name:design_classifi type:string require:1 desc:设计分类
  187. * @param name:skills_label type:string require:1 desc:技能标签
  188. * @param name:good_type type:string require:1 desc:擅长类型
  189. * @param name:good_style type:string require:1 desc:擅长风格
  190. * @param name:province type:string require:1 desc:省
  191. * @param name:city type:string require:1 desc:市
  192. * @param name:area type:string require:1 desc:区
  193. * @param name:work_experience type:string require:1 desc:工作经历
  194. * @param name:work_year type:string require:1 desc:工作年限
  195. * @param name:identity_card_zheng type:string require:1 desc:身份证正面
  196. * @param name:identity_card_fan type:string require:1 desc:身份证反面
  197. * @param name:related_certificate type:string require:1 desc:相关证书,数组
  198. * @param name:works type:string require:1 desc:作品,数组
  199. * @param name:wd type:string require:1 desc:当前位置纬度
  200. * @param name:jd type:string require:1 desc:当前位置经度
  201. * @param name:signature type:string require:0 default:1 desc:个性签名
  202. */
  203. public function apply_designer(){
  204. $user_id = $this->check_login();
  205. $data['name'] = input('name'); //姓名
  206. $data['design_classifi'] = input('design_classifi'); //设计分类
  207. $data['skills_label'] = input('skills_label'); //技能标签
  208. $data['good_type'] = input('good_type'); //擅长类型
  209. // $data['good_style'] = input('good_style'); //擅长风格
  210. $data['province'] = input('province'); //省
  211. $data['city'] = input('city'); //市
  212. $data['area'] = input('area'); //区
  213. // $data['work_experience'] = input('work_experience'); //工作经历
  214. $data['work_year'] = input('work_year'); //工作年限
  215. $data['identity_card_zheng'] = input('identity_card_zheng'); //身份证正面
  216. $data['identity_card_fan'] = input('identity_card_fan'); //身份证反面
  217. $data['related_certificate'] = input('related_certificate'); //相关证书
  218. $data['works'] = input('works'); //作品
  219. $data['wd'] = input('wd'); //当前位置纬度
  220. $data['jd'] = input('jd'); //当前位置经度
  221. $data['signature'] = input('signature');
  222. if (!$data['name'] || !$data['design_classifi'] || !$data['design_classifi'] || !$data['skills_label'] || !$data['good_type'] || !$data['identity_card_zheng'] || !$data['identity_card_fan'] || !$data['province']
  223. || !$data['city'] || !$data['area'] || !$data['work_year'] || !$data['works']){
  224. $this->error('参数错误');
  225. }
  226. $data['related_certificate'] = implode(',',$data['related_certificate']);
  227. $data['works'] = implode(',',$data['works']);
  228. $data['skills_label'] = implode(',',$data['skills_label']);
  229. $data['good_type'] = implode(',',$data['good_type']);
  230. $result = Users::applyDesigner($user_id,$data);
  231. if ($result['code']){
  232. $this->success($result['msg']);
  233. }else{
  234. $this->error($result['msg']);
  235. }
  236. }
  237. /**
  238. * @title 投诉提交
  239. * @desc 投诉提交
  240. * @url /api/User/message
  241. * @method POST
  242. * @tag 基础
  243. * @header name:Authorization require:1 default: desc:验证token
  244. *
  245. * @param name:content type:string require:0 desc:内容
  246. */
  247. public function message(){
  248. $user_id = $this->check_login();
  249. $content = input('content'); //内容
  250. if (!$content) $this->error('参数错误');
  251. $result = Users::Message($user_id,$content);
  252. if ($result['code']){
  253. $this->success($result['msg']);
  254. }else{
  255. $this->error($result['msg']);
  256. }
  257. }
  258. /**
  259. * @title 时间管理列表
  260. * @desc 时间管理列表
  261. * @url /api/User/time_list
  262. * @method POST
  263. * @tag 基础
  264. * @header name:Authorization require:1 default: desc:验证token
  265. *
  266. *
  267. * @return name:switch type:int desc:1:开启2:关闭
  268. * @return name:date type:int desc:日期
  269. * @return name:price type:int desc:价格
  270. */
  271. public function time_list(){
  272. $user_id = $this->check_login();
  273. $result = Users::timeList($user_id);
  274. $this->success('成功',$result['data']);
  275. }
  276. /**
  277. * @title 时间设置开关
  278. * @desc 时间设置开关
  279. * @url /api/User/time_switch
  280. * @method POST
  281. * @tag 基础
  282. * @header name:Authorization require:1 default: desc:验证token
  283. *
  284. * @param name:json type:json require:1 desc:json
  285. */
  286. public function time_switch(){
  287. $user_id = $this->check_login();
  288. $json = input('json');
  289. // $date = input('date'); //日期
  290. // $switch = input('switch'); //1:开 2:关
  291. // $price = input('price'); //价格
  292. // if (!$date || !$switch || !$price || $price<=0) $this->error('参数错误');
  293. if (!$json) $this->error('参数错误');
  294. // $result = Users::timeSwitch($user_id,$date,$switch,$price);
  295. $json = json_decode($json,true);
  296. $result = Users::timeSwitch($user_id,$json);
  297. if ($result['code']){
  298. $this->success($result['msg']);
  299. }else{
  300. $this->error($result['msg']);
  301. }
  302. }
  303. /**
  304. * @title 设计师端余额提现
  305. * @desc 设计师端余额提现
  306. * @url /api/User/user_withdraw
  307. * @method POST
  308. * @tag 基础
  309. * @header name:Authorization require:1 default: desc:验证token
  310. *
  311. * @param name:money type:string require:0 desc:金额
  312. * @param name:withdraw_type type:string require:0 desc:提现方式weixin:微信zfb:支付宝
  313. */
  314. public function user_withdraw(){
  315. $user_id = $this->check_login();
  316. $money = input('money'); //提现金额
  317. $withdraw_type = input('withdraw_type'); //提现方式
  318. if (!in_array($withdraw_type,array('weixin','zfb'))) $this->error('提现方式错误');
  319. if (!$money || $money<=0) $this->error('金额错误');
  320. $day = date('d');
  321. if ($day!=1 || $day!=15){
  322. $this->error('每月1号和15号才可以提现');
  323. }
  324. $result = Users::userWithdraw($user_id,$money,$withdraw_type);
  325. if ($result['code']){
  326. $this->success($result['msg']);
  327. }else{
  328. $this->error($result['msg']);
  329. }
  330. }
  331. /**
  332. * @title 设计师端消费明细
  333. * @desc 设计师端消费明细
  334. * @url /api/User/money_record
  335. * @method POST
  336. * @tag 基础
  337. * @header name:Authorization require:1 default: desc:验证token
  338. * @param name:page type:int require:0 default:1 desc:
  339. * @param name:limit type:int require:0 default:10 desc:
  340. *
  341. *
  342. *
  343. * @return name:paid type:int desc:是否完成0:审核中1:成功2:拒绝
  344. * @return name:withdraw_type type:string desc:方式(weixin:微信,zfb:支付宝,sy:订单收益)
  345. * @return name:create_at type:string desc:时间
  346. * @return name:price type:string desc:金额
  347. *
  348. */
  349. public function money_record(){
  350. $user_id = $this->check_login();
  351. $Nowpage = input('page',1);
  352. $limits = input("limit",10);
  353. $result = Users::moneyRecord($user_id,$Nowpage,$limits);
  354. $this->success($result['msg'],$result['data']);
  355. }
  356. /**
  357. * @title 用户端订单列表
  358. * @desc 用户端订单列表
  359. * @url /api/User/user_order_list
  360. * @method POST
  361. * @tag 基础
  362. * @header name:Authorization require:1 default: desc:验证token
  363. * @param name:page type:int require:0 default:1 desc:
  364. * @param name:limit type:int require:0 default:10 desc:
  365. * @param name:keywords type:int require:0 default:10 desc:关键词
  366. * @param name:status type:int require:0 default:10 desc:订单状态(-1:申请退款中-2:退款成功-3:退款失败0:待付款1:待服务;2:进行中;3:已完成,待评价;4:已评价5:取消订单all:全部订单)
  367. *
  368. *
  369. */
  370. public function user_order_list(){
  371. $user_id = $this->check_login();
  372. $Nowpage = input('page',1);
  373. $limits = input("limit",10);
  374. $status = input("status",'all');
  375. $keywords = input('keywords'); //搜索关键词
  376. $result = Users::userOrderList($user_id,$status,$keywords,$Nowpage,$limits);
  377. $this->success($result['msg'],$result['data']);
  378. }
  379. /**
  380. * @title 订单支付
  381. * @desc 订单支付
  382. * @url /api/User/pay_order
  383. * @method POST
  384. * @tag 基础
  385. * @header name:Authorization require:1 default: desc:验证token
  386. * @param name:order_no type:string require:0 default: desc:订单号
  387. *
  388. */
  389. public function pay_order(){
  390. $user_id = $this->check_login();
  391. $order_no = input('order_no'); //订单号
  392. if (!$order_no) $this->error('订单号为空');
  393. $result = Users::payOrder($user_id,$order_no);
  394. if ($result['code']){
  395. $this->success($result['msg'],$result['data']);
  396. }else{
  397. $this->error($result['msg']);
  398. }
  399. }
  400. /**
  401. * @title 订单支付加班费
  402. * @desc 订单支付加班费
  403. * @url /api/User/overtime_pay_order
  404. * @method POST
  405. * @tag 基础
  406. * @header name:Authorization require:1 default: desc:验证token
  407. * @param name:order_no type:string require:0 default: desc:订单号
  408. * @param name:pay_type type:string require:0 default: desc:支付方式(weixin:微信,zfb:支付宝)
  409. *
  410. */
  411. public function overtime_pay_order(){
  412. $user_id = $this->check_login();
  413. $order_no = input('order_no'); //订单号
  414. if (!$order_no) $this->error('订单号为空');
  415. $pay_type = input("pay_type",'weixin');
  416. if (!in_array($pay_type,array('weixin','zfb'))) $this->error('支付方式错误');
  417. $result = Users::overtimePayOrder($user_id,$order_no,$pay_type);
  418. if ($result['code']){
  419. $this->success($result['msg'],$result['data']);
  420. }else{
  421. $this->error($result['msg']);
  422. }
  423. }
  424. /**
  425. * @title 订单详情
  426. * @desc 订单详情
  427. * @url /api/User/order_detail
  428. * @method POST
  429. * @tag 基础
  430. * @header name:Authorization require:1 default: desc:验证token
  431. * @param name:order_no type:string require:0 default: desc:订单号
  432. *
  433. *
  434. */
  435. public function order_detail(){
  436. $this->check_login();
  437. $order_no= input('order_no'); //订单号
  438. $result = Users::orderDetail($order_no);
  439. if ($result['code']){
  440. $this->success($result['msg'],$result['data']);
  441. }else{
  442. $this->error($result['msg']);
  443. }
  444. }
  445. /**
  446. * @title 取消订单
  447. * @desc 取消订单
  448. * @url /api/User/cancel_order
  449. * @method POST
  450. * @tag 基础
  451. * @header name:Authorization require:1 default: desc:验证token
  452. * @param name:order_no type:string require:0 default: desc:订单号
  453. *
  454. *
  455. */
  456. public function cancel_order(){
  457. $user_id = $this->check_login();
  458. $order_no= input('order_no');
  459. $result = Users::cancelOrder($user_id,$order_no);
  460. if ($result['code']){
  461. $this->success($result['msg'],$result['data']);
  462. }else{
  463. $this->error($result['msg']);
  464. }
  465. }
  466. /**
  467. * @title 删除订单
  468. * @desc 删除订单
  469. * @url /api/User/del_order
  470. * @method POST
  471. * @tag 基础
  472. * @header name:Authorization require:1 default: desc:验证token
  473. * @param name:order_no type:string require:0 default: desc:订单号
  474. *
  475. *
  476. */
  477. public function del_order(){
  478. $user_id = $this->check_login();
  479. $order_no= input('order_no');
  480. $result = Users::delOrder($user_id,$order_no);
  481. if ($result['code']){
  482. $this->success($result['msg'],$result['data']);
  483. }else{
  484. $this->error($result['msg']);
  485. }
  486. }
  487. /**
  488. * @title 订单评价
  489. * @desc 订单评价
  490. * @url /api/User/evaluation_order
  491. * @method POST
  492. * @tag 基础
  493. * @header name:Authorization require:1 default: desc:验证token
  494. * @param name:order_no type:string require:0 default: desc:订单号
  495. * @param name:evaluation type:int require:0 default: desc:几颗星
  496. * @param name:evaluation_content type:string require:0 default: desc:评价内容
  497. *
  498. */
  499. public function evaluation_order(){
  500. $user_id = $this->check_login();
  501. $order_no= input('order_no'); //订单号
  502. $evaluation = intval(input('evaluation')); //几颗星
  503. $evaluation_content = input('evaluation_content'); //评价内容
  504. if (!$evaluation) $this->error('请评分');
  505. if ($evaluation<1 || $evaluation>5) $this->error('评分1-5');
  506. if (!$evaluation_content) $this->error('请输入评价内容');
  507. $result = Users::evaluationOrder($user_id,$order_no,$evaluation,$evaluation_content);
  508. if ($result['code']){
  509. $this->success($result['msg']);
  510. }else{
  511. $this->error($result['msg']);
  512. }
  513. }
  514. /**
  515. * @title 用户端我的评价
  516. * @desc 用户端我的评价
  517. * @url /api/User/user_evaluation_list
  518. * @method POST
  519. * @tag 基础
  520. * @header name:Authorization require:1 default: desc:验证token
  521. * @param name:page type:int require:0 default:1 desc:
  522. * @param name:limit type:int require:0 default:10 desc:
  523. *
  524. * @return name:order_no type:string desc:订单号
  525. * @return name:evaluation type:string desc:几颗星
  526. * @return name:evaluation_time type:string desc:时间
  527. * @return name:evaluation_content type:string desc:评价内容
  528. * @return name:name type:string desc:用户姓名
  529. * @return name:nickname type:string desc:用户昵称
  530. * @return name:headimg type:string desc:头像
  531. * @return name:designer_name type:string desc:设计师姓名
  532. */
  533. public function user_evaluation_list(){
  534. $user_id = $this->check_login();
  535. $Nowpage = input('page',1);
  536. $limits = input("limit",10);
  537. $result = Users::userEvaluationList($user_id,$Nowpage,$limits);
  538. $this->success($result['msg'],$result['data']);
  539. }
  540. /**
  541. * @title 设计师端我的评价
  542. * @desc 设计师端我的评价
  543. * @url /api/User/designer_evaluation_list
  544. * @method POST
  545. * @tag 基础
  546. * @header name:Authorization require:1 default: desc:验证token
  547. * @param name:page type:int require:0 default:1 desc:
  548. * @param name:limit type:int require:0 default:10 desc:
  549. *
  550. * @return name:order_no type:string desc:订单号
  551. * @return name:evaluation type:string desc:几颗星
  552. * @return name:evaluation_time type:string desc:时间
  553. * @return name:evaluation_content type:string desc:评价内容
  554. * @return name:name type:string desc:用户姓名
  555. * @return name:nickname type:string desc:用户昵称
  556. * @return name:headimg type:string desc:头像
  557. */
  558. public function designer_evaluation_list(){
  559. $user_id = $this->check_login();
  560. $Nowpage = input('page',1);
  561. $limits = input("limit",10);
  562. $result = Users::designerEvaluationList($user_id,$Nowpage,$limits);
  563. $this->success($result['msg'],$result['data']);
  564. }
  565. /**
  566. * @title 设计师端添加作品
  567. * @desc 设计师端添加作品
  568. * @url /api/User/add_works
  569. * @method POST
  570. * @tag 基础
  571. * @header name:Authorization require:1 default: desc:验证token
  572. * @param name:imgs type:array require:1 default: desc:作品图片,数组
  573. *
  574. */
  575. public function add_works(){
  576. $user_id = $this->check_login();
  577. $imgs = input('imgs'); //图片
  578. if (!$imgs) $this->error('请上传图片');
  579. $result = Users::addWorks($user_id,$imgs);
  580. if ($result['code']){
  581. $this->success($result['msg']);
  582. }else{
  583. $this->error($result['msg']);
  584. }
  585. }
  586. /**
  587. * @title 设计师端作品列表
  588. * @desc 设计师端作品列表
  589. * @url /api/User/work_list
  590. * @method POST
  591. * @tag 基础
  592. * @header name:Authorization require:1 default: desc:验证token
  593. *
  594. * @return name:date type:string desc:日期
  595. * @return name:imgs@id type:string desc:主键ID
  596. * @return name:imgs@img type:string desc:图片地址
  597. */
  598. public function work_list(){
  599. $user_id = $this->check_login();
  600. $result = Users::workList($user_id);
  601. $this->success($result['msg'],$result['data']);
  602. }
  603. /**
  604. * @title 设计师端删除作品
  605. * @desc 设计师端删除作品
  606. * @url /api/User/del_works
  607. * @method POST
  608. * @tag 基础
  609. * @header name:Authorization require:1 default: desc:验证token
  610. * @param name:ids type:string require:1 default: desc:作品id,多个以逗号隔开
  611. *
  612. */
  613. public function del_works(){
  614. $user_id = $this->check_login();
  615. $ids = input('ids'); //作品id
  616. if (!$ids) $this->error('作品id为空');
  617. $result = Users::delWorks($user_id,$ids);
  618. if ($result['code']){
  619. $this->success($result['msg']);
  620. }else{
  621. $this->error($result['msg']);
  622. }
  623. }
  624. /**
  625. * @title 设计师端订单列表
  626. * @desc 设计师端订单列表
  627. * @url /api/User/designer_order_list
  628. * @method POST
  629. * @tag 基础
  630. * @header name:Authorization require:1 default: desc:验证token
  631. *
  632. * @param name:page type:int require:0 default:1 desc:
  633. * @param name:limit type:int require:0 default:10 desc:
  634. * @param name:keywords type:int require:0 default:10 desc:关键词
  635. * @param name:status type:int require:0 default:10 desc:订单状态(1:已接单;2:待完成;3:已完成;all:全部订单)
  636. */
  637. public function designer_order_list(){
  638. $user_id = $this->check_login();
  639. $Nowpage = input('page',1);
  640. $limits = input("limit",10);
  641. $status = input("status",'all');
  642. $keywords = input('keywords'); //搜索关键词
  643. $result = Users::designerOrderList($user_id,$status,$keywords,$Nowpage,$limits);
  644. $this->success($result['msg'],$result['data']);
  645. }
  646. /**
  647. * @title 设计师开始工作打卡
  648. * @desc 设计师开始工作打卡
  649. * @url /api/User/clock_in_start
  650. * @method POST
  651. * @tag 基础
  652. * @header name:Authorization require:1 default: desc:验证token
  653. *
  654. * @param name:order_no type:string require:1 default: desc:订单号
  655. * @param name:start_address type:string require:0 default:10 desc:打卡地址
  656. */
  657. public function clock_in_start(){
  658. $user_id = $this->check_login();
  659. $order_no = input('order_no');
  660. $start_address = input('start_address');
  661. if (!$order_no || !$start_address) $this->error('参数错误');
  662. $result = Users::clockInStart($user_id,$order_no,$start_address);
  663. $this->success($result['msg'],$result['data']);
  664. }
  665. /**
  666. * @title 设计师结束工作打卡
  667. * @desc 设计师结束工作打卡
  668. * @url /api/User/clock_in_end
  669. * @method POST
  670. * @tag 基础
  671. * @header name:Authorization require:1 default: desc:验证token
  672. *
  673. * @param name:order_no type:string require:1 default: desc:订单号
  674. * @param name:end_address type:string require:0 default:10 desc:打卡地址
  675. */
  676. public function clock_in_end(){
  677. $user_id = $this->check_login();
  678. $order_no = input('order_no');
  679. $end_address = input('end_address');
  680. if (!$order_no || !$end_address) $this->error('参数错误');
  681. $result = Users::clockInEnd($user_id,$order_no,$end_address);
  682. $this->success($result['msg'],$result['data']);
  683. }
  684. /**
  685. * @title 设计师结束工作上传作品
  686. * @desc 设计师结束工作上传作品
  687. * @url /api/User/order_uploading
  688. * @method POST
  689. * @tag 基础
  690. * @header name:Authorization require:1 default: desc:验证token
  691. *
  692. * @param name:order_no type:string require:1 default: desc:订单号
  693. * @param name:works type:string require:0 default:10 desc:上传作品,数组
  694. */
  695. public function order_uploading(){
  696. $user_id = $this->check_login();
  697. $order_no = input('order_no');
  698. $works = input('works');
  699. if (!$order_no || !$works) $this->error('参数错误');
  700. $result = Users::orderUploading($user_id,$order_no,$works);
  701. $this->success($result['msg'],$result['data']);
  702. }
  703. /**
  704. * @title 用户优惠券列表
  705. * @desc 用户优惠券列表
  706. * @url /api/User/coupon_list
  707. * @method POST
  708. * @tag 基础
  709. * @header name:Authorization require:1 default: desc:验证token
  710. *
  711. * @param name:page type:int require:0 default:1 desc:
  712. * @param name:limit type:int require:0 default:10 desc:
  713. */
  714. public function coupon_list(){
  715. $user_id = $this->check_login();
  716. $Nowpage = input('page',1);
  717. $limits = input("limit",10);
  718. $result = Users::couponList($user_id,$Nowpage,$limits);
  719. $this->success($result['msg'],$result['data']);
  720. }
  721. /**
  722. * @title 注销
  723. * @desc 注销
  724. * @url /api/User/cancellation
  725. * @method POST
  726. * @tag 基础
  727. * @header name:Authorization require:1 default: desc:验证token
  728. *
  729. * @param name:page type:int require:0 default:1 desc:
  730. * @param name:limit type:int require:0 default:10 desc:
  731. */
  732. public function cancellation(){
  733. $user_id = $this->check_login();
  734. $this->success('成功');
  735. }
  736. }