MassagerService.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. <?php
  2. namespace app\api\service;
  3. use app\admin\model\dynamic\Dynamic;
  4. use app\admin\model\dynamic\Like;
  5. use app\api\model\massager\Massager;
  6. use app\api\model\massager\Collect;
  7. use app\api\model\massager\Comment;
  8. use app\api\model\massager\Work;
  9. use app\api\model\massager\WorkPeriod;
  10. use app\api\model\order\Order;
  11. use app\api\model\service\Service;
  12. use redis\RedisClient;
  13. class MassagerService extends BaseService
  14. {
  15. private $massagerModel;
  16. private $colletModel;
  17. private $commentModel;
  18. private $orderModel;
  19. private $workModel;
  20. public function __construct()
  21. {
  22. $this->massagerModel = new Massager();
  23. $this->colletModel = new Collect();
  24. $this->commentModel = new Comment();
  25. $this->orderModel = new Order();
  26. $this->workModel = new Work();
  27. }
  28. /**
  29. * 合并助教数据代码
  30. * @param $paginate
  31. * @param $user_id
  32. * @return array
  33. */
  34. private function mergeMassager($paginate, $user_id)
  35. {
  36. $items = $paginate->items();
  37. $collet_relation = [];
  38. if ($user_id) {
  39. $collet_relation = $this->colletModel->fetchByUserIdAndMassagerIds($user_id, array_map(function ($data) {
  40. return $data['id'];
  41. }, $items));
  42. $collet_relation = array_reduce($collet_relation, function ($p, $cur) {
  43. $p[$cur['massager_id']] = 1;
  44. return $p;
  45. }, []);
  46. }
  47. $services = (new \app\admin\model\Service())->where([
  48. "duration_minute" => 120,
  49. "type" => \E_SERVICE_TYPE::App,
  50. ])->select();
  51. $services = array_reduce($services, function ($p, $cur) {
  52. $p[$cur["level"]] = $cur["real_price"];
  53. return $p;
  54. }, []);
  55. foreach ($items as &$item) {
  56. $recently_work_date = $this->workDateRange(array_map(function ($data) {
  57. return [strtotime($data["service_start_date"]), strtotime($data["service_end_date"])];
  58. }, $item["nearly_two_days_orders"]), true);
  59. $item['recently_work_date'] = $recently_work_date;
  60. $item['is_can_collet'] = !isset($collet_relation[$item['id']]);
  61. $item["price"] = isset($services[$item['level']]) ? $services[$item['level']] : 260;
  62. unset($item['nearly_two_days_orders']);
  63. }
  64. return [
  65. array_map(function ($data) {
  66. return Massager::fmtMassager($data);
  67. }, $items),
  68. $paginate->total()
  69. ];
  70. }
  71. /**
  72. * 判断是否能够选择
  73. * @param $in_time
  74. * @param $ranges
  75. * @return bool
  76. */
  77. private function checkCanOption($in_time, $ranges)
  78. {
  79. foreach ($ranges as $range) {
  80. if ($in_time >= $range[0] && $in_time <= $range[1]) {
  81. return false;
  82. }
  83. }
  84. return true;
  85. }
  86. /**
  87. * 获取可助教工作的时间段
  88. * @param array $order_date_range
  89. * @param bool $recently
  90. * @return array|false|string|null
  91. */
  92. private function workDateRange(array $order_date_range, $recently = true)
  93. {
  94. $now_time = time();
  95. $range = [];
  96. $max_time = strtotime(date("Y-m-d 23:59:59"));
  97. $acc_time = $now_time;
  98. $recently_work_date = null;
  99. while (true) {
  100. if ($acc_time === $now_time) {
  101. $y_m_d = date("Y-m-d", $acc_time);
  102. $now_minute = date("i", $acc_time);
  103. if ($now_minute < 30) {
  104. $range["$y_m_d"] = ["date" => $y_m_d, "range" => [["value" => date("H:30", $acc_time), "can_option" => false]]];
  105. }
  106. }
  107. $acc_time += (60 * 60);
  108. $y_m_d = date("Y-m-d", $acc_time);
  109. $y_m_d_h = date("Y-m-d H:00:00", $acc_time);
  110. $v_1 = [
  111. "value" => date("H:00", strtotime($y_m_d_h)),
  112. "can_option" => (($acc_time - (60 * 60)) === $now_time) ? false : $this->checkCanOption(strtotime($y_m_d_h), $order_date_range)
  113. ];
  114. $v_2 = [
  115. "value" => date("H:30", $acc_time),
  116. "can_option" => $this->checkCanOption($acc_time + (30 * 60), $order_date_range)
  117. ];
  118. if ($recently) {
  119. if ($v_1["can_option"]) {
  120. $recently_work_date = "$y_m_d_h";
  121. break;
  122. }
  123. if ($v_2["can_option"]) {
  124. $recently_work_date = date("Y-m-d H:30:00", $acc_time);
  125. break;
  126. }
  127. }
  128. if (isset($range["$y_m_d"])) {
  129. array_push($range["$y_m_d"]["range"], $v_1, $v_2);
  130. } else {
  131. $range["$y_m_d"] = [
  132. "date" => $y_m_d,
  133. "range" => [$v_1, $v_2]
  134. ];
  135. }
  136. if ($acc_time >= $max_time) break;
  137. }
  138. if ($recently) {
  139. return $recently_work_date;
  140. }
  141. $format_range = [];
  142. $keys = array_keys($range);
  143. for ($i = 0; $i <= count($keys) - 1; $i++) {
  144. $key = $keys[$i];
  145. $format_range[$i] = $range[$key];
  146. }
  147. return $format_range;
  148. }
  149. /**
  150. * 获取App助教
  151. * @param null $user_id
  152. * @param array $params
  153. * @param $gender
  154. * @return array
  155. */
  156. public function fetchAppMassager($user_id, array $params, $gender)
  157. {
  158. $paginate = $this->massagerModel->fetchAppMassager(
  159. $params['city_code'],
  160. $params['lng_lat'],
  161. isset($params['search_text']) && mb_strlen($params['search_text']) > 0 ? $params['search_text'] : null,
  162. isset($params['distance']) && is_numeric($params["distance"]) ? $params['distance'] : 300,
  163. isset($params['service_status']) && is_numeric($params['service_status']) ? $params['service_status'] : null,
  164. $gender,
  165. isset($params['free_travel']) && is_numeric($params['free_travel']) ? $params['free_travel'] : null,
  166. isset($params['hot']) && is_numeric($params['hot']) ? $params['hot'] : null,
  167. isset($params['service_id']) && is_numeric($params['service_id']) ? $params['service_id'] : null,
  168. $params['sort'] ?? null,
  169. $params['page'] ?? 1,
  170. $params['size'] ?? 10,
  171. $user_id,
  172. isset($params['level']) && is_numeric($params['level']) ? $params['level'] : null
  173. );
  174. return $this->mergeMassager($paginate, $user_id);
  175. }
  176. /**
  177. * 获取球房助教
  178. * @param array $params
  179. * @param $gender
  180. * @param null $user_id
  181. * @return array
  182. */
  183. public function fetchStoreMassager(array $params, $gender, $user_id = null)
  184. {
  185. $paginate = $this->massagerModel->fetchStoreMassager(
  186. $params['store_id'],
  187. $params['service_id'] ?? null,
  188. $params['search_text'] ?? null,
  189. $params['hot'] ?? null,
  190. $gender,
  191. $params['page'] ?? 1,
  192. $params['size'] ?? 10
  193. );
  194. return $this->mergeMassager($paginate, $user_id);
  195. }
  196. /**
  197. * 获取助教上班的的时间
  198. * @param $id
  199. * @return |null
  200. */
  201. public function getWorkDateRange($id)
  202. {
  203. $massager = $this->massagerModel->getMassager($id, ["store", "nearlyTwoDaysOrders"]);
  204. if (!$massager)
  205. return $this->ok([]);
  206. $order_date_range = array_map(function ($data) {
  207. return [strtotime($data["service_start_date"]), strtotime($data["service_end_date"])];
  208. }, $massager["nearlyTwoDaysOrders"]);
  209. $no_work_ranges = (new WorkPeriod())->where("massager_id", $id)->where("end_time", ">", time())->select();
  210. $ranges_ = array_map(function ($data) {
  211. return [$data["start_time"], $data["end_time"]];
  212. }, $no_work_ranges);
  213. $range = $this->workDateRange(array_merge($order_date_range, $ranges_), false);
  214. return $this->ok([
  215. "id" => $massager->id,
  216. "range" => $range
  217. ]);
  218. }
  219. /**
  220. * 获取单个助教详情
  221. * @param $massager_id
  222. * @param null $user_id
  223. * @return |null
  224. */
  225. public function get($massager_id, $user_id = null, $is_add_clock = null)
  226. {
  227. $massager = $this->massagerModel->fetchHiddenAndNormal($massager_id);
  228. if (null === $massager)
  229. return null;
  230. $massager['is_can_collet'] = true;
  231. if ($user_id) {
  232. $relation = $this->colletModel->getByUserIdAndMassagerId($user_id, $massager_id);
  233. if ($relation)
  234. $massager['is_can_collet'] = false;
  235. }
  236. $serviceModel = new Service();
  237. $query = $serviceModel
  238. ->where([
  239. "level" => $massager["level"],
  240. "type" => \E_SERVICE_TYPE::App
  241. ]);
  242. if (is_null($is_add_clock) || $is_add_clock != 1) {
  243. $query->where("is_add_clock", 0);
  244. }
  245. $q = ["id", "<>", "276"];
  246. $exist = null;
  247. if ($user_id) {
  248. $exist = RedisClient::of()->get("scan:qr:codes:" . $user_id);
  249. if ($exist) {
  250. $q = ["id", ">", "0"];
  251. }
  252. }
  253. $items = collection($query
  254. ->where($q[0], $q[1], $q[2])
  255. ->order('sort', 'desc')
  256. ->order('real_price', 'ASC')->select())->toArray();
  257. $membership_discount_rate = config("site.membership_discount_rate") / 100;
  258. $available_services = [];
  259. foreach ($items as &$item) {
  260. $item["membership_discount_price"] = fixed2Float($item["real_price"] * $membership_discount_rate);
  261. if ($item["id"] != 276) {
  262. $available_services[] = $item;
  263. } else {
  264. if ($massager["store_id"] == $exist && $exist > 0) {
  265. $available_services[] = $item;
  266. }
  267. }
  268. }
  269. $massager["services"] = $available_services;
  270. return Massager::fmtMassager($massager);
  271. }
  272. /**
  273. * @param $massager_id
  274. * @param $page
  275. * @param $size
  276. * @return array
  277. * @throws \think\exception\DbException
  278. */
  279. public function fetchMassagerComment($massager_id, $page, $size)
  280. {
  281. $paginate = $this->commentModel->fetchByMassagerId($massager_id, $page, $size);
  282. $items = $paginate->items();
  283. return [
  284. array_map(function ($data) {
  285. $nickname = "匿名用户";
  286. $avatar = null;
  287. if ($data['user'] && 0 == $data['is_anonymity']) {
  288. $nickname = $data['user']['nickname'];
  289. $avatar = $data['user']['avatar'];
  290. }
  291. $data['user_nickname'] = $nickname;
  292. $data['user_avatar'] = $avatar;
  293. unset($data['user']);
  294. return $data;
  295. }, $items),
  296. $paginate->total()
  297. ];
  298. }
  299. public function getMassagerTentativeNowLevelConfiguration($m_id, $city_code, $intraday = null)
  300. {
  301. $configuration = [
  302. [0, 50],
  303. [300, 60],
  304. [500, 65],
  305. [700, 70]
  306. ];
  307. $level_index = 1;
  308. $profit_rate = 50;
  309. $next_configuration = 288;
  310. $sumPerformanceByNowMonth = $this->orderModel->sumPerformanceByIntraday($m_id, $city_code, $intraday);
  311. if ($sumPerformanceByNowMonth > $configuration[0][0]) {
  312. for ($index = 0; $index < count($configuration); $index++) {
  313. $item = $configuration[$index];
  314. if ($sumPerformanceByNowMonth > $item[0]) {
  315. $level_index += 1;
  316. $profit_rate = $item[1];
  317. $next_configuration = isset($configuration[$index + 1]) ? $configuration[$index + 1][0] : null;
  318. }
  319. }
  320. $level_index -= 1;
  321. }
  322. return [
  323. "level" => $level_index,
  324. "profit_rate" => $profit_rate,
  325. "next_configuration" => $next_configuration,
  326. "sum_performance_by_now_month" => $sumPerformanceByNowMonth,
  327. ];
  328. }
  329. public function getMassagerNowLevelConfiguration($m_id, $city_code, $y = null, $m = null)
  330. {
  331. $configuration = array_map(function ($data) {
  332. $performance = explode("|", $data["月业绩/元"]);
  333. $duration = explode("|", $data["在岗时长/小时"]);
  334. $reorder = explode("|", $data["加钟比例(%)"]);
  335. $praise = explode("|", $data["好评率(%)"]);
  336. $chargeback = explode("|", $data["退单率(%)"]);
  337. return [
  338. [
  339. "condition" => isset($performance[0]) && is_numeric($performance[0]) ? (float)$performance[0] : 6500,
  340. "rate" => isset($performance[1]) && is_numeric($performance[1]) ? (float)$performance[1] : 55
  341. ],
  342. [
  343. "condition" => isset($duration[0]) && is_numeric($duration[0]) ? (float)$duration[0] : 100,
  344. "rate" => isset($duration[1]) && is_numeric($duration[1]) ? (float)$duration[1] : 1
  345. ],
  346. [
  347. "condition" => isset($reorder[0]) && is_numeric($reorder[0]) ? (float)$reorder[0] : 30,
  348. "rate" => isset($reorder[1]) && is_numeric($reorder[1]) ? (float)$reorder[1] : 1
  349. ],
  350. [
  351. "condition" => isset($praise[0]) && is_numeric($praise[0]) ? (float)$praise[0] : 30,
  352. "rate" => isset($praise[1]) && is_numeric($praise[1]) ? (float)$praise[1] : 1
  353. ],
  354. [
  355. "condition" => isset($chargeback[0]) && is_numeric($chargeback[0]) ? (float)$chargeback[0] : 30,
  356. "rate" => isset($chargeback[1]) && is_numeric($chargeback[1]) ? (float)$chargeback[1] : -1
  357. ]
  358. ];
  359. }, [
  360. config("site.massager_level_1"),
  361. config("site.massager_level_2"),
  362. config("site.massager_level_3"),
  363. config("site.massager_level_4"),
  364. config("site.massager_level_5"),
  365. ]);
  366. $sumPerformanceByNowMonth = $this->orderModel->sumPerformanceByNowMonth($m_id, $city_code, $y, $m);
  367. $sumDurationByNowMonth = $this->workModel->sumByNowMonth($m_id, $y, $m);
  368. $reorderRateByNowMonth = $this->orderModel->reorderRateByNowMonth($m_id, $city_code, $y, $m);
  369. $praiseRateByNowMonth = $this->orderModel->countByPraiseRate($m_id, $city_code, $y, $m);
  370. $chargebackRateByNowMonth = $this->orderModel->chargebackRate($m_id, $city_code, $y, $m);
  371. $profit_rate = config("site.massager_basics_deposit_rate") ?? 50;
  372. $level_index = 0;
  373. $next_configuration = null;
  374. for ($i = 0; $i < count($configuration); $i++) {
  375. $now_configuration = $configuration[$i];
  376. if ($sumPerformanceByNowMonth >= $now_configuration[0]["condition"]) {
  377. $level_index += 1;
  378. $next_configuration = isset($configuration[$i + 1]) ? $configuration[$i + 1] : null;
  379. $profit_rate = $now_configuration[0]["rate"];
  380. $profit_rate += ($sumDurationByNowMonth >= $now_configuration[1]["condition"] ? $now_configuration[1]["rate"] : 0);
  381. $profit_rate += ($reorderRateByNowMonth >= $now_configuration[2]["condition"] ? $now_configuration[2]["rate"] : 0);
  382. $profit_rate += ($praiseRateByNowMonth >= $now_configuration[3]["condition"] ? $now_configuration[3]["rate"] : 0);
  383. $profit_rate += ($chargebackRateByNowMonth >= $now_configuration[4]["condition"] ? $now_configuration[4]["rate"] : 0);
  384. } else {
  385. break;
  386. }
  387. }
  388. return [
  389. "level" => $level_index,
  390. "profit_rate" => $profit_rate,
  391. "next_configuration" => $next_configuration,
  392. "sum_performance_by_now_month" => $sumPerformanceByNowMonth,
  393. ];
  394. }
  395. public function getProfitRate($m_id, $city_code, $y = null, $m = null, $intraday = null): float
  396. {
  397. $massager = $this->massagerModel->findById($m_id);
  398. if (!$massager)
  399. return 0;
  400. if ($massager["fixed_profit_rate"] > 0)
  401. return $massager["fixed_profit_rate"];
  402. // DOTO: 临时替换
  403. $level_info = $this->getMassagerTentativeNowLevelConfiguration($m_id, $city_code, $intraday);
  404. // $level_info = $this->getMassagerNowLevelConfiguration($m_id, $city_code, $y, $m);
  405. return $level_info["profit_rate"];
  406. }
  407. public function interiorScoreLevel($score)
  408. {
  409. $config = config("site.massager_review_level");
  410. $keys = array_keys($config);
  411. $level_desc = "不及格";
  412. foreach ($keys as $key) {
  413. if ($score >= (float)$key) {
  414. $level_desc = $config[$key];
  415. } else {
  416. break;
  417. }
  418. }
  419. return $level_desc;
  420. }
  421. public function updateInteriorScore($m_id, $year, $month)
  422. {
  423. $config = config("site.massager_review_score");
  424. $fmt_config = [
  425. "duration" => explode("|", $config["时长/天"] ?? "6|2"),
  426. "praise" => explode("|", $config["评论/好评"] ?? "1|2"),
  427. "negative" => explode("|", $config["评论/差评"] ?? "1|-10"),
  428. "performance" => explode("|", $config["业绩/天"] ?? "500|2"),
  429. "reorder" => explode("|", $config["项目加钟"] ?? "1|2")
  430. ];
  431. $byDuration = $this->interiorScoreByDuration($m_id, $year, $month, $fmt_config["duration"]);
  432. $byPraise = $this->interiorScoreByPraise($m_id, $year, $month, $fmt_config["praise"]);
  433. $byNegative = $this->interiorScoreByNegative($m_id, $year, $month, $fmt_config["negative"]);
  434. $byPerformance = $this->interiorScoreByPerformance($m_id, $year, $month, $fmt_config["performance"]);
  435. $byReorder = $this->interiorScoreByReorder($m_id, $year, $month, $fmt_config["reorder"]);
  436. $total_score = fixed2Float(
  437. $byDuration["score"]
  438. + $byPraise["score"]
  439. + $byNegative["score"]
  440. + $byPerformance["score"]
  441. + $byReorder["score"]
  442. );
  443. if (date("Y") == $year && date("m") == $month) {
  444. $this->massagerModel->update([
  445. "interior_score" => $total_score
  446. ], ["id" => $m_id]);
  447. }
  448. return [
  449. "total_interior_score" => $total_score,
  450. "level_desc" => $this->interiorScoreLevel($total_score),
  451. "items" => [
  452. "byDuration" => $byDuration,
  453. "byPraise" => $byPraise,
  454. "byNegative" => $byNegative,
  455. "byPerformance" => $byPerformance,
  456. "byReorder" => $byReorder
  457. ]
  458. ];
  459. }
  460. public function interiorScoreByDuration($m_id, $year, $month, $config)
  461. {
  462. $last_day = date("t", strtotime("$year-$month-01 00:00:00"));
  463. $starttime = strtotime("$year-$month-01 00:00:00");
  464. $endtime = strtotime("$year-$month-$last_day 23:59:59");
  465. $works = (new Work())
  466. ->where("massager_id", $m_id)
  467. ->where("clock_in_time", ">=", $starttime)
  468. ->where("clock_off_time", "<=", $endtime)
  469. ->select();
  470. $clocks_times = [];
  471. foreach ($works as $work) {
  472. $times = splittingDate($work["clock_in_time"], $work["clock_off_time"]);
  473. $clocks_times = array_merge($clocks_times, $times);
  474. }
  475. $clocks_times = array_merge(array_unique($clocks_times));
  476. $every_days = [];
  477. $DAY_TIME = 24 * 60 * 60;
  478. $start_time_copy = $starttime;
  479. while ($start_time_copy <= $endtime) {
  480. array_push($every_days, date("Y-m-d", $start_time_copy));
  481. $start_time_copy += $DAY_TIME;
  482. }
  483. $score = 0;
  484. $intersections = [];
  485. foreach ($every_days as $now_day) {
  486. $now_day_times = splittingDate(strtotime("$now_day 00:00:00"), strtotime("$now_day 23:59:59"));
  487. $intersection = array_intersect($now_day_times, $clocks_times);
  488. $meet = count($intersection) >= (fixed2Float((($config[0] ?? 6) * 60) / 10) + 1);
  489. if ($meet) {
  490. $intersections[] = [
  491. "date" => $now_day,
  492. "count" => count($intersection),
  493. ];
  494. $score += $config[1] ?? 2;
  495. }
  496. }
  497. return [
  498. "score" => fixed2Float($score),
  499. "details" => $intersections
  500. ];
  501. }
  502. public function interiorScoreByPraise($m_id, $year, $month, $config)
  503. {
  504. $negative = $this->commentModel->fetchPraiseCommentByMassager($m_id, $year, $month);
  505. $count = count($negative);
  506. $item_score = $config[1] / $config[0];
  507. return ["score" => fixed2Float($item_score * $count), "details" => $negative];
  508. }
  509. public function interiorScoreByNegative($m_id, $year, $month, $config)
  510. {
  511. $negative = $this->commentModel->fetchNegativeCommentByMassager($m_id, $year, $month);
  512. $count = count($negative);
  513. $item_score = $config[1] / $config[0];
  514. return ["score" => fixed2Float($item_score * $count), "details" => $negative];
  515. }
  516. public function interiorScoreByPerformance($m_id, $year, $month, $config)
  517. {
  518. $all_orders = $this->orderModel->fetchByMassager($m_id, $year, $month);
  519. $fmt = [];
  520. foreach ($all_orders as $order) {
  521. $key = date("Y-m-d", $order["pay_time"]);
  522. if (isset($fmt[$key])) {
  523. $fmt[$key] += $order["total_real_amount"];
  524. } else {
  525. $fmt[$key] = $order["total_real_amount"];
  526. }
  527. }
  528. $score = 0;
  529. $details = [];
  530. foreach ($fmt as $key => $value) {
  531. if ($value >= $config[0]) {
  532. $details[] = [
  533. "date" => $key,
  534. "count" => $value,
  535. ];
  536. $score += $config[1];
  537. }
  538. }
  539. return ["score" => fixed2Float($score), "details" => $details];
  540. }
  541. public function interiorScoreByReorder($m_id, $year, $month, $config)
  542. {
  543. $all_orders = $this->orderModel->fetchReorderByMassager($m_id, $year, $month);
  544. $count = count($all_orders);
  545. $item_score = $config[1] / $config[0];
  546. return ["score" => fixed2Float($item_score * $count), "details" => $all_orders];
  547. }
  548. public function fetchSelfDynamics($m_id, $page = 1, $size = 10)
  549. {
  550. $paginate = (new Dynamic())
  551. ->where("massager_id", $m_id)
  552. ->with(["comments", "likes"])
  553. ->page($page)
  554. ->paginate($size);
  555. return [
  556. $paginate->items(),
  557. $paginate->total()
  558. ];
  559. }
  560. public function fetchFansNumberAndPraiseNumber($m_id)
  561. {
  562. return [
  563. "fansNumber" => Collect::where("massager_id", $m_id)->count(),
  564. "praiseNumber" => Like::where("massager_id", $m_id)->count()
  565. ];
  566. }
  567. }