setName('wechat_merchant_transfer') ->setDescription('商家转账到零钱查询'); } protected function execute(Input $input, Output $output) { $transfer_way = ConfigService::get('config', 'transfer_way',1); //选择了商家转账到零钱再进行查询 if ($transfer_way == WithdrawEnum::ENTERPRISE) { return false; } //默认使用小程序配置 $config = WeChatConfigService::getWechatConfigByTerminal(UserTerminalEnum::WECHAT_MMP); $lists = WithdrawApply::where(['type'=>WithdrawEnum::TYPE_WECHAT_CHANGE,'status'=>WithdrawEnum::STATUS_ING]) ->field('id,sn,batch_no,user_id,money') ->select(); foreach ($lists as $list) { $result = WechatMerchantTransferLogic::details($list,$config); if(isset($result['detail_status'])) { if ($result['detail_status'] == 'SUCCESS') { //提现成功,更新提现申请单 WithdrawApply::update([ 'status' => WithdrawEnum::STATUS_SUCCESS, 'pay_search_result' => json_encode($result, JSON_UNESCAPED_UNICODE), 'payment_no'=>$result['detail_id'], 'payment_time' => strtotime($result['update_time']), ],['id'=>$list['id']]); } if ($result['detail_status'] == 'FAIL') { //提现成功,更新提现申请单 WithdrawApply::update([ 'status' => WithdrawEnum::STATUS_FAIL, 'pay_search_result' => json_encode($result, JSON_UNESCAPED_UNICODE), ],['id'=>$list['id']]); // 回退提现金额 WithdrawLogic::fallbackMoney($list); // 记录账户流水 AccountLogLogic::add($list['user_id'], AccountLogEnum::BW_INC_PAYMENT_FAIL, AccountLogEnum::INC, $list['money'], $list['sn'], '付款失败回退金额'); } continue; }else { Log::write($result['message'] ?? '商家转账到零钱查询失败'); return null; } } return true; } }