dever 3 yıl önce
ebeveyn
işleme
080dbfddc6

+ 4 - 4
app/goods/database/info_sku.php

@@ -174,7 +174,7 @@ $config = array
             ),
             'type' => 'all',
             'order' => array('id' => 'desc'),
-            'col' => '*,num-sell_num as num|key',
+            'col' => 'id,info_id,`key`,price,s_price,f_price|key',
         ),
 
         # 获取单条数据
@@ -187,7 +187,7 @@ $config = array
                 'state' => 1,
             ),
             'type' => 'one',
-            'col' => '*,num-sell_num as num',
+            'col' => 'id,info_id,price,s_price,f_price',
         ),
 
         'getMinOne' => array
@@ -200,7 +200,7 @@ $config = array
             ),
             'type' => 'one',
             'order' => array('price' => 'asc', 'id' => 'desc'),
-            'col' => '*',
+            'col' => 'id,info_id,price,s_price,f_price',
         ),
 
         'getMaxOne' => array
@@ -213,7 +213,7 @@ $config = array
             ),
             'type' => 'one',
             'order' => array('price' => 'desc', 'id' => 'desc'),
-            'col' => '*',
+            'col' => 'id,info_id,price,s_price,f_price',
         ),
 
         # 更新售出量

+ 8 - 2
app/goods/lib/Info.php

@@ -331,11 +331,12 @@ class Info
     # 获取基本信息
     public function info($info, $key = 'list_reorder', $is_sell = false, $user = array(), $reward = false)
     {
+        $info['category_array'] = Dever::load('category/api')->string($info['category']);
+        
         if ($info['price_type'] == 2) {
             
             $attr = $this->setAttr($info['category'], $key);
             $attr_data = $attr->one($info['id']);
-            $info['category_array'] = Dever::load('category/api')->string($info['category']);
 
             $info['attr'] = $info['sell_attr'] = array();
 
@@ -384,7 +385,12 @@ class Info
             $info['price']['max'] = array();
         }
 
-        //$info['price']['value'] = $info['price']['min']['price'];
+        if (isset($info['price']['min']['price'])) {
+            $info['price']['value'] = $info['price']['min']['price'];
+        } else {
+            $info['price']['value'] = 0;
+        }
+        
        
         if (isset($info['cdate']) && $info['cdate']) {
             $info['cdate_string'] = Dever::mdate($info['cdate'], 2);

+ 1 - 1
app/goods/lib/Manage.php

@@ -282,7 +282,7 @@ class Manage
                         $f_price = $sku[$key]['f_price'];
                         $s_price = $sku[$key]['s_price'];
                         $price = $sku[$key]['price'];
-                        $num = $sku[$key]['num'];
+                        //$num = $sku[$key]['num'];
                     }
                     
                     $body .= '<td width="30"><input type="text" class="layui-input" name="price['.$k.']"  value="'.$price.'"/></td>';

+ 32 - 6
app/shop/src/Buy.php

@@ -49,15 +49,15 @@ class Buy extends Core
         $where['uid'] = $this->uid;
         $where['shop_id'] = $this->shop_id;
 
-        $this->data['card'] = Dever::db('shop/cart')->select($where);
+        $this->data['cart'] = Dever::db('shop/cart')->select($where);
 
-        if ($this->data['card']) {
-            foreach ($this->data['card'] as $k => $v) {
-                $this->data['card'][$k]['goods'] = Dever::load('goods/lib/info')->getPayInfo($v['goods_id'], $v['sku_id']);
+        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']);
             }
         }
 
-        return $this->data['card'];
+        return $this->data['cart'];
     }
 
     # 加入到购物车
@@ -66,13 +66,14 @@ class Buy extends Core
         $where['uid'] = $this->uid;
         $where['shop_id'] = $this->shop_id;
         $where['goods_id'] = Dever::input('goods_id');
+        $where['sku_id'] = Dever::input('sku_id');
         if (!$where['goods_id']) {
             Dever::alert('错误的商品');
         }
 
         $info = Dever::db('shop/cart')->find($where);
 
-        $where['sku_id'] = Dever::input('sku_id');
+        
         $where['num'] = Dever::input('num');
         if (!$info) {
             $state = Dever::db('shop/cart')->insert($where);
@@ -96,6 +97,31 @@ class Buy extends Core
         return $this->alert($state);
     }
 
+    # 更新购物车数量
+    public function upCart()
+    {
+        $where['uid'] = $this->uid;
+        $where['shop_id'] = $this->shop_id;
+        $where['id'] = Dever::input('cart_id');
+        $num = Dever::input('num');
+
+        $info = Dever::db('shop/cart')->find($where);
+
+        $state = false;
+        if ($info) {
+            $where = array();
+            $where['where_id'] = $info['id'];
+            if ($num <= 0) {
+                $state = Dever::db('shop/cart')->delete($where);
+            } else {
+                $where['num'] = $num;
+                $state = Dever::db('shop/cart')->update($where); 
+            }
+        }
+
+        return $this->alert($state);
+    }
+
     # 确认订单页面
     public function confirm()
     {

+ 57 - 7
churen.sql

@@ -3,7 +3,7 @@
 -- https://www.phpmyadmin.net/
 --
 -- 主机: web-mysql
--- 生成日期: 2021-10-09 09:49:40
+-- 生成日期: 2021-10-09 10:59:07
 -- 服务器版本: 10.1.32-MariaDB
 -- PHP 版本: 7.3.22
 
@@ -53,7 +53,11 @@ INSERT INTO `churen_manage_api` (`id`, `name`, `type`, `project`, `site`, `reord
 (4, '合作门店申请', 1, 'shop', 'main.apply', 1, 1, 1633760302),
 (5, '获取门店数据', 1, 'shop', 'main.getShop', 1, 1, 1633762528),
 (6, 'upload/view.files', 1, 'upload', 'view.files', 1, 1, 1633764380),
-(7, '获取商品详情', 1, 'shop', 'buy.getGoodsInfo', 1, 1, 1633770366);
+(7, '获取商品详情', 1, 'shop', 'buy.getGoodsInfo', 1, 1, 1633770366),
+(8, '获取购物车', 1, 'shop', 'buy.getCart', 1, 1, 1633776284),
+(9, '添加购物车', 1, 'shop', 'buy.addCart', 1, 1, 1633776338),
+(10, '清空购物车', 1, 'shop', 'buy.dropCart', 1, 1, 1633776702),
+(11, '更新购物车', 1, 'shop', 'buy.upCart', 1, 1, 1633776906);
 
 -- --------------------------------------------------------
 
@@ -101,7 +105,16 @@ INSERT INTO `churen_manage_api_request` (`id`, `api_id`, `parent_id`, `name`, `t
 (21, 6, -1, 'pg', 'string', '1', 1, 1633764382),
 (22, 6, -1, 'state', 'string', '1', 1, 1633764382),
 (23, 7, -1, 'goods_id', 'int', '商品id', 1, 1633770366),
-(24, 7, -1, 'shop_id', 'int', '店铺id', 1, 1633770366);
+(24, 7, -1, 'shop_id', 'int', '店铺id', 1, 1633770366),
+(25, 8, -1, 'shop_id', 'int', '1', 1, 1633776284),
+(26, 9, -1, 'shop_id', 'int', '1', 1, 1633776338),
+(27, 9, -1, 'goods_id', 'int', '10000001', 1, 1633776338),
+(28, 9, -1, 'sku_id', 'int', NULL, 1, 1633776374),
+(29, 9, -1, 'num', 'string', '1', 1, 1633776374),
+(33, 10, -1, 'shop_id', 'int', '1', 1, 1633776702),
+(37, 11, -1, 'shop_id', 'int', '1', 1, 1633776906),
+(40, 11, -1, 'num', 'string', '11', 1, 1633776906),
+(41, 11, -1, 'id', 'int', '1', 1, 1633776906);
 
 -- --------------------------------------------------------
 
@@ -382,7 +395,44 @@ INSERT INTO `churen_manage_api_response` (`id`, `api_id`, `parent_id`, `name`, `
 (289, 7, 281, 'cdate', 'string', '1633771684', 1, 1633772835),
 (290, 7, 261, 'value_string', 'string', '2人份,1人份', 1, 1633772835),
 (291, 7, 261, 'bg', 'string', 'background-image: url()', 1, 1633772835),
-(292, 7, 261, 'pic', 'string', '<img src=\"\" width=\"18\" />', 1, 1633772835);
+(292, 7, 261, 'pic', 'string', '<img src=\"\" width=\"18\" />', 1, 1633772835),
+(293, 9, -1, 'msg', 'string', '1', 1, 1633776418),
+(294, 8, -1, 'id', 'int', '1', 1, 1633776450),
+(295, 8, -1, 'uid', 'int', '1', 1, 1633776450),
+(296, 8, -1, 'shop_id', 'int', '1', 1, 1633776450),
+(297, 8, -1, 'goods_id', 'int', '10000001', 1, 1633776450),
+(298, 8, -1, 'sku_id', 'int', '0', 1, 1633776450),
+(299, 8, -1, 'num', 'string', '数量', 1, 1633776450),
+(300, 8, -1, 'status', 'string', '1', 1, 1633776450),
+(301, 8, -1, 'state', 'string', '1', 1, 1633776450),
+(302, 8, -1, 'cdate', 'string', '1633776433', 1, 1633776450),
+(303, 8, -1, 'goods', 'string', '见商品详情', 1, 1633776450),
+(304, 8, 303, 'id', 'int', '10000001', 1, 1633776450),
+(305, 8, 303, 'name', 'string', '多组商品', 1, 1633776450),
+(306, 8, 303, 'category', 'string', '1', 1, 1633776450),
+(307, 8, 303, 'top_category_id', 'int', '1', 1, 1633776450),
+(308, 8, 303, 'second_category_id', 'int', '1', 1, 1633776450),
+(309, 8, 303, 'category_id', 'int', '1', 1, 1633776450),
+(310, 8, 303, 'area', 'string', '110000', 1, 1633776450),
+(311, 8, 303, 'mode', 'string', '3', 1, 1633776450),
+(312, 8, 303, 'price_type', 'string', '2', 1, 1633776450),
+(313, 8, 303, 'price', 'string', NULL, 1, 1633776450),
+(314, 8, 303, 's_price', 'string', NULL, 1, 1633776450),
+(315, 8, 303, 'f_price', 'string', NULL, 1, 1633776450),
+(316, 8, 303, 'cover', 'string', '{uploadRes}1/2021/10/08/c2d24eb14a49336964877325bd188c88.jpg', 1, 1633776450),
+(317, 8, 303, 'video', 'int', NULL, 1, 1633776450),
+(318, 8, 303, 'pic', 'string', NULL, 1, 1633776450),
+(319, 8, 303, 'top', 'string', '2', 1, 1633776450),
+(320, 8, 303, 'youhui', 'string', '2', 1, 1633776450),
+(321, 8, 303, 'content', 'string', NULL, 1, 1633776450),
+(322, 8, 303, 'status', 'string', '1', 1, 1633776450),
+(323, 8, 303, 'reorder', 'string', '1', 1, 1633776450),
+(324, 8, 303, 'state', 'string', '1', 1, 1633776450),
+(325, 8, 303, 'udate', 'string', '1633689519', 1, 1633776450),
+(326, 8, 303, 'cdate', 'string', '1633689519', 1, 1633776450),
+(327, 8, 303, 'sku_id', 'int', '0', 1, 1633776450),
+(328, 10, -1, 'msg', 'string', 'ok', 1, 1633776702),
+(329, 11, -1, 'msg', 'string', 'ok', 1, 1633776906);
 
 --
 -- 转储表的索引
@@ -414,19 +464,19 @@ ALTER TABLE `churen_manage_api_response`
 -- 使用表AUTO_INCREMENT `churen_manage_api`
 --
 ALTER TABLE `churen_manage_api`
-  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID', AUTO_INCREMENT=8;
+  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID', AUTO_INCREMENT=12;
 
 --
 -- 使用表AUTO_INCREMENT `churen_manage_api_request`
 --
 ALTER TABLE `churen_manage_api_request`
-  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID', AUTO_INCREMENT=25;
+  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID', AUTO_INCREMENT=42;
 
 --
 -- 使用表AUTO_INCREMENT `churen_manage_api_response`
 --
 ALTER TABLE `churen_manage_api_response`
-  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID', AUTO_INCREMENT=293;
+  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID', AUTO_INCREMENT=330;
 COMMIT;
 
 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

+ 1 - 1
main/lib/Core.php

@@ -36,7 +36,7 @@ class Core
     public function alert($state)
     {
         if ($state) {
-            return 'ok';
+            return array('msg' => 'ok');
         } else {
             Dever::alert('操作失败');
         }