OutBudan.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Module\TransferOld;
  3. use App\Module\Outside\Http;
  4. use App\Module\TransferOld\Enums\TStatus;
  5. use App\Module\TransferOld\Model\TransferOrder;
  6. use Dcore\Helper\Logger;
  7. class OutBudan
  8. {
  9. /**
  10. * 出包 的处理
  11. *
  12. * @param TransferOrder $order
  13. * @return void
  14. */
  15. static public function run(TransferOrder $order,bool $validation )
  16. {
  17. // dump($order);
  18. $user_id = $order->user_id;
  19. $trapp_id = $order->trapp_id;
  20. $app = App::get($trapp_id);
  21. // 出包,进行下单
  22. $app = App::get($trapp_id);
  23. $http = Http::getById($app->out_id);
  24. $data = [
  25. 'wallet_id' => $order->id
  26. ];
  27. $res = $http->postJson($app->order_out_info, $data);
  28. // dd($res,$data);
  29. // "business_id":2010,"business_status":20,"business_amount":"1.000","wallet_id":29,"wallet_amount":"1.000"
  30. Logger::info('out_call2-res',$res);
  31. if ($res['code'] != 0) {
  32. Logger::error('out_call2',$res);
  33. throw new \Exception('回调失败');
  34. }
  35. if($validation){
  36. if( $order->oamount != $res['data']['business_amount']){
  37. return "业务订单 - 钱数不一致 ";
  38. }
  39. if( $order->out_order_id != $res['data']['business_id']){
  40. return "业务订单ID不一致";
  41. }
  42. if( $order->id != $res['data']['wallet_id']){
  43. return "订单ID - 不一致";
  44. }
  45. }
  46. $order->out_order_id = $res['data']['business_id'];
  47. $order->oamount= $res['data']['business_amount'];
  48. $order->status = TStatus::CALL;
  49. if (!$order->save()) {
  50. throw new \Exception('保存失败');
  51. }
  52. return true;
  53. }
  54. }