OrderLists.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\shopapi\lists;
  20. use app\common\enum\DeliveryEnum;
  21. use app\common\enum\OrderEnum;
  22. use app\common\enum\TeamEnum;
  23. use app\common\logic\CommonPresellLogic;
  24. use app\common\model\Order;
  25. use app\common\model\AfterSale;
  26. class OrderLists extends BaseShopDataLists
  27. {
  28. public $c_type = '';
  29. /**
  30. * @notes 列表
  31. * @return array
  32. * @throws \think\db\exception\DataNotFoundException
  33. * @throws \think\db\exception\DbException
  34. * @throws \think\db\exception\ModelNotFoundException
  35. * @author 段誉
  36. * @date 2021/7/23 18:55
  37. */
  38. public function lists(): array
  39. {
  40. // $r_where = [] ;
  41. // if($this->params['type'] == 'return'){
  42. // $r_where[] = ['is_after_sale', '=', 1];
  43. // }
  44. $c_type = $this->params['type'] ;
  45. outFileLog($c_type,'getexpress','c_type');
  46. $lists = Order::withSearch(['order_type', 'user_id'], [
  47. 'order_type' => $this->params['type'],
  48. 'user_id' => $this->userId
  49. ])
  50. ->with(['order_goods' => function ($query) {
  51. $query->field('goods_id,order_id,goods_snap,goods_name,goods_price,goods_num,is_comment,original_price')
  52. ->append(['goods_image', 'spec_value_str'])
  53. ->hidden(['goods_snap']);
  54. }])
  55. // ->where($r_where)
  56. ->field(['id', 'sn', 'order_type', 'order_status', 'total_num', 'order_amount', 'delivery_type', 'is_team_success', 'pay_way', 'pay_status', 'pay_time', 'express_status','delivery_content', 'delivery_content1', 'delivery_content_type', 'create_time', 'presell_id', 'transaction_id' ,'is_after_sale' ,'after_sale_status' ])
  57. ->append(['btn'])
  58. ->order(['id' => 'desc'])
  59. ->limit($this->limitOffset, $this->limitLength)
  60. ->select()->toArray();
  61. foreach ($lists as &$list){
  62. //查看提货码按钮
  63. $list['btn']['pickup_btn'] = ($list['order_status'] == OrderEnum::STATUS_WAIT_DELIVERY && $list['delivery_type'] == DeliveryEnum::SELF_DELIVERY) ? 1 : 0;
  64. //订单状态描述
  65. $list['order_status_desc'] = ($list['order_status'] == OrderEnum::STATUS_WAIT_DELIVERY && $list['delivery_type'] == DeliveryEnum::SELF_DELIVERY) ? '待取货' : OrderEnum::getOrderStatusDesc($list['order_status']);
  66. if ($list['order_type'] == OrderEnum::TEAM_ORDER && $list['is_team_success'] != TeamEnum::TEAM_FOUND_SUCCESS){
  67. $list['btn']['pickup_btn'] = 0;
  68. $list['order_status_desc'] = ($list['order_status'] == OrderEnum::STATUS_WAIT_DELIVERY) ? TeamEnum::getStatusDesc($list['is_team_success']) : OrderEnum::getOrderStatusDesc($list['order_status']);
  69. }
  70. //订单类型
  71. $list['order_type_desc'] = ($list['delivery_type'] == DeliveryEnum::SELF_DELIVERY) ? '自提订单' : OrderEnum::getOrderTypeDesc($list['order_type']);
  72. // 预售信息
  73. if ($list['order_type'] == OrderEnum::PRESELL_ORDER) {
  74. $list['presell'] = CommonPresellLogic::orderInfo($list);
  75. }
  76. if($this->params['type'] == 'return'){
  77. $afterOrder = AfterSale::where(['order_id'=>$list['id']])->find();
  78. $list['after_order'] = $afterOrder;
  79. }
  80. $list['cz_type'] = $c_type;
  81. }
  82. return $lists;
  83. }
  84. /**
  85. * @notes 数量
  86. * @return int
  87. * @author 段誉
  88. * @date 2021/7/23 18:55
  89. */
  90. public function count(): int
  91. {
  92. return Order::withSearch(['order_type', 'user_id'], [
  93. 'order_type' => $this->params['type'],
  94. 'user_id' => $this->userId
  95. ])->count();
  96. }
  97. }