|
|
@@ -141,19 +141,19 @@ class ClearController extends Controller
|
|
|
{
|
|
|
$list = GhsBackClass::getAllByCondition(['id>' => 0], null, '*', 'id', true);
|
|
|
if (!empty($list)) {
|
|
|
- foreach ($list as $ghs) {
|
|
|
- $ownPtStyle = $ghs['ownPtStyle'] ?? 1;
|
|
|
- $balance = $ghs['balance'] ?? 0;
|
|
|
- $customId = $ghs['customId'] ?? 0;
|
|
|
- if ($ownPtStyle == 1) {
|
|
|
- $custom = CustomClass::getById($customId, true);
|
|
|
- if (!empty($custom)) {
|
|
|
- $shopId = $ghs['shopId'] ?? 0;
|
|
|
- $shop = \bizGhs\shop\classes\ShopClass::getById($shopId, true);
|
|
|
- if (!empty($shop)) {
|
|
|
- $connection = Yii::$app->db;
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
- try {
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ foreach ($list as $ghs) {
|
|
|
+ $ownPtStyle = $ghs['ownPtStyle'] ?? 1;
|
|
|
+ $balance = $ghs['balance'] ?? 0;
|
|
|
+ $customId = $ghs['customId'] ?? 0;
|
|
|
+ if ($ownPtStyle == 1) {
|
|
|
+ $custom = CustomClass::getById($customId, true);
|
|
|
+ if (!empty($custom)) {
|
|
|
+ $shopId = $ghs['shopId'] ?? 0;
|
|
|
+ $shop = \bizGhs\shop\classes\ShopClass::getById($shopId, true);
|
|
|
+ if (!empty($shop)) {
|
|
|
$staff = new \stdClass();
|
|
|
$staff->id = 0;
|
|
|
$staff->name = '';
|
|
|
@@ -163,19 +163,19 @@ class ClearController extends Controller
|
|
|
];
|
|
|
// 模拟商家帮充并自动销挂账,payWay 设为 0 (线下微信)
|
|
|
GhsRechargeSettleService::merchantRechargeWithAutoClear($custom, $balance, $shop, $staff, 0, $params);
|
|
|
- $transaction->commit();
|
|
|
echo "customId: {$customId} 充值成功 {$balance} 元\n";
|
|
|
- } catch (\Exception $e) {
|
|
|
- $transaction->rollBack();
|
|
|
- echo "customId: {$customId} 充值失败: " . $e->getMessage() . "\n";
|
|
|
+ } else {
|
|
|
+ echo "customId: {$customId} 找不到对应的 shop\n";
|
|
|
}
|
|
|
} else {
|
|
|
- echo "customId: {$customId} 找不到对应的 shop\n";
|
|
|
+ echo "customId: {$customId} 找不到对应的 custom\n";
|
|
|
}
|
|
|
- } else {
|
|
|
- echo "customId: {$customId} 找不到对应的 custom\n";
|
|
|
}
|
|
|
}
|
|
|
+ $transaction->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ echo "执行失败,整体回滚: " . $e->getMessage() . "\n";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -189,7 +189,6 @@ class ClearController extends Controller
|
|
|
$query->from(Ghs::tableName());
|
|
|
$query->where(['ownPtStyle' => 2]);
|
|
|
foreach ($query->batch(500) as $ghsList) {
|
|
|
-
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|