阶段更新
This commit is contained in:
@@ -16,7 +16,7 @@ class AreaCodeController extends Controller
|
|||||||
*
|
*
|
||||||
* @Author: 玄尘
|
* @Author: 玄尘
|
||||||
* @Date: 2023/1/12 11:03
|
* @Date: 2023/1/12 11:03
|
||||||
* @param AreaCode $areaCode
|
* @param AreaCode $code
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function show(AreaCode $code)
|
public function show(AreaCode $code)
|
||||||
@@ -24,10 +24,48 @@ class AreaCodeController extends Controller
|
|||||||
return $this->success(new AreaCodeResource($code));
|
return $this->success(new AreaCodeResource($code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 根据提货码查询信息
|
||||||
|
*
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date: 2023/1/16 9:48
|
||||||
|
* @param Request $request
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
public function info(Request $request)
|
public function info(Request $request)
|
||||||
{
|
{
|
||||||
$code = AreaCode::query()->where('code', $request->code)->first();
|
$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: 玄尘
|
* @Author: 玄尘
|
||||||
* @Date: 2023/1/11 15:42
|
* @Date: 2023/1/16 11:19
|
||||||
* @param Area $area
|
* @return JsonResponse|mixed
|
||||||
*/
|
*/
|
||||||
public function codes(Request $request)
|
public function show()
|
||||||
{
|
{
|
||||||
$status = $request->status ?? '';
|
|
||||||
|
|
||||||
$area = Area::query()
|
$area = Area::query()
|
||||||
->whereHas('areaClerks', function ($q) {
|
->whereHas('areaClerks', function ($q) {
|
||||||
$q->where('user_id', Api::userId());
|
$q->where('user_id', Api::userId());
|
||||||
})
|
})
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
$codes = $area->areaCodes()
|
if (! $area) {
|
||||||
->when($status, function ($q) use ($status) {
|
return $this->failed('您没有管理的区域无法查看');
|
||||||
$q->where('status', $status);
|
}
|
||||||
})
|
|
||||||
->paginate();
|
|
||||||
|
|
||||||
|
$codes = $area->areaCodes()->latest()->paginate();
|
||||||
$release = $area->areaCodes()->count();
|
$release = $area->areaCodes()->count();
|
||||||
$data = [
|
|
||||||
|
$data = [
|
||||||
'count' => [
|
'count' => [
|
||||||
'all' => $area->stocks()->sum('amount'),
|
'all' => $area->stocks()->sum('amount'),
|
||||||
'stock' => $area->stock,
|
'stock' => $area->stock,
|
||||||
@@ -69,6 +67,36 @@ class IndexController extends Controller
|
|||||||
return $this->success($data);
|
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: 生成提货码
|
* Notes: 生成提货码
|
||||||
*
|
*
|
||||||
|
|||||||
28
app/Api/Resources/Area/AreaCodeVerifyResource.php
Normal file
28
app/Api/Resources/Area/AreaCodeVerifyResource.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Api\Resources\Area;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||||
|
use DNS1D;
|
||||||
|
|
||||||
|
|
||||||
|
class AreaCodeVerifyResource extends JsonResource
|
||||||
|
{
|
||||||
|
|
||||||
|
public function toArray($request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'area_code_id' => $this->id,
|
||||||
|
'code' => $this->code,
|
||||||
|
// 'code_img' => 'data:image/jpg;base64,'.base64_encode(QrCode::format('png')
|
||||||
|
// ->errorCorrection("L")
|
||||||
|
// ->size(300)
|
||||||
|
// ->margin(0)
|
||||||
|
// ->generate($this->code)),
|
||||||
|
'barcode' => 'data:image/png;base64,'.DNS1D::getBarcodePNG($this->code, 'C128', 2, 50),
|
||||||
|
'area' => new AreaFullResource($this->area),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ Route::group([
|
|||||||
'middleware' => config('api.route.middleware_auth'),
|
'middleware' => config('api.route.middleware_auth'),
|
||||||
], function (Router $router) {
|
], function (Router $router) {
|
||||||
$router->get('areas', 'IndexController@index');
|
$router->get('areas', 'IndexController@index');
|
||||||
|
$router->get('areas/show', 'IndexController@show');
|
||||||
$router->get('areas/codes', 'IndexController@codes');
|
$router->get('areas/codes', 'IndexController@codes');
|
||||||
$router->get('areas/generate', 'IndexController@generate');
|
$router->get('areas/generate', 'IndexController@generate');
|
||||||
});
|
});
|
||||||
@@ -19,5 +20,6 @@ Route::group([
|
|||||||
], function (Router $router) {
|
], function (Router $router) {
|
||||||
$router->get('areas/{code}/show', 'AreaCodeController@show');
|
$router->get('areas/{code}/show', 'AreaCodeController@show');
|
||||||
$router->get('areas/code/info', 'AreaCodeController@info');
|
$router->get('areas/code/info', 'AreaCodeController@info');
|
||||||
|
$router->post('areas/code/{code}/verify', 'AreaCodeController@verify');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -15,10 +15,12 @@ class AreaCode extends Model
|
|||||||
|
|
||||||
const STATUS_INIT = 0;
|
const STATUS_INIT = 0;
|
||||||
const STATUS_USED = 1;
|
const STATUS_USED = 1;
|
||||||
|
const STATUS_SIGN = 2;
|
||||||
|
|
||||||
const STATUS = [
|
const STATUS = [
|
||||||
self::STATUS_INIT => '未提取',
|
self::STATUS_INIT => '未提取',
|
||||||
self::STATUS_USED => '已提取',
|
self::STATUS_USED => '已提取',
|
||||||
|
self::STATUS_SIGN => '已核销',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@@ -46,6 +48,21 @@ class AreaCode extends Model
|
|||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 核销
|
||||||
|
*
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date: 2023/1/16 11:15
|
||||||
|
*/
|
||||||
|
public function sign()
|
||||||
|
{
|
||||||
|
$this->order->state = Order::STATUS_SIGNED;
|
||||||
|
$this->order->save();
|
||||||
|
$this->status = self::STATUS_SIGN;
|
||||||
|
$this->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notes: 关联订单
|
* Notes: 关联订单
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
"laravel/framework": "^8.5",
|
"laravel/framework": "^8.5",
|
||||||
"liuhelong/laravel-admin-wechat": "^1.3",
|
"liuhelong/laravel-admin-wechat": "^1.3",
|
||||||
"maatwebsite/excel": "^3.1",
|
"maatwebsite/excel": "^3.1",
|
||||||
|
"milon/barcode": "^9.0",
|
||||||
"nosun/ueditor": "^3.0",
|
"nosun/ueditor": "^3.0",
|
||||||
"nwidart/laravel-modules": "^8.2",
|
"nwidart/laravel-modules": "^8.2",
|
||||||
"overtrue/chinese-calendar": "^1.0",
|
"overtrue/chinese-calendar": "^1.0",
|
||||||
|
|||||||
84
composer.lock
generated
84
composer.lock
generated
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "8ced0e5b40c53cb2324d6151114eb695",
|
"content-hash": "3cbbcb1f21ee24518ad634ab39c67d77",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "adbario/php-dot-notation",
|
"name": "adbario/php-dot-notation",
|
||||||
@@ -4104,6 +4104,86 @@
|
|||||||
},
|
},
|
||||||
"time": "2021-07-01T19:01:15+00:00"
|
"time": "2021-07-01T19:01:15+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "milon/barcode",
|
||||||
|
"version": "9.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/milon/barcode.git",
|
||||||
|
"reference": "6859fe19808380a0b40916d0009d7b4b5e04cc25"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/milon/barcode/zipball/6859fe19808380a0b40916d0009d7b4b5e04cc25",
|
||||||
|
"reference": "6859fe19808380a0b40916d0009d7b4b5e04cc25",
|
||||||
|
"shasum": "",
|
||||||
|
"mirrors": [
|
||||||
|
{
|
||||||
|
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||||
|
"preferred": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/support": "^7.0|^8.0|^9.0",
|
||||||
|
"php": "^7.3 | ^8.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Milon\\Barcode\\BarcodeServiceProvider"
|
||||||
|
],
|
||||||
|
"aliases": {
|
||||||
|
"DNS1D": "Milon\\Barcode\\Facades\\DNS1DFacade",
|
||||||
|
"DNS2D": "Milon\\Barcode\\Facades\\DNS2DFacade"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-0": {
|
||||||
|
"Milon\\Barcode": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"LGPL-3.0"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nuruzzaman Milon",
|
||||||
|
"email": "contact@milon.im"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)",
|
||||||
|
"keywords": [
|
||||||
|
"CODABAR",
|
||||||
|
"CODE 128",
|
||||||
|
"CODE 39",
|
||||||
|
"barcode",
|
||||||
|
"datamatrix",
|
||||||
|
"ean",
|
||||||
|
"laravel",
|
||||||
|
"pdf417",
|
||||||
|
"qr code",
|
||||||
|
"qrcode"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/milon/barcode/issues",
|
||||||
|
"source": "https://github.com/milon/barcode/tree/9.0.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://paypal.me/tomilon",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/milon",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2022-02-15T15:18:46+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "monolog/monolog",
|
"name": "monolog/monolog",
|
||||||
"version": "2.7.0",
|
"version": "2.7.0",
|
||||||
@@ -13150,5 +13230,5 @@
|
|||||||
"php": "^7.4|^8.0"
|
"php": "^7.4|^8.0"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
"plugin-api-version": "2.1.0"
|
"plugin-api-version": "2.3.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use Illuminate\Http\Request;
|
|||||||
use Jason\Api\Api;
|
use Jason\Api\Api;
|
||||||
use Modules\Mall\Facades\Refund;
|
use Modules\Mall\Facades\Refund;
|
||||||
use Modules\Mall\Http\Resources\Api\Order\LogisticResource;
|
use Modules\Mall\Http\Resources\Api\Order\LogisticResource;
|
||||||
|
use Modules\Mall\Http\Resources\Api\Order\OrderAreaCodeResource;
|
||||||
use Modules\Mall\Http\Resources\Api\Order\OrderCollection;
|
use Modules\Mall\Http\Resources\Api\Order\OrderCollection;
|
||||||
use Modules\Mall\Http\Resources\Api\Order\OrderItemResource;
|
use Modules\Mall\Http\Resources\Api\Order\OrderItemResource;
|
||||||
use Modules\Mall\Http\Resources\Api\Order\OrderLogisticResource;
|
use Modules\Mall\Http\Resources\Api\Order\OrderLogisticResource;
|
||||||
@@ -284,4 +285,16 @@ class OrderController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 查看提货码
|
||||||
|
*
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date: 2023/1/16 10:06
|
||||||
|
* @param Order $order
|
||||||
|
*/
|
||||||
|
public function areaCode(Order $order)
|
||||||
|
{
|
||||||
|
return $this->success(new OrderAreaCodeResource($order));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ Route::group([
|
|||||||
$router->put('orders/{order}/sign', 'OrderController@sign')->where(['order' => '[0-9]+']);
|
$router->put('orders/{order}/sign', 'OrderController@sign')->where(['order' => '[0-9]+']);
|
||||||
// 取消订单
|
// 取消订单
|
||||||
$router->put('orders/{order}/cancel', 'OrderController@cancel')->where(['order' => '[0-9]+']);
|
$router->put('orders/{order}/cancel', 'OrderController@cancel')->where(['order' => '[0-9]+']);
|
||||||
|
$router->get('orders/{order}/area_code', 'OrderController@areaCode')->where(['order' => '[0-9]+']);
|
||||||
// 删除订单
|
// 删除订单
|
||||||
$router->delete('orders/{order}', 'OrderController@destroy')->where(['order' => '[0-9]+']);
|
$router->delete('orders/{order}', 'OrderController@destroy')->where(['order' => '[0-9]+']);
|
||||||
//退款
|
//退款
|
||||||
|
|||||||
@@ -463,12 +463,12 @@ class WeChatController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($delivery_code) {
|
if ($delivery_code) {
|
||||||
if (! $user->info->delivery_code) {
|
$areaCode = AreaCode::query()->where('code', $delivery_code)->first();
|
||||||
$areaCode = AreaCode::query()->where('code', $delivery_code)->first();
|
if ($areaCode->user_id) {
|
||||||
if ($areaCode->user_id) {
|
return $this->failed('当前提货码已被别人使用');
|
||||||
return $this->failed('当前提货码已被别人使用');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
if (! $user->info->delivery_code) {
|
||||||
$user->info->update([
|
$user->info->update([
|
||||||
'delivery_code' => $delivery_code
|
'delivery_code' => $delivery_code
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -11,11 +11,7 @@ class UserAccountResource extends JsonResource
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'balance' => floatval($this->balance),//现金
|
'balance' => floatval($this->balance),//现金
|
||||||
'score' => [
|
'score' => floatval($this->score),
|
||||||
'surplus' => floatval($this->score),//水滴余量
|
|
||||||
'use' => 0,//水滴使用
|
|
||||||
'plan' => 300,//水滴赠送
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,18 +29,21 @@ class UserInfoResource extends JsonResource
|
|||||||
'avatar' => $this->info->avatar ?? '',
|
'avatar' => $this->info->avatar ?? '',
|
||||||
'account' => new UserAccountResource($this->account),
|
'account' => new UserAccountResource($this->account),
|
||||||
'identity' => new UserIdentityBaseResource($identity),
|
'identity' => new UserIdentityBaseResource($identity),
|
||||||
'service' => new UserServiceResource($identity->identities()->first()),
|
// 'service' => new UserServiceResource($identity->identities()->first()),
|
||||||
'water_mobile' => app('Conf_mall')['water_mobile'] ?? '',
|
// 'water_mobile' => app('Conf_mall')['water_mobile'] ?? '',
|
||||||
'invite' => Hashids::connection('code')->encode($this->id),
|
'invite' => Hashids::connection('code')->encode($this->id),
|
||||||
'case' => $this->getStockData(),
|
'area_code' => $this->info->area_code,
|
||||||
|
// 'case' => $this->getStockData(),
|
||||||
'created_at' => (string) $this->created_at,
|
'created_at' => (string) $this->created_at,
|
||||||
'status' => $this->getStateData(),
|
'status' => $this->getStateData(),
|
||||||
'nowStatus' => $this->getNowStatus(),
|
// 'nowStatus' => $this->getNowStatus(),
|
||||||
'canPick' => $this->canPick(),
|
// 'canPick' => $this->canPick(),
|
||||||
'count' => [
|
'count' => [
|
||||||
'relation' => $this->getRelationCount(),//下级
|
'relation' => $this->getRelationCount(),//下级
|
||||||
'orders' => $this->getOrderCount(),
|
'orders' => $this->getOrderCount(),
|
||||||
'refunds' => RefundModel::byUser(Api::user())->count(),//退款单数量
|
],
|
||||||
|
'can' => [
|
||||||
|
'area' => $this->areas()->exists(),
|
||||||
],
|
],
|
||||||
'identityShow' => $this->when(true, function () use ($identity) {
|
'identityShow' => $this->when(true, function () use ($identity) {
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Modules\User\Models;
|
namespace Modules\User\Models;
|
||||||
|
|
||||||
|
use App\Models\Area;
|
||||||
|
use App\Models\AreaClerk;
|
||||||
use App\Models\AreaCode;
|
use App\Models\AreaCode;
|
||||||
use App\Traits\Macroable;
|
use App\Traits\Macroable;
|
||||||
use App\Traits\OrderByIdDesc;
|
use App\Traits\OrderByIdDesc;
|
||||||
@@ -308,5 +310,13 @@ class User extends Authenticate
|
|||||||
return sprintf("%s (%s)", $this->username, $this->info->nickname);
|
return sprintf("%s (%s)", $this->username, $this->info->nickname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function areas()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(
|
||||||
|
Area::class,
|
||||||
|
(new AreaClerk())->getTable())->using(AreaClerk::class
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user