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()
{
$product_arr = $this->request->post('product_arr');
$store_arr = $this->request->post('store_arr');
$warehouse_id = $this->request->post('warehouse_id');
$delivery_time = $this->request->post('delivery_time');
$mark = $this->request->post('mark');
$count = count($store_arr);
// 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('商品库存不足');
// }
// }
$type = $this->request->post('order_type', 1);
Db::startTrans();
try {
if ($count == 1) {
$store_id = $store_arr[0];
if($type==1){
$code=getNewOrderId('TGY');
}else{
$code=getNewOrderId('BS');
}
$arr = [
'warehouse_id' => $warehouse_id,
'store_id' => $store_id,
'store_id' => 0,
'supplier_id' => 0,
'code' => getNewOrderId('PS'),
'code' => $code,
'admin_id' => $this->adminId,
'financial_pm' => 0,
'batch' => 0,
@ -103,33 +98,31 @@ class WarehouseOrderController extends BaseAdminController
$data = [
'warehouse_id' => $warehouse_id,
'product_id' => $arr['id'],
'store_id' => $store_id,
'store_id' => 0,
'financial_pm' => 0,
'batch' => 1,
'nums' => $arr['stock'],
'status' => 1,
'admin_id' => $this->adminId,
'type' => $type,
'order_type' => 0,
];
$storeProduct = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray();
if ($arr['stock'] == 0) {
StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $storeProduct);
} else {
$storeProduct = StoreProduct::where('id', $arr['id'])->find();
$data['total_price'] = bcmul($arr['stock'], $storeProduct['purchase'], 2);
$data['purchase'] = $storeProduct['purchase'];
$data['oid'] = $res['id'];
$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();
WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]);
}
}
}
Db::commit();
} catch (\Throwable $e) {
Db::rollback();
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
* @date 2024/08/20 10:50
*/
public function update_edit(){
public function update_edit()
{
$params = $this->request->post();
$result = WarehouseOrderLogic::update_edit($params);
if (true === $result) {

View File

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