Files
digital_doctor/digital_doctor/application/api/controller/Gameprop.php
2024-07-10 17:40:31 +08:00

81 lines
2.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/*
* description
* authorwh
* 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 未解锁
*
* authorwh
*/
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
*
* authorwh
*/
function getGamePropList(){
return Mmodel::catchJson(function (){
$gameprop_list = Db::table(TabConf::$fa_gameprop)->select();
return Tools::set_ok('ok',$gameprop_list);
});
}
}