lqmac 3 months ago
parent fe337dc654
commit 164266c924
  1. 3
      app/api/controller/Goods.php
  2. 4
      app/api/controller/GoodsNew.php
  3. 3
      app/api/service/Goods.php
  4. 35
      app/command/DeleteEsGoods.php
  5. 2
      app/common/library/wxserver/Server.php
  6. 46
      app/common/service/GoodsCateEs.php
  7. 1
      config/console.php

@ -443,8 +443,9 @@ class Goods extends Controller
*/
public function chartsGoodsJing(): Json
{
$param['storeInfo'] = $this->storeInfo;
$service = new GoodsService;
$goodsList = $service->chartsGoodsJing();
$goodsList = $service->chartsGoodsJing($param);
return $this->renderSuccess($goodsList);
}

@ -22,10 +22,10 @@ class GoodsNew extends Controller
$param = $this->request->param();
$page = $this->request->param('page', 1);
$pageSize = $this->request->param('pageSize', 10);
$param['channels'] = $this->storeInfo['open_channel'] ? array_merge(['zy'], explode(",", $this->storeInfo['open_channel'])) : [];
//$param['channels'] = $this->storeInfo['open_channel'] ? array_merge(['zy'], explode(",", $this->storeInfo['open_channel'])) : [];
$param['fliter_condition'] = $this->storeInfo['fliter_condition'];
$param['status'] = 10;
$param['store_id'] = 10038;//$this->storeId;
//$param['store_id'] = 10041;//$this->storeId;
$goodsService = new GoodsCateEs();
$data = $goodsService->list($param, $page, $pageSize);

@ -264,7 +264,7 @@ class Goods extends GoodsService
}
public function chartsGoodsJing(): array
public function chartsGoodsJing($param = []): array
{
$model = new CategoryModel;
$list = $model->where([
@ -279,6 +279,7 @@ class Goods extends GoodsService
'is_delete' => 0,
'is_paihang' => 1,
'categoryId' => $v['category_id'],
'storeInfo' => $param['storeInfo'] ?? [],
], 3);
$v['goods_list'] = $goodsList->toArray()['data'];
// if (!$goodsList->isEmpty()) {

@ -0,0 +1,35 @@
<?php
namespace app\command;
use app\common\service\GoodsCateEs;
use app\common\service\GoodsEs;
use think\console\Command;
use think\console\Output;
use think\console\Input;
class DeleteEsGoods extends Command
{
protected function configure()
{
// 指令配置
$this->setName('DeleteEsGoods')->setDescription('删除es商品');
$this->addArgument("store_id");
$this->addArgument("goods_id");
}
protected function execute(Input $input, Output $output)
{
$store_id = $input->getArgument("store_id");
$goods_id = $input->getArgument("goods_id");
$goodsCateService = new GoodsCateEs();
$goodsCateService->deleteEsGoods($store_id, $goods_id);
}
}

@ -292,6 +292,8 @@ class Server
{
$msg = '未知错误';
$access_token = $this->authorizerAccessToken($appid);
// var_dump($access_token);
// exit;
$url = 'https://api.weixin.qq.com/wxa/getversioninfo?access_token=' . $access_token;
$result = $this->curlPost($url, '{}');
$result = json_decode($result, true);

@ -54,6 +54,9 @@ class GoodsCateEs
if (isset($params['merchantId']) && $params['merchantId']) {
$equal[] = ['merchant_id' => $params['merchantId'] ?? 0];
}
if (isset($params['goods_id']) && $params['goods_id']) {
$equal[] = ['goods_id' => $params['goods_id'] ?? 0];
}
//between查询
if (isset($params['fliter_condition']) && $params['fliter_condition']) {
$fliter_condition = json_decode($params['fliter_condition'], true);
@ -85,7 +88,12 @@ class GoodsCateEs
if ($data['data']) {
$model = new Goods;
$goods_ids = array_column($data['data'], "goods_id");
//返回简单的goods_id
if (isset($params['is_simple']) && $params['is_simple']) {
return $goods_ids;
}
$goods_list = array_column($data['data'], null, "goods_id");
// var_dump($data['data']);
// exit();
//$list = $model->getListByIds($goods_ids, 10);
@ -98,6 +106,11 @@ class GoodsCateEs
$data['data'] = $list;
} else {
//返回简单的goods_id
if (isset($params['is_simple']) && $params['is_simple']) {
return [];
}
}
return $data;
}
@ -407,6 +420,39 @@ class GoodsCateEs
}
return true;
}
public function deleteEsGoods($store_id = 0, $goods_id = 0){
$params = ['is_simple' => 1];
if ($store_id) {
$params['store_id'] = $store_id;
}
if ($goods_id) {
$params['goods_id'] = $goods_id;
}
$page = 1;
$limit = 5000;
while (TRUE) {
$data = $this->list($params, $page, $limit);
if (!$data) {
return false;
}
$goods_list = Goods::whereIn('goods_id', $data)->field("goods_id")->select()->toArray();
if (count($goods_list) == count($data)) {
$page++;
echo "无需删除数据".PHP_EOL;
continue;
}
$diff_goods_ids = array_diff($data, array_column($goods_list, "goods_id"));
echo "<pre>";
print_r($diff_goods_ids);
exit();
//删除父子文档
$this->batchDelete($diff_goods_ids);
$page++;
}
}
/**
* 批量删除父子关系的数据

@ -19,5 +19,6 @@ return [
'HomeLocation' => 'app\command\HomeLocation',
'SyncGoodsToPerMinute' => 'app\command\SyncGoodsToPerMinute',
'UpdateDataProviderGoods' => 'app\command\UpdateDataProviderGoods',
'DeleteEsGoods' => 'app\command\DeleteEsGoods',
],
];

Loading…
Cancel
Save