GiftCardLists.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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\model\GiftCardInfo;
  21. /**
  22. * 兑换礼品卡列表
  23. * Class AccountLogLists
  24. * @package app\shopapi\lists
  25. */
  26. class GiftCardLists extends BaseShopDataLists
  27. {
  28. /**
  29. * @notes 设置搜索条件
  30. * @author Tab
  31. * @date 2021/8/9 17:31
  32. */
  33. public function setWhere()
  34. {
  35. // 指定用户
  36. $this->searchWhere[] = ['user_id', '=', $this->userId];
  37. }
  38. /**
  39. * @notes 账户流水列表
  40. * @return array
  41. * @throws \think\db\exception\DataNotFoundException
  42. * @throws \think\db\exception\DbException
  43. * @throws \think\db\exception\ModelNotFoundException
  44. * @author Tab
  45. * @date 2021/8/9 17:37
  46. */
  47. public function lists(): array
  48. {
  49. // 设置搜索条件
  50. $this->setWhere();
  51. $field = 'user_id,card_pass,card_money,used_time';
  52. $lists = GiftCardInfo::field($field)
  53. ->where($this->searchWhere)
  54. ->order('used_time', 'desc')
  55. ->limit($this->limitOffset, $this->limitLength)
  56. ->order('used_time', 'desc')
  57. ->select()
  58. ->toArray();
  59. foreach($lists as &$item) {
  60. // $item['used_time'] = $item['action'] == AccountLogEnum::DEC ? '-' . $item['change_amount'] : '+' . $item['change_amount'];
  61. }
  62. return $lists;
  63. }
  64. /**
  65. * @notes 账户流水记录数
  66. * @return int
  67. * @author Tab
  68. * @date 2021/8/9 17:36
  69. */
  70. public function count(): int
  71. {
  72. // 设置搜索条件
  73. $this->setWhere();
  74. $count = GiftCardInfo::where($this->searchWhere)->count();
  75. return $count;
  76. }
  77. }