更新
This commit is contained in:
371
application/adminapi/controller/RoomHourRanking.php
Normal file
371
application/adminapi/controller/RoomHourRanking.php
Normal file
@@ -0,0 +1,371 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\adminapi\controller;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
|
class RoomHourRanking
|
||||||
|
{
|
||||||
|
public static function withdraw_status (){
|
||||||
|
return [
|
||||||
|
// [25 => '全时段'],
|
||||||
|
[0 => '00:00-01:00'],
|
||||||
|
[1 => '01:00-02:00'],
|
||||||
|
[2 => '02:00-03:00'],
|
||||||
|
[3 => '03:00-04:00'],
|
||||||
|
[4 => '04:00-05:00'],
|
||||||
|
[5 => '05:00-06:00'],
|
||||||
|
[6 => '06:00-07:00'],
|
||||||
|
[7 => '07:00-08:00'],
|
||||||
|
[8 => '08:00-09:00'],
|
||||||
|
[9 => '09:00-10:00'],
|
||||||
|
[10 => '10:00-11:00'],
|
||||||
|
[11 => '11:00-12:00'],
|
||||||
|
[12 => '12:00-13:00'],
|
||||||
|
[13 => '13:00-14:00'],
|
||||||
|
[14 => '14:00-15:00'],
|
||||||
|
[15 => '15:00-16:00'],
|
||||||
|
[16 => '16:00-17:00'],
|
||||||
|
[17 => '17:00-18:00'],
|
||||||
|
[18 => '18:00-19:00'],
|
||||||
|
[19 => '19:00-20:00'],
|
||||||
|
[20 => '20:00-21:00'],
|
||||||
|
[21 => '21:00-22:00'],
|
||||||
|
[22 => '22:00-23:00'],
|
||||||
|
[23 => '23:00-00:00'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//房间小时榜列表
|
||||||
|
public function room_hour_ranking()
|
||||||
|
{
|
||||||
|
$page = input('page', 1);
|
||||||
|
$page_limit = input('page_limit', 20);
|
||||||
|
$search_ranking = input('search_ranking', '');
|
||||||
|
$search_stime = input('search_stime', '');
|
||||||
|
$search_etime = input('search_etime', '');
|
||||||
|
$where = [];
|
||||||
|
if ($search_ranking) {
|
||||||
|
$where[] = ['room_name', 'like', '%' . $search_ranking . '%'];
|
||||||
|
}
|
||||||
|
if ($search_stime) {
|
||||||
|
$where[] = ['stime', '>=', $search_stime];
|
||||||
|
}
|
||||||
|
if ($search_etime) {
|
||||||
|
$where[] = ['etime', '<=', $search_etime];
|
||||||
|
}
|
||||||
|
$count = db::name('vs_hour_ranking')->where($where)->count();
|
||||||
|
$list = db::name('vs_hour_ranking')->where($where)->page($page, $page_limit)->order('id desc')->select();
|
||||||
|
if($list){
|
||||||
|
foreach ($list as &$v){
|
||||||
|
$v['room_name'] = db::name('vs_room')->where(['id'=>$v['room_id']])->value('room_name');
|
||||||
|
$v['user_id'] = db::name('vs_room')->where(['id'=>$v['room_id']])->value('user_id');
|
||||||
|
if($v['user_id']){
|
||||||
|
$v['nickname'] = db::name('user')->where(['id'=>$v['user_id']])->value('nickname');
|
||||||
|
}
|
||||||
|
$v['stime'] = date('Y-m-d H:i', $v['stime']);
|
||||||
|
$v['etime'] = date('Y-m-d H:i', $v['etime']);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$return_data = [
|
||||||
|
'page' =>$page,
|
||||||
|
'page_limit' => $page_limit,
|
||||||
|
'count' => $count,
|
||||||
|
'lists' => $list
|
||||||
|
];
|
||||||
|
return V(1,"成功", $return_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//房间小时榜配置
|
||||||
|
public function room_hour_ranking_config()
|
||||||
|
{
|
||||||
|
$list = db::name('vs_hour_ranking_config')->where('id', '1')->find();
|
||||||
|
if($list){
|
||||||
|
//open_time 字段转化为2025-09-30 07:00 的格式
|
||||||
|
$list['open_time'] = $list['open_time'] ? date('Y-m-d H:i', $list['open_time']) : 0;
|
||||||
|
}
|
||||||
|
return V(1,"成功", $list);
|
||||||
|
}
|
||||||
|
|
||||||
|
//房间小时榜配置修改
|
||||||
|
public function room_hour_ranking_config_edit()
|
||||||
|
{
|
||||||
|
$id = input('id');
|
||||||
|
$data['is_open_red_pack'] = 0;//暂时不开启
|
||||||
|
$data['is_public_server'] = input('is_public_server');
|
||||||
|
$data['broadcast_times'] = input('broadcast_times');
|
||||||
|
$data['is_open_xlh'] = input('is_open_xlh');
|
||||||
|
$data['min_price'] = input('min_price');
|
||||||
|
$open_time = input('open_time');
|
||||||
|
$data['open_time'] = $open_time ? strtotime($open_time) : 0;
|
||||||
|
$data['createtime'] = time();
|
||||||
|
$data['updatetime'] = time();
|
||||||
|
|
||||||
|
$timeSlots = json_decode(input('timeJson'), true);
|
||||||
|
|
||||||
|
$timePeriods = $this->withdraw_status();
|
||||||
|
|
||||||
|
// 构建正确的时间映射关系
|
||||||
|
$timeMap = [];
|
||||||
|
foreach($timePeriods as $period) {
|
||||||
|
foreach($period as $key => $value) {
|
||||||
|
$timeMap[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//$timeMap 里面 键值互换
|
||||||
|
$timeMap = array_flip($timeMap);
|
||||||
|
//开启事务
|
||||||
|
db::startTrans();
|
||||||
|
if($timeSlots){
|
||||||
|
$insertData = [];
|
||||||
|
foreach ($timeSlots as $timeSlot) {
|
||||||
|
// $timeRange = ;
|
||||||
|
$timeRange = $timeMap[$timeSlot['time']] ?? '99';
|
||||||
|
|
||||||
|
foreach ($timeSlot['reward'] as $rewardItem) {
|
||||||
|
$hasReward = !empty($rewardItem['content']);
|
||||||
|
|
||||||
|
if ($hasReward) {
|
||||||
|
// 有奖励内容:为每个奖励内容创建一条记录
|
||||||
|
foreach ($rewardItem['content'] as $rewardContent) {
|
||||||
|
if($rewardContent['type'] == 0){
|
||||||
|
$coin = $rewardContent['value'];
|
||||||
|
$gift_id = 0;
|
||||||
|
$gift_name = '';
|
||||||
|
}else{
|
||||||
|
$coin = 0;
|
||||||
|
$gift_id = $rewardContent['value'];
|
||||||
|
$gift_name = $rewardContent['name'];
|
||||||
|
}
|
||||||
|
$insertData[] = [
|
||||||
|
'time_id' => $timeRange,
|
||||||
|
'ranking' => $rewardItem['index'],
|
||||||
|
// 'rank_name' => $rewardItem['name'],
|
||||||
|
'gift_type' => $rewardContent['type'],
|
||||||
|
'gift_id' => $gift_id,
|
||||||
|
'coin' => $coin,
|
||||||
|
'name' => $gift_name,
|
||||||
|
'createtime' => time()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 无奖励内容:插入一条空奖励记录
|
||||||
|
$insertData[] = [
|
||||||
|
'time_id' => $timeRange,
|
||||||
|
'ranking' => $rewardItem['index'],
|
||||||
|
// 'rank_name' => $rewardItem['name'],
|
||||||
|
'gift_type' => 0,
|
||||||
|
'gift_id' => 0,
|
||||||
|
'coin' => 0,
|
||||||
|
'name' => '',
|
||||||
|
'createtime' => time(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量插入
|
||||||
|
if (!empty($insertData)) {
|
||||||
|
$del = db::name('vs_hour_ranking_gift_config')->where('id','>',0)->delete();
|
||||||
|
$ins = db::name('vs_hour_ranking_gift_config')->insertAll($insertData);
|
||||||
|
}else{
|
||||||
|
$ins = false;
|
||||||
|
$del = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$del = true;
|
||||||
|
$ins = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $res = db::name('vs_hour_ranking_config')->where('id', $id)->update($data);
|
||||||
|
$res = db::name('vs_hour_ranking_config')->where('id', $id)->update($data);
|
||||||
|
// if ($del && $ins && $res) {
|
||||||
|
if ($ins) {
|
||||||
|
db::commit();
|
||||||
|
return V(1, "成功");
|
||||||
|
} else {
|
||||||
|
db::rollback();
|
||||||
|
return V(0, "失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//时间段对应关系
|
||||||
|
public function time_period_correspondence()
|
||||||
|
{
|
||||||
|
$list = $this->withdraw_status();
|
||||||
|
$timePeriods = $this->withdraw_status();
|
||||||
|
$timeMap = [];
|
||||||
|
foreach($timePeriods as $period) {
|
||||||
|
foreach($period as $key => $value) {
|
||||||
|
$timeMap[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return V(1,"成功", $timeMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//添加核心配置
|
||||||
|
public function add_core_config()
|
||||||
|
{
|
||||||
|
$data['is_public_server'] = input('is_public_server');
|
||||||
|
$data['createtime'] = time();
|
||||||
|
$data['updatetime'] = time();
|
||||||
|
|
||||||
|
|
||||||
|
$res = db::name('vs_hour_ranking_config')->insert($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//核心配置列表
|
||||||
|
public function core_config_list()
|
||||||
|
{
|
||||||
|
$timePeriods = $this->withdraw_status();
|
||||||
|
|
||||||
|
// 构建正确的时间映射关系
|
||||||
|
$timeMap = [];
|
||||||
|
foreach($timePeriods as $period) {
|
||||||
|
foreach($period as $key => $value) {
|
||||||
|
$timeMap[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 先按时间段和排名索引分组查询
|
||||||
|
$timeRanges = db::name('vs_hour_ranking_gift_config')->distinct(true)
|
||||||
|
->order('time_id')
|
||||||
|
->column('time_id');
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
foreach ($timeRanges as $timeRange) {
|
||||||
|
// 查询该时间段的所有数据
|
||||||
|
$rewards = db::name('vs_hour_ranking_gift_config')->where('time_id', $timeRange)
|
||||||
|
->field('ranking, gift_type, gift_id,coin,name')
|
||||||
|
->order('ranking')
|
||||||
|
->select();
|
||||||
|
|
||||||
|
$rewardMap = [];
|
||||||
|
foreach ($rewards as $reward) {
|
||||||
|
$rankIndex = $reward['ranking'];
|
||||||
|
|
||||||
|
if (!isset($rewardMap[$rankIndex])) {
|
||||||
|
$rewardMap[$rankIndex] = [
|
||||||
|
'index' => $rankIndex,
|
||||||
|
// 'name' => $reward['rank_name'],
|
||||||
|
'content' => []
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加奖励内容到content数组
|
||||||
|
if ($reward['gift_id'] != 0 || $reward['coin'] != 0) {
|
||||||
|
if($reward['gift_id'] != 0){
|
||||||
|
$rewardMap[$rankIndex]['content'][] = [
|
||||||
|
'type' => $reward['gift_type'],
|
||||||
|
'value' => $reward['gift_id'],
|
||||||
|
// 'coin' => $reward['coin'],
|
||||||
|
'name' => $reward['name'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if($reward['coin'] != 0){
|
||||||
|
$rewardMap[$rankIndex]['content'][] = [
|
||||||
|
'type' => $reward['gift_type'],
|
||||||
|
'value' => $reward['coin'],
|
||||||
|
'name' => $reward['name'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按index排序
|
||||||
|
ksort($rewardMap);
|
||||||
|
|
||||||
|
$result[] = [
|
||||||
|
'time' => $timeMap[$timeRange],
|
||||||
|
'reward' => array_values($rewardMap)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return V(1, "成功", $result);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// public function core_config_lists()
|
||||||
|
// {
|
||||||
|
// $list = db::name('vs_hour_ranking_gift_config')->select();
|
||||||
|
// $data = [];
|
||||||
|
//
|
||||||
|
// // 按 time_id 和 ranking 重组数据
|
||||||
|
// $reorganizedData = [];
|
||||||
|
// $timePeriods = $this->withdraw_status();
|
||||||
|
//
|
||||||
|
// // 构建正确的时间映射关系
|
||||||
|
// $timeMap = [];
|
||||||
|
// foreach($timePeriods as $period) {
|
||||||
|
// foreach($period as $key => $value) {
|
||||||
|
// $timeMap[$key] = $value;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// foreach ($list as $item) {
|
||||||
|
//// $timeId = $item['time_id'];
|
||||||
|
// $timeId = $timeMap[$item['time_id']] ?? '未知时间段';
|
||||||
|
// $ranking = $item['ranking'];
|
||||||
|
//
|
||||||
|
// $gift_name = '';
|
||||||
|
// if (!isset($reorganizedData[$timeId])) {
|
||||||
|
// $reorganizedData[$timeId] = [];
|
||||||
|
// }
|
||||||
|
// if (!isset($reorganizedData[$timeId][$ranking])) {
|
||||||
|
// $reorganizedData[$timeId][$ranking] = [];
|
||||||
|
// }
|
||||||
|
// if($item['gift_id']){
|
||||||
|
// if($item['gift_type'] == 2){
|
||||||
|
// $gift_name = db::name('vs_gift')->where(['gid'=>$item['gift_id']])->value('gift_name');
|
||||||
|
// }
|
||||||
|
// if($item['gift_type'] == 3 || $item['gift_type'] == 4){
|
||||||
|
// $gift_name = db::name('vs_decorate')->where(['did'=>$item['gift_id']])->value('title');
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }else{
|
||||||
|
// $gift_name = '';
|
||||||
|
// }
|
||||||
|
// $reorganizedData[$timeId][$ranking][] = [
|
||||||
|
// 'gift_type' => $item['gift_type'],
|
||||||
|
// 'gift_id' => $item['gift_id'],
|
||||||
|
// 'gift_name' => $gift_name,
|
||||||
|
// 'coin' => $item['coin']
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 输出重组后的数据
|
||||||
|
// print_r($reorganizedData);
|
||||||
|
// return V(1, "成功", $data);
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
131
application/api/controller/BlindBoxTurntable.php
Normal file
131
application/api/controller/BlindBoxTurntable.php
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use app\common\controller\BaseCom;
|
||||||
|
use think\Controller;
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 盲盒转盘
|
||||||
|
* 2025-08-16
|
||||||
|
*/
|
||||||
|
|
||||||
|
class BlindBoxTurntable extends BaseCom
|
||||||
|
{
|
||||||
|
protected function initialize()
|
||||||
|
{
|
||||||
|
//允许跨域
|
||||||
|
header('Access-Control-Allow-Origin: *');
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 获取活动奖池礼物列表
|
||||||
|
*/
|
||||||
|
public function get_gift_list(){
|
||||||
|
$gift_bag_id = input('gift_bag_id',0);
|
||||||
|
$room_id = input('room_id',0);
|
||||||
|
$reslut = model('BlindBoxTurntableGift')->get_gift_list($gift_bag_id,$room_id);
|
||||||
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 抽奖
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function draw_gift(){
|
||||||
|
$gift_bag_id = input('gift_bag_id',0);
|
||||||
|
$user_id = $this->uid;
|
||||||
|
$room_id = input('room_id',0);
|
||||||
|
$gift_user_ids = input('gift_user_ids',0);
|
||||||
|
$num = input('num',1);
|
||||||
|
$heart_id = input('heart_id',0);
|
||||||
|
$auction_id = input('auction_id',0);
|
||||||
|
$reslut = model('BlindBoxTurntableGiftDrawWorld')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id,$auction_id);
|
||||||
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 礼物发放
|
||||||
|
*/
|
||||||
|
public function gift_send(){
|
||||||
|
// $key_name = "api:blind_box_turntable:gift_send:" . $this->uid;
|
||||||
|
// redis_lock_exit($key_name);
|
||||||
|
$send_id = input('send_id',0);
|
||||||
|
$reslut = model('BlindBoxTurntableGift')->gift_send($send_id);
|
||||||
|
// redis_unlock($key_name);
|
||||||
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 获取我的抽奖记录
|
||||||
|
*/
|
||||||
|
public function get_my_record(){
|
||||||
|
$user_id = $this->uid;
|
||||||
|
$gift_bag_id = input('gift_bag_id',0);
|
||||||
|
$page = input('page',1);
|
||||||
|
$page_size = input('page_size',12);
|
||||||
|
$reslut = model('BlindBoxTurntableGift')->get_user_record($gift_bag_id,$user_id,$page,$page_size);
|
||||||
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 获取全服抽奖记录
|
||||||
|
*/
|
||||||
|
public function get_all_record(){
|
||||||
|
$gift_bag_id = input('gift_bag_id',0);
|
||||||
|
$page = input('page',1);
|
||||||
|
$page_size = input('page_size',12);
|
||||||
|
$reslut = model('BlindBoxTurntableGift')->get_all_record($gift_bag_id,$page,$page_size);
|
||||||
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 巡乐会
|
||||||
|
*/
|
||||||
|
public function xlh(){
|
||||||
|
$room_id = input('room_id',0);
|
||||||
|
$reslut = model('BlindBoxTurntableGift')->xlh_gift_list($room_id);
|
||||||
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 巡乐会抽奖
|
||||||
|
*/
|
||||||
|
public function xlh_draw_gift(){
|
||||||
|
$user_id = $this->uid;
|
||||||
|
$room_id = input('room_id',0);
|
||||||
|
$num = input('num',1);
|
||||||
|
$reslut = model('BlindBoxTurntableGiftDrawWorld')->xlh_draw_gift($user_id,$num,$room_id);
|
||||||
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 获取我的巡乐会记录
|
||||||
|
*/
|
||||||
|
public function get_xlh_my_record(){
|
||||||
|
$page = input('page',1);
|
||||||
|
$page_size = input('page_size',12);
|
||||||
|
$user_id = $this->uid;
|
||||||
|
$room_id = input('room_id',0);
|
||||||
|
$reslut = model('BlindBoxTurntableGift')->xlh_get_user_record($user_id,$room_id,$page,$page_size);
|
||||||
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 获取全服巡乐会记录(榜单)
|
||||||
|
*/
|
||||||
|
public function get_xlh_all_record(){
|
||||||
|
$page = input('page',1);
|
||||||
|
$page_size = input('page_size',12);
|
||||||
|
$room_id = input('room_id',0);
|
||||||
|
$reslut = model('BlindBoxTurntableGift')->xlh_ranking($room_id,$page,$page_size);
|
||||||
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 巡乐会榜单 (以期数显示)
|
||||||
|
*/
|
||||||
|
public function get_xlh_ranking(){
|
||||||
|
$page = input('page',1);
|
||||||
|
$page_size = input('page_size',12);
|
||||||
|
$room_id = input('room_id',0);
|
||||||
|
$reslut = model('BlindBoxTurntableGift')->xlh_ranking_list($room_id,$page,$page_size);
|
||||||
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
}
|
||||||
65
application/api/controller/Friend.php
Normal file
65
application/api/controller/Friend.php
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use app\common\controller\BaseCom;
|
||||||
|
|
||||||
|
class Friend extends BaseCom
|
||||||
|
{
|
||||||
|
//交友开始
|
||||||
|
public function start_friend(){
|
||||||
|
$key_name = "api:friend:start_friend:" . $this->uid;
|
||||||
|
redis_lock_exits($key_name);
|
||||||
|
$room_id = input('room_id', '');
|
||||||
|
$reslut = model('Friend')->start_friend($this->uid,$room_id);
|
||||||
|
redis_unlocks($key_name);
|
||||||
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//交友延时
|
||||||
|
public function delay(){
|
||||||
|
$friend_id = input('friend_id', '');
|
||||||
|
$room_id = input('room_id', '');
|
||||||
|
$delay_times = input('delay_times', '');//分钟
|
||||||
|
|
||||||
|
$reslut = model('Friend')->delay($this->uid,$room_id,$friend_id,$delay_times);
|
||||||
|
|
||||||
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//交友结束
|
||||||
|
public function end_friend(){
|
||||||
|
|
||||||
|
$friend_id = input('friend_id', '');
|
||||||
|
$room_id = input('room_id', '');
|
||||||
|
|
||||||
|
$result = model('Friend')->end_friend($this->uid,$room_id,$friend_id);
|
||||||
|
|
||||||
|
return V($result['code'], $result['msg'], $result['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//卡关系 创建关系
|
||||||
|
public function create_relation()
|
||||||
|
{
|
||||||
|
$key_name = "api:friend:create_relation:" . $this->uid;
|
||||||
|
redis_lock_exits($key_name);
|
||||||
|
$room_id = input('room_id', '');
|
||||||
|
$friend_id = input('friend_id', '');
|
||||||
|
$user1_id = input('user1_id', '');
|
||||||
|
$user2_id = input('user2_id', '');
|
||||||
|
$relation_id = input('relation_id', '');
|
||||||
|
$result = model('Friend')->createRelation($this->uid,$room_id,$friend_id,$user1_id,$user2_id,$relation_id);
|
||||||
|
redis_unlocks($key_name);
|
||||||
|
return V($result['code'], $result['msg'], $result['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//退出私密小屋
|
||||||
|
public function out_room()
|
||||||
|
{
|
||||||
|
$room_id = input('room_id', '');
|
||||||
|
|
||||||
|
$result = model('Friend')->outRoom($this->uid,$room_id);
|
||||||
|
|
||||||
|
return V($result['code'], $result['msg'], $result['data']);
|
||||||
|
}
|
||||||
|
}
|
||||||
119
application/api/controller/Redpacket.php
Normal file
119
application/api/controller/Redpacket.php
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use app\common\controller\BaseCom;
|
||||||
|
use app\common\service\RedpacketService;
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 红包接口
|
||||||
|
*/
|
||||||
|
class Redpacket extends BaseCom
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发红包
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$data = $this->request->post();
|
||||||
|
|
||||||
|
$data['user_id'] = $this->uid;
|
||||||
|
|
||||||
|
$service = new RedpacketService();
|
||||||
|
$reslut = $service->create($data);
|
||||||
|
|
||||||
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抢红包
|
||||||
|
*/
|
||||||
|
public function grab()
|
||||||
|
{
|
||||||
|
$redpacketId = input('redpacket_id', 0);
|
||||||
|
|
||||||
|
if (empty($redpacketId)) {
|
||||||
|
return V(0, '红包ID不能为空');
|
||||||
|
}
|
||||||
|
|
||||||
|
$service = new RedpacketService();
|
||||||
|
// 在抢红包前确保状态正确
|
||||||
|
$service->checkAndUpdateRedpacketStatus($redpacketId);
|
||||||
|
$reslut = $service->grabWithResult($redpacketId, $this->uid);
|
||||||
|
|
||||||
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取抢红包结果
|
||||||
|
*/
|
||||||
|
public function grabResult()
|
||||||
|
{
|
||||||
|
$redpacketId = $this->request->get('redpacket_id');
|
||||||
|
|
||||||
|
if (empty($redpacketId)) {
|
||||||
|
return V(0, '红包ID不能为空');
|
||||||
|
}
|
||||||
|
|
||||||
|
$service = new RedpacketService();
|
||||||
|
$result = $service->getGrabResult($redpacketId, $this->uid);
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
return V(0, '红包不存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
return V(1, '获取成功', $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 红包详情
|
||||||
|
*/
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
$redpacketId = input('redpacket_id', 0);
|
||||||
|
|
||||||
|
if (empty($redpacketId)) {
|
||||||
|
return V(0, '红包ID不能为空');
|
||||||
|
}
|
||||||
|
|
||||||
|
$service = new RedpacketService();
|
||||||
|
// 在获取详情前确保状态正确
|
||||||
|
$service->checkAndUpdateRedpacketStatus($redpacketId);
|
||||||
|
$detail = $service->getDetail($redpacketId, $this->uid);
|
||||||
|
|
||||||
|
if (!$detail) {
|
||||||
|
return V(0, '红包不存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
return V(1, '获取成功', $detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取倒计时选项
|
||||||
|
*/
|
||||||
|
public function countdownOptions()
|
||||||
|
{
|
||||||
|
$options = \app\common\model\Redpacket::$countdownOptions;
|
||||||
|
$this->success('获取成功', $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取房间内红包列表
|
||||||
|
public function roomRedPackets()
|
||||||
|
{
|
||||||
|
$roomId = $this->request->get('room_id');
|
||||||
|
$result = Db::name('redpacket')->where(['room_id' => $roomId, 'status' => ['<=',1]])->select();
|
||||||
|
if($result){
|
||||||
|
foreach ($result as &$item) {
|
||||||
|
$item['redpacket_id'] = $item['id'];
|
||||||
|
$item['redpacket_time'] = get_system_config_value('red_packet_time');//展示时间
|
||||||
|
$item['nickname'] = Db::name('user')->where('id', $item['user_id'])->value('nickname');
|
||||||
|
$item['avatar'] = Db::name('user')->where('id', $item['user_id'])->value('avatar');
|
||||||
|
$is_qiang = Db::name('redpacket_record')->where(['redpacket_id' => $item['id'], 'user_id' => $this->uid])->find();
|
||||||
|
$item['is_qiang'] = $is_qiang ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return V(1, '获取成功', $result);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
application/api/controller/RoomHourRanking.php
Normal file
34
application/api/controller/RoomHourRanking.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use app\common\controller\BaseCom;
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
|
class RoomHourRanking extends BaseCom
|
||||||
|
{
|
||||||
|
//房间小时榜是否开启
|
||||||
|
public function room_hour_ranking_is_open()
|
||||||
|
{
|
||||||
|
$open_time = db::name('vs_hour_ranking_config')->order('id', 'desc')->value('open_time');
|
||||||
|
return V(1, '获取成功', ['open_time' => $open_time]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//房间小时榜玩法
|
||||||
|
public function room_hour_ranking_play()
|
||||||
|
{
|
||||||
|
$introd = db::name('vs_hour_ranking_config')->order('id', 'desc')->value('introd');
|
||||||
|
return V(1, '获取成功', ['introd' => $introd]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//房间小时榜
|
||||||
|
public function room_hour_ranking()
|
||||||
|
{
|
||||||
|
$page = input('page', 1);
|
||||||
|
$page_limit = input('page_limit', 20);
|
||||||
|
|
||||||
|
$reslut = model('RoomHourRanking')->room_hour_ranking($page, $page_limit);
|
||||||
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
39
application/api/controller/Xintiao.php
Normal file
39
application/api/controller/Xintiao.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use think\Controller;
|
||||||
|
use think\Db;
|
||||||
|
use think\Log;
|
||||||
|
|
||||||
|
use app\common\controller\BaseCom;
|
||||||
|
|
||||||
|
class Xintiao extends BaseCom
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public function keep_xintiao()
|
||||||
|
{
|
||||||
|
$user_id = $this->uid;
|
||||||
|
$is_xintiao = db::name('vs_xintiao')->where('user_id' , $user_id)->find();
|
||||||
|
if($is_xintiao){
|
||||||
|
db::name('vs_xintiao')->where('user_id' , $user_id)->update(['updatetime' => time()]);
|
||||||
|
}else{
|
||||||
|
db::name('vs_xintiao')->insert([
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'createtime' => time(),
|
||||||
|
'updatetime' => time()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
434
application/api/controller/Xxiaoshi.php
Normal file
434
application/api/controller/Xxiaoshi.php
Normal file
@@ -0,0 +1,434 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use think\Controller;
|
||||||
|
use think\Db;
|
||||||
|
use think\Log;
|
||||||
|
|
||||||
|
use app\common\controller\Push;
|
||||||
|
|
||||||
|
class Xxiaoshi extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public function send_gift()
|
||||||
|
{
|
||||||
|
//获取上一个小时的开始时间和结束时间
|
||||||
|
$start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour')));
|
||||||
|
$end_time = strtotime(date('Y-m-d H:00:00'));
|
||||||
|
echo "开始时间:" .$start_time."\n";
|
||||||
|
echo "结束时间:" .$end_time."\n";
|
||||||
|
//当前小时的前一个小时(24小时计时法,0-23)
|
||||||
|
$pre_hour = date('H', strtotime('-1 hour'));
|
||||||
|
echo "上个时间段:" .$pre_hour."\n";
|
||||||
|
$is_open_time = db::name('vs_hour_ranking_config')->where('id', 1)->value('open_time');
|
||||||
|
if ($is_open_time == 0) {
|
||||||
|
echo "未开启时间段:" .$is_open_time."\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//是否全局飘瓶
|
||||||
|
$is_public_server = db::name('vs_hour_ranking_config')->where('id', 1)->value('is_public_server');
|
||||||
|
if ($is_public_server == 1) {
|
||||||
|
//全局飘瓶时间段
|
||||||
|
$xlh_time_range = db::name('vs_hour_ranking_config')->where('id', 1)->value('broadcast_times');
|
||||||
|
if($xlh_time_range){
|
||||||
|
if($xlh_time_range == 25){
|
||||||
|
$is_piao = 1;
|
||||||
|
}else{
|
||||||
|
|
||||||
|
//当前的前一个小时是否在 $xlh_time_range中
|
||||||
|
if (in_array($pre_hour, explode(',', $xlh_time_range))) {
|
||||||
|
$is_piao = 1;
|
||||||
|
} else {
|
||||||
|
$is_piao = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$is_piao = 0;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$is_piao = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取上一个时间段的配置
|
||||||
|
// $gift_list = db::name('vs_hour_ranking_gift_config')->where('time_id',$pre_hour)->group('ranking')->order('id', 'desc')->select();
|
||||||
|
$gift_list = $this->get_hour_ranking($pre_hour);
|
||||||
|
// echo "上个时间段的配置:" .json_encode($gift_list)."\n";
|
||||||
|
// 提取所有有奖励的内容
|
||||||
|
$allRewards = $this->extractAllRewards($gift_list);
|
||||||
|
// 按index分组
|
||||||
|
$groupedRewards = $this->groupRewardsByIndex($allRewards);
|
||||||
|
// 按名次顺序分配奖励
|
||||||
|
$distributionResult = $this->distributeByRank($groupedRewards);
|
||||||
|
|
||||||
|
//获取上个数组的个数,从而获取配置了多少个名次
|
||||||
|
$count = count($distributionResult);
|
||||||
|
echo "上个时间段的配置总数:" .$count."\n";
|
||||||
|
//获取前一个小时的 前$count名房间排行
|
||||||
|
$room_list = model('api/RoomHourRanking')->room_hour_ranking(1, $count, $start_time, $end_time);
|
||||||
|
$room_owner = [];
|
||||||
|
if ($room_list['code'] == 1) {
|
||||||
|
//获取房间排行奖励最低值
|
||||||
|
$min_price = db::name('vs_hour_ranking_config')->where('id', 1)->value('min_price');
|
||||||
|
if ($room_list['data']['lists']) {
|
||||||
|
echo "房间列表:" .json_encode($room_list['data']['lists'])."\n";
|
||||||
|
foreach ($room_list['data']['lists'] as $v){
|
||||||
|
if ($v['total_price'] >= $min_price) {
|
||||||
|
$room_owner[] = [
|
||||||
|
'user_id' => $v['user_id'],
|
||||||
|
'room_name' => $v['room_name'],
|
||||||
|
'room_id' => $v['room_id'],
|
||||||
|
'total_price' => $v['total_price']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($distributionResult && $room_owner) {
|
||||||
|
$text_list_new = [];
|
||||||
|
echo "礼物数:" .json_encode($distributionResult)."\n";
|
||||||
|
echo "房主:" .json_encode($room_owner)."\n";
|
||||||
|
foreach ($distributionResult as $k => $value) {
|
||||||
|
//礼物全部给他偷偷放在装扮表及金额 中
|
||||||
|
//有几个用户就发几个
|
||||||
|
if(count($room_owner) > $k){
|
||||||
|
// 为每个房间添加一个标志,表示是否已处理推送信息
|
||||||
|
$hasProcessedPush = false;
|
||||||
|
|
||||||
|
foreach ($value['rewards'] as $v){
|
||||||
|
// if($v['type'] == 0){//1金币2礼物3头像4坐骑
|
||||||
|
// echo "发金币:" .$v['value'].'==>'.$room_owner[$k]['user_id']."\n";
|
||||||
|
// $res = $this->add_coin($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao);
|
||||||
|
// }elseif ($v['type'] == 1){
|
||||||
|
// echo "发礼物:" .$v['value'].'==>'.$room_owner[$k]['user_id']."\n";
|
||||||
|
// $res = $this->add_gift($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao);
|
||||||
|
// }elseif ($v['type'] == 2){
|
||||||
|
// $res = $this->add_decorate($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao,3);
|
||||||
|
// }elseif ($v['type'] == 3){
|
||||||
|
// $res = $this->add_decorate($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao,4);
|
||||||
|
// }
|
||||||
|
// 只有在第一次处理奖励时添加推送信息,避免重复推送
|
||||||
|
if(!$hasProcessedPush && $is_piao == 1) {
|
||||||
|
$room_name = $room_owner[$k]['room_name'];
|
||||||
|
//推送礼物横幅
|
||||||
|
if ($k == 0) {
|
||||||
|
$text = '新科状元!【' . $room_name . '】独占鳌头!';
|
||||||
|
} elseif ($k == 1) {
|
||||||
|
$text = '金榜榜眼!【' . $room_name . '】才气逼人!';
|
||||||
|
} elseif ($k == 2) {
|
||||||
|
$text = '风采探花!【' . $room_name . '】实力绽放!';
|
||||||
|
}
|
||||||
|
|
||||||
|
$text_list_new[] = [
|
||||||
|
'text' => $text ?? '恭喜【' . $room_name . '】获得礼物!',
|
||||||
|
'room_id' => $room_owner[$k]['room_id'],
|
||||||
|
'room_name' => $room_name,
|
||||||
|
'rank_number' => $k + 1,
|
||||||
|
];
|
||||||
|
|
||||||
|
$hasProcessedPush = true; // 标记已处理推送
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!empty($text_list_new)){
|
||||||
|
$push = new Push();
|
||||||
|
$push->hourRankingcs($text_list_new);
|
||||||
|
Log::record("小时榜推送:".json_encode($text_list_new),"infos");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "送礼-共" . count($room_owner) . "个房间房主获益\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加金币到钱包
|
||||||
|
// public function add_coin($coin,$user_id,$ranking,$room_id,$total_price,$is_piao){
|
||||||
|
// if($coin > 0){
|
||||||
|
// $data = [
|
||||||
|
// 'user_id' => $user_id,
|
||||||
|
// 'change_value' => $coin,
|
||||||
|
// // 'room_id' => $room_ids,
|
||||||
|
// 'money_type' => 1,
|
||||||
|
// 'change_type' => 27,
|
||||||
|
// 'from_id' => 0,
|
||||||
|
// 'remarks' => '小时榜获得',
|
||||||
|
// 'createtime' => time()
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// //开启事务
|
||||||
|
// Db::startTrans();
|
||||||
|
// $res = Db::name('vs_user_money_log')->insert($data);
|
||||||
|
// if(!$res){
|
||||||
|
// Db::rollback();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //增加用户金币
|
||||||
|
// $res1 = Db::name('user_wallet')->where(['user_id'=>$user_id])->setInc('coin',$coin);
|
||||||
|
// if(!$res1){
|
||||||
|
// Db::rollback();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //添加到排行表
|
||||||
|
// $start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour')));
|
||||||
|
// $end_time = strtotime(date('Y-m-d H:00:00')) - 1;
|
||||||
|
// $res2 = db::name('vs_hour_ranking')->insert([
|
||||||
|
// 'ranking' => $ranking,
|
||||||
|
// 'room_id' => $room_id,
|
||||||
|
// 'flowing_water' => $total_price,
|
||||||
|
// 'coin' => $coin,
|
||||||
|
// 'time_id' => date('H', strtotime('-1 hour')),
|
||||||
|
// 'stime' => $start_time,
|
||||||
|
// 'etime' => $end_time,
|
||||||
|
// 'createtime' => time(),
|
||||||
|
// 'updatetime' => time(),
|
||||||
|
// 'is_public_server' => $is_piao
|
||||||
|
// ]);
|
||||||
|
// if(!$res2){
|
||||||
|
// Db::rollback();
|
||||||
|
// }
|
||||||
|
// Db::commit();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //添加礼物到背包
|
||||||
|
// public function add_gift($gift_id,$user_id,$ranking,$room_id,$total_price,$is_piao){
|
||||||
|
// $res = model('api/UserGiftPack')->change_user_gift_pack($user_id,$gift_id,1,model('UserGiftPack')::HOUR_RANK_GET,"小时榜获得");
|
||||||
|
// if($res['code'] == 0){
|
||||||
|
// Log::record("小时榜获取礼物失败:".$res['msg'],"info");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //添加到排行表
|
||||||
|
// $start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour')));
|
||||||
|
// $end_time = strtotime(date('Y-m-d H:00:00')) - 1;
|
||||||
|
// $res2 = db::name('vs_hour_ranking')->insert([
|
||||||
|
// 'ranking' => $ranking,
|
||||||
|
// 'room_id' => $room_id,
|
||||||
|
// 'flowing_water' => $total_price,
|
||||||
|
// 'gift_id' => $gift_id,
|
||||||
|
// 'gift_type' => 2,
|
||||||
|
// 'time_id' => date('H', strtotime('-1 hour')),
|
||||||
|
// 'stime' => $start_time,
|
||||||
|
// 'etime' => $end_time,
|
||||||
|
// 'createtime' => time(),
|
||||||
|
// 'updatetime' => time(),
|
||||||
|
// 'is_public_server' => $is_piao
|
||||||
|
// ]);
|
||||||
|
// if(!$res2){
|
||||||
|
// Log::record("小时榜礼物锁定失败","info");
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //添加装扮到背包
|
||||||
|
// public function add_decorate($avatar_id,$user_id,$ranking,$room_id,$total_price,$is_piao,$type){
|
||||||
|
// $decorate_price_info = db::name('vs_decorate_price')->where(['id'=>$avatar_id])->find();
|
||||||
|
// if(empty($decorate_price_info)){
|
||||||
|
// Log::record("小时榜获取装扮失败:没有找到装扮!".$avatar_id,"info");
|
||||||
|
// }
|
||||||
|
// $res = model('api/Decorate')->pay_decorate($user_id,$decorate_price_info['did'],$decorate_price_info['day'],2);
|
||||||
|
// if($res['code'] == 0){
|
||||||
|
// Log::record("小时榜获取装扮失败:".$res['msg']."-".$avatar_id,"info");
|
||||||
|
// }
|
||||||
|
// //添加到排行表
|
||||||
|
// $start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour')));
|
||||||
|
// $end_time = strtotime(date('Y-m-d H:00:00')) - 1;
|
||||||
|
// $res2 = db::name('vs_hour_ranking')->insert([
|
||||||
|
// 'ranking' => $ranking,
|
||||||
|
// 'room_id' => $room_id,
|
||||||
|
// 'flowing_water' => $total_price,
|
||||||
|
// 'gift_id' => $avatar_id,
|
||||||
|
// 'gift_type' => $type,
|
||||||
|
// 'time_id' => date('H', strtotime('-1 hour')),
|
||||||
|
// 'stime' => $start_time,
|
||||||
|
// 'etime' => $end_time,
|
||||||
|
// 'createtime' => time(),
|
||||||
|
// 'updatetime' => time(),
|
||||||
|
// 'is_public_server' => $is_piao,
|
||||||
|
// ]);
|
||||||
|
// if(!$res2){
|
||||||
|
// Log::record("小时榜咋装扮锁定失败","info");
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提取所有有奖励的内容
|
||||||
|
*/
|
||||||
|
private function extractAllRewards($responseData)
|
||||||
|
{
|
||||||
|
$allRewards = [];
|
||||||
|
|
||||||
|
foreach ($responseData as $timeSlot) {
|
||||||
|
foreach ($timeSlot['reward'] as $rewardItem) {
|
||||||
|
$index = $rewardItem['index'];
|
||||||
|
$content = $rewardItem['content'];
|
||||||
|
|
||||||
|
// 只处理有奖励内容的数据
|
||||||
|
if (!empty($content)) {
|
||||||
|
foreach ($content as $rewardContent) {
|
||||||
|
$allRewards[] = [
|
||||||
|
'index' => $index,
|
||||||
|
'type' => $rewardContent['type'],
|
||||||
|
'value' => $rewardContent['value'],
|
||||||
|
'name' => $rewardContent['name'] ?? ''
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $allRewards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按index分组奖励
|
||||||
|
*/
|
||||||
|
private function groupRewardsByIndex($allRewards)
|
||||||
|
{
|
||||||
|
$grouped = [];
|
||||||
|
|
||||||
|
foreach ($allRewards as $reward) {
|
||||||
|
$index = $reward['index'];
|
||||||
|
if (!isset($grouped[$index])) {
|
||||||
|
$grouped[$index] = [];
|
||||||
|
}
|
||||||
|
$grouped[$index][] = $reward;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按index排序
|
||||||
|
ksort($grouped);
|
||||||
|
|
||||||
|
return $grouped;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按名次顺序分配奖励
|
||||||
|
*/
|
||||||
|
private function distributeByRank($groupedRewards)
|
||||||
|
{
|
||||||
|
$distribution = [];
|
||||||
|
$currentRank = 0; // 从第1名开始
|
||||||
|
|
||||||
|
// 按index顺序分配(index 0 = 第1名,index 1 = 第2名,以此类推)
|
||||||
|
foreach ($groupedRewards as $index => $rewards) {
|
||||||
|
// 确保名次连续,如果有空缺则填充空名次
|
||||||
|
while ($currentRank < $index) {
|
||||||
|
$distribution[] = [
|
||||||
|
'rank' => $currentRank + 1,
|
||||||
|
'rewards' => []
|
||||||
|
];
|
||||||
|
$currentRank++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分配当前名次的奖励
|
||||||
|
$distribution[] = [
|
||||||
|
'rank' => $currentRank + 1,
|
||||||
|
'rewards' => $rewards
|
||||||
|
];
|
||||||
|
$currentRank++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $distribution;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_hour_ranking($time){
|
||||||
|
// 先按时间段和排名索引分组查询
|
||||||
|
$timeRanges = db::name('vs_hour_ranking_gift_config')->distinct(true)
|
||||||
|
->where('time_id', '=', $time)
|
||||||
|
->order('time_id')
|
||||||
|
->column('time_id');
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
foreach ($timeRanges as $timeRange) {
|
||||||
|
// 查询该时间段的所有数据
|
||||||
|
$rewards = db::name('vs_hour_ranking_gift_config')->where('time_id', $timeRange)
|
||||||
|
->field('ranking, gift_type, gift_id,coin,name')
|
||||||
|
->order('ranking')
|
||||||
|
->select();
|
||||||
|
|
||||||
|
$rewardMap = [];
|
||||||
|
foreach ($rewards as $reward) {
|
||||||
|
$rankIndex = $reward['ranking'];
|
||||||
|
|
||||||
|
if (!isset($rewardMap[$rankIndex])) {
|
||||||
|
$rewardMap[$rankIndex] = [
|
||||||
|
'index' => $rankIndex,
|
||||||
|
// 'name' => $reward['rank_name'],
|
||||||
|
'content' => []
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加奖励内容到content数组
|
||||||
|
if ($reward['gift_id'] != 0 || $reward['coin'] != 0) {
|
||||||
|
if($reward['gift_id'] != 0){
|
||||||
|
$rewardMap[$rankIndex]['content'][] = [
|
||||||
|
'type' => $reward['gift_type'],
|
||||||
|
'value' => $reward['gift_id'],
|
||||||
|
// 'coin' => $reward['coin'],
|
||||||
|
'name' => $reward['name'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if($reward['coin'] != 0){
|
||||||
|
$rewardMap[$rankIndex]['content'][] = [
|
||||||
|
'type' => $reward['gift_type'],
|
||||||
|
'value' => $reward['coin'],
|
||||||
|
'name' => $reward['name'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按index排序
|
||||||
|
ksort($rewardMap);
|
||||||
|
|
||||||
|
$result[] = [
|
||||||
|
'time' => $timeRange,
|
||||||
|
'reward' => array_values($rewardMap)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function give_gifts(){
|
||||||
|
$data = db::name('vs_give_gift')->where('from_id',5483)->select();
|
||||||
|
$num = 0;
|
||||||
|
$i=0;
|
||||||
|
$j = 0;
|
||||||
|
foreach($data as $v){
|
||||||
|
$j += $v['total_price'];
|
||||||
|
$nuu = db::name('vs_give_gift_ratio_log')->where('give_gift_id',$v['id'])->value('room_owner_earning');
|
||||||
|
$id = db::name('vs_give_gift_ratio_log')->where('give_gift_id',$v['id'])->value('id');
|
||||||
|
// echo $id."--".$nuu."\n";
|
||||||
|
$num += $nuu;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
echo $num;
|
||||||
|
echo "==".$i."==".$j;
|
||||||
|
|
||||||
|
// echo db::name()->where(['user_id' => 10857,'money_type' =>2,'change_type' =>18])-sum('change_value');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function room_liushui(){
|
||||||
|
// $room = db::name('vs_give_gift')->where(['from_id' => ['<>',5418],'from' => 2])->group('from_id');
|
||||||
|
$dd = db::name('vs_user_gift_pack')->alias('a')->join('vs_gift b','a.gid = b.gid')->field('a.gid,a.num,b.gift_price')->where(['a.num' =>['>',0]])->select();
|
||||||
|
$count = 0;
|
||||||
|
foreach ($dd as $v){
|
||||||
|
$count += $v['gift_price'] * $v['num'];
|
||||||
|
}
|
||||||
|
echo $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
416
application/api/model/BlindBoxTurntableGift.php
Normal file
416
application/api/model/BlindBoxTurntableGift.php
Normal file
@@ -0,0 +1,416 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\model;
|
||||||
|
use app\common\controller\Push;
|
||||||
|
use think\Cache;
|
||||||
|
use think\Model;
|
||||||
|
use think\Db;
|
||||||
|
use think\Session;
|
||||||
|
/*
|
||||||
|
* 盲盒转盘
|
||||||
|
* 2025-08-16
|
||||||
|
*/
|
||||||
|
class BlindBoxTurntableGift extends Model
|
||||||
|
{
|
||||||
|
// 开启自动写入时间戳字段
|
||||||
|
protected $autoWriteTimestamp = true;
|
||||||
|
// 定义时间戳字段名
|
||||||
|
protected $createTime = 'createtime';
|
||||||
|
protected $updateTime = 'updatetime';
|
||||||
|
protected $table = 'fa_vs_gift';
|
||||||
|
|
||||||
|
//获取奖池礼物列表
|
||||||
|
public function get_gift_list($gift_bag_id,$room_id)
|
||||||
|
{
|
||||||
|
$box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
||||||
|
$gifts = db::name('vs_gift_bag_detail')->where('gift_bag_id',$gift_bag_id)->order("id desc")->select();
|
||||||
|
$gift_list = [];
|
||||||
|
foreach ($gifts as $key => $value) {
|
||||||
|
$gift_data = db::name('vs_gift')->where('gid',$value['foreign_id'])->where('delete_time',0)->find();
|
||||||
|
if($gift_data){
|
||||||
|
$gift_list[$key]['number'] = $key;
|
||||||
|
$gift_list[$key]['gift_id'] = $gift_data['gid'];
|
||||||
|
$gift_list[$key]['gift_name'] = $gift_data['gift_name'];
|
||||||
|
$gift_list[$key]['base_image'] = $gift_data['base_image'];
|
||||||
|
$gift_list[$key]['play_image'] = $gift_data['play_image'];
|
||||||
|
$gift_list[$key]['gift_price'] = $gift_data['gift_price'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ext = json_decode($box['ext'],true);
|
||||||
|
$box_gift = Db::name('vs_gift')->where('gid',$ext['gift_id'])->find();
|
||||||
|
|
||||||
|
//巡乐会
|
||||||
|
$is_xlh = 0;
|
||||||
|
$xlh_box = db::name('vs_gift_bag')->where('id',13)->find();
|
||||||
|
$xlh_ext = json_decode($xlh_box['ext'],true);
|
||||||
|
$xlh = [];
|
||||||
|
if($xlh_ext['inlet_bag_id'] == $box['id']){
|
||||||
|
$is_xlh = 1;
|
||||||
|
$xlh['waiting_start_num'] = $xlh_ext['open_condition']['waiting_start_num'];//等待开奖次数
|
||||||
|
$xlh['start_num'] = $xlh_ext['open_condition']['start_num'];//开始开奖次数
|
||||||
|
//当前抽奖次数
|
||||||
|
$xlh['current_num'] = Cache::get("xlh_periods_num") ?? 0;
|
||||||
|
//状态
|
||||||
|
if($xlh['current_num'] >= $xlh_ext['open_condition']['start_num']){
|
||||||
|
$xlh['status'] = 1;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始
|
||||||
|
} elseif($xlh['current_num'] >= $xlh_ext['open_condition']['waiting_start_num'] && $xlh['current_num'] < $xlh_ext['open_condition']['start_num']){
|
||||||
|
$xlh['status'] = 2;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始
|
||||||
|
}else{
|
||||||
|
$xlh['status'] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$result_data = [
|
||||||
|
'title' => $box['name'],
|
||||||
|
'rule_url' => get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$box["id"],
|
||||||
|
'box_price' => $box_gift['gift_price'],
|
||||||
|
'is_xlh' => $is_xlh,
|
||||||
|
'xlh_data' => $xlh,
|
||||||
|
'gift_list' => $gift_list,
|
||||||
|
];
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $result_data];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 礼物特效播放
|
||||||
|
*/
|
||||||
|
public function gift_send($send_id){
|
||||||
|
try{
|
||||||
|
$blind_box_turntable = db('vs_blind_box_turntable_log')->where(['id'=>$send_id,'is_sued'=>0])->find();
|
||||||
|
if(!$blind_box_turntable){
|
||||||
|
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||||
|
}
|
||||||
|
$room_id = $blind_box_turntable['room_id'];
|
||||||
|
$blind_box_turntable_log = db('vs_blind_box_turntable_results_log')->where(['tid'=>$send_id])->select();
|
||||||
|
if(!$blind_box_turntable_log){
|
||||||
|
return ['code' => 0, 'msg' => '数据不存在','data' => null];
|
||||||
|
}
|
||||||
|
$room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name');
|
||||||
|
$FromUserInfo = Db::name('user')->where(['id'=>$blind_box_turntable['user_id']])->find();
|
||||||
|
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($blind_box_turntable['user_id']);//财富图标
|
||||||
|
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($blind_box_turntable['user_id']);//魅力图标
|
||||||
|
$user_nickname = $FromUserInfo['nickname'];
|
||||||
|
$textMessage = $user_nickname;
|
||||||
|
$text_message = [];
|
||||||
|
foreach ($blind_box_turntable_log as $key => $value) {
|
||||||
|
$ToUserInfo = Db::name('user')->where(['id' => $value['gift_user_id']])->field('id as user_id,nickname,avatar,sex')->find();
|
||||||
|
$draw_gift = Db::name('vs_gift')->where(['gid'=>$value['gift_id']])->find();
|
||||||
|
$textMessage = $textMessage . ' 送给 ' . $ToUserInfo['nickname']. ' 盲盒转盘礼物 ' . $draw_gift['gift_name'].' x ' .$value['count']."\n";
|
||||||
|
$play_image[] = $draw_gift['play_image'];
|
||||||
|
$gift_names[] = $draw_gift['gift_name'];
|
||||||
|
|
||||||
|
$text_message = $user_nickname . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $draw_gift['gift_name'] . 'X' . $value['count']."\n";
|
||||||
|
if($draw_gift['is_public_server'] == 1) {
|
||||||
|
$text_list_new[] = [
|
||||||
|
'text' => $text_message,
|
||||||
|
'gift_picture' => $draw_gift['base_image'],
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'fromUserName' => $FromUserInfo['nickname'],
|
||||||
|
'toUserName' => $ToUserInfo['nickname'],
|
||||||
|
'giftName' => $draw_gift['gift_name'],
|
||||||
|
'roomId' => $room_id,
|
||||||
|
'number' => $value['count'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$ToUserInfosList[$value['gift_user_id']] = $ToUserInfo;
|
||||||
|
|
||||||
|
}
|
||||||
|
foreach($ToUserInfosList as &$userInfo) {
|
||||||
|
$userInfo['icon'][0] = model('UserData')->user_wealth_icon($userInfo['user_id']);//财富图标
|
||||||
|
$userInfo['icon'][1] = model('UserData')->user_charm_icon($userInfo['user_id']);//魅力图标
|
||||||
|
$userInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $userInfo['user_id'],'room_id' => $room_id])->value('charm');//魅力
|
||||||
|
$ToUserInfos[] = $userInfo;
|
||||||
|
}
|
||||||
|
$text = [
|
||||||
|
'FromUserInfo' => $FromUserInfo,
|
||||||
|
'ToUserInfos' => $ToUserInfos,
|
||||||
|
'GiftInfo' => [
|
||||||
|
'play_image' => implode(',',$play_image),
|
||||||
|
'gift_name' => implode(',',$gift_names),
|
||||||
|
],
|
||||||
|
'text' => rtrim($textMessage, "\n")
|
||||||
|
];
|
||||||
|
//聊天室推送系统消息
|
||||||
|
model('Chat')->sendMsg(1005,$room_id,$text);
|
||||||
|
$roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||||
|
if($roomtype == 6){
|
||||||
|
//推送消息
|
||||||
|
$hot_value = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',6)
|
||||||
|
->sum('total_price');
|
||||||
|
$text1 = [
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'hot_value' => $hot_value * 10,
|
||||||
|
'text' => '房间心动值变化'
|
||||||
|
];
|
||||||
|
//聊天室推送系统消息
|
||||||
|
model('Chat')->sendMsg(1028,$room_id,$text1);
|
||||||
|
}else{
|
||||||
|
if(!empty($text_list_new)){
|
||||||
|
//推送礼物横幅
|
||||||
|
$push = new Push($blind_box_turntable['user_id'], $room_id);
|
||||||
|
$push->giftBanner($text_list_new);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
db::name('vs_blind_box_turntable_log')->where('id', $send_id)->update(['is_sued' => 1, 'updatetime' => time()]);
|
||||||
|
return ['code' => 1, 'msg' => '成功', 'data' => null];
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return ['code' => 0, 'msg' => "网络请求错误,请重试!", 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 获取用户抽奖记录
|
||||||
|
*/
|
||||||
|
public function get_user_record($gift_bag_id,$user_id=0,$page=1,$page_size=12){
|
||||||
|
$where = [];
|
||||||
|
$where['b.gift_bag_id'] = $gift_bag_id;
|
||||||
|
if($user_id > 0){
|
||||||
|
$where['b.user_id'] = $user_id;
|
||||||
|
}
|
||||||
|
$list = db('vs_blind_box_turntable_results_log')
|
||||||
|
->alias('a')
|
||||||
|
->join('vs_blind_box_turntable_log b','b.id = a.tid','left')
|
||||||
|
->join('user c','a.gift_user_id = c.id','left')
|
||||||
|
->join('vs_gift d','d.gid = a.gift_id','left')
|
||||||
|
->field('a.gift_id,a.count,a.gift_user_id,a.createtime,c.nickname,d.gift_name as gift_name,d.base_image')
|
||||||
|
->where($where)
|
||||||
|
->order('a.createtime desc')
|
||||||
|
->page($page,$page_size)
|
||||||
|
->select();
|
||||||
|
foreach ($list as &$v){
|
||||||
|
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||||
|
}
|
||||||
|
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 获取全服抽奖记录
|
||||||
|
*/
|
||||||
|
public function get_all_record($gift_bag_id,$page=1,$page_size=12){
|
||||||
|
$where = [];
|
||||||
|
$where['b.gift_bag_id'] = $gift_bag_id;
|
||||||
|
$where['d.gift_bag_id'] = $gift_bag_id;
|
||||||
|
$where['d.is_world_show'] = 1;
|
||||||
|
$list = db('vs_blind_box_turntable_results_log')
|
||||||
|
->alias('a')
|
||||||
|
->join('vs_blind_box_turntable_log b','b.id = a.tid','left')
|
||||||
|
->join('user c','b.user_id = c.id','left')
|
||||||
|
->join('vs_gift_bag_detail d','d.foreign_id = a.gift_id','left')
|
||||||
|
->join('vs_gift e','e.gid = a.gift_id','left')
|
||||||
|
->field('a.gift_id,a.count,b.user_id,a.createtime,c.nickname,d.name as gift_name,e.base_image')
|
||||||
|
->where($where)
|
||||||
|
->order('a.createtime desc')
|
||||||
|
->page($page,$page_size)
|
||||||
|
->select();
|
||||||
|
foreach ($list as &$v){
|
||||||
|
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||||
|
}
|
||||||
|
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* 巡乐会
|
||||||
|
*/
|
||||||
|
public function xlh_gift_list($room_id){
|
||||||
|
$gift_bag_id = 13;
|
||||||
|
$xlh_box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
||||||
|
$xlh_ext = json_decode($xlh_box['ext'],true);
|
||||||
|
$gifts = db::name('vs_gift_bag_detail')->where('gift_bag_id',$gift_bag_id)->order("id desc")->select();
|
||||||
|
$gift_list = [];
|
||||||
|
foreach ($gifts as $key => $value) {
|
||||||
|
$gift_data = db::name('vs_gift')->where('gid',$value['foreign_id'])->where('delete_time',0)->find();
|
||||||
|
if($gift_data){
|
||||||
|
$gift_list[$key]['number'] = $key;
|
||||||
|
$gift_list[$key]['gift_id'] = $gift_data['gid'];
|
||||||
|
$gift_list[$key]['gift_name'] = $gift_data['gift_name'];
|
||||||
|
$gift_list[$key]['base_image'] = $gift_data['base_image'];
|
||||||
|
$gift_list[$key]['play_image'] = $gift_data['play_image'];
|
||||||
|
$gift_list[$key]['gift_price'] = $gift_data['gift_price'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//房主信息
|
||||||
|
// $room_user = db::name('user')->where('id',$room_data['user_id'])->find();
|
||||||
|
//房主礼物
|
||||||
|
$room_user_gift = db::name('vs_gift')->where('gid',$xlh_ext['locking_condition']['give_homeowner_gift_id'])->find();
|
||||||
|
//巡乐会主礼物
|
||||||
|
$xlh_main_gift = db::name('vs_gift')->where('gid',$xlh_ext['locking_condition']['locking_gift_id'])->find();
|
||||||
|
//中奖用户
|
||||||
|
$pan_xlh = db::name('vs_room_pan_xlh')->where(['send_time'=>0,'end_time'=>['>',time()]])->order('id desc')->find();
|
||||||
|
$xlh_periods_num = Cache::get("xlh_periods_num") ?? 0;
|
||||||
|
if(empty($pan_xlh)){
|
||||||
|
if($xlh_periods_num >= $xlh_ext['open_condition']['start_num']){
|
||||||
|
$xlh_periods = Cache::get("this_xlh_periods") ?? 0;
|
||||||
|
$pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'],
|
||||||
|
'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'],
|
||||||
|
'periods' => $xlh_periods+1,
|
||||||
|
'num' => 0,
|
||||||
|
'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60,
|
||||||
|
'createtime' => time()
|
||||||
|
]);
|
||||||
|
Cache::set("this_xlh_periods", $xlh_periods+1, 0);//修改巡乐会期数
|
||||||
|
$pan_xlh = db::name('vs_room_pan_xlh')->where(['id'=>$pan_xlh_id])->find();
|
||||||
|
}else{
|
||||||
|
return ['code' => 0, 'msg' => '巡乐会已结束', 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$xlh_user_data= null;
|
||||||
|
$room_user_data = null;
|
||||||
|
if($pan_xlh && $pan_xlh['user_id']){
|
||||||
|
$xlh_user = db::name('user')->where('id',$pan_xlh['user_id'])->find();
|
||||||
|
$xlh_user_data = [
|
||||||
|
'user_id' => $xlh_user['id'],
|
||||||
|
'nickname' => $xlh_user['nickname'],
|
||||||
|
'avatar' => $xlh_user['avatar'],
|
||||||
|
];
|
||||||
|
if($pan_xlh['room_id']){
|
||||||
|
$room_data = db::name('vs_room')->field('xlh_periods,xlh_periods_num,user_id')-> where('id',$pan_xlh['room_id'])->find();
|
||||||
|
$room_user = db::name('user')->where('id',$room_data['user_id'])->find();
|
||||||
|
$room_user_data = [
|
||||||
|
'user_id' => $room_user['id'],
|
||||||
|
'nickname' => $room_user['nickname'],
|
||||||
|
'avatar' => $room_user['avatar'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//$gift_list 按gift_price 升序排序
|
||||||
|
usort($gift_list, function($a, $b) {
|
||||||
|
return $a['gift_price'] - $b['gift_price'];
|
||||||
|
});
|
||||||
|
|
||||||
|
$result_data = [
|
||||||
|
'title' => $xlh_box['name'],
|
||||||
|
'rule_url' => get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$xlh_box["id"],
|
||||||
|
'box_price' => $xlh_ext['xlh_box_price'],
|
||||||
|
'xlh_end_time' =>$pan_xlh['end_time']??0,
|
||||||
|
'give_homeowner_gift' => [
|
||||||
|
'gift_id' => $room_user_gift['gid'],
|
||||||
|
'gift_name' => $room_user_gift['gift_name'],
|
||||||
|
'gift_price' => $room_user_gift['gift_price'],
|
||||||
|
'base_image' => $room_user_gift['base_image'],
|
||||||
|
],
|
||||||
|
'homeowner_user' => $room_user_data,
|
||||||
|
'locking_gift' => [
|
||||||
|
'gift_id' => $xlh_main_gift['gid'],
|
||||||
|
'gift_name' => $xlh_main_gift['gift_name'],
|
||||||
|
'gift_price' => $xlh_main_gift['gift_price'],
|
||||||
|
'base_image' => $xlh_main_gift['base_image'],
|
||||||
|
'gift_num' => $pan_xlh['num']??0
|
||||||
|
],
|
||||||
|
'xlh_user' => $xlh_user_data,
|
||||||
|
'gift_list' => $gift_list,
|
||||||
|
];
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => $result_data];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 巡乐会抽奖记录
|
||||||
|
*/
|
||||||
|
public function xlh_get_user_record($user_id,$room_id,$page=1,$page_size=12){
|
||||||
|
$where = [];
|
||||||
|
$where['a.gift_bag_id'] = 13;
|
||||||
|
$where['a.user_id'] = $user_id;
|
||||||
|
$list = db('vs_gift_bag_receive_pan_log')
|
||||||
|
->alias('a')
|
||||||
|
->join('vs_room_pan_xlh b','b.id = a.parent_id','left')
|
||||||
|
->join('vs_gift c','c.gid = a.gift_id','left')
|
||||||
|
->field('a.gift_id,a.num as count,a.createtime,c.gift_name as gift_name,c.base_image')
|
||||||
|
->where($where)
|
||||||
|
->order('a.createtime desc')
|
||||||
|
->page($page,$page_size)
|
||||||
|
->select();
|
||||||
|
foreach ($list as &$v){
|
||||||
|
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||||
|
}
|
||||||
|
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 巡乐会榜单
|
||||||
|
*/
|
||||||
|
public function xlh_ranking($room_id,$page=1,$page_size=12){
|
||||||
|
$where = [];
|
||||||
|
$where['a.gift_bag_id'] = 13;
|
||||||
|
$where['e.is_world_show'] = 1;
|
||||||
|
$list = db('vs_gift_bag_receive_pan_log')
|
||||||
|
->alias('a')
|
||||||
|
->join('vs_room_pan_xlh b','b.id = a.parent_id','left')
|
||||||
|
->join('vs_gift c','c.gid = a.gift_id','left')
|
||||||
|
->join('fa_user d','d.id = a.user_id','left')
|
||||||
|
->join('vs_gift_bag_detail e','e.foreign_id = a.gift_id','left')
|
||||||
|
->field('a.gift_id,a.num as count,a.createtime,c.gift_name,c.base_image,d.nickname')
|
||||||
|
->where($where)
|
||||||
|
->order('a.createtime desc')
|
||||||
|
->page($page,$page_size)
|
||||||
|
->select();
|
||||||
|
foreach ($list as &$v){
|
||||||
|
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
|
||||||
|
}
|
||||||
|
return ['code' => 1, 'msg' => '成功', 'data' => $list];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 获取用户当前房间的巡乐会信息
|
||||||
|
*/
|
||||||
|
public function get_user_xlh_info($room_id){
|
||||||
|
$gift_bag_id = 13;
|
||||||
|
$xlh_box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
||||||
|
$xlh_ext = json_decode($xlh_box['ext'],true);
|
||||||
|
$xlh_data = db('vs_room_pan_xlh')->where(["send_time"=>0,"end_time"=>[">",time()]])->field('id,room_id,periods,end_time')->order('periods desc')->find();
|
||||||
|
//寻乐会状态
|
||||||
|
$xlh_status = 0;
|
||||||
|
// 状态
|
||||||
|
$xlh_periods_num = Cache::get("xlh_periods_num") ?? 0;
|
||||||
|
if($xlh_periods_num >= $xlh_ext['open_condition']['start_num']){
|
||||||
|
$xlh_status = 1;//状态 1:巡乐会开始 2:即将开始 0:等待开始
|
||||||
|
} elseif($xlh_periods_num >= $xlh_ext['open_condition']['waiting_start_num'] && $xlh_periods_num < $xlh_ext['open_condition']['start_num']){
|
||||||
|
$xlh_status = 2;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始
|
||||||
|
}else{
|
||||||
|
$xlh_status = 0;//未开始
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
'activities_name' => $xlh_box['name'],
|
||||||
|
'icon' => null,
|
||||||
|
'xlh_status'=>$xlh_status,
|
||||||
|
'end_time'=>$xlh_data['end_time'] ?? 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 巡乐会榜单
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function xlh_ranking_list($room_id,$page=1,$page_size=12){
|
||||||
|
$gift_bag_id = 13;
|
||||||
|
$xlh_box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find();
|
||||||
|
$xlh_ext = json_decode($xlh_box['ext'],true);
|
||||||
|
$pan_xlh = db::name('vs_room_pan_xlh')
|
||||||
|
->order('id desc')
|
||||||
|
->page($page,$page_size)
|
||||||
|
->select();
|
||||||
|
$list = [];
|
||||||
|
foreach ($pan_xlh as $key=>$value){
|
||||||
|
$list[$key]['periods'] = "第".$value['periods']."期";
|
||||||
|
if(!empty($value['user_id'])){
|
||||||
|
$list[$key]['nickname'] = db::name('user')->where(['id'=>$value['user_id']])->value('nickname');
|
||||||
|
}else{
|
||||||
|
$list[$key]['nickname'] = "无";
|
||||||
|
}
|
||||||
|
if(!empty($value['gift_id'])){
|
||||||
|
$gift_data = db::name('vs_gift')->field('gift_name,base_image')->where(['gid'=>$value['gift_id']])->find();
|
||||||
|
$list[$key]['gift_name'] = 'x '.$value['num'].' '.$gift_data['gift_name'];
|
||||||
|
$list[$key]['base_image'] = $gift_data['base_image']??"";
|
||||||
|
}else{
|
||||||
|
$gift_data = db::name('vs_gift')->field('gift_name,base_image')->where(['gid'=>$xlh_ext['locking_condition']['locking_gift_id']])->find();
|
||||||
|
$list[$key]['gift_name'] = 'x 0 '.$gift_data['gift_name'];
|
||||||
|
$list[$key]['base_image'] = $gift_data['base_image']??"";
|
||||||
|
}
|
||||||
|
$list[$key]['createtime'] = $value['send_time'] ? date('Y-m-d H:i:s',$value['send_time']) : '' ;
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => '成功',
|
||||||
|
'data' => $list
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
1603
application/api/model/BlindBoxTurntableGiftDraw.php
Normal file
1603
application/api/model/BlindBoxTurntableGiftDraw.php
Normal file
File diff suppressed because it is too large
Load Diff
1528
application/api/model/BlindBoxTurntableGiftDrawWorld.php
Normal file
1528
application/api/model/BlindBoxTurntableGiftDrawWorld.php
Normal file
File diff suppressed because it is too large
Load Diff
801
application/api/model/Friend.php
Normal file
801
application/api/model/Friend.php
Normal file
@@ -0,0 +1,801 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\model;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
use think\Log;
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
class Friend extends Model
|
||||||
|
{
|
||||||
|
public function start_friend($user_id, $room_id){
|
||||||
|
// 判断用户是否在主持麦
|
||||||
|
$host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9,'user_id' => $user_id])->find();
|
||||||
|
if(!$host){
|
||||||
|
return ['code' => 0, 'msg' => '没有权限操作', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$room_info = db::name('vs_room')->field('id,step,room_status')->where(['id' => $room_id,'room_status' =>1])->find();
|
||||||
|
if (!$room_info) {
|
||||||
|
return ['code' => 0, 'msg' => '房间不存在!', 'data' => null];
|
||||||
|
}
|
||||||
|
if($room_info['step'] == 2 || $room_info['step'] == 3){
|
||||||
|
return ['code' => 0, 'msg' => '交友正在进行中!', 'data' => null];
|
||||||
|
}
|
||||||
|
//在麦位上的用户
|
||||||
|
$pit_user = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7],'user_id' => ['<>',0]])->count();
|
||||||
|
|
||||||
|
if($pit_user >= 2) {
|
||||||
|
$data['room_id'] = $room_id;
|
||||||
|
$data['end_time'] = time() + get_system_config_value('friend_time') * 60;
|
||||||
|
$data['create_time'] = time();
|
||||||
|
$data['status'] = 1;
|
||||||
|
|
||||||
|
$id = db::name('vs_user_friending')->insertGetId($data);
|
||||||
|
|
||||||
|
if (!$id) {
|
||||||
|
return ['code' => 0, 'msg' => '操作失败!', 'data' => null];
|
||||||
|
}
|
||||||
|
//修改房间状态
|
||||||
|
db::name('vs_room')->where(['id' => $room_id])->update(['step' => 2]);
|
||||||
|
//清除房间用户的魅力
|
||||||
|
model('Room')->clear_user_charm($user_id, $room_id);
|
||||||
|
|
||||||
|
//推送给前端消息
|
||||||
|
$text['text'] = '交友开始';
|
||||||
|
$text['step'] = 2;
|
||||||
|
$text['friend_id'] = $id;
|
||||||
|
$text['end_time'] = $data['end_time'];
|
||||||
|
model('api/Chat')->sendMsg(1049,$room_id,$text);
|
||||||
|
return ['code' => 1, 'msg' => '操作成功!', 'data' => ['friend_id' => $id]];
|
||||||
|
}else{
|
||||||
|
return ['code' => 0, 'msg' => '交友麦位至少两位用户才能开始', 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//延时
|
||||||
|
public function delay($user_id,$room_id,$id,$delay_times){
|
||||||
|
// 判断用户是否在主持麦
|
||||||
|
$host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9,'user_id' => $user_id])->find();
|
||||||
|
if(!$host){
|
||||||
|
return ['code' => 0, 'msg' => '没有权限操作', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$id || !$room_id) {
|
||||||
|
return ['code' => 0, 'msg' => '参数有误!', 'data' => null];
|
||||||
|
}
|
||||||
|
if($delay_times <= 0){
|
||||||
|
$delay_times = get_system_config_value('friend_delay_times');
|
||||||
|
}
|
||||||
|
//修改结束 时间
|
||||||
|
$res = db::name('vs_user_friending')->where('id', $id)->update([
|
||||||
|
'end_time' => Db::raw('end_time + ' . ($delay_times * 60))
|
||||||
|
]);
|
||||||
|
if(!$res){
|
||||||
|
return ['code' => 0, 'msg' => '操作失败!', 'data' => null];
|
||||||
|
}
|
||||||
|
//推送延时
|
||||||
|
$text['text'] = '延时';
|
||||||
|
$text['friend_id'] = $id;
|
||||||
|
$text['end_time'] = db::name('vs_user_friending')->where('id', $id)->value('end_time');
|
||||||
|
model('api/Chat')->sendMsg(1050,$room_id,$text);
|
||||||
|
return ['code' => 1, 'msg' => '操作成功!', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
//交友结束(结束牵手良缘)
|
||||||
|
public function end_friend($user_id,$room_id,$id,$is_system = 0){
|
||||||
|
if (!$id || !$room_id) {
|
||||||
|
return ['code' => 0, 'msg' => '参数有误!', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($is_system == 0){
|
||||||
|
// 判断用户是否在主持麦
|
||||||
|
$host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9,'user_id' => $user_id])->find();
|
||||||
|
if(!$host){
|
||||||
|
return ['code' => 0, 'msg' => '没有权限操作', 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取心动值最高的
|
||||||
|
$originalPairs = db::name('vs_user_friending_heart')
|
||||||
|
->where(['room_id'=>$room_id,'friend_id'=>$id ,'status' =>1])
|
||||||
|
->order('heart_value DESC')->find();
|
||||||
|
$friend_heart_value = get_system_config_value('friend_heart_value');
|
||||||
|
if($originalPairs && $originalPairs['heart_value'] >= $friend_heart_value){
|
||||||
|
$step = 3;//结束进入牵手良缘卡关系
|
||||||
|
//心动值达到伐值 返回用户信息与关系列表
|
||||||
|
$return['user1_id'] =$originalPairs['user1_id'];
|
||||||
|
$return['user1_avatar'] = db::name('user')->where(['id'=>$originalPairs['user1_id']])->value('avatar');
|
||||||
|
$return['user1_nickname'] = db::name('user')->where(['id'=>$originalPairs['user1_id']])->value('nickname');
|
||||||
|
$return['user2_id'] =$originalPairs['user2_id'];
|
||||||
|
$return['user2_avatar'] = db::name('user')->where(['id'=>$originalPairs['user2_id']])->value('avatar');
|
||||||
|
$return['user2_nickname'] = db::name('user')->where(['id'=>$originalPairs['user2_id']])->value('nickname');
|
||||||
|
$return['heart_value'] = $originalPairs['heart_value'];
|
||||||
|
$return['heart_id'] = $originalPairs['id'];
|
||||||
|
$room_updatatime = db::name('vs_room')->where(['id' => $room_id,'step' => $step])->value('updatetime');
|
||||||
|
if($room_updatatime){ //60秒内没操作 则创建关系无
|
||||||
|
if(time() - $room_updatatime > 60){
|
||||||
|
$this->createRelation(0,$room_id,$id,$return['user1_id'],$return['user2_id'],0);
|
||||||
|
return ['code' => 1, 'msg' => '操作成功!', 'data' => $return];
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
// 修改当前交友阶段
|
||||||
|
db::name('vs_room')->where(['id' => $room_id])->update(['step' => $step,'updatetime' => time()]);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$step = 1;//结束下一轮
|
||||||
|
// 修改当前交友阶段 分开写 放到前面是为了下麦
|
||||||
|
db::name('vs_room')->where(['id' => $room_id])->update(['step' => 1]);
|
||||||
|
//所有人下麦
|
||||||
|
$on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7],'user_id' => ['<>',0]])->select();
|
||||||
|
if($on_pit){
|
||||||
|
foreach ($on_pit as $pit){
|
||||||
|
model('RoomPit')->DownPit($pit['user_id'], $room_id,$pit['pit_number']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$return = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//结束交友游戏
|
||||||
|
if($step == 1){
|
||||||
|
db::name('vs_user_friending')->where(['id' => $id])->update(['status' => 2]);
|
||||||
|
}
|
||||||
|
//推送给前端消息
|
||||||
|
$text['text'] = $step == 1 ? '交友结束' : '牵手良缘';
|
||||||
|
$text['step'] = $step;//1 等待邂逅 2 心动连线 3 牵手良缘
|
||||||
|
$text['friend_user'] = $return;
|
||||||
|
$text['friend_id'] = $id;
|
||||||
|
model('api/Chat')->sendMsg(1049,$room_id,$text);
|
||||||
|
model('Room')->clear_user_charm(db::name('vs_room')->where(['id' => $room_id])->value('user_id'), $room_id);
|
||||||
|
return ['code' => 1, 'msg' => '操作成功!', 'data' => $return];
|
||||||
|
}
|
||||||
|
|
||||||
|
//心动值超过配置值 创建关系
|
||||||
|
public function createRelation($user_id,$room_id,$friend_id,$user1_id,$user2_id,$friending_config_id){
|
||||||
|
|
||||||
|
if (!$user1_id || !$user2_id || !$friend_id || !$room_id) {
|
||||||
|
return ['code' => 0, 'msg' => '参数有误!', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$user1 = min($user1_id, $user2_id);
|
||||||
|
$user2 = max($user1_id, $user2_id);
|
||||||
|
$friending_heart = db::name('vs_user_friending_heart')
|
||||||
|
->where(['room_id'=>$room_id,'friend_id'=>$friend_id ,'user1_id' =>$user1,'user2_id' => $user2])->order('id desc')->find();
|
||||||
|
|
||||||
|
$originalPairs = db::name('vs_user_friending_heart')
|
||||||
|
->where(['id'=>$friending_heart['id']])
|
||||||
|
->update(['status' => 3,'friend_config_id' =>$friending_config_id]);
|
||||||
|
$msg = '';
|
||||||
|
if ($originalPairs) {
|
||||||
|
$relation = db::name('vs_relation')->where('id',$friending_config_id)->value('name');
|
||||||
|
if($friending_heart['heart_value'] >= get_system_config_value('friend_heart_create_room') && $friending_config_id > 0){
|
||||||
|
//创建小房间
|
||||||
|
$room_ids = model('api/Room')->user_create_room($user1,'的电影房',get_system_config_value('web_site').'/data/avatar/head_pic.png','交友房产生的一次性房间',7);
|
||||||
|
if($room_ids['code'] != 1){
|
||||||
|
$msg = 'cp电影房创建失败';
|
||||||
|
}else{
|
||||||
|
//记录小房间
|
||||||
|
$datda = [
|
||||||
|
'room_id' => $room_ids['data'],
|
||||||
|
'relation_id' => $friending_config_id,
|
||||||
|
'user_id' => $user1,
|
||||||
|
'user_id1' => $user2,
|
||||||
|
'time_day' => time() + get_system_config_value('friend_room_timea') * 60,
|
||||||
|
'createtime' => time(),
|
||||||
|
'status' => 1,
|
||||||
|
'type' => 1
|
||||||
|
];
|
||||||
|
db::name('vs_room_cp_movie')->insert($datda);
|
||||||
|
|
||||||
|
if($room_ids['data']){
|
||||||
|
$text['text'] = '交友结束并创建房间';
|
||||||
|
$text['room_id'] = $room_ids['data'];//前端用来让用户跳转的房间id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$text['text'] = '交友结束未创建房间';
|
||||||
|
}
|
||||||
|
$text['relation_name'] = $relation;
|
||||||
|
$text['user1_id'] = $user1;
|
||||||
|
$text['user2_id'] = $user2;
|
||||||
|
$text['user1_avatar'] = db::name('user')->where(['id'=>$user1])->value('avatar');
|
||||||
|
$text['user1_nickname'] = db::name('user')->where(['id'=>$user1])->value('nickname');
|
||||||
|
$text['user2_avatar'] = db::name('user')->where(['id'=>$user2])->value('avatar');
|
||||||
|
$text['user2_nickname'] = db::name('user')->where(['id'=>$user2])->value('nickname');
|
||||||
|
model('api/Chat')->sendMsg(1051,$room_id,$text);
|
||||||
|
|
||||||
|
// 修改当前交友阶段
|
||||||
|
db::name('vs_room')->where(['id' => $room_id])->update(['step' => 1]);
|
||||||
|
db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2]);
|
||||||
|
//所有人下麦
|
||||||
|
$on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7],'user_id' => ['<>',0]])->select();
|
||||||
|
if($on_pit){
|
||||||
|
foreach ($on_pit as $pit){
|
||||||
|
model('RoomPit')->DownPit($pit['user_id'], $room_id,$pit['pit_number']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$shijian = floor($friending_heart['heart_value']/get_system_config_value('friend_heart_value')) * get_system_config_value('friend_heart_times');
|
||||||
|
$friendendtime = time() + $shijian * 3600;
|
||||||
|
|
||||||
|
//更新关系结束时间
|
||||||
|
db::name('vs_user_friending_heart')->where(['id'=>$friending_heart['id']])->update(['contact_end_time' => $friendendtime]);
|
||||||
|
|
||||||
|
//关系增加时间
|
||||||
|
$room_auction = model('RoomAuction')->room_auction_create_or_add($user1_id,$user2_id,$friending_config_id,$shijian*3600,0);
|
||||||
|
|
||||||
|
//推送给前端消息
|
||||||
|
$text['text'] = '交友结束';
|
||||||
|
$text['step'] = 1;//1 等待邂逅 2 心动连线 3 牵手良缘
|
||||||
|
model('api/Chat')->sendMsg(1049,$room_id,$text);
|
||||||
|
|
||||||
|
return ['code' => 1, 'msg' => '创建关系成功!'.$msg, 'data' => null];
|
||||||
|
} else {
|
||||||
|
//推送给前端消息
|
||||||
|
$text['text'] = '交友结束';
|
||||||
|
$text['step'] = 1;//1 等待邂逅 2 心动连线 3 牵手良缘
|
||||||
|
model('api/Chat')->sendMsg(1049,$room_id,$text);
|
||||||
|
db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2]);
|
||||||
|
return ['code' => 0, 'msg' => '创建关系失败!', 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//退出私密房间
|
||||||
|
public function outRoom($user_id,$room_id){
|
||||||
|
//推送给前端消息
|
||||||
|
$text['text'] = '退出私密小屋';
|
||||||
|
model('api/Chat')->sendMsg(1055,$room_id,$text);
|
||||||
|
|
||||||
|
|
||||||
|
// //查询在房间的用户
|
||||||
|
// $users = db::name('vs_room_visitor')->where(['room_id'=>$room_id])->select();
|
||||||
|
// if($users){
|
||||||
|
// //退出房间
|
||||||
|
// foreach ($users as $v){
|
||||||
|
// //退出房间
|
||||||
|
// model('Room')->quit_room($v['user_id'], $room_id,$v['user_id']);
|
||||||
|
// }
|
||||||
|
// }else{
|
||||||
|
// model('Room')->quit_room($user_id, $room_id,$user_id);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//注销房间
|
||||||
|
db::name('vs_room')->where(['id'=>$room_id])->update(['room_status'=>3]);
|
||||||
|
db::name('vs_room_cp_movie')->where(['room_id'=>$room_id])->update(['status'=>4]);
|
||||||
|
model('api/Tencent')->delete_group('room'.$room_id);
|
||||||
|
|
||||||
|
return ['code' => 1, 'msg' => '退出成功!', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//房间内送礼
|
||||||
|
/*
|
||||||
|
* @param $uid 用户id
|
||||||
|
* @param $to_uid 接收用户id组
|
||||||
|
* @param $gift_id 礼物id
|
||||||
|
* @param $gift_num 礼物数量
|
||||||
|
* @param $from_type 来源 1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼
|
||||||
|
* @param $type 1金币购买 2送背包礼物
|
||||||
|
* @param $room_id 房间id
|
||||||
|
* @param $pit_number 坑位
|
||||||
|
*/
|
||||||
|
public function room_give_gift($uid, $to_uid, $gift_id, $gift_num, $from_type, $type, $room_id, $pit_number, $heart_id,$give_gift_ext)
|
||||||
|
{
|
||||||
|
$res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num, $from_type, $type, $room_id, $pit_number,0,$give_gift_ext);
|
||||||
|
if($res['code'] != 1){
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
//送礼成功后续操作
|
||||||
|
//查看当前时间是否在交友表的创建时间和结束时间段内 用来区分是否要拉取心动值高的用户上麦
|
||||||
|
$friend = db::name('vs_user_friending')->where(['room_id' => $room_id,'status' => 1])->order('id desc')->find();
|
||||||
|
if($friend && time() >= $friend['create_time'] && time() <= $friend['end_time']){
|
||||||
|
$heart_exp = get_system_config_value('coin_charm_exp');//金币与魅力值转换比
|
||||||
|
$sumPrice = $res['data']['gift_total'] * $heart_exp;
|
||||||
|
$user_idd = $to_uid;
|
||||||
|
|
||||||
|
if($heart_id){//有这个值就是助力 不参加抢麦操作
|
||||||
|
db::name('vs_user_friending_heart')->where(['id' => $heart_id])->setInc('heart_value', $sumPrice);
|
||||||
|
$this->pullHeartChange($room_id,$friend['id']);//聊天室心动值变化通知
|
||||||
|
//生成新排名 判断抱上麦 还是换麦
|
||||||
|
$this->pullUserPit($room_id,$friend['id']);
|
||||||
|
}else{
|
||||||
|
//判断送礼人或收礼人里面有主持和嘉宾
|
||||||
|
$host = $this->is_host($uid,$to_uid,$room_id);
|
||||||
|
$user_idd = explode(",", $user_idd); // 将字符串转换为数组
|
||||||
|
//判断是否是主持
|
||||||
|
if($host['is_preside'] == 1){
|
||||||
|
if(!in_array($uid,$host['is_preside_user'])){//主持不是当前送礼人,那就是在收礼人中
|
||||||
|
//从数组中剔除主持人 && $is_preside_user!= UID
|
||||||
|
$user_idd = array_diff($user_idd, $host['is_preside_user']); // 从数组中移除
|
||||||
|
if($user_idd){
|
||||||
|
//插入/更新心动表
|
||||||
|
$this->addUserHeart($uid,$user_idd,$friend['id'],$sumPrice,$room_id,$res['data']['gift_user_data']);
|
||||||
|
//送礼产生心动值并计算 判断拉取用户上麦还是换麦
|
||||||
|
//生成新排名 判断抱上麦 还是换麦
|
||||||
|
$this->pullUserPit($room_id,$friend['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
//插入/更新心动表
|
||||||
|
$this->addUserHeart($uid,$user_idd,$friend['id'],$sumPrice,$room_id,$res['data']['gift_user_data']);
|
||||||
|
//送礼产生心动值并计算 判断拉取用户上麦还是换麦
|
||||||
|
//生成新排名 判断抱上麦 还是换麦
|
||||||
|
$this->pullUserPit($room_id,$friend['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ['code' => 1, 'msg' => '送礼成功', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
//是否主持
|
||||||
|
public function is_host($uid,$to_uid,$room_id){
|
||||||
|
//获取当前主持人和嘉宾
|
||||||
|
$host[] = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number' => 9])->value('user_id');
|
||||||
|
$host[] = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number' => 10])->value('user_id');
|
||||||
|
|
||||||
|
$is_preside_user = [];
|
||||||
|
$is_preside = 0;
|
||||||
|
$user_ids = explode(",", $to_uid);
|
||||||
|
foreach ($user_ids as $value) {
|
||||||
|
//判断收礼人是否是主持
|
||||||
|
if (in_array($value, $host)) {
|
||||||
|
$is_preside = 1;
|
||||||
|
$is_preside_user[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//送礼人是主持或嘉宾
|
||||||
|
if (in_array($uid, $host)) {
|
||||||
|
$is_preside = 1;
|
||||||
|
$is_preside_user[] = $uid;
|
||||||
|
}
|
||||||
|
return ['is_preside' =>$is_preside,'is_preside_user' => $is_preside_user];
|
||||||
|
}
|
||||||
|
|
||||||
|
function pullHeartChange($room_id,$friend_id){
|
||||||
|
//聊天室心动值变化通知
|
||||||
|
$newRanking = $this->getRanking($room_id,$friend_id);
|
||||||
|
//心动值和心动表id
|
||||||
|
if(!isset($newRanking[0]['heart_value']) || $newRanking[0]['heart_value'] <= 0){
|
||||||
|
$heart1 = -1;
|
||||||
|
$heartId1 = -1;
|
||||||
|
}else{
|
||||||
|
$heart1 = $newRanking[0]['heart_value'];
|
||||||
|
$heartId1 = $newRanking[0]['id'];
|
||||||
|
}
|
||||||
|
if(!isset($newRanking[1]['heart_value']) || $newRanking[1]['heart_value'] <= 0){
|
||||||
|
$heart2 = -1;
|
||||||
|
$heartId2 = -1;
|
||||||
|
}else{
|
||||||
|
$heart2 = $newRanking[1]['heart_value'];
|
||||||
|
$heartId2 = $newRanking[1]['id'];
|
||||||
|
}
|
||||||
|
if(!isset($newRanking[2]['heart_value']) || $newRanking[2]['heart_value'] <= 0){
|
||||||
|
$heart3 = -1;
|
||||||
|
$heartId3 = -1;
|
||||||
|
}else{
|
||||||
|
$heart3 = $newRanking[2]['heart_value'];
|
||||||
|
$heartId3 = $newRanking[2]['id'];
|
||||||
|
}
|
||||||
|
$heart[0] = [
|
||||||
|
"heartNum" => $heart1,
|
||||||
|
"heartId" => $heartId1,
|
||||||
|
];
|
||||||
|
$heart[1] = [
|
||||||
|
"heartNum" => $heart2,
|
||||||
|
"heartId" => $heartId2,
|
||||||
|
];
|
||||||
|
$heart[2] = [
|
||||||
|
"heartNum" => $heart3,
|
||||||
|
"heartId" => $heartId3,
|
||||||
|
];
|
||||||
|
|
||||||
|
// $push = new Push(0, $this->room_id); //实例化推送类
|
||||||
|
// $push->heartChatRoom($heart);
|
||||||
|
//推送给前端消息
|
||||||
|
$text['text'] = '心动值变化通知';
|
||||||
|
$text['list'] = $heart;
|
||||||
|
model('api/Chat')->sendMsg(1054,$room_id,$text);
|
||||||
|
return $heart;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取心跳值排行
|
||||||
|
public function getRanking($room_id,$friend_id) {
|
||||||
|
// 获取有心动值的用户对且不重复
|
||||||
|
$originalPairs = db::name('vs_user_friending_heart')
|
||||||
|
->where(['room_id'=>$room_id,'friend_id'=>$friend_id])
|
||||||
|
->order('heart_value DESC')->select();
|
||||||
|
// 初始化排名数组和已使用用户数组
|
||||||
|
$ranking = [];
|
||||||
|
$usedUsers = [];
|
||||||
|
// 优先选择高价值且无重复用户的对
|
||||||
|
$heart_ids = [];
|
||||||
|
foreach ($originalPairs as &$rel) {
|
||||||
|
// 检查当前用户对是否包含已使用的用户ID
|
||||||
|
if (!in_array($rel['user1_id'], $usedUsers) &&
|
||||||
|
!in_array($rel['user2_id'], $usedUsers)) {
|
||||||
|
// 将符合条件的用户对添加到排名列表中
|
||||||
|
$ranking[] = [
|
||||||
|
'heart_value' => $rel['heart_value'],
|
||||||
|
'id' => $rel['id'],
|
||||||
|
'user1_id' => $rel['user1_id'],
|
||||||
|
'user2_id' => $rel['user2_id'],
|
||||||
|
];
|
||||||
|
// 更新已使用用户列表
|
||||||
|
$usedUsers = array_merge($usedUsers, [$rel['user1_id'], $rel['user2_id']]);
|
||||||
|
$heart_ids[] = $rel['id'];
|
||||||
|
// 如果排名列表达到3对用户,则停止循环
|
||||||
|
if (count($ranking) >= 3) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ranking1 = [];
|
||||||
|
$ranking2 = [];
|
||||||
|
if(count($ranking)<3){
|
||||||
|
$make_up_num = 3 - count($ranking);
|
||||||
|
$ranking_make_up = db::name('vs_user_friending_heart')
|
||||||
|
->where(['room_id'=>$room_id,'friend_id'=>$friend_id ,'id'=> ['notin',$heart_ids]])
|
||||||
|
->limit($make_up_num)
|
||||||
|
->order('heart_value DESC')->select();
|
||||||
|
foreach ($ranking_make_up as $rel1) {
|
||||||
|
// 如果两个用户都已使用,跳过这条记录
|
||||||
|
if(in_array($rel1['user1_id'], $usedUsers) && in_array($rel1['user2_id'], $usedUsers)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果只有user1已使用,将user2加入排名
|
||||||
|
if(in_array($rel1['user1_id'], $usedUsers)){
|
||||||
|
$ranking1[] = [
|
||||||
|
'heart_value' => 0,
|
||||||
|
'id' => $rel1['id'],
|
||||||
|
'user1_id' => -1,
|
||||||
|
'user2_id' => $rel1['user2_id'],
|
||||||
|
];
|
||||||
|
$usedUsers[] = $rel1['user2_id'];
|
||||||
|
$heart_ids[] = $rel1['id'];
|
||||||
|
}
|
||||||
|
// 如果只有user2已使用,将user1加入排名
|
||||||
|
elseif(in_array($rel1['user2_id'], $usedUsers)){
|
||||||
|
$ranking1[] = [
|
||||||
|
'heart_value' => 0,
|
||||||
|
'id' => $rel1['id'],
|
||||||
|
'user1_id' => $rel1['user1_id'],
|
||||||
|
'user2_id' => -1,
|
||||||
|
];
|
||||||
|
$usedUsers[] = $rel1['user1_id'];
|
||||||
|
$heart_ids[] = $rel1['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// 返回最终的排名列表
|
||||||
|
$ranking_rut = array_merge($ranking, $ranking1);
|
||||||
|
$nnum = count($ranking)*2 + count($ranking1);
|
||||||
|
if($nnum<6){
|
||||||
|
$make_up_num = 6 - $nnum;
|
||||||
|
$ranking_make_up = db::name('vs_user_friending_heart')
|
||||||
|
->where(array('room_id'=>$room_id,'friend_id'=>$friend_id ,'id'=>array('notin',$heart_ids)))
|
||||||
|
->limit($make_up_num)
|
||||||
|
->order('heart_value DESC')->select();
|
||||||
|
if($ranking_make_up){
|
||||||
|
foreach ($ranking_make_up as $rel1) {
|
||||||
|
if(in_array($rel1['user1_id'], $usedUsers) && in_array($rel1['user2_id'], $usedUsers)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(in_array($rel1['user1_id'], $usedUsers)){
|
||||||
|
$ranking2[] = [
|
||||||
|
'heart_value' => 0,
|
||||||
|
'id' => $rel1['id'],
|
||||||
|
'user1_id' => -1,
|
||||||
|
'user2_id' => $rel1['user2_id'],
|
||||||
|
];
|
||||||
|
$usedUsers[] = $rel1['user2_id'];
|
||||||
|
}
|
||||||
|
if(in_array($rel1['user2_id'], $usedUsers)){
|
||||||
|
$ranking2[] = [
|
||||||
|
'heart_value' => 0,
|
||||||
|
'id' => $rel1['id'],
|
||||||
|
'user1_id' => $rel1['user1_id'],
|
||||||
|
'user2_id' => -1,
|
||||||
|
];
|
||||||
|
$usedUsers[] = $rel1['user1_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return array_merge($ranking_rut, $ranking2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//抱上麦 还是换麦
|
||||||
|
public function pullUserPit($room_id,$friend_id){
|
||||||
|
$friendPlayPit = $this->friendPlayPit($room_id,$friend_id); // 获取实际应该对应的麦位
|
||||||
|
$this->changePitToPosPair($room_id,$friendPlayPit);//换麦,上下麦
|
||||||
|
$this->pullHeartChange($room_id,$friend_id);//聊天室心动值变化通知
|
||||||
|
}
|
||||||
|
|
||||||
|
//交友处理麦位排名
|
||||||
|
public function friendPlayPit($room_id,$friend_id){
|
||||||
|
//查询当前交友心动值表
|
||||||
|
$heart_data = $this->getRanking($room_id,$friend_id);
|
||||||
|
//数组根据里面的heart_value 由大到小进行排序
|
||||||
|
usort($heart_data, function($a, $b) {
|
||||||
|
return $b['heart_value'] - $a['heart_value'];
|
||||||
|
});
|
||||||
|
$pit = [];
|
||||||
|
$pit_number_array = [2=>5,1=>6,3=>4,5=>2,6=>1,4=>3]; //麦位对应关系
|
||||||
|
$pit_number_array_reverse = [0=>2,1=>1,2=>3,3=>4,4=>5,5=>6];
|
||||||
|
if($heart_data){
|
||||||
|
//排麦位
|
||||||
|
$pit_unique = [];
|
||||||
|
$key = 0;
|
||||||
|
foreach($heart_data as $value) {
|
||||||
|
if(count($pit) >= 6){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理两个用户都存在的情况
|
||||||
|
if($value['user1_id'] != -1 && $value['user2_id'] != -1){
|
||||||
|
if(!in_array($value['user1_id'],$pit_unique)){
|
||||||
|
// 检查目标麦位是否已被占用
|
||||||
|
if(!isset($pit[$pit_number_array_reverse[$key]])) {
|
||||||
|
$pit[$pit_number_array_reverse[$key]] = $value['user1_id'];
|
||||||
|
$pit[$pit_number_array[$pit_number_array_reverse[$key]]] = $value['user2_id'];
|
||||||
|
$pit_unique = array_merge($pit_unique, [$value['user1_id'], $value['user2_id']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 处理只有user2存在的情况
|
||||||
|
elseif($value['user1_id'] == -1 && !in_array($value['user2_id'],$pit_unique)){
|
||||||
|
// 检查该键是否已被使用
|
||||||
|
if(!isset($pit[$pit_number_array_reverse[$key]])) {
|
||||||
|
$pit[$pit_number_array_reverse[$key]] = $value['user2_id'];
|
||||||
|
$pit_unique[] = $value['user2_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 处理只有user1存在的情况
|
||||||
|
elseif($value['user2_id'] == -1 && !in_array($value['user1_id'],$pit_unique)){
|
||||||
|
// 检查该键是否已被使用
|
||||||
|
if(!isset($pit[$pit_number_array_reverse[$key]])) {
|
||||||
|
$pit[$pit_number_array_reverse[$key]] = $value['user1_id'];
|
||||||
|
$pit_unique[] = $value['user1_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$key++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $pit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//换麦
|
||||||
|
public function changePitToPosPairs($room_id,$friendPlayPit){
|
||||||
|
$now_pit_u = array_flip($friendPlayPit);
|
||||||
|
//按照键值排序数组
|
||||||
|
ksort($now_pit_u);
|
||||||
|
//查询现在麦位上有用户的数据 并且重组结果,键为麦位,值为用户,值必须存在,没值则不展示
|
||||||
|
$pit_user = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number'=>['<',7],'user_id' => ['>', 0]])
|
||||||
|
->order('pit_number ASC')
|
||||||
|
->column('pit_number,user_id');
|
||||||
|
//比较两个数组,无论是键的差异还是值的差异,都输出字符串”有差异“否则输出”没有差异“
|
||||||
|
$result = array_diff_assoc($pit_user, $now_pit_u);
|
||||||
|
$result2 = array_diff_assoc($now_pit_u, $pit_user);
|
||||||
|
if(!empty($result) || !empty($result2)){
|
||||||
|
// var_dump('有差异');
|
||||||
|
//获取实际麦位上的用
|
||||||
|
$newPitUser = array_keys($friendPlayPit);
|
||||||
|
//获取当前麦位上的用户
|
||||||
|
$oldPitUser = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number'=>['<',7]])->column('user_id');
|
||||||
|
//获取交集
|
||||||
|
$intersection = array_intersect($newPitUser,$oldPitUser);
|
||||||
|
//取差集
|
||||||
|
$diff = array_diff($newPitUser,$oldPitUser);
|
||||||
|
$changeData = [];
|
||||||
|
if($diff){
|
||||||
|
//推下麦
|
||||||
|
foreach($diff as $key => $value){
|
||||||
|
if(in_array($value,$oldPitUser)){
|
||||||
|
//查询当前空麦位
|
||||||
|
$pit_null = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||||
|
if($pit_null){
|
||||||
|
// $this->room_pit_model->getOnPit($this->room_id, $value, $pit_null);
|
||||||
|
model('api/RoomPit')->OnPit($value, $room_id, $pit_null);
|
||||||
|
// db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_null])->update(['user_id' => $value]);
|
||||||
|
}else{
|
||||||
|
//下麦
|
||||||
|
$UserRoomPit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $value])->value('pit_number');
|
||||||
|
model('api/RoomPit')->DownPit($value, $room_id, $UserRoomPit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in_array($value,$newPitUser)){
|
||||||
|
//推上麦
|
||||||
|
//获取目标麦位是否有人
|
||||||
|
$getRoomPitUser= db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $friendPlayPit[$value]])->value('user_id');
|
||||||
|
if($getRoomPitUser){
|
||||||
|
//查询当前空麦位
|
||||||
|
$getRoomNullPitss = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10,$friendPlayPit[$value]]);
|
||||||
|
if($getRoomNullPitss){
|
||||||
|
// $this->room_pit_model->getOnPit($this->room_id, $getRoomPitUser, $getRoomNullPitss);
|
||||||
|
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $getRoomNullPitss])->update(['user_id' => $getRoomPitUser]);
|
||||||
|
}else{
|
||||||
|
model('api/RoomPit')->DownPit($getRoomPitUser, $room_id, $friendPlayPit[$value]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model('api/RoomPit')->OnPit($value, $room_id, $friendPlayPit[$value]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($intersection){//交换麦位
|
||||||
|
//查询麦上的用户
|
||||||
|
$newPitUserStr = implode(',',$newPitUser);
|
||||||
|
$getRoomPit = db::name('vs_room_pit')->where("room_id=".$room_id." AND user_id in (".$newPitUserStr.")")->column('pit_number');
|
||||||
|
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['in', $getRoomPit]])->update(['user_id' => 0]);
|
||||||
|
$changePitUser = [];
|
||||||
|
foreach ($friendPlayPit as $key => $value){
|
||||||
|
if(empty($value)){
|
||||||
|
$value = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||||
|
}
|
||||||
|
//获取目标麦位是否有人
|
||||||
|
$isPitHaveUser= db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $value])->value('user_id');
|
||||||
|
if($isPitHaveUser && !in_array($isPitHaveUser,$newPitUser)){
|
||||||
|
$changePitUser[$key]['user_id'] = $isPitHaveUser;
|
||||||
|
$changePitUser[$key]['pit_number'] = $value;
|
||||||
|
}
|
||||||
|
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $value])->update(['user_id' => $key]);
|
||||||
|
}
|
||||||
|
//处理原麦位上的用户
|
||||||
|
foreach ($changePitUser as $key_change => $value_change){
|
||||||
|
//判断是否在左边 1,,2,,3 麦位上
|
||||||
|
if(in_array($value_change['pit_number'],[1,2,3])){
|
||||||
|
$null_pit = model('api/RoomPit')->getRoomNullPitWithout($room_id, [4,5,6,7,8,9,10]);
|
||||||
|
if(empty($null_pit)){
|
||||||
|
$null_pit = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$null_pit = model('api/RoomPit')->getRoomNullPitWithout($room_id, [1,2,3,7,8,9,10]);
|
||||||
|
if(empty($null_pit)){
|
||||||
|
$null_pit = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $null_pit])->update(['user_id' => $value_change['user_id']]);
|
||||||
|
}
|
||||||
|
// $getRoomNullPit = $this->room_pit_model->where(['room_id'=>$room_id,'pit_number'=>['notin',[7,9]]])->select();
|
||||||
|
$getRoomNullPit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7]])->select();
|
||||||
|
$data_users = [];
|
||||||
|
foreach($getRoomNullPit as $key_data => $value_data){
|
||||||
|
$data_users[$key_data]['user_id'] = $value_data['user_id'];
|
||||||
|
$data_users[$key_data]['nickname'] = db::name('user')->where('id',$value_data['user_id'])->value('nickname');
|
||||||
|
$data_users[$key_data]['avatar'] = db::name('user')->where('id',$value_data['user_id'])->value('avatar');
|
||||||
|
$data_users[$key_data]['sex'] = db::name('user')->where('id',$value_data['user_id'])->value('sex');
|
||||||
|
//获取用户在此房间今天的魅力值
|
||||||
|
$charm =[];
|
||||||
|
if($value_data['user_id']){
|
||||||
|
$charm = db::name('vs_room_user_charm')->where(['user_id' => $value_data['user_id'],'room_id' => $room_id])->value('charm');
|
||||||
|
}
|
||||||
|
$data_users[$key_data]['dress'] = model('Decorate')->user_decorate_detail($value_data['user_id'],1);
|
||||||
|
$data_users[$key_data]['charm'] = $charm??0;
|
||||||
|
$data_users[$key_data]['pit_number'] = $value_data['pit_number'];
|
||||||
|
}
|
||||||
|
//推送给前端消息
|
||||||
|
$text['text'] = '房间换麦位';
|
||||||
|
$text['list'] = $data_users;
|
||||||
|
model('api/Chat')->sendMsg(1053,$room_id,$text);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//换麦
|
||||||
|
public function changePitToPosPair($room_id,$friendPlayPit){
|
||||||
|
$new_pit_u = $friendPlayPit;
|
||||||
|
//按照键值排序数组
|
||||||
|
ksort($new_pit_u);
|
||||||
|
//查询原有麦位上有用户的数据 并且重组结果,键为麦位,值为用户,值必须存在,没值则不展示
|
||||||
|
$pit_users = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number'=>['<',7],'user_id' => ['>', 0]])
|
||||||
|
->order('pit_number ASC')
|
||||||
|
->field('pit_number,user_id')->select();
|
||||||
|
$pit_user = [];
|
||||||
|
foreach ($pit_users as $value_pit_user){
|
||||||
|
$pit_user[$value_pit_user['pit_number']] = $value_pit_user['user_id'];
|
||||||
|
}
|
||||||
|
//比较两个数组,无论是键的差异还是值的差异,都输出字符串”有差异“否则输出”没有差异“
|
||||||
|
$result = array_diff_assoc($pit_user, $new_pit_u);//第一个数组中存在但其他数组中不存在的键/值对
|
||||||
|
$result2 = array_diff_assoc($new_pit_u, $pit_user);
|
||||||
|
if(!empty($result) || !empty($result2)){//换麦
|
||||||
|
db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number' => ['<',7]])->update(['user_id' => 0]);
|
||||||
|
//新麦位上的用户
|
||||||
|
foreach ($new_pit_u as $key_result2 => $value_result2){
|
||||||
|
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $key_result2])->update(['user_id' => $value_result2]);
|
||||||
|
}
|
||||||
|
if($result){//原有麦位上的用户,且不在新麦位上的用户
|
||||||
|
foreach ($result as $key_result => $value_result){
|
||||||
|
$pit_null = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||||
|
$onPitUser = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $value_result])->find();
|
||||||
|
if($pit_null && !$onPitUser){
|
||||||
|
db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_null])->update(['user_id' => $value_result]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$getRoomNullPit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7]])->select();
|
||||||
|
$data_users = [];
|
||||||
|
foreach($getRoomNullPit as $key_data => $value_data){
|
||||||
|
$data_users[$key_data]['user_id'] = $value_data['user_id'];
|
||||||
|
$data_users[$key_data]['nickname'] = db::name('user')->where('id',$value_data['user_id'])->value('nickname');
|
||||||
|
$data_users[$key_data]['avatar'] = db::name('user')->where('id',$value_data['user_id'])->value('avatar');
|
||||||
|
$data_users[$key_data]['sex'] = db::name('user')->where('id',$value_data['user_id'])->value('sex');
|
||||||
|
//获取用户在此房间今天的魅力值
|
||||||
|
$charm =[];
|
||||||
|
if($value_data['user_id']){
|
||||||
|
$charm = db::name('vs_room_user_charm')->where(['user_id' => $value_data['user_id'],'room_id' => $room_id])->value('charm');
|
||||||
|
}
|
||||||
|
$data_users[$key_data]['dress'] = model('Decorate')->user_decorate_detail($value_data['user_id'],1);
|
||||||
|
$data_users[$key_data]['charm'] = $charm??0;
|
||||||
|
$data_users[$key_data]['pit_number'] = $value_data['pit_number'];
|
||||||
|
}
|
||||||
|
//推送给前端消息
|
||||||
|
$text['text'] = '房间换麦位';
|
||||||
|
$text['list'] = $data_users;
|
||||||
|
model('api/Chat')->sendMsg(1053,$room_id,$text);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//交友厅游戏开始后送礼后一系列操作
|
||||||
|
//插入/更新心动表
|
||||||
|
public function addUserHeart($uid,$user_id,$friend_id,$value,$room_id,$user_data){
|
||||||
|
//给多个用户送礼
|
||||||
|
//数组重组 下标从0开始
|
||||||
|
$user_ids = array_values($user_id);
|
||||||
|
// $heart_value = $value;//心动值
|
||||||
|
$heart_value = 0;
|
||||||
|
$heart_exp = get_system_config_value('coin_charm_exp');//金币与魅力值转换比
|
||||||
|
for ($i = 0; $i < count($user_ids); $i++) {
|
||||||
|
foreach ($user_data as $cv){
|
||||||
|
if($user_ids[$i] == $cv['user_id']){
|
||||||
|
$heart_value = $cv['gift_price'] * $heart_exp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 处理用户ID顺序
|
||||||
|
$user1 = min($uid, $user_ids[$i]);
|
||||||
|
$user2 = max($uid, $user_ids[$i]);
|
||||||
|
// 更新心动关系表
|
||||||
|
$relation = db::name('vs_user_friending_heart')->where([
|
||||||
|
'user1_id' => $user1,
|
||||||
|
'user2_id' => $user2,
|
||||||
|
'friend_id' => $friend_id
|
||||||
|
])->find();
|
||||||
|
|
||||||
|
if ($relation) {
|
||||||
|
db::name('vs_user_friending_heart')->where([
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'user1_id' => $user1,
|
||||||
|
'user2_id' => $user2,
|
||||||
|
'friend_id' => $friend_id
|
||||||
|
])->setInc('heart_value', $heart_value);
|
||||||
|
} else {
|
||||||
|
$relation['id'] = db::name('vs_user_friending_heart')->insert([
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'user1_id' => $user1,
|
||||||
|
'user2_id' => $user2,
|
||||||
|
'friend_id' => $friend_id,
|
||||||
|
'heart_value' => $heart_value
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//修改用户心动连线状态
|
||||||
|
// $relation = db::name('vs_user_friending_heart')->where("(user1_id=".$uid." OR user2_id=".$uid.") AND friend_id=$friend_id AND room_id=$room_id AND status!=3")->order('heart_value desc')->find();
|
||||||
|
// if($relation){
|
||||||
|
// db::name('vs_user_friending_heart')->where("(user1_id=".$uid." OR user2_id=".$uid.") AND friend_id=$friend_id AND room_id=$room_id AND status!=3")->update(['status'=>2]);
|
||||||
|
// db::name('vs_user_friending_heart')->where(['id'=>$relation['id']])->update(['status'=>1]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
73
application/api/model/RoomHourRanking.php
Normal file
73
application/api/model/RoomHourRanking.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\model;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
class RoomHourRanking extends Model
|
||||||
|
{
|
||||||
|
//房间小时榜
|
||||||
|
public function room_hour_ranking($page, $page_limit,$start_time = null, $end_time = null)
|
||||||
|
{
|
||||||
|
//当前小时开始时间
|
||||||
|
if($start_time == null){
|
||||||
|
$start_time = strtotime(date('Y-m-d H:00:00'));
|
||||||
|
}
|
||||||
|
|
||||||
|
//结束时间
|
||||||
|
if($end_time == null){
|
||||||
|
$end_time = strtotime(date('Y-m-d H:59:59'));
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断是否开启
|
||||||
|
$open_time = db::name('vs_hour_ranking_config')->where('id', 1)->value('open_time');
|
||||||
|
if ($open_time == 0) {
|
||||||
|
return ['code' => 0, 'msg' => '排行榜暂未开启', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
//是否开启巡乐会
|
||||||
|
$is_open_xlh = db::name('vs_hour_ranking_config')->where('id', 1)->value('is_open_xlh');
|
||||||
|
|
||||||
|
// 更进一步的优化版本:
|
||||||
|
$subQuery = Db::name('vs_give_gift')
|
||||||
|
->where('from', 2)
|
||||||
|
->whereBetween('createtime', [$start_time, $end_time])
|
||||||
|
->buildSql();
|
||||||
|
|
||||||
|
$profit = db::name('vs_room')->alias('a')
|
||||||
|
->join([$subQuery => 'b'], 'a.id = b.from_id', 'left')
|
||||||
|
->join('vs_room_label c', 'a.label_id = c.id','left')
|
||||||
|
->field('a.id as room_id,a.user_id,a.room_name,a.label_id,a.room_cover,IFNULL(SUM(b.total_price), 0) as total_price,c.label_icon')
|
||||||
|
->where('a.room_status', 1)
|
||||||
|
->where('a.apply_status', 2)
|
||||||
|
->where('a.type_id', '<>', 6)
|
||||||
|
->group('a.id')
|
||||||
|
->order('total_price', 'desc')
|
||||||
|
->page($page, $page_limit)
|
||||||
|
->select();
|
||||||
|
|
||||||
|
if($profit){
|
||||||
|
foreach ($profit as &$v) {
|
||||||
|
$v['total_price'] = $v['total_price'] * get_system_config_value('coin_charm_exp');
|
||||||
|
if($v['room_id'] > 0 && $is_open_xlh == 1){
|
||||||
|
$xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($v['room_id']);
|
||||||
|
$v['xlh_status'] = $xlh_status['xlh_status'];
|
||||||
|
}else{
|
||||||
|
$v['xlh_status'] = 0;
|
||||||
|
}
|
||||||
|
//查询房间是否有红包
|
||||||
|
if($v['room_id'] > 0){
|
||||||
|
$red_pack_status = Db::name('redpacket')->where(['room_id' => $v['room_id'], 'status' => ['<=',1]])->count();
|
||||||
|
$v['redpacket_status'] = $red_pack_status;
|
||||||
|
}else{
|
||||||
|
$v['redpacket_status'] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//当前小时开始时间 和结束时间 00:00-00:59 这样的格式
|
||||||
|
$time_range = date('H:') . '00-' . date('H:'). '59';
|
||||||
|
return ['code' => 1, 'msg' => '获取成功', 'data' => ['time_range' => $time_range, 'lists' =>$profit]];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
114
application/common/library/RedpacketLua.php
Normal file
114
application/common/library/RedpacketLua.php
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\library;
|
||||||
|
|
||||||
|
class RedpacketLua
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 抢红包Lua脚本
|
||||||
|
* 保证原子性操作,防止超抢
|
||||||
|
*/
|
||||||
|
public static function grabRedpacketScript()
|
||||||
|
{
|
||||||
|
return <<<LUA
|
||||||
|
-- KEYS[1]: 红包key, KEYS[2]: 用户集合key, KEYS[3]: 用户ID
|
||||||
|
-- ARGV[1]: 当前时间
|
||||||
|
|
||||||
|
local redpacketKey = KEYS[1]
|
||||||
|
local userSetKey = KEYS[2]
|
||||||
|
local userId = KEYS[3]
|
||||||
|
local currentTime = tonumber(ARGV[1])
|
||||||
|
|
||||||
|
-- 检查红包是否存在
|
||||||
|
local redpacketData = redis.call('HGETALL', redpacketKey)
|
||||||
|
if not redpacketData or #redpacketData == 0 then
|
||||||
|
return {0, "红包不存在", 0}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 将哈希数据转为table
|
||||||
|
local redpacket = {}
|
||||||
|
for i = 1, #redpacketData, 2 do
|
||||||
|
redpacket[redpacketData[i]] = redpacketData[i + 1]
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 检查红包状态
|
||||||
|
local status = tonumber(redpacket['status'])
|
||||||
|
local startTime = tonumber(redpacket['start_time'])
|
||||||
|
local endTime = tonumber(redpacket['end_time'])
|
||||||
|
|
||||||
|
if status == 0 then
|
||||||
|
if currentTime < startTime then
|
||||||
|
return {0, "红包还未开始", 0}
|
||||||
|
else
|
||||||
|
-- 更新状态为进行中(1)
|
||||||
|
redis.call('HSET', redpacketKey, 'status', 1)
|
||||||
|
status = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if status ~= 1 then
|
||||||
|
return {0, "红包已结束", 0}
|
||||||
|
end
|
||||||
|
|
||||||
|
if currentTime > endTime then
|
||||||
|
redis.call('HSET', redpacketKey, 'status', 2)
|
||||||
|
return {0, "红包已结束", 0}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 检查是否已经抢过
|
||||||
|
local hasGrabbed = redis.call('SISMEMBER', userSetKey, userId)
|
||||||
|
if hasGrabbed == 1 then
|
||||||
|
return {0, "已经抢过该红包", 0}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 检查是否还有剩余
|
||||||
|
local leftAmount = tonumber(redpacket['left_amount'])
|
||||||
|
local leftCount = tonumber(redpacket['left_count'])
|
||||||
|
|
||||||
|
if leftCount <= 0 or leftAmount <= 0 then
|
||||||
|
return {0, "红包已抢完", 0}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 计算红包金额
|
||||||
|
local amount = 0
|
||||||
|
local isFinished = 0
|
||||||
|
|
||||||
|
if leftCount == 1 then
|
||||||
|
-- 最后一个红包,获得剩余所有金额
|
||||||
|
amount = leftAmount
|
||||||
|
isFinished = 1
|
||||||
|
else
|
||||||
|
-- 随机算法:二倍均值法,保证公平性
|
||||||
|
local maxAmount = leftAmount / leftCount * 2
|
||||||
|
amount = math.random(1, math.floor(maxAmount))
|
||||||
|
-- 确保金额不会超过剩余金额
|
||||||
|
if amount > leftAmount then
|
||||||
|
amount = leftAmount
|
||||||
|
end
|
||||||
|
-- 检查是否是最后一个(由于浮点数计算可能有误差)
|
||||||
|
if leftCount == 1 or (leftAmount - amount) < 0.01 then
|
||||||
|
isFinished = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 更新红包数据
|
||||||
|
local newLeftAmount = leftAmount - amount
|
||||||
|
local newLeftCount = leftCount - 1
|
||||||
|
|
||||||
|
redis.call('HSET', redpacketKey, 'left_amount', newLeftAmount)
|
||||||
|
redis.call('HSET', redpacketKey, 'left_count', newLeftCount)
|
||||||
|
|
||||||
|
-- 标记用户已抢
|
||||||
|
redis.call('SADD', userSetKey, userId)
|
||||||
|
|
||||||
|
-- 如果抢完了,更新状态为已结束(2)
|
||||||
|
if isFinished == 1 then
|
||||||
|
redis.call('HSET', redpacketKey, 'status', 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
return {1, tostring(amount), isFinished}
|
||||||
|
LUA;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
171
application/common/model/Redpacket.php
Normal file
171
application/common/model/Redpacket.php
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use app\common\controller\Push;
|
||||||
|
use think\Model;
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
|
class Redpacket extends Model
|
||||||
|
{
|
||||||
|
// 红包状态
|
||||||
|
const STATUS_PENDING = 0; // 未开始
|
||||||
|
const STATUS_ACTIVE = 1; // 进行中
|
||||||
|
const STATUS_FINISHED = 2; // 已结束
|
||||||
|
const STATUS_REFUNDED = 3; // 已退回
|
||||||
|
|
||||||
|
// 红包类型
|
||||||
|
const TYPE_NORMAL = 1; // 普通红包
|
||||||
|
const TYPE_PASSWORD = 2; // 口令红包
|
||||||
|
|
||||||
|
// 币种类型
|
||||||
|
const COIN_GOLD = 1; // 金币
|
||||||
|
const COIN_DIAMOND = 2; // 钻石
|
||||||
|
|
||||||
|
// 倒计时选项
|
||||||
|
public static $countdownOptions = [
|
||||||
|
0 => '立刻',
|
||||||
|
60 => '1分钟',
|
||||||
|
120 => '2分钟',
|
||||||
|
300 => '5分钟',
|
||||||
|
600 => '10分钟'
|
||||||
|
];
|
||||||
|
|
||||||
|
// 领取条件
|
||||||
|
const CONDITION_NONE = 0;
|
||||||
|
const CONDITION_COLLECT_ROOM = 1;
|
||||||
|
const CONDITION_MIC_USER = 2;
|
||||||
|
|
||||||
|
protected $autoWriteTimestamp = true;
|
||||||
|
protected $createTime = 'createtime';
|
||||||
|
protected $updateTime = 'updatetime';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发红包
|
||||||
|
*/
|
||||||
|
public function createRedpacket($data)
|
||||||
|
{
|
||||||
|
// var_dump($data);exit;
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
// 验证用户余额
|
||||||
|
$wallet = Db::name('user_wallet')->where('user_id', $data['user_id'])->find();
|
||||||
|
|
||||||
|
$coinField = $data['coin_type'] == self::COIN_GOLD ? 'coin' : 'earnings';
|
||||||
|
if ($wallet[$coinField] < $data['total_amount']) {
|
||||||
|
return ['code' => 0, 'msg' => '余额不足', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 扣除余额
|
||||||
|
$delres = Db::name('user_wallet')
|
||||||
|
->where('user_id', $data['user_id'])
|
||||||
|
->dec($coinField, $data['total_amount'])
|
||||||
|
->update();
|
||||||
|
//记录日志 32-发红包(金币),29-发红包(钻石),30-抢红包(金币),31-抢红包(钻石)
|
||||||
|
//记录用户金币日志
|
||||||
|
$data_log = [
|
||||||
|
'user_id' => $data['user_id'],
|
||||||
|
'change_value' => $data['total_amount'],
|
||||||
|
'room_id' => $data['room_id'],
|
||||||
|
'money_type' => $data['coin_type'],
|
||||||
|
'change_type' => $data['coin_type'] == self::COIN_GOLD ? 32 : 29,
|
||||||
|
'from_id' => $data['room_id'],
|
||||||
|
'remarks' => $data['coin_type'] == self::COIN_GOLD ? '金币(发红包)' : '钻石(发红包)',
|
||||||
|
'createtime' => time()
|
||||||
|
];
|
||||||
|
|
||||||
|
$res = Db::name('vs_user_money_log')->insert($data_log);
|
||||||
|
if(!$res || !$delres){
|
||||||
|
Db::rollback();
|
||||||
|
}
|
||||||
|
// 计算开始时间
|
||||||
|
$startTime = $data['countdown'] > 0 ? (time() + $data['countdown']) : time();
|
||||||
|
//获取配置项 红包没有抢完所展示时间
|
||||||
|
$endTime = $startTime + get_system_config_value('red_packet_time') ?? 120; // 默认2分钟后结束
|
||||||
|
|
||||||
|
// 创建红包
|
||||||
|
$redpacketData = [
|
||||||
|
'user_id' => $data['user_id'],
|
||||||
|
'room_id' => $data['room_id'],
|
||||||
|
'type' => $data['type'],
|
||||||
|
'password' => $data['password'] ?? '',
|
||||||
|
'countdown' => $data['countdown'],
|
||||||
|
'coin_type' => $data['coin_type'],
|
||||||
|
'total_amount' => $data['total_amount'],
|
||||||
|
'total_count' => $data['total_count'],
|
||||||
|
'left_amount' => $data['total_amount'],
|
||||||
|
'left_count' => $data['total_count'],
|
||||||
|
'conditions' => $data['conditions'] ?? '',
|
||||||
|
'status' => $data['countdown'] > 0 ? self::STATUS_PENDING : self::STATUS_ACTIVE,
|
||||||
|
'start_time' => $startTime,
|
||||||
|
'end_time' => $endTime,
|
||||||
|
'createtime' => time(),
|
||||||
|
'remark' => (!empty($data['remark']) && trim($data['remark']) !== '') ? trim($data['remark']) : '大吉大利,红包拿来啦!'
|
||||||
|
];
|
||||||
|
|
||||||
|
$redpacketId = $this->insertGetId($redpacketData);
|
||||||
|
|
||||||
|
// 设置Redis缓存
|
||||||
|
$redis = \think\Cache::store('redis')->handler();
|
||||||
|
$redisKey = "redpacket:{$redpacketId}";
|
||||||
|
$redis->hMSet($redisKey, [
|
||||||
|
'total_amount' => $data['total_amount'],
|
||||||
|
'left_amount' => $data['total_amount'],
|
||||||
|
'total_count' => $data['total_count'],
|
||||||
|
'left_count' => $data['total_count'],
|
||||||
|
'status' => $redpacketData['status'],
|
||||||
|
'start_time' => $startTime,
|
||||||
|
'end_time' => $endTime
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 设置过期时间
|
||||||
|
$redis->expireAt($redisKey, $endTime + 3600); // 结束后保留1小时
|
||||||
|
Db::commit();
|
||||||
|
|
||||||
|
//给前端推送信息
|
||||||
|
$data['nickname'] = Db::name('user')->where('id', $data['user_id'])->value('nickname');
|
||||||
|
$data['avatar'] = Db::name('user')->where('id', $data['user_id'])->value('avatar');
|
||||||
|
$data['redpacket_id'] = $redpacketId;
|
||||||
|
$data['start_time'] = $startTime;//红包开抢时间
|
||||||
|
$data['redpacket_time'] = get_system_config_value('red_packet_time');//展示时间
|
||||||
|
$data['room_name'] = Db::name('vs_room')->where('id', $data['room_id'])->value('room_name');
|
||||||
|
$text = [
|
||||||
|
'redpacketInfo' => $data,
|
||||||
|
'text' => ''
|
||||||
|
];
|
||||||
|
model('api/Chat')->sendMsg(1060,$data['room_id'],$text);
|
||||||
|
$push = new Push(UID, $data['room_id']);
|
||||||
|
$texts = [
|
||||||
|
'room_id' => $data['room_id'],
|
||||||
|
'text' => $data['nickname'].'在'.$data['room_name'].'房间发了一个红包!',
|
||||||
|
'room_name' => $data['room_name'],
|
||||||
|
'nickname' => $data['nickname']
|
||||||
|
];
|
||||||
|
$push->redpacketArrive($texts);
|
||||||
|
|
||||||
|
return ['code' => 1, 'msg' => '发红包成功', 'data' => $redpacketId];
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取红包信息
|
||||||
|
*/
|
||||||
|
public function getRedpacketInfo($id)
|
||||||
|
{
|
||||||
|
$redpacket = $this->find($id);
|
||||||
|
if (!$redpacket) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$redpacket = $redpacket->toArray();
|
||||||
|
$redpacket['nickname'] = Db::name('user')->where('id', $redpacket['user_id'])->value('nickname');
|
||||||
|
$redpacket['avatar'] = Db::name('user')->where('id', $redpacket['user_id'])->value('avatar');
|
||||||
|
$redpacket['redpacket_id'] = $redpacket['id'];
|
||||||
|
|
||||||
|
return $redpacket;
|
||||||
|
}
|
||||||
|
}
|
||||||
12
application/common/model/RedpacketRecord.php
Normal file
12
application/common/model/RedpacketRecord.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
class RedpacketRecord extends Model
|
||||||
|
{
|
||||||
|
protected $autoWriteTimestamp = true;
|
||||||
|
protected $createTime = 'createtime';
|
||||||
|
protected $updateTime = false;
|
||||||
|
}
|
||||||
707
application/common/service/RedpacketService.php
Normal file
707
application/common/service/RedpacketService.php
Normal file
@@ -0,0 +1,707 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\service;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
use think\Cache;
|
||||||
|
use app\common\model\Redpacket;
|
||||||
|
use app\common\model\RedpacketRecord;
|
||||||
|
use app\common\model\UserWallet;
|
||||||
|
use app\common\library\RedpacketLua;
|
||||||
|
|
||||||
|
class RedpacketService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 发红包
|
||||||
|
*/
|
||||||
|
public function create($data)
|
||||||
|
{
|
||||||
|
// 验证数据
|
||||||
|
$res = $this->validateCreateData($data);
|
||||||
|
if ($res['code'] == 0) {
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
$redpacketModel = new Redpacket();
|
||||||
|
return $redpacketModel->createRedpacket($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抢红包并返回详细结果
|
||||||
|
*/
|
||||||
|
public function grabWithResult($redpacketId, $userId)
|
||||||
|
{
|
||||||
|
$redpacketModel = new Redpacket();
|
||||||
|
$redpacket = $redpacketModel->getRedpacketInfo($redpacketId);
|
||||||
|
|
||||||
|
if (!$redpacket) {
|
||||||
|
return [
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => '红包不存在',
|
||||||
|
'data' => null
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证领取条件
|
||||||
|
$conditionCheck = $this->checkConditionsWithResult($redpacket, $userId);
|
||||||
|
if ($conditionCheck['code'] != 1) {
|
||||||
|
return $conditionCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查红包状态
|
||||||
|
$statusCheck = $this->checkRedpacketStatus($redpacket);
|
||||||
|
if ($statusCheck['code'] != 1) {
|
||||||
|
return $statusCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否已经抢过
|
||||||
|
if ($this->hasUserGrabbed($redpacketId, $userId)) {
|
||||||
|
// $detail = $this->getGrabResult($redpacketId, $userId);
|
||||||
|
return [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => '已经抢过该红包',
|
||||||
|
'data' => ['code' => 2] //1-抢到了,2-已经抢过红包,3-没有抢到
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用Redis+Lua保证原子性操作
|
||||||
|
$redis = Cache::store('redis')->handler();
|
||||||
|
$script = RedpacketLua::grabRedpacketScript();
|
||||||
|
|
||||||
|
$redpacketKey = "redpacket:{$redpacketId}";
|
||||||
|
$userSetKey = "redpacket_users:{$redpacketId}";
|
||||||
|
|
||||||
|
$result = $redis->eval($script, [
|
||||||
|
$redpacketKey,
|
||||||
|
$userSetKey,
|
||||||
|
$userId,
|
||||||
|
time()
|
||||||
|
], 3);
|
||||||
|
|
||||||
|
if ($result[0] == 0) {
|
||||||
|
$message = $result[1];
|
||||||
|
if ($message == '红包已抢完') {
|
||||||
|
return [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => '手慢了,红包已抢完',
|
||||||
|
'data' => ['code' => 3] //1-抢到了,2-已经抢过红包,3-没有抢到
|
||||||
|
];
|
||||||
|
} elseif ($message == '已经抢过该红包') {
|
||||||
|
return [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => '已经抢过该红包',
|
||||||
|
'data' => ['code' => 2] //1-抢到了,2-已经抢过红包,3-没有抢到
|
||||||
|
];
|
||||||
|
}elseif ($message == '红包已结束') {
|
||||||
|
return [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => '手慢了,红包已抢完',
|
||||||
|
'data' => ['code' => 3] //1-抢到了,2-已经抢过红包,3-没有抢到
|
||||||
|
];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return [
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => $message,
|
||||||
|
'data' => null
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$amount = floatval($result[1]);
|
||||||
|
$isFinished = $result[2] == 1; // Lua脚本返回是否抢完
|
||||||
|
//给前端推送销毁这个红包
|
||||||
|
// redis 记录该红包是否已经推送过了 只推送一次
|
||||||
|
if($isFinished){
|
||||||
|
$redisKey = "redpacket:{$redpacketId}:is_finished";
|
||||||
|
if (!Cache::get($redisKey)) {
|
||||||
|
Cache::set($redisKey, 1, $redpacket['countdown']+get_system_config_value('red_packet_time')+60);
|
||||||
|
$text = [
|
||||||
|
'redpacket_id' => $redpacketId,
|
||||||
|
'text' => '抢完了,请销毁该红包'
|
||||||
|
];
|
||||||
|
model('api/Chat')->sendMsg(1061,$redpacket['room_id'],$text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lua脚本执行成功,记录到数据库
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
// 创建领取记录
|
||||||
|
$recordData = [
|
||||||
|
'redpacket_id' => $redpacketId,
|
||||||
|
'user_id' => $userId,
|
||||||
|
'amount' => $amount
|
||||||
|
];
|
||||||
|
|
||||||
|
$recordModel = new RedpacketRecord();
|
||||||
|
$recordModel->save($recordData);
|
||||||
|
|
||||||
|
// 更新用户钱包
|
||||||
|
$coinField = $redpacket['coin_type'] == 1 ? 'coin' : 'earnings';
|
||||||
|
//增加余额
|
||||||
|
$addres = Db::name('user_wallet')
|
||||||
|
->where('user_id', $userId)
|
||||||
|
->inc($coinField, $amount)
|
||||||
|
->update();
|
||||||
|
//记录用户金币日志
|
||||||
|
$data = [
|
||||||
|
'user_id' => $userId,
|
||||||
|
'change_value' => $amount,
|
||||||
|
'room_id' => $redpacket['room_id'],
|
||||||
|
'money_type' => $redpacket['coin_type'],
|
||||||
|
//记录日志 32-发红包(金币),29-发红包(钻石),30-抢红包(金币),31-抢红包(钻石)
|
||||||
|
'change_type' => $redpacket['coin_type'] == 1 ? 30 : 31,
|
||||||
|
'from_id' => $redpacket['room_id'],
|
||||||
|
'remarks' => '抢红包收入',
|
||||||
|
'createtime' => time()
|
||||||
|
];
|
||||||
|
|
||||||
|
$res = Db::name('vs_user_money_log')->insert($data);
|
||||||
|
if(!$res || !$addres){
|
||||||
|
Db::rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新红包剩余数量和金额,如果抢完了更新状态
|
||||||
|
$updateData = [
|
||||||
|
'left_amount' => Db::raw('left_amount - ' . $amount),
|
||||||
|
'left_count' => Db::raw('left_count - 1'),
|
||||||
|
'updatetime' => time()
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($isFinished) {
|
||||||
|
$updateData['status'] = Redpacket::STATUS_FINISHED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::name('redpacket')
|
||||||
|
->where('id', $redpacketId)
|
||||||
|
->update($updateData);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
|
||||||
|
// 获取抢红包结果详情
|
||||||
|
$grabResult = $this->getGrabResult($redpacketId, $userId);
|
||||||
|
unset($grabResult['previous_records']);//前端不要
|
||||||
|
unset($grabResult['all_records']);//前端不要
|
||||||
|
unset($grabResult['statistics']);//前端不要
|
||||||
|
|
||||||
|
return [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => '抢红包成功',
|
||||||
|
// 'data' => $grabResult
|
||||||
|
// 'data' => null
|
||||||
|
'data' => ['code' => 1] //1-抢到了,2-已经抢过红包,3-没有抢到
|
||||||
|
];
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
// 回滚Redis操作
|
||||||
|
$redis->hIncrByFloat($redpacketKey, 'left_amount', $amount);
|
||||||
|
$redis->hIncrBy($redpacketKey, 'left_count', 1);
|
||||||
|
$redis->sRem($userSetKey, $userId);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => '系统错误,请重试'.$e->getMessage(),
|
||||||
|
'data' => null
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取抢红包结果详情
|
||||||
|
*/
|
||||||
|
public function getGrabResult($redpacketId, $userId)
|
||||||
|
{
|
||||||
|
// 获取红包基本信息
|
||||||
|
$redpacket = Db::name('redpacket')
|
||||||
|
->where('id', $redpacketId)
|
||||||
|
->find();
|
||||||
|
|
||||||
|
if (!$redpacket) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前用户的领取记录
|
||||||
|
$myRecord = Db::name('redpacket_record')
|
||||||
|
->alias('r')
|
||||||
|
->field('r.*, u.nickname, u.avatar')
|
||||||
|
->join('user u', 'u.id = r.user_id')
|
||||||
|
->where('r.redpacket_id', $redpacketId)
|
||||||
|
->where('r.user_id', $userId)
|
||||||
|
->find();
|
||||||
|
|
||||||
|
// 获取在我之前抢到的用户记录
|
||||||
|
$previousRecords = [];
|
||||||
|
if ($myRecord) {
|
||||||
|
$previousRecords = Db::name('redpacket_record')
|
||||||
|
->alias('r')
|
||||||
|
->field('r.*, u.nickname, u.avatar')
|
||||||
|
->join('user u', 'u.id = r.user_id')
|
||||||
|
->where('r.redpacket_id', $redpacketId)
|
||||||
|
->where('r.createtime', '<', $myRecord['createtime'])
|
||||||
|
->order('r.createtime ASC')
|
||||||
|
->select();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取所有记录用于统计
|
||||||
|
$allRecords = Db::name('redpacket_record')
|
||||||
|
->alias('r')
|
||||||
|
->field('r.*, u.nickname, u.avatar')
|
||||||
|
->join('user u', 'u.id = r.user_id')
|
||||||
|
->where('r.redpacket_id', $redpacketId)
|
||||||
|
->order('r.createtime ASC')
|
||||||
|
->select();
|
||||||
|
|
||||||
|
// 统计信息
|
||||||
|
$totalGrabbed = count($allRecords);
|
||||||
|
$totalAmount = array_sum(array_column($allRecords, 'amount'));
|
||||||
|
|
||||||
|
// 手气最佳
|
||||||
|
$bestRecord = null;
|
||||||
|
if ($allRecords) {
|
||||||
|
$maxAmount = max(array_column($allRecords, 'amount'));
|
||||||
|
foreach ($allRecords as $record) {
|
||||||
|
if ($record['amount'] == $maxAmount) {
|
||||||
|
$bestRecord = $record;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'redpacket_info' => [
|
||||||
|
'id' => $redpacket['id'],
|
||||||
|
'total_amount' => $redpacket['total_amount'],
|
||||||
|
'total_count' => $redpacket['total_count'],
|
||||||
|
'left_amount' => $redpacket['left_amount'],
|
||||||
|
'left_count' => $redpacket['left_count'],
|
||||||
|
'coin_type' => $redpacket['coin_type'],
|
||||||
|
'status' => $redpacket['status'],
|
||||||
|
'nickname' => Db::name('user')->where('id', $redpacket['user_id'])->value('nickname')
|
||||||
|
],
|
||||||
|
'my_record' => $myRecord ? [
|
||||||
|
'amount' => $myRecord['amount'],
|
||||||
|
'createtime' => $myRecord['createtime'],
|
||||||
|
'nickname' => $myRecord['nickname'],
|
||||||
|
'avatar' => $myRecord['avatar']
|
||||||
|
] : null,
|
||||||
|
'previous_records' => $previousRecords,
|
||||||
|
'all_records' => $allRecords,
|
||||||
|
'statistics' => [
|
||||||
|
'total_grabbed' => $totalGrabbed,
|
||||||
|
'total_amount_grabbed' => $totalAmount,
|
||||||
|
'best_luck' => $bestRecord ? [
|
||||||
|
'nickname' => $bestRecord['nickname'],
|
||||||
|
'avatar' => $bestRecord['avatar'],
|
||||||
|
'amount' => $bestRecord['amount']
|
||||||
|
] : null
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查红包状态
|
||||||
|
*/
|
||||||
|
private function checkRedpacketStatus($redpacket)
|
||||||
|
{
|
||||||
|
$now = time();
|
||||||
|
|
||||||
|
if ($redpacket['status'] == Redpacket::STATUS_PENDING) {
|
||||||
|
if ($now < $redpacket['start_time']) {
|
||||||
|
return [
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => '红包还未开始',
|
||||||
|
'data' => null
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if ($redpacket['status'] == Redpacket::STATUS_FINISHED ||
|
||||||
|
// $redpacket['status'] == Redpacket::STATUS_REFUNDED) {
|
||||||
|
// return [
|
||||||
|
// 'code' => 0,
|
||||||
|
// 'msg' => '红包已结束',
|
||||||
|
// 'data' => null
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if ($now > $redpacket['end_time']) {
|
||||||
|
// return [
|
||||||
|
// 'code' => 0,
|
||||||
|
// 'msg' => '红包已结束',
|
||||||
|
// 'data' => null
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
|
||||||
|
return ['code' => 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查用户是否已经抢过
|
||||||
|
*/
|
||||||
|
private function hasUserGrabbed($redpacketId, $userId)
|
||||||
|
{
|
||||||
|
$record = Db::name('redpacket_record')
|
||||||
|
->where('redpacket_id', $redpacketId)
|
||||||
|
->where('user_id', $userId)
|
||||||
|
->find();
|
||||||
|
|
||||||
|
return !empty($record);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查领取条件(返回结果格式)
|
||||||
|
*/
|
||||||
|
private function checkConditionsWithResult($redpacket, $userId)
|
||||||
|
{
|
||||||
|
$conditions = $redpacket['conditions'] ? explode(',', $redpacket['conditions']): [];
|
||||||
|
|
||||||
|
if (empty($conditions)) {
|
||||||
|
return ['code' => 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array(Redpacket::CONDITION_NONE, $conditions)) {
|
||||||
|
return ['code' => 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($conditions as $condition) {
|
||||||
|
switch ($condition) {
|
||||||
|
case Redpacket::CONDITION_COLLECT_ROOM:
|
||||||
|
if (!$this->checkUserCollectedRoom($userId, $redpacket['room_id'])) {
|
||||||
|
return [
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => '不满足收藏房间条件',
|
||||||
|
'data' => null
|
||||||
|
];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Redpacket::CONDITION_MIC_USER:
|
||||||
|
if (!$this->checkUserOnMic($userId, $redpacket['room_id'])) {
|
||||||
|
return [
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => '您不是麦上用户',
|
||||||
|
'data' => null
|
||||||
|
];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['code' => 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取红包详情和领取记录
|
||||||
|
*/
|
||||||
|
public function getDetail($redpacketId, $currentUserId = 0)
|
||||||
|
{
|
||||||
|
$redpacketModel = new Redpacket();
|
||||||
|
$redpacket['redpacket_info'] = $redpacketModel->getRedpacketInfo($redpacketId);
|
||||||
|
|
||||||
|
if (!$redpacket) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取领取记录
|
||||||
|
$records = Db::name('redpacket_record')
|
||||||
|
->alias('r')
|
||||||
|
->field('r.*, u.nickname, u.avatar')
|
||||||
|
->join('user u', 'u.id = r.user_id')
|
||||||
|
->where('r.redpacket_id', $redpacketId)
|
||||||
|
->order('r.createtime ASC')
|
||||||
|
->select();
|
||||||
|
//处理createtime 字段
|
||||||
|
$records = array_map(function ($record) {
|
||||||
|
$record['createtime'] = date('Y-m-d H:i:s', $record['createtime']);
|
||||||
|
return $record;
|
||||||
|
}, $records);
|
||||||
|
|
||||||
|
$redpacket['records'] = $records;
|
||||||
|
|
||||||
|
// 检查当前用户是否已抢
|
||||||
|
$redpacket['has_grabbed'] = false;
|
||||||
|
$redpacket['my_record'] = null;
|
||||||
|
|
||||||
|
if ($currentUserId > 0) {
|
||||||
|
foreach ($records as $record) {
|
||||||
|
if ($record['user_id'] == $currentUserId) {
|
||||||
|
$redpacket['has_grabbed'] = true;
|
||||||
|
$redpacket['my_record'] = $record;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $redpacket;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理过期红包退款
|
||||||
|
*/
|
||||||
|
public function processExpiredRedpackets()
|
||||||
|
{
|
||||||
|
$now = time();
|
||||||
|
$redpacketModel = new Redpacket();
|
||||||
|
|
||||||
|
// 查找已结束但未退款的红包
|
||||||
|
$expiredRedpackets = Db::name('redpacket')
|
||||||
|
->where('status', Redpacket::STATUS_ACTIVE)
|
||||||
|
->where('end_time', '<', $now)
|
||||||
|
->where('left_count', '>', 0)
|
||||||
|
->select();
|
||||||
|
|
||||||
|
foreach ($expiredRedpackets as $redpacket) {
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
// 退款给发红包用户
|
||||||
|
if ($redpacket['left_amount'] > 0) {
|
||||||
|
$walletModel = new UserWallet();
|
||||||
|
$walletModel->increaseBalance(
|
||||||
|
$redpacket['user_id'],
|
||||||
|
$redpacket['coin_type'],
|
||||||
|
$redpacket['left_amount']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新红包状态
|
||||||
|
Db::name('redpacket')
|
||||||
|
->where('id', $redpacket['id'])
|
||||||
|
->update([
|
||||||
|
'status' => Redpacket::STATUS_REFUNDED,
|
||||||
|
'updatetime' => $now
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 清理Redis缓存
|
||||||
|
$redis = Cache::store('redis')->handler();
|
||||||
|
$redisKey = "redpacket:{$redpacket['id']}";
|
||||||
|
$redis->del($redisKey);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
// 记录日志
|
||||||
|
\think\Log::error("红包退款失败: {$redpacket['id']}, 错误: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证创建红包数据
|
||||||
|
*/
|
||||||
|
private function validateCreateData($data)
|
||||||
|
{
|
||||||
|
if (empty($data['user_id'])) {
|
||||||
|
return ['code' => 0, 'msg' => '用户ID不能为空', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($data['room_id'])) {
|
||||||
|
return ['code' => 0, 'msg' => '房间ID不能为空', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array($data['type'], [Redpacket::TYPE_NORMAL, Redpacket::TYPE_PASSWORD])) {
|
||||||
|
return ['code' => 0, 'msg' => '红包类型错误', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data['type'] == Redpacket::TYPE_PASSWORD && empty($data['password'])) {
|
||||||
|
return ['code' => 0, 'msg' => '口令红包必须设置口令', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array($data['coin_type'], [Redpacket::COIN_GOLD, Redpacket::COIN_DIAMOND])) {
|
||||||
|
return ['code' => 0, 'msg' => '币种类型错误', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data['total_amount'] <= 0 || $data['total_count'] <= 0) {
|
||||||
|
return ['code' => 0, 'msg' => '金额和数量必须大于0', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data['total_amount'] < $data['total_count']) {
|
||||||
|
return ['code' => 0, 'msg' => '总金额不能小于总个数', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证领取条件
|
||||||
|
if (isset($data['conditions'])) {
|
||||||
|
$res_con = $this->validateConditions($data['conditions']);
|
||||||
|
if ($res_con !== true) {
|
||||||
|
return $res_con;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['code' => 1, 'msg' => '验证成功', 'data' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证领取条件
|
||||||
|
*/
|
||||||
|
private function validateConditions($conditions)
|
||||||
|
{
|
||||||
|
if (empty($conditions)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//字符串转为数组
|
||||||
|
$conditions = explode(',', $conditions);
|
||||||
|
|
||||||
|
if (in_array(Redpacket::CONDITION_NONE, $conditions) && count($conditions) > 1) {
|
||||||
|
return V(0, '选择"无"条件时不能选择其他条件');
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查用户是否满足领取条件
|
||||||
|
*/
|
||||||
|
private function checkConditions($redpacket, $userId)
|
||||||
|
{
|
||||||
|
$conditions = $redpacket['conditions'] ?: [];
|
||||||
|
|
||||||
|
if (empty($conditions)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array(Redpacket::CONDITION_NONE, $conditions)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($conditions as $condition) {
|
||||||
|
switch ($condition) {
|
||||||
|
case Redpacket::CONDITION_COLLECT_ROOM:
|
||||||
|
// 检查用户是否收藏了房间
|
||||||
|
if (!$this->checkUserCollectedRoom($userId)) {
|
||||||
|
throw new \Exception('不满足收藏房间条件');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Redpacket::CONDITION_MIC_USER:
|
||||||
|
// 检查用户是否在麦位上
|
||||||
|
if (!$this->checkUserOnMic($userId)) {
|
||||||
|
throw new \Exception('不满足麦位用户条件');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查用户是否收藏了房间(需要根据实际业务实现)
|
||||||
|
*/
|
||||||
|
private function checkUserCollectedRoom($userId,$roomId)
|
||||||
|
{
|
||||||
|
$collect = Db::name('user_follow')->where(['user_id' => $userId,'type' => 2,'follow_id' => $roomId])->find();
|
||||||
|
if (!$collect) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查用户是否在麦位上(需要根据实际业务实现)
|
||||||
|
*/
|
||||||
|
private function checkUserOnMic($userId,$roomId)
|
||||||
|
{
|
||||||
|
$room_type = Db::name('vs_room')->where('id',$roomId)->field('type_id,label_id')->find();
|
||||||
|
//实际麦位
|
||||||
|
if($room_type['type_id'] == 1 || $room_type['type_id'] == 7 || $room_type['type_id'] == 8){
|
||||||
|
$onPit = Db::name('vs_room_pit')->where(['user_id' => $userId,'room_id' => $roomId])->value('pit_number');
|
||||||
|
if ($onPit <= 0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}elseif($room_type['type_id'] ==2){//拍卖
|
||||||
|
//获取房间的当前拍卖ID
|
||||||
|
$auctionId = Db::name('vs_room_auction')->where(['room_id' => $roomId,'status' => 2])->value('auction_id');
|
||||||
|
$onPit = [];
|
||||||
|
if($auctionId){
|
||||||
|
$onPits = model('api/RoomAuction')->room_auction_list_on($auctionId);
|
||||||
|
//提取数组里面的user_id的值 来判断用户是否在里面
|
||||||
|
$onPit = array_column($onPits,'user_id');
|
||||||
|
//拍卖位 从缓存中取 Cache::get('auction_user_'.$room_id)
|
||||||
|
$onpitNumber_10 = Cache::get('auction_user_'.$roomId);
|
||||||
|
if($onpitNumber_10){
|
||||||
|
$onPit[] = $onpitNumber_10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$onpitNumber_9 = Db::name('vs_room_pit')->where(['pit_number' => 9,'room_id' => $roomId])->value('user_id');
|
||||||
|
if($onpitNumber_9){
|
||||||
|
$onPit[] = $onpitNumber_9;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array($userId,$onPit)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查并更新红包状态
|
||||||
|
* 在抢红包前调用,确保状态正确
|
||||||
|
*/
|
||||||
|
public function checkAndUpdateRedpacketStatus($redpacketId)
|
||||||
|
{
|
||||||
|
$redpacket = Db::name('redpacket')->where('id', $redpacketId)->find();
|
||||||
|
if (!$redpacket) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$now = time();
|
||||||
|
$redis = Cache::store('redis')->handler();
|
||||||
|
$redpacketKey = "redpacket:{$redpacketId}";
|
||||||
|
|
||||||
|
// 如果红包状态为未开始(0),但当前时间已超过开始时间,则更新为进行中(1)
|
||||||
|
if ($redpacket['status'] == Redpacket::STATUS_PENDING && $now >= $redpacket['start_time']) {
|
||||||
|
Db::name('redpacket')
|
||||||
|
->where('id', $redpacketId)
|
||||||
|
->update([
|
||||||
|
'status' => Redpacket::STATUS_ACTIVE,
|
||||||
|
'updatetime' => $now
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 更新Redis中的状态
|
||||||
|
$redis->hSet($redpacketKey, 'status', Redpacket::STATUS_ACTIVE);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果红包状态为进行中(1),但已抢完,则更新为已结束(2)
|
||||||
|
if ($redpacket['status'] == Redpacket::STATUS_ACTIVE && $redpacket['left_count'] <= 0) {
|
||||||
|
Db::name('redpacket')
|
||||||
|
->where('id', $redpacketId)
|
||||||
|
->update([
|
||||||
|
'status' => Redpacket::STATUS_FINISHED,
|
||||||
|
'updatetime' => $now
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 更新Redis中的状态
|
||||||
|
$redis->hSet($redpacketKey, 'status', Redpacket::STATUS_FINISHED);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果红包状态为进行中(1),但已超过结束时间,则更新为已结束(2)
|
||||||
|
if ($redpacket['status'] == Redpacket::STATUS_ACTIVE && $now > $redpacket['end_time']) {
|
||||||
|
Db::name('redpacket')
|
||||||
|
->where('id', $redpacketId)
|
||||||
|
->update([
|
||||||
|
'status' => Redpacket::STATUS_FINISHED,
|
||||||
|
'updatetime' => $now
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 更新Redis中的状态
|
||||||
|
$redis->hSet($redpacketKey, 'status', Redpacket::STATUS_FINISHED);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
56
application/cron/controller/FriendEnd.php
Normal file
56
application/cron/controller/FriendEnd.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\cron\controller;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
|
class FriendEnd
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* 运行函数
|
||||||
|
*/
|
||||||
|
function index()
|
||||||
|
{
|
||||||
|
echo "清除交友房过期未结束数据开始:\n";
|
||||||
|
$this->clearFriendingEndRoom();//清除交友房过期未结束数据
|
||||||
|
echo "清除结束 \n";
|
||||||
|
|
||||||
|
echo "清除私密小屋过期数据开始:\n";
|
||||||
|
$this->clear_room_end();//清除私密小屋过期数据
|
||||||
|
echo "清除私密小屋过期数据结束 \n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//清除交友房过期未结束数据
|
||||||
|
public function clearFriendingEndRoom()
|
||||||
|
{
|
||||||
|
//清除交友房过期数据
|
||||||
|
$room_list = db::name('vs_room')->where(['type_id'=>7])->whereIn('step', [2,3])
|
||||||
|
->field(['id','step'])->select();
|
||||||
|
if(!empty($room_list)){
|
||||||
|
foreach ($room_list as $room) {
|
||||||
|
//查询交友信息
|
||||||
|
$friending_info = db::name('vs_user_friending')->where('room_id', $room['id'])->where('status', 1)->order('id', 'desc')->find();
|
||||||
|
if($friending_info){
|
||||||
|
//判断结束时间是否到期
|
||||||
|
if($friending_info['end_time'] <= time() || $room['step'] == 3){
|
||||||
|
model('Friend')->end_friend(0,$room['id'],$friending_info['id'],1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//清除私密小屋过期数据
|
||||||
|
public function clear_room_end()
|
||||||
|
{
|
||||||
|
$room_list = db::name('vs_room_cp_movie')->where(['status' => 1,'type'=>1,'time_day' =>['<',time()]])->select();
|
||||||
|
if(!empty($room_list)){
|
||||||
|
foreach ($room_list as $room) {
|
||||||
|
model('Friend')->outRoom(0,$room['room_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
405
application/cron/controller/RoomHourRanking.php
Normal file
405
application/cron/controller/RoomHourRanking.php
Normal file
@@ -0,0 +1,405 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\cron\controller;
|
||||||
|
|
||||||
|
use app\common\controller\Push;
|
||||||
|
use think\Db;
|
||||||
|
use think\Log;
|
||||||
|
|
||||||
|
class RoomHourRanking
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* 运行函数
|
||||||
|
*/
|
||||||
|
function index()
|
||||||
|
{
|
||||||
|
echo "小时榜 开始发礼物:\n";
|
||||||
|
$this->send_gift();//小时榜 送礼物
|
||||||
|
echo "发礼物结束 \n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function send_gift()
|
||||||
|
{
|
||||||
|
//获取上一个小时的开始时间和结束时间
|
||||||
|
$start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour')));
|
||||||
|
$end_time = strtotime(date('Y-m-d H:00:00'));
|
||||||
|
echo "开始时间:" .$start_time."\n";
|
||||||
|
echo "结束时间:" .$end_time."\n";
|
||||||
|
//当前小时的前一个小时(24小时计时法,0-23)
|
||||||
|
$pre_hour = date('H', strtotime('-1 hour'));
|
||||||
|
echo "上个时间段:" .$pre_hour."\n";
|
||||||
|
$is_open_time = db::name('vs_hour_ranking_config')->where('id', 1)->value('open_time');
|
||||||
|
if ($is_open_time == 0) {
|
||||||
|
echo "未开启时间段:" .$is_open_time."\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//是否全局飘瓶
|
||||||
|
$is_public_server = db::name('vs_hour_ranking_config')->where('id', 1)->value('is_public_server');
|
||||||
|
if ($is_public_server == 1) {
|
||||||
|
//全局飘瓶时间段
|
||||||
|
$xlh_time_range = db::name('vs_hour_ranking_config')->where('id', 1)->value('broadcast_times');
|
||||||
|
if($xlh_time_range){
|
||||||
|
if($xlh_time_range == 25){
|
||||||
|
$is_piao = 1;
|
||||||
|
}else{
|
||||||
|
|
||||||
|
//当前的前一个小时是否在 $xlh_time_range中
|
||||||
|
if (in_array($pre_hour, explode(',', $xlh_time_range))) {
|
||||||
|
$is_piao = 1;
|
||||||
|
} else {
|
||||||
|
$is_piao = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$is_piao = 0;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$is_piao = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取上一个时间段的配置
|
||||||
|
// $gift_list = db::name('vs_hour_ranking_gift_config')->where('time_id',$pre_hour)->group('ranking')->order('id', 'desc')->select();
|
||||||
|
$gift_list = $this->get_hour_ranking($pre_hour);
|
||||||
|
// echo "上个时间段的配置:" .json_encode($gift_list)."\n";
|
||||||
|
// 提取所有有奖励的内容
|
||||||
|
$allRewards = $this->extractAllRewards($gift_list);
|
||||||
|
// 按index分组
|
||||||
|
$groupedRewards = $this->groupRewardsByIndex($allRewards);
|
||||||
|
// 按名次顺序分配奖励
|
||||||
|
$distributionResult = $this->distributeByRank($groupedRewards);
|
||||||
|
|
||||||
|
//获取上个数组的个数,从而获取配置了多少个名次
|
||||||
|
$count = count($distributionResult);
|
||||||
|
echo "上个时间段的配置总数:" .$count."\n";
|
||||||
|
//获取前一个小时的 前$count名房间排行
|
||||||
|
$room_list = model('api/RoomHourRanking')->room_hour_ranking(1, $count, $start_time, $end_time);
|
||||||
|
$room_owner = [];
|
||||||
|
if ($room_list['code'] == 1) {
|
||||||
|
//获取房间排行奖励最低值
|
||||||
|
$min_price = db::name('vs_hour_ranking_config')->where('id', 1)->value('min_price');
|
||||||
|
if ($room_list['data']['lists']) {
|
||||||
|
echo "房间列表:" .json_encode($room_list['data']['lists'])."\n";
|
||||||
|
foreach ($room_list['data']['lists'] as $v){
|
||||||
|
if ($v['total_price'] >= $min_price) {
|
||||||
|
$room_owner[] = [
|
||||||
|
'user_id' => $v['user_id'],
|
||||||
|
'room_name' => $v['room_name'],
|
||||||
|
'room_id' => $v['room_id'],
|
||||||
|
'total_price' => $v['total_price']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($distributionResult && $room_owner) {
|
||||||
|
$text_list_new = [];
|
||||||
|
echo "礼物数:" .json_encode($distributionResult)."\n";
|
||||||
|
echo "房主:" .json_encode($room_owner)."\n";
|
||||||
|
foreach ($distributionResult as $k => $value) {
|
||||||
|
//礼物全部给他偷偷放在装扮表及金额 中
|
||||||
|
//有几个用户就发几个
|
||||||
|
if(count($room_owner) > $k){
|
||||||
|
// 为每个房间添加一个标志,表示是否已处理推送信息
|
||||||
|
$hasProcessedPush = false;
|
||||||
|
|
||||||
|
foreach ($value['rewards'] as $v){
|
||||||
|
if($v['type'] == 0){//1金币2礼物3头像4坐骑
|
||||||
|
echo "发金币:" .$v['value'].'==>'.$room_owner[$k]['user_id']."\n";
|
||||||
|
$res = $this->add_coin($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao);
|
||||||
|
}elseif ($v['type'] == 1){
|
||||||
|
echo "发礼物:" .$v['value'].'==>'.$room_owner[$k]['user_id']."\n";
|
||||||
|
$res = $this->add_gift($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao);
|
||||||
|
}elseif ($v['type'] == 2){
|
||||||
|
$res = $this->add_decorate($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao,3);
|
||||||
|
}elseif ($v['type'] == 3){
|
||||||
|
$res = $this->add_decorate($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao,4);
|
||||||
|
}
|
||||||
|
// 只有在第一次处理奖励时添加推送信息,避免重复推送
|
||||||
|
if(!$hasProcessedPush && $is_piao == 1) {
|
||||||
|
$room_name = $room_owner[$k]['room_name'];
|
||||||
|
//推送礼物横幅
|
||||||
|
if ($k == 0) {
|
||||||
|
$text = '新科状元!【' . $room_name . '】独占鳌头!';
|
||||||
|
} elseif ($k == 1) {
|
||||||
|
$text = '金榜榜眼!【' . $room_name . '】才气逼人!';
|
||||||
|
} elseif ($k == 2) {
|
||||||
|
$text = '风采探花!【' . $room_name . '】实力绽放!';
|
||||||
|
}
|
||||||
|
|
||||||
|
$text_list_new[] = [
|
||||||
|
'text' => $text ?? '恭喜【' . $room_name . '】获得礼物!',
|
||||||
|
'room_id' => $room_owner[$k]['room_id'],
|
||||||
|
'room_name' => $room_name,
|
||||||
|
'rank_number' => $k + 1,
|
||||||
|
];
|
||||||
|
|
||||||
|
$hasProcessedPush = true; // 标记已处理推送
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!empty($text_list_new)){
|
||||||
|
$push = new Push();
|
||||||
|
$push->hourRanking($text_list_new);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "送礼-共" . count($room_owner) . "个房间房主获益\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加金币到钱包
|
||||||
|
public function add_coin($coin,$user_id,$ranking,$room_id,$total_price,$is_piao){
|
||||||
|
if($coin > 0){
|
||||||
|
$data = [
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'change_value' => $coin,
|
||||||
|
// 'room_id' => $room_ids,
|
||||||
|
'money_type' => 1,
|
||||||
|
'change_type' => 27,
|
||||||
|
'from_id' => 0,
|
||||||
|
'remarks' => '小时榜获得',
|
||||||
|
'createtime' => time()
|
||||||
|
];
|
||||||
|
|
||||||
|
//开启事务
|
||||||
|
Db::startTrans();
|
||||||
|
$res = Db::name('vs_user_money_log')->insert($data);
|
||||||
|
if(!$res){
|
||||||
|
Db::rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
//增加用户金币
|
||||||
|
$res1 = Db::name('user_wallet')->where(['user_id'=>$user_id])->setInc('coin',$coin);
|
||||||
|
if(!$res1){
|
||||||
|
Db::rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加到排行表
|
||||||
|
$start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour')));
|
||||||
|
$end_time = strtotime(date('Y-m-d H:00:00')) - 1;
|
||||||
|
$res2 = db::name('vs_hour_ranking')->insert([
|
||||||
|
'ranking' => $ranking,
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'flowing_water' => $total_price,
|
||||||
|
'coin' => $coin,
|
||||||
|
'time_id' => date('H', strtotime('-1 hour')),
|
||||||
|
'stime' => $start_time,
|
||||||
|
'etime' => $end_time,
|
||||||
|
'createtime' => time(),
|
||||||
|
'updatetime' => time(),
|
||||||
|
'is_public_server' => $is_piao
|
||||||
|
]);
|
||||||
|
if(!$res2){
|
||||||
|
Db::rollback();
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加礼物到背包
|
||||||
|
public function add_gift($gift_id,$user_id,$ranking,$room_id,$total_price,$is_piao){
|
||||||
|
$res = model('api/UserGiftPack')->change_user_gift_pack($user_id,$gift_id,1,model('UserGiftPack')::HOUR_RANK_GET,"小时榜获得");
|
||||||
|
if($res['code'] == 0){
|
||||||
|
Log::record("小时榜获取礼物失败:".$res['msg'],"info");
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加到排行表
|
||||||
|
$start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour')));
|
||||||
|
$end_time = strtotime(date('Y-m-d H:00:00')) - 1;
|
||||||
|
$res2 = db::name('vs_hour_ranking')->insert([
|
||||||
|
'ranking' => $ranking,
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'flowing_water' => $total_price,
|
||||||
|
'gift_id' => $gift_id,
|
||||||
|
'gift_type' => 2,
|
||||||
|
'time_id' => date('H', strtotime('-1 hour')),
|
||||||
|
'stime' => $start_time,
|
||||||
|
'etime' => $end_time,
|
||||||
|
'createtime' => time(),
|
||||||
|
'updatetime' => time(),
|
||||||
|
'is_public_server' => $is_piao
|
||||||
|
]);
|
||||||
|
if(!$res2){
|
||||||
|
Log::record("小时榜礼物锁定失败","info");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加装扮到背包
|
||||||
|
public function add_decorate($avatar_id,$user_id,$ranking,$room_id,$total_price,$is_piao,$type){
|
||||||
|
$decorate_price_info = db::name('vs_decorate_price')->where(['id'=>$avatar_id])->find();
|
||||||
|
if(empty($decorate_price_info)){
|
||||||
|
Log::record("小时榜获取装扮失败:没有找到装扮!".$avatar_id,"info");
|
||||||
|
}
|
||||||
|
$res = model('api/Decorate')->pay_decorate($user_id,$decorate_price_info['did'],$decorate_price_info['day'],2);
|
||||||
|
if($res['code'] == 0){
|
||||||
|
Log::record("小时榜获取装扮失败:".$res['msg']."-".$avatar_id,"info");
|
||||||
|
}
|
||||||
|
//添加到排行表
|
||||||
|
$start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour')));
|
||||||
|
$end_time = strtotime(date('Y-m-d H:00:00')) - 1;
|
||||||
|
$res2 = db::name('vs_hour_ranking')->insert([
|
||||||
|
'ranking' => $ranking,
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'flowing_water' => $total_price,
|
||||||
|
'gift_id' => $avatar_id,
|
||||||
|
'gift_type' => $type,
|
||||||
|
'time_id' => date('H', strtotime('-1 hour')),
|
||||||
|
'stime' => $start_time,
|
||||||
|
'etime' => $end_time,
|
||||||
|
'createtime' => time(),
|
||||||
|
'updatetime' => time(),
|
||||||
|
'is_public_server' => $is_piao,
|
||||||
|
]);
|
||||||
|
if(!$res2){
|
||||||
|
Log::record("小时榜咋装扮锁定失败","info");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提取所有有奖励的内容
|
||||||
|
*/
|
||||||
|
private function extractAllRewards($responseData)
|
||||||
|
{
|
||||||
|
$allRewards = [];
|
||||||
|
|
||||||
|
foreach ($responseData as $timeSlot) {
|
||||||
|
foreach ($timeSlot['reward'] as $rewardItem) {
|
||||||
|
$index = $rewardItem['index'];
|
||||||
|
$content = $rewardItem['content'];
|
||||||
|
|
||||||
|
// 只处理有奖励内容的数据
|
||||||
|
if (!empty($content)) {
|
||||||
|
foreach ($content as $rewardContent) {
|
||||||
|
$allRewards[] = [
|
||||||
|
'index' => $index,
|
||||||
|
'type' => $rewardContent['type'],
|
||||||
|
'value' => $rewardContent['value'],
|
||||||
|
'name' => $rewardContent['name'] ?? ''
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $allRewards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按index分组奖励
|
||||||
|
*/
|
||||||
|
private function groupRewardsByIndex($allRewards)
|
||||||
|
{
|
||||||
|
$grouped = [];
|
||||||
|
|
||||||
|
foreach ($allRewards as $reward) {
|
||||||
|
$index = $reward['index'];
|
||||||
|
if (!isset($grouped[$index])) {
|
||||||
|
$grouped[$index] = [];
|
||||||
|
}
|
||||||
|
$grouped[$index][] = $reward;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按index排序
|
||||||
|
ksort($grouped);
|
||||||
|
|
||||||
|
return $grouped;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按名次顺序分配奖励
|
||||||
|
*/
|
||||||
|
private function distributeByRank($groupedRewards)
|
||||||
|
{
|
||||||
|
$distribution = [];
|
||||||
|
$currentRank = 0; // 从第1名开始
|
||||||
|
|
||||||
|
// 按index顺序分配(index 0 = 第1名,index 1 = 第2名,以此类推)
|
||||||
|
foreach ($groupedRewards as $index => $rewards) {
|
||||||
|
// 确保名次连续,如果有空缺则填充空名次
|
||||||
|
while ($currentRank < $index) {
|
||||||
|
$distribution[] = [
|
||||||
|
'rank' => $currentRank + 1,
|
||||||
|
'rewards' => []
|
||||||
|
];
|
||||||
|
$currentRank++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分配当前名次的奖励
|
||||||
|
$distribution[] = [
|
||||||
|
'rank' => $currentRank + 1,
|
||||||
|
'rewards' => $rewards
|
||||||
|
];
|
||||||
|
$currentRank++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $distribution;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_hour_ranking($time){
|
||||||
|
// 先按时间段和排名索引分组查询
|
||||||
|
$timeRanges = db::name('vs_hour_ranking_gift_config')->distinct(true)
|
||||||
|
->where('time_id', '=', $time)
|
||||||
|
->order('time_id')
|
||||||
|
->column('time_id');
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
foreach ($timeRanges as $timeRange) {
|
||||||
|
// 查询该时间段的所有数据
|
||||||
|
$rewards = db::name('vs_hour_ranking_gift_config')->where('time_id', $timeRange)
|
||||||
|
->field('ranking, gift_type, gift_id,coin,name')
|
||||||
|
->order('ranking')
|
||||||
|
->select();
|
||||||
|
|
||||||
|
$rewardMap = [];
|
||||||
|
foreach ($rewards as $reward) {
|
||||||
|
$rankIndex = $reward['ranking'];
|
||||||
|
|
||||||
|
if (!isset($rewardMap[$rankIndex])) {
|
||||||
|
$rewardMap[$rankIndex] = [
|
||||||
|
'index' => $rankIndex,
|
||||||
|
// 'name' => $reward['rank_name'],
|
||||||
|
'content' => []
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加奖励内容到content数组
|
||||||
|
if ($reward['gift_id'] != 0 || $reward['coin'] != 0) {
|
||||||
|
if($reward['gift_id'] != 0){
|
||||||
|
$rewardMap[$rankIndex]['content'][] = [
|
||||||
|
'type' => $reward['gift_type'],
|
||||||
|
'value' => $reward['gift_id'],
|
||||||
|
// 'coin' => $reward['coin'],
|
||||||
|
'name' => $reward['name'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if($reward['coin'] != 0){
|
||||||
|
$rewardMap[$rankIndex]['content'][] = [
|
||||||
|
'type' => $reward['gift_type'],
|
||||||
|
'value' => $reward['coin'],
|
||||||
|
'name' => $reward['name'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按index排序
|
||||||
|
ksort($rewardMap);
|
||||||
|
|
||||||
|
$result[] = [
|
||||||
|
'time' => $timeRange,
|
||||||
|
'reward' => array_values($rewardMap)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
195
application/cron/controller/RoomPan.php
Normal file
195
application/cron/controller/RoomPan.php
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\cron\controller;
|
||||||
|
|
||||||
|
use app\common\controller\Push;
|
||||||
|
use think\Cache;
|
||||||
|
use think\Db;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 定时任务,每秒执行的方法
|
||||||
|
*/
|
||||||
|
class RoomPan
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* 运行函数
|
||||||
|
*/
|
||||||
|
function index()
|
||||||
|
{
|
||||||
|
echo "巡乐会礼物发放开始:\n";
|
||||||
|
$this->xlh_gift_send();//拍卖房结束提醒
|
||||||
|
echo "礼物发放结束 \n";
|
||||||
|
|
||||||
|
echo "盲盒转盘礼物补发:\n";
|
||||||
|
$this->blind_box_turntable_gift_send();//盲盒转盘礼物补发
|
||||||
|
echo "盲盒转盘礼物补发结束 \n";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 盲盒转盘礼物推送补发
|
||||||
|
*/
|
||||||
|
public function blind_box_turntable_gift_send(){
|
||||||
|
$blind_box_turntable = db('vs_blind_box_turntable_log')->where(['is_sued'=>0,'createtime'=>['>=',time()-60*30]])->limit(1000)->select();
|
||||||
|
if(empty($blind_box_turntable)){
|
||||||
|
echo "没有需要发放的礼物 \n";
|
||||||
|
}
|
||||||
|
echo "开始发放".count($blind_box_turntable)." \n";
|
||||||
|
foreach ($blind_box_turntable as $k => $v) {
|
||||||
|
$blind_box_turntable_results_log = db('vs_blind_box_turntable_results_log')->where('tid',$v['id'])->select();
|
||||||
|
if(empty($blind_box_turntable_results_log)){
|
||||||
|
echo $v['id']." 没有需要发放的礼物 \n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$room_id = $v['room_id'];
|
||||||
|
$room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name');
|
||||||
|
$FromUserInfo = Db::name('user')->where(['id'=>$v['user_id']])->find();
|
||||||
|
$FromUserInfo['user_id'] = $FromUserInfo['id'];
|
||||||
|
$FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($v['user_id']);//财富图标
|
||||||
|
$FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($v['user_id']);//魅力图标
|
||||||
|
$user_nickname = $FromUserInfo['nickname'];
|
||||||
|
$textMessage = $user_nickname;
|
||||||
|
$text_message = $user_nickname;
|
||||||
|
foreach ($blind_box_turntable_results_log as $key => $value) {
|
||||||
|
$ToUserInfo = Db::name('user')->where(['id' => $value['gift_user_id']])->field('id as user_id,nickname,avatar,sex')->find();
|
||||||
|
$draw_gift = Db::name('vs_gift')->where(['gid'=>$value['gift_id']])->find();
|
||||||
|
$textMessage = $textMessage . ' 送给 ' . $ToUserInfo['nickname']. ' 盲盒转盘礼物 ' . $draw_gift['gift_name'].' x ' .$value['count']."\n";
|
||||||
|
$play_image[] = $draw_gift['play_image'];
|
||||||
|
$gift_names[] = $draw_gift['gift_name'];
|
||||||
|
|
||||||
|
$text_message = $text_message . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $draw_gift['gift_name'] . 'X' . $value['count']."\n";
|
||||||
|
if($draw_gift['is_public_server'] == 1) {
|
||||||
|
$text_list_new[] = [
|
||||||
|
'text' => $text_message,
|
||||||
|
'gift_picture' => $draw_gift['base_image'],
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'fromUserName' => $FromUserInfo['nickname'],
|
||||||
|
'toUserName' => $ToUserInfo['nickname'],
|
||||||
|
'giftName' => $draw_gift['gift_name'],
|
||||||
|
'roomId' => $room_id,
|
||||||
|
'number' => $value['count'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$ToUserInfosList[$value['gift_user_id']] = $ToUserInfo;
|
||||||
|
}
|
||||||
|
foreach($ToUserInfosList as &$userInfo) {
|
||||||
|
$userInfo['icon'][0] = model('UserData')->user_wealth_icon($userInfo['user_id']);//财富图标
|
||||||
|
$userInfo['icon'][1] = model('UserData')->user_charm_icon($userInfo['user_id']);//魅力图标
|
||||||
|
$userInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $userInfo['user_id'],'room_id' => $room_id])->value('charm');//魅力
|
||||||
|
$ToUserInfos[] = $userInfo;
|
||||||
|
}
|
||||||
|
$text = [
|
||||||
|
'FromUserInfo' => $FromUserInfo,
|
||||||
|
'ToUserInfos' => $ToUserInfos,
|
||||||
|
'GiftInfo' => [
|
||||||
|
'play_image' => implode(',',$play_image),
|
||||||
|
'gift_name' => implode(',',$gift_names),
|
||||||
|
],
|
||||||
|
'text' => rtrim($textMessage, "\n")
|
||||||
|
];
|
||||||
|
//聊天室推送系统消息
|
||||||
|
model('Chat')->sendMsg(1005,$room_id,$text);
|
||||||
|
$roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||||
|
if($roomtype == 6){
|
||||||
|
//推送消息
|
||||||
|
$hot_value = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',6)
|
||||||
|
->sum('total_price');
|
||||||
|
$text1 = [
|
||||||
|
'room_id' => $room_id,
|
||||||
|
'hot_value' => $hot_value * 10,
|
||||||
|
'text' => '房间心动值变化'
|
||||||
|
];
|
||||||
|
//聊天室推送系统消息
|
||||||
|
model('Chat')->sendMsg(1028,$room_id,$text1);
|
||||||
|
}else{
|
||||||
|
if(!empty($text_list_new)){
|
||||||
|
//推送礼物横幅
|
||||||
|
$push = new Push($v['user_id'], $room_id);
|
||||||
|
$push->giftBanner($text_list_new);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
db::name('vs_blind_box_turntable_log')->where('id', $v['id'])->update(['is_sued' => 1, 'updatetime' => time()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 巡乐会结束 礼物发放 【定时脚本】
|
||||||
|
*/
|
||||||
|
public function xlh_gift_send(){
|
||||||
|
$xlh_list = db::name('vs_room_pan_xlh')->where(['send_time'=>0,'end_time'=>['<=',time()]])->select();
|
||||||
|
if(empty($xlh_list)){
|
||||||
|
echo "没有需要发放的礼物 \n";
|
||||||
|
}
|
||||||
|
foreach ($xlh_list as $key=>$value){
|
||||||
|
try{
|
||||||
|
if($value['user_id'] == 0){
|
||||||
|
echo "第.".$value['periods']." 巡乐会结束 没有中奖用户 \n";
|
||||||
|
$res = db::name('vs_room_pan_xlh')->where('id',$value['id'])->update([
|
||||||
|
'send_time' => time()
|
||||||
|
]);
|
||||||
|
// db::name("vs_room")->where('id',$value['room_id'])->update([
|
||||||
|
// 'xlh_periods_num' => 0
|
||||||
|
// ]);
|
||||||
|
Cache::set("xlh_periods_num", 0, 0);
|
||||||
|
//推送礼物横幅
|
||||||
|
$text = "本轮巡乐会已结束,请大家重新开始下一轮巡乐会";
|
||||||
|
$push = new Push(0, $value['room_id']);
|
||||||
|
$text_list_new = [
|
||||||
|
'text' => $text,
|
||||||
|
'room_id' => $value['room_id'],
|
||||||
|
'from_type' => 104
|
||||||
|
];
|
||||||
|
$push->xunlehui($text_list_new);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//发放
|
||||||
|
//抽中礼物落包
|
||||||
|
$res = [];
|
||||||
|
$res = model('api/UserGiftPack')->change_user_gift_pack($value['user_id'],$value['gift_id'],$value['num'],model('UserGiftPack')::XLH_DRAW_GIFT_GET,"巡乐会中奖发放");
|
||||||
|
if ($res['code'] != 1) {
|
||||||
|
echo $res['msg']."\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
echo "巡乐会中奖礼物发放成功 用户Id:".$value['user_id']."\n";
|
||||||
|
//房主礼物落包
|
||||||
|
$res = [];
|
||||||
|
//获取房主id
|
||||||
|
$user_id = db::name('vs_room')->where(['id'=>$value['room_id']])->value('user_id');
|
||||||
|
$res = model('api/UserGiftPack')->change_user_gift_pack($user_id,$value['homeowner_gift_id'],1,model('UserGiftPack')::XLH_DRAW_GIFT_GET,"巡乐会中奖后房主礼物发放");
|
||||||
|
if ($res['code'] != 1) {
|
||||||
|
echo $res['msg']."\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
echo "巡乐会中奖后房主礼物发放成功 房主Id:".$user_id."\n";
|
||||||
|
//处理发放记录
|
||||||
|
$res = [];
|
||||||
|
$res = db::name('vs_room_pan_xlh')->where('id',$value['id'])->update([
|
||||||
|
'send_time' => time()
|
||||||
|
]);
|
||||||
|
$xlh_log = db::name('vs_room_pan_xlh_log')->where(['xlh_id'=>$value['id'],'user_id'=>$value['user_id']])->order('id desc')->find();
|
||||||
|
$res = db::name('vs_room_pan_xlh_log')->where('id',$xlh_log['id'])->update([
|
||||||
|
'is_send' => 1
|
||||||
|
]);
|
||||||
|
if ($res === false) {
|
||||||
|
echo "处理发放记录失败 \n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Cache::set("xlh_periods_num", 0, 0);
|
||||||
|
//推送
|
||||||
|
$FromUserInfo = db::name('user')->field('nickname,avatar')->where(['id'=>$value['user_id']])->find();
|
||||||
|
$gift_name = db::name('vs_gift')->where(['gid'=>$value['gift_id']])->value('gift_name');
|
||||||
|
$text = $FromUserInfo['nickname'] . ' 用户在巡乐会中 ' .$gift_name.'礼物 x ' .$value['num']." 已收入背包";
|
||||||
|
//推送礼物横幅
|
||||||
|
$push = new Push(0, $value['room_id']);
|
||||||
|
$text_list_new = [
|
||||||
|
'text' => $text,
|
||||||
|
'room_id' => $value['room_id'],
|
||||||
|
'from_type' => 104
|
||||||
|
];
|
||||||
|
$push->xunlehui($text_list_new);
|
||||||
|
}catch (\Exception $e){
|
||||||
|
echo $e->getMessage()."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
158
application/cron/controller/Test.php
Normal file
158
application/cron/controller/Test.php
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\cron\controller;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
use Yzh\YunPay;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 定时任务,每秒执行的方法
|
||||||
|
*/
|
||||||
|
class Test
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* 运行函数
|
||||||
|
*/
|
||||||
|
function index()
|
||||||
|
{
|
||||||
|
// 设置脚本执行时间无限
|
||||||
|
set_time_limit(0);
|
||||||
|
echo "统计盲盒转盘错误数据\n";
|
||||||
|
$this->blind_box_error();
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//统计盲盒转盘错误数据
|
||||||
|
public function blind_box_error()
|
||||||
|
{
|
||||||
|
die("暂停");
|
||||||
|
// 设置数据库查询超时时间
|
||||||
|
Db::query("SET SESSION wait_timeout=600");
|
||||||
|
Db::query("SET SESSION interactive_timeout=600");
|
||||||
|
|
||||||
|
// 使用连表查询,直接找出送给多人的数据
|
||||||
|
echo "开始查询送给多人的数据...\n";
|
||||||
|
|
||||||
|
// 先查询所有有多个不同 gift_user_id 的 tid
|
||||||
|
$multipleGiftRecords = Db::name('vs_blind_box_turntable_results_log')
|
||||||
|
->group('tid')
|
||||||
|
->having('COUNT(DISTINCT gift_user_id) > 1')
|
||||||
|
->field('tid, COUNT(DISTINCT gift_user_id) as user_count,gift_user_id')
|
||||||
|
->select();
|
||||||
|
|
||||||
|
echo "找到 " . count($multipleGiftRecords) . " 条送给多人的记录\n";
|
||||||
|
|
||||||
|
// 输出详细信息
|
||||||
|
foreach ($multipleGiftRecords as $record) {
|
||||||
|
echo "转盘ID: {$record['tid']}, 接收人数: {$record['user_count']}\n";
|
||||||
|
// 获取该转盘的详细信息
|
||||||
|
$turntableInfo = Db::name('vs_blind_box_turntable_log')
|
||||||
|
->where('id', $record['tid'])
|
||||||
|
->find();
|
||||||
|
|
||||||
|
if ($turntableInfo) {
|
||||||
|
echo " 开奖用户ID: {$turntableInfo['user_id']}, 礼包ID: {$turntableInfo['gift_bag_id']}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "统计盲盒转盘错误数据完成\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//统计盲盒转盘错误数据
|
||||||
|
public function blind_box_error1()
|
||||||
|
{
|
||||||
|
die("暂停");
|
||||||
|
// 设置数据库查询超时时间
|
||||||
|
Db::query("SET SESSION wait_timeout=600");
|
||||||
|
Db::query("SET SESSION interactive_timeout=600");
|
||||||
|
|
||||||
|
// 分批处理数据,避免一次性加载大量数据到内存
|
||||||
|
$batchSize = 1000;
|
||||||
|
$offset = 0;
|
||||||
|
$data_multiple = [];
|
||||||
|
$totalProcessed = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
// 分批获取数据
|
||||||
|
$turntable_log = Db::name('vs_blind_box_turntable_log')
|
||||||
|
->limit($offset, $batchSize)
|
||||||
|
->select();
|
||||||
|
|
||||||
|
// 如果没有更多数据,退出循环
|
||||||
|
if (empty($turntable_log)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($turntable_log as $key => $value) {
|
||||||
|
//查询本轮是否有多个接收礼物的人
|
||||||
|
$turntable_results_log = Db::name('vs_blind_box_turntable_results_log')
|
||||||
|
->where('tid', $value['id'])
|
||||||
|
->group('gift_user_id')
|
||||||
|
->select();
|
||||||
|
|
||||||
|
// 统计送给多人的数据
|
||||||
|
if (count($turntable_results_log) > 1) {
|
||||||
|
$data_multiple[] = [
|
||||||
|
'turntable_id' => $value['id'],
|
||||||
|
'recipient_count' => count($turntable_results_log),
|
||||||
|
'data' => $value
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$totalProcessed++;
|
||||||
|
|
||||||
|
// 每处理100条记录输出一次进度
|
||||||
|
if ($totalProcessed % 100 == 0) {
|
||||||
|
echo "已处理 {$totalProcessed} 条记录...\n";
|
||||||
|
// 每100条记录后清理内存
|
||||||
|
gc_collect_cycles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新偏移量
|
||||||
|
$offset += $batchSize;
|
||||||
|
|
||||||
|
// 释放内存
|
||||||
|
unset($turntable_log);
|
||||||
|
unset($turntable_results_log);
|
||||||
|
|
||||||
|
} while ($totalProcessed <= 1400);
|
||||||
|
|
||||||
|
echo "送给多人的数据共 " . count($data_multiple) . " 条记录\n";
|
||||||
|
echo "统计盲盒转盘错误数据完成-共处理 " . $totalProcessed . " 条数据\n";
|
||||||
|
|
||||||
|
// 输出详细信息
|
||||||
|
foreach ($data_multiple as $item) {
|
||||||
|
echo "转盘ID: {$item['turntable_id']}, 接收人数: {$item['recipient_count']}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function RoomOwners()
|
||||||
|
{
|
||||||
|
$room = Db::name('vs_room')->where(['room_status' => 1,'apply_status' => 2])->select();
|
||||||
|
$arr = [];
|
||||||
|
foreach ($room as $key => $value) {
|
||||||
|
$liushui = Db::name('vs_give_gift')->where(['from_id' => $value['id'],'from' => 2])->sum('total_price');
|
||||||
|
$usercode = Db::name('user')->where(['id' => $value['user_id']])->value('user_code');
|
||||||
|
$nickname = Db::name('user')->where(['id' => $value['user_id']])->value('nickname');
|
||||||
|
$arr[] = [
|
||||||
|
'room_id' => $value['id'],
|
||||||
|
'user_id' => $value['user_id'],
|
||||||
|
'user_code' => $usercode,
|
||||||
|
'nickname' => $nickname,
|
||||||
|
'liushui' => $liushui
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
//房主的收益
|
||||||
|
foreach ($arr as $key => $v){
|
||||||
|
$shouyi = db::name('vs_user_money_log')->where(['user_id' => $v['user_id'],'change_type' => 18,'money_type' =>2,'createtime'=>['<',1759585380]])->sum('change_value');
|
||||||
|
$arr[$key]['shouyi'] = $shouyi;
|
||||||
|
$arr[$key]['duibi'] = $shouyi.'-'.$v['liushui']/10/10;
|
||||||
|
$arr[$key]['chazhi'] = $v['liushui']/10/10 - $shouyi;
|
||||||
|
}
|
||||||
|
var_dump($arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
12
application/extra/redis.php
Normal file
12
application/extra/redis.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'host' => '127.0.0.1',
|
||||||
|
'port' => 6379,
|
||||||
|
'password' => '',
|
||||||
|
'select' => 0,
|
||||||
|
'timeout' => 0,
|
||||||
|
'expire' => 0,
|
||||||
|
'persistent' => false,
|
||||||
|
'prefix' => 'fa_redpacket_',
|
||||||
|
];
|
||||||
81
extend/Yzh/CalculateLaborServiceClient.php
Normal file
81
extend/Yzh/CalculateLaborServiceClient.php
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh;
|
||||||
|
|
||||||
|
use Yzh\Exception\ConfigException;
|
||||||
|
use Yzh\Exception\ExceptionCode;
|
||||||
|
|
||||||
|
|
||||||
|
use Yzh\Model\Calculatelabor\LaborCaculatorRequest;
|
||||||
|
use Yzh\Model\Calculatelabor\LaborCaculatorResponse;
|
||||||
|
use Yzh\Model\Calculatelabor\CalcTaxRequest;
|
||||||
|
use Yzh\Model\Calculatelabor\CalcTaxResponse;
|
||||||
|
use Yzh\Model\Calculatelabor\CalculationYearH5UrlRequest;
|
||||||
|
use Yzh\Model\Calculatelabor\CalculationYearH5UrlResponse;
|
||||||
|
use Yzh\Model\Calculatelabor\CalculationH5UrlRequest;
|
||||||
|
use Yzh\Model\Calculatelabor\CalculationH5UrlResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务税费试算
|
||||||
|
* Class CalculateLaborServiceClient
|
||||||
|
*/
|
||||||
|
class CalculateLaborServiceClient extends BaseClient
|
||||||
|
{
|
||||||
|
protected static $service_name = 'calculatelaborservice';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务税费试算(计算器)
|
||||||
|
* @param LaborCaculatorRequest $request
|
||||||
|
* @param null $option
|
||||||
|
* @return LaborCaculatorResponse
|
||||||
|
*/
|
||||||
|
public function laborCaculator($request, $option = null)
|
||||||
|
{
|
||||||
|
if (!$request instanceof LaborCaculatorRequest) {
|
||||||
|
throw new ConfigException("Calculatelabor->laborCaculator request 必须是 Yzh\\Model\\Calculatelabor\\LaborCaculatorRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||||
|
}
|
||||||
|
return $this->send('POST', '/api/tax/v1/labor-caculator', $request, "Yzh\\Model\\Calculatelabor\\LaborCaculatorResponse", $option);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单税费试算
|
||||||
|
* @param CalcTaxRequest $request
|
||||||
|
* @param null $option
|
||||||
|
* @return CalcTaxResponse
|
||||||
|
*/
|
||||||
|
public function calcTax($request, $option = null)
|
||||||
|
{
|
||||||
|
if (!$request instanceof CalcTaxRequest) {
|
||||||
|
throw new ConfigException("Calculatelabor->calcTax request 必须是 Yzh\\Model\\Calculatelabor\\CalcTaxRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||||
|
}
|
||||||
|
return $this->send('POST', '/api/payment/v1/calc-tax', $request, "Yzh\\Model\\Calculatelabor\\CalcTaxResponse", $option);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务年度税费测算-H5
|
||||||
|
* @param CalculationYearH5UrlRequest $request
|
||||||
|
* @param null $option
|
||||||
|
* @return CalculationYearH5UrlResponse
|
||||||
|
*/
|
||||||
|
public function calculationYearH5Url($request, $option = null)
|
||||||
|
{
|
||||||
|
if (!$request instanceof CalculationYearH5UrlRequest) {
|
||||||
|
throw new ConfigException("Calculatelabor->calculationYearH5Url request 必须是 Yzh\\Model\\Calculatelabor\\CalculationYearH5UrlRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||||
|
}
|
||||||
|
return $this->send('GET', '/api/labor/service/calculation/year/h5url', $request, "Yzh\\Model\\Calculatelabor\\CalculationYearH5UrlResponse", $option);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务单笔结算税费测算-H5
|
||||||
|
* @param CalculationH5UrlRequest $request
|
||||||
|
* @param null $option
|
||||||
|
* @return CalculationH5UrlResponse
|
||||||
|
*/
|
||||||
|
public function calculationH5Url($request, $option = null)
|
||||||
|
{
|
||||||
|
if (!$request instanceof CalculationH5UrlRequest) {
|
||||||
|
throw new ConfigException("Calculatelabor->calculationH5Url request 必须是 Yzh\\Model\\Calculatelabor\\CalculationH5UrlRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||||
|
}
|
||||||
|
return $this->send('GET', '/api/labor/service/calculation/h5url', $request, "Yzh\\Model\\Calculatelabor\\CalculationH5UrlResponse", $option);
|
||||||
|
}
|
||||||
|
}
|
||||||
40
extend/Yzh/CustomerLinkClient.php
Normal file
40
extend/Yzh/CustomerLinkClient.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh;
|
||||||
|
|
||||||
|
use Yzh\Utils\Rsa;
|
||||||
|
use Yzh\Utils\Hmac;
|
||||||
|
use Yzh\Utils\MessString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 专属客服链接
|
||||||
|
* Class CustomerLinkClient
|
||||||
|
*/
|
||||||
|
class CustomerLinkClient extends BaseClient
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取客服链接
|
||||||
|
* @return str
|
||||||
|
*/
|
||||||
|
public function getCustomerLink($base_url, $member_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
$mess = MessString::rand(16);
|
||||||
|
$timestamp = time();
|
||||||
|
$signature = "";
|
||||||
|
$encodesign = "";
|
||||||
|
// 签名
|
||||||
|
$signdata = "data=member_id=".$member_id."&mess=".$mess."×tamp=".$timestamp."&key=".$this->config->app_key;
|
||||||
|
|
||||||
|
if ($this->config->sign_type == Config::SIGN_TYPE_RSA) {
|
||||||
|
$signature = $this->rsa->sign($signdata);
|
||||||
|
}else if($this->config->sign_type == Config::SIGN_TYPE_HMAC) {
|
||||||
|
$signature = $this->hmac->sign($signdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
$encodesign = urlencode($signature);
|
||||||
|
|
||||||
|
$url = $base_url."?sign_type=".$this->config->sign_type."&sign=".$encodesign."&member_id=".$member_id."&mess=".$mess."×tamp=".$timestamp;
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
}
|
||||||
335
extend/Yzh/Model/Calculatelabor/CalcTaxDetail.php
Normal file
335
extend/Yzh/Model/Calculatelabor/CalcTaxDetail.php
Normal file
@@ -0,0 +1,335 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税费明细
|
||||||
|
* Class CalcTaxDetail
|
||||||
|
*/
|
||||||
|
class CalcTaxDetail extends BaseModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 预扣个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $personal_tax;
|
||||||
|
/**
|
||||||
|
* 预扣增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $value_added_tax;
|
||||||
|
/**
|
||||||
|
* 预扣附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $additional_tax;
|
||||||
|
/**
|
||||||
|
* 用户预扣个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_personal_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业预扣个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_personal_tax;
|
||||||
|
/**
|
||||||
|
* 云账户预扣个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_personal_tax;
|
||||||
|
/**
|
||||||
|
* 用户预扣增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_value_added_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业预扣增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_value_added_tax;
|
||||||
|
/**
|
||||||
|
* 云账户预扣增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_value_added_tax;
|
||||||
|
/**
|
||||||
|
* 用户预扣附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_additional_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业预扣附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_additional_tax;
|
||||||
|
/**
|
||||||
|
* 云账户预扣附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_additional_tax;
|
||||||
|
/**
|
||||||
|
* 预扣个税税率
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $personal_tax_rate;
|
||||||
|
/**
|
||||||
|
* 预扣个税速算扣除数
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $deduct_tax;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税
|
||||||
|
* @var string $personal_tax
|
||||||
|
*/
|
||||||
|
public function setPersonalTax($personal_tax)
|
||||||
|
{
|
||||||
|
$this->personal_tax = $personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣增值税
|
||||||
|
* @var string $value_added_tax
|
||||||
|
*/
|
||||||
|
public function setValueAddedTax($value_added_tax)
|
||||||
|
{
|
||||||
|
$this->value_added_tax = $value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣附加税费
|
||||||
|
* @var string $additional_tax
|
||||||
|
*/
|
||||||
|
public function setAdditionalTax($additional_tax)
|
||||||
|
{
|
||||||
|
$this->additional_tax = $additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣个税
|
||||||
|
* @var string $user_personal_tax
|
||||||
|
*/
|
||||||
|
public function setUserPersonalTax($user_personal_tax)
|
||||||
|
{
|
||||||
|
$this->user_personal_tax = $user_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->user_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣个税
|
||||||
|
* @var string $dealer_personal_tax
|
||||||
|
*/
|
||||||
|
public function setDealerPersonalTax($dealer_personal_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_personal_tax = $dealer_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云账户预扣个税
|
||||||
|
* @var string $broker_personal_tax
|
||||||
|
*/
|
||||||
|
public function setBrokerPersonalTax($broker_personal_tax)
|
||||||
|
{
|
||||||
|
$this->broker_personal_tax = $broker_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云账户预扣个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->broker_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣增值税
|
||||||
|
* @var string $user_value_added_tax
|
||||||
|
*/
|
||||||
|
public function setUserValueAddedTax($user_value_added_tax)
|
||||||
|
{
|
||||||
|
$this->user_value_added_tax = $user_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->user_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣增值税
|
||||||
|
* @var string $dealer_value_added_tax
|
||||||
|
*/
|
||||||
|
public function setDealerValueAddedTax($dealer_value_added_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_value_added_tax = $dealer_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云账户预扣增值税
|
||||||
|
* @var string $broker_value_added_tax
|
||||||
|
*/
|
||||||
|
public function setBrokerValueAddedTax($broker_value_added_tax)
|
||||||
|
{
|
||||||
|
$this->broker_value_added_tax = $broker_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云账户预扣增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->broker_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣附加税费
|
||||||
|
* @var string $user_additional_tax
|
||||||
|
*/
|
||||||
|
public function setUserAdditionalTax($user_additional_tax)
|
||||||
|
{
|
||||||
|
$this->user_additional_tax = $user_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->user_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣附加税费
|
||||||
|
* @var string $dealer_additional_tax
|
||||||
|
*/
|
||||||
|
public function setDealerAdditionalTax($dealer_additional_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_additional_tax = $dealer_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云账户预扣附加税费
|
||||||
|
* @var string $broker_additional_tax
|
||||||
|
*/
|
||||||
|
public function setBrokerAdditionalTax($broker_additional_tax)
|
||||||
|
{
|
||||||
|
$this->broker_additional_tax = $broker_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云账户预扣附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->broker_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税税率
|
||||||
|
* @var string $personal_tax_rate
|
||||||
|
*/
|
||||||
|
public function setPersonalTaxRate($personal_tax_rate)
|
||||||
|
{
|
||||||
|
$this->personal_tax_rate = $personal_tax_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税税率
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPersonalTaxRate()
|
||||||
|
{
|
||||||
|
return $this->personal_tax_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税速算扣除数
|
||||||
|
* @var string $deduct_tax
|
||||||
|
*/
|
||||||
|
public function setDeductTax($deduct_tax)
|
||||||
|
{
|
||||||
|
$this->deduct_tax = $deduct_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税速算扣除数
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDeductTax()
|
||||||
|
{
|
||||||
|
return $this->deduct_tax;
|
||||||
|
}
|
||||||
|
}
|
||||||
52
extend/Yzh/Model/Calculatelabor/CalcTaxRequest.php
Normal file
52
extend/Yzh/Model/Calculatelabor/CalcTaxRequest.php
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单税费试算请求
|
||||||
|
* Class CalcTaxRequest
|
||||||
|
*/
|
||||||
|
class CalcTaxRequest extends BaseRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 平台企业 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $dealer_id;
|
||||||
|
/**
|
||||||
|
* 综合服务主体 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $broker_id;
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $real_name;
|
||||||
|
/**
|
||||||
|
* 证件号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $id_card;
|
||||||
|
/**
|
||||||
|
* 测算金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $pay;
|
||||||
|
/**
|
||||||
|
* 测算类型
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $tax_type;
|
||||||
|
|
||||||
|
public function __construct($params = array())
|
||||||
|
{
|
||||||
|
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||||
|
if (isset($params[$property])) {
|
||||||
|
$this->{$property} = $params[$property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
extend/Yzh/Model/Calculatelabor/CalcTaxResponse.php
Normal file
33
extend/Yzh/Model/Calculatelabor/CalcTaxResponse.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseResponse;
|
||||||
|
use Yzh\Model\ResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单税费试算返回
|
||||||
|
* Class CalcTaxResponse
|
||||||
|
*/
|
||||||
|
class CalcTaxResponse extends BaseResponse implements ResponseInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取数据对象
|
||||||
|
* @return CalcTaxResponseData
|
||||||
|
*/
|
||||||
|
public function getData()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置数据对象
|
||||||
|
* @param array $data
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setData($data)
|
||||||
|
{
|
||||||
|
$this->data = new CalcTaxResponseData($data);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
405
extend/Yzh/Model/Calculatelabor/CalcTaxResponseData.php
Normal file
405
extend/Yzh/Model/Calculatelabor/CalcTaxResponseData.php
Normal file
@@ -0,0 +1,405 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
use Yzh\Model\ResponseDataInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单税费试算返回
|
||||||
|
* Class CalcTaxResponseData
|
||||||
|
*/
|
||||||
|
class CalcTaxResponseData extends BaseModel implements ResponseDataInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 测算金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $pay;
|
||||||
|
/**
|
||||||
|
* 税费总额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $tax;
|
||||||
|
/**
|
||||||
|
* 税后结算金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $after_tax_amount;
|
||||||
|
/**
|
||||||
|
* 缴税明细
|
||||||
|
* @var CalcTaxDetail
|
||||||
|
*/
|
||||||
|
protected $tax_detail;
|
||||||
|
/**
|
||||||
|
* 税前订单金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $before_tax_amount;
|
||||||
|
/**
|
||||||
|
* 用户税费总额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业税费总额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_tax;
|
||||||
|
/**
|
||||||
|
* 云账户税费总额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_tax;
|
||||||
|
/**
|
||||||
|
* 用户服务费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_fee;
|
||||||
|
/**
|
||||||
|
* 结果
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $status;
|
||||||
|
/**
|
||||||
|
* 结果详细状态码
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $status_detail;
|
||||||
|
/**
|
||||||
|
* 结果说明
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $status_message;
|
||||||
|
/**
|
||||||
|
* 结果详细状态码描述
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $status_detail_message;
|
||||||
|
/**
|
||||||
|
* 用户实收金额(未扣除追缴的增附税)
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_real_excluding_vat_amount;
|
||||||
|
/**
|
||||||
|
* 用户还未缴清的增附税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_remaining_repayment_amount;
|
||||||
|
/**
|
||||||
|
* 已追缴增附税(本笔订单)
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_recover_tax_amount;
|
||||||
|
/**
|
||||||
|
* 待追缴增附税总金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_total_recover_tax_amount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测算金额
|
||||||
|
* @var string $pay
|
||||||
|
*/
|
||||||
|
public function setPay($pay)
|
||||||
|
{
|
||||||
|
$this->pay = $pay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测算金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPay()
|
||||||
|
{
|
||||||
|
return $this->pay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税费总额
|
||||||
|
* @var string $tax
|
||||||
|
*/
|
||||||
|
public function setTax($tax)
|
||||||
|
{
|
||||||
|
$this->tax = $tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税费总额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTax()
|
||||||
|
{
|
||||||
|
return $this->tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税后结算金额
|
||||||
|
* @var string $after_tax_amount
|
||||||
|
*/
|
||||||
|
public function setAfterTaxAmount($after_tax_amount)
|
||||||
|
{
|
||||||
|
$this->after_tax_amount = $after_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税后结算金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAfterTaxAmount()
|
||||||
|
{
|
||||||
|
return $this->after_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缴税明细
|
||||||
|
* @var CalcTaxDetail $tax_detail
|
||||||
|
*/
|
||||||
|
public function setTaxDetail($tax_detail)
|
||||||
|
{
|
||||||
|
$this->tax_detail = $tax_detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缴税明细
|
||||||
|
* @return CalcTaxDetail
|
||||||
|
*/
|
||||||
|
public function getTaxDetail()
|
||||||
|
{
|
||||||
|
return $this->tax_detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税前订单金额
|
||||||
|
* @var string $before_tax_amount
|
||||||
|
*/
|
||||||
|
public function setBeforeTaxAmount($before_tax_amount)
|
||||||
|
{
|
||||||
|
$this->before_tax_amount = $before_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税前订单金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBeforeTaxAmount()
|
||||||
|
{
|
||||||
|
return $this->before_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户税费总额
|
||||||
|
* @var string $user_tax
|
||||||
|
*/
|
||||||
|
public function setUserTax($user_tax)
|
||||||
|
{
|
||||||
|
$this->user_tax = $user_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户税费总额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserTax()
|
||||||
|
{
|
||||||
|
return $this->user_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业税费总额
|
||||||
|
* @var string $dealer_tax
|
||||||
|
*/
|
||||||
|
public function setDealerTax($dealer_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_tax = $dealer_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业税费总额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云账户税费总额
|
||||||
|
* @var string $broker_tax
|
||||||
|
*/
|
||||||
|
public function setBrokerTax($broker_tax)
|
||||||
|
{
|
||||||
|
$this->broker_tax = $broker_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云账户税费总额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerTax()
|
||||||
|
{
|
||||||
|
return $this->broker_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户服务费
|
||||||
|
* @var string $user_fee
|
||||||
|
*/
|
||||||
|
public function setUserFee($user_fee)
|
||||||
|
{
|
||||||
|
$this->user_fee = $user_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户服务费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserFee()
|
||||||
|
{
|
||||||
|
return $this->user_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结果
|
||||||
|
* @var string $status
|
||||||
|
*/
|
||||||
|
public function setStatus($status)
|
||||||
|
{
|
||||||
|
$this->status = $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结果
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatus()
|
||||||
|
{
|
||||||
|
return $this->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结果详细状态码
|
||||||
|
* @var string $status_detail
|
||||||
|
*/
|
||||||
|
public function setStatusDetail($status_detail)
|
||||||
|
{
|
||||||
|
$this->status_detail = $status_detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结果详细状态码
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatusDetail()
|
||||||
|
{
|
||||||
|
return $this->status_detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结果说明
|
||||||
|
* @var string $status_message
|
||||||
|
*/
|
||||||
|
public function setStatusMessage($status_message)
|
||||||
|
{
|
||||||
|
$this->status_message = $status_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结果说明
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatusMessage()
|
||||||
|
{
|
||||||
|
return $this->status_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结果详细状态码描述
|
||||||
|
* @var string $status_detail_message
|
||||||
|
*/
|
||||||
|
public function setStatusDetailMessage($status_detail_message)
|
||||||
|
{
|
||||||
|
$this->status_detail_message = $status_detail_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结果详细状态码描述
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatusDetailMessage()
|
||||||
|
{
|
||||||
|
return $this->status_detail_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实收金额(未扣除追缴的增附税)
|
||||||
|
* @var string $user_real_excluding_vat_amount
|
||||||
|
*/
|
||||||
|
public function setUserRealExcludingVatAmount($user_real_excluding_vat_amount)
|
||||||
|
{
|
||||||
|
$this->user_real_excluding_vat_amount = $user_real_excluding_vat_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实收金额(未扣除追缴的增附税)
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserRealExcludingVatAmount()
|
||||||
|
{
|
||||||
|
return $this->user_real_excluding_vat_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户还未缴清的增附税
|
||||||
|
* @var string $user_remaining_repayment_amount
|
||||||
|
*/
|
||||||
|
public function setUserRemainingRepaymentAmount($user_remaining_repayment_amount)
|
||||||
|
{
|
||||||
|
$this->user_remaining_repayment_amount = $user_remaining_repayment_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户还未缴清的增附税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserRemainingRepaymentAmount()
|
||||||
|
{
|
||||||
|
return $this->user_remaining_repayment_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已追缴增附税(本笔订单)
|
||||||
|
* @var string $user_recover_tax_amount
|
||||||
|
*/
|
||||||
|
public function setUserRecoverTaxAmount($user_recover_tax_amount)
|
||||||
|
{
|
||||||
|
$this->user_recover_tax_amount = $user_recover_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已追缴增附税(本笔订单)
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserRecoverTaxAmount()
|
||||||
|
{
|
||||||
|
return $this->user_recover_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 待追缴增附税总金额
|
||||||
|
* @var string $user_total_recover_tax_amount
|
||||||
|
*/
|
||||||
|
public function setUserTotalRecoverTaxAmount($user_total_recover_tax_amount)
|
||||||
|
{
|
||||||
|
$this->user_total_recover_tax_amount = $user_total_recover_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 待追缴增附税总金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserTotalRecoverTaxAmount()
|
||||||
|
{
|
||||||
|
return $this->user_total_recover_tax_amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
47
extend/Yzh/Model/Calculatelabor/CalculationH5UrlRequest.php
Normal file
47
extend/Yzh/Model/Calculatelabor/CalculationH5UrlRequest.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务单笔结算税费测算-H5 请求
|
||||||
|
* Class CalculationH5UrlRequest
|
||||||
|
*/
|
||||||
|
class CalculationH5UrlRequest extends BaseRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 平台企业 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $dealer_id;
|
||||||
|
/**
|
||||||
|
* 综合服务主体 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $broker_id;
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $real_name;
|
||||||
|
/**
|
||||||
|
* 证件号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $id_card;
|
||||||
|
/**
|
||||||
|
* 主题颜色
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $color;
|
||||||
|
|
||||||
|
public function __construct($params = array())
|
||||||
|
{
|
||||||
|
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||||
|
if (isset($params[$property])) {
|
||||||
|
$this->{$property} = $params[$property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
extend/Yzh/Model/Calculatelabor/CalculationH5UrlResponse.php
Normal file
33
extend/Yzh/Model/Calculatelabor/CalculationH5UrlResponse.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseResponse;
|
||||||
|
use Yzh\Model\ResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务单笔结算税费测算-H5 返回
|
||||||
|
* Class CalculationH5UrlResponse
|
||||||
|
*/
|
||||||
|
class CalculationH5UrlResponse extends BaseResponse implements ResponseInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取数据对象
|
||||||
|
* @return CalculationH5UrlResponseData
|
||||||
|
*/
|
||||||
|
public function getData()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置数据对象
|
||||||
|
* @param array $data
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setData($data)
|
||||||
|
{
|
||||||
|
$this->data = new CalculationH5UrlResponseData($data);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
use Yzh\Model\ResponseDataInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务单笔结算税费测算-H5 返回
|
||||||
|
* Class CalculationH5UrlResponseData
|
||||||
|
*/
|
||||||
|
class CalculationH5UrlResponseData extends BaseModel implements ResponseDataInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 连续劳务单笔结算税费测算 H5 页面 URL
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务单笔结算税费测算 H5 页面 URL
|
||||||
|
* @var string $url
|
||||||
|
*/
|
||||||
|
public function setUrl($url)
|
||||||
|
{
|
||||||
|
$this->url = $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务单笔结算税费测算 H5 页面 URL
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUrl()
|
||||||
|
{
|
||||||
|
return $this->url;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务年度税费测算-H5 请求
|
||||||
|
* Class CalculationYearH5UrlRequest
|
||||||
|
*/
|
||||||
|
class CalculationYearH5UrlRequest extends BaseRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 平台企业 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $dealer_id;
|
||||||
|
/**
|
||||||
|
* 综合服务主体 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $broker_id;
|
||||||
|
/**
|
||||||
|
* 主题颜色
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $color;
|
||||||
|
|
||||||
|
public function __construct($params = array())
|
||||||
|
{
|
||||||
|
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||||
|
if (isset($params[$property])) {
|
||||||
|
$this->{$property} = $params[$property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseResponse;
|
||||||
|
use Yzh\Model\ResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务年度税费测算-H5 返回
|
||||||
|
* Class CalculationYearH5UrlResponse
|
||||||
|
*/
|
||||||
|
class CalculationYearH5UrlResponse extends BaseResponse implements ResponseInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取数据对象
|
||||||
|
* @return CalculationYearH5UrlResponseData
|
||||||
|
*/
|
||||||
|
public function getData()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置数据对象
|
||||||
|
* @param array $data
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setData($data)
|
||||||
|
{
|
||||||
|
$this->data = new CalculationYearH5UrlResponseData($data);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
use Yzh\Model\ResponseDataInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务年度税费测算-H5 返回
|
||||||
|
* Class CalculationYearH5UrlResponseData
|
||||||
|
*/
|
||||||
|
class CalculationYearH5UrlResponseData extends BaseModel implements ResponseDataInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 年度劳务测算 H5 页面 URL
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 年度劳务测算 H5 页面 URL
|
||||||
|
* @var string $url
|
||||||
|
*/
|
||||||
|
public function setUrl($url)
|
||||||
|
{
|
||||||
|
$this->url = $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 年度劳务测算 H5 页面 URL
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUrl()
|
||||||
|
{
|
||||||
|
return $this->url;
|
||||||
|
}
|
||||||
|
}
|
||||||
37
extend/Yzh/Model/Calculatelabor/LaborCaculatorRequest.php
Normal file
37
extend/Yzh/Model/Calculatelabor/LaborCaculatorRequest.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务税费试算(计算器)请求
|
||||||
|
* Class LaborCaculatorRequest
|
||||||
|
*/
|
||||||
|
class LaborCaculatorRequest extends BaseRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 平台企业 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $dealer_id;
|
||||||
|
/**
|
||||||
|
* 综合服务主体 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $broker_id;
|
||||||
|
/**
|
||||||
|
* 月度收入列表
|
||||||
|
* @var MonthSettlement[]
|
||||||
|
*/
|
||||||
|
public $month_settlement_list;
|
||||||
|
|
||||||
|
public function __construct($params = array())
|
||||||
|
{
|
||||||
|
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||||
|
if (isset($params[$property])) {
|
||||||
|
$this->{$property} = $params[$property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
extend/Yzh/Model/Calculatelabor/LaborCaculatorResponse.php
Normal file
33
extend/Yzh/Model/Calculatelabor/LaborCaculatorResponse.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseResponse;
|
||||||
|
use Yzh\Model\ResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务税费试算(计算器)返回
|
||||||
|
* Class LaborCaculatorResponse
|
||||||
|
*/
|
||||||
|
class LaborCaculatorResponse extends BaseResponse implements ResponseInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取数据对象
|
||||||
|
* @return LaborCaculatorResponseData
|
||||||
|
*/
|
||||||
|
public function getData()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置数据对象
|
||||||
|
* @param array $data
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setData($data)
|
||||||
|
{
|
||||||
|
$this->data = new LaborCaculatorResponseData($data);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
use Yzh\Model\ResponseDataInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务税费试算(计算器)返回
|
||||||
|
* Class LaborCaculatorResponseData
|
||||||
|
*/
|
||||||
|
class LaborCaculatorResponseData extends BaseModel implements ResponseDataInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 综合所得汇算清缴
|
||||||
|
* @var YearTaxInfo
|
||||||
|
*/
|
||||||
|
protected $year_tax_info;
|
||||||
|
/**
|
||||||
|
* 月度税务信息列表
|
||||||
|
* @var MontTax[]
|
||||||
|
*/
|
||||||
|
protected $month_tax_list;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合所得汇算清缴
|
||||||
|
* @var YearTaxInfo $year_tax_info
|
||||||
|
*/
|
||||||
|
public function setYearTaxInfo($year_tax_info)
|
||||||
|
{
|
||||||
|
$this->year_tax_info = $year_tax_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合所得汇算清缴
|
||||||
|
* @return YearTaxInfo
|
||||||
|
*/
|
||||||
|
public function getYearTaxInfo()
|
||||||
|
{
|
||||||
|
return $this->year_tax_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array $items
|
||||||
|
*/
|
||||||
|
public function setMonthTaxList($items)
|
||||||
|
{
|
||||||
|
$this->month_tax_list = array();
|
||||||
|
foreach ($items as $k => $v) {
|
||||||
|
array_push($this->month_tax_list, new MontTax($v));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月度税务信息列表
|
||||||
|
* @return MontTax[]
|
||||||
|
*/
|
||||||
|
public function getMonthTaxList()
|
||||||
|
{
|
||||||
|
return $this->month_tax_list;
|
||||||
|
}
|
||||||
|
}
|
||||||
243
extend/Yzh/Model/Calculatelabor/MontTax.php
Normal file
243
extend/Yzh/Model/Calculatelabor/MontTax.php
Normal file
@@ -0,0 +1,243 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月度税务信息
|
||||||
|
* Class MontTax
|
||||||
|
*/
|
||||||
|
class MontTax extends BaseModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 月份
|
||||||
|
* @var int32
|
||||||
|
*/
|
||||||
|
protected $month;
|
||||||
|
/**
|
||||||
|
* 含增值税收入
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $pre_tax_amount;
|
||||||
|
/**
|
||||||
|
* 不含增值税收入
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $excluding_vat_amount;
|
||||||
|
/**
|
||||||
|
* 增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $value_added_tax;
|
||||||
|
/**
|
||||||
|
* 附加税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $additional_tax;
|
||||||
|
/**
|
||||||
|
* 个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $personal_tax;
|
||||||
|
/**
|
||||||
|
* 个税税率
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $personal_tax_rate;
|
||||||
|
/**
|
||||||
|
* 速算扣除数
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $deduct_tax;
|
||||||
|
/**
|
||||||
|
* 税后金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $post_tax_amount;
|
||||||
|
/**
|
||||||
|
* 税负率
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $total_tax_rate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月份
|
||||||
|
* @var int32 $month
|
||||||
|
*/
|
||||||
|
public function setMonth($month)
|
||||||
|
{
|
||||||
|
$this->month = $month;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月份
|
||||||
|
* @return int32
|
||||||
|
*/
|
||||||
|
public function getMonth()
|
||||||
|
{
|
||||||
|
return $this->month;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 含增值税收入
|
||||||
|
* @var string $pre_tax_amount
|
||||||
|
*/
|
||||||
|
public function setPreTaxAmount($pre_tax_amount)
|
||||||
|
{
|
||||||
|
$this->pre_tax_amount = $pre_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 含增值税收入
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPreTaxAmount()
|
||||||
|
{
|
||||||
|
return $this->pre_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不含增值税收入
|
||||||
|
* @var string $excluding_vat_amount
|
||||||
|
*/
|
||||||
|
public function setExcludingVatAmount($excluding_vat_amount)
|
||||||
|
{
|
||||||
|
$this->excluding_vat_amount = $excluding_vat_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不含增值税收入
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getExcludingVatAmount()
|
||||||
|
{
|
||||||
|
return $this->excluding_vat_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增值税
|
||||||
|
* @var string $value_added_tax
|
||||||
|
*/
|
||||||
|
public function setValueAddedTax($value_added_tax)
|
||||||
|
{
|
||||||
|
$this->value_added_tax = $value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 附加税
|
||||||
|
* @var string $additional_tax
|
||||||
|
*/
|
||||||
|
public function setAdditionalTax($additional_tax)
|
||||||
|
{
|
||||||
|
$this->additional_tax = $additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 附加税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个税
|
||||||
|
* @var string $personal_tax
|
||||||
|
*/
|
||||||
|
public function setPersonalTax($personal_tax)
|
||||||
|
{
|
||||||
|
$this->personal_tax = $personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个税税率
|
||||||
|
* @var string $personal_tax_rate
|
||||||
|
*/
|
||||||
|
public function setPersonalTaxRate($personal_tax_rate)
|
||||||
|
{
|
||||||
|
$this->personal_tax_rate = $personal_tax_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个税税率
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPersonalTaxRate()
|
||||||
|
{
|
||||||
|
return $this->personal_tax_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 速算扣除数
|
||||||
|
* @var string $deduct_tax
|
||||||
|
*/
|
||||||
|
public function setDeductTax($deduct_tax)
|
||||||
|
{
|
||||||
|
$this->deduct_tax = $deduct_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 速算扣除数
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDeductTax()
|
||||||
|
{
|
||||||
|
return $this->deduct_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税后金额
|
||||||
|
* @var string $post_tax_amount
|
||||||
|
*/
|
||||||
|
public function setPostTaxAmount($post_tax_amount)
|
||||||
|
{
|
||||||
|
$this->post_tax_amount = $post_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税后金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPostTaxAmount()
|
||||||
|
{
|
||||||
|
return $this->post_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税负率
|
||||||
|
* @var string $total_tax_rate
|
||||||
|
*/
|
||||||
|
public function setTotalTaxRate($total_tax_rate)
|
||||||
|
{
|
||||||
|
$this->total_tax_rate = $total_tax_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税负率
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTotalTaxRate()
|
||||||
|
{
|
||||||
|
return $this->total_tax_rate;
|
||||||
|
}
|
||||||
|
}
|
||||||
59
extend/Yzh/Model/Calculatelabor/MonthSettlement.php
Normal file
59
extend/Yzh/Model/Calculatelabor/MonthSettlement.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月度收入
|
||||||
|
* Class MonthSettlement
|
||||||
|
*/
|
||||||
|
class MonthSettlement extends BaseModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 月份
|
||||||
|
* @var int32
|
||||||
|
*/
|
||||||
|
protected $month;
|
||||||
|
/**
|
||||||
|
* 月度收入
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $month_pre_tax_amount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月份
|
||||||
|
* @var int32 $month
|
||||||
|
*/
|
||||||
|
public function setMonth($month)
|
||||||
|
{
|
||||||
|
$this->month = $month;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月份
|
||||||
|
* @return int32
|
||||||
|
*/
|
||||||
|
public function getMonth()
|
||||||
|
{
|
||||||
|
return $this->month;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月度收入
|
||||||
|
* @var string $month_pre_tax_amount
|
||||||
|
*/
|
||||||
|
public function setMonthPreTaxAmount($month_pre_tax_amount)
|
||||||
|
{
|
||||||
|
$this->month_pre_tax_amount = $month_pre_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月度收入
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getMonthPreTaxAmount()
|
||||||
|
{
|
||||||
|
return $this->month_pre_tax_amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
151
extend/Yzh/Model/Calculatelabor/YearTaxInfo.php
Normal file
151
extend/Yzh/Model/Calculatelabor/YearTaxInfo.php
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Calculatelabor;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合所得汇算清缴信息
|
||||||
|
* Class YearTaxInfo
|
||||||
|
*/
|
||||||
|
class YearTaxInfo extends BaseModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 连续劳务年度个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $continuous_month_personal_tax;
|
||||||
|
/**
|
||||||
|
* 综合所得汇算清缴年度个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $personal_tax;
|
||||||
|
/**
|
||||||
|
* 年度扣除费用
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $deduct_cost;
|
||||||
|
/**
|
||||||
|
* 个税税率
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $personal_tax_rate;
|
||||||
|
/**
|
||||||
|
* 速算扣除数
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $deduct_tax;
|
||||||
|
/**
|
||||||
|
* 税负率
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $total_tax_rate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务年度个税
|
||||||
|
* @var string $continuous_month_personal_tax
|
||||||
|
*/
|
||||||
|
public function setContinuousMonthPersonalTax($continuous_month_personal_tax)
|
||||||
|
{
|
||||||
|
$this->continuous_month_personal_tax = $continuous_month_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续劳务年度个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getContinuousMonthPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->continuous_month_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合所得汇算清缴年度个税
|
||||||
|
* @var string $personal_tax
|
||||||
|
*/
|
||||||
|
public function setPersonalTax($personal_tax)
|
||||||
|
{
|
||||||
|
$this->personal_tax = $personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合所得汇算清缴年度个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 年度扣除费用
|
||||||
|
* @var string $deduct_cost
|
||||||
|
*/
|
||||||
|
public function setDeductCost($deduct_cost)
|
||||||
|
{
|
||||||
|
$this->deduct_cost = $deduct_cost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 年度扣除费用
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDeductCost()
|
||||||
|
{
|
||||||
|
return $this->deduct_cost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个税税率
|
||||||
|
* @var string $personal_tax_rate
|
||||||
|
*/
|
||||||
|
public function setPersonalTaxRate($personal_tax_rate)
|
||||||
|
{
|
||||||
|
$this->personal_tax_rate = $personal_tax_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个税税率
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPersonalTaxRate()
|
||||||
|
{
|
||||||
|
return $this->personal_tax_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 速算扣除数
|
||||||
|
* @var string $deduct_tax
|
||||||
|
*/
|
||||||
|
public function setDeductTax($deduct_tax)
|
||||||
|
{
|
||||||
|
$this->deduct_tax = $deduct_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 速算扣除数
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDeductTax()
|
||||||
|
{
|
||||||
|
return $this->deduct_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税负率
|
||||||
|
* @var string $total_tax_rate
|
||||||
|
*/
|
||||||
|
public function setTotalTaxRate($total_tax_rate)
|
||||||
|
{
|
||||||
|
$this->total_tax_rate = $total_tax_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 税负率
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTotalTaxRate()
|
||||||
|
{
|
||||||
|
return $this->total_tax_rate;
|
||||||
|
}
|
||||||
|
}
|
||||||
427
extend/Yzh/Model/Dataservice/OrderTaxDetail.php
Normal file
427
extend/Yzh/Model/Dataservice/OrderTaxDetail.php
Normal file
@@ -0,0 +1,427 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Dataservice;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缴税明细
|
||||||
|
* Class OrderTaxDetail
|
||||||
|
*/
|
||||||
|
class OrderTaxDetail extends BaseModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 预扣个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $personal_tax;
|
||||||
|
/**
|
||||||
|
* 预扣增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $value_added_tax;
|
||||||
|
/**
|
||||||
|
* 预扣附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $additional_tax;
|
||||||
|
/**
|
||||||
|
* 实缴个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_personal_tax;
|
||||||
|
/**
|
||||||
|
* 实缴增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_value_added_tax;
|
||||||
|
/**
|
||||||
|
* 实缴附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_additional_tax;
|
||||||
|
/**
|
||||||
|
* 用户预扣个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_personal_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业预扣个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_personal_tax;
|
||||||
|
/**
|
||||||
|
* 用户预扣增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_value_added_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业预扣增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_value_added_tax;
|
||||||
|
/**
|
||||||
|
* 用户预扣附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_additional_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业预扣附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_additional_tax;
|
||||||
|
/**
|
||||||
|
* 用户实缴个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_received_personal_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业实缴个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_received_personal_tax;
|
||||||
|
/**
|
||||||
|
* 用户实缴增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_received_value_added_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业实缴增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_received_value_added_tax;
|
||||||
|
/**
|
||||||
|
* 用户实缴附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_received_additional_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业实缴附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_received_additional_tax;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税
|
||||||
|
* @var string $personal_tax
|
||||||
|
*/
|
||||||
|
public function setPersonalTax($personal_tax)
|
||||||
|
{
|
||||||
|
$this->personal_tax = $personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣增值税
|
||||||
|
* @var string $value_added_tax
|
||||||
|
*/
|
||||||
|
public function setValueAddedTax($value_added_tax)
|
||||||
|
{
|
||||||
|
$this->value_added_tax = $value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣附加税费
|
||||||
|
* @var string $additional_tax
|
||||||
|
*/
|
||||||
|
public function setAdditionalTax($additional_tax)
|
||||||
|
{
|
||||||
|
$this->additional_tax = $additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴个税
|
||||||
|
* @var string $received_personal_tax
|
||||||
|
*/
|
||||||
|
public function setReceivedPersonalTax($received_personal_tax)
|
||||||
|
{
|
||||||
|
$this->received_personal_tax = $received_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->received_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴增值税
|
||||||
|
* @var string $received_value_added_tax
|
||||||
|
*/
|
||||||
|
public function setReceivedValueAddedTax($received_value_added_tax)
|
||||||
|
{
|
||||||
|
$this->received_value_added_tax = $received_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->received_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴附加税费
|
||||||
|
* @var string $received_additional_tax
|
||||||
|
*/
|
||||||
|
public function setReceivedAdditionalTax($received_additional_tax)
|
||||||
|
{
|
||||||
|
$this->received_additional_tax = $received_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->received_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣个税
|
||||||
|
* @var string $user_personal_tax
|
||||||
|
*/
|
||||||
|
public function setUserPersonalTax($user_personal_tax)
|
||||||
|
{
|
||||||
|
$this->user_personal_tax = $user_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->user_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣个税
|
||||||
|
* @var string $dealer_personal_tax
|
||||||
|
*/
|
||||||
|
public function setDealerPersonalTax($dealer_personal_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_personal_tax = $dealer_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣增值税
|
||||||
|
* @var string $user_value_added_tax
|
||||||
|
*/
|
||||||
|
public function setUserValueAddedTax($user_value_added_tax)
|
||||||
|
{
|
||||||
|
$this->user_value_added_tax = $user_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->user_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣增值税
|
||||||
|
* @var string $dealer_value_added_tax
|
||||||
|
*/
|
||||||
|
public function setDealerValueAddedTax($dealer_value_added_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_value_added_tax = $dealer_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣附加税费
|
||||||
|
* @var string $user_additional_tax
|
||||||
|
*/
|
||||||
|
public function setUserAdditionalTax($user_additional_tax)
|
||||||
|
{
|
||||||
|
$this->user_additional_tax = $user_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->user_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣附加税费
|
||||||
|
* @var string $dealer_additional_tax
|
||||||
|
*/
|
||||||
|
public function setDealerAdditionalTax($dealer_additional_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_additional_tax = $dealer_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实缴个税
|
||||||
|
* @var string $user_received_personal_tax
|
||||||
|
*/
|
||||||
|
public function setUserReceivedPersonalTax($user_received_personal_tax)
|
||||||
|
{
|
||||||
|
$this->user_received_personal_tax = $user_received_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实缴个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserReceivedPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->user_received_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业实缴个税
|
||||||
|
* @var string $dealer_received_personal_tax
|
||||||
|
*/
|
||||||
|
public function setDealerReceivedPersonalTax($dealer_received_personal_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_received_personal_tax = $dealer_received_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业实缴个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerReceivedPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_received_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实缴增值税
|
||||||
|
* @var string $user_received_value_added_tax
|
||||||
|
*/
|
||||||
|
public function setUserReceivedValueAddedTax($user_received_value_added_tax)
|
||||||
|
{
|
||||||
|
$this->user_received_value_added_tax = $user_received_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实缴增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserReceivedValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->user_received_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业实缴增值税
|
||||||
|
* @var string $dealer_received_value_added_tax
|
||||||
|
*/
|
||||||
|
public function setDealerReceivedValueAddedTax($dealer_received_value_added_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_received_value_added_tax = $dealer_received_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业实缴增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerReceivedValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_received_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实缴附加税费
|
||||||
|
* @var string $user_received_additional_tax
|
||||||
|
*/
|
||||||
|
public function setUserReceivedAdditionalTax($user_received_additional_tax)
|
||||||
|
{
|
||||||
|
$this->user_received_additional_tax = $user_received_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实缴附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserReceivedAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->user_received_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业实缴附加税费
|
||||||
|
* @var string $dealer_received_additional_tax
|
||||||
|
*/
|
||||||
|
public function setDealerReceivedAdditionalTax($dealer_received_additional_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_received_additional_tax = $dealer_received_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业实缴附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerReceivedAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_received_additional_tax;
|
||||||
|
}
|
||||||
|
}
|
||||||
37
extend/Yzh/Model/Payment/GetOrderLxlwRequest.php
Normal file
37
extend/Yzh/Model/Payment/GetOrderLxlwRequest.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Payment;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询劳务模式单笔订单信息请求
|
||||||
|
* Class GetOrderLxlwRequest
|
||||||
|
*/
|
||||||
|
class GetOrderLxlwRequest extends BaseRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 平台企业订单号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $order_id;
|
||||||
|
/**
|
||||||
|
* 支付路径
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $channel;
|
||||||
|
/**
|
||||||
|
* 数据类型
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $data_type;
|
||||||
|
|
||||||
|
public function __construct($params = array())
|
||||||
|
{
|
||||||
|
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||||
|
if (isset($params[$property])) {
|
||||||
|
$this->{$property} = $params[$property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
extend/Yzh/Model/Payment/GetOrderLxlwResponse.php
Normal file
33
extend/Yzh/Model/Payment/GetOrderLxlwResponse.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Payment;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseResponse;
|
||||||
|
use Yzh\Model\ResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询劳务模式单笔订单信息返回
|
||||||
|
* Class GetOrderLxlwResponse
|
||||||
|
*/
|
||||||
|
class GetOrderLxlwResponse extends BaseResponse implements ResponseInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取数据对象
|
||||||
|
* @return GetOrderLxlwResponseData
|
||||||
|
*/
|
||||||
|
public function getData()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置数据对象
|
||||||
|
* @param array $data
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setData($data)
|
||||||
|
{
|
||||||
|
$this->data = new GetOrderLxlwResponseData($data);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
1003
extend/Yzh/Model/Payment/GetOrderLxlwResponseData.php
Normal file
1003
extend/Yzh/Model/Payment/GetOrderLxlwResponseData.php
Normal file
File diff suppressed because it is too large
Load Diff
749
extend/Yzh/Model/Payment/NotifyOrderLxlwData copy.php
Normal file
749
extend/Yzh/Model/Payment/NotifyOrderLxlwData copy.php
Normal file
@@ -0,0 +1,749 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Payment;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 劳务模式订单支付状态回调通知数据
|
||||||
|
* Class NotifyOrderLxlwData
|
||||||
|
*/
|
||||||
|
class NotifyOrderLxlwData extends BaseModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 平台企业订单号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $order_id;
|
||||||
|
/**
|
||||||
|
* 订单金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $pay;
|
||||||
|
/**
|
||||||
|
* 综合服务主体 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_id;
|
||||||
|
/**
|
||||||
|
* 平台企业 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_id;
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $real_name;
|
||||||
|
/**
|
||||||
|
* 收款人账号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $card_no;
|
||||||
|
/**
|
||||||
|
* 身份证号码
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $id_card;
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $phone_no;
|
||||||
|
/**
|
||||||
|
* 订单状态码
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $status;
|
||||||
|
/**
|
||||||
|
* 订单详情状态码
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $status_detail;
|
||||||
|
/**
|
||||||
|
* 订单状态码描述
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $status_message;
|
||||||
|
/**
|
||||||
|
* 订单详情状态码描述
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $status_detail_message;
|
||||||
|
/**
|
||||||
|
* 订单状态补充信息
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $supplemental_detail_message;
|
||||||
|
/**
|
||||||
|
* 综合服务主体支付金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_amount;
|
||||||
|
/**
|
||||||
|
* 综合服务平台流水号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $ref;
|
||||||
|
/**
|
||||||
|
* 支付交易流水号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_bank_bill;
|
||||||
|
/**
|
||||||
|
* 支付路径
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $withdraw_platform;
|
||||||
|
/**
|
||||||
|
* 订单接收时间,精确到秒
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $created_at;
|
||||||
|
/**
|
||||||
|
* 订单完成时间,精确到秒
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $finished_time;
|
||||||
|
/**
|
||||||
|
* 应收综合服务主体加成服务费金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_fee;
|
||||||
|
/**
|
||||||
|
* 应收余额账户支出加成服务费金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_real_fee;
|
||||||
|
/**
|
||||||
|
* 应收加成服务费抵扣金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_deduct_fee;
|
||||||
|
/**
|
||||||
|
* 应收用户加成服务费金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_fee;
|
||||||
|
/**
|
||||||
|
* 实收综合服务主体加成服务费金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_broker_fee;
|
||||||
|
/**
|
||||||
|
* 实收余额账户支出加成服务费金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_broker_real_fee;
|
||||||
|
/**
|
||||||
|
* 实收加成服务费抵扣金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_broker_deduct_fee;
|
||||||
|
/**
|
||||||
|
* 实收用户加成服务费金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_user_fee;
|
||||||
|
/**
|
||||||
|
* 订单备注
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $pay_remark;
|
||||||
|
/**
|
||||||
|
* 银行名称
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $bank_name;
|
||||||
|
/**
|
||||||
|
* 业务线标识
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $project_id;
|
||||||
|
/**
|
||||||
|
* 用户实收金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_real_amount;
|
||||||
|
/**
|
||||||
|
* 缴税明细
|
||||||
|
* @var TaxDetail
|
||||||
|
*/
|
||||||
|
protected $tax_detail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业订单号
|
||||||
|
* @var string $order_id
|
||||||
|
*/
|
||||||
|
public function setOrderId($order_id)
|
||||||
|
{
|
||||||
|
$this->order_id = $order_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业订单号
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getOrderId()
|
||||||
|
{
|
||||||
|
return $this->order_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单金额
|
||||||
|
* @var string $pay
|
||||||
|
*/
|
||||||
|
public function setPay($pay)
|
||||||
|
{
|
||||||
|
$this->pay = $pay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPay()
|
||||||
|
{
|
||||||
|
return $this->pay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合服务主体 ID
|
||||||
|
* @var string $broker_id
|
||||||
|
*/
|
||||||
|
public function setBrokerId($broker_id)
|
||||||
|
{
|
||||||
|
$this->broker_id = $broker_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合服务主体 ID
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerId()
|
||||||
|
{
|
||||||
|
return $this->broker_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业 ID
|
||||||
|
* @var string $dealer_id
|
||||||
|
*/
|
||||||
|
public function setDealerId($dealer_id)
|
||||||
|
{
|
||||||
|
$this->dealer_id = $dealer_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业 ID
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerId()
|
||||||
|
{
|
||||||
|
return $this->dealer_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
* @var string $real_name
|
||||||
|
*/
|
||||||
|
public function setRealName($real_name)
|
||||||
|
{
|
||||||
|
$this->real_name = $real_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRealName()
|
||||||
|
{
|
||||||
|
return $this->real_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收款人账号
|
||||||
|
* @var string $card_no
|
||||||
|
*/
|
||||||
|
public function setCardNo($card_no)
|
||||||
|
{
|
||||||
|
$this->card_no = $card_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收款人账号
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCardNo()
|
||||||
|
{
|
||||||
|
return $this->card_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证号码
|
||||||
|
* @var string $id_card
|
||||||
|
*/
|
||||||
|
public function setIdCard($id_card)
|
||||||
|
{
|
||||||
|
$this->id_card = $id_card;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证号码
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getIdCard()
|
||||||
|
{
|
||||||
|
return $this->id_card;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
* @var string $phone_no
|
||||||
|
*/
|
||||||
|
public function setPhoneNo($phone_no)
|
||||||
|
{
|
||||||
|
$this->phone_no = $phone_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPhoneNo()
|
||||||
|
{
|
||||||
|
return $this->phone_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单状态码
|
||||||
|
* @var string $status
|
||||||
|
*/
|
||||||
|
public function setStatus($status)
|
||||||
|
{
|
||||||
|
$this->status = $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单状态码
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatus()
|
||||||
|
{
|
||||||
|
return $this->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单详情状态码
|
||||||
|
* @var string $status_detail
|
||||||
|
*/
|
||||||
|
public function setStatusDetail($status_detail)
|
||||||
|
{
|
||||||
|
$this->status_detail = $status_detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单详情状态码
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatusDetail()
|
||||||
|
{
|
||||||
|
return $this->status_detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单状态码描述
|
||||||
|
* @var string $status_message
|
||||||
|
*/
|
||||||
|
public function setStatusMessage($status_message)
|
||||||
|
{
|
||||||
|
$this->status_message = $status_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单状态码描述
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatusMessage()
|
||||||
|
{
|
||||||
|
return $this->status_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单详情状态码描述
|
||||||
|
* @var string $status_detail_message
|
||||||
|
*/
|
||||||
|
public function setStatusDetailMessage($status_detail_message)
|
||||||
|
{
|
||||||
|
$this->status_detail_message = $status_detail_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单详情状态码描述
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatusDetailMessage()
|
||||||
|
{
|
||||||
|
return $this->status_detail_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单状态补充信息
|
||||||
|
* @var string $supplemental_detail_message
|
||||||
|
*/
|
||||||
|
public function setSupplementalDetailMessage($supplemental_detail_message)
|
||||||
|
{
|
||||||
|
$this->supplemental_detail_message = $supplemental_detail_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单状态补充信息
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSupplementalDetailMessage()
|
||||||
|
{
|
||||||
|
return $this->supplemental_detail_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合服务主体支付金额
|
||||||
|
* @var string $broker_amount
|
||||||
|
*/
|
||||||
|
public function setBrokerAmount($broker_amount)
|
||||||
|
{
|
||||||
|
$this->broker_amount = $broker_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合服务主体支付金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerAmount()
|
||||||
|
{
|
||||||
|
return $this->broker_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合服务平台流水号
|
||||||
|
* @var string $ref
|
||||||
|
*/
|
||||||
|
public function setRef($ref)
|
||||||
|
{
|
||||||
|
$this->ref = $ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合服务平台流水号
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRef()
|
||||||
|
{
|
||||||
|
return $this->ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付交易流水号
|
||||||
|
* @var string $broker_bank_bill
|
||||||
|
*/
|
||||||
|
public function setBrokerBankBill($broker_bank_bill)
|
||||||
|
{
|
||||||
|
$this->broker_bank_bill = $broker_bank_bill;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付交易流水号
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerBankBill()
|
||||||
|
{
|
||||||
|
return $this->broker_bank_bill;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付路径
|
||||||
|
* @var string $withdraw_platform
|
||||||
|
*/
|
||||||
|
public function setWithdrawPlatform($withdraw_platform)
|
||||||
|
{
|
||||||
|
$this->withdraw_platform = $withdraw_platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付路径
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getWithdrawPlatform()
|
||||||
|
{
|
||||||
|
return $this->withdraw_platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单接收时间,精确到秒
|
||||||
|
* @var string $created_at
|
||||||
|
*/
|
||||||
|
public function setCreatedAt($created_at)
|
||||||
|
{
|
||||||
|
$this->created_at = $created_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单接收时间,精确到秒
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCreatedAt()
|
||||||
|
{
|
||||||
|
return $this->created_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单完成时间,精确到秒
|
||||||
|
* @var string $finished_time
|
||||||
|
*/
|
||||||
|
public function setFinishedTime($finished_time)
|
||||||
|
{
|
||||||
|
$this->finished_time = $finished_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单完成时间,精确到秒
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFinishedTime()
|
||||||
|
{
|
||||||
|
return $this->finished_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收综合服务主体加成服务费金额
|
||||||
|
* @var string $broker_fee
|
||||||
|
*/
|
||||||
|
public function setBrokerFee($broker_fee)
|
||||||
|
{
|
||||||
|
$this->broker_fee = $broker_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收综合服务主体加成服务费金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerFee()
|
||||||
|
{
|
||||||
|
return $this->broker_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收余额账户支出加成服务费金额
|
||||||
|
* @var string $broker_real_fee
|
||||||
|
*/
|
||||||
|
public function setBrokerRealFee($broker_real_fee)
|
||||||
|
{
|
||||||
|
$this->broker_real_fee = $broker_real_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收余额账户支出加成服务费金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerRealFee()
|
||||||
|
{
|
||||||
|
return $this->broker_real_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收加成服务费抵扣金额
|
||||||
|
* @var string $broker_deduct_fee
|
||||||
|
*/
|
||||||
|
public function setBrokerDeductFee($broker_deduct_fee)
|
||||||
|
{
|
||||||
|
$this->broker_deduct_fee = $broker_deduct_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收加成服务费抵扣金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerDeductFee()
|
||||||
|
{
|
||||||
|
return $this->broker_deduct_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收用户加成服务费金额
|
||||||
|
* @var string $user_fee
|
||||||
|
*/
|
||||||
|
public function setUserFee($user_fee)
|
||||||
|
{
|
||||||
|
$this->user_fee = $user_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收用户加成服务费金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserFee()
|
||||||
|
{
|
||||||
|
return $this->user_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收综合服务主体加成服务费金额
|
||||||
|
* @var string $received_broker_fee
|
||||||
|
*/
|
||||||
|
public function setReceivedBrokerFee($received_broker_fee)
|
||||||
|
{
|
||||||
|
$this->received_broker_fee = $received_broker_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收综合服务主体加成服务费金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedBrokerFee()
|
||||||
|
{
|
||||||
|
return $this->received_broker_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收余额账户支出加成服务费金额
|
||||||
|
* @var string $received_broker_real_fee
|
||||||
|
*/
|
||||||
|
public function setReceivedBrokerRealFee($received_broker_real_fee)
|
||||||
|
{
|
||||||
|
$this->received_broker_real_fee = $received_broker_real_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收余额账户支出加成服务费金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedBrokerRealFee()
|
||||||
|
{
|
||||||
|
return $this->received_broker_real_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收加成服务费抵扣金额
|
||||||
|
* @var string $received_broker_deduct_fee
|
||||||
|
*/
|
||||||
|
public function setReceivedBrokerDeductFee($received_broker_deduct_fee)
|
||||||
|
{
|
||||||
|
$this->received_broker_deduct_fee = $received_broker_deduct_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收加成服务费抵扣金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedBrokerDeductFee()
|
||||||
|
{
|
||||||
|
return $this->received_broker_deduct_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收用户加成服务费金额
|
||||||
|
* @var string $received_user_fee
|
||||||
|
*/
|
||||||
|
public function setReceivedUserFee($received_user_fee)
|
||||||
|
{
|
||||||
|
$this->received_user_fee = $received_user_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收用户加成服务费金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedUserFee()
|
||||||
|
{
|
||||||
|
return $this->received_user_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单备注
|
||||||
|
* @var string $pay_remark
|
||||||
|
*/
|
||||||
|
public function setPayRemark($pay_remark)
|
||||||
|
{
|
||||||
|
$this->pay_remark = $pay_remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单备注
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPayRemark()
|
||||||
|
{
|
||||||
|
return $this->pay_remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行名称
|
||||||
|
* @var string $bank_name
|
||||||
|
*/
|
||||||
|
public function setBankName($bank_name)
|
||||||
|
{
|
||||||
|
$this->bank_name = $bank_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行名称
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBankName()
|
||||||
|
{
|
||||||
|
return $this->bank_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务线标识
|
||||||
|
* @var string $project_id
|
||||||
|
*/
|
||||||
|
public function setProjectId($project_id)
|
||||||
|
{
|
||||||
|
$this->project_id = $project_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务线标识
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getProjectId()
|
||||||
|
{
|
||||||
|
return $this->project_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实收金额
|
||||||
|
* @var string $user_real_amount
|
||||||
|
*/
|
||||||
|
public function setUserRealAmount($user_real_amount)
|
||||||
|
{
|
||||||
|
$this->user_real_amount = $user_real_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实收金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserRealAmount()
|
||||||
|
{
|
||||||
|
return $this->user_real_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缴税明细
|
||||||
|
* @var TaxDetail $tax_detail
|
||||||
|
*/
|
||||||
|
public function setTaxDetail($tax_detail)
|
||||||
|
{
|
||||||
|
$this->tax_detail = $tax_detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缴税明细
|
||||||
|
* @return TaxDetail
|
||||||
|
*/
|
||||||
|
public function getTaxDetail()
|
||||||
|
{
|
||||||
|
return $this->tax_detail;
|
||||||
|
}
|
||||||
|
}
|
||||||
910
extend/Yzh/Model/Payment/NotifyOrderLxlwData.php
Normal file
910
extend/Yzh/Model/Payment/NotifyOrderLxlwData.php
Normal file
@@ -0,0 +1,910 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Payment;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 劳务模式订单支付状态回调通知数据
|
||||||
|
* Class NotifyOrderLxlwData
|
||||||
|
*/
|
||||||
|
class NotifyOrderLxlwData extends BaseModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 平台企业订单号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $order_id;
|
||||||
|
/**
|
||||||
|
* 订单金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $pay;
|
||||||
|
/**
|
||||||
|
* 综合服务主体 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_id;
|
||||||
|
/**
|
||||||
|
* 平台企业 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_id;
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $real_name;
|
||||||
|
/**
|
||||||
|
* 收款人账号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $card_no;
|
||||||
|
/**
|
||||||
|
* 身份证号码
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $id_card;
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $phone_no;
|
||||||
|
/**
|
||||||
|
* 订单状态码
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $status;
|
||||||
|
/**
|
||||||
|
* 订单详情状态码
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $status_detail;
|
||||||
|
/**
|
||||||
|
* 订单状态码描述
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $status_message;
|
||||||
|
/**
|
||||||
|
* 订单详情状态码描述
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $status_detail_message;
|
||||||
|
/**
|
||||||
|
* 订单状态补充信息
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $supplemental_detail_message;
|
||||||
|
/**
|
||||||
|
* 综合服务主体支付金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_amount;
|
||||||
|
/**
|
||||||
|
* 综合服务平台流水号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $ref;
|
||||||
|
/**
|
||||||
|
* 支付交易流水号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_bank_bill;
|
||||||
|
/**
|
||||||
|
* 支付路径
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $withdraw_platform;
|
||||||
|
/**
|
||||||
|
* 订单接收时间,精确到秒
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $created_at;
|
||||||
|
/**
|
||||||
|
* 订单完成时间,精确到秒
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $finished_time;
|
||||||
|
/**
|
||||||
|
* 应收综合服务主体加成服务费金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_fee;
|
||||||
|
/**
|
||||||
|
* 应收余额账户支出加成服务费金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_real_fee;
|
||||||
|
/**
|
||||||
|
* 应收加成服务费抵扣金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $broker_deduct_fee;
|
||||||
|
/**
|
||||||
|
* 应收用户加成服务费金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_fee;
|
||||||
|
/**
|
||||||
|
* 实收综合服务主体加成服务费金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_broker_fee;
|
||||||
|
/**
|
||||||
|
* 实收余额账户支出加成服务费金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_broker_real_fee;
|
||||||
|
/**
|
||||||
|
* 实收加成服务费抵扣金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_broker_deduct_fee;
|
||||||
|
/**
|
||||||
|
* 实收用户加成服务费金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_user_fee;
|
||||||
|
/**
|
||||||
|
* 订单备注
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $pay_remark;
|
||||||
|
/**
|
||||||
|
* 银行名称
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $bank_name;
|
||||||
|
/**
|
||||||
|
* 业务线标识
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $project_id;
|
||||||
|
/**
|
||||||
|
* 用户实收金额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_real_amount;
|
||||||
|
/**
|
||||||
|
* 缴税明细
|
||||||
|
* @var TaxDetail
|
||||||
|
*/
|
||||||
|
protected $tax_detail;
|
||||||
|
/**
|
||||||
|
* 互联网平台名称
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_platform_name;
|
||||||
|
/**
|
||||||
|
* 用户名称/昵称
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_user_nickname;
|
||||||
|
/**
|
||||||
|
* 用户唯一标识码
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_user_id;
|
||||||
|
/**
|
||||||
|
* 预扣税费总额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $tax;
|
||||||
|
/**
|
||||||
|
* 实缴税费总额
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_tax_amount;
|
||||||
|
/**
|
||||||
|
* 用户实收金额(追缴前)
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_real_excluding_vat_amount;
|
||||||
|
/**
|
||||||
|
* 已追缴增附税(本笔订单)
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_recover_tax_amount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业订单号
|
||||||
|
* @var string $order_id
|
||||||
|
*/
|
||||||
|
public function setOrderId($order_id)
|
||||||
|
{
|
||||||
|
$this->order_id = $order_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业订单号
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getOrderId()
|
||||||
|
{
|
||||||
|
return $this->order_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单金额
|
||||||
|
* @var string $pay
|
||||||
|
*/
|
||||||
|
public function setPay($pay)
|
||||||
|
{
|
||||||
|
$this->pay = $pay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPay()
|
||||||
|
{
|
||||||
|
return $this->pay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合服务主体 ID
|
||||||
|
* @var string $broker_id
|
||||||
|
*/
|
||||||
|
public function setBrokerId($broker_id)
|
||||||
|
{
|
||||||
|
$this->broker_id = $broker_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合服务主体 ID
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerId()
|
||||||
|
{
|
||||||
|
return $this->broker_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业 ID
|
||||||
|
* @var string $dealer_id
|
||||||
|
*/
|
||||||
|
public function setDealerId($dealer_id)
|
||||||
|
{
|
||||||
|
$this->dealer_id = $dealer_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业 ID
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerId()
|
||||||
|
{
|
||||||
|
return $this->dealer_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
* @var string $real_name
|
||||||
|
*/
|
||||||
|
public function setRealName($real_name)
|
||||||
|
{
|
||||||
|
$this->real_name = $real_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRealName()
|
||||||
|
{
|
||||||
|
return $this->real_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收款人账号
|
||||||
|
* @var string $card_no
|
||||||
|
*/
|
||||||
|
public function setCardNo($card_no)
|
||||||
|
{
|
||||||
|
$this->card_no = $card_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收款人账号
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCardNo()
|
||||||
|
{
|
||||||
|
return $this->card_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证号码
|
||||||
|
* @var string $id_card
|
||||||
|
*/
|
||||||
|
public function setIdCard($id_card)
|
||||||
|
{
|
||||||
|
$this->id_card = $id_card;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证号码
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getIdCard()
|
||||||
|
{
|
||||||
|
return $this->id_card;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
* @var string $phone_no
|
||||||
|
*/
|
||||||
|
public function setPhoneNo($phone_no)
|
||||||
|
{
|
||||||
|
$this->phone_no = $phone_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPhoneNo()
|
||||||
|
{
|
||||||
|
return $this->phone_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单状态码
|
||||||
|
* @var string $status
|
||||||
|
*/
|
||||||
|
public function setStatus($status)
|
||||||
|
{
|
||||||
|
$this->status = $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单状态码
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatus()
|
||||||
|
{
|
||||||
|
return $this->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单详情状态码
|
||||||
|
* @var string $status_detail
|
||||||
|
*/
|
||||||
|
public function setStatusDetail($status_detail)
|
||||||
|
{
|
||||||
|
$this->status_detail = $status_detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单详情状态码
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatusDetail()
|
||||||
|
{
|
||||||
|
return $this->status_detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单状态码描述
|
||||||
|
* @var string $status_message
|
||||||
|
*/
|
||||||
|
public function setStatusMessage($status_message)
|
||||||
|
{
|
||||||
|
$this->status_message = $status_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单状态码描述
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatusMessage()
|
||||||
|
{
|
||||||
|
return $this->status_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单详情状态码描述
|
||||||
|
* @var string $status_detail_message
|
||||||
|
*/
|
||||||
|
public function setStatusDetailMessage($status_detail_message)
|
||||||
|
{
|
||||||
|
$this->status_detail_message = $status_detail_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单详情状态码描述
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatusDetailMessage()
|
||||||
|
{
|
||||||
|
return $this->status_detail_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单状态补充信息
|
||||||
|
* @var string $supplemental_detail_message
|
||||||
|
*/
|
||||||
|
public function setSupplementalDetailMessage($supplemental_detail_message)
|
||||||
|
{
|
||||||
|
$this->supplemental_detail_message = $supplemental_detail_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单状态补充信息
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSupplementalDetailMessage()
|
||||||
|
{
|
||||||
|
return $this->supplemental_detail_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合服务主体支付金额
|
||||||
|
* @var string $broker_amount
|
||||||
|
*/
|
||||||
|
public function setBrokerAmount($broker_amount)
|
||||||
|
{
|
||||||
|
$this->broker_amount = $broker_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合服务主体支付金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerAmount()
|
||||||
|
{
|
||||||
|
return $this->broker_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合服务平台流水号
|
||||||
|
* @var string $ref
|
||||||
|
*/
|
||||||
|
public function setRef($ref)
|
||||||
|
{
|
||||||
|
$this->ref = $ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合服务平台流水号
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRef()
|
||||||
|
{
|
||||||
|
return $this->ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付交易流水号
|
||||||
|
* @var string $broker_bank_bill
|
||||||
|
*/
|
||||||
|
public function setBrokerBankBill($broker_bank_bill)
|
||||||
|
{
|
||||||
|
$this->broker_bank_bill = $broker_bank_bill;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付交易流水号
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerBankBill()
|
||||||
|
{
|
||||||
|
return $this->broker_bank_bill;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付路径
|
||||||
|
* @var string $withdraw_platform
|
||||||
|
*/
|
||||||
|
public function setWithdrawPlatform($withdraw_platform)
|
||||||
|
{
|
||||||
|
$this->withdraw_platform = $withdraw_platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付路径
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getWithdrawPlatform()
|
||||||
|
{
|
||||||
|
return $this->withdraw_platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单接收时间,精确到秒
|
||||||
|
* @var string $created_at
|
||||||
|
*/
|
||||||
|
public function setCreatedAt($created_at)
|
||||||
|
{
|
||||||
|
$this->created_at = $created_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单接收时间,精确到秒
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCreatedAt()
|
||||||
|
{
|
||||||
|
return $this->created_at;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单完成时间,精确到秒
|
||||||
|
* @var string $finished_time
|
||||||
|
*/
|
||||||
|
public function setFinishedTime($finished_time)
|
||||||
|
{
|
||||||
|
$this->finished_time = $finished_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单完成时间,精确到秒
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFinishedTime()
|
||||||
|
{
|
||||||
|
return $this->finished_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收综合服务主体加成服务费金额
|
||||||
|
* @var string $broker_fee
|
||||||
|
*/
|
||||||
|
public function setBrokerFee($broker_fee)
|
||||||
|
{
|
||||||
|
$this->broker_fee = $broker_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收综合服务主体加成服务费金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerFee()
|
||||||
|
{
|
||||||
|
return $this->broker_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收余额账户支出加成服务费金额
|
||||||
|
* @var string $broker_real_fee
|
||||||
|
*/
|
||||||
|
public function setBrokerRealFee($broker_real_fee)
|
||||||
|
{
|
||||||
|
$this->broker_real_fee = $broker_real_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收余额账户支出加成服务费金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerRealFee()
|
||||||
|
{
|
||||||
|
return $this->broker_real_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收加成服务费抵扣金额
|
||||||
|
* @var string $broker_deduct_fee
|
||||||
|
*/
|
||||||
|
public function setBrokerDeductFee($broker_deduct_fee)
|
||||||
|
{
|
||||||
|
$this->broker_deduct_fee = $broker_deduct_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收加成服务费抵扣金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBrokerDeductFee()
|
||||||
|
{
|
||||||
|
return $this->broker_deduct_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收用户加成服务费金额
|
||||||
|
* @var string $user_fee
|
||||||
|
*/
|
||||||
|
public function setUserFee($user_fee)
|
||||||
|
{
|
||||||
|
$this->user_fee = $user_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应收用户加成服务费金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserFee()
|
||||||
|
{
|
||||||
|
return $this->user_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收综合服务主体加成服务费金额
|
||||||
|
* @var string $received_broker_fee
|
||||||
|
*/
|
||||||
|
public function setReceivedBrokerFee($received_broker_fee)
|
||||||
|
{
|
||||||
|
$this->received_broker_fee = $received_broker_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收综合服务主体加成服务费金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedBrokerFee()
|
||||||
|
{
|
||||||
|
return $this->received_broker_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收余额账户支出加成服务费金额
|
||||||
|
* @var string $received_broker_real_fee
|
||||||
|
*/
|
||||||
|
public function setReceivedBrokerRealFee($received_broker_real_fee)
|
||||||
|
{
|
||||||
|
$this->received_broker_real_fee = $received_broker_real_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收余额账户支出加成服务费金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedBrokerRealFee()
|
||||||
|
{
|
||||||
|
return $this->received_broker_real_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收加成服务费抵扣金额
|
||||||
|
* @var string $received_broker_deduct_fee
|
||||||
|
*/
|
||||||
|
public function setReceivedBrokerDeductFee($received_broker_deduct_fee)
|
||||||
|
{
|
||||||
|
$this->received_broker_deduct_fee = $received_broker_deduct_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收加成服务费抵扣金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedBrokerDeductFee()
|
||||||
|
{
|
||||||
|
return $this->received_broker_deduct_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收用户加成服务费金额
|
||||||
|
* @var string $received_user_fee
|
||||||
|
*/
|
||||||
|
public function setReceivedUserFee($received_user_fee)
|
||||||
|
{
|
||||||
|
$this->received_user_fee = $received_user_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实收用户加成服务费金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedUserFee()
|
||||||
|
{
|
||||||
|
return $this->received_user_fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单备注
|
||||||
|
* @var string $pay_remark
|
||||||
|
*/
|
||||||
|
public function setPayRemark($pay_remark)
|
||||||
|
{
|
||||||
|
$this->pay_remark = $pay_remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单备注
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPayRemark()
|
||||||
|
{
|
||||||
|
return $this->pay_remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行名称
|
||||||
|
* @var string $bank_name
|
||||||
|
*/
|
||||||
|
public function setBankName($bank_name)
|
||||||
|
{
|
||||||
|
$this->bank_name = $bank_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行名称
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBankName()
|
||||||
|
{
|
||||||
|
return $this->bank_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务线标识
|
||||||
|
* @var string $project_id
|
||||||
|
*/
|
||||||
|
public function setProjectId($project_id)
|
||||||
|
{
|
||||||
|
$this->project_id = $project_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务线标识
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getProjectId()
|
||||||
|
{
|
||||||
|
return $this->project_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实收金额
|
||||||
|
* @var string $user_real_amount
|
||||||
|
*/
|
||||||
|
public function setUserRealAmount($user_real_amount)
|
||||||
|
{
|
||||||
|
$this->user_real_amount = $user_real_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实收金额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserRealAmount()
|
||||||
|
{
|
||||||
|
return $this->user_real_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缴税明细
|
||||||
|
* @var TaxDetail $tax_detail
|
||||||
|
*/
|
||||||
|
public function setTaxDetail($tax_detail)
|
||||||
|
{
|
||||||
|
$this->tax_detail = $tax_detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缴税明细
|
||||||
|
* @return TaxDetail
|
||||||
|
*/
|
||||||
|
public function getTaxDetail()
|
||||||
|
{
|
||||||
|
return $this->tax_detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 互联网平台名称
|
||||||
|
* @var string $dealer_platform_name
|
||||||
|
*/
|
||||||
|
public function setDealerPlatformName($dealer_platform_name)
|
||||||
|
{
|
||||||
|
$this->dealer_platform_name = $dealer_platform_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 互联网平台名称
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerPlatformName()
|
||||||
|
{
|
||||||
|
return $this->dealer_platform_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名称/昵称
|
||||||
|
* @var string $dealer_user_nickname
|
||||||
|
*/
|
||||||
|
public function setDealerUserNickname($dealer_user_nickname)
|
||||||
|
{
|
||||||
|
$this->dealer_user_nickname = $dealer_user_nickname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名称/昵称
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerUserNickname()
|
||||||
|
{
|
||||||
|
return $this->dealer_user_nickname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户唯一标识码
|
||||||
|
* @var string $dealer_user_id
|
||||||
|
*/
|
||||||
|
public function setDealerUserId($dealer_user_id)
|
||||||
|
{
|
||||||
|
$this->dealer_user_id = $dealer_user_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户唯一标识码
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerUserId()
|
||||||
|
{
|
||||||
|
return $this->dealer_user_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣税费总额
|
||||||
|
* @var string $tax
|
||||||
|
*/
|
||||||
|
public function setTax($tax)
|
||||||
|
{
|
||||||
|
$this->tax = $tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣税费总额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTax()
|
||||||
|
{
|
||||||
|
return $this->tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴税费总额
|
||||||
|
* @var string $received_tax_amount
|
||||||
|
*/
|
||||||
|
public function setReceivedTaxAmount($received_tax_amount)
|
||||||
|
{
|
||||||
|
$this->received_tax_amount = $received_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴税费总额
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedTaxAmount()
|
||||||
|
{
|
||||||
|
return $this->received_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实收金额(追缴前)
|
||||||
|
* @var string $user_real_excluding_vat_amount
|
||||||
|
*/
|
||||||
|
public function setUserRealExcludingVatAmount($user_real_excluding_vat_amount)
|
||||||
|
{
|
||||||
|
$this->user_real_excluding_vat_amount = $user_real_excluding_vat_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实收金额(追缴前)
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserRealExcludingVatAmount()
|
||||||
|
{
|
||||||
|
return $this->user_real_excluding_vat_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已追缴增附税(本笔订单)
|
||||||
|
* @var string $user_recover_tax_amount
|
||||||
|
*/
|
||||||
|
public function setUserRecoverTaxAmount($user_recover_tax_amount)
|
||||||
|
{
|
||||||
|
$this->user_recover_tax_amount = $user_recover_tax_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已追缴增附税(本笔订单)
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserRecoverTaxAmount()
|
||||||
|
{
|
||||||
|
return $this->user_recover_tax_amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
37
extend/Yzh/Model/Payment/NotifyOrderLxlwRequest copy.php
Normal file
37
extend/Yzh/Model/Payment/NotifyOrderLxlwRequest copy.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Payment;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 劳务模式订单支付状态回调通知
|
||||||
|
* Class NotifyOrderLxlwRequest
|
||||||
|
*/
|
||||||
|
class NotifyOrderLxlwRequest extends BaseRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 通知 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $notify_id;
|
||||||
|
/**
|
||||||
|
* 通知时间
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $notify_time;
|
||||||
|
/**
|
||||||
|
* 返回数据
|
||||||
|
* @var NotifyOrderLxlwData
|
||||||
|
*/
|
||||||
|
public $data;
|
||||||
|
|
||||||
|
public function __construct($params = array())
|
||||||
|
{
|
||||||
|
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||||
|
if (isset($params[$property])) {
|
||||||
|
$this->{$property} = $params[$property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
37
extend/Yzh/Model/Payment/NotifyOrderLxlwRequest.php
Normal file
37
extend/Yzh/Model/Payment/NotifyOrderLxlwRequest.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Payment;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 劳务模式订单支付状态回调通知
|
||||||
|
* Class NotifyOrderLxlwRequest
|
||||||
|
*/
|
||||||
|
class NotifyOrderLxlwRequest extends BaseRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 通知 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $notify_id;
|
||||||
|
/**
|
||||||
|
* 通知时间
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $notify_time;
|
||||||
|
/**
|
||||||
|
* 返回数据
|
||||||
|
* @var NotifyOrderLxlwData
|
||||||
|
*/
|
||||||
|
public $data;
|
||||||
|
|
||||||
|
public function __construct($params = array())
|
||||||
|
{
|
||||||
|
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||||
|
if (isset($params[$property])) {
|
||||||
|
$this->{$property} = $params[$property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
473
extend/Yzh/Model/Payment/TaxDetail.php
Normal file
473
extend/Yzh/Model/Payment/TaxDetail.php
Normal file
@@ -0,0 +1,473 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Payment;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缴税明细
|
||||||
|
* Class TaxDetail
|
||||||
|
*/
|
||||||
|
class TaxDetail extends BaseModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 预扣个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $personal_tax;
|
||||||
|
/**
|
||||||
|
* 预扣增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $value_added_tax;
|
||||||
|
/**
|
||||||
|
* 预扣附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $additional_tax;
|
||||||
|
/**
|
||||||
|
* 实缴个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_personal_tax;
|
||||||
|
/**
|
||||||
|
* 实缴增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_value_added_tax;
|
||||||
|
/**
|
||||||
|
* 实缴附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $received_additional_tax;
|
||||||
|
/**
|
||||||
|
* 用户预扣个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_personal_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业预扣个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_personal_tax;
|
||||||
|
/**
|
||||||
|
* 用户预扣增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_value_added_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业预扣增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_value_added_tax;
|
||||||
|
/**
|
||||||
|
* 用户预扣附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_additional_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业预扣附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_additional_tax;
|
||||||
|
/**
|
||||||
|
* 用户实缴个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_received_personal_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业实缴个税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_received_personal_tax;
|
||||||
|
/**
|
||||||
|
* 用户实缴增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_received_value_added_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业实缴增值税
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_received_value_added_tax;
|
||||||
|
/**
|
||||||
|
* 用户实缴附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $user_received_additional_tax;
|
||||||
|
/**
|
||||||
|
* 平台企业实缴附加税费
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $dealer_received_additional_tax;
|
||||||
|
/**
|
||||||
|
* 预扣个税税率
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $personal_tax_rate;
|
||||||
|
/**
|
||||||
|
* 预扣个税速算扣除数
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $deduct_tax;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税
|
||||||
|
* @var string $personal_tax
|
||||||
|
*/
|
||||||
|
public function setPersonalTax($personal_tax)
|
||||||
|
{
|
||||||
|
$this->personal_tax = $personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣增值税
|
||||||
|
* @var string $value_added_tax
|
||||||
|
*/
|
||||||
|
public function setValueAddedTax($value_added_tax)
|
||||||
|
{
|
||||||
|
$this->value_added_tax = $value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣附加税费
|
||||||
|
* @var string $additional_tax
|
||||||
|
*/
|
||||||
|
public function setAdditionalTax($additional_tax)
|
||||||
|
{
|
||||||
|
$this->additional_tax = $additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴个税
|
||||||
|
* @var string $received_personal_tax
|
||||||
|
*/
|
||||||
|
public function setReceivedPersonalTax($received_personal_tax)
|
||||||
|
{
|
||||||
|
$this->received_personal_tax = $received_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->received_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴增值税
|
||||||
|
* @var string $received_value_added_tax
|
||||||
|
*/
|
||||||
|
public function setReceivedValueAddedTax($received_value_added_tax)
|
||||||
|
{
|
||||||
|
$this->received_value_added_tax = $received_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->received_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴附加税费
|
||||||
|
* @var string $received_additional_tax
|
||||||
|
*/
|
||||||
|
public function setReceivedAdditionalTax($received_additional_tax)
|
||||||
|
{
|
||||||
|
$this->received_additional_tax = $received_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实缴附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReceivedAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->received_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣个税
|
||||||
|
* @var string $user_personal_tax
|
||||||
|
*/
|
||||||
|
public function setUserPersonalTax($user_personal_tax)
|
||||||
|
{
|
||||||
|
$this->user_personal_tax = $user_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->user_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣个税
|
||||||
|
* @var string $dealer_personal_tax
|
||||||
|
*/
|
||||||
|
public function setDealerPersonalTax($dealer_personal_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_personal_tax = $dealer_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣增值税
|
||||||
|
* @var string $user_value_added_tax
|
||||||
|
*/
|
||||||
|
public function setUserValueAddedTax($user_value_added_tax)
|
||||||
|
{
|
||||||
|
$this->user_value_added_tax = $user_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->user_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣增值税
|
||||||
|
* @var string $dealer_value_added_tax
|
||||||
|
*/
|
||||||
|
public function setDealerValueAddedTax($dealer_value_added_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_value_added_tax = $dealer_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣附加税费
|
||||||
|
* @var string $user_additional_tax
|
||||||
|
*/
|
||||||
|
public function setUserAdditionalTax($user_additional_tax)
|
||||||
|
{
|
||||||
|
$this->user_additional_tax = $user_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户预扣附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->user_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣附加税费
|
||||||
|
* @var string $dealer_additional_tax
|
||||||
|
*/
|
||||||
|
public function setDealerAdditionalTax($dealer_additional_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_additional_tax = $dealer_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业预扣附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实缴个税
|
||||||
|
* @var string $user_received_personal_tax
|
||||||
|
*/
|
||||||
|
public function setUserReceivedPersonalTax($user_received_personal_tax)
|
||||||
|
{
|
||||||
|
$this->user_received_personal_tax = $user_received_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实缴个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserReceivedPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->user_received_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业实缴个税
|
||||||
|
* @var string $dealer_received_personal_tax
|
||||||
|
*/
|
||||||
|
public function setDealerReceivedPersonalTax($dealer_received_personal_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_received_personal_tax = $dealer_received_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业实缴个税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerReceivedPersonalTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_received_personal_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实缴增值税
|
||||||
|
* @var string $user_received_value_added_tax
|
||||||
|
*/
|
||||||
|
public function setUserReceivedValueAddedTax($user_received_value_added_tax)
|
||||||
|
{
|
||||||
|
$this->user_received_value_added_tax = $user_received_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实缴增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserReceivedValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->user_received_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业实缴增值税
|
||||||
|
* @var string $dealer_received_value_added_tax
|
||||||
|
*/
|
||||||
|
public function setDealerReceivedValueAddedTax($dealer_received_value_added_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_received_value_added_tax = $dealer_received_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业实缴增值税
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerReceivedValueAddedTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_received_value_added_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实缴附加税费
|
||||||
|
* @var string $user_received_additional_tax
|
||||||
|
*/
|
||||||
|
public function setUserReceivedAdditionalTax($user_received_additional_tax)
|
||||||
|
{
|
||||||
|
$this->user_received_additional_tax = $user_received_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实缴附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUserReceivedAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->user_received_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业实缴附加税费
|
||||||
|
* @var string $dealer_received_additional_tax
|
||||||
|
*/
|
||||||
|
public function setDealerReceivedAdditionalTax($dealer_received_additional_tax)
|
||||||
|
{
|
||||||
|
$this->dealer_received_additional_tax = $dealer_received_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业实缴附加税费
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDealerReceivedAdditionalTax()
|
||||||
|
{
|
||||||
|
return $this->dealer_received_additional_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税税率
|
||||||
|
* @var string $personal_tax_rate
|
||||||
|
*/
|
||||||
|
public function setPersonalTaxRate($personal_tax_rate)
|
||||||
|
{
|
||||||
|
$this->personal_tax_rate = $personal_tax_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税税率
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPersonalTaxRate()
|
||||||
|
{
|
||||||
|
return $this->personal_tax_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税速算扣除数
|
||||||
|
* @var string $deduct_tax
|
||||||
|
*/
|
||||||
|
public function setDeductTax($deduct_tax)
|
||||||
|
{
|
||||||
|
$this->deduct_tax = $deduct_tax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预扣个税速算扣除数
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDeductTax()
|
||||||
|
{
|
||||||
|
return $this->deduct_tax;
|
||||||
|
}
|
||||||
|
}
|
||||||
97
extend/Yzh/Model/Realname/CollectRealNameInfoRequest.php
Normal file
97
extend/Yzh/Model/Realname/CollectRealNameInfoRequest.php
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Realname;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
* Class CollectRealNameInfoRequest
|
||||||
|
*/
|
||||||
|
class CollectRealNameInfoRequest extends BaseRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 综合服务主体 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $broker_id;
|
||||||
|
/**
|
||||||
|
* 平台企业 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $dealer_id;
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $real_name;
|
||||||
|
/**
|
||||||
|
* 证件号码
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $id_card;
|
||||||
|
/**
|
||||||
|
* 实名认证结果
|
||||||
|
* @var int32
|
||||||
|
*/
|
||||||
|
public $realname_result;
|
||||||
|
/**
|
||||||
|
* 实名认证通过时间
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $realname_time;
|
||||||
|
/**
|
||||||
|
* 实名认证方式
|
||||||
|
* @var int32
|
||||||
|
*/
|
||||||
|
public $realname_type;
|
||||||
|
/**
|
||||||
|
* 实名认证唯一可追溯编码
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $realname_trace_id;
|
||||||
|
/**
|
||||||
|
* 认证平台
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $realname_platform;
|
||||||
|
/**
|
||||||
|
* 人脸照片
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $face_image;
|
||||||
|
/**
|
||||||
|
* 人脸识别验证分数
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $face_verify_score;
|
||||||
|
/**
|
||||||
|
* 银行卡号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $bank_no;
|
||||||
|
/**
|
||||||
|
* 银行预留手机号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $bank_phone;
|
||||||
|
/**
|
||||||
|
* 平台企业审核人
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $reviewer;
|
||||||
|
/**
|
||||||
|
* 人脸照片收集类型
|
||||||
|
* @var int32
|
||||||
|
*/
|
||||||
|
public $face_image_collect_type;
|
||||||
|
|
||||||
|
public function __construct($params = array())
|
||||||
|
{
|
||||||
|
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||||
|
if (isset($params[$property])) {
|
||||||
|
$this->{$property} = $params[$property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
extend/Yzh/Model/Realname/CollectRealNameInfoResponse.php
Normal file
33
extend/Yzh/Model/Realname/CollectRealNameInfoResponse.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Realname;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseResponse;
|
||||||
|
use Yzh\Model\ResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
* Class CollectRealNameInfoResponse
|
||||||
|
*/
|
||||||
|
class CollectRealNameInfoResponse extends BaseResponse implements ResponseInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取数据对象
|
||||||
|
* @return CollectRealNameInfoResponseData
|
||||||
|
*/
|
||||||
|
public function getData()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置数据对象
|
||||||
|
* @param array $data
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setData($data)
|
||||||
|
{
|
||||||
|
$this->data = new CollectRealNameInfoResponseData($data);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Realname;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
use Yzh\Model\ResponseDataInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
* Class CollectRealNameInfoResponseData
|
||||||
|
*/
|
||||||
|
class CollectRealNameInfoResponseData extends BaseModel implements ResponseDataInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 录入状态
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 录入状态
|
||||||
|
* @var string $status
|
||||||
|
*/
|
||||||
|
public function setStatus($status)
|
||||||
|
{
|
||||||
|
$this->status = $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 录入状态
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatus()
|
||||||
|
{
|
||||||
|
return $this->status;
|
||||||
|
}
|
||||||
|
}
|
||||||
42
extend/Yzh/Model/Realname/QueryRealNameInfoRequest.php
Normal file
42
extend/Yzh/Model/Realname/QueryRealNameInfoRequest.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Realname;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
* Class QueryRealNameInfoRequest
|
||||||
|
*/
|
||||||
|
class QueryRealNameInfoRequest extends BaseRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 综合服务主体 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $broker_id;
|
||||||
|
/**
|
||||||
|
* 平台企业 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $dealer_id;
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $real_name;
|
||||||
|
/**
|
||||||
|
* 证件号码
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $id_card;
|
||||||
|
|
||||||
|
public function __construct($params = array())
|
||||||
|
{
|
||||||
|
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||||
|
if (isset($params[$property])) {
|
||||||
|
$this->{$property} = $params[$property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
extend/Yzh/Model/Realname/QueryRealNameInfoResponse.php
Normal file
33
extend/Yzh/Model/Realname/QueryRealNameInfoResponse.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Realname;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseResponse;
|
||||||
|
use Yzh\Model\ResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
* Class QueryRealNameInfoResponse
|
||||||
|
*/
|
||||||
|
class QueryRealNameInfoResponse extends BaseResponse implements ResponseInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取数据对象
|
||||||
|
* @return QueryRealNameInfoResponseData
|
||||||
|
*/
|
||||||
|
public function getData()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置数据对象
|
||||||
|
* @param array $data
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setData($data)
|
||||||
|
{
|
||||||
|
$this->data = new QueryRealNameInfoResponseData($data);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
244
extend/Yzh/Model/Realname/QueryRealNameInfoResponseData.php
Normal file
244
extend/Yzh/Model/Realname/QueryRealNameInfoResponseData.php
Normal file
@@ -0,0 +1,244 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\Realname;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
use Yzh\Model\ResponseDataInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
* Class QueryRealNameInfoResponseData
|
||||||
|
*/
|
||||||
|
class QueryRealNameInfoResponseData extends BaseModel implements ResponseDataInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 实名认证结果
|
||||||
|
* @var int32
|
||||||
|
*/
|
||||||
|
protected $realname_result;
|
||||||
|
/**
|
||||||
|
* 实名认证通过时间
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $realname_time;
|
||||||
|
/**
|
||||||
|
* 实名认证方式
|
||||||
|
* @var int32
|
||||||
|
*/
|
||||||
|
protected $realname_type;
|
||||||
|
/**
|
||||||
|
* 实名认证唯一可追溯编码
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $realname_trace_id;
|
||||||
|
/**
|
||||||
|
* 认证平台
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $realname_platform;
|
||||||
|
/**
|
||||||
|
* 是否存在人脸照片
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $face_image;
|
||||||
|
/**
|
||||||
|
* 人脸识别验证分数
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $face_verify_score;
|
||||||
|
/**
|
||||||
|
* 银行卡号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $bank_no;
|
||||||
|
/**
|
||||||
|
* 银行预留手机号
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $bank_phone;
|
||||||
|
/**
|
||||||
|
* 平台企业审核人
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $reviewer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实名认证结果
|
||||||
|
* @var int32 $realname_result
|
||||||
|
*/
|
||||||
|
public function setRealnameResult($realname_result)
|
||||||
|
{
|
||||||
|
$this->realname_result = $realname_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实名认证结果
|
||||||
|
* @return int32
|
||||||
|
*/
|
||||||
|
public function getRealnameResult()
|
||||||
|
{
|
||||||
|
return $this->realname_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实名认证通过时间
|
||||||
|
* @var string $realname_time
|
||||||
|
*/
|
||||||
|
public function setRealnameTime($realname_time)
|
||||||
|
{
|
||||||
|
$this->realname_time = $realname_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实名认证通过时间
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRealnameTime()
|
||||||
|
{
|
||||||
|
return $this->realname_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实名认证方式
|
||||||
|
* @var int32 $realname_type
|
||||||
|
*/
|
||||||
|
public function setRealnameType($realname_type)
|
||||||
|
{
|
||||||
|
$this->realname_type = $realname_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实名认证方式
|
||||||
|
* @return int32
|
||||||
|
*/
|
||||||
|
public function getRealnameType()
|
||||||
|
{
|
||||||
|
return $this->realname_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实名认证唯一可追溯编码
|
||||||
|
* @var string $realname_trace_id
|
||||||
|
*/
|
||||||
|
public function setRealnameTraceId($realname_trace_id)
|
||||||
|
{
|
||||||
|
$this->realname_trace_id = $realname_trace_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实名认证唯一可追溯编码
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRealnameTraceId()
|
||||||
|
{
|
||||||
|
return $this->realname_trace_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 认证平台
|
||||||
|
* @var string $realname_platform
|
||||||
|
*/
|
||||||
|
public function setRealnamePlatform($realname_platform)
|
||||||
|
{
|
||||||
|
$this->realname_platform = $realname_platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 认证平台
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRealnamePlatform()
|
||||||
|
{
|
||||||
|
return $this->realname_platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否存在人脸照片
|
||||||
|
* @var string $face_image
|
||||||
|
*/
|
||||||
|
public function setFaceImage($face_image)
|
||||||
|
{
|
||||||
|
$this->face_image = $face_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否存在人脸照片
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFaceImage()
|
||||||
|
{
|
||||||
|
return $this->face_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人脸识别验证分数
|
||||||
|
* @var string $face_verify_score
|
||||||
|
*/
|
||||||
|
public function setFaceVerifyScore($face_verify_score)
|
||||||
|
{
|
||||||
|
$this->face_verify_score = $face_verify_score;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人脸识别验证分数
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFaceVerifyScore()
|
||||||
|
{
|
||||||
|
return $this->face_verify_score;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行卡号
|
||||||
|
* @var string $bank_no
|
||||||
|
*/
|
||||||
|
public function setBankNo($bank_no)
|
||||||
|
{
|
||||||
|
$this->bank_no = $bank_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行卡号
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBankNo()
|
||||||
|
{
|
||||||
|
return $this->bank_no;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行预留手机号
|
||||||
|
* @var string $bank_phone
|
||||||
|
*/
|
||||||
|
public function setBankPhone($bank_phone)
|
||||||
|
{
|
||||||
|
$this->bank_phone = $bank_phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 银行预留手机号
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBankPhone()
|
||||||
|
{
|
||||||
|
return $this->bank_phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业审核人
|
||||||
|
* @var string $reviewer
|
||||||
|
*/
|
||||||
|
public function setReviewer($reviewer)
|
||||||
|
{
|
||||||
|
$this->reviewer = $reviewer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台企业审核人
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getReviewer()
|
||||||
|
{
|
||||||
|
return $this->reviewer;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\UserCollect;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询手机号码绑定状态请求
|
||||||
|
* Class GetUserCollectPhoneStatusRequest
|
||||||
|
*/
|
||||||
|
class GetUserCollectPhoneStatusRequest extends BaseRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 平台企业 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $dealer_id;
|
||||||
|
/**
|
||||||
|
* 综合服务主体 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $broker_id;
|
||||||
|
/**
|
||||||
|
* 平台企业用户 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $dealer_user_id;
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $real_name;
|
||||||
|
/**
|
||||||
|
* 证件号码
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $id_card;
|
||||||
|
/**
|
||||||
|
* 证件类型编码
|
||||||
|
* @var int32
|
||||||
|
*/
|
||||||
|
public $certificate_type;
|
||||||
|
|
||||||
|
public function __construct($params = array())
|
||||||
|
{
|
||||||
|
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||||
|
if (isset($params[$property])) {
|
||||||
|
$this->{$property} = $params[$property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\UserCollect;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseResponse;
|
||||||
|
use Yzh\Model\ResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询手机号码绑定状态返回
|
||||||
|
* Class GetUserCollectPhoneStatusResponse
|
||||||
|
*/
|
||||||
|
class GetUserCollectPhoneStatusResponse extends BaseResponse implements ResponseInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取数据对象
|
||||||
|
* @return GetUserCollectPhoneStatusResponseData
|
||||||
|
*/
|
||||||
|
public function getData()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置数据对象
|
||||||
|
* @param array $data
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setData($data)
|
||||||
|
{
|
||||||
|
$this->data = new GetUserCollectPhoneStatusResponseData($data);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\UserCollect;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
use Yzh\Model\ResponseDataInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询手机号码绑定状态返回
|
||||||
|
* Class GetUserCollectPhoneStatusResponseData
|
||||||
|
*/
|
||||||
|
class GetUserCollectPhoneStatusResponseData extends BaseModel implements ResponseDataInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 手机号码收集 Token
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $token;
|
||||||
|
/**
|
||||||
|
* 绑定状态
|
||||||
|
* @var int32
|
||||||
|
*/
|
||||||
|
protected $status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号码收集 Token
|
||||||
|
* @var string $token
|
||||||
|
*/
|
||||||
|
public function setToken($token)
|
||||||
|
{
|
||||||
|
$this->token = $token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号码收集 Token
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getToken()
|
||||||
|
{
|
||||||
|
return $this->token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定状态
|
||||||
|
* @var int32 $status
|
||||||
|
*/
|
||||||
|
public function setStatus($status)
|
||||||
|
{
|
||||||
|
$this->status = $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定状态
|
||||||
|
* @return int32
|
||||||
|
*/
|
||||||
|
public function getStatus()
|
||||||
|
{
|
||||||
|
return $this->status;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\UserCollect;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取收集手机号码页面请求
|
||||||
|
* Class GetUserCollectPhoneUrlRequest
|
||||||
|
*/
|
||||||
|
class GetUserCollectPhoneUrlRequest extends BaseRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 手机号码收集 Token
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $token;
|
||||||
|
/**
|
||||||
|
* 主题颜色
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $color;
|
||||||
|
/**
|
||||||
|
* 回调地址
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $url;
|
||||||
|
/**
|
||||||
|
* 跳转 URL
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $redirect_url;
|
||||||
|
|
||||||
|
public function __construct($params = array())
|
||||||
|
{
|
||||||
|
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||||
|
if (isset($params[$property])) {
|
||||||
|
$this->{$property} = $params[$property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\UserCollect;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseResponse;
|
||||||
|
use Yzh\Model\ResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取收集手机号码页面返回
|
||||||
|
* Class GetUserCollectPhoneUrlResponse
|
||||||
|
*/
|
||||||
|
class GetUserCollectPhoneUrlResponse extends BaseResponse implements ResponseInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取数据对象
|
||||||
|
* @return GetUserCollectPhoneUrlResponseData
|
||||||
|
*/
|
||||||
|
public function getData()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置数据对象
|
||||||
|
* @param array $data
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setData($data)
|
||||||
|
{
|
||||||
|
$this->data = new GetUserCollectPhoneUrlResponseData($data);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\UserCollect;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseModel;
|
||||||
|
use Yzh\Model\ResponseDataInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取收集手机号码页面返回
|
||||||
|
* Class GetUserCollectPhoneUrlResponseData
|
||||||
|
*/
|
||||||
|
class GetUserCollectPhoneUrlResponseData extends BaseModel implements ResponseDataInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 收集手机号码页面 URL
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收集手机号码页面 URL
|
||||||
|
* @var string $url
|
||||||
|
*/
|
||||||
|
public function setUrl($url)
|
||||||
|
{
|
||||||
|
$this->url = $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收集手机号码页面 URL
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUrl()
|
||||||
|
{
|
||||||
|
return $this->url;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh\Model\UserCollect;
|
||||||
|
|
||||||
|
use Yzh\Model\BaseRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收集手机号码结果回调通知
|
||||||
|
* Class NotifyUserCollectPhoneRequest
|
||||||
|
*/
|
||||||
|
class NotifyUserCollectPhoneRequest extends BaseRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 平台企业用户 ID
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $dealer_user_id;
|
||||||
|
/**
|
||||||
|
* 手机号码绑定状态
|
||||||
|
* @var int32
|
||||||
|
*/
|
||||||
|
public $status;
|
||||||
|
|
||||||
|
public function __construct($params = array())
|
||||||
|
{
|
||||||
|
foreach (array_keys(get_object_vars($this)) as $property) {
|
||||||
|
if (isset($params[$property])) {
|
||||||
|
$this->{$property} = $params[$property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
49
extend/Yzh/RealNameServiceClient.php
Normal file
49
extend/Yzh/RealNameServiceClient.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh;
|
||||||
|
|
||||||
|
use Yzh\Exception\ConfigException;
|
||||||
|
use Yzh\Exception\ExceptionCode;
|
||||||
|
|
||||||
|
|
||||||
|
use Yzh\Model\Realname\CollectRealNameInfoRequest;
|
||||||
|
use Yzh\Model\Realname\CollectRealNameInfoResponse;
|
||||||
|
use Yzh\Model\Realname\QueryRealNameInfoRequest;
|
||||||
|
use Yzh\Model\Realname\QueryRealNameInfoResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实名信息收集
|
||||||
|
* Class RealNameServiceClient
|
||||||
|
*/
|
||||||
|
class RealNameServiceClient extends BaseClient
|
||||||
|
{
|
||||||
|
protected static $service_name = 'realnameservice';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实名认证信息收集
|
||||||
|
* @param CollectRealNameInfoRequest $request
|
||||||
|
* @param null $option
|
||||||
|
* @return CollectRealNameInfoResponse
|
||||||
|
*/
|
||||||
|
public function collectRealNameInfo($request, $option = null)
|
||||||
|
{
|
||||||
|
if (!$request instanceof CollectRealNameInfoRequest) {
|
||||||
|
throw new ConfigException("Realname->collectRealNameInfo request 必须是 Yzh\\Model\\Realname\\CollectRealNameInfoRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||||
|
}
|
||||||
|
return $this->send('POST', '/api/user/v1/collect/realname/info', $request, "Yzh\\Model\\Realname\\CollectRealNameInfoResponse", $option);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户实名认证信息查询
|
||||||
|
* @param QueryRealNameInfoRequest $request
|
||||||
|
* @param null $option
|
||||||
|
* @return QueryRealNameInfoResponse
|
||||||
|
*/
|
||||||
|
public function queryRealNameInfo($request, $option = null)
|
||||||
|
{
|
||||||
|
if (!$request instanceof QueryRealNameInfoRequest) {
|
||||||
|
throw new ConfigException("Realname->queryRealNameInfo request 必须是 Yzh\\Model\\Realname\\QueryRealNameInfoRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||||
|
}
|
||||||
|
return $this->send('GET', '/api/user/v1/query/realname/info', $request, "Yzh\\Model\\Realname\\QueryRealNameInfoResponse", $option);
|
||||||
|
}
|
||||||
|
}
|
||||||
49
extend/Yzh/UserCollectServiceClient.php
Normal file
49
extend/Yzh/UserCollectServiceClient.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Yzh;
|
||||||
|
|
||||||
|
use Yzh\Exception\ConfigException;
|
||||||
|
use Yzh\Exception\ExceptionCode;
|
||||||
|
|
||||||
|
|
||||||
|
use Yzh\Model\Usercollect\GetUserCollectPhoneStatusRequest;
|
||||||
|
use Yzh\Model\Usercollect\GetUserCollectPhoneStatusResponse;
|
||||||
|
use Yzh\Model\Usercollect\GetUserCollectPhoneUrlRequest;
|
||||||
|
use Yzh\Model\Usercollect\GetUserCollectPhoneUrlResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户信息收集
|
||||||
|
* Class UserCollectServiceClient
|
||||||
|
*/
|
||||||
|
class UserCollectServiceClient extends BaseClient
|
||||||
|
{
|
||||||
|
protected static $service_name = 'usercollectservice';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询手机号码绑定状态
|
||||||
|
* @param GetUserCollectPhoneStatusRequest $request
|
||||||
|
* @param null $option
|
||||||
|
* @return GetUserCollectPhoneStatusResponse
|
||||||
|
*/
|
||||||
|
public function getUserCollectPhoneStatus($request, $option = null)
|
||||||
|
{
|
||||||
|
if (!$request instanceof GetUserCollectPhoneStatusRequest) {
|
||||||
|
throw new ConfigException("UserCollect->getUserCollectPhoneStatus request 必须是 Yzh\\Model\\UserCollect\\GetUserCollectPhoneStatusRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||||
|
}
|
||||||
|
return $this->send('GET', '/api/user/v1/collect/phone/status', $request, "Yzh\\Model\\UserCollect\\GetUserCollectPhoneStatusResponse", $option);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取收集手机号码页面
|
||||||
|
* @param GetUserCollectPhoneUrlRequest $request
|
||||||
|
* @param null $option
|
||||||
|
* @return GetUserCollectPhoneUrlResponse
|
||||||
|
*/
|
||||||
|
public function getUserCollectPhoneUrl($request, $option = null)
|
||||||
|
{
|
||||||
|
if (!$request instanceof GetUserCollectPhoneUrlRequest) {
|
||||||
|
throw new ConfigException("UserCollect->getUserCollectPhoneUrl request 必须是 Yzh\\Model\\UserCollect\\GetUserCollectPhoneUrlRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM);
|
||||||
|
}
|
||||||
|
return $this->send('GET', '/api/user/v1/collect/phone/url', $request, "Yzh\\Model\\UserCollect\\GetUserCollectPhoneUrlResponse", $option);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
vendor/adbario/php-dot-notation/LICENSE.md
vendored
Normal file
21
vendor/adbario/php-dot-notation/LICENSE.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016-2019 Riku Särkinen
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
29
vendor/adbario/php-dot-notation/composer.json
vendored
Normal file
29
vendor/adbario/php-dot-notation/composer.json
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name": "adbario/php-dot-notation",
|
||||||
|
"description": "PHP dot notation access to arrays",
|
||||||
|
"keywords": ["dotnotation", "arrayaccess"],
|
||||||
|
"homepage": "https://github.com/adbario/php-dot-notation",
|
||||||
|
"license": "MIT",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Riku Särkinen",
|
||||||
|
"email": "riku@adbar.io"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": "^5.5 || ^7.0 || ^8.0",
|
||||||
|
"ext-json": "*"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^4.8|^5.7|^6.6|^7.5|^8.5|^9.5",
|
||||||
|
"squizlabs/php_codesniffer": "^3.6"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"src/helpers.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Adbar\\": "src"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
623
vendor/adbario/php-dot-notation/src/Dot.php
vendored
Normal file
623
vendor/adbario/php-dot-notation/src/Dot.php
vendored
Normal file
@@ -0,0 +1,623 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Dot - PHP dot notation access to arrays
|
||||||
|
*
|
||||||
|
* @author Riku Särkinen <riku@adbar.io>
|
||||||
|
* @link https://github.com/adbario/php-dot-notation
|
||||||
|
* @license https://github.com/adbario/php-dot-notation/blob/2.x/LICENSE.md (MIT License)
|
||||||
|
*/
|
||||||
|
namespace Adbar;
|
||||||
|
|
||||||
|
use Countable;
|
||||||
|
use ArrayAccess;
|
||||||
|
use ArrayIterator;
|
||||||
|
use JsonSerializable;
|
||||||
|
use IteratorAggregate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dot
|
||||||
|
*
|
||||||
|
* This class provides a dot notation access and helper functions for
|
||||||
|
* working with arrays of data. Inspired by Laravel Collection.
|
||||||
|
*/
|
||||||
|
class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The stored items
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $items = [];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The delimiter (alternative to a '.') to be used.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $delimiter = '.';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Dot instance
|
||||||
|
*
|
||||||
|
* @param mixed $items
|
||||||
|
* @param string $delimiter
|
||||||
|
*/
|
||||||
|
public function __construct($items = [], $delimiter = '.')
|
||||||
|
{
|
||||||
|
$this->items = $this->getArrayItems($items);
|
||||||
|
$this->delimiter = strlen($delimiter) ? $delimiter : '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a given key / value pair or pairs
|
||||||
|
* if the key doesn't exist already
|
||||||
|
*
|
||||||
|
* @param array|int|string $keys
|
||||||
|
* @param mixed $value
|
||||||
|
*/
|
||||||
|
public function add($keys, $value = null)
|
||||||
|
{
|
||||||
|
if (is_array($keys)) {
|
||||||
|
foreach ($keys as $key => $value) {
|
||||||
|
$this->add($key, $value);
|
||||||
|
}
|
||||||
|
} elseif (is_null($this->get($keys))) {
|
||||||
|
$this->set($keys, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all the stored items
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function all()
|
||||||
|
{
|
||||||
|
return $this->items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the contents of a given key or keys
|
||||||
|
*
|
||||||
|
* @param array|int|string|null $keys
|
||||||
|
*/
|
||||||
|
public function clear($keys = null)
|
||||||
|
{
|
||||||
|
if (is_null($keys)) {
|
||||||
|
$this->items = [];
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$keys = (array) $keys;
|
||||||
|
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
$this->set($key, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the given key or keys
|
||||||
|
*
|
||||||
|
* @param array|int|string $keys
|
||||||
|
*/
|
||||||
|
public function delete($keys)
|
||||||
|
{
|
||||||
|
$keys = (array) $keys;
|
||||||
|
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
if ($this->exists($this->items, $key)) {
|
||||||
|
unset($this->items[$key]);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = &$this->items;
|
||||||
|
$segments = explode($this->delimiter, $key);
|
||||||
|
$lastSegment = array_pop($segments);
|
||||||
|
|
||||||
|
foreach ($segments as $segment) {
|
||||||
|
if (!isset($items[$segment]) || !is_array($items[$segment])) {
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = &$items[$segment];
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($items[$lastSegment]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given key exists in the provided array.
|
||||||
|
*
|
||||||
|
* @param array $array Array to validate
|
||||||
|
* @param int|string $key The key to look for
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function exists($array, $key)
|
||||||
|
{
|
||||||
|
return array_key_exists($key, $array);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flatten an array with the given character as a key delimiter
|
||||||
|
*
|
||||||
|
* @param string $delimiter
|
||||||
|
* @param array|null $items
|
||||||
|
* @param string $prepend
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function flatten($delimiter = '.', $items = null, $prepend = '')
|
||||||
|
{
|
||||||
|
$flatten = [];
|
||||||
|
|
||||||
|
if (is_null($items)) {
|
||||||
|
$items = $this->items;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!func_num_args()) {
|
||||||
|
$delimiter = $this->delimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($items as $key => $value) {
|
||||||
|
if (is_array($value) && !empty($value)) {
|
||||||
|
$flatten = array_merge(
|
||||||
|
$flatten,
|
||||||
|
$this->flatten($delimiter, $value, $prepend.$key.$delimiter)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$flatten[$prepend.$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $flatten;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the value of a given key
|
||||||
|
*
|
||||||
|
* @param int|string|null $key
|
||||||
|
* @param mixed $default
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function get($key = null, $default = null)
|
||||||
|
{
|
||||||
|
if (is_null($key)) {
|
||||||
|
return $this->items;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->exists($this->items, $key)) {
|
||||||
|
return $this->items[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($key, $this->delimiter) === false) {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = $this->items;
|
||||||
|
|
||||||
|
foreach (explode($this->delimiter, $key) as $segment) {
|
||||||
|
if (!is_array($items) || !$this->exists($items, $segment)) {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = &$items[$segment];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the given items as an array
|
||||||
|
*
|
||||||
|
* @param mixed $items
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getArrayItems($items)
|
||||||
|
{
|
||||||
|
if (is_array($items)) {
|
||||||
|
return $items;
|
||||||
|
} elseif ($items instanceof self) {
|
||||||
|
return $items->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (array) $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a given key or keys exists
|
||||||
|
*
|
||||||
|
* @param array|int|string $keys
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function has($keys)
|
||||||
|
{
|
||||||
|
$keys = (array) $keys;
|
||||||
|
|
||||||
|
if (!$this->items || $keys === []) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
$items = $this->items;
|
||||||
|
|
||||||
|
if ($this->exists($items, $key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (explode($this->delimiter, $key) as $segment) {
|
||||||
|
if (!is_array($items) || !$this->exists($items, $segment)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = $items[$segment];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a given key or keys are empty
|
||||||
|
*
|
||||||
|
* @param array|int|string|null $keys
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isEmpty($keys = null)
|
||||||
|
{
|
||||||
|
if (is_null($keys)) {
|
||||||
|
return empty($this->items);
|
||||||
|
}
|
||||||
|
|
||||||
|
$keys = (array) $keys;
|
||||||
|
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
if (!empty($this->get($key))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge a given array or a Dot object with the given key
|
||||||
|
* or with the whole Dot object
|
||||||
|
*
|
||||||
|
* @param array|string|self $key
|
||||||
|
* @param array|self $value
|
||||||
|
*/
|
||||||
|
public function merge($key, $value = [])
|
||||||
|
{
|
||||||
|
if (is_array($key)) {
|
||||||
|
$this->items = array_merge($this->items, $key);
|
||||||
|
} elseif (is_string($key)) {
|
||||||
|
$items = (array) $this->get($key);
|
||||||
|
$value = array_merge($items, $this->getArrayItems($value));
|
||||||
|
|
||||||
|
$this->set($key, $value);
|
||||||
|
} elseif ($key instanceof self) {
|
||||||
|
$this->items = array_merge($this->items, $key->all());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively merge a given array or a Dot object with the given key
|
||||||
|
* or with the whole Dot object.
|
||||||
|
*
|
||||||
|
* Duplicate keys are converted to arrays.
|
||||||
|
*
|
||||||
|
* @param array|string|self $key
|
||||||
|
* @param array|self $value
|
||||||
|
*/
|
||||||
|
public function mergeRecursive($key, $value = [])
|
||||||
|
{
|
||||||
|
if (is_array($key)) {
|
||||||
|
$this->items = array_merge_recursive($this->items, $key);
|
||||||
|
} elseif (is_string($key)) {
|
||||||
|
$items = (array) $this->get($key);
|
||||||
|
$value = array_merge_recursive($items, $this->getArrayItems($value));
|
||||||
|
|
||||||
|
$this->set($key, $value);
|
||||||
|
} elseif ($key instanceof self) {
|
||||||
|
$this->items = array_merge_recursive($this->items, $key->all());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively merge a given array or a Dot object with the given key
|
||||||
|
* or with the whole Dot object.
|
||||||
|
*
|
||||||
|
* Instead of converting duplicate keys to arrays, the value from
|
||||||
|
* given array will replace the value in Dot object.
|
||||||
|
*
|
||||||
|
* @param array|string|self $key
|
||||||
|
* @param array|self $value
|
||||||
|
*/
|
||||||
|
public function mergeRecursiveDistinct($key, $value = [])
|
||||||
|
{
|
||||||
|
if (is_array($key)) {
|
||||||
|
$this->items = $this->arrayMergeRecursiveDistinct($this->items, $key);
|
||||||
|
} elseif (is_string($key)) {
|
||||||
|
$items = (array) $this->get($key);
|
||||||
|
$value = $this->arrayMergeRecursiveDistinct($items, $this->getArrayItems($value));
|
||||||
|
|
||||||
|
$this->set($key, $value);
|
||||||
|
} elseif ($key instanceof self) {
|
||||||
|
$this->items = $this->arrayMergeRecursiveDistinct($this->items, $key->all());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges two arrays recursively. In contrast to array_merge_recursive,
|
||||||
|
* duplicate keys are not converted to arrays but rather overwrite the
|
||||||
|
* value in the first array with the duplicate value in the second array.
|
||||||
|
*
|
||||||
|
* @param array $array1 Initial array to merge
|
||||||
|
* @param array $array2 Array to recursively merge
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function arrayMergeRecursiveDistinct(array $array1, array $array2)
|
||||||
|
{
|
||||||
|
$merged = &$array1;
|
||||||
|
|
||||||
|
foreach ($array2 as $key => $value) {
|
||||||
|
if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
|
||||||
|
$merged[$key] = $this->arrayMergeRecursiveDistinct($merged[$key], $value);
|
||||||
|
} else {
|
||||||
|
$merged[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $merged;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the value of a given key and
|
||||||
|
* delete the key
|
||||||
|
*
|
||||||
|
* @param int|string|null $key
|
||||||
|
* @param mixed $default
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function pull($key = null, $default = null)
|
||||||
|
{
|
||||||
|
if (is_null($key)) {
|
||||||
|
$value = $this->all();
|
||||||
|
$this->clear();
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = $this->get($key, $default);
|
||||||
|
$this->delete($key);
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Push a given value to the end of the array
|
||||||
|
* in a given key
|
||||||
|
*
|
||||||
|
* @param mixed $key
|
||||||
|
* @param mixed $value
|
||||||
|
*/
|
||||||
|
public function push($key, $value = null)
|
||||||
|
{
|
||||||
|
if (is_null($value)) {
|
||||||
|
$this->items[] = $key;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = $this->get($key);
|
||||||
|
|
||||||
|
if (is_array($items) || is_null($items)) {
|
||||||
|
$items[] = $value;
|
||||||
|
$this->set($key, $items);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace all values or values within the given key
|
||||||
|
* with an array or Dot object
|
||||||
|
*
|
||||||
|
* @param array|string|self $key
|
||||||
|
* @param array|self $value
|
||||||
|
*/
|
||||||
|
public function replace($key, $value = [])
|
||||||
|
{
|
||||||
|
if (is_array($key)) {
|
||||||
|
$this->items = array_replace($this->items, $key);
|
||||||
|
} elseif (is_string($key)) {
|
||||||
|
$items = (array) $this->get($key);
|
||||||
|
$value = array_replace($items, $this->getArrayItems($value));
|
||||||
|
|
||||||
|
$this->set($key, $value);
|
||||||
|
} elseif ($key instanceof self) {
|
||||||
|
$this->items = array_replace($this->items, $key->all());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a given key / value pair or pairs
|
||||||
|
*
|
||||||
|
* @param array|int|string $keys
|
||||||
|
* @param mixed $value
|
||||||
|
*/
|
||||||
|
public function set($keys, $value = null)
|
||||||
|
{
|
||||||
|
if (is_array($keys)) {
|
||||||
|
foreach ($keys as $key => $value) {
|
||||||
|
$this->set($key, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = &$this->items;
|
||||||
|
|
||||||
|
foreach (explode($this->delimiter, $keys) as $key) {
|
||||||
|
if (!isset($items[$key]) || !is_array($items[$key])) {
|
||||||
|
$items[$key] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = &$items[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace all items with a given array
|
||||||
|
*
|
||||||
|
* @param mixed $items
|
||||||
|
*/
|
||||||
|
public function setArray($items)
|
||||||
|
{
|
||||||
|
$this->items = $this->getArrayItems($items);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace all items with a given array as a reference
|
||||||
|
*
|
||||||
|
* @param array $items
|
||||||
|
*/
|
||||||
|
public function setReference(array &$items)
|
||||||
|
{
|
||||||
|
$this->items = &$items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the value of a given key or all the values as JSON
|
||||||
|
*
|
||||||
|
* @param mixed $key
|
||||||
|
* @param int $options
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function toJson($key = null, $options = 0)
|
||||||
|
{
|
||||||
|
if (is_string($key)) {
|
||||||
|
return json_encode($this->get($key), $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = $key === null ? 0 : $key;
|
||||||
|
|
||||||
|
return json_encode($this->items, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* --------------------------------------------------------------
|
||||||
|
* ArrayAccess interface
|
||||||
|
* --------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a given key exists
|
||||||
|
*
|
||||||
|
* @param int|string $key
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
|
public function offsetExists($key)
|
||||||
|
{
|
||||||
|
return $this->has($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the value of a given key
|
||||||
|
*
|
||||||
|
* @param int|string $key
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
|
public function offsetGet($key)
|
||||||
|
{
|
||||||
|
return $this->get($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a given value to the given key
|
||||||
|
*
|
||||||
|
* @param int|string|null $key
|
||||||
|
* @param mixed $value
|
||||||
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
|
public function offsetSet($key, $value)
|
||||||
|
{
|
||||||
|
if (is_null($key)) {
|
||||||
|
$this->items[] = $value;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->set($key, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the given key
|
||||||
|
*
|
||||||
|
* @param int|string $key
|
||||||
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
|
public function offsetUnset($key)
|
||||||
|
{
|
||||||
|
$this->delete($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* --------------------------------------------------------------
|
||||||
|
* Countable interface
|
||||||
|
* --------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the number of items in a given key
|
||||||
|
*
|
||||||
|
* @param int|string|null $key
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
|
public function count($key = null)
|
||||||
|
{
|
||||||
|
return count($this->get($key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* --------------------------------------------------------------
|
||||||
|
* IteratorAggregate interface
|
||||||
|
* --------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an iterator for the stored items
|
||||||
|
*
|
||||||
|
* @return \ArrayIterator
|
||||||
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
|
public function getIterator()
|
||||||
|
{
|
||||||
|
return new ArrayIterator($this->items);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* --------------------------------------------------------------
|
||||||
|
* JsonSerializable interface
|
||||||
|
* --------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return items for JSON serialization
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
|
public function jsonSerialize()
|
||||||
|
{
|
||||||
|
return $this->items;
|
||||||
|
}
|
||||||
|
}
|
||||||
24
vendor/adbario/php-dot-notation/src/helpers.php
vendored
Normal file
24
vendor/adbario/php-dot-notation/src/helpers.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Dot - PHP dot notation access to arrays
|
||||||
|
*
|
||||||
|
* @author Riku Särkinen <riku@adbar.io>
|
||||||
|
* @link https://github.com/adbario/php-dot-notation
|
||||||
|
* @license https://github.com/adbario/php-dot-notation/blob/2.x/LICENSE.md (MIT License)
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Adbar\Dot;
|
||||||
|
|
||||||
|
if (! function_exists('dot')) {
|
||||||
|
/**
|
||||||
|
* Create a new Dot object with the given items and optional delimiter
|
||||||
|
*
|
||||||
|
* @param mixed $items
|
||||||
|
* @param string $delimiter
|
||||||
|
* @return \Adbar\Dot
|
||||||
|
*/
|
||||||
|
function dot($items, $delimiter = '.')
|
||||||
|
{
|
||||||
|
return new Dot($items, $delimiter);
|
||||||
|
}
|
||||||
|
}
|
||||||
18
vendor/alibabacloud/credentials/CHANGELOG.md
vendored
Normal file
18
vendor/alibabacloud/credentials/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# CHANGELOG
|
||||||
|
|
||||||
|
## 1.2.0 - 2024-10-17
|
||||||
|
|
||||||
|
- Refactor all credentials providers.
|
||||||
|
|
||||||
|
## 1.1.3 - 2020-12-24
|
||||||
|
|
||||||
|
- Require guzzle ^6.3|^7.0
|
||||||
|
|
||||||
|
## 1.0.2 - 2020-02-14
|
||||||
|
- Update Tea.
|
||||||
|
|
||||||
|
## 1.0.1 - 2019-12-30
|
||||||
|
- Supported get `Role Name` automatically.
|
||||||
|
|
||||||
|
## 1.0.0 - 2019-09-01
|
||||||
|
- Initial release of the Alibaba Cloud Credentials for PHP Version 1.0.0 on Packagist See <https://github.com/aliyun/credentials-php> for more information.
|
||||||
30
vendor/alibabacloud/credentials/CONTRIBUTING.md
vendored
Normal file
30
vendor/alibabacloud/credentials/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# CONTRIBUTING
|
||||||
|
|
||||||
|
We work hard to provide a high-quality and useful SDK for Alibaba Cloud, and
|
||||||
|
we greatly value feedback and contributions from our community. Please submit
|
||||||
|
your [issues][issues] or [pull requests][pull-requests] through GitHub.
|
||||||
|
|
||||||
|
## Tips
|
||||||
|
|
||||||
|
- The SDK is released under the [Apache license][license]. Any code you submit
|
||||||
|
will be released under that license. For substantial contributions, we may
|
||||||
|
ask you to sign a [Alibaba Documentation Corporate Contributor License
|
||||||
|
Agreement (CLA)][cla].
|
||||||
|
- We follow all of the relevant PSR recommendations from the [PHP Framework
|
||||||
|
Interop Group][php-fig]. Please submit code that follows these standards.
|
||||||
|
The [PHP CS Fixer][cs-fixer] tool can be helpful for formatting your code.
|
||||||
|
Your can use `composer fixer` to fix code.
|
||||||
|
- We maintain a high percentage of code coverage in our unit tests. If you make
|
||||||
|
changes to the code, please add, update, and/or remove tests as appropriate.
|
||||||
|
- If your code does not conform to the PSR standards, does not include adequate
|
||||||
|
tests, or does not contain a changelog document, we may ask you to update
|
||||||
|
your pull requests before we accept them. We also reserve the right to deny
|
||||||
|
any pull requests that do not align with our standards or goals.
|
||||||
|
|
||||||
|
[issues]: https://github.com/aliyun/credentials-php/issues
|
||||||
|
[pull-requests]: https://github.com/aliyun/credentials-php/pulls
|
||||||
|
[license]: http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
[cla]: https://alibaba-cla-2018.oss-cn-beijing.aliyuncs.com/Alibaba_Documentation_Open_Source_Corporate_CLA.pdf
|
||||||
|
[php-fig]: http://php-fig.org
|
||||||
|
[cs-fixer]: http://cs.sensiolabs.org/
|
||||||
|
[docs-readme]: https://github.com/aliyun/credentials-php/blob/master/README.md
|
||||||
13
vendor/alibabacloud/credentials/LICENSE.md
vendored
Normal file
13
vendor/alibabacloud/credentials/LICENSE.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
88
vendor/alibabacloud/credentials/NOTICE.md
vendored
Normal file
88
vendor/alibabacloud/credentials/NOTICE.md
vendored
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
# NOTICE
|
||||||
|
|
||||||
|
<https://www.alibabacloud.com/>
|
||||||
|
|
||||||
|
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License").
|
||||||
|
You may not use this file except in compliance with the License.
|
||||||
|
A copy of the License is located at
|
||||||
|
|
||||||
|
<http://www.apache.org/licenses/LICENSE-2.0>
|
||||||
|
|
||||||
|
or in the "license" file accompanying this file. This file is distributed
|
||||||
|
on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
||||||
|
express or implied. See the License for the specific language governing
|
||||||
|
permissions and limitations under the License.
|
||||||
|
|
||||||
|
# Guzzle
|
||||||
|
|
||||||
|
<https://github.com/guzzle/guzzle>
|
||||||
|
|
||||||
|
Copyright (c) 2011-2018 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
# jmespath.php
|
||||||
|
|
||||||
|
<https://github.com/mtdowling/jmespath.php>
|
||||||
|
|
||||||
|
Copyright (c) 2014 Michael Dowling, https://github.com/mtdowling
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
# Dot
|
||||||
|
|
||||||
|
<https://github.com/adbario/php-dot-notation>
|
||||||
|
|
||||||
|
Copyright (c) 2016-2019 Riku Särkinen
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
423
vendor/alibabacloud/credentials/README-zh-CN.md
vendored
Normal file
423
vendor/alibabacloud/credentials/README-zh-CN.md
vendored
Normal file
@@ -0,0 +1,423 @@
|
|||||||
|
[English](/README.md) | 简体中文
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
# Alibaba Cloud Credentials for PHP
|
||||||
|
|
||||||
|
[](https://github.com/aliyun/credentials-php/actions/workflows/ci.yml)
|
||||||
|
[](https://codecov.io/gh/aliyun/credentials-php)
|
||||||
|
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||||
|
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||||
|
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||||
|
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||||
|
|
||||||
|
Alibaba Cloud Credentials for PHP 是帮助 PHP 开发者管理凭据的工具。
|
||||||
|
|
||||||
|
## 先决条件
|
||||||
|
|
||||||
|
您的系统需要满足[先决条件](/docs/zh-CN/0-Prerequisites.md),包括 PHP> = 5.6。 我们强烈建议使用cURL扩展,并使用TLS后端编译cURL 7.16.2+。
|
||||||
|
|
||||||
|
## 安装依赖
|
||||||
|
|
||||||
|
如果已在系统上[全局安装 Composer](https://getcomposer.org/doc/00-intro.md#globally),请直接在项目目录中运行以下内容来安装 Alibaba Cloud Credentials for PHP 作为依赖项:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
composer require alibabacloud/credentials
|
||||||
|
```
|
||||||
|
|
||||||
|
> 一些用户可能由于网络问题无法安装,可以使用[阿里云 Composer 全量镜像](https://developer.aliyun.com/composer)。
|
||||||
|
|
||||||
|
请看[安装](/docs/zh-CN/1-Installation.md)有关通过 Composer 和其他方式安装的详细信息。
|
||||||
|
|
||||||
|
## 快速使用
|
||||||
|
|
||||||
|
在您开始之前,您需要注册阿里云帐户并获取您的[凭证](https://usercenter.console.aliyun.com/#/manage/ak)。
|
||||||
|
|
||||||
|
### 凭证类型
|
||||||
|
|
||||||
|
#### 使用默认凭据链
|
||||||
|
当您在初始化凭据客户端不传入任何参数时,Credentials工具会使用默认凭据链方式初始化客户端。默认凭据的读取逻辑请参见[默认凭据链](#默认凭证提供程序链)。
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
|
||||||
|
// Chain Provider if no Parameter
|
||||||
|
$client = new Credential();
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
$credential->getSecurityToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### AccessKey
|
||||||
|
|
||||||
|
通过[用户信息管理][ak]设置 access_key,它们具有该账户完全的权限,请妥善保管。有时出于安全考虑,您不能把具有完全访问权限的主账户 AccessKey 交于一个项目的开发者使用,您可以[创建RAM子账户][ram]并为子账户[授权][permissions],使用RAM子用户的 AccessKey 来进行API调用。
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
// Access Key
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'access_key',
|
||||||
|
'accessKeyId' => '<access_key_id>',
|
||||||
|
'accessKeySecret' => '<access_key_secret>',
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### STS
|
||||||
|
|
||||||
|
通过安全令牌服务(Security Token Service,简称 STS),申请临时安全凭证(Temporary Security Credentials,简称 TSC),创建临时安全凭证。
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'sts',
|
||||||
|
'accessKeyId' => '<access_key_id>',
|
||||||
|
'accessKeySecret' => '<access_key_secret>',
|
||||||
|
'securityToken' => '<security_token>',
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
$credential->getSecurityToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### RamRoleArn
|
||||||
|
|
||||||
|
通过指定RAM角色的ARN(Alibabacloud Resource Name),Credentials工具可以帮助开发者前往STS换取STS Token。您也可以通过为 `Policy` 赋值来限制RAM角色到一个更小的权限集合。
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'ram_role_arn',
|
||||||
|
'accessKeyId' => '<access_key_id>',
|
||||||
|
'accessKeySecret' => '<access_key_secret>',
|
||||||
|
// 要扮演的RAM角色ARN,示例值:acs:ram::123456789012****:role/adminrole,可以通过环境变量ALIBABA_CLOUD_ROLE_ARN设置role_arn
|
||||||
|
'roleArn' => '<role_arn>',
|
||||||
|
// 角色会话名称,可以通过环境变量ALIBABA_CLOUD_ROLE_SESSION_NAME设置role_session_name
|
||||||
|
'roleSessionName' => '<role_session_name>',
|
||||||
|
// 设置更小的权限策略,非必填。示例值:{"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}
|
||||||
|
'policy' => '',
|
||||||
|
// 设置session过期时间,非必填。
|
||||||
|
'roleSessionExpiration' => 3600,
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
$credential->getSecurityToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### EcsRamRole
|
||||||
|
|
||||||
|
ECS和ECI实例均支持绑定实例RAM角色,当在实例中使用Credentials工具时,将自动获取实例绑定的RAM角色,并通过访问元数据服务获取RAM角色的STS Token,以完成凭据客户端的初始化。
|
||||||
|
|
||||||
|
实例元数据服务器支持加固模式和普通模式两种访问方式,Credentials工具默认使用加固模式(IMDSv2)获取访问凭据。若使用加固模式时发生异常,您可以通过设置disableIMDSv1来执行不同的异常处理逻辑:
|
||||||
|
|
||||||
|
- 当值为false(默认值)时,会使用普通模式继续获取访问凭据。
|
||||||
|
|
||||||
|
- 当值为true时,表示只能使用加固模式获取访问凭据,会抛出异常。
|
||||||
|
|
||||||
|
服务端是否支持IMDSv2,取决于您在服务器的配置。
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'ecs_ram_role',
|
||||||
|
// 选填,该ECS角色的角色名称,不填会自动获取,但是建议加上以减少请求次数,可以通过环境变量ALIBABA_CLOUD_ECS_METADATA设置role_name
|
||||||
|
'roleName' => '<role_name>',
|
||||||
|
// 选填,是否强制关闭IMDSv1,即必须使用IMDSv2加固模式,可以通过环境变量ALIBABA_CLOUD_IMDSV1_DISABLED设置
|
||||||
|
'disableIMDSv1' => true,
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
$credential->getSecurityToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### OIDCRoleArn
|
||||||
|
|
||||||
|
在容器服务 Kubernetes 版中设置了Worker节点RAM角色后,对应节点内的Pod中的应用也就可以像ECS上部署的应用一样,通过元数据服务(Meta Data Server)获取关联角色的STS Token。但如果容器集群上部署的是不可信的应用(比如部署您的客户提交的应用,代码也没有对您开放),您可能并不希望它们能通过元数据服务获取Worker节点关联实例RAM角色的STS Token。为了避免影响云上资源的安全,同时又能让这些不可信的应用安全地获取所需的 STS Token,实现应用级别的权限最小化,您可以使用RRSA(RAM Roles for Service Account)功能。阿里云容器集群会为不同的应用Pod创建和挂载相应的服务账户OIDC Token文件,并将相关配置信息注入到环境变量中,Credentials工具通过获取环境变量的配置信息,调用STS服务的AssumeRoleWithOIDC - OIDC角色SSO时获取扮演角色的临时身份凭证接口换取绑定角色的STS Token。详情请参见[通过RRSA配置ServiceAccount的RAM权限实现Pod权限隔离](https://help.aliyun.com/zh/ack/ack-managed-and-ack-dedicated/user-guide/use-rrsa-to-authorize-pods-to-access-different-cloud-services#task-2142941)。
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'oidc_role_arn',
|
||||||
|
// OIDC提供商ARN,可以通过环境变量ALIBABA_CLOUD_OIDC_PROVIDER_ARN设置oidc_provider_arn
|
||||||
|
'oidcProviderArn' => '<oidc_provider_arn>',
|
||||||
|
// OIDC Token文件路径,可以通过环境变量ALIBABA_CLOUD_OIDC_TOKEN_FILE设置oidc_token_file_path
|
||||||
|
'oidcTokenFilePath' => '<oidc_token_file_path>',
|
||||||
|
// 要扮演的RAM角色ARN,示例值:acs:ram::123456789012****:role/adminrole,可以通过环境变量ALIBABA_CLOUD_ROLE_ARN设置role_arn
|
||||||
|
'roleArn' => '<role_arn>',
|
||||||
|
// 角色会话名称,可以通过环境变量ALIBABA_CLOUD_ROLE_SESSION_NAME设置role_session_name
|
||||||
|
'roleSessionName' => '<role_session_name>',
|
||||||
|
// 设置更小的权限策略,非必填。示例值:{"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}
|
||||||
|
'policy' => '',
|
||||||
|
# 设置session过期时间
|
||||||
|
'roleSessionExpiration' => 3600,
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
$credential->getSecurityToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Credentials URI
|
||||||
|
|
||||||
|
通过指定提供凭证的自定义网络服务地址,让凭证自动申请维护 STS Token。
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'credentials_uri',
|
||||||
|
// 凭证的 URI,格式为http://local_or_remote_uri/,可以通过环境变量ALIBABA_CLOUD_CREDENTIALS_URI设置credentials_uri
|
||||||
|
'credentialsURI' => '<credentials_uri>',
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
$credential->getSecurityToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Bearer Token
|
||||||
|
|
||||||
|
目前只有云呼叫中心 CCC 这款产品支持 Bearer Token 的凭据初始化方式。
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'bearer',
|
||||||
|
// 填入您的Bearer Token
|
||||||
|
'bearerToken' => '<bearer_token>',
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getBearerToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
## 默认凭证提供程序链
|
||||||
|
|
||||||
|
当您的程序开发环境和生产环境采用不同的凭据类型,常见做法是在代码中获取当前环境信息,编写获取不同凭据的分支代码。借助Credentials工具的默认凭据链,您可以用同一套代码,通过程序之外的配置来控制不同环境下的凭据获取方式。当您在不传入参数的情况下,直接使用$credential = new Credential();初始化凭据客户端时,阿里云SDK将会尝试按照如下顺序查找相关凭据信息。
|
||||||
|
|
||||||
|
### 1. 使用环境变量
|
||||||
|
|
||||||
|
Credentials工具会优先在环境变量中获取凭据信息。
|
||||||
|
|
||||||
|
- 如果系统环境变量 `ALIBABA_CLOUD_ACCESS_KEY_ID`(密钥Key) 和 `ALIBABA_CLOUD_ACCESS_KEY_SECRET`(密钥Value) 不为空,Credentials工具会优先使用它们作为默认凭据。
|
||||||
|
|
||||||
|
- 如果系统环境变量 `ALIBABA_CLOUD_ACCESS_KEY_ID`(密钥Key)、`ALIBABA_CLOUD_ACCESS_KEY_SECRET`(密钥Value)、`ALIBABA_CLOUD_SECURITY_TOKEN`(Token)均不为空,Credentials工具会优先使用STS Token作为默认凭据。
|
||||||
|
|
||||||
|
### 2. 使用OIDC RAM角色
|
||||||
|
若不存在优先级更高的凭据信息,Credentials工具会在环境变量中获取如下内容:
|
||||||
|
|
||||||
|
`ALIBABA_CLOUD_ROLE_ARN`:RAM角色名称ARN;
|
||||||
|
|
||||||
|
`ALIBABA_CLOUD_OIDC_PROVIDER_ARN`:OIDC提供商ARN;
|
||||||
|
|
||||||
|
`ALIBABA_CLOUD_OIDC_TOKEN_FILE`:OIDC Token文件路径;
|
||||||
|
|
||||||
|
若以上三个环境变量都已设置内容,Credentials将会使用变量内容调用STS服务的[AssumeRoleWithOIDC - OIDC角色SSO时获取扮演角色的临时身份凭证](https://help.aliyun.com/zh/ram/developer-reference/api-sts-2015-04-01-assumerolewithoidc)接口换取STS Token作为默认凭据。
|
||||||
|
|
||||||
|
### 3. 使用 Aliyun CLI 工具的 config.json 配置文件
|
||||||
|
|
||||||
|
若不存在优先级更高的凭据信息,Credentials工具会优先在如下位置查找 `config.json` 文件是否存在:
|
||||||
|
Linux系统:`~/.aliyun/config.json`
|
||||||
|
Windows系统: `C:\Users\USER_NAME\.aliyun\config.json`
|
||||||
|
如果文件存在,程序将会使用配置文件中 `current` 指定的凭据信息初始化凭据客户端。当然,您也可以通过环境变量 `ALIBABA_CLOUD_PROFILE` 来指定凭据信息,例如设置 `ALIBABA_CLOUD_PROFILE` 的值为 `AK`。
|
||||||
|
|
||||||
|
在config.json配置文件中每个module的值代表了不同的凭据信息获取方式:
|
||||||
|
|
||||||
|
- AK:使用用户的Access Key作为凭据信息;
|
||||||
|
- RamRoleArn:使用RAM角色的ARN来获取凭据信息;
|
||||||
|
- EcsRamRole:利用ECS绑定的RAM角色来获取凭据信息;
|
||||||
|
- OIDC:通过OIDC ARN和OIDC Token来获取凭据信息;
|
||||||
|
- ChainableRamRoleArn:采用角色链的方式,通过指定JSON文件中的其他凭据,以重新获取新的凭据信息。
|
||||||
|
|
||||||
|
配置示例信息如下:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"current": "AK",
|
||||||
|
"profiles": [
|
||||||
|
{
|
||||||
|
"name": "AK",
|
||||||
|
"mode": "AK",
|
||||||
|
"access_key_id": "access_key_id",
|
||||||
|
"access_key_secret": "access_key_secret"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "RamRoleArn",
|
||||||
|
"mode": "RamRoleArn",
|
||||||
|
"access_key_id": "access_key_id",
|
||||||
|
"access_key_secret": "access_key_secret",
|
||||||
|
"ram_role_arn": "ram_role_arn",
|
||||||
|
"ram_session_name": "ram_session_name",
|
||||||
|
"expired_seconds": 3600,
|
||||||
|
"sts_region": "cn-hangzhou"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "EcsRamRole",
|
||||||
|
"mode": "EcsRamRole",
|
||||||
|
"ram_role_name": "ram_role_name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "OIDC",
|
||||||
|
"mode": "OIDC",
|
||||||
|
"ram_role_arn": "ram_role_arn",
|
||||||
|
"oidc_token_file": "path/to/oidc/file",
|
||||||
|
"oidc_provider_arn": "oidc_provider_arn",
|
||||||
|
"ram_session_name": "ram_session_name",
|
||||||
|
"expired_seconds": 3600,
|
||||||
|
"sts_region": "cn-hangzhou"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ChainableRamRoleArn",
|
||||||
|
"mode": "ChainableRamRoleArn",
|
||||||
|
"source_profile": "AK",
|
||||||
|
"ram_role_arn": "ram_role_arn",
|
||||||
|
"ram_session_name": "ram_session_name",
|
||||||
|
"expired_seconds": 3600,
|
||||||
|
"sts_region": "cn-hangzhou"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. 使用配置文件
|
||||||
|
>
|
||||||
|
> 如果用户主目录存在默认文件 `~/.alibabacloud/credentials` (Windows 为 `C:\Users\USER_NAME\.alibabacloud\credentials`),程序会自动创建指定类型和名称的凭证。您也可通过环境变量 `ALIBABA_CLOUD_CREDENTIALS_FILE` 指定配置文件路径。如果文件存在,程序将会使用配置文件中 default 指定的凭据信息初始化凭据客户端。当然,您也可以通过环境变量 `ALIBABA_CLOUD_PROFILE` 来指定凭据信息,例如设置 `ALIBABA_CLOUD_PROFILE` 的值为 `client1`。
|
||||||
|
|
||||||
|
配置示例信息如下:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[default]
|
||||||
|
type = access_key # 认证方式为 access_key
|
||||||
|
access_key_id = foo # Key
|
||||||
|
access_key_secret = bar # Secret
|
||||||
|
|
||||||
|
[project1]
|
||||||
|
type = ecs_ram_role # 认证方式为 ecs_ram_role
|
||||||
|
role_name = EcsRamRoleTest # Role Name,非必填,不填则自动获取,建议设置,可以减少网络请求。
|
||||||
|
|
||||||
|
[project2]
|
||||||
|
type = ram_role_arn # 认证方式为 ram_role_arn
|
||||||
|
access_key_id = foo
|
||||||
|
access_key_secret = bar
|
||||||
|
role_arn = role_arn
|
||||||
|
role_session_name = session_name
|
||||||
|
|
||||||
|
[project3]
|
||||||
|
type=oidc_role_arn # 认证方式为 oidc_role_arn
|
||||||
|
oidc_provider_arn=oidc_provider_arn
|
||||||
|
oidc_token_file_path=oidc_token_file_path
|
||||||
|
role_arn=role_arn
|
||||||
|
role_session_name=session_name
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. 使用 ECS 实例RAM角色
|
||||||
|
|
||||||
|
若不存在优先级更高的凭据信息,Credentials工具将通过环境变量获取ALIBABA_CLOUD_ECS_METADATA(ECS实例RAM角色名称)的值。若该变量的值存在,程序将采用加固模式(IMDSv2)访问ECS的元数据服务(Meta Data Server),以获取ECS实例RAM角色的STS Token作为默认凭据信息。在使用加固模式时若发生异常,将使用普通模式兜底来获取访问凭据。您也可以通过设置环境变量ALIBABA_CLOUD_IMDSV1_DISABLED,执行不同的异常处理逻辑:
|
||||||
|
|
||||||
|
- 当值为false时,会使用普通模式继续获取访问凭据。
|
||||||
|
|
||||||
|
- 当值为true时,表示只能使用加固模式获取访问凭据,会抛出异常。
|
||||||
|
|
||||||
|
服务端是否支持IMDSv2,取决于您在服务器的配置。
|
||||||
|
|
||||||
|
### 6. 使用外部服务 Credentials URI
|
||||||
|
|
||||||
|
若不存在优先级更高的凭据信息,Credentials工具会在环境变量中获取ALIBABA_CLOUD_CREDENTIALS_URI,若存在,程序将请求该URI地址,获取临时安全凭证作为默认凭据信息。
|
||||||
|
|
||||||
|
外部服务响应结构应如下:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Code": "Success",
|
||||||
|
"AccessKeyId": "AccessKeyId",
|
||||||
|
"AccessKeySecret": "AccessKeySecret",
|
||||||
|
"SecurityToken": "SecurityToken",
|
||||||
|
"Expiration": "2024-10-26T03:46:38Z"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 文档
|
||||||
|
|
||||||
|
* [先决条件](/docs/zh-CN/0-Prerequisites.md)
|
||||||
|
* [安装](/docs/zh-CN/1-Installation.md)
|
||||||
|
|
||||||
|
## 问题
|
||||||
|
|
||||||
|
[提交 Issue](https://github.com/aliyun/credentials-php/issues/new/choose),不符合指南的问题可能会立即关闭。
|
||||||
|
|
||||||
|
## 发行说明
|
||||||
|
|
||||||
|
每个版本的详细更改记录在[发行说明](/CHANGELOG.md)中。
|
||||||
|
|
||||||
|
## 贡献
|
||||||
|
|
||||||
|
提交 Pull Request 之前请阅读[贡献指南](/CONTRIBUTING.md)。
|
||||||
|
|
||||||
|
## 相关
|
||||||
|
|
||||||
|
* [OpenAPI 开发者门户][open-api]
|
||||||
|
* [Packagist][packagist]
|
||||||
|
* [Composer][composer]
|
||||||
|
* [Guzzle中文文档][guzzle-docs]
|
||||||
|
* [最新源码][latest-release]
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
[Apache-2.0](/LICENSE.md)
|
||||||
|
|
||||||
|
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||||
|
|
||||||
|
[open-api]: https://api.aliyun.com
|
||||||
|
[latest-release]: https://github.com/aliyun/credentials-php
|
||||||
|
[guzzle-docs]: https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html
|
||||||
|
[composer]: https://getcomposer.org
|
||||||
|
[packagist]: https://packagist.org/packages/alibabacloud/credentials
|
||||||
422
vendor/alibabacloud/credentials/README.md
vendored
Normal file
422
vendor/alibabacloud/credentials/README.md
vendored
Normal file
@@ -0,0 +1,422 @@
|
|||||||
|
English | [简体中文](/README-zh-CN.md)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
# Alibaba Cloud Credentials for PHP
|
||||||
|
|
||||||
|
[](https://github.com/aliyun/credentials-php/actions/workflows/ci.yml)
|
||||||
|
[](https://codecov.io/gh/aliyun/credentials-php)
|
||||||
|
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||||
|
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||||
|
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||||
|
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||||
|
|
||||||
|
Alibaba Cloud Credentials for PHP is a tool that helps PHP developers manage their credentials.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Your system needs to meet [Prerequisites](/docs/zh-CN/0-Prerequisites.md), including PHP> = 5.6. We strongly recommend using the cURL extension and compiling cURL 7.16.2+ using the TLS backend.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
If you have [Globally Install Composer](https://getcomposer.org/doc/00-intro.md#globally) on your system, install Alibaba Cloud Credentials for PHP as a dependency by running the following directly in the project directory:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
composer require alibabacloud/credentials
|
||||||
|
```
|
||||||
|
|
||||||
|
> Some users may not be able to install due to network problems, you can switch to the [Alibaba Cloud Composer Mirror](https://developer.aliyun.com/composer).
|
||||||
|
|
||||||
|
See [Installation](/docs/zh-CN/1-Installation.md) for details on installing through Composer and other means.
|
||||||
|
|
||||||
|
## Quick Examples
|
||||||
|
|
||||||
|
Before you begin, you need to sign up for an Alibaba Cloud account and retrieve your [Credentials](https://usercenter.console.aliyun.com/#/manage/ak).
|
||||||
|
|
||||||
|
### Credential Type
|
||||||
|
|
||||||
|
#### Default credential provider chain
|
||||||
|
|
||||||
|
If you do not specify a method to initialize a Credentials client, the default credential provider chain is used. For more information, see the Default credential provider chain section of this topic.
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
|
||||||
|
// Chain Provider if no Parameter
|
||||||
|
// Do not specify a method to initialize a Credentials client.
|
||||||
|
$client = new Credential();
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
$credential->getSecurityToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### AccessKey
|
||||||
|
|
||||||
|
Setup access_key credential through [User Information Management][ak], it have full authority over the account, please keep it safe. Sometimes for security reasons, you cannot hand over a primary account AccessKey with full access to the developer of a project. You may create a sub-account [RAM Sub-account][ram] , grant its [authorization][permissions],and use the AccessKey of RAM Sub-account.
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
// Access Key
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'access_key',
|
||||||
|
'accessKeyId' => '<access_key_id>',
|
||||||
|
'accessKeySecret' => '<access_key_secret>',
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### STS
|
||||||
|
|
||||||
|
Create a temporary security credential by applying Temporary Security Credentials (TSC) through the Security Token Service (STS).
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'sts',
|
||||||
|
'accessKeyId' => '<access_key_id>',
|
||||||
|
'accessKeySecret' => '<access_key_secret>',
|
||||||
|
'securityToken' => '<security_token>',
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
$credential->getSecurityToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### RamRoleArn
|
||||||
|
|
||||||
|
By specifying [RAM Role][RAM Role], the credential will be able to automatically request maintenance of STS Token. If you want to limit the permissions([How to make a policy][policy]) of STS Token, you can assign value for `Policy`.
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'ram_role_arn',
|
||||||
|
'accessKeyId' => '<access_key_id>',
|
||||||
|
'accessKeySecret' => '<access_key_secret>',
|
||||||
|
// Specify the ARN of the RAM role to be assumed. Example: acs:ram::123456789012****:role/adminrole.
|
||||||
|
'roleArn' => '<role_arn>',
|
||||||
|
// Specify the name of the role session.
|
||||||
|
'roleSessionName' => '<role_session_name>',
|
||||||
|
// Optional. Specify limited permissions for the RAM role. Example: {"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}.
|
||||||
|
'policy' => '',
|
||||||
|
// Optional. Specify the expiration of the session
|
||||||
|
'roleSessionExpiration' => 3600,
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
$credential->getSecurityToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### EcsRamRole
|
||||||
|
|
||||||
|
Both ECS and ECI instances support binding instance RAM roles. When the Credentials tool is used in an instance, the RAM role bound to the instance will be automatically obtained, and the STS Token of the RAM role will be obtained by accessing the metadata service to complete the initialization of the credential client.
|
||||||
|
|
||||||
|
The instance metadata server supports two access modes: hardened mode and normal mode. The Credentials tool uses hardened mode (IMDSv2) by default to obtain access credentials. If an exception occurs when using hardened mode, you can set disableIMDSv1 to perform different exception handling logic:
|
||||||
|
|
||||||
|
- When the value is false (default value), the normal mode will continue to be used to obtain access credentials.
|
||||||
|
|
||||||
|
- When the value is true, it means that only hardened mode can be used to obtain access credentials, and an exception will be thrown.
|
||||||
|
|
||||||
|
Whether the server supports IMDSv2 depends on your configuration on the server.
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'ecs_ram_role',
|
||||||
|
// Optional. Specify the name of the RAM role of the ECS instance. If you do not specify this parameter, its value is automatically obtained. To reduce the number of requests, we recommend that you specify this parameter.
|
||||||
|
'roleName' => '<role_name>',
|
||||||
|
//Optional, whether to forcibly disable IMDSv1, that is, to use IMDSv2 hardening mode, which can be set by the environment variable ALIBABA_CLOUD_IMDSV1_DISABLED
|
||||||
|
'disableIMDSv1' => true,
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
$credential->getSecurityToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### OIDCRoleArn
|
||||||
|
|
||||||
|
After you attach a RAM role to a worker node in an Container Service for Kubernetes, applications in the pods on the worker node can use the metadata server to obtain an STS token the same way in which applications on ECS instances do. However, if an untrusted application is deployed on the worker node, such as an application that is submitted by your customer and whose code is unavailable to you, you may not want the application to use the metadata server to obtain an STS token of the RAM role attached to the worker node. To ensure the security of cloud resources and enable untrusted applications to securely obtain required STS tokens, you can use the RAM Roles for Service Accounts (RRSA) feature to grant minimum necessary permissions to an application. In this case, the ACK cluster creates a service account OpenID Connect (OIDC) token file, associates the token file with a pod, and then injects relevant environment variables into the pod. Then, the Credentials tool uses the environment variables to call the AssumeRoleWithOIDC operation of STS and obtains an STS token of the RAM role. For more information about the RRSA feature, see [Use RRSA to authorize different pods to access different cloud services](https://www.alibabacloud.com/help/en/ack/ack-managed-and-ack-dedicated/user-guide/use-rrsa-to-authorize-pods-to-access-different-cloud-services#task-2142941).
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'oidc_role_arn',
|
||||||
|
// Specify the ARN of the OIDC IdP by specifying the ALIBABA_CLOUD_OIDC_PROVIDER_ARN environment variable.
|
||||||
|
'oidcProviderArn' => '<oidc_provider_arn>',
|
||||||
|
// Specify the path of the OIDC token file by specifying the ALIBABA_CLOUD_OIDC_TOKEN_FILE environment variable.
|
||||||
|
'oidcTokenFilePath' => '<oidc_token_file_path>',
|
||||||
|
// Specify the ARN of the RAM role by specifying the ALIBABA_CLOUD_ROLE_ARN environment variable.
|
||||||
|
'roleArn' => '<role_arn>',
|
||||||
|
// Specify the role session name by specifying the ALIBABA_CLOUD_ROLE_SESSION_NAME environment variable.
|
||||||
|
'roleSessionName' => '<role_session_name>',
|
||||||
|
// Optional. Specify limited permissions for the RAM role. Example: {"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}.
|
||||||
|
'policy' => '',
|
||||||
|
// Optional. Specify the validity period of the session.
|
||||||
|
'roleSessionExpiration' => 3600,
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
$credential->getSecurityToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Credentials URI
|
||||||
|
|
||||||
|
By specifying the url, the credential will be able to automatically request maintenance of STS Token.
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'credentials_uri',
|
||||||
|
// Format: http url. `credentialsURI` can be replaced by setting environment variable: ALIBABA_CLOUD_CREDENTIALS_URI
|
||||||
|
'credentialsURI' => '<credentials_uri>',
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getAccessKeyId();
|
||||||
|
$credential->getAccessKeySecret();
|
||||||
|
$credential->getSecurityToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Bearer Token
|
||||||
|
|
||||||
|
If credential is required by the Cloud Call Centre (CCC), please apply for Bearer Token maintenance by yourself.
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential;
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
|
||||||
|
$config = new Config([
|
||||||
|
'type' => 'bearer',
|
||||||
|
'bearerToken' => '<bearer_token>',
|
||||||
|
]);
|
||||||
|
$client = new Credential($config);
|
||||||
|
|
||||||
|
$credential = $client->getCredential();
|
||||||
|
$credential->getBearerToken();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Default credential provider chain
|
||||||
|
|
||||||
|
If you want to use different types of credentials in the development and production environments of your application, you generally need to obtain the environment information from the code and write code branches to obtain different credentials for the development and production environments. The default credential provider chain of the Credentials tool allows you to use the same code to obtain credentials for different environments based on configurations independent of the application. If you use $credential = new Credential(); to initialize a Credentials client without specifying an initialization method, the Credentials tool obtains the credential information in the following order:
|
||||||
|
|
||||||
|
### 1. Environmental certificate
|
||||||
|
|
||||||
|
Look for environment credentials in environment variable.
|
||||||
|
- If the `ALIBABA_CLOUD_ACCESS_KEY_ID` and `ALIBABA_CLOUD_ACCESS_KEY_SECRET` environment variables are defined and are not empty, the program will use them to create default credentials.
|
||||||
|
- If the `ALIBABA_CLOUD_ACCESS_KEY_ID`, `ALIBABA_CLOUD_ACCESS_KEY_SECRET` and `ALIBABA_CLOUD_SECURITY_TOKEN` environment variables are defined and are not empty, the program will use them to create temporary security credentials(STS). Note: This token has an expiration time, it is recommended to use it in a temporary environment.
|
||||||
|
|
||||||
|
### 2. The RAM role of an OIDC IdP
|
||||||
|
|
||||||
|
If no credentials are found in the previous step, the Credentials tool obtains the values of the following environment variables:
|
||||||
|
|
||||||
|
`ALIBABA_CLOUD_ROLE_ARN`: the ARN of the RAM role.
|
||||||
|
|
||||||
|
`ALIBABA_CLOUD_OIDC_PROVIDER_ARN`: the ARN of the OIDC IdP.
|
||||||
|
|
||||||
|
`ALIBABA_CLOUD_OIDC_TOKEN_FILE`: the path of the OIDC token file.
|
||||||
|
|
||||||
|
If the preceding three environment variables are specified, the Credentials tool uses the environment variables to call the [AssumeRoleWithOIDC](https://www.alibabacloud.com/help/en/ram/developer-reference/api-sts-2015-04-01-assumerolewithoidc) operation of STS to obtain an STS token as the default credential.
|
||||||
|
|
||||||
|
### 3. Using the config.json Configuration File of Aliyun CLI Tool
|
||||||
|
If there is no higher-priority credential information, the Credentials tool will first check the following locations to see if the config.json file exists:
|
||||||
|
|
||||||
|
Linux system: `~/.aliyun/config.json`
|
||||||
|
Windows system: `C:\Users\USER_NAME\.aliyun\config.json`
|
||||||
|
If the file exists, the program will use the credential information specified by `current` in the configuration file to initialize the credentials client. Of course, you can also use the environment variable `ALIBABA_CLOUD_PROFILE` to specify the credential information, for example by setting the value of `ALIBABA_CLOUD_PROFILE` to `AK`.
|
||||||
|
|
||||||
|
In the config.json configuration file, the value of each module represents different ways to obtain credential information:
|
||||||
|
|
||||||
|
- AK: Use the Access Key of the user as credential information;
|
||||||
|
- RamRoleArn: Use the ARN of the RAM role to obtain credential information;
|
||||||
|
- EcsRamRole: Use the RAM role bound to the ECS to obtain credential information;
|
||||||
|
- OIDC: Obtain credential information through OIDC ARN and OIDC Token;
|
||||||
|
- ChainableRamRoleArn: Use the role chaining method to obtain new credential information by specifying other credentials in the JSON file.
|
||||||
|
|
||||||
|
The configuration example information is as follows:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"current": "AK",
|
||||||
|
"profiles": [
|
||||||
|
{
|
||||||
|
"name": "AK",
|
||||||
|
"mode": "AK",
|
||||||
|
"access_key_id": "access_key_id",
|
||||||
|
"access_key_secret": "access_key_secret"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "RamRoleArn",
|
||||||
|
"mode": "RamRoleArn",
|
||||||
|
"access_key_id": "access_key_id",
|
||||||
|
"access_key_secret": "access_key_secret",
|
||||||
|
"ram_role_arn": "ram_role_arn",
|
||||||
|
"ram_session_name": "ram_session_name",
|
||||||
|
"expired_seconds": 3600,
|
||||||
|
"sts_region": "cn-hangzhou"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "EcsRamRole",
|
||||||
|
"mode": "EcsRamRole",
|
||||||
|
"ram_role_name": "ram_role_name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "OIDC",
|
||||||
|
"mode": "OIDC",
|
||||||
|
"ram_role_arn": "ram_role_arn",
|
||||||
|
"oidc_token_file": "path/to/oidc/file",
|
||||||
|
"oidc_provider_arn": "oidc_provider_arn",
|
||||||
|
"ram_session_name": "ram_session_name",
|
||||||
|
"expired_seconds": 3600,
|
||||||
|
"sts_region": "cn-hangzhou"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ChainableRamRoleArn",
|
||||||
|
"mode": "ChainableRamRoleArn",
|
||||||
|
"source_profile": "AK",
|
||||||
|
"ram_role_arn": "ram_role_arn",
|
||||||
|
"ram_session_name": "ram_session_name",
|
||||||
|
"expired_seconds": 3600,
|
||||||
|
"sts_region": "cn-hangzhou"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Configuration file
|
||||||
|
>
|
||||||
|
> If the user's home directory has the default file `~/.alibabacloud/credentials` (Windows is `C:\Users\USER_NAME\.alibabacloud\credentials`), the program will automatically create credentials with the specified type and name. You can also specify the configuration file path by configuring the `ALIBABA_CLOUD_CREDENTIALS_FILE` environment variable. If the configuration file exists, the application initializes a Credentials client by using the credential information that is specified by default in the configuration file. You can also configure the `ALIBABA_CLOUD_PROFILE` environment variable to modify the default credential information that is read.
|
||||||
|
|
||||||
|
Configuration example:
|
||||||
|
```ini
|
||||||
|
[default]
|
||||||
|
type = access_key # Authentication method is access_key
|
||||||
|
access_key_id = foo # Key
|
||||||
|
access_key_secret = bar # Secret
|
||||||
|
|
||||||
|
[project1]
|
||||||
|
type = ecs_ram_role # Authentication method is ecs_ram_role
|
||||||
|
role_name = EcsRamRoleTest # Role name, optional. It will be retrieved automatically if not set. It is highly recommended to set it up to reduce requests.
|
||||||
|
|
||||||
|
[project2]
|
||||||
|
type = ram_role_arn # Authentication method is ram_role_arn
|
||||||
|
access_key_id = foo
|
||||||
|
access_key_secret = bar
|
||||||
|
role_arn = role_arn
|
||||||
|
role_session_name = session_name
|
||||||
|
|
||||||
|
[project3]
|
||||||
|
type=oidc_role_arn # Authentication method is oidc_role_arn
|
||||||
|
oidc_provider_arn=oidc_provider_arn
|
||||||
|
oidc_token_file_path=oidc_token_file_path
|
||||||
|
role_arn=role_arn
|
||||||
|
role_session_name=session_name
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Instance RAM role
|
||||||
|
|
||||||
|
If there is no credential information with a higher priority, the Credentials tool will obtain the value of ALIBABA_CLOUD_ECS_METADATA (ECS instance RAM role name) through the environment variable. If the value of this variable exists, the program will use the hardened mode (IMDSv2) to access the metadata service (Meta Data Server) of ECS to obtain the STS Token of the ECS instance RAM role as the default credential information. If an exception occurs when using the hardened mode, the normal mode will be used as a fallback to obtain access credentials. You can also set the environment variable ALIBABA_CLOUD_IMDSV1_DISABLED to perform different exception handling logic:
|
||||||
|
|
||||||
|
- When the value is false, the normal mode will continue to obtain access credentials.
|
||||||
|
|
||||||
|
- When the value is true, it means that only the hardened mode can be used to obtain access credentials, and an exception will be thrown.
|
||||||
|
|
||||||
|
Whether the server supports IMDSv2 depends on your configuration on the server.
|
||||||
|
|
||||||
|
### 6. Using External Service Credentials URI
|
||||||
|
|
||||||
|
If there are no higher-priority credential information, the Credentials tool will obtain the `ALIBABA_CLOUD_CREDENTIALS_URI` from the environment variables. If it exists, the program will request the URI address to obtain temporary security credentials as the default credential information.
|
||||||
|
|
||||||
|
The external service response structure should be as follows:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Code": "Success",
|
||||||
|
"AccessKeyId": "AccessKeyId",
|
||||||
|
"AccessKeySecret": "AccessKeySecret",
|
||||||
|
"SecurityToken": "SecurityToken",
|
||||||
|
"Expiration": "2024-10-26T03:46:38Z"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
* [Prerequisites](/docs/zh-CN/0-Prerequisites.md)
|
||||||
|
* [Installation](/docs/zh-CN/1-Installation.md)
|
||||||
|
|
||||||
|
## Issue
|
||||||
|
|
||||||
|
[Submit Issue](https://github.com/aliyun/credentials-php/issues/new/choose), Problems that do not meet the guidelines may close immediately.
|
||||||
|
|
||||||
|
## Release notes
|
||||||
|
|
||||||
|
Detailed changes for each version are recorded in the [Release Notes](/CHANGELOG.md).
|
||||||
|
|
||||||
|
## Contribution
|
||||||
|
|
||||||
|
Please read the [Contribution Guide](/CONTRIBUTING.md) before submitting a Pull Request.
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
* [OpenAPI Developer Portal][open-api]
|
||||||
|
* [Packagist][packagist]
|
||||||
|
* [Composer][composer]
|
||||||
|
* [Guzzle Doc][guzzle-docs]
|
||||||
|
* [Latest Release][latest-release]
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[Apache-2.0](/LICENSE.md)
|
||||||
|
|
||||||
|
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||||
|
|
||||||
|
[open-api]: https://api.alibabacloud.com
|
||||||
|
[latest-release]: https://github.com/aliyun/credentials-php
|
||||||
|
[guzzle-docs]: http://docs.guzzlephp.org/en/stable/request-options.html
|
||||||
|
[composer]: https://getcomposer.org
|
||||||
|
[packagist]: https://packagist.org/packages/alibabacloud/credentials
|
||||||
21
vendor/alibabacloud/credentials/SECURITY.md
vendored
Normal file
21
vendor/alibabacloud/credentials/SECURITY.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
Use this section to tell people about which versions of your project are
|
||||||
|
currently being supported with security updates.
|
||||||
|
|
||||||
|
| Version | Supported |
|
||||||
|
| ------- | ------------------ |
|
||||||
|
| 5.1.x | :white_check_mark: |
|
||||||
|
| 5.0.x | :x: |
|
||||||
|
| 4.0.x | :white_check_mark: |
|
||||||
|
| < 4.0 | :x: |
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
Use this section to tell people how to report a vulnerability.
|
||||||
|
|
||||||
|
Tell them where to go, how often they can expect to get an update on a
|
||||||
|
reported vulnerability, what to expect if the vulnerability is accepted or
|
||||||
|
declined, etc.
|
||||||
6
vendor/alibabacloud/credentials/UPGRADING.md
vendored
Normal file
6
vendor/alibabacloud/credentials/UPGRADING.md
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Upgrading Guide
|
||||||
|
===============
|
||||||
|
|
||||||
|
1.x
|
||||||
|
-----------------------
|
||||||
|
- This is the first version. See <https://github.com/aliyun/credentials-php> for more information.
|
||||||
107
vendor/alibabacloud/credentials/composer.json
vendored
Normal file
107
vendor/alibabacloud/credentials/composer.json
vendored
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
{
|
||||||
|
"name": "alibabacloud/credentials",
|
||||||
|
"homepage": "https://www.alibabacloud.com/",
|
||||||
|
"description": "Alibaba Cloud Credentials for PHP",
|
||||||
|
"keywords": [
|
||||||
|
"sdk",
|
||||||
|
"tool",
|
||||||
|
"cloud",
|
||||||
|
"client",
|
||||||
|
"aliyun",
|
||||||
|
"library",
|
||||||
|
"alibaba",
|
||||||
|
"Credentials",
|
||||||
|
"alibabacloud"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/aliyun/credentials-php",
|
||||||
|
"issues": "https://github.com/aliyun/credentials-php/issues"
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Alibaba Cloud SDK",
|
||||||
|
"email": "sdk-team@alibabacloud.com",
|
||||||
|
"homepage": "http://www.alibabacloud.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.6",
|
||||||
|
"ext-curl": "*",
|
||||||
|
"ext-json": "*",
|
||||||
|
"ext-libxml": "*",
|
||||||
|
"ext-openssl": "*",
|
||||||
|
"ext-mbstring": "*",
|
||||||
|
"ext-simplexml": "*",
|
||||||
|
"ext-xmlwriter": "*",
|
||||||
|
"guzzlehttp/guzzle": "^6.3|^7.0",
|
||||||
|
"adbario/php-dot-notation": "^2.2",
|
||||||
|
"alibabacloud/tea": "^3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"ext-spl": "*",
|
||||||
|
"ext-dom": "*",
|
||||||
|
"ext-pcre": "*",
|
||||||
|
"psr/cache": "^1.0",
|
||||||
|
"ext-sockets": "*",
|
||||||
|
"drupal/coder": "^8.3",
|
||||||
|
"symfony/dotenv": "^3.4",
|
||||||
|
"phpunit/phpunit": "^5.7|^6.6|^9.3",
|
||||||
|
"monolog/monolog": "^1.24",
|
||||||
|
"composer/composer": "^1.8",
|
||||||
|
"mikey179/vfsstream": "^1.6",
|
||||||
|
"symfony/var-dumper": "^3.4"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-sockets": "To use client-side monitoring"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"AlibabaCloud\\Credentials\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"AlibabaCloud\\Credentials\\Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"preferred-install": "dist",
|
||||||
|
"optimize-autoloader": true,
|
||||||
|
"allow-plugins": {
|
||||||
|
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true,
|
||||||
|
"scripts-descriptions": {
|
||||||
|
"cs": "Tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard.",
|
||||||
|
"cbf": "Automatically correct coding standard violations.",
|
||||||
|
"fixer": "Fixes code to follow standards.",
|
||||||
|
"test": "Run all tests.",
|
||||||
|
"unit": "Run Unit tests.",
|
||||||
|
"feature": "Run Feature tests.",
|
||||||
|
"clearCache": "Clear cache like coverage.",
|
||||||
|
"coverage": "Show Coverage html.",
|
||||||
|
"endpoints": "Update endpoints from OSS."
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"cs": "phpcs --standard=PSR2 -n ./",
|
||||||
|
"cbf": "phpcbf --standard=PSR2 -n ./",
|
||||||
|
"fixer": "php-cs-fixer fix ./",
|
||||||
|
"test": [
|
||||||
|
"phpunit --colors=always"
|
||||||
|
],
|
||||||
|
"unit": [
|
||||||
|
"@clearCache",
|
||||||
|
"phpunit --testsuite=Unit --colors=always"
|
||||||
|
],
|
||||||
|
"feature": [
|
||||||
|
"@clearCache",
|
||||||
|
"phpunit --testsuite=Feature --colors=always"
|
||||||
|
],
|
||||||
|
"coverage": "open cache/coverage/index.html",
|
||||||
|
"clearCache": "rm -rf cache/*"
|
||||||
|
}
|
||||||
|
}
|
||||||
86
vendor/alibabacloud/credentials/src/AccessKeyCredential.php
vendored
Normal file
86
vendor/alibabacloud/credentials/src/AccessKeyCredential.php
vendored
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Utils\Filter;
|
||||||
|
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||||
|
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Use the AccessKey to complete the authentication.
|
||||||
|
*/
|
||||||
|
class AccessKeyCredential implements CredentialsInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $accessKeyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $accessKeySecret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccessKeyCredential constructor.
|
||||||
|
*
|
||||||
|
* @param string $access_key_id Access key ID
|
||||||
|
* @param string $access_key_secret Access Key Secret
|
||||||
|
*/
|
||||||
|
public function __construct($access_key_id, $access_key_secret)
|
||||||
|
{
|
||||||
|
Filter::accessKey($access_key_id, $access_key_secret);
|
||||||
|
|
||||||
|
$this->accessKeyId = $access_key_id;
|
||||||
|
$this->accessKeySecret = $access_key_secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAccessKeyId()
|
||||||
|
{
|
||||||
|
return $this->accessKeyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAccessKeySecret()
|
||||||
|
{
|
||||||
|
return $this->accessKeySecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return "$this->accessKeyId#$this->accessKeySecret";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ShaHmac1Signature
|
||||||
|
*/
|
||||||
|
public function getSignature()
|
||||||
|
{
|
||||||
|
return new ShaHmac1Signature();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSecurityToken()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getCredential()
|
||||||
|
{
|
||||||
|
return new CredentialModel([
|
||||||
|
'accessKeyId' => $this->accessKeyId,
|
||||||
|
'accessKeySecret' => $this->accessKeySecret,
|
||||||
|
'type' => 'access_key',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
67
vendor/alibabacloud/credentials/src/BearerTokenCredential.php
vendored
Normal file
67
vendor/alibabacloud/credentials/src/BearerTokenCredential.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Utils\Filter;
|
||||||
|
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||||
|
use AlibabaCloud\Credentials\Signature\BearerTokenSignature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class BearerTokenCredential
|
||||||
|
*/
|
||||||
|
class BearerTokenCredential implements CredentialsInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $bearerToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BearerTokenCredential constructor.
|
||||||
|
*
|
||||||
|
* @param $bearer_token
|
||||||
|
*/
|
||||||
|
public function __construct($bearer_token)
|
||||||
|
{
|
||||||
|
Filter::bearerToken($bearer_token);
|
||||||
|
|
||||||
|
$this->bearerToken = $bearer_token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBearerToken()
|
||||||
|
{
|
||||||
|
return $this->bearerToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return "bearerToken#$this->bearerToken";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return BearerTokenSignature
|
||||||
|
*/
|
||||||
|
public function getSignature()
|
||||||
|
{
|
||||||
|
return new BearerTokenSignature();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getCredential()
|
||||||
|
{
|
||||||
|
return new CredentialModel([
|
||||||
|
'bearerToken' => $this->bearerToken,
|
||||||
|
'type' => 'bearer',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
268
vendor/alibabacloud/credentials/src/Credential.php
vendored
Normal file
268
vendor/alibabacloud/credentials/src/Credential.php
vendored
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential\Config;
|
||||||
|
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||||
|
use AlibabaCloud\Credentials\Providers\DefaultCredentialsProvider;
|
||||||
|
use AlibabaCloud\Credentials\Providers\EcsRamRoleCredentialsProvider;
|
||||||
|
use AlibabaCloud\Credentials\Providers\OIDCRoleArnCredentialsProvider;
|
||||||
|
use AlibabaCloud\Credentials\Providers\RamRoleArnCredentialsProvider;
|
||||||
|
use AlibabaCloud\Credentials\Providers\RsaKeyPairCredentialsProvider;
|
||||||
|
use AlibabaCloud\Credentials\Providers\StaticAKCredentialsProvider;
|
||||||
|
use AlibabaCloud\Credentials\Providers\StaticSTSCredentialsProvider;
|
||||||
|
use AlibabaCloud\Credentials\Providers\URLCredentialsProvider;
|
||||||
|
use AlibabaCloud\Credentials\Utils\Helper;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Credential
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Credential
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version of the Client
|
||||||
|
*/
|
||||||
|
const VERSION = '1.1.5';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Config
|
||||||
|
*/
|
||||||
|
protected $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var CredentialsInterface
|
||||||
|
*/
|
||||||
|
protected $credential;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Credential constructor.
|
||||||
|
*
|
||||||
|
* @param array|Config $config
|
||||||
|
*/
|
||||||
|
public function __construct($config = [])
|
||||||
|
{
|
||||||
|
if (\is_array($config)) {
|
||||||
|
if (empty($config)) {
|
||||||
|
$this->config = null;
|
||||||
|
} else {
|
||||||
|
$this->config = new Config($this->parseConfig($config));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->config = $config;
|
||||||
|
}
|
||||||
|
$this->credential = $this->getCredentials($this->config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $config
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function parseConfig($config)
|
||||||
|
{
|
||||||
|
$res = [];
|
||||||
|
foreach (\array_change_key_case($config) as $key => $value) {
|
||||||
|
$res[Helper::snakeToCamelCase($key)] = $value;
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Credentials getter.
|
||||||
|
*
|
||||||
|
* @param Config $config
|
||||||
|
* @return CredentialsInterface
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function getCredentials($config)
|
||||||
|
{
|
||||||
|
if (is_null($config)) {
|
||||||
|
return new CredentialsProviderWrap('default', new DefaultCredentialsProvider());
|
||||||
|
}
|
||||||
|
switch ($config->type) {
|
||||||
|
case 'access_key':
|
||||||
|
$provider = new StaticAKCredentialsProvider([
|
||||||
|
'accessKeyId' => $config->accessKeyId,
|
||||||
|
'accessKeySecret' => $config->accessKeySecret,
|
||||||
|
]);
|
||||||
|
return new CredentialsProviderWrap('access_key', $provider);
|
||||||
|
case 'sts':
|
||||||
|
$provider = new StaticSTSCredentialsProvider([
|
||||||
|
'accessKeyId' => $config->accessKeyId,
|
||||||
|
'accessKeySecret' => $config->accessKeySecret,
|
||||||
|
'securityToken' => $config->securityToken,
|
||||||
|
]);
|
||||||
|
return new CredentialsProviderWrap('sts', $provider);
|
||||||
|
case 'bearer':
|
||||||
|
return new BearerTokenCredential($config->bearerToken);
|
||||||
|
case 'ram_role_arn':
|
||||||
|
if (!is_null($config->securityToken) && $config->securityToken !== '') {
|
||||||
|
$innerProvider = new StaticSTSCredentialsProvider([
|
||||||
|
'accessKeyId' => $config->accessKeyId,
|
||||||
|
'accessKeySecret' => $config->accessKeySecret,
|
||||||
|
'securityToken' => $config->securityToken,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$innerProvider = new StaticAKCredentialsProvider([
|
||||||
|
'accessKeyId' => $config->accessKeyId,
|
||||||
|
'accessKeySecret' => $config->accessKeySecret,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$provider = new RamRoleArnCredentialsProvider([
|
||||||
|
'credentialsProvider' => $innerProvider,
|
||||||
|
'roleArn' => $config->roleArn,
|
||||||
|
'roleSessionName' => $config->roleSessionName,
|
||||||
|
'policy' => $config->policy,
|
||||||
|
'durationSeconds' => $config->roleSessionExpiration,
|
||||||
|
'externalId' => $config->externalId,
|
||||||
|
'stsEndpoint' => $config->STSEndpoint,
|
||||||
|
], [
|
||||||
|
'connectTimeout' => $config->connectTimeout,
|
||||||
|
'readTimeout' => $config->readTimeout,
|
||||||
|
]);
|
||||||
|
return new CredentialsProviderWrap('ram_role_arn', $provider);
|
||||||
|
case 'rsa_key_pair':
|
||||||
|
$provider = new RsaKeyPairCredentialsProvider([
|
||||||
|
'publicKeyId' => $config->publicKeyId,
|
||||||
|
'privateKeyFile' => $config->privateKeyFile,
|
||||||
|
'durationSeconds' => $config->roleSessionExpiration,
|
||||||
|
'stsEndpoint' => $config->STSEndpoint,
|
||||||
|
], [
|
||||||
|
'connectTimeout' => $config->connectTimeout,
|
||||||
|
'readTimeout' => $config->readTimeout,
|
||||||
|
]);
|
||||||
|
return new CredentialsProviderWrap('rsa_key_pair', $provider);
|
||||||
|
case 'ecs_ram_role':
|
||||||
|
$provider = new EcsRamRoleCredentialsProvider([
|
||||||
|
'roleName' => $config->roleName,
|
||||||
|
'disableIMDSv1' => $config->disableIMDSv1,
|
||||||
|
], [
|
||||||
|
'connectTimeout' => $config->connectTimeout,
|
||||||
|
'readTimeout' => $config->readTimeout,
|
||||||
|
]);
|
||||||
|
return new CredentialsProviderWrap('ecs_ram_role', $provider);
|
||||||
|
case 'oidc_role_arn':
|
||||||
|
$provider = new OIDCRoleArnCredentialsProvider([
|
||||||
|
'roleArn' => $config->roleArn,
|
||||||
|
'oidcProviderArn' => $config->oidcProviderArn,
|
||||||
|
'oidcTokenFilePath' => $config->oidcTokenFilePath,
|
||||||
|
'roleSessionName' => $config->roleSessionName,
|
||||||
|
'policy' => $config->policy,
|
||||||
|
'durationSeconds' => $config->roleSessionExpiration,
|
||||||
|
'stsEndpoint' => $config->STSEndpoint,
|
||||||
|
], [
|
||||||
|
'connectTimeout' => $config->connectTimeout,
|
||||||
|
'readTimeout' => $config->readTimeout,
|
||||||
|
]);
|
||||||
|
return new CredentialsProviderWrap('oidc_role_arn', $provider);
|
||||||
|
case "credentials_uri":
|
||||||
|
$provider = new URLCredentialsProvider([
|
||||||
|
'credentialsURI' => $config->credentialsURI,
|
||||||
|
], [
|
||||||
|
'connectTimeout' => $config->connectTimeout,
|
||||||
|
'readTimeout' => $config->readTimeout,
|
||||||
|
]);
|
||||||
|
return new CredentialsProviderWrap('credentials_uri', $provider);
|
||||||
|
default:
|
||||||
|
throw new InvalidArgumentException('Unsupported credential type option: ' . $config->type . ', support: access_key, sts, bearer, ecs_ram_role, ram_role_arn, rsa_key_pair, oidc_role_arn, credentials_uri');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return CredentialModel
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function getCredential()
|
||||||
|
{
|
||||||
|
return $this->credential->getCredential();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getConfig()
|
||||||
|
{
|
||||||
|
return $this->config->toMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use getCredential() instead
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function getType()
|
||||||
|
{
|
||||||
|
return $this->credential->getCredential()->getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use getCredential() instead
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function getAccessKeyId()
|
||||||
|
{
|
||||||
|
return $this->credential->getCredential()->getAccessKeyId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use getCredential() instead
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function getAccessKeySecret()
|
||||||
|
{
|
||||||
|
return $this->credential->getCredential()->getAccessKeySecret();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use getCredential() instead
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function getSecurityToken()
|
||||||
|
{
|
||||||
|
return $this->credential->getCredential()->getSecurityToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use getCredential() instead
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function getBearerToken()
|
||||||
|
{
|
||||||
|
return $this->credential->getCredential()->getBearerToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @param array $arguments
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function __call($name, $arguments)
|
||||||
|
{
|
||||||
|
return $this->credential->$name($arguments);
|
||||||
|
}
|
||||||
|
}
|
||||||
270
vendor/alibabacloud/credentials/src/Credential/Config.php
vendored
Normal file
270
vendor/alibabacloud/credentials/src/Credential/Config.php
vendored
Normal file
@@ -0,0 +1,270 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Credential;
|
||||||
|
|
||||||
|
use AlibabaCloud\Tea\Model;
|
||||||
|
|
||||||
|
class Config extends Model
|
||||||
|
{
|
||||||
|
public function validate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public function toMap()
|
||||||
|
{
|
||||||
|
$res = [];
|
||||||
|
if (null !== $this->accessKeyId) {
|
||||||
|
$res['accessKeyId'] = $this->accessKeyId;
|
||||||
|
}
|
||||||
|
if (null !== $this->accessKeySecret) {
|
||||||
|
$res['accessKeySecret'] = $this->accessKeySecret;
|
||||||
|
}
|
||||||
|
if (null !== $this->securityToken) {
|
||||||
|
$res['securityToken'] = $this->securityToken;
|
||||||
|
}
|
||||||
|
if (null !== $this->bearerToken) {
|
||||||
|
$res['bearerToken'] = $this->bearerToken;
|
||||||
|
}
|
||||||
|
if (null !== $this->durationSeconds) {
|
||||||
|
$res['durationSeconds'] = $this->durationSeconds;
|
||||||
|
}
|
||||||
|
if (null !== $this->roleArn) {
|
||||||
|
$res['roleArn'] = $this->roleArn;
|
||||||
|
}
|
||||||
|
if (null !== $this->policy) {
|
||||||
|
$res['policy'] = $this->policy;
|
||||||
|
}
|
||||||
|
if (null !== $this->roleSessionExpiration) {
|
||||||
|
$res['roleSessionExpiration'] = $this->roleSessionExpiration;
|
||||||
|
}
|
||||||
|
if (null !== $this->roleSessionName) {
|
||||||
|
$res['roleSessionName'] = $this->roleSessionName;
|
||||||
|
}
|
||||||
|
if (null !== $this->publicKeyId) {
|
||||||
|
$res['publicKeyId'] = $this->publicKeyId;
|
||||||
|
}
|
||||||
|
if (null !== $this->privateKeyFile) {
|
||||||
|
$res['privateKeyFile'] = $this->privateKeyFile;
|
||||||
|
}
|
||||||
|
if (null !== $this->roleName) {
|
||||||
|
$res['roleName'] = $this->roleName;
|
||||||
|
}
|
||||||
|
if (null !== $this->credentialsURI) {
|
||||||
|
$res['credentialsURI'] = $this->credentialsURI;
|
||||||
|
}
|
||||||
|
if (null !== $this->type) {
|
||||||
|
$res['type'] = $this->type;
|
||||||
|
}
|
||||||
|
if (null !== $this->STSEndpoint) {
|
||||||
|
$res['STSEndpoint'] = $this->STSEndpoint;
|
||||||
|
}
|
||||||
|
if (null !== $this->externalId) {
|
||||||
|
$res['externalId'] = $this->externalId;
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param array $map
|
||||||
|
* @return Config
|
||||||
|
*/
|
||||||
|
public static function fromMap($map = [])
|
||||||
|
{
|
||||||
|
$model = new self();
|
||||||
|
if (isset($map['accessKeyId'])) {
|
||||||
|
$model->accessKeyId = $map['accessKeyId'];
|
||||||
|
}
|
||||||
|
if (isset($map['accessKeySecret'])) {
|
||||||
|
$model->accessKeySecret = $map['accessKeySecret'];
|
||||||
|
}
|
||||||
|
if (isset($map['securityToken'])) {
|
||||||
|
$model->securityToken = $map['securityToken'];
|
||||||
|
}
|
||||||
|
if (isset($map['bearerToken'])) {
|
||||||
|
$model->bearerToken = $map['bearerToken'];
|
||||||
|
}
|
||||||
|
if (isset($map['durationSeconds'])) {
|
||||||
|
$model->durationSeconds = $map['durationSeconds'];
|
||||||
|
}
|
||||||
|
if (isset($map['roleArn'])) {
|
||||||
|
$model->roleArn = $map['roleArn'];
|
||||||
|
}
|
||||||
|
if (isset($map['policy'])) {
|
||||||
|
$model->policy = $map['policy'];
|
||||||
|
}
|
||||||
|
if (isset($map['roleSessionExpiration'])) {
|
||||||
|
$model->roleSessionExpiration = $map['roleSessionExpiration'];
|
||||||
|
}
|
||||||
|
if (isset($map['roleSessionName'])) {
|
||||||
|
$model->roleSessionName = $map['roleSessionName'];
|
||||||
|
}
|
||||||
|
if (isset($map['publicKeyId'])) {
|
||||||
|
$model->publicKeyId = $map['publicKeyId'];
|
||||||
|
}
|
||||||
|
if (isset($map['privateKeyFile'])) {
|
||||||
|
$model->privateKeyFile = $map['privateKeyFile'];
|
||||||
|
}
|
||||||
|
if (isset($map['roleName'])) {
|
||||||
|
$model->roleName = $map['roleName'];
|
||||||
|
}
|
||||||
|
if (isset($map['credentialsURI'])) {
|
||||||
|
$model->credentialsURI = $map['credentialsURI'];
|
||||||
|
}
|
||||||
|
if (isset($map['type'])) {
|
||||||
|
$model->type = $map['type'];
|
||||||
|
}
|
||||||
|
if (isset($map['STSEndpoint'])) {
|
||||||
|
$model->STSEndpoint = $map['STSEndpoint'];
|
||||||
|
}
|
||||||
|
if (isset($map['externalId'])) {
|
||||||
|
$model->externalId = $map['externalId'];
|
||||||
|
}
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description credential type
|
||||||
|
* @example access_key
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $type = 'default';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description accesskey id
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $accessKeyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description accesskey secret
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $accessKeySecret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description security token
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $securityToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description bearer token
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $bearerToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description role name
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $roleName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description role arn
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $roleArn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description oidc provider arn
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $oidcProviderArn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description oidc token file path
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $oidcTokenFilePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description role session expiration
|
||||||
|
* @example 3600
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $roleSessionExpiration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description role session name
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $roleSessionName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description role arn policy
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $policy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description external id for ram role arn
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $externalId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description sts endpoint
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $STSEndpoint;
|
||||||
|
|
||||||
|
public $publicKeyId;
|
||||||
|
|
||||||
|
public $privateKeyFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description read timeout
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $readTimeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description connection timeout
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $connectTimeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description disable IMDS v1
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $disableIMDSv1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description credentials URI
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $credentialsURI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public $metadataTokenDuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public $durationSeconds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public $host;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public $expiration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public $certFile = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public $certPassword = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
public $proxy;
|
||||||
|
}
|
||||||
143
vendor/alibabacloud/credentials/src/Credential/CredentialModel.php
vendored
Normal file
143
vendor/alibabacloud/credentials/src/Credential/CredentialModel.php
vendored
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// This file is auto-generated, don't edit it. Thanks.
|
||||||
|
namespace AlibabaCloud\Credentials\Credential;
|
||||||
|
|
||||||
|
use AlibabaCloud\Tea\Model;
|
||||||
|
|
||||||
|
class CredentialModel extends Model
|
||||||
|
{
|
||||||
|
public function validate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public function toMap()
|
||||||
|
{
|
||||||
|
$res = [];
|
||||||
|
if (null !== $this->accessKeyId) {
|
||||||
|
$res['accessKeyId'] = $this->accessKeyId;
|
||||||
|
}
|
||||||
|
if (null !== $this->accessKeySecret) {
|
||||||
|
$res['accessKeySecret'] = $this->accessKeySecret;
|
||||||
|
}
|
||||||
|
if (null !== $this->securityToken) {
|
||||||
|
$res['securityToken'] = $this->securityToken;
|
||||||
|
}
|
||||||
|
if (null !== $this->bearerToken) {
|
||||||
|
$res['bearerToken'] = $this->bearerToken;
|
||||||
|
}
|
||||||
|
if (null !== $this->type) {
|
||||||
|
$res['type'] = $this->type;
|
||||||
|
}
|
||||||
|
if (null !== $this->providerName) {
|
||||||
|
$res['providerName'] = $this->providerName;
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param array $map
|
||||||
|
* @return CredentialModel
|
||||||
|
*/
|
||||||
|
public static function fromMap($map = [])
|
||||||
|
{
|
||||||
|
$model = new self();
|
||||||
|
if (isset($map['accessKeyId'])) {
|
||||||
|
$model->accessKeyId = $map['accessKeyId'];
|
||||||
|
}
|
||||||
|
if (isset($map['accessKeySecret'])) {
|
||||||
|
$model->accessKeySecret = $map['accessKeySecret'];
|
||||||
|
}
|
||||||
|
if (isset($map['securityToken'])) {
|
||||||
|
$model->securityToken = $map['securityToken'];
|
||||||
|
}
|
||||||
|
if (isset($map['bearerToken'])) {
|
||||||
|
$model->bearerToken = $map['bearerToken'];
|
||||||
|
}
|
||||||
|
if (isset($map['type'])) {
|
||||||
|
$model->type = $map['type'];
|
||||||
|
}
|
||||||
|
if(isset($map['providerName'])){
|
||||||
|
$model->providerName = $map['providerName'];
|
||||||
|
}
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description accesskey id
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $accessKeyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description accesskey secret
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $accessKeySecret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description security token
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $securityToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description bearer token
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $bearerToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description type
|
||||||
|
* @example access_key
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description provider name
|
||||||
|
* @example cli_profile/static_ak
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $providerName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAccessKeyId()
|
||||||
|
{
|
||||||
|
return $this->accessKeyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAccessKeySecret()
|
||||||
|
{
|
||||||
|
return $this->accessKeySecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSecurityToken()
|
||||||
|
{
|
||||||
|
return $this->securityToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBearerToken()
|
||||||
|
{
|
||||||
|
return $this->bearerToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getType()
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProviderName()
|
||||||
|
{
|
||||||
|
return $this->providerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
97
vendor/alibabacloud/credentials/src/Credential/RefreshResult.php
vendored
Normal file
97
vendor/alibabacloud/credentials/src/Credential/RefreshResult.php
vendored
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Credential;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Providers\Credentials;
|
||||||
|
|
||||||
|
class RefreshResult
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RefreshResult constructor.
|
||||||
|
* @param Credentials $params
|
||||||
|
* @param int $staleTime
|
||||||
|
* @param int $prefetchTime
|
||||||
|
*/
|
||||||
|
public function __construct($credentials = null, $staleTime = PHP_INT_MAX, $prefetchTime = PHP_INT_MAX)
|
||||||
|
{
|
||||||
|
$this->credentials = $credentials;
|
||||||
|
$this->staleTime = $staleTime;
|
||||||
|
$this->prefetchTime = $prefetchTime;
|
||||||
|
}
|
||||||
|
public function validate() {}
|
||||||
|
public function toMap()
|
||||||
|
{
|
||||||
|
$res = [];
|
||||||
|
if (null !== $this->staleTime) {
|
||||||
|
$res['staleTime'] = $this->staleTime;
|
||||||
|
}
|
||||||
|
if (null !== $this->prefetchTime) {
|
||||||
|
$res['prefetchTime'] = $this->prefetchTime;
|
||||||
|
}
|
||||||
|
if (null !== $this->credentials) {
|
||||||
|
$res['credentials'] = $this->credentials;
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param array $map
|
||||||
|
* @return RefreshResult
|
||||||
|
*/
|
||||||
|
public static function fromMap($map = [])
|
||||||
|
{
|
||||||
|
$model = new self();
|
||||||
|
if (isset($map['staleTime'])) {
|
||||||
|
$model->staleTime = $map['staleTime'];
|
||||||
|
}
|
||||||
|
if (isset($map['prefetchTime'])) {
|
||||||
|
$model->staleTime = $map['prefetchTime'];
|
||||||
|
}
|
||||||
|
if (isset($map['credentials'])) {
|
||||||
|
$model->staleTime = $map['credentials'];
|
||||||
|
}
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description staleTime
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $staleTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description prefetchTime
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $prefetchTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description credentials
|
||||||
|
* @var Credentials
|
||||||
|
*/
|
||||||
|
public $credentials;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Credentials
|
||||||
|
*/
|
||||||
|
public function credentials()
|
||||||
|
{
|
||||||
|
return $this->credentials;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public function staleTime()
|
||||||
|
{
|
||||||
|
return $this->staleTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public function prefetchTime()
|
||||||
|
{
|
||||||
|
return $this->prefetchTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
104
vendor/alibabacloud/credentials/src/Credentials.php
vendored
Normal file
104
vendor/alibabacloud/credentials/src/Credentials.php
vendored
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Providers\ChainProvider;
|
||||||
|
use AlibabaCloud\Credentials\Utils\Filter;
|
||||||
|
use AlibabaCloud\Credentials\Utils\MockTrait;
|
||||||
|
use ReflectionException;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Credentials
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials
|
||||||
|
*/
|
||||||
|
class Credentials
|
||||||
|
{
|
||||||
|
use MockTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array|CredentialsInterface[] containers of credentials
|
||||||
|
*/
|
||||||
|
protected static $credentials = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the credential instance by name.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return Credential
|
||||||
|
* @throws ReflectionException
|
||||||
|
*/
|
||||||
|
public static function get($name = null)
|
||||||
|
{
|
||||||
|
if ($name !== null) {
|
||||||
|
Filter::credentialName($name);
|
||||||
|
} else {
|
||||||
|
$name = ChainProvider::getDefaultName();
|
||||||
|
}
|
||||||
|
|
||||||
|
self::load();
|
||||||
|
|
||||||
|
if (self::has($name)) {
|
||||||
|
return new Credential(self::$credentials[\strtolower($name)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException("Credential '$name' not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function load()
|
||||||
|
{
|
||||||
|
if (self::$credentials) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ChainProvider::hasCustomChain()) {
|
||||||
|
ChainProvider::customProvider(ChainProvider::getDefaultName());
|
||||||
|
} else {
|
||||||
|
ChainProvider::defaultProvider(ChainProvider::getDefaultName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether there is a credential.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function has($name)
|
||||||
|
{
|
||||||
|
Filter::credentialName($name);
|
||||||
|
|
||||||
|
return isset(self::$credentials[\strtolower($name)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function flush()
|
||||||
|
{
|
||||||
|
self::$credentials = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all credentials.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function all()
|
||||||
|
{
|
||||||
|
self::load();
|
||||||
|
|
||||||
|
return self::$credentials;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @param array $credential
|
||||||
|
*/
|
||||||
|
public static function set($name, array $credential)
|
||||||
|
{
|
||||||
|
Filter::credentialName($name);
|
||||||
|
|
||||||
|
self::$credentials[\strtolower($name)] = \array_change_key_case($credential);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
vendor/alibabacloud/credentials/src/CredentialsInterface.php
vendored
Normal file
32
vendor/alibabacloud/credentials/src/CredentialsInterface.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||||
|
use AlibabaCloud\Credentials\Signature\SignatureInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Interface CredentialsInterface
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
interface CredentialsInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function __toString();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @return SignatureInterface
|
||||||
|
*/
|
||||||
|
public function getSignature();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return CredentialModel
|
||||||
|
*/
|
||||||
|
public function getCredential();
|
||||||
|
}
|
||||||
76
vendor/alibabacloud/credentials/src/CredentialsProviderWrap.php
vendored
Normal file
76
vendor/alibabacloud/credentials/src/CredentialsProviderWrap.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||||
|
use AlibabaCloud\Credentials\Providers\CredentialsProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Class CredentialsProviderWrap
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials
|
||||||
|
*/
|
||||||
|
class CredentialsProviderWrap implements CredentialsInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $typeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var CredentialsProvider
|
||||||
|
*/
|
||||||
|
private $credentialsProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CLIProfileCredentialsProvider constructor.
|
||||||
|
*
|
||||||
|
* @param string $typeName
|
||||||
|
* @param CredentialsProvider $credentialsProvider
|
||||||
|
*/
|
||||||
|
public function __construct($typeName, $credentialsProvider)
|
||||||
|
{
|
||||||
|
$this->typeName = $typeName;
|
||||||
|
$this->credentialsProvider = $credentialsProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getCredential()
|
||||||
|
{
|
||||||
|
$credentials = $this->credentialsProvider->getCredentials();
|
||||||
|
return new CredentialModel([
|
||||||
|
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||||
|
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||||
|
'securityToken' => $credentials->getSecurityToken(),
|
||||||
|
'type' => $this->typeName,
|
||||||
|
'providerName' => $credentials->getProviderName(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @param array $arguments
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function __call($name, $arguments)
|
||||||
|
{
|
||||||
|
return $this->credentialsProvider->$name($arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return "credentialsProviderWrap#$this->typeName";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ShaHmac1Signature
|
||||||
|
*/
|
||||||
|
public function getSignature()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
199
vendor/alibabacloud/credentials/src/EcsRamRoleCredential.php
vendored
Normal file
199
vendor/alibabacloud/credentials/src/EcsRamRoleCredential.php
vendored
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Providers\EcsRamRoleCredentialsProvider;
|
||||||
|
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||||
|
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||||
|
use AlibabaCloud\Credentials\Request\Request;
|
||||||
|
use AlibabaCloud\Credentials\Utils\Filter;
|
||||||
|
use Exception;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Use the RAM role of an ECS instance to complete the authentication.
|
||||||
|
*/
|
||||||
|
class EcsRamRoleCredential implements CredentialsInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $roleName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $disableIMDSv1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $metadataTokenDuration;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EcsRamRoleCredential constructor.
|
||||||
|
*
|
||||||
|
* @param $role_name
|
||||||
|
*/
|
||||||
|
public function __construct($role_name = null, $disable_imdsv1 = false, $metadata_token_duration = 21600)
|
||||||
|
{
|
||||||
|
Filter::roleName($role_name);
|
||||||
|
|
||||||
|
$this->roleName = $role_name;
|
||||||
|
|
||||||
|
Filter::disableIMDSv1($disable_imdsv1);
|
||||||
|
|
||||||
|
$this->disableIMDSv1 = $disable_imdsv1;
|
||||||
|
|
||||||
|
$this->metadataTokenDuration = $metadata_token_duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
* @throws GuzzleException
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function getRoleName()
|
||||||
|
{
|
||||||
|
if ($this->roleName !== null) {
|
||||||
|
return $this->roleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->roleName = $this->getRoleNameFromMeta();
|
||||||
|
|
||||||
|
return $this->roleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function getRoleNameFromMeta()
|
||||||
|
{
|
||||||
|
$options = [
|
||||||
|
'http_errors' => false,
|
||||||
|
'timeout' => 1,
|
||||||
|
'connect_timeout' => 1,
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = Request::createClient()->request(
|
||||||
|
'GET',
|
||||||
|
'http://100.100.100.200/latest/meta-data/ram/security-credentials/',
|
||||||
|
$options
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result->getStatusCode() === 404) {
|
||||||
|
throw new InvalidArgumentException('The role name was not found in the instance');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result->getStatusCode() !== 200) {
|
||||||
|
throw new RuntimeException('Error retrieving credentials from result: ' . $result->getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
$role_name = (string) $result;
|
||||||
|
if (!$role_name) {
|
||||||
|
throw new RuntimeException('Error retrieving credentials from result is empty');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $role_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return "roleName#$this->roleName";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ShaHmac1Signature
|
||||||
|
*/
|
||||||
|
public function getSignature()
|
||||||
|
{
|
||||||
|
return new ShaHmac1Signature();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
* @throws Exception
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function getAccessKeyId()
|
||||||
|
{
|
||||||
|
return $this->getSessionCredential()->getAccessKeyId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return AlibabaCloud\Credentials\Providers\Credentials
|
||||||
|
* @throws Exception
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
protected function getSessionCredential()
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
"roleName" => $this->roleName,
|
||||||
|
'disableIMDSv1' => $this->disableIMDSv1,
|
||||||
|
'metadataTokenDuration' => $this->metadataTokenDuration,
|
||||||
|
];
|
||||||
|
return (new EcsRamRoleCredentialsProvider($params))->getCredentials();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
* @throws Exception
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function getAccessKeySecret()
|
||||||
|
{
|
||||||
|
return $this->getSessionCredential()->getAccessKeySecret();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
* @throws Exception
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function getSecurityToken()
|
||||||
|
{
|
||||||
|
return $this->getSessionCredential()->getSecurityToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
* @throws Exception
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function getExpiration()
|
||||||
|
{
|
||||||
|
return $this->getSessionCredential()->getExpiration();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isDisableIMDSv1()
|
||||||
|
{
|
||||||
|
return $this->disableIMDSv1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getCredential()
|
||||||
|
{
|
||||||
|
$credentials = $this->getSessionCredential();
|
||||||
|
return new CredentialModel([
|
||||||
|
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||||
|
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||||
|
'securityToken' => $credentials->getSecurityToken(),
|
||||||
|
'type' => 'ecs_ram_role',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
193
vendor/alibabacloud/credentials/src/Providers/CLIProfileCredentialsProvider.php
vendored
Normal file
193
vendor/alibabacloud/credentials/src/Providers/CLIProfileCredentialsProvider.php
vendored
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Utils\Helper;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Class CLIProfileCredentialsProvider
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials\Providers
|
||||||
|
*/
|
||||||
|
class CLIProfileCredentialsProvider implements CredentialsProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $profileName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var CredentialsProvider
|
||||||
|
*/
|
||||||
|
private $credentialsProvider;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CLIProfileCredentialsProvider constructor.
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
*/
|
||||||
|
public function __construct(array $params = [])
|
||||||
|
{
|
||||||
|
$this->filterProfileName($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterProfileName(array $params)
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_PROFILE')) {
|
||||||
|
$this->profileName = Helper::env('ALIBABA_CLOUD_PROFILE');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['profileName'])) {
|
||||||
|
$this->profileName = $params['profileName'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function shouldReloadCredentialsProvider()
|
||||||
|
{
|
||||||
|
if (is_null($this->credentialsProvider)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return CredentialsProvider
|
||||||
|
*/
|
||||||
|
protected function reloadCredentialsProvider($profileFile, $profileName)
|
||||||
|
{
|
||||||
|
if (!Helper::inOpenBasedir($profileFile)) {
|
||||||
|
throw new RuntimeException('Unable to open credentials file: ' . $profileFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!\is_readable($profileFile) || !\is_file($profileFile)) {
|
||||||
|
throw new RuntimeException('Credentials file is not readable: ' . $profileFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
$jsonContent = \file_get_contents($profileFile);
|
||||||
|
$fileArray = json_decode($jsonContent, true);
|
||||||
|
|
||||||
|
if (\is_array($fileArray) && !empty($fileArray)) {
|
||||||
|
if (is_null($profileName) || $profileName === '') {
|
||||||
|
$profileName = $fileArray['current'];
|
||||||
|
}
|
||||||
|
if (isset($fileArray['profiles'])) {
|
||||||
|
foreach ($fileArray['profiles'] as $profile) {
|
||||||
|
if (Helper::unsetReturnNull($profile, 'name') === $profileName) {
|
||||||
|
switch (Helper::unsetReturnNull($profile, 'mode')) {
|
||||||
|
case 'AK':
|
||||||
|
return new StaticAKCredentialsProvider([
|
||||||
|
'accessKeyId' => Helper::unsetReturnNull($profile, 'access_key_id'),
|
||||||
|
'accessKeySecret' => Helper::unsetReturnNull($profile, 'access_key_secret'),
|
||||||
|
]);
|
||||||
|
case 'StsToken':
|
||||||
|
return new StaticSTSCredentialsProvider([
|
||||||
|
'accessKeyId' => Helper::unsetReturnNull($profile, 'access_key_id'),
|
||||||
|
'accessKeySecret' => Helper::unsetReturnNull($profile, 'access_key_secret'),
|
||||||
|
'securityToken' => Helper::unsetReturnNull($profile, 'sts_token'),
|
||||||
|
]);
|
||||||
|
case 'RamRoleArn':
|
||||||
|
$innerProvider = new StaticAKCredentialsProvider([
|
||||||
|
'accessKeyId' => Helper::unsetReturnNull($profile, 'access_key_id'),
|
||||||
|
'accessKeySecret' => Helper::unsetReturnNull($profile, 'access_key_secret'),
|
||||||
|
]);
|
||||||
|
return new RamRoleArnCredentialsProvider([
|
||||||
|
'credentialsProvider' => $innerProvider,
|
||||||
|
'roleArn' => Helper::unsetReturnNull($profile, 'ram_role_arn'),
|
||||||
|
'roleSessionName' => Helper::unsetReturnNull($profile, 'ram_session_name'),
|
||||||
|
'durationSeconds' => Helper::unsetReturnNull($profile, 'expired_seconds'),
|
||||||
|
'policy' => Helper::unsetReturnNull($profile, 'policy'),
|
||||||
|
'externalId' => Helper::unsetReturnNull($profile, 'external_id'),
|
||||||
|
'stsRegionId' => Helper::unsetReturnNull($profile, 'sts_region'),
|
||||||
|
'enableVpc' => Helper::unsetReturnNull($profile, 'enable_vpc'),
|
||||||
|
]);
|
||||||
|
case 'EcsRamRole':
|
||||||
|
return new EcsRamRoleCredentialsProvider([
|
||||||
|
'roleName' => Helper::unsetReturnNull($profile, 'ram_role_name'),
|
||||||
|
]);
|
||||||
|
case 'OIDC':
|
||||||
|
return new OIDCRoleArnCredentialsProvider([
|
||||||
|
'roleArn' => Helper::unsetReturnNull($profile, 'ram_role_arn'),
|
||||||
|
'oidcProviderArn' => Helper::unsetReturnNull($profile, 'oidc_provider_arn'),
|
||||||
|
'oidcTokenFilePath' => Helper::unsetReturnNull($profile, 'oidc_token_file'),
|
||||||
|
'roleSessionName' => Helper::unsetReturnNull($profile, 'ram_session_name'),
|
||||||
|
'durationSeconds' => Helper::unsetReturnNull($profile, 'expired_seconds'),
|
||||||
|
'policy' => Helper::unsetReturnNull($profile, 'policy'),
|
||||||
|
'stsRegionId' => Helper::unsetReturnNull($profile, 'sts_region'),
|
||||||
|
'enableVpc' => Helper::unsetReturnNull($profile, 'enable_vpc'),
|
||||||
|
]);
|
||||||
|
case 'ChainableRamRoleArn':
|
||||||
|
$previousProvider = $this->reloadCredentialsProvider($profileFile, Helper::unsetReturnNull($profile, 'source_profile'));
|
||||||
|
return new RamRoleArnCredentialsProvider([
|
||||||
|
'credentialsProvider' => $previousProvider,
|
||||||
|
'roleArn' => Helper::unsetReturnNull($profile, 'ram_role_arn'),
|
||||||
|
'roleSessionName' => Helper::unsetReturnNull($profile, 'ram_session_name'),
|
||||||
|
'durationSeconds' => Helper::unsetReturnNull($profile, 'expired_seconds'),
|
||||||
|
'policy' => Helper::unsetReturnNull($profile, 'policy'),
|
||||||
|
'externalId' => Helper::unsetReturnNull($profile, 'external_id'),
|
||||||
|
'stsRegionId' => Helper::unsetReturnNull($profile, 'sts_region'),
|
||||||
|
'enableVpc' => Helper::unsetReturnNull($profile, 'enable_vpc'),
|
||||||
|
]);
|
||||||
|
default:
|
||||||
|
throw new RuntimeException('Unsupported credential mode from CLI credentials file: ' . Helper::unsetReturnNull($profile, 'mode'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException('Failed to get credential from CLI credentials file: ' . $profileFile);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get credential.
|
||||||
|
*
|
||||||
|
* @return Credentials
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
public function getCredentials()
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_CLI_PROFILE_DISABLED') && Helper::env('ALIBABA_CLOUD_CLI_PROFILE_DISABLED') === true) {
|
||||||
|
throw new RuntimeException('CLI credentials file is disabled');
|
||||||
|
}
|
||||||
|
$cliProfileFile = self::getDefaultFile();
|
||||||
|
if ($this->shouldReloadCredentialsProvider()) {
|
||||||
|
$this->credentialsProvider = $this->reloadCredentialsProvider($cliProfileFile, $this->profileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
$credentials = $this->credentialsProvider->getCredentials();
|
||||||
|
return new Credentials([
|
||||||
|
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||||
|
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||||
|
'securityToken' => $credentials->getSecurityToken(),
|
||||||
|
'providerName' => $this->getProviderName() . '/' . $this->credentialsProvider->getProviderName(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default credential file.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getDefaultFile()
|
||||||
|
{
|
||||||
|
return Helper::getHomeDirectory() .
|
||||||
|
DIRECTORY_SEPARATOR .
|
||||||
|
'.aliyun' .
|
||||||
|
DIRECTORY_SEPARATOR .
|
||||||
|
'config.json';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getProviderName()
|
||||||
|
{
|
||||||
|
return 'cli_profile';
|
||||||
|
}
|
||||||
|
}
|
||||||
188
vendor/alibabacloud/credentials/src/Providers/ChainProvider.php
vendored
Normal file
188
vendor/alibabacloud/credentials/src/Providers/ChainProvider.php
vendored
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credentials;
|
||||||
|
use AlibabaCloud\Credentials\Utils\Helper;
|
||||||
|
use Closure;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Class ChainProvider
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials\Providers
|
||||||
|
*/
|
||||||
|
class ChainProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private static $customChains;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param callable ...$providers
|
||||||
|
*/
|
||||||
|
public static function set(...$providers)
|
||||||
|
{
|
||||||
|
if (empty($providers)) {
|
||||||
|
throw new InvalidArgumentException('No providers in chain');
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($providers as $provider) {
|
||||||
|
if (!$provider instanceof Closure) {
|
||||||
|
throw new InvalidArgumentException('Providers must all be Closures');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$customChains = $providers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function hasCustomChain()
|
||||||
|
{
|
||||||
|
return (bool)self::$customChains;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function flush()
|
||||||
|
{
|
||||||
|
self::$customChains = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
*/
|
||||||
|
public static function customProvider($name)
|
||||||
|
{
|
||||||
|
foreach (self::$customChains as $provider) {
|
||||||
|
$provider();
|
||||||
|
|
||||||
|
if (Credentials::has($name)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
*/
|
||||||
|
public static function defaultProvider($name)
|
||||||
|
{
|
||||||
|
$providers = [
|
||||||
|
self::env(),
|
||||||
|
self::ini(),
|
||||||
|
self::instance(),
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($providers as $provider) {
|
||||||
|
$provider();
|
||||||
|
|
||||||
|
if (Credentials::has($name)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Closure
|
||||||
|
*/
|
||||||
|
public static function env()
|
||||||
|
{
|
||||||
|
return static function () {
|
||||||
|
$accessKeyId = Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_ID');
|
||||||
|
$accessKeySecret = Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_SECRET');
|
||||||
|
|
||||||
|
if ($accessKeyId && $accessKeySecret) {
|
||||||
|
Credentials::set(
|
||||||
|
self::getDefaultName(),
|
||||||
|
[
|
||||||
|
'type' => 'access_key',
|
||||||
|
'access_key_id' => $accessKeyId,
|
||||||
|
'access_key_secret' => $accessKeySecret,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getDefaultName()
|
||||||
|
{
|
||||||
|
$name = Helper::envNotEmpty('ALIBABA_CLOUD_PROFILE');
|
||||||
|
|
||||||
|
if ($name) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'default';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Closure
|
||||||
|
*/
|
||||||
|
public static function ini()
|
||||||
|
{
|
||||||
|
return static function () {
|
||||||
|
$filename = Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_FILE');
|
||||||
|
if (!$filename) {
|
||||||
|
$filename = self::getDefaultFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Helper::inOpenBasedir($filename)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filename !== self::getDefaultFile() && (!\is_readable($filename) || !\is_file($filename))) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
'Credentials file is not readable: ' . $filename
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$file_array = \parse_ini_file($filename, true);
|
||||||
|
|
||||||
|
if (\is_array($file_array) && !empty($file_array)) {
|
||||||
|
foreach (\array_change_key_case($file_array) as $name => $configures) {
|
||||||
|
Credentials::set($name, $configures);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default credential file.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getDefaultFile()
|
||||||
|
{
|
||||||
|
return Helper::getHomeDirectory() .
|
||||||
|
DIRECTORY_SEPARATOR .
|
||||||
|
'.alibabacloud' .
|
||||||
|
DIRECTORY_SEPARATOR .
|
||||||
|
'credentials';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Closure
|
||||||
|
*/
|
||||||
|
public static function instance()
|
||||||
|
{
|
||||||
|
return static function () {
|
||||||
|
$instance = Helper::envNotEmpty('ALIBABA_CLOUD_ECS_METADATA');
|
||||||
|
if ($instance) {
|
||||||
|
Credentials::set(
|
||||||
|
self::getDefaultName(),
|
||||||
|
[
|
||||||
|
'type' => 'ecs_ram_role',
|
||||||
|
'role_name' => $instance,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
87
vendor/alibabacloud/credentials/src/Providers/Credentials.php
vendored
Normal file
87
vendor/alibabacloud/credentials/src/Providers/Credentials.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Class Credentials
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials\Providers
|
||||||
|
*/
|
||||||
|
class Credentials
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $accessKeyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $accessKeySecret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $securityToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $expiration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $providerName;
|
||||||
|
|
||||||
|
public function __construct($config = [])
|
||||||
|
{
|
||||||
|
if (!empty($config)) {
|
||||||
|
foreach ($config as $k => $v) {
|
||||||
|
$this->{$k} = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAccessKeyId()
|
||||||
|
{
|
||||||
|
return $this->accessKeyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAccessKeySecret()
|
||||||
|
{
|
||||||
|
return $this->accessKeySecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSecurityToken()
|
||||||
|
{
|
||||||
|
return $this->securityToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getExpiration()
|
||||||
|
{
|
||||||
|
return $this->expiration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getProviderName()
|
||||||
|
{
|
||||||
|
return $this->providerName;
|
||||||
|
}
|
||||||
|
}
|
||||||
24
vendor/alibabacloud/credentials/src/Providers/CredentialsProvider.php
vendored
Normal file
24
vendor/alibabacloud/credentials/src/Providers/CredentialsProvider.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Interface CredentialsInterface
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore
|
||||||
|
*/
|
||||||
|
interface CredentialsProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Credentials
|
||||||
|
*/
|
||||||
|
public function getCredentials();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getProviderName();
|
||||||
|
}
|
||||||
175
vendor/alibabacloud/credentials/src/Providers/DefaultCredentialsProvider.php
vendored
Normal file
175
vendor/alibabacloud/credentials/src/Providers/DefaultCredentialsProvider.php
vendored
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Utils\Filter;
|
||||||
|
use AlibabaCloud\Credentials\Utils\Helper;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use RuntimeException;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Class DefaultCredentialsProvider
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials\Providers
|
||||||
|
*/
|
||||||
|
class DefaultCredentialsProvider implements CredentialsProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private static $defaultProviders = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $reuseLastProviderEnabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var CredentialsProvider
|
||||||
|
*/
|
||||||
|
private $lastUsedCredentialsProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private static $customChain = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefaultCredentialsProvider constructor.
|
||||||
|
* @param array $params
|
||||||
|
*/
|
||||||
|
public function __construct(array $params = [])
|
||||||
|
{
|
||||||
|
$this->filterReuseLastProviderEnabled($params);
|
||||||
|
$this->createDefaultChain();
|
||||||
|
Filter::reuseLastProviderEnabled($this->reuseLastProviderEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterReuseLastProviderEnabled(array $params)
|
||||||
|
{
|
||||||
|
$this->reuseLastProviderEnabled = true;
|
||||||
|
if (isset($params['reuseLastProviderEnabled'])) {
|
||||||
|
$this->reuseLastProviderEnabled = $params['reuseLastProviderEnabled'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createDefaultChain()
|
||||||
|
{
|
||||||
|
self::$defaultProviders = [
|
||||||
|
new EnvironmentVariableCredentialsProvider(),
|
||||||
|
];
|
||||||
|
if (
|
||||||
|
Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_ARN')
|
||||||
|
&& Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_PROVIDER_ARN')
|
||||||
|
&& Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_TOKEN_FILE')
|
||||||
|
) {
|
||||||
|
array_push(
|
||||||
|
self::$defaultProviders,
|
||||||
|
new OIDCRoleArnCredentialsProvider()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
array_push(
|
||||||
|
self::$defaultProviders,
|
||||||
|
new CLIProfileCredentialsProvider()
|
||||||
|
);
|
||||||
|
array_push(
|
||||||
|
self::$defaultProviders,
|
||||||
|
new ProfileCredentialsProvider()
|
||||||
|
);
|
||||||
|
array_push(
|
||||||
|
self::$defaultProviders,
|
||||||
|
new EcsRamRoleCredentialsProvider()
|
||||||
|
);
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_URI')) {
|
||||||
|
array_push(
|
||||||
|
self::$defaultProviders,
|
||||||
|
new URLCredentialsProvider()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param CredentialsProvider ...$providers
|
||||||
|
*/
|
||||||
|
public static function set(...$providers)
|
||||||
|
{
|
||||||
|
if (empty($providers)) {
|
||||||
|
throw new InvalidArgumentException('No providers in chain');
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($providers as $provider) {
|
||||||
|
if (!$provider instanceof CredentialsProvider) {
|
||||||
|
throw new InvalidArgumentException('Providers must all be CredentialsProvider');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$customChain = $providers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function hasCustomChain()
|
||||||
|
{
|
||||||
|
return (bool) self::$customChain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function flush()
|
||||||
|
{
|
||||||
|
self::$customChain = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get credential.
|
||||||
|
*
|
||||||
|
* @return Credentials
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
public function getCredentials()
|
||||||
|
{
|
||||||
|
if ($this->reuseLastProviderEnabled && !is_null($this->lastUsedCredentialsProvider)) {
|
||||||
|
$credentials = $this->lastUsedCredentialsProvider->getCredentials();
|
||||||
|
return new Credentials([
|
||||||
|
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||||
|
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||||
|
'securityToken' => $credentials->getSecurityToken(),
|
||||||
|
'providerName' => $this->getProviderName() . '/' . $this->lastUsedCredentialsProvider->getProviderName(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$providerChain = array_merge(
|
||||||
|
self::$customChain,
|
||||||
|
self::$defaultProviders
|
||||||
|
);
|
||||||
|
|
||||||
|
$exceptionMessages = [];
|
||||||
|
|
||||||
|
foreach ($providerChain as $provider) {
|
||||||
|
try {
|
||||||
|
$credentials = $provider->getCredentials();
|
||||||
|
$this->lastUsedCredentialsProvider = $provider;
|
||||||
|
return new Credentials([
|
||||||
|
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||||
|
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||||
|
'securityToken' => $credentials->getSecurityToken(),
|
||||||
|
'providerName' => $this->getProviderName() . '/' . $provider->getProviderName(),
|
||||||
|
]);
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
array_push($exceptionMessages, basename(str_replace('\\', '/', get_class($provider))) . ': ' . $exception->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException('Unable to load credentials from any of the providers in the chain: ' . implode(', ', $exceptionMessages));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getProviderName()
|
||||||
|
{
|
||||||
|
return "default";
|
||||||
|
}
|
||||||
|
}
|
||||||
276
vendor/alibabacloud/credentials/src/Providers/EcsRamRoleCredentialsProvider.php
vendored
Normal file
276
vendor/alibabacloud/credentials/src/Providers/EcsRamRoleCredentialsProvider.php
vendored
Normal file
@@ -0,0 +1,276 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Utils\Helper;
|
||||||
|
use AlibabaCloud\Credentials\Utils\Filter;
|
||||||
|
use AlibabaCloud\Credentials\Request\Request;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use RuntimeException;
|
||||||
|
use AlibabaCloud\Credentials\Credential\RefreshResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Class EcsRamRoleCredentialsProvider
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials\Providers
|
||||||
|
*/
|
||||||
|
class EcsRamRoleCredentialsProvider extends SessionCredentialsProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $metadataHost = 'http://100.100.100.200';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $ecsUri = '/latest/meta-data/ram/security-credentials/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $metadataTokenUri = '/latest/api/token';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $roleName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $disableIMDSv1 = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $metadataTokenDuration = 21600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $connectTimeout = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $readTimeout = 1;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EcsRamRoleCredentialsProvider constructor.
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
|
public function __construct(array $params = [], array $options = [])
|
||||||
|
{
|
||||||
|
$this->filterOptions($options);
|
||||||
|
$this->filterRoleName($params);
|
||||||
|
$this->filterDisableECSIMDSv1($params);
|
||||||
|
Filter::roleName($this->roleName);
|
||||||
|
Filter::disableIMDSv1($this->disableIMDSv1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterOptions(array $options)
|
||||||
|
{
|
||||||
|
if (isset($options['connectTimeout'])) {
|
||||||
|
$this->connectTimeout = $options['connectTimeout'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['readTimeout'])) {
|
||||||
|
$this->readTimeout = $options['readTimeout'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::timeout($this->connectTimeout, $this->readTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterRoleName(array $params)
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_ECS_METADATA')) {
|
||||||
|
$this->roleName = Helper::env('ALIBABA_CLOUD_ECS_METADATA');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['roleName'])) {
|
||||||
|
$this->roleName = $params['roleName'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterDisableECSIMDSv1($params)
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_IMDSV1_DISABLED')) {
|
||||||
|
$this->disableIMDSv1 = Helper::env('ALIBABA_CLOUD_IMDSV1_DISABLED') === true ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['disableIMDSv1'])) {
|
||||||
|
$this->disableIMDSv1 = $params['disableIMDSv1'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get credentials by request.
|
||||||
|
*
|
||||||
|
* @return RefreshResult
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function refreshCredentials()
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_ECS_METADATA_DISABLED') && Helper::env('ALIBABA_CLOUD_ECS_METADATA_DISABLED') === true) {
|
||||||
|
throw new RuntimeException('IMDS credentials is disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($this->roleName) || $this->roleName === '') {
|
||||||
|
$this->roleName = $this->getRoleNameFromMeta();
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $this->metadataHost . $this->ecsUri . $this->roleName;
|
||||||
|
$options = Request::commonOptions();
|
||||||
|
$options['read_timeout'] = $this->readTimeout;
|
||||||
|
$options['connect_timeout'] = $this->connectTimeout;
|
||||||
|
|
||||||
|
$metadataToken = $this->getMetadataToken();
|
||||||
|
if (!is_null($metadataToken)) {
|
||||||
|
$options['headers']['X-aliyun-ecs-metadata-token'] = $metadataToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = Request::createClient()->request('GET', $url, $options);
|
||||||
|
|
||||||
|
if ($result->getStatusCode() === 404) {
|
||||||
|
throw new InvalidArgumentException('The role was not found in the instance' . (string) $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result->getStatusCode() !== 200) {
|
||||||
|
throw new RuntimeException('Error refreshing credentials from IMDS, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
$credentials = $result->toArray();
|
||||||
|
|
||||||
|
if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken'])) {
|
||||||
|
throw new RuntimeException('Error retrieving credentials from IMDS result:' . $result->toJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($credentials['Code']) || $credentials['Code'] !== 'Success') {
|
||||||
|
throw new RuntimeException('Error retrieving credentials from IMDS result, Code is not Success:' . $result->toJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
return new RefreshResult(new Credentials([
|
||||||
|
'accessKeyId' => $credentials['AccessKeyId'],
|
||||||
|
'accessKeySecret' => $credentials['AccessKeySecret'],
|
||||||
|
'securityToken' => $credentials['SecurityToken'],
|
||||||
|
'expiration' => \strtotime($credentials['Expiration']),
|
||||||
|
'providerName' => $this->getProviderName(),
|
||||||
|
]), $this->getStaleTime(strtotime($credentials["Expiration"])), $this->getPrefetchTime(strtotime($credentials["Expiration"])));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
private function getRoleNameFromMeta()
|
||||||
|
{
|
||||||
|
$options = Request::commonOptions();
|
||||||
|
$options['read_timeout'] = $this->readTimeout;
|
||||||
|
$options['connect_timeout'] = $this->connectTimeout;
|
||||||
|
|
||||||
|
$metadataToken = $this->getMetadataToken();
|
||||||
|
if (!is_null($metadataToken)) {
|
||||||
|
$options['headers']['X-aliyun-ecs-metadata-token'] = $metadataToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = Request::createClient()->request(
|
||||||
|
'GET',
|
||||||
|
'http://100.100.100.200/latest/meta-data/ram/security-credentials/',
|
||||||
|
$options
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result->getStatusCode() === 404) {
|
||||||
|
throw new InvalidArgumentException('The role name was not found in the instance' . (string) $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result->getStatusCode() !== 200) {
|
||||||
|
throw new RuntimeException('Error retrieving role name from result: ' . (string) $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
$role_name = (string) $result;
|
||||||
|
if (!$role_name) {
|
||||||
|
throw new RuntimeException('Error retrieving role name from result is empty');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $role_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get metadata token by request.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
private function getMetadataToken()
|
||||||
|
{
|
||||||
|
$url = $this->metadataHost . $this->metadataTokenUri;
|
||||||
|
$options = Request::commonOptions();
|
||||||
|
$options['read_timeout'] = $this->readTimeout;
|
||||||
|
$options['connect_timeout'] = $this->connectTimeout;
|
||||||
|
$options['headers']['X-aliyun-ecs-metadata-token-ttl-seconds'] = $this->metadataTokenDuration;
|
||||||
|
|
||||||
|
$result = Request::createClient()->request('PUT', $url, $options);
|
||||||
|
|
||||||
|
if ($result->getStatusCode() != 200) {
|
||||||
|
if ($this->disableIMDSv1) {
|
||||||
|
throw new RuntimeException('Failed to get token from ECS Metadata Service. HttpCode= ' . $result->getStatusCode());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (string) $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public function getPrefetchTime($expiration)
|
||||||
|
{
|
||||||
|
return $expiration <= 0 ?
|
||||||
|
time() + (5 * 60) :
|
||||||
|
time() + (60 * 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function key()
|
||||||
|
{
|
||||||
|
return 'ecs_ram_role#roleName#' . $this->roleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getProviderName()
|
||||||
|
{
|
||||||
|
return 'ecs_ram_role';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRoleName()
|
||||||
|
{
|
||||||
|
return $this->roleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isDisableIMDSv1()
|
||||||
|
{
|
||||||
|
return $this->disableIMDSv1;
|
||||||
|
}
|
||||||
|
}
|
||||||
65
vendor/alibabacloud/credentials/src/Providers/EnvironmentVariableCredentialsProvider.php
vendored
Normal file
65
vendor/alibabacloud/credentials/src/Providers/EnvironmentVariableCredentialsProvider.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Utils\Helper;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Class EnvironmentVariableCredentialsProvider
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials\Providers
|
||||||
|
*/
|
||||||
|
class EnvironmentVariableCredentialsProvider implements CredentialsProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* EnvironmentVariableCredentialsProvider constructor.
|
||||||
|
*/
|
||||||
|
public function __construct() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get credential.
|
||||||
|
*
|
||||||
|
* @return Credentials
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function getCredentials()
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_ID')) {
|
||||||
|
$accessKeyId = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_ID');
|
||||||
|
} else {
|
||||||
|
throw new InvalidArgumentException('Access key ID must be specified via environment variable (ALIBABA_CLOUD_ACCESS_KEY_ID)');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_SECRET')) {
|
||||||
|
$accessKeySecret = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_SECRET');
|
||||||
|
} else {
|
||||||
|
throw new InvalidArgumentException('Access key Secret must be specified via environment variable (ALIBABA_CLOUD_ACCESS_KEY_SECRET)');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_SECURITY_TOKEN')) {
|
||||||
|
$securityToken = Helper::env('ALIBABA_CLOUD_SECURITY_TOKEN');
|
||||||
|
return new Credentials([
|
||||||
|
'accessKeyId' => $accessKeyId,
|
||||||
|
'accessKeySecret' => $accessKeySecret,
|
||||||
|
'securityToken' => $securityToken,
|
||||||
|
'providerName' => $this->getProviderName(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Credentials([
|
||||||
|
'accessKeyId' => $accessKeyId,
|
||||||
|
'accessKeySecret' => $accessKeySecret,
|
||||||
|
'providerName' => $this->getProviderName(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getProviderName()
|
||||||
|
{
|
||||||
|
return "env";
|
||||||
|
}
|
||||||
|
}
|
||||||
268
vendor/alibabacloud/credentials/src/Providers/OIDCRoleArnCredentialsProvider.php
vendored
Normal file
268
vendor/alibabacloud/credentials/src/Providers/OIDCRoleArnCredentialsProvider.php
vendored
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Utils\Helper;
|
||||||
|
use AlibabaCloud\Credentials\Utils\Filter;
|
||||||
|
use AlibabaCloud\Credentials\Request\Request;
|
||||||
|
use GuzzleHttp\Psr7\Uri;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use RuntimeException;
|
||||||
|
use Exception;
|
||||||
|
use AlibabaCloud\Credentials\Credential\RefreshResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Class OIDCRoleArnCredentialsProvider
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials\Providers
|
||||||
|
*/
|
||||||
|
class OIDCRoleArnCredentialsProvider extends SessionCredentialsProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $roleArn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $oidcProviderArn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $oidcTokenFilePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $roleSessionName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description role session expiration
|
||||||
|
* @example 3600
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $durationSeconds = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $policy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $stsEndpoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $connectTimeout = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $readTimeout = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OIDCRoleArnCredentialsProvider constructor.
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
|
public function __construct(array $params = [], array $options = [])
|
||||||
|
{
|
||||||
|
$this->filterOptions($options);
|
||||||
|
$this->filterRoleArn($params);
|
||||||
|
$this->filterOIDCProviderArn($params);
|
||||||
|
$this->filterOIDCTokenFilePath($params);
|
||||||
|
$this->filterRoleSessionName($params);
|
||||||
|
$this->filterDurationSeconds($params);
|
||||||
|
$this->filterPolicy($params);
|
||||||
|
$this->filterSTSEndpoint($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterRoleArn(array $params)
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_ARN')) {
|
||||||
|
$this->roleArn = Helper::env('ALIBABA_CLOUD_ROLE_ARN');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['roleArn'])) {
|
||||||
|
$this->roleArn = $params['roleArn'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::roleArn($this->roleArn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterOIDCProviderArn(array $params)
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_PROVIDER_ARN')) {
|
||||||
|
$this->oidcProviderArn = Helper::env('ALIBABA_CLOUD_OIDC_PROVIDER_ARN');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['oidcProviderArn'])) {
|
||||||
|
$this->oidcProviderArn = $params['oidcProviderArn'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::oidcProviderArn($this->oidcProviderArn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterOIDCTokenFilePath(array $params)
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_TOKEN_FILE')) {
|
||||||
|
$this->oidcTokenFilePath = Helper::env('ALIBABA_CLOUD_OIDC_TOKEN_FILE');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['oidcTokenFilePath'])) {
|
||||||
|
$this->oidcTokenFilePath = $params['oidcTokenFilePath'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::oidcTokenFilePath($this->oidcTokenFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterRoleSessionName(array $params)
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_SESSION_NAME')) {
|
||||||
|
$this->roleSessionName = Helper::env('ALIBABA_CLOUD_ROLE_SESSION_NAME');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['roleSessionName'])) {
|
||||||
|
$this->roleSessionName = $params['roleSessionName'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($this->roleSessionName) || $this->roleSessionName === '') {
|
||||||
|
$this->roleSessionName = 'phpSdkRoleSessionName';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterDurationSeconds(array $params)
|
||||||
|
{
|
||||||
|
if (isset($params['durationSeconds'])) {
|
||||||
|
if (is_int($params['durationSeconds'])) {
|
||||||
|
$this->durationSeconds = $params['durationSeconds'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($this->durationSeconds < 900) {
|
||||||
|
throw new InvalidArgumentException('Role session expiration should be in the range of 900s - max session duration');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterPolicy(array $params)
|
||||||
|
{
|
||||||
|
if (isset($params['policy'])) {
|
||||||
|
if (is_string($params['policy'])) {
|
||||||
|
$this->policy = $params['policy'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($params['policy'])) {
|
||||||
|
$this->policy = json_encode($params['policy']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterSTSEndpoint(array $params)
|
||||||
|
{
|
||||||
|
$prefix = 'sts';
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_VPC_ENDPOINT_ENABLED') || (isset($params['enableVpc']) && $params['enableVpc'] === true)) {
|
||||||
|
$prefix = 'sts-vpc';
|
||||||
|
}
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_STS_REGION')) {
|
||||||
|
$this->stsEndpoint = $prefix . '.' . Helper::env('ALIBABA_CLOUD_STS_REGION') . '.aliyuncs.com';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['stsRegionId'])) {
|
||||||
|
$this->stsEndpoint = $prefix . '.' . $params['stsRegionId'] . '.aliyuncs.com';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['stsEndpoint'])) {
|
||||||
|
$this->stsEndpoint = $params['stsEndpoint'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($this->stsEndpoint) || $this->stsEndpoint === '') {
|
||||||
|
$this->stsEndpoint = 'sts.aliyuncs.com';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterOptions(array $options)
|
||||||
|
{
|
||||||
|
if (isset($options['connectTimeout'])) {
|
||||||
|
$this->connectTimeout = $options['connectTimeout'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['readTimeout'])) {
|
||||||
|
$this->readTimeout = $options['readTimeout'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::timeout($this->connectTimeout, $this->readTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get credentials by request.
|
||||||
|
*
|
||||||
|
* @return RefreshResult
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function refreshCredentials()
|
||||||
|
{
|
||||||
|
$options = Request::commonOptions();
|
||||||
|
$options['read_timeout'] = $this->readTimeout;
|
||||||
|
$options['connect_timeout'] = $this->connectTimeout;
|
||||||
|
|
||||||
|
$options['query']['Action'] = 'AssumeRoleWithOIDC';
|
||||||
|
$options['query']['Version'] = '2015-04-01';
|
||||||
|
$options['query']['Format'] = 'JSON';
|
||||||
|
$options['query']['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
|
||||||
|
$options['query']['RoleArn'] = $this->roleArn;
|
||||||
|
$options['query']['OIDCProviderArn'] = $this->oidcProviderArn;
|
||||||
|
try {
|
||||||
|
$oidcToken = file_get_contents($this->oidcTokenFilePath);
|
||||||
|
$options['query']['OIDCToken'] = $oidcToken;
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
throw new InvalidArgumentException($exception->getMessage());
|
||||||
|
}
|
||||||
|
$options['query']['RoleSessionName'] = $this->roleSessionName;
|
||||||
|
$options['query']['DurationSeconds'] = (string) $this->durationSeconds;
|
||||||
|
if (!is_null($this->policy)) {
|
||||||
|
$options['query']['Policy'] = $this->policy;
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = (new Uri())->withScheme('https')->withHost($this->stsEndpoint);
|
||||||
|
|
||||||
|
$result = Request::createClient()->request('POST', $url, $options);
|
||||||
|
|
||||||
|
if ($result->getStatusCode() !== 200) {
|
||||||
|
throw new RuntimeException('Error refreshing credentials from OIDC, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $result->toArray();
|
||||||
|
$credentials = $json['Credentials'];
|
||||||
|
|
||||||
|
if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken'])) {
|
||||||
|
throw new RuntimeException('Error retrieving credentials from OIDC result:' . $result->toJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
return new RefreshResult(new Credentials([
|
||||||
|
'accessKeyId' => $credentials['AccessKeyId'],
|
||||||
|
'accessKeySecret' => $credentials['AccessKeySecret'],
|
||||||
|
'securityToken' => $credentials['SecurityToken'],
|
||||||
|
'expiration' => \strtotime($credentials['Expiration']),
|
||||||
|
'providerName' => $this->getProviderName(),
|
||||||
|
]), $this->getStaleTime(strtotime($credentials['Expiration'])));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function key()
|
||||||
|
{
|
||||||
|
return 'oidc_role_arn#roleArn#' . $this->roleArn . '#oidcProviderArn#' . $this->oidcProviderArn . '#roleSessionName#' . $this->roleSessionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProviderName()
|
||||||
|
{
|
||||||
|
return 'oidc_role_arn';
|
||||||
|
}
|
||||||
|
}
|
||||||
188
vendor/alibabacloud/credentials/src/Providers/ProfileCredentialsProvider.php
vendored
Normal file
188
vendor/alibabacloud/credentials/src/Providers/ProfileCredentialsProvider.php
vendored
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Utils\Helper;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Class ProfileCredentialsProvider
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials\Providers
|
||||||
|
*/
|
||||||
|
class ProfileCredentialsProvider implements CredentialsProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $profileName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $profileFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var CredentialsProvider
|
||||||
|
*/
|
||||||
|
private $credentialsProvider;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProfileCredentialsProvider constructor.
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
*/
|
||||||
|
public function __construct(array $params = [])
|
||||||
|
{
|
||||||
|
$this->filterProfileName($params);
|
||||||
|
$this->filterProfileFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterProfileName(array $params)
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_PROFILE')) {
|
||||||
|
$this->profileName = Helper::env('ALIBABA_CLOUD_PROFILE');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['profileName'])) {
|
||||||
|
$this->profileName = $params['profileName'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($this->profileName) || $this->profileName === '') {
|
||||||
|
$this->profileName = 'default';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterProfileFile()
|
||||||
|
{
|
||||||
|
$this->profileFile = Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_FILE');
|
||||||
|
|
||||||
|
if (!$this->profileFile) {
|
||||||
|
$this->profileFile = self::getDefaultFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function shouldReloadCredentialsProvider()
|
||||||
|
{
|
||||||
|
if (is_null($this->credentialsProvider)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return CredentialsProvider
|
||||||
|
*/
|
||||||
|
private function reloadCredentialsProvider($profileFile, $profileName)
|
||||||
|
{
|
||||||
|
if (!Helper::inOpenBasedir($profileFile)) {
|
||||||
|
throw new RuntimeException('Unable to open credentials file: ' . $profileFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!\is_readable($profileFile) || !\is_file($profileFile)) {
|
||||||
|
throw new RuntimeException('Credentials file is not readable: ' . $profileFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
$fileArray = \parse_ini_file($profileFile, true);
|
||||||
|
|
||||||
|
if (\is_array($fileArray) && !empty($fileArray)) {
|
||||||
|
$credentialsConfigures = [];
|
||||||
|
foreach (\array_change_key_case($fileArray) as $name => $configures) {
|
||||||
|
if ($name === $profileName) {
|
||||||
|
$credentialsConfigures = $configures;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (\is_array($credentialsConfigures) && !empty($credentialsConfigures)) {
|
||||||
|
switch (Helper::unsetReturnNull($credentialsConfigures, 'type')) {
|
||||||
|
case 'access_key':
|
||||||
|
return new StaticAKCredentialsProvider([
|
||||||
|
'accessKeyId' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_id'),
|
||||||
|
'accessKeySecret' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_secret'),
|
||||||
|
]);
|
||||||
|
case 'ram_role_arn':
|
||||||
|
$innerProvider = new StaticAKCredentialsProvider([
|
||||||
|
'accessKeyId' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_id'),
|
||||||
|
'accessKeySecret' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_secret'),
|
||||||
|
]);
|
||||||
|
return new RamRoleArnCredentialsProvider([
|
||||||
|
'credentialsProvider' => $innerProvider,
|
||||||
|
'roleArn' => Helper::unsetReturnNull($credentialsConfigures, 'role_arn'),
|
||||||
|
'roleSessionName' => Helper::unsetReturnNull($credentialsConfigures, 'role_session_name'),
|
||||||
|
'policy' => Helper::unsetReturnNull($credentialsConfigures, 'policy'),
|
||||||
|
]);
|
||||||
|
case 'ecs_ram_role':
|
||||||
|
return new EcsRamRoleCredentialsProvider([
|
||||||
|
'roleName' => Helper::unsetReturnNull($credentialsConfigures, 'role_name'),
|
||||||
|
]);
|
||||||
|
case 'oidc_role_arn':
|
||||||
|
return new OIDCRoleArnCredentialsProvider([
|
||||||
|
'roleArn' => Helper::unsetReturnNull($credentialsConfigures, 'role_arn'),
|
||||||
|
'oidcProviderArn' => Helper::unsetReturnNull($credentialsConfigures, 'oidc_provider_arn'),
|
||||||
|
'oidcTokenFilePath' => Helper::unsetReturnNull($credentialsConfigures, 'oidc_token_file_path'),
|
||||||
|
'roleSessionName' => Helper::unsetReturnNull($credentialsConfigures, 'role_session_name'),
|
||||||
|
'policy' => Helper::unsetReturnNull($credentialsConfigures, 'policy'),
|
||||||
|
]);
|
||||||
|
case 'rsa_key_pair':
|
||||||
|
return new RsaKeyPairCredentialsProvider([
|
||||||
|
'publicKeyId' => Helper::unsetReturnNull($credentialsConfigures, 'public_key_id'),
|
||||||
|
'privateKeyFile' => Helper::unsetReturnNull($credentialsConfigures, 'private_key_file'),
|
||||||
|
]);
|
||||||
|
default:
|
||||||
|
throw new RuntimeException('Unsupported credential type from credentials file: ' . Helper::unsetReturnNull($credentialsConfigures, 'type'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException('Failed to get credential from credentials file: ' . $profileFile);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get credential.
|
||||||
|
*
|
||||||
|
* @return Credentials
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
public function getCredentials()
|
||||||
|
{
|
||||||
|
if ($this->shouldReloadCredentialsProvider()) {
|
||||||
|
$this->credentialsProvider = $this->reloadCredentialsProvider($this->profileFile, $this->profileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
$credentials = $this->credentialsProvider->getCredentials();
|
||||||
|
return new Credentials([
|
||||||
|
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||||
|
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||||
|
'securityToken' => $credentials->getSecurityToken(),
|
||||||
|
'providerName' => $this->getProviderName() . '/' . $this->credentialsProvider->getProviderName(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default credential file.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getDefaultFile()
|
||||||
|
{
|
||||||
|
return Helper::getHomeDirectory() .
|
||||||
|
DIRECTORY_SEPARATOR .
|
||||||
|
'.alibabacloud' .
|
||||||
|
DIRECTORY_SEPARATOR .
|
||||||
|
'credentials';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getProviderName()
|
||||||
|
{
|
||||||
|
return 'profile';
|
||||||
|
}
|
||||||
|
}
|
||||||
321
vendor/alibabacloud/credentials/src/Providers/RamRoleArnCredentialsProvider.php
vendored
Normal file
321
vendor/alibabacloud/credentials/src/Providers/RamRoleArnCredentialsProvider.php
vendored
Normal file
@@ -0,0 +1,321 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Utils\Helper;
|
||||||
|
use AlibabaCloud\Credentials\Utils\Filter;
|
||||||
|
use AlibabaCloud\Credentials\Request\Request;
|
||||||
|
use GuzzleHttp\Psr7\Uri;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use RuntimeException;
|
||||||
|
use AlibabaCloud\Credentials\Credential\RefreshResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Class RamRoleArnCredentialsProvider
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials\Providers
|
||||||
|
*/
|
||||||
|
class RamRoleArnCredentialsProvider extends SessionCredentialsProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var CredentialsProvider
|
||||||
|
*/
|
||||||
|
private $credentialsProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $roleArn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $roleSessionName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description role session expiration
|
||||||
|
* @example 3600
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $durationSeconds = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $externalId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $policy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $stsEndpoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $connectTimeout = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $readTimeout = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RamRoleArnCredentialsProvider constructor.
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
|
public function __construct(array $params = [], array $options = [])
|
||||||
|
{
|
||||||
|
$this->filterOptions($options);
|
||||||
|
$this->filterCredentials($params);
|
||||||
|
$this->filterRoleArn($params);
|
||||||
|
$this->filterRoleSessionName($params);
|
||||||
|
$this->filterDurationSeconds($params);
|
||||||
|
$this->filterPolicy($params);
|
||||||
|
$this->filterExternalId($params);
|
||||||
|
$this->filterSTSEndpoint($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterRoleArn(array $params)
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_ARN')) {
|
||||||
|
$this->roleArn = Helper::env('ALIBABA_CLOUD_ROLE_ARN');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['roleArn'])) {
|
||||||
|
$this->roleArn = $params['roleArn'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::roleArn($this->roleArn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterRoleSessionName(array $params)
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_SESSION_NAME')) {
|
||||||
|
$this->roleSessionName = Helper::env('ALIBABA_CLOUD_ROLE_SESSION_NAME');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['roleSessionName'])) {
|
||||||
|
$this->roleSessionName = $params['roleSessionName'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($this->roleSessionName) || $this->roleSessionName === '') {
|
||||||
|
$this->roleSessionName = 'phpSdkRoleSessionName';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterDurationSeconds(array $params)
|
||||||
|
{
|
||||||
|
if (isset($params['durationSeconds'])) {
|
||||||
|
if (is_int($params['durationSeconds'])) {
|
||||||
|
$this->durationSeconds = $params['durationSeconds'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($this->durationSeconds < 900) {
|
||||||
|
throw new InvalidArgumentException('Role session expiration should be in the range of 900s - max session duration');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterPolicy(array $params)
|
||||||
|
{
|
||||||
|
if (isset($params['policy'])) {
|
||||||
|
if (is_string($params['policy'])) {
|
||||||
|
$this->policy = $params['policy'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($params['policy'])) {
|
||||||
|
$this->policy = json_encode($params['policy']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterExternalId(array $params)
|
||||||
|
{
|
||||||
|
if (isset($params['externalId'])) {
|
||||||
|
if (is_string($params['externalId'])) {
|
||||||
|
$this->externalId = $params['externalId'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterSTSEndpoint(array $params)
|
||||||
|
{
|
||||||
|
$prefix = 'sts';
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_VPC_ENDPOINT_ENABLED') || (isset($params['enableVpc']) && $params['enableVpc'] === true)) {
|
||||||
|
$prefix = 'sts-vpc';
|
||||||
|
}
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_STS_REGION')) {
|
||||||
|
$this->stsEndpoint = $prefix . '.' . Helper::env('ALIBABA_CLOUD_STS_REGION') . '.aliyuncs.com';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['stsRegionId'])) {
|
||||||
|
$this->stsEndpoint = $prefix . '.' . $params['stsRegionId'] . '.aliyuncs.com';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['stsEndpoint'])) {
|
||||||
|
$this->stsEndpoint = $params['stsEndpoint'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($this->stsEndpoint) || $this->stsEndpoint === '') {
|
||||||
|
$this->stsEndpoint = 'sts.aliyuncs.com';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterCredentials(array $params)
|
||||||
|
{
|
||||||
|
if (isset($params['credentialsProvider'])) {
|
||||||
|
if (!($params['credentialsProvider'] instanceof CredentialsProvider)) {
|
||||||
|
throw new InvalidArgumentException('Invalid credentialsProvider option for ram_role_arn');
|
||||||
|
}
|
||||||
|
$this->credentialsProvider = $params['credentialsProvider'];
|
||||||
|
} else if (isset($params['accessKeyId']) && isset($params['accessKeySecret']) && isset($params['securityToken'])) {
|
||||||
|
Filter::accessKey($params['accessKeyId'], $params['accessKeySecret']);
|
||||||
|
Filter::securityToken($params['securityToken']);
|
||||||
|
$this->credentialsProvider = new StaticSTSCredentialsProvider($params);
|
||||||
|
} else if (isset($params['accessKeyId']) && isset($params['accessKeySecret'])) {
|
||||||
|
Filter::accessKey($params['accessKeyId'], $params['accessKeySecret']);
|
||||||
|
$this->credentialsProvider = new StaticAKCredentialsProvider($params);
|
||||||
|
} else {
|
||||||
|
throw new InvalidArgumentException('Missing required credentials option for ram_role_arn');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterOptions(array $options)
|
||||||
|
{
|
||||||
|
if (isset($options['connectTimeout'])) {
|
||||||
|
$this->connectTimeout = $options['connectTimeout'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['readTimeout'])) {
|
||||||
|
$this->readTimeout = $options['readTimeout'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::timeout($this->connectTimeout, $this->readTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get credentials by request.
|
||||||
|
*
|
||||||
|
* @return RefreshResult
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function refreshCredentials()
|
||||||
|
{
|
||||||
|
$options = Request::commonOptions();
|
||||||
|
$options['read_timeout'] = $this->readTimeout;
|
||||||
|
$options['connect_timeout'] = $this->connectTimeout;
|
||||||
|
|
||||||
|
$options['query']['Action'] = 'AssumeRole';
|
||||||
|
$options['query']['Version'] = '2015-04-01';
|
||||||
|
$options['query']['Format'] = 'JSON';
|
||||||
|
$options['query']['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
|
||||||
|
$options['query']['SignatureMethod'] = 'HMAC-SHA1';
|
||||||
|
$options['query']['SignatureVersion'] = '1.0';
|
||||||
|
$options['query']['SignatureNonce'] = Request::uuid(json_encode($options['query']));
|
||||||
|
$options['query']['RoleArn'] = $this->roleArn;
|
||||||
|
$options['query']['RoleSessionName'] = $this->roleSessionName;
|
||||||
|
$options['query']['DurationSeconds'] = (string) $this->durationSeconds;
|
||||||
|
if (!is_null($this->policy) && $this->policy !== '') {
|
||||||
|
$options['query']['Policy'] = $this->policy;
|
||||||
|
}
|
||||||
|
if (!is_null($this->externalId) && $this->externalId !== '') {
|
||||||
|
$options['query']['ExternalId'] = $this->externalId;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sessionCredentials = $this->credentialsProvider->getCredentials();
|
||||||
|
$options['query']['AccessKeyId'] = $sessionCredentials->getAccessKeyId();
|
||||||
|
if (!is_null($sessionCredentials->getSecurityToken())) {
|
||||||
|
$options['query']['SecurityToken'] = $sessionCredentials->getSecurityToken();
|
||||||
|
}
|
||||||
|
$options['query']['Signature'] = Request::shaHmac1sign(
|
||||||
|
Request::signString('GET', $options['query']),
|
||||||
|
$sessionCredentials->getAccessKeySecret() . '&'
|
||||||
|
);
|
||||||
|
|
||||||
|
$url = (new Uri())->withScheme('https')->withHost($this->stsEndpoint);
|
||||||
|
|
||||||
|
$result = Request::createClient()->request('GET', $url, $options);
|
||||||
|
|
||||||
|
if ($result->getStatusCode() !== 200) {
|
||||||
|
throw new RuntimeException('Error refreshing credentials from RamRoleArn, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $result->toArray();
|
||||||
|
$credentials = $json['Credentials'];
|
||||||
|
|
||||||
|
if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken'])) {
|
||||||
|
throw new RuntimeException('Error retrieving credentials from RamRoleArn result:' . $result->toJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
return new RefreshResult(new Credentials([
|
||||||
|
'accessKeyId' => $credentials['AccessKeyId'],
|
||||||
|
'accessKeySecret' => $credentials['AccessKeySecret'],
|
||||||
|
'securityToken' => $credentials['SecurityToken'],
|
||||||
|
'expiration' => \strtotime($credentials['Expiration']),
|
||||||
|
'providerName' => $this->getProviderName(),
|
||||||
|
]), $this->getStaleTime(strtotime($credentials['Expiration'])));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function key()
|
||||||
|
{
|
||||||
|
$credentials = $this->credentialsProvider->getCredentials();
|
||||||
|
return 'ram_role_arn#credential#' . $credentials->getAccessKeyId() . '#roleArn#' . $this->roleArn . '#roleSessionName#' . $this->roleSessionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProviderName()
|
||||||
|
{
|
||||||
|
return 'ram_role_arn/' . $this->credentialsProvider->getProviderName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRoleArn()
|
||||||
|
{
|
||||||
|
return $this->roleArn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRoleSessionName()
|
||||||
|
{
|
||||||
|
return $this->roleSessionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPolicy()
|
||||||
|
{
|
||||||
|
return $this->policy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getOriginalAccessKeyId()
|
||||||
|
{
|
||||||
|
return $this->credentialsProvider->getCredentials()->getAccessKeyId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getOriginalAccessKeySecret()
|
||||||
|
{
|
||||||
|
return $this->credentialsProvider->getCredentials()->getAccessKeySecret();
|
||||||
|
}
|
||||||
|
}
|
||||||
200
vendor/alibabacloud/credentials/src/Providers/RsaKeyPairCredentialsProvider.php
vendored
Normal file
200
vendor/alibabacloud/credentials/src/Providers/RsaKeyPairCredentialsProvider.php
vendored
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Utils\Helper;
|
||||||
|
use AlibabaCloud\Credentials\Utils\Filter;
|
||||||
|
use AlibabaCloud\Credentials\Request\Request;
|
||||||
|
use GuzzleHttp\Psr7\Uri;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use AlibabaCloud\Credentials\Credential\RefreshResult;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use RuntimeException;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Class RsaKeyPairCredentialsProvider
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials\Providers
|
||||||
|
*/
|
||||||
|
class RsaKeyPairCredentialsProvider extends SessionCredentialsProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $publicKeyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $privateKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description role session expiration
|
||||||
|
* @example 3600
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $durationSeconds = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $stsEndpoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $connectTimeout = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $readTimeout = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RsaKeyPairCredentialsProvider constructor.
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
|
public function __construct(array $params = [], array $options = [])
|
||||||
|
{
|
||||||
|
$this->filterOptions($options);
|
||||||
|
$this->filterDurationSeconds($params);
|
||||||
|
$this->filterSTSEndpoint($params);
|
||||||
|
$this->publicKeyId = isset($params['publicKeyId']) ? $params['publicKeyId'] : null;
|
||||||
|
$privateKeyFile = isset($params['privateKeyFile']) ? $params['privateKeyFile'] : null;
|
||||||
|
Filter::publicKeyId($this->publicKeyId);
|
||||||
|
Filter::privateKeyFile($privateKeyFile);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->privateKey = file_get_contents($privateKeyFile);
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
throw new InvalidArgumentException($exception->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterOptions(array $options)
|
||||||
|
{
|
||||||
|
if (isset($options['connectTimeout'])) {
|
||||||
|
$this->connectTimeout = $options['connectTimeout'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['readTimeout'])) {
|
||||||
|
$this->readTimeout = $options['readTimeout'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::timeout($this->connectTimeout, $this->readTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterDurationSeconds(array $params)
|
||||||
|
{
|
||||||
|
if (isset($params['durationSeconds'])) {
|
||||||
|
if (is_int($params['durationSeconds'])) {
|
||||||
|
$this->durationSeconds = $params['durationSeconds'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($this->durationSeconds < 900) {
|
||||||
|
throw new InvalidArgumentException('Role session expiration should be in the range of 900s - max session duration');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterSTSEndpoint(array $params)
|
||||||
|
{
|
||||||
|
if (isset($params['stsEndpoint'])) {
|
||||||
|
$this->stsEndpoint = $params['stsEndpoint'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($this->stsEndpoint) || $this->stsEndpoint === '') {
|
||||||
|
$this->stsEndpoint = 'sts.ap-northeast-1.aliyuncs.com';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get credentials by request.
|
||||||
|
*
|
||||||
|
* @return RefreshResult
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function refreshCredentials()
|
||||||
|
{
|
||||||
|
$options = Request::commonOptions();
|
||||||
|
$options['read_timeout'] = $this->readTimeout;
|
||||||
|
$options['connect_timeout'] = $this->connectTimeout;
|
||||||
|
|
||||||
|
$options['query']['Action'] = 'GenerateSessionAccessKey';
|
||||||
|
$options['query']['Version'] = '2015-04-01';
|
||||||
|
$options['query']['Format'] = 'JSON';
|
||||||
|
$options['query']['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
|
||||||
|
$options['query']['SignatureMethod'] = 'SHA256withRSA';
|
||||||
|
$options['query']['SignatureType'] = 'PRIVATEKEY';
|
||||||
|
$options['query']['SignatureVersion'] = '1.0';
|
||||||
|
$options['query']['SignatureNonce'] = Request::uuid(json_encode($options['query']));
|
||||||
|
$options['query']['DurationSeconds'] = (string) $this->durationSeconds;
|
||||||
|
$options['query']['AccessKeyId'] = $this->publicKeyId;
|
||||||
|
$options['query']['Signature'] = Request::shaHmac256WithRsasign(
|
||||||
|
Request::signString('GET', $options['query']),
|
||||||
|
$this->privateKey
|
||||||
|
);
|
||||||
|
|
||||||
|
$url = (new Uri())->withScheme('https')->withHost($this->stsEndpoint);
|
||||||
|
|
||||||
|
$result = Request::createClient()->request('GET', $url, $options);
|
||||||
|
|
||||||
|
if ($result->getStatusCode() !== 200) {
|
||||||
|
throw new RuntimeException('Error refreshing credentials from RsaKeyPair, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $result->toArray();
|
||||||
|
|
||||||
|
if (!isset($json['SessionAccessKey']['SessionAccessKeyId']) || !isset($json['SessionAccessKey']['SessionAccessKeySecret'])) {
|
||||||
|
throw new RuntimeException('Error retrieving credentials from RsaKeyPair result:' . $result->toJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
$credentials = [];
|
||||||
|
$credentials['AccessKeyId'] = $json['SessionAccessKey']['SessionAccessKeyId'];
|
||||||
|
$credentials['AccessKeySecret'] = $json['SessionAccessKey']['SessionAccessKeySecret'];
|
||||||
|
$credentials['Expiration'] = $json['SessionAccessKey']['Expiration'];
|
||||||
|
$credentials['SecurityToken'] = null;
|
||||||
|
|
||||||
|
|
||||||
|
return new RefreshResult(new Credentials([
|
||||||
|
'accessKeyId' => $credentials['AccessKeyId'],
|
||||||
|
'accessKeySecret' => $credentials['AccessKeySecret'],
|
||||||
|
'securityToken' => $credentials['SecurityToken'],
|
||||||
|
'expiration' => \strtotime($credentials['Expiration']),
|
||||||
|
'providerName' => $this->getProviderName(),
|
||||||
|
]), $this->getStaleTime(strtotime($credentials['Expiration'])));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function key()
|
||||||
|
{
|
||||||
|
return 'rsa_key_pair#publicKeyId#' . $this->publicKeyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProviderName()
|
||||||
|
{
|
||||||
|
return 'rsa_key_pair';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPublicKeyId()
|
||||||
|
{
|
||||||
|
return $this->publicKeyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getPrivateKey()
|
||||||
|
{
|
||||||
|
return $this->privateKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
161
vendor/alibabacloud/credentials/src/Providers/SessionCredentialsProvider.php
vendored
Normal file
161
vendor/alibabacloud/credentials/src/Providers/SessionCredentialsProvider.php
vendored
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Credential\RefreshResult;
|
||||||
|
|
||||||
|
abstract class SessionCredentialsProvider implements CredentialsProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected static $credentialsCache = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expiration time slot for temporary security credentials.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $expirationSlot = 180;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $error = 'Result contains no credentials';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the credentials from the cache in the validity period.
|
||||||
|
*
|
||||||
|
* @return RefreshResult|null
|
||||||
|
*/
|
||||||
|
protected function getCredentialsInCache()
|
||||||
|
{
|
||||||
|
if (isset(self::$credentialsCache[$this->key()])) {
|
||||||
|
$result = self::$credentialsCache[$this->key()];
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache credentials.
|
||||||
|
*
|
||||||
|
* @param RefreshResult $credential
|
||||||
|
*/
|
||||||
|
protected function cache(RefreshResult $credential)
|
||||||
|
{
|
||||||
|
self::$credentialsCache[$this->key()] = $credential;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get credential.
|
||||||
|
*
|
||||||
|
* @return Credentials
|
||||||
|
*/
|
||||||
|
public function getCredentials()
|
||||||
|
{
|
||||||
|
if ($this->cacheIsStale() || $this->shouldInitiateCachePrefetch()) {
|
||||||
|
$result = $this->refreshCache();
|
||||||
|
$this->cache($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->getCredentialsInCache();
|
||||||
|
|
||||||
|
return $result->credentials();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return RefreshResult
|
||||||
|
*/
|
||||||
|
protected function refreshCache()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->handleFetchedSuccess($this->refreshCredentials());
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->handleFetchedFailure($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return RefreshResult
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
protected function handleFetchedFailure(\Exception $e)
|
||||||
|
{
|
||||||
|
$currentCachedValue = $this->getCredentialsInCache();
|
||||||
|
if (is_null($currentCachedValue)) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time() < $currentCachedValue->staleTime()) {
|
||||||
|
return $currentCachedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return RefreshResult
|
||||||
|
*/
|
||||||
|
protected function handleFetchedSuccess(RefreshResult $value)
|
||||||
|
{
|
||||||
|
$now = time();
|
||||||
|
// 过期时间大于15分钟,不用管
|
||||||
|
if ($now < $value->staleTime()) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
// 不足或等于15分钟,但未过期,下次会再次刷新
|
||||||
|
if ($now < $value->staleTime() + 15 * 60) {
|
||||||
|
$value->staleTime = $now;
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
// 已过期,看缓存,缓存若大于15分钟,返回缓存,若小于15分钟,则稍后重试
|
||||||
|
if (is_null($this->getCredentialsInCache())) {
|
||||||
|
throw new \Exception("The fetched credentials have expired and no cache is available.");
|
||||||
|
} else if ($now < $this->getCredentialsInCache()->staleTime()) {
|
||||||
|
return $this->getCredentialsInCache();
|
||||||
|
} else {
|
||||||
|
// 返回成功,延长有效期 1 分钟
|
||||||
|
$expectation = mt_rand(50, 70);
|
||||||
|
$value->staleTime = time() + $expectation;
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function cacheIsStale()
|
||||||
|
{
|
||||||
|
return is_null($this->getCredentialsInCache()) || time() >= $this->getCredentialsInCache()->staleTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function shouldInitiateCachePrefetch()
|
||||||
|
{
|
||||||
|
return is_null($this->getCredentialsInCache()) || time() >= $this->getCredentialsInCache()->prefetchTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getStaleTime($expiration)
|
||||||
|
{
|
||||||
|
return $expiration <= 0 ?
|
||||||
|
time() + (60 * 60) :
|
||||||
|
$expiration - (15 * 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return RefreshResult
|
||||||
|
*/
|
||||||
|
abstract function refreshCredentials();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the toString of the credentials provider as the key.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract function key();
|
||||||
|
}
|
||||||
78
vendor/alibabacloud/credentials/src/Providers/StaticAKCredentialsProvider.php
vendored
Normal file
78
vendor/alibabacloud/credentials/src/Providers/StaticAKCredentialsProvider.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Utils\Helper;
|
||||||
|
use AlibabaCloud\Credentials\Utils\Filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Class StaticAKCredentialsProvider
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials\Providers
|
||||||
|
*/
|
||||||
|
class StaticAKCredentialsProvider implements CredentialsProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $accessKeyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $accessKeySecret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StaticAKCredentialsProvider constructor.
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
*/
|
||||||
|
public function __construct(array $params = [])
|
||||||
|
{
|
||||||
|
$this->filterAK($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterAK(array $params)
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_ID')) {
|
||||||
|
$this->accessKeyId = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_SECRET')) {
|
||||||
|
$this->accessKeySecret = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_SECRET');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['accessKeyId'])) {
|
||||||
|
$this->accessKeyId = $params['accessKeyId'];
|
||||||
|
}
|
||||||
|
if (isset($params['accessKeySecret'])) {
|
||||||
|
$this->accessKeySecret = $params['accessKeySecret'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::accessKey($this->accessKeyId, $this->accessKeySecret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get credential.
|
||||||
|
*
|
||||||
|
* @return Credentials
|
||||||
|
*/
|
||||||
|
public function getCredentials()
|
||||||
|
{
|
||||||
|
return new Credentials([
|
||||||
|
'accessKeyId' => $this->accessKeyId,
|
||||||
|
'accessKeySecret' => $this->accessKeySecret,
|
||||||
|
'providerName' => $this->getProviderName(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getProviderName()
|
||||||
|
{
|
||||||
|
return "static_ak";
|
||||||
|
}
|
||||||
|
}
|
||||||
92
vendor/alibabacloud/credentials/src/Providers/StaticSTSCredentialsProvider.php
vendored
Normal file
92
vendor/alibabacloud/credentials/src/Providers/StaticSTSCredentialsProvider.php
vendored
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AlibabaCloud\Credentials\Providers;
|
||||||
|
|
||||||
|
use AlibabaCloud\Credentials\Utils\Helper;
|
||||||
|
use AlibabaCloud\Credentials\Utils\Filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is intended for internal use within the package.
|
||||||
|
* Class StaticSTSCredentialsProvider
|
||||||
|
*
|
||||||
|
* @package AlibabaCloud\Credentials\Providers
|
||||||
|
*/
|
||||||
|
class StaticSTSCredentialsProvider implements CredentialsProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $accessKeyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $accessKeySecret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $securityToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StaticSTSCredentialsProvider constructor.
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
*/
|
||||||
|
public function __construct(array $params = [])
|
||||||
|
{
|
||||||
|
$this->filterSTS($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filterSTS(array $params)
|
||||||
|
{
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_ID')) {
|
||||||
|
$this->accessKeyId = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_SECRET')) {
|
||||||
|
$this->accessKeySecret = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_SECRET');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Helper::envNotEmpty('ALIBABA_CLOUD_SECURITY_TOKEN')) {
|
||||||
|
$this->securityToken = Helper::env('ALIBABA_CLOUD_SECURITY_TOKEN');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['accessKeyId'])) {
|
||||||
|
$this->accessKeyId = $params['accessKeyId'];
|
||||||
|
}
|
||||||
|
if (isset($params['accessKeySecret'])) {
|
||||||
|
$this->accessKeySecret = $params['accessKeySecret'];
|
||||||
|
}
|
||||||
|
if (isset($params['securityToken'])) {
|
||||||
|
$this->securityToken = $params['securityToken'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Filter::accessKey($this->accessKeyId, $this->accessKeySecret);
|
||||||
|
Filter::securityToken($this->securityToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get credential.
|
||||||
|
*
|
||||||
|
* @return Credentials
|
||||||
|
*/
|
||||||
|
public function getCredentials()
|
||||||
|
{
|
||||||
|
return new Credentials([
|
||||||
|
'accessKeyId' => $this->accessKeyId,
|
||||||
|
'accessKeySecret' => $this->accessKeySecret,
|
||||||
|
'securityToken' => $this->securityToken,
|
||||||
|
'providerName' => $this->getProviderName(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getProviderName()
|
||||||
|
{
|
||||||
|
return "static_sts";
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user