MyController.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 文件说明:幻灯片
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: wuwu <15093565100@163.com>
  8. // +----------------------------------------------------------------------
  9. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  10. // +----------------------------------------------------------------------
  11. // | Date: 2017-5-25
  12. // +----------------------------------------------------------------------
  13. namespace api\rob\controller;
  14. use app\rob\model\OrderModel;
  15. use app\rob\model\OrderProductModel;
  16. use cmf\controller\RestBaseController;
  17. class MyController extends RestBaseController
  18. {
  19. /**
  20. * 列表
  21. */
  22. public function index()
  23. {
  24. $param = $this->request->param();
  25. $page = empty($param['page']) ? 1 : $param['page'];
  26. $size = empty($param['size']) ? 10 : $param['size'];
  27. //搜索条件
  28. $where = [];
  29. if (!empty($param['status'])) {
  30. $where[] = ['status', '=', $param['status']];
  31. }
  32. $list = OrderModel::with('orderProduct')->where($where)
  33. ->order('update_time desc')
  34. ->page($page, $size)
  35. ->select();
  36. //数据处理
  37. if (!$list->isEmpty()) {
  38. foreach ($list as $v) {
  39. foreach ($v['order_product'] as $product) {
  40. $product['product_image'] = cmf_get_image_preview_url($product['product_image']);
  41. }
  42. $v['create_time'] = date('Y-m-d H:i:s', $v['create_time']);
  43. $v['status_text'] = $v['status_text'];
  44. }
  45. }
  46. $this->success('成功', $list);
  47. }
  48. /**
  49. * 确认订单
  50. */
  51. public function orderConfirm()
  52. {
  53. $id = $this->request->param('id');
  54. OrderModel::update(['status' => 2, 'receive_time' => time()], ['id' => $id]);
  55. $this->success('操作成功');
  56. }
  57. /**
  58. * 获取二维码
  59. */
  60. public function qrcode()
  61. {
  62. include('../extend/util/phpqrcode/qrlib.php');
  63. $id = $this->request->param('id');
  64. $product = OrderProductModel::where('order_id',$id)->find();
  65. if (empty($product)) {
  66. $this->error('该订单不支持二维码!');
  67. }
  68. return \QRcode::png($product['code']);
  69. // $this->success('成功',);
  70. }
  71. }