|
@@ -874,22 +874,25 @@ class Sell
|
|
|
|
|
|
# 根据角色设置折扣
|
|
# 根据角色设置折扣
|
|
if ($role) {
|
|
if ($role) {
|
|
- $role_state = false;
|
|
|
|
- $discount_goods = Dever::db('act/discount_goods')->getData(array('discount_id' => $role['id']));
|
|
|
|
- if ($discount_goods) {
|
|
|
|
- $discount_goods = array_keys($discount_goods);
|
|
|
|
- if (in_array($data['list'][$k]['id'], $discount_goods)) {
|
|
|
|
- $role_state = true;
|
|
|
|
|
|
+ $role_set = false;
|
|
|
|
+
|
|
|
|
+ foreach ($role as $rk => $rv) {
|
|
|
|
+ $discount_goods = Dever::db('act/discount_goods')->getData(array('discount_id' => $rv['id']));
|
|
|
|
+ if ($discount_goods) {
|
|
|
|
+ $discount_goods = array_keys($discount_goods);
|
|
|
|
+ if (in_array($data['list'][$k]['id'], $discount_goods)) {
|
|
|
|
+ $role_set = $rv;
|
|
|
|
+ }
|
|
|
|
+ } elseif ($rv['category'] && in_array($data['list'][$k]['top_category_id'], $rv['category'])) {
|
|
|
|
+ $role_set = $rv;
|
|
}
|
|
}
|
|
- } elseif ($role['category'] && in_array($data['list'][$k]['top_category_id'], $role['category'])) {
|
|
|
|
- $role_state = true;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if ($role_state) {
|
|
|
|
- $discount_cash = round($data['list'][$k]['price'] * ($role['num']/10), 2);
|
|
|
|
- $data['list'][$k]['discount_id'] = $role['id'];
|
|
|
|
|
|
+ if ($role_set) {
|
|
|
|
+ $discount_cash = round($data['list'][$k]['price'] * ($role_set['num']/10), 2);
|
|
|
|
+ $data['list'][$k]['discount_id'] = $role_set['id'];
|
|
$data['discount_goods'][] = $data['list'][$k];
|
|
$data['discount_goods'][] = $data['list'][$k];
|
|
- $data['discount_id'] = $role['id'];
|
|
|
|
|
|
+ $data['discount_id'] = $role_set['id'];
|
|
$data['list'][$k]['discount_cash'] = round(($data['list'][$k]['price'] - $discount_cash) * $n, 2);
|
|
$data['list'][$k]['discount_cash'] = round(($data['list'][$k]['price'] - $discount_cash) * $n, 2);
|
|
$data['discount_cash'] += $data['list'][$k]['discount_cash'];
|
|
$data['discount_cash'] += $data['list'][$k]['discount_cash'];
|
|
$data['price'] += $discount_cash * $n;
|
|
$data['price'] += $discount_cash * $n;
|