User.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  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. echo $day;
  322. if ($day!=01 || $day!=15){
  323. $this->error('每月1号和15号才可以提现');
  324. }
  325. echo 222;die;
  326. $result = Users::userWithdraw($user_id,$money,$withdraw_type);
  327. if ($result['code']){
  328. $this->success($result['msg']);
  329. }else{
  330. $this->error($result['msg']);
  331. }
  332. }
  333. /**
  334. * @title 设计师端消费明细
  335. * @desc 设计师端消费明细
  336. * @url /api/User/money_record
  337. * @method POST
  338. * @tag 基础
  339. * @header name:Authorization require:1 default: desc:验证token
  340. * @param name:page type:int require:0 default:1 desc:
  341. * @param name:limit type:int require:0 default:10 desc:
  342. *
  343. *
  344. *
  345. * @return name:paid type:int desc:是否完成0:审核中1:成功2:拒绝
  346. * @return name:withdraw_type type:string desc:方式(weixin:微信,zfb:支付宝,sy:订单收益)
  347. * @return name:create_at type:string desc:时间
  348. * @return name:price type:string desc:金额
  349. *
  350. */
  351. public function money_record(){
  352. $user_id = $this->check_login();
  353. $Nowpage = input('page',1);
  354. $limits = input("limit",10);
  355. $result = Users::moneyRecord($user_id,$Nowpage,$limits);
  356. $this->success($result['msg'],$result['data']);
  357. }
  358. /**
  359. * @title 用户端订单列表
  360. * @desc 用户端订单列表
  361. * @url /api/User/user_order_list
  362. * @method POST
  363. * @tag 基础
  364. * @header name:Authorization require:1 default: desc:验证token
  365. * @param name:page type:int require:0 default:1 desc:
  366. * @param name:limit type:int require:0 default:10 desc:
  367. * @param name:keywords type:int require:0 default:10 desc:关键词
  368. * @param name:status type:int require:0 default:10 desc:订单状态(-1:申请退款中-2:退款成功-3:退款失败0:待付款1:待服务;2:进行中;3:已完成,待评价;4:已评价5:取消订单all:全部订单)
  369. *
  370. *
  371. */
  372. public function user_order_list(){
  373. $user_id = $this->check_login();
  374. $Nowpage = input('page',1);
  375. $limits = input("limit",10);
  376. $status = input("status",'all');
  377. $keywords = input('keywords'); //搜索关键词
  378. $result = Users::userOrderList($user_id,$status,$keywords,$Nowpage,$limits);
  379. $this->success($result['msg'],$result['data']);
  380. }
  381. /**
  382. * @title 订单支付
  383. * @desc 订单支付
  384. * @url /api/User/pay_order
  385. * @method POST
  386. * @tag 基础
  387. * @header name:Authorization require:1 default: desc:验证token
  388. * @param name:order_no type:string require:0 default: desc:订单号
  389. *
  390. */
  391. public function pay_order(){
  392. $user_id = $this->check_login();
  393. $order_no = input('order_no'); //订单号
  394. if (!$order_no) $this->error('订单号为空');
  395. $result = Users::payOrder($user_id,$order_no);
  396. if ($result['code']){
  397. $this->success($result['msg'],$result['data']);
  398. }else{
  399. $this->error($result['msg']);
  400. }
  401. }
  402. /**
  403. * @title 订单支付加班费
  404. * @desc 订单支付加班费
  405. * @url /api/User/overtime_pay_order
  406. * @method POST
  407. * @tag 基础
  408. * @header name:Authorization require:1 default: desc:验证token
  409. * @param name:order_no type:string require:0 default: desc:订单号
  410. * @param name:pay_type type:string require:0 default: desc:支付方式(weixin:微信,zfb:支付宝)
  411. *
  412. */
  413. public function overtime_pay_order(){
  414. $user_id = $this->check_login();
  415. $order_no = input('order_no'); //订单号
  416. if (!$order_no) $this->error('订单号为空');
  417. $pay_type = input("pay_type",'weixin');
  418. if (!in_array($pay_type,array('weixin','zfb'))) $this->error('支付方式错误');
  419. $result = Users::overtimePayOrder($user_id,$order_no,$pay_type);
  420. if ($result['code']){
  421. $this->success($result['msg'],$result['data']);
  422. }else{
  423. $this->error($result['msg']);
  424. }
  425. }
  426. /**
  427. * @title 订单详情
  428. * @desc 订单详情
  429. * @url /api/User/order_detail
  430. * @method POST
  431. * @tag 基础
  432. * @header name:Authorization require:1 default: desc:验证token
  433. * @param name:order_no type:string require:0 default: desc:订单号
  434. *
  435. *
  436. */
  437. public function order_detail(){
  438. $this->check_login();
  439. $order_no= input('order_no'); //订单号
  440. $result = Users::orderDetail($order_no);
  441. if ($result['code']){
  442. $this->success($result['msg'],$result['data']);
  443. }else{
  444. $this->error($result['msg']);
  445. }
  446. }
  447. /**
  448. * @title 取消订单
  449. * @desc 取消订单
  450. * @url /api/User/cancel_order
  451. * @method POST
  452. * @tag 基础
  453. * @header name:Authorization require:1 default: desc:验证token
  454. * @param name:order_no type:string require:0 default: desc:订单号
  455. *
  456. *
  457. */
  458. public function cancel_order(){
  459. $user_id = $this->check_login();
  460. $order_no= input('order_no');
  461. $result = Users::cancelOrder($user_id,$order_no);
  462. if ($result['code']){
  463. $this->success($result['msg'],$result['data']);
  464. }else{
  465. $this->error($result['msg']);
  466. }
  467. }
  468. /**
  469. * @title 删除订单
  470. * @desc 删除订单
  471. * @url /api/User/del_order
  472. * @method POST
  473. * @tag 基础
  474. * @header name:Authorization require:1 default: desc:验证token
  475. * @param name:order_no type:string require:0 default: desc:订单号
  476. *
  477. *
  478. */
  479. public function del_order(){
  480. $user_id = $this->check_login();
  481. $order_no= input('order_no');
  482. $result = Users::delOrder($user_id,$order_no);
  483. if ($result['code']){
  484. $this->success($result['msg'],$result['data']);
  485. }else{
  486. $this->error($result['msg']);
  487. }
  488. }
  489. /**
  490. * @title 订单评价
  491. * @desc 订单评价
  492. * @url /api/User/evaluation_order
  493. * @method POST
  494. * @tag 基础
  495. * @header name:Authorization require:1 default: desc:验证token
  496. * @param name:order_no type:string require:0 default: desc:订单号
  497. * @param name:evaluation type:int require:0 default: desc:几颗星
  498. * @param name:evaluation_content type:string require:0 default: desc:评价内容
  499. *
  500. */
  501. public function evaluation_order(){
  502. $user_id = $this->check_login();
  503. $order_no= input('order_no'); //订单号
  504. $evaluation = intval(input('evaluation')); //几颗星
  505. $evaluation_content = input('evaluation_content'); //评价内容
  506. if (!$evaluation) $this->error('请评分');
  507. if ($evaluation<1 || $evaluation>5) $this->error('评分1-5');
  508. if (!$evaluation_content) $this->error('请输入评价内容');
  509. $result = Users::evaluationOrder($user_id,$order_no,$evaluation,$evaluation_content);
  510. if ($result['code']){
  511. $this->success($result['msg']);
  512. }else{
  513. $this->error($result['msg']);
  514. }
  515. }
  516. /**
  517. * @title 用户端我的评价
  518. * @desc 用户端我的评价
  519. * @url /api/User/user_evaluation_list
  520. * @method POST
  521. * @tag 基础
  522. * @header name:Authorization require:1 default: desc:验证token
  523. * @param name:page type:int require:0 default:1 desc:
  524. * @param name:limit type:int require:0 default:10 desc:
  525. *
  526. * @return name:order_no type:string desc:订单号
  527. * @return name:evaluation type:string desc:几颗星
  528. * @return name:evaluation_time type:string desc:时间
  529. * @return name:evaluation_content type:string desc:评价内容
  530. * @return name:name type:string desc:用户姓名
  531. * @return name:nickname type:string desc:用户昵称
  532. * @return name:headimg type:string desc:头像
  533. * @return name:designer_name type:string desc:设计师姓名
  534. */
  535. public function user_evaluation_list(){
  536. $user_id = $this->check_login();
  537. $Nowpage = input('page',1);
  538. $limits = input("limit",10);
  539. $result = Users::userEvaluationList($user_id,$Nowpage,$limits);
  540. $this->success($result['msg'],$result['data']);
  541. }
  542. /**
  543. * @title 设计师端我的评价
  544. * @desc 设计师端我的评价
  545. * @url /api/User/designer_evaluation_list
  546. * @method POST
  547. * @tag 基础
  548. * @header name:Authorization require:1 default: desc:验证token
  549. * @param name:page type:int require:0 default:1 desc:
  550. * @param name:limit type:int require:0 default:10 desc:
  551. *
  552. * @return name:order_no type:string desc:订单号
  553. * @return name:evaluation type:string desc:几颗星
  554. * @return name:evaluation_time type:string desc:时间
  555. * @return name:evaluation_content type:string desc:评价内容
  556. * @return name:name type:string desc:用户姓名
  557. * @return name:nickname type:string desc:用户昵称
  558. * @return name:headimg type:string desc:头像
  559. */
  560. public function designer_evaluation_list(){
  561. $user_id = $this->check_login();
  562. $Nowpage = input('page',1);
  563. $limits = input("limit",10);
  564. $result = Users::designerEvaluationList($user_id,$Nowpage,$limits);
  565. $this->success($result['msg'],$result['data']);
  566. }
  567. /**
  568. * @title 设计师端添加作品
  569. * @desc 设计师端添加作品
  570. * @url /api/User/add_works
  571. * @method POST
  572. * @tag 基础
  573. * @header name:Authorization require:1 default: desc:验证token
  574. * @param name:imgs type:array require:1 default: desc:作品图片,数组
  575. *
  576. */
  577. public function add_works(){
  578. $user_id = $this->check_login();
  579. $imgs = input('imgs'); //图片
  580. if (!$imgs) $this->error('请上传图片');
  581. $result = Users::addWorks($user_id,$imgs);
  582. if ($result['code']){
  583. $this->success($result['msg']);
  584. }else{
  585. $this->error($result['msg']);
  586. }
  587. }
  588. /**
  589. * @title 设计师端作品列表
  590. * @desc 设计师端作品列表
  591. * @url /api/User/work_list
  592. * @method POST
  593. * @tag 基础
  594. * @header name:Authorization require:1 default: desc:验证token
  595. *
  596. * @return name:date type:string desc:日期
  597. * @return name:imgs@id type:string desc:主键ID
  598. * @return name:imgs@img type:string desc:图片地址
  599. */
  600. public function work_list(){
  601. $user_id = $this->check_login();
  602. $result = Users::workList($user_id);
  603. $this->success($result['msg'],$result['data']);
  604. }
  605. /**
  606. * @title 设计师端删除作品
  607. * @desc 设计师端删除作品
  608. * @url /api/User/del_works
  609. * @method POST
  610. * @tag 基础
  611. * @header name:Authorization require:1 default: desc:验证token
  612. * @param name:ids type:string require:1 default: desc:作品id,多个以逗号隔开
  613. *
  614. */
  615. public function del_works(){
  616. $user_id = $this->check_login();
  617. $ids = input('ids'); //作品id
  618. if (!$ids) $this->error('作品id为空');
  619. $result = Users::delWorks($user_id,$ids);
  620. if ($result['code']){
  621. $this->success($result['msg']);
  622. }else{
  623. $this->error($result['msg']);
  624. }
  625. }
  626. /**
  627. * @title 设计师端订单列表
  628. * @desc 设计师端订单列表
  629. * @url /api/User/designer_order_list
  630. * @method POST
  631. * @tag 基础
  632. * @header name:Authorization require:1 default: desc:验证token
  633. *
  634. * @param name:page type:int require:0 default:1 desc:
  635. * @param name:limit type:int require:0 default:10 desc:
  636. * @param name:keywords type:int require:0 default:10 desc:关键词
  637. * @param name:status type:int require:0 default:10 desc:订单状态(1:已接单;2:待完成;3:已完成;all:全部订单)
  638. */
  639. public function designer_order_list(){
  640. $user_id = $this->check_login();
  641. $Nowpage = input('page',1);
  642. $limits = input("limit",10);
  643. $status = input("status",'all');
  644. $keywords = input('keywords'); //搜索关键词
  645. $result = Users::designerOrderList($user_id,$status,$keywords,$Nowpage,$limits);
  646. $this->success($result['msg'],$result['data']);
  647. }
  648. /**
  649. * @title 设计师开始工作打卡
  650. * @desc 设计师开始工作打卡
  651. * @url /api/User/clock_in_start
  652. * @method POST
  653. * @tag 基础
  654. * @header name:Authorization require:1 default: desc:验证token
  655. *
  656. * @param name:order_no type:string require:1 default: desc:订单号
  657. * @param name:start_address type:string require:0 default:10 desc:打卡地址
  658. */
  659. public function clock_in_start(){
  660. $user_id = $this->check_login();
  661. $order_no = input('order_no');
  662. $start_address = input('start_address');
  663. if (!$order_no || !$start_address) $this->error('参数错误');
  664. $result = Users::clockInStart($user_id,$order_no,$start_address);
  665. $this->success($result['msg'],$result['data']);
  666. }
  667. /**
  668. * @title 设计师结束工作打卡
  669. * @desc 设计师结束工作打卡
  670. * @url /api/User/clock_in_end
  671. * @method POST
  672. * @tag 基础
  673. * @header name:Authorization require:1 default: desc:验证token
  674. *
  675. * @param name:order_no type:string require:1 default: desc:订单号
  676. * @param name:end_address type:string require:0 default:10 desc:打卡地址
  677. */
  678. public function clock_in_end(){
  679. $user_id = $this->check_login();
  680. $order_no = input('order_no');
  681. $end_address = input('end_address');
  682. if (!$order_no || !$end_address) $this->error('参数错误');
  683. $result = Users::clockInEnd($user_id,$order_no,$end_address);
  684. $this->success($result['msg'],$result['data']);
  685. }
  686. /**
  687. * @title 设计师结束工作上传作品
  688. * @desc 设计师结束工作上传作品
  689. * @url /api/User/order_uploading
  690. * @method POST
  691. * @tag 基础
  692. * @header name:Authorization require:1 default: desc:验证token
  693. *
  694. * @param name:order_no type:string require:1 default: desc:订单号
  695. * @param name:works type:string require:0 default:10 desc:上传作品,数组
  696. */
  697. public function order_uploading(){
  698. $user_id = $this->check_login();
  699. $order_no = input('order_no');
  700. $works = input('works');
  701. if (!$order_no || !$works) $this->error('参数错误');
  702. $result = Users::orderUploading($user_id,$order_no,$works);
  703. $this->success($result['msg'],$result['data']);
  704. }
  705. /**
  706. * @title 用户优惠券列表
  707. * @desc 用户优惠券列表
  708. * @url /api/User/coupon_list
  709. * @method POST
  710. * @tag 基础
  711. * @header name:Authorization require:1 default: desc:验证token
  712. *
  713. * @param name:page type:int require:0 default:1 desc:
  714. * @param name:limit type:int require:0 default:10 desc:
  715. */
  716. public function coupon_list(){
  717. $user_id = $this->check_login();
  718. $Nowpage = input('page',1);
  719. $limits = input("limit",10);
  720. $result = Users::couponList($user_id,$Nowpage,$limits);
  721. $this->success($result['msg'],$result['data']);
  722. }
  723. /**
  724. * @title 注销
  725. * @desc 注销
  726. * @url /api/User/cancellation
  727. * @method POST
  728. * @tag 基础
  729. * @header name:Authorization require:1 default: desc:验证token
  730. *
  731. * @param name:page type:int require:0 default:1 desc:
  732. * @param name:limit type:int require:0 default:10 desc:
  733. */
  734. public function cancellation(){
  735. $user_id = $this->check_login();
  736. $this->success('成功');
  737. }
  738. }