更新本地生活购物车总价
This commit is contained in:
parent
fbc85c7094
commit
cba8ae1ebf
@ -113,12 +113,25 @@ class LocalStoreGoodsCartLogic extends Logic
|
||||
}
|
||||
}
|
||||
|
||||
$price = number_format($post['goods_num'] * $item['price'], 2, '.', '');
|
||||
|
||||
LocalStoreGoodsCart::where('id', $post['cart_id'])->update([
|
||||
'goods_num' => $post['goods_num']
|
||||
]);
|
||||
|
||||
$cart = LocalStoreGoodsCart::alias('c')
|
||||
->join('local_store_goods g', 'c.lsg_id = g.id')
|
||||
->where(['c.user_id' => $user_id, 'c.lstore_id' => $post['lstore_id'], 'c.is_delete' => 0, 'g.state' => 1, 'g.audit_status' => 1, 'g.delete_time' => 0])
|
||||
->field('c.id, c.item_id, c.goods_num, g.id as lsg_id, g.title, g.price')
|
||||
->append(['pic', 'item'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$price = 0;
|
||||
foreach ($cart as &$v) {
|
||||
$price += ($v['goods_num'] * $v['price']);
|
||||
}
|
||||
|
||||
$price = number_format($price, 2, '.', '');
|
||||
|
||||
} else {
|
||||
throw new \Exception('商品信息不存在');
|
||||
}
|
||||
@ -127,7 +140,7 @@ class LocalStoreGoodsCartLogic extends Logic
|
||||
}
|
||||
Db::commit();
|
||||
return [
|
||||
'total_amount' => $price
|
||||
'total_amount' => $price,
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user