RecuperateService.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App\Services\Recuperate;
  3. use App\Models\RecuperateApply;
  4. use App\Repositories\RecuperateRepository;
  5. class RecuperateService
  6. {
  7. protected $recuperateRepository;
  8. public function __construct(RecuperateRepository $recuperateRepository)
  9. {
  10. $this->recuperateRepository = $recuperateRepository;
  11. }
  12. /**
  13. * 前台获取列表
  14. */
  15. public function list($key = '', $page = '')
  16. {
  17. //搜索条件
  18. $where = [];
  19. $where[] = ['is_display', '=', '1'];
  20. if ($key) {
  21. $where[] = ['title', 'like', '%' . $key . '%'];
  22. }
  23. //获取列表
  24. $list = $this->recuperateRepository->getRecuperate($where, $page);
  25. //列表处理
  26. if ($list->toArray()) {
  27. foreach ($list as $k => $v) {
  28. $list[$k]->origin_title = $v->title;
  29. $style = '';
  30. if ($v->tit_color) {
  31. $style .= 'color:' . $v->tit_color . ';';
  32. }
  33. if ($v->tit_b == '1') {
  34. $style .= 'font-weight:bold;';
  35. }
  36. if ($style) {
  37. $list[$k]->title = '<span style=' . $style . '>' . $v->title . '</span>';
  38. }
  39. }
  40. }
  41. return $list;
  42. }
  43. /**
  44. * 获取前台显示的疗养信息
  45. */
  46. public function getRecuperateInfo($id)
  47. {
  48. $where = array(
  49. 'id' => $id,
  50. 'is_display' => '1',
  51. );
  52. $article_info = $this->recuperateRepository->firstWhere($where);
  53. return $article_info;
  54. }
  55. /**
  56. * 增加数量
  57. */
  58. public function incrementData($where, $num, $filed)
  59. {
  60. return $this->recuperateRepository->incrementData($where, $num, $filed);
  61. }
  62. }