Compare commits
No commits in common. "7e8a5d5420f2dfd4cb44da7886f95d52730d1775" and "e220e660f8b3d60306d19b2917c4298214cd42b7" have entirely different histories.
7e8a5d5420
...
e220e660f8
@ -1,95 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\admin\controller\product_image;
|
|
||||||
|
|
||||||
|
|
||||||
use app\admin\controller\BaseAdminController;
|
|
||||||
use app\admin\lists\product_image\ProductImageLists;
|
|
||||||
use app\admin\logic\product_image\ProductImageLogic;
|
|
||||||
use app\admin\validate\product_image\ProductImageValidate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品图库管理控制器
|
|
||||||
* Class ProductImageController
|
|
||||||
* @package app\admin\controller\product_image
|
|
||||||
*/
|
|
||||||
class ProductImageController extends BaseAdminController
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 获取商品图库管理列表
|
|
||||||
* @return \think\response\Json
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public function lists()
|
|
||||||
{
|
|
||||||
return $this->dataLists(new ProductImageLists());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 添加商品图库管理
|
|
||||||
* @return \think\response\Json
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public function add()
|
|
||||||
{
|
|
||||||
$params = (new ProductImageValidate())->post()->goCheck('add');
|
|
||||||
$result = ProductImageLogic::add($params);
|
|
||||||
if (true === $result) {
|
|
||||||
return $this->success('添加成功', [], 1, 1);
|
|
||||||
}
|
|
||||||
return $this->fail(ProductImageLogic::getError());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 编辑商品图库管理
|
|
||||||
* @return \think\response\Json
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public function edit()
|
|
||||||
{
|
|
||||||
$params = (new ProductImageValidate())->post()->goCheck('edit');
|
|
||||||
$result = ProductImageLogic::edit($params);
|
|
||||||
if (true === $result) {
|
|
||||||
return $this->success('编辑成功', [], 1, 1);
|
|
||||||
}
|
|
||||||
return $this->fail(ProductImageLogic::getError());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 删除商品图库管理
|
|
||||||
* @return \think\response\Json
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public function delete()
|
|
||||||
{
|
|
||||||
$params = (new ProductImageValidate())->post()->goCheck('delete');
|
|
||||||
ProductImageLogic::delete($params);
|
|
||||||
return $this->success('删除成功', [], 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 获取商品图库管理详情
|
|
||||||
* @return \think\response\Json
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public function detail()
|
|
||||||
{
|
|
||||||
$params = (new ProductImageValidate())->goCheck('detail');
|
|
||||||
$result = ProductImageLogic::detail($params);
|
|
||||||
return $this->data($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -19,11 +19,6 @@ use TencentCloud\Tiia\V20190529\Models\SearchImageRequest;
|
|||||||
use TencentCloud\Tiia\V20190529\TiiaClient;
|
use TencentCloud\Tiia\V20190529\TiiaClient;
|
||||||
use Webman\RedisQueue\Redis;
|
use Webman\RedisQueue\Redis;
|
||||||
|
|
||||||
use app\common\model\product_image\ProductImage;
|
|
||||||
|
|
||||||
use app\admin\logic\product_image\ProductImageLogic;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品列表控制器
|
* 商品列表控制器
|
||||||
* Class StoreProductController
|
* Class StoreProductController
|
||||||
@ -165,13 +160,7 @@ class StoreProductController extends BaseAdminController
|
|||||||
|
|
||||||
public function upload()
|
public function upload()
|
||||||
{
|
{
|
||||||
$params = $this->request->get();
|
$file = $this->request->file('file');
|
||||||
// $params = [
|
|
||||||
// 'ProductId' => '1024',
|
|
||||||
// 'GroupId' => 'default',
|
|
||||||
// ];
|
|
||||||
$storeName = StoreProduct::where('id', $params['ProductId'])->value('store_name');
|
|
||||||
$product_num = ProductImage::where('product_id', $params['ProductId'])->count('id');
|
|
||||||
$cred = new Credential(getenv('TENCENT_SECRET_ID'), getenv('TENCENT_SECRET_KEY'));
|
$cred = new Credential(getenv('TENCENT_SECRET_ID'), getenv('TENCENT_SECRET_KEY'));
|
||||||
$httpProfile = new HttpProfile();
|
$httpProfile = new HttpProfile();
|
||||||
$httpProfile->setEndpoint("tiia.tencentcloudapi.com");
|
$httpProfile->setEndpoint("tiia.tencentcloudapi.com");
|
||||||
@ -179,37 +168,21 @@ class StoreProductController extends BaseAdminController
|
|||||||
$clientProfile->setHttpProfile($httpProfile);
|
$clientProfile->setHttpProfile($httpProfile);
|
||||||
$client = new TiiaClient($cred, "ap-guangzhou", $clientProfile);
|
$client = new TiiaClient($cred, "ap-guangzhou", $clientProfile);
|
||||||
$req = new CreateImageRequest();
|
$req = new CreateImageRequest();
|
||||||
$file = $this->request->file('file');
|
$file = file_get_contents(public_path() . '/可口可乐.jpg');
|
||||||
$filePath = $file->getRealPath();
|
$params = [
|
||||||
$fileName = $file->getuploadName();
|
'GroupId' => 'default',
|
||||||
$file = file_get_contents($filePath);
|
'EntityId' => '可口可乐_330ml_听装',
|
||||||
// $fileName ="矿泉水7";
|
'PicName' => '可口可乐.jpg',
|
||||||
// $file = file_get_contents(public_path() . '/' . $fileName. '.jpg');
|
|
||||||
$ImageParams = [
|
|
||||||
'GroupId' => $params['GroupId'],
|
|
||||||
'EntityId' => $params['ProductId'].'_'.$storeName.'_'.intval($product_num+1),
|
|
||||||
'PicName' => $params['ProductId'].'_'.$fileName,
|
|
||||||
'ImageBase64' => base64_encode($file)
|
'ImageBase64' => base64_encode($file)
|
||||||
];
|
];
|
||||||
$req->fromJsonString(json_encode($ImageParams));
|
$req->fromJsonString(json_encode($params));
|
||||||
$resp = $client->CreateImage($req);
|
$resp = $client->CreateImage($req);
|
||||||
$CreateParams = [
|
|
||||||
'product_id' => $params['ProductId'],
|
|
||||||
'group_id' => $ImageParams['GroupId'],
|
|
||||||
'entity_id' => $ImageParams['EntityId'],
|
|
||||||
'pic_name' => $ImageParams['PicName'],
|
|
||||||
];
|
|
||||||
ProductImageLogic::add($CreateParams);
|
|
||||||
$result = json_decode($resp->toJsonString(), true);
|
$result = json_decode($resp->toJsonString(), true);
|
||||||
return $this->data($result);
|
return $this->data($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function recognition()
|
public function recognition()
|
||||||
{
|
{
|
||||||
$params = $this->request->get();
|
|
||||||
// $params = [
|
|
||||||
// 'GroupId' => 'default',
|
|
||||||
// ];
|
|
||||||
$cred = new Credential(getenv('TENCENT_SECRET_ID'), getenv('TENCENT_SECRET_KEY'));
|
$cred = new Credential(getenv('TENCENT_SECRET_ID'), getenv('TENCENT_SECRET_KEY'));
|
||||||
$httpProfile = new HttpProfile();
|
$httpProfile = new HttpProfile();
|
||||||
$httpProfile->setEndpoint("tiia.tencentcloudapi.com");
|
$httpProfile->setEndpoint("tiia.tencentcloudapi.com");
|
||||||
@ -217,24 +190,17 @@ class StoreProductController extends BaseAdminController
|
|||||||
$clientProfile->setHttpProfile($httpProfile);
|
$clientProfile->setHttpProfile($httpProfile);
|
||||||
$client = new TiiaClient($cred, "ap-guangzhou", $clientProfile);
|
$client = new TiiaClient($cred, "ap-guangzhou", $clientProfile);
|
||||||
$req = new SearchImageRequest();
|
$req = new SearchImageRequest();
|
||||||
$file = $this->request->file('file');
|
$file = file_get_contents(public_path() . '/可口可乐.jpg');
|
||||||
$filePath = $file->getRealPath();
|
// $file = file_get_contents(public_path() . '/可口可乐2.jpg');
|
||||||
$file = file_get_contents($filePath);
|
// $file = file_get_contents(public_path() . '/百事可乐.jpg');
|
||||||
// $fileName ="鱿鱼";
|
$params = [
|
||||||
// $file = file_get_contents(public_path() . '/' . $fileName. '.jpg');
|
'GroupId' => 'default',
|
||||||
$ImageParams = [
|
|
||||||
'GroupId' => $params['GroupId'],
|
|
||||||
'ImageBase64' => base64_encode($file)
|
'ImageBase64' => base64_encode($file)
|
||||||
];
|
];
|
||||||
$req->fromJsonString(json_encode($ImageParams));
|
$req->fromJsonString(json_encode($params));
|
||||||
$resp = $client->SearchImage($req);
|
$resp = $client->SearchImage($req);
|
||||||
if(!empty($resp->ImageInfos)){
|
|
||||||
$ids = array_column($resp->ImageInfos,'EntityId');
|
|
||||||
$data = ProductImage::whereIn('entity_id', $ids)->field('product_id,group_id,entity_id,pic_name')->group(['product_id', 'entity_id'])->select();
|
|
||||||
$resp->ImageInfos = $data->toArray();
|
|
||||||
$resp->Count = $data->count('product_id');
|
|
||||||
}
|
|
||||||
$result = json_decode($resp->toJsonString(), true);
|
$result = json_decode($resp->toJsonString(), true);
|
||||||
return $this->data($result);
|
return $this->data($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\admin\lists\product_image;
|
|
||||||
|
|
||||||
|
|
||||||
use app\admin\lists\BaseAdminDataLists;
|
|
||||||
use app\common\model\product_image\ProductImage;
|
|
||||||
use app\common\lists\ListsSearchInterface;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品图库管理列表
|
|
||||||
* Class ProductImageLists
|
|
||||||
* @package app\admin\listsproduct_image
|
|
||||||
*/
|
|
||||||
class ProductImageLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 设置搜索条件
|
|
||||||
* @return \string[][]
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public function setSearch(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'=' => ['product_id', 'entity_id', 'group_id', 'pic_name'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 获取商品图库管理列表
|
|
||||||
* @return array
|
|
||||||
* @throws \think\db\exception\DataNotFoundException
|
|
||||||
* @throws \think\db\exception\DbException
|
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public function lists(): array
|
|
||||||
{
|
|
||||||
return ProductImage::where($this->searchWhere)
|
|
||||||
->field(['id', 'product_id', 'entity_id', 'group_id', 'pic_name'])
|
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
|
||||||
->order(['id' => 'desc'])
|
|
||||||
->select()
|
|
||||||
->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 获取商品图库管理数量
|
|
||||||
* @return int
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public function count(): int
|
|
||||||
{
|
|
||||||
return ProductImage::where($this->searchWhere)->count();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,102 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\admin\logic\product_image;
|
|
||||||
|
|
||||||
|
|
||||||
use app\common\model\product_image\ProductImage;
|
|
||||||
use app\common\logic\BaseLogic;
|
|
||||||
use support\exception\BusinessException;
|
|
||||||
use think\facade\Db;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品图库管理逻辑
|
|
||||||
* Class ProductImageLogic
|
|
||||||
* @package app\admin\logic\product_image
|
|
||||||
*/
|
|
||||||
class ProductImageLogic extends BaseLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 添加商品图库管理
|
|
||||||
* @param array $params
|
|
||||||
* @return bool
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public static function add(array $params): bool
|
|
||||||
{
|
|
||||||
Db::startTrans();
|
|
||||||
try {
|
|
||||||
ProductImage::create([
|
|
||||||
'product_id' => $params['product_id'],
|
|
||||||
'entity_id' => $params['entity_id'],
|
|
||||||
'group_id' => $params['group_id'],
|
|
||||||
'pic_name' => $params['pic_name'],
|
|
||||||
'create_time' => time(),
|
|
||||||
'update_time' => time(),
|
|
||||||
|
|
||||||
]);
|
|
||||||
|
|
||||||
Db::commit();
|
|
||||||
return true;
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Db::rollback();
|
|
||||||
throw new BusinessException($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 编辑商品图库管理
|
|
||||||
* @param array $params
|
|
||||||
* @return bool
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public static function edit(array $params): bool
|
|
||||||
{
|
|
||||||
Db::startTrans();
|
|
||||||
try {
|
|
||||||
ProductImage::where('id', $params['id'])->update([
|
|
||||||
'product_id' => $params['product_id'],
|
|
||||||
'entity_id' => $params['entity_id'],
|
|
||||||
'group_id' => $params['group_id'],
|
|
||||||
'pic_name' => $params['pic_name'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
Db::commit();
|
|
||||||
return true;
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
Db::rollback();
|
|
||||||
throw new BusinessException($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 删除商品图库管理
|
|
||||||
* @param array $params
|
|
||||||
* @return bool
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public static function delete(array $params): bool
|
|
||||||
{
|
|
||||||
return ProductImage::destroy($params['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 获取商品图库管理详情
|
|
||||||
* @param $params
|
|
||||||
* @return array
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public static function detail($params): array
|
|
||||||
{
|
|
||||||
return ProductImage::findOrEmpty($params['id'])->toArray();
|
|
||||||
}
|
|
||||||
}
|
|
@ -224,7 +224,7 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
$res = WarehouseProduct::where('id', $params['id'])->withTrashed()->find();
|
$res = WarehouseProduct::where('id', $params['id'])->withTrashed()->find();
|
||||||
$updateNums = bcsub($params['nums'], $res['nums'],2);
|
$updateNums = bcsub($params['nums'], $res['nums'],2);
|
||||||
if ($updateNums != 0) {
|
if ($updateNums != 0) {
|
||||||
if ($res['status'] == 1 && $res['store_id'] > 0) {
|
if ($res['status'] == 1) {
|
||||||
throw new BusinessException('门店已确认入库,不能修改数量');
|
throw new BusinessException('门店已确认入库,不能修改数量');
|
||||||
}
|
}
|
||||||
$storageNum = $res['financial_pm'] == 0 ? -$updateNums : $updateNums;
|
$storageNum = $res['financial_pm'] == 0 ? -$updateNums : $updateNums;
|
||||||
|
@ -113,8 +113,13 @@ class WarehouseProductReturnLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
$find->save(['nums' => $nums, 'total_price' => $total_price]);
|
$find->save(['nums' => $nums, 'total_price' => $total_price]);
|
||||||
$total_price = WarehouseProduct::where('oid', $find['oid'])->sum('total_price');
|
$total_price = WarehouseProduct::where('oid', $find['oid'])->sum('total_price');
|
||||||
|
if ($nums > 0) {
|
||||||
WarehouseOrder::where(['id' => $find['oid']])->update(['total_price' => $total_price]);
|
WarehouseOrder::where(['id' => $find['oid']])->update(['total_price' => $total_price]);
|
||||||
BeforehandOrder::update(['pay_price' => $total_price, 'total_price' => $total_price], ['id' => $params['bhoid']]);
|
BeforehandOrder::update(['pay_price' => $total_price], ['id' => $params['bhoid']]);
|
||||||
|
} elseif ($nums == 0) {
|
||||||
|
WarehouseOrder::where(['id' => $find['oid']])->update(['total_price' => $total_price]);
|
||||||
|
BeforehandOrder::update(['pay_price' => $total_price], ['id' => $params['bhoid']]);
|
||||||
|
}
|
||||||
$res=WarehouseProductStorege::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id']])->find();
|
$res=WarehouseProductStorege::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id']])->find();
|
||||||
$res->save(['nums' =>bcadd( $res['nums'],$params['nums'],2)]);
|
$res->save(['nums' =>bcadd( $res['nums'],$params['nums'],2)]);
|
||||||
SqlChannelLog('WarehouseProductStorege', $res['id'], $params['nums'], 1, Request()->url(),$params['admin_id']);
|
SqlChannelLog('WarehouseProductStorege', $res['id'], $params['nums'], 1, Request()->url(),$params['admin_id']);
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\admin\validate\product_image;
|
|
||||||
|
|
||||||
|
|
||||||
use app\common\validate\BaseValidate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品图库管理验证器
|
|
||||||
* Class ProductImageValidate
|
|
||||||
* @package app\admin\validate\product_image
|
|
||||||
*/
|
|
||||||
class ProductImageValidate extends BaseValidate
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置校验规则
|
|
||||||
* @var string[]
|
|
||||||
*/
|
|
||||||
protected $rule = [
|
|
||||||
'id' => 'require',
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 参数描述
|
|
||||||
* @var string[]
|
|
||||||
*/
|
|
||||||
protected $field = [
|
|
||||||
'id' => 'id',
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 添加场景
|
|
||||||
* @return ProductImageValidate
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public function sceneAdd()
|
|
||||||
{
|
|
||||||
return $this->remove('id', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 编辑场景
|
|
||||||
* @return ProductImageValidate
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public function sceneEdit()
|
|
||||||
{
|
|
||||||
return $this->only(['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 删除场景
|
|
||||||
* @return ProductImageValidate
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public function sceneDelete()
|
|
||||||
{
|
|
||||||
return $this->only(['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 详情场景
|
|
||||||
* @return ProductImageValidate
|
|
||||||
* @author admin
|
|
||||||
* @date 2025/04/14 11:02
|
|
||||||
*/
|
|
||||||
public function sceneDetail()
|
|
||||||
{
|
|
||||||
return $this->only(['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\common\model\product_image;
|
|
||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
|
||||||
use think\model\concern\SoftDelete;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品图库管理模型
|
|
||||||
* Class ProductImage
|
|
||||||
* @package app\common\model\product_image
|
|
||||||
*/
|
|
||||||
class ProductImage extends BaseModel
|
|
||||||
{
|
|
||||||
use SoftDelete;
|
|
||||||
protected $name = 'product_image';
|
|
||||||
protected $deleteTime = 'delete_time';
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user