/** * 解冻资金 * @param $out_freeze_no 需要解冻的当单号 * @param $money 解冻金额 * @param $summary 解冻原因 * @return array */ public static function balanceUnfreeze($out_freeze_no, $money, $summary) { $flag = SinaFreeze::findOne(['out_freeze_no' => $out_freeze_no, 'status' => SinaFreeze::STATUS_FREEZE]); if (!$flag) { $return = array('errorNum' => '1', 'errorMsg' => '解冻订单信息错误', 'data' => null); return $return; } $identity_id = $flag->identity_id; $freeze_money = $flag->freeze_money; if ($freeze_money < $money) { $return = array('errorNum' => '1', 'errorMsg' => '解冻金额不能大于冻结金额', 'data' => null); return $return; } $sina = new sina(); $out_unfreeze_no = self::build_order_no(); $unfreeze = $sina->balance_unfreeze($out_unfreeze_no, $out_freeze_no, $identity_id, $money, $summary); if ($unfreeze['response_code'] == 'APPLY_SUCCESS') { $unfreeze_money = $flag->unfreeze_money; $flag->unfreeze_money = $unfreeze_money + $money; $flag->status = SinaFreeze::STATUS_UNFREEZE; $flag->msg = '解冻成功'; $flag->save(); $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => null); return $return; } else { $unfreeze_money = $flag->unfreeze_money; $flag->unfreeze_money = $unfreeze_money + $money; $flag->status = SinaFreeze::STATUS_ERROR; $flag->msg = '解冻失败'; $flag->save(); $return = array('errorNum' => '1', 'errorMsg' => $unfreeze['response_message'], 'data' => null); return $return; } }
/** * Finds the SinaFreeze model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return SinaFreeze the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = SinaFreeze::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }