diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index f564003f..75693447 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.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); } diff --git a/app/api/controller/GoodsNew.php b/app/api/controller/GoodsNew.php index be14951f..40424d7d 100644 --- a/app/api/controller/GoodsNew.php +++ b/app/api/controller/GoodsNew.php @@ -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); diff --git a/app/api/service/Goods.php b/app/api/service/Goods.php index 6d1026b9..6b6979ec 100644 --- a/app/api/service/Goods.php +++ b/app/api/service/Goods.php @@ -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()) { diff --git a/app/command/DeleteEsGoods.php b/app/command/DeleteEsGoods.php new file mode 100644 index 00000000..acbda511 --- /dev/null +++ b/app/command/DeleteEsGoods.php @@ -0,0 +1,35 @@ +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); + + + } + +} \ No newline at end of file diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index 7dd77332..6fbbbd39 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -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); diff --git a/app/common/service/GoodsCateEs.php b/app/common/service/GoodsCateEs.php index 4455e991..ac278c9c 100644 --- a/app/common/service/GoodsCateEs.php +++ b/app/common/service/GoodsCateEs.php @@ -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 "
"; + print_r($diff_goods_ids); + exit(); + //删除父子文档 + $this->batchDelete($diff_goods_ids); + $page++; + } + } /** * 批量删除父子关系的数据 diff --git a/config/console.php b/config/console.php index d0611b58..adae03b0 100644 --- a/config/console.php +++ b/config/console.php @@ -19,5 +19,6 @@ return [ 'HomeLocation' => 'app\command\HomeLocation', 'SyncGoodsToPerMinute' => 'app\command\SyncGoodsToPerMinute', 'UpdateDataProviderGoods' => 'app\command\UpdateDataProviderGoods', + 'DeleteEsGoods' => 'app\command\DeleteEsGoods', ], ];