Authored by 郝肖肖

有货币使用规则改造

... ... @@ -269,12 +269,12 @@ class CartData
$param['client_secret'] = Sign::getSign($param);
// print_r(Yohobuy::get(API_URL, $param));
return Yohobuy::get(API_URL, $param);
return Yohobuy::get('http://192.168.102.205:8080/gateway/', $param);
}
/**
* 购物车结算--支付方式和配送方式选择
*
*http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E8%AE%A2%E5%8D%95/shopping.md
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
... ... @@ -306,7 +306,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);
}
/**
... ...
... ... @@ -14,7 +14,7 @@ var $invoice = $('.invoice'),
$couponUse = $('.coupon-use.used'),
$addressWrap = $('.address-wrap'),
$coinCheck = $('.coin-check'),
$coinUsed = $('.coin .used'),
$coinLi = $('li.coin'),
$subBlock = $('.sub-block'),
$ticketsMobile = $('#mobile'),
payType,
... ... @@ -27,6 +27,7 @@ var $invoice = $('.invoice'),
productSku = $('#productSku').val(),
buyNumber = $('#buyNumber').val(),
headerTop = $("#yoho-header").outerHeight(),
isYohoCoinClick = $coinLi.data('yoho-coin-click'),//判断有币是否可以单击
addressTop = $(".address-wrap").outerHeight();
var orderCont = window.cookie('order-info') && JSON.parse(window.cookie('order-info'));
... ... @@ -121,13 +122,18 @@ if (queryString.cartType || queryString.carttype || !orderInfo('cartType')) {
// $cur.addClass('chosed');
// }
$('.checkbox').on('touchstart', function() {
$('.checkbox').on('touchstart', function(e) {
var $this = $(this);
if ($(e.target).closest('.coin-check').length && !isYohoCoinClick) {
return true;
}
if ($this.hasClass('icon-cb-radio')) {
$this.removeClass('icon-cb-radio').addClass('icon-radio');
return;
}
if ($this.hasClass('icon-radio')) {
$this.removeClass('icon-radio').addClass('icon-cb-radio');
}
... ... @@ -211,9 +217,8 @@ function orderCompute() {
}
if (res.use_yoho_coin) {
$coinCheck.find('em').html('- ¥ ' + res.use_yoho_coin);
$coinUsed.html('已抵¥' + res.use_yoho_coin);
$coinCheck.find('em').show();
$coinUsed.show();
$coinLi.find('.msg').html(res.yohoCoinCompute.yohoCoinMsg);
}
total = '';
if (res.promotion_formula_list) {
... ... @@ -343,9 +348,15 @@ $('.coin').on('touchend', function(e) {
$('.yoho-coin-help-dialog').removeClass('hide');
return true;
}
if ($(e.target).closest('.coin-check').length <= 0) {
return false;
}
if (!isYohoCoinClick) {
return true;
}
if ($this.find('.checkbox').hasClass('icon-cb-radio')) {
orderInfo('yohoCoin', $this.data('yoho-coin'));
$this.find('.can-use').hide();
... ...
... ... @@ -492,6 +492,7 @@
text-align: center;
color: #fff;
font-size: 22px;
margin-left: 10px;
}
}
... ...
... ... @@ -111,25 +111,17 @@
</a>
</li>
{{/if}}
<li class="coin" data-yoho-coin="{{yohoCoin}}">
<li class="coin" data-yoho-coin="{{yohoCoinCompute.yohoCoin}}" data-yoho-coin-click={{yohoCoinCompute.yohoCoinClick}}>
<span class="title">有货币</span>
{{#if yohoCoin}}
<span class="desc used {{#unless useYohoCoin}}hide{{/unless}}">已抵¥{{useYohoCoin}}</span>
<span class="desc can-use {{#if useYohoCoin}}hide{{/if}}">可抵¥{{yohoCoin}}</span>
<span class="yoho-coin-help">?</span>
{{#if useYohoCoin}}
<span class="coin-check">
<i class="iconfont checkbox icon-cb-radio"></i>
</span>
{{else}}
<span class="coin-check">
<i class="iconfont checkbox icon-radio"></i>
</span>
{{/if}}
{{^}}
<span class="not-used coin-check">
无有货币可用
<span class="desc msg">{{yohoCoinCompute.yohoCoinMsg}}</span>
<span class="yoho-coin-help">?</span>
{{#if yohoCoinCompute.useYohoCoin}}
<span class="coin-check">
<i class="iconfont checkbox icon-cb-radio"></i>
</span>
{{else}}
<span class="coin-check">
<i class="iconfont checkbox icon-radio"></i>
</span>
{{/if}}
</li>
... ...
... ... @@ -398,7 +398,13 @@ class CartModel
if (!empty($orderInfo)) {
$orderInfo['paymentType'] = isset($orderInfo['paymentType']) ? $orderInfo['paymentType'] : '';
$orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentType'], $orderInfo['couponCode'], $orderInfo['yohoCoin'], $skuList);
// 有货币
$result['yohoCoinCompute'] = $orderCompute['yohoCoinCompute'];
} else {
// 有货币
$result['yohoCoinCompute'] = self::yohoCoinCompute($pay);
}
// 根据地址id查询地址信息
if (isset($orderInfo['address'])) {
$address = $orderInfo['address'];
... ... @@ -525,17 +531,17 @@ class CartModel
if (isset($payReturn['payment_way'])) {
$onePay = array();
$isPaymentType = true;
foreach ($payReturn['payment_way'] as $pay) {
if ($pay['is_support'] !== 'Y') {
foreach ($payReturn['payment_way'] as $val) {
if ($val['is_support'] !== 'Y') {
continue;
}
$onePay = array();
$onePay['id'] = $pay['payment_id'];
$onePay['paymentType'] = $pay['payment_type'];
$onePay['name'] = $pay['payment_type_name'];
$onePay['isSupport'] = $pay['is_support'] === 'Y';
// $onePay['default'] = ($pay['default'] === 'Y');
$onePay['id'] = $val['payment_id'];
$onePay['paymentType'] = $val['payment_type'];
$onePay['name'] = $val['payment_type_name'];
$onePay['isSupport'] = $val['is_support'] === 'Y';
// $onePay['default'] = ($val['default'] === 'Y');
if (isset($orderInfo['paymentType']) && $onePay['paymentType'] === $orderInfo['paymentType']) {
$onePay['recommend'] = true;
$isPaymentType = false;
... ... @@ -550,14 +556,6 @@ class CartModel
}
}
// 有货币
$result['yohoCoin'] = Helpers::transPrice($payReturn['yoho_coin']);
/*
* 默认使用有货币
* $result['useYohoCoin'] = isset($orderCompute['use_yoho_coin']) ? $orderCompute['use_yoho_coin'] : $payReturn['use_yoho_coin'];
*/
$result['useYohoCoin'] = isset($orderCompute['use_yoho_coin']) ? $orderCompute['use_yoho_coin'] : false;
// 订单数据
if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) {
//判断是否为JIT商品
... ... @@ -579,8 +577,6 @@ class CartModel
// 商品金额
$result['goodsPrice'] = $payReturn['shopping_cart_data']['str_order_amount'];
//print_r($payReturn['shopping_cart_data']['gain_yoho_coin']);
//有货币
if((int)$payReturn['shopping_cart_data']['gain_yoho_coin'] > 0) {
... ... @@ -630,6 +626,35 @@ class CartModel
}
/**
*有货币使用前端方案显示及是否可单击判断
*/
public static function yohoCoinCompute($orderCompute) {
$yohoCoinData = ['totalYohoCoinNum' => 0, 'yohoCoin' => 0, 'useYohoCoin' => 0, 'yohoCoinClick' => 0, 'yohoCoinMsg' => ''];
if (empty($orderCompute)) {
return $yohoCoinData;
}
$yohoCoinData = [
'totalYohoCoinNum' => intval($orderCompute['total_yoho_coin_num']),
'yohoCoin' => Helpers::transPrice($orderCompute['yoho_coin']),
'useYohoCoin' => Helpers::transPrice($orderCompute['use_yoho_coin']),
'yohoCoinClick' => 0,
'yohoCoinMsg' => ''
];
if ($yohoCoinData['totalYohoCoinNum'] < 100) {
$yohoCoinData['yohoCoinMsg'] = "共{$yohoCoinCompute['totalYohoCoinNum']}有币币,满100可用";
} else if ($yohoCoinData['useYohoCoin'] > 0 || $yohoCoinData['yohoCoin'] > 0) {
$yohoCoinData['yohoCoinMsg'] = '可抵¥' . ($yohoCoinData['useYohoCoin'] > 0 ? $yohoCoinData['useYohoCoin'] : $yohoCoinData['yohoCoin']);
$yohoCoinData['yohoCoinClick'] = 1;
} else {
$yohoCoinData['yohoCoinMsg'] = "不满足有货币使用条件";
}
return $yohoCoinData;
}
/**
* 购物车结算--获取可用的优惠券数目
*
* @param int $uid 用户ID
... ... @@ -668,6 +693,7 @@ class CartModel
// 有货币添加.00后缀
$compute['data']['use_yoho_coin'] = Helpers::transPrice($compute['data']['use_yoho_coin']);
$result = $compute['data'];
$result['yohoCoinCompute'] = self::yohoCoinCompute($compute['data']);
}
return $result;
... ...
... ... @@ -17,10 +17,10 @@ define('USE_INTER_FACE_SHUNT', false);//分流开关
#dev环境
define('API_URL', 'http://api-test1.yohops.com:9999/');
define('SERVICE_URL', 'http://service-test1.yohops.com:9999/');
define('API_URL', 'http://api-test3.yohops.com:9999/');
define('SERVICE_URL', 'http://service-test3.yohops.com:9999/');
define('YOHOBUY_URL', 'http://www.yohobuy.com/');
define('SERVICE_NOTIFY', 'http://service-test1.yohops.com:9999/');
define('SERVICE_NOTIFY', 'http://service-test3.yohops.com:9999/');
$application = new Application(APPLICATION_PATH . '/configs/application.developer.ini');
$application->bootstrap()->run();
... ...