<?php
|
|
namespace app\api\controller\user;
|
|
use app\api\controller\Controller;
|
use app\api\model\plus\agent\Setting;
|
use app\api\model\user\User as UserModel;
|
use app\api\model\order\Order as OrderModel;
|
use app\api\model\settings\Setting as SettingModel;
|
use app\api\model\plus\coupon\UserCoupon as UserCouponModel;
|
use app\common\enum\settings\GetPhoneTypeEnum;
|
use think\facade\Cache;
|
use app\api\model\supplier\Supplier as SupplierModel;
|
use app\api\model\plus\chat\Chat as ChatModel;
|
use app\common\model\app\AppWx as AppWxModel; //by lyzflash
|
use app\api\model\user\UserAuth as UserAuthModel; //by lyzflash
|
use app\api\model\user\CardRecord as CardRecordModel; //by lyzflash
|
use app\api\model\user\Card as CardModel; //by lyzflash
|
use app\api\model\supplier\Balance as SupplierBalanceModel;
|
use app\common\model\branch\User as BranchUserModel; //by lyzflash
|
|
/**
|
* 个人中心主页
|
*/
|
class Index extends Controller
|
{
|
/**
|
* 获取当前用户信息
|
*/
|
public function detail($source = 'wx')
|
{
|
// 当前用户信息
|
$user = $this->getUser();
|
//付呗分账相关 by lyzflash
|
// $wxConfig = AppWxModel::getAppWxCache($user['app_id']);
|
// $user['isFbpay'] = $wxConfig["apitype"] == 1; //付呗支付
|
// $user['auth_status'] = UserAuthModel::authStatus($user['user_id']);
|
|
// 同步瑞和购物旧系统积分 by lyzflsh
|
if ($user['app_id'] == 10027) {
|
(new UserModel)->syncPoints($user['open_id']);
|
}
|
//店铺信息
|
$user['is_recycle'] = $user['supplierUser']?SupplierModel::detail($user['supplierUser']['shop_supplier_id'])['is_recycle']:'';
|
$coupon_model = new UserCouponModel();
|
$coupon = count($coupon_model->getList($user['user_id'], -1, false, false));
|
// 订单总数
|
$model = new OrderModel;
|
|
// 分销商基本设置
|
$setting = Setting::getItem('basic');
|
// 是否开启分销功能
|
$agent_open = $setting['is_open'];
|
//商城设置
|
$store = SettingModel::getItem('store');
|
//供应商入住背景图
|
$supplier_image = isset($store['supplier_image'])?$store['supplier_image']:'';
|
// 充值功能是否开启
|
$balance_setting = SettingModel::getItem('balance');
|
$balance_open = intval($balance_setting['is_open']);
|
$cardDetail = CardRecordModel::getCardDetail($user['user_id']); // 会员卡 by lyzflash
|
$cardCount = (new CardModel)->getCount($user);
|
|
//商户是否独立收款 by yj 2024.3.14
|
$is_independent = SettingModel::getIndependentOpen();
|
if(!empty($is_independent) && $is_independent == 1){
|
//获取每个商户加起来的余额
|
$user["balance"] = SupplierBalanceModel::getTotalBalance($user['user_id']);
|
}
|
|
// 判断用户是不是分会管理员 by lyzflash
|
$user['is_branch_manager'] = BranchUserModel::isManager($user['user_id']);
|
|
return $this->renderSuccess('', [
|
'coupon' => $coupon,
|
'userInfo' => $user,
|
'orderCount' => [
|
'payment' => $model->getCount($user, 'payment'),
|
'delivery' => $model->getCount($user, 'delivery'),
|
'received' => $model->getCount($user, 'received'),
|
'comment' => $model->getCount($user, 'comment'),
|
],
|
'setting' => [
|
'points_name' => SettingModel::getPointsName(),
|
'agent_open' => $agent_open,
|
'supplier_image' => $supplier_image,
|
'balance_open' => $balance_open
|
],
|
'sign' => SettingModel::getItem('sign'),
|
'getPhone' => $this->isGetPhone(),
|
'msgcount' => (new ChatModel)->mCount($user),
|
'menus' => UserModel::getMenus($user, $source), // 个人中心菜单列表
|
'cardDetail' => $cardDetail,//会员卡信息 by lyzflash
|
'card_total' => empty($cardCount) ? "" : $cardCount['cardCount'],
|
//是否显示店铺信息
|
'store_open' => SettingModel::getStoreOpen(),
|
'supplierStatus' => SupplierModel::getStatus($user),
|
]);
|
}
|
|
/**
|
* 当前用户设置
|
*/
|
public function setting()
|
{
|
// 当前用户信息
|
$user = $this->getUser();
|
|
//by lyzflash
|
$wxConfig = AppWxModel::getAppWxCache($user['app_id']);
|
$user['isFbpay'] = $wxConfig["apitype"] == 1; //付呗支付
|
$user['auth_status'] = UserAuthModel::authStatus($user['user_id']);
|
|
return $this->renderSuccess('', [
|
'userInfo' => $user
|
]);
|
}
|
|
private function isGetPhone()
|
{
|
$user = $this->getUser();
|
if($user['mobile'] != ''){
|
return false;
|
}
|
$settings = SettingModel::getItem('getPhone');
|
if(in_array(GetPhoneTypeEnum::USER, $settings['area_type'])){
|
// 缓存时间
|
$key = 'get_phone_' . $user['user_id'];
|
if (!$data = Cache::get($key)) {
|
$settings['send_day'] > 0 && Cache::set($key, '1', 86400 * $settings['send_day']);
|
return true;
|
}
|
}
|
return false;
|
}
|
}
|