阶段更新
This commit is contained in:
@@ -16,7 +16,7 @@ class AreaCodeController extends Controller
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2023/1/12 11:03
|
||||
* @param AreaCode $areaCode
|
||||
* @param AreaCode $code
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function show(AreaCode $code)
|
||||
@@ -24,10 +24,48 @@ class AreaCodeController extends Controller
|
||||
return $this->success(new AreaCodeResource($code));
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 根据提货码查询信息
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2023/1/16 9:48
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function info(Request $request)
|
||||
{
|
||||
$code = AreaCode::query()->where('code', $request->code)->first();
|
||||
return $this->success(new AreaCodeResource($code));
|
||||
if (! $code) {
|
||||
return $this->failed('未查询到此提货码信息');
|
||||
} else {
|
||||
return $this->success(new AreaCodeResource($code));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 核销提货码
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2023/1/16 10:56
|
||||
* @param Request $request
|
||||
* @return JsonResponse|mixed
|
||||
*/
|
||||
public function verify(Request $request)
|
||||
{
|
||||
$code = $request->code ?? '';
|
||||
if (! $code) {
|
||||
return $this->failed('缺少提货码');
|
||||
}
|
||||
$areaCode = AreaCode::query()->where('code', $code)->first();
|
||||
if ($areaCode->status != AreaCode::STATUS_INIT) {
|
||||
return $this->failed('此提货码已提货');
|
||||
}
|
||||
try {
|
||||
$areaCode->sign();
|
||||
return $this->success('提货成功');
|
||||
} catch (\Exception $exception) {
|
||||
return $this->failed($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,30 +33,28 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 查看管理的提货码
|
||||
* Notes: 查看库存量
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2023/1/11 15:42
|
||||
* @param Area $area
|
||||
* @Date: 2023/1/16 11:19
|
||||
* @return JsonResponse|mixed
|
||||
*/
|
||||
public function codes(Request $request)
|
||||
public function show()
|
||||
{
|
||||
$status = $request->status ?? '';
|
||||
|
||||
$area = Area::query()
|
||||
->whereHas('areaClerks', function ($q) {
|
||||
$q->where('user_id', Api::userId());
|
||||
})
|
||||
->first();
|
||||
|
||||
$codes = $area->areaCodes()
|
||||
->when($status, function ($q) use ($status) {
|
||||
$q->where('status', $status);
|
||||
})
|
||||
->paginate();
|
||||
if (! $area) {
|
||||
return $this->failed('您没有管理的区域无法查看');
|
||||
}
|
||||
|
||||
$codes = $area->areaCodes()->latest()->paginate();
|
||||
$release = $area->areaCodes()->count();
|
||||
$data = [
|
||||
|
||||
$data = [
|
||||
'count' => [
|
||||
'all' => $area->stocks()->sum('amount'),
|
||||
'stock' => $area->stock,
|
||||
@@ -69,6 +67,36 @@ class IndexController extends Controller
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 查看管理的提货码
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2023/1/11 15:42
|
||||
* @param Request $request
|
||||
* @return JsonResponse|mixed
|
||||
*/
|
||||
public function codes(Request $request)
|
||||
{
|
||||
$status = $request->status ?? '';
|
||||
|
||||
$area = Area::query()
|
||||
->whereHas('areaClerks', function ($q) {
|
||||
$q->where('user_id', Api::userId());
|
||||
})
|
||||
->first();
|
||||
if (! $area) {
|
||||
return $this->failed('您没有管理的区域无法查看');
|
||||
}
|
||||
|
||||
$codes = $area->areaCodes()
|
||||
->when($status, function ($q) use ($status) {
|
||||
$q->where('status', $status);
|
||||
})
|
||||
->paginate();
|
||||
|
||||
return $this->success(new AreaCodeCollection($codes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 生成提货码
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user