commit
13e36d232f
@ -0,0 +1,52 @@ |
|||||||
|
<?php |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Author: 萤火科技 <admin@yiovo.com> |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
declare (strict_types=1); |
||||||
|
|
||||||
|
namespace app\api\controller; |
||||||
|
|
||||||
|
use app\api\model\Region as RegionModel; |
||||||
|
use think\response\Json; |
||||||
|
|
||||||
|
/** |
||||||
|
* 地区管理 |
||||||
|
* Class Region |
||||||
|
* @package app\api\controller |
||||||
|
*/ |
||||||
|
class Region extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* 获取所有地区 |
||||||
|
* @return Json |
||||||
|
* @throws \think\db\exception\DataNotFoundException |
||||||
|
* @throws \think\db\exception\DbException |
||||||
|
* @throws \think\db\exception\ModelNotFoundException |
||||||
|
*/ |
||||||
|
public function all(): Json |
||||||
|
{ |
||||||
|
$list = RegionModel::getCacheAll(); |
||||||
|
return $this->renderSuccess(compact('list')); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取所有地区(树状) |
||||||
|
* @return Json |
||||||
|
* @throws \think\db\exception\DataNotFoundException |
||||||
|
* @throws \think\db\exception\DbException |
||||||
|
* @throws \think\db\exception\ModelNotFoundException |
||||||
|
*/ |
||||||
|
public function tree(): Json |
||||||
|
{ |
||||||
|
$model = new RegionModel(); |
||||||
|
$list = $model->getNewTreeList(); |
||||||
|
//$list = array_values($list); |
||||||
|
return $this->renderSuccess(compact('list')); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,329 @@ |
|||||||
|
<?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; |
||||||
|
use app\store\model\Category as CategoryModel; |
||||||
|
use app\common\model\Store; |
||||||
|
use think\facade\Db; |
||||||
|
|
||||||
|
class SyncCategory extends Command |
||||||
|
{ |
||||||
|
|
||||||
|
const DEFAULT_STORE_ID = 0; |
||||||
|
protected function configure() |
||||||
|
{ |
||||||
|
// 指令配置 |
||||||
|
$this->setName('SyncCategory')->setDescription('同步商品数据到ES'); |
||||||
|
$this->addArgument("store_id"); |
||||||
|
$this->addArgument("is_update_image"); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected function execute(Input $input, Output $output) |
||||||
|
{ |
||||||
|
// $store_id = $input->getArgument("store_id"); |
||||||
|
$is_update_image = $input->getArgument("is_update_image"); |
||||||
|
// $where[] = ['is_sync_cate','=', 1]; |
||||||
|
// $where[] = ['is_delete','=', 0]; |
||||||
|
// $where[] = ['is_recycle','=', 0]; |
||||||
|
// $where[] = ['status','=', 1]; |
||||||
|
|
||||||
|
// if ($store_id) { |
||||||
|
// $where[] = ['store_id','=', $store_id]; |
||||||
|
// } else { |
||||||
|
// $where[] = ['store_id', '<>', self::DEFAULT_STORE_ID]; |
||||||
|
// } |
||||||
|
// $stores = Store::where($where)->field('store_id,is_sync,is_recycle,status,is_delete')->select()->toArray(); |
||||||
|
// if (!$stores) { |
||||||
|
// echo "没有要同步的商城了"; |
||||||
|
// return; |
||||||
|
// } |
||||||
|
// foreach ($stores as $store) { |
||||||
|
$this->copyCategory(0, $is_update_image); |
||||||
|
//} |
||||||
|
} |
||||||
|
|
||||||
|
public function copyCategory(int $new_store_id, $is_update_image = 0){ |
||||||
|
$store_id = 0; |
||||||
|
$model = new CategoryModel; |
||||||
|
$list = Db::connect("shopMysql")->name('yoshop_category')->where('store_id', 0)->order(['sort', 'create_time'])->select(); |
||||||
|
$list = $this->getTreeData($list); |
||||||
|
//$list = $model->getList(['store_id' => self::DEFAULT_STORE_ID]); |
||||||
|
// var_dump($list); |
||||||
|
// exit(); |
||||||
|
if (!$list) { |
||||||
|
return; |
||||||
|
} |
||||||
|
foreach ($list as $value) { |
||||||
|
//$value = $value->toArray(); |
||||||
|
if ($value['status'] != 1) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
$category = CategoryModel::where('original_category_id', $value['category_id'])->where('store_id', $new_store_id)->find(); |
||||||
|
if ($category) { |
||||||
|
//更新分类 |
||||||
|
//父类id |
||||||
|
if ($value['parent_id']) { |
||||||
|
$p_category = CategoryModel::where('original_category_id', $value['parent_id'])->where('store_id', $new_store_id)->find(); |
||||||
|
} |
||||||
|
$upData = [ |
||||||
|
'name' => $value['name'], |
||||||
|
'level' => $value['level'], |
||||||
|
'sort' => $value['sort'], |
||||||
|
'parent_id' => $p_category['category_id'] ?? 0, |
||||||
|
]; |
||||||
|
if ($is_update_image) { |
||||||
|
$upData['image_id'] = $value['image_id'] ? $this->copyImage($value['image_id'], $new_store_id) : 0; |
||||||
|
$upData['rank_image_id'] = $value['rank_image_id'] ? $this->copyImage($value['rank_image_id'], $new_store_id) : 0; |
||||||
|
} |
||||||
|
// var_dump($upData); |
||||||
|
// exit(); |
||||||
|
$ret = CategoryModel::where('category_id', $category->category_id)->update($upData); |
||||||
|
echo "更新成功".PHP_EOL; |
||||||
|
var_dump($ret); |
||||||
|
$firstid = $category->category_id; |
||||||
|
} else { |
||||||
|
//新增一个分类 |
||||||
|
$value['store_id'] = $new_store_id; |
||||||
|
$value['create_time'] = time(); |
||||||
|
$value['update_time'] = time(); |
||||||
|
$value['image_id'] = $value['image_id'] ? $this->copyImage($value['image_id'], $new_store_id) : 0; |
||||||
|
$value['rank_image_id'] = $value['rank_image_id'] ? $this->copyImage($value['rank_image_id'], $new_store_id) : 0; |
||||||
|
$value['original_category_id'] = $value['category_id']; |
||||||
|
$temp = $value; |
||||||
|
unset($temp['children']); |
||||||
|
unset($temp['rankimage']); |
||||||
|
unset($temp['image']); |
||||||
|
unset($temp['category_id']); |
||||||
|
$firstid = Db::table('yoshop_category')->insertGetId($temp); |
||||||
|
} |
||||||
|
|
||||||
|
if (!isset($value['children']) || !$value['children']) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
foreach ($value['children'] as $value1) { |
||||||
|
//$value1 = $value1->toArray(); |
||||||
|
if ($value1['status'] != 1) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
$category1 = CategoryModel::where('original_category_id', $value1['category_id'])->where('store_id', $new_store_id)->find(); |
||||||
|
//var_dump($category1->toArray()); |
||||||
|
if ($category1) { |
||||||
|
//更新分类 |
||||||
|
//父类id |
||||||
|
$p_category1 = CategoryModel::where('original_category_id', $value1['parent_id'])->where('store_id', $new_store_id)->find(); |
||||||
|
// var_dump($p_category1); |
||||||
|
// exit(); |
||||||
|
$upData1 = [ |
||||||
|
'name' => $value1['name'], |
||||||
|
'level' => $value1['level'], |
||||||
|
'sort' => $value1['sort'], |
||||||
|
'parent_id' => $p_category1['category_id'] ?? 0, |
||||||
|
]; |
||||||
|
if ($is_update_image) { |
||||||
|
$upData1['image_id'] = $value1['image_id'] ? $this->copyImage($value1['image_id'], $new_store_id) : 0; |
||||||
|
$upData1['rank_image_id'] = $value1['rank_image_id'] ? $this->copyImage($value1['rank_image_id'], $new_store_id) : 0; |
||||||
|
} |
||||||
|
$ret = CategoryModel::where('category_id', $category1->category_id)->update($upData1); |
||||||
|
echo "更新成功".PHP_EOL; |
||||||
|
var_dump($ret); |
||||||
|
$secondid = $category1->category_id; |
||||||
|
} else { |
||||||
|
//新增一个分类 |
||||||
|
$value1['parent_id'] = $firstid; |
||||||
|
$value1['store_id'] = $new_store_id; |
||||||
|
$value1['create_time'] = time(); |
||||||
|
$value1['update_time'] = time(); |
||||||
|
$value1['image_id'] = $value1['image_id'] ? $this->copyImage($value1['image_id'], $new_store_id) : 0; |
||||||
|
$value1['rank_image_id'] = $value1['rank_image_id'] ? $this->copyImage($value1['rank_image_id'], $new_store_id) : 0; |
||||||
|
$value1['original_category_id'] = $value1['category_id']; |
||||||
|
$temp1 = $value1; |
||||||
|
unset($temp1['children']); |
||||||
|
unset($temp1['image']); |
||||||
|
unset($temp1['rankimage']); |
||||||
|
unset($temp1['category_id']); |
||||||
|
|
||||||
|
$secondid = Db::table('yoshop_category')->insertGetId($temp1); |
||||||
|
} |
||||||
|
|
||||||
|
if (!isset($value1['children']) || !$value1['children']) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
foreach ($value1['children'] as $value2) { |
||||||
|
//$value2 = $value2->toArray(); |
||||||
|
if ($value2['status'] != 1) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
$category2 = CategoryModel::where('original_category_id', $value2['category_id'])->where('store_id', $new_store_id)->find(); |
||||||
|
if ($category2) { |
||||||
|
//更新分类 |
||||||
|
//父类id |
||||||
|
$p_category2 = CategoryModel::where('original_category_id', $value2['parent_id'])->where('store_id', $new_store_id)->find(); |
||||||
|
$upData2 = [ |
||||||
|
'name' => $value2['name'], |
||||||
|
'level' => $value2['level'], |
||||||
|
'sort' => $value2['sort'], |
||||||
|
'parent_id' => $p_category2['category_id'] ?? 0, |
||||||
|
]; |
||||||
|
if ($is_update_image) { |
||||||
|
$upData2['image_id'] = $value2['image_id'] ? $this->copyImage($value2['image_id'], $new_store_id) : 0; |
||||||
|
$upData2['rank_image_id'] = $value2['rank_image_id'] ? $this->copyImage($value2['rank_image_id'], $new_store_id) : 0; |
||||||
|
} |
||||||
|
$ret = CategoryModel::where('category_id', $category2->category_id)->update($upData2); |
||||||
|
echo "更新成功".PHP_EOL; |
||||||
|
var_dump($ret); |
||||||
|
$thirdid = $category2->category_id; |
||||||
|
} else { |
||||||
|
//新增一个分类 |
||||||
|
$value2['parent_id'] = $secondid; |
||||||
|
$value2['store_id'] = $new_store_id; |
||||||
|
$value2['create_time'] = time(); |
||||||
|
$value2['update_time'] = time(); |
||||||
|
$value2['image_id'] = $value2['image_id'] ? $this->copyImage($value2['image_id'], $new_store_id) : 0; |
||||||
|
$value2['rank_image_id'] = $value2['rank_image_id'] ? $this->copyImage($value2['rank_image_id'], $new_store_id) : 0; |
||||||
|
$value2['original_category_id'] = $value2['category_id']; |
||||||
|
$temp2 = $value2; |
||||||
|
unset($temp2['children']); |
||||||
|
unset($temp2['image']); |
||||||
|
unset($temp2['rankimage']); |
||||||
|
unset($temp2['category_id']); |
||||||
|
|
||||||
|
$thirdid = Db::table('yoshop_category')->insertGetId($temp2); |
||||||
|
} |
||||||
|
|
||||||
|
if (!isset($value2['children']) || !$value2['children']) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
foreach ($value2['children'] as $value3) { |
||||||
|
//$value3 = $value3->toArray(); |
||||||
|
if ($value3['status'] != 1) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
$category3 = CategoryModel::where('original_category_id', $value3['category_id'])->where('store_id', $new_store_id)->find(); |
||||||
|
if ($category3) { |
||||||
|
//更新分类 |
||||||
|
//父类id |
||||||
|
$p_category3 = CategoryModel::where('original_category_id', $value3['parent_id'])->where('store_id', $new_store_id)->find(); |
||||||
|
$upData3 = [ |
||||||
|
'name' => $value3['name'], |
||||||
|
'level' => $value3['level'], |
||||||
|
'sort' => $value3['sort'], |
||||||
|
'parent_id' => $p_category3['category_id'] ?? 0, |
||||||
|
]; |
||||||
|
if ($is_update_image) { |
||||||
|
$upData3['image_id'] = $value3['image_id'] ? $this->copyImage($value3['image_id'], $new_store_id) : 0; |
||||||
|
$upData3['rank_image_id'] = $value3['rank_image_id'] ? $this->copyImage($value3['rank_image_id'], $new_store_id) : 0; |
||||||
|
} |
||||||
|
$ret = CategoryModel::where('category_id', $category3->category_id)->update($upData3); |
||||||
|
echo "更新成功".PHP_EOL; |
||||||
|
var_dump($ret); |
||||||
|
$fourthid = $category3->category_id; |
||||||
|
} else { |
||||||
|
$value3['parent_id'] = $thirdid; |
||||||
|
$value3['store_id'] = $new_store_id; |
||||||
|
$value3['create_time'] = time(); |
||||||
|
$value3['update_time'] = time(); |
||||||
|
$value3['image_id'] = $value3['image_id'] ? $this->copyImage($value3['image_id'], $new_store_id) : 0; |
||||||
|
$value3['rank_image_id'] = $value3['rank_image_id'] ? $this->copyImage($value3['rank_image_id'], $new_store_id) : 0; |
||||||
|
$value3['original_category_id'] = $value3['category_id']; |
||||||
|
$temp3 = $value3; |
||||||
|
unset($temp3['children']); |
||||||
|
unset($temp3['image']); |
||||||
|
unset($temp3['rankimage']); |
||||||
|
unset($temp3['category_id']); |
||||||
|
|
||||||
|
$fourthid = Db::table('yoshop_category')->insertGetId($temp3); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
if (!isset($value3['children']) || !$value3['children']) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
foreach ($value3['children'] as $value4) { |
||||||
|
//$value4 = $value4->toArray(); |
||||||
|
if ($value4['status'] != 1) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
$category4 = CategoryModel::where('original_category_id', $value4['category_id'])->where('store_id', $new_store_id)->find(); |
||||||
|
if ($category4) { |
||||||
|
//更新分类 |
||||||
|
//父类id |
||||||
|
$p_category4 = CategoryModel::where('original_category_id', $value4['parent_id'])->where('store_id', $new_store_id)->find(); |
||||||
|
$upData4 = [ |
||||||
|
'name' => $value4['name'], |
||||||
|
'level' => $value4['level'], |
||||||
|
'sort' => $value4['sort'], |
||||||
|
'parent_id' => $p_category4['category_id'] ?? 0, |
||||||
|
]; |
||||||
|
if ($is_update_image) { |
||||||
|
$upData4['image_id'] = $value4['image_id'] ? $this->copyImage($value4['image_id'], $new_store_id) : 0; |
||||||
|
$upData4['rank_image_id'] = $value4['rank_image_id'] ? $this->copyImage($value4['rank_image_id'], $new_store_id) : 0; |
||||||
|
} |
||||||
|
$ret = CategoryModel::where('category_id', $category4->category_id)->update($upData4); |
||||||
|
echo "更新成功".PHP_EOL; |
||||||
|
var_dump($ret); |
||||||
|
} else { |
||||||
|
$value4['parent_id'] = $fourthid; |
||||||
|
$value4['store_id'] = $new_store_id; |
||||||
|
$value4['create_time'] = time(); |
||||||
|
$value4['update_time'] = time(); |
||||||
|
$value4['image_id'] = $value4['image_id'] ? $this->copyImage($value4['image_id'], $new_store_id) : 0; |
||||||
|
$value4['rank_image_id'] = $value4['rank_image_id'] ? $this->copyImage($value4['rank_image_id'], $new_store_id) : 0; |
||||||
|
$value4['original_category_id'] = $value4['category_id']; |
||||||
|
$temp4 = $value4; |
||||||
|
unset($temp4['children']); |
||||||
|
unset($temp4['image']); |
||||||
|
unset($temp4['rankimage']); |
||||||
|
unset($temp4['category_id']); |
||||||
|
|
||||||
|
Db::table('yoshop_category')->insertGetId($temp4); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public function copyImage($image_id, $store_id){ |
||||||
|
$upload_file = Db::connect("shopMysql")->name('yoshop_upload_file')->where('file_id', $image_id)->find(); |
||||||
|
if (!$upload_file) { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
$upload_file['store_id'] = $store_id; |
||||||
|
$upload_file['create_time'] = time(); |
||||||
|
unset($upload_file['file_id']); |
||||||
|
$new_image_id = DB::table("yoshop_upload_file")->insertGetId($upload_file); |
||||||
|
return $new_image_id; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取树状列表 |
||||||
|
* @param $list |
||||||
|
* @param int $parentId |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
private function getTreeData($list, int $parentId = 0): array |
||||||
|
{ |
||||||
|
$data = []; |
||||||
|
foreach ($list as $key => $item) { |
||||||
|
if ($item['parent_id'] == $parentId) { |
||||||
|
$children = $this->getTreeData($list, $item['category_id']); |
||||||
|
!empty($children) && $item['children'] = $children; |
||||||
|
$data[] = $item; |
||||||
|
unset($list[$key]); |
||||||
|
} |
||||||
|
} |
||||||
|
return $data; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,565 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
declare (strict_types=1); |
||||||
|
|
||||||
|
namespace app\command; |
||||||
|
|
||||||
|
use think\console\Command; |
||||||
|
use think\console\Output; |
||||||
|
use think\console\Input; |
||||||
|
use think\facade\Db; |
||||||
|
use app\common\model\MaintenanceCategory; |
||||||
|
use app\common\model\Maintenance; |
||||||
|
use app\common\model\article\Category; |
||||||
|
use app\common\model\Article; |
||||||
|
use app\common\model\Store; |
||||||
|
use app\common\model\Agreement; |
||||||
|
use app\common\model\UploadFile; |
||||||
|
use app\common\model\Banner; |
||||||
|
use app\common\model\Express; |
||||||
|
use app\store\model\server\RecoveryCategory; |
||||||
|
use app\store\model\server\ServerRecovery; |
||||||
|
use app\store\model\server\Server; |
||||||
|
use app\store\model\ServerCategory; |
||||||
|
use app\store\model\Setting; |
||||||
|
|
||||||
|
// /www/server/php/74/bin/php /server/wwwroot/yanzong/think test |
||||||
|
class SyncStoreBasicData extends Command |
||||||
|
{ |
||||||
|
const DEFAULT_STORE_ID = 10048; |
||||||
|
|
||||||
|
protected function configure() |
||||||
|
{ |
||||||
|
// 指令配置 |
||||||
|
$this->setName('SyncStoreBasicData')->setDescription('同步商城基础数据'); |
||||||
|
$this->addArgument("store_id"); |
||||||
|
$this->addArgument("isSyncMaintenanceData"); |
||||||
|
$this->addArgument("isSyncHelpData"); |
||||||
|
$this->addArgument("isSyncRichTextData"); |
||||||
|
$this->addArgument("isSyncRecoveryData"); |
||||||
|
$this->addArgument("isSyncServerData"); |
||||||
|
$this->addArgument("isSyncBannerData"); |
||||||
|
$this->addArgument("isSyncStoreSettingData"); |
||||||
|
$this->addArgument("isSyncStoreExpressData"); |
||||||
|
} |
||||||
|
|
||||||
|
protected function execute(Input $input, Output $output) |
||||||
|
{ |
||||||
|
$store_id = $input->getArgument("store_id"); |
||||||
|
$isSyncMaintenanceData = $input->getArgument("isSyncMaintenanceData"); |
||||||
|
$isSyncHelpData = $input->getArgument("isSyncHelpData"); |
||||||
|
$isSyncRichTextData = $input->getArgument("isSyncRichTextData"); |
||||||
|
$isSyncRecoveryData = $input->getArgument("isSyncRecoveryData"); |
||||||
|
$isSyncServerData = $input->getArgument("isSyncServerData"); |
||||||
|
$isSyncBannerData = $input->getArgument("isSyncBannerData"); |
||||||
|
$isSyncStoreSettingData = $input->getArgument("isSyncStoreSettingData"); |
||||||
|
$isSyncStoreExpressData = $input->getArgument("isSyncStoreExpressData"); |
||||||
|
|
||||||
|
$where[] = ['is_sync','=', 0]; |
||||||
|
$where[] = ['is_delete','=', 0]; |
||||||
|
$where[] = ['is_recycle','=', 0]; |
||||||
|
$where[] = ['status','=', 1]; |
||||||
|
|
||||||
|
if ($store_id) { |
||||||
|
$where[] = ['store_id','=', $store_id]; |
||||||
|
} else { |
||||||
|
$where[] = ['store_id', '<>', self::DEFAULT_STORE_ID]; |
||||||
|
} |
||||||
|
$stores = Store::where($where)->field('store_id,is_sync,is_recycle,status,is_delete')->select()->toArray(); |
||||||
|
// echo "<pre>"; |
||||||
|
// print_r($stores); |
||||||
|
// exit(); |
||||||
|
if (!$stores) { |
||||||
|
echo "没有要同步的商城了"; |
||||||
|
return; |
||||||
|
} |
||||||
|
foreach ($stores as $store) { |
||||||
|
if ($isSyncMaintenanceData) { |
||||||
|
$this->syncMaintenanceData($store); |
||||||
|
} |
||||||
|
if ($isSyncHelpData) { |
||||||
|
$this->syncHelpData($store); |
||||||
|
} |
||||||
|
if ($isSyncRichTextData) { |
||||||
|
$this->syncRichTextData($store); |
||||||
|
} |
||||||
|
if ($isSyncRecoveryData) { |
||||||
|
$this->syncRecoveryData($store); |
||||||
|
} |
||||||
|
if ($isSyncServerData) { |
||||||
|
$this->syncServerData($store); |
||||||
|
} |
||||||
|
if ($isSyncBannerData) { |
||||||
|
$this->syncBannerData($store); |
||||||
|
} |
||||||
|
if ($isSyncStoreSettingData) { |
||||||
|
$this->syncStoreSettingData($store); |
||||||
|
} |
||||||
|
if ($isSyncStoreExpressData) { |
||||||
|
$this->syncStoreExpressData($store); |
||||||
|
} |
||||||
|
Store::where('store_id', $store['store_id'])->update(['is_sync' => 1]); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
/** |
||||||
|
* 同步物流公司 |
||||||
|
* [syncStoreExpressData description] |
||||||
|
* @param [type] $store [description] |
||||||
|
* @return [type] [description] |
||||||
|
*/ |
||||||
|
private function syncStoreExpressData($store){ |
||||||
|
//维修分类数据同步 |
||||||
|
$expressList = Db::connect("shopMysql")->name('yoshop_express')->where('store_id',self::DEFAULT_STORE_ID)->select()->toArray(); |
||||||
|
if ($expressList) { |
||||||
|
foreach ($expressList as &$express) { |
||||||
|
$info = Express::where('store_id', $store['store_id'])->where('kuaidi100_code', $express['kuaidi100_code'])->where('kdniao_code', $express['kdniao_code'])->find(); |
||||||
|
if ($info) { |
||||||
|
echo $express['express_id']."物流公司已存在".PHP_EOL; |
||||||
|
$ret = Express::where('store_id', $store['store_id'])->where('express_id', $info['express_id'])->update([ |
||||||
|
'express_name' => $express['express_name'], |
||||||
|
'kuaidi100_code' => $express['kuaidi100_code'], |
||||||
|
'kdniao_code' => $express['kdniao_code'], |
||||||
|
'original_id' => $express['express_id'], |
||||||
|
]); |
||||||
|
var_dump($ret); |
||||||
|
continue; |
||||||
|
} |
||||||
|
$express['create_time'] = time(); |
||||||
|
$express['update_time'] = time(); |
||||||
|
$express['original_id'] = $express['express_id']; |
||||||
|
$express['store_id'] = $store['store_id']; |
||||||
|
unset($express['express_id']); |
||||||
|
$ret = Express::create($express); |
||||||
|
var_dump($ret->express_id); |
||||||
|
} |
||||||
|
unset($express); |
||||||
|
} |
||||||
|
} |
||||||
|
/** |
||||||
|
* 同步基本信息,七牛云、快递100、99api的配置 |
||||||
|
* [syncSettingData description] |
||||||
|
* @param [type] $store [description] |
||||||
|
* @return [type] [description] |
||||||
|
*/ |
||||||
|
private function syncStoreSettingData($store){ |
||||||
|
//99api配置 |
||||||
|
// $collector = Setting::where('key','collector')->where('store_id', $store['store_id'])->find(); |
||||||
|
|
||||||
|
// if (!$collector) { |
||||||
|
// $collectorData = [ |
||||||
|
// "key" => "collector", |
||||||
|
// "describe" => "商品采集设置", |
||||||
|
// "values" => json_decode('{"config":{"99api":{"apiKey":"9271DA7BF37C6F50BED49B7F0ADD49A2"}}}', true), |
||||||
|
// "store_id" => $store['store_id'], |
||||||
|
// "create_time" => time(), |
||||||
|
// "update_time" => time(), |
||||||
|
// ]; |
||||||
|
// $ret = Setting::create($collectorData); |
||||||
|
// echo "99api配置新增成功"; |
||||||
|
// var_dump($ret->key); |
||||||
|
// } |
||||||
|
//配送设置 |
||||||
|
$delivery = Setting::where('key','delivery')->where('store_id', $store['store_id'])->find(); |
||||||
|
|
||||||
|
if (!$delivery) { |
||||||
|
$deliveryData = [ |
||||||
|
"key" => "delivery", |
||||||
|
"describe" => "配送设置", |
||||||
|
"values" => json_decode('{"traces":{"enable":1,"default":"kd100","providerConfig":{"kd100":{"customer":"F6CAEF5CEA6B5BF219149B9B42BECAA1","key":"pjVBLUai1633"},"aliyun":{"appCode":""}}},"delivery_type":[10,20,30]}', true), |
||||||
|
"store_id" => $store['store_id'], |
||||||
|
"create_time" => time(), |
||||||
|
"update_time" => time(), |
||||||
|
]; |
||||||
|
$ret = Setting::create($deliveryData); |
||||||
|
echo "配送设置新增成功"; |
||||||
|
var_dump($ret->key); |
||||||
|
} |
||||||
|
//上传设置 |
||||||
|
$storage = Setting::where('key','storage')->where('store_id', $store['store_id'])->find(); |
||||||
|
if (!$storage) { |
||||||
|
$storageData = [ |
||||||
|
"key" => "storage", |
||||||
|
"describe" => "上传设置", |
||||||
|
"values" => json_decode('{"default":"qiniu","engine":{"qiniu":{"bucket":"saasyovo","access_key":"ehSHgkSkS9lGex8n0-vMf1-wkbgi56yv6fhEwsYS","secret_key":"jNXsuPmTnmfiRlNs-JoAmT833o0qusgXrXqeR3VK","domain":"https:\/\/qiniu.shop.royaum.com.cn"},"aliyun":{"bucket":"","access_key_id":"","access_key_secret":"","domain":"http:\/\/"},"qcloud":{"bucket":"","region":"","secret_id":"","secret_key":"","domain":"http:\/\/"}}}', true), |
||||||
|
"store_id" => $store['store_id'], |
||||||
|
"create_time" => time(), |
||||||
|
"update_time" => time(), |
||||||
|
]; |
||||||
|
$ret = Setting::create($storageData); |
||||||
|
echo "上传设置新增成功"; |
||||||
|
var_dump($ret->key); |
||||||
|
} |
||||||
|
} |
||||||
|
/** |
||||||
|
* 同步富文本数据 |
||||||
|
* [syncHelpData description] |
||||||
|
* @param [type] $store [description] |
||||||
|
* @return [type] [description] |
||||||
|
*/ |
||||||
|
private function syncRichTextData($store){ |
||||||
|
//维修分类数据同步 |
||||||
|
$agreementList = Db::connect("shopMysql")->name('yoshop_agreement')->where('store_id',self::DEFAULT_STORE_ID)->select()->toArray(); |
||||||
|
if ($agreementList) { |
||||||
|
foreach ($agreementList as &$agreement) { |
||||||
|
$info = Agreement::where('store_id', $store['store_id'])->where('original_id', $agreement['id'])->find(); |
||||||
|
if ($info) { |
||||||
|
echo $agreement['id']."富文本已存在".PHP_EOL; |
||||||
|
continue; |
||||||
|
} |
||||||
|
$agreement['create_time'] = time(); |
||||||
|
$agreement['update_time'] = time(); |
||||||
|
$agreement['original_id'] = $agreement['id']; |
||||||
|
$agreement['store_id'] = $store['store_id']; |
||||||
|
unset($agreement['id']); |
||||||
|
$ret = Agreement::create($agreement); |
||||||
|
var_dump($ret->id); |
||||||
|
} |
||||||
|
unset($agreement); |
||||||
|
} |
||||||
|
} |
||||||
|
/** |
||||||
|
* 同步帮助中心数据 |
||||||
|
* [syncHelpData description] |
||||||
|
* @param [type] $store [description] |
||||||
|
* @return [type] [description] |
||||||
|
*/ |
||||||
|
private function syncHelpData($store){ |
||||||
|
//维修分类数据同步 |
||||||
|
$articleCategoryList = Db::connect("shopMysql")->name('yoshop_article_category')->where('store_id',self::DEFAULT_STORE_ID)->where('status', 1)->select()->toArray(); |
||||||
|
if ($articleCategoryList) { |
||||||
|
foreach ($articleCategoryList as &$articleCategory) { |
||||||
|
$info = Category::where('store_id', $store['store_id'])->where('original_id', $articleCategory['category_id'])->find(); |
||||||
|
if ($info) { |
||||||
|
echo $articleCategory['category_id']."帮助分类已存在".PHP_EOL; |
||||||
|
continue; |
||||||
|
} |
||||||
|
$articleCategory['create_time'] = time(); |
||||||
|
$articleCategory['update_time'] = time(); |
||||||
|
$articleCategory['original_id'] = $articleCategory['category_id']; |
||||||
|
$articleCategory['store_id'] = $store['store_id']; |
||||||
|
unset($articleCategory['category_id']); |
||||||
|
|
||||||
|
//复制图片 |
||||||
|
$upload_file = Db::connect("shopMysql")->name('yoshop_upload_file')->where('file_id', $articleCategory['img_id'])->find(); |
||||||
|
if ($upload_file) { |
||||||
|
$upload_file['store_id'] = $store['store_id']; |
||||||
|
$upload_file['create_time'] = time(); |
||||||
|
unset($upload_file['file_id']); |
||||||
|
$image_id = Db::name('upload_file')->insertGetId($upload_file); |
||||||
|
} |
||||||
|
//写入维修数据 |
||||||
|
$articleCategory['img_id'] = $image_id ?? 0; |
||||||
|
$ret = Category::create($articleCategory); |
||||||
|
var_dump($ret->id); |
||||||
|
} |
||||||
|
unset($articleCategory); |
||||||
|
} |
||||||
|
|
||||||
|
//维修数据同步 |
||||||
|
$articleList = Db::connect("shopMysql")->name('yoshop_article')->where('store_id',self::DEFAULT_STORE_ID)->where('is_delete', 0)->where('status', 1)->select()->toArray(); |
||||||
|
if ($articleList) { |
||||||
|
foreach ($articleList as &$article) { |
||||||
|
$info = Article::where('store_id', $store['store_id'])->where('original_id', $article['article_id'])->find(); |
||||||
|
if ($info) { |
||||||
|
echo $article['article_id']."帮助已存在".PHP_EOL; |
||||||
|
continue; |
||||||
|
} |
||||||
|
//查询分类id |
||||||
|
$articleCategory = Category::where('original_id', $article['category_id'])->where('store_id', $store['store_id'])->find(); |
||||||
|
if (!$articleCategory) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
$article['create_time'] = time(); |
||||||
|
$article['update_time'] = time(); |
||||||
|
$article['original_id'] = $article['article_id']; |
||||||
|
$article['category_id'] = $articleCategory['category_id']; |
||||||
|
$article['store_id'] = $store['store_id']; |
||||||
|
unset($article['article_id']); |
||||||
|
//复制图片 |
||||||
|
$upload_file = Db::connect("shopMysql")->name('yoshop_upload_file')->where('file_id', $article['image_id'])->find(); |
||||||
|
if ($upload_file) { |
||||||
|
$upload_file['store_id'] = $store['store_id']; |
||||||
|
$upload_file['create_time'] = time(); |
||||||
|
unset($upload_file['file_id']); |
||||||
|
$image_id = Db::name('upload_file')->insertGetId($upload_file); |
||||||
|
} |
||||||
|
//写入维修数据 |
||||||
|
$article['image_id'] = $image_id; |
||||||
|
$ret = Article::create($article); |
||||||
|
//写入图片id |
||||||
|
var_dump($ret->id); |
||||||
|
} |
||||||
|
unset($article); |
||||||
|
} |
||||||
|
} |
||||||
|
/** |
||||||
|
* 同步维修数据 |
||||||
|
* [syncMaintenanceData description] |
||||||
|
* @param [type] $store [description] |
||||||
|
* @return [type] [description] |
||||||
|
*/ |
||||||
|
private function syncMaintenanceData($store){ |
||||||
|
//维修分类数据同步 |
||||||
|
$maintenanceCategoryList = Db::connect("shopMysql")->name('yoshop_maintenance_category')->where('store_id',self::DEFAULT_STORE_ID)->where('status', 1)->select()->toArray(); |
||||||
|
|
||||||
|
if ($maintenanceCategoryList) { |
||||||
|
foreach ($maintenanceCategoryList as &$maintenanceCategory) { |
||||||
|
$info = MaintenanceCategory::where('store_id', $store['store_id'])->where('original_id', $maintenanceCategory['id'])->find(); |
||||||
|
if ($info) { |
||||||
|
echo $maintenanceCategory['id']."维修分类已存在".PHP_EOL; |
||||||
|
continue; |
||||||
|
} |
||||||
|
$maintenanceCategory['create_time'] = time(); |
||||||
|
$maintenanceCategory['update_time'] = time(); |
||||||
|
$maintenanceCategory['original_id'] = $maintenanceCategory['id']; |
||||||
|
$maintenanceCategory['store_id'] = $store['store_id']; |
||||||
|
unset($maintenanceCategory['id']); |
||||||
|
// echo "<pre>"; |
||||||
|
// print_r($maintenanceCategory); |
||||||
|
// exit(); |
||||||
|
$ret = MaintenanceCategory::create($maintenanceCategory); |
||||||
|
var_dump($ret->id); |
||||||
|
} |
||||||
|
unset($maintenanceCategory); |
||||||
|
} |
||||||
|
|
||||||
|
//维修数据同步 |
||||||
|
$maintenanceList = Db::connect("shopMysql")->name('yoshop_maintenance')->where('store_id',self::DEFAULT_STORE_ID)->where('is_delete', 0)->select()->toArray(); |
||||||
|
|
||||||
|
if ($maintenanceList) { |
||||||
|
foreach ($maintenanceList as &$maintenance) { |
||||||
|
$info = Maintenance::where('store_id', $store['store_id'])->where('original_id', $maintenance['id'])->find(); |
||||||
|
if ($info) { |
||||||
|
echo $maintenance['id']."维修已存在".PHP_EOL; |
||||||
|
continue; |
||||||
|
} |
||||||
|
// echo "<pre>"; |
||||||
|
// print_r($info); |
||||||
|
// exit(); |
||||||
|
//查询分类id |
||||||
|
$maintenanceCategory = MaintenanceCategory::where('original_id', $maintenance['category_id'])->where('store_id', $store['store_id'])->find(); |
||||||
|
if (!$maintenanceCategory) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
$maintenance['create_time'] = time(); |
||||||
|
$maintenance['update_time'] = time(); |
||||||
|
$maintenance['original_id'] = $maintenance['id']; |
||||||
|
$maintenance['category_id'] = $maintenanceCategory['id']; |
||||||
|
$maintenance['store_id'] = $store['store_id']; |
||||||
|
unset($maintenance['id']); |
||||||
|
//复制图片 |
||||||
|
$upload_file = Db::connect("shopMysql")->name('yoshop_upload_file')->where('file_id', $maintenance['img_id'])->find(); |
||||||
|
if ($upload_file) { |
||||||
|
$upload_file['store_id'] = $store['store_id']; |
||||||
|
$upload_file['create_time'] = time(); |
||||||
|
unset($upload_file['file_id']); |
||||||
|
// echo "<pre>"; |
||||||
|
// print_r($upload_file); |
||||||
|
// exit(); |
||||||
|
$image_id = Db::name('upload_file')->insertGetId($upload_file); |
||||||
|
} |
||||||
|
|
||||||
|
//写入维修数据 |
||||||
|
$maintenance['img_id'] = $image_id ?? 0; |
||||||
|
$ret = Maintenance::create($maintenance); |
||||||
|
//写入图片id |
||||||
|
var_dump($ret->id); |
||||||
|
} |
||||||
|
unset($maintenance); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 同步回收数据 |
||||||
|
* [syncHelpData description] |
||||||
|
* @param [type] $store [description] |
||||||
|
* @return [type] [description] |
||||||
|
*/ |
||||||
|
private function syncRecoveryData($store){ |
||||||
|
//维修分类数据同步 |
||||||
|
$articleCategoryList = Db::connect("shopMysql")->name('yoshop_server_recovery_category')->where('store_id',self::DEFAULT_STORE_ID)->where('status', 1)->select()->toArray(); |
||||||
|
if ($articleCategoryList) { |
||||||
|
foreach ($articleCategoryList as &$articleCategory) { |
||||||
|
$info = RecoveryCategory::where('store_id', $store['store_id'])->where('original_id', $articleCategory['category_id'])->find(); |
||||||
|
if ($info) { |
||||||
|
echo $articleCategory['category_id']."回收已存在".PHP_EOL; |
||||||
|
continue; |
||||||
|
} |
||||||
|
$articleCategory['create_time'] = time(); |
||||||
|
$articleCategory['update_time'] = time(); |
||||||
|
$articleCategory['original_id'] = $articleCategory['category_id']; |
||||||
|
$articleCategory['store_id'] = $store['store_id']; |
||||||
|
unset($articleCategory['category_id']); |
||||||
|
|
||||||
|
//复制图片 |
||||||
|
$upload_file = Db::connect("shopMysql")->name('yoshop_upload_file')->where('file_id', $articleCategory['image_id'])->find(); |
||||||
|
if ($upload_file) { |
||||||
|
$upload_file['store_id'] = $store['store_id']; |
||||||
|
$upload_file['create_time'] = time(); |
||||||
|
unset($upload_file['file_id']); |
||||||
|
$image_id = Db::name('upload_file')->insertGetId($upload_file); |
||||||
|
} |
||||||
|
//写入维修数据 |
||||||
|
$articleCategory['image_id'] = $image_id ?? 0; |
||||||
|
$ret = RecoveryCategory::create($articleCategory); |
||||||
|
var_dump($ret->category_id); |
||||||
|
} |
||||||
|
unset($articleCategory); |
||||||
|
} |
||||||
|
|
||||||
|
//维修数据同步 |
||||||
|
$articleList = Db::connect("shopMysql")->name('yoshop_server_recovery')->where('store_id',self::DEFAULT_STORE_ID)->where('status', 1)->select()->toArray(); |
||||||
|
if ($articleList) { |
||||||
|
foreach ($articleList as &$article) { |
||||||
|
$info = ServerRecovery::where('store_id', $store['store_id'])->where('original_id', $article['recovery_id'])->find(); |
||||||
|
if ($info) { |
||||||
|
echo $article['recovery_id']."回收已存在".PHP_EOL; |
||||||
|
continue; |
||||||
|
} |
||||||
|
//查询分类id |
||||||
|
$articleCategory = RecoveryCategory::where('original_id', $article['category_id'])->where('store_id', $store['store_id'])->find(); |
||||||
|
if (!$articleCategory) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
$article['create_time'] = time(); |
||||||
|
$article['update_time'] = time(); |
||||||
|
$article['original_id'] = $article['recovery_id']; |
||||||
|
$article['category_id'] = $articleCategory['category_id']; |
||||||
|
$article['store_id'] = $store['store_id']; |
||||||
|
unset($article['recovery_id']); |
||||||
|
//复制图片 |
||||||
|
$upload_file = Db::connect("shopMysql")->name('yoshop_upload_file')->where('file_id', $article['image_id'])->find(); |
||||||
|
if ($upload_file) { |
||||||
|
$upload_file['store_id'] = $store['store_id']; |
||||||
|
$upload_file['create_time'] = time(); |
||||||
|
unset($upload_file['file_id']); |
||||||
|
$image_id = Db::name('upload_file')->insertGetId($upload_file); |
||||||
|
} |
||||||
|
//写入维修数据 |
||||||
|
$article['image_id'] = $image_id; |
||||||
|
$ret = ServerRecovery::create($article); |
||||||
|
//写入图片id |
||||||
|
var_dump($ret->recovery_id); |
||||||
|
} |
||||||
|
unset($article); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 同步服务数据 |
||||||
|
* [syncHelpData description] |
||||||
|
* @param [type] $store [description] |
||||||
|
* @return [type] [description] |
||||||
|
*/ |
||||||
|
private function syncServerData($store){ |
||||||
|
//服务分类数据同步 |
||||||
|
$articleCategoryList = Db::connect("shopMysql")->name('yoshop_server_category')->where('store_id',self::DEFAULT_STORE_ID)->where('status', 1)->select()->toArray(); |
||||||
|
if ($articleCategoryList) { |
||||||
|
foreach ($articleCategoryList as &$articleCategory) { |
||||||
|
$info = ServerCategory::where('store_id', $store['store_id'])->where('original_id', $articleCategory['category_id'])->find(); |
||||||
|
if ($info) { |
||||||
|
echo $articleCategory['category_id']."服务分类已存在".PHP_EOL; |
||||||
|
continue; |
||||||
|
} |
||||||
|
$articleCategory['create_time'] = time(); |
||||||
|
$articleCategory['update_time'] = time(); |
||||||
|
$articleCategory['original_id'] = $articleCategory['category_id']; |
||||||
|
$articleCategory['store_id'] = $store['store_id']; |
||||||
|
unset($articleCategory['category_id']); |
||||||
|
|
||||||
|
//复制图片 |
||||||
|
$upload_file = Db::connect("shopMysql")->name('yoshop_upload_file')->where('file_id', $articleCategory['image_id'])->find(); |
||||||
|
if ($upload_file) { |
||||||
|
$upload_file['store_id'] = $store['store_id']; |
||||||
|
$upload_file['create_time'] = time(); |
||||||
|
unset($upload_file['file_id']); |
||||||
|
$image_id = Db::name('upload_file')->insertGetId($upload_file); |
||||||
|
} |
||||||
|
//写入维修数据 |
||||||
|
$articleCategory['image_id'] = $image_id ?? 0; |
||||||
|
$ret = ServerCategory::create($articleCategory); |
||||||
|
var_dump($ret->category_id); |
||||||
|
} |
||||||
|
unset($articleCategory); |
||||||
|
} |
||||||
|
|
||||||
|
//服务数据同步 |
||||||
|
$articleList = Db::connect("shopMysql")->name('yoshop_server')->where('store_id',self::DEFAULT_STORE_ID)->where('status', 1)->select()->toArray(); |
||||||
|
if ($articleList) { |
||||||
|
foreach ($articleList as &$article) { |
||||||
|
$info = Server::where('store_id', $store['store_id'])->where('original_id', $article['server_id'])->find(); |
||||||
|
if ($info) { |
||||||
|
echo $article['server_id']."服务已存在".PHP_EOL; |
||||||
|
continue; |
||||||
|
} |
||||||
|
//查询分类id |
||||||
|
$articleCategory = ServerCategory::where('original_id', $article['category_id'])->where('store_id', $store['store_id'])->find(); |
||||||
|
if (!$articleCategory) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
$article['create_time'] = time(); |
||||||
|
$article['update_time'] = time(); |
||||||
|
$article['original_id'] = $article['server_id']; |
||||||
|
$article['category_id'] = $articleCategory['category_id']; |
||||||
|
$article['store_id'] = $store['store_id']; |
||||||
|
unset($article['server_id']); |
||||||
|
//复制图片 |
||||||
|
$upload_file = Db::connect("shopMysql")->name('yoshop_upload_file')->where('file_id', $article['image_id'])->find(); |
||||||
|
if ($upload_file) { |
||||||
|
$upload_file['store_id'] = $store['store_id']; |
||||||
|
$upload_file['create_time'] = time(); |
||||||
|
unset($upload_file['file_id']); |
||||||
|
$image_id = Db::name('upload_file')->insertGetId($upload_file); |
||||||
|
} |
||||||
|
//写入维修数据 |
||||||
|
$article['image_id'] = $image_id; |
||||||
|
$ret = Server::create($article); |
||||||
|
//写入图片id |
||||||
|
var_dump($ret->server_id); |
||||||
|
} |
||||||
|
unset($article); |
||||||
|
} |
||||||
|
} |
||||||
|
/** |
||||||
|
* 同步轮播图数据 |
||||||
|
* [syncHelpData description] |
||||||
|
* @param [type] $store [description] |
||||||
|
* @return [type] [description] |
||||||
|
*/ |
||||||
|
private function syncBannerData($store){ |
||||||
|
//服务分类数据同步 |
||||||
|
$articleCategoryList = Db::connect("shopMysql")->name('yoshop_banner')->where('store_id',self::DEFAULT_STORE_ID)->where('status', 10)->select()->toArray(); |
||||||
|
if ($articleCategoryList) { |
||||||
|
foreach ($articleCategoryList as &$articleCategory) { |
||||||
|
$info = Banner::where('store_id', $store['store_id'])->where('original_id', $articleCategory['id'])->find(); |
||||||
|
if ($info) { |
||||||
|
echo $articleCategory['id']."轮播图已存在".PHP_EOL; |
||||||
|
continue; |
||||||
|
} |
||||||
|
$articleCategory['create_time'] = time(); |
||||||
|
$articleCategory['update_time'] = time(); |
||||||
|
$articleCategory['original_id'] = $articleCategory['id']; |
||||||
|
$articleCategory['store_id'] = $store['store_id']; |
||||||
|
unset($articleCategory['id']); |
||||||
|
unset($articleCategory['redirect_url']); |
||||||
|
|
||||||
|
//复制图片 |
||||||
|
$upload_file = Db::connect("shopMysql")->name('yoshop_upload_file')->where('file_id', $articleCategory['image_id'])->find(); |
||||||
|
if ($upload_file) { |
||||||
|
$upload_file['store_id'] = $store['store_id']; |
||||||
|
$upload_file['create_time'] = time(); |
||||||
|
unset($upload_file['file_id']); |
||||||
|
$image_id = Db::name('upload_file')->insertGetId($upload_file); |
||||||
|
} |
||||||
|
//写入维修数据 |
||||||
|
$articleCategory['image_id'] = $image_id ?? 0; |
||||||
|
$ret = Banner::create($articleCategory); |
||||||
|
var_dump($ret->id); |
||||||
|
} |
||||||
|
unset($articleCategory); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue