55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\api\controller;
|
||
|
|
|
||
|
|
use app\common\controller\Api;
|
||
|
|
use app\common\model\IntimacyConfig as IntimacyConfigModel;
|
||
|
|
use app\common\model\IntimacyDay as IntimacyDayModel;
|
||
|
|
use app\common\model\IntimacyFriend as IntimacyFriendModel;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 会员接口
|
||
|
|
*/
|
||
|
|
class IntimacyConfig extends Api
|
||
|
|
{
|
||
|
|
protected $noNeedLogin = ['lists'];
|
||
|
|
protected $noNeedRight = '*';
|
||
|
|
|
||
|
|
|
||
|
|
/*
|
||
|
|
* 获取任务列表
|
||
|
|
*/
|
||
|
|
public function lists(){
|
||
|
|
$lists = IntimacyConfigModel::getList();
|
||
|
|
$this->success('获取成功',$lists);
|
||
|
|
}
|
||
|
|
|
||
|
|
/*
|
||
|
|
* 获取每日亲密度
|
||
|
|
*/
|
||
|
|
public function getDailyIntimacy(){
|
||
|
|
|
||
|
|
$user_id = $this->auth->id;
|
||
|
|
$friend_id = $this->request->post('friend_id','');
|
||
|
|
if (!$friend_id) $this->error('请选择好友');
|
||
|
|
|
||
|
|
//先获取每日亲密度任务
|
||
|
|
$lists = IntimacyDayModel::getList();
|
||
|
|
//在获取已完成的任务
|
||
|
|
$day = date('Y-m-d');
|
||
|
|
$friend_lists = IntimacyFriendModel::getList($user_id,$friend_id,$day);
|
||
|
|
foreach ($lists as $k=>&$v){
|
||
|
|
$v['intimacy'] = 0;
|
||
|
|
if (!empty($friend_lists)){
|
||
|
|
foreach ($friend_lists as $k1=>$v1){
|
||
|
|
if ($v['type'] == $v1['type']){
|
||
|
|
$v['intimacy'] = $v1['intimacy'];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$this->success('获取成功',$lists);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|