|
@@ -29,16 +29,51 @@ class RefillOil extends refill\IRefillOil
|
|
|
$params['fuelCardUserName'] = "";
|
|
|
$params['fuelCardUserID'] = "";
|
|
|
|
|
|
- $mobile = $this->make_mobile();
|
|
|
- $params['telephone'] = $mobile;
|
|
|
- $params['phoneNumber'] = $mobile;
|
|
|
+ $refill_info = $this->refill_info($card_no,$card_type);
|
|
|
+ $params['telephone'] = $refill_info['bind_phone'];
|
|
|
+ $params['phoneNumber'] = $refill_info['bind_phone'];
|
|
|
|
|
|
- return $params;
|
|
|
+ return [$params, $refill_info];
|
|
|
+ }
|
|
|
+
|
|
|
+ private function refill_info($card_no, $card_type)
|
|
|
+ {
|
|
|
+ $data = rcache($card_no, 'cardrefill-');
|
|
|
+ if(empty($data))
|
|
|
+ {
|
|
|
+ $mod_topcard = Model('topcard');
|
|
|
+ $ret = $mod_topcard->get_card($card_no);
|
|
|
+ if(empty($ret)) {
|
|
|
+ $bind_phone = $this->make_mobile();
|
|
|
+ $mod_topcard->add($card_no,$card_type,time(),$bind_phone);
|
|
|
+ $data['bind_phone'] = $bind_phone;
|
|
|
+ $data['refill_time'] = time();
|
|
|
+ $data['times'] = 0;
|
|
|
+
|
|
|
+ wcache($card_no,$data,'cardrefill-');
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $val = $ret[0];
|
|
|
+
|
|
|
+ $data['bind_phone'] = $val['bind_phone'];
|
|
|
+ $data['refill_time'] = time();
|
|
|
+ $data['times'] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function inc_card($card_no, $refill_info)
|
|
|
+ {
|
|
|
+ $refill_info['times'] += 1;
|
|
|
+ $refill_info['refill_time'] = time();
|
|
|
+ wcache($card_no,$refill_info,'cardrefill-');
|
|
|
}
|
|
|
|
|
|
private function make_mobile()
|
|
|
{
|
|
|
- $no = "1" . mt_rand(3000000000, 9999999999);
|
|
|
+ $no = "1" . mt_rand(3000000000, 3999999999);
|
|
|
return $no;
|
|
|
}
|
|
|
|
|
@@ -109,7 +144,8 @@ class RefillOil extends refill\IRefillOil
|
|
|
|
|
|
public function add($card_no,$card_type,$amount,$input)
|
|
|
{
|
|
|
- $params = $this->req_params($card_no,$card_type,$amount,$input);
|
|
|
+ [$params,$refill_info] = $this->req_params($card_no,$card_type,$amount,$input);
|
|
|
+
|
|
|
$sign = $this->sign($params);
|
|
|
$params['signature'] = $sign;
|
|
|
|
|
@@ -125,6 +161,7 @@ class RefillOil extends refill\IRefillOil
|
|
|
|
|
|
if($resp['code'] == 0)
|
|
|
{
|
|
|
+ $this->inc_card($card_no,$refill_info);
|
|
|
$data = $resp['data'];
|
|
|
return [true,$data['orderNumber']];
|
|
|
}
|