Authored by 郝肖肖

正常购物 有货币使用改造

... ... @@ -259,7 +259,7 @@ class CartData
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param);
return Yohobuy::get('http://192.168.102.205:8080/gateway/', $param);
}
/**
... ... @@ -303,7 +303,7 @@ class CartData
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param);
return Yohobuy::get('http://192.168.102.205:8080/gateway/', $param);
}
/**
... ...
... ... @@ -368,31 +368,32 @@
<dl class="play-bi-pan pan">
<dt>使用有货币支付</dt>
<dd>
<ul class="play-pan">
<ul class="play-pan" id="biprice" data-yoho-coin-num={{yohoCoinCompute.yohoCoinNum}} data-yoho-coin-click={{yohoCoinCompute.yohoCoinClick}}>
<li>
<div class="float-left">
有货币满<span class="sign-amount">100</span>个即可使用,每次使用有货币为<span class="sign-amount">10</span>个
有货币满<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>
<div class="float-right yoho-coin-help">?
<div class="yoho-coin-help-dialog">
<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元(含)</li>
<li>(2)有货币数量大于100个含)</li>
<li>(3)有货币支付不得超过每笔订单应付金额50%</li>
<li>备注:使用有货币数量为100的整数倍,100有货币抵1元。</li>
<li>(2)有货币数量大于<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}}</span>的整数倍,100有货币抵1元。</li>
</ul>
</div>
</div>
</div>
</li>
<li>
您当前共有有货币<span class="sign-amount">450</span>个,可用<span class="sign-amount">300</span> 个
您当前共有有货币<span class="sign-amount totalYohoCoinNum">{{yohoCoinCompute.totalYohoCoinNum}}</span>个,
可用<span class="sign-amount yohoCoinNum">{{yohoCoinCompute.yohoCoinNum}}</span> 个
</li>
<li>
本次使用有货币 <span class="sign-amount">450</span>个 抵扣<span class="sign-amount">¥3.00</span>
本次使用有货币<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">
... ...
... ... @@ -9,7 +9,8 @@ var $ = require('yoho.jquery'),
$receiptInfoSaveBtn = $('.receipt-info .save-receipt'),
$receiptInfoCancelBtn = $('.receipt-info .cancel-receipt'),
$eReceiptBtn = $('.receipt-type .e-receipt'),
$paperReceiptBtn = $('.receipt-type .paper-receipt');
$paperReceiptBtn = $('.receipt-type .paper-receipt'),
$yohoCoinHelp = $('.yoho-coin-help');
var address = require('./address'),
... ... @@ -272,13 +273,14 @@ var Order = {
e.$toPay.html((data.last_order_amount).toFixed(2));
//有货币清零状态更新
$('#biprice').val(accMul(100, data.use_yoho_coin));
if (~~data.use_yoho_coin === 0) {
$('#biprice').val(accMul(100, data.yohoCoinCompute.useYohoCoin));
if (~~data.yohoCoinCompute.useYohoCoin === 0) {
$('.errbitip').text('');
} else {
$('.errbitip').text('抵扣' + data.use_yoho_coin.toFixed(2) + '元');
$('.errbitip').text('抵扣' + data.yohoCoinCompute.useYohoCoin.toFixed(2) + '元');
}
//使用的红包
envelopesVal = e.$useEnvelopesInput.data('all') - data.use_red_envelopes;
if (~~data.use_red_envelopes > 0) {
... ... @@ -462,9 +464,11 @@ var Order = {
e.$loading.show();
options = {
type: 'POST',
url: '/cart/index/orderCompute',
data: d,
success: function(data) {
... ... @@ -566,20 +570,21 @@ var Order = {
c.winShow($pan);
});
//不须要手动输入有货币了。
// e.$bp.keyup(function() {
e.$bp.keyup(function() {
var val = $(this).val();
// var val = $(this).val();
//if (val * 1 < 0 || val.indexOf('.') > 0) {
if (!/^\d+$/.test(val + '')) {
e.$errorTip.html('请输入一个正整数');
} else if (val * 1 > $(this).data('bi') * 1) {
e.$errorTip.html('您的有货币不足');
} else {
e.$errorTip.html('抵扣' + (val / 100).toFixed(2) + '元');
}
});
// //if (val * 1 < 0 || val.indexOf('.') > 0) {
// if (!/^\d+$/.test(val + '')) {
// e.$errorTip.html('请输入一个正整数');
// } else if (val * 1 > $(this).data('bi') * 1) {
// e.$errorTip.html('您的有货币不足');
// } else {
// e.$errorTip.html('抵扣' + (val / 100).toFixed(2) + '元');
// }
// });
// 取消yoho 币
$('.cancel-bi').click(function() {
... ... @@ -788,6 +793,7 @@ $('.why').click(function() {
$('#differentBag').click(function() {
return false;
});
$(document).click(function() {
$('#differentBag').hide();
});
... ... @@ -1049,3 +1055,10 @@ $('#input-mobile').bind('input propertychange', function() {
$('.invoice-phone .enpty-input').addClass('hide');
}
});
//有货币帮助弹框
$yohoCoinHelp.hover(function() {
$(this).find('.yoho-coin-help-dialog').removeClass('hide');
}, function() {
$(this).find('.yoho-coin-help-dialog').addClass('hide');
});
\ No newline at end of file
... ...
... ... @@ -354,8 +354,12 @@
}
li {
margin-bottom: 10px;
margin-top: 18px;
overflow: hidden;
&:last-child {
margin-top: 28px;
}
}
.yoho-coin-help {
... ... @@ -368,6 +372,7 @@
text-align: center;
color: #fff;
font-size: 14px;
cursor: pointer;
}
.yoho-coin-help-dialog {
... ... @@ -381,6 +386,11 @@
height: 140px;
padding: 15px;
text-align: left;
cursor: auto;
li {
margin-top: 10px;
}
}
.yoho-coin-help-dialog-title {
... ...
... ... @@ -55,7 +55,6 @@ class CartModel
// 调用接口,获取购物车数据
$cartData = CartData::cartData($uid, $shoppingKey);
// print_r($cartData); exit;
// 接口异常时,购物车置为空
if (empty($cartData['data'])) {
$result['isEmpty'] = true;
... ... @@ -694,7 +693,6 @@ class CartModel
{
/* 调接口订单确认接口 */
$pay = CartData::cartPay($uid, $cartType);
return self::filterCartPay($pay, $cartType, $isAdvanceCart, $uid);
}
/**
... ... @@ -909,6 +907,8 @@ class CartModel
}
$result['isNewUser'] = $isNewUser ? true : false;
//有货币
$result['yohoCoinCompute'] = self::yohoCoinCompute($pay['data']);
//JIT拆单需求 package
$result['packages'] = self::getPackageInfo($pay['data']['shopping_cart_data']);
} while (false);
... ... @@ -1002,6 +1002,8 @@ class CartModel
$compute['data']['promotion_formula_list'] = $promotionFormulaList;
//JIT拆单
$compute['packages'] = self::getPackageInfo($compute['data']);
//有货币
$compute['data']['yohoCoinCompute'] = self::yohoCoinCompute($compute['data']);
}
$result = $compute;
}
... ... @@ -1580,4 +1582,36 @@ class CartModel
{
return CartData::submitTicket($uid, $productSku, $buyNumber, $mobile, $yohoCoin);
}
/**
*有货币使用前端方案显示及是否可单击判断
*/
public static function yohoCoinCompute($orderCompute) {
$yohoCoinData = ['totalYohoCoinNum' => 0, 'yohoCoin' => 0, 'yohoCoinNum' =>0, 'useYohoCoin' => 0, 'yohoCoinClick' => 0, 'yohoCoinMsg' => ''];
if (empty($orderCompute)) {
return $yohoCoinData;
}
$yohoCoinData = [
'totalYohoCoinNum' => isset($orderCompute['total_yoho_coin_num']) ? intval($orderCompute['total_yoho_coin_num']) : 0,
'yohoCoin' => isset($orderCompute['yoho_coin']) ? Helpers::transPrice($orderCompute['yoho_coin']) : 0,
'yohoCoinNum' => isset($orderCompute['yoho_coin']) ? $orderCompute['yoho_coin'] * 100 : 0,
'useYohoCoin' => isset($orderCompute['use_yoho_coin']) ? Helpers::transPrice($orderCompute['use_yoho_coin']) : 0,
'yohoCoinClick' => 0,
'yohoCoinMsg' => '',
'yoho_coin_pay_rule' => $orderCompute['yoho_coin_pay_rule']
];
if ($yohoCoinData['totalYohoCoinNum'] < 100) {
$yohoCoinData['yohoCoinMsg'] = "共{$yohoCoinData['totalYohoCoinNum']}有货币,满{$orderCompute['yoho_coin_pay_rule']['num_limit']}可用";
} else if ($yohoCoinData['useYohoCoin'] > 0 || $yohoCoinData['yohoCoin'] > 0) {
$yohoCoinData['yohoCoinMsg'] = '可抵¥' . ($yohoCoinData['useYohoCoin'] > 0 ? $yohoCoinData['useYohoCoin'] : $yohoCoinData['yohoCoin']);
$yohoCoinData['yohoCoinClick'] = 1;
$yohoCoinData['yohoCoinNum'] = ($yohoCoinData['useYohoCoin'] > 0 ? $yohoCoinData['useYohoCoin'] : $yohoCoinData['yohoCoin']) * 100;
} else {
$yohoCoinData['yohoCoinMsg'] = "不满足有货币使用条件";
}
return $yohoCoinData;
}
}
... ...