Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zptz-sass-kelaidian
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
李大见
zptz-sass-kelaidian
Commits
4d0f23d5
提交
4d0f23d5
authored
5月 20, 2026
作者:
窦斌
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
edit
上级
f25508b0
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
259 行增加
和
0 行删除
+259
-0
InventoryController.php
app/Http/Controllers/Api/MobileWeb/InventoryController.php
+61
-0
InventoryValidator.php
.../Requests/Validators/Api/MobileWeb/InventoryValidator.php
+67
-0
Inventory.php
app/Models/Inventory.php
+25
-0
InventoryService.php
app/Services/Api/MobileWeb/InventoryService.php
+101
-0
api.php
routes/api.php
+5
-0
没有找到文件。
app/Http/Controllers/Api/MobileWeb/InventoryController.php
0 → 100644
浏览文件 @
4d0f23d5
<?php
namespace
App\Http\Controllers\Api\MobileWeb
;
use
App\Services\Api\MobileWeb\InventoryService
;
use
Illuminate\Http\Request
;
use
App\Http\Controllers\Controller
;
use
App\Http\Requests\Validators\Api\MobileWeb\InventoryValidator
;
use
BlueCity\Core\Inc\ErrorInc
;
// 移动端-技师管理
class
InventoryController
extends
Controller
{
// 列表每页显示数据个数
protected
$show_count
=
10
;
public
function
__construct
()
{
$this
->
dataValidator
=
new
InventoryValidator
();
}
// 列表
public
function
index
(
Request
$request
)
{
// 验证数据
$error_message
=
$this
->
dataValidator
->
indexValidator
(
$request
->
all
());
if
(
$error_message
)
{
return
response
()
->
json
([
'ErrorCode'
=>
ErrorInc
::
INVALID_PARAM
,
'ErrorMessage'
=>
$error_message
->
first
(),
'Data'
=>
[
$error_message
]]);
}
$return_data
=
InventoryService
::
index
(
$request
->
all
(),
$this
->
show_count
);
return
$return_data
;
}
/**|---------------------------------------------------------------------------------
* @name 获取品牌
* @retrun \Illuminate\Http\JsonResponse /multitype:array
* @author dou 2026/5/20 14:13
* |---------------------------------------------------------------------------------
*/
public
function
getBrand
(
Request
$request
){
$return_data
=
InventoryService
::
getBrand
(
$request
->
all
());
return
$return_data
;
}
/**|---------------------------------------------------------------------------------
* @name 编辑商品数量
* @param string goodid 商品id
* @param string goodnum 库存数量
* @retrun \Illuminate\Http\JsonResponse /multitype:array
* @author dou 2026/5/20 15:56
* |---------------------------------------------------------------------------------
*/
public
function
edit
(
Request
$request
){
// 验证数据
$error_message
=
$this
->
dataValidator
->
editValidator
(
$request
->
all
());
if
(
$error_message
)
{
return
response
()
->
json
([
'ErrorCode'
=>
ErrorInc
::
INVALID_PARAM
,
'ErrorMessage'
=>
$error_message
->
first
(),
'Data'
=>
[
$error_message
]]);
}
$return_data
=
InventoryService
::
edit
(
$request
->
all
());
return
$return_data
;
}
}
app/Http/Requests/Validators/Api/MobileWeb/InventoryValidator.php
0 → 100644
浏览文件 @
4d0f23d5
<?php
namespace
App\Http\Requests\Validators\Api\MobileWeb
;
use
Illuminate\Foundation\Http\FormRequest
;
use
Illuminate\Validation\Rule
;
use
Validator
;
class
InventoryValidator
extends
FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public
function
authorize
()
{
return
false
;
}
// 新增验证器
public
function
indexValidator
(
$data
)
{
// 自定义错误消息
$messages
=
[
'gs_bid.required'
=>
'请选择品牌'
,
];
// 数据验证
$validator
=
Validator
::
make
(
$data
,
[
'gs_bid'
=>
'required'
,
],
$messages
);
// 判断数据验证是否成功
if
(
$validator
->
fails
())
{
return
$validator
->
errors
();
}
}
// 修改密码验证器
public
function
editValidator
(
$data
)
{
// 自定义错误消息
$messages
=
[
'goodid.required'
=>
'参数错误'
,
'goodid.integer'
=>
'参数错误'
,
'goodid.min'
=>
'参数错误'
,
'goodnum.required'
=>
'参数错误'
,
'goodnum.integer'
=>
'参数错误'
,
'goodnum.min'
=>
'参数错误'
,
'brand.required'
=>
'参数错误'
,
'brand.string'
=>
'参数错误'
,
];
// 数据验证
$validator
=
Validator
::
make
(
$data
,
[
'goodid'
=>
'required|integer|min:1'
,
'goodnum'
=>
'required|integer|min:0'
,
'brand'
=>
'required|string'
,
],
$messages
);
// 判断数据验证是否成功
if
(
$validator
->
fails
())
{
return
$validator
->
errors
();
}
}
}
app/Models/Inventory.php
0 → 100644
浏览文件 @
4d0f23d5
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\Model
;
class
Inventory
extends
Model
{
protected
$table
=
'inventory'
;
protected
$primaryKey
=
'inv_id'
;
public
$timestamps
=
false
;
protected
$fillable
=
[
'inv_goodid'
,
'inv_serid'
,
'inv_company_id'
,
'inv_brand'
,
'inv_num'
,
'inv_time'
,
];
}
app/Services/Api/MobileWeb/InventoryService.php
0 → 100644
浏览文件 @
4d0f23d5
<?php
namespace
App\Services\Api\MobileWeb
;
use
App\Models\Inventory
;
use
App\Services\CommonService
;
use
Illuminate\Support\Facades\Request
;
use
Illuminate\Support\Facades\DB
;
use
BlueCity\Core\Inc\ErrorInc
;
// 移动端,技师管理
class
InventoryService
{
// 列表查询
public
static
function
index
(
$request
,
$show_count
=
10
)
{
$session
=
$request
[
'session'
];
$session
[
'company_id'
]
=
14
;
if
(
$session
[
'user_type'
]
==
1
){
return
[
'ErrorCode'
=>
1
,
'ErrorMessage'
=>
'暂无数据'
,
'data'
=>
[]];
}
//获取商品信息
// CommonService::startmysql();
$list_data
=
DB
::
table
(
'pj_goods'
)
->
leftJoin
(
'inventory'
,
function
(
$join
)
use
(
$session
)
{
$join
->
on
(
'pj_goods.pg_id'
,
'='
,
'inventory.inv_goodid'
)
->
where
(
'inventory.inv_serid'
,
$session
[
'admin_id'
])
//所属服务商
->
where
(
'inventory.inv_company_id'
,
$session
[
'company_id'
]);
//所属公司
})
->
where
(
'company_id'
,
$session
[
'company_id'
])
//所属公司
->
where
(
'is_delect'
,
1
)
->
where
(
function
(
$query
)
use
(
$request
)
{
// 品牌id
if
(
!
empty
(
$request
[
'gs_bid'
]))
{
$query
->
where
(
'gs_bid'
,
$request
[
'gs_bid'
]);
}
})
->
select
(
'pg_id'
,
'pg_goodsname'
,
DB
::
raw
(
'IFNULL(gone_inventory.inv_num, 0) as stock_num'
))
->
orderby
(
'pg_id'
,
'desc'
)
->
get
();
// ->paginate($show_count);
// $data['sql'] = CommonService::showmysql();
// $page['count'] = 0;
// $page['page'] = 0;
// $page['page_size'] = $show_count;
// $page['allPage'] = 0;
// $data['list'] = [];
// $data['page'] = $page;
// $list_items = $list_data->items();
// if ($list_items) {
// $page['count'] = $list_data->total(); //总数据个数
// $page['page'] = $list_data->currentPage(); //当前页面页码
// $page['page_size'] = $show_count; //一页显示多少个
// $page['allPage'] = $list_data->lastPage(); //表示最后一页的页码
// $data['list'] = $list_items;
// $data['page'] = $page;
// }
// if ($data['list']) {
return
[
'ErrorCode'
=>
1
,
'ErrorMessage'
=>
'成功'
,
'data'
=>
$list_data
];
// } else {
// return ['ErrorCode' => 1, 'ErrorMessage'=>'暂无数据', 'data'=>$data];
// }
}
//获取品牌
public
static
function
getBrand
(
$request
){
$session
=
$request
[
'session'
];
$session
[
'company_id'
]
=
14
;
$list_data
=
DB
::
table
(
'goods_brand'
)
->
where
(
"company_id"
,
$session
[
'company_id'
])
->
where
(
"del_flag"
,
1
)
->
select
(
'id'
,
'brand_name'
)
->
get
();
return
[
'ErrorCode'
=>
1
,
'ErrorMessage'
=>
'成功'
,
'data'
=>
$list_data
];
}
//编辑库存
public
static
function
edit
(
$request
){
$session
=
$request
[
'session'
];
$session
[
'company_id'
]
=
14
;
$res
=
Inventory
::
updateOrCreate
(
[
'inv_goodid'
=>
$request
[
'goodid'
],
'inv_serid'
=>
$session
[
'admin_id'
],
'inv_company_id'
=>
$session
[
'company_id'
],
],
[
'inv_num'
=>
$request
[
'goodnum'
],
'inv_brand'
=>
$request
[
'brand'
],
'inv_time'
=>
date
(
"Y-m-d H:i:s"
),
]
);
if
(
$res
)
{
return
[
'ErrorCode'
=>
1
,
'ErrorMessage'
=>
'操作成功'
,
'data'
=>
$res
];
}
else
{
return
[
'ErrorCode'
=>
201
,
'ErrorMessage'
=>
'操作失败'
,
'data'
=>
$res
];
}
}
}
routes/api.php
浏览文件 @
4d0f23d5
...
...
@@ -1522,5 +1522,10 @@ Route::namespace('Api')->group(function () {
Route
::
post
(
'w1/statement/index'
,
'MobileWeb\StatementsListController@index'
);
//列表页
Route
::
post
(
'w1/statement/info'
,
'MobileWeb\StatementsListController@info'
);
//列表页
Route
::
post
(
'w1/statement/businessFirm'
,
'MobileWeb\StatementsListController@businessFirm'
);
//商家确认
//库存管理
Route
::
post
(
'w1/inventory/index'
,
'MobileWeb\InventoryController@index'
);
//列表页
Route
::
post
(
'w1/inventory/getBrand'
,
'MobileWeb\InventoryController@getBrand'
);
//编辑数量
Route
::
post
(
'w1/inventory/edit'
,
'MobileWeb\InventoryController@edit'
);
//编辑数量
});
});
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论