From 2d6468b3cd03ba5df49ed214defe5c73200b79ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Thu, 29 Jul 2021 11:20:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=B7=AE=E9=A2=9D=E5=A5=96?= =?UTF-8?q?=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/service/RebateService.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/data/service/RebateService.php b/app/data/service/RebateService.php index 689b93e0a..1827e9d6a 100644 --- a/app/data/service/RebateService.php +++ b/app/data/service/RebateService.php @@ -325,13 +325,14 @@ class RebateService extends Service $itemJson = $this->app->db->name('BaseUserDiscount')->where(['status' => 1, 'deleted' => 0])->value('items'); if (!empty($itemJson) && is_array($rules = json_decode($itemJson, true))) { [$tVip, $tRate] = [$item['vip_code'], $item['discount_rate']]; - foreach ($rules as $rule) if ($rule['level'] > $tVip) foreach ($users as $user) if ($user['vip_code'] > $tVip) { + foreach ($users as $user) if (isset($rules[$user['vip_code']]) && $user['vip_code'] > $tVip) { + $rule = $rules[$user['vip_code']]; if ($tRate > $rule['discount'] && $tRate < 100) { $map = ['uuid' => $user['id'], 'type' => self::PRIZE_05]; $map['code'] = "{$this->order['order_no']}#{$item['id']}#{$tVip}.{$user['vip_code']}"; if ($this->app->db->name($this->table)->where($map)->count() < 1) { - $dRate = ($tRate - $rule['discount']) / 100; - $name = "等级差额奖励{$tVip}#{$user['vip_code']}商品的{$dRate}%"; + $dRate = ($rate = $tRate - $rule['discount']) / 100; + $name = "等级差额奖励{$tVip}#{$user['vip_code']}商品原价{$item['total_selling']}元的{$rate}%"; $amount = $dRate * $item['total_selling']; // 写入用户返利记录 $this->writeRabate($user['id'], $map, $name, $amount);