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
hf
9 years ago
Commit
db9c8ca830dfbba74ef5296038d77c30e8123124
1 parent
13f4b637
code review by hf: do modify shopping cart name
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
899 additions
and
918 deletions
docs/data-structure.md
library/Api/Yohobuy.php
static/js/shopping-cart/cart.js
static/js/shopping-cart/chose-panel.js
static/js/shopping-cart/good.js
static/sass/shopping-cart/_chose-panel.scss
static/sass/shopping-cart/_good.scss
static/sass/shopping-cart/_index.scss
template/m.yohobuy.com/actions/index/shoppingcart/gift-advance.phtml
template/m.yohobuy.com/actions/index/shoppingCart/index.phtml → template/m.yohobuy.com/actions/index/shoppingcart/index.phtml
template/m.yohobuy.com/actions/index/shoppingcart/order-ensure.phtml
template/m.yohobuy.com/actions/index/shoppingcart/select-address.phtml
template/m.yohobuy.com/actions/index/shoppingcart/select-coupon.phtml
template/m.yohobuy.com/partials/shopping-cart/cart-content.phtml
template/m.yohobuy.com/partials/shopping-cart/chose-panel.phtml
template/m.yohobuy.com/partials/shopping-cart/good.phtml
yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
docs/data-structure.md
View file @
db9c8ca
...
...
@@ -1266,16 +1266,9 @@
'notForSale':'非卖品',
<<<<<<< HEAD
thumb:
[
{
id:1,
url : ''
=======
thumbs: [
{
img : ''
>>>>>>> develop
},
...
],
...
...
@@ -1283,21 +1276,6 @@
price: '',
salePrice: '',
colors: [
<<<<<<< HEAD
{
id: 1,
chosed: true,
name: '黄色',
colorNum:10,
sizeNumStr:'10/20/30' //对应的商品尺码数目,用斜杠分割
},
...
],
sizes: [
{
id: 2,
=======
{
id: 1,
skcId:,
...
...
@@ -1315,20 +1293,13 @@
id: 2,
skuId:,
goodId:,
>>>>>>> develop
chosed: true,
name: 'X',
sizeNum: 2,
colorNumStr:'10/20/30' //对应的商品颜色数目用斜杠分割
},
...
<<<<<<< HEAD
],
totalNum: 20
=======
]
>>>>>>> develop
},
'introUrl' : '',
'id' : '',
...
...
library/Api/Yohobuy.php
View file @
db9c8ca
...
...
@@ -23,16 +23,16 @@ class Yohobuy
// const SERVICE_URL = 'http://service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
const
API_URL
=
'http://apih5.yoho.cn/'
;
const
API_URL2
=
'http://apih5.yoho.cn/'
;
const
SERVICE_URL
=
'http://serviceh5.yoho.cn/'
;
const
YOHOBUY_URL
=
'http://www.yohobuy.com/'
;
// /* 测试环境 */
// const API_URL = 'http://testapi.yoho.cn:28078/';
// const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
// const API_URL = 'http://apih5.yoho.cn/';
// const API_URL2 = 'http://apih5.yoho.cn/';
// const SERVICE_URL = 'http://serviceh5.yoho.cn/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
/* 测试环境 */
const
API_URL
=
'http://testapi.yoho.cn:28078/'
;
const
SERVICE_URL
=
'http://testservice.yoho.cn:28077/'
;
const
YOHOBUY_URL
=
'http://www.yohobuy.com/'
;
/**
* 私钥列表
*
...
...
static/js/shopping-cart/cart.js
View file @
db9c8ca
...
...
@@ -66,4 +66,4 @@ $('.chose').on('touchend', function() {
cartInfo
=
0
;
cartInfo
=
0
;
\ No newline at end of file
...
...
static/js/shopping-cart/chose-panel.js
View file @
db9c8ca
...
...
@@ -78,11 +78,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
//根据颜色切换图片
if
(
$this
.
closest
(
'.block-list'
).
hasClass
(
'color-list'
))
{
<<<<<<<
HEAD
$
(
'.chose-panel .basic-info'
).
find
(
'.thumb'
).
addClass
(
'hide'
).
eq
(
index
).
removeClass
(
'hide'
);
=======
$
(
'.chose-panel'
).
find
(
'.thumb'
).
addClass
(
'hide'
).
eq
(
index
).
removeClass
(
'hide'
);
>>>>>>>
develop
}
if
(
$chosed
.
length
===
0
)
{
...
...
@@ -124,13 +120,10 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
}
numArray
=
$siblingBlock
.
find
(
'.chosed'
).
data
(
'numstr'
).
split
(
'/'
);
$that
.
find
(
'.num .left-num'
).
html
(
'剩余'
+
numArray
[
index
]
+
'件'
);
<<<<<<<
HEAD
=======
if
(
2
===
$chosed
.
closest
(
'.zero-stock'
).
length
)
{
$
(
'#chose-btn-sure'
).
css
(
'background-color'
,
'#c0c0c0'
);
$
(
'#chose-btn-sure'
).
html
(
'已售罄'
);
}
>>>>>>>
develop
}
}).
on
(
'touchstart'
,
'.btn-minus'
,
function
()
{
...
...
static/js/shopping-cart/good.js
View file @
db9c8ca
...
...
@@ -10,23 +10,11 @@ var $ = require('jquery'),
lazyLoad
=
require
(
'yoho.lazyload'
);
var
dialog
=
require
(
'../me/dialog'
),
<<<<<<<
HEAD
tip
=
require
(
'../plugin/tip'
),
chosePanel
=
require
(
'./chose-panel'
);
var
$names
;
//chosePanel = require('./chose-panel');
var
cartType
=
'ordinary'
;
=======
tip
=
require
(
'../plugin/tip'
);
var
$names
;
>>>>>>>
develop
//var $curDelPanel;
////删除面板显示后任何点击行为都将触发隐藏面板
...
...
@@ -42,13 +30,8 @@ ellipsis.init();
lazyLoad
({
try_again_css
:
'order-failure'
});
<<<<<<<
HEAD
=======
>>>>>>>
develop
$names
=
$
(
'.name'
);
if
(
$names
.
length
>
0
)
{
$names
[
0
].
mlellipsis
(
2
);
...
...
@@ -96,8 +79,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
});
}).
on
(
'touchstart'
,
'.icon-edit'
,
function
()
{
<<<<<<<
HEAD
=======
//var $this = $(this);
//
//var $cartgood = $this.closest('.shopping-cart-good');
...
...
@@ -116,7 +97,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
//}
>>>>>>>
develop
}).
on
(
'touchstart'
,
'.icon-del'
,
function
(
e
)
{
var
$this
=
$
(
this
);
...
...
@@ -128,90 +108,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
//$curDelPanel = $(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide');
//
//$(document).on('touchstart', docTouchEvt);
<<<<<<<
HEAD
dialog
.
showDialog
({
dialogText
:
'您确定要从购物车中删除吗?'
,
hasFooter
:
{
leftBtnText
:
'取消'
,
rightBtnText
:
'确定'
}
},
function
()
{
var
id
=
$this
.
closest
(
'.shopping-cart-good'
).
data
(
'id'
);
$
.
ajax
({
method
:
'post'
,
url
:
'/shoppingCart/del'
,
data
:
{
id
:
id
}
}).
then
(
function
(
data
)
{
if
(
data
.
code
===
200
)
{
dialog
.
showDialog
({
dialogText
:
'删除成功'
,
autoHide
:
true
,
fast
:
true
});
history
.
go
(
0
);
}
}).
fail
(
function
()
{
dialog
.
showDialog
({
autoHide
:
true
,
dialogText
:
'网络错误~'
});
});
});
});
// .on('touchstart', '.opt-panel', function() {
// var $this = $(this),
// id = $this.closest('.shopping-cart-good').data('id'),
// url;
//
// if ($this.closest('.put-in-favorite').length > 0) {
//
// //移入收藏夹
// url = '/shoppingCart/col';
// } else {
//
// //删除
// url = '/shoppingCart/del';
// }
//
// $.ajax({
// type: 'POST',
// url: url,
// data: {
// id: id
// }
// });
//})
$
(
'.btn-balance'
).
on
(
'touchend'
,
function
()
{
window
.
location
.
href
=
'/shoppingCart/orderEnsure?cartType='
+
cartType
;
});
$
(
'.advance-buy'
).
on
(
'touchend'
,
function
()
{
var
$advanceBuy
=
$
(
'#advanceBuy'
),
$mainCart
=
$
(
'#mainCart'
);
if
(
$advanceBuy
.
hasClass
(
'hide'
))
{
$mainCart
.
removeClass
(
'show'
).
addClass
(
'hide'
);
$advanceBuy
.
removeClass
(
'hide'
).
addClass
(
'show'
);
}
else
{
$advanceBuy
.
removeClass
(
'show'
).
addClass
(
'hide'
);
$mainCart
.
removeClass
(
'hide'
).
addClass
(
'show'
);
}
});
$
(
'.chose'
).
on
(
'touchend'
,
function
()
{
//var id = $(this).closest('.gift-advance-good').data('id');
chosePanel
.
show
();
=======
dialog
.
showDialog
({
dialogText
:
'您确定要从购物车中删除吗?'
,
...
...
@@ -301,6 +197,5 @@ $('.cut').on('touchend', function() {
}
});
>>>>>>>
develop
});
...
...
static/sass/shopping-cart/_chose-panel.scss
View file @
db9c8ca
...
...
@@ -113,11 +113,7 @@
border-color
:
#e0e0e0
;
background
:
none
;
color
:
#e0e0e0
;
<<<<<<<
HEAD
background-color
:
#f0f0f0
;
=======
background-color
:
#c0c0c0
;
>>>>>>>
develop
}
}
...
...
static/sass/shopping-cart/_good.scss
View file @
db9c8ca
...
...
@@ -151,8 +151,6 @@
}
}
}
<<<<<<<
HEAD
=======
.calculate-num
{
float
:
right
;
.calculate
{
...
...
@@ -209,7 +207,6 @@
}
}
>>>>>>>
develop
}
.shopping-cart-good
:last-child
{
...
...
static/sass/shopping-cart/_index.scss
View file @
db9c8ca
...
...
@@ -178,119 +178,6 @@
}
}
<<<<<<<
HEAD
.gift-advance-good
{
position
:
relative
;
padding
:
20rem
/
$pxConvertRem
0
;
margin-left
:
34rem
/
$pxConvertRem
;
height
:
160rem
/
$pxConvertRem
;
border-bottom
:
1px
solid
#e0e0e0
;
&
:last-child
{
border-bottom
:
none
;
}
}
.advance-block
.gift-advance-good
:last-child
{
border-bottom
:
none
;
}
.advance-block
:last-child
.gift-advance-good
:last-child
{
border-bottom
:
1px
solid
#e0e0e0
;
}
.thumb-wrap
{
position
:
relative
;
float
:
left
;
width
:
120rem
/
$pxConvertRem
;
height
:
160rem
/
$pxConvertRem
;
.thumb
{
width
:
100%
;
height
:
100%
;
}
}
.tag
{
position
:
absolute
;
bottom
:
0
;
left
:
0
;
right
:
0
;
height
:
25rem
/
$pxConvertRem
;
color
:
#fff
;
text-align
:
center
;
background
:
#a1ce4e
;
&
:before
{
content
:
'赠品'
;
}
}
.deps
{
margin-left
:
135rem
/
$pxConvertRem
;
}
.name
{
font-size
:
28rem
/
$pxConvertRem
;
}
.row
:nth-child
(
2
)
{
font-size
:
22rem
/
$pxConvertRem
;
height
:
45rem
/
$pxConvertRem
;
line-height
:
45rem
/
$pxConvertRem
;
>
span
{
margin-right
:
15rem
/
$pxConvertRem
;
}
}
.row
:nth-child
(
3
)
{
position
:
relative
;
}
.color
,
.size
{
color
:
#b6b6b6
;
}
.price
{
font-size
:
24rem
/
$pxConvertRem
;
color
:
#000
;
}
.count
{
font-size
:
20rem
/
$pxConvertRem
;
color
:
#999
;
margin-left
:
22rem
/
$pxConvertRem
;
}
.chose
{
position
:
absolute
;
width
:
88rem
/
$pxConvertRem
;
height
:
58rem
/
$pxConvertRem
;
background
:
#f8f8f8
;
border
:
1px
solid
#ccc
;
right
:
20rem
/
$pxConvertRem
;
top
:
71rem
/
$pxConvertRem
;
font-size
:
26rem
/
$pxConvertRem
;
}
.title
{
height
:
50rem
/
$pxConvertRem
;
line-height
:
50rem
/
$pxConvertRem
;
padding-left
:
20rem
/
$pxConvertRem
;
font-size
:
24rem
/
$pxConvertRem
;
background
:
#f8f8f8
;
}
.advance-block
.tag
{
background
:
#eb76aa
;
&
:before
{
content
:
'加价购'
;
}
}
=======
>>>>>>>
develop
}
.shopping-cart-zero
{
.cart-zero
{
...
...
template/m.yohobuy.com/actions/index/shoppingcart/gift-advance.phtml
0 → 100644
View file @
db9c8ca
{
{>
layout/header
}
}
<div
class=
"gift-advance-page yoho-page"
>
{
{#
shoppingCart
}
}
{
{#if
gift
}
}
{
{#
gift
}
}
{
{>
shopping-cart/gift-advance-good
}
}
{
{/
gift
}
}
{
{^
}
}
{
{#
advance
}
}
<div
class=
"advance-block"
>
<p
class=
"title"
>
{
{title
}
}</p>
{
{#
goods
}
}
{
{>
shopping-cart/gift-advance-good
}
}
{
{/
goods
}
}
</div>
{
{/
advance
}
}
{
{/if
}
}
{
{/
shoppingCart
}
}
</div>
{
{>
layout/footer
}
}
\ No newline at end of file
...
...
template/m.yohobuy.com/actions/index/shopping
C
art/index.phtml → template/m.yohobuy.com/actions/index/shopping
c
art/index.phtml
View file @
db9c8ca
{
{>
layout/header
}
}
<div
id=
"mainCart"
class=
"shopping-cart-page yoho-page"
>
<<<<<<<
HEAD
=======
>>>>>>>
develop
{
{#
shoppingCart
}
}
{
{#if
cartNav
}
}
<ul
class=
"cart-nav clearfix"
>
...
...
@@ -48,10 +44,6 @@
{
{/
shoppingCart
}
}
</div>
<<<<<<<
HEAD
=======
>>>>>>>
develop
<div
id=
"advanceBuy"
class=
"shopping-cart-page yoho-page hide"
>
{
{#
shoppingCart
}
}
{
{#
commonCart
}
}
...
...
@@ -76,8 +68,5 @@
{
{>
product/recommend-for-you
}
}
</div>
<<<<<<<
HEAD
=======
{
{>
shopping-cart/chose-panel
}
}
>>>>>>>
develop
{
{>
layout/footer
}
}
\ No newline at end of file
...
...
template/m.yohobuy.com/actions/index/shoppingcart/order-ensure.phtml
0 → 100644
View file @
db9c8ca
{
{>
layout/header
}
}
<div
class=
"order-ensure-page yoho-page"
>
{
{#
orderEnsure
}
}
<a
class=
"address-wrap block"
data-id=
"{{addressId}}"
href=
"/shoppingCart/selectAddress"
>
<p
class=
"infos"
>
收货地址
<span
class=
"per-info"
>
{
{name
}
}
{
{phoneNum
}
}</span>
<span
class=
"address"
>
{
{area
}
}
{
{address
}
}</span>
</p>
<span
class=
"iconfont"
>
614
;</span>
</a>
<section
class=
"dispatch block"
>
<div
class=
"sub-block"
>
<h
3
class=
"title"
>配送方式</h
3
>
<ul
class=
"dispatch-mode clearfix"
>
{
{#each
dispatchMode
}
}
<li
{
{#if
isSelected
}
}class=
"chosed"
{
{/if
}
}
data-id=
"{{id}}"
>
{
{name
}
}</li>
{
{/each
}
}
</ul>
</div>
<div
class=
"sub-block"
>
<h
3
class=
"title"
>送货时间</h
3
>
<ul
class=
"dispatch-time clearfix"
>
{
{#each
dispatchTime
}
}
<li
{
{#if
isSelected
}
}class=
"chosed"
{
{/if
}
}
data-id=
"{{id}}"
>
{
{name
}
}</li>
{
{/each
}
}
</ul>
</div>
</section>
<section
class=
"block"
>
<h
3
class=
"title"
>商品</h
3
>
<div
class=
"goods"
>
{
{#each
goods
}
}
{
{>
me/order/good
}
}
{
{/each
}
}
</div>
</section>
<section
class=
"block"
>
<ul
class=
"sale-invoice"
>
{
{#
coupon
}
}
<li
class=
"coupon"
>
<a
href=
"/shoppingCart/selectCoupon"
>
<span
class=
"title"
>优惠券</span>
{
{#if
count
}
}
<span
class=
"coupon-count"
>
{
{count
}
}张可用
</span>
{
{/if
}
}
{
{#if
value
}
}
<span
class=
"used coupon-use"
>
-¥
{
{value
}
}
<i
class=
"iconfont"
>
614
;</i>
</span>
{
{^
}
}
<span
class=
"not-used coupon-use"
>
未使用
<i
class=
"iconfont"
>
614
;</i>
</span>
{
{/if
}
}
</a>
</li>
{
{/coupon
}
}
<li
class=
"coin"
data-yoho-coin=
"{{yohoCoin}}"
>
<span
class=
"title"
>YOHO币</span>
<span
class=
"desc"
>可抵用¥
{
{yohoCoin
}
}</span>
<span
class=
"coin-check"
>
<em>-
¥
{
{yohoCoin
}
}</em>
<i
class=
"iconfont checkbox icon-cb-checked"
></i>
</span>
</li>
{
{#if
invoice
}
}
<li
class=
"invoice {{#if needInvoice}}focus{{/if}}"
>
<span
class=
"title"
>发票</span>
<span
class=
"iconfont checkbox {{#if needInvoice}}icon-cb-checked{{else}}icon-checkbox{{/if}}"
></span>
<form
id=
"invoice"
>
<input
type=
"text"
name=
"invoice-title"
value=
"{{invoiceText}}"
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>
<form
id=
"msg"
action=
""
method=
"post"
>
<input
type=
"text"
name=
"msg"
value=
"{{msg}}"
placeholder=
"留言"
>
</form>
</section>
<section
class=
"price-cal block"
>
<ul
class=
"total"
>
<li>
<span>总价</span>
¥
{
{sumPrice
}
}
</li>
<li>
<span>活动价</span>
-
¥
{
{salePrice
}
}
</li>
<li>
<span>运费</span>
+
{
{freight
}
}
</li>
{
{#couponPrice
}
}
<li>
<span>优惠券</span>
-
¥
{
{.
}
}
</li>
{
{/couponPrice
}
}
<li>
<span>YOHO币</span>
-
¥
{
{yohoCoin
}
}
</li>
<li
class=
"cost"
>
应付金额:
<em>¥
{
{price
}
}</em>
</li>
</ul>
</section>
<ul
class=
"pay-mode"
>
{
{#
paymentWay
}
}
<li
class=
"{{#if default}}default{{/if}}"
data-pay-type=
"{{paymentType}}"
data-pay-id=
"{{id}}"
>
<span
class=
"iconfont"
>
{
{#if
default
}
}

62
f;
{
{else
}
}

62
e;
{
{/if
}
}
</span>
{
{name
}
}
</li>
{
{/
paymentWay
}
}
</ul>
{
{/
orderEnsure
}
}
</div>
<script
id=
"tmpl-price"
type=
"text/tmpl"
>
<ul
class=
"total"
>
<li>
<span>总价</span>
¥\
{
{sumPrice
}
}
</li>
<li>
<span>活动价</span>
-
¥\
{
{salePrice
}
}
</li>
<li>
<span>运费</span>
+
\
{
{freight
}
}
</li>
\
{
{#couponPrice
}
}
<li>
<span>优惠券</span>
-
¥\
{
{.
}
}
</li>
\
{
{/couponPrice
}
}
<li>
<span>YOHO币</span>
-
¥\
{
{yohoCoin
}
}
</li>
<li
class=
"cost"
>
应付金额:
<em>¥\
{
{price
}
}</em>
</li>
</ul>
</script>
{
{>
layout/footer
}
}
...
...
template/m.yohobuy.com/actions/index/shoppingcart/select-address.phtml
0 → 100644
View file @
db9c8ca
{
{>
layout/header
}
}
<div
class=
"my-address-page select-address-page yoho-page"
>
<div
class=
"page-wrap"
>
{
{#
address
}
}
<a
class=
"address-item"
data-address-id=
"{{address_id}}"
href=
"/shoppingCart/orderEnsure"
>
<span
class=
"name"
>
{
{consignee
}
}</span>
<span
class=
"tel"
>
{
{mobile
}
}</span>
<p
class=
"address-info"
>
{
{area
}
}
{
{address
}
}</p>
<div
class=
"action iconfont"
>
<span
class=
"edit"
data-href=
"/home/addressAct?id={{address_id}}&refer=shopping"
>
61
e;</span>
<span
class=
"del"
data-id=
"{{address_id}}"
>
621
;</span>
</div>
</a>
{
{/
address
}
}
<a
class=
"add-address"
data-href=
"/home/addressAct?refer=shopping"
>
添加新地址
</a>
<div
class=
"confim-mask hide"
>
<div
class=
"confim-box"
>
<div
class=
"content"
>
您确定要删除地址?
</div>
<div
class=
"action"
>
<span
class=
"cancel"
>
取消
</span>
<span
class=
"confim"
>
确认
</span>
</div>
</div>
</div>
</div>
</div>
{
{>
layout/footer
}
}
...
...
template/m.yohobuy.com/actions/index/shoppingcart/select-coupon.phtml
0 → 100644
View file @
db9c8ca
{
{>
layout/header
}
}
<div
class=
"yoho-page select-coupon-page my-coupon-page"
>
<form
id=
"new-coupon"
method=
"POST"
action=
""
>
<input
type=
"text"
name=
"couponCode"
value=
""
placeholder=
"输入优惠券码"
>
<button
type=
"submit"
class=
"submit"
>确定</button>
</form>
<div
id=
"coupon-list"
class=
"coupon-list"
></div>
<div
class=
"not-avaliable-coupon-line hide"
>不可使用的优惠券</div>
<div
id=
"coupon-list-not"
class=
"coupon-list"
></div>
</div>
<script
id=
"tmpl-coupon"
type=
"text/tmpl"
>
\
{
{#coupons
}
}
\
{
{^
notAvailable
}
}
<a
class=
"employ-main"
data-coupon-code=
"\{{ couponCode}}"
data-coupon-value=
"\{{ couponValue}}"
href=
"/shoppingCart/orderEnsure"
>
<span>\
{
{
couponValue
}
}</span>
<p
class=
"coupon-name"
>\
{
{
couponDetailInfomation
}
}</p>
<p>有效期:\
{
{
couponValidity
}
}</p>
</a>
\
{
{/
notAvailable
}
}
\
{
{/coupons
}
}
</script>
<script
id=
"tmpl-coupon-not-avaliable"
type=
"text/tmpl"
>
\
{
{#
notAvailableCoupons
}
}
<div
class=
"employ-main not-avaliable"
>
<span>\
{
{
couponValue
}
}</span>
<p
class=
"coupon-name"
>\
{
{
couponDetailInfomation
}
}</p>
<p>有效期:\
{
{
couponValidity
}
}</p>
</div>
\
{
{/
notAvailableCoupons
}
}
</script>
<script
id=
"tmpl-no-coupon"
type=
"text/tmpl"
>
<div
class=
"coupon-list"
>
<div
class=
"null"
>
<i></i>
<p>您还没有优惠券!</p>
</div>
</div>
</script>
{
{>
layout/footer
}
}
...
...
template/m.yohobuy.com/partials/shopping-cart/cart-content.phtml
View file @
db9c8ca
...
...
@@ -26,11 +26,7 @@
<span class="iconfont"></span>
加价购
<a>
<<<<<<< HEAD
<span class="count">{{count}}</span>
=======
<span class="count">{{advanceBuyCount}}</span>
>>>>>>> develop
<span class="iconfont icon-right-arrow"></span>
</a>
</li>
...
...
template/m.yohobuy.com/partials/shopping-cart/chose-panel.phtml
View file @
db9c8ca
<<<<<<< HEAD
{{#cartInfo}}
=======
>>>>>>> develop
<div class="chose-panel">
<div class="main">
<div class="infos">
...
...
@@ -29,11 +25,7 @@
<span>颜色</span>
<ul class="clearfix" data-type="color">
{{# colors}}
<<<<<<< HEAD
<li class="block {{#if chosed}}chosed{{/if}} {{#unless colorNum}}zero-stock{{/unless}}" data-num="{{colorNum}}" data-numstr="{{sizeNumStr}}">
=======
<li class="block {{#if chosed}}chosed{{/if}} {{#unless colorNum}}zero-stock{{/unless}}" data-num="{{colorNum}}" data-numstr="{{sizeNumStr}}" data-skcid="{{skcId}}">
>>>>>>> develop
{{name}}
</li>
{{/ colors}}
...
...
@@ -43,11 +35,7 @@
<span>尺码</span>
<ul class="clearfix" data-type="size" >
{{# sizes}}
<<<<<<< HEAD
<li class="block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}" data-id={{id}} data-num="{{sizeNum}}" data-numstr="{{colorNumStr}}">
=======
<li class="block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}" data-id={{id}} data-num="{{sizeNum}}" data-numstr="{{colorNumStr}}" data-skuid="{{skuId}}" data-goodid="{{goodId}}">
>>>>>>> develop
{{name}}
</li>
{{/ sizes}}
...
...
@@ -73,7 +61,3 @@
</div>
</div>
</div>
<<<<<<< HEAD
{{/cartInfo}}
=======
>>>>>>> develop
...
...
template/m.yohobuy.com/partials/shopping-cart/good.phtml
View file @
db9c8ca
...
...
@@ -95,8 +95,5 @@
删除
</div>
</div>-->
<<<<<<< HEAD
=======
>>>>>>> develop
</div>
...
...
yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php
View file @
db9c8ca
...
...
@@ -8,7 +8,7 @@ use Plugin\Helpers;
/**
* 购物车
*/
class
Shopping
C
artController
extends
AbstractAction
class
Shopping
c
artController
extends
AbstractAction
{
/*
* 购物车首页
...
...
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
View file @
db9c8ca
...
...
@@ -17,629 +17,632 @@ use Plugin\Images;
class
CartModel
{
/**
* 加入购物车
*
* @param int $productSku 商品SKU
* @param int $buyNumber 购买数量
* @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int $isEdit 是否是编辑商品SKU,0表示不是编辑
* @param null|int $promotionId 促销id,默认null(加价购有关)
* @param null|int $uid 用户UID,可以不传
* @return array 加入购物车接口返回的数据
*/
public
static
function
addToCart
(
$productSku
,
$buyNumber
,
$goodsType
,
$isEdit
,
$promotionId
,
$uid
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~~'
);
$addCart
=
CartData
::
addToCart
(
$productSku
,
$buyNumber
,
$goodsType
,
$isEdit
,
$promotionId
,
$uid
);
if
(
$addCart
&&
isset
(
$addCart
[
'code'
]))
{
$result
=
$addCart
;
}
return
$result
;
}
/**
* @param integer $uid 用户ID
* @param string $shoppingKey 未登录用户唯一识别码
* @param bool $onlyGift 只获取赠品的商品数据
* @param bool $onlyAdvanceBuy 只获取加价购的商品数据
* @return array|mixed 处理之后的购物车数据
*/
public
static
function
getCartData
(
$uid
,
$shoppingKey
,
$onlyGift
=
false
,
$onlyAdvanceBuy
=
false
)
{
$result
=
array
(
'cartNav'
=>
true
);
// 用户是否登录
if
(
empty
(
$uid
))
{
$result
[
'showLoginInfo'
]
=
true
;
}
// 调用接口获取购物车的数据
$cartData
=
CartData
::
cartData
(
$uid
,
$shoppingKey
);
// 处理普通购物车和预售购物车的数据
if
(
isset
(
$cartData
[
'data'
])
&&
!
empty
(
$cartData
[
'data'
]))
{
$cart
=
$cartData
[
'data'
];
/* 普通购物车 */
if
(
isset
(
$cart
[
'ordinary_cart_data'
]))
{
$result
[
'commonGoodsCount'
]
=
$cart
[
'ordinary_cart_data'
][
'shopping_cart_data'
][
'goods_count'
];
$result
[
'commonCart'
]
=
self
::
procCartData
(
$cart
[
'ordinary_cart_data'
],
$onlyGift
,
$onlyAdvanceBuy
);
}
/* 预售购物车 */
if
(
isset
(
$cart
[
'advance_cart_data'
]))
{
$result
[
'presellGoodsCount'
]
=
$cart
[
'advance_cart_data'
][
'shopping_cart_data'
][
'goods_count'
];
$result
[
'preSellCart'
]
=
self
::
procCartData
(
$cart
[
'advance_cart_data'
],
$onlyGift
,
$onlyAdvanceBuy
);
}
}
return
$result
;
}
/**
* 购物车商品选择与取消接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 处理之后的数据的数据
*/
public
static
function
selectGoods
(
$uid
,
$sku
,
$shoppingKey
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
// 处理sku
$sku_list
=
json_encode
(
array
(
$sku
=>
1
));
$select
=
CartData
::
selectGoods
(
$uid
,
$sku_list
,
$shoppingKey
);
if
(
$select
&&
isset
(
$select
[
'code'
]))
{
$result
[
'code'
]
=
$select
[
'code'
];
$result
[
'message'
]
=
$select
[
'message'
];
}
return
$result
;
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public
static
function
removeFromCart
(
$uid
,
$sku
,
$shoppingKey
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
// 处理sku
$sku_list
=
json_encode
(
array
(
$sku
=>
1
));
$remove
=
CartData
::
removeFromCart
(
$uid
,
$sku_list
,
$shoppingKey
);
if
(
$remove
&&
isset
(
$remove
[
'code'
]))
{
$result
[
'code'
]
=
$remove
[
'code'
];
$result
[
'message'
]
=
$remove
[
'message'
];
}
return
$result
;
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public
static
function
addToFav
(
$uid
,
$sku
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
if
(
empty
(
$uid
))
{
$result
[
'code'
]
=
300
;
$reult
[
'message'
]
=
'请先登录'
;
$result
[
'data'
]
=
'/signin.html'
;
return
$result
;
}
// 处理sku
$sku_list
=
json_encode
(
array
(
$sku
=>
1
));
$add
=
CartData
::
addToFav
(
$uid
,
$sku_list
);
if
(
$add
&&
isset
(
$add
[
'code'
]))
{
$result
[
'code'
]
=
$add
[
'code'
];
$result
[
'message'
]
=
$add
[
'message'
];
}
return
$result
;
}
/**
* 处理购物车商品数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @param int $num 购买数目
* @return array 接口返回的数据
*/
public
static
function
cartProductData
(
$uid
,
$skn
,
$num
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
$product
=
CartData
::
cartProductData
(
$uid
,
$skn
);
if
(
isset
(
$product
[
'code'
])
&&
$product
[
'code'
]
===
200
)
{
$result
[
'code'
]
=
200
;
$data
=
array
();
$productData
=
$product
[
'data'
];
// 品牌信息
if
(
isset
(
$productData
[
'brand_info'
])
&&
!
empty
(
$productData
[
'brand_info'
]))
{
$data
[
'thumb'
]
=
Helpers
::
getImageUrl
(
$productData
[
'brand_info'
][
'brand_ico'
],
120
,
120
);
}
$data
[
'name'
]
=
$productData
[
'product_name'
];
$data
[
'price'
]
=
$productData
[
'market_price'
];
$data
[
'salePrice'
]
=
$productData
[
'sales_price'
];
$data
[
'storage'
]
=
$productData
[
'storage_sum'
];
$data
[
'num'
]
=
$num
;
// 商品选择
if
(
isset
(
$productData
[
'goods_list'
]))
{
$goodsList
=
$productData
[
'goods_list'
];
$colors
=
array
();
$oneColor
=
array
();
$sizes
=
array
();
$oneSize
=
array
();
foreach
(
$goodsList
as
$val
)
{
// 颜色
$oneColor
=
array
();
$oneColor
[
'id'
]
=
$val
[
'color_id'
];
$oneColor
[
'name'
]
=
$val
[
'color_name'
];
// 尺码
foreach
(
$val
[
'size_list'
]
as
$one
)
{
$oneSize
=
array
();
$oneSize
[
'id'
]
=
$one
[
'size_id'
];
$oneSize
[
'name'
]
=
$one
[
'size_name'
];
}
$sizes
[]
=
$oneSize
;
$oneColor
[
'sizes'
]
=
$sizes
;
$colors
[]
=
$oneColor
;
}
$data
[
'colors'
]
=
$colors
;
}
$result
[
'data'
]
=
$data
;
}
return
$result
;
}
/**
* 处理加价购商品数据
*
* @param int $skn 商品skn
* @param int $promotionId 加价购商品促销ID
* @return array
*/
public
static
function
giftProductData
(
$skn
,
$promotionId
)
{
$result
=
array
();
$product
=
CartData
::
giftProductData
(
$skn
,
$promotionId
);
if
(
isset
(
$product
[
'code'
])
&&
$product
[
'code'
]
===
200
)
{
$result
[
'code'
]
=
200
;
$data
=
array
();
$productData
=
$product
[
'data'
];
// 品牌信息
if
(
isset
(
$productData
[
'brand_info'
])
&&
!
empty
(
$productData
[
'brand_info'
]))
{
$data
[
'thumb'
]
=
Helpers
::
getImageUrl
(
$productData
[
'brand_info'
][
'brand_ico'
],
120
,
120
);
}
$data
[
'name'
]
=
$productData
[
'product_name'
];
$data
[
'price'
]
=
$productData
[
'market_price'
];
$data
[
'salePrice'
]
=
$productData
[
'sales_price'
];
$data
[
'storage'
]
=
$productData
[
'storage_sum'
];
// 商品选择
if
(
isset
(
$productData
[
'goods_list'
]))
{
$goodsList
=
$productData
[
'goods_list'
];
$colors
=
array
();
$oneColor
=
array
();
$sizes
=
array
();
$oneSize
=
array
();
foreach
(
$goodsList
as
$val
)
{
// 颜色
$oneColor
=
array
();
$oneColor
[
'id'
]
=
$val
[
'color_id'
];
$oneColor
[
'name'
]
=
$val
[
'color_name'
];
// 尺码
foreach
(
$val
[
'size_list'
]
as
$one
)
{
$oneSize
=
array
();
$oneSize
[
'id'
]
=
$one
[
'size_id'
];
$oneSize
[
'name'
]
=
$one
[
'size_name'
];
}
$sizes
[]
=
$oneSize
;
$oneColor
[
'sizes'
]
=
$sizes
;
$colors
[]
=
$oneColor
;
}
$data
[
'colors'
]
=
$colors
;
}
$result
[
'data'
]
=
$data
;
}
return
$result
;
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $param 要更改的数据
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public
static
function
modifyCartProduct
(
$uid
,
$param
,
$shoppingKey
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
// 处理要更改的数据
$swapData
=
json_encode
(
array
(
$param
));
$modify
=
CartData
::
modifyCartProduct
(
$uid
,
$swapData
,
$shoppingKey
);
if
(
$modify
&&
isset
(
$modify
[
'code'
]))
{
$result
[
'code'
]
=
$modify
[
'code'
];
$result
[
'message'
]
=
$modify
[
'message'
];
}
return
$result
;
}
/**
* 调用购物车结算接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param null|string $cookieData cookie中记录的一些订单有关数据
* @return array 接口返回的数据
*/
public
static
function
cartPay
(
$uid
,
$cartType
,
$cookieData
)
{
$result
=
array
();
$pay
=
CartData
::
cartPay
(
$uid
,
$cartType
);
if
(
$pay
&&
isset
(
$pay
[
'code'
])
&&
$pay
[
'code'
]
===
200
)
{
$payReturn
=
$pay
[
'data'
];
$orderInfo
=
array
();
$address
=
array
();
$orderCompute
=
array
();
// cookie保存的数据
if
(
!
empty
(
$cookieData
))
{
$orderInfo
=
json_decode
(
$cookieData
,
true
);
$orderCompute
=
self
::
orderCompute
(
$uid
,
$cartType
,
$orderInfo
[
'deliveryId'
],
$orderInfo
[
'paymentTypeId'
],
$orderInfo
[
'couponCode'
],
$orderInfo
[
'yohoCoin'
]);
}
// 根据地址id查询地址信息
if
(
isset
(
$orderInfo
[
'addressId'
]))
{
$address
=
UserModel
::
getAddressDataById
(
$uid
,
$orderInfo
[
'addressId'
]);
}
// 收货人有关信息
if
(
isset
(
$payReturn
[
'delivery_address'
])
&&
!
empty
(
$payReturn
[
'delivery_address'
]))
{
$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'
];
/**
* 加入购物车
*
* @param int $productSku 商品SKU
* @param int $buyNumber 购买数量
* @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int $isEdit 是否是编辑商品SKU,0表示不是编辑
* @param null|int $promotionId 促销id,默认null(加价购有关)
* @param null|int $uid 用户UID,可以不传
* @return array 加入购物车接口返回的数据
*/
public
static
function
addToCart
(
$productSku
,
$buyNumber
,
$goodsType
,
$isEdit
,
$promotionId
,
$uid
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~~'
);
$addCart
=
CartData
::
addToCart
(
$productSku
,
$buyNumber
,
$goodsType
,
$isEdit
,
$promotionId
,
$uid
);
if
(
$addCart
&&
isset
(
$addCart
[
'code'
]))
{
$result
=
$addCart
;
}
return
$result
;
}
/**
* @param integer $uid 用户ID
* @param string $shoppingKey 未登录用户唯一识别码
* @param bool $onlyGift 只获取赠品的商品数据
* @param bool $onlyAdvanceBuy 只获取加价购的商品数据
* @return array|mixed 处理之后的购物车数据
*/
public
static
function
getCartData
(
$uid
,
$shoppingKey
,
$onlyGift
=
false
,
$onlyAdvanceBuy
=
false
)
{
$result
=
array
(
'cartNav'
=>
true
);
// 用户是否登录
if
(
empty
(
$uid
))
{
$result
[
'showLoginInfo'
]
=
true
;
}
// 调用接口获取购物车的数据
$cartData
=
CartData
::
cartData
(
$uid
,
$shoppingKey
);
// 处理普通购物车和预售购物车的数据
if
(
isset
(
$cartData
[
'data'
])
&&
!
empty
(
$cartData
[
'data'
]))
{
$cart
=
$cartData
[
'data'
];
/* 普通购物车 */
if
(
isset
(
$cart
[
'ordinary_cart_data'
]))
{
$result
[
'commonGoodsCount'
]
=
$cart
[
'ordinary_cart_data'
][
'shopping_cart_data'
][
'goods_count'
];
$result
[
'commonCart'
]
=
self
::
procCartData
(
$cart
[
'ordinary_cart_data'
],
$onlyGift
,
$onlyAdvanceBuy
);
}
/* 预售购物车 */
if
(
isset
(
$cart
[
'advance_cart_data'
]))
{
$result
[
'presellGoodsCount'
]
=
$cart
[
'advance_cart_data'
][
'shopping_cart_data'
][
'goods_count'
];
$result
[
'preSellCart'
]
=
self
::
procCartData
(
$cart
[
'advance_cart_data'
],
$onlyGift
,
$onlyAdvanceBuy
);
}
}
return
$result
;
}
/**
* 购物车商品选择与取消接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 处理之后的数据的数据
*/
public
static
function
selectGoods
(
$uid
,
$sku
,
$shoppingKey
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
// 处理sku
$sku_list
=
json_encode
(
array
(
$sku
=>
1
));
$select
=
CartData
::
selectGoods
(
$uid
,
$sku_list
,
$shoppingKey
);
if
(
$select
&&
isset
(
$select
[
'code'
]))
{
$result
[
'code'
]
=
$select
[
'code'
];
$result
[
'message'
]
=
$select
[
'message'
];
}
return
$result
;
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public
static
function
removeFromCart
(
$uid
,
$sku
,
$shoppingKey
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
// 处理sku
$sku_list
=
json_encode
(
array
(
$sku
=>
1
));
$remove
=
CartData
::
removeFromCart
(
$uid
,
$sku_list
,
$shoppingKey
);
if
(
$remove
&&
isset
(
$remove
[
'code'
]))
{
$result
[
'code'
]
=
$remove
[
'code'
];
$result
[
'message'
]
=
$remove
[
'message'
];
}
return
$result
;
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public
static
function
addToFav
(
$uid
,
$sku
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
if
(
empty
(
$uid
))
{
$result
[
'code'
]
=
300
;
$reult
[
'message'
]
=
'请先登录'
;
$result
[
'data'
]
=
'/signin.html'
;
return
$result
;
}
// 处理sku
$sku_list
=
json_encode
(
array
(
$sku
=>
1
));
$add
=
CartData
::
addToFav
(
$uid
,
$sku_list
);
if
(
$add
&&
isset
(
$add
[
'code'
]))
{
$result
[
'code'
]
=
$add
[
'code'
];
$result
[
'message'
]
=
$add
[
'message'
];
}
return
$result
;
}
/**
* 处理购物车商品数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @param int $num 购买数目
* @return array 接口返回的数据
*/
public
static
function
cartProductData
(
$uid
,
$skn
,
$num
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
$product
=
CartData
::
cartProductData
(
$uid
,
$skn
);
if
(
isset
(
$product
[
'code'
])
&&
$product
[
'code'
]
===
200
)
{
$result
[
'code'
]
=
200
;
$data
=
array
();
$productData
=
$product
[
'data'
];
// 品牌信息
if
(
isset
(
$productData
[
'brand_info'
])
&&
!
empty
(
$productData
[
'brand_info'
]))
{
$data
[
'thumb'
]
=
Helpers
::
getImageUrl
(
$productData
[
'brand_info'
][
'brand_ico'
],
120
,
120
);
}
$data
[
'name'
]
=
$productData
[
'product_name'
];
$data
[
'price'
]
=
$productData
[
'market_price'
];
$data
[
'salePrice'
]
=
$productData
[
'sales_price'
];
$data
[
'storage'
]
=
$productData
[
'storage_sum'
];
$data
[
'num'
]
=
$num
;
// 商品选择
if
(
isset
(
$productData
[
'goods_list'
]))
{
$goodsList
=
$productData
[
'goods_list'
];
$colors
=
array
();
$oneColor
=
array
();
$sizes
=
array
();
$oneSize
=
array
();
foreach
(
$goodsList
as
$val
)
{
// 颜色
$oneColor
=
array
();
$oneColor
[
'id'
]
=
$val
[
'color_id'
];
$oneColor
[
'name'
]
=
$val
[
'color_name'
];
// 尺码
foreach
(
$val
[
'size_list'
]
as
$one
)
{
$oneSize
=
array
();
$oneSize
[
'id'
]
=
$one
[
'size_id'
];
$oneSize
[
'name'
]
=
$one
[
'size_name'
];
}
$sizes
[]
=
$oneSize
;
$oneColor
[
'sizes'
]
=
$sizes
;
$colors
[]
=
$oneColor
;
}
$data
[
'colors'
]
=
$colors
;
}
$result
[
'data'
]
=
$data
;
}
return
$result
;
}
/**
* 处理加价购商品数据
*
* @param int $skn 商品skn
* @param int $promotionId 加价购商品促销ID
* @return array
*/
public
static
function
giftProductData
(
$skn
,
$promotionId
)
{
$result
=
array
();
$product
=
CartData
::
giftProductData
(
$skn
,
$promotionId
);
if
(
isset
(
$product
[
'code'
])
&&
$product
[
'code'
]
===
200
)
{
$result
[
'code'
]
=
200
;
$data
=
array
();
$productData
=
$product
[
'data'
];
// 品牌信息
if
(
isset
(
$productData
[
'brand_info'
])
&&
!
empty
(
$productData
[
'brand_info'
]))
{
$data
[
'thumb'
]
=
Helpers
::
getImageUrl
(
$productData
[
'brand_info'
][
'brand_ico'
],
120
,
120
);
}
$data
[
'name'
]
=
$productData
[
'product_name'
];
$data
[
'price'
]
=
$productData
[
'market_price'
];
$data
[
'salePrice'
]
=
$productData
[
'sales_price'
];
$data
[
'storage'
]
=
$productData
[
'storage_sum'
];
// 商品选择
if
(
isset
(
$productData
[
'goods_list'
]))
{
$goodsList
=
$productData
[
'goods_list'
];
$colors
=
array
();
$oneColor
=
array
();
$sizes
=
array
();
$oneSize
=
array
();
foreach
(
$goodsList
as
$val
)
{
// 颜色
$oneColor
=
array
();
$oneColor
[
'id'
]
=
$val
[
'color_id'
];
$oneColor
[
'name'
]
=
$val
[
'color_name'
];
// 尺码
foreach
(
$val
[
'size_list'
]
as
$one
)
{
$oneSize
=
array
();
$oneSize
[
'id'
]
=
$one
[
'size_id'
];
$oneSize
[
'name'
]
=
$one
[
'size_name'
];
}
$sizes
[]
=
$oneSize
;
$oneColor
[
'sizes'
]
=
$sizes
;
$colors
[]
=
$oneColor
;
}
$data
[
'colors'
]
=
$colors
;
}
$result
[
'data'
]
=
$data
;
}
return
$result
;
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $param 要更改的数据
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public
static
function
modifyCartProduct
(
$uid
,
$param
,
$shoppingKey
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
// 处理要更改的数据
$swapData
=
json_encode
(
array
(
$param
));
$modify
=
CartData
::
modifyCartProduct
(
$uid
,
$swapData
,
$shoppingKey
);
if
(
$modify
&&
isset
(
$modify
[
'code'
]))
{
$result
[
'code'
]
=
$modify
[
'code'
];
$result
[
'message'
]
=
$modify
[
'message'
];
}
return
$result
;
}
/**
* 调用购物车结算接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param null|string $cookieData cookie中记录的一些订单有关数据
* @return array 接口返回的数据
*/
public
static
function
cartPay
(
$uid
,
$cartType
,
$cookieData
)
{
$result
=
array
();
$pay
=
CartData
::
cartPay
(
$uid
,
$cartType
);
if
(
$pay
&&
isset
(
$pay
[
'code'
])
&&
$pay
[
'code'
]
===
200
)
{
$payReturn
=
$pay
[
'data'
];
$orderInfo
=
array
();
$address
=
array
();
$orderCompute
=
array
();
// cookie保存的数据
if
(
!
empty
(
$cookieData
))
{
$orderInfo
=
json_decode
(
$cookieData
,
true
);
$orderCompute
=
self
::
orderCompute
(
$uid
,
$cartType
,
$orderInfo
[
'deliveryId'
],
$orderInfo
[
'paymentTypeId'
],
$orderInfo
[
'couponCode'
],
$orderInfo
[
'yohoCoin'
]);
}
// 根据地址id查询地址信息
if
(
isset
(
$orderInfo
[
'addressId'
]))
{
$address
=
UserModel
::
getAddressDataById
(
$uid
,
$orderInfo
[
'addressId'
]);
}
// 收货人有关信息
if
(
isset
(
$payReturn
[
'delivery_address'
])
&&
!
empty
(
$payReturn
[
'delivery_address'
]))
{
$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
[
'isSupport'
]
=
(
$payReturn
[
'delivery_address'
][
'is_support'
]
===
'Y'
);
}
// 配送方式
if
(
isset
(
$payReturn
[
'delivery_way'
]))
{
$idArr
=
array
();
$defaultKey
=
0
;
$oneDeliv
=
array
();
foreach
(
$payReturn
[
'delivery_way'
]
as
$key
=>
$val
)
{
$oneDeliv
=
array
();
$oneDeliv
[
'id'
]
=
$val
[
'delivery_way_id'
];
$oneDeliv
[
'name'
]
=
$val
[
'delivery_way_name'
];
(
$val
[
'default'
]
===
'Y'
)
&&
$defaultKey
=
$key
;
$idArr
[
$key
]
=
$oneDeliv
[
'id'
];
$result
[
'dispatchMode'
][
$key
]
=
$oneDeliv
;
}
if
(
isset
(
$orderInfo
[
'deliveryId'
]))
{
$flag
=
array_search
(
$orderInfo
[
'deliveryId'
],
$idArr
);
$flag
!==
false
&&
$result
[
'dispatchMode'
][
$flag
][
'isSelected'
]
=
true
;
}
else
{
$result
[
'dispatchMode'
][
$defaultKey
][
'isSelected'
]
=
true
;
}
}
// 配送时间
if
(
isset
(
$payReturn
[
'delivery_time'
]))
{
$idArr
=
array
();
$defaultKey
=
0
;
$oneDelivTime
=
array
();
foreach
(
$payReturn
[
'delivery_time'
]
as
$key
=>
$one
)
{
$oneDelivTime
=
array
();
$oneDelivTime
[
'id'
]
=
$one
[
'delivery_time_id'
];
$oneDelivTime
[
'name'
]
=
$one
[
'delivery_time_string'
];
(
$one
[
'default'
]
===
'Y'
)
&&
$defaultKey
=
$key
;
$idArr
[
$key
]
=
$oneDelivTime
[
'id'
];
$result
[
'dispatchTime'
][]
=
$oneDelivTime
;
}
if
(
isset
(
$orderInfo
[
'deliveryTimeId'
]))
{
$flag
=
array_search
(
$orderInfo
[
'deliveryTimeId'
],
$idArr
);
$flag
!==
false
&&
$result
[
'dispatchTime'
][
$flag
][
'isSelected'
]
=
true
;
}
else
{
$result
[
'dispatchTime'
][
$defaultKey
][
'isSelected'
]
=
true
;
}
}
// 订单商品
if
(
isset
(
$payReturn
[
'goods_list'
]))
{
$oneGoods
=
array
();
foreach
(
$payReturn
[
'goods_list'
]
as
$single
)
{
$oneGoods
=
array
();
$oneGoods
[
'id'
]
=
$single
[
'product_sku'
];
// TODO 未确定用哪个
$oneGoods
[
'thumb'
]
=
Images
::
getImageUrl
(
$single
[
'goods_images'
],
120
,
120
);
$oneGoods
[
'name'
]
=
$single
[
'product_name'
];
$oneGoods
[
'color'
]
=
$single
[
'color_name'
];
$oneGoods
[
'size'
]
=
$single
[
'size_name'
];
$oneGoods
[
'price'
]
=
Helpers
::
transPrice
(
$single
[
'sales_price'
]);
$oneGoods
[
'count'
]
=
$single
[
'buy_number'
];
$result
[
'goods'
][]
=
$oneGoods
;
}
}
// 支付方式
if
(
isset
(
$payReturn
[
'payment_way'
]))
{
$onePay
=
array
();
foreach
(
$payReturn
[
'payment_way'
]
as
$pay
)
{
$onePay
=
array
();
$onePay
[
'id'
]
=
$pay
[
'payment_id'
];
$onePay
[
'paymentType'
]
=
$pay
[
'payment_type'
];
$onePay
[
'name'
]
=
$pay
[
'payment_type_name'
];
$onePay
[
'default'
]
=
(
$pay
[
'default'
]
===
'Y'
);
$result
[
'paymentWay'
][]
=
$onePay
;
}
}
// 有货币
$result
[
'yohoCoin'
]
=
(
isset
(
$orderCompute
[
'use_yoho_coin'
])
&&
!
empty
(
$orderCompute
[
'use_yoho_coin'
]))
?
$orderCompute
[
'use_yoho_coin'
]
:
$payReturn
[
'yoho_coin'
];
// 订单数据
if
(
isset
(
$payReturn
[
'shopping_cart_data'
])
&&
!
empty
(
$payReturn
[
'shopping_cart_data'
]))
{
$sumPrice
=
isset
(
$orderCompute
[
'order_amount'
])
?
$orderCompute
[
'order_amount'
]
:
$payReturn
[
'shopping_cart_data'
][
'order_amount'
];
$freight
=
isset
(
$orderCompute
[
'promotion_formula_list'
][
'promotion_amount'
])
?
$orderCompute
[
'promotion_formula_list'
][
1
][
'promotion_amount'
]
:
$payReturn
[
'shopping_cart_data'
][
'promotion_formula_list'
][
1
][
'promotion_amount'
];
$couponPrice
=
isset
(
$orderCompute
[
'coupon_amount'
])
?
$orderCompute
[
'coupon_amount'
]
:
false
;
$salePrice
=
isset
(
$orderCompute
[
'discount_amount'
])
?
$orderCompute
[
'discount_amount'
]
:
$payReturn
[
'shopping_cart_data'
][
'promotion_formula_list'
][
3
][
'promotion_amount'
];
$price
=
isset
(
$orderCompute
[
'last_order_amount'
])
?
$orderCompute
[
'last_order_amount'
]
:
$payReturn
[
'shopping_cart_data'
][
'last_order_amount'
];
$result
[
'sumPrice'
]
=
Helpers
::
transPrice
(
$sumPrice
);
$result
[
'salePrice'
]
=
Helpers
::
transPrice
(
$salePrice
);
$result
[
'price'
]
=
Helpers
::
transPrice
(
$price
);
$result
[
'freight'
]
=
$freight
;
$result
[
'couponPrice'
]
=
$couponPrice
;
}
// 发票有关数据
if
(
isset
(
$payReturn
[
'invoices'
])
&&
!
empty
(
$payReturn
[
'invoices'
]))
{
$one
=
array
();
foreach
(
$payReturn
[
'invoices'
][
'invoices_type_list'
]
as
$inv
)
{
$one
=
array
();
$one
[
'id'
]
=
$inv
[
'invoices_type_id'
];
$one
[
'name'
]
=
$inv
[
'invoices_type_name'
];
$result
[
'isSupport'
]
=
(
$payReturn
[
'delivery_address'
][
'is_support'
]
===
'Y'
);
}
// 配送方式
if
(
isset
(
$payReturn
[
'delivery_way'
]))
{
$idArr
=
array
();
$defaultKey
=
0
;
$oneDeliv
=
array
();
foreach
(
$payReturn
[
'delivery_way'
]
as
$key
=>
$val
)
{
$oneDeliv
=
array
();
$oneDeliv
[
'id'
]
=
$val
[
'delivery_way_id'
];
$oneDeliv
[
'name'
]
=
$val
[
'delivery_way_name'
];
(
$val
[
'default'
]
===
'Y'
)
&&
$defaultKey
=
$key
;
$idArr
[
$key
]
=
$oneDeliv
[
'id'
];
$result
[
'dispatchMode'
][
$key
]
=
$oneDeliv
;
}
if
(
isset
(
$orderInfo
[
'deliveryId'
]))
{
$flag
=
array_search
(
$orderInfo
[
'deliveryId'
],
$idArr
);
$flag
!==
false
&&
$result
[
'dispatchMode'
][
$flag
][
'isSelected'
]
=
true
;
}
else
{
$result
[
'dispatchMode'
][
$defaultKey
][
'isSelected'
]
=
true
;
}
}
// 配送时间
if
(
isset
(
$payReturn
[
'delivery_time'
]))
{
$idArr
=
array
();
$defaultKey
=
0
;
$oneDelivTime
=
array
();
foreach
(
$payReturn
[
'delivery_time'
]
as
$key
=>
$one
)
{
$oneDelivTime
=
array
();
$oneDelivTime
[
'id'
]
=
$one
[
'delivery_time_id'
];
$oneDelivTime
[
'name'
]
=
$one
[
'delivery_time_string'
];
(
$one
[
'default'
]
===
'Y'
)
&&
$defaultKey
=
$key
;
$idArr
[
$key
]
=
$oneDelivTime
[
'id'
];
$result
[
'dispatchTime'
][]
=
$oneDelivTime
;
}
if
(
isset
(
$orderInfo
[
'deliveryTimeId'
]))
{
$flag
=
array_search
(
$orderInfo
[
'deliveryTimeId'
],
$idArr
);
$flag
!==
false
&&
$result
[
'dispatchTime'
][
$flag
][
'isSelected'
]
=
true
;
}
else
{
$result
[
'dispatchTime'
][
$defaultKey
][
'isSelected'
]
=
true
;
}
}
// 订单商品
if
(
isset
(
$payReturn
[
'goods_list'
]))
{
$oneGoods
=
array
();
foreach
(
$payReturn
[
'goods_list'
]
as
$single
)
{
$oneGoods
=
array
();
$oneGoods
[
'id'
]
=
$single
[
'product_sku'
];
// TODO 未确定用哪个
$oneGoods
[
'thumb'
]
=
Images
::
getImageUrl
(
$single
[
'goods_images'
],
120
,
120
);
$oneGoods
[
'name'
]
=
$single
[
'product_name'
];
$oneGoods
[
'color'
]
=
$single
[
'color_name'
];
$oneGoods
[
'size'
]
=
$single
[
'size_name'
];
$oneGoods
[
'price'
]
=
Helpers
::
transPrice
(
$single
[
'sales_price'
]);
$oneGoods
[
'count'
]
=
$single
[
'buy_number'
];
$result
[
'goods'
][]
=
$oneGoods
;
}
}
// 支付方式
if
(
isset
(
$payReturn
[
'payment_way'
]))
{
$onePay
=
array
();
foreach
(
$payReturn
[
'payment_way'
]
as
$pay
)
{
$onePay
=
array
();
$onePay
[
'id'
]
=
$pay
[
'payment_id'
];
$onePay
[
'paymentType'
]
=
$pay
[
'payment_type'
];
$onePay
[
'name'
]
=
$pay
[
'payment_type_name'
];
$onePay
[
'default'
]
=
(
$pay
[
'default'
]
===
'Y'
);
$result
[
'paymentWay'
][]
=
$onePay
;
}
}
// 有货币
$result
[
'yohoCoin'
]
=
(
isset
(
$orderCompute
[
'use_yoho_coin'
])
&&
!
empty
(
$orderCompute
[
'use_yoho_coin'
]))
?
$orderCompute
[
'use_yoho_coin'
]
:
$payReturn
[
'yoho_coin'
];
// 订单数据
if
(
isset
(
$payReturn
[
'shopping_cart_data'
])
&&
!
empty
(
$payReturn
[
'shopping_cart_data'
]))
{
$sumPrice
=
isset
(
$orderCompute
[
'order_amount'
])
?
$orderCompute
[
'order_amount'
]
:
$payReturn
[
'shopping_cart_data'
][
'order_amount'
];
$freight
=
isset
(
$orderCompute
[
'promotion_formula_list'
][
'promotion_amount'
])
?
$orderCompute
[
'promotion_formula_list'
][
1
][
'promotion_amount'
]
:
$payReturn
[
'shopping_cart_data'
][
'promotion_formula_list'
][
1
][
'promotion_amount'
];
$couponPrice
=
isset
(
$orderCompute
[
'coupon_amount'
])
?
$orderCompute
[
'coupon_amount'
]
:
false
;
$salePrice
=
isset
(
$orderCompute
[
'discount_amount'
])
?
$orderCompute
[
'discount_amount'
]
:
$payReturn
[
'shopping_cart_data'
][
'promotion_formula_list'
][
3
][
'promotion_amount'
];
$price
=
isset
(
$orderCompute
[
'last_order_amount'
])
?
$orderCompute
[
'last_order_amount'
]
:
$payReturn
[
'shopping_cart_data'
][
'last_order_amount'
];
$result
[
'sumPrice'
]
=
Helpers
::
transPrice
(
$sumPrice
);
$result
[
'salePrice'
]
=
Helpers
::
transPrice
(
$salePrice
);
$result
[
'price'
]
=
Helpers
::
transPrice
(
$price
);
$result
[
'freight'
]
=
$freight
;
$result
[
'couponPrice'
]
=
$couponPrice
;
}
// 发票有关数据
if
(
isset
(
$payReturn
[
'invoices'
])
&&
!
empty
(
$payReturn
[
'invoices'
]))
{
$one
=
array
();
foreach
(
$payReturn
[
'invoices'
][
'invoices_type_list'
]
as
$inv
)
{
$one
=
array
();
$one
[
'id'
]
=
$inv
[
'invoices_type_id'
];
$one
[
'name'
]
=
$inv
[
'invoices_type_name'
];
isset
(
$orderInfo
[
'invoiceType'
])
&&
$one
[
'id'
]
==
$orderInfo
[
'invoiceType'
]
&&
$one
[
'isSelected'
]
=
true
;
$result
[
'invoice'
][]
=
$one
;
}
$result
[
'invoice'
][]
=
$one
;
}
// 发票信息需要记录
if
(
isset
(
$orderInfo
[
'invoice'
]))
{
$result
[
'needInvoice'
]
=
$orderInfo
[
'invoice'
];
$result
[
'invoiceText'
]
=
$orderInfo
[
'invoiceText'
];
}
}
if
(
isset
(
$orderInfo
[
'invoice'
]))
{
$result
[
'needInvoice'
]
=
$orderInfo
[
'invoice'
];
$result
[
'invoiceText'
]
=
$orderInfo
[
'invoiceText'
];
}
}
// 留言
isset
(
$orderInfo
[
'msg'
])
&&
$result
[
'msg'
]
=
$orderInfo
[
'msg'
];
// 优惠券数据
$coupons
=
array
();
!
empty
(
$orderCompute
[
'coupon_amount'
])
&&
$coupons
[
'value'
]
=
$orderInfo
[
'couponValue'
];
$coupons
+=
self
::
getCouponList
(
$uid
,
true
);
$result
[
'coupon'
]
=
$coupons
;
}
return
$result
;
}
/**
* 购物车结算--支付方式和配送方式选择以及是否使用YOHO币接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param int $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量
* @return array 接口返回的数据
*/
public
static
function
orderCompute
(
$uid
,
$cartType
,
$deliveryWay
,
$paymentType
,
$couponCode
,
$yohoCoin
)
{
$result
=
array
();
$compute
=
CartData
::
orderCompute
(
$uid
,
$cartType
,
$deliveryWay
,
$paymentType
,
$couponCode
,
$yohoCoin
);
if
(
$compute
&&
isset
(
$compute
[
'code'
])
&&
$compute
[
'code'
]
===
200
)
{
$result
=
$compute
[
'data'
];
}
return
$result
;
}
/**
* 购物车结算--输入优惠券代码返回的结果处理
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public
static
function
searchCoupon
(
$uid
,
$couponCode
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
$coupon
=
CartData
::
searchCoupon
(
$uid
,
$couponCode
);
if
(
$coupon
&&
isset
(
$coupon
[
'code'
]))
{
$result
=
$coupon
;
}
return
$result
;
}
/**
* 处理优惠券列表数据
*
* @param int $uid 用户ID
* @param boolean $onlyTotal 只返回总数
* @return array|mixed 处理之后的优惠券数据
*/
public
static
function
getCouponList
(
$uid
,
$onlyTotal
=
false
)
{
$result
=
array
();
// 调用接口获取优惠券数据
$coupons
=
CartData
::
getCouponList
(
$uid
);
// 处理优惠券数据
if
(
isset
(
$coupons
[
'data'
]))
{
if
(
$onlyTotal
)
{
$result
[
'count'
]
=
count
(
$coupons
[
'data'
][
'couponList'
]);
}
else
{
$couponArr
=
array
();
isset
(
$coupons
[
'data'
][
'couponList'
])
&&
$couponArr
=
$coupons
[
'data'
][
'couponList'
];
foreach
(
$couponArr
as
&
$val
)
{
$notAvailableRes
=
self
::
searchCoupon
(
$uid
,
$val
[
'couponCode'
]);
// 处理可用的优惠券
if
(
isset
(
$notAvailableRes
[
'code'
])
&&
$notAvailableRes
[
'code'
]
!==
200
)
{
$val
[
'notAvailable'
]
=
true
;
}
}
!
empty
(
$couponArr
)
&&
$result
=
$couponArr
;
}
}
return
$result
;
}
/**
* 购物车结算--提交结算信息
*
* @param int $uid 用户ID
* @param int $addressId 地址ID
* @param int $cartType 购物车类型ID
* @param int $deliveryTime 寄送时间ID
* @param int $deliveryWay 寄送方式ID
* @param string $invoiceTitle 发票说明
* @param int $invoiceId 发票类型ID
* @param int $paymentId 支付方式ID
* @param int $paymentType 支付类型ID
* @param string $remark 留言
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量或为空
* @return array 接口返回的数据
*/
public
static
function
orderSub
(
$uid
,
$addressId
,
$cartType
,
$deliveryTime
,
$deliveryWay
,
$invoiceTitle
,
$invoiceId
,
$paymentId
,
$paymentType
,
$remark
,
$couponCode
,
$yohoCoin
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦'
);
if
(
empty
(
$addressId
))
{
$result
[
'code'
]
=
401
;
$result
[
'message'
]
=
'配送地址不能为空'
;
}
elseif
(
empty
(
$deliveryTime
))
{
$result
[
'code'
]
=
402
;
$result
[
'message'
]
=
'请选择配送时间'
;
}
elseif
(
empty
(
$deliveryWay
))
{
$result
[
'code'
]
=
403
;
$result
[
'message'
]
=
'请选择配送方式'
;
}
else
{
$orderSubRes
=
CartData
::
orderSub
(
$uid
,
$addressId
,
$cartType
,
$deliveryTime
,
$deliveryWay
,
$invoiceTitle
,
$invoiceId
,
$paymentId
,
$paymentType
,
$remark
,
$couponCode
,
$yohoCoin
);
// 优惠券数据
$coupons
=
array
();
!
empty
(
$orderCompute
[
'coupon_amount'
])
&&
$coupons
[
'value'
]
=
$orderInfo
[
'couponValue'
];
$coupons
+=
self
::
getCouponList
(
$uid
,
true
);
$result
[
'coupon'
]
=
$coupons
;
}
return
$result
;
}
/**
* 购物车结算--支付方式和配送方式选择以及是否使用YOHO币接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param int $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量
* @return array 接口返回的数据
*/
public
static
function
orderCompute
(
$uid
,
$cartType
,
$deliveryWay
,
$paymentType
,
$couponCode
,
$yohoCoin
)
{
$result
=
array
();
$compute
=
CartData
::
orderCompute
(
$uid
,
$cartType
,
$deliveryWay
,
$paymentType
,
$couponCode
,
$yohoCoin
);
if
(
$compute
&&
isset
(
$compute
[
'code'
])
&&
$compute
[
'code'
]
===
200
)
{
$result
=
$compute
[
'data'
];
}
return
$result
;
}
/**
* 购物车结算--输入优惠券代码返回的结果处理
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public
static
function
searchCoupon
(
$uid
,
$couponCode
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
$coupon
=
CartData
::
searchCoupon
(
$uid
,
$couponCode
);
if
(
$coupon
&&
isset
(
$coupon
[
'code'
]))
{
$result
=
$coupon
;
}
return
$result
;
}
/**
* 处理优惠券列表数据
*
* @param int $uid 用户ID
* @param boolean $onlyTotal 只返回总数
* @return array|mixed 处理之后的优惠券数据
*/
public
static
function
getCouponList
(
$uid
,
$onlyTotal
=
false
)
{
$result
=
array
();
// 调用接口获取优惠券数据
$coupons
=
CartData
::
getCouponList
(
$uid
);
// 处理优惠券数据
if
(
isset
(
$coupons
[
'data'
]))
{
if
(
$onlyTotal
)
{
$result
[
'count'
]
=
count
(
$coupons
[
'data'
][
'couponList'
]);
}
else
{
$couponArr
=
array
();
isset
(
$coupons
[
'data'
][
'couponList'
])
&&
$couponArr
=
$coupons
[
'data'
][
'couponList'
];
foreach
(
$couponArr
as
&
$val
)
{
$notAvailableRes
=
self
::
searchCoupon
(
$uid
,
$val
[
'couponCode'
]);
// 处理可用的优惠券
if
(
isset
(
$notAvailableRes
[
'code'
])
&&
$notAvailableRes
[
'code'
]
!==
200
)
{
$val
[
'notAvailable'
]
=
true
;
}
}
!
empty
(
$couponArr
)
&&
$result
=
$couponArr
;
}
}
return
$result
;
}
/**
* 购物车结算--提交结算信息
*
* @param int $uid 用户ID
* @param int $addressId 地址ID
* @param int $cartType 购物车类型ID
* @param int $deliveryTime 寄送时间ID
* @param int $deliveryWay 寄送方式ID
* @param string $invoiceTitle 发票说明
* @param int $invoiceId 发票类型ID
* @param int $paymentId 支付方式ID
* @param int $paymentType 支付类型ID
* @param string $remark 留言
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量或为空
* @return array 接口返回的数据
*/
public
static
function
orderSub
(
$uid
,
$addressId
,
$cartType
,
$deliveryTime
,
$deliveryWay
,
$invoiceTitle
,
$invoiceId
,
$paymentId
,
$paymentType
,
$remark
,
$couponCode
,
$yohoCoin
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦'
);
if
(
empty
(
$addressId
))
{
$result
[
'code'
]
=
401
;
$result
[
'message'
]
=
'配送地址不能为空'
;
}
elseif
(
empty
(
$deliveryTime
))
{
$result
[
'code'
]
=
402
;
$result
[
'message'
]
=
'请选择配送时间'
;
}
elseif
(
empty
(
$deliveryWay
))
{
$result
[
'code'
]
=
403
;
$result
[
'message'
]
=
'请选择配送方式'
;
}
else
{
$orderSubRes
=
CartData
::
orderSub
(
$uid
,
$addressId
,
$cartType
,
$deliveryTime
,
$deliveryWay
,
$invoiceTitle
,
$invoiceId
,
$paymentId
,
$paymentType
,
$remark
,
$couponCode
,
$yohoCoin
);
if
(
$orderSubRes
&&
isset
(
$orderSubRes
[
'code'
]))
{
$result
=
$orderSubRes
;
}
}
return
$result
;
}
/**
* 处理不同类型的购物车数据
*
* @param array $data 不同类型购物车数据
* @param bool $onlyGift 只获取赠品的商品数据
* @param bool $onlyAdvanceBuy 只获取加价购的商品数据
* @return array $result 处理之后的不同类型购物车数据
*/
private
static
function
procCartData
(
$data
,
$onlyGift
=
false
,
$onlyAdvanceBuy
=
false
)
{
$result
=
array
();
if
(
!
$onlyAdvanceBuy
)
{
// 赠品
$result
[
'giftCount'
]
=
0
;
$result
[
'freebie'
]
=
Helpers
::
formatAdvanceGoods
(
$data
[
'gift_list'
],
$result
[
'giftCount'
]);
}
if
(
!
$onlyGift
)
{
// 加价购
$result
[
'advanceBuyCount'
]
=
0
;
$result
[
'advanceBuy'
]
=
Helpers
::
formatAdvanceGoods
(
$data
[
'price_gift'
],
$result
[
'advanceBuyCount'
]);
}
if
(
!
$onlyGift
&&
!
$onlyAdvanceBuy
)
{
// 购买的可用商品列表
$validGoods
=
Helpers
::
formatCartGoods
(
$data
[
'goods_list'
]);
!
empty
(
$validGoods
)
&&
$result
[
'goods'
]
=
$validGoods
;
// 失效商品列表
$notValidGoods
=
Helpers
::
formatCartGoods
(
$data
[
'sold_out_goods_list'
]);
!
empty
(
$notValidGoods
)
&&
$result
[
'$notValidGoods'
]
=
$notValidGoods
;
// 赠品和加价购商品
(
count
(
$data
[
'gift_list'
])
||
count
(
$data
[
'price_gift'
]))
&&
$result
[
'freebieOrAdvanceBuy'
]
=
true
;
// 结算数据
$result
[
'price'
]
=
Helpers
::
transPrice
(
$data
[
'shopping_cart_data'
][
'order_amount'
]);
$result
[
'activityPrice'
]
=
Helpers
::
transPrice
(
$data
[
'shopping_cart_data'
][
'discount_amount'
]);
$result
[
'count'
]
=
$data
[
'shopping_cart_data'
][
'goods_count'
];
$result
[
'sumPrice'
]
=
Helpers
::
transPrice
(
$data
[
'shopping_cart_data'
][
'order_amount'
]);
}
return
$result
;
}
$result
=
$orderSubRes
;
}
}
return
$result
;
}
/**
* 处理不同类型的购物车数据
*
* @param array $data 不同类型购物车数据
* @param bool $onlyGift 只获取赠品的商品数据
* @param bool $onlyAdvanceBuy 只获取加价购的商品数据
* @return array $result 处理之后的不同类型购物车数据
*/
private
static
function
procCartData
(
$data
,
$onlyGift
=
false
,
$onlyAdvanceBuy
=
false
)
{
$result
=
array
();
if
(
!
$onlyAdvanceBuy
)
{
// 赠品
$result
[
'giftCount'
]
=
0
;
$result
[
'freebie'
]
=
Helpers
::
formatAdvanceGoods
(
$data
[
'gift_list'
],
$result
[
'giftCount'
]);
}
if
(
!
$onlyGift
)
{
// 加价购
$result
[
'advanceBuyCount'
]
=
0
;
$result
[
'advanceBuy'
]
=
Helpers
::
formatAdvanceGoods
(
$data
[
'price_gift'
],
$result
[
'advanceBuyCount'
]);
}
if
(
!
$onlyGift
&&
!
$onlyAdvanceBuy
)
{
// 购买的可用商品列表
$validGoods
=
Helpers
::
formatCartGoods
(
$data
[
'goods_list'
]);
!
empty
(
$validGoods
)
&&
$result
[
'goods'
]
=
$validGoods
;
// 失效商品列表
$notValidGoods
=
Helpers
::
formatCartGoods
(
$data
[
'sold_out_goods_list'
]);
!
empty
(
$notValidGoods
)
&&
$result
[
'$notValidGoods'
]
=
$notValidGoods
;
// 赠品和加价购商品
(
count
(
$data
[
'gift_list'
])
||
count
(
$data
[
'price_gift'
]))
&&
$result
[
'freebieOrAdvanceBuy'
]
=
true
;
// 结算数据
$result
[
'price'
]
=
Helpers
::
transPrice
(
$data
[
'shopping_cart_data'
][
'order_amount'
]);
$result
[
'activityPrice'
]
=
Helpers
::
transPrice
(
$data
[
'shopping_cart_data'
][
'discount_amount'
]);
$result
[
'count'
]
=
$data
[
'shopping_cart_data'
][
'goods_count'
];
$result
[
'sumPrice'
]
=
Helpers
::
transPrice
(
$data
[
'shopping_cart_data'
][
'order_amount'
]);
}
return
$result
;
}
}
...
...
Please
register
or
login
to post a comment