Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Rock Zhang
9 years ago
Commit
dfc2f12777483ba1cb1561a7a6dadda9323506ba
1 parent
7ecd8ff7
去除结算页面请求的单地址查询,优惠券可用性验证等接口,从而优化性能
Code Review By Rock Zhang
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
21 deletions
static/js/cart/select-address.js
template/m.yohobuy.com/actions/cart/index/order-ensure.phtml
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
static/js/cart/select-address.js
View file @
dfc2f12
...
...
@@ -11,7 +11,16 @@ var $confim = $('.confim-mask'),
deleteId
;
$
(
'.address-item'
).
on
(
'touchend'
,
function
()
{
orderInfo
(
'addressId'
,
$
(
this
).
data
(
'address-id'
));
var
$this
=
$
(
this
);
var
addressId
=
$this
.
data
(
'address-id'
);
var
address
=
{
address_id
:
$this
.
data
(
'address-id'
),
consignee
:
$this
.
find
(
'.name'
).
text
(),
mobile
:
$this
.
find
(
'.tel'
).
text
(),
address_info
:
$this
.
find
(
'.address-info'
).
text
()
};
orderInfo
(
'addressId'
,
addressId
);
orderInfo
(
'address'
,
address
);
}).
on
(
'touchend'
,
'.edit'
,
function
()
{
window
.
location
.
href
=
$
(
this
).
data
(
'href'
);
return
false
;
...
...
@@ -22,5 +31,6 @@ $('.address-item').on('touchend', function() {
$confim
.
on
(
'touchend'
,
'.confim'
,
function
()
{
if
(
orderInfo
(
'addressId'
)
===
deleteId
)
{
orderInfo
(
'addressId'
,
null
);
orderInfo
(
'address'
,
null
);
}
});
...
...
template/m.yohobuy.com/actions/cart/index/order-ensure.phtml
View file @
dfc2f12
...
...
@@ -5,7 +5,7 @@
<p
class=
"infos"
>
收货地址
<span
class=
"per-info"
>
{
{name
}
}
{
{phoneNum
}
}</span>
<span
class=
"address"
>
{
{a
rea
}
}
{
{address
}
}</span>
<span
class=
"address"
>
{
{a
ddressInfo
}
}</span>
</p>
<span
class=
"iconfont"
>
614
;</span>
</a>
...
...
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
View file @
dfc2f12
...
...
@@ -324,6 +324,12 @@ class CartModel
$pay
=
CartData
::
cartPay
(
$uid
,
$cartType
);
// 商品为空返回
if
(
!
$pay
||
(
isset
(
$pay
[
'data'
][
'goods_list'
])
&&
empty
(
$pay
[
'data'
][
'goods_list'
])))
{
$result
[
'cartUrl'
]
=
Helpers
::
url
(
'/cart/index/index'
);
return
$result
;
}
if
(
$pay
&&
isset
(
$pay
[
'code'
])
&&
$pay
[
'code'
]
===
200
)
{
$payReturn
=
$pay
[
'data'
];
$address
=
array
();
...
...
@@ -335,8 +341,8 @@ class CartModel
}
// 根据地址id查询地址信息
if
(
isset
(
$orderInfo
[
'addressId'
]))
{
$address
=
UserModel
::
getAddressDataById
(
$uid
,
$orderInfo
[
'addressId'
]);
if
(
isset
(
$orderInfo
[
'address'
]))
{
$address
=
$orderInfo
[
'address'
];
}
// 收货人有关信息
...
...
@@ -344,8 +350,8 @@ class CartModel
$result
[
'addressId'
]
=
isset
(
$address
[
'address_id'
])
?
$address
[
'address_id'
]
:
$payReturn
[
'delivery_address'
][
'address_id'
];
$result
[
'name'
]
=
isset
(
$address
[
'consignee'
])
?
$address
[
'consignee'
]
:
$payReturn
[
'delivery_address'
][
'consignee'
];
$result
[
'phoneNum'
]
=
isset
(
$address
[
'mobile'
])
?
$address
[
'mobile'
]
:
$payReturn
[
'delivery_address'
][
'mobile'
];
$result
[
'area'
]
=
isset
(
$address
[
'area'
])
?
$address
[
'area'
]
:
$payReturn
[
'delivery_address'
][
'area'
];
$result
[
'address'
]
=
isset
(
$address
[
'address'
])
?
$address
[
'address'
]
:
$payReturn
[
'delivery_address'
][
'address'
];
// $result['area'] = isset($address['area']) ? $address['area'] : $payReturn['delivery_address']['area'];
$result
[
'addressInfo'
]
=
isset
(
$address
[
'address_info'
])
?
$address
[
'address_info'
]
:
$payReturn
[
'delivery_address'
][
'area'
]
.
' '
.
$payReturn
[
'delivery_address'
][
'address'
];
$isSupport
=
isset
(
$address
[
'is_support'
])
?
$address
[
'is_support'
]
:
$payReturn
[
'delivery_address'
][
'is_support'
];
$result
[
'isSupport'
]
=
$isSupport
===
'Y'
;
}
...
...
@@ -477,9 +483,10 @@ class CartModel
isset
(
$orderInfo
[
'msg'
])
&&
$result
[
'msg'
]
=
$orderInfo
[
'msg'
];
// 优惠券数据
$coupons
=
array
();
!
empty
(
$orderCompute
[
'coupon_amount'
])
&&
$coupons
[
'couponName'
]
=
$orderInfo
[
'couponName'
];
$coupons
+=
self
::
getCouponList
(
$uid
,
true
);
$coupons
=
array
(
'couponName'
=>
''
);
if
(
!
empty
(
$orderCompute
[
'coupon_amount'
]))
{
$coupons
[
'couponName'
]
=
$orderCompute
[
'coupon_amount'
];
}
$result
[
'coupon'
]
=
$coupons
;
}
...
...
@@ -553,11 +560,10 @@ class CartModel
do
{
if
(
isset
(
$coupons
[
'data'
][
'couponList'
]))
{
foreach
(
$coupons
[
'data'
][
'couponList'
]
as
$val
)
{
$notAvailableRes
=
self
::
searchCoupon
(
$uid
,
$val
[
'couponCode'
]);
//
$notAvailableRes = self::searchCoupon($uid, $val['couponCode']);
// 处理可用的优惠券
if
(
$val
[
'isValidity'
]
===
'N'
||
(
isset
(
$notAvailableRes
[
'code'
])
&&
$notAvailableRes
[
'code'
]
!==
200
)
)
{
if
(
$val
[
'isValidity'
]
===
'N'
)
{
$val
[
'notAvailable'
]
=
true
;
// continue;
}
$result
[]
=
$val
;
}
...
...
yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
View file @
dfc2f12
...
...
@@ -283,22 +283,17 @@ class IndexController extends AbstractAction
$orderInfo
=
json_decode
(
$cookieData
,
true
);
$cartType
=
$orderInfo
[
'cartType'
];
}
$cartKey
=
'commonCart'
;
if
(
$cartType
===
'advance'
)
{
$cartKey
=
'preSellCart'
;
}
$shoppingKey
=
Helpers
::
getShoppingKeyByCookie
();
$uid
=
$this
->
getUid
(
true
);
$cartGoods
=
CartModel
::
getCartData
(
$uid
,
$shoppingKey
);
if
(
isset
(
$cartGoods
[
'isEmptyCart'
])
||
empty
(
$cartGoods
[
$cartKey
]))
{
$this
->
go
(
Helpers
::
url
(
'/cart/index/index'
));
$order
=
CartModel
::
cartPay
(
$uid
,
$cartType
,
$orderInfo
);
if
(
isset
(
$order
[
'cartUrl'
]))
{
$this
->
go
(
$order
[
'cartUrl'
]);
}
$data
=
array
(
'orderEnsurePage'
=>
true
,
'isOrdinaryCart'
=>
(
$cartType
!==
'advance'
),
'orderEnsure'
=>
CartModel
::
cartPay
(
$uid
,
$cartType
,
$orderInfo
)
'orderEnsure'
=>
$order
);
$this
->
_view
->
display
(
'order-ensure'
,
$data
);
...
...
Please
register
or
login
to post a comment