Authored by 郝肖肖

有货币使用规则改造

@@ -269,12 +269,12 @@ class CartData @@ -269,12 +269,12 @@ class CartData
269 $param['client_secret'] = Sign::getSign($param); 269 $param['client_secret'] = Sign::getSign($param);
270 // print_r(Yohobuy::get(API_URL, $param)); 270 // print_r(Yohobuy::get(API_URL, $param));
271 271
272 - return Yohobuy::get(API_URL, $param); 272 + return Yohobuy::get('http://192.168.102.205:8080/gateway/', $param);
273 } 273 }
274 274
275 /** 275 /**
276 * 购物车结算--支付方式和配送方式选择 276 * 购物车结算--支付方式和配送方式选择
277 - * 277 + *http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E8%AE%A2%E5%8D%95/shopping.md
278 * @param int $uid 用户ID 278 * @param int $uid 用户ID
279 * @param string $cartType 购物车类型,ordinary表示普通购物车 279 * @param string $cartType 购物车类型,ordinary表示普通购物车
280 * @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运 280 * @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
@@ -306,7 +306,7 @@ class CartData @@ -306,7 +306,7 @@ class CartData
306 $param['uid'] = $uid; 306 $param['uid'] = $uid;
307 $param['client_secret'] = Sign::getSign($param); 307 $param['client_secret'] = Sign::getSign($param);
308 308
309 - return Yohobuy::get(API_URL, $param); 309 + return Yohobuy::get('http://192.168.102.205:8080/gateway/', $param);
310 } 310 }
311 311
312 /** 312 /**
@@ -14,7 +14,7 @@ var $invoice = $('.invoice'), @@ -14,7 +14,7 @@ var $invoice = $('.invoice'),
14 $couponUse = $('.coupon-use.used'), 14 $couponUse = $('.coupon-use.used'),
15 $addressWrap = $('.address-wrap'), 15 $addressWrap = $('.address-wrap'),
16 $coinCheck = $('.coin-check'), 16 $coinCheck = $('.coin-check'),
17 - $coinUsed = $('.coin .used'), 17 + $coinLi = $('li.coin'),
18 $subBlock = $('.sub-block'), 18 $subBlock = $('.sub-block'),
19 $ticketsMobile = $('#mobile'), 19 $ticketsMobile = $('#mobile'),
20 payType, 20 payType,
@@ -27,6 +27,7 @@ var $invoice = $('.invoice'), @@ -27,6 +27,7 @@ var $invoice = $('.invoice'),
27 productSku = $('#productSku').val(), 27 productSku = $('#productSku').val(),
28 buyNumber = $('#buyNumber').val(), 28 buyNumber = $('#buyNumber').val(),
29 headerTop = $("#yoho-header").outerHeight(), 29 headerTop = $("#yoho-header").outerHeight(),
  30 + isYohoCoinClick = $coinLi.data('yoho-coin-click'),//判断有币是否可以单击
30 addressTop = $(".address-wrap").outerHeight(); 31 addressTop = $(".address-wrap").outerHeight();
31 32
32 var orderCont = window.cookie('order-info') && JSON.parse(window.cookie('order-info')); 33 var orderCont = window.cookie('order-info') && JSON.parse(window.cookie('order-info'));
@@ -121,13 +122,18 @@ if (queryString.cartType || queryString.carttype || !orderInfo('cartType')) { @@ -121,13 +122,18 @@ if (queryString.cartType || queryString.carttype || !orderInfo('cartType')) {
121 // $cur.addClass('chosed'); 122 // $cur.addClass('chosed');
122 // } 123 // }
123 124
124 -$('.checkbox').on('touchstart', function() { 125 +$('.checkbox').on('touchstart', function(e) {
125 var $this = $(this); 126 var $this = $(this);
126 127
  128 + if ($(e.target).closest('.coin-check').length && !isYohoCoinClick) {
  129 + return true;
  130 + }
  131 +
127 if ($this.hasClass('icon-cb-radio')) { 132 if ($this.hasClass('icon-cb-radio')) {
128 $this.removeClass('icon-cb-radio').addClass('icon-radio'); 133 $this.removeClass('icon-cb-radio').addClass('icon-radio');
129 return; 134 return;
130 } 135 }
  136 +
131 if ($this.hasClass('icon-radio')) { 137 if ($this.hasClass('icon-radio')) {
132 $this.removeClass('icon-radio').addClass('icon-cb-radio'); 138 $this.removeClass('icon-radio').addClass('icon-cb-radio');
133 } 139 }
@@ -211,9 +217,8 @@ function orderCompute() { @@ -211,9 +217,8 @@ function orderCompute() {
211 } 217 }
212 if (res.use_yoho_coin) { 218 if (res.use_yoho_coin) {
213 $coinCheck.find('em').html('- ¥ ' + res.use_yoho_coin); 219 $coinCheck.find('em').html('- ¥ ' + res.use_yoho_coin);
214 - $coinUsed.html('已抵¥' + res.use_yoho_coin);  
215 $coinCheck.find('em').show(); 220 $coinCheck.find('em').show();
216 - $coinUsed.show(); 221 + $coinLi.find('.msg').html(res.yohoCoinCompute.yohoCoinMsg);
217 } 222 }
218 total = ''; 223 total = '';
219 if (res.promotion_formula_list) { 224 if (res.promotion_formula_list) {
@@ -343,9 +348,15 @@ $('.coin').on('touchend', function(e) { @@ -343,9 +348,15 @@ $('.coin').on('touchend', function(e) {
343 $('.yoho-coin-help-dialog').removeClass('hide'); 348 $('.yoho-coin-help-dialog').removeClass('hide');
344 return true; 349 return true;
345 } 350 }
  351 +
346 if ($(e.target).closest('.coin-check').length <= 0) { 352 if ($(e.target).closest('.coin-check').length <= 0) {
347 return false; 353 return false;
348 } 354 }
  355 +
  356 + if (!isYohoCoinClick) {
  357 + return true;
  358 + }
  359 +
349 if ($this.find('.checkbox').hasClass('icon-cb-radio')) { 360 if ($this.find('.checkbox').hasClass('icon-cb-radio')) {
350 orderInfo('yohoCoin', $this.data('yoho-coin')); 361 orderInfo('yohoCoin', $this.data('yoho-coin'));
351 $this.find('.can-use').hide(); 362 $this.find('.can-use').hide();
@@ -492,6 +492,7 @@ @@ -492,6 +492,7 @@
492 text-align: center; 492 text-align: center;
493 color: #fff; 493 color: #fff;
494 font-size: 22px; 494 font-size: 22px;
  495 + margin-left: 10px;
495 } 496 }
496 } 497 }
497 498
@@ -111,14 +111,11 @@ @@ -111,14 +111,11 @@
111 </a> 111 </a>
112 </li> 112 </li>
113 {{/if}} 113 {{/if}}
114 - <li class="coin" data-yoho-coin="{{yohoCoin}}"> 114 + <li class="coin" data-yoho-coin="{{yohoCoinCompute.yohoCoin}}" data-yoho-coin-click={{yohoCoinCompute.yohoCoinClick}}>
115 <span class="title">有货币</span> 115 <span class="title">有货币</span>
116 -  
117 - {{#if yohoCoin}}  
118 - <span class="desc used {{#unless useYohoCoin}}hide{{/unless}}">已抵¥{{useYohoCoin}}</span>  
119 - <span class="desc can-use {{#if useYohoCoin}}hide{{/if}}">可抵¥{{yohoCoin}}</span> 116 + <span class="desc msg">{{yohoCoinCompute.yohoCoinMsg}}</span>
120 <span class="yoho-coin-help">?</span> 117 <span class="yoho-coin-help">?</span>
121 - {{#if useYohoCoin}} 118 + {{#if yohoCoinCompute.useYohoCoin}}
122 <span class="coin-check"> 119 <span class="coin-check">
123 <i class="iconfont checkbox icon-cb-radio"></i> 120 <i class="iconfont checkbox icon-cb-radio"></i>
124 </span> 121 </span>
@@ -127,11 +124,6 @@ @@ -127,11 +124,6 @@
127 <i class="iconfont checkbox icon-radio"></i> 124 <i class="iconfont checkbox icon-radio"></i>
128 </span> 125 </span>
129 {{/if}} 126 {{/if}}
130 - {{^}}  
131 - <span class="not-used coin-check">  
132 - 无有货币可用  
133 - </span>  
134 - {{/if}}  
135 </li> 127 </li>
136 128
137 {{#if invoice}} 129 {{#if invoice}}
@@ -398,7 +398,13 @@ class CartModel @@ -398,7 +398,13 @@ class CartModel
398 if (!empty($orderInfo)) { 398 if (!empty($orderInfo)) {
399 $orderInfo['paymentType'] = isset($orderInfo['paymentType']) ? $orderInfo['paymentType'] : ''; 399 $orderInfo['paymentType'] = isset($orderInfo['paymentType']) ? $orderInfo['paymentType'] : '';
400 $orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentType'], $orderInfo['couponCode'], $orderInfo['yohoCoin'], $skuList); 400 $orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentType'], $orderInfo['couponCode'], $orderInfo['yohoCoin'], $skuList);
  401 + // 有货币
  402 + $result['yohoCoinCompute'] = $orderCompute['yohoCoinCompute'];
  403 + } else {
  404 + // 有货币
  405 + $result['yohoCoinCompute'] = self::yohoCoinCompute($pay);
401 } 406 }
  407 +
402 // 根据地址id查询地址信息 408 // 根据地址id查询地址信息
403 if (isset($orderInfo['address'])) { 409 if (isset($orderInfo['address'])) {
404 $address = $orderInfo['address']; 410 $address = $orderInfo['address'];
@@ -525,17 +531,17 @@ class CartModel @@ -525,17 +531,17 @@ class CartModel
525 if (isset($payReturn['payment_way'])) { 531 if (isset($payReturn['payment_way'])) {
526 $onePay = array(); 532 $onePay = array();
527 $isPaymentType = true; 533 $isPaymentType = true;
528 - foreach ($payReturn['payment_way'] as $pay) {  
529 - if ($pay['is_support'] !== 'Y') { 534 + foreach ($payReturn['payment_way'] as $val) {
  535 + if ($val['is_support'] !== 'Y') {
530 continue; 536 continue;
531 } 537 }
532 538
533 $onePay = array(); 539 $onePay = array();
534 - $onePay['id'] = $pay['payment_id'];  
535 - $onePay['paymentType'] = $pay['payment_type'];  
536 - $onePay['name'] = $pay['payment_type_name'];  
537 - $onePay['isSupport'] = $pay['is_support'] === 'Y';  
538 -// $onePay['default'] = ($pay['default'] === 'Y'); 540 + $onePay['id'] = $val['payment_id'];
  541 + $onePay['paymentType'] = $val['payment_type'];
  542 + $onePay['name'] = $val['payment_type_name'];
  543 + $onePay['isSupport'] = $val['is_support'] === 'Y';
  544 +// $onePay['default'] = ($val['default'] === 'Y');
539 if (isset($orderInfo['paymentType']) && $onePay['paymentType'] === $orderInfo['paymentType']) { 545 if (isset($orderInfo['paymentType']) && $onePay['paymentType'] === $orderInfo['paymentType']) {
540 $onePay['recommend'] = true; 546 $onePay['recommend'] = true;
541 $isPaymentType = false; 547 $isPaymentType = false;
@@ -550,14 +556,6 @@ class CartModel @@ -550,14 +556,6 @@ class CartModel
550 } 556 }
551 } 557 }
552 558
553 - // 有货币  
554 - $result['yohoCoin'] = Helpers::transPrice($payReturn['yoho_coin']);  
555 - /*  
556 - * 默认使用有货币  
557 - * $result['useYohoCoin'] = isset($orderCompute['use_yoho_coin']) ? $orderCompute['use_yoho_coin'] : $payReturn['use_yoho_coin'];  
558 - */  
559 - $result['useYohoCoin'] = isset($orderCompute['use_yoho_coin']) ? $orderCompute['use_yoho_coin'] : false;  
560 -  
561 // 订单数据 559 // 订单数据
562 if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) { 560 if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) {
563 //判断是否为JIT商品 561 //判断是否为JIT商品
@@ -579,8 +577,6 @@ class CartModel @@ -579,8 +577,6 @@ class CartModel
579 // 商品金额 577 // 商品金额
580 $result['goodsPrice'] = $payReturn['shopping_cart_data']['str_order_amount']; 578 $result['goodsPrice'] = $payReturn['shopping_cart_data']['str_order_amount'];
581 579
582 - //print_r($payReturn['shopping_cart_data']['gain_yoho_coin']);  
583 -  
584 //有货币 580 //有货币
585 if((int)$payReturn['shopping_cart_data']['gain_yoho_coin'] > 0) { 581 if((int)$payReturn['shopping_cart_data']['gain_yoho_coin'] > 0) {
586 582
@@ -630,6 +626,35 @@ class CartModel @@ -630,6 +626,35 @@ class CartModel
630 } 626 }
631 627
632 /** 628 /**
  629 + *有货币使用前端方案显示及是否可单击判断
  630 + */
  631 + public static function yohoCoinCompute($orderCompute) {
  632 + $yohoCoinData = ['totalYohoCoinNum' => 0, 'yohoCoin' => 0, 'useYohoCoin' => 0, 'yohoCoinClick' => 0, 'yohoCoinMsg' => ''];
  633 +
  634 + if (empty($orderCompute)) {
  635 + return $yohoCoinData;
  636 + }
  637 +
  638 + $yohoCoinData = [
  639 + 'totalYohoCoinNum' => intval($orderCompute['total_yoho_coin_num']),
  640 + 'yohoCoin' => Helpers::transPrice($orderCompute['yoho_coin']),
  641 + 'useYohoCoin' => Helpers::transPrice($orderCompute['use_yoho_coin']),
  642 + 'yohoCoinClick' => 0,
  643 + 'yohoCoinMsg' => ''
  644 + ];
  645 +
  646 + if ($yohoCoinData['totalYohoCoinNum'] < 100) {
  647 + $yohoCoinData['yohoCoinMsg'] = "共{$yohoCoinCompute['totalYohoCoinNum']}有币币,满100可用";
  648 + } else if ($yohoCoinData['useYohoCoin'] > 0 || $yohoCoinData['yohoCoin'] > 0) {
  649 + $yohoCoinData['yohoCoinMsg'] = '可抵¥' . ($yohoCoinData['useYohoCoin'] > 0 ? $yohoCoinData['useYohoCoin'] : $yohoCoinData['yohoCoin']);
  650 + $yohoCoinData['yohoCoinClick'] = 1;
  651 + } else {
  652 + $yohoCoinData['yohoCoinMsg'] = "不满足有货币使用条件";
  653 + }
  654 +
  655 + return $yohoCoinData;
  656 + }
  657 + /**
633 * 购物车结算--获取可用的优惠券数目 658 * 购物车结算--获取可用的优惠券数目
634 * 659 *
635 * @param int $uid 用户ID 660 * @param int $uid 用户ID
@@ -668,6 +693,7 @@ class CartModel @@ -668,6 +693,7 @@ class CartModel
668 // 有货币添加.00后缀 693 // 有货币添加.00后缀
669 $compute['data']['use_yoho_coin'] = Helpers::transPrice($compute['data']['use_yoho_coin']); 694 $compute['data']['use_yoho_coin'] = Helpers::transPrice($compute['data']['use_yoho_coin']);
670 $result = $compute['data']; 695 $result = $compute['data'];
  696 + $result['yohoCoinCompute'] = self::yohoCoinCompute($compute['data']);
671 } 697 }
672 698
673 return $result; 699 return $result;
@@ -17,10 +17,10 @@ define('USE_INTER_FACE_SHUNT', false);//分流开关 @@ -17,10 +17,10 @@ define('USE_INTER_FACE_SHUNT', false);//分流开关
17 17
18 #dev环境 18 #dev环境
19 19
20 -define('API_URL', 'http://api-test1.yohops.com:9999/');  
21 -define('SERVICE_URL', 'http://service-test1.yohops.com:9999/'); 20 +define('API_URL', 'http://api-test3.yohops.com:9999/');
  21 +define('SERVICE_URL', 'http://service-test3.yohops.com:9999/');
22 define('YOHOBUY_URL', 'http://www.yohobuy.com/'); 22 define('YOHOBUY_URL', 'http://www.yohobuy.com/');
23 -define('SERVICE_NOTIFY', 'http://service-test1.yohops.com:9999/'); 23 +define('SERVICE_NOTIFY', 'http://service-test3.yohops.com:9999/');
24 24
25 $application = new Application(APPLICATION_PATH . '/configs/application.developer.ini'); 25 $application = new Application(APPLICATION_PATH . '/configs/application.developer.ini');
26 $application->bootstrap()->run(); 26 $application->bootstrap()->run();