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

295 lines
8.6 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
{
2021-07-20 23:45:54 +08:00
return ApiService::ApiDataReturn(UserService::Login($this->data_post));
}
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()
{
2021-07-20 23:45:54 +08:00
return ApiService::ApiDataReturn(UserService::LoginVerifySend($this->data_post));
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 Reg()
{
2021-07-20 23:45:54 +08:00
return ApiService::ApiDataReturn(UserService::Reg($this->data_post));
}
/**
* 用户注册-验证码发送
* @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()
{
2021-07-20 23:45:54 +08:00
return ApiService::ApiDataReturn(UserService::RegVerifySend($this->data_post));
}
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()
{
2021-07-20 23:45:54 +08:00
return ApiService::ApiDataReturn(UserService::ForgetPwd($this->data_post));
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()
{
2021-07-20 23:45:54 +08:00
return ApiService::ApiDataReturn(UserService::ForgetPwdVerifySend($this->data_post));
}
/**
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()
{
2021-11-30 18:54:21 +08:00
return ApiService::ApiDataReturn(UserService::AppMobileBind($this->data_post));
}
/**
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()
{
2021-11-30 18:54:21 +08:00
return ApiService::ApiDataReturn(UserService::AppMobileBindVerifySend($this->data_post));
}
/**
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'),
];
$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
{
2021-11-16 15:05:13 +08:00
$ret = AppMiniUserService::$action($this->data_post);
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
{
2021-11-16 15:05:13 +08:00
$ret = AppMiniUserService::$action($this->data_post);
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()
{
// 登录校验
2019-03-02 23:17:30 +08:00
$this->IsLogin();
2018-12-28 18:58:37 +08:00
// 订单总数
2019-01-10 11:49:18 +08:00
$where = ['user_id'=>$this->user['id'], 'is_delete_time'=>0, 'user_is_delete_time'=>0];
2018-12-28 18:58:37 +08:00
$user_order_count = OrderService::OrderTotal($where);
// 商品收藏总数
$where = ['user_id'=>$this->user['id']];
2020-07-03 23:18:46 +08:00
$user_goods_favor_count = GoodsFavorService::GoodsFavorTotal($where);
2018-12-28 18:58:37 +08:00
// 商品浏览总数
$where = ['user_id'=>$this->user['id']];
2020-07-03 23:18:46 +08:00
$user_goods_browse_count = GoodsBrowseService::GoodsBrowseTotal($where);
2018-12-28 18:58:37 +08:00
// 未读消息总数
2019-01-10 11:48:09 +08:00
$params = ['user'=>$this->user, 'is_more'=>1, 'is_read'=>0];
2018-12-28 18:58:37 +08:00
$common_message_total = MessageService::UserMessageTotal($params);
// 用户订单状态
2019-10-07 18:06:26 +08:00
$user_order_status = OrderService::OrderStatusStepTotal(['user_type'=>'user', 'user'=>$this->user, 'is_comments'=>1, 'is_aftersale'=>1]);
2018-12-28 18:58:37 +08:00
2020-07-03 23:18:46 +08:00
// 用户积分
2021-03-06 13:10:20 +08:00
$integral = IntegralService::UserIntegral($params['user']['id']);
$user_integral = (!empty($integral) && !empty($integral['integral'])) ? $integral['integral'] : 0;
2020-07-03 23:18:46 +08:00
2018-12-28 18:58:37 +08:00
// 初始化数据
$result = array(
2020-07-03 23:18:46 +08:00
'integral' => $user_integral,
2018-12-28 18:58:37 +08:00
'avatar' => $this->user['avatar'],
'nickname' => $this->user['nickname'],
'username' => $this->user['username'],
2020-12-06 13:28:34 +08:00
'user_name_view' => $this->user['user_name_view'],
2018-12-28 18:58:37 +08:00
'user_order_status' => $user_order_status['data'],
'user_order_count' => $user_order_count,
'user_goods_favor_count' => $user_goods_favor_count,
'user_goods_browse_count' => $user_goods_browse_count,
'common_message_total' => $common_message_total,
2019-07-03 21:03:28 +08:00
'navigation' => AppCenterNavService::AppCenterNav(),
'common_cart_total' => GoodsCartService::UserGoodsCartTotal(['user'=>$this->user]),
2018-12-28 18:58:37 +08:00
);
// 返回数据
2021-07-20 23:45:54 +08:00
return ApiService::ApiDataReturn(SystemBaseService::DataReturn($result));
2018-12-28 18:58:37 +08:00
}
/**
2020-09-21 10:03:26 +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_post));
}
2018-12-28 18:58:37 +08:00
}
?>