OrderEffectiveLogLists.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\lists\effective;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\adminapi\logic\effective\OrderEffectiveLogLogic;
  17. use app\common\model\orders\OrderEffectiveLog;
  18. use app\common\lists\ListsSearchInterface;
  19. use app\common\model\user\User;
  20. use app\common\model\works\ServiceWork;
  21. /**
  22. * OrderEffectiveLog列表
  23. * Class OrderEffectiveLogLists
  24. * @package app\adminapi\lists
  25. */
  26. class OrderEffectiveLogLists extends BaseAdminDataLists implements ListsSearchInterface
  27. {
  28. /**
  29. * @notes 设置搜索条件
  30. * @return \string[][]
  31. * @author likeadmin
  32. * @date 2025/01/17 11:10
  33. */
  34. public function setSearch(): array
  35. {
  36. if(isset($this->params['mobile']) && !empty($this->params['mobile'])){
  37. $userIds = User::whereLike('mobile',"%{$this->params['mobile']}%")->column('id')??[0];
  38. $this->params['user_id'] = $userIds;
  39. }
  40. return [
  41. '=' => ['effective_id', 'sn', 'work_id', 'goods_id', 'effective_unit', 'effective_num', 'remark', 'end_effective_time','effective_status'],
  42. 'in' => ['user_id']
  43. ];
  44. }
  45. /**
  46. * @notes 获取列表
  47. * @return array
  48. * @throws \think\db\exception\DataNotFoundException
  49. * @throws \think\db\exception\DbException
  50. * @throws \think\db\exception\ModelNotFoundException
  51. * @author likeadmin
  52. * @date 2025/01/17 11:10
  53. */
  54. public function lists(): array
  55. {
  56. $list = OrderEffectiveLog::with(['goods'=>function ($query) {
  57. $query->with(['goodsCategory'=>function ($query1) {
  58. $query1->field(['name','picture']);
  59. }]);
  60. },'serviceWork','originalServiceWork','userInfo'])->where('effective_status','>',0)->where($this->searchWhere)
  61. ->field(['*'])
  62. ->limit($this->limitOffset, $this->limitLength)
  63. ->order(['id' => 'desc'])
  64. ->select()
  65. ->toArray();
  66. foreach ($list as &$value) {
  67. $value['income_fee'] = 0;
  68. if($value['originalServiceWork']) $value['income_fee'] = OrderEffectiveLogLogic::commissionAndAssuranceDeposit($value['originalServiceWork']);
  69. }
  70. return $list;
  71. }
  72. /**
  73. * @notes 获取数量
  74. * @return int
  75. * @author likeadmin
  76. * @date 2025/01/17 11:10
  77. */
  78. public function count(): int
  79. {
  80. return OrderEffectiveLog::where($this->searchWhere)->count();
  81. }
  82. }