|
@@ -1,37 +1,33 @@
|
|
|
<?php
|
|
|
|
|
|
namespace mapi;
|
|
|
-use mapi\config\config;
|
|
|
class CTCard implements IOpenCard
|
|
|
{
|
|
|
- private function create_guid() : string
|
|
|
+ private function head($method) : array
|
|
|
{
|
|
|
- $str = md5(uniqid(mt_rand(), true));
|
|
|
- $uuid = substr($str,0,8);
|
|
|
- $uuid .= substr($str,8,4);
|
|
|
- $uuid .= substr($str,12,4);
|
|
|
- $uuid .= substr($str,16,4);
|
|
|
- $uuid .= substr($str,20,12);
|
|
|
- return $uuid;
|
|
|
- }
|
|
|
-
|
|
|
- private function generate_packet_sequence_number() : string
|
|
|
- {
|
|
|
- return config::SYS_CODE.config::APP_CODE.date("ymdhm", time()).$this->create_guid();
|
|
|
- }
|
|
|
+ $guider = function (): string
|
|
|
+ {
|
|
|
+ $str = md5(uniqid(mt_rand(), true));
|
|
|
+ $uuid = substr($str, 0, 8);
|
|
|
+ $uuid .= substr($str, 8, 4);
|
|
|
+ $uuid .= substr($str, 12, 4);
|
|
|
+ $uuid .= substr($str, 16, 4);
|
|
|
+ $uuid .= substr($str, 20, 12);
|
|
|
+ return $uuid;
|
|
|
+ };
|
|
|
+ $make_sn = function () use ($guider){
|
|
|
+ return config::SYS_CODE . config::APP_CODE . date("ymdhm", time()) . $guider();
|
|
|
+ };
|
|
|
+ $signer = function ($sn) {
|
|
|
+ return md5("$sn" . config::KEY);
|
|
|
+ };
|
|
|
|
|
|
- private function sign() : string
|
|
|
- {
|
|
|
- return md5($this->generate_packet_sequence_number().config::KEY);
|
|
|
- }
|
|
|
-
|
|
|
- public function createHead($method) : array
|
|
|
- {
|
|
|
$sysCode = config::SYS_CODE;
|
|
|
$appCode = config::APP_CODE;
|
|
|
- $transactionId = $this->generate_packet_sequence_number();
|
|
|
+ $transactionId = $make_sn();
|
|
|
$reqTime = date("Y-m-d H:i:s", time());
|
|
|
- $sign = $this->sign();
|
|
|
+ $sign = $signer($transactionId);
|
|
|
+
|
|
|
return [
|
|
|
"sysCode"=>$sysCode,
|
|
|
"appCode"=>$appCode,
|
|
@@ -47,12 +43,10 @@ class CTCard implements IOpenCard
|
|
|
|
|
|
public function fraud_check($biz, $net_errno) : bool
|
|
|
{
|
|
|
- $params['head'] = $this->createHead("fraudCheck");
|
|
|
+ $params['head'] = $this->head("fraudCheck");
|
|
|
$params['biz'] = $biz;
|
|
|
$requestParameters = json_encode($params);
|
|
|
$resp = http_post_data(config::production_env['DcoosExternalNetwork'], $requestParameters , config::HeaderProduction, $net_errno);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|