VerificationOrderLists.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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\businessapi\lists;
  20. use app\common\enum\AfterSaleEnum;
  21. use app\common\enum\DeliveryEnum;
  22. use app\common\enum\OrderEnum;
  23. use app\common\enum\PayEnum;
  24. use app\common\model\AfterSale;
  25. use app\common\model\Order;
  26. /**
  27. * 订单列表
  28. * Class OrderLists
  29. * @package app\businessapi\lists
  30. */
  31. class VerificationOrderLists extends BaseBusinesseDataLists{
  32. public function searchwhere()
  33. {
  34. $where = [];
  35. $where[] = ['pay_status','=',PayEnum::ISPAID];
  36. $where[] = ['delivery_type','=',DeliveryEnum::SELF_DELIVERY];
  37. if(isset($this->params['type'])){
  38. $where[] = ['verification_status','=',$this->params['type']];
  39. }
  40. // 已售后成且订单已关闭的订单 无需再显示在待核销列表
  41. if (($this->params['type'] ?? 0) == 0) {
  42. $where[] = [
  43. 'order_status',
  44. 'in',
  45. [
  46. OrderEnum::STATUS_WAIT_DELIVERY,
  47. OrderEnum::STATUS_WAIT_RECEIVE,
  48. ],
  49. ];
  50. }
  51. return $where;
  52. }
  53. /**
  54. * @notes 实现数据列表
  55. * @return array
  56. * @author 令狐冲
  57. * @date 2021/7/6 00:33
  58. */
  59. public function lists(): array
  60. {
  61. $lists = Order::withSearch(['order_type'], [
  62. 'order_type' => $this->params['type'],
  63. ])
  64. ->with(['order_goods' => function ($query) {
  65. $query->field('id,goods_id,order_id,goods_snap,goods_name,goods_price,goods_num,is_comment,original_price')
  66. ->append(['goods_image', 'spec_value_str'])
  67. ->hidden(['goods_snap']);
  68. }])
  69. ->append(['consignee','mobile'])
  70. ->hidden(['address'])
  71. ->where($this->searchwhere())
  72. ->field(['id', 'sn', 'user_id','order_type', 'order_status', 'total_num', 'order_amount', 'delivery_type', 'pay_status','address','create_time','verification_status'])
  73. ->order(['id' => 'desc'])
  74. ->limit($this->limitOffset, $this->limitLength)
  75. ->select()->toArray();
  76. foreach ($lists as &$list){
  77. foreach ($list['order_goods'] as &$orderGoods){
  78. //售后状态
  79. $orderGoods['after_sale_status_desc'] = '无售后';
  80. $after_sale = AfterSale::where(['order_goods_id' => $orderGoods['id'], 'order_id' => $orderGoods['order_id']])->findOrEmpty();
  81. if (!$after_sale->isEmpty()) {
  82. $orderGoods['after_sale_status_desc'] = AfterSaleEnum::getStatusDesc($after_sale->status);
  83. }
  84. }
  85. }
  86. return $lists;
  87. }
  88. /**
  89. * @notes 实现数据列表记录数
  90. * @return int
  91. * @author 令狐冲
  92. * @date 2021/7/6 00:34
  93. */
  94. public function count(): int
  95. {
  96. return (new Order())
  97. ->where($this->searchwhere())
  98. ->count();
  99. }
  100. }