Commit c852001d by 孙亚楠

d

parent 7420790e
......@@ -77,6 +77,9 @@ class ActionAPI extends APIBase {
case "getMerchantLiveProduct":// 查询商户下可用订单的产品
opResult = await this.eorderSve.getMerchantLiveProduct(action_body);
break;
case "getMerchantLiveAllProducts":// 查询商户下所有的订单产品
opResult = await this.eorderSve.getMerchantLiveAllProducts(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -105,5 +105,23 @@ class EorderDao extends Dao{
return await this.customQuery(sql.join(" "), {merchantId: merchantId});
}
/**
* fn:查询商户下所有订单的产产品
* @param merchant_id
* @returns {Promise<void>}
*/
async getMerchantLiveAllProducts(merchant_id){
let sql = [];
sql.push("SELECT");
sql.push(" t1.product_property, t1.product_id, t1.product_name");
sql.push("FROM e_order_product t1");
sql.push("INNER JOIN e_order t2 ON t1.order_id = t2.id");
sql.push("WHERE t2.merchant_id = :merchant_id");
sql.push("AND t2.live_status = '20' AND t2.engine_account_id <> ''");
sql.push("ORDER BY t1.`created_at` ASC");
return await this.customQuery(sql.join(" "), {merchant_id: merchant_id});
}
}
module.exports=EorderDao;
......@@ -436,5 +436,34 @@ class EorderService extends ServiceBase {
let res = await this.dao.getMerchantLiveProduct(params.merchant_id);
return system.getResultSuccess(res);
}
/**
* fn:查询商户下可用订单的产品(所有)
* @param params
* @returns {Promise<{msg: *, data, status: number}>}
*/
async getMerchantLiveAllProducts(params) {
if (!params.merchant_id) {
return system.getResultSuccess([]);
}
try{
let res = await this.dao.getMerchantLiveAllProducts(params.merchant_id);
let map = {};
for (let item of res) {
map[item.product_id]=item || {};
}
let arr = [];
for(let ele in map){
arr.push(map[ele]);
}
return system.getResultSuccess(arr);
}catch (e) {
console.log(e);
system.getResult(null, `系统错误`);
}
}
}
module.exports = EorderService;
\ 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