room_id)
|| empty($request->day)
|| empty($request->uid)
) {
return [
'code' => 10005,
'msg' => '参数错误'
];
}
// uid -> 绑定openid
$openData = User::getOpenidByUid($request->uid);
// 期数,房间号,匹配对象uid
$roomModel = new RoomModel();
$room = $roomModel->getRoom($request->room_id, $request->uid);
// 匹配对象照片;
$pairUser = UserModel::find($room->member[0]);
// 任务及信息推送
switch ($request->day) {
case '1':
// 任务完成推送
$content = "你已经完成第一天的恋爱任务!解锁对方交友卡片,点此查看";
$array = [
'touser' => $openData['openid'],
'content' => $content,
'kf_account' => 'notice@admin'
];
Kfaccount::text($array);
break;
case '2':
if (!$pairUser->check_photo) {
break;
}
// 任务完成推送
$content = "你已经完成第二天的恋爱任务!解锁对方照片,点此查看";
$array = [
'touser' => $openData['openid'],
'content' => $content,
'kf_account' => 'notice@admin'
];
Kfaccount::text($array);
// 交友照片推送
$img = "http://oss.pocketuniversity.cn{$pairUser->photo_src}";
$response = Media::uploadImg($img);
if ($response['code'] == 0) {
Kfaccount::image($openData['openid'], ['media_id' => $response['data']['media_id']]);
} else {
return $response;
}
break;
case '3':
if (!$pairUser->check_contact) {
break;
}
// 任务完成推送
$content = "你已经完成第三天的恋爱任务!解锁对方联系方式,点此查看";
$array = [
'touser' => $openData['openid'],
'content' => $content,
'kf_account' => 'notice@admin'
];
Kfaccount::text($array);
// 联系方式推送
$content_1 = "TA的联系方式是:";
$content = "";
if ($pairUser->qq) {
$content .= "{$pairUser->qq}(QQ)|";
}
if ($pairUser->weixin) {
$content .= "{$pairUser->weixin}(微信)";
}
if (!empty($content)) {
$content = $content_1 . $content;
$array = [
'touser' => $openData['openid'],
'content' => $content,
'kf_account' => 'notice@admin'
];
Kfaccount::text($array);
break;
}
}
return [
'code' => 0,
'msg' => '成功'
];
}
/**
* 自动创建分配对象当前期cp任务
*/
public static function autoCreateCpTask()
{
$taskModel = new TaskModel();
$activitys = ActivityModel::getActivitys();
$stage_id = $activitys['next'];
$task = $taskModel->where('term', $stage_id)->first();
if (collect($task)->isEmpty()) {
$lastTask = $taskModel->where('term', $activitys['last'])->get();
if (collect($lastTask)->isEmpty()) {
Ding::robot([
'title' => '[分配对象]CP任务创建提醒',
'text' => "尝试创建分配对象第「{$stage_id}」期CP任务...\n没有找到上期任务...\n放弃创建\n"
]);
} else {
foreach ($lastTask as $value) {
$taskModel->create([
'data' => $value->data,
'term' => $stage_id,
'day' => $value->day
]);
}
Ding::robot([
'title' => '[分配对象]CP任务创建提醒',
'text' => "尝试创建分配对象第「{$stage_id}」期CP任务...\n创建成功\n"
]);
}
} else {
Ding::robot([
'title' => '[分配对象]CP任务创建提醒',
'text' => "尝试创建分配对象第「{$stage_id}」期CP任务...\n该任务易存在...\n放弃创建\n"
]);
}
}
}