添加采购单

This commit is contained in:
DESKTOP-GMUNQ1B\Administrator 2024-12-18 14:48:31 +08:00
parent 516adaf674
commit c0cdd0974b
3 changed files with 17 additions and 1 deletions

View File

@ -110,6 +110,8 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
$item->outbound = '无须出库';
} elseif ($item->order_type == 6) {
$item->order_type_name = '往期补单';
} elseif ($item->order_type == 7) {
$item->order_type_name = '采购订单';
}
$item->msg = '';
$count1 = PurchaseProductOffer::where('order_id', $item->id)->where('buyer_confirm', 0)->count('id');

View File

@ -678,6 +678,10 @@ class BeforehandOrderLogic extends BaseLogic
{
$order_info = new OrderInfo();
$order = BeforehandOrder::where('id', $params['id'])->find();
if ($order['order_type'] == 7 && $params['print'] == 1) {
$order->is_buying = 1;
$order->save();
}
$order['admin_name'] = Admin::where('id', $order['admin_id'])->value('name');
$data = PurchaseProductOffer::where('order_id', $params['id'])->select()->each(function ($item) {
$find = StoreProduct::where('id', $item['product_id'])->field('top_cate_id,store_name,unit,gross_weight,net_weight')->withTrashed()->find();

View File

@ -41,13 +41,23 @@ class PurchaseProductOfferLogic extends BaseLogic
{
Db::startTrans();
try {
$procurementOrder = BeforehandOrder::where('order_type', 7)->where('is_buying', 0)->find();
if (empty($procurementOrder)) {
$beforeOrder = BeforehandOrder::where('id', $params['order_id'])->findOrEmpty()->toArray();
unset($beforeOrder['id'], $beforeOrder['create_time'], $beforeOrder['update_time']);
$procurementOrder = new BeforehandOrder();
$procurementOrder->setAttrs($beforeOrder);
$procurementOrder->order_id = getNewOrderId('CG');
$procurementOrder->order_type = 7;
$procurementOrder->save();
}
$mark = $params['mark'] ?? '';
if ($mark == '') {
$mark = BeforehandOrderCartInfo::where('bhoid', $params['order_id'])->where('product_id', $params['product_id'])->value('mark');
}
$find=StoreProduct::where('id',$params['product_id'])->find();
PurchaseProductOffer::create([
'order_id' => $params['order_id'],
'order_id' => $procurementOrder['id'],
'product_id' => $params['product_id'],
'unit' => $params['unit'],
'is_buyer' => $params['is_buyer'],