Commit 72212885 by linboxuan

ucommune-back api add

parent 81798486
...@@ -26,9 +26,27 @@ class ucommuneOrder extends APIBase { ...@@ -26,9 +26,27 @@ class ucommuneOrder extends APIBase {
async opActionProcess(pobj, action_type, req) { async opActionProcess(pobj, action_type, req) {
var opResult = null; var opResult = null;
switch (action_type) { switch (action_type) {
case "ucommuneGetOrderList": case "ucommuneGetOrderList":// uk后端订单拉取功能
opResult = await this.ucommuneOrderSve.getOrderInfo(pobj,pobj.actionBody); opResult = await this.ucommuneOrderSve.getOrderInfo(pobj,pobj.actionBody);
break; break;
case "getStatistics":// 概览-业务统计
opResult = await this.ucommuneOrderSve.getStatistics(pobj, pobj.actionBody);
break;
case "getTrend":// 概览-业务统计
opResult = await this.ucommuneOrderSve.getTrend(pobj, pobj.actionBody);
break;
case "getProductTypesales":// 概览-产品销售分布
opResult = await this.ucommuneOrderSve.getProductTypesales(pobj, pobj.actionBody);
break;
case "getCustomerArea":// 概览-客户地域分布
opResult = await this.ucommuneOrderSve.getCustomerArea(pobj, pobj.actionBody);
break;
case "getOrderInfo":// 订单列表
opResult = await this.ucommuneOrderSve.getOrderInfo(pobj, pobj.actionBody);
break;
case "getOrderDelivery":// 订单详情
opResult = await this.ucommuneOrderSve.getOrderDelivery(pobj, pobj.actionBody);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
...@@ -3,6 +3,8 @@ const ServiceBase = require("../../sve.base"); ...@@ -3,6 +3,8 @@ const ServiceBase = require("../../sve.base");
class OrderInfoService extends ServiceBase { class OrderInfoService extends ServiceBase {
constructor() { constructor() {
super("dbcorder", ServiceBase.getDaoName(OrderInfoService)); super("dbcorder", ServiceBase.getDaoName(OrderInfoService));
this.orderInfoDao = system.getObject("db.dbcorder.orderinfoDao");
this.needInfoDao = system.getObject("db.dbneed.needinfoDao");
} }
async getOrderInfo(pobj, actionBody) {//获取订单列表信息 async getOrderInfo(pobj, actionBody) {//获取订单列表信息
...@@ -50,5 +52,36 @@ class OrderInfoService extends ServiceBase { ...@@ -50,5 +52,36 @@ class OrderInfoService extends ServiceBase {
return result; return result;
} }
async getStatistics(pobj, actionBody) {// uk运营后台 业务统计
var needsCount = await this.needInfoDao.findCount({where:{uapp_id:actionBody.uappId}});// 需求量
var sql = "SELECT DISTINCT need.needNo,count(1) as count "
+ " FROM n_need_info AS need LEFT JOIN n_need_solution AS solution ON need.needNo = solution.needNo "
+ " where solution.orderNo is not null and need.uapp_id = " + actionBody.uappId;
var conversionRateList = await this.needInfoDao.customQuery(sql);
if(conversionRateList.length != 1) {
conversionRate = 0;
}
var conversionRate = (conversionRateList[0]["count"] / needsCount).toFixed(2);// 需求订单转化为订单的数量 保留两位
var sql = "select sum(totalSum) as totalSum,sum(pfProfitSum) as parentProfit,sum(channelProfitSum) as grossProfit, count(1) as count "
+ " from c_order_info where uapp_id=" + actionBody.uappId + " and orderStatus=2";
var payObj = await this.customQuery(sql);// 订单量/交易总额/公司宝结算额/对方毛利
if(payObj.length != 1) {
}
let resultObj = {
needsCount: needsCount,
payCount:payObj[0].count,
conversionRate: conversionRate,
paySumCount: payObj[0].totalSum,
parentProfit: payObj[0].parentProfit,
grossProfit: payObj[0].grossProfit
}
var result = system.getResultSuccess(resultObj);
return result;
}
} }
module.exports = OrderInfoService; module.exports = OrderInfoService;
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