Browse Source

sunguidong

zhangguidong 2 years ago
parent
commit
5e2edf01cd
2 changed files with 12 additions and 2 deletions
  1. 11 1
      app/api/controller/Cart.php
  2. 1 1
      app/model/goods/Cart.php

+ 11 - 1
app/api/controller/Cart.php

@@ -106,9 +106,19 @@ class Cart extends BaseApi
 		$token = $this->checkToken();
 		if ($token['code'] < 0) return $this->response($token);
 		$cart = new CartModel();
+        $goods_model = new \app\model\goods\Goods();
 		$list = $cart->getCart($token['data']['member_id']);
-        print_r($list);die;
         foreach ($list['data'] as &$v){
+            $gods_price =$goods_model->getGoodsInfo([['goods_id','=',$v['goods_id']]],'pay_num1,pay_num2,pay_num3,price1,price2,price3');
+            if($v['num']>=$gods_price['pay_num1']){
+                $v['price'] =$gods_price['price1'];
+            }
+            if($v['num']>=$gods_price['pay_num2']){
+                $v['price'] =$gods_price['price2'];
+            }
+            if($v['num']>=$gods_price['pay_num3']){
+                $v['price'] =$gods_price['price3'];
+            }
             $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
         }
 		return $this->response($list);

+ 1 - 1
app/model/goods/Cart.php

@@ -73,7 +73,7 @@ class Cart extends BaseModel
 	 */
 	public function getCart($member_id)
 	{
-		$field = 'ngc.cart_id, ngc.site_id, ngc.member_id, ngc.sku_id, ngc.num,ngc.create_time, ngs.sku_name,
+		$field = 'ngc.cart_id, ngc.site_id, ngc.member_id, ngc.sku_id, ngc.num,ngc.create_time,ngc.goods_id, ngs.sku_name,
             ngs.sku_no, ngs.sku_spec_format, ngs.price, ngs.market_price, ngs.cost_price, 
             ngs.discount_price, ngs.promotion_type, ngs.start_time, ngs.end_time, ngs.stock, 
             ngs.sku_image, ngs.sku_images, ngs.site_name, ngs.website_id, ngs.is_own, ngs.goods_state,