Merge pull request 'feat(WarehouseOrderController): 修改仓库订单控制器和仓库逻辑,优化库存处理和统计数据获取' (#150) from dev into main
Reviewed-on: #150
This commit is contained in:
commit
eaceddcc08
@ -81,7 +81,6 @@ class WarehouseOrderController extends BaseAdminController
|
||||
return $this->fail('商品库存不足');
|
||||
}
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
if ($count == 1) {
|
||||
@ -117,16 +116,6 @@ class WarehouseOrderController extends BaseAdminController
|
||||
$data['purchase'] = $storeProduct['purchase'];
|
||||
$data['oid'] = $res['id'];
|
||||
WarehouseProductLogic::add($data);
|
||||
$find = StoreBranchProduct::where('product_id', $arr['id'])->where('store_id', $store_id)->find();
|
||||
if ($find) {
|
||||
StoreBranchProduct::where('id', $find['id'])->inc('stock', $arr['stock'])->update();
|
||||
} else {
|
||||
$ordinary=StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $storeProduct);
|
||||
if(empty($ordinary)){
|
||||
throw new BusinessException('商品不存在');
|
||||
}
|
||||
StoreBranchProduct::where('id', $ordinary['id'])->inc('stock', $arr['stock'])->update();
|
||||
}
|
||||
$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']]);
|
||||
}
|
||||
@ -135,6 +124,7 @@ class WarehouseOrderController extends BaseAdminController
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
d($e);
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
return $this->success('已导入后台队列,请在门店入库记录中查看', [], 1, 1);
|
||||
|
@ -3,11 +3,16 @@
|
||||
namespace app\admin\logic\statistic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserVisit;
|
||||
use app\common\model\user_recharge\UserRecharge;
|
||||
use app\common\model\warehouse_order\WarehouseOrder;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
@ -22,7 +27,7 @@ class WarehouseLogic extends BaseLogic
|
||||
$topData[] = [
|
||||
'title' => '总采购金额',
|
||||
'desc' => '平台采购商品总支付金额',
|
||||
'total_money' => 22,
|
||||
'total_money' => WarehouseOrder::sum('total_price'),
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
@ -31,54 +36,56 @@ class WarehouseLogic extends BaseLogic
|
||||
$topData[] = [
|
||||
'title' => '已结算金额',
|
||||
'desc' => '平台支付给供应商的金额',
|
||||
'total_money' => 6565,
|
||||
'total_money' => WarehouseOrder::sum('completed_amount'),
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
$topData[] = [
|
||||
'title' => '未结算金额',
|
||||
'desc' => '平台未支付给供应商的金额',
|
||||
'total_money' => 6565,
|
||||
'total_money' => WarehouseOrder::sum('outstanding_amount'),
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
$store_stock_1 = StoreBranchProduct::where('stock','>',0)->sum('stock');
|
||||
$store_stock_2 = WarehouseProductStorege::where('nums','>',0)->sum('nums');
|
||||
$topData[] = [
|
||||
'title' => '总商品库存',
|
||||
'desc' => '平台统计商品总库存、含门店仓库',
|
||||
'total_money' => 6565,
|
||||
'cash_title' => 12322,
|
||||
'total_money' => bcadd($store_stock_1,$store_stock_2,2),
|
||||
'cash_title' => 0,
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
$topData[] = [
|
||||
'title' => '总仓库库存',
|
||||
'desc' => '平台统计仓库库存',
|
||||
'total_money' => 6565,
|
||||
'cash_title' => 12322,
|
||||
'total_money' => WarehouseProductStorege::sum('stock'),
|
||||
'cash_title' => 0,
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
$topData[] = [
|
||||
'title' => '海吉星仓库库存',
|
||||
'desc' => '平台统计海吉星仓库库存',
|
||||
'total_money' => 6565,
|
||||
'cash_title' => 12322,
|
||||
'total_money' => WarehouseProductStorege::where('warehouse_id',1)->sum('stock'),
|
||||
'cash_title' => 0,
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
$topData[] = [
|
||||
'title' => '泸县集采集配库存',
|
||||
'desc' => '平台统计泸县集采集配库存',
|
||||
'total_money' => 6565,
|
||||
'cash_title' => 12322,
|
||||
'total_money' => WarehouseProductStorege::where('warehouse_id',2)->sum('stock'),
|
||||
'cash_title' => 0,
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
$topData[] = [
|
||||
'title' => '总门店库存',
|
||||
'desc' => '平台统计门店库存',
|
||||
'total_money' => 6565,
|
||||
'cash_title' => 12322,
|
||||
'total_money' => StoreBranchProduct::sum('stock'),
|
||||
'cash_title' => 0,
|
||||
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
@ -96,7 +103,22 @@ class WarehouseLogic extends BaseLogic
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function warehouse_list() {
|
||||
// StoreProduct::where('is_show',1)->
|
||||
public static function warehouse_list()
|
||||
{
|
||||
$list = StoreProduct::where('is_show', 1)->select()->each(function ($item) {
|
||||
$item->sales = StoreOrderCartInfo::where('product_id', $item['id'])->sum('cart_num');
|
||||
$store_stock = StoreBranchProduct::where('product_id', $item['id'])->sum('stock');
|
||||
$warehouse_stock = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums');
|
||||
$item->store_stock=$store_stock;
|
||||
$item->warehouse_stock=$warehouse_stock;
|
||||
$item->total_stock=$store_stock+$warehouse_stock;
|
||||
$item->total_purchase=WarehouseProduct::where('product_id', $item['id'])->sum('total_price');
|
||||
$item->total_completed_amount=WarehouseProduct::where('product_id', $item['id'])->where('is_pay',1)->sum('total_price');
|
||||
$item->total_outstanding_amount=WarehouseProduct::where('product_id', $item['id'])->where('is_pay',0)->sum('total_price');
|
||||
|
||||
})->toArray();
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user