更新采购商品结算

This commit is contained in:
yaooo 2023-08-23 16:05:26 +08:00
parent 20e0f50e54
commit faa2e16f7a
2 changed files with 21 additions and 13 deletions

View File

@ -102,17 +102,21 @@ class StoreOrderCreateRepository extends StoreOrderRepository
}
$community = [];
if ($order_type == 98) {
$communityIdArray = [];
$sourceIdArray = [];
foreach($merchantCart['list'] as $prod){
$communityIdArray[] = $prod['source_id'] ?? 0;
if ($prod['source_id'] > 0) {
$sourceIdArray[] = $prod['source_id'];
}
}
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) {
$deliverMethod = Db::name('resale')->where('community_id', $communityIdArray[0] ?? 0)->value('deliver_method');
$deliverMethodArray = explode(',', $deliverMethod);
if (count($sourceIdArray)) {
if (count(array_unique($sourceIdArray)) > 1) {
throw new ValidateException('转售商品数据异常');
}
$community = Db::name('Community')->where('community_id', $communityIdArray[0] ?? 0)->field('community_id, title, image')->fetchSql(false)->find();
if ($community) {
$deliverMethod = Db::name('resale')->where('community_id', $communityIdArray[0] ?? 0)->value('deliver_method');
$deliverMethodArray = explode(',', $deliverMethod);
}
}
}
unset($merchantCart, $cart);

View File

@ -527,11 +527,15 @@ class StoreOrderRepository extends BaseRepository
return $cart['activeSku']['active_price'];
// 更新调货价格
} else if ($cart['product_type'] == '98') {
$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;
if ($cart['source_id'] > 0) {
$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 {
throw new ValidateException('转售商品数据异常');
}
} else {
throw new ValidateException('转售商品数据异常');
return $cart['productAttr']['price'];
}
} else {
return $cart['productAttr']['price'];