Authored by 郝肖肖

虚拟门票有货币使用改造

... ... @@ -568,7 +568,7 @@ class CartData
}
$param['client_secret'] = Sign::getSign($param);
$data = Yohobuy::get(API_URL, $param);
$data = Yohobuy::get('http://192.168.102.205:8080/gateway/', $param);
//展览票不显示区域,上面要求的。@高扬、@徐洪云,2016/7/6
if (isset($data['data']) && !empty($data['data']['goods_list'])) {
... ...
... ... @@ -112,22 +112,47 @@
</ul>
<dl class="play-bi-pan pan">
<dt>使用有货币支付</dt>
<dt class="{{#unless yohoCoinCompute.yohoCoinClick}}not-btn{{/unless}}">
<span class="not-btn-tip red {{#if yohoCoinCompute.yohoCoinClick}}hide{{/if}}">抱歉,您的订单实付款不满足有货币使用条件</span>使用有货币支付
</dt>
<dd>
<div class="play-pan">
<div class="strong">
使用有货币:
<input type="text" class="textbox" id="biprice" data-bi="{{ownYohoCoin}}" value="0" />
<div class="errbitip red"></div>
<ul class="play-pan" id="biprice" data-yoho-coin-num={{yohoCoinCompute.yohoCoinNum}} data-yoho-coin-click={{yohoCoinCompute.yohoCoinClick}}>
<li>
<div class="float-left num-list-width">
有货币满<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>的整数倍
</div>
<p >
您目前有有货币 <em class="strong">{{ownYohoCoin}}</em>
</p>
<p class="errbitip red"></p>
<div class="btn-group clearfix">
<div class="float-right yoho-coin-help">?
<div class="yoho-coin-help-dialog hide">
<span class="arrow-up"></span>
<div class="yoho-coin-help-dialog-title">有货币使用条件:</div>
<div class="yoho-coin-help-dialog-content">
<ul>
<li>1.订单金额大于20元(含20元)</li>
<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>
<li>3.每笔支付不得超过应付金额{{yohoCoinCompute.yoho_coin_pay_rule.max_pay_rate_desc}}</li>
<li>备注:使用有货币数量为<span class="num-limit-coin">{{yohoCoinCompute.yoho_coin_pay_rule.num_limit}}的整数倍,100有货币抵1元。</li>
</ul>
</div>
</div>
</div>
</li>
<li>
您当前共有有货币<span class="sign-amount totalYohoCoinNum">{{yohoCoinCompute.totalYohoCoinNum}}</span>个,可用<span class="sign-amount yohoCoinNum">{{yohoCoinCompute.yohoCoinNum}}</span>
</li>
<li>
本次使用有货币<span class="sign-amount yohoCoinNum">{{yohoCoinCompute.yohoCoinNum}}</span>个 抵扣<span class="sign-amount yohoCoin"{{yohoCoinCompute.yohoCoin}}</span>
</li>
<li>
<div class="float-left btn-group clearfix">
<input type="button" class="ok" value="确定" id="bisubmit"/>
<input type="button" class="cancel cancel-bi" value="取消"/>
</div>
<div class="float-right">
<a class="yoho-coin-help-link" href="/help/?category_id=87" target="_blank">有货币使用规则?</a>
</div>
</li>
</ul>
</dd>
</dl><!--/play-bi-pan pan-->
</div><!--/play-right-->
... ...
... ... @@ -389,7 +389,7 @@ var Order = {
var $juangroupInput = $('.play-juan.is-select input[name="juangroup"]:checked');
var expressVal = $('.express-list input[name="carriagegroup"]:checked').val();
var biVal = $('#biprice.is-select').data('yoho-coin-num');
var biVal = $('#biprice.is-select').data('yoho-coin-num') * 1;
var codeVal = $juangroupInput.val();
var cartType = $('.address-manage').attr('cart-type');
var redEnvelopes = $('.use-envelopes input:checked').attr('data-use');
... ... @@ -534,7 +534,6 @@ var Order = {
$('.errbitip').html('请输入一个正整数');
$('#biprice').removeClass('is-select');
return false;
}
e.$loading.show();
... ...
... ... @@ -33,6 +33,7 @@ var TicketCat = {
$toPay: $('.ticket-play em'),
$errorTip: $('.errbitip'),
$tbody: $('table tbody', '.pay-wapper'),
$yohoCoinHelp: $('.yoho-coin-help'),
//门票js
$showTicketMobile: $('.show-ticket-mobile'),
... ... @@ -147,6 +148,10 @@ var TicketCat = {
el.$pan.find('dt').click(function() {
var pan = $(this).parent('dl.pan');
if ($(this).hasClass('not-btn')) {
return false;
}
if (pan.find('dd').is(':hidden')) {
c.winShow(pan);
$(this).addClass('active');
... ... @@ -161,16 +166,19 @@ var TicketCat = {
var pan = $(this).parents('dl.pan');
var selectData = {};
if (!$('#biprice').data('yoho-coin-click')) {
$('.errbitip').html('抱歉,您的订单实付款不满足有货币使用条件');
return true;
}
$('#biprice').addClass('is-select');
selectData = _this.getSelectData();
if (!/^\d+$/.test(selectData.yohoCoin + '') || selectData.yohoCoin * 1 === 0) {
if (selectData.yohoCoin * 1 <= 0) {
$('.errbitip').html('请输入一个正整数');
$('#biprice').removeClass('is-select');
} else if (selectData.yohoCoin * 1 > $('.play-pan em').text() * 1) {
$('.errbitip').html('您的有货币不足');
$('#biprice').removeClass('is-select');
} else {
return false;
}
el.$loading.show();
$.ajax({
type: 'POST',
... ... @@ -187,7 +195,6 @@ var TicketCat = {
}
}
});
}
});
// 修改有货币
... ... @@ -280,6 +287,12 @@ var TicketCat = {
});
});
//有货币帮助弹框
el.$yohoCoinHelp.hover(function() {
$(this).find('.yoho-coin-help-dialog').removeClass('hide');
}, function() {
$(this).find('.yoho-coin-help-dialog').addClass('hide');
});
},
//渲染价格明细
... ... @@ -312,17 +325,22 @@ var TicketCat = {
e.$toPay.html((data.shopping_cart_data.last_order_amount).toFixed(2));
//有货币清零状态更新
$('#biprice').val(accMul(100, data.shopping_cart_data.use_yoho_coin));
if (data.use_yoho_coin === 0) {
$('.errbitip').text('');
} else {
$('.errbitip').text('抵扣' + data.shopping_cart_data.use_yoho_coin.toFixed(2) + '元');
$('dl.play-bi-pan').find('dt').removeClass('not-btn');
$('.not-btn-tip').addClass('hide');
if (!data.yohoCoinCompute.yohoCoinClick) {
//不可以使用状态
$('dl.play-bi-pan').find('dt').addClass('not-btn');
$('.not-btn-tip').removeClass('hide');
}
$('#biprice').data('.yoho-coin-click', data.yohoCoinCompute.yohoCoinClick);
$('#biprice').find('.num-limit-coin').html(data.yohoCoinCompute.yoho_coin_pay_rule.num_limit);
$('#biprice').find('.totalYohoCoinNum').html(data.yohoCoinCompute.totalYohoCoinNum);
$('#biprice').find('.yohoCoinNum').html(data.yohoCoinCompute.yohoCoinNum);
$('#biprice').find('.yohoCoin').html(data.yohoCoinCompute.yohoCoin);
},
getSelectData: function() {
var expressVal = $('.express-list input[name="carriagegroup"]:checked').val();
var biVal = $('#biprice.is-select').val();
var biVal = $('#biprice.is-select').data('yoho-coin-num') * 1;
var cartType = $('.address-manage').attr('cart-type');
var resultData;
... ...
... ... @@ -691,9 +691,15 @@ class CartModel
*/
public static function cartPay($uid, $cartType, $isAdvanceCart)
{
$result = [];
/* 调接口订单确认接口 */
$pay = CartData::cartPay($uid, $cartType);
return self::filterCartPay($pay, $cartType, $isAdvanceCart, $uid);
$result = self::filterCartPay($pay, $cartType, $isAdvanceCart, $uid);
//有货币
$result['yohoCoinCompute'] = self::yohoCoinCompute($pay['data']);
return $result;
}
/**
* 处理购物车返回
... ... @@ -880,10 +886,7 @@ class CartModel
}
// 返还的 YOHO 币
$result['totalYoho'] = $pay['data']['shopping_cart_data']['gain_yoho_coin'];
// 拥有的有货币
$result['ownYohoCoin'] = $pay['data']['yoho_coin'] * 100;
// 默认是否使用有货币
$result['useYohoCoin'] = empty($pay['data']['use_yoho_coin']) ? false : true;
// 红包总金额
$result['redEnvelopes'] = empty($pay['data']['red_envelopes']) ? false : Helpers::transPrice($pay['data']['red_envelopes']);
// 使用的红包金额
... ... @@ -906,9 +909,6 @@ class CartModel
$isNewUser = false;
}
$result['isNewUser'] = $isNewUser ? true : false;
//有货币
$result['yohoCoinCompute'] = self::yohoCoinCompute($pay['data']);
//JIT拆单需求 package
$result['packages'] = self::getPackageInfo($pay['data']['shopping_cart_data']);
} while (false);
... ... @@ -1550,7 +1550,13 @@ class CartModel
*/
public function addTicket($uid, $productSku, $buyNumber, $yohoCoin = 0)
{
return CartData::addTicket($uid, $productSku, $buyNumber, $yohoCoin);
$result = [];
$result = CartData::addTicket($uid, $productSku, $buyNumber, $yohoCoin);
//有货币
if (isset($result['data']['shopping_cart_data'])) {
$result['data']['yohoCoinCompute'] = self::yohoCoinCompute($result['data']['shopping_cart_data']);
}
return $result;
}
/**
... ... @@ -1563,10 +1569,17 @@ class CartModel
*/
public function filterTicket($uid, $productSku, $buyNumber, $yohoCoin = 0)
{
$result = [];
$cartType = 'advance';
$data = self::addTicket($uid, $productSku, $buyNumber, $yohoCoin);
return self::filterCartPay($data, $cartType, false);
$result = self::filterCartPay($data, $cartType, false);
//有货币
if (isset($data['data']['shopping_cart_data'])) {
$result['yohoCoinCompute'] = self::yohoCoinCompute($data['data']['shopping_cart_data']);
}
return $result;
}
/**
... ... @@ -1589,7 +1602,7 @@ class CartModel
public static function yohoCoinCompute($orderCompute) {
$yohoCoinData = ['totalYohoCoinNum' => 0, 'yohoCoin' => 0, 'yohoCoinNum' =>0, 'useYohoCoin' => 0, 'yohoCoinClick' => 0, 'yohoCoinMsg' => ''];
if (empty($orderCompute)) {
if (empty($orderCompute) || empty($orderCompute['yoho_coin_pay_rule'])) {
return $yohoCoinData;
}
... ...