dever 3 anos atrás
pai
commit
c02946e6a8
2 arquivos alterados com 16 adições e 9 exclusões
  1. 3 8
      app/mshop/src/Act.php
  2. 13 1
      app/shop/src/Buy.php

+ 3 - 8
app/mshop/src/Act.php

@@ -23,14 +23,9 @@ class Act extends Core
         }
         
         $num = Dever::input('num');
+        if (!$num) {
+            Dever::alert('请传入数量');
+        }
         $num = explode(',', $num);
-            
-        # 获取门店分配的仓库和工厂
-
-        $sql = 'select *,round((st_distance(point(lng, lat), point('.$shop['lng'].', '.$shop['lat'].'))*111195)/1000, 2) as distance from {table} where '.$where.' order by distance asc';
-
-        $data = Dever::db('shop/info')->$method($sql, array(), $page);
-
-        $store = Dever::db('shop/store')->select();
     }
 }

+ 13 - 1
app/shop/src/Buy.php

@@ -90,6 +90,10 @@ class Buy extends Core
         if ($this->data['cart']) {
             foreach ($this->data['cart'] as $k => $v) {
                 $this->data['cart'][$k]['goods'] = Dever::load('goods/lib/info')->getPayInfo($v['goods_id'], $v['sku_id']);
+
+                if (isset($this->data['cart'][$k]['goods']['sku_id'])) {
+                    $this->data['cart'][$k]['price_id'] = $this->data['cart'][$k]['goods']['sku_id'];
+                }
             }
         }
 
@@ -144,19 +148,27 @@ class Buy extends Core
         $where['id'] = Dever::input('cart_id');
 
         $status = Dever::input('status', 1);
+        $type = Dever::input('type', 1);
         $num = Dever::input('num');
 
         $info = Dever::db('shop/cart')->find($where);
 
         $state = false;
+
         if ($info) {
+            if ($type == 1) {
+                $num = $info['num'] + $num;
+            } else {
+                $num = $info['num'] - $num;
+            }
             $where = array();
             $where['where_id'] = $info['id'];
             if ($num <= 0) {
                 $state = Dever::db('shop/cart')->delete($where);
             } else {
                 $where['status'] = $status;
-                $where['num'] = $info['num'] + $num;
+                $where['num'] = $num;
+                
                 # 验证库存
                 Dever::load('shop/lib/info')->checkTotal($where['num'], $info['goods_id'], $this->shop_id, $info['sku_id'], 2);
                 $state = Dever::db('shop/cart')->update($where);