|
|
@@ -36,6 +36,87 @@ class ItemController extends Controller
|
|
|
|
|
|
public $sjId, $shopId, $sj;
|
|
|
|
|
|
+ //复制迁移花材 ssh 20251210
|
|
|
+ public function actionMigrate()
|
|
|
+ {
|
|
|
+ if (getenv('YII_ENV') == 'production') {
|
|
|
+ $newMainId = 79955;
|
|
|
+ $oldMainId = 16720;
|
|
|
+ } else {
|
|
|
+ $newMainId = 762;
|
|
|
+ $oldMainId = 644;
|
|
|
+ util::stop('测试环境未开通');
|
|
|
+ }
|
|
|
+ $list = ItemClass::getAllByCondition(['mainId' => $newMainId], null, '*');
|
|
|
+ if (!empty($list)) {
|
|
|
+ echo '已经有花材了';
|
|
|
+ exit();
|
|
|
+ }
|
|
|
+ $classList = ItemClassClass::getAllByCondition(['mainId' => $oldMainId], null, '*', null, true);
|
|
|
+ if (empty($classList)) {
|
|
|
+ echo '没有找到老店的分类';
|
|
|
+ exit();
|
|
|
+ }
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ foreach ($classList as $class) {
|
|
|
+ $oldId = $class->id ?? 0;
|
|
|
+ $cover = $class->cover ?? '';
|
|
|
+ $name = $class->name ?? '';
|
|
|
+ $inTurn = $class->inTurn ?? 0;
|
|
|
+ $isDefault = $class->isDefault ?? 0;
|
|
|
+ $newClass = [
|
|
|
+ 'mainId' => $newMainId,
|
|
|
+ 'cover' => $cover,
|
|
|
+ 'name' => $name,
|
|
|
+ 'inTurn' => $inTurn,
|
|
|
+ 'isDefault' => $isDefault,
|
|
|
+ ];
|
|
|
+ $newRespond = ItemClassClass::add($newClass, true);
|
|
|
+ $newClassId = $newRespond->id ?? 0;
|
|
|
+ $oldItemList = ItemClass::getAllByCondition(['classId' => $oldId, 'delStatus' => 0], null, '*');
|
|
|
+ foreach ($oldItemList as $oldItem) {
|
|
|
+ $oldItemId = $oldItem['id'];
|
|
|
+ unset($oldItem['id']);
|
|
|
+ $oldItem['classId'] = $newClassId;
|
|
|
+ $oldItem['stock'] = 0;
|
|
|
+ $oldItem['status'] = 2;
|
|
|
+ $oldItem['mainId'] = $newMainId;
|
|
|
+ $oldItem['sjId'] = 0;
|
|
|
+ $oldItem['shopId'] = 0;
|
|
|
+ $new = ItemClass::add($oldItem, true);
|
|
|
+
|
|
|
+ if (isset($oldItem['variety']) && $oldItem['variety'] == 1) {
|
|
|
+ $xjList = XjClass::getAllByCondition(['itemId' => $oldItemId], null, '*');
|
|
|
+ if (!empty($xjList)) {
|
|
|
+ foreach ($xjList as $oneXj) {
|
|
|
+ unset($oneXj['id']);
|
|
|
+ unset($oneXj['sjId']);
|
|
|
+ unset($oneXj['shopId']);
|
|
|
+ unset($oneXj['mainId']);
|
|
|
+ unset($oneXj['itemId']);
|
|
|
+ unset($oneXj['ptItemId']);
|
|
|
+ unset($oneXj['addTime']);
|
|
|
+ unset($oneXj['updateTime']);
|
|
|
+ $oneXj['mainId'] = $newMainId;
|
|
|
+ $oneXj['itemId'] = $new->id ?? 0;
|
|
|
+ $oneXj['ptItemId'] = $new->itemId ?? 0;
|
|
|
+ XjClass::add($oneXj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $transaction->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $msg = $e->getMessage();
|
|
|
+ echo "报错了:" . $msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function actionCQ()
|
|
|
{
|
|
|
$itemList = ItemClass::getAllByCondition(['mainId' => 14128], null, '*', null, true);
|
|
|
@@ -256,87 +337,6 @@ class ItemController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //复制迁移花材 ssh 20251119
|
|
|
- public function actionMigrate()
|
|
|
- {
|
|
|
- if (getenv('YII_ENV') == 'production') {
|
|
|
- $newMainId = 44624;
|
|
|
- $oldMainId = 16948;
|
|
|
- } else {
|
|
|
- //$newMainId = 762;
|
|
|
- //$oldMainId = 644;
|
|
|
- util::stop('测试环境未开通');
|
|
|
- }
|
|
|
- $list = ItemClass::getAllByCondition(['mainId' => $newMainId], null, '*');
|
|
|
- if (!empty($list)) {
|
|
|
- echo '已经有花材了';
|
|
|
- exit();
|
|
|
- }
|
|
|
- $classList = ItemClassClass::getAllByCondition(['mainId' => $oldMainId], null, '*', null, true);
|
|
|
- if (empty($classList)) {
|
|
|
- echo '没有找到天天鲜花的分类';
|
|
|
- exit();
|
|
|
- }
|
|
|
- $connection = Yii::$app->db;
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
- try {
|
|
|
- foreach ($classList as $class) {
|
|
|
- $oldId = $class->id ?? 0;
|
|
|
- $cover = $class->cover ?? '';
|
|
|
- $name = $class->name ?? '';
|
|
|
- $inTurn = $class->inTurn ?? 0;
|
|
|
- $isDefault = $class->isDefault ?? 0;
|
|
|
- $newClass = [
|
|
|
- 'mainId' => $newMainId,
|
|
|
- 'cover' => $cover,
|
|
|
- 'name' => $name,
|
|
|
- 'inTurn' => $inTurn,
|
|
|
- 'isDefault' => $isDefault,
|
|
|
- ];
|
|
|
- $newRespond = ItemClassClass::add($newClass, true);
|
|
|
- $newClassId = $newRespond->id ?? 0;
|
|
|
- $oldItemList = ItemClass::getAllByCondition(['classId' => $oldId, 'delStatus' => 0], null, '*');
|
|
|
- foreach ($oldItemList as $oldItem) {
|
|
|
- $oldItemId = $oldItem['id'];
|
|
|
- unset($oldItem['id']);
|
|
|
- $oldItem['classId'] = $newClassId;
|
|
|
- $oldItem['stock'] = 0;
|
|
|
- $oldItem['status'] = 2;
|
|
|
- $oldItem['mainId'] = $newMainId;
|
|
|
- $oldItem['sjId'] = 0;
|
|
|
- $oldItem['shopId'] = 0;
|
|
|
- $new = ItemClass::add($oldItem, true);
|
|
|
-
|
|
|
- if (isset($oldItem['variety']) && $oldItem['variety'] == 1) {
|
|
|
- $xjList = XjClass::getAllByCondition(['itemId' => $oldItemId], null, '*');
|
|
|
- if (!empty($xjList)) {
|
|
|
- foreach ($xjList as $oneXj) {
|
|
|
- unset($oneXj['id']);
|
|
|
- unset($oneXj['sjId']);
|
|
|
- unset($oneXj['shopId']);
|
|
|
- unset($oneXj['mainId']);
|
|
|
- unset($oneXj['itemId']);
|
|
|
- unset($oneXj['ptItemId']);
|
|
|
- unset($oneXj['addTime']);
|
|
|
- unset($oneXj['updateTime']);
|
|
|
- $oneXj['mainId'] = $newMainId;
|
|
|
- $oneXj['itemId'] = $new->id ?? 0;
|
|
|
- $oneXj['ptItemId'] = $new->itemId ?? 0;
|
|
|
- XjClass::add($oneXj);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- $transaction->commit();
|
|
|
- } catch (\Exception $e) {
|
|
|
- $transaction->rollBack();
|
|
|
- $msg = $e->getMessage();
|
|
|
- echo "报错了:" . $msg;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
//花材反向更新 ./yii item/reverse-update
|
|
|
public function actionReverseUpdate()
|
|
|
{
|