TakeCashQueryCommand.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\common\command;
  3. use app\common\model\TakeCash;
  4. use app\common\model\User;
  5. use app\service\WechatTransferSvc;
  6. use think\console\Command;
  7. use think\console\Input;
  8. use think\console\Output;
  9. use think\Db;
  10. use think\Log;
  11. class TakeCashQueryCommand extends Command{
  12. protected function configure()
  13. {
  14. $this->setName('tk:query')->setDescription('提现确认');
  15. }
  16. protected function execute(Input $input, Output $output)
  17. {
  18. $cashes=TakeCash::where('check_status',0)
  19. ->where('status',TakeCash::STATUS_PASS)
  20. ->limit(10)
  21. ->select();
  22. $class=new WechatTransferSvc();
  23. foreach ($cashes as $cash){
  24. Db::startTrans();
  25. try {
  26. list($succ,$data)=$class->checkDetail($cash['order_no'],$cash['detail_no']);
  27. if(in_array($data['detail_status'],['SUCCESS','PROCESSING'])){
  28. $cash['check_status']=$data['detail_status']=='SUCCESS'?1:2;
  29. $cash['check_data']=$data['fail_reason']??json_encode($data,256);
  30. $cash->save();
  31. }
  32. Db::commit();
  33. }catch (\Exception $e){
  34. Db::rollback();
  35. }
  36. }
  37. }
  38. }