Authored by 郝肖肖

虚拟门票有货币使用改造

@@ -568,7 +568,7 @@ class CartData @@ -568,7 +568,7 @@ class CartData
568 } 568 }
569 $param['client_secret'] = Sign::getSign($param); 569 $param['client_secret'] = Sign::getSign($param);
570 570
571 - $data = Yohobuy::get(API_URL, $param); 571 + $data = Yohobuy::get('http://192.168.102.205:8080/gateway/', $param);
572 572
573 //展览票不显示区域,上面要求的。@高扬、@徐洪云,2016/7/6 573 //展览票不显示区域,上面要求的。@高扬、@徐洪云,2016/7/6
574 if (isset($data['data']) && !empty($data['data']['goods_list'])) { 574 if (isset($data['data']) && !empty($data['data']['goods_list'])) {
@@ -112,22 +112,47 @@ @@ -112,22 +112,47 @@
112 </ul> 112 </ul>
113 113
114 <dl class="play-bi-pan pan"> 114 <dl class="play-bi-pan pan">
115 - <dt>使用有货币支付</dt> 115 + <dt class="{{#unless yohoCoinCompute.yohoCoinClick}}not-btn{{/unless}}">
  116 + <span class="not-btn-tip red {{#if yohoCoinCompute.yohoCoinClick}}hide{{/if}}">抱歉,您的订单实付款不满足有货币使用条件</span>使用有货币支付
  117 + </dt>
116 <dd> 118 <dd>
117 - <div class="play-pan">  
118 - <div class="strong">  
119 - 使用有货币:  
120 - <input type="text" class="textbox" id="biprice" data-bi="{{ownYohoCoin}}" value="0" /> 119 + <div class="errbitip red"></div>
  120 + <ul class="play-pan" id="biprice" data-yoho-coin-num={{yohoCoinCompute.yohoCoinNum}} data-yoho-coin-click={{yohoCoinCompute.yohoCoinClick}}>
  121 + <li>
  122 + <div class="float-left num-list-width">
  123 + 有货币满<span class="sign-amount num-limit-coin">{{yohoCoinCompute.yoho_coin_pay_rule.num_limit}}</span>个即可使用,每次使用有货币为<span class="sign-amount num-limit-coin">{{yohoCoinCompute.yoho_coin_pay_rule.num_limit}}</span>的整数倍
121 </div> 124 </div>
122 - <p >  
123 - 您目前有有货币 <em class="strong">{{ownYohoCoin}}</em>  
124 - </p>  
125 - <p class="errbitip red"></p>  
126 - <div class="btn-group clearfix"> 125 + <div class="float-right yoho-coin-help">?
  126 + <div class="yoho-coin-help-dialog hide">
  127 + <span class="arrow-up"></span>
  128 + <div class="yoho-coin-help-dialog-title">有货币使用条件:</div>
  129 + <div class="yoho-coin-help-dialog-content">
  130 + <ul>
  131 + <li>1.订单金额大于20元(含20元)</li>
  132 + <li>2.有货币数量大于<span class="num-limit-coin">{{yohoCoinCompute.yoho_coin_pay_rule.num_limit}}</span>个(含<span class="num-limit-coin">{{yohoCoinCompute.yoho_coin_pay_rule.num_limit}}</span>个)</li>
  133 + <li>3.每笔支付不得超过应付金额{{yohoCoinCompute.yoho_coin_pay_rule.max_pay_rate_desc}}</li>
  134 + <li>备注:使用有货币数量为<span class="num-limit-coin">{{yohoCoinCompute.yoho_coin_pay_rule.num_limit}}的整数倍,100有货币抵1元。</li>
  135 + </ul>
  136 + </div>
  137 + </div>
  138 + </div>
  139 + </li>
  140 + <li>
  141 + 您当前共有有货币<span class="sign-amount totalYohoCoinNum">{{yohoCoinCompute.totalYohoCoinNum}}</span>个,可用<span class="sign-amount yohoCoinNum">{{yohoCoinCompute.yohoCoinNum}}</span>
  142 + </li>
  143 + <li>
  144 + 本次使用有货币<span class="sign-amount yohoCoinNum">{{yohoCoinCompute.yohoCoinNum}}</span>个 抵扣<span class="sign-amount yohoCoin"{{yohoCoinCompute.yohoCoin}}</span>
  145 + </li>
  146 + <li>
  147 + <div class="float-left btn-group clearfix">
127 <input type="button" class="ok" value="确定" id="bisubmit"/> 148 <input type="button" class="ok" value="确定" id="bisubmit"/>
128 <input type="button" class="cancel cancel-bi" value="取消"/> 149 <input type="button" class="cancel cancel-bi" value="取消"/>
129 </div> 150 </div>
  151 + <div class="float-right">
  152 + <a class="yoho-coin-help-link" href="/help/?category_id=87" target="_blank">有货币使用规则?</a>
130 </div> 153 </div>
  154 + </li>
  155 + </ul>
131 </dd> 156 </dd>
132 </dl><!--/play-bi-pan pan--> 157 </dl><!--/play-bi-pan pan-->
133 </div><!--/play-right--> 158 </div><!--/play-right-->
@@ -389,7 +389,7 @@ var Order = { @@ -389,7 +389,7 @@ var Order = {
389 389
390 var $juangroupInput = $('.play-juan.is-select input[name="juangroup"]:checked'); 390 var $juangroupInput = $('.play-juan.is-select input[name="juangroup"]:checked');
391 var expressVal = $('.express-list input[name="carriagegroup"]:checked').val(); 391 var expressVal = $('.express-list input[name="carriagegroup"]:checked').val();
392 - var biVal = $('#biprice.is-select').data('yoho-coin-num'); 392 + var biVal = $('#biprice.is-select').data('yoho-coin-num') * 1;
393 var codeVal = $juangroupInput.val(); 393 var codeVal = $juangroupInput.val();
394 var cartType = $('.address-manage').attr('cart-type'); 394 var cartType = $('.address-manage').attr('cart-type');
395 var redEnvelopes = $('.use-envelopes input:checked').attr('data-use'); 395 var redEnvelopes = $('.use-envelopes input:checked').attr('data-use');
@@ -534,7 +534,6 @@ var Order = { @@ -534,7 +534,6 @@ var Order = {
534 $('.errbitip').html('请输入一个正整数'); 534 $('.errbitip').html('请输入一个正整数');
535 $('#biprice').removeClass('is-select'); 535 $('#biprice').removeClass('is-select');
536 return false; 536 return false;
537 -  
538 } 537 }
539 538
540 e.$loading.show(); 539 e.$loading.show();
@@ -33,6 +33,7 @@ var TicketCat = { @@ -33,6 +33,7 @@ var TicketCat = {
33 $toPay: $('.ticket-play em'), 33 $toPay: $('.ticket-play em'),
34 $errorTip: $('.errbitip'), 34 $errorTip: $('.errbitip'),
35 $tbody: $('table tbody', '.pay-wapper'), 35 $tbody: $('table tbody', '.pay-wapper'),
  36 + $yohoCoinHelp: $('.yoho-coin-help'),
36 37
37 //门票js 38 //门票js
38 $showTicketMobile: $('.show-ticket-mobile'), 39 $showTicketMobile: $('.show-ticket-mobile'),
@@ -147,6 +148,10 @@ var TicketCat = { @@ -147,6 +148,10 @@ var TicketCat = {
147 el.$pan.find('dt').click(function() { 148 el.$pan.find('dt').click(function() {
148 var pan = $(this).parent('dl.pan'); 149 var pan = $(this).parent('dl.pan');
149 150
  151 + if ($(this).hasClass('not-btn')) {
  152 + return false;
  153 + }
  154 +
150 if (pan.find('dd').is(':hidden')) { 155 if (pan.find('dd').is(':hidden')) {
151 c.winShow(pan); 156 c.winShow(pan);
152 $(this).addClass('active'); 157 $(this).addClass('active');
@@ -161,16 +166,19 @@ var TicketCat = { @@ -161,16 +166,19 @@ var TicketCat = {
161 var pan = $(this).parents('dl.pan'); 166 var pan = $(this).parents('dl.pan');
162 var selectData = {}; 167 var selectData = {};
163 168
  169 + if (!$('#biprice').data('yoho-coin-click')) {
  170 + $('.errbitip').html('抱歉,您的订单实付款不满足有货币使用条件');
  171 + return true;
  172 + }
  173 +
164 $('#biprice').addClass('is-select'); 174 $('#biprice').addClass('is-select');
165 selectData = _this.getSelectData(); 175 selectData = _this.getSelectData();
166 -  
167 - if (!/^\d+$/.test(selectData.yohoCoin + '') || selectData.yohoCoin * 1 === 0) { 176 + if (selectData.yohoCoin * 1 <= 0) {
168 $('.errbitip').html('请输入一个正整数'); 177 $('.errbitip').html('请输入一个正整数');
169 $('#biprice').removeClass('is-select'); 178 $('#biprice').removeClass('is-select');
170 - } else if (selectData.yohoCoin * 1 > $('.play-pan em').text() * 1) {  
171 - $('.errbitip').html('您的有货币不足');  
172 - $('#biprice').removeClass('is-select');  
173 - } else { 179 + return false;
  180 + }
  181 +
174 el.$loading.show(); 182 el.$loading.show();
175 $.ajax({ 183 $.ajax({
176 type: 'POST', 184 type: 'POST',
@@ -187,7 +195,6 @@ var TicketCat = { @@ -187,7 +195,6 @@ var TicketCat = {
187 } 195 }
188 } 196 }
189 }); 197 });
190 - }  
191 }); 198 });
192 199
193 // 修改有货币 200 // 修改有货币
@@ -280,6 +287,12 @@ var TicketCat = { @@ -280,6 +287,12 @@ var TicketCat = {
280 }); 287 });
281 }); 288 });
282 289
  290 + //有货币帮助弹框
  291 + el.$yohoCoinHelp.hover(function() {
  292 + $(this).find('.yoho-coin-help-dialog').removeClass('hide');
  293 + }, function() {
  294 + $(this).find('.yoho-coin-help-dialog').addClass('hide');
  295 + });
283 }, 296 },
284 297
285 //渲染价格明细 298 //渲染价格明细
@@ -312,17 +325,22 @@ var TicketCat = { @@ -312,17 +325,22 @@ var TicketCat = {
312 e.$toPay.html((data.shopping_cart_data.last_order_amount).toFixed(2)); 325 e.$toPay.html((data.shopping_cart_data.last_order_amount).toFixed(2));
313 326
314 //有货币清零状态更新 327 //有货币清零状态更新
315 - $('#biprice').val(accMul(100, data.shopping_cart_data.use_yoho_coin));  
316 - if (data.use_yoho_coin === 0) {  
317 - $('.errbitip').text('');  
318 - } else {  
319 - $('.errbitip').text('抵扣' + data.shopping_cart_data.use_yoho_coin.toFixed(2) + '元'); 328 + $('dl.play-bi-pan').find('dt').removeClass('not-btn');
  329 + $('.not-btn-tip').addClass('hide');
  330 + if (!data.yohoCoinCompute.yohoCoinClick) {
  331 + //不可以使用状态
  332 + $('dl.play-bi-pan').find('dt').addClass('not-btn');
  333 + $('.not-btn-tip').removeClass('hide');
320 } 334 }
321 - 335 + $('#biprice').data('.yoho-coin-click', data.yohoCoinCompute.yohoCoinClick);
  336 + $('#biprice').find('.num-limit-coin').html(data.yohoCoinCompute.yoho_coin_pay_rule.num_limit);
  337 + $('#biprice').find('.totalYohoCoinNum').html(data.yohoCoinCompute.totalYohoCoinNum);
  338 + $('#biprice').find('.yohoCoinNum').html(data.yohoCoinCompute.yohoCoinNum);
  339 + $('#biprice').find('.yohoCoin').html(data.yohoCoinCompute.yohoCoin);
322 }, 340 },
323 getSelectData: function() { 341 getSelectData: function() {
324 var expressVal = $('.express-list input[name="carriagegroup"]:checked').val(); 342 var expressVal = $('.express-list input[name="carriagegroup"]:checked').val();
325 - var biVal = $('#biprice.is-select').val(); 343 + var biVal = $('#biprice.is-select').data('yoho-coin-num') * 1;
326 var cartType = $('.address-manage').attr('cart-type'); 344 var cartType = $('.address-manage').attr('cart-type');
327 var resultData; 345 var resultData;
328 346
@@ -691,9 +691,15 @@ class CartModel @@ -691,9 +691,15 @@ class CartModel
691 */ 691 */
692 public static function cartPay($uid, $cartType, $isAdvanceCart) 692 public static function cartPay($uid, $cartType, $isAdvanceCart)
693 { 693 {
  694 + $result = [];
694 /* 调接口订单确认接口 */ 695 /* 调接口订单确认接口 */
695 $pay = CartData::cartPay($uid, $cartType); 696 $pay = CartData::cartPay($uid, $cartType);
696 - return self::filterCartPay($pay, $cartType, $isAdvanceCart, $uid); 697 + $result = self::filterCartPay($pay, $cartType, $isAdvanceCart, $uid);
  698 +
  699 + //有货币
  700 + $result['yohoCoinCompute'] = self::yohoCoinCompute($pay['data']);
  701 +
  702 + return $result;
697 } 703 }
698 /** 704 /**
699 * 处理购物车返回 705 * 处理购物车返回
@@ -880,10 +886,7 @@ class CartModel @@ -880,10 +886,7 @@ class CartModel
880 } 886 }
881 // 返还的 YOHO 币 887 // 返还的 YOHO 币
882 $result['totalYoho'] = $pay['data']['shopping_cart_data']['gain_yoho_coin']; 888 $result['totalYoho'] = $pay['data']['shopping_cart_data']['gain_yoho_coin'];
883 - // 拥有的有货币  
884 - $result['ownYohoCoin'] = $pay['data']['yoho_coin'] * 100;  
885 - // 默认是否使用有货币  
886 - $result['useYohoCoin'] = empty($pay['data']['use_yoho_coin']) ? false : true; 889 +
887 // 红包总金额 890 // 红包总金额
888 $result['redEnvelopes'] = empty($pay['data']['red_envelopes']) ? false : Helpers::transPrice($pay['data']['red_envelopes']); 891 $result['redEnvelopes'] = empty($pay['data']['red_envelopes']) ? false : Helpers::transPrice($pay['data']['red_envelopes']);
889 // 使用的红包金额 892 // 使用的红包金额
@@ -906,9 +909,6 @@ class CartModel @@ -906,9 +909,6 @@ class CartModel
906 $isNewUser = false; 909 $isNewUser = false;
907 } 910 }
908 $result['isNewUser'] = $isNewUser ? true : false; 911 $result['isNewUser'] = $isNewUser ? true : false;
909 -  
910 - //有货币  
911 - $result['yohoCoinCompute'] = self::yohoCoinCompute($pay['data']);  
912 //JIT拆单需求 package 912 //JIT拆单需求 package
913 $result['packages'] = self::getPackageInfo($pay['data']['shopping_cart_data']); 913 $result['packages'] = self::getPackageInfo($pay['data']['shopping_cart_data']);
914 } while (false); 914 } while (false);
@@ -1550,7 +1550,13 @@ class CartModel @@ -1550,7 +1550,13 @@ class CartModel
1550 */ 1550 */
1551 public function addTicket($uid, $productSku, $buyNumber, $yohoCoin = 0) 1551 public function addTicket($uid, $productSku, $buyNumber, $yohoCoin = 0)
1552 { 1552 {
1553 - return CartData::addTicket($uid, $productSku, $buyNumber, $yohoCoin); 1553 + $result = [];
  1554 + $result = CartData::addTicket($uid, $productSku, $buyNumber, $yohoCoin);
  1555 + //有货币
  1556 + if (isset($result['data']['shopping_cart_data'])) {
  1557 + $result['data']['yohoCoinCompute'] = self::yohoCoinCompute($result['data']['shopping_cart_data']);
  1558 + }
  1559 + return $result;
1554 } 1560 }
1555 1561
1556 /** 1562 /**
@@ -1563,10 +1569,17 @@ class CartModel @@ -1563,10 +1569,17 @@ class CartModel
1563 */ 1569 */
1564 public function filterTicket($uid, $productSku, $buyNumber, $yohoCoin = 0) 1570 public function filterTicket($uid, $productSku, $buyNumber, $yohoCoin = 0)
1565 { 1571 {
  1572 + $result = [];
1566 $cartType = 'advance'; 1573 $cartType = 'advance';
1567 1574
1568 $data = self::addTicket($uid, $productSku, $buyNumber, $yohoCoin); 1575 $data = self::addTicket($uid, $productSku, $buyNumber, $yohoCoin);
1569 - return self::filterCartPay($data, $cartType, false); 1576 + $result = self::filterCartPay($data, $cartType, false);
  1577 + //有货币
  1578 + if (isset($data['data']['shopping_cart_data'])) {
  1579 + $result['yohoCoinCompute'] = self::yohoCoinCompute($data['data']['shopping_cart_data']);
  1580 + }
  1581 +
  1582 + return $result;
1570 } 1583 }
1571 1584
1572 /** 1585 /**
@@ -1589,7 +1602,7 @@ class CartModel @@ -1589,7 +1602,7 @@ class CartModel
1589 public static function yohoCoinCompute($orderCompute) { 1602 public static function yohoCoinCompute($orderCompute) {
1590 $yohoCoinData = ['totalYohoCoinNum' => 0, 'yohoCoin' => 0, 'yohoCoinNum' =>0, 'useYohoCoin' => 0, 'yohoCoinClick' => 0, 'yohoCoinMsg' => '']; 1603 $yohoCoinData = ['totalYohoCoinNum' => 0, 'yohoCoin' => 0, 'yohoCoinNum' =>0, 'useYohoCoin' => 0, 'yohoCoinClick' => 0, 'yohoCoinMsg' => ''];
1591 1604
1592 - if (empty($orderCompute)) { 1605 + if (empty($orderCompute) || empty($orderCompute['yoho_coin_pay_rule'])) {
1593 return $yohoCoinData; 1606 return $yohoCoinData;
1594 } 1607 }
1595 1608