更新转售下单处理

This commit is contained in:
yaooo 2023-08-16 14:33:36 +08:00
parent a4c3ae5192
commit 5baccb6489
2 changed files with 9 additions and 8 deletions

View File

@ -102,18 +102,19 @@ class StoreOrderCreateRepository extends StoreOrderRepository
}
$community = [];
if ($order_type == 98) {
$attrUniqueArray = [];
$communityIdArray = [];
foreach($merchantCart['list'] as $prod){
$attrUniqueArray[] = $prod['product_attr_unique'];
$communityIdArray[] = $prod['source_id'] ?? 0;
}
$attrInfo = Db::name('Resale')->alias('r')->leftJoin('Community c','r.community_id = c.community_id')->whereIn('r.product_attr_unique', $attrUniqueArray)->distinct(true)->field('c.community_id, c.title, c.image')->fetchSql(false)->select();
if (count($attrInfo) > 1) {
if (count(array_unique($communityIdArray)) > 1) {
throw new ValidateException('转售商品数据异常');
}
$community = Db::name('Community')->where('community_id', $communityIdArray[0] ?? 0)->field('community_id, title, image')->fetchSql(false)->find();
if (!$community) {
throw new ValidateException('转售商品数据异常');
}
$community = $attrInfo[0] ?? [];
}
unset($merchantCart, $cart);
$order_price = 0;
$total_true_price = 0;
$order_total_price = 0;

View File

@ -527,11 +527,11 @@ class StoreOrderRepository extends BaseRepository
return $cart['activeSku']['active_price'];
// 更新调货价格
} else if ($cart['product_type'] == '98') {
$price = Db::name('resale')->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price');
$price = Db::name('resale')->where('community_id', $cart['source_id'])->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price');
if ($price) {
return $price;
} else {
return $cart['productAttr']['price'];
throw new ValidateException('转售商品数据异常');
}
} else {
return $cart['productAttr']['price'];