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('商品库存不足');
|
return $this->fail('商品库存不足');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
if ($count == 1) {
|
if ($count == 1) {
|
||||||
@ -117,16 +116,6 @@ class WarehouseOrderController extends BaseAdminController
|
|||||||
$data['purchase'] = $storeProduct['purchase'];
|
$data['purchase'] = $storeProduct['purchase'];
|
||||||
$data['oid'] = $res['id'];
|
$data['oid'] = $res['id'];
|
||||||
WarehouseProductLogic::add($data);
|
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();
|
$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']]);
|
||||||
}
|
}
|
||||||
@ -135,6 +124,7 @@ class WarehouseOrderController extends BaseAdminController
|
|||||||
Db::commit();
|
Db::commit();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
|
d($e);
|
||||||
throw new BusinessException($e->getMessage());
|
throw new BusinessException($e->getMessage());
|
||||||
}
|
}
|
||||||
return $this->success('已导入后台队列,请在门店入库记录中查看', [], 1, 1);
|
return $this->success('已导入后台队列,请在门店入库记录中查看', [], 1, 1);
|
||||||
|
@ -3,11 +3,16 @@
|
|||||||
namespace app\admin\logic\statistic;
|
namespace app\admin\logic\statistic;
|
||||||
|
|
||||||
use app\common\logic\BaseLogic;
|
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\StoreOrder;
|
||||||
|
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
use app\common\model\user\UserVisit;
|
use app\common\model\user\UserVisit;
|
||||||
use app\common\model\user_recharge\UserRecharge;
|
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;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,7 +27,7 @@ class WarehouseLogic extends BaseLogic
|
|||||||
$topData[] = [
|
$topData[] = [
|
||||||
'title' => '总采购金额',
|
'title' => '总采购金额',
|
||||||
'desc' => '平台采购商品总支付金额',
|
'desc' => '平台采购商品总支付金额',
|
||||||
'total_money' => 22,
|
'total_money' => WarehouseOrder::sum('total_price'),
|
||||||
'value' => [],
|
'value' => [],
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
];
|
];
|
||||||
@ -31,54 +36,56 @@ class WarehouseLogic extends BaseLogic
|
|||||||
$topData[] = [
|
$topData[] = [
|
||||||
'title' => '已结算金额',
|
'title' => '已结算金额',
|
||||||
'desc' => '平台支付给供应商的金额',
|
'desc' => '平台支付给供应商的金额',
|
||||||
'total_money' => 6565,
|
'total_money' => WarehouseOrder::sum('completed_amount'),
|
||||||
'value' => [],
|
'value' => [],
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
];
|
];
|
||||||
$topData[] = [
|
$topData[] = [
|
||||||
'title' => '未结算金额',
|
'title' => '未结算金额',
|
||||||
'desc' => '平台未支付给供应商的金额',
|
'desc' => '平台未支付给供应商的金额',
|
||||||
'total_money' => 6565,
|
'total_money' => WarehouseOrder::sum('outstanding_amount'),
|
||||||
'value' => [],
|
'value' => [],
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
];
|
];
|
||||||
|
$store_stock_1 = StoreBranchProduct::where('stock','>',0)->sum('stock');
|
||||||
|
$store_stock_2 = WarehouseProductStorege::where('nums','>',0)->sum('nums');
|
||||||
$topData[] = [
|
$topData[] = [
|
||||||
'title' => '总商品库存',
|
'title' => '总商品库存',
|
||||||
'desc' => '平台统计商品总库存、含门店仓库',
|
'desc' => '平台统计商品总库存、含门店仓库',
|
||||||
'total_money' => 6565,
|
'total_money' => bcadd($store_stock_1,$store_stock_2,2),
|
||||||
'cash_title' => 12322,
|
'cash_title' => 0,
|
||||||
'value' => [],
|
'value' => [],
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
];
|
];
|
||||||
$topData[] = [
|
$topData[] = [
|
||||||
'title' => '总仓库库存',
|
'title' => '总仓库库存',
|
||||||
'desc' => '平台统计仓库库存',
|
'desc' => '平台统计仓库库存',
|
||||||
'total_money' => 6565,
|
'total_money' => WarehouseProductStorege::sum('stock'),
|
||||||
'cash_title' => 12322,
|
'cash_title' => 0,
|
||||||
'value' => [],
|
'value' => [],
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
];
|
];
|
||||||
$topData[] = [
|
$topData[] = [
|
||||||
'title' => '海吉星仓库库存',
|
'title' => '海吉星仓库库存',
|
||||||
'desc' => '平台统计海吉星仓库库存',
|
'desc' => '平台统计海吉星仓库库存',
|
||||||
'total_money' => 6565,
|
'total_money' => WarehouseProductStorege::where('warehouse_id',1)->sum('stock'),
|
||||||
'cash_title' => 12322,
|
'cash_title' => 0,
|
||||||
'value' => [],
|
'value' => [],
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
];
|
];
|
||||||
$topData[] = [
|
$topData[] = [
|
||||||
'title' => '泸县集采集配库存',
|
'title' => '泸县集采集配库存',
|
||||||
'desc' => '平台统计泸县集采集配库存',
|
'desc' => '平台统计泸县集采集配库存',
|
||||||
'total_money' => 6565,
|
'total_money' => WarehouseProductStorege::where('warehouse_id',2)->sum('stock'),
|
||||||
'cash_title' => 12322,
|
'cash_title' => 0,
|
||||||
'value' => [],
|
'value' => [],
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
];
|
];
|
||||||
$topData[] = [
|
$topData[] = [
|
||||||
'title' => '总门店库存',
|
'title' => '总门店库存',
|
||||||
'desc' => '平台统计门店库存',
|
'desc' => '平台统计门店库存',
|
||||||
'total_money' => 6565,
|
'total_money' => StoreBranchProduct::sum('stock'),
|
||||||
'cash_title' => 12322,
|
'cash_title' => 0,
|
||||||
|
|
||||||
'value' => [],
|
'value' => [],
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
@ -96,7 +103,22 @@ class WarehouseLogic extends BaseLogic
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function warehouse_list() {
|
public static function warehouse_list()
|
||||||
// StoreProduct::where('is_show',1)->
|
{
|
||||||
|
$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