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
yangyang
9 years ago
Commit
457394601560272ffc8bc0ab8e10b4fac6cdbb3f
1 parent
68b0b36a
完善一些代码格式,为添加程序备注,完成随便逛逛url获取
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
146 additions
and
75 deletions
library/LibModels/Wap/Home/OrderData.php
yohobuy/m.yohobuy.com/application/controllers/Home.php
yohobuy/m.yohobuy.com/application/models/Home/Order.php
library/LibModels/Wap/Home/OrderData.php
View file @
4573946
...
...
@@ -46,6 +46,7 @@ class OrderData
*/
static
function
cancelOrderData
(
$order_code
,
$uid
,
$gender
,
$yh_channel
,
$method
)
{
//构建必传参数
$param
=
Yohobuy
::
param
();
$param
[
'order_code'
]
=
$order_code
;
$param
[
'uid'
]
=
$uid
;
...
...
@@ -53,6 +54,7 @@ class OrderData
$param
[
'yh_channel'
]
=
$yh_channel
;
$param
[
'method'
]
=
$method
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
//调用接口获得数据
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
...
...
@@ -63,6 +65,7 @@ class OrderData
*/
static
function
deleteOrderData
(
$order_code
,
$uid
,
$gender
,
$yh_channel
,
$method
)
{
//构建必传参数
$param
=
Yohobuy
::
param
();
$param
[
'order_code'
]
=
$order_code
;
$param
[
'uid'
]
=
$uid
;
...
...
@@ -70,23 +73,56 @@ class OrderData
$param
[
'yh_channel'
]
=
$yh_channel
;
$param
[
'method'
]
=
$method
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
//调用接口删除订单
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/*
*
支付订单
*
我的订单-查看物流
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
static
function
getPaymentData
(
$contentCode
,
$gender
,
$yh_channel
)
{
static
function
LogisticsData
()
{
//构建必传参数
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.express.li'
;
//$param['gender'] = $gender;
//$param['yh_channel'] = $yh_channel;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
//调用接口获得数据
return
Yohobuy
::
get
(
'http://api.open.yohobuy.com/'
,
$param
);
}
/*
* 支付url
* To change this template file, choose Tools | Templates
*/
static
function
paymentData
(
$gender
,
$yh_channel
,
$code
)
{
//构建必传参数
$param
=
Yohobuy
::
param
();
$param
[
'content_code'
]
=
$co
ntentCo
de
;
$param
[
'content_code'
]
=
$code
;
$param
[
'gender'
]
=
$gender
;
$param
[
'yh_channel'
]
=
$yh_channel
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
//print_r($param);
//调用接口获得数据
return
Yohobuy
::
get
(
Yohobuy
::
SERVICE_URL
.
'/operations/api/v5/resource/get'
,
$param
);
}
/*
* 随便逛逛url
* To change this template file, choose Tools | Templates
*/
static
function
strollData
(
$gender
,
$yh_channel
,
$code
)
{
//构建必传参数
$param
=
Yohobuy
::
param
();
$param
[
'content_code'
]
=
$code
;
$param
[
'gender'
]
=
$gender
;
$param
[
'yh_channel'
]
=
$yh_channel
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
//调用接口获得数据
return
Yohobuy
::
get
(
Yohobuy
::
SERVICE_URL
.
'/operations/api/v5/resource/get'
,
$param
);
}
...
...
yohobuy/m.yohobuy.com/application/controllers/Home.php
View file @
4573946
...
...
@@ -37,8 +37,7 @@ class HomeController extends AbstractAction
/**
* 个人中心入口
*/
public
function
indexAction
()
{
public
function
indexAction
()
{
// 设置网站标题
$this
->
setTitle
(
'个人中心'
);
$this
->
setNavHeader
(
'个人中心'
,
true
,
SITE_MAIN
);
...
...
@@ -62,8 +61,7 @@ class HomeController extends AbstractAction
/**
* 用户收藏的商品
*/
public
function
favoriteAction
()
{
public
function
favoriteAction
()
{
// 设置网站标题
$this
->
setTitle
(
'我的收藏'
);
$this
->
setNavHeader
(
'我的收藏'
,
true
,
SITE_MAIN
);
...
...
@@ -87,8 +85,7 @@ class HomeController extends AbstractAction
/**
* 用户收藏的商品-删除
*/
public
function
favoriteDelAction
()
{
public
function
favoriteDelAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
...
...
@@ -108,8 +105,7 @@ class HomeController extends AbstractAction
/**
* 用户收藏的品牌
*/
public
function
favoritebrandAction
()
{
public
function
favoritebrandAction
()
{
$uid
=
$this
->
getUid
();
$gender
=
Helpers
::
getGenderByCookie
();
...
...
@@ -121,8 +117,7 @@ class HomeController extends AbstractAction
/**
* 个人信息
*/
public
function
personalDetailsAction
()
{
public
function
personalDetailsAction
()
{
$this
->
setTitle
(
'个人信息'
);
$this
->
setNavHeader
(
'个人信息'
,
true
,
SITE_MAIN
);
...
...
@@ -136,8 +131,7 @@ class HomeController extends AbstractAction
/**
* YOHO币
*/
public
function
currencyAction
()
{
public
function
currencyAction
()
{
$this
->
setTitle
(
'YOHO币'
);
$this
->
setNavHeader
(
'YOHO币'
,
true
,
false
);
...
...
@@ -152,8 +146,7 @@ class HomeController extends AbstractAction
/**
* 优惠券
*/
public
function
couponsAction
()
{
public
function
couponsAction
()
{
$this
->
setTitle
(
'优惠券'
);
$this
->
setNavHeader
(
'优惠券'
,
true
,
SITE_MAIN
);
...
...
@@ -170,8 +163,7 @@ class HomeController extends AbstractAction
/**
* 我的消息
*/
public
function
messageAction
()
{
public
function
messageAction
()
{
// $uid = $this->getUid();
$page
=
$this
->
get
(
'page'
,
0
);
$size
=
$this
->
get
(
'size'
,
10
);
...
...
@@ -185,8 +177,7 @@ class HomeController extends AbstractAction
/**
* 地址管理
*/
public
function
addressAction
()
{
public
function
addressAction
()
{
// 设置网站标题
$this
->
setTitle
(
'地址管理'
);
$this
->
setNavHeader
(
'地址管理'
,
true
,
SITE_MAIN
);
...
...
@@ -210,8 +201,7 @@ class HomeController extends AbstractAction
/**
* 修改地址或者添加新地址
*/
public
function
saveAddressAction
()
{
public
function
saveAddressAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
...
...
@@ -238,8 +228,7 @@ class HomeController extends AbstractAction
/**
* 设置默认地址
*/
public
function
defaultAddressAction
()
{
public
function
defaultAddressAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
...
...
@@ -260,8 +249,7 @@ class HomeController extends AbstractAction
/**
* 删除地址
*/
public
function
addressDelAction
()
{
public
function
addressDelAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
...
...
@@ -280,8 +268,7 @@ class HomeController extends AbstractAction
}
//在线客服
public
function
onlineServiceAction
()
{
public
function
onlineServiceAction
()
{
// 设置网站标题
$this
->
setTitle
(
'在线客服'
);
$this
->
setNavHeader
(
'在线客服'
,
true
,
SITE_MAIN
);
...
...
@@ -296,8 +283,7 @@ class HomeController extends AbstractAction
}
//在线客服-具体详情
public
function
onlineServiceDetailAction
()
{
public
function
onlineServiceDetailAction
()
{
$service
=
array
();
$cateId
=
$this
->
get
(
'cateId'
,
0
);
$cateName
=
$this
->
get
(
'cateName'
,
''
);
...
...
@@ -312,16 +298,14 @@ class HomeController extends AbstractAction
/**
* 我的逛
*/
public
function
myGuangAction
()
{
public
function
myGuangAction
()
{
echo
'My Guang'
;
}
/**
* 意见反馈
*/
public
function
suggestAction
()
{
public
function
suggestAction
()
{
// 设置网站标题
$this
->
setTitle
(
'意见反馈'
);
$this
->
setNavHeader
(
'意见反馈'
,
true
,
SITE_MAIN
);
...
...
@@ -343,8 +327,7 @@ class HomeController extends AbstractAction
/**
* 意见反馈-提交表单页面
*/
public
function
suggestSubAction
()
{
public
function
suggestSubAction
()
{
// 设置网站标题
$this
->
setTitle
(
'反馈问题'
);
...
...
@@ -372,8 +355,7 @@ class HomeController extends AbstractAction
/**
* 异步上传图片
*/
public
function
suggestimgUploadAction
()
{
public
function
suggestimgUploadAction
()
{
$filename
=
$this
->
post
(
'filename'
,
''
);
$result
=
\Index\UserModel
::
saveSuggestImg
(
$filename
);
...
...
@@ -383,8 +365,7 @@ class HomeController extends AbstractAction
/**
* 异步保存意见反馈数据
*/
public
function
savesuggestAction
()
{
public
function
savesuggestAction
()
{
if
(
$this
->
isAjax
())
{
$uid
=
$this
->
getUid
();
$content
=
$this
->
post
(
'content'
,
''
);
...
...
@@ -398,8 +379,7 @@ class HomeController extends AbstractAction
/**
* 会员等级展示页
*/
public
function
gradeAction
()
{
public
function
gradeAction
()
{
//设置网站seo信息
$this
->
setTitle
(
'会员等级'
);
//显示网站导航头部信息
...
...
@@ -418,8 +398,7 @@ class HomeController extends AbstractAction
* 会员特权查看页
*/
public
function
preferentialAction
()
{
public
function
preferentialAction
()
{
//设置网站seo信息
$this
->
setTitle
(
'会员等级'
);
//显示网站导航头部信息
...
...
@@ -433,12 +412,11 @@ class HomeController extends AbstractAction
}
/*
* 我的订单页面
* 我的订单页面
,获得nav导航条焦点。并且异步请求订单详情列表页(getOrders)
*/
public
function
orderAction
()
{
//获得type值
public
function
orderAction
()
{
//获得type值,type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论。
$type
=
$this
->
get
(
'type'
,
1
);
$this
->
setTitle
(
'我的订单'
);
$this
->
setNavHeader
(
'我的订单'
);
...
...
@@ -448,7 +426,7 @@ class HomeController extends AbstractAction
}
else
{
$this
->
error
();
}
//渲染模板
$this
->
_view
->
display
(
'order'
,
array
(
'order'
=>
$order
,
'pageFooter'
=>
true
,
...
...
@@ -457,8 +435,7 @@ class HomeController extends AbstractAction
}
//ajax请求订单页面
public
function
getOrdersAction
()
{
public
function
getOrdersAction
()
{
//判断是不是ajax请求
if
(
!
$this
->
isAjax
())
{
$this
->
error
();
...
...
@@ -473,15 +450,18 @@ class HomeController extends AbstractAction
$uid
=
'10267443'
;
//测试用
//调用模型层getOrder方法获得并处理数据
$data
=
OrderModel
::
getOrder
(
$type
,
$page
,
$limit
,
$gender
,
$yh_channel
,
$uid
);
//如果没有订单数据,就给一个随便逛逛链接
/* 如果取不到订单数据时,分两种情况:
1、page>1时,echo一个空格字符串到浏览器。
2、page=1时,就给一个随便逛逛的链接。
* */
$order
=
array
();
if
(
!
empty
(
$data
))
{
$order
[
'orders'
]
=
$data
;
}
else
{
if
(
$page
>
1
)
{
echo
" "
;
}
else
{
$order
[
'walkwayUrl'
]
=
'http://www.baidu.com'
;
}
elseif
(
$page
=
1
)
{
$order
[
'walkwayUrl'
]
=
self
::
strollAction
();
}
}
//渲染模板
...
...
@@ -492,8 +472,7 @@ class HomeController extends AbstractAction
* 我的订单-取消订单
*/
public
function
cancelOrderAction
()
{
public
function
cancelOrderAction
()
{
//判断是不是ajax请求
if
(
!
$this
->
isAjax
())
{
...
...
@@ -506,8 +485,9 @@ class HomeController extends AbstractAction
$gender
=
Helpers
::
getGenderByCookie
();
$yh_channel
=
$this
->
get
(
'yh_channel'
,
1
);
$method
=
'app.SpaceOrders.close'
;
//调用取消订单接口,返回订单取消状态
$data
=
OrderData
::
cancelOrderData
(
$order_code
,
$uid
,
$gender
,
$yh_channel
,
$method
);
//将取消状态返回至浏览器
$this
->
echoJson
(
$data
);
}
...
...
@@ -515,8 +495,7 @@ class HomeController extends AbstractAction
* 我的订单-删除订单
*/
public
function
delOrderAction
()
{
public
function
delOrderAction
()
{
//判断是不是ajax请求
if
(
!
$this
->
isAjax
())
{
$this
->
error
();
...
...
@@ -528,15 +507,39 @@ class HomeController extends AbstractAction
$gender
=
Helpers
::
getGenderByCookie
();
$yh_channel
=
$this
->
get
(
'yh_channel'
,
1
);
$method
=
'app.SpaceOrders.delOrderByCode'
;
//调用接口删除订单,并返回订单删除状态
$data
=
OrderData
::
deleteOrderData
(
$order_code
,
$uid
,
$gender
,
$yh_channel
,
$method
);
//将订单删除状态返回至浏览器
$this
->
echoJson
(
$data
);
}
/*
* 我的订单-支付链接获取
*/
private
function
paymentAction
()
{
$gender
=
Helpers
::
getGenderByCookie
();
$yh_channel
=
$this
->
get
(
'yh_channel'
,
1
);
OrderModel
::
payment
(
$gender
,
$yh_channel
);
}
/*
* 我的订单-随便逛逛链接获取
*/
private
function
strollAction
()
{
//获取性别、频道数据
$gender
=
Helpers
::
getGenderByCookie
();
$yh_channel
=
$this
->
get
(
'yh_channel'
,
1
);
//调用接口获取随便逛逛url地址,并return数据
$data
=
OrderModel
::
stroll
(
$gender
,
$yh_channel
);
return
$data
;
}
/**
* 订单详情页
*/
public
function
orderDetailAction
()
{
public
function
orderDetailAction
()
{
$data
=
array
(
'name'
=>
'毛毛莉Lydia'
,
'phoneNum'
=>
'18600001133'
,
...
...
yohobuy/m.yohobuy.com/application/models/Home/Order.php
View file @
4573946
...
...
@@ -18,11 +18,16 @@ use Configs\CacheConfig;
*/
class
OrderModel
{
/* 频道选择页取背景图片的位置码 */
const
CODE_PAYMENT
=
'04cf5abaa7c20178325a07c4a833782c'
;
//支付订单资源码
const
CODE_STROLL
=
'a7989369aa86681c678bc40f171b8f1d'
;
//随便逛逛url地址资源码
/**
* 订单相关数据处理
*/
public
function
getOrder
(
$type
=
1
,
$page
=
1
,
$limit
,
$gender
,
$yh_channel
,
$uid
)
{
static
function
getOrder
(
$type
=
1
,
$page
=
1
,
$limit
,
$gender
,
$yh_channel
,
$uid
)
{
$result
=
array
();
if
(
USE_CACHE
)
{
$key
=
CacheConfig
::
KEY_ACTION_HOME_ORDER_ORDER
;
...
...
@@ -37,32 +42,37 @@ class OrderModel
//检查数据返回是否正常,正常则处理数据
if
(
$data
[
'code'
]
==
200
&&
isset
(
$data
[
'data'
]))
{
foreach
(
$data
[
'data'
][
'order_list'
]
as
$key
=>
$vo
)
{
//订单号,支付状态,订单商品数量,订单总价格
//订单号,支付状态,订单商品数量,订单总价格
(订单总价加上运费)
$result
[
$key
][
'orderNum'
]
=
$vo
[
'order_code'
];
$result
[
$key
][
'orderStatus'
]
=
$vo
[
'status_str'
];
$result
[
$key
][
'count'
]
=
count
(
$vo
[
'order_goods'
]);
$result
[
$key
][
'sumCost'
]
=
$vo
[
'amount'
]
+
$vo
[
'shipping_cost'
];
//
订单商品列表数据
//
类内调用格式化订单商品数据方法
$result
[
$key
][
'goods'
]
=
self
::
formatOrderGoods
(
$vo
[
'order_goods'
]);
//订单status判断订单处于什么状态。
//
根据
订单status判断订单处于什么状态。
do
{
//订单取消状态
//订单取消状态
= Y 时,跳出判断订单状态循环,并设置订单状态为已取消。
if
(
$vo
[
'is_cancel'
]
===
'Y'
)
{
$result
[
$key
][
'canceled'
]
=
true
;
break
;
}
//支付方式不是货到付款时,计算订单状态
/* 先判断订单付款方式,根据不同的付款方式计算订单状态。(注:货到付款没有待付款状态)
* 付款方式:1 => 在线支付,2 => 货到付款,3 => 现金支付,4 => 抵消支付;
*/
//支付方式为非货到付款时,计算订单状态。
if
(
$vo
[
'payment_type'
]
!=
2
)
{
switch
(
$vo
[
'status'
])
{
case
0
:
$result
[
$key
][
'unpaid'
]
=
true
;
break
;
//未发货&未收货 状态,统一合并到待收货状态。
case
1
:
case
2
:
case
3
:
case
4
:
case
5
:
$result
[
$key
][
'unreceived'
]
=
true
;
//待收货状态,给查看物流url
$result
[
$key
][
'logisticsUrl'
]
=
"暂无logisticsUrl数据"
;
break
;
case
6
:
...
...
@@ -72,11 +82,11 @@ class OrderModel
break
;
}
}
elseif
(
$vo
[
'payment_type'
]
==
2
)
{
//订单为货到付款订单时,
订单没有未支付状态
//订单为货到付款订单时,
计算订单状态。(货到付款没有待付款状态)
switch
(
$vo
[
'status'
])
{
case
0
||
1
||
2
||
3
||
4
||
5
:
$result
[
$key
][
'unreceived'
]
=
true
;
//
此处备注,接口没有返回logisticsUrl数据
//
待收货状态,给查看物流url
$resault
[
$key
][
'logisticsUrl'
]
=
"备注:暂无logisticsUrl数据"
;
break
;
case
6
:
...
...
@@ -113,6 +123,7 @@ class OrderModel
$arr
[
$key
][
'size'
]
=
$vo
[
'size_name'
];
$arr
[
$key
][
'price'
]
=
$vo
[
'goods_price'
];
$arr
[
$key
][
'count'
]
=
$vo
[
'buy_number'
];
//gift=>是否赠品,advanceBuy=>是否加价购;
if
(
$vo
[
'goods_type'
]
==
'gift'
)
{
$arr
[
$key
][
'gift'
]
=
true
;
}
elseif
(
$vo
[
'goods_type'
]
==
'price_gift'
)
{
...
...
@@ -123,7 +134,7 @@ class OrderModel
}
//根据type值设置nav属性
publ
ic
function
getNavs
(
$type
)
{
stat
ic
function
getNavs
(
$type
)
{
$nav
=
array
(
array
(
'name'
=>
'全部'
,
...
...
@@ -174,8 +185,29 @@ class OrderModel
}
return
$nav
;
}
//获得支付链接
static
function
payment
(
$gender
,
$yh_channel
)
{
$code
=
self
::
CODE_PAYMENT
;
$data
=
OrderData
::
paymentData
(
$gender
,
$yh_channel
,
$code
);
}
//查看物流
// static function Logistics(){
// OrderData::LogisticsData();
// }
//随便逛逛url获取
static
function
stroll
(
$gender
,
$yh_channel
)
{
//获取随便逛逛url资源码
$code
=
self
::
CODE_STROLL
;
//调用接口获得数据
$data
=
OrderData
::
strollData
(
$gender
,
$yh_channel
,
$code
);
$stroll
=
1
;
//检查数据返回是否正常,正常则处理数据
if
(
$data
[
'code'
]
==
200
)
{
$strollUrl
=
$data
[
'data'
][
0
][
'data'
][
0
][
'url'
];
}
return
$strollUrl
;
}
}
...
...
Please
register
or
login
to post a comment