ChatOrderLists.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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\kefuapi\lists;
  20. use app\common\lists\ListsSearchInterface;
  21. use app\common\model\Order;
  22. /**
  23. * 订单列表(客服页面中-用户订单列表)
  24. * Class ChatOrderLists
  25. * @package app\kefuapi\lists
  26. */
  27. class ChatOrderLists extends BaseKefuDataLists implements ListsSearchInterface
  28. {
  29. /**
  30. * @notes 设置搜索条件
  31. * @return \string[][]
  32. * @author 段誉
  33. * @date 2022/3/14 14:50
  34. */
  35. public function setSearch(): array
  36. {
  37. return [
  38. '%like%' => ['sn'],
  39. '=' => ['user_id'],
  40. ];
  41. }
  42. /**
  43. * @notes 获取用户订单列表
  44. * @return array
  45. * @throws \think\db\exception\DataNotFoundException
  46. * @throws \think\db\exception\DbException
  47. * @throws \think\db\exception\ModelNotFoundException
  48. * @author 段誉
  49. * @date 2022/3/14 14:50
  50. */
  51. public function lists(): array
  52. {
  53. $goodFields = [
  54. 'order_id', 'goods_id', 'item_id', 'goods_snap',
  55. 'goods_name', 'goods_price', 'goods_num'
  56. ];
  57. $lists = Order::with([
  58. 'order_goods' => function ($query) use ($goodFields) {
  59. $query->field($goodFields)
  60. ->append(['goods_image', 'spec_value_str'])
  61. ->hidden(['goods_snap']);
  62. }])
  63. ->field(['id', 'sn', 'order_status', 'order_amount','order_type', 'create_time'])
  64. ->where($this->searchWhere)
  65. ->append(['order_status_desc', 'order_type_desc'])
  66. ->limit($this->limitOffset, $this->limitLength)
  67. ->order('id desc')
  68. ->select()->toArray();
  69. return $lists;
  70. }
  71. /**
  72. * @notes 记录数量
  73. * @return int
  74. * @author 段誉
  75. * @date 2022/3/14 14:51
  76. */
  77. public function count(): int
  78. {
  79. return Order::where($this->searchWhere)->count();
  80. }
  81. }