Commit 8e83344a by 王昆

gsb

parent 8fc483a8
......@@ -5,5 +5,23 @@ class OproductDao extends Dao {
super(Dao.getModelName(OproductDao));
}
async findListByPid(pid) {
let sql = "SELECT * FROM o_product WHERE pid = :pid ORDER BY sort ASC";
return await this.customQuery(sql, {pid: pid});
}
async findMapByPid(pid) {
let result = {};
let list = await this.findListByPid(pid);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return item.id;
}
}
module.exports = OproductDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class OproductprocessDao extends Dao {
constructor() {
super(Dao.getModelName(OproductprocessDao));
......@@ -7,15 +8,17 @@ class OproductprocessDao extends Dao {
/**
* 根据 productId 和 status 查询 商品
* @param {*} productId
* @param {*} status
* @param {*} productId
* @param {*} status
*/
async findByProductIdAndStatus(productId,status){
async findByProductIdAndStatus(productId, status) {
try {
let _productProcess =await this.model.findOne({where:{
productId:productId,
status:status
}});
let _productProcess = await this.model.findOne({
where: {
productId: productId,
status: status
}
});
return _productProcess || {};
} catch (error) {
console.log(`系统错误 错误信息 ${error}`);
......@@ -23,5 +26,36 @@ class OproductprocessDao extends Dao {
}
}
async findMapByProductProductIds(productPid, productIds) {
let result = {};
let sql = [];
sql.push("SELECT");
sql.push("*");
sql.push("FROM o_product_process");
sql.push("WHERE product_pid = :productPid");
if (productIds && productIds.length > 0) {
sql.push("AND product_id IN (:productIds)");
}
sql.push("ORDER BY sort ASC");
let list = await this.customQuery(sql, {productPid: productPid, productIds: productIds});
if (!list || list.length) {
return result;
}
for (let item of list) {
let productId = item.product_id;
let items = result[productId];
if (!items) {
items = [];
}
items.push(item);
result[key] = items;
}
return result;
}
}
module.exports = OproductprocessDao;
\ No newline at end of file
......@@ -51,7 +51,7 @@ class OorderService extends ServiceBase {
}
// 获取产品状态
await this.getProductProcess();
await this.getProductProcessList(productId, );
// 查询产品订单状态
......@@ -79,33 +79,42 @@ class OorderService extends ServiceBase {
// 调用状态func(order, nextObj, params)
}
async getProductProcessList(params) {
var options = {};
options.where = params;
options.raw = true;
options.order = [['sort', 'ASC']];
var oplist = await this.oproductprocessDao.model.findAll(options);
if (!oplist) {
return [];
/**
* 构建产品流程对象
* @param productPid
* @param chooseProductIds
* @returns {Promise<void>}
*/
async getProductProcessList(productPid, chooseProductIds) {
// 查询所有产品子项
let productList = await this.oproductDao.findListByPid(productPid);
// 根据所选产品id, 查询产品流程
let productIds = [];
for (let product of productList) {
// 过滤未选择产品
if(product.is_choose && chooseProductIds && chooseProductIds.indexOf(product.id) == -1) {
continue;
}
productIds.push(product.id);
}
let processIds = [];
for (var item of oplist) {
processIds.push(item.processId);
if (productIds.length == 0) {
return null;
}
var optionsProcess = {};
optionsProcess.where = {
// 查询产品流程
let processMap = await this.oproductprocessDao.findMapByProductProductIds(productPid, productIds);
let orderProcessList = [];
};
optionsProcess.raw = true;
optionsProcess.order = [['sort', 'ASC']];
for (let productId of productIds) {
let currentProcess = processMap[productId];
let orderProcess = {};
if (processList.length > 0) {
let lastProcess = productList[processList.length - 1];
}
}
await this.oprocessDao.model.findAll();
}
}
module.exports = OorderService;
\ No newline at end of file
......@@ -7,7 +7,12 @@ class OproductService extends ServiceBase {
constructor() {
super("product", ServiceBase.getDaoName(OproductService));
this.oproductprocessDao = system.getObject("db.product.oproductprocessDao");
this.iborderbaseDao = system.getObject("db.product.iborderbaseDao");
}
async getProcessList(productPid, productIds) {
}
/**
......
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