VerificationLists.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop开源商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | gitee下载:https://gitee.com/likeshop_gitee
  7. // | github下载:https://github.com/likeshop-github
  8. // | 访问官网:https://www.likeshop.cn
  9. // | 访问社区:https://home.likeshop.cn
  10. // | 访问手册:http://doc.likeshop.cn
  11. // | 微信公众号:likeshop技术社区
  12. // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
  13. // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
  14. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  15. // | likeshop团队版权所有并拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshop.cn.team
  18. // +----------------------------------------------------------------------
  19. namespace app\shopapi\lists;
  20. use app\common\enum\DeliveryEnum;
  21. use app\common\enum\OrderEnum;
  22. use app\common\enum\PayEnum;
  23. use app\common\enum\YesNoEnum;
  24. use app\common\lists\ListsSearchInterface;
  25. use app\common\model\Order;
  26. class VerificationLists extends BaseShopDataLists implements ListsSearchInterface
  27. {
  28. /**
  29. * @notes 设置搜索条件
  30. * @return \string[][]
  31. * @author ljj
  32. * @date 2021/8/27 3:39 下午
  33. */
  34. public function setSearch(): array
  35. {
  36. $where[] = ['o.verification_status', '=', $this->params['type'] ?? 0];
  37. $where[] = ['o.delivery_type', '=', DeliveryEnum::SELF_DELIVERY];
  38. $where[] = ['o.pay_status', '=', PayEnum::ISPAID];
  39. // 已售后成且订单已关闭的订单 无需再显示在待核销列表
  40. if (($this->params['type'] ?? 0) == 0) {
  41. $where[] = [
  42. 'o.order_status',
  43. 'in',
  44. [
  45. OrderEnum::STATUS_WAIT_DELIVERY,
  46. OrderEnum::STATUS_WAIT_RECEIVE,
  47. ],
  48. ];
  49. }
  50. $where[] = ['sv.user_id', '=', $this->request->userId];
  51. $where[] = ['sv.status', '=', YesNoEnum::YES];
  52. return $where;
  53. }
  54. /**
  55. * @notes 查看自提订单列表
  56. * @return array
  57. * @throws \think\db\exception\DataNotFoundException
  58. * @throws \think\db\exception\DbException
  59. * @throws \think\db\exception\ModelNotFoundException
  60. * @author ljj
  61. * @date 2021/8/27 4:14 下午
  62. */
  63. public function lists(): array
  64. {
  65. $lists = Order::field('o.id,o.address,o.verification_status')
  66. ->alias('o')
  67. ->join('selffetch_verifier sv', 'sv.selffetch_shop_id = o.selffetch_shop_id')
  68. ->with(['order_goods' => function ($query) {
  69. $query->field('order_id,goods_snap,goods_name,goods_num')
  70. ->append(['goods_image', 'spec_value_str'])
  71. ->hidden(['goods_snap']);
  72. }])
  73. ->append(['verification_status_desc'])
  74. ->hidden(['verification_status'])
  75. ->where(self::setSearch())
  76. ->limit($this->limitOffset, $this->limitLength)
  77. ->group('o.id')
  78. ->select()
  79. ->toArray();
  80. foreach ($lists as &$list) {
  81. $list['contact'] = $list['address']->contact;
  82. unset($list['address']);
  83. }
  84. return $lists;
  85. }
  86. /**
  87. * @notes 查看自提订单总数
  88. * @return int
  89. * @author ljj
  90. * @date 2021/8/27 4:14 下午]
  91. */
  92. public function count(): int
  93. {
  94. return Order::alias('o')
  95. ->join('selffetch_verifier sv', 'sv.selffetch_shop_id = o.selffetch_shop_id')
  96. ->where(self::setSearch())
  97. ->group('o.id')
  98. ->count();
  99. }
  100. }