| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Module\TransferOld;
- use App\Module\Outside\Http;
- use App\Module\TransferOld\Enums\TStatus;
- use App\Module\TransferOld\Model\TransferOrder;
- use Dcore\Helper\Logger;
- class OutBudan
- {
- /**
- * 出包 的处理
- *
- * @param TransferOrder $order
- * @return void
- */
- static public function run(TransferOrder $order,bool $validation )
- {
- // dump($order);
- $user_id = $order->user_id;
- $trapp_id = $order->trapp_id;
- $app = App::get($trapp_id);
- // 出包,进行下单
- $app = App::get($trapp_id);
- $http = Http::getById($app->out_id);
- $data = [
- 'wallet_id' => $order->id
- ];
- $res = $http->postJson($app->order_out_info, $data);
- // dd($res,$data);
- // "business_id":2010,"business_status":20,"business_amount":"1.000","wallet_id":29,"wallet_amount":"1.000"
- Logger::info('out_call2-res',$res);
- if ($res['code'] != 0) {
- Logger::error('out_call2',$res);
- throw new \Exception('回调失败');
- }
- if($validation){
- if( $order->oamount != $res['data']['business_amount']){
- return "业务订单 - 钱数不一致 ";
- }
- if( $order->out_order_id != $res['data']['business_id']){
- return "业务订单ID不一致";
- }
- if( $order->id != $res['data']['wallet_id']){
- return "订单ID - 不一致";
- }
- }
- $order->out_order_id = $res['data']['business_id'];
- $order->oamount= $res['data']['business_amount'];
- $order->status = TStatus::CALL;
- if (!$order->save()) {
- throw new \Exception('保存失败');
- }
- return true;
- }
- }
|