修复购买产品优惠记录创建时的mark字段问题

在创建购买产品优惠记录时,如果未提供mark参数,将从预订单购物车信息中获取相应的mark值。此修复确保了当没有直接提供mark值时,能够从关联的预订单购物车信息中正确地获取该值。
This commit is contained in:
mkm 2024-10-14 20:49:32 +08:00
parent d1d019ac16
commit f16a694b72

View File

@ -5,6 +5,7 @@ namespace app\admin\logic\purchase_product_offer;
use app\common\model\purchase_product_offer\PurchaseProductOffer;
use app\common\logic\BaseLogic;
use app\common\model\beforehand_order\BeforehandOrder;
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
use support\exception\BusinessException;
use think\facade\Db;
@ -30,13 +31,17 @@ class PurchaseProductOfferLogic extends BaseLogic
{
Db::startTrans();
try {
$mark=$params['mark'] ?? '';
if($mark==''){
$mark=BeforehandOrderCartInfo::where('bhoid',$params['order_id'])->where('product_id',$params['product_id'])->value('mark');
}
PurchaseProductOffer::create([
'order_id' => $params['order_id'],
'product_id' => $params['product_id'],
'unit' => $params['unit'],
'is_buyer' => $params['is_buyer'],
'need_num' => $params['need_num'],
'mark' => $params['mark'] ?? '',
'mark' => $mark,
'buyer_id' => $params['buyer_id'],
'status' => 0,