|
@@ -55,7 +55,7 @@ class Cart extends Base
|
|
|
$carts = (new CartModel)->where(['user_id' => $this->auth->id])
|
|
|
->with([
|
|
|
'product' => function ($query) {
|
|
|
- $query->field(['id', 'image', 'title', 'specTableList','sales','market_price','sales_price','stock','use_spec', 'switch']);
|
|
|
+ $query->field(['id', 'image', 'title', 'specTableList','sales','real_sales','market_price','sales_price','stock','use_spec', 'switch']);
|
|
|
}
|
|
|
])
|
|
|
->order(['createtime' => 'desc'])
|
|
@@ -77,15 +77,15 @@ class Cart extends Base
|
|
|
$choose_price_total = '0';//已选中的总价格
|
|
|
$choose_number = 0;//已选中的个数
|
|
|
foreach ($carts as $item) {
|
|
|
- $oldProduct = json_decode($item['snapshot'], true);
|
|
|
- $oldData = $productExtend->getBaseData($oldProduct, $item['spec'] ?? '');
|
|
|
+// $oldProduct = json_decode($item['snapshot'], true);
|
|
|
+// $oldData = $productExtend->getBaseData($oldProduct, $item['spec'] ?? '');
|
|
|
|
|
|
if (empty($item['product'])) { //商品被删了的情况
|
|
|
continue;//不要了
|
|
|
- $tempData = $oldData;
|
|
|
+ /*$tempData = $oldData;
|
|
|
$tempData['isset'] = false; // 失效
|
|
|
$tempData['title'] = $oldProduct['title'];
|
|
|
- $tempData['choose'] = 0;
|
|
|
+ $tempData['choose'] = 0;*/
|
|
|
} else {
|
|
|
$productData = $item['product']->getData();
|
|
|
$tempData = $productExtend->getBaseData($productData, $item['spec'] ?? '');
|
|
@@ -104,9 +104,9 @@ class Cart extends Base
|
|
|
$tempData['spec'] = $item['spec'];
|
|
|
$tempData['number'] = $item['number'];
|
|
|
|
|
|
- $tempData['image'] = Config::getImagesFullUrl($oldData['image']);
|
|
|
- $tempData['oldPrice'] = round($oldData['sales_price'], 2);
|
|
|
- $tempData['nowPrice'] = round($tempData['sales_price'], 2);
|
|
|
+ $tempData['image'] = Config::getImagesFullUrl($tempData['image']);
|
|
|
+// $tempData['oldPrice'] = round($oldData['sales_price'], 2);
|
|
|
+// $tempData['nowPrice'] = round($tempData['sales_price'], 2);
|
|
|
//新增此商品总价
|
|
|
$tempData['Price_total'] = bcmul($tempData['sales_price'],$tempData['number'],2);
|
|
|
//已选中商品,总价格
|
|
@@ -171,7 +171,7 @@ class Cart extends Base
|
|
|
$cartModel->product_id = $id;
|
|
|
$spec && $cartModel->spec = $spec;
|
|
|
$cartModel->number = $number;
|
|
|
- $cartModel->snapshot = json_encode($product->getData(), true);
|
|
|
+// $cartModel->snapshot = json_encode($product->getData(), true);
|
|
|
$result = $cartModel->save();
|
|
|
}
|
|
|
|