diff --git a/application/admin/controller/Config.php b/application/admin/controller/Config.php index 6678b3944..7dcf28ff7 100644 --- a/application/admin/controller/Config.php +++ b/application/admin/controller/Config.php @@ -15,7 +15,6 @@ namespace app\admin\controller; use controller\BasicAdmin; -use service\ExtendService; use service\LogService; /** @@ -72,17 +71,4 @@ class Config extends BasicAdmin return $this->index(); } - /** - * 短信参数配置 - * @return string - * @throws \think\Exception - * @throws \think\exception\PDOException - */ - public function sms() - { - $this->title = '短信服务配置'; - $this->assign('result', ExtendService::querySmsBalance()); - return $this->index(); - } - } diff --git a/application/admin/view/config/sms.html b/application/admin/view/config/sms.html deleted file mode 100644 index 366b51382..000000000 --- a/application/admin/view/config/sms.html +++ /dev/null @@ -1,41 +0,0 @@ -{extend name="admin@public/content"} - -{block name="content"} -
-{/block} diff --git a/config/wechat.php b/config/wechat.php index 392be7b1b..5d6328cb4 100644 --- a/config/wechat.php +++ b/config/wechat.php @@ -1,5 +1,17 @@ 'http://service.thinkadmin.top', ]; \ No newline at end of file diff --git a/extend/service/ExtendService.php b/extend/service/ExtendService.php deleted file mode 100644 index dbb366cf2..000000000 --- a/extend/service/ExtendService.php +++ /dev/null @@ -1,171 +0,0 @@ - $tkey, - 'mobile' => $phone, - 'content' => $content, - 'username' => sysconf('sms_username'), - 'productid' => $productid, - 'password' => md5(md5(sysconf('sms_password')) . $tkey), - ]; - $result = HttpService::post('http://www.ztsms.cn/sendNSms.do', $data); - list($code, $msg) = explode(',', $result . ','); - $insert = ['phone' => $phone, 'content' => $content, 'result' => $result]; - Db::name('MemberSmsHistory')->insert($insert); - return intval($code) === 1; - } - - /** - * 查询短信余额 - * @return array - * @throws \think\Exception - * @throws \think\exception\PDOException - */ - public static function querySmsBalance() - { - $tkey = date("YmdHis"); - $data = [ - 'tkey' => $tkey, - 'username' => sysconf('sms_username'), - 'password' => md5(md5(sysconf('sms_password')) . $tkey), - ]; - $result = HttpService::post('http://www.ztsms.cn/balanceN.do', $data); - if ($result > -1) { - return ['code' => 1, 'num' => $result, 'msg' => '获取短信剩余条数成功!']; - } elseif ($result > -2) { - return ['code' => 0, 'num' => '0', 'msg' => '用户名或者密码不正确!']; - } elseif ($result > -3) { - return ['code' => 0, 'num' => '0', 'msg' => 'tkey不正确!']; - } elseif ($result > -4) { - return ['code' => 0, 'num' => '0', 'msg' => '用户不存在或用户停用!']; - } - } - - /** - * 通用物流单查询 - * @param string $code 快递物流编号 - * @return array - */ - public static function expressByAuto($code) - { - list($result, $client_ip) = [[], Request::instance()->ip()]; - $header = ['Host' => 'www.kuaidi100.com', 'CLIENT-IP' => $client_ip, 'X-FORWARDED-FOR' => $client_ip]; - $autoResult = HttpService::get("http://www.kuaidi100.com/autonumber/autoComNum?text={$code}", [], ['header' => $header, 'timeout' => 30]); - foreach (json_decode($autoResult)->auto as $vo) { - $result[$vo->comCode] = self::express($vo->comCode, $code); - } - return $result; - } - - /** - * 查询物流信息 - * @param string $express_code 快递公司编辑 - * @param string $express_no 快递物流编号 - * @return array - */ - public static function express($express_code, $express_no) - { - list($microtime, $client_ip) = [microtime(true), Request::instance()->ip()]; - $header = ['Host' => 'www.kuaidi100.com', 'CLIENT-IP' => $client_ip, 'X-FORWARDED-FOR' => $client_ip]; - $location = "http://www.kuaidi100.com/query?type={$express_code}&postid={$express_no}&id=1&valicode=&temp={$microtime}"; - return json_decode(HttpService::get($location, [], ['header' => $header, 'timeout' => 30]), true); - } - - /** - * 下载CSV文件 - * @param string $filename 导出文件名 - * @param array $options 数据规则,如:['用户名'=>'username','性别'=>'sex'] - * @param \think\Db\Query $query - * @throws \think\exception\DbException - */ - public static function downloadCsv($filename, $options, $query) - { - self::downloadCsvHeader($filename, array_keys($options)); - $query->chunk(1000, function ($list) use ($options) { - self::downloadCsvBody($list, array_values($options)); - }); - } - - /** - * 写入CSV文件头部 - * @param string $filename 导出文件 - * @param array $headers CSV 头部(一级数组) - */ - public static function downloadCsvHeader($filename, $headers) - { - header('Content-Type: application/octet-stream'); - header("Content-Disposition: attachment; filename=" . iconv('utf-8', 'gbk//TRANSLIT', $filename)); - echo @iconv('utf-8', 'gbk//TRANSLIT', '"' . implode('","', $headers) . "\"\n"); - } - - /** - * 写入CSV文件内容 - * @param array $list 数据列表(二维数组或多维数组) - * @param array $rules 数据规则(一维数组) - */ - public static function downloadCsvBody($list, $rules) - { - foreach ($list as $data) { - $rows = []; - foreach ($rules as $rule) { - $item = self::parseKeyDot($data, $rule); - $rows[] = $item === $data ? '' : $item; - } - echo @iconv('utf-8', 'gbk//TRANSLIT', '"' . implode('","', $rows) . "\"\n"); - flush(); - } - } - - /** - * 根据数组key查询(可带点规则) - * @param array $data 数据 - * @param string $rule 规则,如: order.order_no - * @return mixed - */ - private static function parseKeyDot($data, $rule) - { - list($temp, $attr) = [$data, explode('.', trim($rule, '.'))]; - while ($key = array_shift($attr)) { - $temp = isset($temp[$key]) ? $temp[$key] : $temp; - } - return is_string($temp) ? $temp : ''; - } - -}