Order.php 900 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use addons\epay\library\Service;
  6. /**
  7. * 订单
  8. */
  9. class order extends Api
  10. {
  11. protected $noNeedLogin = [''];
  12. protected $noNeedRight = ['*'];
  13. public function lists()
  14. {
  15. $where = [
  16. 'order.user_id'=>$this->auth->id,
  17. ];
  18. $list = Db::name('order')->field('order.*,product.images,product.title,product.category')
  19. ->join('product','order.product_id = product.id','LEFT')
  20. ->where($where)->order('order.id desc')->autopage()->select();
  21. $list = list_domain_image($list,['images']);
  22. if(!empty($list)){
  23. foreach($list as $key => &$item){
  24. //第一个图
  25. $item['image'] = isset($item['images'][0]) ? $item['images'][0] : '';
  26. }
  27. }
  28. $this->success(1,$list);
  29. }
  30. }