SmsManager.php
22.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
<?php
namespace common\exts\sms;
use Yii;
use yii\base\Component;
use yii\base\InvalidConfigException;
use domain\system\message\SmsMessage;
/**
* 短信发送管理器(集成阿里云短信服务)
*/
if (!defined('SMS_ROOT')) {
define('SMS_ROOT', dirname(__FILE__) . '/');
}
class SmsManager extends Component
{
public $smsKey;
public $smsSecret;
public $smsSignName;
private $aliSms;
private $req;
public function init()
{
if($this->smsKey === null){
throw new InvalidConfigException("smsKey 是必要参数");
}elseif($this->smsSecret === null){
throw new InvalidConfigException("smsSecret 是必要参数");
}elseif($this->smsSignName === null){
throw new InvalidConfigException("smsSignName 是必要参数");
}
require(SMS_ROOT.'aliyun/TopSdk.php');
$this->aliSms = new \TopClient;
$this->aliSms->appkey = $this->smsKey;
$this->aliSms->secretKey = $this->smsSecret;
$this->req = new \AlibabaAliqinFcSmsNumSendRequest;
$this->req->setSmsFreeSignName($this->smsSignName);
}
/**
* 手机验证码
* 模版内容: ${code}(手机验证码,有效期5分钟)
* 申请说明: 验证手机是否有效
* @param $phone
* @param $code
* @param $signName
* @return mixed
*/
public function sendRegCode($phone, $code, $signName = '')
{
// 设置短信签名
if (!empty($signName)) {
$this->req->setSmsFreeSignName($signName);
}
$this->req->setSmsType("normal");
$this->req->setSmsParam("{\"code\":\"".$code."\"}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_62690160");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 绑定手机号成功, 推送极办公业务介绍短信(已作废)
* 模版内容: 办公设备极速报修平台。 新用户享50元优惠券!修完抢最高50元红包。提供打印机、复印机、电脑维修服务!-回复T退订
* 申请说明: 给用户发送认证成功后消息
* @param $phone
* @return mixed
*/
public function sendBindPhoneSuccessMsg($phone)
{
$this->req->setSmsType("normal");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_131430002");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 补发首单有礼优惠券短信(已废弃)
* 模版内容: 打印机、复印机维修,换耗材,“极办公”给您派新年利是!100元优惠券,首次报修可全额抵扣,请到#极办公小程序#个人中心查看。-回复T退订
* 申请说明: 回馈极办公老客户,派发维修费代金券
* @param $phone
* @return mixed
*/
public function reSendBindPhoneCouponMsg($phone)
{
$this->req->setSmsType("normal");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_118725110");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 发送订单质保申请通知
* 模版内容: 收到客户质保申请,请${contactHour}小时内致电客户,${finishHour}小时内处理完毕。逾期未处理账号将无法接单。若故障未解决,可能会扣除您该笔订单的维修费用。
* 申请说明: 当有用户维修订单出现质保问题时发送给工程师,提醒工程师及时处理质保问题
* @param $phone 手机号
* @param $contactHour 多少小时内联系客户
* @param $finishHour 多少小时内处理完毕
* @return mixed
*/
public function sendWarrantyApplyMsg($phone, $contactHour, $finishHour)
{
$this->req->setSmsType("normal");
$this->req->setSmsParam("{contactHour:" . $contactHour . ", finishHour:" . $finishHour . "}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_150170068"); // SMS_147200443
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 新订单
* 模版内容: 您收到一个“${device}”的平台订单,马上打开极窝订单宝微信公众号查看吧~
* 申请说明: 用于通知工程师收到新的平台订单
* @param $phone
* @return mixed
*/
public function sendNewOrderMsg($phone, $device)
{
$this->req->setSmsType("normal");
$this->req->setRecNum($phone);
$params = json_encode(['device' => (string)$device]);
$this->req->setSmsParam($params);
$this->req->setSmsTemplateCode("SMS_173479889");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 系统关闭订单通知
* 模版内容: 您的“${device}”订单暂无工程师接单已经关闭,建议您换个时间再次提交报修。
* 申请说明: 关闭短信,通知用户
* @param $phone
* @return mixed
*/
public function sendCloseOrderMsg($phone, $device, $signName = '')
{
// 设置短信签名
if (!empty($signName)) {
$this->req->setSmsFreeSignName($signName);
}
$this->req->setSmsType("normal");
$this->req->setRecNum($phone);
$params = json_encode(['device' => (string)$device]);
$this->req->setSmsParam($params);
$this->req->setSmsTemplateCode("SMS_149417787"); // SMS_125810114
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 设备绑定成功(目前未启用)
* 模版内容: 您绑定的用户设备“${device}”已审核通过,马上打开极办公微信公众号查看吧!
* 申请说明: 提醒 工程师设备绑定申请已经成功
* @return mixed
*/
public function sendBindDeviceSuccessMsg($phone,$device)
{
$this->req->setSmsType("normal");
$this->req->setSmsParam("{\"device\":\"".$device."\"}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_65935276");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 设备绑定失败(目前未启用)
* 模版内容: 您绑定的用户设备“${device}”审核不通过,请打开极办公微信公众号查看原因!
* 申请说明: 设备绑定失败的时候通知工程师
* @param $phone
* @return mixed
*/
public function sendBindDeviceFailMsg($phone,$device)
{
$this->req->setSmsType("normal");
$this->req->setSmsParam("{\"device\":\"".$device."\"}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_65925271");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 技能认证成功通知
* 模版内容: 恭喜您通过“${skill}”技能认证。极办公工程师公众号接单,收入约40元-100元/单,新工程师完成的前10单补贴10元/单。SMS_149422688
* 模版内容: 恭喜您通过“${skill}”技能认证。极办公工程师公众号接单,收入约40元-100元/单 SMS_155570179
* 模版内容: 恭喜您通过“${skill}”技能认证。接下来能接到更多订单了。SMS_173341678
* 申请说明: 工程师技能认证通过推送消息
*/
public function sendSkillAuthSuccessMsg($phone, $skill, $freeCommissionCount)
{
if ($freeCommissionCount > 0) {
// 恭喜您通过“${skill}”技能认证。极办公工程师公众号接单,收入约50元-200元/单,前${count}单不抽佣,佣金全额返还。
$param = "{skill:" . $skill . "}";
$templateCode = "SMS_173341678";
} else {
// 恭喜您通过“${skill}”技能认证。极办公工程师公众号接单,收入约50元-200元/单。
$param = "{skill:" . $skill . "}";
$templateCode = "SMS_173341678";
}
$this->req->setSmsType("normal");
$this->req->setSmsParam($param);
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode($templateCode);
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 技能认证考试失败(已废弃)
* 模版内容: 您的“${skill}”技能认证审核不通过!请打开极办公微信公众号查看原因!
* 申请说明: 工程师技能认证失败通知
*/
public function sendSkillAuthFailMsg($phone,$skill)
{
$this->req->setSmsType("normal");
$this->req->setSmsParam("{\"skill\":\"".$skill."\"}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_66020229");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 实名认证成功
* 模版内容: 恭喜您成功通过实名认证!请打开极办公微信公众号继续完成技能认证!
* 申请说明: 工程师实名认证成功后通知工程师
* @param $phone
* @return mixed
*/
public function sendUserAuthSuccessMsg($phone)
{
$this->req->setSmsType("normal");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_66070260");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 实名认证失败
* 模版内容: 您的实名认证审核不通过!请打开极办公微信公众号查看原因!
* 申请说明: 工程师实名认证失败的时候通知工程师
* @param $phone
* @return mixed
*/
public function sendUserAuthFailMsg($phone)
{
$this->req->setSmsType("normal");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_66005216");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 余额不足提醒(已废弃)
* 模版内容: 微信商户平台${appid}余额不足,请及时充值!
* 申请说明: 用户提现的时候,发现余额不足,提醒管理员
*/
public function sendNoMoneyNotice($phone, $appid)
{
$this->req->setSmsType("normal");
$this->req->setSmsParam("{\"appid\":\"".$appid."\"}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_76950035");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 微信商户号余额不足提醒
* 模版内容: 微信商户号${mch_id}当前余额${balance}元,低于${warning_balance}元,请及时充值!
* 申请说明: 用户提现的时候,发现微信商户号余额不足,提醒管理员
*/
public function sendNoMoneyWarning($phone, $mchId, $balance, $warningBalance)
{
$this->req->setSmsType("normal");
$this->req->setSmsParam("{mch_id:" . $mchId . ", balance:" . $balance . ", warning_balance:" . $warningBalance . "}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_140731639");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 发票已经发送提醒
* 模版内容: 您于${date}申请的电子票已发送,您可前往“极办公小程序”个人中心或者登录您的邮箱,查看电子票信息,感谢您的使用!
* 申请说明: 用于通知客户已经发送开具的电子票到指定邮箱
*/
public function sendInvoiceNotice($phone, $date, $signName = SmsMessage::SIGN_NAME_JIWORK)
{
$this->req->setSmsFreeSignName($signName);
$this->req->setSmsType("normal");
$this->req->setSmsParam("{\"date\":\"".$date."\"}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_149417844");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 通过技能实操考核(已废弃)
* 模版内容: 恭喜您通过“${skill}”技能的实操考核!请打开极办公工程师微信公众号开始接单吧~
* 申请说明: 通过技能实操考核短信提醒
*/
public function sendSkillPracticeSuccessMsg($phone, $skill)
{
$this->req->setSmsType("normal");
$this->req->setSmsParam("{\"skill\":\"".$skill."\"}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_128455012");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 微信支付接口告警
* 模版内容: 微信支付接口告警(${client_name}) 错误描述: ${errorMsg},请及时处理!
* 申请说明: 当平台调用微信支付接口返回错误时需及时通知平台管理员。
* 示例:微信支付接口告警(微信小程序) 错误描述:NOTENOUGH=>商户后台余额不足,请及时处理!
*/
public function sendWechatPayNotice($phone, $clientName, $errorMsg)
{
$this->req->setSmsType("normal");
$this->req->setSmsParam("{client_name:" . $clientName . ", errorMsg:" . $errorMsg . "}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_128595001");
$result = $this->aliSms->execute($this->req);
return $result;
}
/** 封号短信(已废弃)
* 模版内容: 您的账号因为${reason}被系统封号,如有疑问请联系极办公客服
* 申请说明: 工程师封号
* @param $phone
* @param $reason
* @return mixed
*/
public function sendBlockEngineerMsg($phone, $reason)
{
$this->req->setSmsType("normal");
$this->req->setSmsParam('{"reason":"' . $reason . '"}');
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_135345116");
$result = $this->aliSms->execute($this->req);
return $result;
}
/** 解封短信
* 模版内容: 您的账号已经解封,未来请严格按照平台规则接单。
* 申请说明: 解封工程师账号
* @param $phone
* @return mixed
*/
public function sendUnblockEngineerMsg($phone)
{
$this->req->setSmsType("normal");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_149417910"); // SMS_135355121
$result = $this->aliSms->execute($this->req);
return $result;
}
/** 【客服】48小时质保申请延期通知
* 模版内容: 收到一条客户质保申请,来自订单号(${orderno}),已超过48小时,请提醒工程师处理。
* 申请说明: 客服订单质保通知
* @param $phone
* @param $orderno
* @return mixed
*/
public function sendCustomServiceWarrantyDelayMsg($phone, $orderno)
{
$this->req->setSmsType("normal");
$this->req->setSmsParam('{"orderno":"' . $orderno . '"}');
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_149422796"); // SMS_147195475
$result = $this->aliSms->execute($this->req);
return $result;
}
/**【客服】工程师频繁质保通知
* 模版内容: 工程师${engineer}一个月内被客户申请质保达到${times}次,已被系统禁用${days}天,请重新安排技能实操考核。
* 申请说明: 工程师服务质量太差,频繁被申请质保通知客服处理
* @param $phone
* @param $engineer
* @param $times
* @param $days
* @return mixed
*/
public function sendCustomServiceFreqWarrantyMsg($phone, $engineer, $times, $days)
{
$this->req->setSmsType("normal");
$this->req->setSmsParam("{engineer:" . $engineer . ", times:" . $times . ", days:" . $days . "}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_150180079");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 工程师接单成功短信模板
* 模版内容: 您的“${device}”维修订单已经被${engineer}接单,稍后工程师会与您电话联系。为保护客户隐私,我们的来电为虚拟电话。进入“极办公”公众号查看订单进度
* 申请说明: 工程师接单成功短信提醒
*/
public function sendPickOrderNotice($phone, $device, $engineer, $signName = '')
{
// 设置短信签名
if (!empty($signName)) {
$this->req->setSmsFreeSignName($signName);
}
$this->req->setSmsType("normal");
$this->req->setSmsParam("{device:" . $device . ", engineer:" . $engineer . "}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_178980160");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 工程师取消订单短信
* 模版内容: 您的“${device}”维修订单,已被${engineer}取消,取消原因:${reason}。再下个订单吧,让其它工程师为您服务。
* 申请说明: 工程师取消订单短信通知
*/
public function sendEngineerCancelOrderNotice($phone, $device, $engineer, $reason, $signName = '')
{
// 设置短信签名
if (!empty($signName)) {
$this->req->setSmsFreeSignName($signName);
}
$this->req->setSmsType("normal");
$this->req->setSmsParam("{device:" . $device . ", engineer:" . $engineer . ", reason:" . $reason . "}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_149422817"); // SMS_140731732
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 用户新年利是短信
* 模版内容: 打印机电脑报修平台,感谢老客户。微信搜索关注“极办公”公众号,领取猪年开工利是,${expire_hour}小时内有效。
* 申请说明: 用户新年利是短信
*/
public function sendUserNewYearRedPackNotice($phone, $expire_hour = 24)
{
$this->req->setSmsType("normal");
$this->req->setSmsParam("{expire_hour:" . (int)$expire_hour . "}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_156470575"); // SMS_156470575
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 模版名称: 用户新年利是(新)
* 模版CODE: SMS_157284328
* 模版内容: 打印机电脑报修平台,感谢老客户。微信搜索关注“极办公”公众号,输入暗号${order}, 领取猪年开工利是,${expire_hour}小时内有效。
*/
public function sendUserNewYearRedPackNoticeHasOrder($phone, $expire_hour = 24, $order_word = "")
{
$this->req->setSmsType("normal");
$this->req->setSmsParam("{expire_hour:" . (int)$expire_hour . ", order:" . $order_word . "}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_157284328"); // SMS_156470575
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 您下的***机器的维修订单暂无工程师接单,如需急用,可增加感谢费加快接单速度
* @param $phone
* @param int $expire_hour
* @return mixed
*/
public function sendThankFeeNotice($phone, $deviceName, $signName = '')
{
// 设置短信签名
if (!empty($signName)) {
$this->req->setSmsFreeSignName($signName);
}
$this->req->setSmsType("normal");
$this->req->setRecNum($phone);
$this->req->setSmsParam("{device_name:" . $deviceName . "}");
$this->req->setSmsTemplateCode("SMS_166776550");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 工程师修改手机验证码
* 验证码:${code},10分钟内有效。您正在申请修改手机号码
* @param $phone
* @return mixed
*/
public function sendEngineerPhoneCode($phone, $code)
{
$this->req->setSmsType("normal");
$this->req->setRecNum($phone);
$params = json_encode(['code' => (string)$code]);
$this->req->setSmsParam($params);
$this->req->setSmsTemplateCode("SMS_169642915");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 订单宝: 订单宝-自有订单通知
* 模版内容: 您收到一张自有订单,设备“${device}”。进入公众号,您可以自己接单或者把订单转给其他工程师处理。
* 申请说明: 用于通知工程师收到新的专属订单
* @param $phone
* @return mixed
*/
public function sendPrivateNewOrderMsg($phone, $device)
{
$this->req->setSmsType("normal");
$this->req->setRecNum($phone);
$params = json_encode(['device' => (string)$device]);
$this->req->setSmsParam($params);
$this->req->setSmsTemplateCode("SMS_173474941");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 订单宝: 订单宝-转出订单通知
* 模版内容: 您收到了一张“${device}”设备的转出订单,马上打开极窝订单宝微信公众号查看吧~
* 申请说明: 用于通知工程师收到新的专属订单
* @param $phone
* @return mixed
*/
public function sendPrivateForwardOrderMsg($phone, $device)
{
$this->req->setSmsType("normal");
$this->req->setRecNum($phone);
$params = json_encode(['device' => (string)$device]);
$this->req->setSmsParam($params);
$this->req->setSmsTemplateCode("SMS_173474272");
$result = $this->aliSms->execute($this->req);
return $result;
}
/**
* 工程师接自有订单单成功短信模板(自有订单)
* 模版内容: 您的“${device}”维修订单已经被${engineer}接单,稍后工程师会与您电话联系。进入“订单宝客户端”微信小程序查看订单进度。
* 申请说明: 工程师接单成功短信提醒
*/
public function sendPickPrivateOrderNotice($phone, $device, $engineer, $signName = '')
{
// 设置短信签名
if (!empty($signName)) {
$this->req->setSmsFreeSignName($signName);
}
$this->req->setSmsType("normal");
$this->req->setSmsParam("{device:" . $device . ", engineer:" . $engineer . "}");
$this->req->setRecNum($phone);
$this->req->setSmsTemplateCode("SMS_173760001");
$result = $this->aliSms->execute($this->req);
return $result;
}
}