lqmac 10 months ago
parent 3e46c1b408
commit 6be4a2bfd9
  1. 4
      app/api/controller/Refund.php
  2. 158
      app/command/SyncStoreBasicData.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'));
}

@ -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);
}
}
}

Loading…
Cancel
Save