Compare commits

..

78 Commits

Author SHA1 Message Date
mkm
fb3b626970 Merge pull request '添加导入商品采购价' (#29) from dev into main
Reviewed-on: #29
2025-04-23 15:22:57 +08:00
959978f746 添加导入商品采购价 2025-04-23 15:22:27 +08:00
mkm
fbba725ce7 Merge pull request '同步商品价格比例' (#28) from dev into main
Reviewed-on: #28
2025-04-18 18:00:39 +08:00
11687aa3d4 同步商品价格比例 2025-04-18 18:00:11 +08:00
mkm
a08d11f69c Merge pull request '同步商品价格比例' (#27) from dev into main
Reviewed-on: #27
2025-04-18 17:50:28 +08:00
49d534a48d 同步商品价格比例 2025-04-18 17:49:43 +08:00
mkm
0a046509dd Merge pull request '添加商品价格更新时间' (#26) from dev into main
Reviewed-on: #26
2025-04-18 17:30:15 +08:00
970a7f07c5 添加商品价格更新时间 2025-04-18 17:22:06 +08:00
mkm
848dbf2c80 Merge pull request 'dev' (#25) from dev into main
Reviewed-on: #25
2025-04-18 16:33:03 +08:00
463da3cef1 Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into dev 2025-04-18 16:32:27 +08:00
5e35acdc39 修改商品零售价格的错误 2025-04-18 16:31:14 +08:00
mkm
58b70c53f8 Merge pull request 'refactor(xlsx): 调整订单供货出库表格的列标题和数据填充逻辑' (#24) from dev into main
Reviewed-on: #24
2025-04-18 15:20:36 +08:00
mkm
b9e34a94d9 refactor(xlsx): 调整订单供货出库表格的列标题和数据填充逻辑
- 将"出库单价"、"出库总价"、"供货价"、"供货总价"等列
2025-04-18 15:19:00 +08:00
mkm
6d67d00c63 Merge pull request 'feat(admin): 仓库产品列表增加分类搜索功能' (#23) from dev into main
Reviewed-on: #23
2025-04-18 13:48:42 +08:00
mkm
3976af97f1 feat(admin): 仓库产品列表增加分类搜索功能
- 添加了根据分类 ID 进行搜索的功能
- 如果请求中包含 'class_all' 参数,则在查询中加入相应的条件
- 通过 StoreProduct 模型获取符合条件的产品 ID 列表
- 如果没有符合条件的产品,则返回空数组
2025-04-18 13:47:42 +08:00
mkm
a89f7fbe28 Merge pull request '调整了查询条件,增加了对class_all参数的处理。' (#22) from dev into main
Reviewed-on: #22
2025-04-18 12:07:45 +08:00
bb039fcf5e 调整了查询条件,增加了对class_all参数的处理。 2025-04-18 12:06:16 +08:00
mkm
b461c79b53 Merge pull request '修改商品列表搜索' (#21) from dev into main
Reviewed-on: #21
2025-04-17 09:57:21 +08:00
197a31668e 修改商品列表搜索 2025-04-17 09:57:07 +08:00
mkm
b3dee9c166 Merge pull request '修改商品列表搜索' (#20) from dev into main
Reviewed-on: #20
2025-04-17 09:44:42 +08:00
6dcd228e3c 修改商品列表搜索 2025-04-17 09:44:17 +08:00
mkm
fb4d528070 Merge pull request '更新 app/admin/logic/store_product/StoreProductLogic.php' (#19) from mkm-patch-2 into main
Reviewed-on: #19
2025-04-16 18:20:31 +08:00
mkm
90927b1c8e 更新 app/admin/logic/store_product/StoreProductLogic.php 2025-04-16 18:20:21 +08:00
mkm
363c7d604a Merge pull request 'dev' (#18) from dev into main
Reviewed-on: #18
2025-04-16 17:18:47 +08:00
eb24c561ad 修改商品列表搜索 2025-04-16 17:17:55 +08:00
4fc5b2d8dd 修改商品列表搜索 2025-04-16 17:14:58 +08:00
mkm
42750fcab9 Merge pull request '修改商品列表搜索' (#17) from dev into main
Reviewed-on: #17
2025-04-16 17:00:51 +08:00
022a25c6a6 修改商品列表搜索 2025-04-16 17:00:29 +08:00
mkm
4f7c8ffa85 Merge pull request '修改商品列表搜索' (#16) from dev into main
Reviewed-on: #16
2025-04-16 16:44:58 +08:00
881164ebbd 修改商品列表搜索 2025-04-16 16:43:41 +08:00
mkm
0d6c8f8057 Merge pull request '调试导入赠品' (#15) from dev into main
Reviewed-on: #15
2025-04-16 10:29:23 +08:00
fae49b796f 调试导入赠品 2025-04-16 10:24:40 +08:00
mkm
7e8a5d5420 Merge pull request 'dev' (#14) from dev into main
Reviewed-on: #14
2025-04-14 17:31:58 +08:00
3d47bb1b5d 修改预订单商品退库 2025-04-14 17:30:52 +08:00
c19efa176a 商品图片管理1 2025-04-14 16:02:44 +08:00
c19ef6080a 商品图片管理 2025-04-14 15:33:52 +08:00
mkm
e220e660f8 Merge pull request 'dev' (#13) from dev into main
Reviewed-on: #13
2025-04-14 14:45:22 +08:00
daf4b858ce 修改采购价格录入限制 2025-04-14 14:44:25 +08:00
e6e0eaadab 调试图片上传和识别 2025-04-14 09:40:54 +08:00
mkm
a4eb84500a Merge pull request 'fix(product): 修复商品价格保存逻辑' (#12) from dev into main
Reviewed-on: #12
2025-04-12 15:57:00 +08:00
mkm
f9d969c85c fix(product): 修复商品价格保存逻辑
- 在 StoreProductPriceLogic 类中,将价格保存逻辑中的 'price' 字段错误地设置为 'vip_price' 的值
- 已将相关代码修正,确保 'price' 字段正确保存为 'price' 的值
2025-04-12 15:56:30 +08:00
mkm
0ae06f9bfb Merge pull request '商品列表添加改价' (#11) from dev into main
Reviewed-on: #11
2025-04-12 11:43:30 +08:00
41264fd9a0 商品列表添加改价 2025-04-12 11:24:54 +08:00
mkm
40ede21710 Merge pull request '修改往期补单入库' (#10) from dev into main
Reviewed-on: #10
2025-04-11 10:24:37 +08:00
ed4d7bb3ae 修改往期补单入库 2025-04-11 10:02:50 +08:00
mkm
f7379b663a Merge pull request 'dev' (#9) from dev into main
Reviewed-on: #9
2025-04-10 14:36:21 +08:00
d13c5c16b0 修改小程序端订单详情 2025-04-10 14:24:27 +08:00
776ee0bfbc Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into HEAD 2025-04-09 12:28:14 +08:00
1182ee6279 调拨单详情备注 2025-04-09 12:21:35 +08:00
mkm
dcaca31635 add tencent sdk 2025-04-08 15:33:59 +08:00
8d085e688e 调拨订单导出和插入修改1 2025-04-08 14:44:26 +08:00
5e378a3372 调拨订单导出和插入修改1 2025-04-08 14:40:56 +08:00
83fe8c4539 调拨订单导出和插入修改 2025-04-08 12:40:18 +08:00
95514a0da6 调拨订单导出和插入修改 2025-04-08 12:32:33 +08:00
d05a8c842d 调拨订单导出和插入修改 2025-04-08 12:23:52 +08:00
dd681470d8 调拨订单导出和插入arr 2025-04-08 11:39:42 +08:00
be9781f170 调拨订单导出和插入 2025-04-08 11:23:09 +08:00
6e291277d0 调拨订单导出和插入 2025-04-08 11:18:54 +08:00
c26790ebbe excel导入铺货。修改接口 2025-04-07 14:01:01 +08:00
08fa715e73 excel导入铺货。修改接口 2025-04-07 13:37:23 +08:00
4875159679 excel导入铺货。修改接口 2025-04-07 12:10:28 +08:00
e3dc0985bd excel导入铺货 2025-04-07 10:46:37 +08:00
3a1f256fe9 Merge pull request '修改商品出库的错误' (#8) from dev into main
Reviewed-on: #8
2025-04-06 10:57:12 +08:00
d1a4e5acdf 修改商品出库的错误 2025-04-06 10:56:09 +08:00
d71b3ddefa Merge pull request '修改采购价格录入的错误' (#7) from dev into main
Reviewed-on: #7
2025-04-06 10:35:44 +08:00
850773a2fd 修改采购价格录入的错误 2025-04-06 10:33:06 +08:00
5b37749696 Merge pull request '修改预订单高级会员导出' (#6) from dev into main
Reviewed-on: #6
2025-04-03 16:52:01 +08:00
8aa2740b50 修改预订单高级会员导出 2025-04-03 16:51:06 +08:00
8deb9a32bb Merge pull request '修改预订单高级会员导出' (#5) from dev into main
Reviewed-on: #5
2025-04-03 14:59:05 +08:00
2439429e4c 修改预订单高级会员导出 2025-04-03 14:58:12 +08:00
mkm
d3c4bf923f Merge pull request '修改预订单高级会员导出' (#4) from dev into main
Reviewed-on: #4
2025-04-03 11:40:30 +08:00
b55503650c 修改预订单高级会员导出 2025-04-03 11:40:07 +08:00
mkm
ef846fe23d Merge pull request 'dev' (#3) from dev into main
Reviewed-on: #3
2025-04-03 11:32:03 +08:00
mkm
94676eb4ea Merge branch 'main' into dev 2025-04-03 11:30:22 +08:00
7ea7dde782 Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into dev 2025-04-03 11:29:02 +08:00
407553baaf 修改预订单高级会员导出 2025-04-03 11:28:58 +08:00
mkm
98181dfbf9 Merge pull request '更新 app/api/lists/order/CartList.php' (#2) from dev into main
Reviewed-on: #2
2025-04-02 16:12:18 +08:00
mkm
ba6d76de7e 更新 app/api/lists/order/CartList.php 2025-04-02 16:12:02 +08:00
35902 changed files with 3653540 additions and 168 deletions

View File

@ -4,6 +4,10 @@ namespace app\admin\controller;
use app\admin\logic\beforehand_order_cart_info\BeforehandOrderCartInfoLogic; use app\admin\logic\beforehand_order_cart_info\BeforehandOrderCartInfoLogic;
use app\admin\logic\product_source_link_info\ProductSourceLinkInfoLogic; use app\admin\logic\product_source_link_info\ProductSourceLinkInfoLogic;
use app\admin\logic\inventory_transfer_order\InventoryTransferOrderLogic;
use app\admin\logic\store_product\StoreProductLogic;
use app\admin\logic\store_product_price\StoreProductPriceLogic;
use app\admin\service\ProductPriceService;
use app\common\model\beforehand_order\BeforehandOrder; use app\common\model\beforehand_order\BeforehandOrder;
use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo;
use app\common\model\CeshiCopy; use app\common\model\CeshiCopy;
@ -13,9 +17,13 @@ use app\common\model\purchase_product_offer\PurchaseProductOffer;
use app\common\model\store_category\StoreCategory; use app\common\model\store_category\StoreCategory;
use app\common\model\store_product\StoreProduct; use app\common\model\store_product\StoreProduct;
use app\common\model\store_product_group_price\StoreProductGroupPrice; use app\common\model\store_product_group_price\StoreProductGroupPrice;
use app\common\model\store_product_price\StoreProductPrice;
use app\common\model\StoreProductPriceList; use app\common\model\StoreProductPriceList;
use app\common\model\warehouse_order\WarehouseOrder; use app\common\model\warehouse_order\WarehouseOrder;
use app\common\model\warehouse_product\WarehouseProduct; use app\common\model\warehouse_product\WarehouseProduct;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\system_store\SystemStore;
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\IOFactory;
use support\exception\BusinessException; use support\exception\BusinessException;
use support\Redis; use support\Redis;
@ -24,9 +32,132 @@ use think\facade\Db;
class LocalController extends BaseAdminController class LocalController extends BaseAdminController
{ {
public $notNeedLogin = ['activityPrice', 'searchProduct', 'setPrice', 'index', 'updateProductPriceList', 'importOrder', 'warehousing', 'outbound']; public $notNeedLogin = ['importPrice', 'searchProduct', 'setPrice', 'index', 'updateProductPriceList', 'importOrder', 'warehousing', 'outbound', 'syncPrice', 'importProduct'];
public $ids = [1829,1828,1827,1826,1825,1824,1823,1821,1820,1814,1813,1811,1810,1809,1808,1807,1806,1800,1799,1798,1796,1795,1794,1793,1792,1791,1790,1789,1788,1787,1786,1785,1784,1783,1782,1781,1780,1779,1778,1777,1776,1775,1774,1773,1772,1771,1770,1768,1765,1764,1763,1762,1761,1760,1759,1758,1757,1756,1755,1754,1753,1752,1751,1750,1749,1748,1747,1746,1745,1744,1743,1742,1741,1740,1739,1738,1737,1736,1735,1733,1732,1731,1730,1729,1728,1727,1726,1725,1724,1723,1722,1720,1719,1718,1717,1716,1715,1714,1713,1712,1711,1710,1709,1708,1707,1706,1705,1704,1703,1701,1700,1699,1698,1697,1696,1695,1694,1693,1692,1691,1690,1689,1688,1687,1686,1685,1684,1683,1682,1681,1680,1679,1678,1677,1676,1675,1674,1673,1672,1671,1670,1668,1667,1666,1665,1664,1663,1660,1659,1658,1657,1656,1655,1654,1652,1651,1650,1649,1648,1647,1646,1645,1644,1643,1642,1641,1640,1639,1638,1637,1636,1635,1634,1633,1632,1631,1630,1629,1628,1627,1626,1623,1622]; public $ids = [1829, 1828, 1827, 1826, 1825, 1824, 1823, 1821, 1820, 1814, 1813, 1811, 1810, 1809, 1808, 1807, 1806, 1800, 1799, 1798, 1796, 1795, 1794, 1793, 1792, 1791, 1790, 1789, 1788, 1787, 1786, 1785, 1784, 1783, 1782, 1781, 1780, 1779, 1778, 1777, 1776, 1775, 1774, 1773, 1772, 1771, 1770, 1768, 1765, 1764, 1763, 1762, 1761, 1760, 1759, 1758, 1757, 1756, 1755, 1754, 1753, 1752, 1751, 1750, 1749, 1748, 1747, 1746, 1745, 1744, 1743, 1742, 1741, 1740, 1739, 1738, 1737, 1736, 1735, 1733, 1732, 1731, 1730, 1729, 1728, 1727, 1726, 1725, 1724, 1723, 1722, 1720, 1719, 1718, 1717, 1716, 1715, 1714, 1713, 1712, 1711, 1710, 1709, 1708, 1707, 1706, 1705, 1704, 1703, 1701, 1700, 1699, 1698, 1697, 1696, 1695, 1694, 1693, 1692, 1691, 1690, 1689, 1688, 1687, 1686, 1685, 1684, 1683, 1682, 1681, 1680, 1679, 1678, 1677, 1676, 1675, 1674, 1673, 1672, 1671, 1670, 1668, 1667, 1666, 1665, 1664, 1663, 1660, 1659, 1658, 1657, 1656, 1655, 1654, 1652, 1651, 1650, 1649, 1648, 1647, 1646, 1645, 1644, 1643, 1642, 1641, 1640, 1639, 1638, 1637, 1636, 1635, 1634, 1633, 1632, 1631, 1630, 1629, 1628, 1627, 1626, 1623, 1622];
public function importPrice()
{
$file = $this->request->file('file');
$reader = IOFactory::createReader('Xlsx');
$spreadsheet = $reader->load($file->getRealPath());
$data = $spreadsheet->getActiveSheet()->toArray();
foreach ($data as $k => $v) {
if ($k < 1) {
continue;
}
$productId = $v[0];
$purchasePrice = $v[12];
$product = StoreProduct::where('id', $productId)->find();
if (empty($product)) {
continue;
}
$params = [
'product_id' => $productId,
'purchase_price' => $purchasePrice,
'status' => 1,
];
$productService = new ProductPriceService();
$productPriceRate = $productService->getProductPriceRate($productId);
if (!empty($productPriceRate)) {
$priceArray = $productService->setProductPrice($params['purchase_price'], $productPriceRate);
$params = array_merge($params, $priceArray);
}
StoreProductPriceLogic::add($params);
}
}
public function importProduct()
{
$file = $this->request->file('file');
$reader = IOFactory::createReader('Xlsx');
$spreadsheet = $reader->load($file->getRealPath());
$data = $spreadsheet->getActiveSheet()->toArray();
$createTime = time();
$updateTime = time();
foreach ($data as $k => $v) {
if ($k < 1) {
continue;
}
$productName = $v[0];
$num = $v[1];
$package = $v[2];
$product = StoreProduct::where('store_name', $productName)->find();
if (empty($product)) {
$product = StoreProductLogic::add([
'store_name' => $productName,
'image' => '',
'cate_id' => 15627,
'cate_arr' => [15324, 15627],
'package' => $package,
'unit' => 0,
'price' => 0,
'vip_price' => 0,
'cost' => 0,
'purchase' => 0,
'is_return' => 0,
'is_store_all' => 1,
'product_type' => 3,
]);
}
$warehouseProduct = WarehouseProductStorege::where('product_id', $product->id)->find();
if (empty($warehouseProduct)) {
WarehouseProductStorege::create([
'product_id' => $product->id,
'nums' => $num,
'warehouse_id' => 1,
'create_time' => $createTime,
'update_time' => $updateTime,
]);
} else {
$warehouseProduct->save(['nums' => $num]);
}
}
}
public function syncPrice(ProductPriceService $productPriceService)
{
$data = Db::connect('local')->query('SELECT id, product_id,purchase_price FROM (SELECT id,product_id,purchase_price,ROW_NUMBER() OVER (PARTITION BY product_id ORDER BY id DESC) as rn FROM la_store_product_price) subquery WHERE rn = 1');
$products = StoreProduct::whereIn('id', array_column($data, 'product_id'))->field('id,store_name,top_cate_id,cate_id')->select()->toArray();
$products = reset_index($products, 'id');
$update = [];
$update2 = [];
foreach ($data as $item) {
$product = $products[$item['product_id']] ?? [];
if (empty($product)) {
continue;
}
$priceRateList = $productPriceService->getProductPriceRate($product['id'], true);
$rate = $priceRateList['supply_rate'];
$costRate = $priceRateList['merchant_rate'];
$vipPriceRate = $priceRateList['vip_rate'];
$priceRate = $priceRateList['price_rate'];
$purchase = bcmul($item['purchase_price'], $rate, 2);
$cost = bcmul($purchase, $costRate, 2);
$price = bcmul($purchase, $priceRate, 2);
$vipPrice = bcmul($purchase, $vipPriceRate, 2);
$update[] = [
'id' => $item['id'],
'purchase_lv' => $rate,
'purchase' => $purchase,
'cost_lv' => $costRate,
'cost' => $cost,
'price_lv' => $priceRate,
'price' => $price,
'vip_lv' => $vipPriceRate,
'vip_price' => $vipPrice,
];
$update2[] = [
'id' => $item['product_id'],
'purchase' => $purchase,
'cost' => $cost,
'price' => $price,
'vip_price' => $vipPrice,
];
}
(new StoreProductPrice())->saveAll($update);
(new StoreProduct())->saveAll($update2);
}
public function warehousing() public function warehousing()
{ {
@ -514,4 +645,53 @@ class LocalController extends BaseAdminController
} }
} }
public function importStorege()
{
$file = $this->request->file('file');
$reader = IOFactory::createReader('Xlsx');
$spreadsheet = $reader->load($file->getRealPath());
$sheets = $spreadsheet->getActiveSheet()->toArray();
$new_params = [];
$params = [];
$system_store_id = 0;
$params['product_arr'] = [];
foreach ($sheets as $key => $row) {
if ($key == 0) {
continue;
}
if (!$system_store_id) {
$system_store_id = SystemStore::where('name', $row[1])->value('id');
}
$product = StoreBranchProduct::where('product_id', $row[0])->where('store_id', $system_store_id)->field('id,product_id,stock')->findOrEmpty();
if ($row[10] == $product->stock && intval($product->stock) > 0) {
$arr = [
'nums' => $row[10],
'product_id' => $product->product_id,
'purchase' => 0,
'total_price' => $product->total_price,
];
$params['product_arr'][] = $arr;
} else {
$arr = [];
$arr['product_id'] = $row[0];
$arr['product_name'] = $row[2] ?? '';
$arr['store_id'] = $system_store_id;
$arr['nums'] = $row[10] ?? 0;
$arr['stock'] = $product->stock ?? 0;
$new_params[] = $arr;
}
}
// 生成铺货单
$params['mark'] = "门店铺货-excel导入";
$params['one_id'] = $system_store_id; //门店id
$params['one_type'] = 1; //1门店2仓库
$params['two_id'] = 1; //1海吉星仓库
$params['two_type'] = 2; //1门店2仓库
$params['types'] = 0; //0减库存 1不减库存
InventoryTransferOrderLogic::add($params, $this->adminId);
$new_params = json_encode($new_params, true);
file_put_contents(public_path() . '/output.text', $new_params);
return $this->success('导入成功');
}
} }

View File

@ -84,7 +84,7 @@ class BeforehandOrderController extends BaseAdminController
'regional_manager' => $params['regional_manager'] ?? '', 'regional_manager' => $params['regional_manager'] ?? '',
]; ];
$params['other_data'] = $other_data; $params['other_data'] = $other_data;
if ($params['order_type'] == 7) { if (in_array($params['order_type'], [7, 9])) {
PurchaseProductOfferLogic::batchCreate($params); PurchaseProductOfferLogic::batchCreate($params);
} else { } else {
BeforehandOrderLogic::add($params); BeforehandOrderLogic::add($params);

View File

@ -7,7 +7,8 @@ use app\admin\controller\BaseAdminController;
use app\admin\lists\inventory_transfer\InventoryTransferLists; use app\admin\lists\inventory_transfer\InventoryTransferLists;
use app\admin\logic\inventory_transfer\InventoryTransferLogic; use app\admin\logic\inventory_transfer\InventoryTransferLogic;
use app\admin\validate\inventory_transfer\InventoryTransferValidate; use app\admin\validate\inventory_transfer\InventoryTransferValidate;
use app\admin\logic\inventory_transfer_order\InventoryTransferOrderLogic;
use app\common\service\xlsx\InventoryTransferXlsx;
/** /**
* 商品调拨控制器 * 商品调拨控制器
@ -38,8 +39,8 @@ class InventoryTransferController extends BaseAdminController
*/ */
public function add() public function add()
{ {
$params = (new InventoryTransferValidate())->post()->goCheck('add'); $params = $this->request->post();
$result = InventoryTransferLogic::add($params,$this->adminId); $result = InventoryTransferLogic::add($params, $this->adminId);
if (true === $result) { if (true === $result) {
return $this->success('添加成功', [], 1, 1); return $this->success('添加成功', [], 1, 1);
} }
@ -91,6 +92,4 @@ class InventoryTransferController extends BaseAdminController
$result = InventoryTransferLogic::detail($params); $result = InventoryTransferLogic::detail($params);
return $this->data($result); return $this->data($result);
} }
} }

View File

@ -7,7 +7,8 @@ use app\admin\controller\BaseAdminController;
use app\admin\lists\inventory_transfer_order\InventoryTransferOrderLists; use app\admin\lists\inventory_transfer_order\InventoryTransferOrderLists;
use app\admin\logic\inventory_transfer_order\InventoryTransferOrderLogic; use app\admin\logic\inventory_transfer_order\InventoryTransferOrderLogic;
use app\admin\validate\inventory_transfer_order\InventoryTransferOrderValidate; use app\admin\validate\inventory_transfer_order\InventoryTransferOrderValidate;
use app\common\service\xlsx\InventoryTransferXlsx;
use app\common\model\inventory_transfer\InventoryTransfer;
/** /**
* 商品调拨订单控制器 * 商品调拨订单控制器
@ -39,7 +40,7 @@ class InventoryTransferOrderController extends BaseAdminController
public function add() public function add()
{ {
$params = $this->request->post(); $params = $this->request->post();
$result = InventoryTransferOrderLogic::add($params,$this->adminId); $result = InventoryTransferOrderLogic::add($params, $this->adminId);
if (true === $result) { if (true === $result) {
return $this->success('添加成功', [], 1, 1); return $this->success('添加成功', [], 1, 1);
} }
@ -104,4 +105,15 @@ class InventoryTransferOrderController extends BaseAdminController
return $this->success('删除成功', [], 1, 1); return $this->success('删除成功', [], 1, 1);
} }
/**
* 导出调拨表格
*/
public function export()
{
$params = $this->request->post();
$xlsx = new InventoryTransferXlsx();
$order = InventoryTransferOrderLogic::detail($params);
$file_path = $xlsx->export($order['product_list'], $order);
return $this->success('导出成功', ['url' => $file_path]);
}
} }

View File

@ -0,0 +1,95 @@
<?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);
}
}

View File

@ -91,5 +91,10 @@ class StoreCategoryController extends BaseAdminController
return $this->data($result); return $this->data($result);
} }
public function tree()
{
$result = StoreCategoryLogic::tree();
return $this->data($result);
}
} }

View File

@ -11,8 +11,19 @@ use app\admin\validate\store_product\StoreProductValidate;
use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_product\StoreProduct; use app\common\model\store_product\StoreProduct;
use app\common\model\warehouse_product_storege\WarehouseProductStorege; 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; use Webman\RedisQueue\Redis;
use app\common\model\product_image\ProductImage;
use app\admin\logic\product_image\ProductImageLogic;
/** /**
* 商品列表控制器 * 商品列表控制器
* Class StoreProductController * Class StoreProductController
@ -21,6 +32,7 @@ use Webman\RedisQueue\Redis;
class StoreProductController extends BaseAdminController class StoreProductController extends BaseAdminController
{ {
public $notNeedLogin = ['upload', 'recognition'];
/** /**
* @notes 获取商品列表列表 * @notes 获取商品列表列表
@ -151,4 +163,78 @@ class StoreProductController extends BaseAdminController
return $this->success('删除成功', [], 1, 1); return $this->success('删除成功', [], 1, 1);
} }
public function upload()
{
$params = $this->request->get();
// $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'));
$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 = $this->request->file('file');
$filePath = $file->getRealPath();
$fileName = $file->getuploadName();
$file = file_get_contents($filePath);
// $fileName ="矿泉水7";
// $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)
];
$req->fromJsonString(json_encode($ImageParams));
$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);
return $this->data($result);
}
public function recognition()
{
$params = $this->request->get();
// $params = [
// 'GroupId' => 'default',
// ];
$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 = $this->request->file('file');
$filePath = $file->getRealPath();
$file = file_get_contents($filePath);
// $fileName ="鱿鱼";
// $file = file_get_contents(public_path() . '/' . $fileName. '.jpg');
$ImageParams = [
'GroupId' => $params['GroupId'],
'ImageBase64' => base64_encode($file)
];
$req->fromJsonString(json_encode($ImageParams));
$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);
return $this->data($result);
}
} }

View File

@ -6,6 +6,7 @@ namespace app\admin\controller\store_product_price;
use app\admin\controller\BaseAdminController; use app\admin\controller\BaseAdminController;
use app\admin\lists\store_product_price\StoreProductPriceLists; use app\admin\lists\store_product_price\StoreProductPriceLists;
use app\admin\logic\store_product_price\StoreProductPriceLogic; use app\admin\logic\store_product_price\StoreProductPriceLogic;
use app\admin\service\ProductPriceService;
use app\admin\validate\store_product_price\StoreProductPriceValidate; use app\admin\validate\store_product_price\StoreProductPriceValidate;
@ -114,4 +115,21 @@ class StoreProductPriceController extends BaseAdminController
return $this->data($data); return $this->data($data);
} }
public function getRate(ProductPriceService $productPriceService)
{
$params = $this->request->get();
$productPriceRate = $productPriceService->getProductPriceRate($params['product_id'], true);
return $this->data($productPriceRate);
}
public function create()
{
$params = request()->post();
$result = StoreProductPriceLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(StoreProductPriceLogic::getError());
}
} }

View File

@ -0,0 +1,65 @@
<?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();
}
}

View File

@ -54,17 +54,6 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
*/ */
public function lists(): array public function lists(): array
{ {
$class_all = $this->request->get('class_all');
if ($class_all) {
//查3级别的
$arr = Cate::where('pid', $class_all)->column('id');
if ($arr) {
$arr2 = Cate::where('pid', 'in', $arr)->column('id');
$this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)];
} else {
$this->searchWhere[] = ['cate_id', '=', $class_all];
}
}
$is_warehouse = $this->request->get('is_warehouse', 0); $is_warehouse = $this->request->get('is_warehouse', 0);
$order_type = $this->request->get('order_type', 0); $order_type = $this->request->get('order_type', 0);
$userShip = 0; $userShip = 0;
@ -82,6 +71,18 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
$query->where('is_show', 1); $query->where('is_show', 1);
} }
} }
$class_all = $this->request->get('class_all');
if ($class_all) {
if (count($class_all) == 1) {
$query->where('top_cate_id', $class_all[0]);
} elseif (count($class_all) == 2) {
$query->where(function ($query) use ($class_all) {
$query->where('two_cate_id', $class_all[1])->whereOr('cate_id', $class_all[1]);
});
} else {
$query->where('cate_id', $class_all[2]);
}
}
if (!empty($this->params['activity_zone_form_id'])) { if (!empty($this->params['activity_zone_form_id'])) {
$exceptIds = ActivityZone::where('form_id', $this->params['activity_zone_form_id'])->column('product_id'); $exceptIds = ActivityZone::where('form_id', $this->params['activity_zone_form_id'])->column('product_id');
$query->where('is_show', 1)->where('product_type', '<>', 5)->whereNotIn('id', $exceptIds); $query->where('is_show', 1)->where('product_type', '<>', 5)->whereNotIn('id', $exceptIds);
@ -97,6 +98,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
$list = $query->limit($this->limitOffset, $this->limitLength) $list = $query->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select()->each(function ($item) use ($is_warehouse, $userShip, $order_type, $is_true) { ->select()->each(function ($item) use ($is_warehouse, $userShip, $order_type, $is_true) {
$item['price_update_time'] = !empty($item['price_update_time']) ? date('Y-m-d H:i:s', $item['price_update_time']) : '';
$item['product_id'] = $item['id']; $item['product_id'] = $item['id'];
$item['bar_code_two'] = ''; $item['bar_code_two'] = '';
if (in_array($item['unit'], [2, 21])) { if (in_array($item['unit'], [2, 21])) {
@ -180,21 +182,19 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
*/ */
public function count(): int public function count(): int
{ {
$export = $this->request->get('export'); $query = StoreProduct::where($this->searchWhere);
if ($export == 1) {
$class_all = $this->request->get('class_all'); $class_all = $this->request->get('class_all');
if ($class_all) { if ($class_all) {
//查3级别的 if (count($class_all) == 1) {
$arr = Cate::where('pid', $class_all)->column('id'); $query->where('top_cate_id', $class_all[0]);
if ($arr) { } elseif (count($class_all) == 2) {
$arr2 = Cate::where('pid', 'in', $arr)->column('id'); $query->where(function ($query) use ($class_all) {
$this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)]; $query->where('two_cate_id', $class_all[1])->whereOr('cate_id', $class_all[1]);
});
} else { } else {
$this->searchWhere[] = ['cate_id', '=', $class_all]; $query->where('cate_id', $class_all[2]);
} }
} }
}
$query = StoreProduct::where($this->searchWhere);
if (isset($this->params['type_filter'])) { if (isset($this->params['type_filter'])) {
if ($this->params['type_filter'] == 0) { if ($this->params['type_filter'] == 0) {
$query->where(function ($query) { $query->where(function ($query) {

View File

@ -66,7 +66,11 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe
{ {
if ($this->request->get('store_name')) { if ($this->request->get('store_name')) {
$this->store_name = $this->request->get('store_name'); $this->store_name = $this->request->get('store_name');
$ids = StoreProduct::where('store_name', 'like', '%' . $this->request->get('store_name') . '%')->column('id'); $where[] = ['store_name', 'like', '%' . $this->request->get('store_name') . '%'];
if($this->request->get('class_all')){
$where[] = ['top_cate_id', 'in', $this->request->get('class_all')];
}
$ids = StoreProduct::where($where)->column('id');
if ($ids) { if ($ids) {
$this->searchWhere[] = ['product_id', 'in', $ids]; $this->searchWhere[] = ['product_id', 'in', $ids];
$this->ids = $ids; $this->ids = $ids;
@ -84,6 +88,16 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe
return []; return [];
} }
} }
if($this->request->get('class_all')){
$where[] = ['top_cate_id', 'in', $this->request->get('class_all')];
}
$ids = StoreProduct::where($where)->column('id');
if ($ids) {
$this->searchWhere[] = ['product_id', 'in', $ids];
$this->ids = $ids;
} else {
return [];
}
return WarehouseProductStorege::where($this->searchWhere) return WarehouseProductStorege::where($this->searchWhere)
->field(['id','is_verify','warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status']) ->field(['id','is_verify','warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status'])
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)

View File

@ -968,25 +968,14 @@ class BeforehandOrderLogic extends BaseLogic
$v['store_name'] = $find['store_name']; $v['store_name'] = $find['store_name'];
$v['mark'] = $find['after_sales']; $v['mark'] = $find['after_sales'];
if (isset($params['type']) && $params['type'] == 2) { if (isset($params['type']) && $params['type'] == 2) {
$price = $v['cost']; $v['price'] = $v['vip_price']; //出库单价
$v['pay_price'] = bcmul($price, $v['nums'], 2); $v['purchase'] = $v['cost']; //高级会员单,供货价=商户价
} else { } else {
if ($v['vip_price'] > 0) { $v['purchase'] = $v['vip_price'] > 0 ? $v['vip_price'] : $v['price']; //会员单,供货价=会员价
$v['pay_price'] = bcmul($v['vip_price'], $v['nums'], 2);
$price = $v['vip_price'];
} else {
$price = StoreProductGroupPrice::where('product_id', $v['product_id'])->where('group_id', $user_ship)->value('price');
if ($price > 0) {
$v['pay_price'] = bcmul($price, $v['nums'], 2);
} else {
$price = $find['cost'];
$v['pay_price'] = bcmul($price, $v['nums'], 2);
}
WarehouseProduct::where('id', $v['id'])->update(['vip_price' => $price]);
}
} }
$v['purchase'] = $price; $v['total_price'] = bcmul($v['price'], $v['nums'], 2); //出库总价
$v['pay_price'] = bcmul($v['purchase'], $v['nums'], 2); //供货总价
$v['profit'] = bcsub($v['total_price'], $v['pay_price'], 2); $v['profit'] = bcsub($v['total_price'], $v['pay_price'], 2);
$total_profit = bcadd($total_profit, $v['profit'], 2); $total_profit = bcadd($total_profit, $v['profit'], 2);
$pay_price = bcadd($pay_price, $v['pay_price'], 2); $pay_price = bcadd($pay_price, $v['pay_price'], 2);

View File

@ -4,10 +4,12 @@ namespace app\admin\logic\inventory_transfer;
use app\admin\logic\warehouse_product\WarehouseProductLogic; use app\admin\logic\warehouse_product\WarehouseProductLogic;
use app\common\model\inventory_transfer\InventoryTransfer; use app\common\model\inventory_transfer\InventoryTransfer;
use app\admin\logic\inventory_transfer_order\InventoryTransferOrderLogic;
use app\common\logic\BaseLogic; use app\common\logic\BaseLogic;
use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_product\StoreProduct; use app\common\model\store_product\StoreProduct;
use app\common\model\warehouse_product_storege\WarehouseProductStorege; use app\common\model\warehouse_product_storege\WarehouseProductStorege;
use app\common\model\inventory_transfer_order\InventoryTransferOrder;
use support\exception\BusinessException; use support\exception\BusinessException;
use think\facade\Db; use think\facade\Db;
@ -28,9 +30,62 @@ class InventoryTransferLogic extends BaseLogic
* @author admin * @author admin
* @date 2024/08/13 16:18 * @date 2024/08/13 16:18
*/ */
public static function add(array $params,$admin_id=0): bool public static function add(array $params, $admin_id = 0)
{ {
$find = InventoryTransferOrder::where('id', $params['oid'])->find()->toArray();
if (empty($params['product_arr'])) {
throw new BusinessException('请选择商品');
}
$productIds = array_column($params['product_arr'], 'id');
if ($find['one_type'] == 1) {
$outProducts = StoreBranchProduct::whereIn('product_id', $productIds)->where('store_id', $find['one_id'])->field('id,product_id,stock')->select()->toArray();
} else {
$outProducts = WarehouseProductStorege::whereIn('product_id', $productIds)->where('warehouse_id', $find['one_id'])->field('id,product_id,nums stock')->select()->toArray();
}
$outProducts = reset_index($outProducts, 'product_id');
if ($find['two_type'] == 1) {
$inProducts = StoreBranchProduct::whereIn('product_id', $productIds)->where('store_id', $find['two_id'])->field('id,product_id,stock')->select()->toArray();
} else {
$inProducts = WarehouseProductStorege::whereIn('product_id', $productIds)->where('warehouse_id', $find['two_id'])->field('id,product_id,nums stock')->select()->toArray();
}
$inProducts = reset_index($inProducts, 'product_id');
$insert = [];
Db::startTrans();
try {
$insert = [];
foreach ($params['product_arr'] as $v) {
$outProduct = !empty($outProducts[$v['id']]) ? $outProducts[$v['id']] : ['stock' => 0, 'id' => 0, 'product_id' => $v['id']];
$inProduct = !empty($inProducts[$v['id']]) ? $inProducts[$v['id']] : ['stock' => 0, 'id' => 0, 'product_id' => $v['id']];
if ($outProduct['stock'] < $v['nums']) {
throw new BusinessException("出库商品库存不足 {$outProduct['product_id']} 调拨数量不能大于当前仓库库存");
continue;
}
$insert[] = [
'oid' => $find['id'],
'product_id' => $v['id'],
'nums' => $v['nums'],
'remark' => $v['remark'],
'one_before_nums' => $outProduct['stock'],
'one_after_nums' => bcsub($outProduct['stock'], $v['nums']),
'two_before_nums' => $inProduct['stock'],
'two_after_nums' => bcadd($inProduct['stock'], $v['nums']),
'one_type' => $find['one_type'],
'two_type' => $find['two_type'],
'one_id' => $find['one_id'],
'two_id' => $find['two_id'],
'create_time' => time(),
];
}
InventoryTransfer::insertAll($insert);
if ($find['two_type'] == 1 && $find['status'] == 1) {
InventoryTransferOrderLogic::audit($find, $insert, $admin_id);
}
Db::commit();
return true; return true;
} catch (\Throwable $e) {
Db::rollback();
throw new BusinessException($e->getMessage());
}
} }
/** /**

View File

@ -32,9 +32,9 @@ class InventoryTransferOrderLogic extends BaseLogic
* @author admin * @author admin
* @date 2025/01/24 09:59 * @date 2025/01/24 09:59
*/ */
public static function add(array $params,$admin_id): bool public static function add(array $params, $admin_id): bool
{ {
$types=$params['types']??0; $types = $params['types'] ?? 0;
if (empty($params['product_arr'])) { if (empty($params['product_arr'])) {
throw new BusinessException('请选择商品'); throw new BusinessException('请选择商品');
} }
@ -65,6 +65,7 @@ class InventoryTransferOrderLogic extends BaseLogic
$insert[] = [ $insert[] = [
'product_id' => $v['product_id'], 'product_id' => $v['product_id'],
'nums' => $v['nums'], 'nums' => $v['nums'],
'remark' => $v['remark'],
'one_before_nums' => $outProduct['stock'], 'one_before_nums' => $outProduct['stock'],
'one_after_nums' => bcsub($outProduct['stock'], $v['nums']), 'one_after_nums' => bcsub($outProduct['stock'], $v['nums']),
'two_before_nums' => $inProduct['stock'], 'two_before_nums' => $inProduct['stock'],
@ -76,21 +77,21 @@ class InventoryTransferOrderLogic extends BaseLogic
'create_time' => time(), 'create_time' => time(),
]; ];
} }
$order=InventoryTransferOrder::create([ $order = InventoryTransferOrder::create([
'order_id' => getNewOrderId('DB'), 'order_id' => getNewOrderId('DB'),
'one_type' => $params['one_type'], 'one_type' => $params['one_type'],
'two_type' => $params['two_type'], 'two_type' => $params['two_type'],
'one_id' => $params['one_id'], 'one_id' => $params['one_id'],
'two_id' => $params['two_id'], 'two_id' => $params['two_id'],
'types' => $types, 'types' => $types,
'mark' => $params['mark']??'', 'mark' => $params['mark'] ?? '',
'status' => ($params['two_type'] == 2 && $types == 0) ? 0 : 1, 'status' => ($params['two_type'] == 2 && $types == 0) ? 0 : 1,
]); ]);
foreach ($insert as $k => $v) { foreach ($insert as $k => $v) {
$insert[$k]['oid'] = $order['id']; $insert[$k]['oid'] = $order['id'];
} }
InventoryTransfer::insertAll($insert); InventoryTransfer::insertAll($insert);
if($types==0 && $params['two_type']==1){ if ($types == 0 && $params['two_type'] == 1) {
self::audit($params, $insert, $admin_id); self::audit($params, $insert, $admin_id);
} }
@ -108,17 +109,17 @@ class InventoryTransferOrderLogic extends BaseLogic
$products = InventoryTransfer::where('oid', $order['id'])->select()->toArray(); $products = InventoryTransfer::where('oid', $order['id'])->select()->toArray();
} }
foreach ($products as $v) { foreach ($products as $v) {
if($order['one_type']==1){ if ($order['one_type'] == 1) {
$find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $order['one_id'])->find(); $find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $order['one_id'])->find();
$find->save(['stock' =>bcsub( $find['stock'],$v['nums'],2)]); $find->save(['stock' => bcsub($find['stock'], $v['nums'], 2)]);
SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], -1, Request()->url(),$admin_id); SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], -1, Request()->url(), $admin_id);
} elseif ($order['one_type'] == 2) { } elseif ($order['one_type'] == 2) {
$find=WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $order['one_id'])->find(); $find = WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $order['one_id'])->find();
$find->save(['nums' =>bcsub( $find['nums'],$v['nums'],2)]); $find->save(['nums' => bcsub($find['nums'], $v['nums'], 2)]);
SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], -1, Request()->url(),$admin_id); SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], -1, Request()->url(), $admin_id);
} }
if($order['two_type']==1){ if ($order['two_type'] == 1) {
$find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $order['two_id'])->find(); $find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $order['two_id'])->find();
if (empty($find)) { if (empty($find)) {
$storeProduct = StoreProduct::field('top_cate_id,two_cate_id,cate_id,store_name,image,price,vip_price,cost,purchase,keyword,bar_code,store_info,rose,product_type,unit,batch,store_batch,label_id,is_lack,manufacturer_information')->where('id', $v['product_id'])->find()->toArray(); $storeProduct = StoreProduct::field('top_cate_id,two_cate_id,cate_id,store_name,image,price,vip_price,cost,purchase,keyword,bar_code,store_info,rose,product_type,unit,batch,store_batch,label_id,is_lack,manufacturer_information')->where('id', $v['product_id'])->find()->toArray();
$find = new StoreBranchProduct(); $find = new StoreBranchProduct();
@ -128,11 +129,11 @@ class InventoryTransferOrderLogic extends BaseLogic
$find->setAttrs($storeProduct); $find->setAttrs($storeProduct);
$find->save(); $find->save();
} else { } else {
$find->save(['stock' =>bcadd( $find['stock'],$v['nums'],2)]); $find->save(['stock' => bcadd($find['stock'], $v['nums'], 2)]);
} }
SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], 1, Request()->url(),$admin_id); SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], 1, Request()->url(), $admin_id);
} elseif ($order['two_type'] == 2) { } elseif ($order['two_type'] == 2) {
$find=WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $order['two_id'])->find(); $find = WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $order['two_id'])->find();
if (empty($find)) { if (empty($find)) {
$find = new WarehouseProductStorege(); $find = new WarehouseProductStorege();
$find->warehouse_id = $order['two_id']; $find->warehouse_id = $order['two_id'];
@ -140,9 +141,9 @@ class InventoryTransferOrderLogic extends BaseLogic
$find->nums = $v['nums']; $find->nums = $v['nums'];
$find->save(); $find->save();
} else { } else {
$find->save(['nums' =>bcadd( $find['nums'],$v['nums'],2)]); $find->save(['nums' => bcadd($find['nums'], $v['nums'], 2)]);
} }
SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], 1, Request()->url(),$admin_id); SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], 1, Request()->url(), $admin_id);
} }
InventoryTransferOrder::where('id', $order['id'])->update(['status' => 1]); InventoryTransferOrder::where('id', $order['id'])->update(['status' => 1]);
@ -209,26 +210,26 @@ class InventoryTransferOrderLogic extends BaseLogic
*/ */
public static function detail($params): array public static function detail($params): array
{ {
$data= InventoryTransferOrder::findOrEmpty($params['id']); $data = InventoryTransferOrder::findOrEmpty($params['id']);
$type_name=''; $type_name = '';
if($data->one_type==1){ if ($data->one_type == 1) {
$data->one_name=SystemStore::where('id',$data->one_id)->value('name'); $data->one_name = SystemStore::where('id', $data->one_id)->value('name');
$type_name='门店转'; $type_name = '门店转';
}else{ } else {
$data->one_name=Warehouse::where('id',$data->one_id)->value('name'); $data->one_name = Warehouse::where('id', $data->one_id)->value('name');
$type_name='仓库转'; $type_name = '仓库转';
} }
if($data->two_type==1){ if ($data->two_type == 1) {
$type_name.='门店'; $type_name .= '门店';
$data->two_name=SystemStore::where('id',$data->two_id)->value('name'); $data->two_name = SystemStore::where('id', $data->two_id)->value('name');
}else{ } else {
$type_name.='仓库'; $type_name .= '仓库';
$data->two_name=Warehouse::where('id',$data->two_id)->value('name'); $data->two_name = Warehouse::where('id', $data->two_id)->value('name');
} }
$data->type_name=$type_name; $data->type_name = $type_name;
$data['product_list']=InventoryTransfer::where('oid',$params['id'])->select()->each(function ($item) { $data['product_list'] = InventoryTransfer::where('oid', $params['id'])->select()->each(function ($item) {
$find= StoreProduct::where('id',$item->product_id)->withTrashed()->field('store_name')->find(); $find = StoreProduct::where('id', $item->product_id)->withTrashed()->field('store_name')->find();
$item->store_name=$find['store_name']; $item->store_name = $find['store_name'] ?? '';
}) })
->toArray(); ->toArray();
return $data->toArray(); return $data->toArray();

View File

@ -0,0 +1,102 @@
<?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();
}
}

View File

@ -4,15 +4,11 @@ namespace app\admin\logic\product_source_link;
use app\admin\logic\product_source_link_info\ProductSourceLinkInfoLogic; use app\admin\logic\product_source_link_info\ProductSourceLinkInfoLogic;
use app\admin\logic\purchase_product_offer\PurchaseProductOfferLogic; use app\admin\service\ProductPriceService;
use app\common\model\inventory_transfer\InventoryTransfer;
use app\common\model\product_source_link\ProductSourceLink; use app\common\model\product_source_link\ProductSourceLink;
use app\common\logic\BaseLogic; use app\common\logic\BaseLogic;
use app\common\model\product_source_link_info\ProductSourceLinkInfo; use app\common\model\product_source_link_info\ProductSourceLinkInfo;
use support\exception\BusinessException; use support\exception\BusinessException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Db; use think\facade\Db;
@ -57,7 +53,7 @@ class ProductSourceLinkLogic extends BaseLogic
]; ];
if ($attrs['types'] == ProductSourceLinkInfo::TypeIn) { if ($attrs['types'] == ProductSourceLinkInfo::TypeIn) {
// 商品入库,记录采购总价和供货总价 // 商品入库,记录采购总价和供货总价
$priceRate = PurchaseProductOfferLogic::getProductPriceRate(['id' => $offer['product_id']]); $priceRate = (new ProductPriceService())->getProductPriceRate($offer['product_id']);
$attrs['purchase_price'] = $offer['total_price']; $attrs['purchase_price'] = $offer['total_price'];
$rate = bcdiv($priceRate['supply_rate'], 100, 2); $rate = bcdiv($priceRate['supply_rate'], 100, 2);
$attrs['supply_price'] = bcmul(bcmul($offer['price'], $rate, 2), $offer['nums'], 2); $attrs['supply_price'] = bcmul(bcmul($offer['price'], $rate, 2), $offer['nums'], 2);

View File

@ -3,8 +3,7 @@
namespace app\admin\logic\product_source_link_info; namespace app\admin\logic\product_source_link_info;
use app\admin\logic\product_source_link\ProductSourceLinkLogic; use app\admin\service\ProductPriceService;
use app\admin\logic\purchase_product_offer\PurchaseProductOfferLogic;
use app\common\model\inventory_transfer\InventoryTransfer; use app\common\model\inventory_transfer\InventoryTransfer;
use app\common\model\product_source_link\ProductSourceLink; use app\common\model\product_source_link\ProductSourceLink;
use app\common\model\product_source_link_info\ProductSourceLinkInfo; use app\common\model\product_source_link_info\ProductSourceLinkInfo;
@ -151,7 +150,7 @@ class ProductSourceLinkInfoLogic extends BaseLogic
]; ];
if ($attrs['types'] == ProductSourceLinkInfo::TypeIn) { if ($attrs['types'] == ProductSourceLinkInfo::TypeIn) {
// 商品入库,记录采购总价和供货总价 // 商品入库,记录采购总价和供货总价
$priceRate = PurchaseProductOfferLogic::getProductPriceRate(['id' => $this->purchaseProductOffer['product_id']]); $priceRate = (new ProductPriceService())->getProductPriceRate($this->purchaseProductOffer['product_id']);
$attrs['purchase_price'] = $this->purchaseProductOffer['total_price']; $attrs['purchase_price'] = $this->purchaseProductOffer['total_price'];
$rate = bcdiv($priceRate['supply_rate'], 100, 2); $rate = bcdiv($priceRate['supply_rate'], 100, 2);
$attrs['supply_price'] = bcmul(bcmul($this->purchaseProductOffer['price'], $rate, 2), $this->purchaseProductOffer['nums'], 2); $attrs['supply_price'] = bcmul(bcmul($this->purchaseProductOffer['price'], $rate, 2), $this->purchaseProductOffer['nums'], 2);
@ -300,7 +299,7 @@ class ProductSourceLinkInfoLogic extends BaseLogic
'warehouse_id' => $this->info['warehouse_id'], 'warehouse_id' => $this->info['warehouse_id'],
'store_id' => $this->info['store_id'], 'store_id' => $this->info['store_id'],
'oid' => $item['oid'], 'oid' => $item['oid'],
'types' => empty($this->info['types']) ? ProductSourceLinkInfo::TypeOut: $this->info['types'], 'types' => empty($this->info['types']) ? ProductSourceLinkInfo::TypeOut : $this->info['types'],
'link_id' => $this->info['link_id'], 'link_id' => $this->info['link_id'],
'from_id' => $item['id'], 'from_id' => $item['id'],
'nums' => $needNum, 'nums' => $needNum,
@ -474,10 +473,10 @@ class ProductSourceLinkInfoLogic extends BaseLogic
foreach ($list as $item) { foreach ($list as $item) {
$currentNum = max(bcsub($item['current_nums'], $needNum, 2), 0); $currentNum = max(bcsub($item['current_nums'], $needNum, 2), 0);
if ($item['current_nums'] > $needNum) { if ($item['current_nums'] > $needNum) {
[$update, $insert] = $this->getInsertAndUpdate2($update, $insert, $currentNum, $item, $needNum); [$update, $insert] = $this->getInsertAndUpdate($update, $insert, $currentNum, $item, $needNum);
break; break;
} else { } else {
[$update, $insert] = $this->getInsertAndUpdate2($update, $insert, 0, $item, $item['current_nums']); [$update, $insert] = $this->getInsertAndUpdate($update, $insert, 0, $item, $item['current_nums']);
} }
$needNum = $needNum - $item['current_nums']; $needNum = $needNum - $item['current_nums'];
} }
@ -542,5 +541,4 @@ class ProductSourceLinkInfoLogic extends BaseLogic
(new ProductSourceLinkInfo())->insertAll($insert); (new ProductSourceLinkInfo())->insertAll($insert);
return true; return true;
} }
} }

View File

@ -217,8 +217,8 @@ class PurchaseProductOfferLogic extends BaseLogic
$offer = PurchaseProductOffer::where(['id' => $params['id']])->find(); $offer = PurchaseProductOffer::where(['id' => $params['id']])->find();
$lastPrice = PurchaseProductOffer::where(['product_id' => $offer['product_id']])->where('status', 1)->order('id desc')->value('price'); $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); $currentPrice = bcdiv($params['total_price'], $params['buyer_nums'], 2);
if (!empty($lastPrice) && ($currentPrice > $lastPrice * 3 || $currentPrice < $lastPrice / 3)) { if ($lastPrice > 0 && ($currentPrice > $lastPrice * 3 || $currentPrice < $lastPrice / 3)) {
throw new BusinessException('价格异常,请重新输入'); // throw new BusinessException('价格异常,请重新输入');
} }
// $uid=Admin::where('id',$params['admin_id'])->value('uid'); // $uid=Admin::where('id',$params['admin_id'])->value('uid');
// if($params['admin_id']!=1){ // if($params['admin_id']!=1){
@ -410,9 +410,9 @@ class PurchaseProductOfferLogic extends BaseLogic
'warehouse_id' => $warehouseId, 'warehouse_id' => $warehouseId,
'warehouse_product_id' => $warehouseProductId, 'warehouse_product_id' => $warehouseProductId,
]; ];
$productPriceRate = self::getProductPriceRate($product);
if (!empty($productPriceRate)) {
$productService = new ProductPriceService(); $productService = new ProductPriceService();
$productPriceRate = $productService->getProductPriceRate($product['id']);
if (!empty($productPriceRate)) {
$priceArray = $productService->setProductPrice($params['purchase'], $productPriceRate); $priceArray = $productService->setProductPrice($params['purchase'], $productPriceRate);
$data = array_merge($data, $priceArray); $data = array_merge($data, $priceArray);
} }
@ -425,6 +425,11 @@ class PurchaseProductOfferLogic extends BaseLogic
} }
} }
/**
* @deprecated 已废弃,使用(new ProductPriceService())->getProductPriceRate($product['id'])
* @param $product
* @return array|int[]
*/
public static function getProductPriceRate($product) public static function getProductPriceRate($product)
{ {
$list = StoreProductPriceList::where('product_id', $product['id'])->findOrEmpty()->toArray(); $list = StoreProductPriceList::where('product_id', $product['id'])->findOrEmpty()->toArray();
@ -490,7 +495,7 @@ class PurchaseProductOfferLogic extends BaseLogic
$procurementOrder->order_id = getNewOrderId('CG'); $procurementOrder->order_id = getNewOrderId('CG');
$procurementOrder->buyer_id = $params['buyer_id']; $procurementOrder->buyer_id = $params['buyer_id'];
$procurementOrder->admin_id = $params['admin_id']; $procurementOrder->admin_id = $params['admin_id'];
$procurementOrder->order_type = 7; $procurementOrder->order_type = $params['order_type'];
$procurementOrder->total_price = 0; $procurementOrder->total_price = 0;
$procurementOrder->pay_price = 0; $procurementOrder->pay_price = 0;
$procurementOrder->save(); $procurementOrder->save();

View File

@ -108,4 +108,11 @@ class StoreCategoryLogic extends BaseLogic
{ {
return StoreCategory::findOrEmpty($params['id'])->toArray(); return StoreCategory::findOrEmpty($params['id'])->toArray();
} }
public static function tree()
{
$data = StoreCategory::field('id,pid,name')->order('id desc')->select()->toArray();
return list2tree($data);
}
} }

View File

@ -31,11 +31,10 @@ class StoreProductLogic extends BaseLogic
/** /**
* @notes 添加商品列表 * @notes 添加商品列表
* @param array $params * @param array $params
* @return bool
* @author likeadmin * @author likeadmin
* @date 2024/05/31 10:53 * @date 2024/05/31 10:53
*/ */
public static function add(array $params): bool public static function add(array $params)
{ {
$count = count($params['cate_arr']); $count = count($params['cate_arr']);
$top_cate_id = 0; $top_cate_id = 0;
@ -63,6 +62,7 @@ class StoreProductLogic extends BaseLogic
'vip_price' => $params['vip_price'], 'vip_price' => $params['vip_price'],
'cost' => $params['cost'], 'cost' => $params['cost'],
'purchase' => $params['purchase'], 'purchase' => $params['purchase'],
'package' => $params['package']??'',
'is_return' => $params['is_return'], 'is_return' => $params['is_return'],
'manufacturer_information' => $params['manufacturer_information'] ?? '', 'manufacturer_information' => $params['manufacturer_information'] ?? '',
'swap' => $params['swap'] ?? 0, 'swap' => $params['swap'] ?? 0,
@ -120,7 +120,7 @@ class StoreProductLogic extends BaseLogic
Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => getenv('STORE_ID'), 'stock_type' => 1, 'admin_id' => Request()->adminId]); Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => getenv('STORE_ID'), 'stock_type' => 1, 'admin_id' => Request()->adminId]);
} }
return true; return $res;
} catch (\Exception $e) { } catch (\Exception $e) {
Db::rollback(); Db::rollback();
throw new BusinessException('添加商品失败' . $e->getMessage()); throw new BusinessException('添加商品失败' . $e->getMessage());

View File

@ -37,7 +37,46 @@ class StoreProductPriceLogic extends BaseLogic
{ {
Db::startTrans(); Db::startTrans();
try { try {
StoreProductPrice::create([]); $model = StoreProductPrice::create($params);
$storeProductPriceList = StoreProductPriceList::where('product_id', $model['product_id'])->find();
$attrs = [
'supply_rate' => $params['purchase_lv'] * 100,
'merchant_rate' => $params['cost_lv'] * 100,
'vip_rate' => $params['vip_lv'] * 100,
'price_rate' => $params['price_lv'] * 100,
];
if (empty($storeProductPriceList)) {
$attrs['product_id'] = $model['product_id'];
StoreProductPriceList::create($attrs);
} else {
StoreProductPriceList::where('product_id', $model['product_id'])->update($attrs);
}
$productPrice = StoreProduct::where('id', $model['product_id'])->value('vip_price');
if ($productPrice != $model['vip_price']) {
SqlChannelPriceLog($model['product_id'], 43, $productPrice, $model['vip_price']);
}
StoreProduct::where('id', $model['product_id'])->update([
'purchase' => $model['purchase'],
'cost' => $model['cost'],
'vip_price' => $model['vip_price'],
'price' => $model['price'],
'ot_price' => $model['price'],
'price_update_time' => time(),
]);
StoreBranchProduct::where('product_id', $model['product_id'])->update([
'purchase' => $model['purchase'],
'cost' => $model['cost'],
'vip_price' => $model['vip_price'],
'price' => $model['price'],
'ot_price' => $model['price']
]);
$productSourceLinkInfoLogic = new ProductSourceLinkInfoLogic();
$productSourceLinkInfoLogic->storeProductPrice = $model;
$productSourceLinkInfoLogic->updateSupplyPrice();
Db::commit(); Db::commit();
return true; return true;
@ -104,14 +143,15 @@ class StoreProductPriceLogic extends BaseLogic
'purchase' => $find['purchase'], 'purchase' => $find['purchase'],
'cost' => $find['cost'], 'cost' => $find['cost'],
'vip_price' => $find['vip_price'], 'vip_price' => $find['vip_price'],
'price' => $find['vip_price'], 'price' => $find['price'],
'ot_price' => $find['price'] 'ot_price' => $find['price'],
'price_update_time' => time(),
]); ]);
StoreBranchProduct::where('product_id', $find['product_id'])->update([ StoreBranchProduct::where('product_id', $find['product_id'])->update([
'purchase' => $find['purchase'], 'purchase' => $find['purchase'],
'cost' => $find['cost'], 'cost' => $find['cost'],
'vip_price' => $find['vip_price'], 'vip_price' => $find['vip_price'],
'price' => $find['vip_price'], 'price' => $find['price'],
'ot_price' => $find['price'] 'ot_price' => $find['price']
]); ]);
@ -185,14 +225,15 @@ class StoreProductPriceLogic extends BaseLogic
'purchase' => $find['purchase'] ?? 0, 'purchase' => $find['purchase'] ?? 0,
'cost' => $find['cost'] ?? 0, 'cost' => $find['cost'] ?? 0,
'vip_price' => $find['vip_price'] ?? 0, 'vip_price' => $find['vip_price'] ?? 0,
'price' => $find['vip_price'] ?? 0, 'price' => $find['price'] ?? 0,
'ot_price' => $find['price'] ?? 0, 'ot_price' => $find['price'] ?? 0,
'price_update_time' => time(),
]); ]);
StoreBranchProduct::where('product_id', $find['product_id'])->update([ StoreBranchProduct::where('product_id', $find['product_id'])->update([
'purchase' => $find['purchase'] ?? 0, 'purchase' => $find['purchase'] ?? 0,
'cost' => $find['cost'] ?? 0, 'cost' => $find['cost'] ?? 0,
'vip_price' => $find['vip_price'] ?? 0, 'vip_price' => $find['vip_price'] ?? 0,
'price' => $find['vip_price'] ?? 0, 'price' => $find['price'] ?? 0,
'ot_price' => $find['price'] ?? 0, 'ot_price' => $find['price'] ?? 0,
]); ]);
} }

View File

@ -123,7 +123,11 @@ class WarehouseOrderLogic extends BaseLogic
$data['purchase'] = $v['prices']; $data['purchase'] = $v['prices'];
$data['total_price'] = bcmul($v['prices'], $v['nums'], 2); $data['total_price'] = bcmul($v['prices'], $v['nums'], 2);
} }
if ($data['financial_pm'] == 1) {
WarehouseProductLogic::add($data,1,$params['admin_id']); WarehouseProductLogic::add($data,1,$params['admin_id']);
} else {
WarehouseProductLogic::setOutbound($data,1,$params['admin_id']);
}
} }
$find = WarehouseProduct::where('oid', $params['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); $find = WarehouseProduct::where('oid', $params['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
if ($find) { if ($find) {

View File

@ -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) { if ($res['status'] == 1 && $res['store_id'] > 0) {
throw new BusinessException('门店已确认入库,不能修改数量'); throw new BusinessException('门店已确认入库,不能修改数量');
} }
$storageNum = $res['financial_pm'] == 0 ? -$updateNums : $updateNums; $storageNum = $res['financial_pm'] == 0 ? -$updateNums : $updateNums;

View File

@ -113,13 +113,8 @@ 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], ['id' => $params['bhoid']]); BeforehandOrder::update(['pay_price' => $total_price, 'total_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']);

View File

@ -2,6 +2,9 @@
namespace app\admin\service; namespace app\admin\service;
use app\common\model\store_product\StoreProduct;
use app\common\model\StoreProductPriceList;
class ProductPriceService class ProductPriceService
{ {
@ -22,12 +25,11 @@ class ProductPriceService
$result['vip_price'] = bcmul($result['purchase'], $result['vip_lv'], 2); $result['vip_price'] = bcmul($result['purchase'], $result['vip_lv'], 2);
$result['price_lv'] = bcdiv($productPriceRate['price_rate'], 100, 2); $result['price_lv'] = bcdiv($productPriceRate['price_rate'], 100, 2);
$result['price'] = bcmul($result['purchase'], $result['price_lv'], 2); $result['price'] = bcmul($result['purchase'], $result['price_lv'], 2);
// 暂时不处理零售价,零售价使用会员价 $lastNum = substr($result['price'], -1);
// $lastNum = substr($result['price'], -1); if ($lastNum > 0) {
// if ($lastNum > 0) { $result['price'] = ceil($result['price'] * 10);
// $result['price'] = ceil($result['price'] * 10); $result['price'] = bcdiv($result['price'], 10, 2);
// $result['price'] = bcdiv($result['price'], 10, 2); }
// }
$lastNum = substr($result['vip_price'], -1); $lastNum = substr($result['vip_price'], -1);
if ($lastNum > 0) { if ($lastNum > 0) {
$result['vip_price'] = ceil($result['vip_price'] * 10); $result['vip_price'] = ceil($result['vip_price'] * 10);
@ -36,4 +38,42 @@ class ProductPriceService
return $result; return $result;
} }
/**
* @param $productId int 商品id
* @param $percent bool 是否返回百分比
* @return array|int[]
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getProductPriceRate($productId, $percent = false)
{
$list = StoreProductPriceList::where('product_id', $productId)->findOrEmpty()->toArray();
$product = StoreProduct::where('id', $productId)->field('id,store_name,top_cate_id,cate_id')->find();
if (empty($list)) {
if ($product->isSpecial()) {
$list = [
'supply_rate' => 102,
'merchant_rate' => 102,
'vip_rate' => 104,
'price_rate' => 108,
];
} else {
$list = [
'supply_rate' => 105,
'merchant_rate' => 105,
'vip_rate' => 108,
'price_rate' => 112,
];
}
}
if ($percent) {
$list['supply_rate'] = $list['supply_rate'] / 100;
$list['merchant_rate'] = $list['merchant_rate'] / 100;
$list['vip_rate'] = $list['vip_rate'] / 100;
$list['price_rate'] = $list['price_rate'] / 100;
}
return $list;
}
} }

View File

@ -0,0 +1,82 @@
<?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']);
}
}

View File

@ -85,7 +85,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
if ($off_activity == 0 && $user_ship == 5 && $product['top_cate_id'] == 15189) { if ($off_activity == 0 && $user_ship == 5 && $product['top_cate_id'] == 15189) {
$product['price'] = $product['cost']; $product['price'] = $product['cost'];
} }
if ($user_ship == 4 ) { if ($user_ship == 4) {
$product['price'] = $product['cost']; $product['price'] = $product['cost'];
} }
$item['goods_total_price'] = bcmul($item['cart_num'], $product['price'], 2); $item['goods_total_price'] = bcmul($item['cart_num'], $product['price'], 2);

View File

@ -52,7 +52,7 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
->each(function ($item) { ->each(function ($item) {
$item['goods_list'] = StoreOrderCartInfo::where('oid', $item['id']) $item['goods_list'] = StoreOrderCartInfo::where('oid', $item['id'])
->field('id,product_id,cart_num,verify_code,is_writeoff,writeoff_time,cart_info,status') ->field('id,product_id,cart_num,verify_code,is_writeoff,writeoff_time,cart_info,status')
->limit(3) // ->limit(3)
->select() ->select()
->each(function ($v) use ($item) { ->each(function ($v) use ($item) {
$v['store_name'] = ''; $v['store_name'] = '';

View File

@ -0,0 +1,22 @@
<?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';
}

View File

@ -55,4 +55,13 @@ class StoreProduct extends BaseModel
Log::error('product:'.$e->getMessage()); Log::error('product:'.$e->getMessage());
} }
} }
public function isSpecial()
{
if (in_array($this->top_cate_id, [15189, 6]) || in_array($this->cate_id, [15551, 15552,15569,15570]) || mb_strpos($this->store_name, '鸡精') !== false || mb_strpos($this->store_name, '生抽') !== false || mb_strpos($this->store_name, '多宝鱼') !== false || mb_strpos($this->store_name, '小青虾') !== false) {
return true;
}
return false;
}
} }

View File

@ -24,4 +24,9 @@ class StoreProductPrice extends BaseModel
// 不生成该表的日志 // 不生成该表的日志
public $doNotRecordLog = true; 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');
}
} }

View File

@ -0,0 +1,111 @@
<?php
namespace app\common\service\xlsx;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Border;
use Webman\Exception\BusinessException;
class InventoryTransferXlsx
{
public function export($data, $order)
{
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setTitle('调拨订单'); // 设置列宽
$sheet->getDefaultRowDimension()->setRowHeight(20); // 设置行高
$sheet->getDefaultColumnDimension()->setWidth(20); // 设置列宽
$sheet->getPageSetup()->setFitToPage(true); // 自动适应页面大小
$sheet->getPageSetup()->setHorizontalCentered(true); // 页面水平居中
$sheet->getPageSetup()->setVerticalCentered(true); // 页面垂直居中
$sheet->getPageMargins()->setTop(0.5); // 上边距
$sheet->getPageMargins()->setBottom(0.5); // 下边距
$sheet->getPageMargins()->setLeft(0.5); // 左边距
$sheet->getPageMargins()->setRight(0.5); // 右边距
$sheet->getPageMargins()->setHeader(0.5); // 页眉边距
$sheet->getPageMargins()->setFooter(0.5); // 页脚边距
$sheet->getStyle('A1:H1')->getFont()->setBold(true); // 设置标题字体加粗
$sheet->getStyle('A1:H1')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); // 设置标题水平居中
$sheet->getStyle('A1:H1')->getAlignment()->setVertical(Alignment::VERTICAL_CENTER); // 设置标题垂直居中
$sheet->getStyle('A2:H2')->getFont()->setBold(true); // 设置标题字体加粗
$sheet->getStyle('A2:H2')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); // 设置标题水平居中
// 合并单元格并设置标题
$sheet->mergeCells('A1:G1')->setCellValue('A1', '调拨订单');
$sheet->setCellValue('A2', '订单编号');
$sheet->setCellValue('B2', '转出方');
$sheet->setCellValue('C2', '方式');
$sheet->setCellValue('D2', '转入方');
$sheet->setCellValue('E2', '商品');
$sheet->setCellValue('F2', '数量');
$sheet->setCellValue('G2', '备注');
$sheet->setCellValue('H2', '创建时间');
// 设置列宽
$sheet->getColumnDimension('A')->setAutoSize(true);
$sheet->getColumnDimension('B')->setAutoSize(true);
$sheet->getColumnDimension('C')->setWidth(20);
$sheet->getColumnDimension('D')->setWidth(20);
$sheet->getColumnDimension('E')->setAutoSize(true);
$sheet->getColumnDimension('F')->setAutoSize(true);
$sheet->getColumnDimension('G')->setAutoSize(true);
$sheet->getColumnDimension('H')->setAutoSize(true);
// 设置默认的单元格样式
$defaultStyle = [
'alignment' => [
'horizontal' => Alignment::HORIZONTAL_CENTER,
'vertical' => Alignment::VERTICAL_CENTER,
],
];
$spreadsheet->getDefaultStyle()->applyFromArray($defaultStyle);
// 写入数据
$row = 3;
foreach ($data as $item) {
$sheet->setCellValue('A' . $row, $order['order_id'])
->setCellValue('B' . $row, $order['one_name'])
->setCellValue('C' . $row, $order['type_name'])
->setCellValue('D' . $row, $order['two_name'])
->setCellValue('E' . $row, $item['store_name'])
->setCellValue('F' . $row, $item['nums'])
->setCellValue('G' . $row, $item['remark'])
->setCellValue('H' . $row, $item['create_time']);
$row++;
}
$count = count($data);
// 应用默认样式到整个工作表
// 设置单元格的样式
$styleArray = [
'font' => [
'bold' => true,
'size' => 16,
],
];
$sheet->getStyle('A1')->applyFromArray($styleArray);
// 定义线框样式
$styleArray = [
'borders' => [
'allBorders' => [
'borderStyle' => Border::BORDER_THIN, // 线框样式
'color' => ['argb' => '000000'], // 线框颜色
],
],
];
$sheet->getStyle('A1:H' . ($count + 2))->applyFromArray($styleArray);
// 保存文件到 public 下
$writer = new Xlsx($spreadsheet);
$url = '/export/' . "调拨订单-" . date('YmdHi') . '.xlsx';
$file_path = public_path() . $url;
if (!is_dir(dirname($file_path))) {
mkdir(dirname($file_path), 0777, true);
}
$writer->save($file_path);
return getenv('APP_URL') . $url;
}
}

View File

@ -48,10 +48,10 @@ class OrderSupplyOutbound
$sheet->setCellValue('B3', '品名'); $sheet->setCellValue('B3', '品名');
$sheet->setCellValue('C3', '单位'); $sheet->setCellValue('C3', '单位');
$sheet->setCellValue('D3', '数量'); $sheet->setCellValue('D3', '数量');
$sheet->setCellValue('E3', '出库单价'); $sheet->setCellValue('E3', '进货单价');
$sheet->setCellValue('F3', '出库总价'); $sheet->setCellValue('F3', '进货总价');
$sheet->setCellValue('G3', '供货价'); $sheet->setCellValue('G3', '零售单价');
$sheet->setCellValue('H3', '供货总价'); $sheet->setCellValue('H3', '零售总价');
$sheet->setCellValue('I3', '利润'); $sheet->setCellValue('I3', '利润');
$sheet->setCellValue('J3', '备注'); $sheet->setCellValue('J3', '备注');
@ -71,10 +71,10 @@ class OrderSupplyOutbound
$sheet->setCellValue('B' . ($k + 4), $v['store_name']); $sheet->setCellValue('B' . ($k + 4), $v['store_name']);
$sheet->setCellValue('C' . ($k + 4), $v['unit_name']); $sheet->setCellValue('C' . ($k + 4), $v['unit_name']);
$sheet->setCellValue('D' . ($k + 4), $v['nums']); $sheet->setCellValue('D' . ($k + 4), $v['nums']);
$sheet->setCellValue('E' . ($k + 4), $v['price']); $sheet->setCellValue('E' . ($k + 4), $v['purchase']);
$sheet->setCellValue('F' . ($k + 4), $v['total_price']); $sheet->setCellValue('F' . ($k + 4), $v['pay_price']);
$sheet->setCellValue('G' . ($k + 4), $v['purchase']); $sheet->setCellValue('G' . ($k + 4), $v['price']);
$sheet->setCellValue('H' . ($k + 4), $v['pay_price']); $sheet->setCellValue('H' . ($k + 4), $v['total_price']);
$sheet->setCellValue('I' . ($k + 4), $v['profit']); $sheet->setCellValue('I' . ($k + 4), $v['profit']);
$sheet->mergeCells('J' . ($k + 4) . ':K' . $k + 4); $sheet->mergeCells('J' . ($k + 4) . ':K' . $k + 4);
$sheet->setCellValue('J' . ($k + 4), $v['mark']); $sheet->setCellValue('J' . ($k + 4), $v['mark']);
@ -84,7 +84,7 @@ class OrderSupplyOutbound
$sheet->setCellValue('A' . ($count + 4),'合计'); $sheet->setCellValue('A' . ($count + 4),'合计');
$sheet->setCellValue('B' . ($count + 4),$count); $sheet->setCellValue('B' . ($count + 4),$count);
$sheet->setCellValue('J' . ($count + 4),$order['group_title']??''); // $sheet->setCellValue('J' . ($count + 4),$order['group_title']??'');
$sheet->setCellValue('A' . ($count + 5),'累计接单:'); $sheet->setCellValue('A' . ($count + 5),'累计接单:');
$sheet->setCellValue('C' . ($count + 5),'预收金额:'); $sheet->setCellValue('C' . ($count + 5),'预收金额:');

View File

@ -584,3 +584,30 @@ function SqlChannelPriceLog($product_id=0, $group_id=0, $before_price=0,$after_p
// return $orderId; // return $orderId;
// } // }
// } // }
if (!function_exists('list2tree')) {
function list2tree(array $list, $idKey = 'id', $parentKey = 'pid', $childrenKey = 'children')
{
$tree = [];
$itemsByReference = [];
// 首先将所有项目按id存入引用数组
foreach ($list as &$item) {
$itemsByReference[$item[$idKey]] = &$item;
$item[$childrenKey] = [];
}
// 构建树
foreach ($list as &$item) {
if ($item[$parentKey] && isset($itemsByReference[$item[$parentKey]])) {
$itemsByReference[$item[$parentKey]][$childrenKey][] = &$item;
} else {
$tree[] = &$item;
}
}
return $tree;
}
}

View File

@ -58,7 +58,8 @@
"picqer/php-barcode-generator": "^2.4", "picqer/php-barcode-generator": "^2.4",
"overtrue/easy-sms": "^2.6", "overtrue/easy-sms": "^2.6",
"phpoffice/phpword": "^1.3", "phpoffice/phpword": "^1.3",
"chance-fyi/operation-log": "^3.0" "chance-fyi/operation-log": "^3.0",
"tencentcloud/tencentcloud-sdk-php": "^3.0"
}, },
"suggest": { "suggest": {
"ext-event": "For better performance. " "ext-event": "For better performance. "

56
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "005401e7f7b2cce665fa8d6a9a1cb808", "content-hash": "e0a6dbafa795991cf0ffd520af434c5c",
"packages": [ "packages": [
{ {
"name": "aliyuncs/oss-sdk-php", "name": "aliyuncs/oss-sdk-php",
@ -6760,6 +6760,56 @@
}, },
"time": "2022-08-27T08:29:08+00:00" "time": "2022-08-27T08:29:08+00:00"
}, },
{
"name": "tencentcloud/tencentcloud-sdk-php",
"version": "3.0.1356",
"source": {
"type": "git",
"url": "https://github.com/TencentCloud/tencentcloud-sdk-php.git",
"reference": "927db31908964673afd2691528dda135e29c3e9a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/927db31908964673afd2691528dda135e29c3e9a",
"reference": "927db31908964673afd2691528dda135e29c3e9a",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": "^6.3 || ^7.0",
"php": ">=5.6.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"type": "library",
"autoload": {
"psr-4": {
"TencentCloud\\": "./src/TencentCloud"
},
"classmap": [
"src/QcloudApi/QcloudApi.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "coolli",
"email": "tencentcloudapi@tencent.com",
"homepage": "https://cloud.tencent.com/document/sdk/PHP",
"role": "Developer"
}
],
"description": "TencentCloudApi php sdk",
"homepage": "https://github.com/TencentCloud/tencentcloud-sdk-php",
"support": {
"issues": "https://github.com/TencentCloud/tencentcloud-sdk-php/issues",
"source": "https://github.com/TencentCloud/tencentcloud-sdk-php/tree/3.0.1356"
},
"time": "2025-04-07T20:07:18+00:00"
},
{ {
"name": "thenorthmemory/xml", "name": "thenorthmemory/xml",
"version": "1.1.1", "version": "1.1.1",
@ -8112,7 +8162,7 @@
"packages-dev": [], "packages-dev": [],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": {},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
@ -8120,6 +8170,6 @@
"ext-json": "*", "ext-json": "*",
"ext-bcmath": "*" "ext-bcmath": "*"
}, },
"platform-dev": [], "platform-dev": {},
"plugin-api-version": "2.6.0" "plugin-api-version": "2.6.0"
} }

1
public/output.text Normal file

File diff suppressed because one or more lines are too long

View File

@ -32,6 +32,11 @@ class InstalledVersions
*/ */
private static $installed; private static $installed;
/**
* @var bool
*/
private static $installedIsLocalDir;
/** /**
* @var bool|null * @var bool|null
*/ */
@ -309,6 +314,12 @@ class InstalledVersions
{ {
self::$installed = $data; self::$installed = $data;
self::$installedByVendor = array(); self::$installedByVendor = array();
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
// so we have to assume it does not, and that may result in duplicate data being returned when listing
// all installed packages for example
self::$installedIsLocalDir = false;
} }
/** /**
@ -322,19 +333,27 @@ class InstalledVersions
} }
$installed = array(); $installed = array();
$copiedLocalDir = false;
if (self::$canGetVendors) { if (self::$canGetVendors) {
$selfDir = strtr(__DIR__, '\\', '/');
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
$vendorDir = strtr($vendorDir, '\\', '/');
if (isset(self::$installedByVendor[$vendorDir])) { if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir]; $installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) { } elseif (is_file($vendorDir.'/composer/installed.php')) {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php'; $required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required; self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { $installed[] = $required;
self::$installed = $installed[count($installed) - 1]; if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
self::$installed = $required;
self::$installedIsLocalDir = true;
} }
} }
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
$copiedLocalDir = true;
}
} }
} }
@ -350,7 +369,7 @@ class InstalledVersions
} }
} }
if (self::$installed !== array()) { if (self::$installed !== array() && !$copiedLocalDir) {
$installed[] = self::$installed; $installed[] = self::$installed;
} }

View File

@ -21,6 +21,7 @@ return array(
'Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php', 'Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
'Override' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/Override.php', 'Override' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/Override.php',
'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', 'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php',
'QcloudApi' => $vendorDir . '/tencentcloud/tencentcloud-sdk-php/src/QcloudApi/QcloudApi.php',
'ReturnTypeWillChange' => $vendorDir . '/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php', 'ReturnTypeWillChange' => $vendorDir . '/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php',
'SQLite3Exception' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/SQLite3Exception.php', 'SQLite3Exception' => $vendorDir . '/symfony/polyfill-php83/Resources/stubs/SQLite3Exception.php',
'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', 'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',

View File

@ -7,7 +7,7 @@ $baseDir = dirname($vendorDir);
return array( return array(
'voku\\' => array($vendorDir . '/voku/portable-ascii/src/voku'), 'voku\\' => array($vendorDir . '/voku/portable-ascii/src/voku'),
'think\\' => array($vendorDir . '/topthink/think-container/src', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src'), 'think\\' => array($vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-container/src', $vendorDir . '/topthink/think-helper/src'),
'taoser\\' => array($vendorDir . '/taoser/webman-validate/src'), 'taoser\\' => array($vendorDir . '/taoser/webman-validate/src'),
'support\\' => array($vendorDir . '/workerman/webman-framework/src/support'), 'support\\' => array($vendorDir . '/workerman/webman-framework/src/support'),
'app\\View\\Components\\' => array($baseDir . '/app/view/components'), 'app\\View\\Components\\' => array($baseDir . '/app/view/components'),
@ -30,6 +30,7 @@ return array(
'Tinywan\\Storage\\' => array($vendorDir . '/tinywan/storage/src'), 'Tinywan\\Storage\\' => array($vendorDir . '/tinywan/storage/src'),
'Tinywan\\Jwt\\' => array($vendorDir . '/tinywan/jwt/src'), 'Tinywan\\Jwt\\' => array($vendorDir . '/tinywan/jwt/src'),
'TheNorthMemory\\Xml\\' => array($vendorDir . '/thenorthmemory/xml/src'), 'TheNorthMemory\\Xml\\' => array($vendorDir . '/thenorthmemory/xml/src'),
'TencentCloud\\' => array($vendorDir . '/tencentcloud/tencentcloud-sdk-php/src/TencentCloud'),
'Symfony\\Polyfill\\Php83\\' => array($vendorDir . '/symfony/polyfill-php83'), 'Symfony\\Polyfill\\Php83\\' => array($vendorDir . '/symfony/polyfill-php83'),
'Symfony\\Polyfill\\Php81\\' => array($vendorDir . '/symfony/polyfill-php81'), 'Symfony\\Polyfill\\Php81\\' => array($vendorDir . '/symfony/polyfill-php81'),
'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'), 'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
@ -86,7 +87,7 @@ return array(
'Invoker\\' => array($vendorDir . '/php-di/invoker/src'), 'Invoker\\' => array($vendorDir . '/php-di/invoker/src'),
'Intervention\\Image\\' => array($vendorDir . '/intervention/image/src'), 'Intervention\\Image\\' => array($vendorDir . '/intervention/image/src'),
'Intervention\\Gif\\' => array($vendorDir . '/intervention/gif/src'), 'Intervention\\Gif\\' => array($vendorDir . '/intervention/gif/src'),
'Illuminate\\Support\\' => array($vendorDir . '/illuminate/collections', $vendorDir . '/illuminate/conditionable', $vendorDir . '/illuminate/macroable', $vendorDir . '/illuminate/support'), 'Illuminate\\Support\\' => array($vendorDir . '/illuminate/support', $vendorDir . '/illuminate/collections', $vendorDir . '/illuminate/conditionable', $vendorDir . '/illuminate/macroable'),
'Illuminate\\Redis\\' => array($vendorDir . '/illuminate/redis'), 'Illuminate\\Redis\\' => array($vendorDir . '/illuminate/redis'),
'Illuminate\\Contracts\\' => array($vendorDir . '/illuminate/contracts'), 'Illuminate\\Contracts\\' => array($vendorDir . '/illuminate/contracts'),
'Hyperf\\Pimple\\' => array($vendorDir . '/hyperf/pimple/src'), 'Hyperf\\Pimple\\' => array($vendorDir . '/hyperf/pimple/src'),

View File

@ -91,6 +91,7 @@ class ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc
'Tinywan\\Storage\\' => 16, 'Tinywan\\Storage\\' => 16,
'Tinywan\\Jwt\\' => 12, 'Tinywan\\Jwt\\' => 12,
'TheNorthMemory\\Xml\\' => 19, 'TheNorthMemory\\Xml\\' => 19,
'TencentCloud\\' => 13,
), ),
'S' => 'S' =>
array ( array (
@ -235,9 +236,9 @@ class ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc
), ),
'think\\' => 'think\\' =>
array ( array (
0 => __DIR__ . '/..' . '/topthink/think-container/src', 0 => __DIR__ . '/..' . '/topthink/think-orm/src',
1 => __DIR__ . '/..' . '/topthink/think-helper/src', 1 => __DIR__ . '/..' . '/topthink/think-container/src',
2 => __DIR__ . '/..' . '/topthink/think-orm/src', 2 => __DIR__ . '/..' . '/topthink/think-helper/src',
), ),
'taoser\\' => 'taoser\\' =>
array ( array (
@ -327,6 +328,10 @@ class ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc
array ( array (
0 => __DIR__ . '/..' . '/thenorthmemory/xml/src', 0 => __DIR__ . '/..' . '/thenorthmemory/xml/src',
), ),
'TencentCloud\\' =>
array (
0 => __DIR__ . '/..' . '/tencentcloud/tencentcloud-sdk-php/src/TencentCloud',
),
'Symfony\\Polyfill\\Php83\\' => 'Symfony\\Polyfill\\Php83\\' =>
array ( array (
0 => __DIR__ . '/..' . '/symfony/polyfill-php83', 0 => __DIR__ . '/..' . '/symfony/polyfill-php83',
@ -554,10 +559,10 @@ class ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc
), ),
'Illuminate\\Support\\' => 'Illuminate\\Support\\' =>
array ( array (
0 => __DIR__ . '/..' . '/illuminate/collections', 0 => __DIR__ . '/..' . '/illuminate/support',
1 => __DIR__ . '/..' . '/illuminate/conditionable', 1 => __DIR__ . '/..' . '/illuminate/collections',
2 => __DIR__ . '/..' . '/illuminate/macroable', 2 => __DIR__ . '/..' . '/illuminate/conditionable',
3 => __DIR__ . '/..' . '/illuminate/support', 3 => __DIR__ . '/..' . '/illuminate/macroable',
), ),
'Illuminate\\Redis\\' => 'Illuminate\\Redis\\' =>
array ( array (
@ -718,6 +723,7 @@ class ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc
'Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php', 'Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
'Override' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/Override.php', 'Override' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/Override.php',
'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', 'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php',
'QcloudApi' => __DIR__ . '/..' . '/tencentcloud/tencentcloud-sdk-php/src/QcloudApi/QcloudApi.php',
'ReturnTypeWillChange' => __DIR__ . '/..' . '/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php', 'ReturnTypeWillChange' => __DIR__ . '/..' . '/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php',
'SQLite3Exception' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/SQLite3Exception.php', 'SQLite3Exception' => __DIR__ . '/..' . '/symfony/polyfill-php83/Resources/stubs/SQLite3Exception.php',
'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', 'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php',

View File

@ -6739,6 +6739,59 @@
}, },
"install-path": "../taoser/webman-validate" "install-path": "../taoser/webman-validate"
}, },
{
"name": "tencentcloud/tencentcloud-sdk-php",
"version": "3.0.1356",
"version_normalized": "3.0.1356.0",
"source": {
"type": "git",
"url": "https://github.com/TencentCloud/tencentcloud-sdk-php.git",
"reference": "927db31908964673afd2691528dda135e29c3e9a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/927db31908964673afd2691528dda135e29c3e9a",
"reference": "927db31908964673afd2691528dda135e29c3e9a",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": "^6.3 || ^7.0",
"php": ">=5.6.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"time": "2025-04-07T20:07:18+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"TencentCloud\\": "./src/TencentCloud"
},
"classmap": [
"src/QcloudApi/QcloudApi.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "coolli",
"email": "tencentcloudapi@tencent.com",
"homepage": "https://cloud.tencent.com/document/sdk/PHP",
"role": "Developer"
}
],
"description": "TencentCloudApi php sdk",
"homepage": "https://github.com/TencentCloud/tencentcloud-sdk-php",
"support": {
"issues": "https://github.com/TencentCloud/tencentcloud-sdk-php/issues",
"source": "https://github.com/TencentCloud/tencentcloud-sdk-php/tree/3.0.1356"
},
"install-path": "../tencentcloud/tencentcloud-sdk-php"
},
{ {
"name": "thenorthmemory/xml", "name": "thenorthmemory/xml",
"version": "1.1.1", "version": "1.1.1",

View File

@ -902,6 +902,15 @@
'aliases' => array(), 'aliases' => array(),
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'tencentcloud/tencentcloud-sdk-php' => array(
'pretty_version' => '3.0.1356',
'version' => '3.0.1356.0',
'reference' => '927db31908964673afd2691528dda135e29c3e9a',
'type' => 'library',
'install_path' => __DIR__ . '/../tencentcloud/tencentcloud-sdk-php',
'aliases' => array(),
'dev_requirement' => false,
),
'thenorthmemory/xml' => array( 'thenorthmemory/xml' => array(
'pretty_version' => '1.1.1', 'pretty_version' => '1.1.1',
'version' => '1.1.1.0', 'version' => '1.1.1.0',

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,230 @@
# 简介
欢迎使用腾讯云开发者工具套件SDK3.0SDK3.0是云 API3.0 平台的配套工具。
为方便 PHP 开发者调试和接入腾讯云产品 API这里向您介绍适用于 PHP 的腾讯云开发工具包,并提供首次使用开发工具包的简单示例。让您快速获取腾讯云 PHP SDK 并开始调用。
# 依赖环境
1. PHP 5.6.0 版本及以上
2. 从腾讯云控制台 开通相应产品
3. 获取 SecretID、SecretKey 以及调用地址endpointendpoint 一般形式为 \*.tencentcloudapi.com如CVM 的调用地址为 cvm.tencentcloudapi.com具体参考各产品说明。
# 获取安装
安装 PHP SDK 前先获取安全凭证。在第一次使用云API之前用户首先需要在腾讯云控制台上申请安全凭证安全凭证包括 SecretID 和 SecretKey SecretID 是用于标识 API 调用者的身份SecretKey是用于加密签名字符串和服务器端验证签名字符串的密钥。SecretKey 必须严格保管,避免泄露。
## 通过 Composer 安装
通过 Composer 获取安装是使用 PHP SDK 的推荐方法Composer 是 PHP 的依赖管理工具,支持您项目所需的依赖项,并将其安装到项目中。关于 Composer 详细可参考 Composer 官网 。
安装Composer
windows环境请访问[Composer官网](https://getcomposer.org/download/)下载安装包安装。
unix环境在命令行中执行以下命令安装。
> curl -sS https://getcomposer.org/installer | php
> sudo mv composer.phar /usr/local/bin/composer
### 安装指定产品 SDK推荐
例如:安装指定产品包
```bash
composer require tencentcloud/指定产品包名缩写 # 如 CVM 产品包tencentcloud/cvm
```
具体产品的包名缩写请参考 [products.md](./products.md) 中的包名字段。
### 安装全产品 SDK
```bash
composer require tencentcloud/tencentcloud-sdk-php
```
全产品 SDK 包含了所有云产品的调用代码,体积偏大,对体积敏感的场景,推荐安装指定产品 SDK。
### 注意事项
- 安装全产品 SDK 和安装指定产品的 SDK 两种方式只能选择其中一种。
- 如果同时安装多个产品的包,建议多个产品的包和 common 包保持在同一个版本。
- 无法使用官方源的的用户可以设置镜像源,例如:`composer config -g repos.packagist composer https://mirrors.tencent.com/composer/`
- 推荐使用固定的 SDK 版本开发测试和发布应用,例如 `composer require tencentcloud/cvm=xx.yy.zz`。如果不需要 phpunit 等开发依赖,可以指定 `--update-no-dev` 选项。
- 在代码中添加以下引用代码。注意如下仅为示例composer 会在项目根目录下生成 vendor 目录,`/path/to/`为项目根目录的实际绝对路径,如果是在当前目录执行,可以省略绝对路径。
> require '/path/to/vendor/autoload.php';
# 示例
推荐使用 [API 3.0 Explorer](https://console.cloud.tencent.com/api/explorer)提供在线调用、签名验证、SDK 代码生成和快速检索接口等能力,能显著降低使用云 API 3.0 和 SDK 的难度。
还可以参考 SDK 仓库中 [examples](https://github.com/TencentCloud/tencentcloud-sdk-php/tree/master/examples) 目录中的示例,展示了更多的用法。
下面以查询实例接口DescribeInstances为例:
### 简略版
```php
<?php
require_once '/path/to/vendor/autoload.php';
use TencentCloud\Cvm\V20170312\CvmClient;
use TencentCloud\Cvm\V20170312\Models\DescribeInstancesRequest;
use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Common\Credential;
try {
// 为了保护密钥安全,建议将密钥设置在环境变量中或者配置文件中。
// 硬编码密钥到代码中有可能随代码泄露而暴露,有安全隐患,并不推荐。
// $cred = new Credential("SecretId", "SecretKey");
$cred = new Credential(getenv("TENCENTCLOUD_SECRET_ID"),
getenv("TENCENTCLOUD_SECRET_KEY"));
$client = new CvmClient($cred, "ap-guangzhou");
$req = new DescribeInstancesRequest();
$resp = $client->DescribeInstances($req);
print_r($resp->toJsonString());
}
catch(TencentCloudSDKException $e) {
echo $e;
}
```
### 详细版
```php
<?php
require_once '/path/to/vendor/autoload.php';
// 导入对应产品模块的client
use TencentCloud\Cvm\V20170312\CvmClient;
// 导入要请求接口对应的Request类
use TencentCloud\Cvm\V20170312\Models\DescribeInstancesRequest;
use TencentCloud\Cvm\V20170312\Models\Filter;
use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Common\Credential;
// 导入可选配置类
use TencentCloud\Common\Profile\ClientProfile;
use TencentCloud\Common\Profile\HttpProfile;
try {
// 实例化一个证书对象,入参需要传入腾讯云账户 SecretIdSecretKey
// 为了保护密钥安全,建议将密钥设置在环境变量中或者配置文件中。
// 硬编码密钥到代码中有可能随代码泄露而暴露,有安全隐患,并不推荐。
// $cred = new Credential("SecretId", "SecretKey");
$cred = new Credential(getenv("TENCENTCLOUD_SECRET_ID"),
getenv("TENCENTCLOUD_SECRET_KEY"));
// 实例化一个http选项可选的没有特殊需求可以跳过
$httpProfile = new HttpProfile();
// 配置代理
// $httpProfile->setProxy("https://ip:port");
$httpProfile->setReqMethod("GET"); // post请求(默认为post请求)
$httpProfile->setReqTimeout(30); // 请求超时时间,单位为秒(默认60秒)
$httpProfile->setEndpoint("cvm.ap-shanghai.tencentcloudapi.com"); // 指定接入地域域名(默认就近接入)
// 实例化一个client选项可选的没有特殊需求可以跳过
$clientProfile = new ClientProfile();
$clientProfile->setSignMethod("TC3-HMAC-SHA256"); // 指定签名算法(默认为HmacSHA256)
$clientProfile->setHttpProfile($httpProfile);
// 实例化要请求产品(以cvm为例)的client对象,clientProfile是可选的
$client = new CvmClient($cred, "ap-shanghai", $clientProfile);
// 实例化一个cvm实例信息查询请求对象,每个接口都会对应一个request对象。
$req = new DescribeInstancesRequest();
// 填充请求参数,这里request对象的成员变量即对应接口的入参
// 您可以通过官网接口文档或跳转到request对象的定义处查看请求参数的定义
$respFilter = new Filter(); // 创建Filter对象, 以zone的维度来查询cvm实例
$respFilter->Name = "zone";
$respFilter->Values = ["ap-shanghai-1", "ap-shanghai-2"];
$req->Filters = [$respFilter]; // Filters 是成员为Filter对象的列表
// 通过client对象调用DescribeInstances方法发起请求。注意请求方法名与请求对象是对应的
// 返回的resp是一个DescribeInstancesResponse类的实例与请求对象对应
$resp = $client->DescribeInstances($req);
// 输出json格式的字符串回包
print_r($resp->toJsonString());
// 也可以取出单个值。
// 您可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
print_r($resp->TotalCount);
}
catch(TencentCloudSDKException $e) {
echo $e;
}
```
## Common Client
从 3.0.839 版本起,支持通用请求方式 Common Client可以发起 SDK 中未定义的接口请求。
注意:目前仅支持 POST 方法,签名方法仅支持签名方法 v3。
请参考 [调用示例](https://github.com/TencentCloud/tencentcloud-sdk-php/tree/master/examples/common/CommonClient.php)
# 常见问题
## 代理
如果是有代理的环境下,需要设置系统环境变量 `https_proxy` ,否则可能无法正常调用,抛出连接超时的异常。
或者使用 GuzzleHttp 代理配置:
```php
$httpProfile = new HttpProfile();
$httpProfile->setProxy('https://ip:port');
$clientProfile = new ClientProfile();
$clientProfile->setHttpProfile($httpProfile);
$client = new OcrClient($cred, 'ap-beijing', $this->clientProfile);
```
## 地域容灾
`3.0.933`起 腾讯云 Php SDK 支持地域容灾,当某个域名请求失败时,会自动切换到容灾域名。使用方式如下:
使用地域时有三种状态相互转换:关闭、全开和半开状态
关闭:使用主要域名请求,如果出现错误时,会切换到全开状态
全开:使用容灾域名请求,当达到一定时间时,会切换到半开状态
半开:此时会放少量的请求到主要域名,如果请求失败,则切换到全开状态,当请求成功数达到一定的数量时,会切换到关闭状态
相关设置如下
```php
use TencentCloud\Common\Profile\RegionBreakerProfile;
// 开启地域容灾
$clientProfile->enableRegionBreaker=true;
// 设置主备节点以cvm产品为例假设主节点在上海备节点在北京则配置如下
$regionBreakerProfile = new RegionBreakerProfile(
"cvm.ap-shanghai.tencentcloudapi.com", // 主节点
"cvm.ap-beijing.tencentcloudapi.com" // 备节点
);
$clientProfile->setRegionBreakerProfile($regionBreakerProfile);
```
## 证书问题
如果您的 PHP 环境证书有问题,可能会遇到报错,类似于 `cURL error 60: See http://curl.haxx.se/libcurl/c/libcurl-errors.html`,请尝试按如下步骤解决:
1. 到 [https://curl.haxx.se/ca/cacert.pem](https://curl.haxx.se/ca/cacert.pem) 下载证书文件 `cacert.pem`,将其保存到 PHP 安装路径下。
2. 编辑 `php.ini` 文件,删除 `curl.cainfo` 配置项前的分号注释符(;),值设置为保存的证书文件 `cacert.pem` 的绝对路径。
3. 重启依赖 PHP 的服务。
## php_curl 扩展
此 SDK 依赖的 GuzzleHttp 需要开启 php_curl 扩展,查看环境上的 php.ini 环境确认是否已启用,例如在 Linux 环境下PHP 7.1 版本,托管在 apache 下的服务,可以打开 /etc/php/7.1/apache2/php.ini 中查看 extension=php_curl.dll 配置项是否已被注释,请删除此项配置前的注释符并重启 apache。
## Web 访问异常
命令行下执行正常,但是放在 Web 服务器执行则报错:
cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
此问题出现情况不一。可以运行 `php -r "echo sys_get_temp_dir();"` 打印系统默认临时目录绝对路径,然后在 `php.ini` 配置 `sys_temp_dir` 为这个值尝试是否能解决。
## 源码安装问题
为了支持部分源码安装的需要,我们将依赖的包文件放在 vendor 目录中,又考虑到不能造成对 composer 的不兼容github 不得不设置禁止导出 vendor 目录,造成必须使用 `git clone` 命令才能拿到 vendor 目录的情况,对一些不熟悉 github 的用户造成了困扰。从 3.0.188 版本开始,我们暂时移除了源码安装,必须使用 composer 安装 SDK 和依赖的包。
## 关键字冲突问题
目前已知在 PHP 7.x 版本中,由于关键字冲突,弹性伸缩产品对应的 As 模块可能无法使用。可以考虑升级到 SDK 3.0.362 版本,使用 Autoscaling 模块。或者升级到 PHP 8 版本。
## 内存泄漏问题
如果使用 SDK 对接口进行循环调用,如:
```
while (true) {
$resp = $client->DescribeInstances($req);
}
```
可以看到进程占用的内存持续少量上涨,这是 SDK 依赖的 GuzzleHttp 存在[内存泄漏的问题](https://github.com/guzzle/guzzle/issues/2830),目前官方还未修复。
# 旧版SDK
新版 SDK 兼容旧版 SDK。旧版本的SDK存放于QcloudApi目录但不再维护更新推荐使用新版SDK。

View File

@ -0,0 +1,30 @@
{
"name": "tencentcloud/tencentcloud-sdk-php",
"description": "TencentCloudApi php sdk",
"type": "library",
"homepage": "https://github.com/TencentCloud/tencentcloud-sdk-php",
"license": "Apache-2.0",
"authors": [
{
"name": "coolli",
"email": "tencentcloudapi@tencent.com",
"homepage": "https://cloud.tencent.com/document/sdk/PHP",
"role": "Developer"
}
],
"require": {
"php": ">=5.6.0",
"guzzlehttp/guzzle": "^6.3 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"autoload": {
"classmap": [
"src/QcloudApi/QcloudApi.php"
],
"psr-4": {
"TencentCloud\\": "./src/TencentCloud"
}
}
}

View File

@ -0,0 +1,262 @@
| 包名 | 产品中文名 | 更新时间 |
|-|-|-|
| aai | [](https://cloud.tencent.com/document/product) | 2019-08-08 23:15:13 |
| aca | [AI 临床助手](https://cloud.tencent.com/document/product/1388) | 2025-01-09 01:08:36 |
| acp | [应用合规平台](https://cloud.tencent.com/document/product/1553) | 2025-03-14 01:07:24 |
| advisor | [云顾问](https://cloud.tencent.com/document/product/1264) | 2025-03-25 01:07:48 |
| af | [借贷反欺诈](https://cloud.tencent.com/document/product/668) | 2024-11-22 11:20:38 |
| afc | [定制建模](https://cloud.tencent.com/document/product/1029) | 2024-05-31 01:07:25 |
| aiart | [大模型图像创作引擎](https://cloud.tencent.com/document/product/1668) | 2025-03-10 17:35:02 |
| ame | [正版曲库直通车](https://cloud.tencent.com/document/product/1155) | 2023-08-17 01:06:14 |
| ams | [音频内容安全](https://cloud.tencent.com/document/product/1219) | 2025-03-04 01:07:37 |
| anicloud | [动效素材服务](https://cloud.tencent.com/document/product/1641) | 2023-05-18 01:01:53 |
| antiddos | [T-Sec-DDoS防护(Anti-DDoS)](https://cloud.tencent.com/document/product/297) | 2025-03-31 01:07:28 |
| apcas | [汽车精准获客服务](https://cloud.tencent.com/document/product/1244) | 2022-04-04 06:05:36 |
| ape | [正版图库直通车](https://cloud.tencent.com/document/product/1181) | 2022-04-04 06:05:40 |
| api | [云 API](https://cloud.tencent.com/document/product/1278) | 2023-01-05 01:02:52 |
| apigateway | [API 网关](https://cloud.tencent.com/document/product/628) | 2025-03-28 01:08:35 |
| apm | [应用性能监控](https://cloud.tencent.com/document/product/1463) | 2025-03-24 01:09:19 |
| as | [弹性伸缩](https://cloud.tencent.com/document/product/377) | 2025-03-28 01:09:24 |
| asr | [语音识别](https://cloud.tencent.com/document/product/1093) | 2025-03-19 01:10:31 |
| asw | [应用与服务编排工作流](https://cloud.tencent.com/document/product/1272) | 2023-05-18 01:04:02 |
| ba | [ICP备案](https://cloud.tencent.com/document/product/243) | 2024-12-19 01:10:53 |
| batch | [批量计算](https://cloud.tencent.com/document/product/599) | 2025-04-02 01:08:33 |
| bda | [人体分析](https://cloud.tencent.com/document/product/1208) | 2024-11-14 01:10:31 |
| bh | [运维安全中心(堡垒机)](https://cloud.tencent.com/document/product/1025) | 2025-04-03 01:08:29 |
| bi | [商业智能分析 BI](https://cloud.tencent.com/document/product/590) | 2025-04-02 01:08:56 |
| billing | [费用中心](https://cloud.tencent.com/document/product/555) | 2025-03-20 01:11:13 |
| bizlive | [商业直播](https://cloud.tencent.com/document/product) | 2020-03-10 01:08:07 |
| bm | [黑石物理服务器CPM](https://cloud.tencent.com/document/product/386) | 2024-03-20 01:08:40 |
| bma | [品牌经营管家](https://cloud.tencent.com/document/product/1296) | 2024-10-18 01:04:14 |
| bmeip | [黑石弹性公网IP](https://cloud.tencent.com/document/product/1028) | 2024-03-20 01:08:53 |
| bmlb | [黑石负载均衡](https://cloud.tencent.com/document/product/1027) | 2024-03-20 01:08:56 |
| bmvpc | [黑石私有网络](https://cloud.tencent.com/document/product/1024) | 2024-03-20 01:09:02 |
| bpaas | [商业流程服务](https://cloud.tencent.com/document/product/1083) | 2024-11-29 01:10:03 |
| bri | [业务风险情报](https://cloud.tencent.com/document/product/1064) | 2024-06-19 01:13:52 |
| bsca | [软件成分分析](https://cloud.tencent.com/document/product/1483) | 2024-11-27 01:09:19 |
| btoe | [区块链可信取证](https://cloud.tencent.com/document/product/1259) | 2024-11-06 15:27:32 |
| ca | [腾讯云CA](https://cloud.tencent.com/document/product/1691) | 2025-01-16 01:08:56 |
| cam | [访问管理](https://cloud.tencent.com/document/product/598) | 2025-04-02 01:09:26 |
| captcha | [验证码](https://cloud.tencent.com/document/product/1110) | 2025-03-27 01:08:19 |
| car | [应用云渲染](https://cloud.tencent.com/document/product/1547) | 2024-12-27 10:53:11 |
| cat | [云拨测](https://cloud.tencent.com/document/product/280) | 2025-03-07 01:09:25 |
| cbs | [云硬盘](https://cloud.tencent.com/document/product/362) | 2025-04-02 01:09:47 |
| ccc | [云联络中心](https://cloud.tencent.com/document/product/679) | 2025-03-31 01:09:33 |
| cdb | [云数据库 MySQL](https://cloud.tencent.com/document/product/236) | 2025-03-28 01:13:58 |
| cdc | [本地专用集群](https://cloud.tencent.com/document/product/1346) | 2025-03-28 01:15:04 |
| cdn | [内容分发网络 CDN](https://cloud.tencent.com/document/product/228) | 2025-04-02 01:10:33 |
| cds | [T-Sec-数据安全审计DSA](https://cloud.tencent.com/document/product/856) | 2024-11-08 01:17:02 |
| cdwch | [腾讯云数据仓库TCHouse-C](https://cloud.tencent.com/document/product/1299) | 2025-03-24 01:16:39 |
| cdwdoris | [腾讯云数据仓库 TCHouse-D](https://cloud.tencent.com/document/product/1387) | 2025-03-28 01:16:20 |
| cdwpg | [云数据仓库 PostgreSQL](https://cloud.tencent.com/document/product/878) | 2025-03-27 01:12:24 |
| cdz | [专属可用区](https://cloud.tencent.com/document/product/1629) | 2025-03-28 01:16:55 |
| cfg | [混沌演练平台](https://cloud.tencent.com/document/product/1500) | 2025-04-02 01:11:14 |
| cfs | [文件存储](https://cloud.tencent.com/document/product/582) | 2025-03-28 01:17:07 |
| cfw | [云防火墙](https://cloud.tencent.com/document/product/1132) | 2025-04-04 01:11:14 |
| chc | [云托付物理服务器](https://cloud.tencent.com/document/product/1448) | 2025-03-28 01:18:07 |
| chdfs | [云 HDFS](https://cloud.tencent.com/document/product/1105) | 2025-04-02 01:11:44 |
| ciam | [账号风控平台](https://cloud.tencent.com/document/product/1441) | 2025-03-07 01:11:06 |
| cii | [智能保险助手](https://cloud.tencent.com/document/product/1368) | 2023-05-18 01:12:07 |
| cim | [](https://cloud.tencent.com/document/product) | 2019-05-16 17:21:18 |
| cis | [](https://cloud.tencent.com/document/product) | 2018-06-07 15:01:42 |
| ckafka | [消息队列 CKafka 版](https://cloud.tencent.com/document/product/597) | 2025-04-03 01:11:25 |
| clb | [负载均衡](https://cloud.tencent.com/document/product/214) | 2025-04-03 01:11:40 |
| cloudapp | [云应用](https://cloud.tencent.com/document/product/1689) | 2025-01-09 01:12:37 |
| cloudaudit | [操作审计](https://cloud.tencent.com/document/product/629) | 2025-03-26 01:21:06 |
| cloudhsm | [云加密机](https://cloud.tencent.com/document/product/639) | 2024-11-28 10:52:49 |
| cloudstudio | [Cloud Studio云端 IDE](https://cloud.tencent.com/document/product/1039) | 2025-02-28 01:15:03 |
| cls | [日志服务](https://cloud.tencent.com/document/product/614) | 2025-04-08 01:11:58 |
| cme | [多媒体创作引擎](https://cloud.tencent.com/document/product/1156) | 2025-03-27 20:17:54 |
| cmq | [消息队列 CMQ](https://cloud.tencent.com/document/product/406) | 2025-03-14 01:12:04 |
| cms | [内容安全](https://cloud.tencent.com/document/product/669) | 2024-06-20 01:24:47 |
| config | [配置审计](https://cloud.tencent.com/document/product/1579) | 2025-01-15 01:11:56 |
| controlcenter | [控制中心](https://cloud.tencent.com/document/product/1708) | 2025-04-02 01:12:54 |
| cpdp | [企业收付平台](https://cloud.tencent.com/document/product/1122) | 2023-09-21 02:09:54 |
| csip | [云安全一体化平台](https://cloud.tencent.com/document/product/664) | 2025-03-07 01:12:16 |
| csxg | [5G入云服务](https://cloud.tencent.com/document/product/1687) | 2024-03-20 01:12:25 |
| cvm | [云服务器](https://cloud.tencent.com/document/product/213) | 2025-04-01 01:13:17 |
| cwp | [主机安全](https://cloud.tencent.com/document/product/296) | 2025-04-03 18:32:35 |
| cws | [漏洞扫描服务](https://cloud.tencent.com/document/product) | 2019-11-22 12:16:15 |
| cynosdb | [TDSQL-C MySQL 版](https://cloud.tencent.com/document/product/1003) | 2025-03-31 01:14:08 |
| dasb | [运维安全中心(堡垒机)](https://cloud.tencent.com/document/product/1025) | 2024-11-19 01:26:13 |
| dataintegration | [数据接入平台](https://cloud.tencent.com/document/product/1591) | 2022-07-26 15:32:15 |
| dayu | [DDoS 高防包](https://cloud.tencent.com/document/product/1021) | 2023-05-18 01:20:11 |
| dbbrain | [数据库智能管家 DBbrain](https://cloud.tencent.com/document/product/1130) | 2025-04-02 01:15:06 |
| dbdc | [云数据库独享集群](https://cloud.tencent.com/document/product/1322) | 2025-03-27 01:23:17 |
| dc | [专线接入](https://cloud.tencent.com/document/product/216) | 2025-02-24 01:26:07 |
| dcdb | [TDSQL MySQL 版](https://cloud.tencent.com/document/product/557) | 2025-04-02 01:15:36 |
| dlc | [数据湖计算 DLC](https://cloud.tencent.com/document/product/1342) | 2025-04-01 01:15:35 |
| dnspod | [DNSPod](https://cloud.tencent.com/document/product/1427) | 2025-04-02 01:16:18 |
| domain | [域名注册](https://cloud.tencent.com/document/product/242) | 2025-03-28 01:29:59 |
| drm | [数字版权管理](https://cloud.tencent.com/document/product/1000) | 2025-01-09 01:16:10 |
| ds | [文档服务](https://cloud.tencent.com/document/product/869) | 2024-03-20 01:15:13 |
| dsgc | [数据安全治理中心](https://cloud.tencent.com/document/product/1087) | 2025-03-20 20:20:10 |
| dtf | [分布式事务](https://cloud.tencent.com/document/product/1224) | 2022-04-04 06:38:57 |
| dts | [数据传输服务](https://cloud.tencent.com/document/product/571) | 2025-04-02 16:33:03 |
| eb | [事件总线](https://cloud.tencent.com/document/product/1359) | 2025-03-25 15:22:50 |
| ecc | [英文作文批改](https://cloud.tencent.com/document/product/1076) | 2024-09-05 01:32:54 |
| ecdn | [全站加速网络](https://cloud.tencent.com/document/product/570) | 2025-03-28 01:32:15 |
| ecm | [边缘计算机器](https://cloud.tencent.com/document/product/1108) | 2025-01-10 01:15:40 |
| eiam | [数字身份管控平台(员工版)](https://cloud.tencent.com/document/product/1442) | 2024-06-25 01:14:34 |
| eis | [数据连接器](https://cloud.tencent.com/document/product/1270) | 2023-08-10 01:17:44 |
| emr | [弹性 MapReduce](https://cloud.tencent.com/document/product/589) | 2025-03-28 01:33:26 |
| es | [Elasticsearch Service](https://cloud.tencent.com/document/product/845) | 2025-03-18 01:35:57 |
| ess | [腾讯电子签企业版](https://cloud.tencent.com/document/product/1323) | 2025-04-01 01:17:53 |
| essbasic | [腾讯电子签(基础版)](https://cloud.tencent.com/document/product/1420) | 2025-04-01 01:18:12 |
| facefusion | [人脸融合](https://cloud.tencent.com/document/product/670) | 2025-04-02 01:18:44 |
| faceid | [人脸核身](https://cloud.tencent.com/document/product/1007) | 2025-02-28 01:30:36 |
| fmu | [人脸试妆](https://cloud.tencent.com/document/product/1172) | 2025-03-20 01:38:20 |
| ft | [人像变换](https://cloud.tencent.com/document/product/1202) | 2024-11-21 01:34:23 |
| gaap | [全球应用加速](https://cloud.tencent.com/document/product/608) | 2025-01-09 01:18:35 |
| gme | [游戏多媒体引擎](https://cloud.tencent.com/document/product/607) | 2025-02-21 01:35:33 |
| goosefs | [数据加速器 GooseFS](https://cloud.tencent.com/document/product/1424) | 2025-03-20 01:39:23 |
| gpm | [游戏玩家匹配](https://cloud.tencent.com/document/product/1294) | 2022-07-11 06:12:36 |
| gs | [云游戏](https://cloud.tencent.com/document/product/1162) | 2025-04-08 01:17:33 |
| gse | [游戏服务器伸缩](https://cloud.tencent.com/document/product/1165) | 2022-07-11 06:12:44 |
| gwlb | [网关负载均衡](https://cloud.tencent.com/document/product/1782) | 2025-03-28 01:37:42 |
| habo | [](https://cloud.tencent.com/document/product) | 2019-05-09 19:37:22 |
| hai | [高性能应用服务](https://cloud.tencent.com/document/product/1721) | 2025-04-01 01:19:03 |
| hasim | [高可用物联网卡](https://cloud.tencent.com/document/product/1482) | 2023-05-18 01:29:47 |
| hcm | [数学作业批改](https://cloud.tencent.com/document/product/1004) | 2024-05-09 01:16:27 |
| hunyuan | [腾讯混元大模型](https://cloud.tencent.com/document/product/1729) | 2025-03-27 01:34:12 |
| iai | [人脸识别](https://cloud.tencent.com/document/product/867) | 2024-12-27 11:13:24 |
| iap | [身份识别平台](https://cloud.tencent.com/document/product/1787) | 2025-03-26 01:41:04 |
| ic | [图片瘦身](https://cloud.tencent.com/document/product/636) | 2023-03-02 01:23:21 |
| icr | [对话机器人](https://cloud.tencent.com/document/product/1268) | 2024-04-22 01:17:48 |
| ie | [智能编辑](https://cloud.tencent.com/document/product/1186) | 2023-08-17 03:20:18 |
| iecp | [物联网边缘计算平台](https://cloud.tencent.com/document/product/1118) | 2024-09-25 01:22:07 |
| ig | [智能导诊](https://cloud.tencent.com/document/product/1273) | 2024-11-21 01:36:39 |
| iir | [智能识图](https://cloud.tencent.com/document/product/1217) | 2022-04-04 06:48:05 |
| ims | [图片内容安全](https://cloud.tencent.com/document/product/1125) | 2025-03-28 01:38:47 |
| ioa | [iOA 零信任安全管理系统](https://cloud.tencent.com/document/product/1092) | 2025-02-21 01:37:05 |
| iot | [加速物联网套件](https://cloud.tencent.com/document/product/568) | 2023-07-17 01:22:28 |
| iotcloud | [物联网通信](https://cloud.tencent.com/document/product/634) | 2025-04-01 01:19:27 |
| iotexplorer | [物联网开发平台](https://cloud.tencent.com/document/product/1081) | 2025-04-08 01:18:12 |
| iottid | [物联网设备身份认证](https://cloud.tencent.com/document/product/1086) | 2023-05-18 01:33:02 |
| iotvideo | [物联网智能视频服务](https://cloud.tencent.com/document/product/1131) | 2025-03-28 01:41:10 |
| iotvideoindustry | [物联网智能视频服务(行业版)](https://cloud.tencent.com/document/product/1361) | 2025-04-07 01:39:24 |
| irp | [智能推荐平台](https://cloud.tencent.com/document/product/1541) | 2024-10-17 01:22:29 |
| iss | [智能视图计算平台](https://cloud.tencent.com/document/product/1344) | 2025-04-02 01:21:10 |
| ivld | [媒体智能标签](https://cloud.tencent.com/document/product/1509) | 2024-12-16 01:41:44 |
| keewidb | [云数据库 KeeWiDB](https://cloud.tencent.com/document/product/1520) | 2025-03-10 01:41:29 |
| kms | [密钥管理系统](https://cloud.tencent.com/document/product/573) | 2025-03-14 01:19:50 |
| lcic | [实时互动-教育版](https://cloud.tencent.com/document/product/1639) | 2025-03-26 01:46:29 |
| lighthouse | [轻量应用服务器](https://cloud.tencent.com/document/product/1207) | 2025-03-31 01:21:08 |
| live | [云直播CSS](https://cloud.tencent.com/document/product/267) | 2025-04-01 01:21:49 |
| lke | [大模型知识引擎](https://cloud.tencent.com/document/product/1759) | 2025-03-31 01:21:48 |
| lkeap | [知识引擎原子能力](https://cloud.tencent.com/document/product/1772) | 2025-04-08 01:20:34 |
| lowcode | [云开发低码](https://cloud.tencent.com/document/product/1301) | 2025-03-20 01:49:29 |
| mall | [商场客留大数据](https://cloud.tencent.com/document/product/1707) | 2024-03-20 01:20:11 |
| mariadb | [云数据库 MariaDB](https://cloud.tencent.com/document/product/237) | 2025-04-02 01:23:06 |
| market | [云市场](https://cloud.tencent.com/document/product/306) | 2024-11-25 01:21:47 |
| memcached | [云数据库Memcached](https://cloud.tencent.com/document/product/241) | 2025-03-24 01:49:27 |
| mgobe | [游戏联机对战引擎](https://cloud.tencent.com/document/product/1038) | 2022-07-08 06:11:32 |
| mmps | [小程序安全](https://cloud.tencent.com/document/product/1223) | 2025-03-28 01:47:29 |
| mna | [多网聚合加速](https://cloud.tencent.com/document/product/1385) | 2025-04-08 01:20:55 |
| mongodb | [云数据库 MongoDB](https://cloud.tencent.com/document/product/240) | 2025-03-28 01:48:00 |
| monitor | [腾讯云可观测平台](https://cloud.tencent.com/document/product/248) | 2025-02-18 23:57:24 |
| mps | [媒体处理](https://cloud.tencent.com/document/product/862) | 2025-04-02 01:24:01 |
| mqtt | [消息队列 MQTT 版](https://cloud.tencent.com/document/product/1778) | 2025-04-02 01:24:29 |
| mrs | [医疗报告结构化](https://cloud.tencent.com/document/product/1314) | 2024-12-12 01:48:36 |
| ms | [移动应用安全](https://cloud.tencent.com/document/product/283) | 2024-11-14 01:54:52 |
| msp | [迁移服务平台](https://cloud.tencent.com/document/product/659) | 2024-12-25 01:51:10 |
| mvj | [营销价值判断](https://cloud.tencent.com/document/product) | 2020-03-19 08:11:44 |
| nlp | [NLP 技术](https://cloud.tencent.com/document/product/271) | 2025-01-14 01:21:36 |
| npp | [号码保护](https://cloud.tencent.com/document/product) | 2020-04-22 08:00:22 |
| oceanus | [流计算 Oceanus](https://cloud.tencent.com/document/product/849) | 2025-03-12 01:22:00 |
| ocr | [文字识别](https://cloud.tencent.com/document/product/866) | 2025-04-04 01:23:59 |
| omics | [腾讯健康组学平台](https://cloud.tencent.com/document/product/1643) | 2024-12-25 01:52:29 |
| organization | [集团账号管理](https://cloud.tencent.com/document/product/850) | 2025-04-02 01:25:20 |
| partners | [渠道合作伙伴](https://cloud.tencent.com/document/product/563) | 2025-04-01 10:32:48 |
| pds | [私域安全](https://cloud.tencent.com/document/product/1473) | 2023-05-18 01:44:14 |
| postgres | [云数据库 PostgreSQL](https://cloud.tencent.com/document/product/409) | 2025-03-28 01:53:55 |
| privatedns | [私有域解析 Private DNS](https://cloud.tencent.com/document/product/1338) | 2025-03-27 01:51:08 |
| pts | [云压测](https://cloud.tencent.com/document/product/1484) | 2025-03-07 01:23:46 |
| rce | [全栈式风控引擎](https://cloud.tencent.com/document/product/1343) | 2025-03-28 14:27:40 |
| redis | [云数据库Redis](https://cloud.tencent.com/document/product/239) | 2025-03-28 01:55:05 |
| region | [地域管理系统](https://cloud.tencent.com/document/product/1596) | 2025-03-28 01:55:44 |
| rum | [前端性能监控](https://cloud.tencent.com/document/product/1464) | 2025-03-14 01:24:07 |
| scf | [云函数](https://cloud.tencent.com/document/product/583) | 2025-03-28 01:56:14 |
| ses | [邮件推送](https://cloud.tencent.com/document/product/1288) | 2025-03-18 02:00:38 |
| smh | [智能媒资托管](https://cloud.tencent.com/document/product/1339) | 2025-03-13 01:55:19 |
| smop | [腾讯安心用户运营平台](https://cloud.tencent.com/document/product/1310) | 2025-02-13 01:55:34 |
| smpn | [营销号码安全](https://cloud.tencent.com/document/product/1127) | 2024-07-09 01:21:06 |
| sms | [短信](https://cloud.tencent.com/document/product/382) | 2025-03-07 01:24:40 |
| soe | [智聆口语评测](https://cloud.tencent.com/document/product/884) | 2024-11-13 02:01:41 |
| solar | [智汇零售](https://cloud.tencent.com/document/product) | 2020-03-19 08:01:59 |
| sqlserver | [云数据库 SQL Server](https://cloud.tencent.com/document/product/238) | 2025-04-02 01:27:02 |
| ssa | [安全运营中心](https://cloud.tencent.com/document/product/664) | 2023-11-15 02:18:28 |
| ssl | [SSL 证书](https://cloud.tencent.com/document/product/400) | 2025-03-28 01:58:23 |
| sslpod | [证书监控 SSLPod](https://cloud.tencent.com/document/product/1084) | 2024-03-20 01:24:03 |
| ssm | [凭据管理系统](https://cloud.tencent.com/document/product/1140) | 2024-11-08 02:01:05 |
| sts | [安全凭证服务](https://cloud.tencent.com/document/product/1312) | 2025-03-28 01:59:08 |
| svp | [节省计划](https://cloud.tencent.com/document/product/1761) | 2025-03-24 02:01:25 |
| taf | [流量反欺诈](https://cloud.tencent.com/document/product/1031) | 2025-03-27 01:55:50 |
| tag | [标签](https://cloud.tencent.com/document/product/651) | 2025-03-28 01:59:18 |
| tan | [碳引擎](https://cloud.tencent.com/document/product/1498) | 2024-03-20 01:24:15 |
| tat | [自动化助手](https://cloud.tencent.com/document/product/1340) | 2025-03-26 02:03:49 |
| tav | [文件检测](https://cloud.tencent.com/document/product) | 2019-11-28 22:10:04 |
| tbaas | [腾讯云区块链服务平台 TBaaS](https://cloud.tencent.com/document/product/663) | 2025-03-27 01:56:21 |
| tbm | [](https://cloud.tencent.com/document/product) | 2019-03-29 14:49:11 |
| tbp | [腾讯智能对话平台](https://cloud.tencent.com/document/product/1060) | 2024-03-20 01:24:24 |
| tcaplusdb | [游戏数据库 TcaplusDB](https://cloud.tencent.com/document/product/596) | 2024-08-05 02:05:20 |
| tcb | [云开发 CloudBase](https://cloud.tencent.com/document/product/876) | 2025-04-02 01:28:03 |
| tcbr | [云托管 CloudBase Run](https://cloud.tencent.com/document/product/1243) | 2025-02-28 01:54:37 |
| tccatalog | [统一Catalog服务](https://cloud.tencent.com/document/product/1784) | 2025-02-10 01:57:53 |
| tcex | [腾讯云释义](https://cloud.tencent.com/document/product/1266) | 2022-07-21 06:17:29 |
| tchd | [腾讯云健康看板](https://cloud.tencent.com/document/product/1688) | 2025-03-25 02:03:27 |
| tci | [腾讯智学课堂分析](https://cloud.tencent.com/document/product) | 2020-08-24 08:06:03 |
| tcm | [服务网格](https://cloud.tencent.com/document/product/1261) | 2025-01-06 01:25:44 |
| tcr | [容器镜像服务](https://cloud.tencent.com/document/product/1141) | 2025-03-28 02:01:20 |
| tcss | [容器安全服务](https://cloud.tencent.com/document/product/1285) | 2025-04-03 18:33:40 |
| tdcpg | [TDSQL-C PostgreSQL 版](https://cloud.tencent.com/document/product/1556) | 2025-03-20 12:23:05 |
| tdid | [分布式身份](https://cloud.tencent.com/document/product/1439) | 2025-03-28 02:04:11 |
| tdmq | [消息队列 TDMQ](https://cloud.tencent.com/document/product/1179) | 2025-04-01 01:29:00 |
| tds | [设备安全](https://cloud.tencent.com/document/product/1628) | 2025-03-13 02:01:24 |
| tem | [弹性微服务](https://cloud.tencent.com/document/product/1371) | 2024-12-31 01:29:59 |
| teo | [边缘安全加速平台](https://cloud.tencent.com/document/product/1552) | 2025-04-03 01:29:26 |
| thpc | [高性能计算平台](https://cloud.tencent.com/document/product/1527) | 2025-03-28 02:07:07 |
| tia | [智能钛机器学习](https://cloud.tencent.com/document/product/851) | 2021-10-21 11:12:52 |
| tic | [资源编排 TIC](https://cloud.tencent.com/document/product/1213) | 2023-08-17 05:26:08 |
| ticm | [智能鉴黄](https://cloud.tencent.com/document/product/864) | 2021-01-07 08:08:15 |
| tics | [威胁情报云查服务](https://cloud.tencent.com/document/product/1013) | 2024-03-20 01:27:08 |
| tiems | [腾讯云 TI 平台 TI-EMS ](https://cloud.tencent.com/document/product/1120) | 2022-07-19 06:19:39 |
| tiia | [图像分析](https://cloud.tencent.com/document/product/865) | 2024-12-23 11:03:45 |
| tione | [TI-ONE 训练平台](https://cloud.tencent.com/document/product/851) | 2025-04-03 01:29:58 |
| tiw | [互动白板](https://cloud.tencent.com/document/product/1137) | 2025-03-14 18:22:24 |
| tke | [容器服务](https://cloud.tencent.com/document/product/457) | 2025-03-28 02:09:13 |
| tkgdq | [腾讯知识图谱数据查询](https://cloud.tencent.com/document/product) | 2020-03-10 00:51:44 |
| tms | [文本内容安全](https://cloud.tencent.com/document/product/1124) | 2025-03-07 01:28:04 |
| tmt | [机器翻译](https://cloud.tencent.com/document/product/551) | 2025-03-28 02:09:24 |
| tourism | [文旅客情大数据](https://cloud.tencent.com/document/product/1684) | 2024-03-20 01:28:59 |
| trabbit | [消息队列 RabbitMQ Serverless 版](https://cloud.tencent.com/document/product/1495) | 2025-02-21 02:04:45 |
| trdp | [流量风险决策平台](https://cloud.tencent.com/document/product/1604) | 2023-05-18 02:01:19 |
| trocket | [消息队列 RocketMQ 版](https://cloud.tencent.com/document/product/1493) | 2025-03-28 02:09:45 |
| trp | [T-Sec-安心平台(RP)](https://cloud.tencent.com/document/product/1458) | 2025-03-06 01:27:29 |
| trro | [实时互动-工业能源版](https://cloud.tencent.com/document/product/1584) | 2025-03-31 12:32:21 |
| trtc | [实时音视频](https://cloud.tencent.com/document/product/647) | 2025-04-03 01:31:08 |
| tse | [微服务引擎](https://cloud.tencent.com/document/product/1364) | 2025-04-03 01:31:18 |
| tsf | [微服务平台 TSF](https://cloud.tencent.com/document/product/649) | 2025-03-27 02:08:38 |
| tsi | [腾讯同传系统](https://cloud.tencent.com/document/product/1399) | 2024-10-23 01:36:51 |
| tsw | [微服务观测平台 TSW](https://cloud.tencent.com/document/product/1311) | 2024-03-20 01:30:06 |
| tts | [语音合成](https://cloud.tencent.com/document/product/1073) | 2024-12-27 11:25:13 |
| ump | [客流数字化平台](https://cloud.tencent.com/document/product/1320) | 2024-03-20 01:30:08 |
| vcg | [视频生成](https://cloud.tencent.com/document/product/1770) | 2024-11-22 12:20:45 |
| vclm | [大模型视频创作引擎](https://cloud.tencent.com/document/product/1616) | 2025-03-13 02:09:17 |
| vcube | [音视频终端引擎](https://cloud.tencent.com/document/product/1449) | 2025-03-25 15:52:47 |
| vdb | [向量数据库](https://cloud.tencent.com/document/product/1709) | 2025-04-01 01:32:28 |
| vm | [视频内容安全](https://cloud.tencent.com/document/product/1265) | 2025-03-03 01:29:20 |
| vms | [语音消息](https://cloud.tencent.com/document/product/1128) | 2025-02-13 02:09:44 |
| vod | [云点播](https://cloud.tencent.com/document/product/266) | 2025-04-02 01:33:31 |
| vpc | [私有网络](https://cloud.tencent.com/document/product/215) | 2025-04-02 01:33:36 |
| vrs | [声音复刻](https://cloud.tencent.com/document/product/1283) | 2025-03-19 02:23:02 |
| vtc | [视频转译](https://cloud.tencent.com/document/product/1769) | 2024-10-16 01:32:39 |
| waf | [Web 应用防火墙](https://cloud.tencent.com/document/product/627) | 2025-03-28 02:18:53 |
| wav | [企业微信汽车行业版](https://cloud.tencent.com/document/product/1318) | 2024-11-20 02:21:21 |
| wedata | [数据开发治理平台 WeData](https://cloud.tencent.com/document/product/1267) | 2025-04-03 01:34:17 |
| weilingwith | [微瓴同业开放平台](https://cloud.tencent.com/document/product/1693) | 2025-04-01 01:35:15 |
| wss | [SSL证书管理服务](https://cloud.tencent.com/document/product) | 2020-04-01 08:53:44 |
| yinsuda | [音速达直播音乐版权引擎](https://cloud.tencent.com/document/product/1592) | 2024-06-05 02:38:46 |
| youmall | [](https://cloud.tencent.com/document/product) | 2019-01-11 11:24:15 |
| yunjing | [主机安全](https://cloud.tencent.com/document/product) | 2020-09-15 08:08:47 |
| yunsou | [腾讯云搜TCS](https://cloud.tencent.com/document/product/270) | 2024-03-20 01:33:14 |

View File

@ -0,0 +1,40 @@
<?php
/**
* QcloudApi_Common_Base
*/
abstract class QcloudApi_Common_Base
{
/**
* $_error
* 错误号
*/
protected $_error = 0;
/**
* setError
* 设置错误信息
*
* @param int $code 错误号
* @param string $message 错误信息
* @param string $ext 扩展信息
* @return object
*/
public function setError($code, $message, $ext = '')
{
require_once QCLOUDAPI_ROOT_PATH . '/Common/Error.php';
$this->_error = new QcloudApi_Common_Error($code, $message, $ext);
return $this->_error;
}
/**
* getError
* 获取错误信息
*
* @return object
*/
public function getError()
{
return $this->_error;
}
}

View File

@ -0,0 +1,75 @@
<?php
/**
* QcloudApi_Common_Error
*/
class QcloudApi_Common_Error
{
/**
* LOCAL_ERROR_CODE
*/
const LOCAL_ERROR_CODE = 3000;
/**
* RESOURCE_PARTLY_FAILED
*/
const RESOURCE_PARTLY_FAILED = 5400;
/**
* $_code
* 错误号
*/
protected $_code;
/**
* $_message
* 错误信息
*/
protected $_message;
/**
* $_ext
* 扩展信息
*/
protected $_ext;
/**
* __construct
* @param int $code 错误号
* @param string $message 错误信息
* @param string $ext 扩展信息
*/
public function __construct($code, $message, $ext = '')
{
$code = (int) $code;
$this->_code = $code ? $code : self::LOCAL_ERROR_CODE;
$this->_message = $message;
$this->_ext = $ext;
}
/**
* getCode
* 获取错误号
*/
public function getCode()
{
return $this->_code;
}
/**
* getMessage
* 获取错误信息
*/
public function getMessage()
{
return $this->_message;
}
/**
* getExt
* 获取扩展信息
*/
public function getExt()
{
return $this->_ext;
}
}

View File

@ -0,0 +1,183 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Common/Sign.php';
/**
* QcloudApi_Common_Request
*/
class QcloudApi_Common_Request
{
/**
* $_requestUrl
* 请求url
* @var string
*/
protected static $_requestUrl = '';
/**
* $_rawResponse
* 原始的返回信息
* @var string
*/
protected static $_rawResponse = '';
/**
* $_version
* @var string
*/
protected static $_version = 'SDK_PHP_2.0.6';
/**
* $_timeOut
* 设置连接主机的超时时间
* @var int 数量级:秒
* */
protected static $_timeOut = 10;
/**
* getRequestUrl
* 获取请求url
*/
public static function getRequestUrl()
{
return self::$_requestUrl;
}
/**
* getRawResponse
* 获取原始的返回信息
*/
public static function getRawResponse()
{
return self::$_rawResponse;
}
/**
* generateUrl
* 生成请求的URL
*
* @param array $paramArray
* @param string $secretId
* @param string $secretKey
* @param string $requestHost
* @param string $requestPath
* @param string $requestMethod
* @return
*/
public static function generateUrl($paramArray, $secretId, $secretKey, $requestMethod, $requestHost, $requestPath) {
if(!isset($paramArray['SecretId']))
$paramArray['SecretId'] = $secretId;
if (!isset($paramArray['Nonce']))
$paramArray['Nonce'] = rand(1, 65535);
if (!isset($paramArray['Timestamp']))
$paramArray['Timestamp'] = time();
$signMethod = 'HmacSHA1';
if (isset($paramArray['SignatureMethod']) && $paramArray['SignatureMethod'] == "HmacSHA256")
$signMethod= 'HmacSHA256';
$paramArray['RequestClient'] = self::$_version;
$plainText = QcloudApi_Common_Sign::makeSignPlainText($paramArray,
$requestMethod, $requestHost, $requestPath);
$paramArray['Signature'] = QcloudApi_Common_Sign::sign($plainText, $secretKey, $signMethod);
$url = 'https://' . $requestHost . $requestPath;
if ($requestMethod == 'GET') {
$url .= '?' . http_build_query($paramArray);
}
return $url;
}
/**
* send
* 发起请求
* @param array $paramArray 请求参数
* @param string $secretId secretId
* @param string $secretKey secretKey
* @param string $requestMethod 请求方式GET/POST
* @param string $requestHost 接口域名
* @param string $requestPath url路径
* @return
*/
public static function send($paramArray, $secretId, $secretKey, $requestMethod, $requestHost, $requestPath)
{
if(!isset($paramArray['SecretId']))
$paramArray['SecretId'] = $secretId;
if (!isset($paramArray['Nonce']))
$paramArray['Nonce'] = rand(1, 65535);
if (!isset($paramArray['Timestamp']))
$paramArray['Timestamp'] = time();
$signMethod = 'HmacSHA1';
if (isset($paramArray['SignatureMethod']) && $paramArray['SignatureMethod'] == "HmacSHA256")
$signMethod= 'HmacSHA256';
$paramArray['RequestClient'] = self::$_version;
$plainText = QcloudApi_Common_Sign::makeSignPlainText($paramArray,
$requestMethod, $requestHost, $requestPath);
$paramArray['Signature'] = QcloudApi_Common_Sign::sign($plainText, $secretKey, $signMethod);
$url = 'https://' . $requestHost . $requestPath;
$ret = self::_sendRequest($url, $paramArray, $requestMethod);
return $ret;
}
/**
* _sendRequest
* @param string $url 请求url
* @param array $paramArray 请求参数
* @param string $method 请求方法
* @return
*/
protected static function _sendRequest($url, $paramArray, $method = 'POST')
{
$ch = curl_init();
if ($method == 'POST')
{
$paramArray = is_array( $paramArray ) ? http_build_query( $paramArray ) : $paramArray;
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $paramArray);
}
else
{
$url .= '?' . http_build_query($paramArray);
}
self::$_requestUrl = $url;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT,self::$_timeOut);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if (false !== strpos($url, "https")) {
// 证书
// curl_setopt($ch,CURLOPT_CAINFO,"ca.crt");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
$resultStr = curl_exec($ch);
self::$_rawResponse = $resultStr;
$result = json_decode($resultStr, true);
if (!$result)
{
return $resultStr;
}
return $result;
}
}

View File

@ -0,0 +1,102 @@
<?php
/**
* QcloudApi_Common_Sign
* 签名类
*/
class QcloudApi_Common_Sign
{
/**
* sign
* 生成签名
* @param string $srcStr 拼接签名源文字符串
* @param string $secretKey secretKey
* @param string $method 请求方法
* @return
*/
public static function sign($srcStr, $secretKey, $method = 'HmacSHA1')
{
switch ($method) {
case 'HmacSHA1':
$retStr = base64_encode(hash_hmac('sha1', $srcStr, $secretKey, true));
break;
case 'HmacSHA256':
$retStr = base64_encode(hash_hmac('sha256', $srcStr, $secretKey, true));
break;
default:
throw new Exception($method . ' is not a supported encrypt method');
return false;
break;
}
return $retStr;
}
/**
* makeSignPlainText
* 生成拼接签名源文字符串
* @param array $requestParams 请求参数
* @param string $requestMethod 请求方法
* @param string $requestHost 接口域名
* @param string $requestPath url路径
* @return
*/
public static function makeSignPlainText($requestParams,
$requestMethod = 'GET', $requestHost = YUNAPI_URL,
$requestPath = '/v2/index.php')
{
$url = $requestHost . $requestPath;
// 取出所有的参数
$paramStr = self::_buildParamStr($requestParams, $requestMethod);
$plainText = $requestMethod . $url . $paramStr;
return $plainText;
}
/**
* _buildParamStr
* 拼接参数
* @param array $requestParams 请求参数
* @param string $requestMethod 请求方法
* @return
*/
protected static function _buildParamStr($requestParams, $requestMethod = 'GET')
{
$paramStr = '';
ksort($requestParams);
$i = 0;
foreach ($requestParams as $key => $value)
{
if ($key == 'Signature')
{
continue;
}
// 排除上传文件的参数
if ($requestMethod == 'POST' && substr($value, 0, 1) == '@') {
continue;
}
// 把 参数中的 _ 替换成 .
if (strpos($key, '_'))
{
$key = str_replace('_', '.', $key);
}
if ($i == 0)
{
$paramStr .= '?';
}
else
{
$paramStr .= '&';
}
$paramStr .= $key . '=' . $value;
++$i;
}
return $paramStr;
}
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Account
* 用户账户模块类
*/
class QcloudApi_Module_Account extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'account.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Apigateway
* API网关
*/
class QcloudApi_Module_Apigateway extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'apigateway.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Athena
* https://cloud.tencent.com/document/product/671
*/
class QcloudApi_Module_Athena extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'athena.api.qcloud.com';
}

View File

@ -0,0 +1,262 @@
<?php
if (!defined('QCLOUDAPI_ROOT_PATH')) {
// 目录入口
define('QCLOUDAPI_ROOT_PATH', dirname(dirname(__FILE__)));
}
require_once QCLOUDAPI_ROOT_PATH . '/Common/Base.php';
/**
* QcloudApi_Module_Base
* 模块基类
*/
abstract class QcloudApi_Module_Base extends QcloudApi_Common_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = '';
/**
* $_serverUri
* url路径
* @var string
*/
protected $_serverUri = '/v2/index.php';
/**
* $_secretId
* secretId
* @var string
*/
protected $_secretId = "";
/**
* $_secretKey
* secretKey
* @var string
*/
protected $_secretKey = "";
/**
* $_defaultRegion
* 区域参数
* @var string
*/
protected $_defaultRegion = "";
/**
* $_requestMethod
* 请求方法
* @var string
*/
protected $_requestMethod = "GET";
/**
* __construct
* @param array $config [description]
*/
public function __construct($config = array())
{
if (!empty($config))
$this->setConfig($config);
}
/**
* setConfig
* 设置配置
* @param array $config 模块配置
*/
public function setConfig($config)
{
if (!is_array($config) || !count($config))
return false;
foreach ($config as $key => $val) {
switch ($key) {
case 'SecretId':
$this->setConfigSecretId($val);
break;
case 'SecretKey':
$this->setConfigSecretKey($val);
break;
case 'DefaultRegion':
$this->setConfigDefaultRegion($val);
break;
case 'RequestMethod':
$this->setConfigRequestMethod($val);
break;
default:
;
break;
}
}
return true;
}
/**
* setConfigSecretId
* 设置secretId
* @param string $secretId secretId
*/
public function setConfigSecretId($secretId)
{
$this->_secretId = $secretId;
return $this;
}
/**
* setConfigSecretKey
* 设置secretKey
* @param string $secretKey
*/
public function setConfigSecretKey($secretKey)
{
$this->_secretKey = $secretKey;
return $this;
}
/**
* setConfigDefaultRegion
* 设置区域参数
* @param string $region
*/
public function setConfigDefaultRegion($region)
{
$this->_defaultRegion = $region;
return $this;
}
/**
* setConfigRequestMethod
* 设置请求方法
* @param string $method
*/
public function setConfigRequestMethod($method)
{
$this->_requestMethod = strtoupper($method);
return $this;
}
/**
* getLastRequest
* 获取上次请求的url
* @return
*/
public function getLastRequest()
{
require_once QCLOUDAPI_ROOT_PATH . '/Common/Request.php';
return QcloudApi_Common_Request::getRequestUrl();
}
/**
* getLastResponse
* 获取请求的原始返回
* @return
*/
public function getLastResponse()
{
require_once QCLOUDAPI_ROOT_PATH . '/Common/Request.php';
return QcloudApi_Common_Request::getRawResponse();
}
/**
* generateUrl
* 生成请求的URL不发起请求
* @param string $name 接口方法名
* @param array $params 请求参数
* @return
*/
public function generateUrl($name, $params)
{
require_once QCLOUDAPI_ROOT_PATH . '/Common/Request.php';
$action = ucfirst($name);
$params['Action'] = $action;
if (!isset($params['Region']))
$params['Region'] = $this->_defaultRegion;
return QcloudApi_Common_Request::generateUrl($params, $this->_secretId, $this->_secretKey, $this->_requestMethod,
$this->_serverHost, $this->_serverUri);
}
/**
* __call
* 通过__call转发请求
* @param string $name 方法名
* @param array $arguments 参数
* @return
*/
public function __call($name, $arguments)
{
$response = $this->_dispatchRequest($name, $arguments);
return $this->_dealResponse($response);
}
/**
* _dispatchRequest
* 发起接口请求
* @param string $name 接口名
* @param array $arguments 接口参数
* @return
*/
protected function _dispatchRequest($name, $arguments)
{
$action = ucfirst($name);
$params = array();
if (is_array($arguments) && !empty($arguments)) {
$params = (array) $arguments[0];
}
$params['Action'] = $action;
if (!isset($params['Region']))
$params['Region'] = $this->_defaultRegion;
require_once QCLOUDAPI_ROOT_PATH . '/Common/Request.php';
$response = QcloudApi_Common_Request::send($params, $this->_secretId, $this->_secretKey, $this->_requestMethod,
$this->_serverHost, $this->_serverUri);
return $response;
}
/**
* _dealResponse
* 处理返回
* @param array $rawResponse
* @return
*/
protected function _dealResponse($rawResponse)
{
if (!is_array($rawResponse) || (!isset($rawResponse['code']) && !isset($rawResponse['Response']))) {
$this->setError("", 'request falied!');
return false;
}
if ($rawResponse['code']) {
$ext = '';
require_once QCLOUDAPI_ROOT_PATH . '/Common/Error.php';
if (isset($rawResponse['detail'])) {
// 批量异步操作,返回任务失败信息
$ext = $rawResponse['detail'];
}
$this->setError($rawResponse['code'], $rawResponse['message'], $ext);
return false;
}
unset($rawResponse['code'], $rawResponse['message']);
if (count($rawResponse))
return $rawResponse;
else
return true;
}
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Batch
* 批量计算
*/
class QcloudApi_Module_Batch extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'batch.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Bgpip
* 大禹网络安全模块
*/
class QcloudApi_Module_Bgpip extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'bgpip.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Bill
* Bill账单模块类
*/
class QcloudApi_Module_Bill extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'bill.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Bm
* 黑石类
*/
class QcloudApi_Module_Bm extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'bm.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Bmeip
* 黑石eip模块类
*/
class QcloudApi_Module_Bmeip extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'bmeip.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Bmlb
* 黑石LB类
*/
class QcloudApi_Module_Bmlb extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'bmlb.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Bmvpc
* 黑石VPC模块类
*/
class QcloudApi_Module_Bmvpc extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'bmvpc.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Cbs
* 云硬盘模块类
*/
class QcloudApi_Module_Cbs extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'cbs.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Ccs
* 容器服务
*/
class QcloudApi_Module_Ccs extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'ccs.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Cdb
* CDB数据库模块类
*/
class QcloudApi_Module_Cdb extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'cdb.api.qcloud.com';
}

View File

@ -0,0 +1,51 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Cdn
* CDN模块类
*/
class QcloudApi_Module_Cdn extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'cdn.api.qcloud.com';
/**
* UploadCdnEntity
* 上传CDN文件
* @param array $params 请求参数
*/
public function UploadCdnEntity($params) {
$name = 'UploadCdnEntity';
$entityFile = $params['entityFile'];
if (!file_exists($entityFile)) {
$this->setError('', 'entityFile is not exists.');
return false;
}
if (!$params['entityFileMd5']) {
$params['entityFileMd5'] = md5_file($entityFile);
}
$params['entityFile'] = '@' . $entityFile;
$response = $this->_dispatchRequest($name, array($params));
if (!$response) {
$this->setError("", 'request falied!');
return false;
}
if (is_array($response) && $response['code']) {
$this->setError($response['code'], $response['message']);
return false;
}
unset($response['code'], $response['message']);
return $response;
}
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Cloudaudit
* 云审计模块类
*/
class QcloudApi_Module_Cloudaudit extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'cloudaudit.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Cmem
* 云缓存模块类
*/
class QcloudApi_Module_Cmem extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'cmem.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Cns
* 云解析模块类
*/
class QcloudApi_Module_Cns extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'cns.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Cvm
* 云服务器模块类
*/
class QcloudApi_Module_Cvm extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'cvm.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Dfw
* 安全组
*/
class QcloudApi_Module_Dfw extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'dfw.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Eip
* 弹性公网Ip模块类
*/
class QcloudApi_Module_Eip extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'eip.api.qcloud.com';
}

View File

@ -0,0 +1,14 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* https://cloud.tencent.com/document/product/589
*/
class QcloudApi_Module_Emr extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'emr.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Feecenter
* 费用中心类
*/
class QcloudApi_Module_Feecenter extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'feecenter.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Image
* 镜像模块类
*/
class QcloudApi_Module_Image extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'image.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Lb
* 负载均衡模块类
*/
class QcloudApi_Module_Lb extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'lb.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Live
* 直播模块类
*/
class QcloudApi_Module_Live extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'live.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Market
* Market模块类
*/
class QcloudApi_Module_Market extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'market.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Monitor
* 云监控模块类
*/
class QcloudApi_Module_Monitor extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'monitor.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Partners
* 渠道合作伙伴
*/
class QcloudApi_Module_Partners extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'partners.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Redis
* 弹性缓存
*/
class QcloudApi_Module_Redis extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'redis.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Scaling
* 弹性伸缩模块类
*/
class QcloudApi_Module_Scaling extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'Scaling.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Scf
* 无服务器云函数
*/
class QcloudApi_Module_Scf extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'scf.api.qcloud.com';
}

View File

@ -0,0 +1,45 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Sec
* 云安全模块类
*/
class QcloudApi_Module_Sec extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'csec.api.qcloud.com';
/**
* captchaQuery
* 获取验证码
* @param array $params 请求参数
* @return
*/
public function captchaQuery($params) {
$name = 'captchaQuery';
$response = $this->_dispatchRequest($name, array($params));
if (!$response) {
$this->setError("", 'request falied!');
return false;
}
if (is_array($response) && $response['code']) {
$this->setError($response['code'], $response['message']);
return false;
}
if ($params['script'] == 1) {
return $response;
}
unset($response['code'], $response['message']);
return $response;
}
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Snapshot
* 快照模块类
*/
class QcloudApi_Module_Snapshot extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'snapshot.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Sts
* https://cloud.tencent.com/document/product/598
*/
class QcloudApi_Module_Sts extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'sts.api.qcloud.com';
}

View File

@ -0,0 +1,14 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* https://cloud.tencent.com/document/product/663
*/
class QcloudApi_Module_Tbaas extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'tbaas.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Tdsql
* 云数据库Tdsql模块类
*/
class QcloudApi_Module_Tdsql extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'tdsql.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Tmt
* 机器翻译
*/
class QcloudApi_Module_Tmt extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'tmt.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Trade
* 产品售卖模块类
*/
class QcloudApi_Module_Trade extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'trade.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Vod
* 视频云模块类
*/
class QcloudApi_Module_Vod extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'vod.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Vpc
* VPC模块类
*/
class QcloudApi_Module_Vpc extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'vpc.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_WENZHI
* 文智模块类
*/
class QcloudApi_Module_Wenzhi extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'wenzhi.api.qcloud.com';
}

View File

@ -0,0 +1,15 @@
<?php
require_once QCLOUDAPI_ROOT_PATH . '/Module/Base.php';
/**
* QcloudApi_Module_Vod
* 视频云模块类
*/
class QcloudApi_Module_Yunsou extends QcloudApi_Module_Base
{
/**
* $_serverHost
* 接口域名
* @var string
*/
protected $_serverHost = 'yunsou.api.qcloud.com';
}

View File

@ -0,0 +1,283 @@
<?php
// 目录入口
define('QCLOUDAPI_ROOT_PATH', dirname(__FILE__));
/**
* QcloudApi
* SDK入口文件
*/
class QcloudApi
{
/**
* MODULE_ACCOUNT
* 用户账户
*/
const MODULE_ACCOUNT = 'account';
/**
* MODULE_CVM
* 云服务器
*/
const MODULE_CVM = 'cvm';
/**
* MODULE_CDB
* CDB数据库
*/
const MODULE_CDB = 'cdb';
/**
* MODULE_LB
* 负载均衡
*/
const MODULE_LB = 'lb';
/**
* MODULE_TRADE
* 产品售卖
*/
const MODULE_TRADE = 'trade';
/**
* MODULE_BILL
* 账单
*/
const MODULE_BILL = 'bill';
/**
* MODULE_SEC
* 云安全
*/
const MODULE_SEC = 'sec';
/**
* MODULE_IMAGE
* 镜像
*/
const MODULE_IMAGE = 'image';
/**
* MODULE_MONITOR
* 云监控
*/
const MODULE_MONITOR = 'monitor';
/**
* MODULE_CDN
* CDN
*/
const MODULE_CDN = 'cdn';
/**
* MODULE_VPC
* VPC
*/
const MODULE_VPC = 'vpc';
/**
* MODULE_VOD
* VOD
*/
const MODULE_VOD = 'vod';
/**
* YUNSOU
*/
const MODULE_YUNSOU = 'yunsou';
/**
* cns
*/
const MODULE_CNS = 'cns';
/**
* wenzhi
*/
const MODULE_WENZHI = 'wenzhi';
/**
* MARKET
*/
const MODULE_MARKET = 'market';
/**
* MODULE_EIP
* 弹性公网Ip
*/
const MODULE_EIP = 'eip';
/**
* MODULE_LIVE
* 直播
*/
const MODULE_LIVE = 'live';
/**
* MODULE_SNAPSHOT
* 快照
*/
const MODULE_SNAPSHOT = 'snapshot';
/**
* MODULE_CBS
* 云硬盘
*/
const MODULE_CBS = 'cbs';
/**
* MODULE_SCALING
* 弹性伸缩
*/
const MODULE_SCALING = 'scaling';
/**
* MODULE_CMEM
* 云缓存
*/
const MODULE_CMEM = 'cmem';
/**
* MODULE_TDSQL
* 云数据库TDSQL
*/
const MODULE_TDSQL = 'tdsql';
/**
* MODULE_BM
* 黑石BM
*/
const MODULE_BM = 'bm';
/**
* MODULE_BMLB
* 黑石BMLB
*/
const MODULE_BMLB = 'bmlb';
/**
* MODULE_FEECENTER
* 费用中心
*/
const MODULE_FEECENTER = 'feecenter';
/**
* MODULE_BMEIP
* 黑石eip
*/
const MODULE_BMEIP = 'bmeip';
/**
* MODULE_BMVPC
* 黑石vpc
*/
const MODULE_BMVPC = 'bmvpc';
/**
* MODULE_BGPIP
* 大禹网络安全
*/
const MODULE_BGPIP = 'bgpip';
/**
* MODULE_CLOUDAUDIT
* 云审计模块
*/
const MODULE_CLOUDAUDIT = 'cloudaudit';
/**
* MODULE_DFW
* 安全组模块
*/
const MODULE_DFW = 'dfw';
/**
* MODULE_SCF
* 无服务器云函数
*/
const MODULE_SCF = 'scf';
/**
* MODULE_APIGATEWAY
* API网关
*/
const MODULE_APIGATEWAY = 'apigateway';
/**
* MODULE_TMT
* 机器翻译
*/
const MODULE_TMT = 'tmt';
/**
* MODULE_BATCH
* 批量计算
*/
const MODULE_BATCH = 'batch';
/**
* MODULE_CCS
* 容器服务
*/
const MODULE_CCS = 'ccs';
/**
* MODULE_REDIS
* 弹性缓存
*/
const MODULE_REDIS = 'redis';
/**
* MODULE_PARTNERS
* 渠道合作伙伴
*/
const MODULE_PARTNERS = 'partners';
/**
* MODULE_STS
*/
const MODULE_STS = "sts";
/**
* MODULE_ATHENA
* 金融智能客服
*/
const MODULE_ATHENA = "athena";
/**
* MODULE_TBAAS
* 区块链服务
*/
const MODULE_TBAAS = "tbaas";
/**
* MODULE_EMR
* 弹性 MapReduce
*/
const MODULE_EMR = "emr";
/**
* load
* 加载模块文件
* @param string $moduleName 模块名称
* @param array $moduleConfig 模块配置
* @return
*/
public static function load($moduleName, $moduleConfig = array())
{
$moduleName = ucfirst($moduleName);
$moduleClassFile = QCLOUDAPI_ROOT_PATH . '/Module/' . $moduleName . '.php';
if (!file_exists($moduleClassFile)) {
return false;
}
require_once $moduleClassFile;
$moduleClassName = 'QcloudApi_Module_' . $moduleName;
$moduleInstance = new $moduleClassName();
if (!empty($moduleConfig)) {
$moduleInstance->setConfig($moduleConfig);
}
return $moduleInstance;
}
}

View File

@ -0,0 +1,69 @@
<?php
/*
* Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace TencentCloud\Aai\V20180522;
use TencentCloud\Common\AbstractClient;
use TencentCloud\Common\Profile\ClientProfile;
use TencentCloud\Common\Credential;
use TencentCloud\Aai\V20180522\Models as Models;
/**
* @method Models\ChatResponse Chat(Models\ChatRequest $req) 提供基于文本的基础聊天能力,可以让您的应用快速拥有具备深度语义理解的机器聊天功能。
* @method Models\SentenceRecognitionResponse SentenceRecognition(Models\SentenceRecognitionRequest $req) 识别60s内的短语音当音频放在请求body中传输时整个请求大小不能超过600KB当音频以url方式传输时音频时长不可超过60s。所有请求参数放在post的body中采用x-www-form-urlencoded数据转换成一个字符串name1=value1&name2=value2…进行urlencode后编码传输。现暂只支持中文普通话识别支持识别8k(16k)的16bit的mp3或者wav音频。
* @method Models\SimultaneousInterpretingResponse SimultaneousInterpreting(Models\SimultaneousInterpretingRequest $req) 该接口是实时流式识别可同时返回语音识别文本及翻译文本当前仅支持中文和英文。该接口可配合同传windows客户端提供会议现场同传服务。
* @method Models\TextToVoiceResponse TextToVoice(Models\TextToVoiceRequest $req) 腾讯云语音合成技术TTS可以将任意文本转化为语音实现让机器和应用张口说话。
腾讯TTS技术可以应用到很多场景比如移动APP语音播报新闻智能设备语音提醒依靠网上现有节目或少量录音快速合成明星语音降低邀约成本支持车载导航语音合成的个性化语音播报。
内测期间免费使用。
*/
class AaiClient extends AbstractClient
{
/**
* @var string
*/
protected $endpoint = "aai.tencentcloudapi.com";
/**
* @var string
*/
protected $service = "aai";
/**
* @var string
*/
protected $version = "2018-05-22";
/**
* @param Credential $credential
* @param string $region
* @param ClientProfile|null $profile
* @throws TencentCloudSDKException
*/
function __construct($credential, $region, $profile=null)
{
parent::__construct($this->endpoint, $this->version, $credential, $region, $profile);
}
public function returnResponse($action, $response)
{
$respClass = "TencentCloud"."\\".ucfirst("aai")."\\"."V20180522\\Models"."\\".ucfirst($action)."Response";
$obj = new $respClass();
$obj->deserialize($response);
return $obj;
}
}

View File

@ -0,0 +1,77 @@
<?php
/*
* Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace TencentCloud\Aai\V20180522\Models;
use TencentCloud\Common\AbstractModel;
/**
* Chat请求参数结构体
*
* @method string getText() 获取聊天输入文本
* @method void setText(string $Text) 设置聊天输入文本
* @method integer getProjectId() 获取腾讯云项目 ID可填 0,总长度不超过 1024 字节。
* @method void setProjectId(integer $ProjectId) 设置腾讯云项目 ID可填 0,总长度不超过 1024 字节。
* @method string getUser() 获取json格式比如 {"id":"test","gender":"male"}。记录当前与机器人交互的用户id非必须但强烈建议传入否则多轮聊天功能会受影响
* @method void setUser(string $User) 设置json格式比如 {"id":"test","gender":"male"}。记录当前与机器人交互的用户id非必须但强烈建议传入否则多轮聊天功能会受影响
*/
class ChatRequest extends AbstractModel
{
/**
* @var string 聊天输入文本
*/
public $Text;
/**
* @var integer 腾讯云项目 ID可填 0,总长度不超过 1024 字节。
*/
public $ProjectId;
/**
* @var string json格式比如 {"id":"test","gender":"male"}。记录当前与机器人交互的用户id非必须但强烈建议传入否则多轮聊天功能会受影响
*/
public $User;
/**
* @param string $Text 聊天输入文本
* @param integer $ProjectId 腾讯云项目 ID可填 0,总长度不超过 1024 字节。
* @param string $User json格式比如 {"id":"test","gender":"male"}。记录当前与机器人交互的用户id非必须但强烈建议传入否则多轮聊天功能会受影响
*/
function __construct()
{
}
/**
* For internal only. DO NOT USE IT.
*/
public function deserialize($param)
{
if ($param === null) {
return;
}
if (array_key_exists("Text",$param) and $param["Text"] !== null) {
$this->Text = $param["Text"];
}
if (array_key_exists("ProjectId",$param) and $param["ProjectId"] !== null) {
$this->ProjectId = $param["ProjectId"];
}
if (array_key_exists("User",$param) and $param["User"] !== null) {
$this->User = $param["User"];
}
}
}

View File

@ -0,0 +1,65 @@
<?php
/*
* Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace TencentCloud\Aai\V20180522\Models;
use TencentCloud\Common\AbstractModel;
/**
* Chat返回参数结构体
*
* @method string getAnswer() 获取聊天输出文本
* @method void setAnswer(string $Answer) 设置聊天输出文本
* @method string getRequestId() 获取唯一请求 ID每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
* @method void setRequestId(string $RequestId) 设置唯一请求 ID每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
*/
class ChatResponse extends AbstractModel
{
/**
* @var string 聊天输出文本
*/
public $Answer;
/**
* @var string 唯一请求 ID每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
*/
public $RequestId;
/**
* @param string $Answer 聊天输出文本
* @param string $RequestId 唯一请求 ID每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
*/
function __construct()
{
}
/**
* For internal only. DO NOT USE IT.
*/
public function deserialize($param)
{
if ($param === null) {
return;
}
if (array_key_exists("Answer",$param) and $param["Answer"] !== null) {
$this->Answer = $param["Answer"];
}
if (array_key_exists("RequestId",$param) and $param["RequestId"] !== null) {
$this->RequestId = $param["RequestId"];
}
}
}

View File

@ -0,0 +1,149 @@
<?php
/*
* Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace TencentCloud\Aai\V20180522\Models;
use TencentCloud\Common\AbstractModel;
/**
* SentenceRecognition请求参数结构体
*
* @method integer getProjectId() 获取腾讯云项目 ID可填 0,总长度不超过 1024 字节。
* @method void setProjectId(integer $ProjectId) 设置腾讯云项目 ID可填 0,总长度不超过 1024 字节。
* @method integer getSubServiceType() 获取子服务类型。2一句话识别。
* @method void setSubServiceType(integer $SubServiceType) 设置子服务类型。2一句话识别。
* @method string getEngSerViceType() 获取引擎类型。8k电话 8k 通用模型16k16k 通用模型。只支持单声道音频识别。
* @method void setEngSerViceType(string $EngSerViceType) 设置引擎类型。8k电话 8k 通用模型16k16k 通用模型。只支持单声道音频识别。
* @method integer getSourceType() 获取语音数据来源。0语音 URL1语音数据post body
* @method void setSourceType(integer $SourceType) 设置语音数据来源。0语音 URL1语音数据post body
* @method string getVoiceFormat() 获取识别音频的音频格式支持mp3,wav
* @method void setVoiceFormat(string $VoiceFormat) 设置识别音频的音频格式支持mp3,wav
* @method string getUsrAudioKey() 获取用户端对此任务的唯一标识,用户自助生成,用于用户查找识别结果。
* @method void setUsrAudioKey(string $UsrAudioKey) 设置用户端对此任务的唯一标识,用户自助生成,用于用户查找识别结果。
* @method string getUrl() 获取语音 URL公网可下载。当 SourceType 值为 0 时须填写该字段,为 1 时不填URL 的长度大于 0,小于 2048需进行urlencode编码。音频时间长度要小于60s。
* @method void setUrl(string $Url) 设置语音 URL公网可下载。当 SourceType 值为 0 时须填写该字段,为 1 时不填URL 的长度大于 0,小于 2048需进行urlencode编码。音频时间长度要小于60s。
* @method string getData() 获取语音数据当SourceType 值为1时必须填写为0可不写。要base64编码(采用python语言时注意读取文件应该为string而不是byte以byte格式读取后要decode()。编码后的数据不可带有回车换行符)。音频数据要小于600kB。
* @method void setData(string $Data) 设置语音数据当SourceType 值为1时必须填写为0可不写。要base64编码(采用python语言时注意读取文件应该为string而不是byte以byte格式读取后要decode()。编码后的数据不可带有回车换行符)。音频数据要小于600kB。
* @method integer getDataLen() 获取数据长度,当 SourceType 值为1时必须填写为0可不写此数据长度为数据未进行base64编码时的数据长度
* @method void setDataLen(integer $DataLen) 设置数据长度,当 SourceType 值为1时必须填写为0可不写此数据长度为数据未进行base64编码时的数据长度
*/
class SentenceRecognitionRequest extends AbstractModel
{
/**
* @var integer 腾讯云项目 ID可填 0,总长度不超过 1024 字节。
*/
public $ProjectId;
/**
* @var integer 子服务类型。2一句话识别。
*/
public $SubServiceType;
/**
* @var string 引擎类型。8k电话 8k 通用模型16k16k 通用模型。只支持单声道音频识别。
*/
public $EngSerViceType;
/**
* @var integer 语音数据来源。0语音 URL1语音数据post body
*/
public $SourceType;
/**
* @var string 识别音频的音频格式支持mp3,wav
*/
public $VoiceFormat;
/**
* @var string 用户端对此任务的唯一标识,用户自助生成,用于用户查找识别结果。
*/
public $UsrAudioKey;
/**
* @var string 语音 URL公网可下载。当 SourceType 值为 0 时须填写该字段,为 1 时不填URL 的长度大于 0,小于 2048需进行urlencode编码。音频时间长度要小于60s。
*/
public $Url;
/**
* @var string 语音数据当SourceType 值为1时必须填写为0可不写。要base64编码(采用python语言时注意读取文件应该为string而不是byte以byte格式读取后要decode()。编码后的数据不可带有回车换行符)。音频数据要小于600kB。
*/
public $Data;
/**
* @var integer 数据长度,当 SourceType 值为1时必须填写为0可不写此数据长度为数据未进行base64编码时的数据长度
*/
public $DataLen;
/**
* @param integer $ProjectId 腾讯云项目 ID可填 0,总长度不超过 1024 字节。
* @param integer $SubServiceType 子服务类型。2一句话识别。
* @param string $EngSerViceType 引擎类型。8k电话 8k 通用模型16k16k 通用模型。只支持单声道音频识别。
* @param integer $SourceType 语音数据来源。0语音 URL1语音数据post body
* @param string $VoiceFormat 识别音频的音频格式支持mp3,wav
* @param string $UsrAudioKey 用户端对此任务的唯一标识,用户自助生成,用于用户查找识别结果。
* @param string $Url 语音 URL公网可下载。当 SourceType 值为 0 时须填写该字段,为 1 时不填URL 的长度大于 0,小于 2048需进行urlencode编码。音频时间长度要小于60s。
* @param string $Data 语音数据当SourceType 值为1时必须填写为0可不写。要base64编码(采用python语言时注意读取文件应该为string而不是byte以byte格式读取后要decode()。编码后的数据不可带有回车换行符)。音频数据要小于600kB。
* @param integer $DataLen 数据长度,当 SourceType 值为1时必须填写为0可不写此数据长度为数据未进行base64编码时的数据长度
*/
function __construct()
{
}
/**
* For internal only. DO NOT USE IT.
*/
public function deserialize($param)
{
if ($param === null) {
return;
}
if (array_key_exists("ProjectId",$param) and $param["ProjectId"] !== null) {
$this->ProjectId = $param["ProjectId"];
}
if (array_key_exists("SubServiceType",$param) and $param["SubServiceType"] !== null) {
$this->SubServiceType = $param["SubServiceType"];
}
if (array_key_exists("EngSerViceType",$param) and $param["EngSerViceType"] !== null) {
$this->EngSerViceType = $param["EngSerViceType"];
}
if (array_key_exists("SourceType",$param) and $param["SourceType"] !== null) {
$this->SourceType = $param["SourceType"];
}
if (array_key_exists("VoiceFormat",$param) and $param["VoiceFormat"] !== null) {
$this->VoiceFormat = $param["VoiceFormat"];
}
if (array_key_exists("UsrAudioKey",$param) and $param["UsrAudioKey"] !== null) {
$this->UsrAudioKey = $param["UsrAudioKey"];
}
if (array_key_exists("Url",$param) and $param["Url"] !== null) {
$this->Url = $param["Url"];
}
if (array_key_exists("Data",$param) and $param["Data"] !== null) {
$this->Data = $param["Data"];
}
if (array_key_exists("DataLen",$param) and $param["DataLen"] !== null) {
$this->DataLen = $param["DataLen"];
}
}
}

View File

@ -0,0 +1,65 @@
<?php
/*
* Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace TencentCloud\Aai\V20180522\Models;
use TencentCloud\Common\AbstractModel;
/**
* SentenceRecognition返回参数结构体
*
* @method string getResult() 获取识别结果。
* @method void setResult(string $Result) 设置识别结果。
* @method string getRequestId() 获取唯一请求 ID每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
* @method void setRequestId(string $RequestId) 设置唯一请求 ID每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
*/
class SentenceRecognitionResponse extends AbstractModel
{
/**
* @var string 识别结果。
*/
public $Result;
/**
* @var string 唯一请求 ID每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
*/
public $RequestId;
/**
* @param string $Result 识别结果。
* @param string $RequestId 唯一请求 ID每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
*/
function __construct()
{
}
/**
* For internal only. DO NOT USE IT.
*/
public function deserialize($param)
{
if ($param === null) {
return;
}
if (array_key_exists("Result",$param) and $param["Result"] !== null) {
$this->Result = $param["Result"];
}
if (array_key_exists("RequestId",$param) and $param["RequestId"] !== null) {
$this->RequestId = $param["RequestId"];
}
}
}

Some files were not shown because too many files have changed in this diff Show More