|
@@ -285,12 +285,17 @@ class OrderService extends BaseService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 是否购买过
|
|
// 是否购买过
|
|
|
- $checkOrder = $this->checkBusinessOrder($userId, $mealId);
|
|
|
|
|
- if ($checkOrder) {
|
|
|
|
|
- RedisService::clear($cacheLockKey);
|
|
|
|
|
- $this->error = '抱歉,您已经购买过该礼包';
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ $buyLimit = ConfigService::make()->getConfigByCode('business_buy_limit', 0);
|
|
|
|
|
+ $buyLimit = $buyLimit>0?$buyLimit:0;
|
|
|
|
|
+ if($buyLimit>0){
|
|
|
|
|
+ $checkOrderCount = $this->checkBusinessOrder($userId, $mealId);
|
|
|
|
|
+ if ($checkOrderCount >= $buyLimit) {
|
|
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
|
|
+ $this->error = $buyLimit>1?"抱歉该创业礼包仅限购买{$buyLimit}次":'抱歉,您已经购买过该礼包';
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 收货地址信息
|
|
// 收货地址信息
|
|
@@ -496,9 +501,8 @@ class OrderService extends BaseService
|
|
|
$data = $this->model->where(['user_id' => $userId, 'meal_id' => $goodsId, 'mark' => 1])
|
|
$data = $this->model->where(['user_id' => $userId, 'meal_id' => $goodsId, 'mark' => 1])
|
|
|
->where('status', '<=', 5)
|
|
->where('status', '<=', 5)
|
|
|
->where('refund_status', '<=', 0)
|
|
->where('refund_status', '<=', 0)
|
|
|
- ->select(['id', 'order_no', 'meal_id', 'status'])
|
|
|
|
|
->orderBy('id', 'desc')
|
|
->orderBy('id', 'desc')
|
|
|
- ->first();
|
|
|
|
|
|
|
+ ->count('id');
|
|
|
$data = $data ? $data->toArray() : [];
|
|
$data = $data ? $data->toArray() : [];
|
|
|
if ($data) {
|
|
if ($data) {
|
|
|
RedisService::set($cacheKey, $data, rand(5, 10));
|
|
RedisService::set($cacheKey, $data, rand(5, 10));
|