GoodsFeeStandardsLists.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace app\workerapi\lists;
  3. use app\common\lists\ListsSearchInterface;
  4. use app\common\model\goods_fee_standards\GoodsFeeStandards;
  5. use app\common\model\recharge\RechargeOrder;
  6. /**
  7. * GoodsFeeStandards列表
  8. * Class GoodsFeeStandardsLists
  9. * @package app\workerapi\lists
  10. */
  11. class GoodsFeeStandardsLists extends BaseWorkerDataLists implements ListsSearchInterface
  12. {
  13. /**
  14. * 设置搜索条件
  15. * @return array[]
  16. * @author liuguanci
  17. * @date 2024/7/11 下午1:46
  18. */
  19. public function setSearch(): array
  20. {
  21. if(isset($this->params['work_id'])){
  22. $rechargeOrder = RechargeOrder::with(['orderGoods'])->where('work_id',$this->params['work_id'])->where('payment_type','IN',[0,1])->find()->toArray();
  23. $this->params['goods_id'] = $rechargeOrder['orderGoods'][0]['goods_id']??0;
  24. }
  25. return [
  26. '=' => ['goods_id'],
  27. ];
  28. }
  29. /*
  30. * 查询条件
  31. * @return array
  32. * @author liuguanci
  33. * @date 2024/7/11 下午1:46
  34. */
  35. public function queryWhere(){
  36. $where = [];
  37. return $where;
  38. }
  39. /**
  40. * @notes 获取列表
  41. * @return array
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\DbException
  44. * @throws \think\db\exception\ModelNotFoundException
  45. * @author likeadmin
  46. * @date 2024/09/14 15:08
  47. */
  48. public function lists(): array
  49. {
  50. return GoodsFeeStandards::where($this->queryWhere())->where($this->searchWhere)
  51. ->field(['*'])
  52. ->append(['type_text'])
  53. ->select()->toArray();
  54. /*return array_values(array_reduce($data, function ($carry, $item) {
  55. $type = $item['type'];
  56. if (!isset($carry[$type])) {
  57. $carry[$type] = [
  58. 'type' => $type,
  59. 'type_text'=>$item['type_text'],
  60. 'type_data'=>[],
  61. ];
  62. }
  63. $carry[$type]['type_data'][] = $item;
  64. return $carry;
  65. }, []));*/
  66. }
  67. /**
  68. * @notes 获取数量
  69. * @return int
  70. * @author likeadmin
  71. * @date 2024/09/14 15:08
  72. */
  73. public function count(): int
  74. {
  75. return GoodsFeeStandards::where($this->queryWhere())->where($this->searchWhere)->count();
  76. }
  77. }