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
王水玲
7 years ago
Commit
30e5fea642f58eccc2261d64ae8c6fee000f0fdd
1 parent
0bf966a6
master
...
baidu_ocpcapi
develop
feature/canbuy
feature/channelDataMap
feature/company-profile
feature/contact
feature/detail-link
feature/home-optimize
feature/overseas-edition
feature/payment
feature/pcurl
feature/reduce
feature/refactor_alert
feature/shoppingPay
feature/virtualOrder
hotfix/11
hotfix/cart
hotfix/changeappversion
hotfix/gift
hotfix/im
hotfix/link
hotfix/ocpc
hotfix/shop
hotfix/upload
hotfix/yohobi
release/6.9.0
release/6.9.2
2019-12-5
all
api 更改
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
317 additions
and
217 deletions
apps/activity/controllers/coupon.js
apps/activity/models/coupon.js
apps/brands/models/brands-service.js
apps/common/controllers/erp2goods.js
apps/common/controllers/passport.js
apps/common/controllers/recent-view.js
apps/common/models/erp2goods-api.js
apps/common/models/erp2goods-service.js
apps/common/models/passport.js
apps/common/models/recent-view.js
apps/home/controllers/comment.js
apps/home/controllers/consult.js
apps/home/controllers/new-user.js
apps/home/models/comment.js
apps/home/models/consult.js
apps/home/models/new-user-api.js
apps/home/models/new-user-service.js
apps/home/models/returns.js
apps/home/models/user-service.js
apps/product/controllers/search.js
apps/product/models/sale.js
apps/product/models/search.js
apps/shop/controllers/shop.js
apps/shop/models/shop-service.js
apps/activity/controllers/coupon.js
View file @
30e5fea
...
...
@@ -13,7 +13,7 @@ const contentCode = 'bb7268bd46dd46d304c2917309814681';
exports
.
index
=
(
req
,
res
,
next
)
=>
{
const
channel
=
req
.
cookies
.
_Channel
||
'boys'
;
couponModel
.
getCouponData
(
channel
,
{
req
.
ctx
(
couponModel
)
.
getCouponData
(
channel
,
{
uid
:
req
.
user
.
uid
,
contentCode
:
req
.
query
.
contentCode
||
contentCode
}).
then
(
result
=>
{
...
...
@@ -31,7 +31,7 @@ exports.index = (req, res, next) => {
};
exports
.
getCouponStatus
=
(
req
,
res
,
next
)
=>
{
couponModel
.
getCouponStatus
({
req
.
ctx
(
couponModel
)
.
getCouponStatus
({
uid
:
req
.
user
.
uid
,
contentCode
:
req
.
query
.
contentCode
||
contentCode
}).
then
(
result
=>
{
...
...
@@ -40,7 +40,7 @@ exports.getCouponStatus = (req, res, next) => {
};
exports
.
sendcoupon
=
(
req
,
res
,
next
)
=>
{
couponModel
.
sendcoupon
(
req
.
query
.
id
,
req
.
user
.
uid
).
then
(
result
=>
{
req
.
ctx
(
couponModel
)
.
sendcoupon
(
req
.
query
.
id
,
req
.
user
.
uid
).
then
(
result
=>
{
res
.
json
(
result
);
}).
catch
(
next
);
};
...
...
apps/activity/models/coupon.js
View file @
30e5fea
...
...
@@ -7,14 +7,15 @@
const
_
=
require
(
'lodash'
);
const
Promise
=
require
(
'bluebird'
);
const
api
=
global
.
yoho
.
API
;
const
crypto
=
global
.
yoho
.
crypto
;
const
helpers
=
global
.
yoho
.
helpers
;
const
HeaderModel
=
require
(
'../../../doraemon/models/header'
);
const
homeService
=
require
(
'../../product/models/home-service'
);
const
config
=
global
.
yoho
.
config
;
exports
.
getCouponData
=
(
channel
,
params
)
=>
{
function
getCouponData
(
channel
,
params
)
{
let
that
=
this
;
return
Promise
.
coroutine
(
function
*
()
{
const
result
=
{
pathNav
:
[
homeService
.
getHomeChannelNav
(
channel
),
{
...
...
@@ -28,9 +29,12 @@ exports.getCouponData = (channel, params) => {
};
const
requestData
=
yield
Promise
.
all
([
api
.
get
(
''
,
Object
.
assign
(
params
,
{
method
:
'app.promotion.queryCouponCenter'
}),
config
.
apiCache
),
that
.
get
({
data
:
Object
.
assign
(
params
,
{
method
:
'app.promotion.queryCouponCenter'
}),
param
:
config
.
apiCache
}),
HeaderModel
.
requestHeaderData
(
channel
)
]);
...
...
@@ -78,13 +82,15 @@ exports.getCouponData = (channel, params) => {
while
(
false
);
return
result
;
})();
}
;
}
exports
.
getCouponStatus
=
(
params
)
=>
{
function
getCouponStatus
(
params
)
{
return
Promise
.
coroutine
(
function
*
()
{
const
coupon
=
yield
api
.
get
(
''
,
Object
.
assign
(
params
,
{
method
:
'app.promotion.couponStatus'
}));
const
coupon
=
yield
this
.
get
({
data
:
Object
.
assign
(
params
,
{
method
:
'app.promotion.couponStatus'
})
});
const
result
=
{
code
:
coupon
.
code
,
categories
:
[]
...
...
@@ -116,18 +122,20 @@ exports.getCouponStatus = (params) => {
while
(
false
);
return
result
;
})();
}
;
}
exports
.
sendcoupon
=
(
couponId
,
uid
)
=>
{
function
sendcoupon
(
couponId
,
uid
)
{
let
returnData
=
{};
couponId
=
crypto
.
decrypt
(
'yoho9646abcdefgh'
,
couponId
);
// 领取优惠券
return
api
.
get
(
''
,
{
method
:
'app.promotion.getCoupon'
,
couponId
:
couponId
,
uid
:
uid
return
this
.
get
({
data
:
{
method
:
'app.promotion.getCoupon'
,
couponId
:
couponId
,
uid
:
uid
}
}).
then
(
result
=>
{
switch
(
result
.
code
)
{
case
200
:
...
...
@@ -164,4 +172,15 @@ exports.sendcoupon = (couponId, uid) => {
}
return
returnData
;
});
}
module
.
exports
=
class
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
super
(
ctx
);
this
.
getCouponData
=
getCouponData
.
bind
(
this
);
this
.
getCouponStatus
=
getCouponStatus
.
bind
(
this
);
this
.
sendcoupon
=
sendcoupon
.
bind
(
this
);
}
};
...
...
apps/brands/models/brands-service.js
View file @
30e5fea
...
...
@@ -7,7 +7,6 @@
const
Promise
=
require
(
'bluebird'
);
const
co
=
Promise
.
coroutine
;
const
api
=
global
.
yoho
.
API
;
const
headerModel
=
require
(
'../../../doraemon/models/header'
);
const
BrandsModel
=
require
(
'./brands-model'
);
const
_
=
require
(
'lodash'
);
...
...
@@ -157,7 +156,7 @@ module.exports = class extends global.yoho.BaseModel {
brandsModelCtx
.
getBrandViewList
(
channel
)
// 分屏加载
];
return
api
.
all
(
apiMethod
).
then
(
result
=>
{
return
Promise
.
all
(
apiMethod
).
then
(
result
=>
{
let
responseData
=
{
module
:
'brands'
,
page
:
'brands'
,
...
...
@@ -208,7 +207,7 @@ module.exports = class extends global.yoho.BaseModel {
brandsModelCtx
.
getBrandViewList
(
channel
,
start
)
];
return
api
.
all
(
apiMethod
).
then
(
result
=>
{
return
Promise
.
all
(
apiMethod
).
then
(
result
=>
{
let
responseData
=
{};
// 品牌一览列表
...
...
@@ -231,7 +230,7 @@ module.exports = class extends global.yoho.BaseModel {
brandsModelCtx
.
getBrandInfo
(
brandId
,
uid
)
];
return
api
.
all
(
apiMethod
).
then
(
result
=>
{
return
Promise
.
all
(
apiMethod
).
then
(
result
=>
{
let
responseData
=
{
code
:
_
.
isEmpty
(
result
[
0
])
?
400
:
200
,
brand
:
_
.
isEmpty
(
result
[
0
])
?
''
:
result
[
0
],
...
...
apps/common/controllers/erp2goods.js
View file @
30e5fea
...
...
@@ -7,7 +7,7 @@ const find = (req, res, next) => {
let
skn
=
req
.
query
.
skn
||
''
;
let
sku
=
req
.
query
.
sku
||
''
;
service
.
find
({
req
.
ctx
(
service
)
.
find
({
skn
:
skn
,
sku
:
sku
}).
then
((
result
)
=>
{
...
...
apps/common/controllers/passport.js
View file @
30e5fea
...
...
@@ -27,14 +27,14 @@ const index = (req, res, next) => {
if
(
uid
)
{
// 获取个人信息VIP资料
let
profile
=
yield
passportModel
.
getUserProfile
(
uid
).
then
(
ret
=>
{
let
profile
=
yield
req
.
ctx
(
passportModel
)
.
getUserProfile
(
uid
).
then
(
ret
=>
{
if
(
ret
&&
ret
.
code
===
200
)
{
return
ret
.
data
;
}
return
null
;
});
let
userNum
=
yield
passportModel
.
getUserInfoNum
(
uid
).
then
(
ret
=>
{
let
userNum
=
yield
req
.
ctx
(
passportModel
)
.
getUserInfoNum
(
uid
).
then
(
ret
=>
{
if
(
ret
&&
ret
.
code
===
200
)
{
return
ret
.
data
;
}
...
...
apps/common/controllers/recent-view.js
View file @
30e5fea
...
...
@@ -31,7 +31,7 @@ const index = (req, res, next) => {
});
}
else
{
skn
=
_
.
slice
(
_
.
uniq
(
skn
.
split
(
','
)),
0
,
limit
).
join
(
','
);
// 去重+截取
r
vModel
.
index
(
skn
,
limit
).
then
(
data
=>
{
r
eq
.
ctx
(
rvModel
)
.
index
(
skn
,
limit
).
then
(
data
=>
{
res
.
jsonp
(
data
);
}).
catch
(
next
);
}
...
...
@@ -42,7 +42,7 @@ const getRecommend = (req, res, next) => {
let
uid
=
req
.
user
.
uid
;
let
udid
=
req
.
user
.
uid
+
req
.
yoho
.
udid
;
r
vModel
.
recommend
({
r
eq
.
ctx
(
rvModel
)
.
recommend
({
yh_channel
:
req
.
yoho
.
channelNum
,
uid
:
uid
,
udid
:
udid
,
...
...
apps/common/models/erp2goods-api.js
View file @
30e5fea
...
...
@@ -4,7 +4,6 @@
'use strict'
;
const
api
=
global
.
yoho
.
API
;
const
config
=
global
.
yoho
.
config
;
/**
...
...
@@ -12,25 +11,35 @@ const config = global.yoho.config;
* @param pid
* @returns {Promise.<type>}
*/
const
getProductBySknAsync
=
(
skn
)
=>
{
function
getProductBySknAsync
(
skn
)
{
let
params
=
{
method
:
'app.product.data'
,
product_skn
:
skn
};
return
api
.
get
(
''
,
params
,
config
.
apiCache
);
};
return
this
.
get
({
data
:
params
,
param
:
config
.
apiCache
});
}
const
getProductBySkuAsync
=
(
sku
)
=>
{
function
getProductBySkuAsync
(
sku
)
{
let
params
=
{
method
:
'app.shops.productListByskus'
,
skus
:
sku
};
return
api
.
get
(
''
,
params
,
config
.
apiCache
);
};
return
this
.
get
({
data
:
params
,
param
:
config
.
apiCache
});
}
module
.
exports
=
class
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
super
(
ctx
);
module
.
exports
=
{
getProductBySknAsync
,
getProductBySkuAsync
this
.
getProductBySknAsync
=
getProductBySknAsync
.
bind
(
this
);
this
.
getProductBySkuAsync
=
getProductBySkuAsync
.
bind
(
this
);
}
};
...
...
apps/common/models/erp2goods-service.js
View file @
30e5fea
...
...
@@ -4,50 +4,54 @@
'use strict'
;
const
a
pi
=
require
(
'./erp2goods-api'
);
const
Erp2GoodsA
pi
=
require
(
'./erp2goods-api'
);
const
_
=
require
(
'lodash'
);
const
helpers
=
global
.
yoho
.
helpers
;
const
findBySkn
=
(
skn
)
=>
{
return
api
.
getProductBySknAsync
(
skn
).
then
((
result
)
=>
{
if
(
result
&&
result
.
code
&&
result
.
code
===
200
&&
result
.
data
.
product_url
)
{
return
{
url
:
helpers
.
getUrlBySkc
(
result
.
data
.
product_skn
)
};
}
else
{
return
{};
}
});
};
const
findBySku
=
(
sku
)
=>
{
return
api
.
getProductBySkuAsync
(
`
[
$
{
sku
}]
`
).
then
((
result
)
=>
{
if
(
result
&&
result
.
code
&&
result
.
code
===
200
&&
!
_
.
isEmpty
(
result
.
data
))
{
let
product
=
_
.
head
(
result
.
data
)
||
{};
let
skn
=
product
.
erpProductId
||
''
;
module
.
exports
=
class
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
super
(
ctx
);
if
(
skn
)
{
return
findBySkn
(
skn
);
}
this
.
erp2GoodsApi
=
new
Erp2GoodsApi
(
ctx
);
}
return
{};
find
(
q
)
{
if
(
q
.
sku
)
{
return
this
.
_findBySku
(
q
.
sku
);
}
else
if
(
q
.
skn
)
{
return
this
.
_findBySkn
(
q
.
skn
);
}
else
{
return
{}
;
return
Promise
.
reject
()
;
}
});
};
}
_findBySku
(
sku
)
{
return
this
.
erp2GoodsApi
.
getProductBySkuAsync
(
`
[
$
{
sku
}]
`
).
then
((
result
)
=>
{
if
(
result
&&
result
.
code
&&
result
.
code
===
200
&&
!
_
.
isEmpty
(
result
.
data
))
{
let
product
=
_
.
head
(
result
.
data
)
||
{};
let
skn
=
product
.
erpProductId
||
''
;
const
find
=
(
q
)
=>
{
if
(
q
.
sku
)
{
return
findBySku
(
q
.
sku
);
}
else
if
(
q
.
skn
)
{
return
findBySkn
(
q
.
skn
);
}
else
{
return
Promise
.
reject
();
if
(
skn
)
{
return
this
.
_findBySkn
(
skn
);
}
return
{};
}
else
{
return
{};
}
});
}
};
module
.
exports
=
{
find
_findBySkn
(
skn
)
{
return
this
.
erp2GoodsApi
.
getProductBySknAsync
(
skn
).
then
((
result
)
=>
{
if
(
result
&&
result
.
code
&&
result
.
code
===
200
&&
result
.
data
.
product_url
)
{
return
{
url
:
helpers
.
getUrlBySkc
(
result
.
data
.
product_skn
)
};
}
else
{
return
{};
}
});
}
};
...
...
apps/common/models/passport.js
View file @
30e5fea
...
...
@@ -6,7 +6,6 @@
'use strict'
;
const
api
=
global
.
yoho
.
API
;
const
config
=
global
.
yoho
.
config
;
/**
...
...
@@ -14,30 +13,40 @@ const config = global.yoho.config;
* @param uid
* @return string
*/
const
getUserProfile
=
uid
=>
{
function
getUserProfile
(
uid
)
{
let
params
=
{
method
:
'app.passport.profile'
,
uid
:
uid
};
return
api
.
get
(
''
,
params
,
config
.
apiCache
);
};
return
this
.
get
({
data
:
params
,
param
:
config
.
apiCache
});
}
/**
* 获取用户信息
* @param uid
* @return string
*/
const
getUserInfoNum
=
uid
=>
{
function
getUserInfoNum
(
uid
)
{
let
params
=
{
method
:
'app.home.getInfoNum'
,
uid
:
uid
};
return
api
.
get
(
''
,
params
,
config
.
apiCache
);
};
return
this
.
get
({
data
:
params
,
param
:
config
.
apiCache
});
}
module
.
exports
=
class
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
super
(
ctx
);
module
.
exports
=
{
getUserProfile
,
getUserInfoNum
this
.
getUserProfile
=
getUserProfile
.
bind
(
this
);
this
.
getUserInfoNum
=
getUserInfoNum
.
bind
(
this
);
}
};
...
...
apps/common/models/recent-view.js
View file @
30e5fea
...
...
@@ -7,13 +7,12 @@
'use strict'
;
const
_
=
require
(
'lodash'
);
const
api
=
global
.
yoho
.
API
;
const
helper
=
global
.
yoho
.
helpers
;
/**
* 处理商品
*/
const
_handleProduct
=
(
products
)
=>
{
function
_handleProduct
(
products
)
{
return
products
.
map
((
product
)
=>
{
return
{
href
:
helper
.
getUrlBySkc
(
product
.
product_skn
),
...
...
@@ -23,14 +22,16 @@ const _handleProduct = (products) => {
productId
:
product
.
product_id
};
});
}
;
}
const
index
=
(
skn
,
limit
)
=>
{
function
index
(
skn
,
limit
)
{
return
api
.
get
(
''
,
{
method
:
'h5.product.batch'
,
productSkn
:
skn
,
limit
:
limit
return
this
.
get
({
data
:
{
method
:
'h5.product.batch'
,
productSkn
:
skn
,
limit
:
limit
}
}).
then
(
result
=>
{
if
(
result
.
code
===
200
)
{
...
...
@@ -76,24 +77,30 @@ const index = (skn, limit) => {
};
}
});
}
;
}
/**
* [为你优选]
* @param {[type]} params [(yh_channel、uid、udid、rec_pos、limit)]
* @return {[type]} [{}]
*/
const
recommend
=
(
params
)
=>
{
function
recommend
(
params
)
{
params
.
limit
=
params
.
limit
||
30
;
return
api
.
get
(
''
,
Object
.
assign
({
method
:
'app.home.newPreference'
},
params
)).
then
(
d
=>
{
return
this
.
get
({
data
:
Object
.
assign
({
method
:
'app.home.newPreference'
},
params
)
}).
then
(
d
=>
{
return
_handleProduct
(
_
.
get
(
d
,
'data.product_list'
,
[]));
});
};
}
module
.
exports
=
class
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
super
(
ctx
);
module
.
exports
=
{
index
,
recommend
this
.
index
=
index
.
bind
(
this
);
this
.
recommend
=
recommend
.
bind
(
this
);
}
};
...
...
apps/home/controllers/comment.js
View file @
30e5fea
...
...
@@ -23,7 +23,7 @@ exports.index = (req, res, next) => {
// uid = '20000318';
// uid: 20000318 test1
commentModel
.
getCommentList
(
uid
,
isComment
,
page
)
req
.
ctx
(
commentModel
)
.
getCommentList
(
uid
,
isComment
,
page
)
.
then
(
data
=>
{
let
localData
=
_
.
merge
(
data
,
{
module
:
'home'
,
...
...
@@ -40,7 +40,7 @@ exports.commentList4Order = (req, res, next) => {
let
orderId
=
req
.
query
.
orderId
;
// console.log(uid + '===' + orderId);
commentModel
.
getCommentList4Order
(
uid
,
orderId
)
req
.
ctx
(
commentModel
)
.
getCommentList4Order
(
uid
,
orderId
)
.
then
(
data
=>
{
let
result
=
_
.
merge
({
module
:
'home'
,
...
...
@@ -78,7 +78,7 @@ exports.saveComment = (req, res, next) => {
// console.log(JSON.stringify(data));
commentModel
.
saveShareOrder
(
data
)
req
.
ctx
(
commentModel
)
.
saveShareOrder
(
data
)
.
then
(
result
=>
{
let
ret
=
result
;
...
...
@@ -91,7 +91,7 @@ exports.saveComment = (req, res, next) => {
createTime
:
moment
(
new
Date
()).
format
(
'YYYY-MM-DD HH:mm:ss'
),
satisfied
:
data
.
satisfied
,
size
:
data
.
size
,
sizeLabel
:
commentModel
.
sizeLabelMap
[
data
.
size
],
sizeLabel
:
req
.
ctx
(
commentModel
)
.
sizeLabelMap
[
data
.
size
],
url
:
uutils
.
getUploadImgAbsoluteUrl
(
data
.
url
,
'sns'
),
sourceUrl
:
uutils
.
getUploadImgAbsoluteUrl
(
data
.
url
,
'sns'
),
height
:
data
.
height
,
...
...
apps/home/controllers/consult.js
View file @
30e5fea
...
...
@@ -12,7 +12,7 @@ exports.index = (req, res, next) => {
const
uid
=
req
.
user
.
uid
;
const
page
=
req
.
query
.
page
||
1
;
consultModel
.
consultList
(
uid
,
page
/* ,limit=10*/
)
req
.
ctx
(
consultModel
)
.
consultList
(
uid
,
page
/* ,limit=10*/
)
.
then
(
result
=>
{
let
renderData
=
Object
.
assign
({
module
:
'home'
,
...
...
apps/home/controllers/new-user.js
View file @
30e5fea
...
...
@@ -18,7 +18,7 @@ const check = (req, res, next) => {
});
}
newUserService
.
check
(
uid
).
then
((
result
)
=>
{
req
.
ctx
(
newUserService
)
.
check
(
uid
).
then
((
result
)
=>
{
if
(
_
.
isEmpty
(
result
))
{
return
res
.
json
({
code
:
500
,
...
...
apps/home/models/comment.js
View file @
30e5fea
...
...
@@ -16,7 +16,6 @@ const pagerPath = path.join(global.appRoot, '/apps/product/models/public-handler
const
pager
=
require
(
pagerPath
).
handlePagerData
;
const
co
=
Promise
.
coroutine
;
const
api
=
global
.
yoho
.
API
;
const
helpers
=
global
.
yoho
.
helpers
;
...
...
@@ -29,23 +28,26 @@ const sizeLabelMap = {
BIG
:
'偏大'
};
exports
.
sizeLabelMap
=
sizeLabelMap
;
exports
.
getCommentList
=
(
uid
,
isComment
,
page
,
limit
)
=>
{
function
getCommentList
(
uid
,
isComment
,
page
,
limit
)
{
limit
=
limit
||
10
;
let
that
=
this
;
const
process
=
function
*
()
{
let
resData
=
{};
// 临时解决个人中心-评论-用户头像缺失问题,待个人中心整体重构调整头像获取机制
let
proInfo
=
yield
Promise
.
all
([
api
.
post
(
''
,
{
method
:
'web.show.queryOrderProductCommentList'
,
uid
:
uid
that
.
post
({
data
:
{
method
:
'web.show.queryOrderProductCommentList'
,
uid
:
uid
}
}),
api
.
get
(
''
,
{
method
:
'app.passport.profile'
,
uid
:
uid
that
.
get
({
data
:
{
method
:
'app.passport.profile'
,
uid
:
uid
}
})
]);
...
...
@@ -149,17 +151,20 @@ exports.getCommentList = (uid, isComment, page, limit) => {
};
return
co
(
process
)();
}
;
}
exports
.
getCommentList4Order
=
(
uid
,
orderCode
)
=>
{
function
getCommentList4Order
(
uid
,
orderCode
)
{
let
that
=
this
;
const
process
=
function
*
()
{
let
result
=
yield
api
.
post
(
''
,
{
// method: 'show.toShareOrderList',
method
:
'web.show.queryCommentListByOrderCode'
,
uid
:
uid
,
orderCode
:
orderCode
let
result
=
yield
that
.
post
({
data
:
{
// method: 'show.toShareOrderList',
method
:
'web.show.queryCommentListByOrderCode'
,
uid
:
uid
,
orderCode
:
orderCode
}
});
let
commentList
=
{
...
...
@@ -259,11 +264,26 @@ exports.getCommentList4Order = (uid, orderCode) => {
};
return
co
(
process
)();
}
;
}
exports
.
saveShareOrder
=
data
=>
{
return
api
.
post
(
''
,
{
method
:
'show.saveShareOrder'
,
parameters
:
JSON
.
stringify
(
data
)
function
saveShareOrder
(
data
)
{
return
this
.
post
({
data
:
{
method
:
'show.saveShareOrder'
,
parameters
:
JSON
.
stringify
(
data
)
}
});
}
module
.
exports
=
class
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
super
(
ctx
);
this
.
sizeLabelMap
=
sizeLabelMap
;
this
.
getCommentList
=
getCommentList
.
bind
(
this
);
this
.
getCommentList4Order
=
getCommentList4Order
.
bind
(
this
);
this
.
saveShareOrder
=
saveShareOrder
.
bind
(
this
);
}
};
...
...
apps/home/models/consult.js
View file @
30e5fea
...
...
@@ -8,7 +8,6 @@ const Promise = require('bluebird');
const
moment
=
require
(
'moment'
);
const
_
=
require
(
'lodash'
);
const
api
=
global
.
yoho
.
API
;
const
helpers
=
global
.
yoho
.
helpers
;
const
co
=
Promise
.
coroutine
;
...
...
@@ -27,11 +26,13 @@ const NO_CONSULT = '您尚未咨询任何内容';
function
getProductGoodsInfo
(
skns
)
{
const
query
=
_
.
join
(
_
.
uniq
(
skns
),
','
);
return
api
.
get
(
''
,
{
method
:
'h5.product.batch'
,
limit
:
skns
.
length
,
productSkn
:
query
,
contain_all
:
'Y'
return
this
.
get
({
data
:
{
method
:
'h5.product.batch'
,
limit
:
skns
.
length
,
productSkn
:
query
,
contain_all
:
'Y'
}
}).
then
(
result
=>
{
let
resData
=
{};
...
...
@@ -46,7 +47,7 @@ function getProductGoodsInfo(skns) {
/**
* 获取咨询列表
*/
exports
.
consultList
=
(
uid
,
page
,
limit
)
=>
{
function
consultList
(
uid
,
page
,
limit
)
{
page
=
Number
.
parseInt
(
page
,
10
)
||
1
;
limit
=
Number
.
parseInt
(
limit
,
10
)
||
10
;
...
...
@@ -56,10 +57,14 @@ exports.consultList = (uid, page, limit) => {
limit
:
limit
};
let
that
=
this
;
const
fetchConsults
=
co
(
function
*
(
params
)
{
let
res
=
yield
api
.
get
(
''
,
Object
.
assign
({
method
:
'web.personCen.buyConsult'
},
params
));
let
res
=
yield
that
.
get
({
data
:
Object
.
assign
({
method
:
'web.personCen.buyConsult'
},
params
)
});
return
res
;
});
...
...
@@ -117,4 +122,13 @@ exports.consultList = (uid, page, limit) => {
});
return
fetchConsults
(
data
).
then
(
processData
);
}
module
.
exports
=
class
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
super
(
ctx
);
this
.
consultList
=
consultList
.
bind
(
this
);
}
};
...
...
apps/home/models/new-user-api.js
View file @
30e5fea
'use strict'
;
const
api
=
global
.
yoho
.
API
;
exports
.
getUserSuccessfulOrders
=
(
uid
)
=>
{
return
api
.
get
(
''
,
{
method
:
'app.resources.isNewUser'
,
uid
:
uid
function
getUserSuccessfulOrders
(
uid
)
{
return
this
.
get
({
data
:
{
method
:
'app.resources.isNewUser'
,
uid
:
uid
}
});
}
;
}
module
.
exports
=
class
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
super
(
ctx
);
this
.
getUserSuccessfulOrders
=
getUserSuccessfulOrders
.
bind
(
this
);
}
};
...
...
apps/home/models/new-user-service.js
View file @
30e5fea
'use strict'
;
const
_
=
require
(
'lodash'
);
const
a
pi
=
require
(
'../models/new-user-api'
);
const
NewUserA
pi
=
require
(
'../models/new-user-api'
);
const
check
=
(
uid
)
=>
{
return
api
.
getUserSuccessfulOrders
(
uid
).
then
((
result
)
=>
{
function
check
(
uid
)
{
return
this
.
newUserApi
.
getUserSuccessfulOrders
(
uid
).
then
((
result
)
=>
{
if
(
result
.
code
!==
200
)
{
return
{};
}
...
...
@@ -20,8 +20,15 @@ const check = (uid) => {
}
});
};
}
module
.
exports
=
class
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
super
(
ctx
);
module
.
exports
=
{
check
this
.
newUserApi
=
new
NewUserApi
(
ctx
);
this
.
check
=
check
.
bind
(
this
);
}
};
...
...
apps/home/models/returns.js
View file @
30e5fea
...
...
@@ -12,7 +12,6 @@ const OrdersAPI = require('./orders-api');
const
pager
=
require
(
`
$
{
global
.
utils
}
/pager`
)
.setPager
;
const
co
=
Promise
.
coroutine
;
const
api
=
global
.
yoho
.
API
;
const
helpers
=
global
.
yoho
.
helpers
;
// 常量
...
...
@@ -122,11 +121,13 @@ module.exports = class extends global.yoho.BaseModel {
orders
:
[],
pager
:
{}
};
let
response
=
yield
api
.
post
(
''
,
{
method
:
'app.refund.getList'
,
uid
:
uid
,
page
:
page
,
limit
:
limit
let
response
=
yield
that
.
post
({
data
:
{
method
:
'app.refund.getList'
,
uid
:
uid
,
page
:
page
,
limit
:
limit
}
});
let
repData
=
response
.
data
;
...
...
apps/home/models/user-service.js
View file @
30e5fea
...
...
@@ -7,7 +7,6 @@
'use strict'
;
const
Promise
=
require
(
'bluebird'
);
const
co
=
Promise
.
coroutine
;
const
api
=
global
.
yoho
.
API
;
const
_
=
require
(
'lodash'
);
const
UserApi
=
require
(
'./user-api'
);
const
helpers
=
global
.
yoho
.
helpers
;
...
...
@@ -272,7 +271,7 @@ module.exports = class extends global.yoho.BaseModel {
return
co
(
function
*
()
{
let
userDataModel
=
new
UserApi
(
that
.
ctx
);
let
result
=
yield
api
.
all
([
let
result
=
yield
Promise
.
all
([
userDataModel
.
getUserInfo
(
uid
),
userDataModel
.
getTipConfig
(
uid
),
userDataModel
.
getUserContactInfo
(
uid
),
...
...
apps/product/controllers/search.js
View file @
30e5fea
...
...
@@ -153,6 +153,7 @@ const searchHistory = (req, res) => {
history
=
_
.
filter
(
history
.
split
(
','
),
old
=>
old
&&
old
!==
q
);
if
(
q
)
{
sear
;
history
.
unshift
(
q
);
res
.
cookie
(
'_History'
,
_
.
take
(
history
,
9
).
join
(
','
),
{
path
:
'/'
,
...
...
apps/product/models/sale.js
View file @
30e5fea
...
...
@@ -6,7 +6,6 @@
*/
'use strict'
;
const
api
=
global
.
yoho
.
API
;
const
Promise
=
require
(
'bluebird'
);
const
querystring
=
require
(
'querystring'
);
...
...
@@ -145,7 +144,7 @@ function getSaleGoodsData(params, vipLevel) {
* @return {[type]} [description]
*/
function
getSaleIndexData
(
channel
)
{
return
api
.
all
([
return
Promise
.
all
([
headerModel
.
requestHeaderData
(
channel
),
this
.
saleApi
.
getSaleActivityList
(
''
,
channel
),
this
.
saleApi
.
getSaleBannerList
(
contentCode
[
channel
].
sale
),
...
...
@@ -255,7 +254,7 @@ function getSaleOthersData(params, channel) {
baseUrl
+=
'/newSale'
;
}
return
api
.
all
(
promiseObject
).
then
(
result
=>
{
return
Promise
.
all
(
promiseObject
).
then
(
result
=>
{
let
finalResult
=
result
[
0
];
// 获取商品数据
...
...
@@ -380,7 +379,7 @@ function _setSaleDiscountData(info) {
* @return {[type]} [description]
*/
function
getSaleDiscountData
(
params
,
channel
)
{
return
api
.
all
([
return
Promise
.
all
([
headerModel
.
requestHeaderData
(
channel
),
this
.
saleApi
.
getSaleActivityList
(
params
,
channel
)
]).
then
(
result
=>
{
...
...
@@ -408,7 +407,7 @@ function getSaleDiscountData(params, channel) {
}
// 这里把 channel 全都处理掉,因为根据channel查小分类,而传入商品池时,不需要
return
api
.
all
([
return
Promise
.
all
([
this
.
saleApi
.
getSaleGoodsList
({
channel
:
null
,
saleType
:
'3'
,
...
...
@@ -473,7 +472,7 @@ function getSaleDiscountData(params, channel) {
function
getSalebreakingYardsData
(
params
,
channel
)
{
const
baseUrl
=
`
/
$
{
_
.
toLower
(
channel
)}
-
sale
/
breakingYards
`
;
return
api
.
all
([
return
Promise
.
all
([
headerModel
.
requestHeaderData
(
channel
,
true
),
this
.
saleApi
.
getSaleBannerList
(
contentCode
[
channel
].
breakCode
),
this
.
saleApi
.
getSalebreakingYardsSortList
(
params
)
...
...
@@ -502,7 +501,7 @@ function getSalebreakingYardsData(params, channel) {
});
}
return
api
.
all
([
return
Promise
.
all
([
this
.
saleApi
.
getSaleGoodsList
({
channel
:
channel
,
saleType
:
'5'
,
// app 与 pc 有冲突,为 PC 加一个 5 的选项
...
...
apps/product/models/search.js
View file @
30e5fea
...
...
@@ -5,8 +5,6 @@
'use strict'
;
const
utils
=
'../../../utils'
;
const
api
=
global
.
yoho
.
API
;
const
Promise
=
require
(
'bluebird'
);
const
co
=
Promise
.
coroutine
;
const
helpers
=
global
.
yoho
.
helpers
;
...
...
@@ -158,7 +156,7 @@ function getSearchData(params, channel) {
this
.
searchApi
.
getShopList
(
params
)
];
return
api
.
all
(
apiMethod
).
then
(
result
=>
{
return
Promise
.
all
(
apiMethod
).
then
(
result
=>
{
if
(
_
.
get
(
result
,
'[2].data.isChangedQuery'
,
''
)
===
'Y'
)
{
return
this
.
searchApi
.
getSortList
(
Object
.
assign
({},
searchParams
,
{
msort
:
''
,
...
...
@@ -462,7 +460,7 @@ function getSearchKeywordData(params, channel) {
this
.
searchApi
.
getSeoProductList
(
searchParams
,
'fuzzySearch'
)
];
return
api
.
all
(
apiMethod
).
then
(
result
=>
{
return
Promise
.
all
(
apiMethod
).
then
(
result
=>
{
return
_setSearchKeywordData
(
result
,
params
,
channel
);
});
...
...
apps/shop/controllers/shop.js
View file @
30e5fea
...
...
@@ -52,7 +52,7 @@ const apply = (req, res, next) => {
footerTop
:
true
};
Promise
.
all
([
headerModel
.
requestHeaderData
(
channel
),
shopService
.
applyAction
()]).
then
(
result
=>
{
Promise
.
all
([
headerModel
.
requestHeaderData
(
channel
),
req
.
ctx
(
shopService
)
.
applyAction
()]).
then
(
result
=>
{
responseData
.
headerData
=
result
[
0
].
headerData
;
responseData
.
oneCategory
=
result
[
1
];
responseData
.
uploadKey
=
base64StrEncode
(
authcode
(
JSON
.
stringify
(
adpic
),
...
...
@@ -75,7 +75,7 @@ const getTwoCategoryAction = (req, res, next) => {
return
data
;
}
shopService
.
getTwoCategory
(
id
).
then
(
result
=>
{
req
.
ctx
(
shopService
)
.
getTwoCategory
(
id
).
then
(
result
=>
{
res
.
json
(
result
);
}).
catch
(
next
);
};
...
...
@@ -174,7 +174,7 @@ const applysave = (req, res, next) => {
param
.
storeInfo
=
JSON
.
stringify
(
storeInfo
);
param
.
uid
=
uid
;
shopService
.
insertApply
(
param
).
then
(
result
=>
{
req
.
ctx
(
shopService
)
.
insertApply
(
param
).
then
(
result
=>
{
res
.
json
(
result
);
}).
catch
(
next
);
};
...
...
apps/shop/models/shop-service.js
View file @
30e5fea
'use strict'
;
const
_
=
require
(
'lodash'
);
const
api
=
global
.
yoho
.
API
;
/**
* 获取一级品类
* @return type []
*/
const
applyAction
=
()
=>
{
return
api
.
get
(
''
,
{
method
:
'app.category.queryMax'
function
applyAction
()
{
return
this
.
get
({
data
:
{
method
:
'app.category.queryMax'
}
}).
then
((
result
)
=>
{
if
(
result
.
code
&&
result
.
code
===
200
)
{
let
list
=
[];
...
...
@@ -25,17 +24,19 @@ const applyAction = () => {
return
list
;
}
});
}
;
}
/**
* 获取二级品类
* @return type []
*/
const
getTwoCategory
=
(
id
)
=>
{
function
getTwoCategory
(
id
)
{
return
api
.
get
(
''
,
{
method
:
'app.category.queryMin'
,
parent_id
:
id
return
this
.
get
({
data
:
{
method
:
'app.category.queryMin'
,
parent_id
:
id
}
}).
then
((
result
)
=>
{
if
(
result
.
code
&&
result
.
code
===
200
)
{
let
list
=
[];
...
...
@@ -52,50 +53,56 @@ const getTwoCategory = (id) => {
return
result
;
}
});
}
;
}
/**
* 添加入驻申请保存
* @return type []
*/
const
insertApply
=
(
param
)
=>
{
function
insertApply
(
param
)
{
return
api
.
get
(
''
,
{
method
:
'app.shops.insertApply'
,
brandName
:
param
.
brandName
,
registerStatus
:
param
.
registerStatus
,
sellerName
:
param
.
sellerName
,
sellerAddress
:
param
.
sellerAddress
,
zipCode
:
param
.
zipCode
,
contacts
:
param
.
contacts
,
contactPhone
:
param
.
contactPhone
,
contactEmail
:
param
.
contactEmail
,
sellerRole
:
param
.
sellerRole
,
brandWebsite
:
param
.
brandWebsite
,
onlineShopWebsite
:
param
.
onlineShopWebsite
,
categoryInfo
:
param
.
categoryInfo
,
billingCycle
:
param
.
billingCycle
,
warehouseAddress
:
param
.
warehouseAddress
,
producer
:
param
.
producer
,
invoiceType
:
param
.
invoiceType
,
newCycle
:
param
.
newCycle
,
quarterNum
:
param
.
quarterNum
,
supplyCycle
:
param
.
supplyCycle
,
haveStore
:
param
.
haveStore
,
storeInfo
:
param
.
storeInfo
,
brandMaterial
:
param
.
brandMaterial
,
goodsMaterial
:
param
.
goodsMaterial
,
uid
:
param
.
uid
return
this
.
get
({
data
:
{
method
:
'app.shops.insertApply'
,
brandName
:
param
.
brandName
,
registerStatus
:
param
.
registerStatus
,
sellerName
:
param
.
sellerName
,
sellerAddress
:
param
.
sellerAddress
,
zipCode
:
param
.
zipCode
,
contacts
:
param
.
contacts
,
contactPhone
:
param
.
contactPhone
,
contactEmail
:
param
.
contactEmail
,
sellerRole
:
param
.
sellerRole
,
brandWebsite
:
param
.
brandWebsite
,
onlineShopWebsite
:
param
.
onlineShopWebsite
,
categoryInfo
:
param
.
categoryInfo
,
billingCycle
:
param
.
billingCycle
,
warehouseAddress
:
param
.
warehouseAddress
,
producer
:
param
.
producer
,
invoiceType
:
param
.
invoiceType
,
newCycle
:
param
.
newCycle
,
quarterNum
:
param
.
quarterNum
,
supplyCycle
:
param
.
supplyCycle
,
haveStore
:
param
.
haveStore
,
storeInfo
:
param
.
storeInfo
,
brandMaterial
:
param
.
brandMaterial
,
goodsMaterial
:
param
.
goodsMaterial
,
uid
:
param
.
uid
}
}).
then
((
result
)
=>
{
if
(
result
.
code
&&
result
.
code
===
200
)
{
return
result
;
}
});
};
}
module
.
exports
=
class
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
super
(
ctx
);
module
.
exports
=
{
applyAction
,
getTwoCategory
,
insertApply
this
.
applyAction
=
applyAction
.
bind
(
this
);
this
.
getTwoCategory
=
getTwoCategory
.
bind
(
this
);
this
.
insertApply
=
insertApply
.
bind
(
this
);
}
};
...
...
Please
register
or
login
to post a comment