68 lines
1.8 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\api\store\user;
use app\Request;
use app\services\user\UserAddressServices;
/**
* 用户地址类
* Class UserAddress
* @package app\api\controller\store
*/
class UserAddress
{
protected $services;
public function __construct(UserAddressServices $services)
{
$this->services = $services;
}
/**
* 地址列表
* @param Request $request
* @param $uid
* @return \think\Response
*/
public function address_list(Request $request, $uid)
{
$uid = (int)$uid;
$list = [];
if ($uid) {
$list = $this->services->getUserAddressList($uid);
}
return app('json')->successful($list);
}
/**
* 获取默认地址
* @param Request $request
* @param $uid
* @return \think\Response
* @throws \throwable
*/
public function address_default(Request $request, $uid)
{
$uid = (int)$uid;
$defaultAddress = [];
if ($uid) $defaultAddress = $this->services->getUserDefaultAddressCache($uid);
if ($defaultAddress) {
return app('json')->successful('ok', $defaultAddress);
}
return app('json')->successful('empty', []);
}
}