Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
hf
9 years ago
Commit
58104402b3b2bdfcb2363c650530460849a01e97
1 parent
c1874766
do add shopping cart action
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
978 additions
and
931 deletions
library/LibModels/Wap/Home/CartData.php
library/Plugin/Helpers.php
yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
library/LibModels/Wap/Home/CartData.php
View file @
5810440
...
...
@@ -17,255 +17,257 @@ use Api\Yohobuy;
class
CartData
{
/**
* 加入购物车接口
*
* @param int $productSku 商品SKU
* @param int $buyNumber 购买数量
* @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int 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
=
0
,
$promotionId
=
null
,
$uid
=
null
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.add'
;
$param
[
'product_sku'
]
=
$productSku
;
$param
[
'buy_number'
]
=
$buyNumber
;
$param
[
'goods_type'
]
=
$goodsType
;
$param
[
'edit_product_sku'
]
=
$isEdit
;
$param
[
'selected'
]
=
'Y'
;
$param
[
'promotion_id'
]
=
$promotionId
;
if
(
$uid
!==
null
)
{
$param
[
'uid'
]
=
$uid
;
}
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 购物车数据
*
* @param int $uid 用户ID
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 购物车接口返回的数据
*/
public
static
function
cartData
(
$uid
,
$shoppingKey
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.cart'
;
if
(
!
empty
(
$uid
))
{
$param
[
'uid'
]
=
$uid
;
}
if
(
!
empty
(
$shoppingKey
))
{
$param
[
'shopping_key'
]
=
$shoppingKey
;
}
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public
static
function
removeFromCart
(
$uid
,
$sku
,
$shoppingKey
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.remove'
;
$param
[
'product_sku_list'
]
=
$sku
;
if
(
!
empty
(
$uid
))
{
$param
[
'uid'
]
=
$uid
;
}
if
(
!
empty
(
$shoppingKey
))
{
$param
[
'shopping_key'
]
=
$shoppingKey
;
}
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public
static
function
addToFav
(
$uid
,
$sku
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.addfavorite'
;
$param
[
'product_sku_list'
]
=
$sku
;
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 获取购物车商品数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @return array 接口返回的数据
*/
public
static
function
cartProductData
(
$uid
,
$skn
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.product.data'
;
$param
[
'product_skn'
]
=
$skn
;
$param
[
'showcomment'
]
=
'N'
;
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 获取加价购商品数据
*
* @param int $skn 商品skn
* @param int $promotionId 加价购商品促销ID
* @return array 接口返回的数据
*/
public
static
function
giftProductData
(
$skn
,
$promotionId
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.product.gift'
;
$param
[
'product_skn'
]
=
$skn
;
$param
[
'promotion_id'
]
=
$promotionId
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $swapData 商品数据
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public
static
function
modifyCartProduct
(
$uid
,
$swapData
,
$shoppingKey
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.swap'
;
$param
[
'swap_data'
]
=
$swapData
;
if
(
!
empty
(
$uid
))
{
$param
[
'uid'
]
=
$uid
;
}
if
(
$shoppingKey
!==
null
)
{
$param
[
'shopping_key'
]
=
$shoppingKey
;
}
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 购物车结算
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @return array 接口返回的数据
*/
public
static
function
cartPay
(
$uid
,
$cartType
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.payment'
;
$param
[
'cart_type'
]
=
$cartType
;
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 购物车结算--支付方式和配送方式选择
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param string $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param string $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $yohoCoin 使用的YOHO币数量,默认为null表示不适用
* @return array 接口返回的数据
*/
public
static
function
paymentTypeAndDelivery
(
$uid
,
$cartType
,
$deliveryWay
,
$paymentType
,
$yohoCoin
=
null
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.compute'
;
$param
[
'cart_type'
]
=
$cartType
;
$param
[
'delivery_way'
]
=
$deliveryWay
;
$param
[
'payment_type'
]
=
$paymentType
;
if
(
$yohoCoin
!==
null
)
{
$param
[
'use_yoho_coin'
]
=
$yohoCoin
;
}
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 购物车结算--使用优惠券
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public
static
function
getCoupon
(
$uid
,
$couponCode
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.useCoupon'
;
$param
[
'coupon_code'
]
=
$couponCode
;
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 购物车结算--提交结算信息
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public
static
function
orderSub
(
$uid
,
$addressId
,
$cartType
,
$deliveryTime
,
$deliveryWay
,
$invoiceTitle
,
$invoiceId
,
$paymentId
,
$paymentType
,
$remark
,
$yohoCoin
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.submit'
;
$param
[
'addressId'
]
=
$addressId
;
$param
[
'cart_type'
]
=
$cartType
;
$param
[
'delivery_time'
]
=
$deliveryTime
;
$param
[
'delivery_way'
]
=
$deliveryWay
;
$param
[
'invoices_title'
]
=
$invoiceTitle
;
$param
[
'invoices_type_id'
]
=
$invoiceId
;
$param
[
'payment_id'
]
=
$paymentId
;
$param
[
'payment_type'
]
=
$paymentType
;
$param
[
'remark'
]
=
$remark
;
$param
[
'use_yoho_coin'
]
=
$yohoCoin
;
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 加入购物车接口
*
* @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,可以不传
* @param string $shoppingKey 购物的凭证
* @return array 加入购物车接口返回的数据
*/
public
static
function
addToCart
(
$productSku
,
$buyNumber
,
$goodsType
,
$isEdit
=
0
,
$promotionId
=
null
,
$uid
=
null
,
$shoppingKey
=
''
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.add'
;
$param
[
'product_sku'
]
=
$productSku
;
$param
[
'buy_number'
]
=
$buyNumber
;
$param
[
'goods_type'
]
=
$goodsType
;
$param
[
'edit_product_sku'
]
=
$isEdit
;
$param
[
'selected'
]
=
'Y'
;
$param
[
'promotion_id'
]
=
$promotionId
;
$param
[
'shopping_key'
]
=
$shoppingKey
;
if
(
!
empty
(
$uid
))
{
$param
[
'uid'
]
=
$uid
;
}
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 购物车数据
*
* @param int $uid 用户ID
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 购物车接口返回的数据
*/
public
static
function
cartData
(
$uid
,
$shoppingKey
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.cart'
;
if
(
!
empty
(
$uid
))
{
$param
[
'uid'
]
=
$uid
;
}
if
(
!
empty
(
$shoppingKey
))
{
$param
[
'shopping_key'
]
=
$shoppingKey
;
}
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 移出购物车
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public
static
function
removeFromCart
(
$uid
,
$sku
,
$shoppingKey
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.remove'
;
$param
[
'product_sku_list'
]
=
$sku
;
if
(
!
empty
(
$uid
))
{
$param
[
'uid'
]
=
$uid
;
}
if
(
!
empty
(
$shoppingKey
))
{
$param
[
'shopping_key'
]
=
$shoppingKey
;
}
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 移入收藏夹
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public
static
function
addToFav
(
$uid
,
$sku
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.addfavorite'
;
$param
[
'product_sku_list'
]
=
$sku
;
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 获取购物车商品数据
*
* @param int $uid 用户ID
* @param int $skn 商品skn
* @return array 接口返回的数据
*/
public
static
function
cartProductData
(
$uid
,
$skn
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.product.data'
;
$param
[
'product_skn'
]
=
$skn
;
$param
[
'showcomment'
]
=
'N'
;
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 获取加价购商品数据
*
* @param int $skn 商品skn
* @param int $promotionId 加价购商品促销ID
* @return array 接口返回的数据
*/
public
static
function
giftProductData
(
$skn
,
$promotionId
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.product.gift'
;
$param
[
'product_skn'
]
=
$skn
;
$param
[
'promotion_id'
]
=
$promotionId
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
* @param string $swapData 商品数据
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public
static
function
modifyCartProduct
(
$uid
,
$swapData
,
$shoppingKey
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.swap'
;
$param
[
'swap_data'
]
=
$swapData
;
if
(
!
empty
(
$uid
))
{
$param
[
'uid'
]
=
$uid
;
}
if
(
$shoppingKey
!==
null
)
{
$param
[
'shopping_key'
]
=
$shoppingKey
;
}
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 购物车结算
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @return array 接口返回的数据
*/
public
static
function
cartPay
(
$uid
,
$cartType
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.payment'
;
$param
[
'cart_type'
]
=
$cartType
;
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 购物车结算--支付方式和配送方式选择
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param string $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param string $paymentType 支付方式,1表示在线支付,2表示货到付款
* @param string $yohoCoin 使用的YOHO币数量,默认为null表示不适用
* @return array 接口返回的数据
*/
public
static
function
paymentTypeAndDelivery
(
$uid
,
$cartType
,
$deliveryWay
,
$paymentType
,
$yohoCoin
=
null
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.compute'
;
$param
[
'cart_type'
]
=
$cartType
;
$param
[
'delivery_way'
]
=
$deliveryWay
;
$param
[
'payment_type'
]
=
$paymentType
;
if
(
$yohoCoin
!==
null
)
{
$param
[
'use_yoho_coin'
]
=
$yohoCoin
;
}
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 购物车结算--使用优惠券
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public
static
function
getCoupon
(
$uid
,
$couponCode
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.useCoupon'
;
$param
[
'coupon_code'
]
=
$couponCode
;
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 购物车结算--提交结算信息
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public
static
function
orderSub
(
$uid
,
$addressId
,
$cartType
,
$deliveryTime
,
$deliveryWay
,
$invoiceTitle
,
$invoiceId
,
$paymentId
,
$paymentType
,
$remark
,
$yohoCoin
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.submit'
;
$param
[
'addressId'
]
=
$addressId
;
$param
[
'cart_type'
]
=
$cartType
;
$param
[
'delivery_time'
]
=
$deliveryTime
;
$param
[
'delivery_way'
]
=
$deliveryWay
;
$param
[
'invoices_title'
]
=
$invoiceTitle
;
$param
[
'invoices_type_id'
]
=
$invoiceId
;
$param
[
'payment_id'
]
=
$paymentId
;
$param
[
'payment_type'
]
=
$paymentType
;
$param
[
'remark'
]
=
$remark
;
$param
[
'use_yoho_coin'
]
=
$yohoCoin
;
$param
[
'uid'
]
=
$uid
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
}
...
...
library/Plugin/Helpers.php
View file @
5810440
...
...
@@ -123,6 +123,17 @@ class Helpers
}
/**
* 从用户加入购物车的COOKIE取出购物车凭证
*
* @return string
*/
public
static
function
getShoppingKeyByCookie
()
{
$cookie
=
isset
(
$_COOKIE
[
'_spk'
])
?
$_COOKIE
[
'_spk'
]
:
''
;
return
$cookie
;
}
/**
* 获取商品的ICON
*
* @param int $type
...
...
@@ -171,16 +182,16 @@ class Helpers
return
$result
;
}
/**
* 转换价格
*
* @param float|string $price 价格
* @return float|string 转换之后的价格
*/
public
static
function
transPrice
(
$price
)
{
return
(
!
empty
(
$price
)
&&
!
is_float
(
$price
))
?
$price
.
'.00'
:
$price
;
}
/**
* 转换价格
*
* @param float|string $price 价格
* @return float|string 转换之后的价格
*/
public
static
function
transPrice
(
$price
)
{
return
(
!
empty
(
$price
)
&&
!
is_float
(
$price
))
?
$price
.
'.00'
:
$price
;
}
/**
* 格式化商品信息
...
...
@@ -225,8 +236,8 @@ class Helpers
}
$result
[
'is_soon_sold_out'
]
=
(
$productData
[
'is_soon_sold_out'
]
===
'Y'
);
$result
[
'url'
]
=
self
::
url
(
'/product/pro_'
.
$productData
[
'product_id'
]
.
'_'
.
$productData
[
'goods_list'
][
0
][
'goods_id'
]
.
'/'
.
$productData
[
'cn_alphabet'
]
.
'.html'
);
.
$productData
[
'goods_list'
][
0
][
'goods_id'
]
.
'/'
.
$productData
[
'cn_alphabet'
]
.
'.html'
);
// APP访问需要加附加的参数
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if
(
$isApp
)
{
...
...
@@ -515,7 +526,7 @@ class Helpers
public
static
function
formatOrderGoods
(
$orderGoods
,
&
$count
=
0
,
$haveLink
=
false
)
{
$arr
=
array
();
foreach
(
$orderGoods
as
$key
=>
$vo
)
{
$arr
[
$key
][
'thumb'
]
=
Helpers
::
getImageUrl
(
$vo
[
'goods_image'
],
90
,
120
);
$arr
[
$key
][
'name'
]
=
$vo
[
'product_name'
];
...
...
@@ -540,7 +551,7 @@ class Helpers
// 累计购买数
$count
+=
intval
(
$vo
[
'buy_number'
]);
}
return
$arr
;
}
...
...
yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php
View file @
5810440
...
...
@@ -10,217 +10,254 @@ use Plugin\Helpers;
*/
class
ShoppingCartController
extends
AbstractAction
{
/*
* 购物车首页
*/
/*
* 购物车首页
*/
public
function
indexAction
()
{
$this
->
setTitle
(
'购物车'
);
$this
->
setNavHeader
(
'购物车'
);
$shoppingKey
=
$this
->
getSession
(
'shoppingKey'
);
$uid
=
$this
->
getUid
(
true
);
$shoppingKey
=
Helpers
::
getShoppingKeyByCookie
();
$uid
=
$this
->
getUid
(
true
);
$data
=
array
(
'shoppingCartPage'
=>
true
,
'shoppingCart'
=>
CartModel
::
getCartData
(
$uid
,
$shoppingKey
)
'shoppingCartPage'
=>
true
,
'shoppingCart'
=>
CartModel
::
getCartData
(
$uid
,
$shoppingKey
)
);
// 渲染模板
$this
->
_view
->
display
(
'index'
,
$data
);
}
/**
* 移出购物车
*/
public
function
delAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$productId
=
$this
->
post
(
'id'
,
0
);
$uid
=
$this
->
getUid
(
true
);
$shoppingKey
=
$this
->
getSession
(
'shoppingKey'
);
$result
=
CartModel
::
removeFromCart
(
$uid
,
$productId
,
$shoppingKey
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 移入收藏夹
*/
public
function
colAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$productId
=
$this
->
post
(
'id'
,
0
);
$uid
=
$this
->
getUid
(
true
);
$result
=
CartModel
::
addToFav
(
$uid
,
$productId
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/*
* 获取购物车商品数据
*/
public
function
goodinfoAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$num
=
$this
->
get
(
'buy_num'
,
1
);
$skn
=
$this
->
get
(
'id'
,
1
);
$uid
=
$this
->
getUid
(
true
);
$result
=
CartModel
::
cartProductData
(
$uid
,
$skn
,
$num
);
// 测试skn的ID为51172055
$result
[
'num'
]
=
$num
;
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/*
* 获取购物车加价购商品数据
*/
public
function
giftinfoAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$skn
=
$this
->
get
(
'skn'
,
null
);
$promotionId
=
$this
->
get
(
'promotionId'
,
null
);
$result
=
CartModel
::
giftProductData
(
$skn
,
$promotionId
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 修改购物车商品数据
*/
public
function
modifyAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$shoppingKey
=
$this
->
getSession
(
'shoppingKey'
);
$uid
=
$this
->
getUid
(
true
);
$params
=
array
();
$params
[
'old_product_sku'
]
=
$this
->
post
(
'old_product_sku'
,
0
);
$params
[
'new_product_sku'
]
=
$this
->
post
(
'new_product_sku'
,
0
);
$params
[
'buy_number'
]
=
$this
->
post
(
'buy_number'
,
0
);
$params
[
'selected'
]
=
$this
->
post
(
'selected'
,
null
);
$result
=
CartModel
::
modifyCartProduct
(
$uid
,
$params
,
$shoppingKey
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 购物车结算请求
*/
public
function
payAction
()
{
$this
->
setTitle
(
'购物车'
);
$this
->
setNavHeader
(
'购物车'
);
$cartType
=
$this
->
post
(
'cartType'
,
'ordinary'
);
$uid
=
$this
->
getUid
(
true
);
$data
=
array
(
'orderEnsurePage'
=>
true
,
'orderEnsure'
=>
CartModel
::
cartPay
(
$uid
,
$cartType
)
);
$this
->
_view
->
display
(
'order-ensure'
,
$data
);
}
/**
* 购物车选择支付方式和配送方式接口
*/
public
function
payAndDeliveryAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$cartType
=
$this
->
post
(
'cartType'
,
'ordinary'
);
$deliveryWay
=
$this
->
post
(
'deliveryWay'
,
1
);
$paymentType
=
$this
->
post
(
'paymentType'
,
1
);
$uid
=
$this
->
getUid
(
true
);
$result
=
CartModel
::
paymentTypeAndDelivery
(
$uid
,
$cartType
,
$deliveryWay
,
$paymentType
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 购物车输入优惠券码使用优惠券
*/
public
function
couponAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$couponCode
=
$this
->
post
(
'couponCode'
,
''
);
$uid
=
$this
->
getUid
(
true
);
$result
=
CartModel
::
getCoupon
(
$uid
,
$couponCode
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 购物车使用YOHO币
*/
public
function
yohoCoinAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$cartType
=
$this
->
post
(
'cartType'
,
'ordinary'
);
$deliveryWay
=
$this
->
post
(
'deliveryWay'
,
1
);
$paymentType
=
$this
->
post
(
'paymentType'
,
1
);
$yohoCoin
=
$this
->
post
(
'yohoCoin'
,
1
);
$result
=
CartModel
::
paymentTypeAndDelivery
(
$this
->
_uid
,
$cartType
,
$deliveryWay
,
$paymentType
,
$yohoCoin
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 加入购物车
*
* @param string productSku 商品的SKU
* @param int buyNumber 购买数量
* @param int promotionId 促销ID, 加价购有关
* @param int goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int isEdit 是否是编辑商品SKU,0表示不是编辑
* @return json
*/
public
function
addAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$shoppingKey
=
Helpers
::
getShoppingKeyByCookie
();
$productSku
=
$this
->
post
(
'productSku'
);
$buyNumber
=
$this
->
post
(
'buyNumber'
,
1
);
$goodsType
=
$this
->
post
(
'goodsType'
,
0
);
$promotionId
=
$this
->
post
(
'promotionId'
,
0
);
$isEdit
=
$this
->
post
(
'isEdit'
,
0
);
$uid
=
$this
->
getUid
(
true
);
// 执行加入购物车操作
$result
=
CartModel
::
addToCart
(
$productSku
,
$buyNumber
,
$goodsType
,
$isEdit
,
$promotionId
,
$uid
,
$shoppingKey
);
// 设置加入购物车凭证到客户端浏览器
if
(
isset
(
$result
[
'data'
][
'shopping_key'
]))
{
$this
->
setCookie
(
'_spk'
,
$shoppingKey
);
}
}
$this
->
echoJson
(
$result
);
}
/**
* 移出购物车
*/
public
function
delAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$productId
=
$this
->
post
(
'id'
,
0
);
$uid
=
$this
->
getUid
(
true
);
$shoppingKey
=
Helpers
::
getShoppingKeyByCookie
();
$result
=
CartModel
::
removeFromCart
(
$uid
,
$productId
,
$shoppingKey
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 移入收藏夹
*/
public
function
colAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$productId
=
$this
->
post
(
'id'
,
0
);
$uid
=
$this
->
getUid
(
true
);
$result
=
CartModel
::
addToFav
(
$uid
,
$productId
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/*
* 获取购物车商品数据
*/
public
function
goodinfoAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$num
=
$this
->
get
(
'buy_num'
,
1
);
$skn
=
$this
->
get
(
'id'
,
1
);
$uid
=
$this
->
getUid
(
true
);
$result
=
CartModel
::
cartProductData
(
$uid
,
$skn
,
$num
);
// 测试skn的ID为51172055
$result
[
'num'
]
=
$num
;
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/*
* 获取购物车加价购商品数据
*/
public
function
giftinfoAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$skn
=
$this
->
get
(
'skn'
,
null
);
$promotionId
=
$this
->
get
(
'promotionId'
,
null
);
$result
=
CartModel
::
giftProductData
(
$skn
,
$promotionId
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 修改购物车商品数据
*/
public
function
modifyAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$shoppingKey
=
Helpers
::
getShoppingKeyByCookie
();
$uid
=
$this
->
getUid
(
true
);
$params
=
array
();
$params
[
'old_product_sku'
]
=
$this
->
post
(
'old_product_sku'
,
0
);
$params
[
'new_product_sku'
]
=
$this
->
post
(
'new_product_sku'
,
0
);
$params
[
'buy_number'
]
=
$this
->
post
(
'buy_number'
,
0
);
$params
[
'selected'
]
=
$this
->
post
(
'selected'
,
null
);
$result
=
CartModel
::
modifyCartProduct
(
$uid
,
$params
,
$shoppingKey
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 购物车结算请求
*/
public
function
payAction
()
{
$this
->
setTitle
(
'购物车'
);
$this
->
setNavHeader
(
'购物车'
);
$cartType
=
$this
->
post
(
'cartType'
,
'ordinary'
);
$uid
=
$this
->
getUid
(
true
);
$data
=
array
(
'orderEnsurePage'
=>
true
,
'orderEnsure'
=>
CartModel
::
cartPay
(
$uid
,
$cartType
)
);
$this
->
_view
->
display
(
'order-ensure'
,
$data
);
}
/**
* 购物车选择支付方式和配送方式接口
*/
public
function
payAndDeliveryAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$cartType
=
$this
->
post
(
'cartType'
,
'ordinary'
);
$deliveryWay
=
$this
->
post
(
'deliveryWay'
,
1
);
$paymentType
=
$this
->
post
(
'paymentType'
,
1
);
$uid
=
$this
->
getUid
(
true
);
$result
=
CartModel
::
paymentTypeAndDelivery
(
$uid
,
$cartType
,
$deliveryWay
,
$paymentType
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 购物车输入优惠券码使用优惠券
*/
public
function
couponAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$couponCode
=
$this
->
post
(
'couponCode'
,
''
);
$uid
=
$this
->
getUid
(
true
);
$result
=
CartModel
::
getCoupon
(
$uid
,
$couponCode
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 购物车使用YOHO币
*/
public
function
yohoCoinAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$cartType
=
$this
->
post
(
'cartType'
,
'ordinary'
);
$deliveryWay
=
$this
->
post
(
'deliveryWay'
,
1
);
$paymentType
=
$this
->
post
(
'paymentType'
,
1
);
$yohoCoin
=
$this
->
post
(
'yohoCoin'
,
1
);
$result
=
CartModel
::
paymentTypeAndDelivery
(
$this
->
_uid
,
$cartType
,
$deliveryWay
,
$paymentType
,
$yohoCoin
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
public
function
giftAdvanceAction
()
{
...
...
@@ -267,9 +304,10 @@ class ShoppingCartController extends AbstractAction
'navBack'
=>
true
,
'navTitle'
=>
'加价购'
),
'shoppingCart'
=>
$data
));
}
/*
* 确认订单
*/
/*
* 确认订单
*/
public
function
orderEnsureAction
()
{
$data
=
array
(
...
...
@@ -342,8 +380,8 @@ class ShoppingCartController extends AbstractAction
/**
* 下单流程 选择地址
*/
public
function
selectAddressAction
()
{
public
function
selectAddressAction
()
{
// 设置网站标题
$this
->
setTitle
(
'选择地址'
);
$this
->
setNavHeader
(
'选择地址'
,
Helpers
::
url
(
'/shoppingCart/orderEnsure'
));
...
...
@@ -356,14 +394,13 @@ class ShoppingCartController extends AbstractAction
'pageFooter'
=>
true
,
'address'
=>
$address
));
}
/**
* 下单流程 选择优惠券
*/
public
function
selectCouponAction
()
{
public
function
selectCouponAction
()
{
// 设置网站标题
$this
->
setTitle
(
'选择优惠券'
);
$this
->
setNavHeader
(
'选择优惠券'
,
Helpers
::
url
(
'/shoppingCart/orderEnsure'
));
...
...
@@ -376,6 +413,6 @@ class ShoppingCartController extends AbstractAction
'pageFooter'
=>
true
,
'address'
=>
$address
));
}
}
...
...
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
View file @
5810440
...
...
@@ -3,7 +3,6 @@
namespace
Index
;
use
LibModels\Wap\Home\CartData
;
use
LibModels\Wap\Home\UserData
;
use
Plugin\Helpers
;
use
Plugin\Images
;
...
...
@@ -18,465 +17,463 @@ use Plugin\Images;
class
CartModel
{
/**
* 加入购物车
*
* @param int $productSku 商品SKU
* @param int $buyNumber 购买数量
* @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int 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 未登录用户唯一识别码
* @return array|mixed 处理之后的购物车数据
*/
public
static
function
getCartData
(
$uid
,
$shoppingKey
)
{
$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'
]
=
count
(
$cart
[
'ordinary_cart_data'
][
'goods_list'
]);
$result
[
'commonCart'
]
=
self
::
procCartData
(
$cart
[
'ordinary_cart_data'
]);
}
/* 预售购物车 */
if
(
isset
(
$cart
[
'advance_cart_data'
]))
{
$result
[
'presellGoodsCount'
]
=
count
(
$cart
[
'advance_cart_data'
][
'goods_list'
]);
$result
[
'preSellCart'
]
=
self
::
procCartData
(
$cart
[
'advance_cart_data'
]);
}
}
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表示普通购物车
* @return array 接口返回的数据
*/
public
static
function
cartPay
(
$uid
,
$cartType
)
{
$result
=
array
();
$pay
=
CartData
::
cartPay
(
$uid
,
$cartType
);
if
(
$pay
&&
isset
(
$pay
[
'code'
])
&&
$pay
[
'code'
]
===
200
)
{
$payReturn
=
$pay
[
'data'
];
$result
=
array
();
// 收货人有关信息
if
(
isset
(
$payReturn
[
'delivery_address'
])
&&
!
empty
(
$payReturn
[
'delivery_address'
]))
{
$result
[
'name'
]
=
$payReturn
[
'delivery_address'
][
'consignee'
];
$result
[
'phoneNum'
]
=
$payReturn
[
'delivery_address'
][
'mobile'
]
?:
$payReturn
[
'delivery_address'
][
'phone'
];
$result
[
'address'
]
=
$payReturn
[
'delivery_address'
][
'address'
];
}
// 配送方式
if
(
isset
(
$payReturn
[
'delivery_way'
]))
{
$oneDeliv
=
array
();
foreach
(
$payReturn
[
'delivery_way'
]
as
$val
)
{
$oneDeliv
=
array
();
$oneDeliv
[
'id'
]
=
$val
[
'delivery_way_id'
];
$oneDeliv
[
'name'
]
=
$val
[
'delivery_way_name'
];
$oneDeliv
[
'default'
]
=
(
$val
[
'default'
]
===
'Y'
);
$result
[
'dispatchMode'
][]
=
$oneDeliv
;
}
}
// 配送时间
if
(
isset
(
$payReturn
[
'delivery_time'
]))
{
$oneDelivTime
=
array
();
foreach
(
$payReturn
[
'delivery_time'
]
as
$one
)
{
$oneDelivTime
=
array
();
$oneDelivTime
[
'id'
]
=
$one
[
'delivery_time_id'
];
$oneDelivTime
[
'name'
]
=
$one
[
'delivery_time_string'
];
$oneDelivTime
[
'default'
]
=
(
$one
[
'default'
]
===
'Y'
);
$result
[
'dispatchTime'
][]
=
$oneDelivTime
;
}
}
// 订单商品
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
[
'real_price'
]);
// last_price有些带.00,有些不带,real_price都不带.00
$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'
]
=
$payReturn
[
'yoho_coin'
];
// 订单数据
if
(
isset
(
$payReturn
[
'shopping_cart_data'
])
&&
!
empty
(
$payReturn
[
'shopping_cart_data'
]))
{
$result
[
'sumPrice'
]
=
Helpers
::
transPrice
(
$payReturn
[
'shopping_cart_data'
][
'order_amount'
]);
$result
[
'salePrice'
]
=
Helpers
::
transPrice
(
$payReturn
[
'shopping_cart_data'
][
'discount_amount'
]);
$result
[
'price'
]
=
Helpers
::
transPrice
(
$payReturn
[
'shopping_cart_data'
][
'last_order_amount'
]);
$result
[
'freight'
]
=
Helpers
::
transPrice
(
$payReturn
[
'shopping_cart_data'
][
'shipping_cost'
]);
}
// 发票有关数据
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
[
'invoice'
][]
=
$one
;
}
}
// 优惠券数据
$coupons
=
array
(
'notUsed'
=>
true
);
$coupons
+=
UserModel
::
getCouponData
(
$uid
,
0
,
1
,
true
);
$result
[
'coupon'
]
=
$coupons
;
}
return
$result
;
}
/**
* 购物车结算--支付方式和配送方式选择以及是否使用YOHO币接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param string $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param string $paymentType 支付方式,1表示在线支付,2表示货到付款
* @return array 接口返回的数据
*/
public
static
function
paymentTypeAndDelivery
(
$uid
,
$cartType
,
$deliveryWay
,
$paymentType
)
{
$result
=
array
();
$pay
=
CartData
::
paymentTypeAndDelivery
(
$uid
,
$cartType
,
$deliveryWay
,
$paymentType
);
if
(
$pay
&&
isset
(
$pay
[
'code'
])
&&
$pay
[
'code'
]
===
200
)
{
$result
=
$pay
[
'data'
];
}
return
$result
;
}
/**
* 购物车结算--输入优惠券代码返回的结果处理
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public
static
function
getCoupon
(
$uid
,
$couponCode
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
$coupon
=
CartData
::
getCoupon
(
$uid
,
$couponCode
);
if
(
$coupon
&&
isset
(
$coupon
[
'code'
])
&&
$coupon
[
'code'
]
===
200
)
{
$result
[
'code'
]
=
$coupon
[
'code'
];
$result
[
'message'
]
=
$coupon
[
'message'
];
}
return
$result
;
}
/**
* 处理不同类型的购物车数据
*
* @param array $data 不同类型购物车数据
* @return array $result 处理之后的不同类型购物车数据
*/
private
static
function
procCartData
(
$data
)
{
$result
=
array
();
$oneGoods
=
array
();
// 购买的商品列表
foreach
(
$data
[
'goods_list'
]
as
$value
)
{
$oneGoods
[
'id'
]
=
$value
[
'product_sku'
];
$oneGoods
[
'skn'
]
=
$value
[
'product_skn'
];
$oneGoods
[
'name'
]
=
$value
[
'product_name'
];
$oneGoods
[
'thumb'
]
=
Images
::
getImageUrl
(
$value
[
'goods_images'
],
120
,
120
);
$oneGoods
[
'color'
]
=
$value
[
'color_name'
];
$oneGoods
[
'size'
]
=
$value
[
'size_name'
];
$oneGoods
[
'appearDate'
]
=
'12月'
;
// 目前app接口没有返回该数据
$oneGoods
[
'price'
]
=
$value
[
'real_price'
];
$oneGoods
[
'count'
]
=
$value
[
'buy_number'
];
$oneGoods
[
'lowStocks'
]
=
true
;
$result
[
'goods'
][]
=
$oneGoods
;
}
// 赠品
count
(
$data
[
'gift_list'
])
&&
$result
[
'freebieOrAdvanceBuy'
]
=
true
;
$result
[
'freebie'
]
=
$data
[
'gift_list'
];
// 加价购
$result
[
'advanceBuy'
]
=
$data
[
'price_gift'
];
// 结算数据
$result
[
'price'
]
=
$data
[
'shopping_cart_data'
][
'order_amount'
];
$result
[
'activityPrice'
]
=
$data
[
'shopping_cart_data'
][
'discount_amount'
];
$result
[
'count'
]
=
$data
[
'shopping_cart_data'
][
'goods_count'
];
$result
[
'sumPrice'
]
=
$data
[
'shopping_cart_data'
][
'order_amount'
];
return
$result
;
}
/**
* 加入购物车
*
* @param int $productSku 商品SKU
* @param int $buyNumber 购买数量
* @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int 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
,
$shoppingKey
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~~'
);
$addCart
=
CartData
::
addToCart
(
$productSku
,
$buyNumber
,
$goodsType
,
$isEdit
,
$promotionId
,
$uid
,
$shoppingKey
);
if
(
$addCart
&&
isset
(
$addCart
[
'code'
]))
{
$result
=
$addCart
;
}
return
$result
;
}
/**
* @param integer $uid 用户ID
* @param string $shoppingKey 未登录用户唯一识别码
* @return array|mixed 处理之后的购物车数据
*/
public
static
function
getCartData
(
$uid
,
$shoppingKey
)
{
$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'
]
=
count
(
$cart
[
'ordinary_cart_data'
][
'goods_list'
]);
$result
[
'commonCart'
]
=
self
::
procCartData
(
$cart
[
'ordinary_cart_data'
]);
}
/* 预售购物车 */
if
(
isset
(
$cart
[
'advance_cart_data'
]))
{
$result
[
'presellGoodsCount'
]
=
count
(
$cart
[
'advance_cart_data'
][
'goods_list'
]);
$result
[
'preSellCart'
]
=
self
::
procCartData
(
$cart
[
'advance_cart_data'
]);
}
}
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表示普通购物车
* @return array 接口返回的数据
*/
public
static
function
cartPay
(
$uid
,
$cartType
)
{
$result
=
array
();
$pay
=
CartData
::
cartPay
(
$uid
,
$cartType
);
if
(
$pay
&&
isset
(
$pay
[
'code'
])
&&
$pay
[
'code'
]
===
200
)
{
$payReturn
=
$pay
[
'data'
];
$result
=
array
();
// 收货人有关信息
if
(
isset
(
$payReturn
[
'delivery_address'
])
&&
!
empty
(
$payReturn
[
'delivery_address'
]))
{
$result
[
'name'
]
=
$payReturn
[
'delivery_address'
][
'consignee'
];
$result
[
'phoneNum'
]
=
$payReturn
[
'delivery_address'
][
'mobile'
]
?
:
$payReturn
[
'delivery_address'
][
'phone'
];
$result
[
'address'
]
=
$payReturn
[
'delivery_address'
][
'address'
];
}
// 配送方式
if
(
isset
(
$payReturn
[
'delivery_way'
]))
{
$oneDeliv
=
array
();
foreach
(
$payReturn
[
'delivery_way'
]
as
$val
)
{
$oneDeliv
=
array
();
$oneDeliv
[
'id'
]
=
$val
[
'delivery_way_id'
];
$oneDeliv
[
'name'
]
=
$val
[
'delivery_way_name'
];
$oneDeliv
[
'default'
]
=
(
$val
[
'default'
]
===
'Y'
);
$result
[
'dispatchMode'
][]
=
$oneDeliv
;
}
}
// 配送时间
if
(
isset
(
$payReturn
[
'delivery_time'
]))
{
$oneDelivTime
=
array
();
foreach
(
$payReturn
[
'delivery_time'
]
as
$one
)
{
$oneDelivTime
=
array
();
$oneDelivTime
[
'id'
]
=
$one
[
'delivery_time_id'
];
$oneDelivTime
[
'name'
]
=
$one
[
'delivery_time_string'
];
$oneDelivTime
[
'default'
]
=
(
$one
[
'default'
]
===
'Y'
);
$result
[
'dispatchTime'
][]
=
$oneDelivTime
;
}
}
// 订单商品
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
[
'real_price'
]);
// last_price有些带.00,有些不带,real_price都不带.00
$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'
]
=
$payReturn
[
'yoho_coin'
];
// 订单数据
if
(
isset
(
$payReturn
[
'shopping_cart_data'
])
&&
!
empty
(
$payReturn
[
'shopping_cart_data'
]))
{
$result
[
'sumPrice'
]
=
Helpers
::
transPrice
(
$payReturn
[
'shopping_cart_data'
][
'order_amount'
]);
$result
[
'salePrice'
]
=
Helpers
::
transPrice
(
$payReturn
[
'shopping_cart_data'
][
'discount_amount'
]);
$result
[
'price'
]
=
Helpers
::
transPrice
(
$payReturn
[
'shopping_cart_data'
][
'last_order_amount'
]);
$result
[
'freight'
]
=
Helpers
::
transPrice
(
$payReturn
[
'shopping_cart_data'
][
'shipping_cost'
]);
}
// 发票有关数据
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
[
'invoice'
][]
=
$one
;
}
}
// 优惠券数据
$coupons
=
array
(
'notUsed'
=>
true
);
$coupons
+=
UserModel
::
getCouponData
(
$uid
,
0
,
1
,
true
);
$result
[
'coupon'
]
=
$coupons
;
}
return
$result
;
}
/**
* 购物车结算--支付方式和配送方式选择以及是否使用YOHO币接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param string $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param string $paymentType 支付方式,1表示在线支付,2表示货到付款
* @return array 接口返回的数据
*/
public
static
function
paymentTypeAndDelivery
(
$uid
,
$cartType
,
$deliveryWay
,
$paymentType
)
{
$result
=
array
();
$pay
=
CartData
::
paymentTypeAndDelivery
(
$uid
,
$cartType
,
$deliveryWay
,
$paymentType
);
if
(
$pay
&&
isset
(
$pay
[
'code'
])
&&
$pay
[
'code'
]
===
200
)
{
$result
=
$pay
[
'data'
];
}
return
$result
;
}
/**
* 购物车结算--输入优惠券代码返回的结果处理
*
* @param int $uid 用户ID
* @param string $couponCode 优惠券代码
* @return array 接口返回的数据
*/
public
static
function
getCoupon
(
$uid
,
$couponCode
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
$coupon
=
CartData
::
getCoupon
(
$uid
,
$couponCode
);
if
(
$coupon
&&
isset
(
$coupon
[
'code'
])
&&
$coupon
[
'code'
]
===
200
)
{
$result
[
'code'
]
=
$coupon
[
'code'
];
$result
[
'message'
]
=
$coupon
[
'message'
];
}
return
$result
;
}
/**
* 处理不同类型的购物车数据
*
* @param array $data 不同类型购物车数据
* @return array $result 处理之后的不同类型购物车数据
*/
private
static
function
procCartData
(
$data
)
{
$result
=
array
();
$oneGoods
=
array
();
// 购买的商品列表
foreach
(
$data
[
'goods_list'
]
as
$value
)
{
$oneGoods
[
'id'
]
=
$value
[
'product_sku'
];
$oneGoods
[
'skn'
]
=
$value
[
'product_skn'
];
$oneGoods
[
'name'
]
=
$value
[
'product_name'
];
$oneGoods
[
'thumb'
]
=
Images
::
getImageUrl
(
$value
[
'goods_images'
],
120
,
120
);
$oneGoods
[
'color'
]
=
$value
[
'color_name'
];
$oneGoods
[
'size'
]
=
$value
[
'size_name'
];
$oneGoods
[
'appearDate'
]
=
'12月'
;
// 目前app接口没有返回该数据
$oneGoods
[
'price'
]
=
$value
[
'real_price'
];
$oneGoods
[
'count'
]
=
$value
[
'buy_number'
];
$oneGoods
[
'lowStocks'
]
=
true
;
$result
[
'goods'
][]
=
$oneGoods
;
}
// 赠品
count
(
$data
[
'gift_list'
])
&&
$result
[
'freebieOrAdvanceBuy'
]
=
true
;
$result
[
'freebie'
]
=
$data
[
'gift_list'
];
// 加价购
$result
[
'advanceBuy'
]
=
$data
[
'price_gift'
];
// 结算数据
$result
[
'price'
]
=
$data
[
'shopping_cart_data'
][
'order_amount'
];
$result
[
'activityPrice'
]
=
$data
[
'shopping_cart_data'
][
'discount_amount'
];
$result
[
'count'
]
=
$data
[
'shopping_cart_data'
][
'goods_count'
];
$result
[
'sumPrice'
]
=
$data
[
'shopping_cart_data'
][
'order_amount'
];
return
$result
;
}
}
...
...
Please
register
or
login
to post a comment