Merge pull request 'dev' (#13) from dev into main
Reviewed-on: https://gitea.lihaink.cn/mkm/multi-store/pulls/13
This commit is contained in:
commit
e220e660f8
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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){
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user