public function notify(array $order)
{
$log = Logger::getInstance();
$log->debug('Alipay Run..');
foreach ($order as $key => $v) {
$log->debug('K:' . $key . ', V:' . $v);
}
$t = Trade::getByTrade($order['trade']);
if (!$t) {
$trade = new Trade();
$trade->time = $order['time'];
$trade->title = $order['title'];
$trade->trade = $order['trade'];
$trade->name = $order['name'];
$trade->amount = $order['amount'];
$trade->has_notify = 0;
$trade->save();
} else {
if ($t->has_notify == 1) {
return 'done';
}
}
//MD5加密下当作签名传过去好校验是不是自己的
$order['sig'] = strtoupper(md5($this->token));
return "success";
/*
$ch = curl_init($this->notify);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($order));
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
//print_r($response);
if(curl_errno($ch)) return curl_error($ch);
if($response == 'success') {
$this->db->update('trade',['has_notify' => 1],['AND' => [['trade' => $order['trade']]]]);
return 'success';
} else {
return '服务器未返回正确的参数。';
}
*/
}