소스 검색

add short message to tiancai for notify body

stanley-king 4 년 전
부모
커밋
60618430a1
3개의 변경된 파일40개의 추가작업 그리고 0개의 파일을 삭제
  1. 28 0
      helper/refill/policy/xyz/policy.php
  2. 1 0
      mobile/control/refill.php
  3. 11 0
      test/TestRedis.php

+ 28 - 0
helper/refill/policy/xyz/policy.php

@@ -6,6 +6,7 @@ namespace refill;
 use Log;
 use rbridge\RBridgeFactory;
 use StatesHelper;
+use mtopcard;
 
 class policy extends ProviderManager implements IPolicy
 {
@@ -188,12 +189,39 @@ class policy extends ProviderManager implements IPolicy
             'message' => $refill_info['err_msg'] ?? "",
             "state" => $state];
 
+        [$has_sms,$sms] = $this->sms($refill_info);
+        if($has_sms) {
+            $params['sms'] = $sms;
+        }
+
         $secure_key = $mch_info['secure_key'];
         $sign = $this->sign($params, $secure_key);
 
         return [$params, $sign];
     }
 
+    private function sms($refill_info)
+    {
+        $mchids = [10116];
+        $mchid = $refill_info['mchid'];
+        $official_sn = $refill_info['official_sn'] ?? "";
+        $card_type = $refill_info['card_type'];
+        $card_no = $refill_info['card_no'];
+        $amount = intval($refill_info['refill_amount']);
+
+        if(in_array($mchid,$mchids) && !empty($official_sn) && $card_type == mtopcard\SinopecCard && !empty($card_no))
+        {
+            $short_no = substr($card_no,-6);
+            $ret = preg_match('/\d{4}(?P<month>\d{2})(?P<day>\d{2})(?P<hour>\d{2})(?P<min>\d{2})\d{4}/u', $official_sn, $matches);
+            if($ret > 0) {
+                $sms = "【中国石化】您尾号为{$short_no}的加油卡于{$matches['month']}月{$matches['day']}日 {$matches['hour']}时{$matches['min']}分充值成功,金额{$amount}元,订单号:{$official_sn}";
+                return [true,$sms];
+            }
+        }
+
+        return [false,''];
+    }
+
     private function sign($params, $key)
     {
         ksort($params);

+ 1 - 0
mobile/control/refill.php

@@ -190,6 +190,7 @@ class refillControl extends merchantControl
         $result['order_time'] = $refill_info['order_time'];
         $result['success_time'] = $refill_info['notify_time'];
         $result['order_state'] = $order_info['order_state'];
+        $result['official_sn'] = $refill_info['official_sn'] ?? "";
 
         return $result;
     }

+ 11 - 0
test/TestRedis.php

@@ -191,6 +191,17 @@ class TestRedis extends TestCase
         $resp = json_decode('',true);
     }
 
+    public function testFormat()
+    {
+        $body = 'a2421040915130540';
+        $ret = preg_match('/^\d{4}(?P<month>\d{2})(?P<day>\d{2})(?P<hour>\d{2})(?P<min>\d{2})\d{4}/u', $body, $matches);
+
+        $short_no = substr('1000115100002086143',-6);
+
+
+
+    }
+
     public static function tearDownAfterClass() : void
     {