12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace app\common\command;
- use app\common\model\MoneyLog;
- use app\common\model\TakeCash;
- use app\common\model\User;
- use app\service\WechatTransferSvc;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\Db;
- use think\Log;
- class TakeCashQueryCommand extends Command{
- protected function configure()
- {
- $this->setName('tk:query')->setDescription('提现确认');
- }
- protected function execute(Input $input, Output $output)
- {
- $cashes=TakeCash::where('check_status',0)
- ->where('status',TakeCash::STATUS_PASS)
- ->limit(10)
- ->select();
- $class=new WechatTransferSvc();
- foreach ($cashes as $cash){
- Db::startTrans();
- try {
- list($succ,$data)=$class->checkDetail($cash['order_no'],$cash['detail_no']);
- user_log('/tkquery',['cash'=>$cash['id'],'data'=>$data]);
- if(in_array($data['detail_status'],['SUCCESS','FAIL'])){
- $cash['check_status']=$data['detail_status']=='SUCCESS'?1:2;
- if($cash['check_status']==2) {
- $cash['check_data'] = $data['fail_reason'] ?? json_encode($data, 256);
- User::money($this['amount'],$cash['user_id'],MoneyLog::TYPE_TAKECASH_REJECT,'提现打款失败');
- }
- $cash->save();
- }
- Db::commit();
- }catch (\Exception $e){
- Db::rollback();
- }
- }
- }
- }
|