|
|
@@ -5,6 +5,7 @@ namespace console\controllers;
|
|
|
use biz\ghs\classes\GhsBackClass;
|
|
|
use bizGhs\clear\classes\OrderCgClearClass;
|
|
|
use bizGhs\clear\models\Clear;
|
|
|
+use bizGhs\custom\classes\CustomClass;
|
|
|
use bizGhs\ghs\classes\GhsClass;
|
|
|
use bizGhs\ghs\models\Ghs;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
@@ -109,28 +110,23 @@ class ClearController extends Controller
|
|
|
|
|
|
}
|
|
|
|
|
|
- public function actionGhsBalance()
|
|
|
+ public function actionBalance()
|
|
|
{
|
|
|
ini_set('memory_limit', '2045M');
|
|
|
set_time_limit(0);
|
|
|
-
|
|
|
- $sql = "delete from xhGhsBack";
|
|
|
- Yii::$app->db->createCommand($sql)->execute();
|
|
|
-
|
|
|
+ //$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();
|
|
|
@@ -140,7 +136,7 @@ class ClearController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function actionGhsUp()
|
|
|
+ public function actionGhsGhs()
|
|
|
{
|
|
|
ini_set('memory_limit', '2045M');
|
|
|
set_time_limit(0);
|
|
|
@@ -153,14 +149,14 @@ class ClearController extends Controller
|
|
|
$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]);
|
|
|
+ $customId = $ghs['customId'] ?? 0;
|
|
|
+ CustomClass::updateById($customId, ['balance' => -$balance, 'debtNum' => $debtNum]);
|
|
|
}
|
|
|
-
|
|
|
$transaction->commit();
|
|
|
} catch (\Exception $e) {
|
|
|
$transaction->rollBack();
|