From c1c7dddabb76f88e78c3195b25f777d03f26f60c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Mon, 23 Sep 2024 11:05:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BE=AE=E4=BF=A1=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E6=8E=A5=E5=8F=A3=E4=B9=9F=E6=94=BE=E8=BF=9B?= =?UTF-8?q?=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../think-plugs-wemall/src/command/Trans.php | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/plugin/think-plugs-wemall/src/command/Trans.php b/plugin/think-plugs-wemall/src/command/Trans.php index 7748f9cde..509ad4bb1 100644 --- a/plugin/think-plugs-wemall/src/command/Trans.php +++ b/plugin/think-plugs-wemall/src/command/Trans.php @@ -179,6 +179,101 @@ class Trans extends Command } } + + /** + * 企业付款到银行卡 + * @param PluginWemallUserTransfer $model + * @return array + * @throws \WeChat\Exceptions\InvalidDecryptException + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + * @throws \think\admin\Exception + * @deprecated 微信商户已不再提供此接口 + */ + private function createTransferBank(PluginWemallUserTransfer $model): array + { + return TransfersBank::instance($this->getConfig($model))->create([ + 'partner_trade_no' => $model->getAttr('code'), + 'enc_bank_no' => $model->getAttr('bank_code'), + 'enc_true_name' => $model->getAttr('bank_user'), + 'bank_code' => $model->getAttr('bank_wseq'), + 'amount' => intval($model->getAttr('amount') - $model->getAttr('charge_amount')) * 100, + 'desc' => '微信银行卡提现', + ]); + } + + /** + * 企业付款到零钱 + * @param PluginWemallUserTransfer $model + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + * @throws \think\admin\Exception + * @deprecated 微信商户已不再提供此接口 + */ + private function createTransferWallet(PluginWemallUserTransfer $model): array + { + return Transfers::instance($this->getConfig($model))->create([ + 'openid' => $model->getAttr('openid'), + 'amount' => intval($model->getAttr('amount') - $model->getAttr('charge_amount')) * 100, + 'partner_trade_no' => $model->getAttr('code'), + 'spbill_create_ip' => '127.0.0.1', + 'check_name' => 'NO_CHECK', + 'desc' => '微信余额提现!', + ]); + } + + /** + * 查询企业付款到银行卡 + * @param PluginWemallUserTransfer $model + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + * @throws \think\admin\Exception + * @deprecated 微信商户已不再提供此接口 + */ + private function queryTransferBank(PluginWemallUserTransfer $model) + { + $result = TransfersBank::instance($this->getConfig($model))->query($model->getAttr('trade_no')); + if ($result['return_code'] === 'SUCCESS' && $result['result_code'] === 'SUCCESS') { + if ($result['status'] === 'SUCCESS') { + $model->save([ + 'status' => 5, + 'trade_time' => $result['pay_succ_time'] ?: date('Y-m-d H:i:s'), + 'change_time' => date('Y-m-d H:i:s'), + 'change_desc' => '微信提现打款成功', + ]); + } elseif (in_array($result['status'], ['FAILED', 'BANK_FAIL'])) { + $model->save([ + 'status' => 0, + 'change_time' => date('Y-m-d H:i:s'), + 'change_desc' => '微信提现打款失败', + ]); + // 刷新用户可提现余额 + UserRebate::recount($model->getAttr('unid')); + } + } + } + + /** + * 查询企业付款到零钱 + * @param PluginWemallUserTransfer $model + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + * @throws \think\admin\Exception + */ + private function queryTransferWallet(PluginWemallUserTransfer $model) + { + $result = Transfers::instance($this->getConfig($model))->query($model->getAttr('trade_no')); + if ($result['return_code'] === 'SUCCESS' && $result['result_code'] === 'SUCCESS') { + $model->save([ + 'status' => 5, + 'trade_time' => $result['payment_time'], + 'change_time' => date('Y-m-d H:i:s'), + 'change_desc' => '微信提现打款成功!', + ]); + } + } + /** * 获取微信提现参数 * @param PluginWemallUserTransfer $model