调拨订单导出和插入arr
This commit is contained in:
parent
be9781f170
commit
dd681470d8
@ -233,6 +233,7 @@ class InventoryTransferOrderLogic extends BaseLogic
|
|||||||
->toArray();
|
->toArray();
|
||||||
return $data->toArray();
|
return $data->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入调拨订单
|
* 插入调拨订单
|
||||||
*/
|
*/
|
||||||
@ -240,18 +241,44 @@ class InventoryTransferOrderLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$find = InventoryTransfer::where('product_id', $params['product_id'])->where('oid', $params['id'])->find()->toArray();
|
$product_arr = $params['product_arr'];
|
||||||
if ($find) {
|
$insert = [];
|
||||||
unset($find['id']);
|
foreach ($product_arr as $v) {
|
||||||
$find['nums'] = $params['nums'];
|
$find = InventoryTransfer::where('product_id', $v['id'])->where('oid', $params['oid'])->find()->toArray();
|
||||||
$find['create_time'] = time();
|
if ($find) {
|
||||||
|
unset($find['id']);
|
||||||
|
$find['nums'] = $v['nums'];
|
||||||
|
$find['create_time'] = time();
|
||||||
|
$insert[] = $find;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
InventoryTransfer::insert($find);
|
InventoryTransfer::insertAll($insert);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
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