81 lines
2.0 KiB
PHP
81 lines
2.0 KiB
PHP
<?php
|
||
/*
|
||
* description:
|
||
* author:wh
|
||
* email:
|
||
* createTime:{2024/5/23} {0:06}
|
||
*/
|
||
|
||
namespace app\api\controller;
|
||
|
||
|
||
use app\common\model\TabConf;
|
||
use think\Db;
|
||
use wanghua\general_utility_tools_php\Mmodel;
|
||
use wanghua\general_utility_tools_php\tool\Tools;
|
||
|
||
/**
|
||
* 游戏道具
|
||
*
|
||
* Class Gameprop
|
||
* @package app\api\controller
|
||
*/
|
||
class Gameprop extends BaseHttpApi
|
||
{
|
||
|
||
/**
|
||
* desc:游戏道具已解锁、未解锁接口
|
||
* api/gameprop/getprop
|
||
* 参数:
|
||
*
|
||
* 返回:
|
||
* have_arr 已解锁
|
||
* no_arr 未解锁
|
||
*
|
||
* author:wh
|
||
*/
|
||
function getprop(){
|
||
return Mmodel::catchJson(function (){
|
||
$openid = api_user_openid();
|
||
//查询所有未获取的道具列表
|
||
$gameprop_list = Db::table(TabConf::$fa_gameprop)->select();
|
||
|
||
$have_arr = [];//已拥有
|
||
$no_arr = [];//未拥有
|
||
foreach ($gameprop_list as $item){
|
||
$tmp_arr = [];
|
||
$usergameprop = Db::table(TabConf::$fa_usergameprop)
|
||
->where('openid',$openid)
|
||
->where('gameprop_id',$item['id'])
|
||
->find();
|
||
if($usergameprop){
|
||
$tmp_arr['num'] = $usergameprop['num'];
|
||
//已拥有
|
||
$have_arr[] = array_merge($tmp_arr, $item);
|
||
}else{
|
||
//未拥有
|
||
$no_arr[] = $item;
|
||
}
|
||
}
|
||
|
||
return Tools::set_ok('ok',[
|
||
'have_arr'=>$have_arr,
|
||
'no_arr'=>$no_arr,
|
||
]);
|
||
});
|
||
}
|
||
|
||
/**
|
||
* desc:获取游戏道具列表(肥料等各种道具)
|
||
*
|
||
* api/gameprop/getGamePropList
|
||
*
|
||
* author:wh
|
||
*/
|
||
function getGamePropList(){
|
||
return Mmodel::catchJson(function (){
|
||
$gameprop_list = Db::table(TabConf::$fa_gameprop)->select();
|
||
return Tools::set_ok('ok',$gameprop_list);
|
||
});
|
||
}
|
||
} |