code review by fei.hong : do modify weixin and aliwap pay notice url to java
Showing
31 changed files
with
919 additions
and
104 deletions
@@ -18,17 +18,17 @@ class Yohobuy | @@ -18,17 +18,17 @@ class Yohobuy | ||
18 | { | 18 | { |
19 | /* 正式环境 */ | 19 | /* 正式环境 */ |
20 | // php API | 20 | // php API |
21 | - const API_URL = 'http://api2.open.yohobuy.com/'; | ||
22 | - const API_URL2 = 'http://api.open.yohobuy.com/'; | ||
23 | - const SERVICE_URL = 'http://service.api.yohobuy.com/'; | ||
24 | - const YOHOBUY_URL = 'http://www.yohobuy.com/'; | 21 | +// const API_URL = 'http://api2.open.yohobuy.com/'; |
22 | +// const API_URL2 = 'http://api.open.yohobuy.com/'; | ||
23 | +// const SERVICE_URL = 'http://service.api.yohobuy.com/'; | ||
24 | +// const YOHOBUY_URL = 'http://www.yohobuy.com/'; | ||
25 | 25 | ||
26 | //java API | 26 | //java API |
27 | -// const API_URL = 'http://apih5.yoho.cn/'; | ||
28 | -// const API_URL2 = 'http://apih5.yoho.cn/'; | ||
29 | -// const SERVICE_URL = 'http://serviceh5.yoho.cn/'; | ||
30 | -// const YOHOBUY_URL = 'http://www.yohobuy.com/'; | ||
31 | -// const API_OLD = 'http://api2.open.yohobuy.com/'; | 27 | + const API_URL = 'http://apih5.yoho.cn/'; |
28 | + const API_URL2 = 'http://apih5.yoho.cn/'; | ||
29 | + const SERVICE_URL = 'http://serviceh5.yoho.cn/'; | ||
30 | + const YOHOBUY_URL = 'http://www.yohobuy.com/'; | ||
31 | + const API_OLD = 'http://api2.open.yohobuy.com/'; | ||
32 | 32 | ||
33 | /* 测试环境 */ | 33 | /* 测试环境 */ |
34 | // const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/' | 34 | // const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/' |
@@ -403,7 +403,7 @@ class Yohobuy | @@ -403,7 +403,7 @@ class Yohobuy | ||
403 | * @see http://php.net/manual/zh/class.yar-concurrent-client.php | 403 | * @see http://php.net/manual/zh/class.yar-concurrent-client.php |
404 | * @param string $uri | 404 | * @param string $uri |
405 | * @param string $method | 405 | * @param string $method |
406 | - * @param array $parameter | 406 | + * @param array $parameters |
407 | * @param callable $callback | 407 | * @param callable $callback |
408 | * @param int $timeout | 408 | * @param int $timeout |
409 | * @return void | 409 | * @return void |
@@ -99,32 +99,6 @@ class Cache | @@ -99,32 +99,6 @@ class Cache | ||
99 | } | 99 | } |
100 | 100 | ||
101 | /** | 101 | /** |
102 | - * 累加 | ||
103 | - * | ||
104 | - * @param string $key | ||
105 | - * @param int $offset | ||
106 | - * @param int $initialValue | ||
107 | - * @param int $expiry | ||
108 | - * @return boolean | ||
109 | - */ | ||
110 | - public static function increment($key, $offset = 1, $initialValue = 0, $expiry = 0) | ||
111 | - { | ||
112 | - return HoodCache::Memcached('master')->increment(self::makeKey($key, 'master'), $offset, $initialValue, $expiry); | ||
113 | - } | ||
114 | - | ||
115 | - /** | ||
116 | - * 递减 | ||
117 | - * | ||
118 | - * @param string $key | ||
119 | - * @param int $offset | ||
120 | - * @return boolean | ||
121 | - */ | ||
122 | - public static function decrement($key, $offset = 1) | ||
123 | - { | ||
124 | - return HoodCache::Memcached('master')->decrement(self::makeKey($key, 'master'), $offset); | ||
125 | - } | ||
126 | - | ||
127 | - /** | ||
128 | * 生成键名 | 102 | * 生成键名 |
129 | * | 103 | * |
130 | * @param string $key 键名 | 104 | * @param string $key 键名 |
@@ -32,7 +32,7 @@ class AliwapConfig | @@ -32,7 +32,7 @@ class AliwapConfig | ||
32 | * Enter description here ... | 32 | * Enter description here ... |
33 | * @var String | 33 | * @var String |
34 | */ | 34 | */ |
35 | - var $notify_url = 'http://testservice.yoho.cn:28077/payment/alipaywap_notify';//"http://m.yohobuy.com/shopping/pay/aliwapnotice"; | 35 | + var $notify_url = 'http://service.yoho.cn/payment/alipaywap_notify';//"http://m.yohobuy.com/shopping/pay/aliwapnotice"; |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * 浏览器的返回 | 38 | * 浏览器的返回 |
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * 支付配置 | ||
5 | + * | ||
6 | + * @name AliwapConfig | ||
7 | + * @package Plugin\Pay\aliwap\v303 | ||
8 | + * @copyright yoho.inc | ||
9 | + * @version 1.0 (2016-1-25 19:39:30) | ||
10 | + * @author fei.hong <fei.hong@yoho.cn> | ||
11 | + */ | ||
12 | +return array( | ||
13 | + 'pay_url' => 'https://mapi.alipay.com/gateway.do?', | ||
14 | + // 支付宝的用户ID | ||
15 | + 'partner' => '2088701661478015', | ||
16 | + // 收款支付宝账号 | ||
17 | + 'seller_id' => '2088701661478015', | ||
18 | + // 编码 | ||
19 | + 'input_charset' => 'utf-8', | ||
20 | + // 支付类型 | ||
21 | + 'payment_type' => '1', | ||
22 | + // 通知url | ||
23 | + 'notify_url' => 'http://testservice.yoho.cn:28077/payment/alipaywap_notify', //'http://m.yohobuy.com/shopping/pay/aliwapnotice' | ||
24 | + // 回调url | ||
25 | + 'return_url' => 'http://m.yohobuy.com/shopping/pay/aliwapreturn', | ||
26 | + // DSA、RSA、MD5三个值可选,必须大写 | ||
27 | + 'sign_type' => 'MD5', | ||
28 | + // MD5签名对应的KEY | ||
29 | + 'key' => 'kcxawi9bb07mzh0aq2wcirsf9znusobw', | ||
30 | + // 访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http | ||
31 | + 'transport' => 'http', | ||
32 | + // ca证书路径地址,用于curl中ssl校验 | ||
33 | + 'cacert' => 'cacert.pem', | ||
34 | +); |
1 | +<?php | ||
2 | + | ||
3 | +namespace Plugin\Pay\aliwap\v303; | ||
4 | + | ||
5 | +/** | ||
6 | + * 支付宝手机网页支付 | ||
7 | + */ | ||
8 | +class AliwapService | ||
9 | +{ | ||
10 | + | ||
11 | + var $config; | ||
12 | + var $alipay_config; | ||
13 | + | ||
14 | + public function __construct() | ||
15 | + { | ||
16 | + $this->config = require(dirname(__FILE__) . '/AliwapConfig.php'); | ||
17 | + | ||
18 | + require_once(dirname(__FILE__) . '/lib/alipay_submit.class.php'); | ||
19 | + } | ||
20 | + | ||
21 | + /** | ||
22 | + * 构造请求参数 | ||
23 | + * @see QPay_Utils_Interface::getPayRequestPars() | ||
24 | + */ | ||
25 | + public function getResponse($params) | ||
26 | + { | ||
27 | + $this->config['cacert'] = dirname(__FILE__) . '/cacert.pem'; | ||
28 | + | ||
29 | + //构造要请求的参数数组,无需改动 | ||
30 | + $parameter = array( | ||
31 | + "service" => 'alipay.wap.create.direct.pay.by.user', | ||
32 | + "partner" => $this->config['partner'], | ||
33 | + "seller_id" => $this->config['seller_id'], | ||
34 | + "payment_type" => $this->config['payment_type'], | ||
35 | + "notify_url" => $this->config['notify_url'], | ||
36 | + "return_url" => $this->config['return_url'], | ||
37 | + "out_trade_no" => date('Ymdhis') . $params['orderCode'], | ||
38 | + "subject" => 'yoho order:' . $params['orderCode'], | ||
39 | + "total_fee" => $params['totalFee'], | ||
40 | + "show_url" => $params['showUrl'], | ||
41 | + "body" => '有货订单号:' . $params['orderCode'], | ||
42 | + "it_b_pay" => $params['payExpire'], | ||
43 | + "_input_charset" => $this->config['input_charset'], | ||
44 | + ); | ||
45 | + | ||
46 | + //建立请求 | ||
47 | + $alipaySubmit = new \AlipaySubmit($this->config); | ||
48 | + $para = $alipaySubmit->buildRequestHttp($parameter); | ||
49 | + var_dump($para); | ||
50 | + } | ||
51 | + | ||
52 | +} |
library/Plugin/Pay/aliwap/v303/cacert.pem
0 → 100644
This diff could not be displayed because it is too large.
1 | +<?php | ||
2 | + | ||
3 | +/* * | ||
4 | + * 支付宝接口公用函数 | ||
5 | + * 详细:该类是请求、通知返回两个文件所调用的公用函数核心处理文件 | ||
6 | + * 版本:3.3 | ||
7 | + * 日期:2012-07-19 | ||
8 | + * 说明: | ||
9 | + * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 | ||
10 | + * 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 | ||
11 | + */ | ||
12 | + | ||
13 | +/** | ||
14 | + * 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串 | ||
15 | + * @param $para 需要拼接的数组 | ||
16 | + * return 拼接完成以后的字符串 | ||
17 | + */ | ||
18 | +function createLinkstring($para) | ||
19 | +{ | ||
20 | + $arg = ""; | ||
21 | + while (list ($key, $val) = each($para)) { | ||
22 | + $arg.=$key . "=" . $val . "&"; | ||
23 | + } | ||
24 | + //去掉最后一个&字符 | ||
25 | + $arg = substr($arg, 0, count($arg) - 2); | ||
26 | + | ||
27 | + //如果存在转义字符,那么去掉转义 | ||
28 | + if (get_magic_quotes_gpc()) { | ||
29 | + $arg = stripslashes($arg); | ||
30 | + } | ||
31 | + | ||
32 | + return $arg; | ||
33 | +} | ||
34 | + | ||
35 | +/** | ||
36 | + * 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码 | ||
37 | + * @param $para 需要拼接的数组 | ||
38 | + * return 拼接完成以后的字符串 | ||
39 | + */ | ||
40 | +function createLinkstringUrlencode($para) | ||
41 | +{ | ||
42 | + $arg = ""; | ||
43 | + while (list ($key, $val) = each($para)) { | ||
44 | + $arg.=$key . "=" . urlencode($val) . "&"; | ||
45 | + } | ||
46 | + //去掉最后一个&字符 | ||
47 | + $arg = substr($arg, 0, count($arg) - 2); | ||
48 | + | ||
49 | + //如果存在转义字符,那么去掉转义 | ||
50 | + if (get_magic_quotes_gpc()) { | ||
51 | + $arg = stripslashes($arg); | ||
52 | + } | ||
53 | + | ||
54 | + return $arg; | ||
55 | +} | ||
56 | + | ||
57 | +/** | ||
58 | + * 除去数组中的空值和签名参数 | ||
59 | + * @param $para 签名参数组 | ||
60 | + * return 去掉空值与签名参数后的新签名参数组 | ||
61 | + */ | ||
62 | +function paraFilter($para) | ||
63 | +{ | ||
64 | + $para_filter = array(); | ||
65 | + while (list ($key, $val) = each($para)) { | ||
66 | + if ($key == "sign" || $key == "sign_type" || $val == "") | ||
67 | + continue; | ||
68 | + else | ||
69 | + $para_filter[$key] = $para[$key]; | ||
70 | + } | ||
71 | + return $para_filter; | ||
72 | +} | ||
73 | + | ||
74 | +/** | ||
75 | + * 对数组排序 | ||
76 | + * @param $para 排序前的数组 | ||
77 | + * return 排序后的数组 | ||
78 | + */ | ||
79 | +function argSort($para) | ||
80 | +{ | ||
81 | + ksort($para); | ||
82 | + reset($para); | ||
83 | + return $para; | ||
84 | +} | ||
85 | + | ||
86 | +/** | ||
87 | + * 写日志,方便测试(看网站需求,也可以改成把记录存入数据库) | ||
88 | + * 注意:服务器需要开通fopen配置 | ||
89 | + * @param $word 要写入日志里的文本内容 默认值:空值 | ||
90 | + */ | ||
91 | +function logResult($word = '') | ||
92 | +{ | ||
93 | + $fp = fopen("log.txt", "a"); | ||
94 | + flock($fp, LOCK_EX); | ||
95 | + fwrite($fp, "执行日期:" . strftime("%Y%m%d%H%M%S", time()) . "\n" . $word . "\n"); | ||
96 | + flock($fp, LOCK_UN); | ||
97 | + fclose($fp); | ||
98 | +} | ||
99 | + | ||
100 | +/** | ||
101 | + * 远程获取数据,POST模式 | ||
102 | + * 注意: | ||
103 | + * 1.使用Crul需要修改服务器中php.ini文件的设置,找到php_curl.dll去掉前面的";"就行了 | ||
104 | + * 2.文件夹中cacert.pem是SSL证书请保证其路径有效,目前默认路径是:getcwd().'\\cacert.pem' | ||
105 | + * @param $url 指定URL完整路径地址 | ||
106 | + * @param $cacert_url 指定当前工作目录绝对路径 | ||
107 | + * @param $para 请求的数据 | ||
108 | + * @param $input_charset 编码格式。默认值:空值 | ||
109 | + * return 远程输出的数据 | ||
110 | + */ | ||
111 | +function getHttpResponsePOST($url, $cacert_url, $para, $input_charset = '') | ||
112 | +{ | ||
113 | + | ||
114 | + if (trim($input_charset) != '') { | ||
115 | + $url = $url . "_input_charset=" . $input_charset; | ||
116 | + } | ||
117 | + $curl = curl_init($url); | ||
118 | + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); //SSL证书认证 | ||
119 | + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); //严格认证 | ||
120 | + curl_setopt($curl, CURLOPT_CAINFO, $cacert_url); //证书地址 | ||
121 | + curl_setopt($curl, CURLOPT_HEADER, 0); // 过滤HTTP头 | ||
122 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 显示输出结果 | ||
123 | + curl_setopt($curl, CURLOPT_POST, true); // post传输数据 | ||
124 | + curl_setopt($curl, CURLOPT_POSTFIELDS, $para); // post传输数据 | ||
125 | + $responseText = curl_exec($curl); | ||
126 | + //var_dump( curl_error($curl) );//如果执行curl过程中出现异常,可打开此开关,以便查看异常内容 | ||
127 | + curl_close($curl); | ||
128 | + | ||
129 | + return $responseText; | ||
130 | +} | ||
131 | + | ||
132 | +/** | ||
133 | + * 远程获取数据,GET模式 | ||
134 | + * 注意: | ||
135 | + * 1.使用Crul需要修改服务器中php.ini文件的设置,找到php_curl.dll去掉前面的";"就行了 | ||
136 | + * 2.文件夹中cacert.pem是SSL证书请保证其路径有效,目前默认路径是:getcwd().'\\cacert.pem' | ||
137 | + * @param $url 指定URL完整路径地址 | ||
138 | + * @param $cacert_url 指定当前工作目录绝对路径 | ||
139 | + * return 远程输出的数据 | ||
140 | + */ | ||
141 | +function getHttpResponseGET($url, $cacert_url) | ||
142 | +{ | ||
143 | + $curl = curl_init($url); | ||
144 | + curl_setopt($curl, CURLOPT_HEADER, 0); // 过滤HTTP头 | ||
145 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 显示输出结果 | ||
146 | + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); //SSL证书认证 | ||
147 | + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); //严格认证 | ||
148 | + curl_setopt($curl, CURLOPT_CAINFO, $cacert_url); //证书地址 | ||
149 | + $responseText = curl_exec($curl); | ||
150 | + //var_dump( curl_error($curl) );//如果执行curl过程中出现异常,可打开此开关,以便查看异常内容 | ||
151 | + curl_close($curl); | ||
152 | + | ||
153 | + return $responseText; | ||
154 | +} | ||
155 | + | ||
156 | +/** | ||
157 | + * 实现多种字符编码方式 | ||
158 | + * @param $input 需要编码的字符串 | ||
159 | + * @param $_output_charset 输出的编码格式 | ||
160 | + * @param $_input_charset 输入的编码格式 | ||
161 | + * return 编码后的字符串 | ||
162 | + */ | ||
163 | +function charsetEncode($input, $_output_charset, $_input_charset) | ||
164 | +{ | ||
165 | + $output = ""; | ||
166 | + if (!isset($_output_charset)) | ||
167 | + $_output_charset = $_input_charset; | ||
168 | + if ($_input_charset == $_output_charset || $input == null) { | ||
169 | + $output = $input; | ||
170 | + } elseif (function_exists("mb_convert_encoding")) { | ||
171 | + $output = mb_convert_encoding($input, $_output_charset, $_input_charset); | ||
172 | + } elseif (function_exists("iconv")) { | ||
173 | + $output = iconv($_input_charset, $_output_charset, $input); | ||
174 | + } else | ||
175 | + die("sorry, you have no libs support for charset change."); | ||
176 | + return $output; | ||
177 | +} | ||
178 | + | ||
179 | +/** | ||
180 | + * 实现多种字符解码方式 | ||
181 | + * @param $input 需要解码的字符串 | ||
182 | + * @param $_output_charset 输出的解码格式 | ||
183 | + * @param $_input_charset 输入的解码格式 | ||
184 | + * return 解码后的字符串 | ||
185 | + */ | ||
186 | +function charsetDecode($input, $_input_charset, $_output_charset) | ||
187 | +{ | ||
188 | + $output = ""; | ||
189 | + if (!isset($_input_charset)) | ||
190 | + $_input_charset = $_input_charset; | ||
191 | + if ($_input_charset == $_output_charset || $input == null) { | ||
192 | + $output = $input; | ||
193 | + } elseif (function_exists("mb_convert_encoding")) { | ||
194 | + $output = mb_convert_encoding($input, $_output_charset, $_input_charset); | ||
195 | + } elseif (function_exists("iconv")) { | ||
196 | + $output = iconv($_input_charset, $_output_charset, $input); | ||
197 | + } else | ||
198 | + die("sorry, you have no libs support for charset changes."); | ||
199 | + return $output; | ||
200 | +} | ||
201 | + | ||
202 | +?> |
1 | +<?php | ||
2 | + | ||
3 | +/* * | ||
4 | + * MD5 | ||
5 | + * 详细:MD5加密 | ||
6 | + * 版本:3.3 | ||
7 | + * 日期:2012-07-19 | ||
8 | + * 说明: | ||
9 | + * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 | ||
10 | + * 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 | ||
11 | + */ | ||
12 | + | ||
13 | +/** | ||
14 | + * 签名字符串 | ||
15 | + * @param $prestr 需要签名的字符串 | ||
16 | + * @param $key 私钥 | ||
17 | + * return 签名结果 | ||
18 | + */ | ||
19 | +function md5Sign($prestr, $key) | ||
20 | +{ | ||
21 | + $prestr = $prestr . $key; | ||
22 | + return md5($prestr); | ||
23 | +} | ||
24 | + | ||
25 | +/** | ||
26 | + * 验证签名 | ||
27 | + * @param $prestr 需要签名的字符串 | ||
28 | + * @param $sign 签名结果 | ||
29 | + * @param $key 私钥 | ||
30 | + * return 签名结果 | ||
31 | + */ | ||
32 | +function md5Verify($prestr, $sign, $key) | ||
33 | +{ | ||
34 | + $prestr = $prestr . $key; | ||
35 | + $mysgin = md5($prestr); | ||
36 | + if ($mysgin == $sign) { | ||
37 | + return true; | ||
38 | + } else { | ||
39 | + return false; | ||
40 | + } | ||
41 | +} | ||
42 | + | ||
43 | +?> |
1 | +<?php | ||
2 | + | ||
3 | +/* * | ||
4 | + * 类名:AlipayNotify | ||
5 | + * 功能:支付宝通知处理类 | ||
6 | + * 详细:处理支付宝各接口通知返回 | ||
7 | + * 版本:3.2 | ||
8 | + * 日期:2011-03-25 | ||
9 | + * 说明: | ||
10 | + * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 | ||
11 | + * 该代码仅供学习和研究支付宝接口使用,只是提供一个参考 | ||
12 | + | ||
13 | + * ************************注意************************* | ||
14 | + * 调试通知返回时,可查看或改写log日志的写入TXT里的数据,来检查通知返回是否正常 | ||
15 | + */ | ||
16 | + | ||
17 | +require_once("alipay_core.function.php"); | ||
18 | +require_once("alipay_rsa.function.php"); | ||
19 | + | ||
20 | +class AlipayNotify | ||
21 | +{ | ||
22 | + | ||
23 | + /** | ||
24 | + * HTTPS形式消息验证地址 | ||
25 | + */ | ||
26 | + var $https_verify_url = 'https://mapi.alipay.com/gateway.do?service=notify_verify&'; | ||
27 | + | ||
28 | + /** | ||
29 | + * HTTP形式消息验证地址 | ||
30 | + */ | ||
31 | + var $http_verify_url = 'http://notify.alipay.com/trade/notify_query.do?'; | ||
32 | + var $alipay_config; | ||
33 | + | ||
34 | + function __construct($alipay_config) | ||
35 | + { | ||
36 | + $this->alipay_config = $alipay_config; | ||
37 | + } | ||
38 | + | ||
39 | + function AlipayNotify($alipay_config) | ||
40 | + { | ||
41 | + $this->__construct($alipay_config); | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * 针对notify_url验证消息是否是支付宝发出的合法消息 | ||
46 | + * @return 验证结果 | ||
47 | + */ | ||
48 | + function verifyNotify() | ||
49 | + { | ||
50 | + if (empty($_POST)) {//判断POST来的数组是否为空 | ||
51 | + return false; | ||
52 | + } else { | ||
53 | + //生成签名结果 | ||
54 | + $isSign = $this->getSignVeryfy($_POST, $_POST["sign"]); | ||
55 | + //获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息) | ||
56 | + $responseTxt = 'false'; | ||
57 | + if (!empty($_POST["notify_id"])) { | ||
58 | + $responseTxt = $this->getResponse($_POST["notify_id"]); | ||
59 | + } | ||
60 | + | ||
61 | + //写日志记录 | ||
62 | + //if ($isSign) { | ||
63 | + // $isSignStr = 'true'; | ||
64 | + //} | ||
65 | + //else { | ||
66 | + // $isSignStr = 'false'; | ||
67 | + //} | ||
68 | + //$log_text = "responseTxt=".$responseTxt."\n notify_url_log:isSign=".$isSignStr.","; | ||
69 | + //$log_text = $log_text.createLinkString($_POST); | ||
70 | + //logResult($log_text); | ||
71 | + //验证 | ||
72 | + //$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关 | ||
73 | + //isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关 | ||
74 | + if (preg_match("/true$/i", $responseTxt) && $isSign) { | ||
75 | + return true; | ||
76 | + } else { | ||
77 | + return false; | ||
78 | + } | ||
79 | + } | ||
80 | + } | ||
81 | + | ||
82 | + /** | ||
83 | + * 针对return_url验证消息是否是支付宝发出的合法消息 | ||
84 | + * @return 验证结果 | ||
85 | + */ | ||
86 | + function verifyReturn() | ||
87 | + { | ||
88 | + if (empty($_GET)) {//判断POST来的数组是否为空 | ||
89 | + return false; | ||
90 | + } else { | ||
91 | + //生成签名结果 | ||
92 | + $isSign = $this->getSignVeryfy($_GET, $_GET["sign"]); | ||
93 | + //获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息) | ||
94 | + $responseTxt = 'false'; | ||
95 | + if (!empty($_GET["notify_id"])) { | ||
96 | + $responseTxt = $this->getResponse($_GET["notify_id"]); | ||
97 | + } | ||
98 | + | ||
99 | + //写日志记录 | ||
100 | + //if ($isSign) { | ||
101 | + // $isSignStr = 'true'; | ||
102 | + //} | ||
103 | + //else { | ||
104 | + // $isSignStr = 'false'; | ||
105 | + //} | ||
106 | + //$log_text = "responseTxt=".$responseTxt."\n return_url_log:isSign=".$isSignStr.","; | ||
107 | + //$log_text = $log_text.createLinkString($_GET); | ||
108 | + //logResult($log_text); | ||
109 | + //验证 | ||
110 | + //$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关 | ||
111 | + //isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关 | ||
112 | + if (preg_match("/true$/i", $responseTxt) && $isSign) { | ||
113 | + return true; | ||
114 | + } else { | ||
115 | + return false; | ||
116 | + } | ||
117 | + } | ||
118 | + } | ||
119 | + | ||
120 | + /** | ||
121 | + * 获取返回时的签名验证结果 | ||
122 | + * @param $para_temp 通知返回来的参数数组 | ||
123 | + * @param $sign 返回的签名结果 | ||
124 | + * @return 签名验证结果 | ||
125 | + */ | ||
126 | + function getSignVeryfy($para_temp, $sign) | ||
127 | + { | ||
128 | + //除去待签名参数数组中的空值和签名参数 | ||
129 | + $para_filter = paraFilter($para_temp); | ||
130 | + | ||
131 | + //对待签名参数数组排序 | ||
132 | + $para_sort = argSort($para_filter); | ||
133 | + | ||
134 | + //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串 | ||
135 | + $prestr = createLinkstring($para_sort); | ||
136 | + | ||
137 | + $isSgin = false; | ||
138 | + switch (strtoupper(trim($this->alipay_config['sign_type']))) { | ||
139 | + case "RSA" : | ||
140 | + $isSgin = rsaVerify($prestr, trim($this->alipay_config['ali_public_key_path']), $sign); | ||
141 | + break; | ||
142 | + default : | ||
143 | + $isSgin = false; | ||
144 | + } | ||
145 | + | ||
146 | + return $isSgin; | ||
147 | + } | ||
148 | + | ||
149 | + /** | ||
150 | + * 获取远程服务器ATN结果,验证返回URL | ||
151 | + * @param $notify_id 通知校验ID | ||
152 | + * @return 服务器ATN结果 | ||
153 | + * 验证结果集: | ||
154 | + * invalid命令参数不对 出现这个错误,请检测返回处理中partner和key是否为空 | ||
155 | + * true 返回正确信息 | ||
156 | + * false 请检查防火墙或者是服务器阻止端口问题以及验证时间是否超过一分钟 | ||
157 | + */ | ||
158 | + function getResponse($notify_id) | ||
159 | + { | ||
160 | + $transport = strtolower(trim($this->alipay_config['transport'])); | ||
161 | + $partner = trim($this->alipay_config['partner']); | ||
162 | + $veryfy_url = ''; | ||
163 | + if ($transport == 'https') { | ||
164 | + $veryfy_url = $this->https_verify_url; | ||
165 | + } else { | ||
166 | + $veryfy_url = $this->http_verify_url; | ||
167 | + } | ||
168 | + $veryfy_url = $veryfy_url . "partner=" . $partner . "¬ify_id=" . $notify_id; | ||
169 | + $responseTxt = getHttpResponseGET($veryfy_url, $this->alipay_config['cacert']); | ||
170 | + | ||
171 | + return $responseTxt; | ||
172 | + } | ||
173 | + | ||
174 | +} | ||
175 | + | ||
176 | +?> |
1 | +<?php | ||
2 | + | ||
3 | +/* * | ||
4 | + * 支付宝接口RSA函数 | ||
5 | + * 详细:RSA签名、验签、解密 | ||
6 | + * 版本:3.3 | ||
7 | + * 日期:2012-07-23 | ||
8 | + * 说明: | ||
9 | + * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 | ||
10 | + * 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 | ||
11 | + */ | ||
12 | + | ||
13 | +/** | ||
14 | + * RSA签名 | ||
15 | + * @param $data 待签名数据 | ||
16 | + * @param $private_key_path 商户私钥文件路径 | ||
17 | + * return 签名结果 | ||
18 | + */ | ||
19 | +function rsaSign($data, $private_key_path) | ||
20 | +{ | ||
21 | + $priKey = file_get_contents($private_key_path); | ||
22 | + $res = openssl_get_privatekey($priKey); | ||
23 | + openssl_sign($data, $sign, $res); | ||
24 | + openssl_free_key($res); | ||
25 | + //base64编码 | ||
26 | + $sign = base64_encode($sign); | ||
27 | + return $sign; | ||
28 | +} | ||
29 | + | ||
30 | +/** | ||
31 | + * RSA验签 | ||
32 | + * @param $data 待签名数据 | ||
33 | + * @param $ali_public_key_path 支付宝的公钥文件路径 | ||
34 | + * @param $sign 要校对的的签名结果 | ||
35 | + * return 验证结果 | ||
36 | + */ | ||
37 | +function rsaVerify($data, $ali_public_key_path, $sign) | ||
38 | +{ | ||
39 | + $pubKey = file_get_contents($ali_public_key_path); | ||
40 | + $res = openssl_get_publickey($pubKey); | ||
41 | + $result = (bool) openssl_verify($data, base64_decode($sign), $res); | ||
42 | + openssl_free_key($res); | ||
43 | + return $result; | ||
44 | +} | ||
45 | + | ||
46 | +/** | ||
47 | + * RSA解密 | ||
48 | + * @param $content 需要解密的内容,密文 | ||
49 | + * @param $private_key_path 商户私钥文件路径 | ||
50 | + * return 解密后内容,明文 | ||
51 | + */ | ||
52 | +function rsaDecrypt($content, $private_key_path) | ||
53 | +{ | ||
54 | + $priKey = file_get_contents($private_key_path); | ||
55 | + $res = openssl_get_privatekey($priKey); | ||
56 | + //用base64将内容还原成二进制 | ||
57 | + $content = base64_decode($content); | ||
58 | + //把需要解密的内容,按128位拆开解密 | ||
59 | + $result = ''; | ||
60 | + for ($i = 0; $i < strlen($content) / 128; $i++) { | ||
61 | + $data = substr($content, $i * 128, 128); | ||
62 | + openssl_private_decrypt($data, $decrypt, $res); | ||
63 | + $result .= $decrypt; | ||
64 | + } | ||
65 | + openssl_free_key($res); | ||
66 | + return $result; | ||
67 | +} | ||
68 | + | ||
69 | +?> |
1 | +<?php | ||
2 | + | ||
3 | +/* * | ||
4 | + * 类名:AlipaySubmit | ||
5 | + * 功能:支付宝各接口请求提交类 | ||
6 | + * 详细:构造支付宝各接口表单HTML文本,获取远程HTTP数据 | ||
7 | + * 版本:3.3 | ||
8 | + * 日期:2012-07-23 | ||
9 | + * 说明: | ||
10 | + * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 | ||
11 | + * 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 | ||
12 | + */ | ||
13 | +require_once("alipay_core.function.php"); | ||
14 | +require_once("alipay_rsa.function.php"); | ||
15 | +require_once("alipay_md5.function.php"); | ||
16 | + | ||
17 | +class AlipaySubmit | ||
18 | +{ | ||
19 | + | ||
20 | + var $alipay_config; | ||
21 | + | ||
22 | + /** | ||
23 | + * 支付宝网关地址(新) | ||
24 | + */ | ||
25 | + var $alipay_gateway_new = 'https://mapi.alipay.com/gateway.do?'; | ||
26 | + | ||
27 | + function __construct($alipay_config) | ||
28 | + { | ||
29 | + $this->alipay_config = $alipay_config; | ||
30 | + } | ||
31 | + | ||
32 | + function AlipaySubmit($alipay_config) | ||
33 | + { | ||
34 | + $this->__construct($alipay_config); | ||
35 | + } | ||
36 | + | ||
37 | + /** | ||
38 | + * 生成签名结果 | ||
39 | + * @param $para_sort 已排序要签名的数组 | ||
40 | + * return 签名结果字符串 | ||
41 | + */ | ||
42 | + function buildRequestMysign($para_sort) | ||
43 | + { | ||
44 | + //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串 | ||
45 | + $prestr = createLinkstring($para_sort); | ||
46 | + | ||
47 | + $mysign = ""; | ||
48 | + switch (strtoupper(trim($this->alipay_config['sign_type']))) { | ||
49 | + case "RSA" : | ||
50 | + $mysign = rsaSign($prestr, $this->alipay_config['private_key_path']); | ||
51 | + break; | ||
52 | + case "MD5" : | ||
53 | + $mysign = md5Sign($prestr, $this->alipay_config['key']); | ||
54 | + break; | ||
55 | + default : | ||
56 | + $mysign = ""; | ||
57 | + } | ||
58 | + | ||
59 | + return $mysign; | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * 生成要请求给支付宝的参数数组 | ||
64 | + * @param $para_temp 请求前的参数数组 | ||
65 | + * @return 要请求的参数数组 | ||
66 | + */ | ||
67 | + function buildRequestPara($para_temp) | ||
68 | + { | ||
69 | + //除去待签名参数数组中的空值和签名参数 | ||
70 | + $para_filter = paraFilter($para_temp); | ||
71 | + | ||
72 | + //对待签名参数数组排序 | ||
73 | + $para_sort = argSort($para_filter); | ||
74 | + | ||
75 | + //生成签名结果 | ||
76 | + $mysign = $this->buildRequestMysign($para_sort); | ||
77 | + | ||
78 | + //签名结果与签名方式加入请求提交参数组中 | ||
79 | + $para_sort['sign'] = $mysign; | ||
80 | + $para_sort['sign_type'] = strtoupper(trim($this->alipay_config['sign_type'])); | ||
81 | + | ||
82 | + return $para_sort; | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * 生成要请求给支付宝的参数数组 | ||
87 | + * @param $para_temp 请求前的参数数组 | ||
88 | + * @return 要请求的参数数组字符串 | ||
89 | + */ | ||
90 | + function buildRequestParaToString($para_temp) | ||
91 | + { | ||
92 | + //待请求参数数组 | ||
93 | + $para = $this->buildRequestPara($para_temp); | ||
94 | + | ||
95 | + //把参数组中所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码 | ||
96 | + $request_data = createLinkstringUrlencode($para); | ||
97 | + | ||
98 | + return $request_data; | ||
99 | + } | ||
100 | + | ||
101 | + /** | ||
102 | + * 建立请求,以表单HTML形式构造(默认) | ||
103 | + * @param $para_temp 请求参数数组 | ||
104 | + * @param $method 提交方式。两个值可选:post、get | ||
105 | + * @param $button_name 确认按钮显示文字 | ||
106 | + * @return 提交表单HTML文本 | ||
107 | + */ | ||
108 | + function buildRequestForm($para_temp, $method, $button_name) | ||
109 | + { | ||
110 | + //待请求参数数组 | ||
111 | + $para = $this->buildRequestPara($para_temp); | ||
112 | + | ||
113 | + $sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='" . $this->alipay_gateway_new . "_input_charset=" . trim(strtolower($this->alipay_config['input_charset'])) . "' method='" . $method . "'>"; | ||
114 | + while (list ($key, $val) = each($para)) { | ||
115 | + $sHtml.= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>"; | ||
116 | + } | ||
117 | + | ||
118 | + //submit按钮控件请不要含有name属性 | ||
119 | + $sHtml = $sHtml . "<input type='submit' value='" . $button_name . "'></form>"; | ||
120 | + | ||
121 | + $sHtml = $sHtml . "<script>document.forms['alipaysubmit'].submit();</script>"; | ||
122 | + | ||
123 | + return $sHtml; | ||
124 | + } | ||
125 | + | ||
126 | + /** | ||
127 | + * 建立请求,以模拟远程HTTP的POST请求方式构造并获取支付宝的处理结果 | ||
128 | + * @param $para_temp 请求参数数组 | ||
129 | + * @return 支付宝处理结果 | ||
130 | + */ | ||
131 | + function buildRequestHttp($para_temp) | ||
132 | + { | ||
133 | + $sResult = ''; | ||
134 | + | ||
135 | + //待请求参数数组字符串 | ||
136 | + $request_data = $this->buildRequestPara($para_temp); | ||
137 | + | ||
138 | + //远程获取数据 | ||
139 | + $sResult = getHttpResponsePOST($this->alipay_gateway_new, $this->alipay_config['cacert'], $request_data, trim(strtolower($this->alipay_config['input_charset']))); | ||
140 | + | ||
141 | + return $sResult; | ||
142 | + } | ||
143 | + | ||
144 | + /** | ||
145 | + * 建立请求,以模拟远程HTTP的POST请求方式构造并获取支付宝的处理结果,带文件上传功能 | ||
146 | + * @param $para_temp 请求参数数组 | ||
147 | + * @param $file_para_name 文件类型的参数名 | ||
148 | + * @param $file_name 文件完整绝对路径 | ||
149 | + * @return 支付宝返回处理结果 | ||
150 | + */ | ||
151 | + function buildRequestHttpInFile($para_temp, $file_para_name, $file_name) | ||
152 | + { | ||
153 | + | ||
154 | + //待请求参数数组 | ||
155 | + $para = $this->buildRequestPara($para_temp); | ||
156 | + $para[$file_para_name] = "@" . $file_name; | ||
157 | + | ||
158 | + //远程获取数据 | ||
159 | + $sResult = getHttpResponsePOST($this->alipay_gateway_new, $this->alipay_config['cacert'], $para, trim(strtolower($this->alipay_config['input_charset']))); | ||
160 | + | ||
161 | + return $sResult; | ||
162 | + } | ||
163 | + | ||
164 | + /** | ||
165 | + * 用于防钓鱼,调用接口query_timestamp来获取时间戳的处理函数 | ||
166 | + * 注意:该功能PHP5环境及以上支持,因此必须服务器、本地电脑中装有支持DOMDocument、SSL的PHP配置环境。建议本地调试时使用PHP开发软件 | ||
167 | + * return 时间戳字符串 | ||
168 | + */ | ||
169 | + function query_timestamp() | ||
170 | + { | ||
171 | + $url = $this->alipay_gateway_new . "service=query_timestamp&partner=" . trim(strtolower($this->alipay_config['partner'])) . "&_input_charset=" . trim(strtolower($this->alipay_config['input_charset'])); | ||
172 | + $encrypt_key = ""; | ||
173 | + | ||
174 | + $doc = new DOMDocument(); | ||
175 | + $doc->load($url); | ||
176 | + $itemEncrypt_key = $doc->getElementsByTagName("encrypt_key"); | ||
177 | + $encrypt_key = $itemEncrypt_key->item(0)->nodeValue; | ||
178 | + | ||
179 | + return $encrypt_key; | ||
180 | + } | ||
181 | + | ||
182 | +} | ||
183 | + | ||
184 | +?> |
@@ -34,7 +34,7 @@ class WxPayConfig | @@ -34,7 +34,7 @@ class WxPayConfig | ||
34 | const JS_API_CALL_URL = 'http://m.yohobuy.com/shopping/pay/wechatwap'; | 34 | const JS_API_CALL_URL = 'http://m.yohobuy.com/shopping/pay/wechatwap'; |
35 | //=======【异步通知url设置】=================================== | 35 | //=======【异步通知url设置】=================================== |
36 | //异步通知url,商户根据实际开发过程设定 | 36 | //异步通知url,商户根据实际开发过程设定 |
37 | - const NOTIFY_URL = 'http://testservice.yoho.cn:28077/payment/wechatwap_notify';//'http://pay.yohobuy.com/notify/wechatwap'; | 37 | + const NOTIFY_URL = 'http://service.yoho.cn/payment/wechatwap_notify';//'http://pay.yohobuy.com/notify/wechatwap'; |
38 | //=======【证书路径设置】===================================== | 38 | //=======【证书路径设置】===================================== |
39 | /** | 39 | /** |
40 | * TODO:设置商户证书路径 | 40 | * TODO:设置商户证书路径 |
@@ -219,9 +219,9 @@ $yohoPage.on('touchstart', '.tap-hightlight', function() { | @@ -219,9 +219,9 @@ $yohoPage.on('touchstart', '.tap-hightlight', function() { | ||
219 | $(this).removeClass('highlight'); | 219 | $(this).removeClass('highlight'); |
220 | }); | 220 | }); |
221 | 221 | ||
222 | -$('.nav-home').on('touchstart', function() { | ||
223 | - $('.homebuttom').toggleClass('none'); | ||
224 | -}); | 222 | +// $('.nav-home').on('touchstart', function() { |
223 | +// $('.homebuttom').toggleClass('none'); | ||
224 | +// }); | ||
225 | 225 | ||
226 | (function() { | 226 | (function() { |
227 | var lastTime = 0, | 227 | var lastTime = 0, |
@@ -143,16 +143,6 @@ function showPage() { | @@ -143,16 +143,6 @@ function showPage() { | ||
143 | $pageList.css('visibility', 'visible'); | 143 | $pageList.css('visibility', 'visible'); |
144 | } | 144 | } |
145 | 145 | ||
146 | -function bindTouchedEvent() { | ||
147 | - var $boxs = $('.box'); | ||
148 | - | ||
149 | - $boxs.on('touchstart', function(e) { | ||
150 | - $(this).addClass('bytouch'); | ||
151 | - }).on('touchend touchcancel', function() { | ||
152 | - $boxs.removeClass('bytouch'); | ||
153 | - }); | ||
154 | -} | ||
155 | - | ||
156 | if (wxHammer) { | 146 | if (wxHammer) { |
157 | wxHammer.on('tap', function() { | 147 | wxHammer.on('tap', function() { |
158 | callpay(theOrderCode); | 148 | callpay(theOrderCode); |
@@ -164,11 +154,9 @@ function main() { | @@ -164,11 +154,9 @@ function main() { | ||
164 | loading.hideLoadingMask(); | 154 | loading.hideLoadingMask(); |
165 | showPage(); | 155 | showPage(); |
166 | loadIcon(); | 156 | loadIcon(); |
167 | - bindTouchedEvent(); | ||
168 | } | 157 | } |
169 | 158 | ||
170 | loading.showLoadingMask(); | 159 | loading.showLoadingMask(); |
171 | 160 | ||
172 | $(document).ready(main); | 161 | $(document).ready(main); |
173 | 162 | ||
174 | - |
@@ -48,7 +48,7 @@ | @@ -48,7 +48,7 @@ | ||
48 | 48 | ||
49 | .gift-advance-good .name { | 49 | .gift-advance-good .name { |
50 | margin-bottom: 20rem / $pxConvertRem; | 50 | margin-bottom: 20rem / $pxConvertRem; |
51 | - width: 320rem / $pxConvertRem; | 51 | + width: 440rem / $pxConvertRem; |
52 | font-size: 28rem / $pxConvertRem; | 52 | font-size: 28rem / $pxConvertRem; |
53 | } | 53 | } |
54 | 54 |
@@ -97,7 +97,7 @@ | @@ -97,7 +97,7 @@ | ||
97 | float: left; | 97 | float: left; |
98 | color: #fff; | 98 | color: #fff; |
99 | font-size: pxToRem(28px); | 99 | font-size: pxToRem(28px); |
100 | - width: pxToRem(212px); | 100 | + width: pxToRem(320px); |
101 | // width: pxToRem(213px); 三栏宽度 | 101 | // width: pxToRem(213px); 三栏宽度 |
102 | 102 | ||
103 | &.highlight { | 103 | &.highlight { |
@@ -5,10 +5,6 @@ | @@ -5,10 +5,6 @@ | ||
5 | visibility: hidden; | 5 | visibility: hidden; |
6 | } | 6 | } |
7 | 7 | ||
8 | - .box.bytouch { | ||
9 | - background-color:#eee; | ||
10 | - } | ||
11 | - | ||
12 | .box { | 8 | .box { |
13 | border: 1px solid #eee; | 9 | border: 1px solid #eee; |
14 | border-radius: 10rem / $pxConvertRem; | 10 | border-radius: 10rem / $pxConvertRem; |
@@ -27,7 +23,6 @@ | @@ -27,7 +23,6 @@ | ||
27 | @include flexbox((display: flex, align-items: center)); | 23 | @include flexbox((display: flex, align-items: center)); |
28 | } | 24 | } |
29 | 25 | ||
30 | - | ||
31 | .icon { | 26 | .icon { |
32 | width: 15%; | 27 | width: 15%; |
33 | 28 | ||
@@ -43,7 +38,7 @@ | @@ -43,7 +38,7 @@ | ||
43 | height: 60rem / $pxConvertRem; | 38 | height: 60rem / $pxConvertRem; |
44 | background-image: image-url("layout/pay-icon.png"); | 39 | background-image: image-url("layout/pay-icon.png"); |
45 | background-size: 90%; | 40 | background-size: 90%; |
46 | - background-position-y: 12rem / $pxConvertRem; | 41 | + background-position-y: 8rem / $pxConvertRem; |
47 | background-position-x: center; | 42 | background-position-x: center; |
48 | background-repeat: no-repeat; | 43 | background-repeat: no-repeat; |
49 | } | 44 | } |
@@ -28,10 +28,14 @@ | @@ -28,10 +28,14 @@ | ||
28 | {{#isLogin}}{{brand_favorite_total}}{{/isLogin}} | 28 | {{#isLogin}}{{brand_favorite_total}}{{/isLogin}} |
29 | <p>收藏的品牌</p> | 29 | <p>收藏的品牌</p> |
30 | </a> | 30 | </a> |
31 | + {{! | ||
31 | <a class="link-item tap-hightlight" href="/home/record"> | 32 | <a class="link-item tap-hightlight" href="/home/record"> |
32 | - {{#isLogin}}{{product_browse}}{{/isLogin}} | 33 | + <!-- product_browse --> |
34 | + | ||
33 | <p>浏览记录</p> | 35 | <p>浏览记录</p> |
34 | </a> | 36 | </a> |
37 | + }} | ||
38 | + | ||
35 | </div> | 39 | </div> |
36 | <div class="my-order"> | 40 | <div class="my-order"> |
37 | <a class="order-title" href="/home/orders"> | 41 | <a class="order-title" href="/home/orders"> |
@@ -38,13 +38,4 @@ | @@ -38,13 +38,4 @@ | ||
38 | {{/ logisticDetail}} | 38 | {{/ logisticDetail}} |
39 | </div> | 39 | </div> |
40 | </div> | 40 | </div> |
41 | -<div class="banner"> | ||
42 | - {{#banner}} | ||
43 | - <a href="{{url}}"> | ||
44 | - <img src="{{img}}" alt="img"> | ||
45 | - </a> | ||
46 | - {{/banner}} | ||
47 | -</div> | ||
48 | - | ||
49 | -{{> home/maybe_like}} | ||
50 | {{> layout/footer}} | 41 | {{> layout/footer}} |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | <a href="{{#if backUrl}}{{backUrl}}{{^}}javascript:history.go(-1);{{/if}}" class="iconfont nav-back"></a> | 4 | <a href="{{#if backUrl}}{{backUrl}}{{^}}javascript:history.go(-1);{{/if}}" class="iconfont nav-back"></a> |
5 | {{/navBack}} | 5 | {{/navBack}} |
6 | {{#navHome}} | 6 | {{#navHome}} |
7 | - <span class="iconfont nav-home"></span> | 7 | + <a href="{{.}}" class="iconfont nav-home"></a> |
8 | {{/navHome}} | 8 | {{/navHome}} |
9 | {{#currencyPage}} | 9 | {{#currencyPage}} |
10 | <a href="/home/helpDetail?code=20151230-102233&caption=YOHO币介绍" class="iconfont nav-home"></a> | 10 | <a href="/home/helpDetail?code=20151230-102233&caption=YOHO币介绍" class="iconfont nav-home"></a> |
@@ -18,34 +18,32 @@ | @@ -18,34 +18,32 @@ | ||
18 | {{#navTitle}} | 18 | {{#navTitle}} |
19 | <p class="nav-title">{{.}}</p> | 19 | <p class="nav-title">{{.}}</p> |
20 | {{/navTitle}} | 20 | {{/navTitle}} |
21 | -</header> | ||
22 | -<div class="homebuttom none"> | 21 | + {{# navBtn}} |
22 | + <span class="nav-btn">{{.}}</span> | ||
23 | + {{!-- | ||
24 | + <i class="iconfont nav-home"></i> | ||
25 | + <div class="homebuttom none"> | ||
23 | <ul> | 26 | <ul> |
24 | <li> | 27 | <li> |
25 | - <a href="/"> | ||
26 | <i class="iconfont"></i> | 28 | <i class="iconfont"></i> |
27 | <span>首页</span> | 29 | <span>首页</span> |
28 | - </a> | ||
29 | </li> | 30 | </li> |
30 | <li> | 31 | <li> |
31 | - <a href="cate"> | ||
32 | <i class="iconfont"></i> | 32 | <i class="iconfont"></i> |
33 | <span>分类</span> | 33 | <span>分类</span> |
34 | - </a> | ||
35 | </li> | 34 | </li> |
36 | <li> | 35 | <li> |
37 | - <a href="cart/index/index"> | ||
38 | <i class="iconfont"></i> | 36 | <i class="iconfont"></i> |
39 | <span>购物车</span> | 37 | <span>购物车</span> |
40 | - </a> | ||
41 | </li> | 38 | </li> |
42 | <li> | 39 | <li> |
43 | - <a href="/home"> | ||
44 | <i class="iconfont"></i> | 40 | <i class="iconfont"></i> |
45 | <span>我的</span> | 41 | <span>我的</span> |
46 | - </a> | ||
47 | </li> | 42 | </li> |
48 | </ul> | 43 | </ul> |
49 | -</div> | 44 | + </div> |
45 | + --}} | ||
46 | + {{/ navBtn}} | ||
47 | +</header> | ||
50 | 48 | ||
51 | {{/pageHeader}} | 49 | {{/pageHeader}} |
@@ -22,8 +22,6 @@ class BoysController extends AbstractAction | @@ -22,8 +22,6 @@ class BoysController extends AbstractAction | ||
22 | $this->setExpires(300); // 缓存5分钟 | 22 | $this->setExpires(300); // 缓存5分钟 |
23 | } | 23 | } |
24 | 24 | ||
25 | - // 设置COOKIE标识用户访问过该页面了 | ||
26 | - // Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_BOYS); | ||
27 | // 设置网站标题 | 25 | // 设置网站标题 |
28 | $this->setTitle('男生首页'); | 26 | $this->setTitle('男生首页'); |
29 | // 显示侧边栏 | 27 | // 显示侧边栏 |
@@ -15,9 +15,8 @@ class GirlsController extends AbstractAction | @@ -15,9 +15,8 @@ class GirlsController extends AbstractAction | ||
15 | public function indexAction() | 15 | public function indexAction() |
16 | { | 16 | { |
17 | // 设置浏览器缓存5分钟 | 17 | // 设置浏览器缓存5分钟 |
18 | - $this->setExpires(300); // 缓存5分钟 | ||
19 | - // 设置COOKIE标识用户访问过该页面了 | ||
20 | - // Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_GIRLS); | 18 | + $this->setExpires(300); |
19 | + | ||
21 | // 设置网站标题 | 20 | // 设置网站标题 |
22 | $this->setTitle('女生首页'); | 21 | $this->setTitle('女生首页'); |
23 | // 显示侧边栏 | 22 | // 显示侧边栏 |
@@ -937,7 +937,7 @@ class HomeController extends AbstractAction | @@ -937,7 +937,7 @@ class HomeController extends AbstractAction | ||
937 | } | 937 | } |
938 | 938 | ||
939 | $this->setTitle('订单详情'); | 939 | $this->setTitle('订单详情'); |
940 | - $this->setNavHeader('订单详情', Helpers::url('/home/orders'), false); | 940 | + $this->setNavHeader('订单详情', true, false); |
941 | 941 | ||
942 | $this->_view->display('order-detail', array( | 942 | $this->_view->display('order-detail', array( |
943 | 'orderDetailPage' => true, | 943 | 'orderDetailPage' => true, |
@@ -15,9 +15,8 @@ class KidsController extends AbstractAction | @@ -15,9 +15,8 @@ class KidsController extends AbstractAction | ||
15 | public function indexAction() | 15 | public function indexAction() |
16 | { | 16 | { |
17 | // 设置浏览器缓存5分钟 | 17 | // 设置浏览器缓存5分钟 |
18 | - $this->setExpires(300); // 缓存5分钟 | ||
19 | - // 设置COOKIE标识用户访问过该页面了 | ||
20 | - // Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_KIDS); | 18 | + $this->setExpires(300); |
19 | + | ||
21 | // 设置网站标题 | 20 | // 设置网站标题 |
22 | $this->setTitle('潮童首页'); | 21 | $this->setTitle('潮童首页'); |
23 | // 显示侧边栏 | 22 | // 显示侧边栏 |
@@ -15,9 +15,8 @@ class LifestyleController extends AbstractAction | @@ -15,9 +15,8 @@ class LifestyleController extends AbstractAction | ||
15 | public function indexAction() | 15 | public function indexAction() |
16 | { | 16 | { |
17 | // 设置浏览器缓存5分钟 | 17 | // 设置浏览器缓存5分钟 |
18 | - $this->setExpires(300); // 缓存5分钟 | ||
19 | - // 设置COOKIE标识用户访问过该页面了 | ||
20 | - // Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_LIFESTYLE); | 18 | + $this->setExpires(300); |
19 | + | ||
21 | // 设置网站标题 | 20 | // 设置网站标题 |
22 | $this->setTitle('创意生活首页'); | 21 | $this->setTitle('创意生活首页'); |
23 | // 显示侧边栏 | 22 | // 显示侧边栏 |
@@ -39,14 +39,13 @@ class ClassModel | @@ -39,14 +39,13 @@ class ClassModel | ||
39 | 39 | ||
40 | do { | 40 | do { |
41 | $data = ClassData::getClassesData(); | 41 | $data = ClassData::getClassesData(); |
42 | - if (empty($data['data']) || $data['code'] != 200) { | 42 | + if (empty($data['data'])) { |
43 | break; | 43 | break; |
44 | } | 44 | } |
45 | 45 | ||
46 | $genderArr = array('boy' => '1,3', 'girl' => '2,3', 'kids' => '1,2,3', 'lifestyle' => '1,2,3'); | 46 | $genderArr = array('boy' => '1,3', 'girl' => '2,3', 'kids' => '1,2,3', 'lifestyle' => '1,2,3'); |
47 | $oneClass = array(); | 47 | $oneClass = array(); |
48 | $item = array(); | 48 | $item = array(); |
49 | - $subitem = array(); | ||
50 | foreach ($data['data'] as $k => $v) { | 49 | foreach ($data['data'] as $k => $v) { |
51 | $oneClass = array('name' => ucfirst(rtrim($k, 's')), 'ca' => array()); | 50 | $oneClass = array('name' => ucfirst(rtrim($k, 's')), 'ca' => array()); |
52 | 51 |
@@ -115,7 +115,7 @@ class UserModel | @@ -115,7 +115,7 @@ class UserModel | ||
115 | // 处理个人中心页面优选新品数据 | 115 | // 处理个人中心页面优选新品数据 |
116 | if (!empty($preferenceData['data'])) { | 116 | if (!empty($preferenceData['data'])) { |
117 | foreach ($preferenceData['data'] as $value) { | 117 | foreach ($preferenceData['data'] as $value) { |
118 | - $value = Helpers::formatProduct($value, false, true, true, 299, 388, false); | 118 | + $value = Helpers::formatProduct($value, false, true, true, 299, 388, false, false); |
119 | if (false !== $value) { | 119 | if (false !== $value) { |
120 | $result['recommendList'][] = $value; | 120 | $result['recommendList'][] = $value; |
121 | } | 121 | } |
@@ -221,7 +221,7 @@ class InfoController extends AbstractAction | @@ -221,7 +221,7 @@ class InfoController extends AbstractAction | ||
221 | $data['guang']['id'] = $id; | 221 | $data['guang']['id'] = $id; |
222 | 222 | ||
223 | // 获取详情内容信息, 异常则跳到错误页面 | 223 | // 获取详情内容信息, 异常则跳到错误页面 |
224 | - $detail = DetailData::packageFoEzine($id, true); | 224 | + $detail = DetailData::package($id, true); |
225 | if (empty($detail['getArticle'])) { | 225 | if (empty($detail['getArticle'])) { |
226 | $this->_view->display('index', $data); | 226 | $this->_view->display('index', $data); |
227 | return; | 227 | return; |
@@ -248,7 +248,8 @@ class InfoController extends AbstractAction | @@ -248,7 +248,8 @@ class InfoController extends AbstractAction | ||
248 | // 单张图 | 248 | // 单张图 |
249 | elseif (isset($value['singleImage'])) { | 249 | elseif (isset($value['singleImage'])) { |
250 | $build['bigImage'] = Helpers::getImageUrl($value['singleImage']['data'][0]['src'], 640, 640); | 250 | $build['bigImage'] = Helpers::getImageUrl($value['singleImage']['data'][0]['src'], 640, 640); |
251 | - } elseif (isset($value['smallPic']['data'])) { | 251 | + } |
252 | + elseif (isset($value['smallPic']['data'])) { | ||
252 | $imgs = $value['smallPic']['data']; | 253 | $imgs = $value['smallPic']['data']; |
253 | $build['smallImage'] = array( | 254 | $build['smallImage'] = array( |
254 | array( | 255 | array( |
@@ -343,4 +344,117 @@ class InfoController extends AbstractAction | @@ -343,4 +344,117 @@ class InfoController extends AbstractAction | ||
343 | $data = array(); | 344 | $data = array(); |
344 | } | 345 | } |
345 | 346 | ||
347 | + /** | ||
348 | + * 提供给YOHO资讯站调用的接口 | ||
349 | + * | ||
350 | + * @param int id 逛内容ID | ||
351 | + * @return json | ||
352 | + */ | ||
353 | + public function foryohoAction() | ||
354 | + { | ||
355 | + $result = array(); | ||
356 | + | ||
357 | + do { | ||
358 | + /* 判断参数是否有效 */ | ||
359 | + $id = $this->get('id'); | ||
360 | + if (!is_numeric($id)) { | ||
361 | + break; | ||
362 | + } | ||
363 | + | ||
364 | + $app = $this->get('app'); | ||
365 | + $isApp = empty($app) ? false : true; | ||
366 | + | ||
367 | + /* 判断是否有内容 */ | ||
368 | + $detail = DetailData::package($id, $isApp); | ||
369 | + if (empty($detail['getArticleContent'])) { | ||
370 | + break; | ||
371 | + } | ||
372 | + | ||
373 | + /* 品牌信息 */ | ||
374 | + $result['brand'] = $detail['getBrand']; | ||
375 | + | ||
376 | + $build = array(); | ||
377 | + $good = array(); | ||
378 | + $skns = array(); | ||
379 | + $product = array(); | ||
380 | + | ||
381 | + /* 商品信息 */ | ||
382 | + foreach ($detail['getArticleContent'] as $value) { | ||
383 | + $build = array(); | ||
384 | + // 文字 | ||
385 | + if (isset($value['text'])) { | ||
386 | + $build['text'] = $value['text']['data']['text']; | ||
387 | + } | ||
388 | + // 单张图 | ||
389 | + elseif (isset($value['singleImage'])) { | ||
390 | + $build['bigImage'] = Helpers::getImageUrl($value['singleImage']['data'][0]['src'], 640, 640); | ||
391 | + } | ||
392 | + elseif (isset($value['smallPic']['data'])) { | ||
393 | + $imgs = $value['smallPic']['data']; | ||
394 | + $build['smallImage'] = array( | ||
395 | + array( | ||
396 | + 'src' => Helpers::getImageUrl($imgs[0]['src'], 315, 420) | ||
397 | + ), | ||
398 | + array( | ||
399 | + 'src' => Helpers::getImageUrl($imgs[1]['src'], 315, 420) | ||
400 | + ) | ||
401 | + ); | ||
402 | + } | ||
403 | + elseif (isset($value['goods']['data'])) { | ||
404 | + $good = array(); | ||
405 | + // 遍历取得SKN | ||
406 | + $skns = array(); | ||
407 | + foreach ($value['goods']['data'] as $goods) { | ||
408 | + $skns[] = $goods['id']; | ||
409 | + } | ||
410 | + // 通过SKN获取商品信息 | ||
411 | + $product = ListData::productInfoBySkns($skns); | ||
412 | + if (!empty($product['data']['product_list'])) { | ||
413 | + foreach ($product['data']['product_list'] as $i => $goods) { | ||
414 | + // 最多显示4个 | ||
415 | + if ($i > 3) { | ||
416 | + break; | ||
417 | + } | ||
418 | + $good[] = Helpers::formatProduct($goods, false, true, true, 235, 314, true); | ||
419 | + } | ||
420 | + } | ||
421 | + // 没有商品 | ||
422 | + if (!isset($i)) { | ||
423 | + continue; | ||
424 | + } | ||
425 | + $result['goods'] = $good; | ||
426 | + } | ||
427 | + // 悬停浮动商品 | ||
428 | + elseif (isset($value['goodsGroup']['data'])) { | ||
429 | + foreach ($value['goodsGroup']['data'] as $goods) { | ||
430 | + $good = array(); | ||
431 | + $good['img'] = Helpers::getImageUrl($goods['cover']['cover'], 235, 314); | ||
432 | + $good['icon'] = Helpers::getProductIcon($goods['cover']['maxSortId']); | ||
433 | + $good['goods'] = array(); | ||
434 | + $skns = array(); | ||
435 | + foreach ($goods['list'] as $mini) { | ||
436 | + $skns[] = $mini['id']; | ||
437 | + } | ||
438 | + // 通过SKN获取商品信息 | ||
439 | + $product = ListData::productInfoBySkns($skns); | ||
440 | + if (!empty($product['data']['product_list'])) { | ||
441 | + foreach ($product['data']['product_list'] as $i => $goods) { | ||
442 | + $good['goods'][] = Helpers::formatProduct($goods, false, true, true, 235, 314, true); | ||
443 | + } | ||
444 | + $result['group'][] = $good; | ||
445 | + } | ||
446 | + } | ||
447 | + } | ||
448 | + | ||
449 | + // 内容详情 | ||
450 | + if (array() !== $build) { | ||
451 | + $result['content'][] = $build; | ||
452 | + } | ||
453 | + } | ||
454 | + } | ||
455 | + while (false); | ||
456 | + | ||
457 | + $this->echoJson($result); | ||
458 | + } | ||
459 | + | ||
346 | } | 460 | } |
@@ -4,7 +4,7 @@ application.directory = APPLICATION_PATH "/application" | @@ -4,7 +4,7 @@ application.directory = APPLICATION_PATH "/application" | ||
4 | ;;website library | 4 | ;;website library |
5 | application.library = ROOT_PATH "/library" | 5 | application.library = ROOT_PATH "/library" |
6 | ;;模块配置 | 6 | ;;模块配置 |
7 | -application.modules = "Index,Category,Channel,Guang,Passport,Product,Cart" | 7 | +application.modules = "Index,Category,Channel,Guang,Passport,Product,Cart,Shopping" |
8 | ;;加载 | 8 | ;;加载 |
9 | application.bootstrap = APPLICATION_PATH "/application/Bootstrap.php" | 9 | application.bootstrap = APPLICATION_PATH "/application/Bootstrap.php" |
10 | ;;view文件的扩展名 | 10 | ;;view文件的扩展名 |
-
Please register or login to post a comment