CustomerRecycleLogic.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\logics;
  4. use app\model\CustomerRecycle as Model;
  5. class CustomerRecycleLogic
  6. {
  7. public static function list($condition = [], $page, $limit, $order)
  8. {
  9. $page = intval($page);
  10. $limit = intval($limit);
  11. $data = Model::with(['employee', 'org', 'designer'])
  12. ->where($condition)
  13. ->page($page, $limit)->order($order)->select();
  14. $data = $data->visible(['id', 'customer_id', 'employee_id', 'name', 'community_name', 'phone', 'level', 'state', 'square', 'revisit_time', 'addtime', 'org_id', 'protected_to', 'is_resource', 'employee.name', 'org_name', 'designer.name'])->toArray();
  15. foreach ($data as &$item) {
  16. $item['protected'] = false;
  17. if (isset($item['protected_to']) && time() < strtotime($item['protected_to'])) {
  18. $item['protected'] = true;
  19. }
  20. $item['square'] = floatval($item['square']);
  21. $item['phone'] = substr_replace($item['phone'], '******', 3, 6);
  22. }
  23. return $data;
  24. }
  25. public static function count($condition = [])
  26. {
  27. return Model::where($condition)->count();
  28. }
  29. public static function info($id)
  30. {
  31. return Model::where('id', $id)->find();
  32. }
  33. }