2025-11-21 19:13:01 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace app\KitchenScale2\controller\app;
|
|
|
|
|
|
|
|
|
|
|
|
use think\Db;
|
2025-11-28 19:45:05 +08:00
|
|
|
|
use app\KitchenScale2\controller\app\Countfood;
|
2025-11-21 19:13:01 +08:00
|
|
|
|
|
|
|
|
|
|
class Usercenter extends Base{
|
|
|
|
|
|
|
|
|
|
|
|
protected $code_time = 50;
|
|
|
|
|
|
// protected $token_time = 2592000;//30天的秒数
|
|
|
|
|
|
protected $default_head_pic = 'http://tc.pcxbc.com/tsf/head_pic.png';
|
|
|
|
|
|
protected $page_num = 20;
|
|
|
|
|
|
protected $reedaw_db_msg = [
|
|
|
|
|
|
'zhanghao'=>'app_account_number',//账号表
|
|
|
|
|
|
'juese'=>'app_user_data',//角色表
|
|
|
|
|
|
];
|
|
|
|
|
|
protected $kitchenscale_db_msg = [
|
|
|
|
|
|
'cookbook'=>'app_user_cookbook',//菜谱表
|
|
|
|
|
|
'cookbook_label'=>'app_user_cookbook_label',//菜谱标签表
|
|
|
|
|
|
'uploadimg'=>'app_user_upload_img',//图片素材表
|
|
|
|
|
|
'foodlist1'=>'app_z_national_standard_food_type_1',//食材列表1
|
|
|
|
|
|
'foodlist2'=>'app_z_national_standard_food_type_2',//食材列表2
|
|
|
|
|
|
'foodlist3'=>'app_z_national_standard_food_type_3',//食材列表3
|
|
|
|
|
|
'collect_list'=>'app_user_collect_list',//点赞表
|
|
|
|
|
|
'banner'=>'app_banner_data',//banner
|
|
|
|
|
|
'user'=>'app_user_data',//用户表
|
|
|
|
|
|
'search_history'=>'app_user_search_history',//用户搜索表
|
|
|
|
|
|
'business_cooperation'=>'app_business_cooperation_log',//商务合作
|
|
|
|
|
|
'eat_log'=>'app_user_kcal_log',//食材列表3
|
|
|
|
|
|
];
|
2025-12-19 21:44:56 +08:00
|
|
|
|
protected $language_country = [
|
|
|
|
|
|
'zh' => '中文', // 中文(简体)★
|
|
|
|
|
|
'en' => 'English', // 英语(通用)★
|
|
|
|
|
|
'jp' => '日本語', // 日语(变化)
|
|
|
|
|
|
'fra' => 'Français', // 法语(变化)
|
|
|
|
|
|
'de' => 'Deutsch', // 德语
|
|
|
|
|
|
'kor' => '한국어', // 韩语(变化)
|
|
|
|
|
|
'ru' => 'Русский', // 俄语
|
|
|
|
|
|
'pt' => 'Português', // 葡萄牙
|
|
|
|
|
|
'spa' => 'Español', // 西班牙(变化)
|
|
|
|
|
|
'ara' => 'العربية', // 阿拉伯(变化)
|
|
|
|
|
|
];
|
2025-11-21 19:13:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 加 bcadd(,,20)
|
|
|
|
|
|
// 减 bcsub(,,20)
|
|
|
|
|
|
// 乘 bcmul(,,20)
|
|
|
|
|
|
// 除 bcdiv(,,20)
|
|
|
|
|
|
################################################################接口################################################################
|
|
|
|
|
|
################################################################接口################################################################
|
|
|
|
|
|
################################################################接口################################################################
|
|
|
|
|
|
|
|
|
|
|
|
// 获取角色信息
|
2025-11-28 19:45:05 +08:00
|
|
|
|
public function get_user_msg(){
|
|
|
|
|
|
try {
|
|
|
|
|
|
$data = input('post.');
|
2025-11-21 19:13:01 +08:00
|
|
|
|
if(!array_key_exists('token', $data)){
|
|
|
|
|
|
return $this->msg(10001);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
|
}
|
|
|
|
|
|
$return_data = $this->get_user_msg_action($data);
|
|
|
|
|
|
return $return_data;
|
2025-11-28 19:45:05 +08:00
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
// 捕获异常
|
|
|
|
|
|
$logContent["flie"] = $e->getFile();
|
|
|
|
|
|
$logContent["line"] = $e->getLine();
|
|
|
|
|
|
$logContent['all_content'] = "异常信息:\n";
|
|
|
|
|
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "接口: (get_default_config)\n";
|
|
|
|
|
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
|
|
|
|
|
$this->record_api_log($data, $logContent, null);
|
|
|
|
|
|
return $this->msg(99999);
|
|
|
|
|
|
}
|
2025-11-21 19:13:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 修改用户
|
|
|
|
|
|
public function update_user_msg(){
|
|
|
|
|
|
try {
|
2025-11-28 19:45:05 +08:00
|
|
|
|
$data = input('post.');
|
2025-11-21 19:13:01 +08:00
|
|
|
|
if(!array_key_exists('token', $data)){
|
|
|
|
|
|
return $this->msg(10001,'token is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('nickname', $data)){
|
|
|
|
|
|
return $this->msg(10001,'nickname is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('gender', $data)){
|
|
|
|
|
|
return $this->msg(10001,'gender is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('birthday', $data)){
|
|
|
|
|
|
return $this->msg(10001,'birthday is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('height', $data)){
|
|
|
|
|
|
return $this->msg(10001,'height is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('weight', $data)){
|
|
|
|
|
|
return $this->msg(10001,'weight is miss');
|
|
|
|
|
|
}
|
2025-11-28 19:45:05 +08:00
|
|
|
|
if(!array_key_exists('activity_level', $data)){
|
|
|
|
|
|
return $this->msg(10001,'weight is miss');
|
|
|
|
|
|
}
|
2025-11-21 19:13:01 +08:00
|
|
|
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'token type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['nickname'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'nickname type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['gender'],'intnum')){
|
|
|
|
|
|
return $this->msg(10005,'gender type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['birthday'],'datetime')){
|
|
|
|
|
|
return $this->msg(10005,'birthday type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['height'],'num')){
|
|
|
|
|
|
return $this->msg(10005,'height type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['weight'],'num')){
|
|
|
|
|
|
return $this->msg(10005,'weight type is error');
|
|
|
|
|
|
}
|
2025-11-28 19:45:05 +08:00
|
|
|
|
if(!$this->verify_data_is_ok($data['activity_level'],'num')){
|
|
|
|
|
|
return $this->msg(10005,'activity_level type is error');
|
|
|
|
|
|
}
|
2025-11-21 19:13:01 +08:00
|
|
|
|
$return_data = $this->update_user_msg_action($data);
|
|
|
|
|
|
return $return_data;
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
// 捕获异常
|
|
|
|
|
|
$logContent["flie"] = $e->getFile();
|
|
|
|
|
|
$logContent["line"] = $e->getLine();
|
|
|
|
|
|
$logContent['all_content'] = "异常信息:\n";
|
|
|
|
|
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "接口: (get_default_config)\n";
|
|
|
|
|
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
|
|
|
|
|
$this->record_api_log($data, $logContent, null);
|
|
|
|
|
|
return $this->msg(99999);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取用户收藏点赞列表(OK)
|
2025-11-28 19:45:05 +08:00
|
|
|
|
public function get_user_collect_list(){
|
2025-11-21 19:13:01 +08:00
|
|
|
|
try {
|
2025-11-28 19:45:05 +08:00
|
|
|
|
$data = input('post.');
|
2025-11-21 19:13:01 +08:00
|
|
|
|
if(!array_key_exists('token', $data)){
|
|
|
|
|
|
return $this->msg(10001,'token is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('page', $data)){
|
|
|
|
|
|
return $this->msg(10001,'page is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'token type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['page'],'intnum')){
|
|
|
|
|
|
return $this->msg(10005,'page type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
$return_data = $this->get_user_collect_list_action($data);
|
|
|
|
|
|
return $return_data;
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
// 捕获异常
|
|
|
|
|
|
$logContent["flie"] = $e->getFile();
|
|
|
|
|
|
$logContent["line"] = $e->getLine();
|
|
|
|
|
|
$logContent['all_content'] = "异常信息:\n";
|
|
|
|
|
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "接口: (get_default_config)\n";
|
|
|
|
|
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
|
|
|
|
|
$this->record_api_log($data, $logContent, null);
|
|
|
|
|
|
return $this->msg(99999);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 我的菜谱
|
2025-11-28 19:45:05 +08:00
|
|
|
|
public function get_my_cookbook(){
|
2025-11-21 19:13:01 +08:00
|
|
|
|
try {
|
2025-11-28 19:45:05 +08:00
|
|
|
|
$data = input('post.');
|
2025-11-21 19:13:01 +08:00
|
|
|
|
if(!array_key_exists('token', $data)){
|
|
|
|
|
|
return $this->msg(10001,'token is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('page', $data)){
|
|
|
|
|
|
return $this->msg(10001,'page is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'token type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['page'],'intnum')){
|
|
|
|
|
|
return $this->msg(10005,'page type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
$return_data = $this->get_my_cookbook_action($data);
|
|
|
|
|
|
return $return_data;
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
// 捕获异常
|
|
|
|
|
|
$logContent["flie"] = $e->getFile();
|
|
|
|
|
|
$logContent["line"] = $e->getLine();
|
|
|
|
|
|
$logContent['all_content'] = "异常信息:\n";
|
|
|
|
|
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "接口: (get_default_config)\n";
|
|
|
|
|
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
|
|
|
|
|
$this->record_api_log($data, $logContent, null);
|
|
|
|
|
|
return $this->msg(99999);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 菜谱删除
|
2025-11-28 19:45:05 +08:00
|
|
|
|
public function del_my_cookbook(){
|
2025-11-21 19:13:01 +08:00
|
|
|
|
try {
|
2025-11-28 19:45:05 +08:00
|
|
|
|
$data = input('post.');
|
2025-11-21 19:13:01 +08:00
|
|
|
|
if(!array_key_exists('token', $data)){
|
|
|
|
|
|
return $this->msg(10001,'token is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('aud_id', $data)){
|
|
|
|
|
|
return $this->msg(10001,'aud_id is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('cookbook_id', $data)){
|
|
|
|
|
|
return $this->msg(10001,'cookbook_id is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'token type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['aud_id'],'intnum')){
|
|
|
|
|
|
return $this->msg(10005,'aud_id type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['cookbook_id'],'intnum')){
|
|
|
|
|
|
return $this->msg(10005,'cookbook_id type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
$return_data = $this->del_my_cookbook_action($data);
|
|
|
|
|
|
return $return_data;
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
// 捕获异常
|
|
|
|
|
|
$logContent["flie"] = $e->getFile();
|
|
|
|
|
|
$logContent["line"] = $e->getLine();
|
|
|
|
|
|
$logContent['all_content'] = "异常信息:\n";
|
|
|
|
|
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "接口: (get_default_config)\n";
|
|
|
|
|
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
|
|
|
|
|
$this->record_api_log($data, $logContent, null);
|
|
|
|
|
|
return $this->msg(99999);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 搜索历史删除
|
|
|
|
|
|
public function del_search_history(){
|
|
|
|
|
|
// 尝试捕获异常
|
|
|
|
|
|
try {
|
2025-11-28 19:45:05 +08:00
|
|
|
|
$data = input('post.');
|
2025-11-21 19:13:01 +08:00
|
|
|
|
if(!array_key_exists('token', $data)){
|
|
|
|
|
|
return $this->msg(10001,'token is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'token type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('del_arr', $data)){
|
|
|
|
|
|
return $this->msg(10001,'del_arr is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['del_arr'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'del_arr type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
$data['del_arr'] = strval($data['del_arr']);
|
|
|
|
|
|
$data['del_arr'] = trim($data['del_arr']);
|
|
|
|
|
|
// 判断是否是 "all"(不区分大小写)
|
|
|
|
|
|
if (strtolower($data['del_arr']) !== 'all' && preg_match('/^\d+(,\d+)*$/', $data['del_arr']) !== 1) {
|
|
|
|
|
|
return $this->msg(10005,'del_arr type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$return_data = $this->del_search_history_action($data);
|
|
|
|
|
|
return $return_data;
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
// 捕获异常
|
|
|
|
|
|
$logContent["flie"] = $e->getFile();
|
|
|
|
|
|
$logContent["line"] = $e->getLine();
|
|
|
|
|
|
$logContent['all_content'] = "异常信息:\n";
|
|
|
|
|
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
|
|
|
|
|
// 记录日志
|
|
|
|
|
|
$this->record_api_log($data, $logContent, null);
|
|
|
|
|
|
return json(['status' => 'error', 'message' => '系统错误']);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 商务合作
|
|
|
|
|
|
public function business_cooperation(){
|
|
|
|
|
|
return $this->fetch();
|
|
|
|
|
|
}
|
2025-11-28 19:45:05 +08:00
|
|
|
|
|
|
|
|
|
|
// 设置营养比例
|
|
|
|
|
|
public function set_nutrition_proportion(){
|
|
|
|
|
|
// 尝试捕获异常
|
|
|
|
|
|
try {
|
|
|
|
|
|
$data = input('post.');
|
|
|
|
|
|
if(!array_key_exists('token', $data)){
|
|
|
|
|
|
return $this->msg(10001,'token is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'token type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('set_kcal', $data)){
|
|
|
|
|
|
return $this->msg(10001,'set_kcal is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['set_kcal'],'num')){
|
|
|
|
|
|
return $this->msg(10005,'set_kcal type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!array_key_exists('carbohydrate_v', $data)){
|
|
|
|
|
|
return $this->msg(10001,'carbohydrate_v is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['carbohydrate_v'],'num')){
|
|
|
|
|
|
return $this->msg(10005,'carbohydrate_v type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('carbohydrate_p', $data)){
|
|
|
|
|
|
return $this->msg(10001,'carbohydrate_p is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['carbohydrate_p'],'num')){
|
|
|
|
|
|
return $this->msg(10005,'carbohydrate_p type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!array_key_exists('protein_v', $data)){
|
|
|
|
|
|
return $this->msg(10001,'protein_v is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['protein_v'],'num')){
|
|
|
|
|
|
return $this->msg(10005,'protein_v type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('protein_p', $data)){
|
|
|
|
|
|
return $this->msg(10001,'protein_p is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['protein_p'],'num')){
|
|
|
|
|
|
return $this->msg(10005,'protein_p type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!array_key_exists('fat_v', $data)){
|
|
|
|
|
|
return $this->msg(10001,'fat_v is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['fat_v'],'num')){
|
|
|
|
|
|
return $this->msg(10005,'fat_v type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('fat_p', $data)){
|
|
|
|
|
|
return $this->msg(10001,'fat_p is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['fat_p'],'num')){
|
|
|
|
|
|
return $this->msg(10005,'fat_p type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// $data['del_arr'] = strval($data['del_arr']);
|
|
|
|
|
|
// $data['del_arr'] = trim($data['del_arr']);
|
|
|
|
|
|
// 判断是否是 "all"(不区分大小写)
|
|
|
|
|
|
// if (strtolower($data['del_arr']) !== 'all' && preg_match('/^\d+(,\d+)*$/', $data['del_arr']) !== 1) {
|
|
|
|
|
|
// return $this->msg(10005,'del_arr type is error');
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
$return_data = $this->set_nutrition_proportion_action($data);
|
|
|
|
|
|
return $return_data;
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
// 捕获异常
|
|
|
|
|
|
$logContent["flie"] = $e->getFile();
|
|
|
|
|
|
$logContent["line"] = $e->getLine();
|
|
|
|
|
|
$logContent['all_content'] = "异常信息:\n";
|
|
|
|
|
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
|
|
|
|
|
// 记录日志
|
|
|
|
|
|
$this->record_api_log($data, $logContent, null);
|
|
|
|
|
|
return json(['status' => 'error', 'message' => '系统错误']);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 重置密码
|
|
|
|
|
|
public function update_my_password(){
|
|
|
|
|
|
try {
|
|
|
|
|
|
$data = input('post.');
|
|
|
|
|
|
if(!array_key_exists('token', $data)){
|
|
|
|
|
|
return $this->msg(10001,'token is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('password', $data)){
|
|
|
|
|
|
return $this->msg(10001,'password is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('c_password', $data)){
|
|
|
|
|
|
return $this->msg(10001,'c_password is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'token type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if($data['password'] != $data['c_password']){
|
|
|
|
|
|
return $this->msg(10005,'两次密码不一致');
|
|
|
|
|
|
}
|
|
|
|
|
|
if($data['password'] == ''){
|
|
|
|
|
|
return $this->msg(10005,'密码不能为空');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['password'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'password type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['c_password'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'c_password type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
$return_data = $this->update_my_password_action($data);
|
|
|
|
|
|
return $return_data;
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
// 捕获异常
|
|
|
|
|
|
$logContent["flie"] = $e->getFile();
|
|
|
|
|
|
$logContent["line"] = $e->getLine();
|
|
|
|
|
|
$logContent['all_content'] = "异常信息:\n";
|
|
|
|
|
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "接口: (get_default_config)\n";
|
|
|
|
|
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
|
|
|
|
|
$this->record_api_log($data, $logContent, null);
|
|
|
|
|
|
return $this->msg(99999);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 绑定手机/邮箱
|
|
|
|
|
|
public function update_my_account_msg(){
|
|
|
|
|
|
try {
|
|
|
|
|
|
$data = input('post.');
|
|
|
|
|
|
if(!array_key_exists('token', $data)){
|
|
|
|
|
|
return $this->msg(10001,'token is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('data', $data)){
|
|
|
|
|
|
return $this->msg(10001,'data is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('code', $data)){
|
|
|
|
|
|
return $this->msg(10001,'code is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'token type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['data'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'data type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['code'],'intnum')){
|
|
|
|
|
|
return $this->msg(10005,'code type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
$return_data = $this->update_my_account_msg_action($data);
|
|
|
|
|
|
return $return_data;
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
// 捕获异常
|
|
|
|
|
|
$logContent["flie"] = $e->getFile();
|
|
|
|
|
|
$logContent["line"] = $e->getLine();
|
|
|
|
|
|
$logContent['all_content'] = "异常信息:\n";
|
|
|
|
|
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "接口: (get_default_config)\n";
|
|
|
|
|
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
|
|
|
|
|
$this->record_api_log($data, $logContent, null);
|
|
|
|
|
|
return $this->msg(99999);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-19 21:44:56 +08:00
|
|
|
|
|
|
|
|
|
|
public function update_language(){
|
|
|
|
|
|
try {
|
|
|
|
|
|
$data = input('post.');
|
|
|
|
|
|
if(!array_key_exists('token', $data)){
|
|
|
|
|
|
return $this->msg(10001,'token is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists('language', $data)){
|
|
|
|
|
|
return $this->msg(10001,'language is miss');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!$this->verify_data_is_ok($data['token'],'str')){
|
|
|
|
|
|
return $this->msg(10005,'token type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!array_key_exists($data['language'],$this->language_country)){
|
|
|
|
|
|
return $this->msg(10005,'language type is error');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$return_data = $this->update_language_action($data);
|
|
|
|
|
|
return $return_data;
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
// 捕获异常
|
|
|
|
|
|
$logContent["flie"] = $e->getFile();
|
|
|
|
|
|
$logContent["line"] = $e->getLine();
|
|
|
|
|
|
$logContent['all_content'] = "异常信息:\n";
|
|
|
|
|
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "接口: (get_default_config)\n";
|
|
|
|
|
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
|
|
|
|
|
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
|
|
|
|
|
$this->record_api_log($data, $logContent, null);
|
|
|
|
|
|
return $this->msg(99999);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-28 19:45:05 +08:00
|
|
|
|
|
2025-11-21 19:13:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#######################################################################action#######################################################################
|
|
|
|
|
|
#######################################################################action#######################################################################
|
|
|
|
|
|
#######################################################################action#######################################################################
|
|
|
|
|
|
|
|
|
|
|
|
public function get_user_msg_action($data){
|
|
|
|
|
|
// 获取账号下信息以及用户信息
|
|
|
|
|
|
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->field('id,token,nickname,head_pic,tel,email')->find();
|
|
|
|
|
|
if(!$user_data){
|
|
|
|
|
|
return $this->msg(10004);
|
|
|
|
|
|
}
|
|
|
|
|
|
// $return_data = [];
|
|
|
|
|
|
// 获取账号下信息以及用户信息start
|
|
|
|
|
|
$user_all_data['aud_id'] = '';
|
|
|
|
|
|
$user_all_data['token'] = $user_data['token'];
|
|
|
|
|
|
$user_all_data['nickname'] = $user_data['nickname'];
|
|
|
|
|
|
$user_all_data['head_pic'] = $user_data['head_pic'];
|
|
|
|
|
|
$user_all_data['gender'] = '';
|
|
|
|
|
|
$user_all_data['age'] = '';
|
|
|
|
|
|
$user_all_data['height'] = '';
|
|
|
|
|
|
$user_all_data['weight'] = '';
|
|
|
|
|
|
$user_all_data['set_kcal'] = '';
|
|
|
|
|
|
$user_all_data['is_use_set_kcal'] = '';
|
|
|
|
|
|
$user_all_data['tel'] = $user_data['tel'];
|
|
|
|
|
|
$user_all_data['email'] = $user_data['email'];
|
|
|
|
|
|
$cfc = Db::connect('cfc_db');
|
2025-12-27 21:27:08 +08:00
|
|
|
|
|
2025-11-21 19:13:01 +08:00
|
|
|
|
$user_account = $cfc->table($this->kitchenscale_db_msg['user'])
|
|
|
|
|
|
->where(["token"=>$data['token']])
|
2025-11-28 19:45:05 +08:00
|
|
|
|
->field('id as aud_id,token,nickname,head_pic,gender,age,height,weight,set_kcal,is_use_set_kcal,birthday,activity_level')
|
2025-11-21 19:13:01 +08:00
|
|
|
|
->find();
|
2025-12-27 21:27:08 +08:00
|
|
|
|
|
2025-11-21 19:13:01 +08:00
|
|
|
|
if($user_account){
|
|
|
|
|
|
if($user_account['set_kcal'] == '.00'){
|
|
|
|
|
|
$user_account['set_kcal'] = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
$user_all_data['aud_id'] = $user_account['aud_id'];
|
|
|
|
|
|
$user_all_data['gender'] = $user_account['gender'];
|
|
|
|
|
|
$user_all_data['age'] = $user_account['age']?$user_account['age']:$this->calculate_age($user_account['birthday']);
|
|
|
|
|
|
$user_all_data['height'] = $user_account['height'];
|
|
|
|
|
|
$user_all_data['weight'] = $user_account['weight'];
|
|
|
|
|
|
$user_all_data['set_kcal'] = $user_account['set_kcal'];
|
|
|
|
|
|
$user_all_data['is_use_set_kcal'] = $user_account['is_use_set_kcal'];
|
|
|
|
|
|
$user_all_data['birthday'] = $user_account['birthday'];
|
2025-11-28 19:45:05 +08:00
|
|
|
|
$user_all_data['activity_level'] = $user_account['activity_level'];
|
|
|
|
|
|
if($user_all_data['gender'] == 2){
|
|
|
|
|
|
if($user_all_data['age'] <= 18){
|
|
|
|
|
|
$user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman1.png";
|
|
|
|
|
|
}else if($user_all_data['age'] <= 39 && $user_all_data['age'] > 18){
|
|
|
|
|
|
$user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman2.png";
|
|
|
|
|
|
}else if($user_all_data['age'] <= 59 && $user_all_data['age'] > 39){
|
|
|
|
|
|
$user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman3.png";
|
|
|
|
|
|
}else if($user_all_data['age'] >= 60){
|
|
|
|
|
|
$user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman4.png";
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if($user_all_data['age'] <= 18){
|
|
|
|
|
|
$user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man1.png";
|
|
|
|
|
|
}else if($user_all_data['age'] <= 39 && $user_all_data['age'] > 18){
|
|
|
|
|
|
$user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man2.png";
|
|
|
|
|
|
}else if($user_all_data['age'] <= 59 && $user_all_data['age'] > 39){
|
|
|
|
|
|
$user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man3.png";
|
|
|
|
|
|
}else if($user_all_data['age'] >= 60){
|
|
|
|
|
|
$user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man4.png";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$countfood = new Countfood;
|
|
|
|
|
|
$user_all_data['food_count'] = $countfood->get_countfoot_content_action(['token'=>$data['token'],'aud_id'=>$user_all_data['aud_id'],'time'=>date('Y-m-d')]);
|
|
|
|
|
|
$user_all_data['food_count'] = ($user_all_data['food_count']->getData())['data'];
|
|
|
|
|
|
// dump($user_all_data['food_count']);
|
2025-11-21 19:13:01 +08:00
|
|
|
|
}else{
|
2025-12-27 21:27:08 +08:00
|
|
|
|
$user_account['set_kcal'] = 0;
|
|
|
|
|
|
$user_all_data['aud_id'] = null;
|
|
|
|
|
|
$user_all_data['gender'] = 0;
|
|
|
|
|
|
$user_all_data['age'] = false;
|
|
|
|
|
|
$user_all_data['height'] = null;
|
|
|
|
|
|
$user_all_data['weight'] = null;
|
|
|
|
|
|
$user_all_data['set_kcal'] = 0;
|
|
|
|
|
|
$user_all_data['is_use_set_kcal'] = 0;
|
|
|
|
|
|
$user_all_data['birthday'] = null;
|
|
|
|
|
|
$user_all_data['activity_level'] = null;
|
|
|
|
|
|
$user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man1.png";
|
|
|
|
|
|
// if($user_all_data['gender'] == 2){
|
|
|
|
|
|
// if($user_all_data['age'] <= 18){
|
|
|
|
|
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman1.png";
|
|
|
|
|
|
// }else if($user_all_data['age'] <= 39 && $user_all_data['age'] > 18){
|
|
|
|
|
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman2.png";
|
|
|
|
|
|
// }else if($user_all_data['age'] <= 59 && $user_all_data['age'] > 39){
|
|
|
|
|
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman3.png";
|
|
|
|
|
|
// }else if($user_all_data['age'] >= 60){
|
|
|
|
|
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/woman4.png";
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }else{
|
|
|
|
|
|
// if($user_all_data['age'] <= 18){
|
|
|
|
|
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man1.png";
|
|
|
|
|
|
// }else if($user_all_data['age'] <= 39 && $user_all_data['age'] > 18){
|
|
|
|
|
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man2.png";
|
|
|
|
|
|
// }else if($user_all_data['age'] <= 59 && $user_all_data['age'] > 39){
|
|
|
|
|
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man3.png";
|
|
|
|
|
|
// }else if($user_all_data['age'] >= 60){
|
|
|
|
|
|
// $user_all_data['head_pic'] = "https://tc.pcxbc.com/kitchenscale_all/man4.png";
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
$countfood = new Countfood;
|
|
|
|
|
|
$user_all_data['food_count'] = $countfood->get_countfoot_content_action(['token'=>$data['token'],'aud_id'=>$user_all_data['aud_id'],'time'=>date('Y-m-d')]);
|
|
|
|
|
|
$user_all_data['food_count'] = ($user_all_data['food_count']->getData())['data'];
|
2025-11-21 19:13:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $return_data = $user_all_data;
|
|
|
|
|
|
return $this->msg($user_all_data);
|
|
|
|
|
|
// 获取账号下信息以及用户信息end
|
|
|
|
|
|
}
|
|
|
|
|
|
public function update_user_msg_action($data){
|
|
|
|
|
|
if($data['gender'] == 0){
|
|
|
|
|
|
return $this->msg(10005,'性别信息错误');
|
|
|
|
|
|
}
|
|
|
|
|
|
// 获取账号下信息以及用户信息
|
|
|
|
|
|
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->count();
|
|
|
|
|
|
if($user_data<=0){
|
|
|
|
|
|
return $this->msg(10005,'账号信息错误');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$cfc = Db::connect('cfc_db');
|
|
|
|
|
|
|
|
|
|
|
|
$is_user_true = $cfc->table($this->kitchenscale_db_msg['user'])->where(['token'=>$data['token']])->count();
|
|
|
|
|
|
|
|
|
|
|
|
$user_msg['nickname'] = $data['nickname'];
|
|
|
|
|
|
$user_msg['head_pic'] = $data['gender'] == 1?'https://tc.pcxbc.com/tsf/1.png':'https://tc.pcxbc.com/tsf/2.png';
|
|
|
|
|
|
$user_msg['gender'] = $data['gender'];
|
|
|
|
|
|
$user_msg['birthday'] = $data['birthday'];
|
|
|
|
|
|
$user_msg['height'] = $data['height'];
|
|
|
|
|
|
$user_msg['weight'] = $data['weight'];
|
2025-11-28 19:45:05 +08:00
|
|
|
|
$user_msg['activity_level'] = $data['activity_level'];
|
2025-11-21 19:13:01 +08:00
|
|
|
|
|
|
|
|
|
|
if($is_user_true>0){
|
|
|
|
|
|
$user_msg['update_time'] = date('Y-m-d H:i:s');
|
|
|
|
|
|
$result = $cfc->table($this->kitchenscale_db_msg['user'])
|
|
|
|
|
|
->where(['token'=>$data['token']])
|
|
|
|
|
|
->update($user_msg);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
$user_msg['token'] = $data['token'];
|
|
|
|
|
|
$result = $cfc->table($this->kitchenscale_db_msg['user'])
|
|
|
|
|
|
->insert($user_msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->update(['nickname'=>$user_msg['nickname']]);
|
|
|
|
|
|
if($result){
|
|
|
|
|
|
return $this->msg([]);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return $this->msg(10002);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public function get_user_collect_list_action($data){
|
|
|
|
|
|
// 获取账号下信息以及用户信息
|
|
|
|
|
|
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->count();
|
|
|
|
|
|
if($user_data<=0){
|
|
|
|
|
|
return $this->msg(10005,'账号信息错误');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$search_sql_str = "a.token = '".$data['token']."' AND a.is_del = 0 AND b.is_del = 0";
|
|
|
|
|
|
if(!array_key_exists('search_data', $data)){
|
|
|
|
|
|
$data['search_data'] = "";
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if($data['search_data'] === ""){
|
|
|
|
|
|
$data['search_data'] = "";
|
|
|
|
|
|
}else{
|
|
|
|
|
|
$data['search_data'] = " AND (b.title LIKE '%".$data['search_data']."%' OR b.describe_data LIKE '%".$data['search_data']."%')";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
$search_sql_str = $search_sql_str.$data['search_data'];
|
|
|
|
|
|
// "a.token = 'asdasdasdasda' AND a.is_del = 0 AND b.title LIKE '%鱼%' OR b.describe_data LIKE '%鱼%'";
|
|
|
|
|
|
|
|
|
|
|
|
$cfc = Db::connect('cfc_db');
|
|
|
|
|
|
|
|
|
|
|
|
$content_num = $cfc->table($this->kitchenscale_db_msg['collect_list'])
|
|
|
|
|
|
->alias('a')
|
|
|
|
|
|
->join($this->kitchenscale_db_msg['cookbook'].' b','a.cookbook_id = b.id','LEFT')
|
|
|
|
|
|
->join($this->kitchenscale_db_msg['uploadimg'].' c','b.cover = c.id','LEFT')
|
|
|
|
|
|
->where($search_sql_str)
|
|
|
|
|
|
->count();
|
|
|
|
|
|
$page_total = ceil($content_num/$this->page_num);;
|
|
|
|
|
|
$collect_list = $cfc->table($this->kitchenscale_db_msg['collect_list'])
|
|
|
|
|
|
->alias('a')
|
|
|
|
|
|
->join($this->kitchenscale_db_msg['cookbook'].' b','a.cookbook_id = b.id','LEFT')
|
|
|
|
|
|
->join($this->kitchenscale_db_msg['uploadimg'].' c','b.cover = c.id','LEFT')
|
|
|
|
|
|
->where($search_sql_str)
|
|
|
|
|
|
->field("b.id,b.title,b.cover as cover_id,c.pic_url as cover_url,b.likes_num,b.create_user_token,b.create_user_head_pic,b.create_user_nickname")
|
|
|
|
|
|
->page($data['page'],$this->page_num)
|
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($collect_list as $key => $value) {
|
|
|
|
|
|
$collect_list[$key]['is_me_like_it'] = 'yes';
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $this->msg([
|
|
|
|
|
|
'page_now'=>$data['page'],
|
|
|
|
|
|
'page_total'=>$page_total,
|
|
|
|
|
|
'content_list'=>$collect_list
|
|
|
|
|
|
]);
|
|
|
|
|
|
}
|
|
|
|
|
|
public function get_my_cookbook_action($data){
|
|
|
|
|
|
// 获取账号下信息以及用户信息
|
|
|
|
|
|
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->count();
|
|
|
|
|
|
if($user_data<=0){
|
|
|
|
|
|
return $this->msg(10005,'账号信息错误');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$search_sql_str = "b.create_user_token = '".$data['token']."' AND b.is_del = 0";
|
|
|
|
|
|
if(!array_key_exists('search_data', $data)){
|
|
|
|
|
|
$data['search_data'] = "";
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if($data['search_data'] === ""){
|
|
|
|
|
|
$data['search_data'] = "";
|
|
|
|
|
|
}else{
|
|
|
|
|
|
$data['search_data'] = " AND (b.title LIKE '%".$data['search_data']."%' OR b.describe_data LIKE '%".$data['search_data']."%')";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
$search_sql_str = $search_sql_str.$data['search_data'];
|
|
|
|
|
|
|
|
|
|
|
|
$cfc = Db::connect('cfc_db');
|
|
|
|
|
|
$content_num = $cfc->table($this->kitchenscale_db_msg['cookbook'])
|
|
|
|
|
|
->alias('b')
|
|
|
|
|
|
->join($this->kitchenscale_db_msg['uploadimg'].' c','b.cover = c.id','LEFT')
|
|
|
|
|
|
->where($search_sql_str)
|
|
|
|
|
|
->count();
|
|
|
|
|
|
$page_total = ceil($content_num/$this->page_num);;
|
|
|
|
|
|
$content_list = $cfc->table($this->kitchenscale_db_msg['cookbook'])
|
|
|
|
|
|
->alias('b')
|
|
|
|
|
|
->join($this->kitchenscale_db_msg['uploadimg'].' c','b.cover = c.id','LEFT')
|
|
|
|
|
|
->where($search_sql_str)
|
|
|
|
|
|
->field("b.id,b.title,b.cover as cover_id,c.pic_url as cover_url,b.likes_num,b.create_user_token,b.create_user_head_pic,b.create_user_nickname")
|
|
|
|
|
|
->page($data['page'],$this->page_num)
|
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
|
|
// 获取用户收藏列表
|
|
|
|
|
|
$my_collect_list = $cfc->table($this->kitchenscale_db_msg['collect_list'])
|
|
|
|
|
|
->where(['token'=>$data['token'],'is_del'=>0])
|
|
|
|
|
|
->column('cookbook_id');
|
|
|
|
|
|
// dump($my_collect_list);
|
|
|
|
|
|
// 处理菜谱收藏信息
|
|
|
|
|
|
foreach ($content_list as $key => $value) {
|
|
|
|
|
|
// if(in_array($value['id'],$my_collect_list)){
|
|
|
|
|
|
if(array_key_exists($value['id'],$my_collect_list)){
|
|
|
|
|
|
$content_list[$key]['is_me_like_it'] = 'yes';
|
|
|
|
|
|
}else{
|
|
|
|
|
|
$content_list[$key]['is_me_like_it'] = 'no';
|
|
|
|
|
|
}
|
|
|
|
|
|
// if($value['cover'] == null){
|
|
|
|
|
|
// $content_list[$key]['cover'] = 'https://tc.pcxbc.com/kitchenscale_all/diule.jpg';
|
|
|
|
|
|
// }
|
|
|
|
|
|
unset($content_list[$key]['ROW_NUMBER']);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// foreach ($collect_list as $key => $value) {
|
|
|
|
|
|
// $collect_list[$key]['is_me_like_it'] = 'yes';
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
return $this->msg([
|
|
|
|
|
|
'page_now'=>$data['page'],
|
|
|
|
|
|
'page_total'=>$page_total,
|
|
|
|
|
|
'content_list'=>$content_list
|
|
|
|
|
|
]);
|
|
|
|
|
|
}
|
|
|
|
|
|
public function del_my_cookbook_action($data){
|
|
|
|
|
|
// 获取账号下信息以及用户信息
|
|
|
|
|
|
$user_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token']])->count();
|
|
|
|
|
|
if($user_data<=0){
|
|
|
|
|
|
return $this->msg(10005,'账号信息错误');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$cfc = Db::connect('cfc_db');
|
|
|
|
|
|
|
|
|
|
|
|
$cookbook_data = $cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id'],'create_user_token'=>$data['token']])->find();
|
|
|
|
|
|
|
|
|
|
|
|
if($cookbook_data){
|
|
|
|
|
|
|
|
|
|
|
|
// 启动事务
|
|
|
|
|
|
$cfc->startTrans();
|
|
|
|
|
|
try{
|
|
|
|
|
|
$cfc->table($this->kitchenscale_db_msg['cookbook'])->where(['id'=>$data['cookbook_id']])->update(['is_del'=>1]);
|
|
|
|
|
|
$result_banner = $cfc->table($this->kitchenscale_db_msg['banner'])->where(['cookbook_id'=>$cookbook_data['id']])->count();
|
|
|
|
|
|
if($result_banner > 0){
|
|
|
|
|
|
$cfc->table($this->kitchenscale_db_msg['banner'])->where(['cookbook_id'=>$cookbook_data['id']])->update(['is_del'=>1]);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 提交事务
|
|
|
|
|
|
$cfc->commit();
|
|
|
|
|
|
return $this->msg([]);
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
// 回滚事务
|
|
|
|
|
|
$cfc->rollback();
|
|
|
|
|
|
return $this->msg(10002);
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return $this->msg(10003);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public function del_search_history_action($data){
|
|
|
|
|
|
|
|
|
|
|
|
// $data['del_arr'] = strval($data['del_arr']);
|
|
|
|
|
|
// $data['del_arr'] = trim($data['del_arr']);
|
|
|
|
|
|
|
|
|
|
|
|
// // 正确的判断逻辑:如果不是all 并且 不是ID列表,就报错
|
|
|
|
|
|
// if (strtolower($data['del_arr']) !== 'all' && preg_match('/^\d+(,\d+)*$/', $data['del_arr']) !== 1) {
|
|
|
|
|
|
// return $this->msg(10005, 'del_arr type is error');
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$cfc = Db::connect('cfc_db');
|
|
|
|
|
|
$user = $cfc->table($this->kitchenscale_db_msg['user'])->where(['token'=>$data['token']])->field('id,token')->find();
|
|
|
|
|
|
if(!$user){
|
|
|
|
|
|
return $this->msg(20001,'账号信息错误');
|
|
|
|
|
|
}
|
|
|
|
|
|
if($data['del_arr'] == 'all'){
|
|
|
|
|
|
$result = $cfc->table($this->kitchenscale_db_msg['search_history'])
|
|
|
|
|
|
->where(['user_id'=>$user['id']])
|
|
|
|
|
|
->update(['is_del'=>1]);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
$result = $cfc->table($this->kitchenscale_db_msg['search_history'])
|
|
|
|
|
|
->where("user_id = ".$user['id']." AND id IN (".$data['del_arr'].")")
|
|
|
|
|
|
->update(['is_del'=>1]);
|
|
|
|
|
|
}
|
|
|
|
|
|
if($result){
|
|
|
|
|
|
return $this->msg([]);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return $this->msg(10002);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取菜谱分类标签end
|
|
|
|
|
|
}
|
|
|
|
|
|
public function business_cooperation_action(){
|
|
|
|
|
|
$data = input();
|
|
|
|
|
|
|
|
|
|
|
|
$cfc = Db::connect('cfc_db');
|
|
|
|
|
|
$result = $cfc->table($this->kitchenscale_db_msg['business_cooperation'])
|
|
|
|
|
|
->insert([
|
|
|
|
|
|
'name'=>$data['name'],
|
|
|
|
|
|
'tel'=>$data['phone'],
|
|
|
|
|
|
'company'=>$data['company'],
|
|
|
|
|
|
'intention_data'=> implode(',',$data['selectedValues']),
|
|
|
|
|
|
'notes_data'=>$data['remark'],
|
|
|
|
|
|
'create_time'=>date('Y-m-s H:i:s'),
|
|
|
|
|
|
]);
|
|
|
|
|
|
if($result){
|
|
|
|
|
|
return $this->msg([]);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return $this->msg(10002);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-28 19:45:05 +08:00
|
|
|
|
public function set_nutrition_proportion_action($data){
|
2025-11-21 19:13:01 +08:00
|
|
|
|
$cfc = Db::connect('cfc_db');
|
2025-11-28 19:45:05 +08:00
|
|
|
|
$result = $cfc->table($this->kitchenscale_db_msg['user'])
|
|
|
|
|
|
->where(['token'=>$data['token']])
|
|
|
|
|
|
->update([
|
|
|
|
|
|
'is_use_set_kcal'=>1,
|
|
|
|
|
|
'set_kcal'=>$data['set_kcal'],
|
|
|
|
|
|
'set_carbohydrate_v'=>$data['carbohydrate_v'],
|
|
|
|
|
|
'set_carbohydrate_p'=>$data['carbohydrate_p'],
|
|
|
|
|
|
'set_protein_v'=>$data['protein_v'],
|
|
|
|
|
|
'set_protein_p'=>$data['protein_p'],
|
|
|
|
|
|
'set_fat_v'=>$data['fat_v'],
|
|
|
|
|
|
'set_fat_p'=>$data['fat_p'],
|
|
|
|
|
|
]);
|
|
|
|
|
|
if($result){
|
|
|
|
|
|
return $this->msg([]);
|
2025-11-21 19:13:01 +08:00
|
|
|
|
}else{
|
2025-11-28 19:45:05 +08:00
|
|
|
|
return $this->msg(10002);
|
2025-11-21 19:13:01 +08:00
|
|
|
|
}
|
2025-11-28 19:45:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
public function update_my_password_action($data){
|
|
|
|
|
|
// $cfc = Db::connect('cfc_db');
|
|
|
|
|
|
// 检查账号是否存在
|
|
|
|
|
|
$find_data = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token'],'is_del'=>0])->count();
|
|
|
|
|
|
if(!$find_data){
|
|
|
|
|
|
return $this->msg(10003);
|
|
|
|
|
|
}
|
|
|
|
|
|
$result = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token'],'is_del'=>0])->update(['password'=>$data['password']]);
|
|
|
|
|
|
if($result){
|
|
|
|
|
|
return $this->msg([]);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return $this->msg(10002);
|
2025-11-21 19:13:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-28 19:45:05 +08:00
|
|
|
|
public function update_my_account_msg_action($data){
|
|
|
|
|
|
$validate_result = $this->check_code($data['data'],$data['code']);
|
|
|
|
|
|
if($validate_result !== true){
|
|
|
|
|
|
return $this->msg(10001,$validate_result);
|
|
|
|
|
|
}
|
|
|
|
|
|
$montage_data = $this->is_tel_email($data['data']);
|
|
|
|
|
|
if($montage_data == false){
|
|
|
|
|
|
return $this->msg(10005);
|
|
|
|
|
|
}
|
|
|
|
|
|
$result = Db::table($this->reedaw_db_msg['zhanghao'])->where(['token'=>$data['token'],'is_del'=>0])->update([
|
|
|
|
|
|
$montage_data=>$data['data'],
|
|
|
|
|
|
'update_time'=>date('Y-m-d H:i:s')
|
|
|
|
|
|
]);
|
|
|
|
|
|
if($result){
|
|
|
|
|
|
return $this->msg([]);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return $this->msg(10002);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-19 21:44:56 +08:00
|
|
|
|
public function update_language_action($data){
|
|
|
|
|
|
$cfc = Db::connect('cfc_db');
|
|
|
|
|
|
$result = $cfc->table($this->kitchenscale_db_msg['user'])->where(['token'=>$data['token']])->update(['language'=>$data['language']]);
|
|
|
|
|
|
if($result){
|
|
|
|
|
|
return $this->msg([]);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return $this->msg([10002]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-28 19:45:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-11-21 19:13:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|