Exemplo n.º 1
0
 public function fire($job, $data)
 {
     $orderId = $data['id'];
     $ret = true;
     switch ($data['notify_type']) {
         case 'direct':
             $order = RechargeModel::find($orderId);
             break;
         case 'consume':
             $order = ConsumeModel::find($orderId);
             break;
         case 'refund':
             $order = RefundModel::find($orderId);
             break;
         case 'trans':
             $order = TransModel::find($orderId);
             break;
     }
     if ($order && $order->callback_status != 2 && $order->callback_count < 20) {
         try {
             $ret = BusiNotifyBiz::getInstance()->notifyCallback($order, $data['notify_type']);
         } catch (PayException $e) {
             $ret = true;
         } catch (\Exception $e) {
             $ret = false;
         }
         $job->release(pow($order->callback_count, 2) * 60);
     }
     if ($ret == true) {
         $job->delete();
     }
 }
Exemplo n.º 2
0
 public function confirmRefundOrderById($orderId, $data)
 {
     $time = time();
     $errCode = 0;
     $errMsg = '';
     \DB::beginTransaction();
     do {
         try {
             $order = RefundModel::find($orderId);
             if (!$order) {
                 throw new PayException(ErrCode::ERR_ORDER_NO_EXISTS);
             } elseif ($order->status == RefundModel::STATUS_SUCCESS) {
                 $errCode = 1;
                 break;
             }
             if (isset($data['ser_refund_no']) && !empty($data['ser_refund_no'])) {
                 $order->ser_refund_no = $data['ser_refund_no'];
             }
             if (isset($data['notify_log'])) {
                 $order->ser_notify_log = $data['notify_log'];
             }
             if (isset($data['notify_status'])) {
                 $order->ser_notify_status = $data['notify_status'];
             }
             if (isset($data['seller_partner'])) {
                 $order->seller_partner = $data['seller_partner'];
             }
             $order->refund_time = $data['refund_time'];
             $order->ser_notify_time = $data['notify_time'];
             $order->save();
             AccountBiz::getInstance()->updateUserAccount($order->user_id, RefundModel::DEAL_OUT_REFUND, $order->refund_amount, $order->channel);
         } catch (\Exception $e) {
             $errCode = 1;
         }
     } while (0);
     if ($errCode == 0) {
         \DB::commit();
         if (true !== BusiNotifyBiz::getInstance()->notifyCallback($order, 'refund')) {
             \Queue::later(5, '\\Pay\\Service\\Queue\\BusiNotifyQueue', ['id' => $order->id, 'notify_type' => 'refund']);
         }
         return true;
     } else {
         \DB::rollback();
         return false;
     }
 }
Exemplo n.º 3
0
 public function confirmConsumeOrderById($orderId)
 {
     $time = time();
     $errCode = 0;
     $errMsg = '';
     \DB::beginTransaction();
     do {
         try {
             $order = ConsumeModel::find($orderId);
             if (!$order) {
                 throw new PayException(ErrCode::ERR_ORDER_NO_EXISTS);
             } elseif ($order->status == ConsumeModel::STATUS_SUCCESS) {
                 $errCode = 1;
                 break;
             }
             $order->status = ConsumeModel::STATUS_SUCCESS;
             $order->pay_time = $time;
             $order->update_time = $time;
             $order->save();
             AccountBiz::getInstance()->updateUserAccount($order->user_id, ConsumeModel::DEAL_CONSUME, $order->consume_amount, $order->channel);
         } catch (\Exception $e) {
             $errCode = 2;
         }
     } while (0);
     if ($errCode == 0) {
         \DB::commit();
         if (true !== BusiNotifyBiz::getInstance()->notifyCallback($order, 'consume')) {
             \Queue::later(5, '\\Pay\\Service\\Queue\\BusiNotifyQueue', ['id' => $order->id, 'notify_type' => 'consume']);
         }
         return true;
     } else {
         \DB::rollback();
         return false;
     }
 }