diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 29963878..95718ff6 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -72,7 +72,7 @@ class Goods extends Controller // wmc商品详情 $model = new GoodsModel; $goodsInfo = $model->getDetails($goodsId, $verifyStatus); - + if (!empty($goodsInfo['content'])) { $goodsInfo['content'] = str_ireplace('onload="if(this.width>750){this.height=this.height*(750.0/this.width); this.width = 750;}', '', $goodsInfo['content']); } @@ -111,7 +111,7 @@ class Goods extends Controller $return = []; foreach ($params['list'] as $value) { $res = "无货"; - $goods = GoodsModel::where('goods_id', $value['goods_id'])->find(); + $goods = GoodsModel::withoutGlobalScope()->where('goods_id', $value['goods_id'])->find(); if (!$goods) { return $this->renderError('商品不存在'); } @@ -487,7 +487,7 @@ class Goods extends Controller ], ]; $app = Factory::miniProgram($config); - $data = $app->short_link->getShortLink($page_url, "", false); + $data = $app->short_link->getShortLink($page_url, "", true); $url = ""; if ($data['errcode'] == 0) { $url = $data['link']; diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php index 11f746a0..b09055ff 100644 --- a/app/api/model/Goods.php +++ b/app/api/model/Goods.php @@ -438,6 +438,9 @@ class Goods extends GoodsModel // 关联查询(商品图片、sku列表) //$with = ['images.file', 'skuList.image', 'video', 'videoCover']; $info = $this->field('spec_type,goods_id')->find($goodsId); + if (!$info) { + throwError('很抱歉,商品信息不存在'); + } // 关联查询 if ($info->spec_type == GoodsSpecTypeEnum::SINGLE) { $with = ['images.file', 'skuList1.image', 'video', 'videoCover']; diff --git a/app/common/model/Goods.php b/app/common/model/Goods.php index 2b77209a..7b33bd4b 100644 --- a/app/common/model/Goods.php +++ b/app/common/model/Goods.php @@ -27,6 +27,8 @@ use think\model\relation\HasOne; use think\Paginator; use app\store\model\GoodsImage as GoodsImageModel; use app\store\model\UploadFile as UploadFileModel; +use app\common\model\Region; + /** * 商品模型 * Class Goods @@ -177,7 +179,60 @@ class Goods extends BaseModel { return $this->hasMany('Comment'); } + /** + * 中文销售区域处理 + * [dealGoodsSaleArea description] + * @param [type] $sale_areas [description] + * @return [type] [description] + */ + public static function dealGoodsSaleArea($sale_areas){ + //批量导入销售区域处理 + $region = []; + $region_text = []; + if ($sale_areas) { + $sale_areas = explode("、", $sale_areas); + $cityNames = []; + foreach ($sale_areas as $value) { + if (strpos($value, "-") === false) { + $province = Region::withoutGlobalScope()->where('name', $value)->where('level', 1)->find(); + $citys = Region::withoutGlobalScope()->where('pid', $province['id'] ?? 0)->where('level', 2)->select()->toArray(); + $citys = array_column($citys, "name"); + + } else { + list($province, $city) = explode("-", $value); + $citys = [$city]; + } + $cityNames = array_merge($cityNames, $citys); + } + $regions = Region::withoutGlobalScope()->whereIn('name', $cityNames)->where('level', 2)->select()->toArray(); + $regionsnew = []; + foreach ($regions as $key => $value) { + $regionsnew[$value['pid']][] = $value; + } + // echo "
";
+            // print_r($regionsnew);
+            foreach ($regionsnew as $pid => $value) {
+                $privince = Region::withoutGlobalScope()->where('id', $pid)->find();
+                $region_text[$pid]['name'] = $privince['name'] ?? "";
+                $citys = [];
+
+                foreach ($value as $val) {
+                    $region[] = $val['id'];
+                    $citys[] = ['name' => $val['name']];
+                }
+                $region_text[$pid]['citys'] = $citys;
+            }
+            unset($pid);
 
+            foreach ($region_text as $pid => &$item) {
+                //如果传入的是整个省份
+                if (count($item['citys']) == Region::withoutGlobalScope()->whereIn('pid', $pid)->count()) {
+                    $item['citys'] = [];
+                }
+            }
+        }
+        return [$region, $region_text];
+    }
     /**
      * 获取商品列表
      * @param array $param 查询条件
@@ -209,7 +264,7 @@ class Goods extends BaseModel
         // 执行查询
         $list = $query
             ->alias($this->name)
-            ->field(['goods.goods_id', 'goods.goods_name', 'cmmdty_model', 'remark', 'cost_price_min', 'stock_total', 'is_check', 'goods_price_min','goods_no','goods_source','delivery_time','delivery_id','status','link','link_other','channel','is_use_jd_stock','video_id'])
+            ->field(['goods.goods_id', 'goods.goods_name', 'cmmdty_model', 'remark', 'cost_price_min', 'stock_total', 'is_check', 'goods_price_min','goods_no','goods_source','delivery_time','delivery_id','status','link','link_other','channel','is_use_jd_stock','video_id','region_text'])
             ->where('is_delete', '=', 0)
             ->order($sort)
             ->paginate($listRows);
diff --git a/app/common/service/Jd.php b/app/common/service/Jd.php
index 46bc9a8b..7367ddab 100644
--- a/app/common/service/Jd.php
+++ b/app/common/service/Jd.php
@@ -9,6 +9,7 @@ namespace app\common\service;
  * 京东服务
  */
 class Jd extends BaseService {
+
     /**
      * 获取京东商品库存
      * [getGoodsStock description]
@@ -74,8 +75,21 @@ class Jd extends BaseService {
         return [];
     }
 
-
-
+    /**
+     * 获取京东短链接
+     * [getJdShortLink description]
+     * @param  [type] $skuId [description]
+     * @return [type]        [description]
+     */
+    public function getJdShortLink($skuId){
+        //$url = "http://47.98.251.206:8811/api/goods/info/v2?sku=".$skuId."&areaId=";
+        $url = "http://8.130.98.31:8811/api/link?sku=".$skuId;
+        $res = httpRequest($url);
+        if ($res && $res['code'] == 0 && isset($res['data'])) {
+            return $res['data'];
+        }
+        return "";
+    }
 
 
 
diff --git a/app/job/controller/goods/StoreGoodsOffline.php b/app/job/controller/goods/StoreGoodsOffline.php
index 65170d57..7750a097 100644
--- a/app/job/controller/goods/StoreGoodsOffline.php
+++ b/app/job/controller/goods/StoreGoodsOffline.php
@@ -32,7 +32,7 @@ class StoreGoodsOffline extends BaseJob
     public function handle(array $data): bool
     {
         $time = date('H:i:s');
-        echo "\n  ---- GoodsOffline ----  {$time} ----   \n";
+        echo "\n  ---- StoreGoodsOffline ----  {$time} ----   \n";
 
         $service = new StoreGoodsOfflineService;
         return $service->batch($data['list']);
diff --git a/app/job/controller/goods/StoreGoodsOnline.php b/app/job/controller/goods/StoreGoodsOnline.php
index 1daab0a2..5f71d210 100644
--- a/app/job/controller/goods/StoreGoodsOnline.php
+++ b/app/job/controller/goods/StoreGoodsOnline.php
@@ -32,7 +32,7 @@ class StoreGoodsOnline extends BaseJob
     public function handle(array $data): bool
     {
         $time = date('H:i:s');
-        echo "\n  ---- GoodsOnline ----  {$time} ----   \n";
+        echo "\n  ---- StoreGoodsOnline ----  {$time} ----   \n";
 
         $service = new StoreGoodsOnlineService;
         return $service->batch($data['list']);
diff --git a/app/job/service/goods/GoodsDelete.php b/app/job/service/goods/GoodsDelete.php
index a659352a..5e3f09fc 100644
--- a/app/job/service/goods/GoodsDelete.php
+++ b/app/job/service/goods/GoodsDelete.php
@@ -12,6 +12,9 @@ use cores\exception\BaseException;
 use think\facade\Log;
 use app\common\model\Channel;
 use app\common\model\Region;
+use think\facade\Db;
+
+
 /**
  * 服务类:商品批量导入
  * Class Import
@@ -40,9 +43,18 @@ class GoodsDelete extends BaseService
             return true;
         }
         $goodsIds = array_column($goods_list->toArray(), "goods_id");
+        //删除零售商城端
         GoodsModel::whereIn('origin_goods_id', $goodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
         
-        //删除批发商城的商品
+        //删除批发商城总后台的商品
+        $wholesalePlatformGoodsList = Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $goodsIds)->field(['goods_id','is_sale','is_pool'])->select();
+        if ($wholesalePlatformGoodsList->isEmpty()) {
+            return true;
+        }
+        Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $goodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
+        //删除批发商城-商城端的商品
+        $wholesalePlatformGoodsIds = array_column($wholesalePlatformGoodsList->toArray(), "goods_id");
+        Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $wholesalePlatformGoodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
         return true;
     }
 
diff --git a/app/job/service/goods/GoodsOffline.php b/app/job/service/goods/GoodsOffline.php
index 8040c556..de5f6290 100644
--- a/app/job/service/goods/GoodsOffline.php
+++ b/app/job/service/goods/GoodsOffline.php
@@ -12,6 +12,8 @@ use cores\exception\BaseException;
 use think\facade\Log;
 use app\common\model\Channel;
 use app\common\model\Region;
+use think\facade\Db;
+
 /**
  * 服务类:商品批量导入
  * Class Import
@@ -46,7 +48,15 @@ class GoodsOffline extends BaseService
         //GoodsModel::whereIn('origin_goods_id', $goodsIds)->update(['status' => 20, 'is_jd_remove' => 1, 'update_time' => time()]);
         GoodsModel::whereIn('origin_goods_id', $goodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
         
-        //下架批发商城的商品
+        //删除批发商城总后台的商品
+        $wholesalePlatformGoodsList = Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $goodsIds)->field(['goods_id','is_sale','is_pool'])->select();
+        if ($wholesalePlatformGoodsList->isEmpty()) {
+            return true;
+        }
+        Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $goodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
+        //删除批发商城-商城端的商品
+        $wholesalePlatformGoodsIds = array_column($wholesalePlatformGoodsList->toArray(), "goods_id");
+        Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $wholesalePlatformGoodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
         return true;
     }
 
diff --git a/app/job/service/goods/GoodsOnline.php b/app/job/service/goods/GoodsOnline.php
index 0829f403..ba1ea70e 100644
--- a/app/job/service/goods/GoodsOnline.php
+++ b/app/job/service/goods/GoodsOnline.php
@@ -12,6 +12,8 @@ use cores\exception\BaseException;
 use think\facade\Log;
 use app\common\model\Channel;
 use app\common\model\Region;
+use think\facade\Db;
+
 /**
  * 服务类:商品批量导入
  * Class Import
@@ -42,9 +44,25 @@ class GoodsOnline extends BaseService
             return true;
         }
         $goodsIds = array_column($goods_list->toArray(), "goods_id");
-        GoodsModel::whereIn('origin_goods_id', $goodsIds)->update(['status' => 10, 'is_jd_remove' => 0, 'update_time' => time(), 'is_delete' => 0]);
+        $up_data = [
+            'is_sale' => 1, 
+            'is_pool' => 1, 
+            'status' => 10, 
+            'is_jd_remove' => 0, 
+            'update_time' => time(), 
+            'is_delete' => 0
+        ];
+        GoodsModel::whereIn('origin_goods_id', $goodsIds)->update($up_data);
 
-        //上架批发商城的商品
+        //上架批发商城总后台的商品
+        $wholesalePlatformGoodsList = Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $goodsIds)->field(['goods_id','is_sale','is_pool'])->select();
+        if ($wholesalePlatformGoodsList->isEmpty()) {
+            return true;
+        }
+        Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $goodsIds)->update($up_data);
+        //上架批发商城-商城端的商品
+        $wholesalePlatformGoodsIds = array_column($wholesalePlatformGoodsList->toArray(), "goods_id");
+        Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $wholesalePlatformGoodsIds)->update($up_data);
         return true;
     }
 
diff --git a/app/job/service/goods/GoodsStoreImport.php b/app/job/service/goods/GoodsStoreImport.php
index 895fdecd..b1ffaec3 100644
--- a/app/job/service/goods/GoodsStoreImport.php
+++ b/app/job/service/goods/GoodsStoreImport.php
@@ -197,50 +197,51 @@ class GoodsStoreImport extends BaseService
     public function createData(array $original, int $storeId, int $merchantId = 0): array
     {
         //批量导入销售区域处理
-        $region = [];
-        $region_text = [];
-        if ($original["L"]) {
-            $sale_areas = $original["L"] ? explode("、", $original["L"]) : [];
-            $cityNames = [];
-            foreach ($sale_areas as $value) {
-                if (strpos($value, "-") === false) {
-                    $province = Region::withoutGlobalScope()->where('name', $value)->where('level', 1)->find();
-                    $citys = Region::withoutGlobalScope()->where('pid', $province['id'] ?? 0)->where('level', 2)->select()->toArray();
-                    $citys = array_column($citys, "name");
+        // $region = [];
+        // $region_text = [];
+        // if ($original["L"]) {
+        //     $sale_areas = $original["L"] ? explode("、", $original["L"]) : [];
+        //     $cityNames = [];
+        //     foreach ($sale_areas as $value) {
+        //         if (strpos($value, "-") === false) {
+        //             $province = Region::withoutGlobalScope()->where('name', $value)->where('level', 1)->find();
+        //             $citys = Region::withoutGlobalScope()->where('pid', $province['id'] ?? 0)->where('level', 2)->select()->toArray();
+        //             $citys = array_column($citys, "name");
 
-                } else {
-                    list($province, $city) = explode("-", $value);
-                    $citys = [$city];
-                }
-                $cityNames = array_merge($cityNames, $citys);
-            }
-            $regions = Region::withoutGlobalScope()->whereIn('name', $cityNames)->where('level', 2)->select()->toArray();
-            $regionsnew = [];
-            foreach ($regions as $key => $value) {
-                $regionsnew[$value['pid']][] = $value;
-            }
-            // echo "
";
-            // print_r($regionsnew);
-            foreach ($regionsnew as $pid => $value) {
-                $privince = Region::withoutGlobalScope()->where('id', $pid)->find();
-                $region_text[$pid]['name'] = $privince['name'] ?? "";
-                $citys = [];
+        //         } else {
+        //             list($province, $city) = explode("-", $value);
+        //             $citys = [$city];
+        //         }
+        //         $cityNames = array_merge($cityNames, $citys);
+        //     }
+        //     $regions = Region::withoutGlobalScope()->whereIn('name', $cityNames)->where('level', 2)->select()->toArray();
+        //     $regionsnew = [];
+        //     foreach ($regions as $key => $value) {
+        //         $regionsnew[$value['pid']][] = $value;
+        //     }
+        //     // echo "
";
+        //     // print_r($regionsnew);
+        //     foreach ($regionsnew as $pid => $value) {
+        //         $privince = Region::withoutGlobalScope()->where('id', $pid)->find();
+        //         $region_text[$pid]['name'] = $privince['name'] ?? "";
+        //         $citys = [];
 
-                foreach ($value as $val) {
-                    $region[] = $val['id'];
-                    $citys[] = ['name' => $val['name']];
-                }
-                $region_text[$pid]['citys'] = $citys;
-            }
-            unset($pid);
+        //         foreach ($value as $val) {
+        //             $region[] = $val['id'];
+        //             $citys[] = ['name' => $val['name']];
+        //         }
+        //         $region_text[$pid]['citys'] = $citys;
+        //     }
+        //     unset($pid);
 
-            foreach ($region_text as $pid => &$item) {
-                //如果传入的是整个省份
-                if (count($item['citys']) == Region::withoutGlobalScope()->whereIn('pid', $pid)->count()) {
-                    $item['citys'] = [];
-                }
-            }
-        }
+        //     foreach ($region_text as $pid => &$item) {
+        //         //如果传入的是整个省份
+        //         if (count($item['citys']) == Region::withoutGlobalScope()->whereIn('pid', $pid)->count()) {
+        //             $item['citys'] = [];
+        //         }
+        //     }
+        // }
+        list($region, $region_text) = GoodsModel::dealGoodsSaleArea($original["L"]);
         // echo "
";
         //     print_r($region_text);
         //     print_r($region);
diff --git a/app/job/service/goods/StoreGoodsDelete.php b/app/job/service/goods/StoreGoodsDelete.php
index 1170a9ab..dfa763f4 100644
--- a/app/job/service/goods/StoreGoodsDelete.php
+++ b/app/job/service/goods/StoreGoodsDelete.php
@@ -12,6 +12,8 @@ use cores\exception\BaseException;
 use think\facade\Log;
 use app\common\model\Channel;
 use app\common\model\Region;
+use think\facade\Db;
+
 /**
  * 服务类:商品批量导入
  * Class Import
@@ -32,6 +34,7 @@ class StoreGoodsDelete extends BaseService
      */
     public function batch(array $goodsIds): bool
     {
+        
         $goods_list = GoodsModel::whereIn('goods_id', $goodsIds)
                     ->where('is_delete',1)
                     ->field(['goods_id','is_sale','is_pool'])
@@ -40,9 +43,25 @@ class StoreGoodsDelete extends BaseService
             return true;
         }
         $goodsIds = array_column($goods_list->toArray(), "goods_id");
-        GoodsModel::whereIn('origin_goods_id', $goodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
+        $platformGoodsList = GoodsModel::whereIn('origin_goods_id', $goodsIds)->field(['goods_id','is_sale','is_pool'])->select();
+        if ($platformGoodsList->isEmpty()) {
+            return true;
+        }
+        //删除零售总后台的商品
         
-        //删除批发商城的商品
+        GoodsModel::whereIn('origin_goods_id', $goodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
+        //删除零售商城的商品
+        $platformGoodsIds = array_column($platformGoodsList->toArray(), "goods_id");
+        GoodsModel::whereIn('origin_goods_id', $platformGoodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
+        //删除批发商城总后台的商品
+        $wholesalePlatformGoodsList = Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $platformGoodsIds)->field(['goods_id','is_sale','is_pool'])->select();
+        if ($wholesalePlatformGoodsList->isEmpty()) {
+            return true;
+        }
+        Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $platformGoodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
+        //删除批发商城-商城端的商品
+        $wholesalePlatformGoodsIds = array_column($wholesalePlatformGoodsList->toArray(), "goods_id");
+        Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $wholesalePlatformGoodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
         return true;
     }
 
diff --git a/app/job/service/goods/StoreGoodsOffline.php b/app/job/service/goods/StoreGoodsOffline.php
index 8040c556..4a65abd0 100644
--- a/app/job/service/goods/StoreGoodsOffline.php
+++ b/app/job/service/goods/StoreGoodsOffline.php
@@ -12,12 +12,14 @@ use cores\exception\BaseException;
 use think\facade\Log;
 use app\common\model\Channel;
 use app\common\model\Region;
+use think\facade\Db;
+
 /**
  * 服务类:商品批量导入
  * Class Import
  * @package app\job\service\goods
  */
-class GoodsOffline extends BaseService
+class StoreGoodsOffline extends BaseService
 {
     /**
      * 批量导入商品
@@ -33,20 +35,32 @@ class GoodsOffline extends BaseService
     public function batch(array $goodsIds): bool
     {
         $goods_list = GoodsModel::whereIn('goods_id', $goodsIds)
-                    ->where('is_delete',0)
-                    ->where(function($query){
-                        $query->where('is_pool',2)->whereOr('is_sale',0);
-                    })
                     ->field(['goods_id','is_sale','is_pool'])
                     ->select();
         if ($goods_list->isEmpty()) {
             return true;
         }
         $goodsIds = array_column($goods_list->toArray(), "goods_id");
-        //GoodsModel::whereIn('origin_goods_id', $goodsIds)->update(['status' => 20, 'is_jd_remove' => 1, 'update_time' => time()]);
+        $platformGoodsList = GoodsModel::whereIn('origin_goods_id', $goodsIds)->field(['goods_id','is_sale','is_pool'])->select();
+        if ($platformGoodsList->isEmpty()) {
+            return true;
+        }
+        //删除零售总后台的商品
+        
         GoodsModel::whereIn('origin_goods_id', $goodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
+        //删除零售商城的商品
+        $platformGoodsIds = array_column($platformGoodsList->toArray(), "goods_id");
+        GoodsModel::whereIn('origin_goods_id', $platformGoodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
+        //删除批发商城总后台的商品
+        $wholesalePlatformGoodsList = Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $platformGoodsIds)->field(['goods_id','is_sale','is_pool'])->select();
+        if ($wholesalePlatformGoodsList->isEmpty()) {
+            return true;
+        }
+        Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $platformGoodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
+        //删除批发商城-商城端的商品
+        $wholesalePlatformGoodsIds = array_column($wholesalePlatformGoodsList->toArray(), "goods_id");
+        Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $wholesalePlatformGoodsIds)->update(['is_delete' => 1, 'update_time' => time()]);
         
-        //下架批发商城的商品
         return true;
     }
 
diff --git a/app/job/service/goods/StoreGoodsOnline.php b/app/job/service/goods/StoreGoodsOnline.php
index 7eafdfd8..dcd4fd43 100644
--- a/app/job/service/goods/StoreGoodsOnline.php
+++ b/app/job/service/goods/StoreGoodsOnline.php
@@ -12,6 +12,8 @@ use cores\exception\BaseException;
 use think\facade\Log;
 use app\common\model\Channel;
 use app\common\model\Region;
+use think\facade\Db;
+
 /**
  * 服务类:商品批量导入
  * Class Import
@@ -34,7 +36,7 @@ class StoreGoodsOnline extends BaseService
     {
         $goods_list = GoodsModel::whereIn('goods_id', $goodsIds)
                     ->where('is_delete',0)
-                    ->where('is_sale',1)
+                    ->where('status',10)
                     ->where('is_pool',1)
                     ->field(['goods_id','is_sale','is_pool'])
                     ->select();
@@ -42,9 +44,32 @@ class StoreGoodsOnline extends BaseService
             return true;
         }
         $goodsIds = array_column($goods_list->toArray(), "goods_id");
-        GoodsModel::whereIn('origin_goods_id', $goodsIds)->update(['status' => 10, 'is_jd_remove' => 0, 'update_time' => time(), 'is_delete' => 0]);
-
-        //上架批发商城的商品
+        $platformGoodsList = GoodsModel::whereIn('origin_goods_id', $goodsIds)->field(['goods_id','is_sale','is_pool'])->select();
+        if ($platformGoodsList->isEmpty()) {
+            return true;
+        }
+        $up_data = [
+            'is_sale' => 1, 
+            'is_pool' => 1, 
+            'status' => 10, 
+            'is_jd_remove' => 0, 
+            'update_time' => time(), 
+            'is_delete' => 0
+        ];
+        //上架零售商城总后台的商品
+        GoodsModel::whereIn('origin_goods_id', $goodsIds)->update($up_data);
+        //上架零售商城-商城端的商品
+        $platformGoodsIds = array_column($platformGoodsList->toArray(), "goods_id");
+        GoodsModel::whereIn('origin_goods_id', $platformGoodsIds)->update($up_data);
+        //上架批发商城总后台的商品
+        $wholesalePlatformGoodsList = Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $platformGoodsIds)->field(['goods_id','is_sale','is_pool'])->select();
+        if ($wholesalePlatformGoodsList->isEmpty()) {
+            return true;
+        }
+        Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $platformGoodsIds)->update($up_data);
+        //上架批发商城-商城端的商品
+        $wholesalePlatformGoodsIds = array_column($wholesalePlatformGoodsList->toArray(), "goods_id");
+        Db::connect("dataCenterMysql")->table('yoshop_goods')->whereIn('origin_goods_id', $wholesalePlatformGoodsIds)->update($up_data);
         return true;
     }
 
diff --git a/app/store/controller/Controller.php b/app/store/controller/Controller.php
index b50d0573..25bbc188 100644
--- a/app/store/controller/Controller.php
+++ b/app/store/controller/Controller.php
@@ -201,6 +201,7 @@ class Controller extends BaseController
      */
     private function checkStore(): void
     {
+       
         if (!$this->storeId) {
             return;
         }
diff --git a/app/store/controller/Goods.php b/app/store/controller/Goods.php
index 32826691..a04d054d 100644
--- a/app/store/controller/Goods.php
+++ b/app/store/controller/Goods.php
@@ -18,6 +18,14 @@ use cores\exception\BaseException;
 use app\store\model\Goods as GoodsModel;
 use app\store\model\goods\Import as ImportModel;
 use app\common\model\GoodsCategoryRel;
+use app\common\model\Category;
+use app\job\controller\goods\StoreGoodsOffline as StoreGoodsOfflineJob;
+use app\job\controller\goods\StoreGoodsOnline as StoreGoodsOnlineJob;
+use app\job\controller\goods\StoreGoodsDelete as StoreGoodsDeleteJob;
+use app\common\service\Jd;
+use app\common\model\wxapp\Setting as WxappSettingModel;
+use EasyWeChat\Factory;
+
 /**
  * 商品管理控制器
  * Class Goods
@@ -197,6 +205,24 @@ class Goods extends Controller
         if (!$model->setIsPool($goodsIds, $state)) {
             return $this->renderError($model->getError() ?: '操作失败');
         }
+        // 分批每次导入20条
+        $limit = 20;
+        // 根据商品总数量计算需要的队列任务数量
+        $jobCount = \count($goodsIds) / $limit;
+        // 逐次发布队列任务
+        for ($i = 0; $i < $jobCount; $i++) {
+            $data = array_slice($goodsIds, $i * $limit, $limit);
+            if ($state == 2) {
+                StoreGoodsOfflineJob::dispatch([
+                        'list' => $data,
+                    ]);
+                
+            } elseif ($state == 1) {
+                StoreGoodsOnlineJob::dispatch([
+                        'list' => $data,
+                    ]);
+            }
+        }
         return $this->renderSuccess('操作成功');
     }
     /**
@@ -211,6 +237,24 @@ class Goods extends Controller
         if (!$model->setStatus($goodsIds, $state)) {
             return $this->renderError($model->getError() ?: '操作失败');
         }
+        // 分批每次导入20条
+        $limit = 20;
+        // 根据商品总数量计算需要的队列任务数量
+        $jobCount = \count($goodsIds) / $limit;
+        // 逐次发布队列任务
+        for ($i = 0; $i < $jobCount; $i++) {
+            $data = array_slice($goodsIds, $i * $limit, $limit);
+            if ($state == false) {
+                StoreGoodsOfflineJob::dispatch([
+                        'list' => $data,
+                    ]);
+                
+            } elseif ($state == true) {
+                StoreGoodsOnlineJob::dispatch([
+                        'list' => $data,
+                    ]);
+            }
+        }
         return $this->renderSuccess('操作成功');
     }
     /**
@@ -341,12 +385,27 @@ class Goods extends Controller
                 }
                 $cates = GoodsCategoryRel::where('goods_id', $value['goods_id'])->select()->toArray();
                 $value['category_id'] = $cates ? implode(",", array_column($cates, "category_id")) : "";
+                $region_text = $value['region_text'] ? json_decode($value['region_text'], true) : [];
+                $str = "";
+                $link = ";";
+                $replace = "、";
+                if ($region_text) {
+                    foreach ($region_text as $key => $val) {
+                        if (!$val['citys']) {
+                            $str .= $val['name'].$link;
+                        } else {
+                            foreach ($val['citys'] as $key => $va) {
+                                $str .= $val['name']."-".$va['name'].$link;
+                            }
+                            
+                        }
+                    }
+                }
+
+                $value['region_text'] =  str_replace(";", $replace, rtrim($str, $link)) ;
             }
         }
         
-        // echo "
";
-        // print_r($data);
-        // exit();
         $titles = [
             ['goods_id'=>'系统编码(禁止修改)'],
             ['goods_name'=>'标题'],
@@ -364,11 +423,113 @@ class Goods extends Controller
             // ['stock_total'=>'库存量'],
             ['remark'=>'下单须知'],
             ['is_use_jd_stock'=>'是否使用京东库存(是填1 否填0)'],
+            ['region_text'=>'销售区域'],
+
         ];
         
         downLoadExcel('导出数据-'.date('Y-m-d', time()),$titles,$data['data']);
     }
+    //文案导出
+    public function copyExport(){
+        ini_set('memory_limit', '2024M');
+        set_time_limit(0);
+        $model = new GoodsModel;
+        $params = $this->request->param();
+        $params['store_id'] = $this->storeId;
+        $perSize = 10000;
+        $params['page'] = 1;
+        if ($this->merchantId) {
+            $params['merchantId'] = $this->merchantId;
+        }
+        //$params['channels'] = ['zy'];
+        // echo "
";
+        // print_r($params);
+        //exit();
+        $data = $model->getAdminListExport($params, $perSize)->toArray();
+        // echo "
";
+        // print_r($data['data']);
+        // exit();
+        $jd = new Jd();
+        $store_id = GoodsModel::$storeId;
+        $wxConfig = WxappSettingModel::getConfigBasic($store_id);
+        $config = [
+            'app_id' => $wxConfig['app_id'],
+            'secret' => $wxConfig['app_secret'],
+            'response_type' => 'array',// 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
+            'log' => [
+                'level' => 'debug',
+                'file' => app()->getRuntimePath().'wechat.log',
+            ],
+        ];
+        $app = Factory::miniProgram($config);
+        
+
+        if ($data['data']) {
+            foreach ($data['data'] as &$value) {
+                //小程序短链
+                $data1 = $app->short_link->getShortLink("pages/goods/detail?refereeId=0&goodsId=".$value['goods_id'], "", true);
+                $value['applet_short_url'] = "";
+                if ($data1['errcode'] == 0) {
+                    $value['applet_short_url'] = $data1['link'];
+                }
+                //京东短链
+                $value['jd_short_url'] = $jd->getJdShortLink($value['goods_no']);
+                $value['h5_url'] = "https://www.royaum.com.cn/mobile/#/pages/goods/detail?goodsId=".$value['goods_id']."&storeId=".$store_id;
+                //分类
+                $value['category_3'] = "无";
+                $value['category_4'] = "无";
+                $value['membership_price'] = $value['goods_price_min'];
+                $cates = GoodsCategoryRel::where('goods_id', $value['goods_id'])->select()->toArray();
+                if ($cates) {
+                    $cateList = Category::whereIn('category_id', array_column($cates, 'category_id'))->whereIn('level',[3,4])->order("level asc")->select()->toArray();
+
+                    $value['category_3'] = $cateList[0]['name'] ?? "无";
+                    $value['category_4'] = $cateList[1]['name'] ?? "无";
+                    //会员价
+                    $value['membership_price'] = \app\common\model\PriceSet::membershipPrice($value['goods_price_min'], $value['cost_price_min'], array_column($cates, 'category_id'));
+                }
+                
+                //销售区域
+                $region_text = $value['region_text'] ? json_decode($value['region_text'], true) : [];
+                $str = "";
+                $link = ";";
+                $replace = "、";
+                if ($region_text) {
+                    foreach ($region_text as $key => $val) {
+                        if (!$val['citys']) {
+                            $str .= $val['name'].$link;
+                        } else {
+                            foreach ($val['citys'] as $key => $va) {
+                                $str .= $val['name']."-".$va['name'].$link;
+                            }
+                            
+                        }
+                    }
+                }
 
+                $value['region_text'] =  $str ? str_replace(";", $replace, rtrim($str, $link)) : "全国";
+            }
+        }
+        
+        // echo "
";
+        // print_r($data);
+        // exit();
+        $titles = [
+            ['goods_id'=>'系统编码'],
+            ['category_3'=>'三级分类'],
+            ['category_4'=>'四级分类'],
+            ['goods_name'=>'标题'],
+            ['cmmdty_model'=>'型号'],
+            ['membership_price'=>'推广价'],
+            ['goods_price_min'=>'市场价'],
+            ['jd_short_url'=>'同款链接'],
+            ['applet_short_url'=>'小程序链接'],
+            ['h5_url'=>'H5链接'],
+            ['region_text'=>'销售区域'],
+        ];
+        
+        downLoadExcel('导出数据-'.date('Y-m-d', time()),$titles,$data['data']);
+    }
     public function import(){
         // 新增记录
         $model = new ImportModel;
diff --git a/app/store/controller/Store.php b/app/store/controller/Store.php
index 115fa011..1432708b 100644
--- a/app/store/controller/Store.php
+++ b/app/store/controller/Store.php
@@ -15,6 +15,7 @@ namespace app\store\controller;
 use app\common\model\store\StoreSettle;
 use think\response\Json;
 use app\store\model\Store as StoreModel;
+use app\admin\model\Store as AdminStoreModel;
 use app\common\model\Channel;
 use app\common\model\PriceSet;
 
@@ -26,6 +27,53 @@ use app\common\model\PriceSet;
 
 class Store extends Controller
 {
+    /**
+     * 商城列表
+     * @return Json
+     * @throws \think\db\exception\DbException
+     */
+    public function index(): Json
+    {
+        // 商城列表
+        $model = new AdminStoreModel;
+        $list = $model->getList();
+        if (!$list->isEmpty()) {
+            $list = $list->toArray();
+            foreach ($list['data'] as &$value) {
+                $value['store_version'] = $value['store_version'] == 0 ? "单商户" : "多商户";
+            }
+        }
+        return $this->renderSuccess(compact('list'));
+    }
+    /**
+     * 新增商城
+     * @return Json
+     */
+    public function add(): Json
+    {
+        // 新增记录
+        $model = new AdminStoreModel;
+        if ($model->add($this->postForm())) {
+            return $this->renderSuccess('添加成功');
+        }
+        return $this->renderError($model->getError() ?: '添加失败');
+    }
+    /**
+     * 更新商城信息
+     * @return Json
+     */
+    public function edit(int $storeId): Json
+    {
+        $params = $this->postForm();
+        // 商城详情
+        $model = AdminStoreModel::detail($storeId);
+        // 更新记录
+        if (!$model->edit($params)) {
+            return $this->renderError($model->getError() ?: '更新失败');
+        }
+        return $this->renderSuccess('更新成功');
+    }
+
     /**
      * 获取当前登录的商城信息
      * @return Json
diff --git a/app/store/model/goods/Import.php b/app/store/model/goods/Import.php
index f8cce590..a3af3f48 100644
--- a/app/store/model/goods/Import.php
+++ b/app/store/model/goods/Import.php
@@ -241,7 +241,7 @@ class Import extends ImportModel
         
         self::$storeId = $form['store_id'] ?? 0;
         foreach ($execlData as $key => $value) {
-
+            list($region, $region_text) = GoodsModel::dealGoodsSaleArea($value["P"]);
             $upData = [
                 'goods_name'=> $value['B'],
                 'cmmdty_model'=> $value['C'],
@@ -259,6 +259,8 @@ class Import extends ImportModel
                 'stock_total'=> $value['M'],
                 'remark'=> $value['N'],
                 'is_use_jd_stock'=> $value['O'],
+                'region' => $region ? json_encode($region, JSON_UNESCAPED_UNICODE) : "",
+                'region_text' => $region_text ? json_encode(array_values($region_text), JSON_UNESCAPED_UNICODE) : "",
             ];
             $goods = GoodsModel::where('goods_id', $value['A'])->find();
             if (!$goods) {
diff --git a/config/allowapi.php b/config/allowapi.php
index 16f2a9d3..07f9a745 100644
--- a/config/allowapi.php
+++ b/config/allowapi.php
@@ -12,6 +12,7 @@
 		"/goods/setNew",
 		"/goods/setBrand",
 		"/goods/pool",
+		"/goods/copyExport",
 		"/merchant/getMerchantGoodsCate",
 		"/merchant/setMerchantGoodsCate",
 		"/merchant/getShopCategory",
diff --git a/config/database.php b/config/database.php
index 966fe179..f3327b1f 100644
--- a/config/database.php
+++ b/config/database.php
@@ -33,6 +33,7 @@ return [
 
     // 数据库连接配置信息
     'connections' => [
+        //零售商城数据库
         'mysql' => [
             // 数据库类型
             'type' => env('database.type', 'mysql'),
@@ -72,6 +73,7 @@ return [
             // 字段缓存路径
             'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR,
         ],
+        //批发商城数据库
         'dataCenterMysql' => [
             // 数据库类型
             'type' => env('wdatabase.type', 'mysql'),
@@ -88,9 +90,9 @@ return [
             // 数据库连接参数
             'params' => [],
             // 数据库编码默认采用utf8
-            'charset' => env('wdatabase.charset', 'utf8'),
+            'charset' => env('wdatabase.charset', 'utf8mb4'),
             // 数据库表前缀
-            'prefix' => "",
+            //'prefix' => env('database.prefix', 'yoshop_'),
 
             // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
             'deploy' => 0,