shish il y a 4 ans
Parent
commit
daebef9995
1 fichiers modifiés avec 26 ajouts et 741 suppressions
  1. 26 741
      console/controllers/InitController.php

+ 26 - 741
console/controllers/InitController.php

@@ -2,768 +2,53 @@
 
 namespace console\controllers;
 
-use biz\admin\classes\AdminClass;
-use biz\admin\classes\AdminRoleClass;
-use biz\product\classes\XjClass;
-use biz\pt\classes\PtYeChangeClass;
-use biz\recharge\classes\RechargeClass;
-use biz\shop\classes\MainClass;
-use biz\shop\classes\ShopAdminClass;
-use biz\shop\classes\ShopClass;
-use biz\shop\classes\ShopYeChangeClass;
-use biz\sj\classes\CashClass;
-use biz\sj\classes\SjClass;
-use biz\stat\classes\StatCgClass;
-use biz\stat\classes\StatCgGhsClass;
-use biz\stat\classes\StatCgGhsMonthClass;
-use biz\stat\classes\StatCgMonthClass;
-use biz\stat\classes\StatOrderCountClass;
-use biz\stat\classes\StatOutClass;
-use biz\stat\classes\StatOutMonthClass;
-use biz\stat\classes\StatPdAddClass;
-use biz\stat\classes\StatPdAddMonthClass;
-use biz\stat\classes\StatPdSubClass;
-use biz\stat\classes\StatPdSubMonthClass;
-use biz\stat\classes\StatRefundClass;
-use biz\stat\classes\StatRefundMonthClass;
-use biz\stat\classes\StatSaleClass;
-use biz\stat\classes\StatSaleMonthClass;
-use biz\stat\classes\StatStockInClass;
-use biz\stat\classes\StatStockInMonthClass;
-use biz\stat\classes\StatStockOutClass;
-use biz\stat\classes\StatStockOutMonthClass;
-use biz\stat\classes\StatWastClass;
-use biz\stat\classes\StatWastMonthClass;
-use bizGhs\cg\classes\CgClass;
-use bizGhs\clear\classes\ClearClass;
-use bizGhs\clear\models\Clear;
-use bizGhs\custom\classes\CustomClass;
-use bizGhs\item\classes\ItemClass;
-use bizGhs\item\classes\ItemClassClass;
-use bizGhs\order\classes\CheckOrderClass;
-use bizGhs\order\classes\OrderClass;
-use bizGhs\order\classes\OrderItemClass;
-use bizGhs\order\classes\RefundOrderClass;
-use bizGhs\order\classes\RefundOrderItemClass;
-use bizGhs\order\classes\StockWastageOrderClass;
-use bizGhs\order\classes\StockWastageOrderItemClass;
-use bizGhs\stat\classes\StatYjClass;
-use bizGhs\stat\classes\StatYjMonthClass;
-use bizHd\cg\classes\CgRefundClass;
-use bizHd\cg\classes\CgRefundItemClass;
-use bizHd\ghs\classes\GhsClass;
-use bizHd\goods\classes\CategoryClass;
-use bizHd\goods\classes\GoodsCategoryClass;
-use bizHd\goods\classes\GoodsClass;
-use bizHd\goods\classes\GoodsSettingClass;
-use bizHd\purchase\classes\PurchaseClass;
-use bizHd\purchase\classes\PurchaseItemClass;
-use bizHd\saas\classes\FestRiseClass;
-use bizHd\stat\classes\StatOrderClass;
-use bizHd\stat\classes\StatOrderMonthClass;
-use bizHd\stat\classes\StatUserClass;
-use bizHd\stat\classes\StatUserMonthClass;
-use bizHd\stat\classes\StatVisitClass;
-use bizHd\stat\classes\StatVisitMonthClass;
-use bizHd\user\classes\UserClass;
-use common\components\dict;
-use common\components\stringUtil;
+use bizHd\order\classes\OrderClass;
+use bizHd\order\models\Order;
 use Yii;
 use yii\console\Controller;
 
 class InitController extends Controller
 {
 
-    //花材菜单 ./yii init/menu
-    public function actionMenu()
-    {
-        $sql = "ALTER TABLE xhGhsItemClass ADD shopId INT NOT NULL DEFAULT 0 COMMENT '门店id' AFTER sjId;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE xhAdminRole ADD shopId INT NOT NULL DEFAULT 0 COMMENT '门店id' AFTER `sjId`;";
-        Yii::$app->db->createCommand($sql)->execute();
-
-        $list = SjClass::getAllByCondition(['id>' => 0], null, '*', null, true);
-        if (!empty($list)) {
-            foreach ($list as $sj) {
-                $sjId = $sj->id ?? 0;
-                if (empty($sjId)) {
-                    continue;
-                }
-                $shopList = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true);
-                if (empty($shopList)) {
-                    continue;
-                }
-                //补花材
-                $classList = ItemClassClass::getAllByCondition(['sjId' => $sjId], null, '*');
-                if (!empty($classList)) {
-                    foreach ($shopList as $shop) {
-                        $shopId = $shop->id ?? 0;
-                        foreach ($classList as $class) {
-                            $classId = $class['id'] ?? 0;
-                            $name = $class['name'] ?? '';
-                            $inTurn = $class['inTurn'] ?? '';
-                            $isDefault = $class['isDefault'] ?? 0;
-                            $data = [
-                                'shopId' => $shopId,
-                                'sjId' => $sjId,
-                                'name' => $name,
-                                'inTurn' => $inTurn,
-                                'isDefault' => $isDefault,
-                            ];
-                            $r = ItemClassClass::add($data, true);
-                            $newId = $r->id ?? 0;
-                            ItemClass::updateByCondition(['shopId' => $shopId, 'classId' => $classId], ['classId' => $newId]);
-                        }
-                    }
-                }
-
-                //补角色
-                $roleList = AdminRoleClass::getAllByCondition(['sjId' => $sjId], null, '*');
-                if (!empty($roleList)) {
-                    foreach ($shopList as $shop) {
-                        $shopId = $shop->id ?? 0;
-                        foreach ($roleList as $role) {
-                            $roleName = $role['roleName'] ?? '';
-                            $roleId = $role['id'] ?? 0;
-                            $roleData = [
-                                'shopId' => $shopId,
-                                'sjId' => $sjId,
-                                'roleName' => $roleName,
-                            ];
-                            $new = AdminRoleClass::add($roleData, true);
-                            $newId = $new->id ?? 0;
-                            ShopAdminClass::updateByCondition(['shopId' => $shopId, 'roleId' => $roleId], ['roleId' => $newId]);
-                        }
-                    }
-                }
-
-            }
-        }
-
-    }
-
-    //初始化 ./yii init/main
-    public function actionMain()
+    //供应商和花店历史订单和历史结账单 payStatus payTime更新
+    // ./yii init/pay-status
+    public function actionPayStatus()
     {
         ini_set('memory_limit', '2045M');
         set_time_limit(0);
 
-        //基地批发商
-        $jdShopList = ShopClass::getAllByCondition(['ptStyle' => dict::getDict('ptStyle', 'kmGhs')], 'default DESC', '*', null, true);
-        if (!empty($jdShopList)) {
-            foreach ($jdShopList as $jdShop) {
-                $main = MainClass::add(['id' => null], true);
-                $mainId = $main->id ?? 0;
-                if (empty($mainId)) {
-                    echo "mainId没有生成 \n";
-                    exit();
-                }
-                $jdShop->mainId = $mainId;
-                $jdShop->save();
-            }
-        }
-
-        //批发商
-        $pfShopList = ShopClass::getAllByCondition(['ptStyle' => dict::getDict('ptStyle', 'ghs')], 'default DESC', '*', null, true);
-        if (!empty($pfShopList)) {
-            foreach ($pfShopList as $pfShop) {
-                $pfShopId = $pfShop->id ?? 0;
-                $main = MainClass::add(['id' => null], true);
-                $mainId = $main->id ?? 0;
-                if (empty($mainId)) {
-                    echo "mainId没有生成 \n";
-                    exit();
-                }
-                $pfShop->mainId = $mainId;
-                $pfShop->save();
-
-                //将shop资产信息迁移到main
-                self::migration($main, $pfShop);
-
-                //员工数据迁移到currentGhsShopId,删除零售和基地供应商的管理员信息
-                $staffList = ShopAdminClass::getAllByCondition(['shopId' => $pfShopId], null, '*');
-                if (!empty($staffList)) {
-                    foreach ($staffList as $staff) {
-                        $pfAdminId = $staff['adminId'] ?? 0;
-                        $pfAdmin = AdminClass::getById($pfAdminId, true);
-                        if (!empty($pfAdmin)) {
-                            if (empty($pfAdmin->currentGhsShopId)) {
-                                $pfAdmin->currentGhsShopId = $pfShopId;
-                                $pfAdmin->ghsMiniOpenId = $pfAdmin->miniOpenId ?? '';
-                                $pfAdmin->miniOpenId = '';
-                                $pfAdmin->currentShopId = 0;
-                                $pfAdmin->save();
-                            }
-                        } else {
-                            echo "没有找到shopId:{$pfShopId}批发店的员工\n";
-                        }
-                        $staffMobile = $staff['mobile'] ?? '';
-                        //删除和批发店用一样手机号的 零售和基地供应商 员工
-                        if (!empty($staffMobile)) {
-                            $h = AdminClass::getAllByCondition(['mobile' => $staffMobile, 'style' => dict::getDict('ptStyle', 'hd')], null, '*', null, true);
-                            if (!empty($h)) {
-                                foreach ($h as $he) {
-                                    $currentAdminId = $he->id ?? 0;
-                                    ShopAdminClass::deleteByCondition(['adminId' => $currentAdminId]);
-                                    $he->delete();
-                                }
-                            }
-                            $j = AdminClass::getAllByCondition(['mobile' => $staffMobile, 'style' => dict::getDict('ptStyle', 'kmGhs')], null, '*', null, true);
-                            if (!empty($j)) {
-                                foreach ($j as $je) {
-                                    $currentAdminId = $je->id ?? 0;
-                                    ShopAdminClass::deleteByCondition(['adminId' => $currentAdminId]);
-                                    $je->delete();
-                                }
-                            }
-                        }
-                    }
-                }
-
-                //花材和分类,零售和批发都有,单独拎出来
-                ItemClass::updateByCondition(['shopId' => $pfShopId], ['mainId' => $mainId]);
-                ItemClassClass::updateByCondition(['shopId' => $pfShopId], ['mainId' => $mainId]);
-
-                self::setCommon($pfShopId, $mainId);
-                self::setGhs($pfShopId, $mainId);
-
-            }
-
-        }
-
-        //零售
-        $lsShopList = ShopClass::getAllByCondition(['ptStyle' => dict::getDict('ptStyle', 'hd')], 'default DESC', '*', null, true);
-        if (!empty($lsShopList)) {
-            foreach ($lsShopList as $lsShop) {
-                $main = MainClass::add(['id' => null], true);
-                $mainId = $main->id ?? 0;
-                if (empty($mainId)) {
-                    echo "mainId没有生成 \n";
-                    exit();
-                }
-                $lsShop->mainId = $mainId;
-                $lsShop->save();
-                $lsShopId = $lsShop->id ?? 0;
-                $lsSjId = $lsShop->sjId ?? 0;
-
-                //将shop资产信息迁移到main
-                self::migration($main, $lsShop);
-
-                $staffList = ShopAdminClass::getAllByCondition(['shopId' => $lsShopId], null, '*');
-                if (!empty($staffList)) {
-                    foreach ($staffList as $staff) {
-                        $adminId = $staff['adminId'] ?? 0;
-                        $admin = AdminClass::getById($adminId, true);
-                        if (!empty($admin)) {
-                            if (empty($admin->currentShopId)) {
-                                $admin->currentShopId = $lsShopId;
-                                $admin->save();
-                            }
-                        }
-                    }
-                }
-
-                //花材和分类,零售和批发都有,单独拎出来
-                ItemClass::updateByCondition(['shopId' => $lsShopId], ['mainId' => $mainId]);
-                ItemClassClass::updateByCondition(['shopId' => $lsShopId], ['mainId' => $mainId]);
-
-                self::setCommon($lsShopId, $mainId);
-                self::setHd($lsSjId, $lsShopId, $mainId);
-
-            }
-        }
-
-        //清除零售商城相关的数据
-        $sql = "TRUNCATE xhUser;TRUNCATE xhCustom;truncate xhUserAsset;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "UPDATE xhOrder SET customId=0,customName='',alipayId=0;";
-        Yii::$app->db->createCommand($sql)->execute();
-        //补已经存在花店的默认客户
-        $lsShopList = ShopClass::getAllByCondition(['ptStyle' => dict::getDict('ptStyle', 'hd')], null, '*', null, true);
-        if (!empty($lsShopList)) {
-            foreach ($lsShopList as $lsShop) {
-                $mobile = $lsShop->mobile ?? 0;
-                if (empty($mobile) || stringUtil::isMobile($mobile) == false) {
-                    continue;
-                }
-                $user = UserClass::replaceUser(['mobile' => $mobile]);
-                $custom = \bizHd\custom\classes\CustomClass::replaceCustom($lsShop, $user);
-                $customId = $custom->id ?? 0;
-                $lsShop->defaultCustomId = $customId;
-                $lsShop->save();
-            }
-        }
-
-        //欠款字段迁移
-        $sql = 'UPDATE xhGhsOrder SET debtPrice=actPrice,remainDebtPrice=actPrice WHERE debt=1';
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = 'UPDATE xhCg SET debtPrice=actPrice,remainDebtPrice=actPrice WHERE debt=1;';
+        $sql = "UPDATE `xhOrder` SET `payStatus`=0;";
         Yii::$app->db->createCommand($sql)->execute();
-
-        $map = [];
-        $allShop = ShopClass::getAllByCondition(['id>' => 0], null, '*', null, true);
-        if (!empty($allShop)) {
-            foreach ($allShop as $single) {
-                $mainId = $single->mainId ?? 0;
-                $shopId = $single->id ?? 0;
-                $map[$shopId] = $mainId;
-            }
-        }
-
-
-        //供应商的销售单 和 零售的退款单,老字段数据要迁到新字段数据上
-        $ghsSaleRefund = [];
-        $hdCgRefund = [];
-        $refundList = RefundOrderClass::getAllByCondition(['id>' => 0], null, '*', null, true);
-        if (!empty($refundList)) {
-            foreach ($refundList as $key => $refund) {
-                $orderSn = $refund->orderSn ?? '';
-                $relateOrderSn = $refund->relateOrderSn ?? '';
-                $shopId = $refund->shopId ?? 0;
-                $mainId = $map[$shopId] ?? 0;
-                $refund->mainId = $mainId;
-                $refund->save();
-                if (empty($orderSn)) {
-                    continue;
-                }
-                $refundItemList = RefundOrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
-                if (!empty($refundItemList)) {
-                    foreach ($refundItemList as $refundItem) {
-                        $refundItem->xhNum = floatval($refundItem->itemNum);
-                        $refundItem->xhUnitName = '扎';
-                        $refundItem->xhUnitType = 0;
-                        $refundItem->xhUnitPrice = $refundItem->itemPrice;
-                        $refundItem->xhPrice = bcmul($refundItem->itemPrice, $refundItem->itemNum, 2);
-                        $refundItem->mainId = $mainId;
-                        $refundItem->save();
-                        $productId = $refundItem->productId ?? 0;
-                        $ghsSaleRefund[$relateOrderSn][$productId] = floatval($refundItem->itemNum);
-                    }
-                }
-            }
-        }
-        $cgRefundList = CgRefundClass::getAllByCondition(['id>' => 0], null, '*', null, true);
-        if (!empty($cgRefundList)) {
-            foreach ($cgRefundList as $cgRefund) {
-                $orderSn = $cgRefund->orderSn ?? '';
-                $cgId = $cgRefund->cgId ?? 0;
-                $shopId = $cgRefund->shopId ?? 0;
-                $mainId = $map[$shopId] ?? 0;
-                $cgRefund->mainId = $mainId;
-                $cgRefund->save();
-                if (empty($orderSn)) {
-                    continue;
-                }
-                $cgRefundItemList = CgRefundItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
-                if (!empty($cgRefundItemList)) {
-                    foreach ($cgRefundItemList as $cgItem) {
-                        $cgItem->xhNum = floatval($cgItem->itemNum);
-                        $cgItem->xhUnitName = '扎';
-                        $cgItem->xhUnitType = 0;
-                        $cgItem->xhUnitPrice = $cgItem->itemPrice;
-                        $cgItem->xhPrice = bcmul($cgItem->itemPrice, $cgItem->itemNum, 2);
-                        $cgItem->mainId = $mainId;
-                        $cgItem->save();
-                        $productId = $cgItem->productId ?? 0;
-                        $hdCgRefund[$cgId][$productId] = floatval($cgItem->itemNum);
-                    }
-                }
-            }
-        }
-
-        //供应商的销售单 和 零售的采购单,老字段数据要迁到新字段数据上
-        $orderList = OrderClass::getAllByCondition(['id>' => 0], null, '*', null, true);
-        if (!empty($orderList)) {
-            foreach ($orderList as $order) {
-                $orderSn = $order->orderSn ?? '';
-                if (empty($orderSn)) {
-                    continue;
-                }
-                $order->orderPrice = bcadd($order->prePrice, $order->discountAmount, 2);
-                $order->save();
-                $orderItemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
-                if (!empty($orderItemList)) {
-                    foreach ($orderItemList as $orderItem) {
-                        $productId = $orderItem->productId ?? 0;
-                        $refundNum = $ghsSaleRefund[$orderSn][$productId] ?? 0;
-
-                        $bigNum = $orderItem->bigNum ?? 0;
-                        $smallNum = $orderItem->smallNum ?? 0;
-                        $unitPrice = $orderItem->unitPrice ?? 0;
-                        $smallUnitPrice = $orderItem->smallUnitPrice ?? 0;
-                        if ($bigNum > 0) {
-                            $xhUnitType = 0;
-                            $xhUnitName = '扎';
-                            $xhNum = $bigNum;
-                            $xhUnitPrice = $unitPrice;
-                        } else {
-                            $xhUnitType = 1;
-                            $xhUnitName = '支';
-                            $xhNum = $smallNum;
-                            $xhUnitPrice = $smallUnitPrice;
-                        }
-
-                        $orderItem->xhNum = $xhNum;
-                        $orderItem->xhUnitName = $xhUnitName;
-                        $orderItem->xhUnitType = $xhUnitType;
-                        $orderItem->xhUnitPrice = $xhUnitPrice;
-                        $orderItem->xhPrice = bcmul($xhNum, $xhUnitPrice, 2);
-                        $orderItem->xhPreNum = 0;
-                        $orderItem->xhPreUnitName = 0;
-                        $orderItem->xhPreUnitType = 0;
-                        $orderItem->xhPreUnitPrice = 0;
-                        $orderItem->xhPrePrice = 0;
-                        //refundNum 已退货数量
-                        $orderItem->refundNum = $refundNum;
-                        $orderItem->save();
-                    }
-                }
-            }
-        }
-
-        $cgList = PurchaseClass::getAllByCondition(['id>' => 0], null, '*', null, true);
-        if (!empty($cgList)) {
-            foreach ($cgList as $cg) {
-                $orderSn = $cg->orderSn ?? '';
-                $cgId = $cg->id ?? 0;
-                if (empty($orderSn)) {
-                    continue;
-                }
-                $cg->orderPrice = bcsub($cg->prePrice, $cg->discountAmount, 2);
-                $cg->save();
-                $cgItemList = PurchaseItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
-                if (!empty($cgItemList)) {
-                    foreach ($cgItemList as $cgItem) {
-                        $productId = $cgItem->productId ?? 0;
-                        $refundNum = $hdCgRefund[$cgId][$productId] ?? 0;
-
-                        if (floor($cgItem->itemNum) == $cgItem->itemNum) {
-                            $xhNum = $cgItem->itemNum;
-                            $xhUnitType = 0;
-                            $xhUnitName = '扎';
-                            $xhUnitPrice = $cgItem->price;
-                            $xhPrice = $cgItem->totalPrice;
-                        } else {
-                            $xhUnitType = 1;
-                            $xhUnitName = '支';
-                            $xhNum = bcmul($cgItem->ratio, $cgItem->itemNum);
-                            $xhUnitPrice = $cgItem->smallPrice;
-                            $xhPrice = $cgItem->totalPrice;
-                        }
-
-                        $cgItem->xhNum = $xhNum;
-                        $cgItem->xhUnitName = $xhUnitName;
-                        $cgItem->xhUnitType = $xhUnitType;
-                        $cgItem->xhUnitPrice = $xhUnitPrice;
-                        $cgItem->xhPrice = $xhPrice;
-
-                        $cgItem->refundNum = $refundNum;
-                        $cgItem->save();
-                    }
-                }
-            }
-        }
-
-        //将平台花材的散客加价设置为8,花店加价设置为6,同行加价设置为4
-        $sql = 'UPDATE `xhPtItem` SET `skAddPrice`=8,`addPrice`=6,`hjAddPrice`=4;';
+        $sql = "UPDATE `xhGhsOrder` SET `payStatus`=0;";
         Yii::$app->db->createCommand($sql)->execute();
 
-        self::migrationDel();
-
-        //客户和供应商的中央化
-        self::ghsCustomMain($map);
-
-    }
-
-    //客户和供应商的中央化 ssh 20220506
-    public static function ghsCustomMain($map)
-    {
-        $customList = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true);
-        if (!empty($customList)) {
-            foreach ($customList as $custom) {
-                $shopId = $custom->shopId ?? 0;
-                $mainId = $map[$shopId] ?? 0;
-                $custom->mainId = $mainId;
-                $ownShopId = $custom->ownShopId ?? 0;
-                $ownMainId = $map[$ownShopId] ?? 0;
-                $custom->ownMainId = $ownMainId;
-                $custom->save();
+        $query = new \yii\db\Query();
+        $query->from(Order::tableName());
+        $query->where(['status' => ['in', [2, 3, 4]]]);
+        $query->orderBy('deadline ASC');
+        foreach ($query->batch() as $batchOrder) {
+            foreach ($batchOrder as $hdOrder) {
+                $addTime = $hdOrder['addTime'] ?? '';
+                $id = $hdOrder['id'] ?? 0;
+                OrderClass::updateById($id, ['payTime' => $addTime, 'payStatus' => 1]);
             }
         }
 
-        $ghsList = GhsClass::getAllByCondition(['id>' => 0], null, '*', null, true);
-        foreach ($ghsList as $ghs) {
-            $shopId = $ghs->shopId ?? 0;
-            $mainId = $map[$shopId] ?? 0;
-            $ghs->mainId = $mainId;
-            $ownShopId = $ghs->ownShopId ?? 0;
-            $ownMainId = $map[$ownShopId] ?? 0;
-            $ghs->ownMainId = $ownMainId;
-            $ghs->save();
-        }
-    }
-
-
-    public static function setCommon($shopId, $mainId)
-    {
-        ShopAdminClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        CashClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        AdminRoleClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        CheckOrderClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatPdAddClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatPdAddMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatPdSubClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatPdSubMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatWastClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatWastMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-    }
-
-    public static function setGhs($shopId, $mainId)
-    {
-        StatSaleClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatSaleMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        StatUserClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatUserMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        StatVisitClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatVisitMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        StatOutClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatOutMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        PtYeChangeClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        ShopYeChangeClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        RechargeClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        StatYjClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatYjMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        StatOrderClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatOrderMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        StatOrderCountClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        RefundOrderClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        //采购统计
-        StatCgClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatCgMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatCgGhsClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatCgGhsMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        CustomClass::updateByCondition(['ownShopId' => $shopId], ['ownMainId' => $mainId]);
-
-        StatStockOutClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatStockOutMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        StatStockInClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatStockInMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        StatRefundClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        StatRefundMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        CgClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        XjClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-
-        //报损中央化
-        StockWastageOrderClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-        $wastageList = StockWastageOrderClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
-        if (!empty($wastageList)) {
-            foreach ($wastageList as $wastage) {
-                $wastageOrderSn = $wastage->orderSn ?? 0;
-                StockWastageOrderItemClass::updateByCondition(['orderSn' => $wastageOrderSn], ['mainId' => $mainId]);
+        $query = new \yii\db\Query();
+        $query->from(\bizGhs\order\models\Order::tableName());
+        $query->where(['status' => ['in', [2, 3, 4]]]);
+        $query->orderBy('deadline ASC');
+        foreach ($query->batch() as $batchOrder) {
+            foreach ($batchOrder as $ghsOrder) {
+                $addTime = $ghsOrder['addTime'] ?? '';
+                $id = $ghsOrder['id'] ?? 0;
+                \bizGhs\order\classes\OrderClass::updateById($id, ['payTime' => $addTime, 'payStatus' => 1]);
             }
         }
-    }
 
-    public static function setHd($sjId, $shopId, $mainId)
-    {
-        GoodsClass::updateByCondition(['sjId' => $sjId], ['mainId' => $mainId]);
-        GoodsCategoryClass::updateByCondition(['sjId' => $sjId], ['mainId' => $mainId]);
-        CategoryClass::updateByCondition(['sjId' => $sjId], ['mainId' => $mainId]);
-        GoodsSettingClass::updateByCondition(['sjId' => $sjId], ['mainId' => $mainId]);
-        FestRiseClass::updateByCondition(['sjId' => $sjId], ['mainId' => $mainId]);
-        GhsClass::updateByCondition(['ownShopId' => $shopId], ['ownMainId' => $mainId]);
-        PurchaseClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
-    }
-
-    public static function migration($main, $shop)
-    {
-        //shop数据迁移到main,保存之后请在migrationDel()增加对应字段!!!!!!
-        $main->balance = $shop->balance ?? 0;
-        $main->freezeBalance = $shop->freezeBalance ?? 0;
-        $main->txBalance = $shop->txBalance ?? 0;
-        $main->fixBalance = $shop->fixBalance ?? 0;
-        $main->totalRecharge = $shop->totalRecharge ?? 0;
-        $main->totalIncome = $shop->totalIncome ?? 0;
-        $main->totalExpend = $shop->totalExpend ?? 0;
-        $main->totalPurchase = $shop->totalPurchase ?? 0;
-        $main->totalItem = $shop->totalItem ?? 0;
-        $main->totalSale = $shop->totalSale ?? 0;
-        $main->totalStockIn = $shop->totalStockIn ?? 0;
-        $main->totalStockOut = $shop->totalStockOut ?? 0;
-        $main->totalRefund = $shop->totalRefund ?? 0;
-        $main->totalWast = $shop->totalWast ?? 0;
-        $main->totalPdSub = $shop->totalPdSub ?? 0;
-        $main->totalPdAdd = $shop->totalPdAdd ?? 0;
-        $main->totalPurchaseOrder = $shop->totalPurchaseOrder ?? 0;
-        $main->totalUser = $shop->totalUser ?? 0;
-        $main->totalVisit = $shop->totalVisit ?? 0;
-        $main->totalView = $shop->totalView ?? 0;
-        $main->cashName = $shop->cashName ?? '';
-        $main->cashAccount = $shop->cashAccount ?? '';
-        $main->cashBank = $shop->cashBank ?? '';
-
-        $main->cgUnPay = $shop->cgUnPay ?? 0;
-        $main->cgUnSend = $shop->cgUnSend ?? 0;
-        $main->cgSending = $shop->cgSending ?? 0;
-        $main->cgFinish = $shop->cgFinish ?? 0;
-        $main->cgCancel = $shop->cgCancel ?? 0;
-        $main->mayGatheringNum = $shop->mayGatheringNum ?? 0;
-        $main->mayGathering = $shop->mayGathering ?? 0;
-        $main->mayPay = $shop->mayPay ?? 0;
-        $main->mayPayNum = $shop->mayPayNum ?? 0;
-
-        $main->totalOrder = $shop->totalOrder ?? 0;
-        $main->totalOrderNum = $shop->totalOrderNum ?? 0;
-        $main->finishOrder = $shop->finishOrder ?? 0;
-        $main->unPayOrder = $shop->unPayOrder ?? 0;
-        $main->unSendOrder = $shop->unSendOrder ?? 0;
-        $main->sendingOrder = $shop->sendingOrder ?? 0;
-        $main->cancelOrder = $shop->cancelOrder ?? 0;
-
-        $main->save();
-    }
-
-    //迁移完成之后删除xhShop对应字段
-    public static function migrationDel()
-    {
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `balance`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `freezeBalance`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `txBalance`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `fixBalance`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalRecharge`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalIncome`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalExpend`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalPurchase`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalItem`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalSale`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalStockIn`;";
+        $sql = "UPDATE `xhClear` SET `payTime`=`addTime` where `status`=2;";
         Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalStockOut`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalRefund`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalWast`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalPdSub`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalPdAdd`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalPurchaseOrder`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalUser`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalVisit`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalView`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cashName`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cashAccount`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cashBank`;";
-
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cgUnPay`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cgUnSend`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cgSending`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cgFinish`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cgCancel`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `mayGathering`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `mayGatheringNum`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `mayPay`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `mayPayNum`;";
-        Yii::$app->db->createCommand($sql)->execute();
-
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalOrder`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `totalOrderNum`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `finishOrder`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `unPayOrder`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `unSendOrder`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `sendingOrder`;";
-        Yii::$app->db->createCommand($sql)->execute();
-        $sql = "ALTER TABLE `xhShop` DROP COLUMN `cancelOrder`;";
-        Yii::$app->db->createCommand($sql)->execute();
-
-    }
 
-    //结账单补数据
-    public function actionClear()
-    {
-        $query = new \yii\db\Query();
-        $query->from(Clear::tableName());
-        $query->where(['>', 'id', 0]);
-        $query->orderBy('addTime ASC');
-        foreach ($query->batch() as $clearBatch) {
-            $batchGhsId = array_column($clearBatch, 'ghsId');
-            $batchCustomId = array_column($clearBatch, 'customId');
-            $batchGhsId = array_unique(array_filter($batchGhsId));
-            $batchCustomId = array_unique(array_filter($batchCustomId));
-            $customInfo = CustomClass::getByIds($batchCustomId, null, 'id');
-            $ghsInfo = GhsClass::getByIds($batchGhsId, null, 'id');
-            foreach ($clearBatch as $clear) {
-                $id = $clear['id'];
-                $clearStyle = $clear['clearStyle'] ?? 1;
-                if ($clearStyle != dict::getDict('clearStyle', 'gys2KmGys')) {
-                    $customId = $clear['customId'] ?? 0;
-                    $ghsId = $clear['ghsId'] ?? 0;
-                    $customShopId = $customInfo[$customId]['shopId'] ?? 0;
-                    $ghsShopId = $ghsInfo[$ghsId]['shopId'] ?? 0;
-                    $params = ['customShopId' => $customShopId, 'ghsShopId' => $ghsShopId];
-                    ClearClass::updateById($id, $params);
-                } else {
-                    $currentGhsId = $clear['ghsId'] ?? 0;
-                    if (empty($currentGhsId)) {
-                        echo "出现空的ghsId clearId:{$id} \n";
-                        continue;
-                    }
-                    $currentGhs = GhsClass::getById($currentGhsId, true);
-                    $currentCustomId = $currentGhs->customId ?? 0;
-                    $currentCustom = CustomClass::getById($currentCustomId, true);
-                    $customShopId = $currentCustom->shopId ?? 0;
-                    $ghsShopId = $currentGhs->shopId ?? 0;
-                    $params = ['customShopId' => $customShopId, 'customId' => $currentCustomId, 'ghsShopId' => $ghsShopId];
-                    ClearClass::updateById($id, $params);
-                }
-            }
-        }
     }
 
 }