Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Rock Zhang
9 years ago
Commit
488b01340a8fee874cde5dc08bb2696629cc1602
1 parent
a752f6ed
添加部分购物车结算页面的接口”
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
205 additions
and
1 deletions
framework
library/LibModels/Wap/Home/CartData.php
yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
framework
@
e9d066dd
Subproject commit
75bbc3b075de19f239532f60c5995d06c5f814e2
Subproject commit
e9d066dd88a8e7e37103021c427a205a5cfcdcec
...
...
library/LibModels/Wap/Home/CartData.php
View file @
488b013
...
...
@@ -105,4 +105,67 @@ class CartData
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
);
}
}
...
...
yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php
View file @
488b013
...
...
@@ -104,6 +104,87 @@ class ShoppingCartController extends AbstractAction
}
}
/**
* 购物车结算请求
*/
public
function
payAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$cartType
=
$this
->
post
(
'cartType'
,
'ordinary'
);
$result
=
CartModel
::
cartPay
(
$this
->
_uid
,
$cartType
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 购物车选择支付方式和配送方式接口
*/
public
function
payAndDeliveryAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$cartType
=
$this
->
post
(
'cartType'
,
'ordinary'
);
$deliveryWay
=
$this
->
post
(
'deliveryWay'
,
1
);
$paymentType
=
$this
->
post
(
'paymentType'
,
1
);
$result
=
CartModel
::
paymentTypeAndDelivery
(
$this
->
_uid
,
$cartType
,
$deliveryWay
,
$paymentType
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 购物车输入优惠券码使用优惠券
*/
public
function
couponAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$couponCode
=
$this
->
post
(
'couponCode'
,
''
);
$result
=
CartModel
::
getCoupon
(
$this
->
_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
()
{
$data
=
array
(
...
...
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
View file @
488b013
...
...
@@ -185,6 +185,66 @@ class CartModel
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
)
{
$result
=
$pay
[
'data'
];
}
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
;
}
/**
* 处理不同类型的购物车数据
...
...
Please
register
or
login
to post a comment