sign($input); if ($params['signature'] == $sign) { return true; } else { return false; } } private function sign($params) { $body = $this->body($params); $body .= config::APP_SECRET; return md5($body); } protected function check_empty($value) { if (!isset($value)) return true; if ($value === null) return true; if (trim($value) === "") return true; return false; } private function body($params) { ksort($params); $body = ""; $i = 0; foreach ($params as $k => $v) { if (false === $this->check_empty($v) && "@" != substr($v, 0, 1)) { if ($i == 0) { $body .= "{$k}" . "=" . $v; } else { $body .= "&" . "{$k}" . "=" . $v; } $i++; } } return $body; } public function notify($params) { $status = intval($params['status']); $order_sn = $params['channelOrderNumber']; $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]); if (empty($order_info)) { return [false, false, false,false]; } $order_id = $order_info['order_id']; $data['official_sn'] = $params['voucher']; $data['ch_trade_no'] = $params['orderNumber']; $data['err_msg'] = $params['message']; Model('refill_order')->edit($order_id, $data); //[$order_id, 成功失败, 是否能重试,接下来是否需要处理] if ($status === 101) { return [$order_id, true, false, true]; } elseif ($status === 109) { $this->onError($params['message'], $order_id); return [$order_id, false, true, true]; } elseif ($status === 120) { return [$order_id, false, false, false]; } else { return [$order_id, false, false, false]; } } public function onError($msg,$order_id) { if(in_array($msg,config::BlackMsgs)) { $refill = Model('refill_order'); $order = $refill->getOrderInfo(['order_id' => $order_id]); if(empty($order)) return false; $card_no = $order['card_no']; if(!empty($card_no)) { refill\util::set_black($card_no); return true; } } return false; } }