GoldRice.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\store\model\member;
  13. use app\common\enum\member\GoldType;
  14. use app\common\model\member\GoldRice as GoldRiceModel;
  15. /**
  16. * 商品服务与承诺模型
  17. * Class Service
  18. */
  19. class GoldRice extends GoldRiceModel
  20. {
  21. // 全部
  22. const LIST_TYPE_ALL = 'all';
  23. // 收入
  24. const LIST_TYPE_IN = 'in';
  25. // 支出
  26. const LIST_TYPE_OUT = 'out';
  27. /**
  28. * 获取列表记录
  29. * @param string $dataType 类型
  30. * @param array $param
  31. * @return \think\Paginator
  32. * @throws \think\db\exception\DbException
  33. */
  34. // public function getList(string $dataType = self::LIST_TYPE_ALL,array $param = [])
  35. // {
  36. // // 检索查询条件
  37. // $filter = $this->getFilter($param);
  38. // // 设置订单类型条件
  39. // $dataTypeFilter = $this->getFilterDataType($dataType);
  40. // return $this->where($dataTypeFilter)
  41. // ->where($filter)
  42. // ->order('id','desc')
  43. // ->paginate();
  44. // }
  45. /**
  46. * 获取查询条件
  47. * @param array $param
  48. * @return array
  49. */
  50. private function getFilter(array $param = [])
  51. {
  52. // 默认查询参数
  53. $params = $this->setQueryDefaultValue($param, ['userId' => 0]);
  54. // 检索查询条件
  55. $filter = [];
  56. $params['userId']>0 && $filter[] = ['user_id', $params['userId']];
  57. return $filter;
  58. }
  59. /**
  60. * 设置类型条件
  61. * @param string $dataType
  62. * @return array
  63. */
  64. private function getFilterDataType(string $dataType = self::LIST_TYPE_ALL): array
  65. {
  66. // 数据类型
  67. $filter = [];
  68. switch ($dataType) {
  69. case self::LIST_TYPE_ALL:
  70. $filter = [];
  71. break;
  72. case self::LIST_TYPE_IN:
  73. $filter = [
  74. ['type', '=', GoldType::IN],
  75. ];
  76. break;
  77. case self::LIST_TYPE_OUT:
  78. $filter = [
  79. ['type', '=', GoldType::OUT],
  80. ];
  81. break;
  82. }
  83. return $filter;
  84. }
  85. }