diff --git a/app/Controller/NotifyController.php b/app/Controller/NotifyController.php index 1d2c1be..fb4de38 100644 --- a/app/Controller/NotifyController.php +++ b/app/Controller/NotifyController.php @@ -29,6 +29,8 @@ use Symfony\Component\HttpFoundation\Request; class NotifyController extends BaseController { + const AWARD_LIMIT_AMOUNT = 3; + /** * @Inject * @var MqttServiceInterface @@ -321,7 +323,7 @@ class NotifyController extends BaseController $needAward = true; } else { $isStoreFirstOrderToday = $this->userService->isStoreFirstOrderToday($orderItem['user_id'],$orderItem['store_id'],$orderItem['id']); - if ($isStoreFirstOrderToday) { + if ($isStoreFirstOrderToday && $orderItem['money'] >= self::AWARD_LIMIT_AMOUNT) { $awardAmount = SystemConfig::query()->where(['type' => 1, 'menu_name' => 'award_each_order'])->value('value'); // 流水 $record = [ diff --git a/app/Service/UserService.php b/app/Service/UserService.php index 6881a6f..c045850 100644 --- a/app/Service/UserService.php +++ b/app/Service/UserService.php @@ -22,8 +22,8 @@ class UserService implements UserServiceInterface $exist = OrderMain::query() ->where(['user_id' => $user_id]) ->where(function ($query){ - $query->where('state', 'in', [4,5,10]) - ->orWhere('dm_state', 'in', [2,3]); + $query->where('state', 'in', [OrderMain::ORDER_STATE_COMPLETE,OrderMain::ORDER_STATE_EVALUATED,OrderMain::ORDER_STATE_UNREFUND]) + ->orWhere('dm_state', 'in', [OrderMain::ORDER_STATE_UNTAKE,OrderMain::ORDER_STATE_DELIVERY]); }) ->exists(); @@ -63,13 +63,13 @@ class UserService implements UserServiceInterface /** * @inheritDoc */ - public function isStoreFirstOrderToday($user_id, $store_id, $current_order_id, $limit_amount = 3) + public function isStoreFirstOrderToday($user_id, $store_id, $current_order_id) { return !Order::query() - ->where(['user_id' => $user_id, 'store_id' => $store_id, 'dm_state' => 2]) + ->where(['user_id' => $user_id, 'store_id' => $store_id]) + ->whereIn('dm_state', [OrderMain::ORDER_STATE_UNTAKE,OrderMain::ORDER_STATE_DELIVERY]) ->where('time_add', '>=', date('Y-m-d 00:00:00')) ->where('time_add', '<=', date('Y-m-d 23:59:59')) - ->where('money', '>=', $limit_amount) ->where('id', '!=', $current_order_id) ->exists(); } diff --git a/app/Service/UserServiceInterface.php b/app/Service/UserServiceInterface.php index 5f7bbd3..2e41493 100644 --- a/app/Service/UserServiceInterface.php +++ b/app/Service/UserServiceInterface.php @@ -23,6 +23,6 @@ interface UserServiceInterface * @param int $limit_amount * @return mixed */ - public function isStoreFirstOrderToday($user_id, $store_id, $current_order_id, $limit_amount = 3); + public function isStoreFirstOrderToday($user_id, $store_id, $current_order_id); } \ No newline at end of file