feat : order
This commit is contained in:
@@ -219,8 +219,8 @@ abstract class LoginBaseService extends BaseService
|
||||
*/
|
||||
protected function addCoupon(): void
|
||||
{
|
||||
$couponTemplateId = $this->configCache->getConfigValue(ConfigCode::COUPONS_FOR_NEWCOMERS);
|
||||
$couponValidity = $this->configCache->getConfigValue(ConfigCode::NEWBIE_COUPON_VALIDITY);
|
||||
$couponTemplateId = $this->configCache->getConfigValueByKey(ConfigCode::COUPONS_FOR_NEWCOMERS);
|
||||
$couponValidity = $this->configCache->getConfigValueByKey(ConfigCode::NEWBIE_COUPON_VALIDITY);
|
||||
|
||||
// 随便一个为0代表不赠送
|
||||
if ($couponValidity == 0 || $couponTemplateId == 0) return;
|
||||
|
||||
@@ -70,6 +70,11 @@ abstract class BaseOrderService extends BaseService
|
||||
*/
|
||||
protected array $skuArr;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected array $skuImageArr;
|
||||
|
||||
/**
|
||||
* 订单结果
|
||||
* @var array
|
||||
|
||||
@@ -67,7 +67,7 @@ class PlaceOrderService extends BaseOrderService
|
||||
$this->joinCancelDelayQueue(
|
||||
$this->orderId,
|
||||
OrderCode::ORDER_TYPE_GOOD,
|
||||
(int)$this->configCache->getConfigValue(ConfigCode::ORDER_CANCEL_TIME_KEY) * DateUtil::MINUTE * DateUtil::MS
|
||||
(int)$this->configCache->getConfigValueByKey(ConfigCode::ORDER_CANCEL_TIME_KEY) * DateUtil::MINUTE * DateUtil::MS
|
||||
);
|
||||
|
||||
$this->sendStockMq($this->orderId,OrderCode::WAIT_PAY);
|
||||
@@ -84,10 +84,11 @@ class PlaceOrderService extends BaseOrderService
|
||||
private function reduceStock(): void
|
||||
{
|
||||
$this->rollbackStockCache = [];
|
||||
|
||||
// var_dump($this->cartFirstData);
|
||||
foreach ($this->cartFirstData as $goodId => $stock) {
|
||||
$this->rollbackStockCache[$goodId] = $stock;
|
||||
if (!($this->redis->zAdd($this->stockKey,'-'.$stock,$goodId))) {
|
||||
if (!($this->redis->zIncrBy($this->stockKey,-$stock,$goodId))) {
|
||||
echo '123';
|
||||
throw new Exception('cache error');
|
||||
}
|
||||
}
|
||||
@@ -103,7 +104,7 @@ class PlaceOrderService extends BaseOrderService
|
||||
if (empty($this->rollbackStockCache)) return;
|
||||
|
||||
foreach ($this->rollbackStockCache as $goodId => $stock) {
|
||||
$this->redis->zAdd($this->stockKey,$stock,$goodId);
|
||||
$this->redis->zIncrBy($this->stockKey,$stock,$goodId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +127,7 @@ class PlaceOrderService extends BaseOrderService
|
||||
|
||||
Db::commit();
|
||||
} catch (Exception $e){
|
||||
echo $e->getMessage();
|
||||
//回滚数据库 和 缓存
|
||||
Db::rollBack();
|
||||
$this->rollbackStock();
|
||||
@@ -181,7 +183,7 @@ class PlaceOrderService extends BaseOrderService
|
||||
$orderInsertModel->user_id = $this->userId;
|
||||
$orderInsertModel->cycle_id = $this->cycleId;
|
||||
$orderInsertModel->site_id = $this->siteId;
|
||||
$orderInsertModel->city_id = $this->orderRes['site']['city_id'];
|
||||
$orderInsertModel->city_id = $this->orderRes['site_info']['city_id'];
|
||||
$orderInsertModel->coupon_id = $this->couponId;
|
||||
$orderInsertModel->meal_copies = $this->orderRes['meal_copies'];
|
||||
$orderInsertModel->optional_copies = $this->orderRes['optional_copies'];
|
||||
|
||||
@@ -77,7 +77,7 @@ class SiteService extends BaseService
|
||||
|
||||
if (in_array($id, $siteIds)) throw new ErrException('已添加该地点');
|
||||
|
||||
$poolNumber = $this->configCache->getConfigValue(ConfigCode::NUMBER_OF_USER_ADDRESS_POOLS);
|
||||
$poolNumber = $this->configCache->getConfigValueByKey(ConfigCode::NUMBER_OF_USER_ADDRESS_POOLS);
|
||||
if (count($siteIds) >= $poolNumber) throw new ErrException('已达到地址最大添加数量,请删除后再添加');
|
||||
|
||||
$insertModel = new UserSite();
|
||||
|
||||
Reference in New Issue
Block a user