Commit 736890f0 by 蒋勇

d

parent 2ae532b5
...@@ -5,43 +5,43 @@ class ProductService extends ServiceBase { ...@@ -5,43 +5,43 @@ class ProductService extends ServiceBase {
super("product", ServiceBase.getDaoName(ProductService)); super("product", ServiceBase.getDaoName(ProductService));
this.priceDao = system.getObject("db.product.productpriceDao") this.priceDao = system.getObject("db.product.productpriceDao")
} }
async findPriceStrategys(stragetyids,t){ async findPriceStrategys (stragetyids, t) {
//按照策略id查询出定价策略集合 //按照策略id查询出定价策略集合
let pts=await this.db.models.pricestrategy.findAll({ where: { id: { [this.db.Op.in]: stragetyids } },attributes:['id','optionunion'],transaction:t}) let pts = await this.db.models.pricestrategy.findAll({ where: { id: { [this.db.Op.in]: stragetyids } }, attributes: ['id', 'optionunion'], transaction: t })
let tmpdic={} let tmpdic = {}
pts.forEach(p=>{ pts.forEach(p => {
tmpdic[p.id+'']=p.optionunion tmpdic[p.id + ''] = p.optionunion
}) })
return tmpdic return tmpdic
} }
async create(p) { async create (p) {
if (!p.name || p.name == "") { if (!p.name || p.name == "") {
p.name = p.productcatpath+ "~" + p.regionpath p.name = p.productcatpath + "~" + p.regionpath
} }
//策略ids //策略ids
let stragetyids = p.sts let stragetyids = p.sts
let skucodemap=p.skucodemap let skucodemap = p.skucodemap
var self = this; var self = this;
return this.db.transaction(async function (t) { return this.db.transaction(async function (t) {
let pnew = await self.dao.create(p, t) let pnew = await self.dao.create(p, t)
let productprices = [] let productprices = []
//按照策略id查询出定价策略集合 //按照策略id查询出定价策略集合
let tmpdic=await self.findPriceStrategys(stragetyids,t) let tmpdic = await self.findPriceStrategys(stragetyids, t)
stragetyids.forEach(stragetyid => { stragetyids.forEach(stragetyid => {
if(skucodemap){ if (skucodemap) {
p.skucode=skucodemap[stragetyid] p.skucode = skucodemap[stragetyid]
} }
let pps = { let pps = {
product_id: pnew.id, product_id: pnew.id,
pricestrategy_id: stragetyid, pricestrategy_id: stragetyid,
pname:p.name, pname: p.name,
strategyitems:tmpdic[stragetyid+''], strategyitems: tmpdic[stragetyid + ''],
company_id:p.company_id, company_id: p.company_id,
skucode:p.skucode?p.skucode:self.getUUID(), skucode: p.skucode ? p.skucode : self.getUUID(),
skuname:p.skuname?p.skuname:p.name, skuname: p.skuname ? p.skuname : p.name,
sptags:p.sptags, sptags: p.sptags,
channeltags:p.channeltags channeltags: p.channeltags
} }
productprices.push(pps) productprices.push(pps)
}) })
...@@ -49,7 +49,7 @@ class ProductService extends ServiceBase { ...@@ -49,7 +49,7 @@ class ProductService extends ServiceBase {
return pnew; return pnew;
}); });
} }
async update(p) { async update (p) {
if (!p.name || p.name == "") { if (!p.name || p.name == "") {
p.name = p.regionpath + "~" + p.productcatpath p.name = p.regionpath + "~" + p.productcatpath
} }
...@@ -63,44 +63,44 @@ class ProductService extends ServiceBase { ...@@ -63,44 +63,44 @@ class ProductService extends ServiceBase {
//在传入中的不做处理 //在传入中的不做处理
let currentProduct = await self.dao.model.findOne({ let currentProduct = await self.dao.model.findOne({
where: { id: p.id }, include: [ 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 ], transaction: t
}) })
let notInInput=[]//需要删除 let notInInput = []//需要删除
let skusarray=[] let skusarray = []
currentProduct.skus.forEach(sku=>{ currentProduct.skus.forEach(sku => {
skusarray.push(sku.pricestrategy_id) skusarray.push(sku.pricestrategy_id)
if(stragetyids.indexOf(sku.pricestrategy_id)<0){ if (stragetyids.indexOf(sku.pricestrategy_id) < 0) {
notInInput.push(sku.id) notInInput.push(sku.id)
} }
}) })
//删除 //删除
if(notInInput.length>0){ if (notInInput.length > 0) {
await self.priceDao.bulkDelete(notInInput,t) await self.priceDao.bulkDelete(notInInput, t)
} }
//传入不在查出中的,需要新增 //传入不在查出中的,需要新增
let notintables=[] let notintables = []
stragetyids.forEach(st=>{ stragetyids.forEach(st => {
if(skusarray.indexOf(st)<0){ if (skusarray.indexOf(st) < 0) {
notintables.push(st) notintables.push(st)
} }
}) })
//新增 //新增
let productprices = [] let productprices = []
let tmpdic=await self.findPriceStrategys(stragetyids,t) let tmpdic = await self.findPriceStrategys(stragetyids, t)
notintables.forEach(stragetyid => { notintables.forEach(stragetyid => {
let pps = { let pps = {
product_id: p.id, product_id: p.id,
pricestrategy_id: stragetyid, pricestrategy_id: stragetyid,
pname:p.name, pname: p.name,
strategyitems:tmpdic[stragetyid+''], strategyitems: tmpdic[stragetyid + ''],
company_id:p.company_id, company_id: p.company_id,
skucode:this.getUUID(), skucode: self.getUUID(),
skuname:p.name, skuname: p.name,
} }
productprices.push(pps) productprices.push(pps)
}) })
if(productprices.length>0){ if (productprices.length > 0) {
await self.priceDao.bulkCreate(productprices, t) await self.priceDao.bulkCreate(productprices, t)
} }
return {}; return {};
......
...@@ -33,3 +33,39 @@ ...@@ -33,3 +33,39 @@
5、K8s环境搭建 5、K8s环境搭建
--提供k8集群/镜像服务--git push tag--自动打包 --提供k8集群/镜像服务--git push tag--自动打包
--我们提供yaml上线文件/Dockerfile --我们提供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