Browse Source

奖励

master
weigang 6 years ago
parent
commit
f5ad8df2d8
  1. 2
      app/Controller/NotifyController.php
  2. 3
      app/Service/UserService.php
  3. 2
      app/Service/UserServiceInterface.php

2
app/Controller/NotifyController.php

@ -322,7 +322,7 @@ class NotifyController extends BaseController
]; ];
$needAward = true; $needAward = true;
} else { } else {
$isStoreFirstOrderToday = $this->userService->isStoreFirstOrderToday($orderItem['user_id'],$orderItem['store_id'],$orderItem['id']);
$isStoreFirstOrderToday = $this->userService->isStoreFirstOrderToday($orderItem['user_id'],$orderItem['store_id'],$orderItem['id'], self::AWARD_LIMIT_AMOUNT);
if ($isStoreFirstOrderToday && $orderItem['money'] >= self::AWARD_LIMIT_AMOUNT) { if ($isStoreFirstOrderToday && $orderItem['money'] >= self::AWARD_LIMIT_AMOUNT) {
$awardAmount = SystemConfig::query()->where(['type' => 1, 'menu_name' => 'award_each_order'])->value('value'); $awardAmount = SystemConfig::query()->where(['type' => 1, 'menu_name' => 'award_each_order'])->value('value');
// 流水 // 流水

3
app/Service/UserService.php

@ -65,13 +65,14 @@ class UserService implements UserServiceInterface
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function isStoreFirstOrderToday($user_id, $store_id, $current_order_id)
public function isStoreFirstOrderToday($user_id, $store_id, $current_order_id, $limit_amount = 3)
{ {
return !Order::query() return !Order::query()
->where(['user_id' => $user_id, 'store_id' => $store_id]) ->where(['user_id' => $user_id, 'store_id' => $store_id])
->whereIn('dm_state', [OrderMain::ORDER_STATE_UNTAKE,OrderMain::ORDER_STATE_DELIVERY]) ->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 00:00:00'))
->where('time_add', '<=', date('Y-m-d 23:59:59')) ->where('time_add', '<=', date('Y-m-d 23:59:59'))
->where('money', '>=', $limit_amount)
->where('id', '!=', $current_order_id) ->where('id', '!=', $current_order_id)
->exists(); ->exists();
} }

2
app/Service/UserServiceInterface.php

@ -24,6 +24,6 @@ interface UserServiceInterface
* @param int $limit_amount * @param int $limit_amount
* @return mixed * @return mixed
*/ */
public function isStoreFirstOrderToday($user_id, $store_id, $current_order_id);
public function isStoreFirstOrderToday($user_id, $store_id, $current_order_id, $limit_amount = 3);
} }
Loading…
Cancel
Save