IntegralOrderLists.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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\IntegralOrderEnum;
  21. use app\common\model\IntegralOrder;
  22. use app\common\service\FileService;
  23. /**
  24. * 积分订单列表
  25. * Class IntegralGoodsLists
  26. * @package app\shopapi\lists
  27. */
  28. class IntegralOrderLists extends BaseShopDataLists
  29. {
  30. /**
  31. * @notes 搜索条件
  32. * @return array
  33. * @author 段誉
  34. * @date 2022/3/31 14:41
  35. */
  36. public function setSearch(): array
  37. {
  38. $where[] = ['user_id', '=', $this->userId];
  39. if (isset($this->params['type']) && $this->params['type'] != '') {
  40. $where[] = ['order_status', '=', $this->params['type']];
  41. }
  42. return $where;
  43. }
  44. /**
  45. * @notes 积分商品列表
  46. * @return array
  47. * @throws \think\db\exception\DataNotFoundException
  48. * @throws \think\db\exception\DbException
  49. * @throws \think\db\exception\ModelNotFoundException
  50. * @author 段誉
  51. * @date 2022/3/31 9:40
  52. */
  53. public function lists(): array
  54. {
  55. $field = [
  56. 'id', 'sn', 'order_status', 'pay_status', 'express_status',
  57. 'express_price', 'delivery_way', 'order_amount', 'total_num',
  58. 'order_integral', 'goods_snap', 'create_time', 'refund_status', 'pay_way'
  59. ];
  60. $lists = IntegralOrder::where($this->setSearch())
  61. ->field($field)
  62. ->limit($this->limitOffset, $this->limitLength)
  63. ->order('id desc')
  64. ->append(['btns', 'order_status_desc'])
  65. ->select()->toArray();
  66. foreach ($lists as &$item) {
  67. $goods = $item['goods_snap'];
  68. $item['goods'] = [
  69. 'image' => FileService::getFileUrl($goods['image']),
  70. 'name' => $goods['name'],
  71. 'need_integral' => $goods['need_integral'],
  72. 'need_money' => $goods['need_money'],
  73. 'exchange_way' => $goods['exchange_way'],
  74. ];
  75. unset($item['goods_snap']);
  76. }
  77. return $lists;
  78. }
  79. /**
  80. * @notes 积分商品数量
  81. * @return int
  82. * @author 段誉
  83. * @date 2022/3/31 9:40
  84. */
  85. public function count(): int
  86. {
  87. return IntegralOrder::where($this->setSearch())->count();
  88. }
  89. }