feat : site
This commit is contained in:
@@ -11,6 +11,7 @@ class ConfigCode
|
|||||||
const string ORDER_CANCEL_TIME_KEY = 'OrderCancelTime'; // 订单取消时间(下单后自动取消)
|
const string ORDER_CANCEL_TIME_KEY = 'OrderCancelTime'; // 订单取消时间(下单后自动取消)
|
||||||
const string SUNDRY_UNIT_PRICE = 'SundryUnitPrice'; // 附加费单价 (服务费)
|
const string SUNDRY_UNIT_PRICE = 'SundryUnitPrice'; // 附加费单价 (服务费)
|
||||||
const string SUNDRY_PRICE_COMPUTE_TYPE = 'SundryPriceComputeType'; // 附加费计算方式 1 仅自选计算(默认值) 2 仅套餐计算 3 套餐+自选计算
|
const string SUNDRY_PRICE_COMPUTE_TYPE = 'SundryPriceComputeType'; // 附加费计算方式 1 仅自选计算(默认值) 2 仅套餐计算 3 套餐+自选计算
|
||||||
|
const string NUMBER_OF_USER_ADDRESS_POOLS = 'NumberOfUserAddressPools'; // 用户可以设置的送达地址的数量
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string CouponConfiguration|优惠券配置
|
* @var string CouponConfiguration|优惠券配置
|
||||||
@@ -28,6 +29,7 @@ class ConfigCode
|
|||||||
self::ORDER_CANCEL_TIME_KEY => 5,
|
self::ORDER_CANCEL_TIME_KEY => 5,
|
||||||
self::SUNDRY_UNIT_PRICE => '3',
|
self::SUNDRY_UNIT_PRICE => '3',
|
||||||
self::SUNDRY_PRICE_COMPUTE_TYPE => 1,
|
self::SUNDRY_PRICE_COMPUTE_TYPE => 1,
|
||||||
|
self::NUMBER_OF_USER_ADDRESS_POOLS => 10,
|
||||||
//CouponConfiguration
|
//CouponConfiguration
|
||||||
self::COUPONS_FOR_NEWCOMERS => '0',
|
self::COUPONS_FOR_NEWCOMERS => '0',
|
||||||
self::NEWBIE_COUPON_VALIDITY => '0',
|
self::NEWBIE_COUPON_VALIDITY => '0',
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class UserController extends AbstractController
|
|||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
#[RequestMapping(path: 'site/list',methods: 'post')]
|
#[RequestMapping(path: 'site/list',methods: 'GET')]
|
||||||
#[Scene(scene: 'site_list')]
|
#[Scene(scene: 'site_list')]
|
||||||
public function userSiteList()
|
public function userSiteList()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,6 +48,16 @@ class UserSite extends Model
|
|||||||
return $this->find($id);
|
return $this->find($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $userId
|
||||||
|
* @param int $siteId
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getInfoByUserIdAndSiteId(int $userId, int $siteId): Collection
|
||||||
|
{
|
||||||
|
return $this->where('user_id', $userId)->where('site_id', $siteId)->first();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $userId
|
* @param int $userId
|
||||||
* @return array
|
* @return array
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ declare(strict_types=1);
|
|||||||
namespace App\Service\Api\User;
|
namespace App\Service\Api\User;
|
||||||
|
|
||||||
use App\Cache\Redis\Api\SiteCache;
|
use App\Cache\Redis\Api\SiteCache;
|
||||||
|
use App\Cache\Redis\Common\ConfigCache;
|
||||||
use App\Constants\Common\SiteCode;
|
use App\Constants\Common\SiteCode;
|
||||||
|
use App\Constants\ConfigCode;
|
||||||
use App\Exception\ErrException;
|
use App\Exception\ErrException;
|
||||||
use App\Model\UserSite;
|
use App\Model\UserSite;
|
||||||
use App\Service\Api\BaseService;
|
use App\Service\Api\BaseService;
|
||||||
@@ -35,6 +37,12 @@ class SiteService extends BaseService
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected SiteCache $siteCache;
|
protected SiteCache $siteCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ConfigCache
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected ConfigCache $configCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
@@ -67,6 +75,9 @@ class SiteService extends BaseService
|
|||||||
|
|
||||||
if (in_array($id, $siteIds)) throw new ErrException('已添加该地点');
|
if (in_array($id, $siteIds)) throw new ErrException('已添加该地点');
|
||||||
|
|
||||||
|
$poolNumber = $this->configCache->getConfigValue(ConfigCode::NUMBER_OF_USER_ADDRESS_POOLS);
|
||||||
|
if (count($siteIds) >= $poolNumber) throw new ErrException('已达到地址最大添加数量,请删除后再添加');
|
||||||
|
|
||||||
$insertModel = new UserSite();
|
$insertModel = new UserSite();
|
||||||
|
|
||||||
$insertModel->user_id = $this->userId;
|
$insertModel->user_id = $this->userId;
|
||||||
@@ -87,9 +98,9 @@ class SiteService extends BaseService
|
|||||||
*/
|
*/
|
||||||
public function del(): array
|
public function del(): array
|
||||||
{
|
{
|
||||||
$id = (int)$this->request->input('id');
|
$id = (int)$this->request->input('site_id');
|
||||||
|
|
||||||
$info = $this->userSiteModel->getInfoById($id);
|
$info = $this->userSiteModel->getInfoByUserIdAndSiteId($this->userId,$id);
|
||||||
|
|
||||||
Db::transaction(function () use ($info) {
|
Db::transaction(function () use ($info) {
|
||||||
if ($info->is_default == SiteCode::USER_DEFAULT) {
|
if ($info->is_default == SiteCode::USER_DEFAULT) {
|
||||||
|
|||||||
Reference in New Issue
Block a user