|
|
@@ -5,8 +5,8 @@ namespace console\controllers;
|
|
|
use biz\main\classes\MainClass;
|
|
|
use biz\shop\classes\ShopAdminClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
+use common\components\dict;
|
|
|
use common\components\noticeUtil;
|
|
|
-use common\components\util;
|
|
|
use yii\console\Controller;
|
|
|
use biz\sj\classes\CashClass;
|
|
|
use Yii;
|
|
|
@@ -14,9 +14,97 @@ use Yii;
|
|
|
class CashController extends Controller
|
|
|
{
|
|
|
|
|
|
+ //提现审核通过 ssh 20231016
|
|
|
+ public function actionPass()
|
|
|
+ {
|
|
|
+ $cashList = CashClass::getAllByCondition(['status' => 1], null, '*', null, true);
|
|
|
+ if (empty($cashList)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ foreach ($cashList as $cash) {
|
|
|
+ //事务处理
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+
|
|
|
+ $remark = '系统自动提现';
|
|
|
+ $status = $cash->status;
|
|
|
+ $shopId = $cash->shopId;
|
|
|
+ $orderSn = $cash->orderSn ?? '';
|
|
|
+ $shop = ShopClass::getLockById($shopId);
|
|
|
+ if (empty($shop)) {
|
|
|
+ noticeUtil::push("提现审核失败,没有找到门店,orderSn:" . $orderSn, '15280215347');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $main = MainClass::getLockById($mainId);
|
|
|
+ if (empty($main)) {
|
|
|
+ noticeUtil::push("提现审核失败,没有main信息,orderSn:" . $orderSn, '15280215347');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $cashAmount = isset($cash->amount) ? floatval($cash->amount) : 0;
|
|
|
+ if ($cashAmount <= 0) {
|
|
|
+ CashClass::rollback($cash, $shop, $transaction, $cashAmount, $remark);
|
|
|
+ noticeUtil::push("提现金额有问题,已回滚,orderSn:" . $orderSn, '15280215347');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $miniCashAmount = dict::getDict('miniCashAmount');
|
|
|
+ if ($cashAmount < $miniCashAmount) {
|
|
|
+ if (getenv('YII_ENV') == 'production') {
|
|
|
+ CashClass::rollback($cash, $shop, $transaction, $cashAmount, $remark);
|
|
|
+ noticeUtil::push("余额不足{$miniCashAmount}元,已回滚,orderSn:" . $orderSn, '15280215347');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $getAmount = $cash->beAmount;
|
|
|
+
|
|
|
+ if ($status != CashClass::STATUS_CHECK_YES) {
|
|
|
+ CashClass::rollback($cash, $shop, $transaction, $cashAmount, $remark);
|
|
|
+ noticeUtil::push("已审核过,已回滚,orderSn:" . $orderSn, '15280215347');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ $cashAccount = $main->cashAccount ?? '';
|
|
|
+ $cashName = $main->cashName ?? '';
|
|
|
+
|
|
|
+ $cashSn = $cash->orderSn;
|
|
|
+ if (empty($cashSn)) {
|
|
|
+ CashClass::rollback($cash, $shop, $transaction, $cashAmount, $remark);
|
|
|
+ noticeUtil::push("没有找到订单号,已回滚,orderSn:" . $orderSn, '15280215347');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bccomp($cashAmount, $main->freezeBalance) == 1) {
|
|
|
+ CashClass::rollback($cash, $shop, $transaction, $cashAmount, $remark);
|
|
|
+ noticeUtil::push("冻结金额不足提现,已回滚,orderSn:" . $orderSn, '15280215347');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ $cash->status = CashClass::STATUS_CHECK_YES;
|
|
|
+ $cash->remark = $remark;
|
|
|
+ $cash->getAmount = $getAmount;
|
|
|
+ $cash->cashName = $cashName;
|
|
|
+ $cash->cashAccount = $cashAccount;
|
|
|
+ $cash->save();
|
|
|
+ //扣掉冻结的金额
|
|
|
+ $main->freezeBalance = bcsub($main->freezeBalance, $cashAmount, 2);
|
|
|
+ $main->save();
|
|
|
+ $transaction->commit();
|
|
|
+
|
|
|
+ } catch (\Exception $exception) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $msg = $exception->getMessage();
|
|
|
+ noticeUtil::push("审核失败,错误信息:" . $msg . ",orderSn:" . $orderSn, '15280215347');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//自动提现 ssh 2023116
|
|
|
public function actionAuto()
|
|
|
{
|
|
|
+ ini_set('memory_limit', '2045M');
|
|
|
+ set_time_limit(0);
|
|
|
$mainList = MainClass::getAllByCondition(['txBalance>' => 0], null, 'id,txBalance', null, true);
|
|
|
if (empty($mainList)) {
|
|
|
return false;
|