cxfoot/modules/api/models/DeviceUniqueDataForm.php
2023-10-24 14:54:18 +08:00

671 lines
26 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

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

<?php
/**
* @author Any
* @description KISS
* @date 2020-12-2
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\modules\api\models;
use app\models\Detection;
use app\models\UserBallArm;
use function AlibabaCloud\Client\value;
use app\components\SiteHelper;
use app\models\Coach;
use app\models\DeviceUniqueBindStore;
use app\models\DeviceUniqueBindUser;
use app\models\DeviceUniqueConfig;
use app\models\DeviceUniqueData;
use app\models\Store;
use app\models\User;
use app\components\auth\AToken;
use app\components\EncryptHelper;
use app\modules\api\components\GetDistance;
use yii\data\Pagination;
class DeviceUniqueDataForm extends ApiModel
{
public $user_id;
//数据状态
const STATUS_ING = 1;
const STATUS_BING = 2;
const STATUS_OK = 3;
const STATUS_MANUAL_END = 4;
const STATUS_END = 5;
// 数据键
// const FIELD_KEY = ['Club Speed', 'Angle of Attack', 'Club Path', 'Dynamic Loft', 'Face To Target', 'Face To Path', 'Efficiency', 'Lie Angle', 'Horizontal Impact', 'Vertical Impact', 'Closure Rate', 'F-Axis', 'Ball Speed', 'Launch Angle', 'Launch Direction', 'Spin Rate', 'Spin Axis Tilt', 'Back Spin', 'Side Spin', 'Carry', 'Total', 'Offline', 'Total Offline', 'Curve', 'Peak Height', 'Descent Angle', 'Distance To Target', 'Dispersion', 'Range', 'Spray', 'Accuracy', 'Range Cons.', 'Spray Cons.', 'Impact Point Cons.'];
const FIELD_KEY = ['Club Speed', 'Ball Speed', 'Side Spin','Back Spin', 'Angle of Attack', 'Launch Angle','Carry','Total','Club Path', 'Launch Direction', 'Face To Path', 'Face To Target', 'Horizontal Impact','Vertical Impact','Dynamic Loft', 'Lie Angle', 'F-Axis', 'Curve', 'Peak Height', 'Descent Angle', 'Offline','Efficiency','Closure Rate', 'Spin Rate', 'Spin Axis Tilt', 'Total Offline', 'Distance To Target', 'Dispersion', 'Range', 'Spray', 'Accuracy', 'Range Cons.', 'Spray Cons.', 'Impact Point Cons.'];
public $keywords;
public $limit;
public $page;
public $type;
public $data;
public function rules()
{
return [
[['keywords', 'url_alias'], 'trim'],
[['keywords', 'url_alias', 'limit', 'type', 'data'], 'string'],
[['page'], 'default', 'value' => 1],
[['limit'], 'default', 'value' => 20],
];
}
/**
* 本场平均 //根据user_id 获取最新 staus=3
*/
public function uniqueIndex()
{
//获取属于这个用户的全部数据 根据id 降序排列
$userUniqueData = DeviceUniqueBindUser::find()->alias('c')
->innerJoin(['rt' => DeviceUniqueBindStore::tableName()], 'c.unique_id = rt.id')
->where(['c.uid' => $this->user_id, 'c.status' => self::STATUS_OK])
->select('c.id ,c.c_id,c.start_at,c.end_at,c.status,c.unique_id,rt.store_id,c.is_show')
->limit(1)->orderBy(['c.id' => SORT_DESC])->asArray()->one();
// var_dump($userUniqueData);
$userData = $userUniqueData;
if (empty($userData)) {
return $this->apiReturnSuccess('ok', []);
}
$bindId = $userData['id']; //用户当前绑定的门店设备ID
//根据绑定的设备ID 查询出本场所有回合数据
$data = DeviceUniqueData::find()->where(['bind_id' => $bindId])->select('id,data,created_at,pole_type,pole_class')->orderBy(['id' => SORT_ASC])->asArray()->all();
$store_id = $userData['store_id'];
$c_id = $userData['c_id'];
$storeArr = Store::find()->where(['id' => $store_id])->select('name')->asArray()->one();
$coachInfoArr = User::find()->where(['id' => $c_id])->select('real_name')->asArray()->one();
$coachArr = Coach::find()->where(['user_id' => $c_id])->select('coach_photo')->asArray()->one();
// 获取设置
$field_config_ = $this->deviceConfigList();
if (empty($field_config_['data']) || empty($field_config_['data']['key_val'])) {
$field_config = [];
} else {
foreach ($field_config_['data']['key_val'] as $key => $val) {
if (intval($val) === 1) {
$field_config[$key] = 1;
}
}
}
$arr = [];
foreach ($data as $key => $val) {
$json = json_decode($val['data'], true);
unset($json['Index']);
foreach ($json as $k => $v) {
if (empty($field_config[$k])) {
unset($json[$k]);
continue;
}
if ($v == '' || $v == '-') {
$json[$k] = '-';
} else {
$json[$k] = floatval($v);
}
}
$json['pole_type'] = $val['pole_type'] ?? '-';
$json['pole_class'] = $val['pole_class'] ?? '-';
if (!empty($json['pole_class'])) {
// 截取前两字符
$json['pole_class'] = mb_substr($json['pole_class'], 0, 2);
}
$json['pole_class'] = strtoupper($json['pole_class']);
$json['pole_type'] = strtolower($json['pole_type']);
$arr[] = $json;
}
$data_info = [];
foreach ($arr as $key => $val) {
$data_info[$key] = [];
foreach ($val as $k => $v) {
$data_info[$key][] = [
'title' => $k,
'value' => $v,
];
}
}
$resArr['id'] = $userData['id']; // 本场id
$resArr['c_id'] = $c_id;
$resArr['data_info'] = $data_info;
$resArr['start_at'] = date('Y-m-d H:i:s', $userData['start_at']);
$resArr['end_at'] = date('Y-m-d H:i:s', $userData['end_at']);
$resArr['store_name'] = $storeArr['name'];
$resArr['coach_name'] = $coachInfoArr['real_name'];
$resArr['coach_photo'] = SiteHelper::getFullUrl($coachArr['coach_photo']);
$resArr['system_content'] = "大数据分析结果xxxxxxxxxxxxxx";
// $resArr['ball_arm'] = $this->getBallArmData($userData['id']); # 球杆数据
// 更新未查看的数据为已查看
if (empty($userData['is_show'])) {
DeviceUniqueBindUser::updateAll([
'is_show' => 1,
], [
'id' => $userData['id'],
]);
}
return $this->apiReturnSuccess('ok', $resArr);
}
/**
* 计算历史数据平均值
* @param $data
* @return array
*/
public function avg($data)
{
if (empty($data)) {
return [];
}
$res = [];
foreach ($data as $key => $val) {
foreach ($val as $k => $v) {
if (empty($k)) {
$res[$k] = [];
}
$res[$k][] = floatval($v);
}
}
$count = count($data);
foreach ($res as $key => $val) {
$res[$key] = strval(round(array_sum($val) / $count, 2));
}
return $res;
}
/**
* 历史数据
*/
public function historicalData()
{
if (empty($this->user_id)) {
return $this->apiReturnError('用户错误');
}
$query = DeviceUniqueBindUser::find()->alias('c')
->innerJoin(['rt' => DeviceUniqueBindStore::tableName()], 'c.unique_id = rt.id')
// ->innerJoin(['rt' => DeviceUniqueBindStore::tableName()], 'c.unique_id = rt.id')
->where(['c.uid' => $this->user_id, 'c.status' => self::STATUS_OK])
->select('c.id ,c.c_id,c.start_at,c.end_at,c.status,c.unique_id,rt.store_id');
if (!$query) {
return $this->apiReturnSuccess('ok', []);
}
//门店名称 教练名称 教练头像 coach_photo
$count_query = clone $query;
$count = $count_query->count();
if (empty($this->limit)) {
$this->limit = 10;
}
if (empty($this->page)) {
$this->page = 1;
}
$pagination = new Pagination(['pageSize' => $this->limit, 'totalCount' => $count, 'page' => $this->page - 1]);
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['c.id' => SORT_DESC])->asArray()->all();
$coachArr = [];
$storeArr = [];
$userCoachArr = [];
foreach ($list as $index => $value) {
if (empty($userCoachArr[$value['c_id']])) {
$userCoachArr[$value['c_id']] = User::find()->where(['id' => $value['c_id']])->select('real_name')->asArray()->one();
}
if (empty($coachArr[$value['c_id']])) {
$coachArr[$value['c_id']] = Coach::find()->where(['id' => $value['c_id']])->select('coach_photo')->asArray()->one();
}
if (empty($storeArr[$value['store_id']])) {
$storeArr[$value['store_id']] = Store::find()->where(['id' => $value['store_id']])->select('name')->asArray()->one();
}
$value['store_name'] = $storeArr[$value['store_id']]['name']; //门店名称
$value['coach_name'] = $userCoachArr[$value['c_id']]['real_name']; //教练名称
$value['coach_photo'] = SiteHelper::getFullUrl($coachArr[$value['c_id']]['coach_photo']);
$value['start_at'] = date('Y-m-d H:i:s', $value['start_at']);
$value['end_at'] = date('Y-m-d H:i:s', $value['end_at']);
$list[$index] = $value;
}
//是否已经全部加载
$end_flag = $this->page > $pagination->pageCount ? true : false;
return [
'code' => 0,
'msg' => 'ok',
'data' => $list,
'count' => $count,
'page_size' => $this->limit,
'page_count' => $pagination->pageCount,
'page_no' => $this->page,
'end_flag' => $end_flag
];
}
/**
* 历史数据详情
*/
public function historicalDataOne($bind_id)
{
if (empty($bind_id)) {
return $this->apiReturnError('详情ID不能为空');
}
$userUniqueData = DeviceUniqueBindUser::find()->alias('c')
->innerJoin(['rt' => DeviceUniqueBindStore::tableName()], 'c.unique_id = rt.id')
->andWhere(['c.id' => $bind_id]);
if (false) {
// 判断是否为教练如果不是则需要加上当前用户id
$userUniqueData->andWhere([
'c.uid' => $this->user_id,
]);
}
$userUniqueData = $userUniqueData->select('c.id ,c.c_id,c.uid,c.start_at,c.end_at,c.status,c.unique_id,rt.store_id,c.ball_arm_ids')->asArray()->one();
if (!$userUniqueData) {
return $this->apiReturnSuccess('ok', []);
}
$storeArr = Store::find()->where(['id' => $userUniqueData['store_id']])->select('name')->asArray()->one();
$coachInfoArr = User::find()->where(['id' => $userUniqueData['c_id']])->select('real_name')->asArray()->one();
$coachArr = Coach::find()->where(['user_id' => $userUniqueData['c_id']])->select('coach_photo')->asArray()->one();
//根据 bind_id 查询出所有回合数 数据
$data = DeviceUniqueData::find()->where(['bind_id' => $bind_id])->select('id,data,created_at,pole_type,pole_class')->orderBy(['id' => SORT_DESC])->asArray()->all();
// 获取设置
$field_config_ = $this->deviceConfigList();
if (empty($field_config_['data']) || empty($field_config_['data']['key_val'])) {
$field_config = [];
} else {
foreach ($field_config_['data']['key_val'] as $key => $val) {
if (intval($val) === 1) {
$field_config[$key] = 1;
}
}
}
foreach ($data as $key => $val) {
$json = json_decode($val['data'], true);
unset($json['Index']);
foreach ($json as $k => $v) {
if (empty($field_config[$k])) {
unset($json[$k]);
continue;
}
$json['pole_type'] = $val['pole_type'] ?? '-';
$json['pole_class'] = $val['pole_class'] ?? '-';
if (!empty($json['pole_class'])) {
// 截取前两字符
$json['pole_class'] = mb_substr($json['pole_class'], 0, 2);
}
$json['pole_class'] = strtoupper($json['pole_class']);
$json['pole_type'] = strtolower($json['pole_type']);
if ($v == '' || $v == '-') {
$json[$k] = '-';
} else {
$json[$k] = floatval($v);
}
}
$arr[] = $json;
}
$data_info = [];
foreach ($arr as $key => $val) {
$data_info[$key] = [];
foreach ($val as $k => $v) {
$data_info[$key][] = [
'title' => $k,
'value' => $v,
];
}
}
$resArr['data_info'] = $data_info;
$resArr['start_at'] = date('Y-m-d H:i:s', $userUniqueData['start_at']);
$resArr['end_at'] = date('Y-m-d H:i:s', $userUniqueData['end_at']);
$resArr['store_name'] = $storeArr['name'];
$resArr['coach_name'] = $coachInfoArr['real_name'];
$resArr['coach_photo'] = SiteHelper::getFullUrl($coachArr['coach_photo']);
$resArr['system_content'] = "大数据分析结果xxxxxxxxxxxxxx";
$resArr['ball_arm'] = $this->getBallArmData($userUniqueData['ball_arm_ids']); # 球杆数据
return $this->apiReturnSuccess('ok', $resArr);
}
/**
* 数据设置-设置列表
* @return array
*/
public function deviceConfigList()
{
$configList = DeviceUniqueConfig::findOne(['user_id' => $this->user_id]);
if (empty($configList)) {
// 获取数据
$res = [];
foreach (self::FIELD_KEY as $key => $val) {
$res[] = [
'title' => $val,
'value' => 1,
];
}
// 保存数据
$obj = new DeviceUniqueConfig();
$obj->user_id = $this->user_id;
$obj->config = json_encode($res, JSON_UNESCAPED_UNICODE);
$obj->created_at = time();
$obj->updated_at = time();
$obj->save();
} else {
$res = json_decode($configList->config, true);
}
$key_val = [];
$field_data = self::FIELD_KEY;
$field_data = array_flip(array_slice($field_data,0,22));
foreach ($res as $key => $val) {
if(isset($field_data[$val['title']])){
$res[$key]['value'] = 1;
$key_val[$val['title']] = 1;
}else{
$key_val[$val['title']] = $val['value'];
}
}
return $this->apiReturnSuccess('ok', [
'data' => array_merge($res),
'key_val' => $key_val,
]);
}
/**
* 数据设置
* @param $data
*/
public function deviceConfig($data, $id)
{
if (empty($data)) {
return $this->apiReturnError('参数不能为空');
}
$arr = json_decode($data, true);
$status = [1, 0];
foreach ($arr as $key => $value) {
if (!in_array((int)$value, $status)) {
return $this->apiReturnError('参数不正确');
}
}
$userData = DeviceUniqueConfig::find()->where(['user_id' => $this->user_id])->one();
if (!$id) {
return $this->apiReturnError('配置ID不能为空');
}
$userData->config = $data;
$userData->updated_at = time();
if (!$userData->save()) {
return $this->getModelError($userData);
}
return $this->apiReturnSuccess("设置成功");
}
/**
* 获取数据统计【近10场数据】
*/
public function actionGetCountList()
{
// 获取配置
$field_config_ = $this->deviceConfigList();
if (empty($field_config_['data']) || empty($field_config_['data']['key_val'])) {
$field_config = [];
} else {
foreach ($field_config_['data']['key_val'] as $key => $val) {
if (intval($val) === 1) {
$field_config[$key] = 1;
}
}
}
$select = DeviceUniqueBindUser::find()
->andWhere([
'status' => self::STATUS_OK,
'is_delete' => 0,
'uid' => $this->user_id,
])
->limit(10)->select('*')->orderBy(['id' => SORT_DESC])->asArray()->all();
$field_data = [];
$field_id = [];
foreach (self::FIELD_KEY as $key => $val) {
if (empty($field_config[$val])) {
continue;
}
$k = (strval($key + 1));
$field_data[$k] = [
'title' => $val,
'id' => $k,
];
$field_id[$val] = $k;
}
$return = [
'field' => array_merge($field_data),
'avg_data' => [], # 图表数据
'data_info' => [],
'avg_len' => 0, # 图表长度
'info_data' => [], # 各项信息
'table_len' => 0, # 表格高度
'table_data' => [], # 底部表格数据
'table_null_msg' => '', # 表格空信息展示内容
'status' => 2, # 状态1.有数据2.没有数据
];
if (empty($select)) {
return $this->apiReturnSuccess('ok', $return);
}
$return['status'] = 1;
// 获取所有的数据
$select_data = DeviceUniqueData::find()
->andWhere([
'in', 'bind_id', array_column($select, 'id')
])->select('*')->asArray()->all();
$data_json = [];
$bind_id_len = [];
foreach ($select_data as $k1 => $v1) {
if (empty($data_json[$v1['bind_id']])) {
$data_json[$v1['bind_id']] = [];
$bind_id_len[$v1['bind_id']] = 0;
}
$json = json_decode($v1['data'], true);
foreach ($json as $k => $v) {
// if (empty($field_config[$k])) {
// unset($json[$k]);
// continue;
// }
$json['pole_type'] = $v1['pole_type'] ?? '-';
$json['pole_class'] = $v1['pole_class'] ?? '-';
if (!empty($json['pole_class'])) {
// 截取前两字符
$json['pole_class'] = mb_substr($json['pole_class'], 0, 2);
}
$json['pole_class'] = strtoupper($json['pole_class']);
$json['pole_type'] = strtolower($json['pole_type']);
if ($v == '' || $v == '-') {
$json[$k] = '-';
} else {
$json[$k] = floatval($v);
}
}
unset($json['Index']);
$data_json[$v1['bind_id']][] = $json;
$bind_id_len[$v1['bind_id']] += 1;
}
// 每场的每杆数据合并
$table_data = [];
$avg_res_data = [];
$table_len = [];
$data_info = [];
foreach ($data_json as $key => $val) {
$table_len[$key] = 0;
$data_info[$key] = [];
foreach ($val as $k => $v) {
$data_info[$key][$k] = [];
foreach ($v as $k1 => $v1) {
$data_info[$key][$k][] = [
'title' => $k1,
'value' => $v1,
];
}
}
}
foreach ($table_data as $key => $val) {
$table_data[$key] = array_merge($val);
}
$start_time = end($select)['start_at'];
$end_time = reset($select)['end_at'];
$return['info_data'] = [
'start_time' => date('Y-m-d H:i:s', $start_time),
'end_time' => date('Y-m-d H:i:s', $end_time),
];
$return['avg_len'] = count($bind_id_len);
$return['avg_data'] = $avg_res_data;
$return['table_len'] = max($table_len);
$return['table_data'] = ($table_data);
$return['table_null_msg'] = "-";
$return['data_info'] = $data_info;
return $this->apiReturnSuccess('', $return);
}
/**
* 获取当前教练信息
*/
public function getNowCoachInfo()
{
// 获取最近一场比赛
$find = DeviceUniqueBindUser::find()
->andWhere([
'uid' => $this->user_id,
'is_delete' => 0,
])->andWhere([
'in', 'status', [1, 2, 3]
])->orderBy(['id' => SORT_DESC])->select('*')->asArray()->one();
if (empty($find)) {
return $this->apiReturnError('暂无教练');
}
// 获取教练信息
$find_coach = Coach::findOne([
'user_id' => $find['c_id'],
'is_delete' => 0,
]);
if (empty($find_coach)) {
return $this->apiReturnError('暂无教练');
}
// 获取用户名称
$find_user = User::findOne([
'id' => $find['c_id'],
]);
$find_coach['content'] = str_replace("/upload/0/1/upload/image", \Yii::$app->request->getHostInfo() . "/upload/0/1/upload/image", $find_coach['content']);
$arr = [
'title' => $find_coach->title,
'coach_photo' => SiteHelper::getFullUrl($find_coach['coach_photo']),
'number' => $find_coach['number'],
'content' => $find_coach['content'],
'real_name' => $find_user['real_name'] ?? '',
];
return $this->apiReturnSuccess('ok', $arr);
}
/**
* @ Author : Lw
* @ CreateTime : 2022-07-16
* @ Info : 球杆信息
*/
public function getBallArmData($ball_arm_ids = 0)
{
if (!empty($ball_arm_ids)) {
$explode = explode(',',$ball_arm_ids);
$select = UserBallArm::find()
->andWhere([
'in','id',$explode,
])->select('*')->asArray()->all();
$json_de = [];
$temp_k = [];
}else{
$select = [];
}
if(!empty($select)){
foreach ($select as $key=>$val){
$json_de[$key] = json_decode($val['data'],true);
$temp_k[$key] = $val;
}
}else{
$data = '[{"CLUB":"1W","MODEL":"TL TSI1","LENGTH":"45.75","LOFT":"10","LIE":"58.5","S/W":"D3","T/W":"","SHAFT":"Aldila Ascent 40","CPM":"","TQ":"","GRIP":"GP velvet 360","SICE":"","TYPE":""},
{"CLUB":"2W","MODEL":"","LENGTH":"","LOFT":"","LIE":"","S/W":"","T/W":"","SHAFT":"","CPM":"","TQ":"","GRIP":"","SICE":"","TYPE":""},
{"CLUB":"3W","MODEL":"TL TSI1","LENGTH":"43","LOFT":"15","LIE":"56.5","S/W":"D0.5","T/W":"","SHAFT":"Aldila Ascent 40","CPM":"","TQ":"","GRIP":"GP velvet 360","SICE":"","TYPE":""},
{"CLUB":"5W","MODEL":"TL TSI1","LENGTH":"42","LOFT":"18","LIE":"57.5","S/W":"D0.5","T/W":"","SHAFT":"Aldila Ascent 40","CPM":"","TQ":"","GRIP":"GP velvet 360","SICE":"","TYPE":""},
{"CLUB":"I3","MODEL":"","LENGTH":"","LOFT":"","LIE":"","S/W":"","T/W":"","SHAFT":"","CPM":"","TQ":"","GRIP":"","SICE":"","TYPE":""},
{"CLUB":"I4","MODEL":"TL t100","LENGTH":"38.5","LOFT":"24","LIE":"61.5","S/W":"D1","T/W":"","SHAFT":"Project x LZ5.5","CPM":"","TQ":"","GRIP":"GP velvet 360","SICE":"","TYPE":""},
{"CLUB":"I5","MODEL":"TL t100","LENGTH":"38","LOFT":"27","LIE":"62","S/W":"D1","T/W":"","SHAFT":"Project x LZ5.5","CPM":"","TQ":"","GRIP":"GP velvet 360","SICE":"","TYPE":""},
{"CLUB":"I6","MODEL":"TL t100","LENGTH":"37.5","LOFT":"30","LIE":"62.5","S/W":"D1","T/W":"","SHAFT":"Project x LZ5.5","CPM":"","TQ":"","GRIP":"GP velvet 360","SICE":"","TYPE":""},
{"CLUB":"I7","MODEL":"TL t100","LENGTH":"37","LOFT":"34","LIE":"63","S/W":"D1","T/W":"","SHAFT":"Project x LZ5.5","CPM":"","TQ":"","GRIP":"GP velvet 360","SICE":"","TYPE":""},
{"CLUB":"I8","MODEL":"TL t100","LENGTH":"36.5","LOFT":"38","LIE":"63.5","S/W":"D1","T/W":"","SHAFT":"Project x LZ5.5","CPM":"","TQ":"","GRIP":"GP velvet 360","SICE":"","TYPE":""},
{"CLUB":"I9","MODEL":"TL t100","LENGTH":"36","LOFT":"42","LIE":"64","S/W":"D1","T/W":"","SHAFT":"Project x LZ5.5","CPM":"","TQ":"","GRIP":"GP velvet 360","SICE":"","TYPE":""},
{"CLUB":"Pw","MODEL":"TL t100","LENGTH":"35.75","LOFT":"46","LIE":"64.5","S/W":"D1.5","T/W":"","SHAFT":"Project x LZ5.5","CPM":"","TQ":"","GRIP":"GP velvet 360","SICE":"","TYPE":""}]';
$json_de = json_decode($data, True);
}
$res_data = [];
$jc_user = [];
foreach ($json_de as $key => $val) {
if(empty($jc_user[$temp_k[$key]['jc_uid']])){
$jc_find = Detection::find()->alias('d')
->join('inner join',['u'=>User::tableName()],'d.user_id = u.id')
->andWhere([
'd.is_delete' => 0,
'u.is_delete' => 0,
'u.id' => $temp_k[$key]['jc_uid'],
])->select('d.id,d.name,u.avatar_url')->asArray()->one();
if(empty($jc_find)){
$jc_find = [
'name' => '',
'avatar_url' => '',
];
}
$jc_user[$temp_k[$key]['jc_uid']] = $jc_find;
}else{
$jc_find = $jc_user[$temp_k[$key]['jc_uid']];
}
$res_data[$key] = [
'index' => $val['CLUB'] ?? $key,
'type' => !empty($val['TYPE']) ?$val['TYPE']: 'Iron',
'title' => $temp_k[$key]['title']??'--', # 球杆名称
'user_name' => $jc_find['name'], # 用户名称
'user_img' => SiteHelper::getFullUrl($jc_find['avatar_url']), # 用户头像
'time' => date('Y-m-d H:i:s',$temp_k[$key]['created_at']),# 日期
'data' => [],
];
foreach ($val as $k => $v) {
if (empty($v)) {
$v = '-';
}
$res_data[$key]['data'][] = [
'title' => $k,
'value' => $v,
];
}
}
return $res_data;
}
/**
* 大数据分析数据
*/
public function actionGetSystemContent()
{
if (empty($this->data)) {
return $this->apiReturnError('没有传入参数');
}
$json = json_decode($this->data, true);
if (empty($json)) {
return $this->apiReturnError('传入参数错误');
}
if (!is_array($json)) {
return $this->apiReturnError('传入参数错误.');
}
return $this->apiReturnError('stop');
$msg = "大数据评语";
return $this->apiReturnSuccess('ok', [
'content' => $msg,
]);
}
}