>>>>>> f0f562f584d13f17f95fdaaa1933ea9b918ba31c use Yii; use yii\console\Controller; class InitController extends Controller { <<<<<<< HEAD //供应商和花店历史订单和历史结账单 payStatus payTime更新 // ./yii init/pay-status public function actionPayStatus() ======= //花店订单脚本 public function actionHdOrder() { $query = new \yii\db\Query(); $query->from(Order::tableName()); $query->where(['mainId' => 742]); foreach ($query->batch() as $batchOrder) { foreach ($batchOrder as $order) { $addTime = $order['addTime'] ?? ''; $goodsPrice = $order['goodsPrice'] ?? 0; $goodsPrice = floatval($goodsPrice); $sendCost = $order['sendCost'] ?? 0; $sendCost = floatval($sendCost); $labourCost = $order['labourCost'] ?? 0; $labourCost = floatval($labourCost); $discountAmount = $order['discountAmount'] ?? 0; $discountAmount = floatval($discountAmount); $orderPrice = $order['orderPrice'] ?? 0; $orderPrice = floatval($orderPrice); $total = bcadd($goodsPrice, $sendCost, 2); $total = bcadd($total, $labourCost, 2); $final = bcsub($total, $discountAmount, 2); $final = floatval($final); $shopAdminName = $order['shopAdminName'] ?? ''; $actPrice = $order['actPrice'] ?? 0; $orderSn = $order['orderSn'] ?? ''; if ($final != $orderPrice) { echo "订单号:{$orderSn} {$addTime} \n"; echo "===\n"; $itemList = \bizHd\order\classes\OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*'); if (!empty($itemList)) { foreach ($itemList as $item) { echo $item['name'] . " " . $item['num'] . "X" . $item['unitPrice'] . " " . $item['price'] . "\n"; } } $goodsList = OrderGoodsClass::getAllByCondition(['orderSn' => $orderSn], null, '*'); if (!empty($goodsList)) { foreach ($goodsList as $goods) { echo $goods['name'] . " " . $goods['num'] . "X" . $goods['unitPrice'] . " " . $goods['price'] . "\n"; } } echo "===\n"; echo "商品总和:{$goodsPrice} \n运费:{$sendCost} \n人工包装费:{$labourCost} \n合计:{$total} \n优惠:{$discountAmount} \n订单金额:{$orderPrice} \n实付金额:{$actPrice} \n开单人:{$shopAdminName}\n\n\n\n\n"; } } } } //花材菜单 ./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() >>>>>>> f0f562f584d13f17f95fdaaa1933ea9b918ba31c { ini_set('memory_limit', '2045M'); set_time_limit(0); $sql = "UPDATE `xhOrder` SET `payStatus`=0;"; Yii::$app->db->createCommand($sql)->execute(); $sql = "UPDATE `xhGhsOrder` SET `payStatus`=0;"; Yii::$app->db->createCommand($sql)->execute(); $query = new \yii\db\Query(); $query->from(Order::tableName()); $query->where(['in', 'status', [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]); } } $query = new \yii\db\Query(); $query->from(\bizGhs\order\models\Order::tableName()); $query->where(['in', 'status', [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]); } } $sql = "UPDATE `xhClear` SET `payTime`=`addTime` where `status`=2;"; Yii::$app->db->createCommand($sql)->execute(); } }