From 6be4a2bfd935971726c9331c693c58915b292cdb Mon Sep 17 00:00:00 2001 From: lqmac Date: Wed, 8 May 2024 10:02:47 +0800 Subject: [PATCH] 1 --- app/api/controller/Refund.php | 4 + app/command/SyncStoreBasicData.php | 158 +++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) diff --git a/app/api/controller/Refund.php b/app/api/controller/Refund.php index fa8ab851..e343474f 100644 --- a/app/api/controller/Refund.php +++ b/app/api/controller/Refund.php @@ -74,6 +74,10 @@ class Refund extends Controller public function detail(int $orderRefundId): Json { $detail = OrderRefundModel::getDetail($orderRefundId, true); + if ($detail) { + $detail->refuse_desc = $detail->refuse_desc ? htmlspecialchars_decode($detail->refuse_desc) : ""; + } + return $this->renderSuccess(compact('detail')); } diff --git a/app/command/SyncStoreBasicData.php b/app/command/SyncStoreBasicData.php index 737eb05b..ab2ca128 100644 --- a/app/command/SyncStoreBasicData.php +++ b/app/command/SyncStoreBasicData.php @@ -15,6 +15,10 @@ use app\common\model\Article; use app\common\model\Store; use app\common\model\Agreement; use app\common\model\UploadFile; +use app\store\model\server\RecoveryCategory; +use app\store\model\server\ServerRecovery; +use app\store\model\server\Server; +use app\store\model\ServerCategory; // /www/server/php/74/bin/php /server/wwwroot/yanzong/think test class SyncStoreBasicData extends Command @@ -29,6 +33,8 @@ class SyncStoreBasicData extends Command $this->addArgument("isSyncMaintenanceData"); $this->addArgument("isSyncHelpData"); $this->addArgument("isSyncRichTextData"); + $this->addArgument("isSyncRecoveryData"); + $this->addArgument("isSyncServerData"); } protected function execute(Input $input, Output $output) @@ -250,4 +256,156 @@ class SyncStoreBasicData extends Command } } + /** + * 同步回收数据 + * [syncHelpData description] + * @param [type] $store [description] + * @return [type] [description] + */ + private function syncRecoveryData($store){ + //维修分类数据同步 + $articleCategoryList = RecoveryCategory::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::name('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->id); + } + unset($articleCategory); + } + + //维修数据同步 + $articleList = ServerRecovery::where('store_id',self::DEFAULT_STORE_ID)->where('is_delete', 0)->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::name('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->id); + } + unset($article); + } + } + + /** + * 同步服务数据 + * [syncHelpData description] + * @param [type] $store [description] + * @return [type] [description] + */ + private function syncServerData($store){ + //维修分类数据同步 + $articleCategoryList = ServerCategory::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::name('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->id); + } + unset($articleCategory); + } + + //维修数据同步 + $articleList = Server::where('store_id',self::DEFAULT_STORE_ID)->where('is_delete', 0)->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::name('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->id); + } + unset($article); + } + } + }