阿貍子訂單管理系統 是基于ThinkPHP開發的微信商城系統,是一款極簡的PHP訂單系統,支持貨到付款,微信支付,非常不錯,簡介大方,適合做百度推廣、聯盟推廣,高效快捷,后臺功能齊全,小編今天就以替換短信接口為例帶大家進行二次開發,我們使用的短信接口是我們短信寶短信群發平臺的短信接口,我們短信寶短信群發平臺非常穩定,發送速度快,注冊就送測試短信,推薦大家使用
1:打開項目:\Public\Common\alizi.setting.php 在128行左右 增加短信端相關配置
1
2
3
4
5
6
7
|
'sms_setting' => array( 'sms_send' => array( 'name' => '短信發送' , 'options' =>array( '0' => '關閉' , '1' => '啟用' ,), 'tags' => 'select' , 'decription' => '' , 'width' =>30, 'height' =>0, 'separator' =>0,), 'sms_admin' => array( 'name' => '通知對象' , 'value' =>1, 'options' =>array( '0' => '只通知客戶' , '1' => '只通知管理員' , '2' => '同時通知管理員和客戶' ,), 'tags' => 'select' , 'decription' => '' , 'width' =>35, 'height' =>0, 'separator' =>0,), 'sms_admin_mobile' => array( 'name' => '' , 'options' => '' , 'tags' => 'text' , 'decription' => '請填寫管理員手機號,多個號碼請用英文逗號隔開' , 'width' =>30, 'height' =>0, 'separator' =>0,), 'sms_account' => array( 'name' => '短信寶賬號' , 'options' => '' , 'tags' => 'text' , 'decription' => '' , 'width' =>30, 'height' =>0, 'separator' =>0,), 'sms_password' => array( 'name' => '短信寶密碼' , 'options' => '' , 'tags' => 'text' , 'decription' => '' , 'width' =>30, 'height' =>0, 'separator' =>0,), ), |
2:打開項目:\Home\Lib\Action\ApiAction.class.php 修改發送類函數
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
|
private function sendSMS($order_id){ if (empty($ this ->aliziConfig[ 'sms_send' ])){ return array( 'status' =>0); } $order = M( 'Order' )->where(array( 'id' =>$order_id))->find(); if (empty($order)) return array( 'status' =>0); $item = M( 'Item' )->where( 'id=' .$order[ 'item_id' ])->field( 'id,sms_send' )->find(); $sms = json_decode($item[ 'sms_send' ], true ); $status=$order[ 'status' ]; if ($sms[$status][ 'status' ]==1 && !empty($sms[$status][ 'content' ])){ //發送內容替換 $express = C( 'DELIVERY' ); $http_type = ((isset($_SERVER[ 'HTTPS' ]) && $_SERVER[ 'HTTPS' ] == 'on' ) || (isset($_SERVER[ 'HTTP_X_FORWARDED_PROTO' ]) && $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] == 'https' )) ? 'https://' : 'http://' ; $aliziHost = $http_type.$_SERVER[ 'HTTP_HOST' ].C( 'ALIZI_ROOT' ); $confirmUrl = $aliziHost.(C( 'URL_MODEL' )==2? 'a/' .$order[ 'order_no' ]: 'Api/confirm.php?id=' .$order[ 'order_no' ]); $mobiles = $order[ 'mobile' ]; if (!empty($ this ->aliziConfig[ 'sms_admin_mobile' ])){ switch ($ this ->aliziConfig[ 'sms_admin' ]) { case '1' : $mobiles = $ this ->aliziConfig[ 'sms_admin_mobile' ]; break ; case '2' : $mobiles .= ',' .$ this ->aliziConfig[ 'sms_admin_mobile' ]; break ; } } $replace = array( '{[AliziTitle]}' => $order[ 'item_name' ], '{[AliziParams]}' => $order[ 'item_params' ], '{[AliziName]}' => $order[ 'name' ], '{[AliziQuantity]}' => $order[ 'quantity' ], '{[AliziPrice]}' => $order[ 'total_price' ], '{[AliziExpress]}' => $express[$order[ 'delivery_name' ]], '{[AliziExpressNum]}' => $order[ 'delivery_no' ], '{[AliziConfirmUrl]}' => $confirmUrl, '#title#' => $order[ 'item_name' ], '#params#' => $order[ 'item_params' ], '#name#' => $order[ 'name' ], '#mobile#' => $order[ 'mobile' ], '#quantity#' => $order[ 'quantity' ], '#price#' => $order[ 'total_price' ], '#express#' => $express[$order[ 'delivery_name' ]], '#expressNum#' => $order[ 'delivery_no' ], '#confirmUrl#' => $confirmUrl, '#orderNum#' => $order[ 'order_no' ], ); $content = str_replace(array_keys($replace),array_values($replace),$sms[$status][ 'content' ]); $param[ 'u' ]=$ this ->aliziConfig[ 'sms_account' ]; $param[ 'p' ]=md5($ this ->aliziConfig[ 'sms_password' ]); $param[ 'm' ]=$order[ 'mobile' ]; $param[ 'c' ]= '【' .$ this ->aliziConfig[ 'title' ]. '】' .$content; $rs=file_get_contents($url.http_build_query($param)); if ($rs == "0" ){ $sendData = array( 'order_id' =>$order_id, 'order_status' =>$order[ 'status' ], 'mobile' =>$mobiles, 'sent_content' =>$content, 'sent_time' =>date( 'Y-m-d H:i:s' ), 'sent_status' =>1, ); M( 'Sent' )->add($sendData); } } } |
3:打開項目:\Admin\Lib\Action\IndexAction.class.php 修改查詢余額類函數
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
public function smsBalance(){ header( 'Content-type: application/json' ); $aliziConfig = S( 'aliziConfig' ); if (empty($aliziConfig[ 'sms_account' ]) || empty($aliziConfig[ 'sms_password' ])){ $json = json_encode(array( 'status' =>0, 'data' =>0)); } else { $data = array( //'method'=>'balance', 'u' =>$aliziConfig[ 'sms_account' ], 'p' =>md5($aliziConfig[ 'sms_password' ]) //'url'=>"http://{$_SERVER['SERVER_NAME']}{$_SERVER['SCRIPT_NAME']}", ); $result=file_get_contents($url.http_build_query($data)); $result=explode( ',' ,$result); $json=json_encode(array( 'status' =>0, 'data' =>$result[1])); //$json = http( C('ALIZI_API').'/sms/', 'POST', $data ); } die($json); } |
經過上面的替換,短信寶的短信平臺已經替換成功了,可以正常使用了。進行測試發送:
報備一下短信寶的VIP模板,這樣就可以走短信寶的優質通道了,即便遇到敏感文字我們都不會人工審核,短信內容3~5秒就可送達。
另外:我們已經開發好完整的阿貍子V_2.9系統短信寶插件,點擊此鏈接 下載及查看安裝流程。
最新更新
電商類
CMS類
微信類