PartnerService.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace App\Http\Services\V1_1;
  3. use App\Generated\V1_1\Messages\Partner\GetPartnerUserMessage;
  4. use App\Generated\V1_1\Messages\Partner\ThumbPartnerMessage;
  5. use App\Generated\V1_1\Messages\Partner\SetPartnerSellMessage;
  6. use App\Generated\V1_1\Messages\Partner\LockLikeMeMessage;
  7. use App\Http\Controllers\Core\Auth;
  8. use App\Managers\PartnerManager;
  9. use App\Models\PartnerModel;
  10. use App\Models\User\UserModel;
  11. class PartnerService
  12. {
  13. public function getPartnerUser(GetPartnerUserMessage $message)
  14. {
  15. $uid = Auth::auth();
  16. if ($partner_id = $message->getPartnerId()) {
  17. $partner = PartnerModel::findOrFail($partner_id);
  18. } else {
  19. $uid = $message->getUid();
  20. $partner = PartnerModel::whereUid($uid)->firstOrFail();
  21. }
  22. /** @var PartnerModel $partner */
  23. $partnerManager = new PartnerManager();
  24. $message->setResponse($partnerManager->partnerUser($uid, $partner));
  25. }
  26. public function thumbPartner(ThumbPartnerMessage $message)
  27. {
  28. $uid = Auth::auth();
  29. $partnerId = $message->getPartnerId();
  30. $thumb = $message->getThumb();
  31. $ps = new \App\Services\User\PartnerService();
  32. $data = $ps->thumb($uid, $partnerId, $thumb);
  33. $message->setResponse($data);
  34. }
  35. public function lockLikeMe(LockLikeMeMessage $message)
  36. {
  37. $origin = $message->getOrigin() ?: 'supvip';
  38. $partnerId = $message->getPartnerId();
  39. $uid = Auth::auth();
  40. $ps = new \App\Services\User\PartnerService();
  41. if ($origin == 'app_sign') {
  42. $ps->appLockLikeMe($uid, $partnerId);
  43. } else {
  44. $ps->lockLikeme($uid, $partnerId);
  45. }
  46. }
  47. /**
  48. * 设置(开/关)隐身模式
  49. * @param SetPartnerSellMessage $message
  50. * @throws \App\Exceptions\AlertException
  51. */
  52. public function setPartnerSell(SetPartnerSellMessage $message)
  53. {
  54. $uid = Auth::auth();
  55. $sell = $message->getIs_sell();
  56. $user = UserModel::find($uid);
  57. $ups = new \App\Services\User\PartnerService();
  58. $ups->sell($user->partner_id, $sell);
  59. }
  60. }