修改采购订单写入

This commit is contained in:
luofei 2024-02-02 14:57:44 +08:00
parent 31349fc1ef
commit 9f476e7634

View File

@ -2,11 +2,9 @@
namespace app\controller\api\store\order;
use app\common\model\system\merchant\Merchant;
use think\facade\Db;
use crmeb\basic\BaseController;
use think\facade\Log;
use app\common\repositories\system\merchant\FinancialRecordRepository;
/**
* 订单处理
@ -43,6 +41,8 @@ class StoreProcessing extends BaseController
$order['user_phone'] = $merchant_two['mer_phone'];
$order['user_address'] = $merchant_two['mer_address'];
$order['order_type'] = 0;
$order['pay_price'] = $order['procure_price'];
$order['total_price'] = $order['procure_price'];
unset($order['order_id'], $order['orderProduct'], $order['user'], $order['supply_chain_rate'], $order['logistics_code'], $order['logistics_phone']);
$order_id = Db::name('store_order_other')->strict(false)->insertGetId($order);
@ -50,8 +50,13 @@ class StoreProcessing extends BaseController
foreach ($arr as $key => $value) {
$arr[$key]['order_id'] = $order_id;
$arr[$key]['source'] = 104;
$cartInfo = json_decode($value['cart_info'], true);
$arr[$key]['product_price'] = bcmul($cartInfo['productAttr']['procure_price'], $value['product_num'], 2);
$arr[$key]['total_price'] = $arr[$key]['product_price'];
$arr[$key]['pay_price'] = $arr[$key]['product_price'];
$arr[$key]['product_id'] = $value['product_source_id'];
unset($arr[$key]['order_product_id']);
Db::name('store_product')->where('product_id',$value['product_id'])->dec('stock');
Db::name('store_product')->where('product_id',$value['product_source_id'])->dec('stock');
}
// $financialRecordRepository->insertAll($finance);
Db::name('store_order_product_other')->strict(false)->insertAll($arr);