Files
shopxo/app/api/controller/User.php

365 lines
11 KiB
PHP
Raw Normal View History

2018-12-28 18:58:37 +08:00
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
2021-03-16 10:34:52 +08:00
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
2018-12-28 18:58:37 +08:00
// +----------------------------------------------------------------------
2021-03-16 10:34:52 +08:00
// | Licensed ( https://opensource.org/licenses/mit-license.php )
2018-12-28 18:58:37 +08:00
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\api\controller;
2021-07-20 23:45:54 +08:00
use app\service\ApiService;
2021-04-11 15:51:06 +08:00
use app\service\SystemBaseService;
use app\service\UserService;
use app\service\OrderService;
use app\service\GoodsService;
use app\service\MessageService;
2019-07-03 21:03:28 +08:00
use app\service\AppCenterNavService;
2020-01-06 18:53:24 +08:00
use app\service\BuyService;
2020-07-03 23:18:46 +08:00
use app\service\GoodsFavorService;
use app\service\GoodsBrowseService;
use app\service\IntegralService;
2021-11-16 15:05:13 +08:00
use app\service\AppMiniUserService;
use app\service\GoodsCartService;
2018-12-28 18:58:37 +08:00
/**
* 用户
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class User extends Common
{
/**
* 构造方法
2018-12-28 18:58:37 +08:00
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-03T12:39:08+0800
*/
public function __construct()
{
// 调用父类前置方法
parent::__construct();
}
/**
* 用户登录
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-03-04
* @desc description
2018-12-28 18:58:37 +08:00
*/
public function Login()
2018-12-28 18:58:37 +08:00
{
return ApiService::ApiDataReturn(UserService::Login($this->data_request));
}
2018-12-28 18:58:37 +08:00
/**
* 用户登录-验证码发送
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-03-04
* @desc description
*/
public function LoginVerifySend()
{
return ApiService::ApiDataReturn(UserService::LoginVerifySend($this->data_request));
2018-12-28 18:58:37 +08:00
}
/**
2024-12-25 17:35:54 +08:00
* 用户基础信息手机
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-03-04
* @desc description
*/
public function Reg()
{
return ApiService::ApiDataReturn(UserService::Reg($this->data_request));
}
/**
* 用户注册-验证码发送
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-03-04
* @desc description
2018-12-28 18:58:37 +08:00
*/
public function RegVerifySend()
{
return ApiService::ApiDataReturn(UserService::RegVerifySend($this->data_request));
}
2018-12-28 18:58:37 +08:00
/**
* 密码找回
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-03-04
* @desc description
*/
public function ForgetPwd()
{
return ApiService::ApiDataReturn(UserService::ForgetPwd($this->data_request));
2018-12-28 18:58:37 +08:00
}
/**
* 密码找回-验证码发送
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-03-04
* @desc description
*/
public function ForgetPwdVerifySend()
{
return ApiService::ApiDataReturn(UserService::ForgetPwdVerifySend($this->data_request));
}
/**
2021-11-30 18:54:21 +08:00
* app用户手机绑定
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-03-04
* @desc description
*/
2021-11-30 18:54:21 +08:00
public function AppMobileBind()
{
return ApiService::ApiDataReturn(UserService::AppMobileBind($this->data_request));
}
/**
2021-11-30 18:54:21 +08:00
* app用户手机绑定-验证码发送
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-03-04
* @desc description
*/
2021-11-30 18:54:21 +08:00
public function AppMobileBindVerifySend()
{
return ApiService::ApiDataReturn(UserService::AppMobileBindVerifySend($this->data_request));
}
2024-04-15 10:25:01 +08:00
/**
* app用户邮箱绑定
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-03-04
* @desc description
*/
public function AppEmailBind()
{
return ApiService::ApiDataReturn(UserService::AppEmailBind($this->data_request));
}
/**
* app用户邮箱绑定-验证码发送
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-03-04
* @desc description
*/
public function AppEmailBindVerifySend()
{
return ApiService::ApiDataReturn(UserService::AppEmailBindVerifySend($this->data_request));
}
/**
2021-11-30 18:54:21 +08:00
* 用户-验证码显示
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-03-04
* @desc description
*/
2021-11-30 18:54:21 +08:00
public function UserVerifyEntry()
{
2021-11-30 18:54:21 +08:00
$params = [
'width' => 100,
'height' => 28,
'key_prefix' => input('type', 'user_reg'),
2023-08-27 16:59:15 +08:00
'expire_time' => MyC('common_verify_expire_time'),
2021-11-30 18:54:21 +08:00
];
$verify = new \base\Verify($params);
$verify->Entry();
}
2021-11-18 10:29:47 +08:00
2021-12-07 18:16:37 +08:00
/**
* 根据token获取用户信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-11-15
* @desc description
*/
public function TokenUserinfo()
{
return ApiService::ApiDataReturn(UserService::TokenUserinfo($this->data_request));
}
2021-11-18 10:29:47 +08:00
/**
2021-11-16 15:05:13 +08:00
* 小程序用户授权
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
2021-11-16 15:05:13 +08:00
* @date 2021-11-15
2018-12-28 18:58:37 +08:00
* @desc description
*/
2021-11-16 15:05:13 +08:00
public function AppMiniUserAuth()
2018-12-28 18:58:37 +08:00
{
2021-11-16 15:05:13 +08:00
$module = '\app\service\AppMiniUserService';
$action = ucfirst(APPLICATION_CLIENT_TYPE).'UserAuth';
if(method_exists($module, $action))
2018-12-28 18:58:37 +08:00
{
$ret = AppMiniUserService::$action($this->data_request);
2021-07-20 23:45:54 +08:00
} else {
2021-11-16 15:05:13 +08:00
$ret = DataReturn('方法未定义['.$action.']', -1);
2018-12-28 18:58:37 +08:00
}
2021-07-20 23:45:54 +08:00
return ApiService::ApiDataReturn($ret);
2018-12-28 18:58:37 +08:00
}
2019-11-29 20:53:08 +08:00
/**
2021-11-16 15:05:13 +08:00
* 小程序用户信息
* @author Devil
2019-10-31 14:51:15 +08:00
* @blog http://gong.gg/
* @version 1.0.0
2021-11-16 15:05:13 +08:00
* @date 2021-11-15
2019-10-31 14:51:15 +08:00
* @desc description
*/
2021-11-16 15:05:13 +08:00
public function AppMiniUserInfo()
2019-10-31 14:51:15 +08:00
{
2021-11-16 15:05:13 +08:00
$module = '\app\service\AppMiniUserService';
$action = ucfirst(APPLICATION_CLIENT_TYPE).'UserInfo';
if(method_exists($module, $action))
2019-10-31 14:51:15 +08:00
{
$ret = AppMiniUserService::$action($this->data_request);
2019-10-31 14:51:15 +08:00
} else {
2021-11-16 15:05:13 +08:00
$ret = DataReturn('方法未定义['.$action.']', -1);
2019-10-31 14:51:15 +08:00
}
2021-07-20 23:45:54 +08:00
return ApiService::ApiDataReturn($ret);
2019-10-31 14:51:15 +08:00
}
2018-12-28 18:58:37 +08:00
/**
* 用户中心
2018-12-28 18:58:37 +08:00
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-05-21T15:21:52+0800
*/
public function Center()
{
2024-12-25 17:35:54 +08:00
if(empty($this->user))
{
$user_order_count = 0;
$user_goods_favor_count = 0;
$user_goods_browse_count = 0;
$message_total = 0;
$user_integral = 0;
$cart_total = [];
} else {
// 订单总数
$where = [
['user_id', '=', $this->user['id']],
['is_delete_time', '=', 0],
['user_is_delete_time', '=', 0],
];
$user_order_count = OrderService::OrderTotal($where);
2018-12-28 18:58:37 +08:00
2024-12-25 17:35:54 +08:00
// 商品收藏总数
$where = [
['user_id', '=', $this->user['id']],
];
$user_goods_favor_count = GoodsFavorService::GoodsFavorTotal($where);
2018-12-28 18:58:37 +08:00
2024-12-25 17:35:54 +08:00
// 商品浏览总数
$where = [
['user_id', '=', $this->user['id']],
];
$user_goods_browse_count = GoodsBrowseService::GoodsBrowseTotal($where);
2018-12-28 18:58:37 +08:00
2024-12-25 17:35:54 +08:00
// 未读消息总数
$params = ['user'=>$this->user, 'is_more'=>1, 'is_read'=>0];
$message_total = MessageService::UserMessageTotal($params);
2018-12-28 18:58:37 +08:00
2024-12-25 17:35:54 +08:00
// 用户积分
$integral = IntegralService::UserIntegral($params['user']['id']);
$user_integral = (!empty($integral) && !empty($integral['integral'])) ? $integral['integral'] : 0;
}
2018-12-28 18:58:37 +08:00
// 用户订单状态
2024-12-25 17:35:54 +08:00
$uos_res = OrderService::OrderStatusStepTotal(['user_type'=>'user', 'user'=>empty($this->user) ? '' : $this->user, 'is_comments'=>1, 'is_aftersale'=>1]);
$user_order_status = $uos_res['data'];
2018-12-28 18:58:37 +08:00
2024-12-25 17:35:54 +08:00
// 购物车计数数据
$cart_total = GoodsCartService::UserGoodsCartTotal(empty($this->user) ? [] : ['user'=>$this->user]);
2020-07-03 23:18:46 +08:00
2018-12-28 18:58:37 +08:00
// 初始化数据
2024-12-25 17:35:54 +08:00
$result = [
'integral' => $user_integral,
2024-12-25 17:35:54 +08:00
'avatar' => empty($this->user['avatar']) ? '' : $this->user['avatar'],
'nickname' => empty($this->user['nickname']) ? '' : $this->user['nickname'],
'username' => empty($this->user['username']) ? '' : $this->user['username'],
'user_name_view' => empty($this->user['user_name_view']) ? '' : $this->user['user_name_view'],
'user_order_status' => $user_order_status,
'user_order_count' => $user_order_count,
'user_goods_favor_count' => $user_goods_favor_count,
'user_goods_browse_count' => $user_goods_browse_count,
'message_total' => $message_total,
'navigation' => AppCenterNavService::AppCenterNav(),
2024-12-25 17:35:54 +08:00
'cart_total' => $cart_total,
];
2021-07-20 23:45:54 +08:00
return ApiService::ApiDataReturn(SystemBaseService::DataReturn($result));
2018-12-28 18:58:37 +08:00
}
/**
2024-12-25 17:35:54 +08:00
* 小程序用户手机并一键绑定
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-09-20
* @desc description
*/
2020-09-21 10:03:26 +08:00
public function OnekeyUserMobileBind()
{
return ApiService::ApiDataReturn(AppMiniUserService::AppMiniOnekeyUserMobileBind($this->data_request));
}
2024-12-25 17:35:54 +08:00
/**
* 小程序用户手机解密
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-09-20
* @desc description
*/
public function OnekeyUserMobileDecrypt()
{
return ApiService::ApiDataReturn(AppMiniUserService::AppMiniOnekeyUserMobileDecrypt($this->data_request));
}
/**
* 小程序用户基础信息注册
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-09-20
* @desc description
*/
public function UserBaseReg()
{
return ApiService::ApiDataReturn(AppMiniUserService::AppMiniUserBaseReg($this->data_request));
}
2018-12-28 18:58:37 +08:00
}
?>