Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
1b663fe1
Commit
1b663fe1
authored
Jan 07, 2020
by
庄冰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
productSve
parent
209fd1cf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
0 deletions
+100
-0
center-app/app/base/service/impl/dbproduct/productSve.js
+100
-0
No files found.
center-app/app/base/service/impl/dbproduct/productSve.js
View file @
1b663fe1
...
...
@@ -5,6 +5,106 @@ const settings = require("../../../../config/settings");
class
ProductService
extends
ServiceBase
{
constructor
()
{
super
(
"dbproduct"
,
ServiceBase
.
getDaoName
(
ProductService
));
this
.
productpriceDao
=
system
.
getObject
(
"db.dbproduct.productpriceDao"
);
}
/**
* 获取产品详情
* @param {*} pid 产品id
*/
async
getProductDetailById
(
pid
){
if
(
!
pid
){
return
system
.
getResult
(
null
,
"产品id有误"
);
}
var
sql
=
"select * from v_product where id="
+
pid
;
var
tmpResult
=
await
this
.
customQuery
(
sql
);
if
(
tmpResult
&&
tmpResult
.
length
>
0
){
for
(
var
i
=
0
;
i
<
tmpResult
.
length
;
i
++
){
var
pro
=
tmpResult
[
i
];
if
(
pro
.
id
){
var
ppList
=
await
this
.
productpriceDao
.
model
.
findAll
({
where
:{
product_id
:
pro
.
id
},
attributes
:
[
"price"
,
"supply_price"
,
"service_charge"
,
"public_expense"
,
"is_default"
,
"price_type"
,
"price_type_name"
,
"sort"
,
"price_desc"
,
"min_qty"
,
"max_qty"
],
raw
:
true
});
pro
.
productPriceList
=
ppList
;
}
}
}
return
system
.
getResultSuccess
(
tmpResult
);
}
/**
* 获取产品详情2
* @param {*} pcode 产品码
* @param {*} appid 渠道id
*/
async
getProductDetailByCode
(
pcode
,
appid
){
if
(
!
pcode
){
return
system
.
getResult
(
null
,
"产品编码有误"
);
}
if
(
!
appid
){
return
system
.
getResult
(
null
,
"渠道编码有误"
);
}
var
sql
=
"select * from v_product where uapp_id="
+
appid
+
" and item_code='"
+
pcode
+
"'"
;
var
tmpResult
=
await
this
.
customQuery
(
sql
);
if
(
tmpResult
&&
tmpResult
.
length
>
0
){
for
(
var
i
=
0
;
i
<
tmpResult
.
length
;
i
++
){
var
pro
=
tmpResult
[
i
];
if
(
pro
.
id
){
var
ppList
=
await
this
.
productpriceDao
.
model
.
findAll
({
where
:{
product_id
:
pro
.
id
},
attributes
:
[
"price"
,
"supply_price"
,
"service_charge"
,
"public_expense"
,
"is_default"
,
"price_type"
,
"price_type_name"
,
"sort"
,
"price_desc"
,
"min_qty"
,
"max_qty"
],
raw
:
true
});
pro
.
productPriceList
=
ppList
;
}
}
}
return
system
.
getResultSuccess
(
tmpResult
);
}
/**
* 通过产品类别编码获取产品列表
* @param {*} obj
*/
async
findByTypeCode
(
obj
){
var
app
=
obj
.
app
;
if
(
!
app
||
!
app
.
id
){
return
system
.
getResult
(
null
,
"渠道参数有误"
);
}
var
typeCode
=
obj
.
typeCode
;
if
(
!
typeCode
){
return
system
.
getResult
(
null
,
"产品类别编码有误"
);
}
var
sql
=
"select * from v_product where uapp_id="
+
app
.
id
+
" and type_code='"
+
typeCode
+
"'"
;
var
tmpResult
=
await
this
.
customQuery
(
sql
);
return
system
.
getResultSuccess
(
tmpResult
);
}
/**
* 通过产品大类编码获取产品列表
* @param {*} obj
*/
async
findByTypeOneCode
(
obj
){
var
app
=
obj
.
app
;
if
(
!
app
||
!
app
.
id
){
return
system
.
getResult
(
null
,
"渠道参数有误"
);
}
var
typeOneCode
=
obj
.
typeOneCode
;
if
(
!
typeOneCode
){
return
system
.
getResult
(
null
,
"产品类别编码有误"
);
}
var
sql
=
"select * from v_product where uapp_id="
+
app
.
id
+
" and p_type_code='"
+
typeOneCode
+
"'"
;
var
tmpResult
=
await
this
.
customQuery
(
sql
);
return
system
.
getResultSuccess
(
tmpResult
);
}
}
module
.
exports
=
ProductService
;
// var task = new ProductService();
// task.getProductDetailByCode("test002",7).then(d=>{
// console.log(d,"ddddddddddddddddddddddddddddddddddddddddddddddd");
// console.log(d.data[0],"eeeee");
// });
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment