Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
htoooth
8 years ago
Commit
f875f8c483b75be19de5f948d1a0a9cc424429b3
1 parent
29546a0f
order detail
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
713 additions
and
146 deletions
apps/home/controllers/Index.js
apps/home/controllers/order.js
apps/home/controllers/orders.js
apps/home/models/ChannelConfig.js
apps/home/models/index-service.js
apps/home/models/order-api.js → apps/home/models/orders-api.js
apps/home/models/order-service.js → apps/home/models/orders-service.js
apps/home/router.js
apps/home/views/action/home/orders/order-detail.hbs
apps/home/views/partial/home/orders/order-block.hbs
config/common.js
doraemon/middleware/set-yoho-data.js
public/gulpfile.js
apps/home/controllers/Index.js
View file @
f875f8c
...
...
@@ -8,7 +8,7 @@
const
Promise
=
require
(
'bluebird'
);
const
co
=
Promise
.
coroutine
;
const
OrderData
=
require
(
'../models/order-api'
);
const
OrderData
=
require
(
'../models/order
s
-api'
);
const
IndexModel
=
require
(
'../models/index-service'
);
...
...
apps/home/controllers/order.js
deleted
100644 → 0
View file @
29546a0
'use strict'
;
const
_
=
require
(
'lodash'
);
const
orderService
=
require
(
'../models/order-service'
);
const
index
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
page
=
_
.
parseInt
(
req
.
query
.
page
)
||
1
;
let
type
=
_
.
parseInt
(
req
.
query
.
type
)
||
orderService
.
ORDER_TYPE
.
all
;
let
limit
=
_
.
parseInt
(
req
.
query
.
limit
)
||
10
;
orderService
.
index
(
uid
,
page
,
limit
,
type
).
then
((
result
)
=>
{
return
res
.
render
(
'home/orders/orders'
,
{
meOrdersPage
:
true
,
meOrders
:
result
});
}).
catch
(
next
);
};
module
.
exports
=
{
index
};
apps/home/controllers/orders.js
0 → 100644
View file @
f875f8c
'use strict'
;
const
_
=
require
(
'lodash'
);
const
ordersService
=
require
(
'../models/orders-service'
);
const
index
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
page
=
_
.
parseInt
(
req
.
query
.
page
)
||
1
;
let
type
=
_
.
parseInt
(
req
.
query
.
type
)
||
ordersService
.
ORDER_TYPE
.
all
;
let
limit
=
_
.
parseInt
(
req
.
query
.
limit
)
||
10
;
ordersService
.
index
(
uid
,
page
,
limit
,
type
).
then
((
result
)
=>
{
return
res
.
render
(
'home/orders/orders'
,
{
meOrdersPage
:
true
,
meOrders
:
result
});
}).
catch
(
next
);
};
const
reBuy
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
orderId
=
req
.
body
.
orderCode
||
''
;
if
(
!
orderId
)
{
return
res
.
json
({
code
:
400
,
message
:
'缺少参数'
});
}
ordersService
.
reBuy
(
uid
,
orderId
).
then
((
result
)
=>
{
return
res
.
json
(
result
);
}).
catch
(
next
);
};
const
del
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
orderId
=
req
.
body
.
orderCode
||
''
;
let
channel
=
req
.
yoho
.
channel
;
let
gender
=
req
.
yoho
.
gender
;
if
(
!
orderId
)
{
return
res
.
json
({
code
:
400
,
message
:
'缺失必填项'
});
}
ordersService
.
del
(
uid
,
gender
,
channel
,
orderId
).
then
((
result
)
=>
{
return
res
.
json
(
result
);
}).
catch
(
next
);
};
const
modifyAddress
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
orderId
=
req
.
body
.
orderCode
||
''
;
//订单号
let
userName
=
req
.
body
.
userName
||
''
;
//收货人
let
areaCode
=
req
.
body
.
areaCode
||
''
;
//区号
let
address
=
req
.
body
.
address
||
''
;
//地址
let
mobile
=
req
.
body
.
mobile
||
''
;
//手机号码
let
phoneNum
=
req
.
body
.
phoneNum
||
''
;
//固定电话
let
phoneCode
=
req
.
body
.
phoneCode
||
''
;
//电话编号
let
phone
=
phoneNum
?
`
$
{
phoneCode
}
-
$
{
phoneNum
}
`
:
''
;
if
(
!
orderId
||
!
userName
||
!
areaCode
||
!
address
)
{
return
res
.
json
({
code
:
400
,
message
:
'缺失必镇项'
});
}
ordersService
.
updateDeliveryAddress
(
orderId
,
userName
,
areaCode
,
address
,
mobile
,
phone
,
uid
)
.
then
(
result
=>
res
.
json
(
result
))
.
catch
(
next
);
};
const
confirm
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
orderId
=
req
.
body
.
orderCode
||
''
;
if
(
!
orderId
)
{
return
res
.
json
({
code
:
400
,
message
:
'参数缺失'
});
}
ordersService
.
confirm
(
uid
,
orderId
).
then
((
result
)
=>
{
return
res
.
json
(
result
);
}).
catch
(
next
);
};
const
cancel
=
(
req
,
res
,
next
)
=>
{
let
uid
=
req
.
user
.
uid
;
let
orderId
=
req
.
body
.
orderCode
||
''
;
let
reason
=
req
.
body
.
reason
||
''
;
let
reasonId
=
req
.
body
.
reasonId
||
''
;
ordersService
.
cancel
(
uid
,
orderId
,
reason
,
reasonId
)
.
then
(
result
=>
res
.
json
(
result
))
.
catch
(
next
);
};
const
detail
=
(
req
,
res
,
next
)
=>
{
let
orderId
=
req
.
query
.
orderCode
||
req
.
query
.
order_code
;
let
uid
=
req
.
user
.
uid
;
if
(
!
orderId
)
{
return
res
.
redirect
(
'/home'
);
}
ordersService
.
detail
(
uid
,
orderId
).
then
((
result
)
=>
{
if
(
_
.
isEmpty
(
result
))
{
return
res
.
redirect
(
'/home'
);
}
return
res
.
render
(
'home/orders/order-detail'
,
{
meOrderPage
:
true
,
meOrderDetail
:
result
.
detail
,
packages
:
result
.
package
,
cancelReason
:
result
.
cancelReason
});
}).
catch
(
next
);
};
module
.
exports
=
{
index
,
reBuy
,
del
,
modifyAddress
,
confirm
,
cancel
,
detail
};
...
...
apps/home/models/ChannelConfig.js
View file @
f875f8c
/**
* @author: weiqingting<qingting.wei@yoho.cn>
*/
const
exchangeDay
=
15
;
const
refundDay
=
7
;
'use strict'
;
module
.
exports
=
{
exchangeDay
,
refundDay
module
.
exports
.
xchangeDay
=
15
;
module
.
exports
.
refundDay
=
7
;
module
.
exports
.
payType
=
{
1
:
'在线支付'
,
2
:
'货到付款'
,
3
:
'刷卡支付'
};
module
.
exports
.
orderTagArr
=
{
gift
:
{
name
:
'赠品'
,
classname
:
'freebie-tag'
},
price_gift
:
{
name
:
'加价购'
,
classname
:
'advance-buy-tag'
},
advance
:
{
name
:
'预售'
,
classname
:
'presall-tag'
},
ticket
:
{
name
:
'虚拟商品'
,
classname
:
'virtual-good-tag'
}
};
...
...
apps/home/models/index-service.js
View file @
f875f8c
...
...
@@ -5,8 +5,8 @@
const
Promise
=
require
(
'bluebird'
);
const
co
=
Promise
.
coroutine
;
const
OrderData
=
require
(
'./order-api'
);
const
OrderModel
=
require
(
'./order-service'
);
const
OrderData
=
require
(
'./orders-api'
);
const
OrderModel
=
require
(
'./orders-service'
);
const
helpers
=
global
.
yoho
.
helpers
;
const
api
=
global
.
yoho
.
API
;
const
searchApi
=
global
.
yoho
.
SearchAPI
;
...
...
apps/home/models/order-api.js → apps/home/models/order
s
-api.js
View file @
f875f8c
...
...
@@ -30,12 +30,11 @@ exports.getUserOrders = (uid, page, limit, type)=>{
* @return type
*/
exports
.
getOrderDetail
=
(
uid
,
orderCode
)
=>
{
let
options
=
{
return
api
.
get
(
''
,
{
method
:
'app.SpaceOrders.detail'
,
uid
:
uid
,
order_code
:
orderCode
};
return
api
.
get
(
''
,
options
);
});
};
...
...
@@ -46,14 +45,12 @@ exports.getOrderDetail = (uid, orderCode)=>{
* @return type
*/
exports
.
cancelUserOrder
=
(
uid
,
orderCode
,
reason
,
reasonId
)
=>
{
reason
=
reason
||
false
;
reasonId
=
reasonId
||
false
;
let
options
=
{
method
:
'app.SpaceOrders.close'
,
uid
:
uid
,
order_code
:
orderCode
};
if
(
reasonId
)
{
Object
.
assign
(
options
,
{
reasonId
:
reasonId
,
...
...
@@ -70,12 +67,11 @@ exports.cancelUserOrder = (uid, orderCode, reason, reasonId)=>{
* @return type
*/
exports
.
confirmUserOrder
=
(
uid
,
orderCode
)
=>
{
let
options
=
{
return
api
.
get
(
''
,
{
method
:
'app.SpaceOrders.confirm'
,
uid
:
uid
,
order_code
:
orderCode
};
return
api
.
get
(
''
,
options
);
});
};
/**
...
...
@@ -155,15 +151,17 @@ exports.closeReasons = ()=>{
* @param type address_id
* @return type
*/
exports
.
updateDeliveryAddress
=
(
order
_code
,
user_name
,
area_code
,
address
,
mobile
,
phone
)
=>
{
exports
.
updateDeliveryAddress
=
(
order
Id
,
userName
,
areaCode
,
address
,
mobile
,
phone
,
uid
)
=>
{
let
options
=
{
method
:
'app.SpaceOrders.updateDeliveryAddress'
,
order_code
:
order_code
,
user_name
:
user_name
,
area_code
:
area_code
,
order_code
:
orderId
,
user_name
:
userName
,
area_code
:
areaCode
,
address
:
address
,
mobile
:
mobile
mobile
:
mobile
,
uid
:
uid
};
if
(
phone
)
{
Object
.
assign
(
options
,
{
phone
:
phone
});
}
...
...
@@ -179,11 +177,35 @@ exports.updateDeliveryAddress = (order_code, user_name, area_code, address, mobi
* @return array
*/
exports
.
viewOrderData
=
(
orderCode
,
uid
,
sessionKey
)
=>
{
let
options
=
{
return
api
.
get
(
''
,
{
method
:
'app.SpaceOrders.info'
,
order_code
:
order
_c
ode
,
order_code
:
order
C
ode
,
uid
:
uid
,
session_key
:
sessionKey
};
return
api
.
get
(
''
,
options
);
});
};
/**
* 重新加入购物车
*/
exports
.
reBuy
=
(
uid
,
orderId
)
=>
{
return
api
.
get
(
''
,
{
method
:
'app.Shopping.readd'
,
uid
:
uid
,
order_code
:
orderId
});
};
/**
* 删除订单数据
*/
exports
.
del
=
(
uid
,
gender
,
channel
,
orderId
)
=>
{
return
api
.
get
(
''
,
{
method
:
'app.SpaceOrders.delOrderByCode'
,
uid
:
uid
,
gender
:
gender
,
yh_channel
:
channel
,
order_code
:
orderId
});
};
...
...
apps/home/models/order-service.js → apps/home/models/order
s
-service.js
View file @
f875f8c
...
...
@@ -10,7 +10,7 @@ const moment = require('moment');
const
helpers
=
global
.
yoho
.
helpers
;
const
pager
=
require
(
'./pager'
).
handlePagerData
;
const
orderApi
=
require
(
'./order-api'
);
const
orderApi
=
require
(
'./order
s
-api'
);
const
ChannelConfig
=
require
(
'./ChannelConfig'
);
const
ORDER_TYPE
=
{
...
...
@@ -93,6 +93,7 @@ const _getOrderStatus = (isCancel, status, payType, payStatus) => {
break
;
}
}
return
ret
;
};
...
...
@@ -124,11 +125,11 @@ const _getOperateInfo = (attribute, isCancel, status,
// 申请退货
let
refundUrl
=
helpers
.
urlFormat
(
'/home/returns/refundrequest'
,
{
orderCode
:
orderCode
});
let
operation
=
{}
;
let
operation
=
[]
;
// 晒单评价
if
(
status
>=
6
&&
isCancel
===
'N'
&&
payStatus
===
'Y'
)
{
Object
.
assign
(
operation
,
{
operation
.
push
(
{
name
:
'晒单评价'
,
comment
:
true
,
href
:
commentUrl
...
...
@@ -137,7 +138,7 @@ const _getOperateInfo = (attribute, isCancel, status,
// 再次购买
if
(
isCancel
===
'Y'
&&
useLimitCode
!==
'Y'
)
{
Object
.
assign
(
operation
,
{
operation
.
push
(
{
name
:
'再次购买'
,
reBuy
:
true
});
...
...
@@ -145,20 +146,20 @@ const _getOperateInfo = (attribute, isCancel, status,
// 立即付款
if
(
payStatus
===
'N'
&&
paymentType
!==
2
&&
isCancel
===
'N'
)
{
Object
.
assign
(
operation
,
{
operation
.
push
(
{
payNow
:
true
,
href
:
payUrl
});
}
Object
.
assign
(
operation
,
{
operation
.
push
(
{
name
:
'查看订单'
,
href
:
orderDetailUrl
});
// 查看订单,虚拟订单查看二维码
if
(
attribute
===
3
&&
payStatus
===
'Y'
)
{
Object
.
assign
(
operation
,
{
operation
.
push
(
{
href
:
ticketUrl
,
name
:
'查看二维码'
});
...
...
@@ -166,7 +167,7 @@ const _getOperateInfo = (attribute, isCancel, status,
// 取消订单
if
(
status
<
3
&&
isCancel
===
'N'
&&
orderType
!==
5
&&
payStatus
===
'N'
)
{
Object
.
assign
(
operation
,
{
operation
.
push
(
{
href
:
cancelOrderUrl
,
name
:
'取消订单'
,
cancelOrder
:
true
...
...
@@ -175,7 +176,7 @@ const _getOperateInfo = (attribute, isCancel, status,
// 确认收货
if
(
status
>=
4
&&
status
<
6
&&
refundStatus
===
0
&&
attribute
!==
3
&&
isCancel
===
'N'
)
{
Object
.
assign
(
operation
,
{
operation
.
push
(
{
href
:
confirmOrderUrl
,
name
:
'确认收货'
,
confirmReceived
:
true
...
...
@@ -187,7 +188,7 @@ const _getOperateInfo = (attribute, isCancel, status,
let
orderExchangeLimitTime
=
ChannelConfig
.
exchangeDay
;
if
(
status
>=
6
&&
time
<
86400
*
orderExchangeLimitTime
&&
attribute
!==
3
&&
isCancel
===
'N'
)
{
Object
.
assign
(
operation
,
{
operation
.
push
(
{
href
:
exchangeUrl
,
name
:
'申请换货'
,
optDis
:
opRefundStatus
...
...
@@ -198,7 +199,7 @@ const _getOperateInfo = (attribute, isCancel, status,
let
orderRefundLimitTime
=
ChannelConfig
.
refundDay
;
if
(
status
>=
6
&&
time
<
86400
*
orderRefundLimitTime
&&
attribute
!==
3
&&
isCancel
===
'N'
)
{
Object
.
assign
(
operation
,
{
operation
.
push
(
{
href
:
refundUrl
,
name
:
'申请退货'
,
optDis
:
opRefundStatus
...
...
@@ -207,9 +208,9 @@ const _getOperateInfo = (attribute, isCancel, status,
// 预售商品提示app操作
if
(
attribute
===
9
)
{
operation
=
{
operation
=
[
{
name
:
'定金预售商品只能在APP端操作'
};
}
]
;
}
return
operation
;
...
...
@@ -290,7 +291,7 @@ const _getExpressInfo = (orderCode, uid, paymetType, createTime, isDetail) => {
if
(
isDetail
)
{
result
.
logistics
.
push
(
''
);
}
else
{
result
.
logistics
.
push
(
moment
.
unix
(
createTime
).
format
(
'YYYY
-M-D H:m:
s'
)
+
' 您的订单已提交,等待付款'
);
result
.
logistics
.
push
(
moment
.
unix
(
createTime
).
format
(
'YYYY
.MM.DD HH:mm:s
s'
)
+
' 您的订单已提交,等待付款'
);
}
}
if
(
paymetType
===
2
)
{
...
...
@@ -301,7 +302,7 @@ const _getExpressInfo = (orderCode, uid, paymetType, createTime, isDetail) => {
'您的订单已提交,等待审核'
]);
}
else
{
result
.
logistics
.
push
(
moment
.
unix
(
createTime
).
format
(
'YYYY
-M-D H:m:
s'
)
+
' 您的订单已提交,等待审核'
);
result
.
logistics
.
push
(
moment
.
unix
(
createTime
).
format
(
'YYYY
.MM.DD HH:mm:s
s'
)
+
' 您的订单已提交,等待审核'
);
}
}
...
...
@@ -321,12 +322,15 @@ const _getExpressInfo = (orderCode, uid, paymetType, createTime, isDetail) => {
result
.
logistics
=
[];
expressDetail
.
forEach
((
value
)
=>
{
let
pos
=
value
.
accept_address
.
indexOf
(
' '
)
/
3
;
let
pos
=
value
.
accept_address
.
indexOf
(
' '
);
pos
=
pos
===
-
1
?
0
:
pos
;
let
city
=
value
.
accept_address
.
substr
(
0
,
pos
);
let
exInfo
=
value
.
accept_address
.
substr
(
pos
);
if
(
isDetail
)
{
result
.
logistics
=
result
.
logistics
.
concat
([
value
.
acceptTime
,
city
,
exInfo
]);
result
.
logistics
.
push
([
value
.
acceptTime
,
city
,
exInfo
]);
}
else
{
result
.
logistics
.
push
(
value
.
acceptTime
+
city
+
exInfo
);
}
...
...
@@ -355,17 +359,24 @@ const _getOrders = (uid, page, limit, type, isPage)=> {
if
(
_
.
isEmpty
(
_
.
get
(
orderInfo
,
'order_list'
,
[])))
{
return
{
empty
:
ORDER_EMPTY_DESC
[
type
]
||
''
,
list
:[]
list
:
[]
};
}
let
result
=
{};
const
handleOrder
=
co
(
function
*
(
order
)
{
order
.
payment_type
=
+
order
.
payment_type
;
let
newOrder
=
{};
newOrder
.
orderNum
=
order
.
order_code
;
// 订单标识
newOrder
.
orderTime
=
moment
.
unix
(
_
.
get
(
order
,
'create_time'
)).
format
(
'YYYY-M-D H:m:s'
);
newOrder
.
orderTime
=
moment
.
unix
(
_
.
get
(
order
,
'create_time'
)).
format
(
'YYYY-MM-DD HH:mm:ss'
);
if
(
order
.
is_cancel
===
'Y'
||
order
.
status
===
6
)
{
newOrder
.
canDelete
=
true
;
// 删除订单
}
let
statusInfo
=
_getOrderStatus
(
order
.
is_cancel
,
order
.
status
,
order
.
payment_type
,
order
.
payment_status
);
// 订单状态
...
...
@@ -432,6 +443,8 @@ const _getOrders = (uid, page, limit, type, isPage)=> {
opRefundStatus
,
order
.
use_limit_code
);
console
.
log
(
newOrder
.
operation
);
return
newOrder
;
});
...
...
@@ -512,7 +525,7 @@ const index = (uid, page, limit, type) => {
result
[
result
.
name
]
=
result
.
list
;
result
.
pager
=
pager
(
result
.
list
.
pager
.
total
,
{
page
,
limit
,
type
});
result
.
pager
=
pager
(
_
.
get
(
result
,
'list.pager.total'
,
0
)
,
{
page
,
limit
,
type
});
return
Object
.
assign
(
result
,
{
tabs
:
_getTabs
(
type
)
...
...
@@ -520,7 +533,362 @@ const index = (uid, page, limit, type) => {
})();
};
const
reBuy
=
(
uid
,
orderId
)
=>
{
return
co
(
function
*
()
{
let
newOrder
=
yield
orderApi
.
reBuy
(
uid
,
orderId
);
if
(
newOrder
.
code
!==
200
)
{
return
{
code
:
400
,
message
:
'商品加入购物车失败'
};
}
return
{
code
:
200
,
message
:
'商品已重新加入购物车'
,
data
:
newOrder
.
data
};
})();
};
const
del
=
co
(
function
*
(
uid
,
gender
,
channel
,
orderId
)
{
let
orderInfo
=
yield
orderApi
.
del
(
uid
,
gender
,
channel
,
orderId
);
if
(
!
_
.
has
(
orderInfo
,
'code'
))
{
return
{
code
:
400
,
message
:
'删除失败'
};
}
return
orderInfo
;
});
const
_getVirtualPro
=
(
isCancel
,
status
,
createTime
)
=>
{
let
process
=
{
middleStatus
:
[
{
name
:
'1. 提交订单'
,
date
:
moment
.
unix
(
createTime
).
format
(
'YYYY.MM.DD HH:mm:ss'
)
},
{
name
:
'2. 已发货'
},
{
name
:
'3. 交易完成'
}
]
};
if
(
isCancel
===
'N'
)
{
if
(
status
===
0
)
{
process
.
percent
=
'30%'
;
process
.
middleStatus
[
0
].
cur
=
true
;
}
else
if
(
status
>
0
&&
status
<
6
)
{
process
.
percent
=
'80%'
;
process
.
middleStatus
[
1
].
cur
=
true
;
}
else
if
(
status
===
6
)
{
process
.
percent
=
'100%'
;
process
.
middleStatus
[
3
].
cur
=
true
;
}
}
return
process
;
};
const
_getNormalPro
=
(
isCancel
,
status
,
createTime
)
=>
{
let
process
=
{
middleStatus
:
[
{
name
:
'1. 提交订单'
,
date
:
moment
.
unix
(
createTime
).
format
(
'YYYY.MM.DD HH:mm:ss'
)
},
{
name
:
'2. 商品出库'
},
{
name
:
'3. 等待收货'
},
{
name
:
'4. 交易完成'
}
]
};
if
(
isCancel
===
'N'
)
{
if
(
status
===
0
)
{
process
.
percent
=
'25%'
;
process
.
middleStatus
[
0
].
cur
=
true
;
}
else
if
(
status
>
0
&&
status
<
4
)
{
process
.
percent
=
'50%'
;
process
.
middleStatus
[
1
].
cur
=
true
;
}
else
if
(
status
>=
4
&&
status
<
6
)
{
process
.
percent
=
'75%'
;
process
.
middleStatus
[
2
].
cur
=
true
;
}
else
if
(
status
===
6
)
{
process
.
percent
=
'100%'
;
process
.
middleStatus
[
3
].
cur
=
true
;
}
}
return
process
;
};
const
_getOrderDetailOp
=
(
orderId
,
payment
,
status
,
isCancel
,
paymentStatus
,
paymentType
,
orderType
,
attribute
,
refundStatus
)
=>
{
let
operation
=
{};
//立刻付款
if
(
paymentType
===
1
&&
paymentStatus
===
'N'
&&
isCancel
===
'N'
&&
payment
!==
19
)
{
Object
.
assign
(
operation
,
{
goPay
:
helpers
.
urlFormat
(
'/shopping/pay'
,
{
ordercode
:
orderId
})
});
}
//取消订单
if
(
status
<
3
&&
isCancel
===
'N'
&&
paymentStatus
===
'N'
&&
orderType
!==
5
)
{
Object
.
assign
(
operation
,
{
cancelOrder
:
true
});
}
//订单已支付
if
(
paymentType
===
1
&&
paymentStatus
===
'Y'
&&
status
<
6
)
{
Object
.
assign
(
operation
,
{
paid
:
true
});
}
//确认收货
if
(
status
>=
4
&&
status
<
6
&&
refundStatus
===
0
&&
attribute
!==
3
&&
isCancel
===
'N'
)
{
Object
.
assign
(
operation
,
{
shipped
:
true
});
}
//订单已取消
if
(
isCancel
===
'Y'
)
{
Object
.
assign
(
operation
,
{
cancel
:
true
});
}
//虚拟查看二维码
if
(
attribute
===
3
)
{
Object
.
assign
(
operation
,
{
checkQrCode
:
helpers
.
urlFormat
(
'/home/orders/ticket'
,
{
orderCode
:
orderId
})
});
}
return
operation
;
};
const
_getPackageInfo
=
(
cartInfo
)
=>
{
// 是否拆单
if
(
cartInfo
.
is_multi_package
!==
'Y'
)
{
return
[];
}
return
_
.
get
(
cartInfo
,
'package_list'
,
[]).
map
((
pack
,
i
)
=>
{
let
newPack
=
{};
newPack
.
title
=
(
pack
.
supplier_id
===
0
)
?
`包裹
$
{
i
}:
总仓发货`
:
`包裹
$
{
i
}:
异地调拨`
;
newPack
.
goodlist
=
_
.
get
(
pack
,
'goods_list'
,
[]).
map
((
good
)
=>
{
let
tagInfo
=
ChannelConfig
.
orderTagArr
[
good
.
goods_type
]
||
''
;
return
{
src
:
helpers
.
image
(
good
.
goods_images
,
90
,
90
),
goodsType
:
tagInfo
.
name
||
''
,
classname
:
tagInfo
.
classname
||
''
,
link
:
'javascritp:void(0)'
};
});
newPack
.
fee
=
pack
.
shopping_cost
===
'0.00'
?
''
:
pack
.
shopping_cost
;
newPack
.
orign
=
pack
.
shopping_orig_cost
;
newPack
.
count
=
pack
.
shopping_cut_cost
;
return
newPack
;
});
};
const
_getOrder
=
co
(
function
*
(
uid
,
orderId
)
{
let
orderInfo
=
yield
orderApi
.
getOrderDetail
(
uid
,
orderId
);
let
detail
=
{};
if
(
orderInfo
.
code
===
400
)
{
return
orderInfo
;
}
if
(
orderInfo
.
data
)
{
let
orderDetail
=
orderInfo
.
data
;
detail
.
orderNum
=
orderDetail
.
order_code
;
// 订单状态
let
statusInfo
=
_getOrderStatus
(
orderDetail
.
is_cancel
,
+
orderDetail
.
status
,
orderDetail
.
payment_type
,
orderDetail
.
payment_status
);
detail
.
statusStr
=
statusInfo
.
statusStr
;
// 订单是否已完成
detail
.
complete
=
+
orderDetail
.
status
===
6
;
detail
.
progress
=
statusInfo
.
cancel
?
false
:
(
function
()
{
//未取消订单,进度
if
(
orderDetail
.
attribute
===
3
)
{
return
_getVirtualPro
(
orderDetail
.
is_cancel
,
+
orderDetail
.
status
,
orderDetail
.
create_time
);
}
else
{
return
_getNormalPro
(
orderDetail
.
is_cancel
,
+
orderDetail
.
status
,
orderDetail
.
create_time
);
}
}());
// 物流信息
detail
.
traceOrder
=
{};
detail
.
traceOrder
.
orderDate
=
moment
.
unix
(
orderDetail
.
create_time
).
format
(
'YYYY.MM.DD HH:mm:ss'
);
let
expressInfo
=
yield
_getExpressInfo
(
orderId
,
uid
,
+
orderDetail
.
payment_type
,
orderDetail
.
create_time
,
true
);
detail
.
traceOrder
.
logistics
=
expressInfo
.
logistics
;
if
(
_
.
get
(
expressInfo
,
'logistics[0]'
))
{
detail
.
hastrace
=
true
;
}
else
{
detail
.
hastrace
=
false
;
}
detail
.
traceOrder
.
logisticsCompany
=
expressInfo
.
logisticsCompany
;
detail
.
traceOrder
.
courierNumbe
=
expressInfo
.
courierNumbe
;
//虚拟商品
if
(
orderDetail
.
attribute
===
3
)
{
detail
.
virtualGoods
=
true
;
detail
.
virtualPayMode
=
{
payMode
:
ChannelConfig
.
payType
[
orderDetail
.
payment_type
],
phone
:
_
.
fill
(
orderDetail
.
mobile
.
split
(
''
),
'*'
,
3
,
4
).
join
(
''
)
};
}
else
{
detail
.
virtualGoods
=
false
;
detail
.
noramlPayMode
=
{
payMode
:
ChannelConfig
.
payType
[
orderDetail
.
payment_type
],
payWay
:
orderDetail
.
payment_name
,
deliverTime
:
orderDetail
.
delivery_time
||
''
};
//配送信息
detail
.
orderInfo
=
{
receiver
:
orderDetail
.
user_name
,
address
:
orderDetail
.
area
+
orderDetail
.
address
,
phone
:
_
.
fill
(
orderDetail
.
mobile
.
split
(
''
),
'*'
,
3
,
4
).
join
(
''
)
+
(
orderDetail
.
phone
?
','
+
_
.
fill
(
orderDetail
.
phone
.
split
(
''
),
'*'
,
3
,
5
).
join
(
''
)
:
''
)
};
detail
.
editInfo
=
{
userName
:
orderDetail
.
user_name
,
address
:
orderDetail
.
address
,
areaCode
:
orderDetail
.
area_code
,
mobile
:
orderDetail
.
mobile
,
phoneNum
:
_
.
nth
(
_
.
split
(
orderDetail
.
phone
),
0
)
||
''
,
phoneCode
:
_
.
nth
(
_
.
split
(
orderDetail
.
phone
),
1
)
||
''
};
}
// 商品信息
if
(
orderDetail
.
order_goods
)
{
detail
.
goods
=
_
.
get
(
orderDetail
,
'order_goods'
,
[]).
map
((
good
)
=>
{
return
{
url
:
helpers
.
getUrlBySkc
(
good
.
product_id
,
good
.
goods_id
,
good
.
cn_alphabet
),
img
:
helpers
.
image
(
good
.
goods_image
,
60
,
60
),
name
:
good
.
product_name
,
color
:
good
.
factory_color_name
,
size
:
good
.
size_name
,
price
:
good
.
goods_price
,
coin
:
good
.
yoho_give_coin
,
num
:
good
.
buy_number
,
sum
:
good
.
goods_amount
,
sku
:
good
.
product_sku
,
[
_getGoodsTag
(
good
.
attribute
,
good
.
goods_type
)]:
true
};
});
}
//详情页-订单付费详情
if
(
orderDetail
.
promotion_formulas
)
{
detail
.
orderBalance
=
_
.
get
(
orderDetail
,
'promotion_formulas'
,
[]).
map
((
promotion
)
=>
{
return
{
promotion
:
promotion
.
promotion
,
account
:
promotion
.
promotion_amount
};
});
detail
.
orderBalance
.
push
({
promotion
:
'实际应支付'
,
account
:
orderDetail
.
amount
});
}
//发票
if
(
orderDetail
.
invoice
)
{
detail
.
invoiceMode
=
true
;
detail
.
invoiceType
=
_
.
get
(
orderDetail
,
'invoice.type'
)
===
2
?
'电子发票'
:
'纸质发票'
;
detail
.
showInvoice
=
_
.
get
(
orderDetail
,
'invoice.showInvoice'
);
detail
.
pdfUrl
=
detail
.
showInvoice
?
_
.
get
(
orderDetail
,
'invoice.pdfUrl'
)
:
''
;
detail
.
title
=
_
.
get
(
orderDetail
,
'invoice.title'
)
||
''
;
detail
.
contentValue
=
_
.
get
(
orderDetail
,
'invoice.contentValue'
)
||
'个人'
;
}
detail
.
totalYoho
=
orderDetail
.
yoho_give_coin
;
detail
.
yohoCoinUrl
=
helpers
.
urlFormat
(
'/help/detail'
,
{
id
:
105
});
// 有货币介绍
detail
.
remark
=
orderDetail
.
remark
;
detail
.
operation
=
_getOrderDetailOp
(
orderDetail
.
order_cde
,
orderDetail
.
payment
,
+
orderDetail
.
status
,
orderDetail
.
is_cancel
,
orderDetail
.
payment_status
,
orderDetail
.
payment_type
,
orderDetail
.
order_type
,
orderDetail
.
attribute
,
orderDetail
.
refund_status
);
detail
.
package
=
_getPackageInfo
(
orderDetail
);
//判断是否可以修改地址
if
(
orderDetail
.
can_update_delivery_address
===
'Y'
)
{
detail
.
changeable
=
true
;
}
return
detail
;
}
});
const
updateDeliveryAddress
=
orderApi
.
updateDeliveryAddress
;
const
confirm
=
orderApi
.
confirmUserOrder
;
const
cancel
=
orderApi
.
cancelUserOrder
;
const
detail
=
co
(
function
*
(
uid
,
orderId
)
{
let
apiData
=
yield
Promise
.
props
({
detailData
:
_getOrder
(
uid
,
orderId
),
reason
:
orderApi
.
closeReasons
()
});
if
(
apiData
.
detailData
.
code
===
400
)
{
return
{};
}
return
{
detail
:
apiData
.
detailData
,
package
:
apiData
.
detailData
.
package
,
cancelReason
:
_
.
get
(
apiData
.
reason
,
'data'
,
[])
};
});
module
.
exports
=
{
index
,
ORDER_TYPE
ORDER_TYPE
,
reBuy
,
del
,
updateDeliveryAddress
,
confirm
,
cancel
,
detail
};
...
...
apps/home/router.js
View file @
f875f8c
...
...
@@ -33,7 +33,7 @@ const bindController = require(`${cRoot}/3party-bind`);
const
AccountController
=
require
(
`
$
{
cRoot
}
/account`
)
;
const
favoriteController
=
require
(
`
$
{
cRoot
}
/favorite`
)
;
const
order
Controller
=
require
(
`
$
{
cRoot
}
/order
`
)
;
const
order
sController
=
require
(
`
$
{
cRoot
}
/orders
`
)
;
// const AddressController = require(`${cRoot}/address`);
// const GiftController = require(`${cRoot}/gift`);
...
...
@@ -43,7 +43,7 @@ const homeNav = (req) => {
{
title
:
'交易管理'
,
subNav
:
[
{
name
:
'我的订单'
,
href
:
'/home/orders'
,
catchs
:
[
'/home/orders'
,
'/home/index'
]},
{
name
:
'我的订单'
,
href
:
'/home/orders'
,
catchs
:
[
'/home/orders'
,
'/home/index'
,
'/home/orders/detail'
]},
{
name
:
'我的收藏'
,
href
:
'/home/favorite'
,
catchs
:
[
'/home/favorite/reduction'
]},
{
name
:
'我的有货币'
,
href
:
'/home/currency'
},
{
name
:
'我的红包'
,
href
:
'/home/redenvelopes'
},
...
...
@@ -120,8 +120,11 @@ const getActiveNav = (req, count)=>{
}
if
(
nav
.
catchs
)
{
if
(
nav
.
catchs
.
indexOf
(
curMatchPath
)
>
-
1
)
{
let
index
=
nav
.
catchs
.
indexOf
(
curMatchPath
);
if
(
index
>
-
1
)
{
nav
.
active
=
true
;
nav
.
curHref
=
nav
.
catchs
[
index
];
}
}
...
...
@@ -156,6 +159,16 @@ const getHomeNav = (req, res, next) => {
bread
.
push
({
name
:
activeNav
.
name
});
// 订单详情
if
(
activeNav
.
curHref
===
'/home/orders/detail'
)
{
Object
.
assign
(
_
.
last
(
bread
),
{
href
:
helpers
.
urlFormat
(
'/home/orders'
)
});
bread
.
push
({
name
:
'订单详情'
});
}
}
else
{
bread
.
push
({
name
:
'个人中心'
...
...
@@ -251,7 +264,25 @@ router.get('/favorite/cancel', favoriteController.cancel);
/********************************* 我的收藏结束 *****************************************/
/********************************* 我的订单开始 *****************************************/
router
.
get
(
'/orders'
,
[
getCommonHeader
,
getHomeNav
],
orderController
.
index
);
router
.
get
(
'/orders'
,
[
getCommonHeader
,
getHomeNav
],
ordersController
.
index
);
// 重新加入购物车
router
.
post
(
'/orders/readd'
,
ordersController
.
reBuy
);
// 删除订单
router
.
post
(
'/orders/delorder'
,
ordersController
.
del
);
// 修改地址
router
.
post
(
'/orders/modifyAddress'
,
ordersController
.
modifyAddress
);
// 确认订单
router
.
post
(
'/orders/confirmOrder'
,
ordersController
.
confirm
);
// 取消订单
router
.
post
(
'/orders/cancelOrder'
,
ordersController
.
cancel
);
// 订单详情
router
.
get
(
'/orders/detail'
,
[
getCommonHeader
,
getHomeNav
],
ordersController
.
detail
);
/********************************* 我的订单结束 *****************************************/
...
...
apps/home/views/action/home/orders/order-detail.hbs
View file @
f875f8c
{{>
layout
/
header
}}
<div
class=
"order-detail-page me-page yoho-page clearfix"
>
{{#
meOrderDetail
}}
{{>
home
/
path
}}
{{>
path
}}
{{>
navigation
}}
{{
>
home
/
navigation
}}
{{
#
meOrderDetail
}}
<div
class=
"me-main"
>
<div
class=
"order-detail block"
data-id=
"
{{
orderNum
}}
"
>
<h2
class=
"title"
></h2>
<div
class=
"detail-info
{{#if
virtualGoods
}}
virtual-detail
{{/
unless
}}
"
>
<div
class=
"detail-info
{{#if
virtualGoods
}}
virtual-detail
{{/
if
}}
"
>
<div
class=
"status"
>
<p>
订单编号:
<em>
{{
orderNum
}}
</em>
</p>
<p
class=
"cur-status clearfix"
>
当前状态:
{{
curStatus
}}
当前状态:
{{
statusStr
}}
{{#if
operation
.
goPay
}}
<a
class=
"go-pay oo-btn"
href=
"
{{
operation
.
goPay
}}
"
>
立即付款
</a>
{{/if}}
...
...
@@ -53,7 +52,9 @@
{{/
progress
}}
{{#if
hastrace
}}
{{#
traceOrder
}}
{{
log
this
}}
<div
class=
"trace-order"
>
<p
class=
"sub-title"
>
<span
class=
"icon"
></span>
...
...
@@ -123,16 +124,6 @@
</div>
</div>
<div
class=
"order-remark"
>
<p
class=
"sub-title"
>
<span
class=
"icon"
></span>
备注
</p>
<p
class=
"content"
>
{{
remark
}}
</p>
</div>
{{#
noramlPayMode
}}
<div
class=
"pay-mode"
>
<p
class=
"sub-title"
>
...
...
@@ -161,6 +152,7 @@
</div>
</div>
{{/
virtualPayMode
}}
<div
class=
"good-list"
>
<p
class=
"sub-title"
>
<span
class=
"icon"
></span>
...
...
@@ -168,46 +160,46 @@
</p>
<!--订单不同包裹提示-->
{{#if
packages
}}
<div
id=
"differentOrder"
class=
"differentOrder"
>
<p
class=
"warn"
>
温馨提示:您购买的商品
<span
class=
"red"
>
分属不同的仓库
</span>
,需要调拨,将被拆分为多个包裹送达
<span
class=
"why"
>
</span>
</p>
<div
id=
"differentBag"
class=
"differentBag"
>
{{#
each
packages
}}
<div
class=
"bag"
>
<h3>
{{
title
}}
</h3>
<p
class=
"pre"
>
</p>
<div
class=
"bagDetil"
>
<ul>
{{#
each
goodlist
}}
<li>
<a
href=
{{
link
}}
>
<img
src=
{{
src
}}
/
>
<div
id=
"differentOrder"
class=
"differentOrder"
>
<p
class=
"warn"
>
温馨提示:您购买的商品
<span
class=
"red"
>
分属不同的仓库
</span>
,需要调拨,将被拆分为多个包裹送达
<span
class=
"why"
>
</span>
</p>
<div
id=
"differentBag"
class=
"differentBag"
>
{{#
each
packages
}}
<div
class=
"bag"
>
<h3>
{{
title
}}
</h3>
<p
class=
"pre"
>
</p>
<div
class=
"bagDetil"
>
<ul>
{{#
each
goodlist
}}
<li>
<a
href=
{{
link
}}
>
<img
src=
{{
src
}}
/
>
</a>
{{#if
goodsType
}}
<p
class=
"
{{
classname
}}
"
>
{{
goodsType
}}
</p>
{{/if}}
</li>
{{/
each
}}
</ul>
</div>
<p
class=
"next"
>
</p>
{{#if
fee
}}
<p>
运费:¥
{{
fee
}}
元(原价
{{
orign
}}
元,优惠
{{
count
}}
元)
</p>
{{else}}
<p>
运费:¥0.00元
</p>
{{/if}}
</div>
{{/
each
}}
</div>
</div>
</a>
{{#if
goodsType
}}
<p
class=
"
{{
classname
}}
"
>
{{
goodsType
}}
</p>
{{/if}}
</li>
{{/
each
}}
</ul>
</div>
<p
class=
"next"
>
</p>
{{#if
fee
}}
<p>
运费:¥
{{
fee
}}
元(原价
{{
orign
}}
元,优惠
{{
count
}}
元)
</p>
{{else}}
<p>
运费:¥0.00元
</p>
{{/if}}
</div>
{{/
each
}}
</div>
</div>
{{/if}}
<div
class=
"content"
>
<table>
...
...
@@ -227,7 +219,7 @@
<td>
<a
class=
"thumb-link"
href=
"
{{
url
}}
"
target=
"_blank"
>
<img
class=
"thumb"
src=
"
{{
img
}}
"
>
{{>
home
/
order-goods-tags
}}
{{>
home
/
order
s
/
order
-goods-tags
}}
</a>
<p
class=
"name-color-size"
>
<a
class=
"name"
href=
"
{{
url
}}
"
target=
"_blank"
>
{{
name
}}
</a>
...
...
@@ -320,8 +312,7 @@
</div>
</div>
</div>
{{>
home
/
order-cancel-tpl
}}
{{>
home
/
order-edit-tpl
}}
{{>
home
/
orders
/
order-edit-tpl
}}
{{/
meOrderDetail
}}
{{>
home
/
orders
/
order-cancel-tpl
}}
</div>
{{>
layout
/
footer
}}
...
...
apps/home/views/partial/home/orders/order-block.hbs
View file @
f875f8c
...
...
@@ -133,19 +133,18 @@
{{^}}
{{#if
reBuy
}}
<span
class=
"rebuy"
>
再次购买
</span>
{{/if}}
{{#if
confirmReceived
}}
<span
class=
"op-item confirm-received"
>
确认收货
</span>
{{^}}
<a
class=
"op-item
{{#if
payNow
}}
pay-now
{{/if}}
{{#if
comment
}}
comment-show-btn
{{/if}}
"
href=
"
{{
href
}}
"
target=
"_blank"
>
{{#if
payNow
}}
立即付款
{{^}}
{{
name
}}
{{/if}}
</a>
{{#if
confirmReceived
}}
<span
class=
"op-item confirm-received"
>
确认收货
</span>
{{^}}
<a
class=
"op-item
{{#if
payNow
}}
pay-now
{{/if}}
{{#if
comment
}}
comment-show-btn
{{/if}}
"
href=
"
{{
href
}}
"
target=
"_blank"
>
{{#if
payNow
}}
立即付款
{{^}}
{{
name
}}
{{/if}}
</a>
{{/if}}
{{/if}}
{{/if}}
{{/if}}
...
...
config/common.js
View file @
f875f8c
...
...
@@ -23,8 +23,8 @@ module.exports = {
// prod
singleApi
:
'http://single.yoho.cn/'
,
api
:
'http://api.yoho.cn/'
,
service
:
'http://service.yoho.cn/'
,
api
:
'http://api.yoho.cn/'
,
service
:
'http://service.yoho.cn/'
,
// gray
//singleApi: 'http://single.gray.yohops.com/',
...
...
doraemon/middleware/set-yoho-data.js
View file @
f875f8c
...
...
@@ -6,6 +6,17 @@
'use strict'
;
const
_getGender
=
(
channel
)
=>
{
switch
(
channel
)
{
case
'boys'
:
return
'1,3'
;
case
'girls'
:
return
'2,3'
;
default
:
return
'1,2,3'
;
}
};
module
.
exports
=
()
=>
{
return
(
req
,
res
,
next
)
=>
{
let
yoho
=
{
...
...
@@ -19,6 +30,9 @@ module.exports = () => {
// 当前频道设置
yoho
.
channel
=
channel
;
// 当前性别
yoho
.
gender
=
_getGender
(
channel
);
yoho
.
isApp
=
req
.
query
.
app_version
||
req
.
query
.
appVersion
;
Object
.
assign
(
res
.
locals
,
yoho
);
...
...
public/gulpfile.js
View file @
f875f8c
...
...
@@ -128,6 +128,10 @@ gulp.task('postcss-dev', () => {
return
gulp
.
src
(
'scss/index.css'
)
.
pipe
(
sourcemaps
.
init
())
.
pipe
(
postcss
(
postcssPlugin
(
env
.
dev
)))
.
on
(
'error'
,
function
(
err
)
{
gutil
.
log
(
err
);
this
.
emit
(
'end'
);
})
.
pipe
(
sourcemaps
.
write
(
'.'
))
.
pipe
(
gulp
.
dest
(
'css/'
));
});
...
...
Please
register
or
login
to post a comment