正在显示
49 个修改的文件
包含
4800 行增加
和
0 行删除
README.en.md
0 → 100644
1 | +# sos | ||
2 | + | ||
3 | +#### Description | ||
4 | +{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} | ||
5 | + | ||
6 | +#### Software Architecture | ||
7 | +Software architecture description | ||
8 | + | ||
9 | +#### Installation | ||
10 | + | ||
11 | +1. xxxx | ||
12 | +2. xxxx | ||
13 | +3. xxxx | ||
14 | + | ||
15 | +#### Instructions | ||
16 | + | ||
17 | +1. xxxx | ||
18 | +2. xxxx | ||
19 | +3. xxxx | ||
20 | + | ||
21 | +#### Contribution | ||
22 | + | ||
23 | +1. Fork the repository | ||
24 | +2. Create Feat_xxx branch | ||
25 | +3. Commit your code | ||
26 | +4. Create Pull Request | ||
27 | + | ||
28 | + | ||
29 | +#### Gitee Feature | ||
30 | + | ||
31 | +1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md | ||
32 | +2. Gitee blog [blog.gitee.com](https://blog.gitee.com) | ||
33 | +3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) | ||
34 | +4. The most valuable open source project [GVP](https://gitee.com/gvp) | ||
35 | +5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) | ||
36 | +6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) |
README.md
0 → 100644
1 | + | ||
2 | +# 开发者文档 | ||
3 | + | ||
4 | +### 一、约束 | ||
5 | +--- | ||
6 | + | ||
7 | +1. 开发规范原则上按照ThinkPHP5.0完全开发手册中的标准。 | ||
8 | +1. 模块 common 中 web 目录内的 BaseModel 为基础共用的 model,不写入任何其他模块业务相关方法。 | ||
9 | +1. 在模块 common 中的模型中显式定义数据库名称。 | ||
10 | +1. 模块 web 中,是我们编写具体业务的模块。其中 model 目录先继承 common 中 model 目录下的 model 再写自己的逻辑。 | ||
11 | +1. 模块 web 中,控制器需要继承当前模块的 Controller,该 Controller 需要继承 common 模块中的 WebController。 | ||
12 | +1. 公共方法参考 common.php,该文件不要维护,如需添加内容,请与项目负责人联系。 | ||
13 | +1. 异常处理使用 application\common\exception\BaseException。 | ||
14 | +1. 返回数据必须使用$this->throwError、$this->renderJson、$this->renderSuccess、$this->renderError。参考 application\common\service\Render。 | ||
15 | +1. 不允许直接使用 Db 操作数据库(特殊需要请说明原因)。 | ||
16 | +1. 原则上在 Controller 不做数据库操作。 | ||
17 | +1. 所有类编写注释。 | ||
18 | +~~~ | ||
19 | + /** | ||
20 | + * 类说明 | ||
21 | + * | ||
22 | + * Class 类名称 | ||
23 | + * @package 位置(例如:app\sapi\controller) | ||
24 | + */ | ||
25 | +~~~ | ||
26 | +12. 任何方法都需要编写注释,说明参数已经方法的含义。 | ||
27 | +~~~ | ||
28 | + /** | ||
29 | + * 方法说明 | ||
30 | + * | ||
31 | + * @param 参数名 含义 | ||
32 | + * @return 返回类型(例如:array|bool|mixed) | ||
33 | + * @throws 异常处理(例如:\think\exception\DbException) | ||
34 | + */ | ||
35 | +~~~ | ||
36 | +13. 任何变量、常量、对象等都需注释说明含义。 | ||
37 | +~~~ | ||
38 | + // 含义 | ||
39 | +或 | ||
40 | + /* @var 类型 名称 含义 */ | ||
41 | +~~~ | ||
42 | +14.原则上每行代码都需要注释清楚作用,也可同一功能一起加注释,如果逻辑性较强的区域需要注释开始、结束。 | ||
43 | +~~~ | ||
44 | + /*---------- 说明 start ----------*/ | ||
45 | + /*---------- 说明 end ----------*/ | ||
46 | +~~~ | ||
47 | +### 二、关于权限 | ||
48 | +--- |
application/command.php
0 → 100644
1 | +<?php | ||
2 | +// +---------------------------------------------------------------------- | ||
3 | +// | ThinkPHP [ WE CAN DO IT JUST THINK ] | ||
4 | +// +---------------------------------------------------------------------- | ||
5 | +// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved. | ||
6 | +// +---------------------------------------------------------------------- | ||
7 | +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) | ||
8 | +// +---------------------------------------------------------------------- | ||
9 | +// | Author: yunwuxin <448901948@qq.com> | ||
10 | +// +---------------------------------------------------------------------- | ||
11 | + | ||
12 | +return []; |
application/common.php
0 → 100644
1 | +<?php | ||
2 | +// +---------------------------------------------------------------------- | ||
3 | +// | ThinkPHP [ WE CAN DO IT JUST THINK ] | ||
4 | +// +---------------------------------------------------------------------- | ||
5 | +// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved. | ||
6 | +// +---------------------------------------------------------------------- | ||
7 | +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) | ||
8 | +// +---------------------------------------------------------------------- | ||
9 | +// | Author: 流年 <liu21st@gmail.com> | ||
10 | +// +---------------------------------------------------------------------- | ||
11 | + | ||
12 | +// 应用公共文件 | ||
13 | +use think\Request; | ||
14 | +use think\Log; | ||
15 | + | ||
16 | +/** | ||
17 | + * 打印调试函数 | ||
18 | + * @param $content | ||
19 | + * @param $is_die | ||
20 | + */ | ||
21 | +function pre($content, $is_die = true) | ||
22 | +{ | ||
23 | + header('Content-type: text/html; charset=utf-8'); | ||
24 | + echo '<pre>' . print_r($content, true); | ||
25 | + $is_die && die(); | ||
26 | +} | ||
27 | + | ||
28 | +/** | ||
29 | + * 驼峰命名转下划线命名 | ||
30 | + * @param $str | ||
31 | + * @return string | ||
32 | + */ | ||
33 | +function toUnderScore($str) | ||
34 | +{ | ||
35 | + $dstr = preg_replace_callback('/([A-Z]+)/', function ($matchs) { | ||
36 | + return '_' . strtolower($matchs[0]); | ||
37 | + }, $str); | ||
38 | + return trim(preg_replace('/_{2,}/', '_', $dstr), '_'); | ||
39 | +} | ||
40 | + | ||
41 | +/** | ||
42 | + * 生成密码hash值 | ||
43 | + * @param $password | ||
44 | + * @return string | ||
45 | + */ | ||
46 | +function api_hash($password) | ||
47 | +{ | ||
48 | + return md5(md5($password) . 'api_salt_SmTRx'); | ||
49 | +} | ||
50 | + | ||
51 | +/** | ||
52 | + * 获取当前域名及根路径 | ||
53 | + * @return string | ||
54 | + */ | ||
55 | +function base_url() | ||
56 | +{ | ||
57 | + static $baseUrl = ''; | ||
58 | + if (empty($baseUrl)) { | ||
59 | + $request = Request::instance(); | ||
60 | + $subDir = str_replace('\\', '/', dirname($request->server('PHP_SELF'))); | ||
61 | + $baseUrl = $request->scheme() . '://' . $request->host() . $subDir . ($subDir === '/' ? '' : '/'); | ||
62 | + } | ||
63 | + return $baseUrl; | ||
64 | +} | ||
65 | + | ||
66 | +/** | ||
67 | + * 写入日志 (使用tp自带驱动记录到runtime目录中) | ||
68 | + * @param $value | ||
69 | + * @param string $type | ||
70 | + */ | ||
71 | +function log_write($value, $type = 'api-info') | ||
72 | +{ | ||
73 | + $msg = is_string($value) ? $value : var_export($value, true); | ||
74 | + Log::record($msg, $type); | ||
75 | +} | ||
76 | + | ||
77 | +/** | ||
78 | + * curl请求指定url (get) | ||
79 | + * @param $url | ||
80 | + * @param array $data | ||
81 | + * @return mixed | ||
82 | + */ | ||
83 | +function curl($url, $data = []) | ||
84 | +{ | ||
85 | + // 处理get数据 | ||
86 | + if (!empty($data)) { | ||
87 | + $url = $url . '?' . http_build_query($data); | ||
88 | + } | ||
89 | + $curl = curl_init(); | ||
90 | + curl_setopt($curl, CURLOPT_URL, $url); | ||
91 | + curl_setopt($curl, CURLOPT_HEADER, false); | ||
92 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | ||
93 | + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);//这个是重点。 | ||
94 | + $result = curl_exec($curl); | ||
95 | + curl_close($curl); | ||
96 | + return $result; | ||
97 | +} | ||
98 | + | ||
99 | +/** | ||
100 | + * curl请求指定url (post) | ||
101 | + * @param $url | ||
102 | + * @param array $data | ||
103 | + * @return mixed | ||
104 | + */ | ||
105 | +function curlPost($url, $data = []) | ||
106 | +{ | ||
107 | + $ch = curl_init(); | ||
108 | + curl_setopt($ch, CURLOPT_POST, 1); | ||
109 | + curl_setopt($ch, CURLOPT_HEADER, 0); | ||
110 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
111 | + curl_setopt($ch, CURLOPT_URL, $url); | ||
112 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | ||
113 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | ||
114 | + $result = curl_exec($ch); | ||
115 | + curl_close($ch); | ||
116 | + return $result; | ||
117 | +} | ||
118 | + | ||
119 | +/** | ||
120 | + * 多维数组合并 | ||
121 | + * @param $array1 | ||
122 | + * @param $array2 | ||
123 | + * @return array | ||
124 | + */ | ||
125 | +function array_merge_multiple($array1, $array2) | ||
126 | +{ | ||
127 | + $merge = $array1 + $array2; | ||
128 | + $data = []; | ||
129 | + foreach ($merge as $key => $val) { | ||
130 | + if ( | ||
131 | + isset($array1[$key]) | ||
132 | + && is_array($array1[$key]) | ||
133 | + && isset($array2[$key]) | ||
134 | + && is_array($array2[$key]) | ||
135 | + ) { | ||
136 | + $data[$key] = array_merge_multiple($array1[$key], $array2[$key]); | ||
137 | + } else { | ||
138 | + $data[$key] = isset($array2[$key]) ? $array2[$key] : $array1[$key]; | ||
139 | + } | ||
140 | + } | ||
141 | + return $data; | ||
142 | +} | ||
143 | + | ||
144 | +/** | ||
145 | + * 二维数组排序 | ||
146 | + * @param $arr | ||
147 | + * @param $keys | ||
148 | + * @param bool $desc | ||
149 | + * @return mixed | ||
150 | + */ | ||
151 | +function array_sort($arr, $keys, $desc = false) | ||
152 | +{ | ||
153 | + $key_value = $new_array = array(); | ||
154 | + foreach ($arr as $k => $v) { | ||
155 | + $key_value[$k] = $v[$keys]; | ||
156 | + } | ||
157 | + if ($desc) { | ||
158 | + arsort($key_value); | ||
159 | + } else { | ||
160 | + asort($key_value); | ||
161 | + } | ||
162 | + reset($key_value); | ||
163 | + foreach ($key_value as $k => $v) { | ||
164 | + $new_array[$k] = $arr[$k]; | ||
165 | + } | ||
166 | + return $new_array; | ||
167 | +} | ||
168 | + | ||
169 | +/** | ||
170 | + * 数据导出到excel(csv文件) | ||
171 | + * @param $fileName | ||
172 | + * @param array $tileArray | ||
173 | + * @param array $dataArray | ||
174 | + */ | ||
175 | +function export_excel($fileName, $tileArray = [], $dataArray = []) | ||
176 | +{ | ||
177 | + ini_set('memory_limit', '512M'); | ||
178 | + ini_set('max_execution_time', 0); | ||
179 | + ob_end_clean(); | ||
180 | + ob_start(); | ||
181 | + header("Content-Type: text/csv"); | ||
182 | + header("Content-Disposition:filename=" . $fileName); | ||
183 | + $fp = fopen('php://output', 'w'); | ||
184 | + fwrite($fp, chr(0xEF) . chr(0xBB) . chr(0xBF));// 转码 防止乱码(比如微信昵称) | ||
185 | + fputcsv($fp, $tileArray); | ||
186 | + $index = 0; | ||
187 | + foreach ($dataArray as $item) { | ||
188 | + if ($index == 1000) { | ||
189 | + $index = 0; | ||
190 | + ob_flush(); | ||
191 | + flush(); | ||
192 | + } | ||
193 | + $index++; | ||
194 | + fputcsv($fp, $item); | ||
195 | + } | ||
196 | + ob_flush(); | ||
197 | + flush(); | ||
198 | + ob_end_clean(); | ||
199 | +} | ||
200 | + | ||
201 | +/** | ||
202 | + * 隐藏敏感字符 | ||
203 | + * @param $value | ||
204 | + * @return string | ||
205 | + */ | ||
206 | +function substr_cut($value) | ||
207 | +{ | ||
208 | + $strlen = mb_strlen($value, 'utf-8'); | ||
209 | + if ($strlen <= 1) return $value; | ||
210 | + $firstStr = mb_substr($value, 0, 1, 'utf-8'); | ||
211 | + $lastStr = mb_substr($value, -1, 1, 'utf-8'); | ||
212 | + return $strlen == 2 ? $firstStr . str_repeat('*', $strlen - 1) : $firstStr . str_repeat("*", $strlen - 2) . $lastStr; | ||
213 | +} | ||
214 | + | ||
215 | +/** | ||
216 | + * 获取当前系统版本号 | ||
217 | + * @return mixed|null | ||
218 | + * @throws Exception | ||
219 | + */ | ||
220 | +function get_version() | ||
221 | +{ | ||
222 | + //return '1.0.1'; | ||
223 | + | ||
224 | + static $version = null; | ||
225 | + if ($version) { | ||
226 | + return $version; | ||
227 | + } | ||
228 | + $file = ROOT_PATH . '/version.json'; | ||
229 | + if (!file_exists($file)) { | ||
230 | + throw new Exception('version.json not found'); | ||
231 | + } | ||
232 | + | ||
233 | + $version = json_decode(file_get_contents($file), true); | ||
234 | + if (!is_array($version)) { | ||
235 | + throw new Exception('version cannot be decoded'); | ||
236 | + } | ||
237 | + return $version['version']; | ||
238 | +} | ||
239 | + | ||
240 | +/** | ||
241 | + * 获取全局唯一标识符 | ||
242 | + * @param bool $trim | ||
243 | + * @return string | ||
244 | + */ | ||
245 | +function getGuidV4($trim = true) | ||
246 | +{ | ||
247 | + // Windows | ||
248 | + if (function_exists('com_create_guid') === true) { | ||
249 | + $charid = com_create_guid(); | ||
250 | + return $trim == true ? trim($charid, '{}') : $charid; | ||
251 | + } | ||
252 | + // OSX/Linux | ||
253 | + if (function_exists('openssl_random_pseudo_bytes') === true) { | ||
254 | + $data = openssl_random_pseudo_bytes(16); | ||
255 | + $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100 | ||
256 | + $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 | ||
257 | + return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); | ||
258 | + } | ||
259 | + // Fallback (PHP 4.2+) | ||
260 | + mt_srand((double)microtime() * 10000); | ||
261 | + $charid = strtolower(md5(uniqid(rand(), true))); | ||
262 | + $hyphen = chr(45); // "-" | ||
263 | + $lbrace = $trim ? "" : chr(123); // "{" | ||
264 | + $rbrace = $trim ? "" : chr(125); // "}" | ||
265 | + $guidv4 = $lbrace . | ||
266 | + substr($charid, 0, 8) . $hyphen . | ||
267 | + substr($charid, 8, 4) . $hyphen . | ||
268 | + substr($charid, 12, 4) . $hyphen . | ||
269 | + substr($charid, 16, 4) . $hyphen . | ||
270 | + substr($charid, 20, 12) . | ||
271 | + $rbrace; | ||
272 | + return $guidv4; | ||
273 | +} | ||
274 | + | ||
275 | +function getRandMd5($start = 0, $len = 32) | ||
276 | +{ | ||
277 | + return ($len == 16 ? 'hr' : '') . substr(md5(time() . mt_rand(1000, 9999) . 'hr'), $start, $len); | ||
278 | +} | ||
279 | + | ||
280 | +/** | ||
281 | + * 时间戳转换日期 | ||
282 | + * @param $timeStamp | ||
283 | + * @return false|string | ||
284 | + */ | ||
285 | +function format_time($timeStamp) | ||
286 | +{ | ||
287 | + return date('Y-m-d H:i:s', $timeStamp); | ||
288 | +} | ||
289 | + | ||
290 | +/** | ||
291 | + * 左侧填充0 | ||
292 | + * @param $value | ||
293 | + * @param int $padLength | ||
294 | + * @return string | ||
295 | + */ | ||
296 | +function pad_left($value, $padLength = 2) | ||
297 | +{ | ||
298 | + return \str_pad($value, $padLength, "0", STR_PAD_LEFT); | ||
299 | +} | ||
300 | + | ||
301 | +/** | ||
302 | + * 获取跳转的真实地址 | ||
303 | + * 如果访问链接是有跳转的,则获得真实跳转地址。 | ||
304 | + * public function index() | ||
305 | + * { | ||
306 | + * return get_redirect_url('http://api.tp5024.com/index.php?s=/oauth/token/a'); | ||
307 | + * } | ||
308 | + * public function a() { | ||
309 | + * return redirect('build123'); | ||
310 | + * } | ||
311 | + */ | ||
312 | +function get_redirect_url($url) | ||
313 | +{ | ||
314 | + $redirect_url = null; | ||
315 | + | ||
316 | + $url_parts = @parse_url($url); | ||
317 | + if (!$url_parts) return false; | ||
318 | + if (!isset($url_parts['host'])) return false; | ||
319 | + if (!isset($url_parts['path'])) $url_parts['path'] = '/'; | ||
320 | + | ||
321 | + $sock = fsockopen($url_parts['host'], (isset($url_parts['port']) ? (int)$url_parts['port'] : 80), $errno, $errstr, 30); | ||
322 | + if (!$sock) return false; | ||
323 | + | ||
324 | + $request = "HEAD " . $url_parts['path'] . (isset($url_parts['query']) ? '?'.$url_parts['query'] : '') . " HTTP/1.1\r\n"; | ||
325 | + $request .= 'Host: ' . $url_parts['host'] . "\r\n"; | ||
326 | + $request .= "Connection: Close\r\n\r\n"; | ||
327 | + fwrite($sock, $request); | ||
328 | + $response = ''; | ||
329 | + while(!feof($sock)) $response .= fread($sock, 8192); | ||
330 | + fclose($sock); | ||
331 | + | ||
332 | + if (preg_match('/^Location: (.+?)$/m', $response, $matches)) { | ||
333 | + if ( substr($matches[1], 0, 1) == "/" ) | ||
334 | + return $url_parts['scheme'] . "://" . $url_parts['host'] . trim($matches[1]); | ||
335 | + else | ||
336 | + return trim($matches[1]); | ||
337 | + } else { | ||
338 | + return false; | ||
339 | + } | ||
340 | +} | ||
341 | + | ||
342 | +/** | ||
343 | + * 获取客户端IP地址 | ||
344 | + * @return mixed | ||
345 | + */ | ||
346 | +function getClientIp1() | ||
347 | +{ | ||
348 | + $ip = false; | ||
349 | + //客户端IP 或 NONE | ||
350 | + if (!empty($_SERVER["HTTP_CLIENT_IP"])) { | ||
351 | + $ip = $_SERVER["HTTP_CLIENT_IP"]; | ||
352 | + } | ||
353 | + //多重代理服务器下的客户端真实IP地址(可能伪造),如果没有使用代理,此字段为空 | ||
354 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { | ||
355 | + $ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']); | ||
356 | + if ($ip) { | ||
357 | + array_unshift($ips, $ip); | ||
358 | + $ip = false; | ||
359 | + } | ||
360 | + for ($i = 0; $i < count($ips); $i++) { | ||
361 | + if (!eregi ("^(10│172.16│192.168).", $ips[$i])) { | ||
362 | + $ip = $ips[$i]; | ||
363 | + break; | ||
364 | + } | ||
365 | + } | ||
366 | + } | ||
367 | + //客户端IP 或 (最后一个)代理服务器 IP | ||
368 | + return ($ip ? $ip : $_SERVER['REMOTE_ADDR']); | ||
369 | +} | ||
370 | + | ||
371 | +/** | ||
372 | + * 获取客户端IP地址 | ||
373 | + * @param integer $type | ||
374 | + * 0 返回IP地址 | ||
375 | + * 1 返回IPV4地址数字 | ||
376 | + * @return mixed | ||
377 | + */ | ||
378 | +function getClientIp($type = 0) { | ||
379 | + $type = $type ? 1 : 0; | ||
380 | + $ip = null; | ||
381 | + if ($ip !== null) return $ip[$type]; | ||
382 | + //nginx 代理模式下,获取客户端真实IP | ||
383 | + if (isset($_SERVER['HTTP_X_REAL_IP'])) { | ||
384 | + $ip = $_SERVER['HTTP_X_REAL_IP']; | ||
385 | + } | ||
386 | + // 客户端的ip | ||
387 | + elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { | ||
388 | + $ip = $_SERVER['HTTP_CLIENT_IP']; | ||
389 | + } | ||
390 | + // 浏览当前页面的用户计算机的网关 | ||
391 | + elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { | ||
392 | + $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); | ||
393 | + $pos = array_search('unknown', $arr); | ||
394 | + if (false !== $pos) unset($arr[$pos]); | ||
395 | + $ip = trim($arr[0]); | ||
396 | + } elseif (isset($_SERVER['REMOTE_ADDR'])) { | ||
397 | + //浏览当前页面的用户计算机的ip地址 | ||
398 | + $ip = $_SERVER['REMOTE_ADDR']; | ||
399 | + } else { | ||
400 | + $ip = $_SERVER['REMOTE_ADDR']; | ||
401 | + } | ||
402 | + // IP地址合法验证 | ||
403 | + $long = sprintf("%u", ip2long($ip)); | ||
404 | + $ip = $long ? array($ip, $long) : array('0.0.0.0', 0); | ||
405 | + return $ip[$type]; | ||
406 | +} |
application/common/behavior/App.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\common\behavior; | ||
4 | + | ||
5 | +use think\Log; | ||
6 | +use think\Request; | ||
7 | + | ||
8 | +/** | ||
9 | + * 应用行为管理 | ||
10 | + * Class App | ||
11 | + * @package app\common\behavior | ||
12 | + */ | ||
13 | +class App | ||
14 | +{ | ||
15 | + /** | ||
16 | + * 应用开始 | ||
17 | + * @param $dispatch | ||
18 | + */ | ||
19 | + public function appBegin($dispatch) | ||
20 | + { | ||
21 | + // 记录访问日志 | ||
22 | + if (!config('app_debug')) { | ||
23 | + $request = Request::instance(); | ||
24 | + Log::record('[ ROUTE ] ' . var_export($dispatch, true), 'begin'); | ||
25 | + Log::record('[ HEADER ] ' . var_export($request->header(), true), 'begin'); | ||
26 | + Log::record('[ PARAM ] ' . var_export($request->param(), true), 'begin'); | ||
27 | + } | ||
28 | + } | ||
29 | +} |
application/common/behavior/Init.php
0 → 100644
application/common/controller/Controller.php
0 → 100644
application/common/enum/EnumBasics.php
0 → 100644
application/common/enum/RedisEnum.php
0 → 100644
1 | +<?php | ||
2 | +namespace app\common\enum; | ||
3 | + | ||
4 | +/** | ||
5 | + * 缓存名称枚举类 | ||
6 | + * Class RedisEnum | ||
7 | + * @package app\common\enum | ||
8 | + */ | ||
9 | +class RedisEnum extends EnumBasics | ||
10 | +{ | ||
11 | + // 权限 urls | ||
12 | + const API_URLS = 'api_urls'; | ||
13 | + | ||
14 | + // 缓存模块,无需验证 urls | ||
15 | + const API_URLS_ALLOW_TABLE = 'api_urls'; | ||
16 | + const API_URLS_ALLOW_KEY = 'cgi_allow'; | ||
17 | + const API_URLS_ALLOW_HASH = API_URLS_ALLOW_TABLE . ':' . API_URLS_ALLOW_KEY; | ||
18 | + | ||
19 | + // 缓存模块,无需验证 urls | ||
20 | + const API_IPS_ALLOW_TABLE = 'api_urls'; | ||
21 | + const API_IPS_ALLOW_KEY = 'cgi_allow'; | ||
22 | + const API_IPS_ALLOW_HASH = API_IPS_ALLOW_TABLE . ':' . API_IPS_ALLOW_KEY; | ||
23 | + | ||
24 | + /** | ||
25 | + * 获取枚举数据 | ||
26 | + * @return array | ||
27 | + */ | ||
28 | + public static function data() | ||
29 | + { | ||
30 | + return [ | ||
31 | + self::API_URLS => [ | ||
32 | + 'name' => '权限 URL', | ||
33 | + 'value' => self::API_URLS, | ||
34 | + ] | ||
35 | + ]; | ||
36 | + } | ||
37 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\common\exception; | ||
4 | + | ||
5 | +use think\Exception; | ||
6 | + | ||
7 | +/** | ||
8 | + * Class BaseException | ||
9 | + * 自定义异常类的基类 | ||
10 | + */ | ||
11 | +class BaseException extends Exception | ||
12 | +{ | ||
13 | + public $code = 0; | ||
14 | + public $message = 'invalid parameters'; | ||
15 | + | ||
16 | + /** | ||
17 | + * 构造函数,接收一个关联数组 | ||
18 | + * @param array $params 关联数组只应包含code、msg,且不应该是空值 | ||
19 | + */ | ||
20 | + public function __construct($params = []) | ||
21 | + { | ||
22 | + if (!is_array($params)) { | ||
23 | + return; | ||
24 | + } | ||
25 | + if (array_key_exists('code', $params)) { | ||
26 | + $this->code = $params['code']; | ||
27 | + } | ||
28 | + if (array_key_exists('msg', $params)) { | ||
29 | + $this->message = $params['msg']; | ||
30 | + } | ||
31 | + } | ||
32 | +} | ||
33 | + |
1 | +<?php | ||
2 | + | ||
3 | +namespace app\common\exception; | ||
4 | + | ||
5 | +use think\exception\Handle; | ||
6 | +use think\Log; | ||
7 | +use Exception; | ||
8 | + | ||
9 | +/** | ||
10 | + * 重写Handle的render方法,实现自定义异常消息 | ||
11 | + * Class ExceptionHandler | ||
12 | + * @package app\common\library\exception | ||
13 | + */ | ||
14 | +class ExceptionHandler extends Handle | ||
15 | +{ | ||
16 | + private $code; | ||
17 | + private $message; | ||
18 | + | ||
19 | + /** | ||
20 | + * 输出异常信息 | ||
21 | + * @param Exception $e | ||
22 | + * @return \think\Response|\think\response\Json | ||
23 | + */ | ||
24 | + public function render(Exception $e) | ||
25 | + { | ||
26 | + if ($e instanceof BaseException) { | ||
27 | + $this->code = $e->code; | ||
28 | + $this->message = $e->message; | ||
29 | + } else { | ||
30 | + if (config('app_debug')) { | ||
31 | + return parent::render($e); | ||
32 | + } | ||
33 | + $this->code = 0; | ||
34 | + $this->message = $e->getMessage() ?: '很抱歉,服务器内部错误'; | ||
35 | + $this->recordErrorLog($e); | ||
36 | + } | ||
37 | + return json(['code' => $this->code, 'msg' => $this->message]); | ||
38 | + } | ||
39 | + | ||
40 | + /** | ||
41 | + * 将异常写入日志 | ||
42 | + * @param Exception $e | ||
43 | + */ | ||
44 | + private function recordErrorLog(Exception $e) | ||
45 | + { | ||
46 | + Log::record($e->getMessage(), 'error'); | ||
47 | + Log::record($e->getTraceAsString(), 'error'); | ||
48 | + } | ||
49 | +} |
application/common/model/BaseModel.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Administrator | ||
5 | + * Date: 2020/6/28 | ||
6 | + * Time: 10:56 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace app\common\model; | ||
10 | + | ||
11 | + | ||
12 | +use think\Model; | ||
13 | + | ||
14 | +/** | ||
15 | + * 基础模型所有模型必须要继承此模型 | ||
16 | + * Class BaseModel | ||
17 | + * @package app\common\model | ||
18 | + */ | ||
19 | +class BaseModel extends Model | ||
20 | +{ | ||
21 | + | ||
22 | + public static function init() | ||
23 | + { | ||
24 | + parent::init(); | ||
25 | + } | ||
26 | + | ||
27 | +} |
application/common/model/Cgi.php
0 → 100644
application/common/model/CommApi.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Administrator | ||
5 | + * Date: 2020/6/28 | ||
6 | + * Time: 11:04 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace app\common\model; | ||
10 | + | ||
11 | + | ||
12 | +class CommApi extends BaseModel | ||
13 | +{ | ||
14 | + | ||
15 | + public function getOne($where, $field = '*') | ||
16 | + { | ||
17 | + $data = $this->where($where)->field($field)->find(); | ||
18 | + if ($data) { | ||
19 | + return $data->toArray(); | ||
20 | + } | ||
21 | + | ||
22 | + return []; | ||
23 | + } | ||
24 | +} |
application/common/model/Notify.php
0 → 100644
application/common/model/ServiceApi.php
0 → 100644
application/common/model/serviceapi/Car.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | + | ||
4 | +namespace app\common\model\serviceapi; | ||
5 | + | ||
6 | + | ||
7 | +use app\common\model\ServiceApi; | ||
8 | + | ||
9 | +/** | ||
10 | + * 功能描述 华安车险车辆信息 | ||
11 | + * Class Car | ||
12 | + * @package app\common\model\commapi | ||
13 | + * Date: 2020/7/21 | ||
14 | + * Time: 16:00 | ||
15 | + * @author nyq | ||
16 | + */ | ||
17 | +class Car extends ServiceApi | ||
18 | +{ | ||
19 | + protected $table = "sos_car_car"; | ||
20 | + protected $pk = "id"; | ||
21 | + | ||
22 | + /** | ||
23 | + * 函数功能描述 根据用户信息查询车辆 | ||
24 | + * @param $data | ||
25 | + * Date: 2020/7/21 | ||
26 | + * Time: 16:50 | ||
27 | + * @author nyq | ||
28 | + */ | ||
29 | + public function getCar($data) { | ||
30 | + $res = static::where($data)->find(); | ||
31 | + return $res; | ||
32 | + } | ||
33 | + | ||
34 | + | ||
35 | + /** | ||
36 | + * 函数功能描述 添加车辆信息 | ||
37 | + * @param $data | ||
38 | + * Date: 2020/7/21 | ||
39 | + * Time: 16:20 | ||
40 | + * @author nyq | ||
41 | + */ | ||
42 | + public function addCar($data) { | ||
43 | + $res = static::insertGetId($data); | ||
44 | + return $res; | ||
45 | + | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * 函数功能描述 根据用户信息修改车辆信息 | ||
50 | + * @param $where | ||
51 | + * @param $data | ||
52 | + * Date: 2020/7/21 | ||
53 | + * Time: 16:22 | ||
54 | + * @author nyq | ||
55 | + */ | ||
56 | + public function updateCar($where, $data) { | ||
57 | + | ||
58 | + $res = static::where($where)->update($data); | ||
59 | + return $res; | ||
60 | + } | ||
61 | + | ||
62 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 华安车险支付回调相关信息表 | ||
7 | + * Class CarCallback | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/7/22 | ||
10 | + * Time: 17:20 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class CarCallback extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table="sos_car_callback"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + /** | ||
19 | + * 函数功能描述 添加支付信息 | ||
20 | + * @param $data | ||
21 | + * Date: 2020/7/22 | ||
22 | + * Time: 18:00 | ||
23 | + * @author nyq | ||
24 | + */ | ||
25 | + public function addData($data) { | ||
26 | + static::insert($data); | ||
27 | + | ||
28 | + } | ||
29 | + | ||
30 | +} |
1 | +<?php | ||
2 | + | ||
3 | + | ||
4 | +namespace app\common\model\serviceapi; | ||
5 | + | ||
6 | + | ||
7 | +use app\common\model\ServiceApi; | ||
8 | + | ||
9 | +/** | ||
10 | + * 功能描述 华安车险险种信息 | ||
11 | + * Class CarInsurance | ||
12 | + * @package app\common\model\commapi | ||
13 | + * Date: 2020/7/21 | ||
14 | + * Time: 16:50 | ||
15 | + * @author nyq | ||
16 | + */ | ||
17 | +class CarInsurance extends ServiceApi | ||
18 | +{ | ||
19 | + protected $table = "sos_car_insurance"; | ||
20 | + protected $pk = "id"; | ||
21 | + | ||
22 | + /** | ||
23 | + * 函数功能描述 根据订单号获取险种信息 | ||
24 | + * Date: 2020/7/21 | ||
25 | + * Time: 16:40 | ||
26 | + * @author nyq | ||
27 | + */ | ||
28 | + public function getCarInsurance($where) { | ||
29 | + $res = static::where($where)->select(); | ||
30 | + return $res; | ||
31 | + } | ||
32 | + | ||
33 | + /** | ||
34 | + * 函数功能描述 根据订单号删除险种 | ||
35 | + * @param $where1 | ||
36 | + * @param $data | ||
37 | + * Date: 2020/7/21 | ||
38 | + * Time: 16:47 | ||
39 | + * @author nyq | ||
40 | + */ | ||
41 | + public function getCarInsuranceDel($where) { | ||
42 | + $res = static::where($where)->delete(); | ||
43 | + return $res; | ||
44 | + } | ||
45 | + | ||
46 | + /** | ||
47 | + * 函数功能描述 添加险种信息 | ||
48 | + * @param $data | ||
49 | + * Date: 2020/7/21 | ||
50 | + * Time: 16:50 | ||
51 | + * @author nyq | ||
52 | + */ | ||
53 | + public function addCarInsurance($data) { | ||
54 | + $res = static::insert($data); | ||
55 | + return $res; | ||
56 | + } | ||
57 | + | ||
58 | + | ||
59 | + | ||
60 | + | ||
61 | + | ||
62 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 华安车险订单信息 | ||
7 | + * Class CarOrder | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/7/21 | ||
10 | + * Time: 16:33 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class CarOrder extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table = "sos_car_order"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + /** | ||
19 | + * 函数功能描述 根据通知订单号获取订单信息 | ||
20 | + * Date: 2020/7/21 | ||
21 | + * Time: 16:40 | ||
22 | + * @author nyq | ||
23 | + */ | ||
24 | + public function getCarOrder($where) { | ||
25 | + $res = static::where($where)->find(); | ||
26 | + return $res; | ||
27 | + } | ||
28 | + /** | ||
29 | + * 函数功能描述 根据返回的查询码获取订单信息 | ||
30 | + * Date: 2020/7/22 | ||
31 | + * Time: 10:06 | ||
32 | + * @author nyq | ||
33 | + */ | ||
34 | + public function getCarOrderList($where) { | ||
35 | + $res = static::where($where)->select(); | ||
36 | + return $res; | ||
37 | + } | ||
38 | + /** | ||
39 | + * 函数功能描述 根据用户信息修改订单信息 | ||
40 | + * @param $where | ||
41 | + * @param $data | ||
42 | + * Date: 2020/7/21 | ||
43 | + * Time: 16:47 | ||
44 | + * @author nyq | ||
45 | + */ | ||
46 | + public function getCarOrderUpdate($where, $data) { | ||
47 | + $res = static::where($where)->update($data); | ||
48 | + return $res; | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * 函数功能描述 添加订单信息 | ||
53 | + * @param $data | ||
54 | + * Date: 2020/7/21 | ||
55 | + * Time: 16:50 | ||
56 | + * @author nyq | ||
57 | + */ | ||
58 | + public function addCarOrder($data) { | ||
59 | + $res = static::insertGetId($data); | ||
60 | + return $res; | ||
61 | + } | ||
62 | + | ||
63 | + | ||
64 | + /** | ||
65 | + * 函数功能描述 根据用户信息修改订单信息 | ||
66 | + * @param $where | ||
67 | + * @param $data | ||
68 | + * Date: 2020/7/22 | ||
69 | + * Time: 16:47 | ||
70 | + * @author gxd | ||
71 | + */ | ||
72 | + public function getCarOrderUpdateAll($where, $data) { | ||
73 | + $res = static::whereIn('appNo',$where)->update($data); | ||
74 | + return $res; | ||
75 | + } | ||
76 | + | ||
77 | + | ||
78 | + | ||
79 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 抽奖 | ||
7 | + * Class CarOrder | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/8/25 | ||
10 | + * Time: 16:33 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class PrizeMember extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table = "sos_prize_member"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + /** | ||
19 | + * 函数功能描述 抽奖用户 | ||
20 | + * Date: 2020/8/25 | ||
21 | + * Time: 16:40 | ||
22 | + * @author nyq | ||
23 | + */ | ||
24 | + | ||
25 | + public function getPrizeMember($code) | ||
26 | + { | ||
27 | + $user = static::where($code)->select(); | ||
28 | + return $user; | ||
29 | + } | ||
30 | + public function getMember($code) | ||
31 | + { | ||
32 | + $user = static::where($code)->find(); | ||
33 | + return $user; | ||
34 | + } | ||
35 | + | ||
36 | + /** | ||
37 | + * 函数功能描述 重置 | ||
38 | + * @param $where | ||
39 | + * @param $data | ||
40 | + * Date: 2020/7/21 | ||
41 | + * Time: 16:47 | ||
42 | + * @author nyq | ||
43 | + */ | ||
44 | + public function prizeReset($wheres,$data) { | ||
45 | + $res = static::where($wheres)->update($data); | ||
46 | + return $res; | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * 函数功能描述 抽奖 | ||
51 | + * @param $where | ||
52 | + * @param $data | ||
53 | + * Date: 2020/7/21 | ||
54 | + * Time: 16:47 | ||
55 | + * @author nyq | ||
56 | + */ | ||
57 | + public function getPrizeMemberAdd($data) { | ||
58 | + | ||
59 | + $res = static::insertGetId($data); | ||
60 | + return $res; | ||
61 | + | ||
62 | + } | ||
63 | + | ||
64 | + | ||
65 | + | ||
66 | + | ||
67 | + | ||
68 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 华安车险订单信息 | ||
7 | + * Class CarOrder | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/7/21 | ||
10 | + * Time: 16:33 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class PrizePrize extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table = "sos_prize_prize"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + /** | ||
19 | + * 函数功能描述 根据通知订单号获取订单信息 | ||
20 | + * Date: 2020/7/21 | ||
21 | + * Time: 16:40 | ||
22 | + * @author nyq | ||
23 | + */ | ||
24 | + | ||
25 | + public function getPrize($code,$offset,$rows) | ||
26 | + { | ||
27 | +// echo $rows; | ||
28 | + $user = static::where($code)->limit($offset,$rows)->select(); | ||
29 | + | ||
30 | + //echo static::getLastSql(); | ||
31 | + | ||
32 | + return $user; | ||
33 | + } | ||
34 | + | ||
35 | + public function getPrizeList($code){ | ||
36 | + $user = static::where($code)->select(); | ||
37 | + return $user; | ||
38 | + } | ||
39 | + | ||
40 | + public function getPrizePrize($code){ | ||
41 | + | ||
42 | + $user = static::where($code)->find(); | ||
43 | + return $user; | ||
44 | + } | ||
45 | + /** | ||
46 | + * 函数功能描述 添加奖品 | ||
47 | + * Date: 2020/8/25 | ||
48 | + * Time: 15:00 | ||
49 | + * @author nyq | ||
50 | + */ | ||
51 | + public function prizeAdd($data) | ||
52 | + { | ||
53 | + $res = static::insertGetId($data); | ||
54 | + return $res; | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * 函数功能描述 编辑奖品 | ||
59 | + * @param $where | ||
60 | + * @param $data | ||
61 | + * Date: 2020/7/21 | ||
62 | + * Time: 16:47 | ||
63 | + * @author nyq | ||
64 | + */ | ||
65 | + public function prizeUp($where, $data) { | ||
66 | + $res = static::where($where)->update($data); | ||
67 | + return $res; | ||
68 | + } | ||
69 | + | ||
70 | + | ||
71 | + | ||
72 | + | ||
73 | + | ||
74 | + | ||
75 | + | ||
76 | + | ||
77 | + | ||
78 | + | ||
79 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 华安车险订单信息 | ||
7 | + * Class CarOrder | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/7/21 | ||
10 | + * Time: 16:33 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class PrizeRule extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table = "sos_prize_rule"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + /** | ||
19 | + * 函数功能描述 查询抽奖规则 | ||
20 | + * Date: 2020/8/25 | ||
21 | + * Time: 16:40 | ||
22 | + * @author nyq | ||
23 | + */ | ||
24 | + | ||
25 | + public function getPrizeRule() | ||
26 | + { | ||
27 | + $user = static::find(); | ||
28 | + return $user; | ||
29 | + } | ||
30 | + | ||
31 | + /** | ||
32 | + * 函数功能描述 添加规则 | ||
33 | + * Date: 2020/8/25 | ||
34 | + * Time: 16:40 | ||
35 | + * @author nyq | ||
36 | + */ | ||
37 | + | ||
38 | + public function prizeRullAdd($data) | ||
39 | + { | ||
40 | + $res = static::insertGetId($data); | ||
41 | + return $res; | ||
42 | + } | ||
43 | + | ||
44 | + | ||
45 | + /** | ||
46 | + * 函数功能描述 编辑规则 | ||
47 | + * @param $where | ||
48 | + * @param $data | ||
49 | + * Date: 2020/8/26 | ||
50 | + * Time: 16:47 | ||
51 | + * @author nyq | ||
52 | + */ | ||
53 | + public function prizeRullEdit($where, $data) { | ||
54 | + $res = static::where($where)->update($data); | ||
55 | + return $res; | ||
56 | + } | ||
57 | + | ||
58 | + | ||
59 | + | ||
60 | + | ||
61 | + | ||
62 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 抽奖token | ||
7 | + * Class token | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/8/31 | ||
10 | + * Time: 16:33 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class PrizeToken extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table = "sos_prize_token"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + /** | ||
19 | + * 函数功能描述 获取token | ||
20 | + * Date: 2020/8/31 | ||
21 | + * Time: 16:40 | ||
22 | + * @author nyq | ||
23 | + */ | ||
24 | + | ||
25 | + public function getToken() | ||
26 | + { | ||
27 | + $user = static::find(); | ||
28 | + return $user; | ||
29 | + } | ||
30 | + /** | ||
31 | + * 函数功能描述 修改token | ||
32 | + * Date: 2020/8/31 | ||
33 | + * Time: 16:40 | ||
34 | + * @author nyq | ||
35 | + */ | ||
36 | + public function updataToken($where, $data) { | ||
37 | + $res = static::where($where)->update($data); | ||
38 | + return $res; | ||
39 | + } | ||
40 | + | ||
41 | + | ||
42 | + /** | ||
43 | + * 函数功能描述 添加token | ||
44 | + * Date: 2020/8/31 | ||
45 | + * Time: 15:00 | ||
46 | + * @author nyq | ||
47 | + */ | ||
48 | + public function addToken($data) | ||
49 | + { | ||
50 | + $res = static::insert($data); | ||
51 | + return $res; | ||
52 | + } | ||
53 | + | ||
54 | + | ||
55 | + | ||
56 | + | ||
57 | + | ||
58 | + | ||
59 | + | ||
60 | + | ||
61 | + | ||
62 | + | ||
63 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 华安车险订单信息 | ||
7 | + * Class CarOrder | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/7/21 | ||
10 | + * Time: 16:33 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class PrizeWin extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table = "sos_prize_win"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + /** | ||
19 | + * 函数功能描述 获取中奖列表 | ||
20 | + * Date: 2020/8/25 | ||
21 | + * Time: 16:40 | ||
22 | + * @author nyq | ||
23 | + */ | ||
24 | + | ||
25 | + public function getPrizeWin($code,$offset,$rows) | ||
26 | + { | ||
27 | + | ||
28 | + $user = static::where($code)->limit($offset,$rows)->order('addTime desc')->select(); | ||
29 | + | ||
30 | + return $user; | ||
31 | + } | ||
32 | + /** | ||
33 | + * 函数功能描述 导出数据 | ||
34 | + * Date: 2020/8/28 | ||
35 | + * Time: 16:40 | ||
36 | + * @author nyq | ||
37 | + */ | ||
38 | + | ||
39 | + public function getPrizeWinToExcel($code) | ||
40 | + { | ||
41 | + $user = static::where($code)->select(); | ||
42 | + return $user; | ||
43 | + } | ||
44 | + | ||
45 | + /** | ||
46 | + * 函数功能描述 统计数量 | ||
47 | + * Date: 2020/8/25 | ||
48 | + * Time: 16:40 | ||
49 | + * @author nyq | ||
50 | + */ | ||
51 | + | ||
52 | + public function getPrizeWinCount($code) | ||
53 | + { | ||
54 | + $user = static::where($code)->count(); | ||
55 | + return $user; | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * 函数功能描述 添加奖品 | ||
60 | + * Date: 2020/8/25 | ||
61 | + * Time: 16:40 | ||
62 | + * @author nyq | ||
63 | + */ | ||
64 | + | ||
65 | + public function prizeAdd($data) | ||
66 | + { | ||
67 | + $res = static::insertGetId($data); | ||
68 | + return $res; | ||
69 | + } | ||
70 | + | ||
71 | + /** | ||
72 | + * 函数功能描述 获取中奖列表 20 条 | ||
73 | + * Date: 2020/8/25 | ||
74 | + * Time: 16:40 | ||
75 | + * @author nyq | ||
76 | + */ | ||
77 | + | ||
78 | + public function getPrizeWinlist($where) | ||
79 | + { | ||
80 | + if (isset($where) && !empty($where)) { | ||
81 | + $user = static::where($where)->select(); | ||
82 | + }else{ | ||
83 | + $user = static::limit(20)->order('id asc' )->select(); | ||
84 | + } | ||
85 | + return $user; | ||
86 | + } | ||
87 | + /** | ||
88 | + * 函数功能描述 兑奖接口 | ||
89 | + * @param $where | ||
90 | + * @param $data | ||
91 | + * Date: 2020/8/26 | ||
92 | + * Time: 16:47 | ||
93 | + * @author nyq | ||
94 | + */ | ||
95 | + | ||
96 | + public function winReset($wheres,$data) { | ||
97 | + $res = static::where($wheres)->update($data); | ||
98 | + return $res; | ||
99 | + } | ||
100 | + /** | ||
101 | + * 函数功能描述 删除抽奖记录 | ||
102 | + * @param $where | ||
103 | + * @param $data | ||
104 | + * Date: 2020/8/26 | ||
105 | + * Time: 16:47 | ||
106 | + * @author nyq | ||
107 | + */ | ||
108 | + | ||
109 | + public function delUser($wheres) { | ||
110 | + $res = static::where($wheres)->delete(); | ||
111 | + return $res; | ||
112 | + } | ||
113 | + | ||
114 | + | ||
115 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 产品管理 | ||
7 | + * Class Product | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/11/2 | ||
10 | + * Time: 16:33 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class Product extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table = "sos_product_goods"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + | ||
19 | + /** | ||
20 | + * 函数功能描述 添加产品 | ||
21 | + * Date: 2020/11/2 | ||
22 | + * Time: 15:00 | ||
23 | + * @author nyq | ||
24 | + */ | ||
25 | + public function add($data) | ||
26 | + { | ||
27 | + $res = static::insertGetId($data); | ||
28 | + return $res; | ||
29 | + } | ||
30 | + /** | ||
31 | + * 函数功能描述 编辑奖品 | ||
32 | + * @param $where | ||
33 | + * @param $data | ||
34 | + * Date: 2020/7/21 | ||
35 | + * Time: 16:47 | ||
36 | + * @author nyq | ||
37 | + */ | ||
38 | + public function productUp($where, $data) { | ||
39 | + $res = static::where($where)->update($data); | ||
40 | + return $res; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * 函数功能描述 获取商品列表 | ||
45 | + * Date: 2020/11/2 | ||
46 | + * Time: 16:40 | ||
47 | + * @author nyq | ||
48 | + */ | ||
49 | + | ||
50 | + public function goodsList($code,$offset,$rows){ | ||
51 | + $user = static::where($code)->limit($offset,$rows)->select(); | ||
52 | + return $user; | ||
53 | + } | ||
54 | + | ||
55 | + | ||
56 | + public function getGoodsList($code){ | ||
57 | + | ||
58 | + $user = static::where($code)->find(); | ||
59 | + return $user; | ||
60 | + } | ||
61 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 用户管理 | ||
7 | + * Class Product | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/11/2 | ||
10 | + * Time: 16:33 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class ProductOrder extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table = "sos_product_order"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + | ||
19 | + /** | ||
20 | + * 函数功能描述 添加订单 | ||
21 | + * Date: 2020/11/2 | ||
22 | + * Time: 15:00 | ||
23 | + * @author nyq | ||
24 | + */ | ||
25 | + public function add($data) | ||
26 | + { | ||
27 | + $res = static::insertGetId($data); | ||
28 | + return $res; | ||
29 | + } | ||
30 | + /** | ||
31 | + * 函数功能描述 删除订单 | ||
32 | + * Date: 2020/11/2 | ||
33 | + * Time: 15:00 | ||
34 | + * @author nyq | ||
35 | + */ | ||
36 | + public function orderDel($data) | ||
37 | + { | ||
38 | + $res = static::where($data)->delete(); | ||
39 | + return $res; | ||
40 | + } | ||
41 | + | ||
42 | + | ||
43 | + /** | ||
44 | + * 函数功能描述 编辑奖品 | ||
45 | + * @param $where | ||
46 | + * @param $data | ||
47 | + * Date: 2020/7/21 | ||
48 | + * Time: 16:47 | ||
49 | + * @author nyq | ||
50 | + */ | ||
51 | + public function productUp($where, $data) { | ||
52 | + $res = static::where($where)->update($data); | ||
53 | + return $res; | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * 函数功能描述 获取商品列表 | ||
58 | + * Date: 2020/11/2 | ||
59 | + * Time: 16:40 | ||
60 | + * @author nyq | ||
61 | + */ | ||
62 | + | ||
63 | + public function orderList($code){ | ||
64 | + $user = static::where($code)->select(); | ||
65 | + return $user; | ||
66 | + } | ||
67 | + | ||
68 | + | ||
69 | + public function getGoodsList($code){ | ||
70 | + | ||
71 | + $user = static::where($code)->find(); | ||
72 | + return $user; | ||
73 | + } | ||
74 | + | ||
75 | + | ||
76 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 用户管理 | ||
7 | + * Class Product | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/11/2 | ||
10 | + * Time: 16:33 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class ProductUser extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table = "sos_product_user"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + | ||
19 | + /** | ||
20 | + * 函数功能描述 添加用户 | ||
21 | + * Date: 2020/11/2 | ||
22 | + * Time: 15:00 | ||
23 | + * @author nyq | ||
24 | + */ | ||
25 | + public function add($data) | ||
26 | + { | ||
27 | + $res = static::insertGetId($data); | ||
28 | + return $res; | ||
29 | + } | ||
30 | + /** | ||
31 | + * 函数功能描述 编辑奖品 | ||
32 | + * @param $where | ||
33 | + * @param $data | ||
34 | + * Date: 2020/7/21 | ||
35 | + * Time: 16:47 | ||
36 | + * @author nyq | ||
37 | + */ | ||
38 | + public function productUp($where, $data) { | ||
39 | + $res = static::where($where)->update($data); | ||
40 | + return $res; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * 函数功能描述 获取商品列表 | ||
45 | + * Date: 2020/11/2 | ||
46 | + * Time: 16:40 | ||
47 | + * @author nyq | ||
48 | + */ | ||
49 | + | ||
50 | + public function getUserlist($code,$offset,$rows){ | ||
51 | + $user = static::alias("user")->where($code)->limit($offset,$rows); | ||
52 | + $res= $user->join("sos_product_order or", "or.user_id=user.id")->join("sos_product_goods go", "or.goods_id=go.id","LEFT") | ||
53 | + ->field("user.*,or.order_code,or.num,or.price,go.name as goods_name") | ||
54 | + ->select(); | ||
55 | + return $res; | ||
56 | + } | ||
57 | + | ||
58 | + public function getUserlistToEx(){ | ||
59 | + $user = static::alias("user"); | ||
60 | + $res= $user->join("sos_product_order or", "or.user_id=user.id")->join("sos_product_goods go", "or.goods_id=go.id","LEFT") | ||
61 | + ->field("user.*,or.order_code,or.num,or.price,go.name as goods_name") | ||
62 | + ->select(); | ||
63 | + return $res; | ||
64 | + } | ||
65 | + | ||
66 | + | ||
67 | + | ||
68 | + | ||
69 | + | ||
70 | + | ||
71 | + | ||
72 | + | ||
73 | + | ||
74 | + | ||
75 | + | ||
76 | + | ||
77 | + | ||
78 | + | ||
79 | + | ||
80 | + | ||
81 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 抽奖 | ||
7 | + * Class turnPrize | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/9/25 | ||
10 | + * Time: 16:33 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class TurnPrizeMember extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table = "sos_prize_turn_member"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + /** | ||
19 | + * 函数功能描述 抽奖用户 | ||
20 | + * Date: 2020/9/25 | ||
21 | + * Time: 16:40 | ||
22 | + * @author nyq | ||
23 | + */ | ||
24 | + | ||
25 | + public function getPrizeMember($code) | ||
26 | + { | ||
27 | + $user = static::where($code)->select(); | ||
28 | + return $user; | ||
29 | + } | ||
30 | + public function getMember($code) | ||
31 | + { | ||
32 | + $user = static::where($code)->find(); | ||
33 | + return $user; | ||
34 | + } | ||
35 | + | ||
36 | + /** | ||
37 | + * 函数功能描述 重置 | ||
38 | + * @param $where | ||
39 | + * @param $data | ||
40 | + * Date: 2020/9/21 | ||
41 | + * Time: 16:47 | ||
42 | + * @author nyq | ||
43 | + */ | ||
44 | + public function prizeReset($wheres,$data) { | ||
45 | + $res = static::where($wheres)->update($data); | ||
46 | + return $res; | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * 函数功能描述 抽奖 | ||
51 | + * @param $where | ||
52 | + * @param $data | ||
53 | + * Date: 2020/9/21 | ||
54 | + * Time: 16:47 | ||
55 | + * @author nyq | ||
56 | + */ | ||
57 | + public function getPrizeMemberAdd($data) { | ||
58 | + $res = static::insertGetId($data); | ||
59 | + return $res; | ||
60 | + | ||
61 | + } | ||
62 | + | ||
63 | + | ||
64 | + | ||
65 | + | ||
66 | + | ||
67 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 华安车险订单信息 | ||
7 | + * Class turnPrize | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/9/21 | ||
10 | + * Time: 16:33 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class TurnPrizePrize extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table = "sos_prize_turn_prize"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + /** | ||
19 | + * 函数功能描述 根据条件获取奖品列表 | ||
20 | + * Date: 2020/9/21 | ||
21 | + * Time: 16:40 | ||
22 | + * @author nyq | ||
23 | + */ | ||
24 | + | ||
25 | + public function getPrize($code,$offset,$rows) | ||
26 | + { | ||
27 | + $user = static::where($code)->limit($offset,$rows)->select(); | ||
28 | + | ||
29 | + return $user; | ||
30 | + } | ||
31 | + | ||
32 | + public function getPrizeList($code){ | ||
33 | + $user = static::where($code)->select(); | ||
34 | + return $user; | ||
35 | + } | ||
36 | + | ||
37 | + public function getPrizePrize($code){ | ||
38 | + | ||
39 | + $user = static::where($code)->find(); | ||
40 | + return $user; | ||
41 | + } | ||
42 | + /** | ||
43 | + * 函数功能描述 添加奖品 | ||
44 | + * Date: 2020/9/25 | ||
45 | + * Time: 15:00 | ||
46 | + * @author nyq | ||
47 | + */ | ||
48 | + public function prizeAdd($data) | ||
49 | + { | ||
50 | + $res = static::insertGetId($data); | ||
51 | + return $res; | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * 函数功能描述 编辑奖品 | ||
56 | + * @param $where | ||
57 | + * @param $data | ||
58 | + * Date: 2020/9/21 | ||
59 | + * Time: 16:47 | ||
60 | + * @author nyq | ||
61 | + */ | ||
62 | + public function prizeUp($where, $data) { | ||
63 | + $res = static::where($where)->update($data); | ||
64 | + return $res; | ||
65 | + } | ||
66 | + | ||
67 | + | ||
68 | + | ||
69 | + | ||
70 | + | ||
71 | + | ||
72 | + | ||
73 | + | ||
74 | + | ||
75 | + | ||
76 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 华安车险订单信息 | ||
7 | + * Class turnPrize | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/9/21 | ||
10 | + * Time: 16:33 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class TurnPrizeRule extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table = "sos_prize_turn_rule"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + /** | ||
19 | + * 函数功能描述 查询抽奖规则 | ||
20 | + * Date: 2020/9/25 | ||
21 | + * Time: 16:40 | ||
22 | + * @author nyq | ||
23 | + */ | ||
24 | + | ||
25 | + public function getPrizeRule() | ||
26 | + { | ||
27 | + $user = static::find(); | ||
28 | + return $user; | ||
29 | + } | ||
30 | + | ||
31 | + /** | ||
32 | + * 函数功能描述 添加规则 | ||
33 | + * Date: 2020/9/25 | ||
34 | + * Time: 16:40 | ||
35 | + * @author nyq | ||
36 | + */ | ||
37 | + | ||
38 | + public function prizeRullAdd($data) | ||
39 | + { | ||
40 | + $res = static::insertGetId($data); | ||
41 | + return $res; | ||
42 | + } | ||
43 | + | ||
44 | + | ||
45 | + /** | ||
46 | + * 函数功能描述 编辑规则 | ||
47 | + * @param $where | ||
48 | + * @param $data | ||
49 | + * Date: 2020/9/26 | ||
50 | + * Time: 16:47 | ||
51 | + * @author nyq | ||
52 | + */ | ||
53 | + public function prizeRullEdit($where, $data) { | ||
54 | + $res = static::where($where)->update($data); | ||
55 | + return $res; | ||
56 | + } | ||
57 | + | ||
58 | + | ||
59 | + | ||
60 | + | ||
61 | + | ||
62 | +} |
1 | +<?php | ||
2 | +namespace app\common\model\serviceapi; | ||
3 | +use app\common\model\ServiceApi; | ||
4 | + | ||
5 | +/** | ||
6 | + * 功能描述 华安车险订单信息 | ||
7 | + * Class turnPrize | ||
8 | + * @package app\common\model\commapi | ||
9 | + * Date: 2020/9/21 | ||
10 | + * Time: 16:33 | ||
11 | + * @author nyq | ||
12 | + */ | ||
13 | +class TurnPrizeWin extends ServiceApi | ||
14 | +{ | ||
15 | + protected $table = "sos_prize_turn_win"; | ||
16 | + protected $pk = "id"; | ||
17 | + | ||
18 | + /** | ||
19 | + * 函数功能描述 获取中奖列表 | ||
20 | + * Date: 2020/9/25 | ||
21 | + * Time: 16:40 | ||
22 | + * @author nyq | ||
23 | + */ | ||
24 | + | ||
25 | + public function getPrizeWin($code,$offset,$rows) | ||
26 | + { | ||
27 | + | ||
28 | + $user = static::field('*,count(*) as num')->where($code)->limit($offset,$rows)->group('member_id')->order('addTime desc')->select(); | ||
29 | + // return $this->getLastSql(); | ||
30 | + return $user; | ||
31 | + } | ||
32 | + /** | ||
33 | + * 函数功能描述 导出数据 | ||
34 | + * Date: 2020/9/28 | ||
35 | + * Time: 16:40 | ||
36 | + * @author nyq | ||
37 | + */ | ||
38 | + | ||
39 | + public function getPrizeWinToExcel($code) | ||
40 | + { | ||
41 | + $user = static::where($code)->select(); | ||
42 | + return $user; | ||
43 | + } | ||
44 | + | ||
45 | + /** | ||
46 | + * 函数功能描述 统计数量 | ||
47 | + * Date: 2020/9/25 | ||
48 | + * Time: 16:40 | ||
49 | + * @author nyq | ||
50 | + */ | ||
51 | + | ||
52 | + public function getPrizeWinCount($code) | ||
53 | + { | ||
54 | + $user = static::where($code)->count(); | ||
55 | + return $user; | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * 函数功能描述 添加奖品 | ||
60 | + * Date: 2020/9/25 | ||
61 | + * Time: 16:40 | ||
62 | + * @author nyq | ||
63 | + */ | ||
64 | + | ||
65 | + public function prizeAdd($data) | ||
66 | + { | ||
67 | + $res = static::insertGetId($data); | ||
68 | + return $res; | ||
69 | + } | ||
70 | + | ||
71 | + /** | ||
72 | + * 函数功能描述 获取中奖列表 20 条 | ||
73 | + * Date: 2020/9/25 | ||
74 | + * Time: 16:40 | ||
75 | + * @author nyq | ||
76 | + */ | ||
77 | + | ||
78 | + public function getPrizeWinlist($where) | ||
79 | + { | ||
80 | + if (isset($where) && !empty($where)) { | ||
81 | + $user = static::where($where)->order('addTime desc' )->select(); | ||
82 | + }else{ | ||
83 | + $user = static::where('is_del !=1')->limit(20)->order('id asc' )->select(); | ||
84 | + } | ||
85 | + return $user; | ||
86 | + } | ||
87 | + /** | ||
88 | + * 函数功能描述 兑奖接口 | ||
89 | + * @param $where | ||
90 | + * @param $data | ||
91 | + * Date: 2020/9/26 | ||
92 | + * Time: 16:47 | ||
93 | + * @author nyq | ||
94 | + */ | ||
95 | + | ||
96 | + public function winReset($wheres,$data) { | ||
97 | + $res = static::where($wheres)->update($data); | ||
98 | + return $res; | ||
99 | + } | ||
100 | + /** | ||
101 | + * 函数功能描述 删除抽奖记录 | ||
102 | + * @param $where | ||
103 | + * @param $data | ||
104 | + * Date: 2020/9/26 | ||
105 | + * Time: 16:47 | ||
106 | + * @author nyq | ||
107 | + */ | ||
108 | + | ||
109 | + public function delUser($wheres) { | ||
110 | + $res = static::where($wheres)->delete(); | ||
111 | + return $res; | ||
112 | + } | ||
113 | + | ||
114 | + | ||
115 | +} |
application/common/service/Render.php
0 → 100644
1 | +<?php | ||
2 | +namespace app\common\service; | ||
3 | + | ||
4 | +use app\common\exception\BaseException; | ||
5 | + | ||
6 | +trait Render | ||
7 | +{ | ||
8 | + /** | ||
9 | + * 输出错误信息 | ||
10 | + * @param int $code | ||
11 | + * @param $msg | ||
12 | + * @throws BaseException | ||
13 | + */ | ||
14 | + protected function throwError($msg, $code = 0) | ||
15 | + { | ||
16 | + throw new BaseException(['code' => $code, 'msg' => $msg]); | ||
17 | + } | ||
18 | + | ||
19 | + /** | ||
20 | + * 返回封装后的 API 数据 | ||
21 | + * @param int $code | ||
22 | + * @param string $msg | ||
23 | + * @param array $data | ||
24 | + * @return array | ||
25 | + */ | ||
26 | + protected function renderJson($code = 0, $msg = '', $data = []) | ||
27 | + { | ||
28 | + return compact('code', 'msg', 'data'); | ||
29 | + } | ||
30 | + | ||
31 | + /** | ||
32 | + * 返回成功json | ||
33 | + * @param array $data | ||
34 | + * @param string|array $msg | ||
35 | + * @return array | ||
36 | + */ | ||
37 | + protected function renderSuccess($data = [], $msg = 'success', $code = 0) | ||
38 | + { | ||
39 | + return $this->renderJson($code, $msg, $data); | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * 返回操作失败json | ||
44 | + * @param string $msg | ||
45 | + * @param array $data | ||
46 | + * @return array | ||
47 | + */ | ||
48 | + protected function renderError($msg = 'error', $code = 1, $data = []) | ||
49 | + { | ||
50 | + return $this->renderJson($code, $msg, $data); | ||
51 | + } | ||
52 | +} | ||
53 | + |
application/common/validate/BaseValidate.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Administrator | ||
5 | + * Date: 2020/6/28 | ||
6 | + * Time: 18:22 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace app\common\validate; | ||
10 | + | ||
11 | + | ||
12 | +use think\Validate; | ||
13 | + | ||
14 | +class BaseValidate extends Validate | ||
15 | +{ | ||
16 | + /** | ||
17 | + * 验证手机号是否正确 | ||
18 | + * @param $value | ||
19 | + * @param $rule | ||
20 | + * @param $data | ||
21 | + */ | ||
22 | + protected function checkPhone($value, $rule, $data) | ||
23 | + { | ||
24 | + return preg_match("/^1[3456789]\d{9}$/", $value) ? true : "手机号不正确"; | ||
25 | + } | ||
26 | + | ||
27 | +} |
application/config.php
0 → 100644
1 | +<?php | ||
2 | +// +---------------------------------------------------------------------- | ||
3 | +// | ThinkPHP [ WE CAN DO IT JUST THINK ] | ||
4 | +// +---------------------------------------------------------------------- | ||
5 | +// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved. | ||
6 | +// +---------------------------------------------------------------------- | ||
7 | +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) | ||
8 | +// +---------------------------------------------------------------------- | ||
9 | +// | Author: liu21st <liu21st@gmail.com> | ||
10 | +// +---------------------------------------------------------------------- | ||
11 | + | ||
12 | +return [ | ||
13 | + // +---------------------------------------------------------------------- | ||
14 | + // | 应用设置 | ||
15 | + // +---------------------------------------------------------------------- | ||
16 | + | ||
17 | + // 应用调试模式 | ||
18 | + 'app_debug' => true, | ||
19 | + // 应用Trace | ||
20 | + 'app_trace' => false, | ||
21 | + // 应用模式状态 | ||
22 | + 'app_status' => '', | ||
23 | + // 是否支持多模块 | ||
24 | + 'app_multi_module' => true, | ||
25 | + // 入口自动绑定模块 | ||
26 | + 'auto_bind_module' => false, | ||
27 | + // 注册的根命名空间 | ||
28 | + 'root_namespace' => [], | ||
29 | + // 扩展函数文件 | ||
30 | + 'extra_file_list' => [THINK_PATH . 'helper' . EXT], | ||
31 | + // 默认输出类型 | ||
32 | + 'default_return_type' => 'json', | ||
33 | + // 默认AJAX 数据返回格式,可选json xml ... | ||
34 | + 'default_ajax_return' => 'json', | ||
35 | + // 默认JSONP格式返回的处理方法 | ||
36 | + 'default_jsonp_handler' => 'jsonpReturn', | ||
37 | + // 默认JSONP处理方法 | ||
38 | + 'var_jsonp_handler' => 'callback', | ||
39 | + // 默认时区 | ||
40 | + 'default_timezone' => 'PRC', | ||
41 | + // 是否开启多语言 | ||
42 | + 'lang_switch_on' => false, | ||
43 | + // 默认全局过滤方法 用逗号分隔多个 | ||
44 | + 'default_filter' => 'htmlspecialchars', | ||
45 | + // 默认语言 | ||
46 | + 'default_lang' => 'zh-cn', | ||
47 | + // 应用类库后缀 | ||
48 | + 'class_suffix' => false, | ||
49 | + // 控制器类后缀 | ||
50 | + 'controller_suffix' => false, | ||
51 | + | ||
52 | + // +---------------------------------------------------------------------- | ||
53 | + // | 模块设置 | ||
54 | + // +---------------------------------------------------------------------- | ||
55 | + | ||
56 | + // 默认模块名 | ||
57 | + 'default_module' => 'web', | ||
58 | + // 禁止访问模块 | ||
59 | + 'deny_module_list' => ['common'], | ||
60 | + // 默认控制器名 | ||
61 | + 'default_controller' => 'Index', | ||
62 | + // 默认操作名 | ||
63 | + 'default_action' => 'index', | ||
64 | + // 默认验证器 | ||
65 | + 'default_validate' => '', | ||
66 | + // 默认的空控制器名 | ||
67 | + 'empty_controller' => 'Error', | ||
68 | + // 操作方法后缀 | ||
69 | + 'action_suffix' => '', | ||
70 | + // 自动搜索控制器 | ||
71 | + 'controller_auto_search' => false, | ||
72 | + | ||
73 | + // +---------------------------------------------------------------------- | ||
74 | + // | URL设置 | ||
75 | + // +---------------------------------------------------------------------- | ||
76 | + | ||
77 | + // PATHINFO变量名 用于兼容模式 | ||
78 | + 'var_pathinfo' => 's', | ||
79 | + // 兼容PATH_INFO获取 | ||
80 | + 'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'], | ||
81 | + // pathinfo分隔符 | ||
82 | + 'pathinfo_depr' => '/', | ||
83 | + // URL伪静态后缀 | ||
84 | + 'url_html_suffix' => '', | ||
85 | + // URL普通方式参数 用于自动生成 | ||
86 | + 'url_common_param' => false, | ||
87 | + // URL参数方式 0 按名称成对解析 1 按顺序解析 | ||
88 | + 'url_param_type' => 0, | ||
89 | + // 是否开启路由 | ||
90 | + 'url_route_on' => true, | ||
91 | + // 路由使用完整匹配 | ||
92 | + 'route_complete_match' => false, | ||
93 | + // 路由配置文件(支持配置多个) | ||
94 | + 'route_config_file' => ['route'], | ||
95 | + // 是否开启路由解析缓存 | ||
96 | + 'route_check_cache' => false, | ||
97 | + // 是否强制使用路由 | ||
98 | + 'url_route_must' => false, | ||
99 | + // 域名部署 | ||
100 | + 'url_domain_deploy' => false, | ||
101 | + // 域名根,如thinkphp.cn | ||
102 | + 'url_domain_root' => '', | ||
103 | + // 是否自动转换URL中的控制器和操作名 | ||
104 | + 'url_convert' => true, | ||
105 | + // 默认的访问控制器层 | ||
106 | + 'url_controller_layer' => 'controller', | ||
107 | + // 表单请求类型伪装变量 | ||
108 | + 'var_method' => '_method', | ||
109 | + // 表单ajax伪装变量 | ||
110 | + 'var_ajax' => '_ajax', | ||
111 | + // 表单pjax伪装变量 | ||
112 | + 'var_pjax' => '_pjax', | ||
113 | + // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则 | ||
114 | + 'request_cache' => false, | ||
115 | + // 请求缓存有效期 | ||
116 | + 'request_cache_expire' => null, | ||
117 | + // 全局请求缓存排除规则 | ||
118 | + 'request_cache_except' => [], | ||
119 | + | ||
120 | + // +---------------------------------------------------------------------- | ||
121 | + // | 模板设置 | ||
122 | + // +---------------------------------------------------------------------- | ||
123 | + | ||
124 | + 'template' => [ | ||
125 | + // 模板引擎类型 支持 php think 支持扩展 | ||
126 | + 'type' => 'Think', | ||
127 | + // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 | ||
128 | + 'auto_rule' => 1, | ||
129 | + // 模板路径 | ||
130 | + 'view_path' => '', | ||
131 | + // 模板后缀 | ||
132 | + 'view_suffix' => 'html', | ||
133 | + // 模板文件名分隔符 | ||
134 | + 'view_depr' => DS, | ||
135 | + // 模板引擎普通标签开始标记 | ||
136 | + 'tpl_begin' => '{', | ||
137 | + // 模板引擎普通标签结束标记 | ||
138 | + 'tpl_end' => '}', | ||
139 | + // 标签库标签开始标记 | ||
140 | + 'taglib_begin' => '{', | ||
141 | + // 标签库标签结束标记 | ||
142 | + 'taglib_end' => '}', | ||
143 | + ], | ||
144 | + | ||
145 | + // 视图输出字符串内容替换 | ||
146 | + 'view_replace_str' => [], | ||
147 | + // 默认跳转页面对应的模板文件 | ||
148 | + 'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', | ||
149 | + 'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', | ||
150 | + | ||
151 | + // +---------------------------------------------------------------------- | ||
152 | + // | 异常及错误设置 | ||
153 | + // +---------------------------------------------------------------------- | ||
154 | + | ||
155 | + // 异常页面的模板文件 | ||
156 | + 'exception_tmpl' => THINK_PATH . 'tpl' . DS . 'think_exception.tpl', | ||
157 | + | ||
158 | + // 错误显示信息,非调试模式有效 | ||
159 | + 'error_message' => '页面错误!请稍后再试~', | ||
160 | + // 显示错误信息 | ||
161 | + 'show_error_msg' => false, | ||
162 | + // 异常处理handle类 留空使用 \think\exception\Handle | ||
163 | + 'exception_handle' => '\\app\\common\\exception\\ExceptionHandler', | ||
164 | + | ||
165 | + // +---------------------------------------------------------------------- | ||
166 | + // | 日志设置 | ||
167 | + // +---------------------------------------------------------------------- | ||
168 | + | ||
169 | + 'log' => [ | ||
170 | + // 日志记录方式,内置 file socket 支持扩展 | ||
171 | + 'type' => 'File', | ||
172 | + // 日志保存目录 | ||
173 | + 'path' => LOG_PATH, | ||
174 | + // 日志记录级别 | ||
175 | + 'level' => [], | ||
176 | + // error和sql日志单独记录 | ||
177 | + 'apart_level' => ['begin', 'error', 'sql', 'info'], | ||
178 | + ], | ||
179 | + | ||
180 | + // +---------------------------------------------------------------------- | ||
181 | + // | Trace设置 开启 app_trace 后 有效 | ||
182 | + // +---------------------------------------------------------------------- | ||
183 | + 'trace' => [ | ||
184 | + // 内置Html Console 支持扩展 | ||
185 | + 'type' => 'Html', | ||
186 | + ], | ||
187 | + | ||
188 | + // +---------------------------------------------------------------------- | ||
189 | + // | 缓存设置 | ||
190 | + // +---------------------------------------------------------------------- | ||
191 | + | ||
192 | + 'cache' => [ | ||
193 | + // 使用复合缓存类型 | ||
194 | + 'type' => 'complex', | ||
195 | + 'default' => [ | ||
196 | + // 驱动方式 | ||
197 | + 'type' => 'File', | ||
198 | + // 缓存保存目录 | ||
199 | + 'path' => CACHE_PATH, | ||
200 | + // 缓存前缀 | ||
201 | + 'prefix' => '', | ||
202 | + // 缓存有效期 0表示永久缓存 | ||
203 | + 'expire' => 0, | ||
204 | + ], | ||
205 | + 'file' => [ | ||
206 | + // 驱动方式 | ||
207 | + 'type' => 'File', | ||
208 | + // 缓存保存目录 | ||
209 | + 'path' => RUNTIME_PATH . 'file/', | ||
210 | + // 缓存前缀 | ||
211 | + 'prefix' => '', | ||
212 | + // 缓存有效期 0表示永久缓存 | ||
213 | + 'expire' => 0, | ||
214 | + ], | ||
215 | + // redis缓存 | ||
216 | + 'redis' => [ | ||
217 | + // 驱动方式 | ||
218 | + 'type' => 'redis', | ||
219 | + // 缓存前缀 | ||
220 | + 'prefix' => '', | ||
221 | + // 缓存有效期 0表示永久缓存 | ||
222 | + 'expire' => 0, | ||
223 | + // 服务器地址 | ||
224 | + 'host' => '127.0.0.1', | ||
225 | + ], | ||
226 | + | ||
227 | + ], | ||
228 | + | ||
229 | + // +---------------------------------------------------------------------- | ||
230 | + // | 会话设置 | ||
231 | + // +---------------------------------------------------------------------- | ||
232 | + | ||
233 | + 'session' => [ | ||
234 | + 'id' => '', | ||
235 | + // SESSION_ID的提交变量,解决flash上传跨域 | ||
236 | + 'var_session_id' => '', | ||
237 | + // SESSION 前缀 | ||
238 | + 'prefix' => 'api', | ||
239 | + // 驱动方式 支持redis memcache memcached | ||
240 | + 'type' => '', | ||
241 | + // 是否自动开启 SESSION | ||
242 | + 'auto_start' => true, | ||
243 | + ], | ||
244 | + | ||
245 | + // +---------------------------------------------------------------------- | ||
246 | + // | Cookie设置 | ||
247 | + // +---------------------------------------------------------------------- | ||
248 | + 'cookie' => [ | ||
249 | + // cookie 名称前缀 | ||
250 | + 'prefix' => '', | ||
251 | + // cookie 保存时间 | ||
252 | + 'expire' => 0, | ||
253 | + // cookie 保存路径 | ||
254 | + 'path' => '/', | ||
255 | + // cookie 有效域名 | ||
256 | + 'domain' => '', | ||
257 | + // cookie 启用安全传输 | ||
258 | + 'secure' => false, | ||
259 | + // httponly设置 | ||
260 | + 'httponly' => '', | ||
261 | + // 是否使用 setcookie | ||
262 | + 'setcookie' => true, | ||
263 | + ], | ||
264 | + | ||
265 | + //分页配置 | ||
266 | + 'paginate' => [ | ||
267 | + 'type' => 'bootstrap', | ||
268 | + 'var_page' => 'page', | ||
269 | + 'list_rows' => 15, | ||
270 | + ], | ||
271 | +]; |
application/database.php
0 → 100644
1 | +<?php | ||
2 | +// +---------------------------------------------------------------------- | ||
3 | +// | ThinkPHP [ WE CAN DO IT JUST THINK ] | ||
4 | +// +---------------------------------------------------------------------- | ||
5 | +// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved. | ||
6 | +// +---------------------------------------------------------------------- | ||
7 | +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) | ||
8 | +// +---------------------------------------------------------------------- | ||
9 | +// | Author: liu21st <liu21st@gmail.com> | ||
10 | +// +---------------------------------------------------------------------- | ||
11 | + | ||
12 | +return [ | ||
13 | + // 数据库类型 | ||
14 | + 'type' => 'mysql', | ||
15 | + // 服务器地址 | ||
16 | + 'hostname' => '49.232.59.136', | ||
17 | + // 数据库名 | ||
18 | + 'database' => 'prize', | ||
19 | + // 用户名 | ||
20 | + 'username' => 'prize', | ||
21 | + // 密码 | ||
22 | + 'password' => 'wfKsEGRtm2NPwWXs', | ||
23 | + // 端口 | ||
24 | + 'hostport' => '3306', | ||
25 | + // 连接dsn | ||
26 | + 'dsn' => '', | ||
27 | + // 数据库连接参数 | ||
28 | + 'params' => [], | ||
29 | + // 数据库编码默认采用utf8 | ||
30 | + 'charset' => 'utf8', | ||
31 | + // 数据库表前缀 | ||
32 | + 'prefix' => 'sos_', | ||
33 | + // 数据库调试模式 | ||
34 | + 'debug' => true, | ||
35 | + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) | ||
36 | + 'deploy' => 0, | ||
37 | + // 数据库读写是否分离 主从式有效 | ||
38 | + 'rw_separate' => false, | ||
39 | + // 读写分离后 主服务器数量 | ||
40 | + 'master_num' => 1, | ||
41 | + // 指定从服务器序号 | ||
42 | + 'slave_no' => '', | ||
43 | + // 自动读取主库数据 | ||
44 | + 'read_master' => false, | ||
45 | + // 是否严格检查字段是否存在 | ||
46 | + 'fields_strict' => true, | ||
47 | + // 数据集返回类型 | ||
48 | + 'resultset_type' => 'collection', | ||
49 | + // 自动写入时间戳字段 | ||
50 | + 'auto_timestamp' => true, | ||
51 | + // 时间字段取出后的默认时间格式 | ||
52 | + 'datetime_format' => 'Y-m-d H:i:s', | ||
53 | + // 是否需要进行SQL性能分析 | ||
54 | + 'sql_explain' => false, | ||
55 | +]; |
application/products/config.php
0 → 100644
application/products/controller/Car.php
0 → 100644
1 | +<?php | ||
2 | +namespace app\products\controller; | ||
3 | + | ||
4 | +use app\products\validate\Car as CarValidate; | ||
5 | +use app\web\controller\BaseController; | ||
6 | +use think\Log; | ||
7 | +use think\Request; | ||
8 | +use util\MCurl; | ||
9 | +header("Content-type: text/html; charset=utf-8"); | ||
10 | +/** | ||
11 | + * 功能描述 华安车险 | ||
12 | + * Class Car | ||
13 | + * @package app\products\controller | ||
14 | + * Date: 2020/8/3 | ||
15 | + * Time: 17:00 | ||
16 | + * @author nyq | ||
17 | + */ | ||
18 | +class Car extends BaseController | ||
19 | +{ | ||
20 | + //请求地址 | ||
21 | + //private $api_url = "https://api.sosyun.com//serviceapi/car/"; | ||
22 | + //private $api_url = "http://demo8.xiaochakeji.com/serviceapi/car/"; | ||
23 | + private $api_url = "www.aisigit.com/products/car/"; | ||
24 | + //回调查询接口 | ||
25 | + private $api_back_url = "http://demo8.xiaochakeji.com/notify/car/"; | ||
26 | + //private $api_back_url = "https://api.sosyun.com//notify/car/"; | ||
27 | + | ||
28 | + /** | ||
29 | + * 函数功能描述 获取订单信息 | ||
30 | + * Date: 2020/8/07 | ||
31 | + * Time: 10:00 | ||
32 | + * @author nyq | ||
33 | + */ | ||
34 | + public function carOrder(Request $request) | ||
35 | + { | ||
36 | + $data = $request->param(); | ||
37 | + $page = isset($_POST['page']) ? intval($_POST['page']) : 1; | ||
38 | + $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; | ||
39 | + $offset=($page-1)*$rows; | ||
40 | + $data['id']=2; | ||
41 | + $data['offset']=$offset; | ||
42 | + $data['rows']=$rows; | ||
43 | + | ||
44 | + $res = MCurl::instance($this->api_url."carOrder")->post($data); | ||
45 | + $json=json_decode($res); | ||
46 | + | ||
47 | + $result["total"] =count($json); | ||
48 | + $result['rows']=$json; | ||
49 | + echo json_encode($result); | ||
50 | + //return $json; | ||
51 | + } | ||
52 | + /** | ||
53 | + * 函数功能描述 获取订单详情 | ||
54 | + * Date: 2020/8/07 | ||
55 | + * Time: 10:00 | ||
56 | + * @author nyq | ||
57 | + */ | ||
58 | + public function carOrderDetail(Request $request) | ||
59 | + { | ||
60 | + $data = $request->param(); | ||
61 | + $id['id']=$data['id']; | ||
62 | + $res = MCurl::instance($this->api_url."carOrderDetail")->post($id); | ||
63 | + $res = json_decode($res, true); | ||
64 | + | ||
65 | + $use_res = MCurl::instance($this->api_url."selMember")->post($id); | ||
66 | + $use_res = json_decode($use_res, true); | ||
67 | + | ||
68 | + $status_arr = ['转人工核保','','','打回修改','拒保','','','待支付','支付成功','支付失败']; | ||
69 | + foreach($res as $k => $v){ | ||
70 | + if($v['riskCode']=='0302'){ | ||
71 | + $res[$k]['type']='商业险'; | ||
72 | + }elseif($v['riskCode']=='0301'){ | ||
73 | + $res[$k]['type']='交强险'; | ||
74 | + } | ||
75 | + $res[$k]['appName']=$use_res['appName']; | ||
76 | + $res[$k]['insuredName']=$use_res['insuredName']; | ||
77 | + $res[$k]['status_arr'] = $status_arr[$v['status']]; | ||
78 | + $res[$k]['operDate'] =date("Y-m-d H:i:s",$v['operDate']); | ||
79 | + } | ||
80 | + return $res; | ||
81 | + } | ||
82 | + /** | ||
83 | + * 函数功能描述 搜索 | ||
84 | + * Date: 2020/8/07 | ||
85 | + * Time: 10:00 | ||
86 | + * @author nyq | ||
87 | + */ | ||
88 | + public function select(Request $request) | ||
89 | + { | ||
90 | + $data = $request->param(); | ||
91 | + | ||
92 | + $page = isset($_POST['page']) ? intval($_POST['page']) : 1; | ||
93 | + $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; | ||
94 | + $offset=($page-1)*$rows; | ||
95 | + $data['id']=2; | ||
96 | + $data['offset']=$offset; | ||
97 | + $data['rows']=$rows; | ||
98 | + | ||
99 | + $res = MCurl::instance($this->api_url."carOrder")->post($data); | ||
100 | + $json=json_decode($res); | ||
101 | + | ||
102 | + $result["total"] =count($json); | ||
103 | + $result['rows']=$json; | ||
104 | + echo json_encode($result); | ||
105 | + } | ||
106 | + | ||
107 | + /** | ||
108 | + * 函数功能描述 支付申请 | ||
109 | + * Date: 2020/8/11 | ||
110 | + * Time: 10:00 | ||
111 | + * @author nyq | ||
112 | + */ | ||
113 | + public function pay(Request $request) | ||
114 | + { | ||
115 | + $data = $request->param(); | ||
116 | + //查询订单信息及金额 | ||
117 | + $order_res = MCurl::instance($this->api_url."pay")->post($data); | ||
118 | + $use_res = MCurl::instance($this->api_url."selMember")->post($data); | ||
119 | + $order_json=json_decode($order_res,true); | ||
120 | + $use_json=json_decode($use_res,true); | ||
121 | + | ||
122 | + $json['jqAppNo']=$order_json[0]['appNo']; | ||
123 | + $json['jqAmount']=$order_json[0]['premium']+$order_json[0]['currentTax']; | ||
124 | + $json['jqAppName']=$use_json['appName']; | ||
125 | + $json['syAppNo']=$order_json[1]['appNo']; | ||
126 | + $json['syAmount']=$order_json[1]['premium']; | ||
127 | + $json['syAppName']=$use_json['appName']; | ||
128 | + $arr['data']=json_encode($json); | ||
129 | + $res = MCurl::instance($this->api_url."launchPayment")->post($arr); | ||
130 | + | ||
131 | + $res=json_decode($res, true); | ||
132 | + | ||
133 | + return $res; | ||
134 | + | ||
135 | + } | ||
136 | + | ||
137 | + | ||
138 | + /** | ||
139 | + * 函数功能描述 获取车型 | ||
140 | + * Date: 2020/8/03 | ||
141 | + * Time: 17:10 | ||
142 | + * @author nyq | ||
143 | + */ | ||
144 | + public function carmodel(Request $request) | ||
145 | + { | ||
146 | + $data = $request->param(); | ||
147 | + $validtaor = new CarValidate(); | ||
148 | + $res = $validtaor->scene("carmodel")->check($data); | ||
149 | + if ($res === false) { | ||
150 | + return ['errcode' => 100, 'errmsg' => $validtaor->getError()]; | ||
151 | + } | ||
152 | + if (in_array("undefined", $data)) { | ||
153 | + return ["errcode" => 100, "errmsg" => "提交数据存在问题"]; | ||
154 | + } | ||
155 | + | ||
156 | + $res = MCurl::instance($this->api_url."carmodel")->post($data); | ||
157 | + $res = json_decode($res, true); | ||
158 | + | ||
159 | + return $res; | ||
160 | + } | ||
161 | + | ||
162 | + | ||
163 | + /** | ||
164 | + * 函数功能描述 车险保费计算 | ||
165 | + * Date: 2020/8/4 | ||
166 | + * Time: 09:12 | ||
167 | + * @author nyq | ||
168 | + */ | ||
169 | + public function premium(Request $request) | ||
170 | + { | ||
171 | + | ||
172 | + $json = $request->param(); // 报错 Array to string conversion | ||
173 | + $data = $request->param('data'); | ||
174 | + | ||
175 | + //数据特殊符号转义 | ||
176 | + $data = htmlspecialchars_decode($data); | ||
177 | + $data = json_decode($data, true); | ||
178 | + //处理校验数据 | ||
179 | + $arr=$this->premiumArray($data); | ||
180 | + $validtaor = new CarValidate(); | ||
181 | + $res = $validtaor->scene("premium")->check($arr); | ||
182 | + if ($res === false) { | ||
183 | + return ['errcode' => 100, 'errmsg' => $validtaor->getError()]; | ||
184 | + } | ||
185 | + if (in_array("undefined", $arr)) { | ||
186 | + return ["errcode" => 100, "errmsg" => "提交数据存在问题"]; | ||
187 | + } | ||
188 | + | ||
189 | + $res = MCurl::instance($this->api_url."premium")->post($json); | ||
190 | + $res = json_decode($res, true); | ||
191 | + | ||
192 | + return $res; | ||
193 | + } | ||
194 | + /** | ||
195 | + * 函数功能描述 车险提交核保 | ||
196 | + * Date: 2020/8/03 | ||
197 | + * Time: 15:10 | ||
198 | + * @author nyq | ||
199 | + */ | ||
200 | + | ||
201 | + public function underwrite() | ||
202 | + { | ||
203 | + $json = $this->request->post(); | ||
204 | + $base = $this->request->post('data'); | ||
205 | + | ||
206 | + $base = htmlspecialchars_decode($base); | ||
207 | + $base = json_decode($base, true); | ||
208 | + | ||
209 | + //进行数据校验 | ||
210 | + $validtaor = new CarValidate(); | ||
211 | + $res = $validtaor->scene("underwrite")->check($base); | ||
212 | + if ($res === false) { | ||
213 | + return ['errcode' => 100, 'errmsg' => $validtaor->getError()]; | ||
214 | + } | ||
215 | + | ||
216 | + $res = MCurl::instance($this->api_url."underwrite")->post($json); | ||
217 | + $res=json_decode($res, true); | ||
218 | + return $res; | ||
219 | + } | ||
220 | + | ||
221 | + | ||
222 | + /** | ||
223 | + * 函数功能描述 支付/核保回调接口 | ||
224 | + * Date: 2020/8/4 | ||
225 | + * Time: 17:00 | ||
226 | + * @author nyq | ||
227 | + */ | ||
228 | + public function get_status() | ||
229 | + { | ||
230 | + $base = $this->request->post(); | ||
231 | + $res = MCurl::instance($this->api_back_url."get_status")->post($base); | ||
232 | + $res=json_decode($res, true); | ||
233 | + return $res; | ||
234 | + } | ||
235 | + | ||
236 | + /** | ||
237 | + * 函数功能描述 支付申请接口 | ||
238 | + * Date: 2020/8/4 | ||
239 | + * Time: 16:30 | ||
240 | + * @author nyq | ||
241 | + */ | ||
242 | + public function payment() | ||
243 | + { | ||
244 | + $json = $this->request->post(); | ||
245 | + $base = $this->request->post('data'); | ||
246 | + $base = htmlspecialchars_decode($base); | ||
247 | + $base=json_decode($base, true); | ||
248 | + | ||
249 | + //进行数据校验 | ||
250 | + $validator = new CarValidate(); | ||
251 | + $res = $validator->scene("pay")->check($base); | ||
252 | + if ($res === false) { | ||
253 | + return ['errcode' => 100, 'errmsg' => $validator->getError()]; | ||
254 | + } | ||
255 | + | ||
256 | + $res = MCurl::instance($this->api_url."payment")->post($json); | ||
257 | + $res=json_decode($res, true); | ||
258 | + return $res; | ||
259 | + } | ||
260 | + | ||
261 | + | ||
262 | + /** | ||
263 | + * 函数功能描述 整理车险检验信息 | ||
264 | + * Date: 2020/7/21 | ||
265 | + * Time: 11:12 | ||
266 | + * @author nyq | ||
267 | + */ | ||
268 | + public function premiumArray($arr){ | ||
269 | + | ||
270 | + //车主信息 | ||
271 | + $owner=$arr['owner']; | ||
272 | + //投保人 | ||
273 | + $applacation=$arr['applacation']; | ||
274 | + //被保人 | ||
275 | + $insured=$arr['insured']; | ||
276 | + //车辆信息 | ||
277 | + $vhl=$arr['vhl']; | ||
278 | + //base | ||
279 | + //$base=$arr['base']; | ||
280 | + $data=array_merge($owner,$applacation,$insured,$vhl); | ||
281 | + //险种信息 | ||
282 | + if(count($arr['riskList'])>1){ | ||
283 | + if($arr['riskList'][0]['riskCode'] != '' && $arr['riskList'][1]['riskCode'] != ''){ | ||
284 | + $data['xz']='true'; | ||
285 | + }else{ | ||
286 | + $data['xz']=''; | ||
287 | + } | ||
288 | + }else{ | ||
289 | + $data['xz']=''; | ||
290 | + } | ||
291 | + $data['cityCode']=$arr['cityCode']; | ||
292 | + $data['modelName']=$arr['modelName']; | ||
293 | + $data['email']=$arr['email']; | ||
294 | + return $data; | ||
295 | + } | ||
296 | + | ||
297 | + | ||
298 | + | ||
299 | + | ||
300 | + | ||
301 | +} |
1 | +<?php | ||
2 | + | ||
3 | + | ||
4 | +namespace app\products\controller; | ||
5 | + | ||
6 | + | ||
7 | +use app\common\controller\ProductsController; | ||
8 | + | ||
9 | +/** | ||
10 | + * 功能描述 换取access_token | ||
11 | + * Class Controller | ||
12 | + * @package app\products\controller | ||
13 | + * Date: 2020/7/14 | ||
14 | + * Time: 16:06 | ||
15 | + * @author gxd | ||
16 | + */ | ||
17 | +class Controller extends ProductsController | ||
18 | +{ | ||
19 | + | ||
20 | + protected $appid = ""; | ||
21 | + protected $appsecret = ""; | ||
22 | + | ||
23 | + public function _initialize() | ||
24 | + { | ||
25 | + parent::_initialize(); // TODO: Change the autogenerated stub | ||
26 | + $this->appid = config("appid"); | ||
27 | + $this->appsecret = config("appsecret"); | ||
28 | + $this->allOrigin(); | ||
29 | + } | ||
30 | + | ||
31 | + public function allOrigin() { | ||
32 | + header('Content-Type: text/html;charset=utf-8'); | ||
33 | + header('Access-Control-Allow-Origin:*'); // *代表允许任何网址请求 | ||
34 | + header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE'); // 允许请求的类型 | ||
35 | + header('Access-Control-Allow-Credentials: true'); // 设置是否允许发送 cookies | ||
36 | + header('Access-Control-Allow-Headers: Content-Type,Content-Length,Accept-Encoding,X-Requested-with, Origin'); | ||
37 | + } | ||
38 | + | ||
39 | +} |
application/products/controller/FuJiTong.php
0 → 100644
1 | +<?php | ||
2 | +namespace app\products\controller; | ||
3 | + | ||
4 | + | ||
5 | + | ||
6 | +use app\common\model\serviceapi\Product as ProductModel; | ||
7 | +use app\common\model\serviceapi\ProductUser as ProductUserModel; | ||
8 | +use app\common\model\serviceapi\ProductOrder as ProductOrderModel; | ||
9 | + | ||
10 | + | ||
11 | +use app\web\controller\BaseController; | ||
12 | +use think\Log; | ||
13 | +use think\Request; | ||
14 | +use util\MCurl; | ||
15 | +use think\Cookie; | ||
16 | +use think\Session; | ||
17 | +header("Content-type: text/html; charset=utf-8"); | ||
18 | +header('Access-Control-Allow-Origin:*'); | ||
19 | +header('Content-Type: application/json; charset=utf-8'); | ||
20 | +header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS'); | ||
21 | +header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); | ||
22 | +/** | ||
23 | + * 功能描述 妇记通获客 | ||
24 | + * Class Product | ||
25 | + * @package app\FuJiTong\controller | ||
26 | + * Date: 2021/5/6 | ||
27 | + * Time: 10:00 | ||
28 | + * @author nyq | ||
29 | + */ | ||
30 | +class FuJiTong extends BaseController | ||
31 | +{ | ||
32 | + | ||
33 | + private $api_domain ="www.aisigit.com/products/fu/customer_list"; //测试平台 | ||
34 | + //private $api_domain = "http://hzy.sosyun.com/products/fu/customer_list"; | ||
35 | + | ||
36 | + /** | ||
37 | + * 函数功能描述 获取客户列表 | ||
38 | + * Date: 2021/5/6 | ||
39 | + * Time: 10:00 | ||
40 | + * @author nyq | ||
41 | + */ | ||
42 | + public function customer_list(Request $request) | ||
43 | + { | ||
44 | + $data = $request->param(); | ||
45 | + | ||
46 | + //return json($data); | ||
47 | + | ||
48 | + Cookie::set('fu_data', $data); | ||
49 | + $page = isset($_POST['page']) ? intval($_POST['page']) : 1; | ||
50 | + $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; | ||
51 | + $offset=($page-1)*$rows; | ||
52 | + $data['offset']=$offset; | ||
53 | + $data['rows']=$rows; | ||
54 | + $json=[ | ||
55 | + "offset"=>$offset, | ||
56 | + "rows"=>$rows, | ||
57 | + "result"=>isset($data['result']) && !empty($data['result']) ? $data['result'] : '', | ||
58 | + "type"=>isset($data['new_type']) && !empty($data['new_type']) ? $data['new_type'] : '', | ||
59 | + "start"=>!empty($data['start']) ? $data['start'] : '', | ||
60 | + "end"=>!empty($data['end']) ? $data['end'] : '', | ||
61 | + "phone"=>!empty($data['phone']) ? $data['phone'] : '', | ||
62 | + ]; | ||
63 | + // return json($json); | ||
64 | + $data_http = http_build_query($json); | ||
65 | + $row=MCurl::instance($this->api_domain)->post($data_http); | ||
66 | + $data_list=json_decode($row,true); | ||
67 | + $data_json=$data_list['rows']; | ||
68 | + foreach($data_json as $key=>$val ){ | ||
69 | + $data_json[$key]['sex']=$val['sex'] == 1? '女' : '男'; | ||
70 | + } | ||
71 | + $result["total"] =$data_list['total']; | ||
72 | + $result['rows']=$data_json; | ||
73 | + echo json_encode($result); | ||
74 | + //return $json; | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * 函数功能描述 导出数据到表格 | ||
79 | + * Date: 2020/8/26 | ||
80 | + * Time: 10:00 | ||
81 | + * @author nyq | ||
82 | + */ | ||
83 | + public function to_excel() | ||
84 | + { | ||
85 | + $data= Cookie::get('fu_data'); | ||
86 | + $json=[ | ||
87 | + "offset"=>1, | ||
88 | + "rows"=>1, | ||
89 | + "result"=>isset($data['result']) && !empty($data['result']) ? $data['result'] : '', | ||
90 | + "type"=>isset($data['new_type']) && !empty($data['new_type']) ? $data['new_type'] : '', | ||
91 | + "start"=>!empty($data['start']) ? $data['start'] : '', | ||
92 | + "end"=>!empty($data['end']) ? $data['end'] : '', | ||
93 | + "phone"=>!empty($data['phone']) ? $data['phone'] : '', | ||
94 | + 'to_excel'=>1 | ||
95 | + ]; | ||
96 | + | ||
97 | + $data_http = http_build_query($json); | ||
98 | + $row=MCurl::instance($this->api_domain)->post($data_http); | ||
99 | + $data_list=json_decode($row,true); | ||
100 | + | ||
101 | + $data_json=$data_list['rows']; | ||
102 | + foreach($data_json as $key=>$val ){ | ||
103 | + $data_json[$key]['sex']=$val['sex'] == 1? '女' : '男'; | ||
104 | + } | ||
105 | + | ||
106 | + | ||
107 | + ob_end_clean();//清除缓冲区,避免乱码 | ||
108 | + Vendor('PHPExcel.PHPExcel'); | ||
109 | + $objPHPExcel=new \PHPExcel(); | ||
110 | + $objPHPExcel->setActiveSheetIndex(0) | ||
111 | + ->setCellValue('A1', '用户名称') | ||
112 | + ->setCellValue('B1', '性别') | ||
113 | + ->setCellValue('C1', '电话') | ||
114 | + ->setCellValue('D1', '证件号码') | ||
115 | + ->setCellValue('E1', '推送结果') | ||
116 | + ->setCellValue('F1', '推送时间'); | ||
117 | + $rowIndex = 2; | ||
118 | + | ||
119 | + foreach ($data_json as $k => $v) { | ||
120 | + $objPHPExcel->getActiveSheet() | ||
121 | + ->setCellValue('A' . $rowIndex, $v['username']) | ||
122 | + ->setCellValue('B' . $rowIndex, $v['sex']) | ||
123 | + ->setCellValue('C' . $rowIndex, $v['phone']) | ||
124 | + ->setCellValue('D' . $rowIndex, $v['certificateNo'].',') | ||
125 | + ->setCellValue('E' . $rowIndex, $v['result'].',') | ||
126 | + ->setCellValue('F' . $rowIndex, $v['create_time']); | ||
127 | + $rowIndex++; | ||
128 | + } | ||
129 | + | ||
130 | + $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(25); | ||
131 | + $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25); | ||
132 | + $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25); | ||
133 | + $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(25); | ||
134 | + $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(25); | ||
135 | + $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(25); | ||
136 | + | ||
137 | + | ||
138 | + $filename = '用户信息列表'; | ||
139 | + header('Content-Type: application/vnd.ms-excel'); | ||
140 | + | ||
141 | + $ua = $_SERVER["HTTP_USER_AGENT"]; | ||
142 | + header('Content-type: text/html; charset=gbk'); | ||
143 | + header("Content-type:application/vnd.ms-excel;charset=gbk"); | ||
144 | + //兼容IE11 | ||
145 | + if (preg_match("/MSIE/", $ua) || preg_match("/Trident\/7.0/", $ua)) { | ||
146 | + header('Content-Disposition: attachment;filename="' . urlencode($filename) . '.xls"'); | ||
147 | + } else if (preg_match("/Firefox/", $ua)) { | ||
148 | + header('Content-Disposition: attachment;filename*="' . $filename . '.xls"'); | ||
149 | + } else { | ||
150 | + header('Content-Disposition: attachment; filename="' . $filename . '.xls"'); | ||
151 | + } | ||
152 | + header('Cache-Control: max-age=0'); | ||
153 | + header('Cache-Control: max-age=1'); | ||
154 | + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | ||
155 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); | ||
156 | + header('Cache-Control: cache, must-revalidate'); | ||
157 | + header('Pragma: public'); | ||
158 | + $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); | ||
159 | + $objWriter->save('php://output'); | ||
160 | + | ||
161 | + } | ||
162 | + | ||
163 | + | ||
164 | + | ||
165 | +} |
application/products/controller/Prize.php
0 → 100644
1 | +<?php | ||
2 | +namespace app\products\controller; | ||
3 | + | ||
4 | +use app\products\validate\Car as CarValidate; | ||
5 | +use app\serviceapi\controller\Prize as prizeModel; | ||
6 | +use app\web\controller\BaseController; | ||
7 | +use think\Log; | ||
8 | +use think\Request; | ||
9 | +use util\MCurl; | ||
10 | +use think\Cookie; | ||
11 | +use think\Session; | ||
12 | +header("Content-type: text/html; charset=utf-8"); | ||
13 | +header('Access-Control-Allow-Origin:*'); | ||
14 | +header('Content-Type: application/json; charset=utf-8'); | ||
15 | +header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS'); | ||
16 | +header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); | ||
17 | +/** | ||
18 | + * 功能描述 抽奖管理 | ||
19 | + * Class Car | ||
20 | + * @package app\products\controller | ||
21 | + * Date: 2020/8/25 | ||
22 | + * Time: 10:00 | ||
23 | + * @author nyq | ||
24 | + */ | ||
25 | +class Prize extends BaseController | ||
26 | +{ | ||
27 | + //正式 | ||
28 | + private $appid = 'wx3e41adc018004fd1'; | ||
29 | + private $appsecrt = 'f072ba0a6dbb24a2f6b504259367ecfc'; | ||
30 | + //测试 | ||
31 | +// private $appid = 'wx8acc3fd862a42941'; | ||
32 | +// private $appsecrt = '04958b3c06a73aca04c2d5d0cfb4fd11'; | ||
33 | + | ||
34 | + //请求地址 | ||
35 | + //private $api_url = "http://demo8.xiaochakeji.com/serviceapi/prize/"; | ||
36 | + //查询接口 | ||
37 | + //private $api_url = "www.aisigit.com/products/prize/"; | ||
38 | + //private $api_url = "http://hzy.sosyun.com/products/prize/"; | ||
39 | + //private $api_url = "https://api.sosyun.com//serviceapi/prize/"; | ||
40 | + | ||
41 | + | ||
42 | + /** | ||
43 | + * 函数功能描述 微信分享获取AccessToken | ||
44 | + * Date: 2020/8/31 | ||
45 | + * Time: 10:00 | ||
46 | + * @author nyq | ||
47 | + */ | ||
48 | + public function getAccessToken() { | ||
49 | + //查询数据表里面的值 | ||
50 | + $data['appid']= $this->appid; | ||
51 | + $data['appsecrt']= $this->appsecrt; | ||
52 | + $prize_win_model = new prizeModel(); | ||
53 | + $info = $prize_win_model->getAccessToken(); | ||
54 | + //$info = MCurl::instance($this->api_url."getAccessToken")->post($data); | ||
55 | + $info = json_decode($info,true); | ||
56 | + | ||
57 | + if(empty($info) || $info['expires_in'] < time()){ | ||
58 | + //获取token的值 | ||
59 | + $url_token = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $this->appid . "&secret=" . $this->appsecrt; | ||
60 | + $tmp = $this->curl_get($url_token); //json格式 | ||
61 | + $obj = json_decode($tmp,true); | ||
62 | + if($obj['access_token'] != null){ | ||
63 | + $data['access_token'] = $obj['access_token']; | ||
64 | + $data['expires_in'] = time() + $obj['expires_in']; | ||
65 | + | ||
66 | + if($info){ | ||
67 | + $data['id'] = $info['id']; | ||
68 | + $info = $prize_win_model->updateAccessToken($data); | ||
69 | + //$arr = MCurl::instance($this->api_url."updateAccessToken")->post($data); | ||
70 | + }else{ | ||
71 | + $info = $prize_win_model->addAccessToken($data); | ||
72 | + //$arr = MCurl::instance($this->api_url."addAccessToken")->post($data); | ||
73 | + } | ||
74 | + return $data; | ||
75 | + }else return 'error'; | ||
76 | + }else return $info; | ||
77 | + } | ||
78 | + /** | ||
79 | + * 函数功能描述 微信分享获取ticket | ||
80 | + * Date: 2020/8/31 | ||
81 | + * Time: 10:00 | ||
82 | + * @author nyq | ||
83 | + */ | ||
84 | + public function getTicket(){ | ||
85 | + $token = $this->getAccessToken(); | ||
86 | + if(empty($token['jsapi_ticket']) || $token['expires_in'] < time()){ | ||
87 | + $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=".$token['access_token']."&type=jsapi"; | ||
88 | + $tmp = $this->curl_get($url); //json格式 | ||
89 | + // return $tmp; | ||
90 | + $obj = json_decode($tmp,true); | ||
91 | + $data['id'] = $token['id']; | ||
92 | + $data['jsapi_ticket'] = $obj['ticket']; | ||
93 | + $prize_win_model = new prizeModel(); | ||
94 | + $info = $prize_win_model->updateAccessToken($data); | ||
95 | + //$arr = MCurl::instance($this->api_url."updateAccessToken")->post($data); | ||
96 | + return $obj['ticket']; | ||
97 | + }else{ | ||
98 | + return $token['jsapi_ticket']; | ||
99 | + } | ||
100 | + } | ||
101 | + | ||
102 | + /** | ||
103 | + * 函数功能描述 微信分享获取sdk | ||
104 | + * Date: 2020/8/31 | ||
105 | + * Time: 10:00 | ||
106 | + * @author nyq | ||
107 | + */ | ||
108 | + public function generateSign(Request $request){ | ||
109 | + | ||
110 | + $dataurl = $request->param('url'); | ||
111 | + $url=str_replace('amp;','',$dataurl); | ||
112 | + $noncestr = uniqid(); | ||
113 | + $timestamp = time(); | ||
114 | + $ticket = $this->getTicket(); | ||
115 | + // return $ticket; | ||
116 | + if ($ticket) { | ||
117 | + $str = 'jsapi_ticket='.$ticket.'&noncestr='.$noncestr.'×tamp='.$timestamp.'&url='.$url; | ||
118 | + //echo $str;die; | ||
119 | + $signature = sha1($str); | ||
120 | + | ||
121 | + $data['str'] = $str; | ||
122 | + $data['ticket'] = $ticket; | ||
123 | + $data['nonceStr'] = $noncestr; | ||
124 | + $data['timestamp'] = $timestamp; | ||
125 | + $data['signature'] = $signature; | ||
126 | + $data['appId'] = $this->appid; | ||
127 | + $data['link'] = $url; | ||
128 | + | ||
129 | + | ||
130 | + return $data; | ||
131 | + } | ||
132 | + } | ||
133 | + | ||
134 | + /** | ||
135 | + * 函数功能描述 抽奖用户模拟微信授权 返回 openid | ||
136 | + * Date: 2020/8/26 | ||
137 | + * Time: 10:00 | ||
138 | + * @author nyq | ||
139 | + */ | ||
140 | + | ||
141 | + public function getWxCode(Request $request) | ||
142 | + { | ||
143 | + $data = $request->param(); | ||
144 | + $code=$data['code']; | ||
145 | + $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $this->appid . "&secret=" . $this->appsecrt . "&code=$code&grant_type=authorization_code"; | ||
146 | + $r = $this->curl_get($url); | ||
147 | + $openid=json_decode($r,true); | ||
148 | + return $openid; | ||
149 | + } | ||
150 | + | ||
151 | + | ||
152 | + | ||
153 | + /** | ||
154 | + * 函数功能描述 获取订单信息 / 获取奖品列表接口 | ||
155 | + * Date: 2020/8/27 | ||
156 | + * Time: 10:00 | ||
157 | + * @author nyq | ||
158 | + */ | ||
159 | + public function prize_list(Request $request) | ||
160 | + { | ||
161 | + $data = $request->param(); | ||
162 | + $page = isset($_POST['page']) ? intval($_POST['page']) : 1; | ||
163 | + $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; | ||
164 | + $offset=($page-1)*$rows; | ||
165 | + $data['offset']=$offset; | ||
166 | + $data['rows']=$rows; | ||
167 | + $prize_win_model = new prizeModel(); | ||
168 | + $res = $prize_win_model->prizeList($data); | ||
169 | + //$res = MCurl::instance($this->api_url."prizeList")->post($data); | ||
170 | + $json=json_decode($res,true); | ||
171 | + | ||
172 | + foreach($json as $key=>$val ){ | ||
173 | + $json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']); | ||
174 | + | ||
175 | + if($val['display'] ==0){ | ||
176 | + $json[$key]['display']="已发布"; | ||
177 | + }else{ | ||
178 | + $json[$key]['display']="未发布"; | ||
179 | + } | ||
180 | + } | ||
181 | + | ||
182 | + //var_dump($json);die; | ||
183 | + // $last_names = array_column($json,'addTime'); | ||
184 | + // array_multisort($last_names,SORT_DESC,$json); | ||
185 | + $result["total"] =count($json); | ||
186 | + $result['rows']=$json; | ||
187 | + echo json_encode($result); | ||
188 | + //return $json; | ||
189 | + } | ||
190 | + /** | ||
191 | + * 函数功能描述 添加奖品 | ||
192 | + * Date: 2020/8/07 | ||
193 | + * Time: 10:00 | ||
194 | + * @author nyq | ||
195 | + */ | ||
196 | + public function prize_add(Request $request) | ||
197 | + { | ||
198 | + $data = $request->param(); | ||
199 | + $data['addTime']=time(); | ||
200 | + $prize_win_model = new prizeModel(); | ||
201 | + $res = $prize_win_model->prizeAdd($data); | ||
202 | + //$res = MCurl::instance($this->api_url."prizeAdd")->post($data); | ||
203 | + $json=json_decode($res,true); | ||
204 | + if(is_numeric($json)){ | ||
205 | + $data=[ | ||
206 | + 'code'=>200, | ||
207 | + 'msg'=>'修改成功' | ||
208 | + ]; | ||
209 | + }else{ | ||
210 | + $data=[ | ||
211 | + 'code'=>100, | ||
212 | + 'msg'=>'修改失败' | ||
213 | + ]; | ||
214 | + } | ||
215 | + return $data; | ||
216 | + } | ||
217 | + /** | ||
218 | + * 函数功能描述 规则设置 // 获取抽奖规则接口 | ||
219 | + * Date: 2020/8/26 | ||
220 | + * Time: 10:00 | ||
221 | + * @author nyq | ||
222 | + */ | ||
223 | + public function prize_rule(Request $request) | ||
224 | + { | ||
225 | + //$data = $request->param(); | ||
226 | + $prize_win_model = new prizeModel(); | ||
227 | + $res = $prize_win_model->prizeRule(); | ||
228 | + //$res = MCurl::instance($this->api_url."prizeRule")->post($data); | ||
229 | + $json=json_decode($res,true); | ||
230 | + $code="fg5Fu7Is9aHJ5ug5".time(); | ||
231 | + $json['openid']=$code; | ||
232 | + return $json; | ||
233 | +// $json=json_encode($res); | ||
234 | +// $aa= html_entity_decode($json); | ||
235 | +// //数据特殊符号转义 | ||
236 | +// $aa = htmlspecialchars_decode($aa); | ||
237 | +// return $aa; | ||
238 | + } | ||
239 | + /** | ||
240 | + * 函数功能描述 修改规则设置 | ||
241 | + * Date: 2020/8/26 | ||
242 | + * Time: 10:00 | ||
243 | + * @author nyq | ||
244 | + */ | ||
245 | + public function prize_rule_edit(Request $request) | ||
246 | + { | ||
247 | + $data = $request->param(); | ||
248 | + | ||
249 | + $data['addTime']=time(); | ||
250 | + if(isset($data['open']) && $data['open']=="on"){ | ||
251 | + $data['open']=1; | ||
252 | + }else{ | ||
253 | + $data['open']=0; | ||
254 | + } | ||
255 | + | ||
256 | + $prize_win_model = new prizeModel(); | ||
257 | + $res = $prize_win_model->prizeRuleEdit($data); | ||
258 | + //$res = MCurl::instance($this->api_url."prizeRuleEdit")->post($data); | ||
259 | + $json=json_decode($res,true); | ||
260 | + | ||
261 | + if(is_numeric($json)){ | ||
262 | + $data=[ | ||
263 | + 'code'=>200, | ||
264 | + 'msg'=>'修改成功' | ||
265 | + ]; | ||
266 | + }else{ | ||
267 | + $data=[ | ||
268 | + 'code'=>100, | ||
269 | + 'msg'=>'修改失败' | ||
270 | + ]; | ||
271 | + } | ||
272 | + return $data; | ||
273 | + | ||
274 | + } | ||
275 | + /** | ||
276 | + * 函数功能描述 重置抽奖次数 | ||
277 | + * Date: 2020/8/26 | ||
278 | + * Time: 10:00 | ||
279 | + * @author nyq | ||
280 | + */ | ||
281 | + public function prize_reset(Request $request) | ||
282 | + { | ||
283 | + //$data = $request->param(); | ||
284 | + $prize_win_model = new prizeModel(); | ||
285 | + $res = $prize_win_model->prizeReset(); | ||
286 | + //$res = MCurl::instance($this->api_url."prizeReset")->post($data); | ||
287 | + $json=json_decode($res,true); | ||
288 | + if(is_numeric($json)){ | ||
289 | + $data=[ | ||
290 | + 'code'=>200, | ||
291 | + 'msg'=>'重置成功' | ||
292 | + ]; | ||
293 | + }else{ | ||
294 | + $data=[ | ||
295 | + 'code'=>100, | ||
296 | + 'msg'=>'重置失败' | ||
297 | + ]; | ||
298 | + } | ||
299 | + return $data; | ||
300 | + } | ||
301 | + /** | ||
302 | + * 函数功能描述 中奖用户列表 | ||
303 | + * Date: 2020/8/26 | ||
304 | + * Time: 10:00 | ||
305 | + * @author nyq | ||
306 | + */ | ||
307 | + public function prize_user_list(Request $request) | ||
308 | + { | ||
309 | + | ||
310 | + $data = $request->param(); | ||
311 | + $page = $data['page']; | ||
312 | + $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; | ||
313 | + $offset=($page-1)*$rows; | ||
314 | + $data['offset']=$offset; | ||
315 | + $data['rows']=$rows; | ||
316 | + Cookie::set('data', $data); | ||
317 | + $prize_win_model = new prizeModel(); | ||
318 | + $res = $prize_win_model->prizeUserList($data); | ||
319 | + //$res = MCurl::instance($this->api_url."prizeUserList")->post($data); | ||
320 | + //$res=json_decode($res,true); | ||
321 | + | ||
322 | + $json=$res['rows']; | ||
323 | + | ||
324 | + | ||
325 | + foreach($json as $key=>$val ){ | ||
326 | + $json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']); | ||
327 | + if($val['receive'] ==0){ | ||
328 | + $json[$key]['receive']="未领取"; | ||
329 | + }else{ | ||
330 | + $json[$key]['receive']="已领取"; | ||
331 | + } | ||
332 | + } | ||
333 | + | ||
334 | + $last_names = array_column($json,'addTime'); | ||
335 | + array_multisort($last_names,SORT_DESC,$json); | ||
336 | + | ||
337 | +// $count = MCurl::instance($this->api_url."prizeUserCount")->post($data); | ||
338 | +// $count=json_decode($count,true); | ||
339 | + // $result["total"] =$count; | ||
340 | + // $result['rows']=$json; | ||
341 | + $result["total"] =$res['total']; | ||
342 | + $result['rows']=$json; | ||
343 | + echo json_encode($result); | ||
344 | + | ||
345 | + //return $json; | ||
346 | + } | ||
347 | + /** | ||
348 | + * 函数功能描述 删除中奖用户列表 | ||
349 | + * Date: 2020/8/07 | ||
350 | + * Time: 10:00 | ||
351 | + * @author nyq | ||
352 | + */ | ||
353 | + public function del_user() | ||
354 | + { | ||
355 | + $data = $this->request->post(); | ||
356 | + $prize_win_model = new prizeModel(); | ||
357 | + $res = $prize_win_model->delUser($data); | ||
358 | + //$res = MCurl::instance($this->api_url."delUser")->post($data); | ||
359 | + | ||
360 | + $json=json_decode($res,true); | ||
361 | + if(is_numeric($json)){ | ||
362 | + $data=[ | ||
363 | + 'code'=>200, | ||
364 | + 'msg'=>'删除成功' | ||
365 | + ]; | ||
366 | + }else{ | ||
367 | + $data=[ | ||
368 | + 'code'=>100, | ||
369 | + 'msg'=>'删除失败' | ||
370 | + ]; | ||
371 | + } | ||
372 | + return $data; | ||
373 | + } | ||
374 | + /** | ||
375 | + * 函数功能描述 文件上传 | ||
376 | + * Date: 2020/8/07 | ||
377 | + * Time: 10:00 | ||
378 | + * @author nyq | ||
379 | + */ | ||
380 | + public function uploadFileImgs(){ | ||
381 | + $files = request()->file('files'); | ||
382 | + $path = input('path'); | ||
383 | + if($files){ | ||
384 | + $imgarr = []; | ||
385 | + foreach($files as $file){ | ||
386 | + $info = $file->validate(['size'=>204800000,'ext'=>'jpg,png,gif'])->move(ROOT_PATH . 'public/web/' . DS . 'prize'); | ||
387 | + if($info){ | ||
388 | + $newurl = '/web/prize/'.$info->getSaveName(); | ||
389 | + $img= str_replace('\\','/',$newurl); | ||
390 | + | ||
391 | + $imgarr[]=$img; | ||
392 | + } | ||
393 | + } | ||
394 | + return json_encode($imgarr); | ||
395 | + }else{ | ||
396 | + echo '没有图片上传'; | ||
397 | + } | ||
398 | + } | ||
399 | + | ||
400 | + | ||
401 | + | ||
402 | + | ||
403 | + | ||
404 | + | ||
405 | + | ||
406 | + /** | ||
407 | + * 函数功能描述 导出数据到表格 | ||
408 | + * Date: 2020/8/26 | ||
409 | + * Time: 10:00 | ||
410 | + * @author nyq | ||
411 | + */ | ||
412 | + public function to_excel() | ||
413 | + { | ||
414 | + //$data = $this->request->Post(); | ||
415 | + $data= Cookie::get('data'); | ||
416 | + $data['to_excel']=1; | ||
417 | + $prize_win_model = new prizeModel(); | ||
418 | + $json = $prize_win_model->prizeUserList($data); | ||
419 | + //$res = MCurl::instance($this->api_url."prizeUserList")->post($data); | ||
420 | + | ||
421 | + //$json=json_decode($res,true); | ||
422 | + | ||
423 | + foreach($json as $key=>$val ){ | ||
424 | + $json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']); | ||
425 | + } | ||
426 | + ob_end_clean();//清除缓冲区,避免乱码 | ||
427 | + Vendor('PHPExcel.PHPExcel'); | ||
428 | + $objPHPExcel=new \PHPExcel(); | ||
429 | + $objPHPExcel->setActiveSheetIndex(0) | ||
430 | + ->setCellValue('A1', '用户名') | ||
431 | + ->setCellValue('B1', '电话') | ||
432 | + ->setCellValue('C1', '奖品名称') | ||
433 | + ->setCellValue('D1', '部门') | ||
434 | + ->setCellValue('E1', '时间'); | ||
435 | + $rowIndex = 2; | ||
436 | + | ||
437 | + foreach ($json as $k => $v) { | ||
438 | + $objPHPExcel->getActiveSheet() | ||
439 | + ->setCellValue('A' . $rowIndex, $v['uname']) | ||
440 | + ->setCellValue('B' . $rowIndex, $v['phone']) | ||
441 | + ->setCellValue('C' . $rowIndex, $v['prizeName']) | ||
442 | + ->setCellValue('D' . $rowIndex, $v['source']) | ||
443 | + ->setCellValue('E' . $rowIndex, $v['addTime']); | ||
444 | + $rowIndex++; | ||
445 | + } | ||
446 | + | ||
447 | + $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(25); | ||
448 | + $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25); | ||
449 | + $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25); | ||
450 | + $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(25); | ||
451 | + $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(25); | ||
452 | + | ||
453 | + $filename = '抽奖用户数据表'; | ||
454 | + header('Content-Type: application/vnd.ms-excel'); | ||
455 | + | ||
456 | + $ua = $_SERVER["HTTP_USER_AGENT"]; | ||
457 | + header('Content-type: text/html; charset=gbk'); | ||
458 | + header("Content-type:application/vnd.ms-excel;charset=gbk"); | ||
459 | + //兼容IE11 | ||
460 | + if (preg_match("/MSIE/", $ua) || preg_match("/Trident\/7.0/", $ua)) { | ||
461 | + header('Content-Disposition: attachment;filename="' . urlencode($filename) . '.xls"'); | ||
462 | + } else if (preg_match("/Firefox/", $ua)) { | ||
463 | + header('Content-Disposition: attachment;filename*="' . $filename . '.xls"'); | ||
464 | + } else { | ||
465 | + header('Content-Disposition: attachment; filename="' . $filename . '.xls"'); | ||
466 | + } | ||
467 | + header('Cache-Control: max-age=0'); | ||
468 | + header('Cache-Control: max-age=1'); | ||
469 | + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | ||
470 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); | ||
471 | + header('Cache-Control: cache, must-revalidate'); | ||
472 | + header('Pragma: public'); | ||
473 | + $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); | ||
474 | + $objWriter->save('php://output'); | ||
475 | + | ||
476 | + } | ||
477 | + | ||
478 | + | ||
479 | + | ||
480 | + | ||
481 | + | ||
482 | + | ||
483 | + | ||
484 | + | ||
485 | + | ||
486 | + | ||
487 | + | ||
488 | + /** | ||
489 | + * 函数功能描述 获取抽奖规则接口 | ||
490 | + * Date: 2020/8/26 | ||
491 | + * Time: 10:00 | ||
492 | + * @author nyq | ||
493 | + */ | ||
494 | + | ||
495 | + public function prize_rule_api(Request $request) | ||
496 | + { | ||
497 | + $data = $request->param(); | ||
498 | + $prize_win_model = new prizeModel(); | ||
499 | + $res = $prize_win_model->prizeRuleEdit($data); | ||
500 | + //$res = MCurl::instance($this->api_url."prizeRuleEdit")->post($data); | ||
501 | + $json=json_decode($res,true); | ||
502 | + | ||
503 | + if(is_numeric($json)){ | ||
504 | + $data=[ | ||
505 | + 'code'=>200, | ||
506 | + 'msg'=>'重置成功' | ||
507 | + ]; | ||
508 | + }else{ | ||
509 | + $data=[ | ||
510 | + 'code'=>100, | ||
511 | + 'msg'=>'重置失败' | ||
512 | + ]; | ||
513 | + } | ||
514 | + return $data; | ||
515 | + | ||
516 | + } | ||
517 | + | ||
518 | + | ||
519 | + /** | ||
520 | + * 函数功能描述 首次进入 合适身份信息 接口 | ||
521 | + * Date: 2020/8/26 | ||
522 | + * Time: 10:00 | ||
523 | + * @author nyq | ||
524 | + */ | ||
525 | + public function sel_prize_member(Request $request) | ||
526 | + { | ||
527 | + $data = $request->param(); | ||
528 | + //给我 openID number | ||
529 | + //查看当前用户是否存在 | ||
530 | + $prize_win_model = new prizeModel(); | ||
531 | + $res = $prize_win_model->selPrizeMember($data); | ||
532 | +// $res = MCurl::instance($this->api_url."selPrizeMember")->post($data); | ||
533 | +// $json=json_decode($res,true); | ||
534 | + | ||
535 | + return $res; | ||
536 | + } | ||
537 | + | ||
538 | + | ||
539 | + /** | ||
540 | + * 函数功能描述 抽奖接口 | ||
541 | + * Date: 2020/8/26 | ||
542 | + * Time: 10:00 | ||
543 | + * @author nyq | ||
544 | + */ | ||
545 | + public function luck_draw(Request $request) | ||
546 | + { | ||
547 | + //传递 openID prize_id | ||
548 | + $data = $request->param(); | ||
549 | + | ||
550 | + //查看当前用户是否存在 | ||
551 | + $prize_win_model = new prizeModel(); | ||
552 | + $res = $prize_win_model->luckDraw($data); | ||
553 | + //$res = MCurl::instance($this->api_url."luckDraw")->post($data); | ||
554 | + //$json=json_decode($res,true); | ||
555 | + //传递 openID prize_id | ||
556 | + return $res; | ||
557 | + } | ||
558 | + | ||
559 | + /** | ||
560 | + * 函数功能描述 获取最新的20条中奖列表 / 个人的奖品列表 接口 | ||
561 | + * Date: 2020/8/26 | ||
562 | + * Time: 10:00 | ||
563 | + * @author nyq | ||
564 | + */ | ||
565 | + public function win_list(Request $request) | ||
566 | + { | ||
567 | + //传递 openID | ||
568 | + $data = $request->param(); | ||
569 | + //查看当前用户是否存在 | ||
570 | + $prize_win_model = new prizeModel(); | ||
571 | + $res = $prize_win_model->prizeWinList($data); | ||
572 | + // $res = MCurl::instance($this->api_url."prizeWinList")->post($data); | ||
573 | + $json=json_decode($res,true); | ||
574 | + | ||
575 | + foreach($json as $key=>$val ){ | ||
576 | + $json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']); | ||
577 | + | ||
578 | + } | ||
579 | + | ||
580 | + //传递 openID prize_id | ||
581 | + return $json; | ||
582 | + } | ||
583 | + | ||
584 | + /** | ||
585 | + * 函数功能描述 兑奖接口 | ||
586 | + * Date: 2020/8/26 | ||
587 | + * Time: 10:00 | ||
588 | + * @author nyq | ||
589 | + */ | ||
590 | + public function cash_prize(Request $request) | ||
591 | + { | ||
592 | + //传递 openID | ||
593 | + $data = $request->param(); | ||
594 | + //查看当前用户是否存在 | ||
595 | + $prize_win_model = new prizeModel(); | ||
596 | + $res = $prize_win_model->cashPrize($data); | ||
597 | + //$res = MCurl::instance($this->api_url."cashPrize")->post($data); | ||
598 | + $json=json_decode($res,true); | ||
599 | + | ||
600 | + if($json==1){ | ||
601 | + $data=[ | ||
602 | + 'code'=>200, | ||
603 | + 'msg'=>'成功' | ||
604 | + ]; | ||
605 | + }else{ | ||
606 | + $data=[ | ||
607 | + 'code'=>100, | ||
608 | + 'msg'=>'失败' | ||
609 | + ]; | ||
610 | + } | ||
611 | + | ||
612 | + //传递 openID prize_id | ||
613 | + return $data; | ||
614 | + } | ||
615 | + | ||
616 | + /** | ||
617 | + * 发起GET请求 | ||
618 | + * @param string $url 请求地址 | ||
619 | + * @param array $data 请求参数 | ||
620 | + * @param string $cookiePath 请求所保存的cookie路径 | ||
621 | + */ | ||
622 | + function curl_get($url, $data=[], $cookiePath = '') | ||
623 | + { | ||
624 | + if(count($data)!=0) { | ||
625 | + $url = get_query_url($url, $data); | ||
626 | + } | ||
627 | + $ch = curl_init(); | ||
628 | + curl_setopt($ch, CURLOPT_URL, $url); | ||
629 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
630 | + curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiePath); | ||
631 | + curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiePath); | ||
632 | + curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0); | ||
633 | + curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0); | ||
634 | + $res = curl_exec($ch); | ||
635 | + curl_close($ch); | ||
636 | + return $res; | ||
637 | + | ||
638 | + } | ||
639 | + | ||
640 | + | ||
641 | + | ||
642 | + | ||
643 | +} |
application/products/controller/Product.php
0 → 100644
1 | +<?php | ||
2 | +namespace app\products\controller; | ||
3 | + | ||
4 | + | ||
5 | + | ||
6 | +use app\common\model\serviceapi\Product as ProductModel; | ||
7 | +use app\common\model\serviceapi\ProductUser as ProductUserModel; | ||
8 | +use app\common\model\serviceapi\ProductOrder as ProductOrderModel; | ||
9 | + | ||
10 | + | ||
11 | +use app\web\controller\BaseController; | ||
12 | +use think\Log; | ||
13 | +use think\Request; | ||
14 | +use util\MCurl; | ||
15 | +use think\Cookie; | ||
16 | +use think\Session; | ||
17 | +header("Content-type: text/html; charset=utf-8"); | ||
18 | +header('Access-Control-Allow-Origin:*'); | ||
19 | +header('Content-Type: application/json; charset=utf-8'); | ||
20 | +header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS'); | ||
21 | +header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); | ||
22 | +/** | ||
23 | + * 功能描述 产品管理 | ||
24 | + * Class Product | ||
25 | + * @package app\products\controller | ||
26 | + * Date: 2020/11/2 | ||
27 | + * Time: 10:00 | ||
28 | + * @author nyq | ||
29 | + */ | ||
30 | +class Product extends BaseController | ||
31 | +{ | ||
32 | + | ||
33 | + private $api_back_url = "http://sosapi.com/commapi/generator_data/sosBxCarInfoAdd"; | ||
34 | + | ||
35 | + | ||
36 | + public function carOrder() | ||
37 | + { | ||
38 | + | ||
39 | + //$res = MCurl::instance($this->api_back_url)->post($data); | ||
40 | + $data=[]; | ||
41 | + $res=[]; | ||
42 | + for($i=0;$i<10;$i++){ | ||
43 | + $res[$i] = json_decode(MCurl::instance($this->api_back_url)->post($data),true); | ||
44 | + } | ||
45 | + | ||
46 | + | ||
47 | + | ||
48 | + | ||
49 | + $this->to($res); | ||
50 | + | ||
51 | + var_dump($res); | ||
52 | + die; | ||
53 | + //var_dump(); | ||
54 | + //echo 111;die; | ||
55 | + | ||
56 | + return $res; | ||
57 | + } | ||
58 | + | ||
59 | + | ||
60 | + public function to($json) | ||
61 | + { | ||
62 | + | ||
63 | + | ||
64 | + | ||
65 | + ob_end_clean();//清除缓冲区,避免乱码 | ||
66 | + Vendor('PHPExcel.PHPExcel'); | ||
67 | + $objPHPExcel=new \PHPExcel(); | ||
68 | + $objPHPExcel->setActiveSheetIndex(0) | ||
69 | + ->setCellValue('A1', '用户名') | ||
70 | + ->setCellValue('B1', '车牌') | ||
71 | + ->setCellValue('C1', '身份证') | ||
72 | + ->setCellValue('D1', '电话') | ||
73 | + ->setCellValue('E1', '年龄') | ||
74 | + ->setCellValue('F1', '性别'); | ||
75 | + | ||
76 | + $rowIndex = 2; | ||
77 | + | ||
78 | + foreach ($json as $k => $v) { | ||
79 | + | ||
80 | + $objPHPExcel->getActiveSheet() | ||
81 | + ->setCellValue('A' . $rowIndex, $v['uname']) | ||
82 | + ->setCellValue('B' . $rowIndex, $v['pai']) | ||
83 | + ->setCellValue('C' . $rowIndex, $v['shen']) | ||
84 | + ->setCellValue('D' . $rowIndex, $v['tel']) | ||
85 | + ->setCellValue('E' . $rowIndex, $v['age']) | ||
86 | + ->setCellValue('F' . $rowIndex, $v['sex']); | ||
87 | + $rowIndex++; | ||
88 | + } | ||
89 | +// echo 3321;die; | ||
90 | + $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(100 | ||
91 | + ); | ||
92 | + // $objPHPExcel->getActiveSheet()->getStyle('C')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT); | ||
93 | + | ||
94 | + $filename = '用户数据表'; | ||
95 | + header('Content-Type: application/vnd.ms-excel'); | ||
96 | + | ||
97 | + $ua = $_SERVER["HTTP_USER_AGENT"]; | ||
98 | + header('Content-type: text/html; charset=gbk'); | ||
99 | + header("Content-type:application/vnd.ms-excel;charset=gbk"); | ||
100 | + //兼容IE11 | ||
101 | + if (preg_match("/MSIE/", $ua) || preg_match("/Trident\/7.0/", $ua)) { | ||
102 | + header('Content-Disposition: attachment;filename="' . urlencode($filename) . '.xls"'); | ||
103 | + } else if (preg_match("/Firefox/", $ua)) { | ||
104 | + header('Content-Disposition: attachment;filename*="' . $filename . '.xls"'); | ||
105 | + } else { | ||
106 | + header('Content-Disposition: attachment; filename="' . $filename . '.xls"'); | ||
107 | + } | ||
108 | + header('Cache-Control: max-age=0'); | ||
109 | + header('Cache-Control: max-age=1'); | ||
110 | + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | ||
111 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); | ||
112 | + header('Cache-Control: cache, must-revalidate'); | ||
113 | + header('Pragma: public'); | ||
114 | + $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); | ||
115 | + $objWriter->save('php://output'); | ||
116 | + | ||
117 | + } | ||
118 | + | ||
119 | + | ||
120 | + | ||
121 | + /** | ||
122 | + * 函数功能描述 删除订单 | ||
123 | + * Date: 2020/8/07 | ||
124 | + * Time: 10:00 | ||
125 | + * @author nyq | ||
126 | + */ | ||
127 | + public function order_del() | ||
128 | + { | ||
129 | + $data = $this->request->post(); | ||
130 | + $product_order_model = new ProductOrderModel(); | ||
131 | + $res = $product_order_model->orderDel($data); | ||
132 | + $json=json_decode($res,true); | ||
133 | + if(is_numeric($json)){ | ||
134 | + $data=[ | ||
135 | + 'code'=>200, | ||
136 | + 'msg'=>'删除成功' | ||
137 | + ]; | ||
138 | + }else{ | ||
139 | + $data=[ | ||
140 | + 'code'=>100, | ||
141 | + 'msg'=>'删除失败' | ||
142 | + ]; | ||
143 | + } | ||
144 | + return $data; | ||
145 | + } | ||
146 | + | ||
147 | + | ||
148 | + | ||
149 | + /** | ||
150 | + * 函数功能描述 生成订单 | ||
151 | + * Date: 2020/11/2 | ||
152 | + * Time: 10:00 | ||
153 | + * @author nyq | ||
154 | + */ | ||
155 | + public function addOrde(Request $request) | ||
156 | + { | ||
157 | + | ||
158 | + | ||
159 | + | ||
160 | + | ||
161 | + | ||
162 | + | ||
163 | + $data = $request->param(); | ||
164 | + //用户信息 | ||
165 | + $user['name']=$data['name']; | ||
166 | + $user['phone']=$data['phone']; | ||
167 | +// $user['sheng']=$data['sheng']; | ||
168 | +// $user['shi']=$data['shi']; | ||
169 | +// $user['qu']=$data['qu']; | ||
170 | + $user['address']=$data['address']; | ||
171 | + $user['addTime']=time(); | ||
172 | + | ||
173 | + $product_user_model = new ProductUserModel(); | ||
174 | + $res = $product_user_model->add($user); | ||
175 | + | ||
176 | + //订单信息 | ||
177 | + $order['order_code']=time().mt_rand(999, 9999); | ||
178 | + $order['user_id']=$res; | ||
179 | + $order['goods_id']=$data['goods_id']; | ||
180 | + $order['num']=$data['num']; | ||
181 | + $order['price']=$data['price']; | ||
182 | +// $order['sheng']=$data['sheng']; | ||
183 | +// $order['shi']=$data['shi']; | ||
184 | +// $order['qu']=$data['qu']; | ||
185 | + $order['address']=$data['address']; | ||
186 | + $order['addTime']=time(); | ||
187 | + $order['upTime']=time(); | ||
188 | + $product_order_model = new ProductOrderModel(); | ||
189 | + $order_res = $product_order_model->add($order); | ||
190 | + | ||
191 | + $json=json_decode($order_res,true); | ||
192 | + if(is_numeric($json)){ | ||
193 | + $data=[ | ||
194 | + 'code'=>200, | ||
195 | + 'msg'=>'成功' | ||
196 | + ]; | ||
197 | + }else{ | ||
198 | + $data=[ | ||
199 | + 'code'=>100, | ||
200 | + 'msg'=>'失败' | ||
201 | + ]; | ||
202 | + } | ||
203 | + return $data; | ||
204 | + } | ||
205 | + /** | ||
206 | + * 函数功能描述 获取订单列表 | ||
207 | + * Date: 2020/11/2 | ||
208 | + * Time: 10:00 | ||
209 | + * @author nyq | ||
210 | + */ | ||
211 | + public function get_order_list(Request $request) | ||
212 | + { | ||
213 | + $data = $request->param(); | ||
214 | + $page = isset($_POST['page']) ? intval($_POST['page']) : 1; | ||
215 | + $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; | ||
216 | + $offset=($page-1)*$rows; | ||
217 | + $data['offset']=$offset; | ||
218 | + $data['rows']=$rows; | ||
219 | + $where=[]; | ||
220 | + $product_user_model = new ProductUserModel(); | ||
221 | + $res = $product_user_model->getUserlist($where,$data['offset'],$data['rows']); | ||
222 | + $json=json_decode($res,true); | ||
223 | + | ||
224 | + | ||
225 | + foreach($json as $key=>$val ){ | ||
226 | + | ||
227 | + $json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']); | ||
228 | + //$json[$key]['address']=$json[$key]['sheng'].$json[$key]['shi'].$json[$key]['qu'].$json[$key]['address']; | ||
229 | + } | ||
230 | + | ||
231 | + $result["total"] =count($json); | ||
232 | + $result['rows']=$json; | ||
233 | + echo json_encode($result); | ||
234 | + //return $json; | ||
235 | + } | ||
236 | + | ||
237 | + | ||
238 | + /** | ||
239 | + * 函数功能描述 根据id查询商品信息 | ||
240 | + * Date: 2020/11/2 | ||
241 | + * Time: 10:00 | ||
242 | + * @author nyq | ||
243 | + */ | ||
244 | + public function get_one_list(Request $request) | ||
245 | + { | ||
246 | + $data = $request->param(); | ||
247 | + $product_model = new ProductModel(); | ||
248 | + $res = $product_model->getGoodsList($data); | ||
249 | + | ||
250 | + | ||
251 | + $res['content'] = htmlspecialchars_decode($res['content']); | ||
252 | + | ||
253 | + | ||
254 | + $img[]=explode(',',$res['images']); | ||
255 | + $res['img']=$img[0][0]; | ||
256 | + $res['img2']=$img[0][1]; | ||
257 | + $res['img3']=$img[0][2]; | ||
258 | + | ||
259 | + unset($res['images']); | ||
260 | + return $res; | ||
261 | + } | ||
262 | + | ||
263 | + | ||
264 | + /** | ||
265 | + * 函数功能描述 获取商品列表 | ||
266 | + * Date: 2020/11/2 | ||
267 | + * Time: 10:00 | ||
268 | + * @author nyq | ||
269 | + */ | ||
270 | + public function goods_list(Request $request) | ||
271 | + { | ||
272 | + $data = $request->param(); | ||
273 | + $page = isset($_POST['page']) ? intval($_POST['page']) : 1; | ||
274 | + $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; | ||
275 | + $offset=($page-1)*$rows; | ||
276 | + $data['offset']=$offset; | ||
277 | + $data['rows']=$rows; | ||
278 | + $product_model = new ProductModel(); | ||
279 | + $where=[]; | ||
280 | + $res = $product_model->goodsList($where,$data['offset'],$data['rows']); | ||
281 | + $json=json_decode($res,true); | ||
282 | + foreach($json as $key=>$val ){ | ||
283 | + $json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']); | ||
284 | + } | ||
285 | + | ||
286 | + $result["total"] =count($json); | ||
287 | + $result['rows']=$json; | ||
288 | + echo json_encode($result); | ||
289 | + //return $json; | ||
290 | + } | ||
291 | + | ||
292 | + | ||
293 | + | ||
294 | + /** | ||
295 | + * 函数功能描述 添加商品 | ||
296 | + * Date: 2020/11/02 | ||
297 | + * Time: 10:00 | ||
298 | + * @author nyq | ||
299 | + */ | ||
300 | + public function goods_add(Request $request) | ||
301 | + { | ||
302 | + $data = $request->param(); | ||
303 | + | ||
304 | + $data['images']=$data['img'].','.$data['img2'].','.$data['img3']; | ||
305 | + | ||
306 | + unset($data['img'],$data['img2'],$data['img3']); | ||
307 | + $product_model = new ProductModel(); | ||
308 | + if(isset($data['goods_id']) && !empty($data['goods_id'])){ | ||
309 | + $data['upTime']=time(); | ||
310 | + $where['id']=$data['goods_id']; | ||
311 | + unset($data['goods_id']); | ||
312 | + $res = $product_model->productUp($where,$data); | ||
313 | + }else{ | ||
314 | + unset($data['goods_id']); | ||
315 | + $data['addTime']=time(); | ||
316 | + $data['upTime']=time(); | ||
317 | + | ||
318 | + $res = $product_model->add($data); | ||
319 | + } | ||
320 | + $json=json_decode($res,true); | ||
321 | + if(is_numeric($json)){ | ||
322 | + $data=[ | ||
323 | + 'code'=>200, | ||
324 | + 'msg'=>'成功' | ||
325 | + ]; | ||
326 | + }else{ | ||
327 | + $data=[ | ||
328 | + 'code'=>100, | ||
329 | + 'msg'=>'失败' | ||
330 | + ]; | ||
331 | + } | ||
332 | + return $data; | ||
333 | + } | ||
334 | + | ||
335 | + | ||
336 | + | ||
337 | + | ||
338 | + /** | ||
339 | + * 函数功能描述 文件上传 | ||
340 | + * Date: 2020/11/02 | ||
341 | + * Time: 10:00 | ||
342 | + * @author nyq | ||
343 | + */ | ||
344 | + public function uploadFileImgs(){ | ||
345 | + $files = request()->file('files'); | ||
346 | + $path = input('path'); | ||
347 | + if($files){ | ||
348 | + $imgarr = []; | ||
349 | + foreach($files as $file){ | ||
350 | + $info = $file->validate(['size'=>204800000,'ext'=>'jpg,png,gif'])->move(ROOT_PATH . 'public/web/' . DS . 'product'); | ||
351 | + if($info){ | ||
352 | + $newurl = '/web/product/'.$info->getSaveName(); | ||
353 | + $img= str_replace('\\','/',$newurl); | ||
354 | + | ||
355 | + $imgarr[]=$img; | ||
356 | + } | ||
357 | + } | ||
358 | + return json_encode($imgarr); | ||
359 | + }else{ | ||
360 | + echo '没有图片上传'; | ||
361 | + } | ||
362 | + } | ||
363 | + | ||
364 | + | ||
365 | + /** | ||
366 | + * 函数功能描述 导出数据到表格 | ||
367 | + * Date: 2020/8/26 | ||
368 | + * Time: 10:00 | ||
369 | + * @author nyq | ||
370 | + */ | ||
371 | + public function to_excel() | ||
372 | + { | ||
373 | + //$data = $this->request->Post(); | ||
374 | +// $data= Cookie::get('data'); | ||
375 | +// $data['to_excel']=1; | ||
376 | + $product_user_model = new ProductUserModel(); | ||
377 | + $json = $product_user_model->getUserlistToEx(); | ||
378 | + | ||
379 | + | ||
380 | + //$res = MCurl::instance($this->api_url."prizeUserList")->post($data); | ||
381 | + | ||
382 | + //$json=json_decode($res,true); | ||
383 | + | ||
384 | + foreach($json as $key=>$val ){ | ||
385 | + $json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']); | ||
386 | + $json[$key]['address']=$json[$key]['sheng'].$json[$key]['shi'].$json[$key]['qu'].$json[$key]['address']; | ||
387 | + } | ||
388 | + | ||
389 | + ob_end_clean();//清除缓冲区,避免乱码 | ||
390 | + Vendor('PHPExcel.PHPExcel'); | ||
391 | + $objPHPExcel=new \PHPExcel(); | ||
392 | + $objPHPExcel->setActiveSheetIndex(0) | ||
393 | + ->setCellValue('A1', '订单编号') | ||
394 | + ->setCellValue('B1', '商品名称') | ||
395 | + ->setCellValue('C1', '用户名') | ||
396 | + ->setCellValue('D1', '电话') | ||
397 | + ->setCellValue('E1', '详细地址') | ||
398 | + ->setCellValue('F1', '产品数量') | ||
399 | + ->setCellValue('G1', '总金额') | ||
400 | + ->setCellValue('H1', '下单时间'); | ||
401 | + $rowIndex = 2; | ||
402 | + | ||
403 | + foreach ($json as $k => $v) { | ||
404 | + $objPHPExcel->getActiveSheet() | ||
405 | + ->setCellValue('A' . $rowIndex, $v['order_code']) | ||
406 | + ->setCellValue('B' . $rowIndex, $v['goods_name']) | ||
407 | + ->setCellValue('C' . $rowIndex, $v['name']) | ||
408 | + ->setCellValue('D' . $rowIndex, $v['phone']) | ||
409 | + ->setCellValue('E' . $rowIndex, $v['address']) | ||
410 | + ->setCellValue('F' . $rowIndex, $v['num']) | ||
411 | + ->setCellValue('G' . $rowIndex, $v['price']) | ||
412 | + ->setCellValue('H' . $rowIndex, $v['addTime']); | ||
413 | + $rowIndex++; | ||
414 | + } | ||
415 | + | ||
416 | + $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(25); | ||
417 | + $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25); | ||
418 | + $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25); | ||
419 | + $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(25); | ||
420 | + $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(25); | ||
421 | + $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(25); | ||
422 | + $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(25); | ||
423 | + $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(25); | ||
424 | + | ||
425 | + $filename = '产品订单列表'; | ||
426 | + header('Content-Type: application/vnd.ms-excel'); | ||
427 | + | ||
428 | + $ua = $_SERVER["HTTP_USER_AGENT"]; | ||
429 | + header('Content-type: text/html; charset=gbk'); | ||
430 | + header("Content-type:application/vnd.ms-excel;charset=gbk"); | ||
431 | + //兼容IE11 | ||
432 | + if (preg_match("/MSIE/", $ua) || preg_match("/Trident\/7.0/", $ua)) { | ||
433 | + header('Content-Disposition: attachment;filename="' . urlencode($filename) . '.xls"'); | ||
434 | + } else if (preg_match("/Firefox/", $ua)) { | ||
435 | + header('Content-Disposition: attachment;filename*="' . $filename . '.xls"'); | ||
436 | + } else { | ||
437 | + header('Content-Disposition: attachment; filename="' . $filename . '.xls"'); | ||
438 | + } | ||
439 | + header('Cache-Control: max-age=0'); | ||
440 | + header('Cache-Control: max-age=1'); | ||
441 | + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | ||
442 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); | ||
443 | + header('Cache-Control: cache, must-revalidate'); | ||
444 | + header('Pragma: public'); | ||
445 | + $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); | ||
446 | + $objWriter->save('php://output'); | ||
447 | + | ||
448 | + } | ||
449 | + | ||
450 | +} |
application/products/controller/Role.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Administrator | ||
5 | + * Date: 2020/6/24 | ||
6 | + * Time: 15:30 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace app\products\controller; | ||
10 | +use app\web\controller\BaseController; | ||
11 | + | ||
12 | +use think\Db; | ||
13 | +use think\Request; | ||
14 | + | ||
15 | +class Role extends BaseController | ||
16 | +{ | ||
17 | + | ||
18 | + public function user_management(){ | ||
19 | + | ||
20 | + return $this->fetch(); | ||
21 | + } | ||
22 | + //获取用户列表 | ||
23 | + public function getUsers(){ | ||
24 | + | ||
25 | + //$org_id = session('organization.org_id'); | ||
26 | + $list= Db::table('sos_user_role')->select()->toArray(); | ||
27 | + | ||
28 | + $type=['','试用期','正式员工','已离职']; | ||
29 | + foreach($list as $key=>$val ){ | ||
30 | + $list[$key]['sex']=$val['sex'] == 1? '男' : '女'; | ||
31 | + //所属机构 | ||
32 | + if($val['mechanism'] != 0){ | ||
33 | + $mechanism= Db::table('sos_user_mechanism')->field('mechanismName')->where('id',$val['mechanism'])->find(); | ||
34 | + } | ||
35 | + $list[$key]['mechanism']=$val['mechanism'] == 0? '男' : $mechanism['mechanismName']; | ||
36 | + //所属部门 | ||
37 | + if($val['department'] != 0){ | ||
38 | + $department= Db::table('sos_user_department')->field('departmentName')->where('id',$val['department'])->find(); | ||
39 | + } | ||
40 | + $list[$key]['department']=$val['department'] == 0? '男' : $department['departmentName']; | ||
41 | + $list[$key]['status']=$type[$val['status']]; | ||
42 | + | ||
43 | + $list[$key]['entryTime']=date('Y-m-d H:i:s',$val['entryTime']); | ||
44 | + $list[$key]['quitTime']=$val['quitTime'] == ''? '' : date('Y-m-d H:i:s',$val['entryTime']); | ||
45 | + | ||
46 | + } | ||
47 | + | ||
48 | + | ||
49 | + | ||
50 | + $result["total"] =count($list); | ||
51 | + $result['rows']=$list; | ||
52 | + echo json_encode($result); | ||
53 | + } | ||
54 | + // 添加用户 | ||
55 | + | ||
56 | + public function store(Request $request) | ||
57 | + { | ||
58 | + $data = $request->post(); | ||
59 | + | ||
60 | + $validate = new UserValidate(); | ||
61 | + $err_msg = $validate->scene("add")->check($data); | ||
62 | + | ||
63 | + if ($err_msg) { | ||
64 | + return json($this->renderError($validate->getError())); | ||
65 | + } | ||
66 | + | ||
67 | + $res = json_decode(curlPost($this->getUrl('add'), $data),true); | ||
68 | + | ||
69 | + if ($res['code'] == self::SUCCESS_CODE) { | ||
70 | + return json($this->renderSuccess()); | ||
71 | + } | ||
72 | + | ||
73 | + return json($res); | ||
74 | + | ||
75 | + } | ||
76 | + //修改用户 | ||
77 | + public function edit(Request $request){ | ||
78 | + $data = $request->post(); | ||
79 | + if($data['id']){ | ||
80 | + $data['uid'] = $data['id']; | ||
81 | + } | ||
82 | + | ||
83 | + $validate = new UserValidate(); | ||
84 | + $err_msg = $validate->scene("update")->check($data); | ||
85 | + | ||
86 | + if ($err_msg) { | ||
87 | + return json($this->renderError($validate->getError())); | ||
88 | + } | ||
89 | + | ||
90 | + $res = json_decode(curlPost($this->getUrl('edit'), $data),true); | ||
91 | + | ||
92 | + if ($res['code'] == self::SUCCESS_CODE) { | ||
93 | + return json($this->renderSuccess()); | ||
94 | + } | ||
95 | + | ||
96 | + return json($res); | ||
97 | + | ||
98 | + } | ||
99 | + //删除用户 | ||
100 | + public function del(Request $request){ | ||
101 | + $data = $request->get(); | ||
102 | + | ||
103 | + if (empty($data['id']) && $data['id'] !== 0) { | ||
104 | + return json($this->renderError("删除失败!")); | ||
105 | + } | ||
106 | + $res = json_decode(curlPost($this->getUrl("del"),['uid'=>$data['id']]),true); | ||
107 | + | ||
108 | + if ($res['code'] != self::SUCCESS_CODE) { | ||
109 | + return json($res); | ||
110 | + } | ||
111 | + | ||
112 | + return json($this->renderSuccess()); | ||
113 | + } | ||
114 | +} |
1 | +<?php | ||
2 | +namespace app\products\controller; | ||
3 | + | ||
4 | + | ||
5 | +use app\serviceapi\controller\TurnPrize as TurnPrizeModel; | ||
6 | +use app\web\controller\BaseController; | ||
7 | +use think\Log; | ||
8 | +use think\Request; | ||
9 | +use util\MCurl; | ||
10 | +use think\Cookie; | ||
11 | +use think\Session; | ||
12 | +header("Content-type: text/html; charset=utf-8"); | ||
13 | +header('Access-Control-Allow-Origin:*'); | ||
14 | +header('Content-Type: application/json; charset=utf-8'); | ||
15 | +header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS'); | ||
16 | +header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); | ||
17 | +/** | ||
18 | + * 功能描述 抽奖管理 | ||
19 | + * Class TurnTable | ||
20 | + * @package app\products\controller | ||
21 | + * Date: 2020/8/25 | ||
22 | + * Time: 10:00 | ||
23 | + * @author nyq | ||
24 | + */ | ||
25 | +class TurnPrize extends BaseController | ||
26 | +{ | ||
27 | + private $appid = 'wx3e41adc018004fd1'; | ||
28 | + private $appsecrt = 'f072ba0a6dbb24a2f6b504259367ecfc'; | ||
29 | + | ||
30 | + //请求地址 | ||
31 | + //private $api_url = "http://demo8.xiaochakeji.com/serviceapi/prize/"; | ||
32 | + //查询接口 | ||
33 | + //本地 | ||
34 | + //private $api_url = "www.aisigit.com/products/Turn_prize/"; | ||
35 | + //测试 | ||
36 | + //private $api_url = "http://demo6.xiaochakeji.com/products/Turn_prize/"; | ||
37 | + //生产 | ||
38 | + // private $api_url = "http://hzy.sosyun.com/products/Turn_prize/"; | ||
39 | + | ||
40 | + | ||
41 | + /** | ||
42 | + * 函数功能描述 微信分享获取AccessToken | ||
43 | + * Date: 2020/8/31 | ||
44 | + * Time: 10:00 | ||
45 | + * @author nyq | ||
46 | + */ | ||
47 | + public function getAccessToken() { | ||
48 | + //查询数据表里面的值 | ||
49 | + $data['appid']= $this->appid; | ||
50 | + $data['appsecrt']= $this->appsecrt; | ||
51 | + $prize_win_model = new TurnPrizeModel(); | ||
52 | + $info = $prize_win_model->getAccessToken(); | ||
53 | + //$info = MCurl::instance($this->api_url."getAccessToken")->post($data); | ||
54 | + $info = json_decode($info,true); | ||
55 | + | ||
56 | + if(empty($info) || $info['expires_in'] < time()){ | ||
57 | + //获取token的值 | ||
58 | + $url_token = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $this->appid . "&secret=" . $this->appsecrt; | ||
59 | + $tmp = $this->curl_get($url_token); //json格式 | ||
60 | + $obj = json_decode($tmp,true); | ||
61 | + if($obj['access_token'] != null){ | ||
62 | + $data['access_token'] = $obj['access_token']; | ||
63 | + $data['expires_in'] = time() + $obj['expires_in']; | ||
64 | + | ||
65 | + if($info){ | ||
66 | + $data['id'] = $info['id']; | ||
67 | + $arr = $prize_win_model->updateAccessToken($data); | ||
68 | + //$arr = MCurl::instance($this->api_url."updateAccessToken")->post($data); | ||
69 | + }else{ | ||
70 | + $arr = $prize_win_model->addAccessToken($data); | ||
71 | + // $arr = MCurl::instance($this->api_url."addAccessToken")->post($data); | ||
72 | + | ||
73 | + } | ||
74 | + return $data; | ||
75 | + }else return 'error'; | ||
76 | + }else return $info; | ||
77 | + } | ||
78 | + /** | ||
79 | + * 函数功能描述 微信分享获取Ticket | ||
80 | + * Date: 2020/8/31 | ||
81 | + * Time: 10:00 | ||
82 | + * @author nyq | ||
83 | + */ | ||
84 | + public function getTicket(){ | ||
85 | + $token = $this->getAccessToken(); | ||
86 | + | ||
87 | + if(empty($token['jsapi_ticket']) || $token['expires_in'] < time()){ | ||
88 | + $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=".$token['access_token']."&type=jsapi"; | ||
89 | + $tmp = $this->curl_get($url); //json格式 | ||
90 | + $obj = json_decode($tmp,true); | ||
91 | + | ||
92 | + $data['id'] = $token['id']; | ||
93 | + $data['jsapi_ticket'] = $obj['jsapi_ticket']; | ||
94 | + $prize_win_model = new TurnPrizeModel(); | ||
95 | + $arr = $prize_win_model->updateAccessToken($data); | ||
96 | + //$arr = MCurl::instance($this->api_url."updateAccessToken")->post($data); | ||
97 | + return $obj['jsapi_ticket']; | ||
98 | + | ||
99 | + }else{ | ||
100 | + | ||
101 | + return $token['jsapi_ticket']; | ||
102 | + } | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
106 | + * 函数功能描述 微信分享获取sdk | ||
107 | + * Date: 2020/8/31 | ||
108 | + * Time: 10:00 | ||
109 | + * @author nyq | ||
110 | + */ | ||
111 | + public function generateSign(Request $request){ | ||
112 | + $dataurl = $request->param('url'); | ||
113 | + //echo $dataurl;die; | ||
114 | + $url=str_replace('amp;','',$dataurl); | ||
115 | + $noncestr = uniqid(); | ||
116 | + $timestamp = time(); | ||
117 | + //$url = 'http://' . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; | ||
118 | + $ticket = $this->getTicket(); | ||
119 | + | ||
120 | + if ($ticket) { | ||
121 | + $str = 'jsapi_ticket='.$ticket.'&noncestr='.$noncestr.'×tamp='.$timestamp.'&url='.$url; | ||
122 | + //return $str;die; | ||
123 | + $signature = sha1($str); | ||
124 | + | ||
125 | + $data['ticket'] = $ticket; | ||
126 | + $data['noncestr'] = $noncestr; | ||
127 | + $data['timestamp'] = $timestamp; | ||
128 | + $data['signature'] = $signature; | ||
129 | + $data['appId'] = $this->appid; | ||
130 | + $data['link'] = $url; | ||
131 | + return $data; | ||
132 | + } | ||
133 | + } | ||
134 | + | ||
135 | + | ||
136 | + /** | ||
137 | + * 函数功能描述 抽奖用户模拟微信授权 返回 openid | ||
138 | + * Date: 2020/8/26 | ||
139 | + * Time: 10:00 | ||
140 | + * @author nyq | ||
141 | + */ | ||
142 | + | ||
143 | + public function getWxCode(Request $request) | ||
144 | + { | ||
145 | + $data = $request->param(); | ||
146 | + $code=$data['code']; | ||
147 | + $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $this->appid . "&secret=" . $this->appsecrt . "&code=$code&grant_type=authorization_code"; | ||
148 | + $r = $this->curl_get($url); | ||
149 | + $openid=json_decode($r,true); | ||
150 | + return $openid; | ||
151 | + } | ||
152 | + | ||
153 | + | ||
154 | + | ||
155 | + /** | ||
156 | + * 函数功能描述 获取订单信息 / 获取奖品列表接口 | ||
157 | + * Date: 2020/8/27 | ||
158 | + * Time: 10:00 | ||
159 | + * @author nyq | ||
160 | + */ | ||
161 | + public function prize_list(Request $request) | ||
162 | + { | ||
163 | + $data = $request->param(); | ||
164 | + //分页暂未开启,保留. | ||
165 | + $page = isset($_POST['page']) ? intval($_POST['page']) : 1; | ||
166 | + $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 25; | ||
167 | + $offset=($page-1)*$rows; | ||
168 | + $data['offset']=$offset; | ||
169 | + $data['rows']=$rows; | ||
170 | + | ||
171 | + $prize_win_model = new TurnPrizeModel(); | ||
172 | + $res = $prize_win_model->prizeList($data); | ||
173 | + | ||
174 | + //$res = MCurl::instance($this->api_url."prizeList")->post($data); | ||
175 | + | ||
176 | + $json=json_decode($res,true); | ||
177 | + | ||
178 | + foreach($json as $key=>$val ){ | ||
179 | + $json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']); | ||
180 | + if($val['display'] ==0){ | ||
181 | + $json[$key]['display']="已发布"; | ||
182 | + }else{ | ||
183 | + $json[$key]['display']="未发布"; | ||
184 | + } | ||
185 | + } | ||
186 | + $result["total"] =count($json); | ||
187 | + $result['rows']=$json; | ||
188 | + echo json_encode($result); | ||
189 | + //return $json; | ||
190 | + } | ||
191 | + | ||
192 | + /** | ||
193 | + * 函数功能描述 文件上传 | ||
194 | + * Date: 2020/8/07 | ||
195 | + * Time: 10:00 | ||
196 | + * @author nyq | ||
197 | + */ | ||
198 | + public function uploadFileImgs(){ | ||
199 | + $files = request()->file('files'); | ||
200 | + $path = input('path'); | ||
201 | + if($files){ | ||
202 | + $imgarr = []; | ||
203 | + foreach($files as $file){ | ||
204 | + $info = $file->validate(['size'=>204800000,'ext'=>'jpg,png,gif'])->move(ROOT_PATH . 'public/web/' . DS . 'prize'); | ||
205 | + if($info){ | ||
206 | + $newurl = '/web/prize/'.$info->getSaveName(); | ||
207 | + $img= str_replace('\\','/',$newurl); | ||
208 | + | ||
209 | + $imgarr[]=$img; | ||
210 | + } | ||
211 | + } | ||
212 | + return json_encode($imgarr); | ||
213 | + }else{ | ||
214 | + echo '没有图片上传'; | ||
215 | + } | ||
216 | + } | ||
217 | + | ||
218 | + | ||
219 | + /** | ||
220 | + * 函数功能描述 删除中奖用户列表 | ||
221 | + * Date: 2020/8/07 | ||
222 | + * Time: 10:00 | ||
223 | + * @author nyq | ||
224 | + */ | ||
225 | + public function del_user() | ||
226 | + { | ||
227 | + $data = $this->request->post(); | ||
228 | + | ||
229 | + $prize_win_model = new TurnPrizeModel(); | ||
230 | + $res = $prize_win_model->delUser($data); | ||
231 | + //$res = MCurl::instance($this->api_url."delUser")->post($data); | ||
232 | + | ||
233 | + $json=json_decode($res,true); | ||
234 | + if(is_numeric($json)){ | ||
235 | + $data=[ | ||
236 | + 'code'=>200, | ||
237 | + 'msg'=>'删除成功' | ||
238 | + ]; | ||
239 | + }else{ | ||
240 | + $data=[ | ||
241 | + 'code'=>100, | ||
242 | + 'msg'=>'删除失败' | ||
243 | + ]; | ||
244 | + } | ||
245 | + return $data; | ||
246 | + | ||
247 | + } | ||
248 | + | ||
249 | + /** | ||
250 | + * 函数功能描述 添加奖品 | ||
251 | + * Date: 2020/8/07 | ||
252 | + * Time: 10:00 | ||
253 | + * @author nyq | ||
254 | + */ | ||
255 | + public function prize_add(Request $request) | ||
256 | + { | ||
257 | + $data = $request->param(); | ||
258 | + $data['addTime']=time(); | ||
259 | + | ||
260 | + $prize_win_model = new TurnPrizeModel(); | ||
261 | + $res = $prize_win_model->prizeAdd($data); | ||
262 | + //return $res; | ||
263 | + | ||
264 | + // $res = MCurl::instance($this->api_url."prizeAdd")->post($data); | ||
265 | + $json=json_decode($res,true); | ||
266 | + if(is_numeric($json)){ | ||
267 | + $data=[ | ||
268 | + 'code'=>200, | ||
269 | + 'msg'=>'修改成功' | ||
270 | + ]; | ||
271 | + }else{ | ||
272 | + $data=[ | ||
273 | + 'code'=>100, | ||
274 | + 'msg'=>'修改失败' | ||
275 | + ]; | ||
276 | + } | ||
277 | + return $data; | ||
278 | + } | ||
279 | + | ||
280 | + /** | ||
281 | + * 函数功能描述 中奖用户列表 | ||
282 | + * Date: 2020/8/26 | ||
283 | + * Time: 10:00 | ||
284 | + * @author nyq | ||
285 | + */ | ||
286 | + public function prize_user_list(Request $request) | ||
287 | + { | ||
288 | + $data = $request->param(); | ||
289 | + | ||
290 | + $page = $data['page']; | ||
291 | + $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; | ||
292 | + $offset=($page-1)*$rows; | ||
293 | + $data['offset']=$offset; | ||
294 | + $data['rows']=$rows; | ||
295 | + | ||
296 | + $prize_win_model = new TurnPrizeModel(); | ||
297 | + $res = $prize_win_model->prizeUserList($data); | ||
298 | + //var_dump($res); die; | ||
299 | + //$res = MCurl::instance($this->api_url."prizeUserList")->post($data); | ||
300 | + | ||
301 | + //$res=json_decode($res,true); | ||
302 | + $json=$res['rows']; | ||
303 | + unset($data['id']); | ||
304 | + Cookie::set('data', $data); | ||
305 | + foreach($json as $key=>$val ){ | ||
306 | + $json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']); | ||
307 | + if(isset($val['num']) && $val['num'] !=1 ){ | ||
308 | + $json[$key]['prizeName']="双击查看"; | ||
309 | + } | ||
310 | + | ||
311 | + if($val['receive'] ==0){ | ||
312 | + $json[$key]['receive']="未领取"; | ||
313 | + }else{ | ||
314 | + $json[$key]['receive']="已领取"; | ||
315 | + } | ||
316 | + } | ||
317 | + $last_names = array_column($json,'addTime'); | ||
318 | + array_multisort($last_names,SORT_DESC,$json); | ||
319 | + | ||
320 | + //获取当前的条数 | ||
321 | +// if(isset($data['phone'])&&!empty($data['phone'])) { | ||
322 | +// $count = count($json); | ||
323 | +// }else{ | ||
324 | +// $count = MCurl::instance($this->api_url . "prizeUserCount")->post($data); | ||
325 | +// $count = json_decode($count, true); | ||
326 | + // } | ||
327 | + $result["total"] =$res['total']; | ||
328 | + $result['rows']=$json; | ||
329 | + echo json_encode($result); | ||
330 | + //return $json; | ||
331 | + } | ||
332 | + /** | ||
333 | + * 函数功能描述 导出数据到表格 | ||
334 | + * Date: 2020/8/26 | ||
335 | + * Time: 10:00 | ||
336 | + * @author nyq | ||
337 | + */ | ||
338 | + public function to_excel() | ||
339 | + { | ||
340 | + $data = $this->request->Post(); | ||
341 | + $data= Cookie::get('data'); | ||
342 | + $data['to_excel']=1; | ||
343 | + $prize_win_model = new TurnPrizeModel(); | ||
344 | + $json = $prize_win_model->prizeUserList($data); | ||
345 | + //$res = MCurl::instance($this->api_url."prizeUserList")->post($data); | ||
346 | + | ||
347 | + // $json=json_decode($res,true); | ||
348 | + foreach($json as $key=>$val ){ | ||
349 | + $json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']); | ||
350 | + } | ||
351 | + ob_end_clean();//清除缓冲区,避免乱码 | ||
352 | + Vendor('PHPExcel.PHPExcel'); | ||
353 | + $objPHPExcel=new \PHPExcel(); | ||
354 | + $objPHPExcel->setActiveSheetIndex(0) | ||
355 | + ->setCellValue('A1', '用户名') | ||
356 | + ->setCellValue('B1', '电话') | ||
357 | + ->setCellValue('C1', '奖品名称') | ||
358 | + ->setCellValue('D1', '部门') | ||
359 | + ->setCellValue('E1', '时间'); | ||
360 | + $rowIndex = 2; | ||
361 | + | ||
362 | + foreach ($json as $k => $v) { | ||
363 | + $objPHPExcel->getActiveSheet() | ||
364 | + ->setCellValue('A' . $rowIndex, $v['uname']) | ||
365 | + ->setCellValue('B' . $rowIndex, $v['phone']) | ||
366 | + ->setCellValue('C' . $rowIndex, $v['prizeName']) | ||
367 | + ->setCellValue('D' . $rowIndex, $v['source']) | ||
368 | + ->setCellValue('E' . $rowIndex, $v['addTime']); | ||
369 | + $rowIndex++; | ||
370 | + } | ||
371 | + | ||
372 | + $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(25); | ||
373 | + $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25); | ||
374 | + $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25); | ||
375 | + $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(25); | ||
376 | + $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(25); | ||
377 | + | ||
378 | + $filename = '抽奖用户数据表'; | ||
379 | + header('Content-Type: application/vnd.ms-excel'); | ||
380 | + | ||
381 | + $ua = $_SERVER["HTTP_USER_AGENT"]; | ||
382 | + header('Content-type: text/html; charset=gbk'); | ||
383 | + header("Content-type:application/vnd.ms-excel;charset=gbk"); | ||
384 | + //兼容IE11 | ||
385 | + if (preg_match("/MSIE/", $ua) || preg_match("/Trident\/7.0/", $ua)) { | ||
386 | + header('Content-Disposition: attachment;filename="' . urlencode($filename) . '.xls"'); | ||
387 | + } else if (preg_match("/Firefox/", $ua)) { | ||
388 | + header('Content-Disposition: attachment;filename*="' . $filename . '.xls"'); | ||
389 | + } else { | ||
390 | + header('Content-Disposition: attachment; filename="' . $filename . '.xls"'); | ||
391 | + } | ||
392 | + header('Cache-Control: max-age=0'); | ||
393 | + header('Cache-Control: max-age=1'); | ||
394 | + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | ||
395 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); | ||
396 | + header('Cache-Control: cache, must-revalidate'); | ||
397 | + header('Pragma: public'); | ||
398 | + $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); | ||
399 | + $objWriter->save('php://output'); | ||
400 | + | ||
401 | + } | ||
402 | + | ||
403 | + /** | ||
404 | + * 函数功能描述 重置抽奖次数 | ||
405 | + * Date: 2020/8/26 | ||
406 | + * Time: 10:00 | ||
407 | + * @author nyq | ||
408 | + */ | ||
409 | + public function prize_reset(Request $request) | ||
410 | + { | ||
411 | + //$data = $request->param(); | ||
412 | + | ||
413 | + $prize_win_model = new TurnPrizeModel(); | ||
414 | + $res = $prize_win_model->prizeReset(); | ||
415 | + | ||
416 | + //$res = MCurl::instance($this->api_url."prizeReset")->post($data); | ||
417 | + $json=json_decode($res,true); | ||
418 | + if(is_numeric($json)){ | ||
419 | + $data=[ | ||
420 | + 'code'=>200, | ||
421 | + 'msg'=>'重置成功' | ||
422 | + ]; | ||
423 | + }else{ | ||
424 | + $data=[ | ||
425 | + 'code'=>100, | ||
426 | + 'msg'=>'重置失败' | ||
427 | + ]; | ||
428 | + } | ||
429 | + return $data; | ||
430 | + } | ||
431 | + | ||
432 | + /** | ||
433 | + * 函数功能描述 规则设置 // 获取抽奖规则接口 | ||
434 | + * Date: 2020/8/26 | ||
435 | + * Time: 10:00 | ||
436 | + * @author nyq | ||
437 | + */ | ||
438 | + public function prize_rule(Request $request) | ||
439 | + { | ||
440 | + //$data = $request->param(); | ||
441 | + $prize_win_model = new TurnPrizeModel(); | ||
442 | + $res = $prize_win_model->prizeRule(); | ||
443 | + //$res = MCurl::instance($this->api_url."prizeRule")->post($data); | ||
444 | + $json=json_decode($res,true); | ||
445 | + $code="fg5Fu7Is9aHJ5ug5".time(); | ||
446 | + $json['openid']=$code; | ||
447 | + return $json; | ||
448 | +// $json=json_encode($res); | ||
449 | +// $aa= html_entity_decode($json); | ||
450 | +// //数据特殊符号转义 | ||
451 | +// $aa = htmlspecialchars_decode($aa); | ||
452 | +// return $aa; | ||
453 | + } | ||
454 | + | ||
455 | + | ||
456 | + /** | ||
457 | + * 函数功能描述 修改规则设置 | ||
458 | + * Date: 2020/8/26 | ||
459 | + * Time: 10:00 | ||
460 | + * @author nyq | ||
461 | + */ | ||
462 | + public function prize_rule_edit(Request $request) | ||
463 | + { | ||
464 | + $data = $request->param(); | ||
465 | + //file_put_contents('aaqq.txt',$data); | ||
466 | + //$data['title']=json_encode($data['title'],true); | ||
467 | + $data['addTime']=time(); | ||
468 | + | ||
469 | + //return $data; | ||
470 | + if(isset($data['open']) && $data['open']=="on"){ | ||
471 | + $data['open']=1; | ||
472 | + }else{ | ||
473 | + $data['open']=0; | ||
474 | + } | ||
475 | + $prize_win_model = new TurnPrizeModel(); | ||
476 | + $res = $prize_win_model->prizeRuleEdit($data); | ||
477 | + //$res = MCurl::instance($this->api_url."prizeRuleEdit")->post($data); | ||
478 | + $json=json_decode($res,true); | ||
479 | + | ||
480 | + if(is_numeric($json)){ | ||
481 | + $data=[ | ||
482 | + 'code'=>200, | ||
483 | + 'msg'=>'修改成功' | ||
484 | + ]; | ||
485 | + }else{ | ||
486 | + $data=[ | ||
487 | + 'code'=>100, | ||
488 | + 'msg'=>'修改失败' | ||
489 | + ]; | ||
490 | + } | ||
491 | + return $data; | ||
492 | + | ||
493 | + } | ||
494 | + | ||
495 | + | ||
496 | + /** | ||
497 | + * 函数功能描述 获取抽奖规则接口 | ||
498 | + * Date: 2020/8/26 | ||
499 | + * Time: 10:00 | ||
500 | + * @author nyq | ||
501 | + */ | ||
502 | + | ||
503 | + public function prize_rule_api(Request $request) | ||
504 | + { | ||
505 | + $data = $request->param(); | ||
506 | + $prize_win_model = new TurnPrizeModel(); | ||
507 | + $res = $prize_win_model->prizeRuleEdit($data); | ||
508 | + // $res = MCurl::instance($this->api_url."prizeRuleEdit")->post($data); | ||
509 | + $json=json_decode($res,true); | ||
510 | + if(is_numeric($json)){ | ||
511 | + $data=[ | ||
512 | + 'code'=>200, | ||
513 | + 'msg'=>'重置成功' | ||
514 | + ]; | ||
515 | + }else{ | ||
516 | + $data=[ | ||
517 | + 'code'=>100, | ||
518 | + 'msg'=>'重置失败' | ||
519 | + ]; | ||
520 | + } | ||
521 | + return $data; | ||
522 | + | ||
523 | + } | ||
524 | + | ||
525 | + /** | ||
526 | + * 函数功能描述 首次进入 合适身份信息 | ||
527 | + * Date: 2020/8/26 | ||
528 | + * Time: 10:00 | ||
529 | + * @author nyq | ||
530 | + */ | ||
531 | + public function sel_prize_member(Request $request) | ||
532 | + { | ||
533 | + $data = $request->param(); | ||
534 | + //给我 openID number | ||
535 | + //查看当前用户是否存在 | ||
536 | + $prize_win_model = new TurnPrizeModel(); | ||
537 | + $res = $prize_win_model->selPrizeMember($data); | ||
538 | + | ||
539 | + return $res; | ||
540 | + | ||
541 | +// //$res = MCurl::instance($this->api_url."selPrizeMember")->post($data); | ||
542 | +// $json=json_decode($res,true); | ||
543 | +// return $json; | ||
544 | + } | ||
545 | + | ||
546 | + | ||
547 | + /** | ||
548 | + * 函数功能描述 抽奖接口 | ||
549 | + * Date: 2020/8/26 | ||
550 | + * Time: 10:00 | ||
551 | + * @author nyq | ||
552 | + */ | ||
553 | + public function luck_draw(Request $request) | ||
554 | + { | ||
555 | + //传递 openID prize_id | ||
556 | + $data = $request->param(); | ||
557 | + | ||
558 | + //查看当前用户是否存在 | ||
559 | + $prize_win_model = new TurnPrizeModel(); | ||
560 | + $json = $prize_win_model->luckDraw($data); | ||
561 | + //$res = MCurl::instance($this->api_url."luckDraw")->post($data); | ||
562 | + //$json=json_decode($res,true); | ||
563 | + //传递 openID prize_id | ||
564 | + return $json; | ||
565 | + } | ||
566 | + | ||
567 | + /** | ||
568 | + * 函数功能描述 获取最新的20条中奖列表 / 个人的奖品列表 | ||
569 | + * Date: 2020/8/26 | ||
570 | + * Time: 10:00 | ||
571 | + * @author nyq | ||
572 | + */ | ||
573 | + public function win_list(Request $request) | ||
574 | + { | ||
575 | + //传递 openID | ||
576 | + $data = $request->param(); | ||
577 | + //查看当前用户是否存在 | ||
578 | + $prize_win_model = new TurnPrizeModel(); | ||
579 | + $res = $prize_win_model->prizeWinList($data); | ||
580 | + //$res = MCurl::instance($this->api_url."prizeWinList")->post($data); | ||
581 | + $json=json_decode($res,true); | ||
582 | + foreach($json as $key=>$val ){ | ||
583 | + $json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']); | ||
584 | + } | ||
585 | + //传递 openID prize_id | ||
586 | + return $json; | ||
587 | + } | ||
588 | + | ||
589 | + /** | ||
590 | + * 函数功能描述 兑奖接口 | ||
591 | + * Date: 2020/8/26 | ||
592 | + * Time: 10:00 | ||
593 | + * @author nyq | ||
594 | + */ | ||
595 | + public function cash_prize(Request $request) | ||
596 | + { | ||
597 | + //传递 openID | ||
598 | + $data = $request->param(); | ||
599 | + //查看当前用户是否存在 | ||
600 | + $prize_win_model = new TurnPrizeModel(); | ||
601 | + $res = $prize_win_model->cashPrize($data); | ||
602 | + //$res = MCurl::instance($this->api_url."cashPrize")->post($data); | ||
603 | + $json=json_decode($res,true); | ||
604 | + | ||
605 | + if($json==1){ | ||
606 | + $data=[ | ||
607 | + 'code'=>200, | ||
608 | + 'msg'=>'成功' | ||
609 | + ]; | ||
610 | + }else{ | ||
611 | + $data=[ | ||
612 | + 'code'=>100, | ||
613 | + 'msg'=>'失败' | ||
614 | + ]; | ||
615 | + } | ||
616 | + | ||
617 | + //传递 openID prize_id | ||
618 | + return $data; | ||
619 | + } | ||
620 | + | ||
621 | + /** | ||
622 | + * 发起GET请求 | ||
623 | + * @param string $url 请求地址 | ||
624 | + * @param array $data 请求参数 | ||
625 | + * @param string $cookiePath 请求所保存的cookie路径 | ||
626 | + */ | ||
627 | + function curl_get($url, $data=[], $cookiePath = '') | ||
628 | + { | ||
629 | + if(count($data)!=0) { | ||
630 | + $url = get_query_url($url, $data); | ||
631 | + } | ||
632 | + $ch = curl_init(); | ||
633 | + curl_setopt($ch, CURLOPT_URL, $url); | ||
634 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
635 | + curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiePath); | ||
636 | + curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiePath); | ||
637 | + curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0); | ||
638 | + curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0); | ||
639 | + $res = curl_exec($ch); | ||
640 | + curl_close($ch); | ||
641 | + return $res; | ||
642 | + | ||
643 | + } | ||
644 | + | ||
645 | + | ||
646 | + | ||
647 | + | ||
648 | +} |
application/products/model/ProductUser.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | + | ||
4 | +namespace app\products\model; | ||
5 | + | ||
6 | +use app\common\model\products\ProductUser as ProductUserModel; | ||
7 | + | ||
8 | +/** | ||
9 | + * 功能描述 保险产品用户表 | ||
10 | + * Class ProductUser | ||
11 | + * @package app\products\model | ||
12 | + * Date: 2020/7/14 | ||
13 | + * Time: 9:49 | ||
14 | + * @author gxd | ||
15 | + */ | ||
16 | +class ProductUser extends ProductUserModel | ||
17 | +{ | ||
18 | + /** | ||
19 | + * 函数功能描述 获取用户是否有推广权限 | ||
20 | + * Date: 2020/7/14 | ||
21 | + * Time: 11:15 | ||
22 | + * @author gxd | ||
23 | + */ | ||
24 | + public function getPrimByUidAndType($uid,$utype=2,$field="*") { | ||
25 | + $res = static::field($field)->where("user_id", $uid)->find(); | ||
26 | + return $res; | ||
27 | + } | ||
28 | + | ||
29 | +} |
application/products/model/Products.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | + | ||
4 | +namespace app\products\model; | ||
5 | +use app\common\model\products\Products as ProductsModel; | ||
6 | + | ||
7 | +/** | ||
8 | + * 功能描述 保险产品表 | ||
9 | + * Class Products | ||
10 | + * @package app\products\model | ||
11 | + * Date: 2020/7/14 | ||
12 | + * Time: 9:49 | ||
13 | + * @author gxd | ||
14 | + */ | ||
15 | +class Products extends ProductsModel | ||
16 | +{ | ||
17 | + | ||
18 | +} |
-
请 注册 或 登录 后发表评论