dever 3 년 전
부모
커밋
3c3e930ea1
2개의 변경된 파일31개의 추가작업 그리고 23개의 파일을 삭제
  1. 16 11
      app/shop/lib/Info.php
  2. 15 12
      app/shop/lib/Sell.php

+ 16 - 11
app/shop/lib/Info.php

@@ -382,18 +382,23 @@ class Info
             if ($uid && $uid > 0) {
                 $role = $this->getRole($uid);
                 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['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['id'], $discount_goods)) {
+                                $role_set = $rv;
+                                break;
+                            }
+                        } elseif ($rv['category'] && in_array($data['top_category_id'], $rv['category'])) {
+                            $role_set = $rv;
+                            break;
                         }
-                    } elseif ($role['category'] && in_array($data['top_category_id'], $role['category'])) {
-                        $role_state = true;
                     }
-                    if ($role_state) {
-                        $data['discount'] = $role;
+                    
+                    if ($role_set) {
+                        $data['discount'] = $role_set;
                     }
                 }
             }
@@ -407,7 +412,7 @@ class Info
     {
         $bind = Dever::db('agent/user_bind')->find(array('uid' => $uid, 'status' => 2));
         if ($bind) {
-            $discount = Dever::db('act/discount')->find(array('role' => 1));
+            $discount = Dever::db('act/discount')->getAll(array('role' => 1));
             return $discount;
         }
         return false;

+ 15 - 12
app/shop/lib/Sell.php

@@ -874,22 +874,25 @@ class Sell
 
                 # 根据角色设置折扣
                 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_id'] = $role['id'];
+                        $data['discount_id'] = $role_set['id'];
                         $data['list'][$k]['discount_cash'] = round(($data['list'][$k]['price'] - $discount_cash) * $n, 2);
                         $data['discount_cash'] += $data['list'][$k]['discount_cash'];
                         $data['price'] += $discount_cash * $n;