1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\common\command;
-
-
- use app\admin\logic\WechatMerchantTransferLogic;
- use app\common\enum\WithdrawEnum;
- use app\common\logic\AccountLogLogic;
- use app\common\model\AccountLog;
- use app\common\model\user\User;
- use app\common\model\WithdrawApply;
- use app\common\server\ConfigServer;
- use think\console\Command;
- use think\console\Output;
- use think\console\Input;
- use think\facade\Log;
-
- class WechatMerchantTransfer extends Command
- {
- protected function configure()
- {
- $this->setName('wechat_merchant_transfer')
- ->setDescription('商家转账到零钱查询');
- }
-
- protected function execute(Input $input, Output $output)
- {
-
- $transfer_way = ConfigServer::get('withdraw', 'transfer_way',1);
-
- if ($transfer_way == 1) {
- return false;
- }
-
- $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);
-
- WithdrawApply::update(['update_time'=>time(),'pay_search_desc'=>json_encode($result, JSON_UNESCAPED_UNICODE)],['id'=>$list['id']]);
- if(isset($result['detail_status'])) {
- if ($result['detail_status'] == 'SUCCESS') {
-
- WithdrawApply::update(['status'=>3,'payment_no'=>$result['detail_id'],'payment_time'=>strtotime($result['update_time'])],['id'=>$list['id']]);
- }
- if ($result['detail_status'] == 'FAIL') {
-
- WithdrawApply::update(['status'=>4],['id'=>$list['id']]);
-
- $user = User::find($list['user_id']);
- $user->earnings = ['inc', $list['money']];
- $user->save();
-
-
- AccountLogLogic::AccountRecord(
- $list['user_id'],
- $list['money'],
- 1,
- AccountLog::withdraw_back_earnings,
- '',
- $list['id'],
- $list['sn']
- );
- }
- if ($result['detail_status'] == 'PROCESSING') {
- return ['code' => 0, 'msg' => '正在处理中'];
- }
- }else{
- Log::write($result['message'] ?? '商家转账到零钱查询失败');
- return null;
- }
- }
-
- return true;
- }
- }
|