调拨订单导出和插入arr
This commit is contained in:
parent
be9781f170
commit
dd681470d8
@ -233,6 +233,7 @@ class InventoryTransferOrderLogic extends BaseLogic
|
||||
->toArray();
|
||||
return $data->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入调拨订单
|
||||
*/
|
||||
@ -240,18 +241,44 @@ class InventoryTransferOrderLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$find = InventoryTransfer::where('product_id', $params['product_id'])->where('oid', $params['id'])->find()->toArray();
|
||||
$product_arr = $params['product_arr'];
|
||||
$insert = [];
|
||||
foreach ($product_arr as $v) {
|
||||
$find = InventoryTransfer::where('product_id', $v['id'])->where('oid', $params['oid'])->find()->toArray();
|
||||
if ($find) {
|
||||
unset($find['id']);
|
||||
$find['nums'] = $params['nums'];
|
||||
$find['nums'] = $v['nums'];
|
||||
$find['create_time'] = time();
|
||||
$insert[] = $find;
|
||||
}
|
||||
InventoryTransfer::insert($find);
|
||||
}
|
||||
InventoryTransfer::insertAll($insert);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * 插入调拨订单
|
||||
// */
|
||||
// public static function insert($params)
|
||||
// {
|
||||
// Db::startTrans();
|
||||
// try {
|
||||
// $find = InventoryTransfer::where('product_id', $params['product_id'])->where('oid', $params['id'])->find()->toArray();
|
||||
// if ($find) {
|
||||
// unset($find['id']);
|
||||
// $find['nums'] = $params['nums'];
|
||||
// $find['create_time'] = time();
|
||||
// }
|
||||
// InventoryTransfer::insert($find);
|
||||
// Db::commit();
|
||||
// return true;
|
||||
// } catch (\Throwable $e) {
|
||||
// Db::rollback();
|
||||
// throw new BusinessException($e->getMessage());
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user