123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- namespace App\Jobs;
- use App\Models\Deed\FriendsModel;
- use App\Models\Partner\ThumbActionModel;
- use App\Models\PartnerModel;
- use App\Models\PraiseModel;
- use App\Models\User\SuperLikeModel;
- use App\Models\User\UserModel;
- use App\Services\Deed\FriendService;
- use Illuminate\Bus\Queueable;
- use Illuminate\Queue\SerializesModels;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- class StoreSelfPartnerJob implements ShouldQueue
- {
- use Dispatchable;
- use InteractsWithQueue;
- use Queueable;
- use SerializesModels;
- private $uid;
- /**
- * Create a new job instance.
- *
- * @param int $uid
- */
- public function __construct(int $uid)
- {
- $this->uid = $uid;
- }
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- $datas = ThumbActionModel::where([
- ['uid', $this->uid],
- ['thumb', 1]
- ])->get();
- foreach ($datas as $data) {
- try {
- list($uid, $partner_id) = array($data->uid, $data->partner_id);
- dump($uid, $partner_id);
- $user = UserModel::findOrFail($uid);
- $partner = PartnerModel::findOrFail($partner_id);
- $pm = new PraiseModel();
- $praise = $pm->where(array(['partner_id', $partner_id], ['uid', $uid]))->first();
- if (collect($praise)->isEmpty()) {
- $lock = 0;
- if (
- SuperLikeModel::where(array(
- ['uid', $partner->uid],
- ['partner_id', $user->partner_id]
- ))->exists()
- ) {
- SuperLikeModel::where(array(
- ['uid', $partner->uid],
- ['partner_id', $user->partner_id]
- ))->update(['reply_at' => time()]);
- $lock = 100;
- }
- if (FriendsModel::where(array(['uid', $uid], ['friend_uid', $partner->uid]))->exists()) {
- $pm->where(array(
- ['uid', $partner->uid],
- ['partner_id', $user->partner_id]
- ))->update(['lock' => 100]);
- $lock = 100;
- }
- $praise = $pm->fill([
- 'create_at' => time(),
- 'created_at' => $data->created_at->timestamp,
- 'updated_at' => $data->updated_at->timestamp,
- 'partner_id' => $partner_id,
- 'uid' => $uid,
- 'type' => 1,
- 'read' => 0,
- 'lock' => $lock
- ]);
- PartnerModel::where('id', $partner_id)->increment('praises', 1);
- // 检验相互喜欢
- $fs = new FriendService();
- if ($datauser = $fs->eachlike($uid, $partner_id, 1)) {
- $res['eachlike'] = true;
- $res['user'] = $datauser;
- $praise->lock = 100;
- $pm->where(array(
- ['uid', $partner->uid],
- ['partner_id', $user->partner_id]
- ))->update(['lock' => 100]);
- }
- // 点赞我通知
- $ns = new \App\Services\User\NoticeService();
- $ns->thumbMe($uid, $partner_id);
- $praise->save();
- }
- $data->thumb = 0;
- $data->save();
- } catch (\Exception $exception) {
- continue;
- }
- }
- }
- }
|