Browse Source

feat: EK-744: 会员注册成功后,增加发送短信功能.

kevinElken 9 tháng trước cách đây
mục cha
commit
1c35a429d4

+ 5 - 1
common/components/EknotifierSmsDriver.php

@@ -2,6 +2,7 @@
 namespace common\components;
 
 use common\helpers\LoggerTool;
+use common\models\Countries;
 use common\models\SmsRecord;
 use ElkenGit\EknotifierPHP\EknotifierSms;
 
@@ -24,16 +25,19 @@ class EknotifierSmsDriver implements SmsDriverInterface
         $applicationCode = \Yii::$app->params['sms']['url'];
         $applicationPassword = \Yii::$app->params['sms']['url'];
 
+        $zoneCode = Countries::getZoneCodeById($countryId);
+
         $eknotifierSms = new EknotifierSms($eknotifierUrl, $applicationCode, $applicationPassword);
         $response = $eknotifierSms->sendSMS($mobile, $message, $userId);
 
-        LoggerTool::debug(json_encode(['eknotifierSms', $eknotifierUrl, $applicationCode, $applicationPassword, $mobile, $message, $userId, $eknotifierSms, $response]));
+        LoggerTool::debug(['eknotifierSms', $eknotifierUrl, $applicationCode, $applicationPassword, $mobile, $zoneCode, $message, $userId, $eknotifierSms, $response]);
 
         $record = new SmsRecord();
         $record->USER_ID = $userId;
         $record->CLASSIFY = $classify;
         $record->COUNTRY_ID = $countryId;
         $record->MOBILE = $mobile;
+        $record->ZONE_CODE = $zoneCode;
         $record->CONTENT = $message;
         $record->RESULT = '';
         $record->save();

+ 5 - 0
common/models/Countries.php

@@ -113,4 +113,9 @@ class Countries extends \common\components\ActiveRecord
         $record = self::findOneAsArray('ID=:ID', [':ID' => $id]);
         return $record['LOCAL_CURRENCY_ID'] ?? 0;
     }
+
+    public static function getZoneCodeById(string $id): string
+    {
+        return self::findOneAsArray('ID=:ID', [':ID' => $id])['ZONE_CODE'] ?? '';
+    }
 }

+ 2 - 0
common/models/SmsRecord.php

@@ -13,6 +13,7 @@ use Yii;
  * @property string CONTENT 内容
  * @property string COUNTRY_ID 国家ID
  * @property string MOBILE 号码
+ * @property string ZONE_CODE 国际区号
  * @property int RESULT 状态
  * @property string RESPONSE 回调
  * @property string CREATED_AT 时间
@@ -49,6 +50,7 @@ class SmsRecord extends \common\components\ActiveRecord
             'CLASSIFY' => '类型',
             'COUNTRY_ID' => '国家ID',
             'MOBILE' => '号码',
+            'ZONE_CODE' => '国际区号',
             'CONTENT' => '内容',
             'RESULT' => '状态',
             'RESPONSE' => '回调',