Commit 736890f0 by 蒋勇

d

parent 2ae532b5
......@@ -5,43 +5,43 @@ class ProductService extends ServiceBase {
super("product", ServiceBase.getDaoName(ProductService));
this.priceDao = system.getObject("db.product.productpriceDao")
}
async findPriceStrategys(stragetyids,t){
async findPriceStrategys (stragetyids, t) {
//按照策略id查询出定价策略集合
let pts=await this.db.models.pricestrategy.findAll({ where: { id: { [this.db.Op.in]: stragetyids } },attributes:['id','optionunion'],transaction:t})
let tmpdic={}
pts.forEach(p=>{
tmpdic[p.id+'']=p.optionunion
let pts = await this.db.models.pricestrategy.findAll({ where: { id: { [this.db.Op.in]: stragetyids } }, attributes: ['id', 'optionunion'], transaction: t })
let tmpdic = {}
pts.forEach(p => {
tmpdic[p.id + ''] = p.optionunion
})
return tmpdic
}
async create(p) {
async create (p) {
if (!p.name || p.name == "") {
p.name = p.productcatpath+ "~" + p.regionpath
p.name = p.productcatpath + "~" + p.regionpath
}
//策略ids
let stragetyids = p.sts
let skucodemap=p.skucodemap
let skucodemap = p.skucodemap
var self = this;
return this.db.transaction(async function (t) {
let pnew = await self.dao.create(p, t)
let productprices = []
//按照策略id查询出定价策略集合
let tmpdic=await self.findPriceStrategys(stragetyids,t)
let tmpdic = await self.findPriceStrategys(stragetyids, t)
stragetyids.forEach(stragetyid => {
if(skucodemap){
p.skucode=skucodemap[stragetyid]
if (skucodemap) {
p.skucode = skucodemap[stragetyid]
}
let pps = {
product_id: pnew.id,
pricestrategy_id: stragetyid,
pname:p.name,
strategyitems:tmpdic[stragetyid+''],
company_id:p.company_id,
skucode:p.skucode?p.skucode:self.getUUID(),
skuname:p.skuname?p.skuname:p.name,
sptags:p.sptags,
channeltags:p.channeltags
pname: p.name,
strategyitems: tmpdic[stragetyid + ''],
company_id: p.company_id,
skucode: p.skucode ? p.skucode : self.getUUID(),
skuname: p.skuname ? p.skuname : p.name,
sptags: p.sptags,
channeltags: p.channeltags
}
productprices.push(pps)
})
......@@ -49,7 +49,7 @@ class ProductService extends ServiceBase {
return pnew;
});
}
async update(p) {
async update (p) {
if (!p.name || p.name == "") {
p.name = p.regionpath + "~" + p.productcatpath
}
......@@ -63,44 +63,44 @@ class ProductService extends ServiceBase {
//在传入中的不做处理
let currentProduct = await self.dao.model.findOne({
where: { id: p.id }, include: [
{model: self.db.models.productprice, as:"skus",attributes: ['id', 'pricestrategy_id'],raw:true},
{ model: self.db.models.productprice, as: "skus", attributes: ['id', 'pricestrategy_id'], raw: true },
], transaction: t
})
let notInInput=[]//需要删除
let skusarray=[]
currentProduct.skus.forEach(sku=>{
let notInInput = []//需要删除
let skusarray = []
currentProduct.skus.forEach(sku => {
skusarray.push(sku.pricestrategy_id)
if(stragetyids.indexOf(sku.pricestrategy_id)<0){
if (stragetyids.indexOf(sku.pricestrategy_id) < 0) {
notInInput.push(sku.id)
}
})
//删除
if(notInInput.length>0){
await self.priceDao.bulkDelete(notInInput,t)
}
//删除
if (notInInput.length > 0) {
await self.priceDao.bulkDelete(notInInput, t)
}
//传入不在查出中的,需要新增
let notintables=[]
stragetyids.forEach(st=>{
if(skusarray.indexOf(st)<0){
let notintables = []
stragetyids.forEach(st => {
if (skusarray.indexOf(st) < 0) {
notintables.push(st)
}
})
//新增
let productprices = []
let tmpdic=await self.findPriceStrategys(stragetyids,t)
let tmpdic = await self.findPriceStrategys(stragetyids, t)
notintables.forEach(stragetyid => {
let pps = {
product_id: p.id,
pricestrategy_id: stragetyid,
pname:p.name,
strategyitems:tmpdic[stragetyid+''],
company_id:p.company_id,
skucode:this.getUUID(),
skuname:p.name,
pname: p.name,
strategyitems: tmpdic[stragetyid + ''],
company_id: p.company_id,
skucode: self.getUUID(),
skuname: p.name,
}
productprices.push(pps)
})
if(productprices.length>0){
if (productprices.length > 0) {
await self.priceDao.bulkCreate(productprices, t)
}
return {};
......
......@@ -33,3 +33,39 @@
5、K8s环境搭建
--提供k8集群/镜像服务--git push tag--自动打包
--我们提供yaml上线文件/Dockerfile
仓库
web-deliver-center 交付中心前端
web-deliver-bussiness 工商交付前端
api-deliver-bussiness 工商交付后台
web-deliver-vat 增值电信前端
api-deliver-vat 增值电信后台
task-deliver 日常任务
仓库到YAML映射
后台(前端代码直接内置到后台服务的public目录下)
api-deliver-center 交付中心后台 -> paas-deployment.yaml
api-deliver-bussiness 工商交付后台 ->ic-deployment.yaml
api-deliver-vat 增值电信后台 -> icp-deployment.yaml
task-deliver 日常任务 ->1.icp_filebuild_cronjobs.yaml
task-deliver 日常任务 ->2.ic_filebuild_cronjobs.yaml
1.中台镜像center-manage
路由域名:delivery.brg.tencentyun.com
后台服务:paas-service
2.工商交付镜像 ic-deliver
路由域名:ic.brg.tencentyun.com
后台服务:icdeliver-service
3.ICP交付镜像 icp-deliver
路由域名:http://icp.brg.tencentyun.com/
后台服务:icpdeliver-service
4.任务镜像 center-taskexecutor
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment