完善
This commit is contained in:
parent
609f5ceb65
commit
3da00000d6
@ -164,9 +164,9 @@ public function updateGoods(): void
|
||||
$goods[$product['itemId']] = $product;
|
||||
$itemIds[] = $product['itemId'];
|
||||
}
|
||||
|
||||
DB::transaction(function () use ($goods, $itemIds, $noticeIdMapItemId) {
|
||||
$items = Good::query()->whereIn('itemid', $itemIds)->with('item')->get();
|
||||
DB::transaction(function () use ($goods, $itemIds, $noticeIdMapItemId, $items) {
|
||||
|
||||
$notices = [];
|
||||
foreach ($items as $item) {
|
||||
$item->fill($goods[$item->itemid]);
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\helpers\apiRequest;
|
||||
|
||||
/**
|
||||
* @property int $notice_id
|
||||
* @property int $notice_type
|
||||
@ -12,4 +14,13 @@
|
||||
*/
|
||||
class Notice extends Base
|
||||
{
|
||||
public static function deleteNotice(int|array $notice_d): bool
|
||||
{
|
||||
if (!is_array($notice_d)) {
|
||||
$notice_d = [$notice_d];
|
||||
}
|
||||
$ids = implode(',', $notice_d);
|
||||
$res = apiRequest::api('/Notic/doNotics', ['notice_ids' => $ids]);
|
||||
return $res['errCode'] == '0000';
|
||||
}
|
||||
}
|
||||
|
@ -89,16 +89,24 @@ public static function requests(Client $client, string $url, mixed $param = [],
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function GetToken(): string
|
||||
public static function getToken(): string
|
||||
{
|
||||
$token = Cache::get('token');
|
||||
if ($token) {
|
||||
return $token;
|
||||
}
|
||||
$appId = env('APP_ID');
|
||||
if (!$appId) {
|
||||
throw new Exception('app_id不能为空');
|
||||
}
|
||||
$appKey = env('APP_KEYX');
|
||||
if (!$appKey) {
|
||||
throw new Exception('app_keyx不能为空');
|
||||
}
|
||||
|
||||
$url = rtrim(env('API_DOMAIN'), '/') . '/Index/getToken';
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$appId = env('APP_ID');
|
||||
$appKey = env('APP_KEYX');
|
||||
|
||||
$sign = sprintf("app_id=%s:app_key=%s:tamptimes=%s", $appId, $appKey, $now);
|
||||
$sign = strtoupper(md5($sign));
|
||||
$form = [
|
||||
@ -127,11 +135,16 @@ public static function api($path, mixed $param = [], int $timeout = 5, array $ex
|
||||
|
||||
/**
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function apis($path, Client $client, mixed $param = [], int $timeout = 5, array $extern = []): mixed
|
||||
{
|
||||
$url = rtrim(env('API_DOMAIN'), '/') . $path;
|
||||
$token = self::GetToken();
|
||||
$domain = env('API_DOMAIN');
|
||||
if (!$domain) {
|
||||
throw new Exception('接口域名不能为空');
|
||||
}
|
||||
$url = rtrim($domain, '/') . $path;
|
||||
$token = self::getToken();
|
||||
$param['token'] = $token;
|
||||
return self::requests($client, $url, $param, FormType::json, true, $timeout, $extern);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user