/**
  * @brief 支付结果的回调函数, 业务逻辑可以在此放入成功和失败的处理逻辑回调函数
  *
  * @return  public function 
  * @retval   
  * @see 
  * @note 
  * @author 吕宝贵
  * @date 2015/12/18 10:49:48
  **/
 public function NotifyProcess($data, &$msg)
 {
     $notfiyOutput = [];
     if (!array_key_exists("transaction_id", $data)) {
         $msg = "输入参数不正确";
         return false;
     }
     //查询订单,判断订单真实性,回调订单失败逻辑
     if (!$this->Queryorder($data["transaction_id"])) {
         @call_user_func($this->payFailedHanlder, $data);
         $msg = "订单查询失败";
         return false;
     } else {
         $receivableId = $data['out_trade_no'];
         $receivable = Receivable::findOne($receivableId);
         return call_user_func($this->paySucceededHandler, $data);
     }
 }
示例#2
0
 /**
  * @brief 检查订单的支付状态,该函数会引起远程网络调用,不能放在事物中处理
  *
  * @return  查询交易状态 
  * @retval   
  * @see 
  * @note 
  * @author 吕宝贵
  * @date 2016/03/10 10:28:03
  **/
 public function getReceivable($receivableId = null)
 {
     if (!$receivableId) {
         $receivableId = $this->_notifyData['out_trade_no'];
     }
     $receivable = Receivable::findOne($receivableId);
     if (!$receivable) {
         Yii::error('无法找到对应的交易订单');
         return false;
     } else {
         return $receivable;
     }
 }
 /**
  * @brief 根据交易记录产生收款记录,用户充值时使用
  *
  * @return  public function 
  * @retval   
  * @see 
  * @note 
  * @author 吕宝贵
  * @date 2015/12/23 00:07:28
  **/
 public function generateReceivable($trans)
 {
     //新建收款记录
     $receivable = null;
     if (!($receivable = Receivable::findOne(['trans_id' => $trans->id]))) {
         $receivable = new Receivable();
     }
     $receivable->money = $trans->total_money;
     $receivable->trans_id = $trans->id;
     $receivable->uid = $trans->from_uid;
     $receivable->status = Receivable::PAY_STATUS_WAITPAY;
     //返回收款记录,用以跳转到第三方进行支付
     if ($receivable->save()) {
         return $receivable;
     } else {
         return false;
     }
 }
示例#4
0
 /**
  * @brief 处理支付回告,并返回交易id
  *
  * @return  public function 
  * @retval   
  * @see 
  * @note 
  * @author 吕宝贵
  * @date 2016/03/28 08:16:09
  **/
 public function processNotify($handlers)
 {
     $receivableId = $this->_notifyData['out_trade_no'];
     $receivable = Receivable::findOne($receivableId);
     if (!$receivable) {
         throw new LBUserException('无法找到对应的交易订单', 3, $this->getErrors());
         return false;
     }
     $receivable->status = Receivable::PAY_STATUS_FINISHED;
     if (!$receivable->save()) {
         throw new LBUserException('保存交易信息失败', 3, $this->getErrors());
         return false;
     } else {
         //call callback function
         if (call_user_func($handlers['paySuccessHandler'], $receivable->trans_id)) {
             return $receivable->trans_id;
         } else {
             Yii::warning(__METHOD__ . ' callback failed');
             return false;
         }
     }
 }