Procházet zdrojové kódy

Merge branch 'master' into dev

shish před 2 měsíci
rodič
revize
5d92837868

+ 1 - 1
app-ghs/controllers/ConsoleController.php

@@ -314,7 +314,7 @@ class ConsoleController extends BaseController
 
 
         $warning = '';
         $warning = '';
         $warningUrl = '';
         $warningUrl = '';
-        $warning = '【必看】挂账结账功能重大调整 查看 >';
+        $warning = '挂账结账功能重大调整(已上线) 查看 >';
         $warningUrl = '/admin/notice/warning';
         $warningUrl = '/admin/notice/warning';
 
 
         util::success([
         util::success([

+ 1 - 0
app-ghs/controllers/TestController.php

@@ -498,6 +498,7 @@ class TestController extends BaseController
             //['name' => '淮北花述语鲜花批发', 'merchantNo' => '82236605992001E', 'wx' => [895627520, 895627914], 'zfb' => '2088680541422679'],
             //['name' => '淮北花述语鲜花批发', 'merchantNo' => '82236605992001E', 'wx' => [895627520, 895627914], 'zfb' => '2088680541422679'],
             //['name' => '泉州馨喜鲜花批发', 'merchantNo' => '8223970599200KD', 'wx' => [896099124, 896098673], 'zfb' => '2088680670320387'],
             //['name' => '泉州馨喜鲜花批发', 'merchantNo' => '8223970599200KD', 'wx' => [896099124, 896098673], 'zfb' => '2088680670320387'],
             //['name' => '东莞石龙我要花', 'merchantNo' => '8226020599200RC', 'wx' => [896365688, 896365294], 'zfb' => '2088680722085035'],
             //['name' => '东莞石龙我要花', 'merchantNo' => '8226020599200RC', 'wx' => [896365688, 896365294], 'zfb' => '2088680722085035'],
+            ['name' => '衡阳昕得鲜花批发', 'merchantNo' => '82255405992002Z', 'wx' => [898896294, 898896948], 'zfb' => '2088780074321358'],
             ['name' => '昆明花满禾鲜花', 'merchantNo' => '82273105992012G', 'wx' => [898442463, 898442140], 'zfb' => '2088780050977551'],
             ['name' => '昆明花满禾鲜花', 'merchantNo' => '82273105992012G', 'wx' => [898442463, 898442140], 'zfb' => '2088780050977551'],
             //['name' => '厦门纯彩花艺', 'merchantNo' => '8223930599200LD', 'wx' => [894984230, 894983290], 'zfb' => '2088680439152343'],
             //['name' => '厦门纯彩花艺', 'merchantNo' => '8223930599200LD', 'wx' => [894984230, 894983290], 'zfb' => '2088680439152343'],
             //['name' => '东莞我要花鲜花', 'merchantNo' => '8226020599200R8', 'wx' => [894794554, 894794917], 'zfb' => '2088680405463378'],
             //['name' => '东莞我要花鲜花', 'merchantNo' => '8226020599200R8', 'wx' => [894794554, 894794917], 'zfb' => '2088680405463378'],

+ 12 - 0
biz/ghs/classes/GhsBackClass.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace biz\ghs\classes;
+
+use biz\base\classes\BaseClass;
+
+class GhsBackClass extends BaseClass
+{
+
+    public static $baseFile = '\biz\ghs\models\GhsBack';
+
+}

+ 13 - 0
biz/ghs/models/GhsBack.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace biz\ghs\models;
+
+use biz\base\models\Base;
+
+class GhsBack extends Base
+{
+    public static function tableName()
+    {
+        return 'xhGhsBack';
+    }
+}

+ 183 - 0
console/controllers/ClearController.php

@@ -0,0 +1,183 @@
+<?php
+
+namespace console\controllers;
+
+use biz\ghs\classes\GhsBackClass;
+use bizGhs\clear\classes\OrderCgClearClass;
+use bizGhs\clear\models\Clear;
+use bizGhs\ghs\classes\GhsClass;
+use bizGhs\ghs\models\Ghs;
+use bizGhs\order\classes\OrderClass;
+use bizGhs\order\classes\PurchaseOrderClass;
+use bizHd\purchase\classes\PurchaseClass;
+use yii\console\Controller;
+use Yii;
+
+class ClearController extends Controller
+{
+
+    //补回 xhOrderCgClear
+    public function actionBc()
+    {
+
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+
+        if (getenv('YII_ENV') == 'production') {
+            $autoId = 817342;
+        } else {
+            $autoId = 1426;
+        }
+
+        $query = new \yii\db\Query();
+        $query->from(Clear::tableName());
+        $query->where(['>', 'id', $autoId]);
+        foreach ($query->batch(500) as $changeList) {
+
+            $ids = array_column($changeList, 'id');
+            $relate = OrderCgClearClass::getAllByCondition(['clearId' => ['in', $ids]], null, '*', 'clearId');
+
+            $connection = Yii::$app->db;
+            $transaction = $connection->beginTransaction();
+
+            try {
+
+                foreach ($changeList as $clear) {
+                    $clearId = $clear['id'] ?? 0;
+                    $clearSn = $clear['orderSn'] ?? '';
+                    $status = $clear['status'] ?? 1;
+                    $clearAmount = $clear['actPrice'] ?? 0;
+                    $purchaseIds = $clear['purchaseIds'] ?? '';
+                    $saleIds = $clear['saleIds'] ?? '';
+                    $clearStyle = $clear['clearStyle'] ?? 1;
+                    if (!isset($relate[$clearId])) {
+                        if ($clearStyle == 3) {
+                            if (!empty($purchaseIds)) {
+                                $purchaseIdList = explode(',', $purchaseIds);
+                                $purchaseInfo = PurchaseOrderClass::getAllByCondition(['id' => ['in', $purchaseIdList]], null, 'id,orderSn', 'id');
+                                foreach ($purchaseInfo as $purchase) {
+                                    $purchaseId = $purchase['id'] ?? 0;
+                                    $purchaseOrderSn = $purchase['orderSn'] ?? 0;
+                                    $addData = ['orderId' => 0, 'orderSn' => '', 'cgId' => $purchaseId, 'cgSn' => $purchaseOrderSn,
+                                        'clearId' => $clearId, 'clearSn' => $clearSn, 'amount' => $clearAmount, 'status' => $status];
+                                    OrderCgClearClass::add($addData);
+                                    echo "ghs cg clearId {$clearId} OK ### \n";
+                                }
+                            } else {
+                                echo "供货商采购 clearId {$clearId} 有缺数据 \n";
+                            }
+                        } else {
+                            if (!empty($saleIds) && !empty($purchaseIds)) {
+                                $saleIdList = explode(',', $saleIds);
+                                $purchaseIdList = explode(',', $purchaseIds);
+                                $saleInfo = OrderClass::getAllByCondition(['id' => ['in', $saleIdList]], null, 'id,orderSn,purchaseId');
+                                $purchaseInfo = PurchaseClass::getAllByCondition(['id' => ['in', $purchaseIdList]], null, 'id,orderSn', 'id');
+                                if (!empty($saleInfo)) {
+                                    foreach ($saleInfo as $sale) {
+                                        $saleId = $sale['id'] ?? 0;
+                                        $purchaseId = $sale['purchaseId'] ?? 0;
+                                        $saleOrderSn = $sale['orderSn'] ?? '';
+                                        $purchase = $purchaseInfo[$purchaseId] ?? [];
+                                        if (empty($purchase)) {
+                                            echo "purchase {$purchaseId} 没有找到 \n";
+                                            exit();
+                                        }
+                                        $purchaseOrderSn = $purchase['orderSn'] ?? '';
+                                        $addData = ['orderId' => $saleId, 'orderSn' => $saleOrderSn, 'cgId' => $purchaseId, 'cgSn' => $purchaseOrderSn,
+                                            'clearId' => $clearId, 'clearSn' => $clearSn, 'amount' => $clearAmount, 'status' => $status];
+                                        OrderCgClearClass::add($addData);
+                                    }
+                                    echo "hd cg clearId {$clearId} OK *** \n";
+                                }
+                            } else {
+                                echo "花店采购 clearId {$clearId} 有缺数据 \n";
+                            }
+                        }
+                    } else {
+                        echo "有记录 {$clearId} \n";
+                    }
+                }
+                $transaction->commit();
+
+            } catch (\Exception $e) {
+                $transaction->rollBack();
+                $msg = $e->getMessage();
+                echo "报错了:" . $msg . "\n";
+            }
+
+        }
+
+    }
+
+    public function actionGhsBalance()
+    {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+
+        $sql = "delete from xhGhsBack";
+        Yii::$app->db->createCommand($sql)->execute();
+
+        $query = new \yii\db\Query();
+        $query->from(Ghs::tableName());
+        $query->where(['ownPtStyle' => 1]);
+        $query->andWhere(['>', 'balance', 0]);
+        foreach ($query->batch(500) as $ghsList) {
+
+            $connection = Yii::$app->db;
+            $transaction = $connection->beginTransaction();
+            try {
+
+                foreach ($ghsList as $ghs) {
+                    GhsBackClass::add($ghs);
+                }
+
+                $transaction->commit();
+            } catch (\Exception $e) {
+                $transaction->rollBack();
+                $msg = $e->getMessage();
+                echo "报错了:" . $msg . "\n";
+            }
+        }
+    }
+
+    //将花店供货商的欠款迁到余额,同时保留欠款项为后面复查预留
+    public function actionGhs()
+    {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+
+        $sql = "UPDATE xhGhs SET balance=-debtAmount WHERE ownPtStyle=1;";
+        Yii::$app->db->createCommand($sql)->execute();
+    }
+
+    public function actionGhsUp()
+    {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+
+        $query = new \yii\db\Query();
+        $query->from(Ghs::tableName());
+        $query->where(['ownPtStyle' => 2]);
+        foreach ($query->batch(500) as $ghsList) {
+
+            $connection = Yii::$app->db;
+            $transaction = $connection->beginTransaction();
+            try {
+
+                foreach ($ghsList as $ghs) {
+                    $ghsId = $ghs['id'] ?? 0;
+                    $balance = PurchaseOrderClass::sum(['ghsId' => $ghsId, 'debt' => 1], 'actPrice');
+                    $debtNum = PurchaseOrderClass::getCount(['ghsId' => $ghsId, 'debt' => 1]);
+                    GhsClass::updateById($ghsId, ['balance' => -$balance, 'debtNum' => $debtNum]);
+                }
+
+                $transaction->commit();
+            } catch (\Exception $e) {
+                $transaction->rollBack();
+                $msg = $e->getMessage();
+                echo "报错了:" . $msg . "\n";
+            }
+        }
+    }
+
+}