Browse Source

修复奖励

master
weigang 6 years ago
parent
commit
69316fac90
  1. 4
      app/Controller/NotifyController.php
  2. 10
      app/Service/UserService.php
  3. 2
      app/Service/UserServiceInterface.php

4
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 = [

10
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();
}

2
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);
}
Loading…
Cancel
Save