From d5f521c8db203a6c7d1fc4e7d23f7abe70d8e4e6 Mon Sep 17 00:00:00 2001 From: lqmac Date: Mon, 24 Jun 2024 18:09:21 +0800 Subject: [PATCH] 1 --- app/api/controller/Goods.php | 8 +++++++- app/command/CalDealerTime.php | 6 ++++-- app/store/model/Goods.php | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 30955fab..dd3873cf 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -91,8 +91,13 @@ class Goods extends Controller foreach ($params['list'] as $value) { $res = "无货"; $goods = GoodsModel::where('goods_id', $value['goods_id'])->find(); + if (!$goods) { + return $this->renderError('商品不存在'); + } //限制销售区域 $city = Region::withoutGlobalScope()->where('name', $params['city'])->where('level', 2)->find(); + // var_dump($goods); + // exit(); if ($goods['region'] && !in_array($city->id, json_decode($goods['region']))) { $data = [ 'state' => "无货", @@ -124,8 +129,9 @@ class Goods extends Controller $arr = []; $ret = $jd->getGoodsStock($province->jd_code, $city->jd_code, $district->jd_code, $goods['goods_no'], $value['num'] ?? 1); + //var_dump($ret); if ($ret) { - $res = $ret['stockResp']['desc']; + $res = $ret['stockResp']['desc'] ?? "无货"; if (strpos($res, "无货") !== false) { $res = "无货"; } elseif (strpos($res, "有货") == false) { diff --git a/app/command/CalDealerTime.php b/app/command/CalDealerTime.php index e881d00d..6493aa25 100644 --- a/app/command/CalDealerTime.php +++ b/app/command/CalDealerTime.php @@ -53,9 +53,11 @@ class CalDealerTime extends Command private function dealerUser($nowDay) { $dealerUser = (new User)->where(['user_type' => UserTypeEnum::DEALER]) - ->whereDay('fx_effective_time', $nowDay) - ->field('user_id,user_type,fx_effective_time,effective_time') + ->where('fx_effective_time', "<", $nowDay) + ->field('user_id,user_type,fx_effective_time,effective_time,store_id') ->select(); + // var_dump($dealerUser); + // exit(); $plusUserIds = []; $normalUserIds = []; if (!$dealerUser->isEmpty()) { diff --git a/app/store/model/Goods.php b/app/store/model/Goods.php index f1d44732..4ab70f10 100644 --- a/app/store/model/Goods.php +++ b/app/store/model/Goods.php @@ -310,6 +310,8 @@ class Goods extends GoodsModel private function createData(array $data): array { $data['goods_sku_no'] = $data['goods_no'] ?? ""; + $data['link'] = $data['goods_no'] ? "https://item.jd.com/".$data['goods_no'].".html" : ""; + // 默认数据 $data = array_merge($data, [ 'line_price' => $data['line_price'] ?? 0,