commit
4a7ad071bc
@ -19,6 +19,7 @@ use app\admin\lists\store_order_cart_info\StoreOrderCartInfoGroupMonthLists;
|
||||
use app\admin\logic\statistic\ProductStatisticLogic;
|
||||
use app\admin\logic\statistic\TradeStatisticLogic;
|
||||
use app\admin\logic\statistic\UserStatisticLogic;
|
||||
use app\admin\logic\statistic\WarehouseLogic;
|
||||
use app\admin\logic\WorkbenchLogic;
|
||||
use app\store\logic\WorkbenchLogic as LogicWorkbenchLogic;
|
||||
use DateInterval;
|
||||
@ -269,4 +270,24 @@ class WorkbenchController extends BaseAdminController
|
||||
return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d", time());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计仓库
|
||||
* @return array
|
||||
*/
|
||||
public function total_warehouse()
|
||||
{
|
||||
$data=WarehouseLogic::total_warehouse();
|
||||
return $this->data($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计仓库
|
||||
* @return array
|
||||
*/
|
||||
public function warehouse_list()
|
||||
{
|
||||
$data=WarehouseLogic::warehouse_list();
|
||||
return $this->data($data);
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,9 @@ class StoreBranchProductController extends BaseAdminController
|
||||
{
|
||||
$params = (new StoreProductValidate())->post()->goCheck('delete');
|
||||
StoreBranchProductLogic::delete($params);
|
||||
if(StoreBranchProductLogic::hasError()){
|
||||
return $this->fail(StoreBranchProductLogic::getError());
|
||||
}
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['oid'],
|
||||
'=' => ['oid','product_id'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
|
||||
public function lists(): array
|
||||
{
|
||||
return StoreOrderCartInfo::where($this->searchWhere)
|
||||
->field('cart_info,product_id,store_id,cart_num,price,total_price')->limit($this->limitOffset, $this->limitLength)
|
||||
->field('cart_info,product_id,store_id,cart_num,price,total_price,create_time')->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->each(function ($item) {
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->find();
|
||||
if($find){
|
||||
|
@ -99,8 +99,10 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
}
|
||||
if ($item->product_id) {
|
||||
$find = StoreProduct::where('id', $item->product_id)->field('image,store_name')->find();
|
||||
$item->store_name = $find->store_name . '|' . $item->product_id;
|
||||
$item->image = $find->image;
|
||||
if($find){
|
||||
$item->store_name = $find->store_name . '|' . $item->product_id;
|
||||
$item->image = $find->image;
|
||||
}
|
||||
} else {
|
||||
$item->store_name = '';
|
||||
}
|
||||
|
102
app/admin/logic/statistic/WarehouseLogic.php
Normal file
102
app/admin/logic/statistic/WarehouseLogic.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic\statistic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
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 Exception;
|
||||
|
||||
/**
|
||||
* Class 仓库统计
|
||||
* @package app\services\statistic
|
||||
*/
|
||||
class WarehouseLogic extends BaseLogic
|
||||
{
|
||||
|
||||
public static function total_warehouse()
|
||||
{
|
||||
$topData[] = [
|
||||
'title' => '总采购金额',
|
||||
'desc' => '平台采购商品总支付金额',
|
||||
'total_money' => 22,
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
|
||||
|
||||
$topData[] = [
|
||||
'title' => '已结算金额',
|
||||
'desc' => '平台支付给供应商的金额',
|
||||
'total_money' => 6565,
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
$topData[] = [
|
||||
'title' => '未结算金额',
|
||||
'desc' => '平台未支付给供应商的金额',
|
||||
'total_money' => 6565,
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
$topData[] = [
|
||||
'title' => '总商品库存',
|
||||
'desc' => '平台统计商品总库存、含门店仓库',
|
||||
'total_money' => 6565,
|
||||
'cash_title' => 12322,
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
$topData[] = [
|
||||
'title' => '总仓库库存',
|
||||
'desc' => '平台统计仓库库存',
|
||||
'total_money' => 6565,
|
||||
'cash_title' => 12322,
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
$topData[] = [
|
||||
'title' => '海吉星仓库库存',
|
||||
'desc' => '平台统计海吉星仓库库存',
|
||||
'total_money' => 6565,
|
||||
'cash_title' => 12322,
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
$topData[] = [
|
||||
'title' => '泸县集采集配库存',
|
||||
'desc' => '平台统计泸县集采集配库存',
|
||||
'total_money' => 6565,
|
||||
'cash_title' => 12322,
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
$topData[] = [
|
||||
'title' => '总门店库存',
|
||||
'desc' => '平台统计门店库存',
|
||||
'total_money' => 6565,
|
||||
'cash_title' => 12322,
|
||||
|
||||
'value' => [],
|
||||
'type' => 1,
|
||||
];
|
||||
$data['series'] = [];
|
||||
foreach ($topData as $k => $v) {
|
||||
// $data['x'] = $Chain['out']['x'];
|
||||
$data['series'][$k]['name'] = $v['title'];
|
||||
$data['series'][$k]['desc'] = $v['desc'];
|
||||
$data['series'][$k]['total_value'] = $v['total_money'];
|
||||
$data['series'][$k]['total_money'] = $v['cash_title'] ?? '';
|
||||
|
||||
$data['series'][$k]['type'] = $v['type'];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function warehouse_list() {
|
||||
// StoreProduct::where('is_show',1)->
|
||||
}
|
||||
}
|
@ -117,6 +117,11 @@ class StoreBranchProductLogic extends BaseLogic
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
$stock=StoreBranchProduct::where('id', $params['id'])->value('stock');
|
||||
if($stock>0){
|
||||
self::setError('商品库存不为0,无法删除');
|
||||
return false;
|
||||
}
|
||||
return StoreBranchProduct::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ class WarehouseOrderLogic extends BaseLogic
|
||||
try {
|
||||
foreach ($params['product_arr'] as $k => $v) {
|
||||
$data['admin_id'] = $params['admin_id'];
|
||||
$data['store_id'] = 0;
|
||||
$data['store_id'] = $find['store_id'];
|
||||
$data['oid'] = $find['id'];
|
||||
$data['supplier_id'] = $find['supplier_id'];
|
||||
$data['warehouse_id'] = $find['warehouse_id'];
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace app\admin\logic\warehouse_product;
|
||||
|
||||
|
||||
use app\admin\logic\store_product\StoreProductLogic;
|
||||
use app\common\model\warehouse_product\WarehouseProduct;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||
@ -43,9 +43,21 @@ class WarehouseProductLogic extends BaseLogic
|
||||
if ($params['financial_pm'] == 0) {
|
||||
$after_nums = $storege['nums'] - $params['nums'];
|
||||
if ($after_nums < 0) {
|
||||
throw new BusinessException('库存不足');
|
||||
throw new BusinessException('库存不足,warehouse_id:'.$params['warehouse_id'].'product_id:'.$params['product_id']);
|
||||
}
|
||||
WarehouseProductStorege::where('id', $storege['id'])->dec('nums', $params['nums'])->update();
|
||||
//门店加库存
|
||||
$storeBranchProduct = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id',$params['store_id'])->find();
|
||||
if(!$storeBranchProduct){
|
||||
$storeProduct = StoreProduct::where('id', $params['product_id'])->findOrEmpty()->toArray();
|
||||
if (!$storeProduct) {
|
||||
throw new BusinessException('商品不存在');
|
||||
}
|
||||
$storeBranchProduct=StoreProductLogic::ordinary(['id'=>$params['product_id']],$params['store_id'], $params['admin_id'], $storeProduct);
|
||||
}
|
||||
if ($params['nums'] > 0) {
|
||||
StoreBranchProduct::where('id', $storeBranchProduct['id'])->inc('stock',$params['nums'])->update();
|
||||
}
|
||||
} else {
|
||||
$after_nums = $storege['nums'] + $params['nums'];
|
||||
WarehouseProductStorege::where('id', $storege['id'])->inc('nums', $params['nums'])->update();
|
||||
|
Loading…
x
Reference in New Issue
Block a user