作者 SHW\戥岁。。

金额格式化

... ... @@ -414,8 +414,8 @@ class Classification extends Api
$goods_spec = Db::name('litestore_goods_spec')
->where('goods_id', $item['goods_id'])
->find();
$item['price'] = $goods_spec['goods_price'];
$item['line_price'] = $goods_spec['line_price'];
$item['price'] = round($goods_spec['goods_price'], 2);
$item['line_price'] = round($goods_spec['line_price'], 2);
//判断是否打折
$item['is_discount'] = 'is';
if ($goods_spec['goods_price'] == $goods_spec['line_price']) {
... ... @@ -452,9 +452,11 @@ class Classification extends Api
$goods_spec = GoodsSpec::all(['goods_id' => $item['goods_id']]);
foreach ($goods_spec as &$spec_value) {
//规格下的购物车数量
$spec_value['cart_number'] = Db::name('cart')
$number = Db::name('cart')
->where(['goods_id' => $spec_value['goods_id'], 'sku_id' => $spec_value['goods_spec_id'], 'user_id' => $this->auth->id])
->value('number');
$spec_value['cart_number'] = $number ?? 0;
//判断是否打折
$spec_value['is_discount'] = 'is';
if ($spec_value['goods_price'] == $spec_value['line_price']) {
... ... @@ -482,8 +484,8 @@ class Classification extends Api
$goods_spec = Db::name('litestore_goods_spec')
->where('goods_id', $item['goods_id'])
->find();
$item['price'] = $goods_spec['goods_price'];
$item['line_price'] = $goods_spec['line_price'];
$item['price'] = round($goods_spec['goods_price'], 2);
$item['line_price'] = round($goods_spec['line_price'], 2);
//判断是否打折
$item['is_discount'] = 'is';
if ($goods_spec['goods_price'] == $goods_spec['line_price']) {
... ... @@ -521,9 +523,11 @@ class Classification extends Api
foreach ($goods_spec as &$spec_value) {
//规格下的购物车数量
$spec_value['cart_number'] = Db::name('cart')
$number = Db::name('cart')
->where(['goods_id' => $spec_value['goods_id'], 'sku_id' => $spec_value['goods_spec_id'], 'user_id' => $this->auth->id])
->value('number');
$spec_value['cart_number'] = $number ?? 0;
//判断是否打折
$spec_value['is_discount'] = 'is';
if ($spec_value['goods_price'] == $spec_value['line_price']) {
... ...
... ... @@ -58,8 +58,8 @@ class Goods extends Api
}
$goods = $goodsmodel::get($goods_id);
$goods_spec = Db::name('litestore_goods_spec')->where('goods_id', $goods['goods_id'])->find();
$goods['price'] = $goods_spec['goods_price'];
$goods['line_price'] = $goods_spec['line_price'];
$goods['price'] = round($goods_spec['goods_price'], 2);
$goods['line_price'] = round($goods_spec['line_price'], 2);
//判断是否打折
$goods['is_discount'] = 'is';
if ($goods_spec['goods_price'] == $goods_spec['line_price']) {
... ... @@ -150,6 +150,8 @@ class Goods extends Api
}
$goods_spec = GoodsSpec::all(['goods_id' => $goods_id]);
foreach ($goods_spec as &$value) {
$value['goods_price'] = round($value['goods_price'], 2);
$value['line_price'] = round($value['line_price'], 2);
//判断是否打折
$value['is_discount'] = 'is';
if ($value['goods_price'] == $value['line_price']) {
... ...