From e6e0eaadabfe28758698d284644127db4e41b008 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Mon, 14 Apr 2025 09:40:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B0=83=E8=AF=95=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=92=8C=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store_product/StoreProductController.php | 52 +++++++++++++++++++ .../store_product_price/StoreProductPrice.php | 5 ++ 2 files changed, 57 insertions(+) diff --git a/app/admin/controller/store_product/StoreProductController.php b/app/admin/controller/store_product/StoreProductController.php index 4e6121f98..e04d8c518 100644 --- a/app/admin/controller/store_product/StoreProductController.php +++ b/app/admin/controller/store_product/StoreProductController.php @@ -11,6 +11,12 @@ use app\admin\validate\store_product\StoreProductValidate; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_product\StoreProduct; use app\common\model\warehouse_product_storege\WarehouseProductStorege; +use TencentCloud\Common\Credential; +use TencentCloud\Common\Profile\ClientProfile; +use TencentCloud\Common\Profile\HttpProfile; +use TencentCloud\Tiia\V20190529\Models\CreateImageRequest; +use TencentCloud\Tiia\V20190529\Models\SearchImageRequest; +use TencentCloud\Tiia\V20190529\TiiaClient; use Webman\RedisQueue\Redis; /** @@ -21,6 +27,7 @@ use Webman\RedisQueue\Redis; class StoreProductController extends BaseAdminController { + public $notNeedLogin = ['upload', 'recognition']; /** * @notes 获取商品列表列表 @@ -151,4 +158,49 @@ class StoreProductController extends BaseAdminController return $this->success('删除成功', [], 1, 1); } + public function upload() + { + $file = $this->request->file('file'); + $cred = new Credential(getenv('TENCENT_SECRET_ID'), getenv('TENCENT_SECRET_KEY')); + $httpProfile = new HttpProfile(); + $httpProfile->setEndpoint("tiia.tencentcloudapi.com"); + $clientProfile = new ClientProfile(); + $clientProfile->setHttpProfile($httpProfile); + $client = new TiiaClient($cred, "ap-guangzhou", $clientProfile); + $req = new CreateImageRequest(); + $file = file_get_contents(public_path() . '/可口可乐.jpg'); + $params = [ + 'GroupId' => 'default', + 'EntityId' => '可口可乐_330ml_听装', + 'PicName' => '可口可乐.jpg', + 'ImageBase64' => base64_encode($file) + ]; + $req->fromJsonString(json_encode($params)); + $resp = $client->CreateImage($req); + $result = json_decode($resp->toJsonString(), true); + return $this->data($result); + } + + public function recognition() + { + $cred = new Credential(getenv('TENCENT_SECRET_ID'), getenv('TENCENT_SECRET_KEY')); + $httpProfile = new HttpProfile(); + $httpProfile->setEndpoint("tiia.tencentcloudapi.com"); + $clientProfile = new ClientProfile(); + $clientProfile->setHttpProfile($httpProfile); + $client = new TiiaClient($cred, "ap-guangzhou", $clientProfile); + $req = new SearchImageRequest(); + $file = file_get_contents(public_path() . '/可口可乐.jpg'); +// $file = file_get_contents(public_path() . '/可口可乐2.jpg'); +// $file = file_get_contents(public_path() . '/百事可乐.jpg'); + $params = [ + 'GroupId' => 'default', + 'ImageBase64' => base64_encode($file) + ]; + $req->fromJsonString(json_encode($params)); + $resp = $client->SearchImage($req); + $result = json_decode($resp->toJsonString(), true); + return $this->data($result); + } + } diff --git a/app/common/model/store_product_price/StoreProductPrice.php b/app/common/model/store_product_price/StoreProductPrice.php index d65cf062a..641501f02 100644 --- a/app/common/model/store_product_price/StoreProductPrice.php +++ b/app/common/model/store_product_price/StoreProductPrice.php @@ -24,4 +24,9 @@ class StoreProductPrice extends BaseModel // 不生成该表的日志 public $doNotRecordLog = true; + public function product() + { + return $this->hasOne(StoreProduct::class, 'id', 'product_id')->field('id,store_name,top_cate_id,two_cate_id,cate_id'); + } + } \ No newline at end of file From daf4b858ce08164f11c7defbe82d3b64afe6fbee Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Mon, 14 Apr 2025 14:44:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E5=BD=95=E5=85=A5=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/purchase_product_offer/PurchaseProductOfferLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 56cceb4b5..3cf561f24 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -218,7 +218,7 @@ class PurchaseProductOfferLogic extends BaseLogic $lastPrice = PurchaseProductOffer::where(['product_id' => $offer['product_id']])->where('status', 1)->order('id desc')->value('price'); $currentPrice = bcdiv($params['total_price'], $params['buyer_nums'], 2); if ($lastPrice > 0 && ($currentPrice > $lastPrice * 3 || $currentPrice < $lastPrice / 3)) { - throw new BusinessException('价格异常,请重新输入'); +// throw new BusinessException('价格异常,请重新输入'); } // $uid=Admin::where('id',$params['admin_id'])->value('uid'); // if($params['admin_id']!=1){