- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明 Made-with: Cursor
77 lines
2.0 KiB
PHP
77 lines
2.0 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Author: ScottPan Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\controller\erp;
|
|
|
|
use app\jobs\product\ProductSyncErp;
|
|
use app\Request;
|
|
use crmeb\services\erp\Erp as ErpServices;
|
|
use crmeb\services\erp\storage\jushuitan\Product as ProductService;
|
|
use think\annotation\Inject;
|
|
use think\Response;
|
|
|
|
/**
|
|
* 商品类
|
|
* Class Product
|
|
* @package app\controller\erp
|
|
*/
|
|
class Product
|
|
{
|
|
|
|
/**
|
|
* @var ErpServices|\crmeb\services\erp\storage\jushuitan\Comment|\crmeb\services\erp\storage\jushuitan\Order|ProductService|\crmeb\services\erp\storage\jushuitan\Stock
|
|
*/
|
|
#[Inject]
|
|
protected ErpServices $services;
|
|
|
|
|
|
/**
|
|
* 使用spu同步商品
|
|
* @param Request $request
|
|
* @return mixed
|
|
* @throws \Exception
|
|
*/
|
|
public function syncProduct(Request $request)
|
|
{
|
|
[$spuStr] = $request->getMore([
|
|
['spu_str', ''],
|
|
], true);
|
|
|
|
if (empty($spuStr)) {
|
|
return app('json')->fail('请输入ERP商品SPU');
|
|
}
|
|
$spuArr = explode(',', $spuStr);
|
|
foreach ($spuArr as $item) {
|
|
// 获取商品
|
|
// ProductSyncErp::dispatchDo('productFromErp', [$item]);
|
|
}
|
|
return app('json')->success('正在同步中,请稍后查看');
|
|
}
|
|
|
|
/**
|
|
* 使用sku同步库存
|
|
* @param Request $request
|
|
* @return mixed
|
|
* @throws \Exception
|
|
*/
|
|
public function syncStock(Request $request)
|
|
{
|
|
[$ids] = $request->getMore([
|
|
['ids', ''],
|
|
], true);
|
|
|
|
if (empty($ids)) {
|
|
return app('json')->fail('请选择商品');
|
|
}
|
|
|
|
$idArr = stringToIntArray($ids);
|
|
$data = array_chunk($idArr, 1);
|
|
foreach ($data as $item) {
|
|
// 获取库存
|
|
// ProductSyncErp::dispatchDo('stockFromErp', [$item]);
|
|
}
|
|
return app('json')->success('正在同步中,请稍后查看');
|
|
}
|
|
} |