zengyyh 5 months ago
commit 685c14e29f
  1. 42
      app/admin/controller/Store.php
  2. 3
      app/api/controller/Goods.php

@ -383,27 +383,27 @@ class Store extends Controller
//删除分类
Category::where('store_id', $storeId)->delete();
GoodsSku::where('store_id', $storeId)->delete();
GoodsImage::where('store_id', $storeId)->delete();
GoodsSpecRel::where('store_id', $storeId)->delete();
GoodsModel::where('store_id', $storeId)->delete();
// $page = 1;
// while (TRUE) {
// $goods_list = GoodsModel::where('store_id', $storeId)->field('goods_id')->page($page)->limit(2000)->select();
// if ($goods_list->isEmpty()) {
// return $this->renderSuccess();
// }
// $goods_ids = array_column($goods_list->toArray(), "goods_id");
// //删除商品sku
// GoodsSku::whereIn('goods_id', $goods_ids)->delete();
// //删除商品图片
// GoodsImage::whereIn('goods_id', $goods_ids)->delete();
// //删除商品规格
// GoodsSpecRel::whereIn('goods_id', $goods_ids)->delete();
// //删除商品
// GoodsModel::whereIn('goods_id', $goods_ids)->delete();
// $page++;
// }
// GoodsSku::where('store_id', $storeId)->delete();
// GoodsImage::where('store_id', $storeId)->delete();
// GoodsSpecRel::where('store_id', $storeId)->delete();
// GoodsModel::where('store_id', $storeId)->delete();
$page = 1;
while (TRUE) {
$goods_list = GoodsModel::where('store_id', $storeId)->where('channel','<>', 'zy')->field('goods_id')->page($page)->limit(2000)->select();
if ($goods_list->isEmpty()) {
return $this->renderSuccess();
}
$goods_ids = array_column($goods_list->toArray(), "goods_id");
//删除商品sku
GoodsSku::whereIn('goods_id', $goods_ids)->delete();
//删除商品图片
GoodsImage::whereIn('goods_id', $goods_ids)->delete();
//删除商品规格
GoodsSpecRel::whereIn('goods_id', $goods_ids)->delete();
//删除商品
GoodsModel::whereIn('goods_id', $goods_ids)->delete();
$page++;
}
return $this->renderSuccess();
}

@ -124,6 +124,7 @@ class Goods extends Controller
case 'jd':
case 'jd1':
case 'jd2':
case 'zy':
$province = Region::withoutGlobalScope()->where('name', $params['province'])->where('level', 1)->find();
//$city = Region::withoutGlobalScope()->where('name', $params['city'])->where('level', 2)->find();
$district = Region::withoutGlobalScope()->where('name', $params['district'])->where('level', 3)->find();
@ -131,6 +132,8 @@ class Goods extends Controller
$arr = [];
$ret = $jd->getGoodsStock($province->jd_code, $city->jd_code, $district->jd_code, $goods['goods_no'], $value['num'] ?? 1);
// echo "<pre>";
// print_r($ret);
//var_dump($ret);
if ($ret) {
$res = $ret['stockResp']['desc'] ?? "无货";

Loading…
Cancel
Save