vr-shopxo-source/application/index/controller/User.php

442 lines
12 KiB
PHP
Raw Normal View History

2018-12-28 10:58:37 +00:00
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2018 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\index\controller;
use app\service\OrderService;
use app\service\GoodsService;
use app\service\UserService;
use app\service\BuyService;
/**
* 用户
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-02T22:48:35+0800
*/
class User extends Common
{
/**
* 构造方法
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-11-30
* @desc description
*/
public function __construct()
{
parent::__construct();
}
/**
* [GetrefererUrl 获取上一个页面地址]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-09T15:46:16+0800
*/
private function GetrefererUrl()
{
// 上一个页面, 空则用户中心
$referer_url = empty($_SERVER['HTTP_REFERER']) ? MyUrl('index/user/index') : $_SERVER['HTTP_REFERER'];
if(!empty($_SERVER['HTTP_REFERER']))
{
$all = ['logininfo', 'reginfo', 'smsreginfo', 'emailreginfo', 'forgetpwdinfo'];
foreach($all as $v)
{
if(strpos($_SERVER['HTTP_REFERER'], $v) !== false)
{
$referer_url = MyUrl('index/user/index');
break;
}
}
}
return $referer_url;
}
/**
* [Index 用户中心]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-02T22:48:35+0800
*/
public function Index()
{
// 登录校验
$this->Is_Login();
// 订单总数
$where = ['user_id'=>$this->user['id'], 'is_delete_time'=>0, 'user_is_delete_time'=>0];
$this->assign('user_order_count', OrderService::OrderTotal($where));
// 商品收藏总数
$where = ['user_id'=>$this->user['id']];
$this->assign('user_goods_favor_count', GoodsService::GoodsFavorTotal($where));
// 商品浏览总数
$where = ['user_id'=>$this->user['id']];
$this->assign('user_goods_browse_count', GoodsService::GoodsBrowseTotal($where));
// 用户订单状态
$user_order_status = OrderService::OrderStatusStepTotal(['user_type'=>'user', 'user'=>$this->user, 'is_comments'=>1]);
$this->assign('user_order_status', $user_order_status['data']);
// 获取进行中的订单列表
$params = array_merge($_POST, $_GET);
$params['user'] = $this->user;
$params['is_more'] = 1;
$params['status'] = [1,2,3,4];
$params['is_comments'] = 0;
$params['user_type'] = 'user';
$where = OrderService::OrderListWhere($params);
$order_params = array(
'm' => 0,
'n' => 3,
'where' => $where,
);
$order = OrderService::OrderList($order_params);
$this->assign('order_list', $order['data']);
// 获取购物车
$cart_list = BuyService::CartList(['user'=>$this->user]);
$this->assign('cart_list', $cart_list['data']);
// 收藏商品
$params = array_merge($_POST, $_GET);
$params['user'] = $this->user;
$where = GoodsService::UserGoodsFavorListWhere($params);
$favor_params = array(
'm' => 0,
'n' => 8,
'where' => $where,
);
$favor = GoodsService::GoodsFavorList($favor_params);
$this->assign('goods_favor_list', $favor['data']);
// 我的足迹
$params = array_merge($_POST, $_GET);
$params['user'] = $this->user;
$where = GoodsService::UserGoodsBrowseListWhere($params);
$browse_params = array(
'm' => 0,
'n' => 6,
'where' => $where,
);
$data = GoodsService::GoodsBrowseList($browse_params);
$this->assign('goods_browse_list', $data['data']);
// 用户中心公告
$this->assign('common_user_center_notice', MyC('common_user_center_notice'));
return $this->fetch();
}
/**
* [ForgetPwdInfo 密码找回]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-10T17:06:47+0800
*/