|
|
@@ -6,6 +6,7 @@ use biz\ghs\classes\GhsBackClass;
|
|
|
use bizGhs\clear\classes\OrderCgClearClass;
|
|
|
use bizGhs\clear\models\Clear;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
+use bizGhs\custom\services\GhsRechargeSettleService;
|
|
|
use bizGhs\ghs\classes\GhsClass;
|
|
|
use bizGhs\ghs\models\Ghs;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
@@ -136,6 +137,49 @@ class ClearController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function actionBalanceBack()
|
|
|
+ {
|
|
|
+ $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 {
|
|
|
+ $staff = new \stdClass();
|
|
|
+ $staff->id = 0;
|
|
|
+ $staff->name = '';
|
|
|
+ $params = [
|
|
|
+ 'remark' => '系统升级恢复',
|
|
|
+ 'rechargeType' => 0, // 0 代表正常充值
|
|
|
+ ];
|
|
|
+ // 模拟商家帮充并自动销挂账,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} 找不到对应的 custom\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function actionGhsGhs()
|
|
|
{
|
|
|
ini_set('memory_limit', '2045M');
|