| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?php
- namespace console\controllers;
- use biz\ghs\classes\GhsClass;
- use biz\shop\classes\ShopClass;
- use biz\shop\models\Shop;
- use bizGhs\custom\classes\CustomClass;
- use bizGhs\order\classes\OrderClass;
- use bizGhs\order\models\Order;
- use bizHd\purchase\classes\PurchaseClass;
- use yii\console\Controller;
- use Yii;
- class ShopController extends Controller
- {
- public function actionHasGhs()
- {
- $query = new \yii\db\Query();
- $query->from(Shop::tableName());
- $query->where(['ptStyle' => 1]);
- foreach ($query->batch() as $shopList) {
- foreach ($shopList as $shop) {
- $shopId = $shop['id'] ?? 0;
- $where = ['ownShopId' => $shopId];
- $count = GhsClass::getCount($where);
- if ($count == 0) {
- //无操作
- } elseif ($count == 1) {
- $ghs = GhsClass::getByCondition($where, true);
- $ghsId = $ghs->id ?? 0;
- if (!empty($ghsId)) {
- ShopClass::updateById($shopId, ['uniGhsId' => $ghsId]);
- }
- } else {
- ShopClass::updateById($shopId, ['hasManyGhs' => 1]);
- }
- }
- }
- }
- public function actionOrder()
- {
- $query = new \yii\db\Query();
- $query->from(Order::tableName());
- $query->where(['>', 'id', 0]);
- foreach ($query->batch() as $orderList) {
- foreach ($orderList as $order) {
- $payTime = $order['payTime'] ?? '';
- if (!empty($payTime) && $payTime != '0000-00-00 00:00:00') {
- $addTime = $order['addTime'] ?? '';
- if ($payTime > $addTime) {
- echo "id:{$order['id']} {$payTime} {$addTime}\n";
- OrderClass::updateById($order['id'], ['addTime' => $payTime]);
- $purchaseId = $order['purchaseId'] ?? 0;
- $cg = PurchaseClass::getById($purchaseId, true);
- if (!empty($cg)) {
- $cg->addTime = $payTime;
- $cg->save();
- }
- }
- }
- }
- }
- }
- public function actionCustom()
- {
- $custom = CustomClass::getAllByCondition(['id>' => 0], null, '*', null, true);
- if (empty($custom)) {
- echo '空';
- return false;
- }
- foreach ($custom as $item) {
- $shopId = $item->shopId ?? 0;
- $shop = ShopClass::getById($shopId, true);
- if ($shop->mainId != $item->mainId) {
- echo "客户id:{$item->id} {$shop->mainId} {$item->mainId}\n";
- if (!empty($shop->mainId)) {
- $item->mainId = $shop->mainId;
- $item->save();
- }
- }
- $ownShopId = $item->ownShopId ?? 0;
- $ownShop = ShopClass::getById($ownShopId, true);
- if ($ownShop->mainId != $item->ownMainId) {
- echo "客户own {$item->id} {$item->ownMainId} {$ownShop->mainId}\n";
- if (!empty($ownShop->mainId)) {
- $item->ownMainId = $ownShop->mainId;
- $item->save();
- }
- }
- }
- }
- public function actionGhs()
- {
- $ghs = GhsClass::getAllByCondition(['id>' => 0], null, '*', null, true);
- if (empty($ghs)) {
- echo '空';
- return false;
- }
- foreach ($ghs as $item) {
- $shopId = $item->shopId ?? 0;
- $mainId = $item->mainId ?? 0;
- $shop = ShopClass::getById($shopId, true);
- if ($shop->mainId != $mainId) {
- echo "ghs {$item->id} {$mainId} {$shop->mainId} \n";
- }
- $ownShopId = $item->ownShopId ?? 0;
- $ownMainId = $item->ownMainId ?? 0;
- $ownShop = ShopClass::getById($ownShopId, true);
- if ($ownShop->mainId != $ownMainId) {
- echo "ghs own {$item->id} {$ownMainId} {$ownShop->mainId} \n";
- if (!empty($ownShop->mainId)) {
- $item->ownMainId = $ownShop->mainId;
- $item->save();
- }
- }
- }
- }
- }
|