Merge pull request 'dev' (#398) from dev into main

Reviewed-on: #398
This commit is contained in:
mkm 2024-12-19 11:27:55 +08:00
commit 5fb2330a6d
2 changed files with 80 additions and 86 deletions

View File

@ -71,27 +71,22 @@ class WarehouseOrderController extends BaseAdminController
public function outbound() public function outbound()
{ {
$product_arr = $this->request->post('product_arr'); $product_arr = $this->request->post('product_arr');
$store_arr = $this->request->post('store_arr');
$warehouse_id = $this->request->post('warehouse_id'); $warehouse_id = $this->request->post('warehouse_id');
$delivery_time = $this->request->post('delivery_time'); $delivery_time = $this->request->post('delivery_time');
$mark = $this->request->post('mark'); $mark = $this->request->post('mark');
$count = count($store_arr); $type = $this->request->post('order_type', 1);
// foreach ($product_arr as $key => $arr) {
// $stock = bcmul($arr['stock'], $count);
// $nums = WarehouseProductStorege::where('warehouse_id', $warehouse_id)->where('product_id', $arr['id'])->value('nums');
// if ($nums < $stock) {
// return $this->fail('商品库存不足');
// }
// }
Db::startTrans(); Db::startTrans();
try { try {
if ($count == 1) { if($type==1){
$store_id = $store_arr[0]; $code=getNewOrderId('TGY');
}else{
$code=getNewOrderId('BS');
}
$arr = [ $arr = [
'warehouse_id' => $warehouse_id, 'warehouse_id' => $warehouse_id,
'store_id' => $store_id, 'store_id' => 0,
'supplier_id' => 0, 'supplier_id' => 0,
'code' => getNewOrderId('PS'), 'code' => $code,
'admin_id' => $this->adminId, 'admin_id' => $this->adminId,
'financial_pm' => 0, 'financial_pm' => 0,
'batch' => 0, 'batch' => 0,
@ -103,33 +98,31 @@ class WarehouseOrderController extends BaseAdminController
$data = [ $data = [
'warehouse_id' => $warehouse_id, 'warehouse_id' => $warehouse_id,
'product_id' => $arr['id'], 'product_id' => $arr['id'],
'store_id' => $store_id, 'store_id' => 0,
'financial_pm' => 0, 'financial_pm' => 0,
'batch' => 1, 'batch' => 1,
'nums' => $arr['stock'], 'nums' => $arr['stock'],
'status' => 1, 'status' => 1,
'admin_id' => $this->adminId, 'admin_id' => $this->adminId,
'type' => $type,
'order_type' => 0,
]; ];
$storeProduct = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray(); $storeProduct = StoreProduct::where('id', $arr['id'])->find();
if ($arr['stock'] == 0) {
StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $storeProduct);
} else {
$data['total_price'] = bcmul($arr['stock'], $storeProduct['purchase'], 2); $data['total_price'] = bcmul($arr['stock'], $storeProduct['purchase'], 2);
$data['purchase'] = $storeProduct['purchase']; $data['purchase'] = $storeProduct['purchase'];
$data['oid'] = $res['id']; $data['oid'] = $res['id'];
$data['financial_pm'] = 0; $data['financial_pm'] = 0;
WarehouseProductLogic::add($data); $data['price'] = $storeProduct['price'];
WarehouseProductLogic::setOutbound($data);
$finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); $finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]); WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]);
} }
}
}
Db::commit(); Db::commit();
} catch (\Throwable $e) { } catch (\Throwable $e) {
Db::rollback(); Db::rollback();
throw new BusinessException($e->getMessage()); throw new BusinessException($e->getMessage());
} }
return $this->success('已导入后台队列,请在门店入库记录中查看', [], 1, 1); return $this->success('出库成功', [], 1, 1);
} }
@ -155,7 +148,8 @@ class WarehouseOrderController extends BaseAdminController
* @author admin * @author admin
* @date 2024/08/20 10:50 * @date 2024/08/20 10:50
*/ */
public function update_edit(){ public function update_edit()
{
$params = $this->request->post(); $params = $this->request->post();
$result = WarehouseOrderLogic::update_edit($params); $result = WarehouseOrderLogic::update_edit($params);
if (true === $result) { if (true === $result) {

View File

@ -91,7 +91,7 @@ class WarehouseProductLogic extends BaseLogic
'nums' => $params['nums'], 'nums' => $params['nums'],
'before_nums' => $before_nums, 'before_nums' => $before_nums,
'after_nums' => $after_nums, 'after_nums' => $after_nums,
// 'price' => $params['price'] ?? '', 'price' => $params['price'] ?? '',
'purchase' => $params['purchase'] ?? '', 'purchase' => $params['purchase'] ?? '',
// 'cost' => $params['cost'] ?? '', // 'cost' => $params['cost'] ?? '',
'total_price' => $params['total_price'] ?? '', 'total_price' => $params['total_price'] ?? '',