Authored by 郝肖肖

Merge branch 'feature/yohoCoin' into release/5.2

... ... @@ -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);
}
/**
... ... @@ -500,7 +500,7 @@ class CartData
}
$param['use_yoho_coin'] = $useYohoCoin;
$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') * 1,//判断有货币是否可以单击
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');
}
... ... @@ -209,12 +215,14 @@ function orderCompute() {
if (typeof res.last_order_amount !== undefined) {
res.last_order_amount = (+res.last_order_amount).toFixed(2);
}
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);
isYohoCoinClick = res.yohoCoinCompute.yohoCoinClick * 1;
total = '';
if (res.promotion_formula_list) {
$.each(res.promotion_formula_list, function(index, value) {
... ... @@ -329,9 +337,29 @@ $('.dispatch-time').on('touchend', 'li', function() {
orderInfo('deliveryTimeId', $(this).data('id'));
});
$('.coin').on('touchend', function() {
$('.yoho-coin-help-dialog-bg, .yoho-coin-footer').on('touchend', function(e) {
e.preventDefault();
$('.yoho-coin-help-dialog-bg').addClass('hide');
$('.yoho-coin-help-dialog').addClass('hide');
});
$('.coin').on('touchend', function(e) {
var $this = $(this);
if ($(e.target).closest('.yoho-coin-help').length) {
$('.yoho-coin-help-dialog-bg').removeClass('hide');
$('.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();
... ...
... ... @@ -294,114 +294,114 @@
}
.order-good {
position: relative;
padding: 20px 0;
margin-left: 34px;
height: 160px;
border-bottom: 1px solid #e0e0e0;
font-size: 26px;
&:last-child {
border-bottom: none;
}
.thumb-wrap {
.order-good {
position: relative;
float: left;
width: 120px;
padding: 20px 0;
margin-left: 34px;
height: 160px;
}
border-bottom: 1px solid #e0e0e0;
font-size: 26px;
.thumb {
width: 100%;
height: 100%;
}
&:last-child {
border-bottom: none;
}
.tag {
position: absolute;
bottom: 0;
left: 0;
right: 0;
color: #fff;
text-align: center;
font-size: 12px;
.thumb-wrap {
position: relative;
float: left;
width: 120px;
height: 160px;
}
&:before {
display: block;
line-height: 1;
transform:scale(0.833);
.thumb {
width: 100%;
height: 100%;
}
}
.gift-tag {
height: 25px;
background: #a1ce4e;
.tag {
position: absolute;
bottom: 0;
left: 0;
right: 0;
color: #fff;
text-align: center;
font-size: 12px;
&:before {
content: '赠品';
&:before {
display: block;
line-height: 1;
transform:scale(0.833);
}
}
}
.advance-buy-tag {
height: 25px;
background: #eb76aa;
.gift-tag {
height: 25px;
background: #a1ce4e;
&:before {
content: '加价购';
&:before {
content: '赠品';
}
}
}
.deps {
margin-left: 135px;
}
.advance-buy-tag {
height: 25px;
background: #eb76aa;
.name {
font-size: 28px;
max-width: 70%;
text-overflow: -o-ellipsis-lastline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
&:before {
content: '加价购';
}
}
.row:nth-child(2) {
height: 45px;
line-height: 45px;
.deps {
margin-left: 135px;
}
> span {
margin-right: 15px;
.name {
font-size: 28px;
max-width: 70%;
text-overflow: -o-ellipsis-lastline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
}
.color, .size {
color: #b6b6b6;
}
.row:nth-child(2) {
height: 45px;
line-height: 45px;
.price-wrap {
position: absolute;
top: 20px;
right: 30px;
text-align: right;
}
> span {
margin-right: 15px;
}
}
.price {
color: #e01;
}
.color, .size {
color: #b6b6b6;
}
.count {
display: block;
color: #999;
text-align: right;
line-height: 45px;
}
.price-wrap {
position: absolute;
top: 20px;
right: 30px;
text-align: right;
}
.price {
color: #e01;
}
.appear-date {
color: #f00;
.count {
display: block;
color: #999;
text-align: right;
line-height: 45px;
}
.appear-date {
color: #f00;
}
}
}
.sale-invoice {
margin-top: -20px;
font-size: 24px;
... ... @@ -488,6 +488,19 @@
.desc {
color: #999;
}
.yoho-coin-help {
display: inline-block;
background-color: #b0b0b0;
border-radius: 28px;
width: 28px;
height: 28px;
line-height: 28px;
text-align: center;
color: #fff;
font-size: 22px;
margin-left: 10px;
}
}
.block {
... ... @@ -569,7 +582,6 @@
input {
margin: 0;
}
}
.total {
... ... @@ -617,6 +629,59 @@
font-size: 32px;
}
}
.yoho-coin-help-dialog-bg {
background-color: #000;
width: 100%;
height: 100%;
position: fixed;
z-index: 1;
left: 0;
top: 0;
opacity: 0.3;
}
.yoho-coin-help-dialog {
position: fixed;
width: 450px;
height: 510px;
background-color: #fff;
z-index: 2;
margin: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
border-radius: 10px;
.yoho-coin-title {
font-size: 34px;
text-align: center;
height: 110px;
line-height: 140px;
color: #000;
}
.yoho-coin-content {
height: 320px;
overflow: auto;
font-size: 28px;
padding: 0 35px;
color: #444;
p {
margin-top: 15px;
}
}
.yoho-coin-footer {
border-top: 1px solid #e0e0e0;
color: #d0021b;
font-size: 34px;
height: 80px;
line-height: 80px;
text-align: center;
}
}
}
.tickets-confirm-page {
... ...
... ... @@ -112,28 +112,18 @@
</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>
{{#if useYohoCoin}}
<span class="coin-check">
<!-- <em>- ¥ {{useYohoCoin}}</em> -->
<i class="iconfont checkbox icon-cb-radio"></i>
</span>
<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">
<!-- <em style="display: none;">- ¥ {{useYohoCoin}}</em> -->
<i class="iconfont checkbox icon-radio"></i>
</span>
{{/if}}
{{^}}
<span class="not-used coin-check">
无有货币可用
</span>
<span class="coin-check">
<i class="iconfont checkbox icon-radio"></i>
</span>
{{/if}}
</li>
... ... @@ -146,17 +136,6 @@
<span class="title">发票信息</span>
<span class="invoice-type"><i class="iconfont">&#xe614;</i></span>
</a>
<!-- <form id="invoice">
<input type="text" name="invoice-title" value="{{invoiceText}}" maxlength="30" placeholder="发票抬头">
<label>
发票类型
<select class="invoice-type" name="invoice-type">
{{# invoice}}
<option value="{{id}}" {{#if isSelected}}selected{{/if}}>{{name}}</option>
{{/ invoice}}
</select>
</label>
</form> -->
</li>
{{/if}}
</ul>
... ... @@ -197,7 +176,17 @@
<a href="javascript:;">提交订单</a>
</div>
<div class="yoho-coin-help-dialog-bg hide"></div>
<div class="yoho-coin-help-dialog hide">
<div class="yoho-coin-title">有货币使用条件:</div>
<div class="yoho-coin-content">
<p>1.订单金额大于20元(含)</p>
<p>2.有货币数量大于{{yohoCoinCompute.yoho_coin_pay_rule.num_limit}}个(含)</p>
<p>3.有货币支付不得超过每笔订单应付金额的{{yohoCoinCompute.yoho_coin_pay_rule.max_pay_rate_desc}}</p>
<p>备注:使用有货币数量为{{yohoCoinCompute.yoho_coin_pay_rule.num_limit}}的整数倍,100有货币抵1元。</p>
</div>
<div class="yoho-coin-footer">知道了</div>
</div>
{{/ orderEnsure}}
</div>
{{> layout/footer}}
... ...
... ... @@ -33,30 +33,20 @@
<section class="block dispatch">
<div class="yoho-coin">
<ul class="sale-invoice">
<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>
{{#if useYohoCoin}}
<span class="coin-check">
<!-- <em>- ¥ {{useYohoCoin}}</em> -->
<i class="iconfont checkbox icon-cb-radio"></i>
</span>
<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">
<!-- <em style="display: none;">- ¥ {{useYohoCoin}}</em> -->
<i class="iconfont checkbox icon-radio"></i>
</span>
{{/if}}
{{^}}
<span class="not-used coin-check">
无有货币可用
</span>
<span class="coin-check">
<i class="iconfont checkbox icon-radio"></i>
</span>
{{/if}}
</li>
</li>
</ul>
</div>
<div class="sub-block delivery-id">
... ... @@ -88,6 +78,19 @@
您需要支付:<span>¥{{price}}</span>
<a href="javascript:;" id="ticketsConfirm">确认</a>
</div>
<!--有货币使用弹框提示-->
<div class="yoho-coin-help-dialog-bg hide"></div>
<div class="yoho-coin-help-dialog hide">
<div class="yoho-coin-title">有货币使用条件:</div>
<div class="yoho-coin-content">
<p>1.订单金额大于20元(含)</p>
<p>2.有货币数量大于{{yohoCoinCompute.yoho_coin_pay_rule.num_limit}}个(含)</p>
<p>3.有货币支付不得超过每笔订单应付金额的{{yohoCoinCompute.yoho_coin_pay_rule.max_pay_rate_desc}}</p>
<p>备注:使用有货币数量为{{yohoCoinCompute.yoho_coin_pay_rule.num_limit}}的整数倍,100有货币抵1元。</p>
</div>
<div class="yoho-coin-footer">知道了</div>
</div>
<input type="hidden" name="ticketsPage" id="ticketsPage" value="1">
<input type="hidden" name="productSku" id="productSku" value="{{productSku}}">
<input type="hidden" name="buyNumber" id="buyNumber" value="{{buyNumber}}">
... ...
... ... @@ -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['data']);
}
// 根据地址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,36 @@ class CartModel
}
/**
*有货币使用前端方案显示及是否可单击判断
*/
public static function yohoCoinCompute($orderCompute) {
$yohoCoinData = ['totalYohoCoinNum' => 0, 'yohoCoin' => 0, 'useYohoCoin' => 0, 'yohoCoinClick' => 0, 'yohoCoinMsg' => '', 'yoho_coin_pay_rule' => []];
if (empty($orderCompute) || empty($orderCompute['yoho_coin_pay_rule'])) {
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,
'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;
} else {
$yohoCoinData['yohoCoinMsg'] = "不满足有货币使用条件";
}
return $yohoCoinData;
}
/**
* 购物车结算--获取可用的优惠券数目
*
* @param int $uid 用户ID
... ... @@ -668,6 +694,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;
... ... @@ -1162,8 +1189,7 @@ class CartModel
$price = $data['data']['shopping_cart_data']['last_order_amount'];
$result['price'] = Helpers::transPrice($price, true);
// 有货币
$result['yohoCoin'] = Helpers::transPrice($data['data']['yoho_coin']);
$result['useYohoCoin'] = isset($data['data']['shopping_cart_data']['use_yoho_coin']) ? $data['data']['shopping_cart_data']['use_yoho_coin'] : false;
$result['yohoCoinCompute'] = self::yohoCoinCompute($data['data']['shopping_cart_data']);
return $result;
}
... ... @@ -1176,6 +1202,7 @@ class CartModel
// 有货币添加.00后缀
$compute['data']['shopping_cart_data']['use_yoho_coin'] = Helpers::transPrice($compute['data']['shopping_cart_data']['use_yoho_coin']);
$result = $compute['data']['shopping_cart_data'];
$result['yohoCoinCompute'] = self::yohoCoinCompute($compute['data']['shopping_cart_data']);
}
return $result;
}
... ...
... ... @@ -20,7 +20,7 @@ define('USE_INTER_FACE_SHUNT', false);//分流开关
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();
... ...