Authored by hf

Merge remote-tracking branch 'origin/hotfix/yohocoinuse' into hotfix

framework @ e9d066dd
1 -Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2 1 +Subproject commit e9d066dd88a8e7e37103021c427a205a5cfcdcec
@@ -22,26 +22,33 @@ class Yohobuy @@ -22,26 +22,33 @@ class Yohobuy
22 // const API_URL2 = 'http://api.open.yohobuy.com/'; 22 // const API_URL2 = 'http://api.open.yohobuy.com/';
23 // const SERVICE_URL = 'http://service.api.yohobuy.com/'; 23 // const SERVICE_URL = 'http://service.api.yohobuy.com/';
24 // const YOHOBUY_URL = 'http://www.yohobuy.com/'; 24 // const YOHOBUY_URL = 'http://www.yohobuy.com/';
25 -  
26 - const API_URL = 'http://apih5.yoho.cn/';  
27 - const API_URL2 = 'http://apih5.yoho.cn/';  
28 - const SERVICE_URL = 'http://serviceh5.yoho.cn/';  
29 - const YOHOBUY_URL = 'http://www.yohobuy.com/';  
30 - const API_OLD = 'http://api2.open.yohobuy.com/';  
31 25
32 -// /* 测试环境 */  
33 -// const API_URL = 'http://testapi.yoho.cn:28078/';  
34 -// const SERVICE_URL = 'http://testservice.yoho.cn:28077/';  
35 -// const YOHOBUY_URL = 'http://www.yohobuy.com/';  
36 -// const API_OLD = 'http://test2.open.yohobuy.com/';  
37 -  
38 -// /* 预览环境 */  
39 -// const API_URL = 'http://preapi.yoho.cn/';  
40 -// const API_URL2 = 'http://preapi.yoho.cn/'; 26 +// const API_URL = 'http://apih5.yoho.cn/';
  27 +// const API_URL2 = 'http://apih5.yoho.cn/';
41 // const SERVICE_URL = 'http://serviceh5.yoho.cn/'; 28 // const SERVICE_URL = 'http://serviceh5.yoho.cn/';
42 // const YOHOBUY_URL = 'http://www.yohobuy.com/'; 29 // const YOHOBUY_URL = 'http://www.yohobuy.com/';
43 // const API_OLD = 'http://api2.open.yohobuy.com/'; 30 // const API_OLD = 'http://api2.open.yohobuy.com/';
44 31
  32 +// /* 测试环境 */
  33 + // const API_URL = 'http://192.168.102.205:8080/gateway/'; // 先临时使用网关
  34 + const API_URL = 'http://testapi.yoho.cn:28078/';
  35 + const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
  36 + const YOHOBUY_URL = 'http://www.yohobuy.com/';
  37 + const API_OLD = 'http://test2.open.yohobuy.com/';
  38 +
  39 + /* 预览环境 */
  40 +// const API_URL = 'http://preapi.yoho.cn/';
  41 +// const API_URL2 = 'http://preapi.yoho.cn/';
  42 +// const SERVICE_URL = 'http://serviceh5.yoho.cn/';
  43 +// const YOHOBUY_URL = 'http://www.yohobuy.com/';
  44 +// const API_OLD = 'http://api2.open.yohobuy.com/';
  45 +
  46 + /* PC重构地址 */
  47 +// const API_URL = 'http://test.open.yohobuy.com/';
  48 +// const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
  49 +// const YOHOBUY_URL = 'http://www.yohobuy.com/';
  50 +// const API_OLD = 'http://api2.open.yohobuy.com/';
  51 +
45 /** 52 /**
46 * 私钥列表 53 * 私钥列表
47 * 54 *
@@ -51,6 +58,7 @@ class Yohobuy @@ -51,6 +58,7 @@ class Yohobuy
51 'android' => 'fd4ad5fcfa0de589ef238c0e7331b585', 58 'android' => 'fd4ad5fcfa0de589ef238c0e7331b585',
52 'iphone' => 'a85bb0674e08986c6b115d5e3a4884fa', 59 'iphone' => 'a85bb0674e08986c6b115d5e3a4884fa',
53 'ipad' => 'ad9fcda2e679cf9229e37feae2cdcf80', 60 'ipad' => 'ad9fcda2e679cf9229e37feae2cdcf80',
  61 + 'web' => '0ed29744ed318fd28d2c07985d3ba633',
54 ); 62 );
55 63
56 /** 64 /**
@@ -64,8 +72,12 @@ class Yohobuy @@ -64,8 +72,12 @@ class Yohobuy
64 } 72 }
65 // 苹果IPAD 73 // 苹果IPAD
66 elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) { 74 elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
  75 +
67 return 'ipad'; 76 return 'ipad';
68 } 77 }
  78 + elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'android')) {
  79 + return 'android';
  80 + }
69 // 其它 81 // 其它
70 else { 82 else {
71 return 'android'; 83 return 'android';
@@ -150,7 +162,6 @@ class Yohobuy @@ -150,7 +162,6 @@ class Yohobuy
150 if (!empty($data)) { 162 if (!empty($data)) {
151 $url = self::httpBuildQuery($url, $data); 163 $url = self::httpBuildQuery($url, $data);
152 } 164 }
153 -  
154 /* 开启缓存的情况 */ 165 /* 开启缓存的情况 */
155 if ($cache && USE_CACHE) { 166 if ($cache && USE_CACHE) {
156 // 先尝试获取一级缓存(master), 有数据则直接返回. 167 // 先尝试获取一级缓存(master), 有数据则直接返回.
@@ -168,7 +179,7 @@ class Yohobuy @@ -168,7 +179,7 @@ class Yohobuy
168 if (!$returnJson && !empty($result)) { 179 if (!$returnJson && !empty($result)) {
169 $result = json_decode($result, true); 180 $result = json_decode($result, true);
170 } 181 }
171 - 182 +
172 curl_close($ch); 183 curl_close($ch);
173 $data = array(); 184 $data = array();
174 185
@@ -216,7 +227,7 @@ class Yohobuy @@ -216,7 +227,7 @@ class Yohobuy
216 } 227 }
217 curl_setopt($ch, CURLOPT_COOKIE, implode(';', $cookie_str)); 228 curl_setopt($ch, CURLOPT_COOKIE, implode(';', $cookie_str));
218 } 229 }
219 - 230 + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 YOHOWEB');
220 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 231 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
221 curl_setopt($ch, CURLOPT_POST, true); 232 curl_setopt($ch, CURLOPT_POST, true);
222 // 销毁私钥参数 233 // 销毁私钥参数
@@ -248,13 +248,15 @@ class CartData @@ -248,13 +248,15 @@ class CartData
248 * 248 *
249 * @param int $uid 用户ID 249 * @param int $uid 用户ID
250 * @param string $cartType 购物车类型,ordinary表示普通购物车 250 * @param string $cartType 购物车类型,ordinary表示普通购物车
  251 + * @param int $isUseYohoCoin 是否使用有货币,默认0不使用, 1使用
251 * @return array 接口返回的数据 252 * @return array 接口返回的数据
252 */ 253 */
253 - public static function cartPay($uid, $cartType) 254 + public static function cartPay($uid, $cartType, $isUseYohoCoin = 0)
254 { 255 {
255 $param = Yohobuy::param(); 256 $param = Yohobuy::param();
256 $param['method'] = 'app.Shopping.payment'; 257 $param['method'] = 'app.Shopping.payment';
257 $param['cart_type'] = $cartType; 258 $param['cart_type'] = $cartType;
  259 + $param['yoho_coin_mode'] = $isUseYohoCoin;
258 $param['uid'] = $uid; 260 $param['uid'] = $uid;
259 $param['client_secret'] = Sign::getSign($param); 261 $param['client_secret'] = Sign::getSign($param);
260 262
@@ -111,6 +111,10 @@ function showChooseGifDialog() { @@ -111,6 +111,10 @@ function showChooseGifDialog() {
111 }, function() { 111 }, function() {
112 window.location.href = cartContentShow().find('.freebie > a').attr('href'); 112 window.location.href = cartContentShow().find('.freebie > a').attr('href');
113 }, function() { 113 }, function() {
  114 + var info = window.cookie('order-info');
  115 + if (info) {
  116 + window.setCookie('order-info', '');
  117 + }
114 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType; 118 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
115 }); 119 });
116 } 120 }
@@ -185,6 +189,7 @@ if ($('.freebie').length > 0) { @@ -185,6 +189,7 @@ if ($('.freebie').length > 0) {
185 } 189 }
186 190
187 $('.btn-balance').on('touchend', function() { 191 $('.btn-balance').on('touchend', function() {
  192 + var info = window.cookie('order-info');
188 if (shouldLowStocks()) { 193 if (shouldLowStocks()) {
189 tip.show('所选商品中含有库存不足的商品'); 194 tip.show('所选商品中含有库存不足的商品');
190 return false; 195 return false;
@@ -196,6 +201,9 @@ $('.btn-balance').on('touchend', function() { @@ -196,6 +201,9 @@ $('.btn-balance').on('touchend', function() {
196 } 201 }
197 202
198 if (hasChecked()) { 203 if (hasChecked()) {
  204 + if (info) {
  205 + window.setCookie('order-info', '');
  206 + }
199 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType; 207 window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
200 } else { 208 } else {
201 tip.show('请先勾选商品'); 209 tip.show('请先勾选商品');
@@ -10,8 +10,7 @@ var $ = require('jquery'), @@ -10,8 +10,7 @@ var $ = require('jquery'),
10 lazyLoad = require('yoho.lazyload'); 10 lazyLoad = require('yoho.lazyload');
11 11
12 var dialog = require('../me/dialog'), 12 var dialog = require('../me/dialog'),
13 - tip = require('../plugin/tip'),  
14 - orderInfo = require('./order-info').orderInfo; 13 + tip = require('../plugin/tip');
15 14
16 var $selectAllBtn = $('.balance .checkbox'), 15 var $selectAllBtn = $('.balance .checkbox'),
17 requesting = false; 16 requesting = false;
@@ -106,8 +105,7 @@ $('.icon-del').on('touchstart', function(e) { @@ -106,8 +105,7 @@ $('.icon-del').on('touchstart', function(e) {
106 autoHide: true, 105 autoHide: true,
107 fast: true 106 fast: true
108 }); 107 });
109 - orderInfo('couponCode', null);  
110 - orderInfo('couponName', null); 108 + //window.setCookie('order-info', '');
111 window.setCookie('_yoho-cart-refreshByDelete', true); 109 window.setCookie('_yoho-cart-refreshByDelete', true);
112 window.location.href = '/cart/index/index?cartType=' + $('#cartType').val(); 110 window.location.href = '/cart/index/index?cartType=' + $('#cartType').val();
113 } else { 111 } else {
@@ -71,18 +71,20 @@ $('.checkbox').on('touchstart', function() { @@ -71,18 +71,20 @@ $('.checkbox').on('touchstart', function() {
71 } 71 }
72 }); 72 });
73 73
74 -$('.invoice').on('touchend', '.checkbox', function() { 74 +$invoice.on('touchend', '.checkbox', function() {
75 var $this = $(this); 75 var $this = $(this);
76 76
77 if ($this.hasClass('icon-cb-checked')) { 77 if ($this.hasClass('icon-cb-checked')) {
78 - $('.invoice').addClass('focus'); 78 + $invoice.addClass('focus');
79 } 79 }
80 if ($this.hasClass('icon-checkbox')) { 80 if ($this.hasClass('icon-checkbox')) {
81 - $('.invoice').removeClass('focus'); 81 + $invoice.removeClass('focus');
82 } 82 }
83 }); 83 });
84 84
85 function orderCompute() { 85 function orderCompute() {
  86 + var yohoCoin = orderInfo('yohoCoin');
  87 +
86 $.ajax({ 88 $.ajax({
87 method: 'POST', 89 method: 'POST',
88 url: '/cart/index/orderCompute', 90 url: '/cart/index/orderCompute',
@@ -91,7 +93,7 @@ function orderCompute() { @@ -91,7 +93,7 @@ function orderCompute() {
91 deliveryId: orderInfo('deliveryId'), 93 deliveryId: orderInfo('deliveryId'),
92 paymentTypeId: orderInfo('paymentTypeId'), 94 paymentTypeId: orderInfo('paymentTypeId'),
93 couponCode: orderInfo('couponCode'), 95 couponCode: orderInfo('couponCode'),
94 - yohoCoin: orderInfo('yohoCoin') 96 + yohoCoin: yohoCoin
95 } 97 }
96 }).then(function(res) { 98 }).then(function(res) {
97 var priceHtml; 99 var priceHtml;
@@ -232,10 +234,12 @@ $('.coin').on('touchend', function() { @@ -232,10 +234,12 @@ $('.coin').on('touchend', function() {
232 orderCompute(); 234 orderCompute();
233 }); 235 });
234 236
235 -$invoice.on('touchend', function() { 237 +$invoice.on('touchend', function(e) {
236 var $this = $(this); 238 var $this = $(this);
237 239
238 orderInfo('invoice', $this.find('.checkbox').hasClass('icon-cb-checked')); 240 orderInfo('invoice', $this.find('.checkbox').hasClass('icon-cb-checked'));
  241 + e.preventDefault();
  242 + e.stopPropagation();
239 }); 243 });
240 244
241 $invoice.find('[name="invoice-title"]').on('blur', function() { 245 $invoice.find('[name="invoice-title"]').on('blur', function() {
@@ -11,10 +11,10 @@ require('../common'); @@ -11,10 +11,10 @@ require('../common');
11 function init() { 11 function init() {
12 info = { 12 info = {
13 uid: window.getUid(), 13 uid: window.getUid(),
14 - deliveryId: 1, 14 + deliveryId: $('.dispatch-mode .chosed').data('id') || 1,
15 deliveryTimeId: 1, 15 deliveryTimeId: 1,
16 paymentTypeId: 1, 16 paymentTypeId: 1,
17 - yohoCoin: $('.coin').data('yoho-coin') || 0, 17 + yohoCoin: 0,
18 addressId: null, 18 addressId: null,
19 couponCode: null, 19 couponCode: null,
20 couponName: null, 20 couponName: null,
@@ -30,9 +30,9 @@ function init() { @@ -30,9 +30,9 @@ function init() {
30 // info 必须是 JSON 字符串 30 // info 必须是 JSON 字符串
31 try { 31 try {
32 info = JSON.parse(info); 32 info = JSON.parse(info);
33 - 33 +
34 // 2015/12/31 hf: fixes bug to 购物车页面调用该JS, 会导致有YOHO币,值却没有传给服务端. 因此需要再设置一下 34 // 2015/12/31 hf: fixes bug to 购物车页面调用该JS, 会导致有YOHO币,值却没有传给服务端. 因此需要再设置一下
35 - info['yohoCoin'] = $('.coin').data('yoho-coin') || 0; 35 + //info['yohoCoin'] = $('.coin').data('yoho-coin') || 0;
36 } catch (e) { 36 } catch (e) {
37 init(); 37 init();
38 } 38 }
@@ -69,7 +69,7 @@ @@ -69,7 +69,7 @@
69 <span class="title">YOHO币</span> 69 <span class="title">YOHO币</span>
70 70
71 {{#if yohoCoin}} 71 {{#if yohoCoin}}
72 - <span class="desc used {{#unless useYohoCoin}}hide{{/if}}">已抵¥{{useYohoCoin}}</span> 72 + <span class="desc used {{#unless useYohoCoin}}hide{{/unless}}">已抵¥{{useYohoCoin}}</span>
73 <span class="desc can-use {{#if useYohoCoin}}hide{{/if}}">可抵¥{{yohoCoin}}</span> 73 <span class="desc can-use {{#if useYohoCoin}}hide{{/if}}">可抵¥{{yohoCoin}}</span>
74 74
75 {{#if useYohoCoin}} 75 {{#if useYohoCoin}}
@@ -449,7 +449,11 @@ class CartModel @@ -449,7 +449,11 @@ class CartModel
449 449
450 // 有货币 450 // 有货币
451 $result['yohoCoin'] = $payReturn['yoho_coin']; 451 $result['yohoCoin'] = $payReturn['yoho_coin'];
452 - $result['useYohoCoin'] = isset($orderCompute['use_yoho_coin']) ? $orderCompute['use_yoho_coin'] : $payReturn['use_yoho_coin']; 452 + /*
  453 + * 默认使用有货币
  454 + * $result['useYohoCoin'] = isset($orderCompute['use_yoho_coin']) ? $orderCompute['use_yoho_coin'] : $payReturn['use_yoho_coin'];
  455 + */
  456 + $result['useYohoCoin'] = isset($orderCompute['use_yoho_coin']) ? $orderCompute['use_yoho_coin'] : false;
453 457
454 // 订单数据 458 // 订单数据
455 if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) { 459 if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) {
@@ -482,7 +486,7 @@ class CartModel @@ -482,7 +486,7 @@ class CartModel
482 486
483 // 优惠券数据 487 // 优惠券数据
484 $coupons = array('couponName' => ''); 488 $coupons = array('couponName' => '');
485 - if (!empty($orderCompute['coupon_amount'])) { 489 + if (isset($orderCompute['coupon_amount']) && (!empty($orderCompute['coupon_amount']) || ($orderCompute['coupon_amount'] === 0 && $orderCompute['shipping_cost'] === 0))) {
486 $coupons['couponName'] = $orderInfo['couponName']; 490 $coupons['couponName'] = $orderInfo['couponName'];
487 } 491 }
488 $result['coupon'] = $coupons; 492 $result['coupon'] = $coupons;
@@ -285,7 +285,7 @@ class IndexController extends AbstractAction @@ -285,7 +285,7 @@ class IndexController extends AbstractAction
285 $cartType = $this->get('cartType', ''); 285 $cartType = $this->get('cartType', '');
286 $cookieData = $this->getCookie('order-info', null); 286 $cookieData = $this->getCookie('order-info', null);
287 $orderInfo = array(); 287 $orderInfo = array();
288 - if (empty($cartType) && !empty($cookieData)) { 288 + if (!empty($cookieData)) {
289 $orderInfo = json_decode($cookieData, true); 289 $orderInfo = json_decode($cookieData, true);
290 $cartType = $orderInfo['cartType']; 290 $cartType = $orderInfo['cartType'];
291 } 291 }