Commit 3eadbdde by 王昆

Merge branch 'xggsve-order-dev' into xggsve-order

parents aa7e6274 0e24e28a
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "启动程序",
"program": "${workspaceFolder}/xggsve-order/main.js"
}
]
}
\ No newline at end of file
......@@ -22,24 +22,7 @@
5、利用k8s上线镜像为运行容器(这一步后续会实现为自动化)
项目版本号段分配
0、bigdata release-v0.x.x
1、igirl-web release-v1.x.x
2、igirl-zcapi release-v2.x.x
3、igirl-channel-web release-v3.x.x
4、igirl-channel release-v4.x.x
5、scratch-web release-v5.x.x
6、ipself-web release-v6.x.x
7. ipop-web release-v7.x.x
8. bpo-web release-v8.x.x
9. bpo-admin release-v9.x.x
10. laowubao release-v10.x.x
11. xggsve-common release-v11.x.x
12. xggsve-merchant release-v12.x.x
13. xggsve-order release-v13.x.x
14. xggsve-invoice release-v14.x.x
15. xggpc release-v15.x.x
16. xggadmin release-v16.x.x
17. xggweb release-v17.x.x
后续号端请继续补充
查看自己项目号段到达的数字,执行git tag | grep v【号段前缀】
......
......@@ -70,7 +70,7 @@ class APIBase extends DocBase {
async doexec(gname, methodname, pobj, query, req) {
var requestid = this.getUUID();
try {
var rtn = await this[methodname](pobj, query, req);
var rtn = await this[methodname](pobj, query, req) || {};
rtn.requestid = requestid;
this.oplogSve.createDb({
......
......@@ -4,11 +4,23 @@ var settings = require("../../../../config/settings");
class ActionAPI extends APIBase {
constructor() {
super();
this.iborderbaseSve = system.getObject("service.order.iborderbaseSve");
this.ibdeliverbaseSve = system.getObject("service.order.ibdeliverbaseSve");
this.iborderSve = system.getObject("service.order.iborderSve");
this.iborderdeliverSve = system.getObject("service.order.iborderdeliverSve");
this.businessmenSve = system.getObject("service.business.businessmenSve");
this.businessmencontractSve = system.getObject("service.business.businessmencontractSve");
//-----------------------------------------------------------------------------------------
this.oorderSve = system.getObject("service.order.oorderSve");
this.oorderdeliverSve = system.getObject("service.order.oorderdeliverSve");
this.oorderstatusSve = system.getObject("service.order.oorderstatusSve");
this.oprocessSve = system.getObject("service.product.oprocessSve");
this.oproductSve = system.getObject("service.product.oproductSve");
this.obusinessmenSve = system.getObject("service.order.obusinessmenSve");
}
/**
* 接口跳转
......@@ -35,129 +47,205 @@ class ActionAPI extends APIBase {
async handleRequest(action_process, action_type, action_body) {
var opResult = null;
switch (action_type) {
// 订单
case "addOrder":
opResult = await this.iborderSve.apiAdd(action_body);
break;
case "updOrder":
opResult = await this.iborderSve.apiUpd(action_body);
break;
case "allOrderList":
opResult = await this.iborderSve.apiAllList(action_body);
break;
case "orderInfo":
opResult = await this.iborderSve.apiInfo(action_body);
break;
case "orderInfoAll":
opResult = await this.iborderSve.apiAllInfo(action_body);
break;
case "byChannelOrderId":
opResult = await this.iborderSve.apiByChannelOrderId(action_body);
break;
case "orderEdit":
opResult = await this.iborderSve.apiEdit(action_body);
break;
case "orderAssign":
opResult = await this.iborderSve.apiAssign(action_body);
break;
case "myOrderPage":
opResult = await this.iborderSve.apiMyPage(action_body);
break;
case "orderPay":
opResult = await this.iborderSve.apiOrderPay(action_body);
break;
case "orderClose":
opResult = await this.iborderSve.apiOrderClose(action_body);
break;
case "closeOrderById":
opResult = await this.iborderSve.apiCloseById(action_body);
break;
case "orderComplete":
opResult = await this.iborderSve.apiComplete(action_body);
break;
case "orderByDeliverId":
opResult = await this.iborderSve.apiByDeliverId(action_body);
break;
try{
switch (action_type) {
case "orderInfo": // 查订单信息
opResult = await this.oorderSve.info(action_body);
break;
case "orderInfoAll": // 查订单信息
opResult = await this.oorderSve.infoAll(action_body);
break;
// 订单办理
case "orderDeliverList":
opResult = await this.iborderdeliverSve.apiPage(action_body);
break;
case "orderDeliverHandle":
opResult = await this.iborderdeliverSve.apiHandle(action_body);
break;
case "orderDeliverInfo":
opResult = await this.iborderdeliverSve.apiInfo(action_body);
break;
case "orderDeliverEdit":
opResult = await this.iborderdeliverSve.apiEdit(action_body);
break;
case "orders": //订单管理(平台)
opResult = await this.oorderSve.orders(action_body);
break;
case "orderDelivers": //订单管理(交付商)
opResult = await this.oorderdeliverSve.orderDelivers(action_body);
break;
case "orderDeliverAudit":
opResult = await this.iborderdeliverSve.apiAudit(action_body);
break;
case "handleStatus": //进度处理
opResult = await this.oorderstatusSve.handleStatus(action_body);
break;
case "orderDeliverClose":
opResult = await this.iborderdeliverSve.apiClose(action_body);
break;
case "addSourceOrder": // 创建来源订单
opResult = await this.oorderSve.addSourceOrder(action_body);
break;
// 个体户管理
case "businessmenByOrderId":
opResult = await this.businessmenSve.apiByOrderId(action_body);
break;
case "businessmenByChannelOrderNo":
opResult = await this.businessmenSve.apiByChannelOrderNo(action_body);
break;
case "businessmenNameList":
opResult = await this.businessmenSve.apiNameList(action_body);
break;
case "businessmenPage":
opResult = await this.businessmenSve.apiPage(action_body);
break;
case "businessmenInfo":
opResult = await this.businessmenSve.apiInfo(action_body);
break;
case "businessmenSign":
opResult = await this.businessmenSve.apiSign(action_body);
break;
case "businessmenSignPage":
opResult = await this.businessmenSve.apiSignPage(action_body);
break;
case "businessmenInfoPage":
opResult = await this.businessmenSve.apiInfoPage(action_body);
break;
case "businessmenUserPage":
opResult = await this.businessmenSve.apiUserPage(action_body);
break;
case "businessmenDeliverPage":
opResult = await this.businessmenSve.apiDeliverPage(action_body);
break;
case "addBusinessmenContract":
opResult = await this.businessmenSve.apiAddContract(action_body);
break;
case "productDics": // 查询产品字典
opResult = await this.oproductSve.productDics(action_body);
break;
case "businessmenCompleteMapByCreditCodes":
opResult = await this.businessmenSve.apiCompleteMapByCreditCodes(action_body);
break;
case "allProcess": // 查询业务进度
opResult = await this.oprocessSve.allNames(action_body);
break;
// 个体户
case "queryObusinessmen": //查询个体工商户信息
opResult = await this.obusinessmenSve.queryObusinessmen(action_body);
break;
case "businessmenPage":
opResult = await this.obusinessmenSve.businessmenPage(action_body);
break;
case "createAccount":
opResult = await this.obusinessmenSve.createAccount(action_body);
break;
case "signing":
opResult = await this.obusinessmenSve.signing(action_body);
break;
// 统计数据(平台)
case "statTransData": //数据简报
opResult = await this.oorderSve.statTransData(action_body);
break;
case "needToBeDealtWith": //待办事项
opResult = await this.oorderSve.needToBeDealtWith(action_body);
break;
case "statDeliverData": //交付商统计
opResult = await this.oorderdeliverSve.statDeliverData(action_body);
break;
// 统计数据(交付商)
case "deliverStatTransData": //交付商统计
opResult = await this.oorderdeliverSve.deliverStatTransData(action_body);
break;
case "businessManagement": //业务办理
opResult = await this.oorderdeliverSve.businessManagement(action_body);
break;
//******************************************************************** */
// 统计数据
case "statTransData":
opResult = await this.iborderSve.apiStatTransData(action_body);
break;
case "statBusinessData":
opResult = await this.iborderSve.apiStatBusinessData(action_body);
break;
case "statDeliverData":
opResult = await this.iborderdeliverSve.apiStatDeliverData(action_body);
break;
// // 订单
// case "createOrder": //创建订单
// opResult = await this.iborderbaseSve.apiCreateOrder(action_body);
// break;
// case "completedOrder": //完善信息接口
// opResult = await this.iborderbaseSve.apiCompletedOrder(action_body);
// break;
// case "handling": //订单办理接口
// opResult = await this.iborderbaseSve.apiHandling(action_body);
// break;
// // case "orders": //订单列表
// // opResult = await this.iborderbaseSve.apiOrders(action_body);
// // break;
// case "addOrder":
// opResult = await this.iborderSve.apiAdd(action_body);
// break;
// case "updOrder":
// opResult = await this.iborderSve.apiUpd(action_body);
// break;
//
// // -------------------
// case "allOrderList":
// opResult = await this.iborderSve.apiAllList(action_body);
// break;
// // case "orderInfo":
// // opResult = await this.iborderSve.apiInfo(action_body);
// // break;
// // case "orderInfoAll":
// // opResult = await this.iborderSve.apiAllInfo(action_body);
// // break;
// case "byChannelOrderId":
// opResult = await this.iborderSve.apiByChannelOrderId(action_body);
// break;
//
//
// case "orderEdit":
// opResult = await this.iborderSve.apiEdit(action_body);
// break;
// case "orderAssign":
// opResult = await this.iborderSve.apiAssign(action_body);
// break;
// case "myOrderPage":
// opResult = await this.iborderSve.apiMyPage(action_body);
// break;
// case "orderPay":
// opResult = await this.iborderSve.apiOrderPay(action_body);
// break;
// case "orderClose":
// opResult = await this.iborderSve.apiOrderClose(action_body);
// break;
// case "closeOrderById":
// opResult = await this.iborderSve.apiCloseById(action_body);
// break;
// case "orderComplete":
// opResult = await this.iborderSve.apiComplete(action_body);
// break;
// case "orderByDeliverId":
// opResult = await this.iborderSve.apiByDeliverId(action_body);
// break;
//
//
// // 订单办理
// case "orderDeliverList":
// opResult = await this.iborderdeliverSve.apiPage(action_body);
// break;
// case "orderDeliverHandle":
// opResult = await this.iborderdeliverSve.apiHandle(action_body);
// break;
// case "orderDeliverInfo":
// opResult = await this.iborderdeliverSve.apiInfo(action_body);
// break;
// case "orderDeliverEdit":
// opResult = await this.iborderdeliverSve.apiEdit(action_body);
// break;
//
// case "orderDeliverAudit":
// opResult = await this.iborderdeliverSve.apiAudit(action_body);
// break;
//
// case "orderDeliverClose":
// opResult = await this.iborderdeliverSve.apiClose(action_body);
// break;
//
// // 个体户管理
// case "businessmenByOrderId":
// opResult = await this.businessmenSve.apiByOrderId(action_body);
// break;
// case "businessmenByChannelOrderNo":
// opResult = await this.businessmenSve.apiByChannelOrderNo(action_body);
// break;
// case "businessmenNameList":
// opResult = await this.businessmenSve.apiNameList(action_body);
// break;
// case "businessmenPage":
// opResult = await this.businessmenSve.apiPage(action_body);
// break;
// case "businessmenInfo":
// opResult = await this.businessmenSve.apiInfo(action_body);
// break;
// case "businessmenSign":
// opResult = await this.businessmenSve.apiSign(action_body);
// break;
// case "businessmenSignPage":
// opResult = await this.businessmenSve.apiSignPage(action_body);
// break;
// case "businessmenInfoPage":
// opResult = await this.businessmenSve.apiInfoPage(action_body);
// break;
// case "businessmenUserPage":
// opResult = await this.businessmenSve.apiUserPage(action_body);
// break;
// case "businessmenDeliverPage":
// opResult = await this.businessmenSve.apiDeliverPage(action_body);
// break;
// case "addBusinessmenContract":
// opResult = await this.businessmenSve.apiAddContract(action_body);
// break;
//
// case "businessmenCompleteMapByCreditCodes":
// opResult = await this.businessmenSve.apiCompleteMapByCreditCodes(action_body);
// break;
//
default:
opResult = system.getResult(null, "action_type参数错误");
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
} catch (e) {
console.log(e);
return system.getResult(null, "order服务异常");
}
return opResult;
}
exam() {
return `<pre><pre/>`;
......
......@@ -35,16 +35,20 @@ class Dao {
}
//批量插入
async bulkCreate(objs) {
async bulkCreate(objs, t) {
if (!objs || objs.length == 0) {
return;
}
for (var obj of objs) {
if (!obj.id) {
if (!obj.id && !obj.autoIncrement) {
obj.id = await this.redisClient.genrateId(this.modelName);
}
}
return await this.model.bulkCreate(objs);
if (t) {
return await this.model.bulkCreate(objs, { transaction: t });
} else {
return await this.model.bulkCreate(objs);
}
}
static getModelName(ClassObj) {
......
......@@ -83,5 +83,13 @@ class BusinessmenDao extends Dao {
}
return result;
}
async findBusinessmenByCreditCode(creditCode){
try {
return await this.model.findOne({where:{creditCode:creditCode}}) || {};
} catch (error) {
return system.getResult(null,`系统错误 错误信息 ${error}`);
}
}
}
module.exports = BusinessmenDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class OsourceDao extends Dao {
constructor() {
super(Dao.getModelName(OsourceDao));
}
/**
* 条件查询所有符合条件的来源数据
* @param {*} params
*/
async listByIds(ids){
if(!ids || ids.length == 0) {
return [];
}
let sql = [];
sql.push(`SELECT * FROM o_source WHERE id in (:sourceIdList)`);
return await this.customQuery(sql.join(" "), {sourceIdList: ids});
}
async mapByIds(params) {
let list = await this.listByIds(params);
var result = {};
for(let item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = OsourceDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class ChannelDao extends Dao {
constructor() {
super(Dao.getModelName(ChannelDao));
this.statusMap = {};
}
}
module.exports = ChannelDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class IbdeliverbaseDao extends Dao {
constructor() {
super(Dao.getModelName(IbdeliverbaseDao));
this.statusMap = {};
}
}
module.exports = IbdeliverbaseDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class IborderbaseDao extends Dao {
constructor() {
super(Dao.getModelName(IborderbaseDao));
this.statusMap = {};
}
async findMapByIds(ids, attrs) {
var result = {};
if (!ids || ids.length == 0) {
return result;
}
attrs = attrs || "*";
var sql = "SELECT " + attrs + " FROM `ib_orderbase` WHERE id IN (:ids)";
var list = await this.customQuery(sql, {
ids: ids
});
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = IborderbaseDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class IborderdkDao extends Dao {
constructor() {
super(Dao.getModelName(IborderdkDao));
this.statusMap = {};
}
}
module.exports = IborderdkDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class IborderdkdeliverDao extends Dao {
constructor() {
super(Dao.getModelName(IborderdkdeliverDao));
this.statusMap = {};
}
}
module.exports = IborderdkdeliverDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class IborderdzDao extends Dao {
constructor() {
super(Dao.getModelName(IborderdzDao));
this.statusMap = {};
}
}
module.exports = IborderdzDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class ObusinessmenDao extends Dao {
constructor() {
super(Dao.getModelName(ObusinessmenDao));
}
async countByCondition(params) {
let sql = [];
sql.push("SELECT");
sql.push("COUNT(1) AS num");
sql.push("FROM `o_businessmen` t1");
sql.push("WHERE 1 = 1");
this.setCondition(sql, params);
let rs = await this.customQuery(sql.join(" "), params);
if (!rs || rs.length == 0) {
return 0;
}
return rs[0].num || 0;
}
async listByCondition(params) {
let sql = [];
sql.push("SELECT");
sql.push("t1.*");
sql.push("FROM `o_businessmen` t1");
sql.push("WHERE 1 = 1");
this.setCondition(sql, params);
sql.push("ORDER BY t1.id DESC");
sql.push("LIMIT :startRow, :pageSize");
return await this.customQuery(sql.join(" "), params);
}
setCondition(sql, params) {
if (params.order_id) {
sql.push("AND t1.order_id = :order_id");
}
if (params.orderIds && params.orderIds.length > 0) {
sql.push("AND t1.order_id IN (:orderIds)");
}
if (params.name) {
params.name_like = "%" + params.name + "%";
sql.push("AND t1.name LIKE :name_like");
}
if (params.bd_id) {
sql.push("AND t1.bd_id = :bd_id");
}
if (params.bd_path) {
params.bd_path_like = params.bd_path + "%";
sql.push("AND t1.bd_path LIKE :bd_path_like");
}
if (params.order_id) {
sql.push("AND t1.order_id = :order_id");
}
if (params.legal_name) {
sql.push("AND t1.legal_name = :legal_name");
}
if (params.legal_mobile) {
sql.push("AND t1.legal_mobile = :legal_mobile");
}
if (params.legal_idcard) {
sql.push("AND t1.legal_idcard = :legal_idcard");
}
if (params.credit_code) {
sql.push("AND t1.credit_code = :credit_code");
}
if (params.hasOwnProperty("isSign")) {
if (params.isSign) {
sql.push("AND t1.sign_time IS NOT NULL");
} else {
sql.push("AND t1.sign_time IS NULL");
}
}
}
}
module.exports = ObusinessmenDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class OorderDao extends Dao {
constructor() {
super(Dao.getModelName(OorderDao));
}
/**
* 订单管理列表 分页总数查询
* @param {*} params
*/
async ordersCount(params){
let sql = [];
sql.push('SELECT COUNT(1) AS orderCount FROM o_order WHERE 1 = 1 ');
this.setOrderCount(sql,params);
return await this.customQuery(sql.join(" "), params);
}
/**
* 订单列表 分页
* @param {*} params
*/
async findAll(params){
let sql = [];
sql.push(`SELECT * FROM o_order WHERE 1=1 `);
this.setOrderCount(sql,params);
sql.push(`limit ${params.startRow} ,${params.pageSize}`);
return await this.customQuery(sql.join(" "), params);
}
/**
* 订单管理列表查询条件参数设置
* @param {*} params
*/
async setOrderCount(sql,params){
if(params.id){
sql.push(`AND id = :id `);
}
if(params.progress){
sql.push(`AND progress = :progress `);
}
if(params.deliver_id){
sql.push(`AND deliver_id = :deliver_id `);
}
if (params.begin) {
sql.push(`AND created_at >= :begin `);
}
if (params.end) {
sql.push(`AND created_at <= :end`);
}
}
async findMapByIds(ids, attrs) {
var result = {};
if (!ids || ids.length == 0) {
return result;
}
attrs = attrs || "*";
var sql = "SELECT " + attrs + " FROM `o_order` WHERE id IN (:ids)";
var list = await this.customQuery(sql, {
ids: ids
});
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
/**
* 平台数据概览
* @param {*} begin
* @param {*} end
*/
async statOrderByTime(begin, end) {
var result = {};
var sql = [];
sql.push("SELECT");
sql.push("DATE_FORMAT(created_at, '%Y-%m') AS `month`, SUM(price) AS orderPrice, COUNT(1) AS orderCount");
sql.push("FROM `o_order`");
sql.push("WHERE 1 = 1");
var params = {
begin: begin,
end: end
};
if (begin) {
sql.push("AND created_at >= :begin");
}
if (end) {
sql.push("AND created_at <= :end");
}
sql.push("GROUP BY `month` ORDER BY `month` ASC");
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return result;
}
for (var idx = 0; idx < list.length; idx++) {
var item = list[idx];
result[item.month] = item;
if (idx == 0) {
result.begin = item.month;
}
if (idx == list.length - 1) {
result.end = item.month;
}
}
return result;
}
async statDayByTime(begin, end) {
var result = {};
var sql = [];
sql.push("SELECT");
sql.push("DATE_FORMAT(created_at, '%Y-%m-%d') AS `day`, SUM(price) AS orderPrice, COUNT(1) AS orderCount");
sql.push("FROM `o_order`");
sql.push("WHERE 1 = 1");
var params = {
begin: begin,
end: end
};
if (begin) {
sql.push("AND created_at >= :begin");
}
if (end) {
sql.push("AND created_at <= :end");
}
sql.push("GROUP BY `day` ORDER BY `day` ASC");
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.day] = item;
}
return result;
}
}
module.exports = OorderDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class OorderdeliverDao extends Dao {
constructor() {
super(Dao.getModelName(OorderdeliverDao));
this.ORDER_HANDING = ['1030', '1040', '1050', '1060', '1070', '1080', '1090', '1100', '1110', '1120', '1130'];
}
/**
* 条件查询所有符合条件的产品
* @param {*} params
*/
async orderIdsByDeliverId(deliver_id) {
if (!deliver_id) {
return [];
}
let sql = `SELECT order_id FROM o_order_deliver WHERE deliver_id = :deliver_id`;
let list = await this.customQuery(sql, { deliver_id: deliver_id });
let rs = [];
if (!list) {
return rs;
}
for (let item of list) {
rs.push(item.order_id);
}
return rs;
}
/**
* 条件查询所有符合条件的产品
* @param {*} params
*/
async orderIdsByOperatorId(operator_id) {
if (!operator_id) {
return [];
}
let sql = `SELECT order_id FROM o_order_deliver WHERE operator_id = :operator_id`;
let list = await this.customQuery(sql, { operator_id: operator_id });
let rs = [];
if (!list) {
return rs;
}
for (let item of list) {
rs.push(item.order_id);
}
return rs;
}
async listByIds(ids) {
if (!ids || ids.length == 0) {
return [];
}
let sql = `SELECT * FROM o_order_deliver WHERE id in (:deliverIdList)`;
return await this.customQuery(sql, { deliverIdList: ids });
}
async mapByIds(params) {
let list = await this.listByIds(params);
var result = {};
for (let item of list) {
result[item.id] = item;
}
return result;
}
/**
* 订单管理列表 分页总数查询
* @param {*} params
*/
async ordersdeliverCount(params) {
let sql = [];
sql.push(`SELECT COUNT(1) AS orderCount FROM o_order_deliver b INNER JOIN o_order a on
b.order_id=a.id WHERE b.deliver_id = '${params.deliver_id}' `);
this.setOrderCount(sql, params);
return await this.customQuery(sql.join(" "), params);
}
/**
* 订单列表 分页
* @param {*} params
*/
async findOrders(params) {
let sql = [];
sql.push(`SELECT a.id,b.created_at,a.service_items,a.status,b.deliver_divide,b.operator_id,b.completed_at,
a.desc, a.service_remark,
b.deliver_name FROM o_order_deliver b INNER JOIN o_order a on
b.order_id=a.id WHERE b.deliver_id = '${params.deliver_id}' `);
this.setOrderCount(sql, params);
sql.push(` order by id desc `);
sql.push(`limit ${params.startRow} ,${params.pageSize}`);
return await this.customQuery(sql.join(" "), params);
}
/**
* 订单管理列表查询条件参数设置
* @param {*} params
*/
async setOrderCount(sql, params) {
if (params.id) {
sql.push(`AND b.id = :id `);
}
if (params.order_id) {
sql.push(`AND b.order_id = :order_id `);
}
if (params.operator_id) {
sql.push(`AND b.operator_id = :operator_id `);
}
if (params.status) {
sql.push(`AND a.status = :status `);
}
if (params.createdBegin) {
sql.push(`AND a.created_at >= :createdBegin `);
}
if (params.createdEnd) {
sql.push(`AND a.created_at <= :createdEnd`);
}
}
/**
* 交付商统计交付商服务费用
*/
async deliverList(begin, end) {
var sql = [];
sql.push("SELECT");
sql.push("SUM(deliver_divide) AS serivce_price, deliver_name,deliver_id");
sql.push("FROM `o_order_deliver`");
sql.push("WHERE 1 = 1");
var params = {
begin: begin,
end: end
};
if (begin) {
sql.push("AND created_at >= :begin");
}
if (end) {
sql.push("AND created_at <= :end");
}
sql.push(" GROUP BY deliver_id");
return await this.customQuery(sql.join(" "), params);
}
/**
* 统计完成的订单
* @param {*} deliverSet
* @param {*} begin
* @param {*} end
*/
async orderCompletesCount(deliverSet, begin, end) {
var sql = [];
sql.push("SELECT");
sql.push("COUNT(1) as order_complete_count ,b.deliver_id");
sql.push("FROM `o_order_deliver` b inner join o_order a on b.id = a.deliver_id");
sql.push("WHERE 1 = 1 and a.status = '1080' ");
var params = {
begin: begin,
end: end,
deliverSet: deliverSet
};
if (begin) {
sql.push("AND a.created_at >= :begin");
}
if (end) {
sql.push("AND a.created_at <= :end");
}
if (deliverSet) {
sql.push(`AND b.deliver_id in (:deliverSet)`);
}
sql.push(" GROUP BY b.deliver_id");
let res = await this.customQuery(sql.join(" "), params);
let result = {};
for (let item of res) {
result[item.deliver_id] = item.order_complete_count;
}
return result;
}
/**
* 订单办理中
* @param {*} params
*/
async orderHandingCount(deliverSet, begin, end) {
var sql = [];
sql.push("SELECT");
sql.push("COUNT(1) as order_handing_count ,b.deliver_id");
sql.push("FROM `o_order_deliver` b inner join o_order a on b.id = a.deliver_id");
sql.push("WHERE 1 = 1");
var params = {
begin: begin,
end: end
};
if (begin) {
sql.push("AND a.created_at >= :begin");
}
if (end) {
sql.push("AND a.created_at <= :end");
}
sql.push(`AND a.status in (${this.ORDER_HANDING}) `);
sql.push(" GROUP BY b.deliver_id");
let res = await this.customQuery(sql.join(" "), params);
let result = {};
for (let item of res) {
result[item.deliver_id] = item.order_handing_count;
}
return result;
}
/**
* 交付上数据概览
* @param {*} begin
* @param {*} end
*/
async statDayByTime(begin, end,deliver_id) {
var result = {};
var sql = [];
sql.push("SELECT");
sql.push("DATE_FORMAT(a.created_at, '%Y-%m-%d') AS `day`, SUM(b.deliver_divide) AS orderPrice, COUNT(1) AS orderCount");
sql.push("from o_order a inner join o_order_deliver b on a.deliver_id = b.id where 1=1 and b.deliver_id = :deliver_id");
var params = {
begin: begin,
end: end,
deliver_id:deliver_id
};
if (begin) {
sql.push("AND a.created_at >= :begin");
}
if (end) {
sql.push("AND a.created_at <= :end");
}
sql.push("GROUP BY `day` ORDER BY `day` ASC");
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.day] = item;
}
return result;
}
/**
* 交付商数据概览
* @param {*} begin
* @param {*} end
*/
async statOrderByTime(begin, end,deliver_id) {
var result = {};
var sql = [];
sql.push("SELECT");
sql.push("DATE_FORMAT(a.created_at, '%Y-%m') AS `month`, SUM(b.deliver_divide) AS orderPrice, COUNT(1) AS orderCount");
sql.push("FROM `o_order` a inner join o_order_deliver b on a.deliver_id = b.id");
sql.push(`WHERE 1 = 1 and b.deliver_id = '${deliver_id}'`);
var params = {
begin: begin,
end: end
};
if (begin) {
sql.push("AND a.created_at >= :begin");
}
if (end) {
sql.push("AND a.created_at <= :end");
}
sql.push("GROUP BY `month` ORDER BY `month` ASC");
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return result;
}
for (var idx = 0; idx < list.length; idx++) {
var item = list[idx];
result[item.month] = item;
if (idx == 0) {
result.begin = item.month;
}
if (idx == list.length - 1) {
result.end = item.month;
}
}
return result;
}
/*********************************************以下是交付商首页**************************************************** */
/**
* 完成订单
* @param {*} begin
* @param {*} end
* @param {*} deliver_id
*/
async orderComplete(begin, end,deliver_id){
var sql = [];
sql.push("SELECT count(1) as count from o_order a inner join o_order_deliver b on a.deliver_id = b.id");
sql.push(`WHERE 1 = 1 and b.deliver_id = '${deliver_id}' and a.status="1180"`);
var params = {
begin: begin,
end: end
};
if (begin) {
sql.push("AND a.created_at >= :begin");
}
if (end) {
sql.push("AND a.created_at <= :end");
}
return await this.customQuery(sql.join(" "), params);
}
/**
* 订单办理中
* @param {*} begin
* @param {*} end
* @param {*} deliver_id
*/
async orderHanding(begin, end,deliver_id){
var sql = [];
sql.push("SELECT count(1) as count from o_order a inner join o_order_deliver b on a.deliver_id = b.id");
sql.push(`WHERE 1 = 1 and b.deliver_id = '${deliver_id}'`);
var params = {
begin: begin,
end: end
};
if (begin) {
sql.push("AND a.created_at >= :begin");
}
if (end) {
sql.push("AND a.created_at <= :end");
}
sql.push(`AND a.status in (${this.ORDER_HANDING}) `);
return await this.customQuery(sql.join(" "), params);
}
}
module.exports = OorderdeliverDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class OorderinforegDao extends Dao {
constructor() {
super(Dao.getModelName(OorderinforegDao));
}
}
module.exports = OorderinforegDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class OorderprocessDao extends Dao {
constructor() {
super(Dao.getModelName(OorderprocessDao));
}
async delByOrderId(order_id) {
if (!order_id) {
return;
}
let sql = "DELETE FROM o_order_process WHERE order_id = :order_id";
await this.customUpdate(sql, {order_id: order_id});
}
async findByOrderIdAndStatus(orderId, status) {
if (!orderId || !status) {
return null;
}
let sql = [];
sql.push("SELECT");
sql.push("*");
sql.push("FROM `o_order_process`");
sql.push("WHERE order_id = :orderId");
sql.push("AND `status` = :status");
let list = await this.customQuery(sql.join(" "), {orderId: orderId, status: status});
if (!list || list.length == 0) {
return null;
}
return list[0];
}
async listByOrderIdsAndStatus(orderIds, statuses) {
var result = {};
if (!orderIds || orderIds.length == 0 || !statuses || statuses.length == 0) {
return result;
}
let sql = [];
sql.push("SELECT");
sql.push("*");
sql.push("FROM `o_order_process`");
sql.push("WHERE order_id IN (:orderIds)");
sql.push("AND `status` IN (:statuses)");
return await this.customQuery(sql.join(" "), {orderIds: orderIds, statuses: statuses});
}
async mapByOrderIdsAndStatus(orderIds, statuses) {
var result = {};
let list = await this.listByOrderIdsAndStatus(orderIds, statuses);
if (!list || list.length == 0) {
return result;
}
for (let item of list) {
result[item.order_id + "_" + item.status] = item;
}
return result;
}
}
module.exports = OorderprocessDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OorderstatusDao extends Dao {
constructor() {
super(Dao.getModelName(OorderstatusDao));
}
}
module.exports = OorderstatusDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class PaymentDao extends Dao {
constructor() {
super(Dao.getModelName(PaymentDao));
this.statusMap = {};
}
}
module.exports = PaymentDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class OprocessDao extends Dao {
constructor() {
super(Dao.getModelName(OprocessDao));
}
async getAll(attrs) {
attrs = attrs || "*";
let sql = "SELECT " + attrs + " FROM `o_process` ORDER BY `status` ASC";
return await this.customQuery(sql);
}
async mapAll(attrs) {
let result = {};
let list = await this.getAll(attrs);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
async findMapByIds(ids, attrs) {
let result = {};
if (!ids || ids.length == 0) {
return result;
}
attrs = attrs || "*";
let sql = "SELECT " + attrs + " FROM `o_process` WHERE id IN (:ids)";
let list = await this.customQuery(sql, {
ids: ids
});
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = OprocessDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class OproductDao extends Dao {
constructor() {
super(Dao.getModelName(OproductDao));
}
async dics(params) {
let sql = [];
sql.push("SELECT");
sql.push("id, `name`, `desc`, pid");
sql.push("FROM o_product");
sql.push("WHERE 1 = 1");
if (params.pid) {
sql.push("AND pid = :pid");
}
if (params.hasOwnProperty("is_choose")) {
sql.push("AND is_choose = :is_choose");
}
return this.customQuery(sql.join(" "), params);
}
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;
}
/**
* 条件查询所有符合条件的产品
* @param {*} params
*/
async listByIds(ids){
if(!ids || ids.length == 0) {
return [];
}
let sql = [];
sql.push(`SELECT * FROM o_product WHERE id in (:productIdList)`);
return await this.customQuery(sql.join(" "), {productIdList: ids});
}
async mapByIds(params) {
let list = await this.listByIds(params);
var result = {};
for(let item of list) {
result[item.id] = item;
}
return result;
}
}
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));
}
/**
* 根据 productId 和 status 查询 商品
* @param {*} productId
* @param {*} status
*/
async findByProductIdAndStatus(productId, status) {
try {
let _productProcess = await this.model.findOne({
where: {
productId: productId,
status: status
}
});
return _productProcess || {};
} catch (error) {
console.log(`系统错误 错误信息 ${error}`);
return {};
}
}
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.join(" "), {productPid: productPid, productIds: productIds});
if (!list || list.length == 0) {
return result;
}
for (let item of list) {
let productId = item.product_id;
let items = result[productId];
if (!items) {
items = [];
}
items.push(item);
result[productId] = items;
}
return result;
}
}
module.exports = OproductprocessDao;
\ No newline at end of file
......@@ -23,11 +23,15 @@ module.exports = (db, DataTypes) => {
businessScope: DataTypes.STRING(500),
regDate: DataTypes.DATE,
businessImg: DataTypes.STRING(300),
gongshangFile: DataTypes.STRING(300),
gongzhang: DataTypes.STRING(300),
caiwuzhang: DataTypes.STRING(300),
fapiaozhang: DataTypes.STRING(300),
hetongzhang: DataTypes.STRING(300),
farenzhang: DataTypes.STRING(300),
kezhangFile: DataTypes.STRING(300),
isBank: {
type: DataTypes.BOOLEAN,
defaultValue: false
......@@ -36,9 +40,13 @@ module.exports = (db, DataTypes) => {
bankNo: DataTypes.STRING(30),
bank: DataTypes.STRING(100),
bankImg: DataTypes.STRING(300),
kaihuFile: DataTypes.STRING(300),
caImg: DataTypes.STRING(300),
taxRegDay: DataTypes.DATE,
taxOrg: DataTypes.STRING(100),
shuiwuFile: DataTypes.STRING(100),
courierNo: DataTypes.STRING(100),
courierImg: DataTypes.STRING(100),
contractStartData: DataTypes.DATE,
......@@ -59,6 +67,8 @@ module.exports = (db, DataTypes) => {
commonOtherLadder: DataTypes.STRING(1000),
specialTaxLadder: DataTypes.STRING(1000),
specialOtherLadder: DataTypes.STRING(1000),
serviceBeginTime: DataTypes.DATE,
serviceEndTime: DataTypes.DATE,
signTime: DataTypes.DATE,
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("channel", {
channelNo: DataTypes.STRING,
channelName: DataTypes.STRING,
statusUrl: DataTypes.STRING,
invoiceAmtUrl: DataTypes.STRING,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'o_channel',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("deliverbase", {
order_id: DataTypes.STRING(32),
// 产品类型 1000注册订单 1010代开订单 1030代账订单 1040增值服务
productType: DataTypes.STRING,
deliver_id: DataTypes.STRING(32),
deliverName: DataTypes.STRING(50),
deliverDivide: DataTypes.BIGINT,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'ib_deliverbase',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ module.exports = (db, DataTypes) => {
idcard: DataTypes.STRING(20),
idcardFront: DataTypes.STRING(300),
idcardBack: DataTypes.STRING(300),
orderpay_id: DataTypes.STRING(32),
bankNo: DataTypes.STRING(30),
bank: DataTypes.STRING(200),
......@@ -55,6 +56,8 @@ module.exports = (db, DataTypes) => {
deliverType: DataTypes.STRING,
deliverNo: DataTypes.STRING,
deliverImg: DataTypes.STRING,
productItems: DataTypes.STRING,
completeFile: DataTypes.STRING,
}, {
paranoid: true, //假的删除
underscored: true,
......@@ -63,37 +66,6 @@ module.exports = (db, DataTypes) => {
//freezeTableName: true,
// define the table's name
tableName: 'ib_order',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
validate: {}
});
}
\ No newline at end of file
......@@ -2,17 +2,23 @@ const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("iborder", {
return db.define("iborderbase", {
merchant_id: DataTypes.STRING(32),
businessmen_id: DataTypes.STRING(32),
channelNo: DataTypes.STRING(32),
thirdNo: DataTypes.STRING(32),
productType: DataTypes.INTEGER,
productType: DataTypes.STRING,
payStatus: DataTypes.STRING,
bdId: DataTypes.STRING,
bdPath: DataTypes.STRING,
price: DataTypes.BIGINT,
status: DataTypes.STRING,
remark: DataTypes.STRING,
isInfoComplete: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
payType:{type: DataTypes.INTEGER, field: 'pay_type',comment:'付款方式 10 按照次付费 20 按照年付费'},
}, {
paranoid: true, //假的删除
underscored: true,
......@@ -20,7 +26,7 @@ module.exports = (db, DataTypes) => {
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'ib_base_order',
tableName: 'ib_orderbase',
validate: {},
indexes: [
// Create a unique index on email
......
......@@ -10,6 +10,20 @@ module.exports = (db, DataTypes) => {
status: DataTypes.STRING,
notes: DataTypes.STRING,
orderDeliverId: DataTypes.STRING(32),
legalName: DataTypes.STRING(20),
legalMobile: DataTypes.STRING(20),
names: DataTypes.STRING(300),
creditCode: DataTypes.STRING(100),
isBank: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
businessScope: DataTypes.STRING(500),
isInfoComplete: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
}, {
paranoid: true, //假的删除
underscored: true,
......
......@@ -2,11 +2,8 @@ const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("iborderdeliver", {
return db.define("iborderdkdeliver", {
order_id: DataTypes.STRING(32),
// 办理状态 1030待处理, 1040关闭订单, 1050执照办理中, 1060已出执照, 1070刻章办理中,
// 1080已刻章, 1090银行开户中, 1100银行卡已开户, 1110税务报道中, 1120已税务报道,
// 1130提交审核, 1140审核失败, 1150审核通过, 1160已邮寄
status: DataTypes.STRING(10),
deliver_id: DataTypes.STRING(32),
......@@ -29,7 +26,7 @@ module.exports = (db, DataTypes) => {
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'ib_order_deliver',
tableName: 'ib_orderdk_deliver',
validate: {},
indexes: [
// Create a unique index on email
......
......@@ -10,6 +10,20 @@ module.exports = (db, DataTypes) => {
status: DataTypes.STRING,
notes: DataTypes.STRING,
orderDeliverId: DataTypes.STRING(32),
legalName: DataTypes.STRING(20),
legalMobile: DataTypes.STRING(20),
names: DataTypes.STRING(300),
creditCode: DataTypes.STRING(100),
isBank: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
businessScope: DataTypes.STRING(500),
isInfoComplete: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
}, {
paranoid: true, //假的删除
underscored: true,
......
'use strict'
/**
* 订单信息明细表
*/
module.exports = function (db, DataTypes) {
return db.define('obusinessmen', {
order_id: {type: DataTypes.STRING, field: 'order_id', allowNull: true, defaultValue:'',comment:'订单id' },
merchant_id: {type: DataTypes.STRING, field: 'merchant_id', allowNull: true, comment:'商户id 为了司机宝' },
channel_order_no: { type: DataTypes.STRING, field: 'channel_order_no', allowNull: true, defaultValue:'', comment:'渠道订单号 为了司机宝'},
legal_name: { type: DataTypes.STRING, field: 'legal_name', allowNull: false,defaultValue:'', comment:'法人姓名'},
legal_mobile: {type: DataTypes.STRING, field: 'legal_mobile', allowNull: true,defaultValue:'', comment:'法人电话'},
legal_idcard: { type: DataTypes.STRING, field: 'legal_idcard', allowNull: true, defaultValue:'',comment:'法人身份证号'},
name: {type: DataTypes.STRING, field: 'name', allowNull: true, defaultValue:'',comment:'个体工商户名称' },
credit_code: { type: DataTypes.STRING, field: 'credit_code', allowNull: true, defaultValue:'', comment:'统一社会信用代码'},
business_place: {type: DataTypes.STRING, field: 'business_place', allowNull: true, defaultValue:'', comment:'经营场所' },
business_scope: {type: DataTypes.STRING, field: 'business_scope', allowNull: true, defaultValue:'', comment:'经营范围' },
reg_date: {type: DataTypes.DATE, field: 'reg_date', allowNull: true, defaultValue:'', comment:'注册日期' },
business_img: {type: DataTypes.STRING, field: 'business_img', allowNull: true, defaultValue:'', comment:'执照照片' },
business_gov_file: {type: DataTypes.STRING, field: 'business_gov_file', allowNull: true, defaultValue:'', comment:'工商官方文件' },
gongzhang: {type: DataTypes.STRING, field: 'gongzhang', allowNull: true, defaultValue:'', comment:'公章' },
caiwuzhang: {type: DataTypes.STRING, field: 'caiwuzhang', allowNull: true, defaultValue:'', comment:'财务章' },
fapiaozhang: {type: DataTypes.STRING, field: 'fapiaozhang', allowNull: true, defaultValue:'', comment:'发票章' },
hetongzhang: {type: DataTypes.STRING, field: 'hetongzhang', allowNull: true, defaultValue:'', comment:'合同章' },
farenzhang: {type: DataTypes.STRING, field: 'farenzhang', allowNull: true, defaultValue:'', comment:'法人章' },
zhang_gov_file: {type: DataTypes.STRING, field: 'zhang_gov_file', allowNull: true, defaultValue:'', comment:'刻章官方文件' },
is_bank: {type: DataTypes.BOOLEAN, field: 'is_bank', allowNull: true, defaultValue:false, comment:'是否开户' },
bank_name: {type: DataTypes.STRING, field: 'bank_name', allowNull: true, defaultValue:'', comment:'账户名称' },
bank_no: {type: DataTypes.STRING, field: 'bank_no', allowNull: true, defaultValue:'', comment:'账户号' },
bank: {type: DataTypes.STRING, field: 'bank', allowNull: true, defaultValue:'', comment:'开户行' },
bank_img: {type: DataTypes.STRING, field: 'bank_img', allowNull: true, defaultValue:'', comment:'账户信息' },
bank_gov_file: {type: DataTypes.STRING, field: 'bank_gov_file', allowNull: true, defaultValue:'', comment:'银行开户官方文件' },
ca_img: {type: DataTypes.STRING, field: 'ca_img', allowNull: true, defaultValue:'', comment:'CA照片' },
tax_reg_day: {type: DataTypes.DATE, field: 'tax_reg_day', allowNull: true, comment:'税务登记日' },
tax_org: {type: DataTypes.STRING, field: 'tax_org', allowNull: true, defaultValue:'', comment:'税务机构名称' },
tax_gov_file: {type: DataTypes.STRING, field: 'tax_gov_file', allowNull: true, defaultValue:'', comment:'税务报道官方文件' },
notes: {type: DataTypes.STRING, field: 'notes', allowNull: true, defaultValue:'', comment:'备注' },
common_tax_ladder: {type: DataTypes.STRING, field: 'common_tax_ladder', allowNull: true, defaultValue:'', comment:'普票个税阶梯' },
common_other_ladder: {type: DataTypes.STRING, field: 'common_other_ladder', allowNull: true, defaultValue:'', comment:'普票增值税、附加税阶梯' },
special_tax_ladder: {type: DataTypes.STRING, field: 'special_tax_ladder', allowNull: true, defaultValue:'', comment:'专票个税阶梯' },
special_other_ladder: {type: DataTypes.STRING, field: 'special_other_ladder', allowNull: true, defaultValue:'', comment:'专票增值税、附加税阶梯' },
service_begin_time: {type: DataTypes.DATE, field: 'service_begin_time', allowNull: true, defaultValue:null, comment:'服务开始时间' },
service_end_time: {type: DataTypes.DATE, field: 'service_end_time', allowNull: true, defaultValue:null, comment:'服务结束时间' },
cost_rate: {type: DataTypes.INTEGER, field: 'cost_rate', allowNull: true, defaultValue:0, comment:'核定成本费用率' },
tax_rate: {type: DataTypes.INTEGER, field: 'tax_rate', allowNull: true, defaultValue:0, comment:'含税价百分比' },
add_value_up_type: {type: DataTypes.STRING, field: 'add_value_up_type', allowNull: true, defaultValue:'1', comment:'增值税累计类型 1按月 2按季度' },
tax_up_type: {type: DataTypes.STRING, field: 'tax_up_type', allowNull: true, defaultValue:'1', comment:'个税累计类型 1按月累计 2按年累计' },
service_rate: {type: DataTypes.INTEGER, field: 'service_rate', allowNull: true, defaultValue:0, comment:'服务费比例' },
sign_notes: {type: DataTypes.STRING, field: 'sign_notes', allowNull: true, defaultValue:'', comment:'签约备注' },
sign_time: {type: DataTypes.DATE, field: 'sign_time', allowNull: true, defaultValue:null, comment:'签约时间' },
is_create_account: {type: DataTypes.BOOLEAN, field: 'is_create_account', allowNull: true, defaultValue:false, comment:'是否建帐' },
bd_id: {type: DataTypes.INTEGER, field: 'bd_id', allowNull: true, defaultValue:'', comment:'业务员id' },
bd_path: {type: DataTypes.STRING, field: 'bd_path', allowNull: true, defaultValue:'', comment:'业务员权限路径' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true }
},
{
timestamps: false,
underscore: true,
paranoid: true,
version: true,
tableName: 'o_businessmen',
comment: '个体户表',
});
}
'use strict'
/**
* 订单表
*/
module.exports = function (db, DataTypes) {
return db.define('oorder', {
merchant_id: {type: DataTypes.STRING, field: 'merchant_id', allowNull: true, defaultValue:'',comment:'商户id, 为了兼容司机宝' },
// order_id: {type: DataTypes.STRING, field: 'order_id', allowNull: true, comment:'订单ID' },
busi_type: {type: DataTypes.STRING, field: 'busi_type', allowNull: true,defaultValue:'', comment:'业务类型 1个体户 2...暂不知道' },
busi_id: { type: DataTypes.STRING, field: 'busi_id', allowNull: false,defaultValue:'', comment:'业务id'},
product_id: {type: DataTypes.BIGINT, field: 'product_id', allowNull: true,defaultValue:0, comment:'产品id'},
price: { type: DataTypes.BIGINT, field: 'price', allowNull: true, defaultValue:0,comment:'订单价格'},
status: {type: DataTypes.INTEGER, field: 'status', allowNull: true, defaultValue:'0',comment:'订单状态 业务进度' },
assign_time: {type: DataTypes.DATE, field: 'assign_time', allowNull: true, defaultValue:null, comment:'分配时间' },
assign_user_id: {type: DataTypes.BIGINT, field: 'assign_user_id', allowNull: true, defaultValue:'0', comment:'分配人id' },
deliver_id: {type: DataTypes.STRING, field: 'deliver_id', allowNull: true, defaultValue:'', comment:'交付商id common微服务下' },
desc: {type: DataTypes.STRING, field: 'desc', allowNull: true, defaultValue:'', comment:'订单信息' },
bd_id: {type: DataTypes.INTEGER, field: 'bd_id', allowNull: true, defaultValue:'', comment:'业务员id' },
bd_path: {type: DataTypes.STRING, field: 'bd_path', allowNull: true, defaultValue:'', comment:'业务员权限路径' },
service_items: {type: DataTypes.STRING, field: 'service_items', allowNull: true, defaultValue:'', comment:'服务项json' },
service_remark: {type: DataTypes.STRING, field: 'service_remark', allowNull: true, defaultValue:'', comment:'服务信息备注' },
source_id: {type: DataTypes.BIGINT, field: 'source_id', allowNull: true, defaultValue:0, comment:'来源id' },
source_no: {type: DataTypes.STRING, field: 'source_no', allowNull: true, defaultValue:'', comment:'来源订单号' },
contact_mobile: {type: DataTypes.STRING, field: 'contact_mobile', allowNull: true, defaultValue:'', comment:'联系电话' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true }
},
{
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'o_order',
});
}
'use strict'
/**
* 订单交付表
*/
module.exports = function (db, DataTypes) {
return db.define('oorderdeliver', {
order_id: {type: DataTypes.STRING, field: 'order_id', allowNull: false,comment:'订单ID' },
deliver_id: {type: DataTypes.STRING, field: 'deliver_id', allowNull: false, comment:'交付商id' },
deliver_name: { type: DataTypes.STRING, field: 'deliver_name', allowNull: false, comment:'交付商名称'},
deliver_divide: {type: DataTypes.STRING, field: 'deliver_divide', allowNull: false,comment:'订单分成' },
audit_result: { type: DataTypes.STRING, field: 'audit_result', allowNull: true,defaultValue:'', comment:'审核结果'},
audit_remark: {type: DataTypes.STRING, field: 'audit_remark', allowNull: true,defaultValue:'', comment:'交付审核备注'},
deliver_mail_addr: { type: DataTypes.STRING, field: 'deliver_mail_addr', allowNull: true, defaultValue:'',comment:'交付地址'},
deliver_mail_to: {type: DataTypes.STRING, field: 'deliver_mail_to', allowNull: true, defaultValue:'',comment:'收件人' },
deliver_mail_mobile: { type: DataTypes.STRING, field: 'deliver_mail_mobile', allowNull: true, defaultValue:'', comment:'联系电话'},
deliver_content: {type: DataTypes.STRING, field: 'deliver_content', allowNull: true, defaultValue:'', comment:'交付内容' },
deliver_mail_no: {type: DataTypes.STRING, field: 'deliver_mail_no', allowNull: true, defaultValue:'', comment:'交付商交付快递单号' },
deliver_mail_img: {type: DataTypes.STRING, field: 'deliver_mail_img', allowNull: true, defaultValue:'', comment:'交付商交付快递单号图片' },
completed_at: { type: DataTypes.DATE, field: 'completed_at', allowNull: true, comment:'订单的完成时间' },
operator_id: { type: DataTypes.STRING, field: 'operator_id', allowNull: true, comment:'业务员id' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true }
},
{
timestamps: false,
underscore: true,
paranoid: true,
version: true,
tableName: 'o_order_deliver',
comment: '订单交付表',
});
}
'use strict'
/**
* 订单信息明细表
*/
module.exports = function (db, DataTypes) {
return db.define('oorderinforeg', {
legal_name: {type: DataTypes.STRING, field: 'legal_name', allowNull: true, defaultValue:'',comment:'法人姓名' },
id_card: {type: DataTypes.STRING, field: 'id_card', allowNull: true, comment:'法人身份证' },
legal_mobile: { type: DataTypes.STRING, field: 'legal_mobile', allowNull: true, defaultValue:'', comment:'法人电话'},
names: {type: DataTypes.STRING, field: 'names', allowNull: true,defaultValue:'', comment:'个体户名称' },
capital: { type: DataTypes.STRING, field: 'capital', allowNull: false,defaultValue:'', comment:'注册资本'},
domicile_id: {type: DataTypes.STRING, field: 'domicile_id', allowNull: true,defaultValue:'', comment:'注册地id'},
domicile_name: { type: DataTypes.STRING, field: 'domicile_name', allowNull: true, defaultValue:'',comment:'注册地名称'},
business_scope_id: {type: DataTypes.STRING, field: 'business_scope_id', allowNull: true, defaultValue:'',comment:'经营范围id' },
business_type: { type: DataTypes.STRING, field: 'business_type', allowNull: true, defaultValue:'', comment:'经营范围'},
business_scope: {type: DataTypes.STRING, field: 'business_scope', allowNull: true, defaultValue:'', comment:'经营范围详情' },
idcard_front: {type: DataTypes.STRING, field: 'idcard_front', allowNull: true, defaultValue:'', comment:'身份证正面照片' },
idcard_back: {type: DataTypes.STRING, field: 'idcard_back', allowNull: true, defaultValue:'', comment:'身份证反面照片' },
other_file: {type: DataTypes.STRING, field: 'other_file', allowNull: true, defaultValue:'', comment:'其他文件' },
notes: {type: DataTypes.STRING, field: 'notes', allowNull: true, defaultValue:'', comment:'备注' },
guest_mail_addr: {type: DataTypes.STRING, field: 'guest_mail_addr', allowNull: true, defaultValue:'', comment:'邮寄客户地址' },
guest_mail_to: {type: DataTypes.STRING, field: 'guest_mail_to', allowNull: true, defaultValue:'', comment:'客户收件人' },
guest_mail_mobile: {type: DataTypes.STRING, field: 'guest_mail_mobile', allowNull: true, defaultValue:'', comment:'客户收件人电话' },
guest_mail_no: {type: DataTypes.STRING, field: 'guest_mail_no', allowNull: true, defaultValue:'', comment:'客户快递单号' },
guest_mail_img: {type: DataTypes.STRING, field: 'guest_mail_img', allowNull: true, defaultValue:'', comment:'交付商交付快递单号图片' },
guest_accpet_file: {type: DataTypes.STRING, field: 'guest_accpet_file', allowNull: true, defaultValue:'', comment:'客户验收文件' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true }
},
{
timestamps: false,
underscore: true,
paranoid: true,
version: true,
tableName: 'o_order_info_reg',
comment: '订单信息明细表',
});
}
'use strict'
/**
* 订单流程表
*/
module.exports = function (db, DataTypes) {
return db.define('oorderprocess', {
product_id: {type: DataTypes.BIGINT, field: 'product_id', allowNull: true, comment:'产品ID' },
order_id: {type: DataTypes.BIGINT, field: 'order_id', allowNull: true, comment:'订单号' },
name: { type: DataTypes.STRING, field: 'name', allowNull: false, defaultValue:"", comment:'产品名称'},
status: {type: DataTypes.STRING, field: 'status', allowNull: true, comment:'状态' },
func: { type: DataTypes.STRING, field: 'func', allowNull: false, comment:'状态执行方法名称'},
next_status: {type: DataTypes.STRING, field: 'next_status', allowNull: true, comment:'下一个状态'},
name1: { type: DataTypes.STRING, field: 'name1', allowNull: true, comment:'状态1'},
name2: {type: DataTypes.STRING, field: 'name2', allowNull: true, comment:'状态2' },
name3: { type: DataTypes.STRING, field: 'name3', allowNull: true, comment:'状态3'},
name4: {type: DataTypes.STRING, field: 'name4', allowNull: true, comment:'状态4' },
sort: {type: DataTypes.BIGINT, field: 'sort', allowNull: false, defaultValue:1000, comment:'排序' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true },
},
{
timestamps: false,
underscore: true,
paranoid: true,
version: true,
tableName: 'o_order_process',
comment: '产品状态表',
});
}
\ No newline at end of file
'use strict'
/**
* 订单表
*/
module.exports = function (db, DataTypes) {
return db.define('oorderstatus', {
merchant_id: {type: DataTypes.STRING, field: 'merchant_id', allowNull: true, defaultValue:'',comment:'商户id, 为了兼容司机宝' },
// order_id: {type: DataTypes.STRING, field: 'order_id', allowNull: true, comment:'订单ID' },
busi_type: {type: DataTypes.STRING, field: 'busi_type', allowNull: true,defaultValue:'', comment:'业务类型 1个体户 2...暂不知道' },
busi_id: { type: DataTypes.STRING, field: 'busi_id', allowNull: false,defaultValue:'', comment:'业务id'},
product_id: {type: DataTypes.BIGINT, field: 'product_id', allowNull: true,defaultValue:0, comment:'产品id'},
price: { type: DataTypes.BIGINT, field: 'price', allowNull: true, defaultValue:0,comment:'订单价格'},
status: {type: DataTypes.INTEGER, field: 'status', allowNull: true, defaultValue:'0',comment:'订单状态 业务进度' },
assign_time: {type: DataTypes.DATE, field: 'assign_time', allowNull: true, defaultValue:null, comment:'分配时间' },
assign_user_id: {type: DataTypes.BIGINT, field: 'assign_user_id', allowNull: true, defaultValue:'0', comment:'分配人id' },
deliver_id: {type: DataTypes.STRING, field: 'deliver_id', allowNull: true, defaultValue:'', comment:'交付商id common微服务下' },
desc: {type: DataTypes.STRING, field: 'desc', allowNull: true, defaultValue:'', comment:'订单信息' },
bd_id: {type: DataTypes.STRING, field: 'bd_id', allowNull: true, defaultValue:'', comment:'业务员id' },
bd_path: {type: DataTypes.BIGINT, field: 'bd_path', allowNull: true, defaultValue:'', comment:'业务员权限路径' },
service_items: {type: DataTypes.STRING, field: 'service_items', allowNull: true, defaultValue:'', comment:'服务项json' },
service_remark: {type: DataTypes.STRING, field: 'service_remark', allowNull: true, defaultValue:'', comment:'服务信息备注' },
source_id: {type: DataTypes.BIGINT, field: 'source_id', allowNull: true, defaultValue:0, comment:'来源id' },
source_no: {type: DataTypes.STRING, field: 'source_no', allowNull: true, defaultValue:'', comment:'来源订单号' },
contact_mobile: {type: DataTypes.STRING, field: 'contact_mobile', allowNull: true, defaultValue:'', comment:'联系电话' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true }
},
{
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'o_order',
});
}
'use strict'
/**
* 订单来源表
*/
module.exports = function (db, DataTypes) {
return db.define('osource', {
name: {type: DataTypes.STRING, field: 'name', allowNull: false, defaultValue:'',comment:'平台来源' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true }
},
{
timestamps: false,
underscore: true,
paranoid: true,
version: true,
tableName: 'o_source',
comment: '订单来源表',
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("payment", {
order_id: DataTypes.STRING(32),
price: DataTypes.BIGINT,
payType: DataTypes.INTEGER,
payStatus: DataTypes.STRING,
channelName: DataTypes.STRING,
companyName: DataTypes.STRING,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'o_payment',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
'use strict'
/**
* 订单流程表
*/
module.exports = function (db, DataTypes) {
return db.define('oprocess', {
name: {type: DataTypes.STRING, field: 'name', allowNull: false, defaultValue:'', comment:'流程名称' },
status: { type: DataTypes.STRING, field: 'status', allowNull: false,defaultValue:'', comment:'流程状态'},
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true }
},
{
timestamps: true,
underscore: true,
paranoid: true,
version: true,
tableName: 'o_process',
comment: '订单交付表',
});
}
/**
* 订单产品表
*/
'use strict'
module.exports = function (db, DataTypes) {
return db.define('oproduct', {
name: {type: DataTypes.STRING, field: 'name', allowNull: true, comment:'产品名称' },
desc: { type: DataTypes.STRING(200), field: 'desc', allowNull: false, defaultValue:"", comment:'产品描述'},
pid: { type: DataTypes.BIGINT, field: 'pid', allowNull: true, comment:'父ID'},
is_choose: { type: DataTypes.BOOLEAN, field: 'is_choose', allowNull: false, defaultValue:false, comment:'是否选择'},
sort: {type: DataTypes.INTEGER, field: 'sort', allowNull: false, defaultValue:1000, comment:'排序' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true },
},
{
timestamps: false,
underscore: true,
paranoid: true,
version: true,
tableName: 'o_product',
comment: '订单产品表',
});
}
/**
* 订单状态表
*/
'use strict'
module.exports = function (db, DataTypes) {
return db.define('oproductprocess', {
product_id: {type: DataTypes.STRING, field: 'product_id', allowNull: true, comment:'产品ID' },
// name: { type: DataTypes.STRING(200), field: 'name', allowNull: false, defaultValue:"", comment:'产品名称'},
// status: {type: DataTypes.STRING, field: 'status', allowNull: true, comment:'状态' },
func: { type: DataTypes.STRING, field: 'func', allowNull: false, comment:'状态执行方法名称'},
next_status: {type: DataTypes.STRING, field: 'next_status', allowNull: true, comment:'下一个状态'},
name1: { type: DataTypes.STRING, field: 'name1', allowNull: true, comment:'状态1'},
name2: {type: DataTypes.STRING, field: 'name2', allowNull: true, comment:'状态2' },
name3: { type: DataTypes.STRING, field: 'name3', allowNull: true, comment:'状态3'},
name4: {type: DataTypes.STRING, field: 'name4', allowNull: true, comment:'状态4' },
sort: {type: DataTypes.INTEGER, field: 'sort', allowNull: false, defaultValue:1, comment:'排序' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true },
},
{
timestamps: true,
underscore: true,
paranoid: true,
version: true,
tableName: 'o_product_process',
comment: '产品状态表',
});
}
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class BusinessmenService extends ServiceBase {
constructor() {
super("business", ServiceBase.getDaoName(BusinessmenService));
......@@ -80,6 +81,7 @@ class BusinessmenService extends ServiceBase {
return system.getResult(null, "接口异常");
}
}
async apiDeliverPage(params) {
try {
return await this.deliverPage(params);
......@@ -271,7 +273,8 @@ class BusinessmenService extends ServiceBase {
async getCompleteMapByCreditCodes(params) {
var result = {};
var attrs = "id, creditCode, name, isBank, taxOrg, taxUpType, addValueUpType, costRate, " +
"taxRate, serviceRate,commonTaxLadder,commonOtherLadder,specialTaxLadder,specialOtherLadder";
"taxRate, serviceRate,commonTaxLadder,commonOtherLadder,specialTaxLadder,specialOtherLadder, " +
"serviceBeginTime, serviceEndTime";
var condition = {
creditCodes: params.creditCodes,
......@@ -284,6 +287,7 @@ class BusinessmenService extends ServiceBase {
var ids = [];
for (var item of list) {
this.handleDate(item, ["serviceBeginTime", "serviceEndTime"], "YYYY-MM-DD", -8);
ids.push(item.id);
}
......@@ -378,7 +382,7 @@ class BusinessmenService extends ServiceBase {
}
return system.getResultSuccess(page);
}
async deliverPage(params) {
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
......@@ -448,25 +452,28 @@ class BusinessmenService extends ServiceBase {
bm.serviceRate = params.serviceRate;
bm.signNotes = this.trim(params.signNotes);
bm.commonTaxLadder = params.commonTaxLadder || "";
bm.commonOtherLadder = params.commonOtherLadder || "";
bm.specialTaxLadder = params.specialTaxLadder || "";
bm.specialOtherLadder = params.specialOtherLadder || "";
bm.serviceBeginTime = pobj.serviceBeginTime;
bm.serviceEndTime = pobj.serviceEndTime;
bm.commonTaxLadder = params.commonTaxLadder || "[]";
bm.commonOtherLadder = params.commonOtherLadder || "[]";
bm.specialTaxLadder = params.specialTaxLadder || "[]";
bm.specialOtherLadder = params.specialOtherLadder || "[]";
bm.signTime = new Date();
await bm.save();
var iclist = params.invoicecontents || [];
await this.businessmeninvoicecontentDao.delByBusinessmenId(bm.id);
var icobjs = [];
for(var ic of iclist) {
if(!ic) {
for (var ic of iclist) {
if (!ic) {
continue;
}
delete ic.id;
ic.businessmen_id = bm.id;
icobjs.push(ic);
}
if(icobjs.length > 0) {
if (icobjs.length > 0) {
await this.businessmeninvoicecontentDao.bulkCreate(icobjs);
}
return system.getResultSuccess();
......@@ -488,11 +495,7 @@ class BusinessmenService extends ServiceBase {
row.invoicecontents = icmap[row.id] || [];
}
}
}
module.exports = BusinessmenService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
const moment = require("moment");
class ChannelService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(ChannelService));
}
}
module.exports = ChannelService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
const moment = require("moment");
class IbdeliverbaseService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(IbdeliverbaseService));
}
}
module.exports = IbdeliverbaseService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
......@@ -2,6 +2,7 @@ const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
const moment = require("moment");
class IborderService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(IborderService));
......@@ -10,6 +11,9 @@ class IborderService extends ServiceBase {
this.microsveClient = system.getObject("util.microsve.microsveClient");
this.businessmenDao = system.getObject("db.business.businessmenDao");
this.iborderbaseDao = system.getObject("db.order.iborderbaseDao");
this.paymentDao = system.getObject("db.order.paymentDao");
}
async api(params) {
......@@ -120,6 +124,7 @@ class IborderService extends ServiceBase {
return system.getResult(null, "接口异常");
}
}
async apiCloseById(params) {
try {
return await this.closeById(params);
......@@ -155,6 +160,7 @@ class IborderService extends ServiceBase {
return system.getResult(null, "接口异常");
}
}
async apiStatBusinessData(params) {
try {
return await this.statBusinessData(params);
......@@ -164,8 +170,113 @@ class IborderService extends ServiceBase {
}
}
// -----------------------以此间隔,上面为API下面为service---------------------------------
async orderPage(params) {
let page = await this.allList(params);
return page;
}
async createOrder(params, t) {
// 产品项
var order = {};
// 赋值
for (var k in params) {
order[k] = params[k];
}
order.productItems = (order.productItems || []).join(",");
order.status = "1010";
var busiStatus = await this.orderBusinessStatus.findOrderBusinessStatus(order.status);
if (busiStatus) {
order.ostatus = busiStatus.ostatus;
}
// 三方渠道号
order.channelOrderNo = this.trim(params.channelOrderNo);
// 订单资料信息
order.legalName = this.trim(params.legalName);
order.legalMobile = this.trim(params.legalMobile);
order = await this.dao.create(order, t);
return system.getResultSuccess({
orderNo: order.id
});
}
async completedOrder(params, t) {
let order = await this.findById(params.id);
if (!params.legalName) {
return system.getResult(null, '法人姓名');
}
if (!params.legalMobile) {
return system.getResult(null, '法人电话');
}
if (!params.idcard) {
return system.getResult(null, '法人身份证');
}
if (!params.idcardFront) {
return system.getResult(null, '身份证正面照片');
}
if (!params.idcardBack) {
return system.getResult(null, '身份证反面照片');
}
if (!params.names) {
return system.getResult(null, '个体户名称');
}
if (!params.capital) {
return system.getResult(null, '注册资本');
}
if (!params.domicile_id) {
return system.getResult(null, '注册地id');
}
if (!params.domicileName) {
return system.getResult(null, '注册地名称');
}
if (!params.businessType) {
return system.getResult(null, '经营范围');
}
if (!params.businessScope) {
return system.getResult(null, '经营范围详情');
}
if (!params.mailAddr) {
return system.getResult(null, '邮寄地址');
}
if (!params.mailTo) {
return system.getResult(null, '收件人');
}
if (!params.mailMobile) {
return system.getResult(null, '收件人电话');
}
order.legalName = params.legalName;
order.legalMobile = params.legalMobile;
order.idcard = params.idcard;
order.idcardFront = params.idcardFront;
order.idcardBack = params.idcardBack;
order.names = params.names;
order.capital = params.capital;
order.domicile_id = params.domicile_id;
order.domicileName = params.domicileName;
order.businessType = params.businessType;
order.businessScope = params.businessScope;
order.mailAddr = params.mailAddr;
order.mailTo = params.mailTo;
order.mailMobile = params.mailMobile;
// -----------------------以此间隔,上面为API,下面为service---------------------------------
order.isInfoComplete = true;
let orderBase = await this.iborderbaseDao.findById(params.id);
orderBase.isInfoComplete = true;
await order.save();
await orderBase.save();
return system.getResultSuccess();
}
async statTransData(params) {
var result = {
......@@ -280,11 +391,11 @@ class IborderService extends ServiceBase {
addStatCount(statusMap, statuses) {
var count = 0;
if(!statuses) {
if (!statuses) {
return count;
}
for(var status of statuses) {
for (var status of statuses) {
count = count + Number(statusMap[status] || 0);
}
return count;
......@@ -317,34 +428,38 @@ class IborderService extends ServiceBase {
}
async add(params) {
var order = {};
let order = {};
order.price = Number(params.price || 300000);
order.status = "1000";
var merchantId = params.merchantId || params.merchant_id;
let payStatus = 10;
let payType = 1;
let merchantId = params.merchantId || params.merchant_id;
if (merchantId) {
var exists = await this.dao.findOne({
let exists = await this.dao.findOne({
merchant_id: this.trim(merchantId),
channelOrderNo: this.trim(params.channelOrderNo),
});
if (exists) {
return system.getResult(null, "订单号【" + params.channelOrderNo + "】重复");
}
var merchantData = await this.microsveClient.call("merchant", "getById", {
let merchantData = await this.microsveClient.call("merchant", "getById", {
"id": merchantId
});
if (merchantData.status != 0) {
return merchantData;
}
var merchant = merchantData.data;
let merchant = merchantData.data;
if (!merchant.mustPay) {
order.price = 0;
order.status = "1020";
payStatus = 20; // 设置已支付
payType = 2; // 设置为按年支付
}
}
var busiStatus = await this.orderBusinessStatus.findOrderBusinessStatus(order.status);
let busiStatus = await this.orderBusinessStatus.findOrderBusinessStatus(order.status);
if (busiStatus) {
order.ostatus = busiStatus.ostatus;
}
......@@ -384,7 +499,39 @@ class IborderService extends ServiceBase {
order.mailMobile = this.trim(params.mailMobile);
order.userId = this.trim(params.userId);
order = await this.dao.create(order);
let baseOrder = {
merchant_id: merchantId,
businessmen_id: "",
channelNo: "qiye",
thirdNo: order.channelOrderNo,
productType: 1000,
bdId: order.bdId,
bdPath: order.bdPath,
price: order.price,
payStatus: payStatus,
status: 1000,
isInfoComplete: true,
};
order = await this.db.transaction(async t => {
baseOrder = await this.iborderbaseDao.create(baseOrder, t);
order.id = baseOrder.id;
let payment = {
order_id: baseOrder.id,
price: baseOrder.price,
channelName: "",
companyName: merchant.name,
payType: payType,
payStatus: "10",
};
payment = await this.paymentDao.create(payment, t);
params.orderpay_id = payment.id;
order = await this.dao.create(order, t);
return order;
});
return system.getResultSuccess({
orderNo: order.id
});
......@@ -463,7 +610,6 @@ class IborderService extends ServiceBase {
if (status) {
where.status = status
}
this.addWhereTime(where, 'created_at', params.createdBegin, params.createdEnd);
this.addWhereTime(where, 'assignTime', params.assignBegin, params.assignEnd);
......@@ -646,6 +792,9 @@ class IborderService extends ServiceBase {
if (order.orderDeliverId) {
return system.getResult(null, "该订单已分配,不允许再次分配");
}
if (!order.isInfoComplete) {
return system.getResult(null, "请先完善订单信息");
}
order.status = "1030";
order.assignTime = new Date();
......@@ -754,6 +903,7 @@ class IborderService extends ServiceBase {
deliverType: self.trim(params.deliverType),
deliverNo: self.trim(params.deliverNo),
deliverImg: self.trim(params.deliverImg),
completeFile: self.trim(params.completeFile),
}
await self.dao.update(orderFields, t);
await self.businessmenDao.update({
......@@ -766,6 +916,7 @@ class IborderService extends ServiceBase {
return system.getResultSuccess();
}
}
module.exports = IborderService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
const moment = require("moment");
class IborderbaseService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(IborderbaseService));
this.iborderSve = system.getObject("service.order.iborderSve");
this.iborderdkSve = system.getObject("service.order.iborderdkSve");
this.iborderdzSve = system.getObject("service.order.iborderdzSve");
this.businessmenSve = system.getObject("service.business.businessmenSve");
this.channelSve = system.getObject("service.order.channelSve");
this.paymentSve = system.getObject("service.order.paymentSve");
this.services = {
"1000": this.iborderSve, // 注册订单
"1010": this.iborderdkSve, // 代开订单
"1030": this.iborderdzSve, // 代账订单
"1040": this.iborderSve, // 增值服务
}
this.verifyProductType=["1010","1030"];
}
getService(productType) {
return this.services[productType];
}
/**
* 创建基类订单
* @param {*} params
*/
async apiCreateOrder(params) {
this.trimObject(params);
if (!params.thirdNo) {
return system.getResult(null, `请传入订单号`);
}
let productType = this.trim(params.productType);
let childSve = this.getService(productType);
if (!childSve) {
return system.getResult(null, `暂不支持此种产品类型:${productType}`);
}
try {
let exists = await this.dao.findOne({thirdNo: params.thirdNo});
if(exists) {
return system.getResult(null, `订单号【${params.thirdNo}】已存在`);
}
let channel =await this.channelSve.findOne({channelNo: params.channelNo});
if (!channel) {
return system.getResult(null, `渠道${params.channelNo}不存在`);
}
params.channelNo = this.trim(params.channelNo);
params.thirdNo = this.trim(params.thirdNo);
params.notes = this.trim(params.notes);
params.legalName = this.trim(params.legalName);
params.legalMobile = this.trim(params.legalMobile);
params.legalEmail = this.trim(params.legalEmail);
params.payType = Number(params.payType || 1);
params.productType = productType;
params.price = Number(params.price || 0);
params.status = "1000"; // 待处理
params.payStatus = "10"; // 支付状态
params.channelOrderNo = params.channelNo;
params.payType = this.trim(params.payType);
let self = this;
//1 保存基类的信息
await this.db.transaction(async t => {
//创建基类表
let _baseOrder = await self.create(params, t);
var payment = {
order_id: _baseOrder.id,
price: params.price,
channelName: channel.channelName,
companyName: "",
payType: params.payType,
payStatus: "10",
};
payment = await this.paymentSve.create(payment, t);
params.orderpay_id = payment.id;
// 将id赋值
params.id = _baseOrder.id;
// 创建订单
await childSve.createOrder(params, t);
});
return system.getResultSuccess();
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 完善信息
* @param {*} params
*/
async apiCompletedOrder(params) {
try {
let baseorder = await this.dao.findById(params.id);
let childSve = this.getService(baseorder.productType);
return await childSve.completedOrder(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 订单办理
* @param {} params
*/
async apiHandling(params) {
try {
let _baseOrder = this.dao.findById({id:this.trim(params.id),productType:this.trim(params.productType)});
if(!_baseOrder){
return system.getResult(null,`参数错误 订单不存在`);
}
let childSve = this.getService(params.productType);
return await childSve.handling(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 订单列表
* @param {*} params
* @param {*} params.productType //产品类型
*/
async apiOrders(params){
try {
let childSve = this.getService(params.productType);
let page = await childSve.orderPage(params);
if(page && page.data && page.data.rows) {
await this.setBaseOrder(page.data.rows);
}
for(let item of page.data.rows){
if(item.baseInfo && item.baseInfo.productType!="1000"){
this.changeStatus(item.baseInfo,item);
this.changePayStatus(item.baseInfo,item);
}
}
return page;
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
changeStatus (baseInfo,orderInfo){
// 1000待处理 1010办理中 1020办理完成 2000已取消
if(baseInfo.status=="1000"){
orderInfo.ostatusName = "待处理";
}else if(baseInfo.status=="1010"){
orderInfo.ostatusName = "办理中";
}else if(baseInfo.status=="1020"){
orderInfo.ostatusName = "办理完成";
}else if(baseInfo.status=="2000"){
orderInfo.ostatusName = "已取消";
}else{
orderInfo.ostatusName = "";
}
}
changePayStatus (baseInfo,orderInfo){
//支付状态 10待支付 20已支付
if(baseInfo.payStatus=="10"){
orderInfo.payStatusName = "待支付";
}else if(baseInfo.payStatus=="20"){
orderInfo.payStatusName = "已支付";
}else{
orderInfo.payStatusName = "";
}
}
/**
* 企服通 推送支付信息接口
* @param {*} params
* id //订单ID
* price //支付金额
* orderpayId //支付id
*
* 所有主表的信息和子表的信息更新 都必须在子实现类中更新
*/
async completedOrderInfo(params, t) {
try {
if(!params.id){
return system.getResult(null,`参数错误 ID不能为空`);
}else{
params.id = this.trim(params.id);
}
if(params.price<0){
return system.getResult(null, `参数错误 支付金额非法`);
}else{
params.price= Number(params.price);
}
if(params.orderpayId){
return system.getResult(null,`参数错误 支付ID非法`);
}else{
params.orderpay_id = orderpayId;
}
let _iborderbase = await this.dao.findById(this.trim(params.id));
if(!_iborderbase){
return system.getResult(null,`订单不存在`);
}
// 产品类型 1000注册订单 1010代开订单 1030代账订单
if(_iborderbase.productType=="1000"){
// await this.iborderdkSve.updateOrder()
return system.getResult(null,`暂不支持 此类型商品`);
}else if(_iborderbase.productType=="1010"){
//业务状态 1000待分配 1010办理中 1020办理完成
params.payStatus = params.payStatus?this.trim(params.payStatus):"20";
params.status=params.status?this.trim(params.status):"1010";
//更新订单
await this.iborderdkSve.updateOrder(params);
}else if(_iborderbase.productType=="1030"){
//await this.iborderdkSve.updateOrder()
return system.getResult(null,`暂不支持 此类型商品`);
}else {
return system.getResult(null,`当前订单类型不存在 请联系管理员`);
}
return system.getResultSuccess();
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async apiAdd(params) {
try {
let sve = this.getService(params.productType);
if (!sve) {
return system.getResult(null, `产品类型错误${params.productType}`);
}
return sve.addOrder(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiSaveInfo() {
try {
let sve = this.getService(params.productType);
if (!sve) {
return system.getResult(null, `产品类型错误${params.productType}`);
}
return sve.saveInfo(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async setBaseOrder(rows) {
if (!rows || rows.length == 0) {
return;
}
var ids = [];
for (var row of rows) {
ids.push(row.id);
}
let map = await this.dao.findMapByIds(ids);
for (var row of rows) {
row.baseInfo = map[row.id];
}
}
}
module.exports = IborderbaseService;
\ No newline at end of file
......@@ -272,21 +272,85 @@ class IborderdeliverService extends ServiceBase {
this.addWhereTime(where, 'created_at', params.createdBegin, params.createdEnd);
var page = await this.getPageList(currentPage, pageSize, where, orderby);
if (page && page.rows) {
await this.setOrder(page.rows, "`id`, `legalName`, `legalMobile`, `price`, `idcard`, `productItems` ");
for (var row of page.rows) {
await this.dao.setRowCodeName(row, "status");
// 下一个状态
var nextObj = await this.orderBusinessStatus.findOrderNextBusinessStatus(row.status);
row.nextStatus = nextObj.status;
row.nextStatusName = nextObj.name;
await this.setNextStatus(row);
// var nextObj = await this.orderBusinessStatus.findOrderNextBusinessStatus(row.status);
// row.nextStatus = nextObj.status;
// row.nextStatusName = nextObj.name;
this.handleDate(row, ["created_at"], null, -8);
}
await this.setOrder(page.rows, "`id`, `legalName`, `legalMobile`, `price`, `idcard`");
}
return system.getResultSuccess(page);
}
async setNextStatus(row) {
if (!row) {
return;
}
let items = this.trim(row.productItems);
if (items) {
let itemArr = items.split(",");
// 当前订单状态
let curStatus = row.status;
let nextStatus = "";
if (curStatus == "1030") {
if(itemArr.indexOf("1050") != -1) {
nextStatus = "1050";
} else if (itemArr.indexOf("1070") != -1) {
nextStatus = "1070";
} else if (itemArr.indexOf("1090") != -1) {
nextStatus = "1090";
} else if (itemArr.indexOf("1110") != -1) {
nextStatus = "1110";
} else {
nextStatus = await this.orderBusinessStatus.findOrderNextBusinessStatus(curStatus);
}
} else if(curStatus == "1050") {
if (itemArr.indexOf("1070") != -1) {
nextStatus = "1070";
} else if (itemArr.indexOf("1090") != -1) {
nextStatus = "1090";
} else if (itemArr.indexOf("1110") != -1) {
nextStatus = "1110";
} else {
nextStatus = await this.orderBusinessStatus.findOrderNextBusinessStatus(curStatus);
}
} else if (curStatus == "1070") {
if (itemArr.indexOf("1090") != -1) {
nextStatus = "1090";
} else if (itemArr.indexOf("1110") != -1) {
nextStatus = "1110";
} else {
nextStatus = await this.orderBusinessStatus.findOrderNextBusinessStatus(curStatus);
}
} else if (curStatus == "1090") {
if (itemArr.indexOf("1110") != -1) {
nextStatus = "1110";
} else {
nextStatus = await this.orderBusinessStatus.findOrderNextBusinessStatus(curStatus);
}
} else {
nextStatus = await this.orderBusinessStatus.findOrderNextBusinessStatus(curStatus);
}
var nextObj = await this.orderBusinessStatus.findOrderBusinessStatus(nextStatus);
row.nextStatus = nextObj.status;
row.nextStatusName = nextObj.name;
return;
}
var nextObj = await this.orderBusinessStatus.findOrderNextBusinessStatus(row.status);
row.nextStatus = nextObj.status;
row.nextStatusName = nextObj.name;
}
async setOrder(rows, attrs) {
if (!rows || rows.length == 0) {
return;
......@@ -358,6 +422,7 @@ class IborderdeliverService extends ServiceBase {
updateFields.legalName = self.trim(order.legalName);
updateFields.legalMobile = self.trim(order.legalMobile);
updateFields.legalIdcard = self.trim(order.idcard);
updateFields.gongshangFile = self.trim(params.gongshangFile);
if (businessmen.id) {
updateFields.id = businessmen.id;
......@@ -395,6 +460,7 @@ class IborderdeliverService extends ServiceBase {
updateFields.fapiaozhang = self.trim(params.fapiaozhang);
updateFields.hetongzhang = self.trim(params.hetongzhang);
updateFields.farenzhang = self.trim(params.farenzhang);
updateFields.kezhangFile = self.trim(params.kezhangFile);
await self.businessmenDao.update(updateFields, t);
await self.updateOrderStatusTranscation(dorder, params.nextObj, t);
......@@ -422,6 +488,8 @@ class IborderdeliverService extends ServiceBase {
updateFields.bank = self.trim(params.bank);
updateFields.bankImg = self.trim(params.bankImg);
updateFields.kaihuFile = self.trim(params.kaihuFile);
await self.businessmenDao.update(updateFields, t);
await self.updateOrderStatusTranscation(dorder, params.nextObj, t);
return 1;
......@@ -446,6 +514,7 @@ class IborderdeliverService extends ServiceBase {
updateFields.caImg = params.caImg;
updateFields.taxRegDay = params.taxRegDay;
updateFields.taxOrg = params.taxOrg;
updateFields.shuiwuFile = self.trim(params.shuiwuFile);
await self.businessmenDao.update(updateFields, t);
await self.updateOrderStatusTranscation(dorder, params.nextObj, t);
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
const moment = require("moment");
const calInvoice = require("../../../utils/calInvoice");
class IborderdkService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(IborderdkService));
this.baseDao = system.getObject("db.order.iborderbaseDao");
this.businessmenDao = system.getObject("db.business.businessmenDao");
this.iborderbaseDao = system.getObject("db.order.iborderbaseDao");
}
async addOrder(params) {
}
/**
* 创建订单
* @param {*} params
*/
async createOrder(params, t) {
try {
this.trimObject(params);
let _ibOrderDk = await this.dao.create(params, t);
return system.getResult(_ibOrderDk);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 更新数据
* @param {*} params
* @param {*} t
*/
async updateOrder(params, t) {
try {
if (!params.id) {
return system.getResult(null, `参数错误 ID 不能为空`);
}
this.trimObject(params);
return await this.dao.update(params, t);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 完善信息
* @param {*} params
* legalName
* legalMobile
* names
* creditCode
* isBank
* businessScope
* orderId
*/
async completedOrder(params) {
try {
//1 检查个体户是否存在 (根据统一社会信用代码查个体工商户是否存在)
this.trimObject(params);
if (!params.orderId) {
return system.getResult(null, `参数错误 ID 不能为空`);
} else {
params.order_id = this.trim(params.orderId);
}
if (!params.legalName) {
return system.getResult(null, `参数错误 法人姓名不能为空`);
}
if (!params.legalMobile) {
return system.getResult(null, `参数错误 法人电话不能为空`);
}
if (!params.creditCode) {
return system.getResult(null, `参数错误 法人统一社会信用代码不能为空`);
}
if (!params.names) {
return system.getResult(null, `参数错误 个体户名称不能为空`);
}
if (!params.businessScope) {
return system.getResult(null, `参数错误 经营范围不能为空`);
}
//2 如果不存在添加保存个体户 完善信息
let _businessmenRes = await this.businessmenDao.findBusinessmenByCreditCode(this.trim(params.creditCode));
if (_businessmenRes.hasOwnProperty("status")) {
return _businessmenRes;
}
if (_businessmenRes.id) {
//如果用户存在id 直接更新
let _iborderbase = await this.iborderbaseDao.findById(this.trim(params.orderId));
if (!_iborderbase) {
return system.getResult(null, `参数错误 订单不存在`);
}
let self = this;
//向参数中添加 是否完善信息标识
// 更新字段设置
let updateFields = {
businessmen_id: self.trim(_businessmenRes.id),
id: self.trim(params.id),
isInfoComplete: 1
};
// 如果businessmen不存在order_id, 设置更新
if(!_businessmenRes || !_businessmenRes.order_id) {
updateFields.order_id = _iborderbase.id;
}
await this.db.transaction(async t => {
//更新主表
await self.iborderbaseDao.update(updateFields, t);
//更新子表
params.id = self.trim(params.order_id);
params.isInfoComplete = 1;
await self.dao.update(params, t);
});
} else {
delete params.id; // 删除id, 因为这个id是 orderId
let self = this;
await this.db.transaction(async t => {
//如果不存在id 创建后更新
let _businessment = await this.businessmenDao.create(params, t);
//更新主表
params.id = self.trim(params.orderId);
params.isInfoComplete = 1;
await self.iborderbaseDao.update({
businessmen_id: self.trim(_businessment.id),
isInfoComplete: 1,
id: params.id
}, t);
//更新子表
await self.dao.update(params, t);
});
}
return system.getResultSuccess();
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 订单办理
* @param {} params
* businessmenId 个体户ID
* id 订单ID
*/
async handling(params) {
try {
let _iborderbase = await this.iborderbaseDao.findById(this.trim(params.id));
if (!_iborderbase.isInfoComplete != 1) {
return system.getResult(null, `请完善信息再注册`);
}
//1 检查个体户是否签约
let _businessmen = await this.businessmenDao.findById(this.trim(params.businessmenId));
if (!_businessmen.signTime) {
return system.getResultFail(-2, "个体户未签约",-2);
}
let valueAddedTax = 0;
let additionalTax = 0;
///**************************************************************** */
if (_iborderbase.payType != 20) {
//如果不是年付费 计算费用
let invoiceParams = await this.buildParamForCalInvoice(params);
valueAddedTax = await calInvoice.calculationValueAddedTax(invoiceParams);
//填充 增值税参数
invoiceParams.valueAddedTax = valueAddedTax;
additionalTax = await calInvoice.calculationAdditionalTax(invoiceParams);
let res = {valueAddedTax: valueAddedTax, additionalTax: additionalTax};
//4 推送计算结果 暂不推送
return system.getResult(res);
} else {
//5 如果是不是按照年付款 直接更新订单金额
// let _arguments = {};
// _arguments.price=Number(valueAddedTax) + Number(additionalTax);
// let updatePriceRes =await this.updateOrder(_arguments);
//6 提交发票申请
let submitApplyInvoiceParams = await this.buildParamForApplyInvoice(params);
if (submitApplyInvoiceParams.hasOwnProperty("status") == 0) {
return system.getResultSuccess(null, `发票申请已提交`);
} else {
return system.getResult(null, `发票申请失败`);
}
}
} catch (error) {
return system.getResult(null, `系统错误 错误信息${error}`);
}
}
/**
* 创建计算发票所需的参数
*/
async buildParamForCalInvoice(params) {
let data = {
"businessmenCreditCode": "111",
"businessmenType": "10",
"calNames": "valueAddedTax",
"valCalWay": "1",
"businessmenId": "12795594625000138",
"taxIncPriRat": 0.03,
"invoiceTime": "2019-11-26",
"invoiceAmount": 20000000,
"perIncTaxRange": [
{
"minValue": 0,
"rate": "5",
"quiCalDed": 0,
"maxValue": 3000000
},
{
"minValue": 3000100,
"rate": "6",
"quiCalDed": 200000,
"maxValue": 10000000
},
{
"minValue": 10000001,
"rate": "8",
"quiCalDed": 0,
"maxValue": 214748364700
}
],
"valAddTaxRange": [
{
"minValue": 0,
"zengzhiRate": "3",
"fujiaRate": "12",
"maxValue": 3000000
},
{
"minValue": 3000100,
"zengzhiRate": "3",
"fujiaRate": "15",
"maxValue": 10000000
},
{
"minValue": 10000001,
"zengzhiRate": "4",
"fujiaRate": "16",
"maxValue": 214748364700
}
]
}
return data;
}
/**
* 创建申请发票所需的参数
* @param {*} params
*/
async buildParamForApplyInvoice(params) {
let data = {
"serviceRate": 4,
"perCalWay": "1",
"valCalWay": "2",
"taxCostPriRat": 0.95,
"taxIncPriRat": 1.50,
"invoiceTime": "2019-10-19",
"perIncTaxRange": [
{
"minValue": 0,
"rate": "1",
"quiCalDed": 100000,
"maxValue": 3000000
},
{
"minValue": 3000100,
"rate": "1.5",
"quiCalDed": 200000,
"maxValue": 10000000
},
{
"minValue": 10000001,
"rate": "4.86",
"quiCalDed": 300000,
"maxValue": 214748364700
}
],
"valAddTaxRange": [
{
"minValue": 0,
"zengzhiRate": "1",
"fujiaRate": "6",
"maxValue": 3000000
},
{
"minValue": 3000100,
"zengzhiRate": "2",
"fujiaRate": "8",
"maxValue": 10000000
},
{
"minValue": 10000001,
"zengzhiRate": "3",
"fujiaRate": "12",
"maxValue": 214748364700
}
],
"merchantId": "11064622752480055",
"merchantAccount": "driverBabyPublicAccount",
"merchantName": "司机宝",
"merchantCreditCode": "91110108MA008KB56P",
"merchantAddr": "北京市海淀区北太平庄路18号3层3-0227",
"merchantMobile": "010-5369854",
"merchantBank": "110108022130868",
"businessmenId": "110115023996882",
"businessmenCreditCode": "91110115MA00HDC44L",
"businessName": "北京富通勤国际贸易有限责任公司(个体工商)",
"isBank": 1,
"taxAuthorities": "北京大兴税务局",
"type": 20,
"invoiceAmount": 4000000,
"statements": "wwww.baidu.com",
"contract": "www.qq.com",
"applyNo": "gongsibao-futong001",
"isInvalid": 2,
"parentId": null,
"status": "1000",
"customerStatus": "1000",
"payWay": "20",
"payAccount": null,
"isPay": 1,
"mailAddr": "北京市海淀区北太平庄路18号3层3-0227",
"mailMobile": "18633923636",
"mailTo": "赵彩红"
}
return data;
}
/**
* 更新订单金额 、订单的状态
* @param {*} params
* id 订单的ID
* price 订单的金额
* status 订单的状态
* orderpay_id 订单的支付Id
*/
async updateOrder(params) {
try {
if (!params.id) {
return system.getResult(null, `参数错误 ID不能为空`);
}
let _iborderbase = await this.iborderbaseDao.findById(this.trim(params.id));
if (!_iborderbase) {
return system.getResult(null, `订单不存在`);
}
let _iborderdk = await this._ibOrderDk.findById(this.trim(params.id));
if (!_iborderdk) {
return system.getResult(null, `订单不存在`);
}
let updateDate = {};
if (params.status) {
updateDate.status = this.trim(params.status);
}
if (params.price) {
updateDate.price = Number(params.price || 0);
}
if (params.orderpay_id) {
updateDate.orderpay_id = this.trim(params.orderpay_id);
}
let self = this;
let res = await this.dao.db.transaction(async t => {
//更新主表
await self._iborderbase.dao.update(updateDate, t);
//更新子表
await self.dao.update(updateDate, t);
});
return system.getResult(res);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async orderPage(params) {
let currentPage = Number(params.currentPage || 1);
let pageSize = Number(params.pageSize || 10);
let statuses = params.statuses;
var where = {};
var orderby = [
["id", 'desc']
];
if (params.id) {
where.id = params.id;
}
if (statuses && statuses.length > 0) {
where.status = {
[this.db.Op.in]: statuses
}
}
this.addWhereTime(where, 'created_at', params.createdBegin, params.createdEnd);
var page = await this.getPageList(currentPage, pageSize, where, orderby, null);
if (page && page.rows) {
for (var row of page.rows) {
await this.dao.setRowCodeName(row, "status");
this.handleDate(row, ["created_at"], null, -8);
}
}
return system.getResultSuccess(page);
}
}
module.exports = IborderdkService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
const moment = require("moment");
class IborderdkdeliverService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(IborderdkdeliverService));
}
}
module.exports = IborderdkdeliverService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
const moment = require("moment");
class IborderdzService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(IborderdzService));
this.iborderbaseDao = system.getObject("db.order.iborderbaseDao");
this.businessmenDao = system.getObject("db.business.businessmenDao");
}
/**
* 创建订单
* @param {*} params
*/
async createOrder(params, t) {
try {
if (!params.merchantId) {
return system.getResult(null, `参数错误 商户ID不能为空`);
}
if (!params.businessmentId) {
return system.getResult(null, `参数错误 个体户ID不能为空`);
}
if (!params.orderpayId) {
return system.getResult(null, `参数错误 支付ID不能为空`);
}
if (!Number(params.price) < 0) {
return system.getResult(null, `参数错误 订单金额格式错误`);
}
this.trimObject(params);
let _ibOrderDk = await this.dao.create(params, t);
return system.getResult(_ibOrderDk);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 更新数据
* @param {*} params
* @param {*} t
*/
async updateOrder(params, t) {
try {
if (!params.id) {
return system.getResult(null, `参数错误 ID 不能为空`);
}
this.trimObject(params);
return await this.dao.update(params, t);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 完善信息
* @param {*} params
* legalName
* legalMobile
* names
* creditCode
* isBank
* businessScope
*/
async completedOrder(params) {
try {
//1 检查个体户是否存在 (根据统一社会信用代码查个体工商户是否存在)
this.trimObject(params);
if (!params.id) {
return system.getResult(null, `参数错误 ID 不能为空`);
}
if (!params.legalName) {
return system.getResult(null, `参数错误 法人姓名不能为空`);
}
if (!params.legalMobile) {
return system.getResult(null, `参数错误 法人电话不能为空`);
}
if (!params.creditCode) {
return system.getResult(null, `参数错误 法人统一社会信用代码不能为空`);
}
if (!params.names) {
return system.getResult(null, `参数错误 个体户名称不能为空`);
}
if (!params.businessScope) {
return system.getResult(null, `参数错误 经营范围不能为空`);
}
params.order_id = params.id;
//2 如果不存在添加保存个体户 完善信息
let _businessmen = await this.businessmenDao.findOne({creditCode: this.trim(params.creditCode)});
if (_businessmen) {
//如果用户存在 直接更新
let _iborderbase = await this.iborderbaseDao.findById(this.trim(params.id));
if (!_iborderbase) {
return system.getResult(null, `参数错误 订单不存在`);
}
let self = this;
//向参数中添加 是否完善信息标识
params.isInfoComplete = 1;
var updateFields = {
businessmen_id: self.trim(_businessmen.id),
id: self.trim(params.id),
isInfoComplete: 1
};
if (!_businessmen || !_businessmen.order_id) {
updateFields.order_id = _iborderbase.id;
}
await this.db.transaction(async t => {
//更新主表
await self.iborderbaseDao.update(updateFields, t);
//更新子表
await this.dao.update(params, t);
});
} else {
delete params.id;
let self = this;
await this.db.transaction(async t => {
//如果不存在id 创建后更新
let _businessment = await this.businessmenDao.create(params, t);
//更新主表
await self.iborderbaseDao.update({
businessmen_id: self.trim(_businessment.id), id: self.trim(params.id),
isInfoComplete: 1
}, t);
//更新子表
await this.dao.update(params, t);
});
}
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 订单办理
* @param {} params
* businessmenId 个体户ID
* id 订单ID
*/
async handing(params) {
try {
let id = Number(params.id);
let baseOrder = this.iborderbaseDao.findById(id);
if (!baseOrder.isInfoComplete != 1) {
return system.getResult(null, `请完善信息再注册`);
}
//1 检查个体户是否签约
let _businessmen = await this.businessmenDao.findById(this.trim(params.businessmenId));
if (!_businessmen.signTime) {
return system.getResultFail(-2, "个体户未签约",-2);
}
let order = this.dao.findById(id);
baseOrder.status = "1020";
order.status = "1020";
await baseOrder.save();
await order.save();
return system.getResultSuccess();
} catch (error) {
return system.getResult(null, `系统错误 错误信息${error}`);
}
}
async orderPage(params) {
let currentPage = Number(params.currentPage || 1);
let pageSize = Number(params.pageSize || 10);
let statuses = params.statuses;
var where = {};
var orderby = [
["id", 'desc']
];
if (params.id) {
where.id = params.id;
}
if (statuses && statuses.length > 0) {
where.status = {
[this.db.Op.in]: statuses
}
}
this.addWhereTime(where, 'created_at', params.createdBegin, params.createdEnd);
var page = await this.getPageList(currentPage, pageSize, where, orderby, null);
if (page && page.rows) {
for (var row of page.rows) {
await this.dao.setRowCodeName(row, "status");
this.handleDate(row, ["created_at"], null, -8);
}
}
return system.getResultSuccess(page);
}
}
module.exports = IborderdzService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
/**
* 个体户
*/
class ObusinessmenService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(ObusinessmenService));
this.oorderDao = system.getObject("db.order.oorderDao");
this.oorderdeliverDao = system.getObject("db.order.oorderdeliverDao");
this.ASSIGN_STATUS = ['1160', '1170', '1180', '1190', '1200'];
}
/**
* 根据ID查记录
* @param {*} params
* @Id 个体户ID
*/
async queryObusinessmen(params) {
try {
let obj = await this.findById(this.trim(params.id));
return system.getResult(obj);
} catch (error) {
console.log(error);
return system.getResult(`系统错误 错误信息 ${error}`);
}
}
/**
* 签约
* @params
* @id
*
*/
async signing(params) {
if (!params.id) {
return system.getResult(null, `参数错误 个体户ID不能为空`);
}
if (!params.hasOwnProperty('cost_rate')) {
return system.getResult(null, `参数错误 核定成本费用率不能为空`);
}
if (!params.hasOwnProperty('add_value_up_type') && !params.add_value_up_type) {
return system.getResult(null, `参数错误 增值税累计类型不能为空`);
}
if (!params.hasOwnProperty('tax_up_type')) {
return system.getResult(null, `参数错误 个税累计类型不能为空`);
}
if (!params.hasOwnProperty('service_begin_time')) {
return system.getResult(null, `参数错误 服务开始时间不能为空`);
}
if (!params.hasOwnProperty('service_end_time')) {
return system.getResult(null, `参数错误 服务结束时间不能为空`);
}
if (!params.hasOwnProperty('service_rate') && !params.service_rate) {
return system.getResult(null, `参数错误 服务费比例不能为空`);
}
if (!params.hasOwnProperty('tax_rate') && !params.tax_rate) {
return system.getResult(null, `参数错误 含税价百分比不能为空`);
}
let _obusinessmen = await this.dao.findById(this.trim(params.id));
let _order = await this.oorderDao.model.findOne({
where:{
id:_obusinessmen.order_id
}
});
if(!_obusinessmen){
return system.getResult(null,`个体户不存在`);
}
if(!_order){
return system.getResult(null,`订单存在`);
}
if(this.ASSIGN_STATUS.indexOf(_order.status.toString())==-1){
return system.getResult(null,`个体工商户不能签约`);
}
_obusinessmen.cost_rate = this.trim(params.cost_rate);
_obusinessmen.add_value_up_type = this.trim(params.add_value_up_type);
_obusinessmen.tax_up_type = this.trim(params.tax_up_type);
_obusinessmen.service_begin_time = this.trim(params.service_begin_time);
_obusinessmen.service_end_time = this.trim(params.service_end_time);
_obusinessmen.service_rate = this.trim(params.service_rate);
_obusinessmen.tax_rate = this.trim(params.tax_rate);
_obusinessmen.sign_time = new Date();
_obusinessmen.sign_notes = this.trim(params.sign_notes);
_obusinessmen.special_other_ladder = params.special_other_ladder;
_obusinessmen.special_tax_ladder = params.special_tax_ladder;
_obusinessmen.common_other_ladder = params.common_other_ladder;
_obusinessmen.common_tax_ladder = params.common_tax_ladder;
try {
await _obusinessmen.save();
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null,`系统错误 错误信息${error}`);
}
}
/**
* 建账
* @param {*} params
*/
async createAccount(params){
if (!params.id) {
return system.getResult(null, `参数错误 个体工商户ID不能为空`);
}
let _obusinessmen = await this.dao.findById(this.trim(params.id));
if(!_obusinessmen){
return system.getResult(null,`个体户不存在`);
}
if (_obusinessmen.is_create_account) {
return system.getResult(null,`该个体户已经建帐`);
}
_obusinessmen.is_create_account = true;
try {
await _obusinessmen.save();
return system.getResultSuccess();
} catch (error) {
console.log(error);
system.getResult(null,`系统错误 错误信息${error}`);
}
}
async businessmenPage(params) {
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
params.startRow = (params.currentPage - 1) * params.pageSize;
let deliverId = params.deliver_id;
let orderIds = [];
if (deliverId) {
// 查询交付商关联订单id
let _orderIds = await this.oorderdeliverDao.orderIdsByDeliverId(deliverId);
if (!_orderIds || _orderIds.length == 0) {
return system.getResultSuccess({count: 0, rows: []});
}
orderIds = orderIds.concat(_orderIds);
}
let operatorId = params.operator_id;
if (operatorId) {
let _orderIds = await this.oorderdeliverDao.orderIdsByOperatorId(operatorId);
if (!_orderIds || _orderIds.length == 0) {
return system.getResultSuccess({count: 0, rows: []});
}
if (orderIds.length == 0) {
orderIds = orderIds.concat(_orderIds);
} else {
let tmpIds = [];
for (let oid of orderIds) {
if (_orderIds.indexOf(oid) != -1) {
tmpIds.push(oid);
}
}
if (tmpIds.length == 0) {
return system.getResultSuccess({count: 0, rows: []});
}
orderIds = tmpIds;
}
}
if (orderIds && orderIds.length > 0) {
params.orderIds = orderIds;
}
let total = await this.dao.countByCondition(params);
if (total == 0) {
return system.getResultSuccess({count: 0, rows: []});
}
let list = await this.dao.listByCondition(params);
if (list) {
for (var row of list) {
this.handleDate(row, ["created_at", "assignTime","reg_date","tax_reg_day","updated_at"], null, -8);
}
await this.doSignBtn(list);
}
return system.getResultSuccess({count: total, rows: list});
}
async doSignBtn(list) {
if (!list || list.length == 0) {
return;
}
let ids = [];
for (let item of list) {
ids.push(item.order_id);
}
let orderMap = await this.oorderDao.findMapByIds(ids, "id, status");
for (let item of list) {
let order = orderMap[item.order_id] || {};
item.showSign = this.ASSIGN_STATUS.indexOf(order.status.toString()) != -1;
}
}
}
module.exports = ObusinessmenService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const moment = require("moment");
/**
* 订单产品表
*/
class OorderService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(OorderService));
this.oorderinforegDao = system.getObject("db.order.oorderinforegDao");
this.oorderdeliverDao = system.getObject("db.order.oorderdeliverDao");
this.oorderprocessDao = system.getObject("db.order.oorderprocessDao");
this.obusinessmenDao = system.getObject("db.order.obusinessmenDao");
this.oorderdeliverDao = system.getObject("db.order.oorderdeliverDao");
this.osourceDao = system.getObject("db.common.osourceDao");
this.oproductDao = system.getObject("db.product.oproductDao");
this.oprocessDao = system.getObject("db.product.oprocessDao");
this.oproductprocessDao = system.getObject("db.product.oproductprocessDao");
}
/**
* 新增渠道订单
* @returns {Promise<void>}
*/
async addSourceOrder(params) {
// 整理参数
let order = {
merchant_id: "",
channel_order_no: "",
busi_type: 1,
busi_id: "",
price: 0,
};
order.product_id = Number(params.product_id);
order.source_id = Number(params.source_id);
order.source_no = this.trim(params.source_no);
order.desc = this.trim(params.notes);
order.contact_mobile = this.trim(params.contact_mobile);
// 验证订单是否存在
let exists = await this.dao.findOne({ source_id: order.source_id, source_no: order.source_no });
if (exists) {
return system.getResult(null, `订单号${order.source_no}已存在`);
}
// 验证来源
let source = await this.osourceDao.findById(order.source_id);
if (!source) {
return system.getResult(null, "来源错误");
}
// 验证产品
let product = await this.oproductDao.findById(order.product_id);
if (!product) {
return system.getResult(null, "产品错误");
}
// 构建订单流程列表
let orderProcessList = await this.buildOrderProcess(order.product_id);
if (!orderProcessList || orderProcessList.length == 0) {
return system.getResult(null, "产品流程未配置");
}
order.status = orderProcessList[0].status;
// 开启事务
var self = this;
await this.db.transaction(async function (t) {
// 插入订单数据
order = await self.dao.create(order, t);
// 插入订单状态数据
for (let op of orderProcessList) {
op.order_id = order.id;
}
await self.oorderprocessDao.bulkCreate(orderProcessList, t);
let orderReg = {
id: order.id,
legal_mobile: order.contact_mobile,
}
await self.oorderinforegDao.create(orderReg, t);
return order;
});
return this.getOrderProcessStatus(order.id, order.status);
// return order;
}
/**
* 查询订单信息
* @param {*} params
*/
async info(params) {
let row = await this.dao.getById(params.id);
if (!row) {
return system.getResult(null, "订单不存在");
}
await this.dao.setRowCodeName(row, "status");
let statusObj = await this.getOrderProcessStatus(row.id, row.status);
row.next_status = JSON.parse(statusObj.next_status || "[]");
row.status_name = statusObj.name;
this.handleDate(row, ["created_at", "assign_time"], null, -8);
return system.getResultSuccess(row);
}
async infoAll(params) {
let result = {};
let order = await this.dao.getById(params.id);
let orderInfo = await this.oorderinforegDao.getById(params.id);
let businessmen = {};
if (order.busi_type == 1) {
businessmen = await this.obusinessmenDao.getById(order.busi_id) || {};
}
let orderDeliver = await this.oorderdeliverDao.getById(order.deliver_id) || {};
await this.formateStatus([order]);
await this.formateSource([order]);
await this.formateProduct([order]);
this.handleDate(order, ["created_at", "sign_time", "assign_time"], "YYYY-MM-DD HH:mm:ss", -8);
this.handleDate(businessmen, ["tax_reg_day", "created_at", 'reg_date'], "YYYY-MM-DD HH:mm:ss", -8);
this.handleDate(orderInfo, ["created_at"], "YYYY-MM-DD HH:mm:ss", -8);
orderDeliver.deliver_divide = system.f2y(orderDeliver.deliver_divide);
orderInfo.capital = system.f2y(orderInfo.capital);
order.service_items = order.service_items.split(",")
result.order = order;
result.regInfo = orderInfo;
result.businessmen = businessmen;
result.orderDeliver = orderDeliver;
return system.getResultSuccess(result);
}
/**
* 构建产品流程对象
* @param productPid
* @param chooseProductIds
* @returns {Promise<void>}
*/
async buildOrderProcess(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);
}
if (productIds.length == 0) {
return null;
}
// 查询产品流程
let productProcessMap = await this.oproductprocessDao.findMapByProductProductIds(productPid, productIds);
// 批量查流程
let processMap = await this.oprocessDao.mapAll();
let orderProcessList = [];
for (let productId of productIds) {
// 产品子项流程列表
let productProcessList = productProcessMap[productId];
if (!productProcessList || productProcessList.length == 0) {
continue;
}
for (let idx = 0; idx < productProcessList.length; idx++) {
// 风还钻该处理每一个子项流程 变为 订单流程对象
let productProcess = productProcessList[idx];
let process = processMap[productProcess.process_id];
let nextArr = this.trim(productProcess.next_status).split(",");
let nextStatus = [];
for (var nextId of nextArr) {
nextId = Number(nextId || 0);
let nextObj = processMap[nextId];
if (!nextObj) {
continue;
}
nextStatus.push({ next_status: nextObj.status, next_name: nextObj.name });
}
let orderProcess = {
product_id: productPid,
name: process.name,
status: process.status,
func: productProcess.func,
next_status: JSON.stringify(nextStatus),
name1: productProcess.name1,
name2: productProcess.name2,
name3: productProcess.name3,
name4: productProcess.name4,
sort: productProcess.sort,
autoIncrement: true
};
// 上一个产品流程于当前产品流程连接
if (idx == 0 && orderProcessList.length > 0) {
let lastProcess = orderProcessList[orderProcessList.length - 1];
let nextObj = processMap[productProcess.process_id];
lastProcess.next_status = JSON.stringify([{ next_status: nextObj.status, next_name: nextObj.name }]);
}
orderProcessList.push(orderProcess);
}
}
return orderProcessList;
}
/**
* 订单管理列表
* @param {*} params
*/
async orders(params) {
let where = {};
if (params.id) {
where.id = this.trim(params.id);
}
if (params.status) {
where.status = this.trim(params.status);
}
if (params.deliver_id) {
where.deliver_id = this.trim(params.deliver_id);
}
if (params.bd_path) {
where.bd_path = {
[this.db.Op.like]: this.trim(params.bd_path) + "%"
}
}
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var orderby = [
["id", 'desc']
];
this.addWhereTime(where, 'created_at', params.createdBegin, params.createdEnd);
try {
var page = await this.getPageList(currentPage, pageSize, where, orderby, null);
//格式化订单来源
await this.formateSource(page.rows);
//格式化订单产品
await this.formateProduct(page.rows);
//格式化交付商
await this.formateDeliver(page.rows);
//格式化业务员
await this.formateStatus(page.rows);
for (let item of page.rows) {
this.handleDate(item, ["created_at", "sign_time"], "YYYY-MM-DD HH:mm:ss", -8);
}
return system.getResult(page);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 格式化列表来源数据
* @param {*} orderList
*/
async formateSource(orderList) {
let sourceSet = new Set();
let sourceIdList = [];
for (let item of orderList) {
if (item.source_id) {
sourceSet.add(item.source_id);
}
}
sourceIdList = Array.from(sourceSet);
let sourceMap = await this.osourceDao.mapByIds(sourceIdList);
for (let item of orderList) {
item.osource = sourceMap[item.source_id] || {}
}
}
/**
* 格式化订单产品
* @param {*} orderList
*/
async formateProduct(orderList) {
let productIdList = [];
for (let item of orderList) {
if (item.product_id) {
productIdList.push(item.product_id);
}
}
let productMap = await this.oproductDao.mapByIds(productIdList);
for (let item of orderList) {
item.oproduct = productMap[item.product_id] || {}
}
}
/**
* 格式化订单交付商
* @param {*} orderList
*/
async formateDeliver(orderList) {
let deliverIdList = [];
for (let item of orderList) {
if (item.deliver_id) {
deliverIdList.push(item.deliver_id);
}
}
let deliverMap = await this.oorderdeliverDao.mapByIds(deliverIdList);
for (let item of orderList) {
item.odeliver = deliverMap[item.deliver_id] || {}
}
}
/**
* 处理订单状态数据
* @param orderList
* @returns {Promise<void>}
*/
async formateStatus(orderList) {
let ids = [];
let statuses = [];
for (let item of orderList) {
ids.push(item.id);
statuses.push(item.status);
}
let map = await this.oorderprocessDao.mapByOrderIdsAndStatus(ids, statuses);
for (let item of orderList) {
let key = item.id + "_" + item.status;
let v = map[key] || {};
item.statusName = v.name;
item.status_name = v.name;
item.next_status = JSON.parse(v.next_status || "[]");
}
console.log(orderList);
}
/**
* 获取订单状态对象
* @param order_id
* @param status
* @returns {Promise<*|{}>}
*/
async getOrderProcessStatus(order_id, status) {
let map = await this.oorderprocessDao.mapByOrderIdsAndStatus([order_id], [status]);
return map[order_id + "_" + status] || {};
}
/**
* 分配业务员
* @param {*} params
* @id String 订单ID
* @bd_id String 业务员ID
* @status String 下一个状态码
* @bd_path String 业务员权限
*/
async assignSalesman(params) {
if (!params.bd_id) {
return system.getResult(null, `参数错误 业务员ID不能为空`);
}
try {
//更新订单业务员
let _order = await this.findById(params.id);
if (!_order) {
return system.getResult(null, `订单不存在`);
}
//to do ... 验证下一个状态
await this.statusAction(params);
_order.bd_id = this.trim(params.bd_id);
_order.status = this.trim(params.status);
_order.bd_path = this.trim(params.bd_path);
let res = await _order.save();
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 验证订单状态
* @param params
* @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}>}
*/
async statusAction(params) {
let _order = await this.findById(params.id);
if (!_order) {
return system.getResult(null, `订单不存在`);
}
//todo ... 验证状态
let _orderStatus = await this.getOrderProcessStatus(_order.id, _order.status);
let nextStatus = JSON.parse(_orderStatus.next_status);
if (params.status != nextStatus.next_status) {
return system.getResult(null, `订单状态错误,下一订单状态应该是${nextStatus.next_name}`);
}
params._order = _order;
return await this['assignDeliver'](params);
}
/**
* 分配交付商
* @param {*} params
* @id String 订单ID
* @deliver_id String 交付商ID
* @deliver_name String 交付商名称
* @deliver_deliver String 交付商分成
* @status String 下一个状态码
*/
async assignDeliver(params) {
//参数验证
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.deliver_id) {
return system.getResult(null, `参数错误 交付商ID不能为空`);
}
if (!params.hasOwnProperty(`deliver_divide`)) {
return system.getResult(null, `参数错误 交付商分成不能为空`);
}
try {
let self = this;
let res = await this.db.transaction(async t => {
//创建orderdeliver记录
await self.oorderdeliverDao.create({
order_id: self.trim(params.id),
deliver_id: self.trim(params.deliver_id),
deliver_name: self.trim(params.deliver_name),
deliver_divide: self.trim(params.deliver_divide),
}, t);
//更新oorder订单记录
await self.dao.update({
deliver_id: self.trim(params.deliver_id),
id: self.trim(params.id),
status: self.trim(params.status)
}, t);
});
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 平台数据统计 (订单数量和交易额度)
* @param {*} params
*/
async statTransData(params) {
if (!params.current_date) {
return system.getResult(null, `参数错误 当前时间不能为空`);
}
try {
var result = {
orderCount: 0,
orderPrice: 0,
};
var begin, end;
// 取开始时间和结束时间
begin = moment(params.current_date).format("YYYY-MM") + "-01 00:00:00";
end = moment(begin).add(1, "months").subtract(1, 'days').format("YYYY-MM-DD") + " 23:59:59";
// echart数据 开始
var days = [];
var dayCounts = [];
var priceCounts = [];
// 处理查询业务
days = this.getDays(end);
// 按天统计
var dayMap = await this.dao.statDayByTime(begin, end);
for (var day of days) {
var ditem = dayMap[day] || {};
dayCounts.push(ditem.orderCount || 0);
priceCounts.push(system.f2y(ditem.orderPrice || 0));
}
//echart数据 结束
//当月订单的数量统计和订单总金额
var orderData = await this.dao.statOrderByTime(begin, end) || {};
result.orderCount = orderData[orderData.begin].orderCount;
result.orderPrice = system.f2y(orderData[orderData.begin].orderPrice);
result.days = days;
result.dayCounts = dayCounts;
result.priceCounts = priceCounts;
return system.getResult(result);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
getDays(end) {
var days = [];
var month = moment(end).format("YYYY-MM");
var endDay = Number(moment(end).format("DD"));
for (var i = 1; i <= endDay; i++) {
if (i < 10) {
days.push(month + "-0" + i);
} else {
days.push(month + "-" + i);
}
}
return days;
}
/**
* 待办事项
* @param {*} params
*/
async needToBeDealtWith(params) {
if (!params.current_date) {
return system.getResult(null, `参数错误 当前时间不能为空`);
}
try {
let begin, end;
begin = moment(params.current_date).format("YYYY-MM") + "-01 00:00:00";
end = moment(begin).add(1, "months").subtract(1, 'days').format("YYYY-MM-DD") + " 23:59:59";
//已经完成
let orderComplete = await this.dao.model.count({
where: {
created_at : {
[this.db.Op.between]: [begin, end]
},
status:"1200"
}
});
//待分配
let orderUnassignment = await this.dao.model.count({
where: {
created_at : {
[this.db.Op.between]: [begin, end]
},
status:"1000"
}
});
//待审核
let orderUnexamine = await this.dao.model.count({
where: {
created_at : {
[this.db.Op.between]: [begin, end]
},
status:"1140"
}
});
//办理中
let orderHandling = await this.dao.model.count({
where: {
created_at : {
[this.db.Op.between]: [begin, end]
},
status:{
[this.db.Op.between]: ["1030", '1130']
}
}
});
return system.getResult({
orderComplete,orderUnassignment,orderUnexamine,orderHandling
});
} catch (error) {
console.log(error);
return system.getResult(null, error);
}
}
/**
* 交付商业务概览
* @param {*} params
*/
async deliverData(params){
if(!params.current_date){
return system.getResult(null,`参数错误 当前时间不能为空`);
}
try {
let begin, end;
begin = moment(params.current_date).format("YYYY-MM") + "-01 00:00:00";
end = moment(begin).add(1, "months").subtract(1, 'days').format("YYYY-MM-DD") + " 23:59:59";
let deliverDataList = await this.dao.deliverData(begin,end);
return system.getResult(deliverDataList);
} catch (error) {
console.log(error);
return system.getResult(error);
}
}
}
module.exports = OorderService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const moment = require("moment");
/**
* 订单交付
*/
class OorderdeliverService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(OorderdeliverService));
this.oorderinforegDao = system.getObject("db.order.oorderinforegDao");
this.oorderDao = system.getObject("db.order.oorderDao");
this.oorderprocessDao = system.getObject("db.order.oorderprocessDao");
this.osourceDao = system.getObject("db.common.osourceDao");
this.oproductDao = system.getObject("db.product.oproductDao");
this.oprocessDao = system.getObject("db.product.oprocessDao");
this.oproductprocessDao = system.getObject("db.product.oproductprocessDao");
}
/**
* 交付商订单管理列表
* @param {*} params
* @operator_id 业务员ID
* @id String 订单号
* @status String 订单状态
* @operator_id String 交付商业务员
*/
async orderDelivers(params) {
let where = {};
if (params.deliver_id) {
where.deliver_id = this.trim(params.deliver_id);
} else {
return system.getResult(null, `参数错误 交付商ID不能为空`);
}
//交付商订单表条件
if (params.createdBegin && params.createdEnd) {
where.createdBegin = this.trim(params.createdBegin);
where.createdEnd = this.trim(params.createdEnd);
}
if (params.operator_id) {
where.operator_id = this.trim(params.operator_id);
}
//下面是订单条件
if (params.id) {
where.id = this.trim(params.id);
}
if (params.status) {
where.status = this.trim(params.status);
}
if (params.order_id) {
where.order_id = this.trim(params.order_id);
}
where.currentPage = Number(params.currentPage || 1);
where.pageSize = Number(params.pageSize || 10);
where.startRow = (where.currentPage - 1) * where.pageSize;
try {
let ordersCountRes = await this.dao.ordersdeliverCount(where);
let count = ordersCountRes[0]['orderCount'];
if (count == 0) {
return system.getResult({ count: 0, rows: [] });
}
let rows = await this.dao.findOrders(where);
//格式化订单状态
await this.formateStatus(rows);
await this.formateServiceItems(rows);
for (var row of rows) {
this.handleDate(row, ["created_at", "completed_at"], "YYYY-MM-DD HH:mm:ss", -8);
}
let res = {
count, rows
};
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 格式化订单交付商
* @param {*} orderList
*/
async formateDeliver(orderList) {
let deliverIdList = [];
for (let item of orderList) {
if (item.deliver_id) {
deliverIdList.push(item.deliver_id);
}
}
let deliverMap = await this.dao.mapByIds(deliverIdList);
for (let item of orderList) {
item.odeliver = deliverMap[item.deliver_id] || {}
}
}
/**
* 格式化订单状态数据
* @param orderList
* @returns {Promise<void>}
*/
async formateStatus(orderList) {
let ids = [];
let statuses = [];
for (let item of orderList) {
ids.push(item.id);
statuses.push(item.status);
}
let map = await this.oorderprocessDao.mapByOrderIdsAndStatus(ids, statuses);
for (let item of orderList) {
let key = item.id + "_" + item.status;
let v = map[key] || {};
item.statusName = v.name;
item.next_status = JSON.parse(v.next_status || "[]");
}
console.log(orderList);
}
async formateServiceItems(orderList) {
let ids = [];
let statuses = [];
for (let item of orderList) {
let productIds = this.trim(item.service_items).split(",");
ids = ids.concat(productIds);
}
let productMap = await this.oproductDao.mapByIds(ids);
for (let item of orderList) {
let productIds = this.trim(item.service_items).split(",");
let names = [];
for (var productId of productIds) {
let product = productMap[productId];
if (product) {
names.push(product.name);
}
}
item.service_items_name = names.join(",");
}
}
/**
* 平台数据概览(交付商数据)
* @param {*} params
*/
async statDeliverData(params) {
if (!params.current_date) {
return system.getResult(null, `参数错误 当前时间不能为空`);
}
try {
let begin, end;
begin = moment(params.current_date).format("YYYY-MM") + "-01 00:00:00";
end = moment(begin).add(1, "months").subtract(1, 'days').format("YYYY-MM-DD") + " 23:59:59";
let deliverList = await this.dao.deliverList(begin, end);
let deliverSet = new Set();
for (let item of deliverList) {
deliverSet.add(item.deliver_id);
}
let _deliverArr = Array.from(deliverSet);
let orderCompletes = await this.dao.orderCompletesCount(_deliverArr, begin, end) ;
let orderHanding = await this.dao.orderHandingCount(_deliverArr, begin, end) ;
for (let item of deliverList) {
item.order_complete_count = orderCompletes[item.deliver_id] || 0;
item.order_handing_count = orderHanding[item.deliver_id] || 0;
}
return system.getResult(deliverList);
} catch (error) {
console.log(error);
return system.getResult(error);
}
}
/**
* 交付商订单统计
* @param {*} params
*/
async deliverStatTransData(params) {
if (!params.current_date) {
return system.getResult(null, `参数错误 当前时间不能为空`);
}
if (!params.deliver_id) {
return system.getResult(null, `参数错误 交付商不能为空`);
}
try {
var result = {
orderCount: 0,
orderPrice: 0,
};
var begin, end;
// 取开始时间和结束时间
begin = moment(params.current_date).format("YYYY-MM") + "-01 00:00:00";
end = moment(begin).add(1, "months").subtract(1, 'days').format("YYYY-MM-DD") + " 23:59:59";
// echart数据 开始
var days = [];
var dayCounts = [];
var priceCounts = [];
// 处理查询业务
days = this.getDays(end);
// 按天统计
var dayMap = await this.dao.statDayByTime(begin, end, this.trim(params.deliver_id));
for (var day of days) {
var ditem = dayMap[day] || {};
dayCounts.push(ditem.orderCount || 0);
priceCounts.push(system.f2y(ditem.orderPrice || 0));
}
//echart数据 结束
//当月订单的数量统计和订单总金额
var orderData = await this.dao.statOrderByTime(begin, end, this.trim(params.deliver_id)) || {};
if(!orderData){
result.orderCount = 0;
result.orderPrice = 0;
}else{
result.orderCount = orderData[orderData.begin]?orderData[orderData.begin]["orderCount"] : 0;
result.orderPrice = orderData[orderData.begin]?system.f2y(orderData[orderData.begin]["orderPrice"]): 0;
}
result.days = days;
result.dayCounts = dayCounts;
result.priceCounts = priceCounts;
return system.getResult(result);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
getDays(end) {
var days = [];
var month = moment(end).format("YYYY-MM");
var endDay = Number(moment(end).format("DD"));
for (var i = 1; i <= endDay; i++) {
if (i < 10) {
days.push(month + "-0" + i);
} else {
days.push(month + "-" + i);
}
}
return days;
}
/**
* 业务办理
* @param {*} params
*/
async businessManagement(params) {
if (!params.current_date) {
return system.getResult(null, `参数错误 当前时间不能为空`);
}
if (!params.deliver_id) {
return system.getResult(null, `参数错误 交付商不能为空`);
}
try {
var begin, end;
// 取开始时间和结束时间
begin = moment(params.current_date).format("YYYY-MM") + "-01 00:00:00";
end = moment(begin).add(1, "months").subtract(1, 'days').format("YYYY-MM-DD") + " 23:59:59";
//已经完成
let orderCompleteRes = await this.dao.orderComplete(begin, end,this.trim(params.deliver_id));
//办理中
let orderHandlingRes = await this.dao.orderHanding(begin, end,this.trim(params.deliver_id));
return system.getResult({
orderCompleteCount:orderCompleteRes[0]['count'],
orderHandlingCount:orderHandlingRes[0]["count"]
});
} catch (error) {
console.log(error);
return system.getResult(error);
}
}
}
module.exports = OorderdeliverService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
/**
* 订单产品表
*/
class OorderinforegService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(OorderinforegService));
}
}
module.exports = OorderinforegService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
/**
* 订单产品表
*/
class OorderprocessService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(OorderprocessService));
}
}
module.exports = OorderprocessService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
/**
* 订单产品表
*/
class OorderstatusService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(OorderstatusService));
this.oorderSve = system.getObject("service.order.oorderSve");
this.oorderinforegDao = system.getObject("db.order.oorderinforegDao");
this.oorderdeliverDao = system.getObject("db.order.oorderdeliverDao");
this.oorderprocessDao = system.getObject("db.order.oorderprocessDao");
this.obusinessmenDao = system.getObject("db.order.obusinessmenDao");
this.osourceDao = system.getObject("db.common.osourceDao");
this.oproductDao = system.getObject("db.product.oproductDao");
this.oprocessDao = system.getObject("db.product.oprocessDao");
this.oproductprocessDao = system.getObject("db.product.oproductprocessDao");
this.BUSI_TYPE = 1; //个体公商户类型
this.ISBANK = true; //银行开户
this.TAXTYPE = [1, 2]; //个税和增值税类别集合
this.PALTFORM_DELIVER_AUDIT_SUCCESS_CODE = "1160"; //平台交付审核成功状态码
this.PALTFORM_DELIVER_AUDIT_FILE_CODE = "1150"; //平台交付审核失败状态码
}
/***************************************以下是订单处理的分发器***************************************************************** */
/**
* 验证订单状态
* @param params
* @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}>}
* @id 订单ID
* @status 订单下一个状态
* @other 其他参数
*/
async handleStatus(params) {
try {
let _order = await this.dao.findById(params.id);
if (!_order) {
return system.getResult(null, `订单不存在`);
}
// 完善订单特殊处理
if (_order.status == 1010) {
let chooseItems = [];
for (let citem of this.trim(params.service_items).split(",")) {
let productId = Number(this.trim(citem) || 0);
if (productId) {
chooseItems.push(productId);
}
}
let orderProcessList = await this.oorderSve.buildOrderProcess(_order.product_id, chooseItems);
if (!orderProcessList || orderProcessList.length == 0) {
return system.getResult(null, "产品流程未配置");
}
for (let process of orderProcessList) {
process.order_id = _order.id;
}
await this.oorderprocessDao.delByOrderId(_order.id);
await this.oorderprocessDao.bulkCreate(orderProcessList);
}
let _orderStatus = await this.getOrderProcessStatus(_order.id, _order.status);
let nextList = JSON.parse(_orderStatus.next_status);
_orderStatus.next_status = nextList;
let flag = false;
let nextNames = [];
let nextName = "";
for (var nextItem of nextList) {
nextNames.push(nextItem.next_name);
if (nextItem.next_status == params.status) {
flag = true;
nextName = nextItem.next_name;
break;
}
}
if (!flag) {
nextNames = nextNames.join("或");
return system.getResult(null, `订单状态错误,下一订单状态应该是${nextNames}`);
}
params._order = _order;
params._orderStatus = _orderStatus;
params.nextName = nextName;
//调用对应的方法 TODO SOMETHING .....
// 调用func
return await this[_orderStatus.func](params);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 获取订单状态对象
* @param order_id
* @param status
* @returns {Promise<*|{}>}
*/
async getOrderProcessStatus(order_id, status) {
let map = await this.oorderprocessDao.mapByOrderIdsAndStatus([order_id], [status]);
return map[order_id + "_" + status] || {};
}
/*******************************以下是订单处理进度(平台)**************************************************** */
/**
* 分配业务员(平台)
* @param {*} params
* @id String 订单ID
* @bd_id String 业务员ID
* @status String 下一个状态码
* @bd_path String 业务员权限
* @assign_user_id String 分配人ID
*/
async platformAassignSalesman(params) {
if (!params.bd_id) {
return system.getResult(null, `参数错误 业务员ID不能为空`);
}
try {
//更新订单业务员
let _order = params._order;
_order.bd_id = this.trim(params.bd_id);
_order.status = this.trim(params.status);
_order.bd_path = this.trim(params.bd_path);
_order.assign_time = new Date();
_order.assign_user_id = this.trim(params.assign_user_id);
let res = await _order.save();
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 业务员完善订单信息
* @param {*} params
* @id String 订单ID
* @status String 下一个状态
* @other Object 其他参数
*/
async perfectInformation(params) {
//验证参数
this.verificationPerfectInformation(params);
let _oorderinforeg = await this.oorderinforegDao.findById(params._order.id);
if (!_oorderinforeg) {
return system.getResult(null, `订单异常 订单明细不存在,请联系管理员`);
}
//更新订单子表
_oorderinforeg.legal_name = this.trim(params.legal_name);
_oorderinforeg.id_card = this.trim(params.id_card);
_oorderinforeg.legal_mobile = this.trim(params.legal_mobile);
_oorderinforeg.names = this.trim(params.names);
_oorderinforeg.capital = this.trim(params.capital);
_oorderinforeg.domicile_id = this.trim(params.domicile_id);
_oorderinforeg.domicile_name = this.trim(params.domicile_name);
_oorderinforeg.business_scope_id = this.trim(params.business_scope_id);
_oorderinforeg.business_type = this.trim(params.business_type);
_oorderinforeg.business_scope = this.trim(params.business_scope);
_oorderinforeg.idcard_front = this.trim(params.idcard_front);
_oorderinforeg.idcard_back = this.trim(params.idcard_back);
_oorderinforeg.other_file = this.trim(params.other_file);
_oorderinforeg.guest_mail_addr = this.trim(params.guest_mail_addr);
_oorderinforeg.guest_mail_to = this.trim(params.guest_mail_to);
_oorderinforeg.guest_mail_mobile = this.trim(params.guest_mail_mobile);
//更新主表
params._order.service_items = this.trim(params.service_items);
params._order.service_remark = this.trim(params.service_remark);
params._order.status = this.trim(params.status);
try {
//开启事务
await this.db.transaction(async t => {
await _oorderinforeg.save();
await params._order.save();
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
verificationPerfectInformation(params) {
if (!params.legal_name) {
return system.getResult(null, `参数错误 法人姓名不能为空`);
}
if (!params.id_card) {
return system.getResult(null, `参数错误 法人身份证不能为空`);
}
if (!params.legal_mobile) {
return system.getResult(null, `参数错误 法人电话不能为空`);
}
if (!params.names) {
return system.getResult(null, `参数错误 个体户名称不能为空`);
}
if (!params.capital) {
return system.getResult(null, `参数错误 注册资本不能为空`);
}
if (!params.domicile_id) {
return system.getResult(null, `参数错误 注册地id不能为空`);
}
if (!params.domicile_name) {
return system.getResult(null, `参数错误 注册地名称不能为空`);
}
if (!params.business_scope_id) {
return system.getResult(null, `参数错误 经营范围id不能为空`);
}
if (!params.business_type) {
return system.getResult(null, `参数错误 经营范围不能为空`);
}
if (!params.business_scope) {
return system.getResult(null, `参数错误 经营范围详情不能为空`);
}
if (!params.idcard_front) {
return system.getResult(null, `参数错误 身份证正面照片不能为空`);
}
if (!params.idcard_back) {
return system.getResult(null, `参数错误 身份证反面照片不能为空`);
}
if (!params.other_file) {
return system.getResult(null, `参数错误 其他文件不能为空`);
}
if (!params.guest_mail_addr) {
return system.getResult(null, `参数错误 邮寄客户地址不能为空`);
}
if (!params.guest_mail_to) {
return system.getResult(null, `参数错误 客户收件人不能为空`);
}
if (!params.guest_mail_mobile) {
return system.getResult(null, `参数错误 客户收件人电话不能为空`);
}
// if(!params.guest_mail_no){
// return system.getResult(null,`参数错误 客户快递单号不能为空`);
// }
// if(!params.guest_mail_img){
// return system.getResult(null,`参数错误 交付商交付快递单号图片不能为空`);
// }
// if(!params.guest_accpet_file){
// return system.getResult(null,`参数错误 客户验收文件不能为空`);
// }
if (!params.service_items) {
return system.getResult(null, `参数错误 服务项不能为空`);
}
}
/**
* 分配交付商
* @param {*} params
* @id String 订单ID
* @deliver_id String 交付商ID
* @deliver_name String 交付商名称
* @deliver_deliver String 交付商分成
* @status String 下一个状态码
*/
async assignDeliver(params) {
//参数验证
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.deliver_id) {
return system.getResult(null, `参数错误 交付商ID不能为空`);
}
if (!params.hasOwnProperty(`deliver_divide`)) {
return system.getResult(null, `参数错误 交付商分成不能为空`);
}
try {
let self = this;
await this.db.transaction(async t => {
//创建orderdeliver记录
let _oorderdeliver = await self.oorderdeliverDao.create({
order_id: self.trim(params.id),
deliver_id: self.trim(params.deliver_id),
deliver_name: self.trim(params.deliver_name),
deliver_divide: self.trim(params.deliver_divide),
}, t);
//更新oorder订单记录
await self.dao.update({
deliver_id: _oorderdeliver.id,
id: self.trim(params.id),
status: self.trim(params.status)
}, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 平台交付审核(审核成功OR失败)
* @param {*} params
* @id String 订单ID
*
*/
async platformDeliverAudit(params) {
//参数验证
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 订单状态不能为空`);
}
let oorderDeliverProperty = {};
if (this.trim(params.status) == this.PALTFORM_DELIVER_AUDIT_SUCCESS_CODE) { //成功
if (!params.audit_remark) {
return system.getResult(null, `参数错误 交付审核备注不能为空`);
}
if (!params.deliver_content) {
return system.getResult(null, `参数错误 交付内容注不能为空`);
}
if (!params.deliver_mail_addr) {
return system.getResult(null, `参数错误 交付地址不能为空`);
}
if (!params.deliver_mail_to) {
return system.getResult(null, `参数错误 收件人不能为空`);
}
if (!params.deliver_mail_mobile) {
return system.getResult(null, `参数错误 联系电话不能为空`);
}
oorderDeliverProperty.audit_remark = this.trim(params.audit_remark);
oorderDeliverProperty.deliver_content = this.trim(params.deliver_content);
oorderDeliverProperty.deliver_mail_addr = this.trim(params.deliver_mail_addr);
oorderDeliverProperty.deliver_mail_to = this.trim(params.deliver_mail_to);
oorderDeliverProperty.deliver_mail_mobile = this.trim(params.deliver_mail_mobile);
} else if (this.trim(params.status) == this.PALTFORM_DELIVER_AUDIT_FILE_CODE) {//失败
// todo somthing...
if (!this.trim(params.audit_remark)) {
return system.getResult(null, `参数错误 交付审核备注不能为空`);
}
oorderDeliverProperty.audit_remark = this.trim(params.audit_remark);
} else {
return system.getResult(null, `参数错误 非法的订单状态`);
}
oorderDeliverProperty.id = params._order.deliver_id;
oorderDeliverProperty.audit_result = params.nextName;
let orderProperty = {};
orderProperty.id = params.id;
orderProperty.status = this.trim(params.status);
try {
let self = this;
await this.db.transaction(async t => {
//更新交付orderdeliver记录
await self.oorderdeliverDao.update(oorderDeliverProperty, t);
//更新oorder订单记录
await self.dao.update(orderProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 平台验收
* @param {*} params
*/
async platformAuditDetermine(params) {
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 订单状态不能为空`);
}
let orderDeliverProperty={};
orderDeliverProperty.completed_at=new Date();
orderDeliverProperty.id=params._order.deliver_id;
let orderProperty = {};
orderProperty.status = this.trim(params.status);
orderProperty.id = this.trim(params._order.id);
try {
await this.db.transaction(async t=>{
await this.dao.update(orderProperty,t);
await this.oorderdeliverDao.update(orderDeliverProperty,t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 客户交付
* @param {*} params
*/
async deliverCustomer(params) {
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 订单状态不能为空`);
}
if (!params.guest_mail_no) {
return system.getResult(null, `参数错误 客户快递单号不能为空`);
}
if (!params.guest_mail_img) {
return system.getResult(null, `参数错误 交付商交付快递单号图片不能为空`);
}
let oorderInforegProperty = {};
oorderInforegProperty.id = this.trim(params._order.id);
oorderInforegProperty.guest_mail_no = this.trim(params.guest_mail_no);
oorderInforegProperty.guest_mail_img = this.trim(params.guest_mail_img);
let oorderProperty = {};
oorderProperty.status = this.trim(params.status);
oorderProperty.id = params._order.id;
try {
await this.db.transaction(async t => {
await this.oorderinforegDao.update(oorderInforegProperty, t);
await this.dao.update(oorderProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 订单完成
* @param {*} params
*/
async orderComplete(params) {
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 订单状态不能为空`);
}
if (!params.guest_accpet_file) {
return system.getResult(null, `参数错误 客户验收文件不能为空`);
}
let oorderInforegProperty = {};
oorderInforegProperty.id = this.trim(params._order.id);
oorderInforegProperty.guest_accpet_file = this.trim(params.guest_accpet_file);
let oorderProperty = {};
oorderProperty.status = this.trim(params.status);
oorderProperty.id = params._order.id;
try {
await this.db.transaction(async t => {
await this.oorderinforegDao.update(oorderInforegProperty, t);
await this.dao.update(oorderProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**********************************以下是交付商订单业务处理******************************************************** */
/**
* 分配业务员(交付商)
* @param {*} params
* @id String 订单ID
* @operator_id String 业务员ID
* @status String 下一个状态码
*/
async deliverAssignSalesman(params) {
if (!params.operator_id) {
return system.getResult(null, `参数错误 业务员ID不能为空`);
}
try {
let _oorderdeliver = await this.oorderdeliverDao.model.findOne({
where: {
order_id: this.trim(params._order.id)
}
});
if (!_oorderdeliver) {
return system.getResult(null, `参数错误 订单交付信息不存在`);
}
let orderdeliverProperty = {};
orderdeliverProperty.operator_id = this.trim(params.operator_id);
orderdeliverProperty.id = _oorderdeliver.id;
let orderProperty = {};
orderProperty.status = this.trim(params.status);
orderProperty.id = this.trim(params._order.id);
await this.db.transaction(async t => {
await this.oorderdeliverDao.update(orderdeliverProperty, t);
await this.dao.update(orderProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 工商注册中
* @param {*} params
* @id 订单ID
* @status String 下一个订单状态
*/
async businessRegister(params) {
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 状态码不能为空`);
}
let _order = params._order;
_order.status = this.trim(params.status);
try {
let res = await _order.save();
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 工商注册完成
* @param {*} params
* @id 订单ID
* @status String 下一个订单状态
*/
async businessRegisterComplete(params) {
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 状态码不能为空`);
}
if (!params.name) {
return system.getResult(null, `参数错误 个体工商户名称不能为空`);
}
if (!params.credit_code) {
return system.getResult(null, `参数错误 统一社会信用代码不能为空`);
}
if (!params.business_place) {
return system.getResult(null, `参数错误 经营场所不能为空`);
}
if (!params.business_scope) {
return system.getResult(null, `参数错误 经营范围不能为空`);
}
if (!params.reg_date) {
return system.getResult(null, `参数错误 注册日期不能为空`);
}
// if (!params.business_img) {
// return system.getResult(null, `参数错误 执照照片不能为空`);
// }
// if (!params.business_gov_file) {
// return system.getResult(null, `参数错误 工商官方文件不能为空`);
// }
let _order = params._order;
let _orderInfo = await this.oorderinforegDao.findById(_order.id);
let _obusinessmenProperty = {};
_obusinessmenProperty.name = this.trim(params.name);
_obusinessmenProperty.credit_code = this.trim(params.credit_code);
_obusinessmenProperty.business_place = this.trim(params.business_place);
_obusinessmenProperty.business_scope = this.trim(params.business_scope);
_obusinessmenProperty.reg_date = this.trim(params.reg_date);
_obusinessmenProperty.business_img = this.trim(params.business_img);
_obusinessmenProperty.business_gov_file = this.trim(params.business_gov_file);
_obusinessmenProperty.order_id = _order.id;
_obusinessmenProperty.legal_name = _orderInfo.legal_name;
_obusinessmenProperty.legal_mobile = _orderInfo.legal_mobile;
_obusinessmenProperty.legal_idcard = _orderInfo.id_card;
_obusinessmenProperty.bd_id = this.trim(params.bd_id);
_obusinessmenProperty.bd_path = this.trim(params.bd_path);
let orderProperty = {};
orderProperty.id = _order.id;
orderProperty.status = this.trim(params.status);
orderProperty.busi_type = this.BUSI_TYPE;
try {
await this.db.transaction(async t => {
let _obusinessmen = await this.obusinessmenDao.create(_obusinessmenProperty, t);
orderProperty.busi_id = _obusinessmen.id;
await this.dao.update(orderProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 刻章办理中
* @param {*} params
* @id 订单ID
* @status String 下一个订单状态
*/
async chapterEngraving(params) {
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 状态码不能为空`);
}
let _order = params._order;
_order.status = this.trim(params.status);
try {
let res = await _order.save();
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(error);
}
}
/**
* 刻章办理已完成
* @param {*} params
* @id String 订单Id
* @Statsu String 下一个订单
* @other Object 其他参数
* @gongzhang String 公章
* @fapiaozhang String 发票章
* @caiwuzhang String 财务章
* @hetongzhang String 合同章
* @farenzhang String 法人章
* @zhang_gov_file String 刻章官方文件
*/
async chapterEngravedComplete(params) {
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 状态码不能为空`);
}
// if (!params.gongzhang) {
// return system.getResult(null, `参数错误 公章不能为空`);
// }
// if (!params.fapiaozhang) {
// return system.getResult(null, `参数错误 发票章不能为空`);
// }
// if (!params.caiwuzhang) {
// return system.getResult(null, `参数错误 财务章不能为空`);
// }
// if (!params.hetongzhang) {
// return system.getResult(null, `参数错误 合同章不能为空`);
// }
// if (!params.farenzhang) {
// return system.getResult(null, `参数错误 法人章不能为空`);
// }
// if (!params.zhang_gov_file) {
// return system.getResult(null, `参数错误 刻章官方文件不能为空`);
// }
let _obusinessmenProperty = {};
_obusinessmenProperty.gongzhang = this.trim(params.gongzhang);
_obusinessmenProperty.fapiaozhang = this.trim(params.fapiaozhang);
_obusinessmenProperty.caiwuzhang = this.trim(params.caiwuzhang);
_obusinessmenProperty.hetongzhang = this.trim(params.hetongzhang);
_obusinessmenProperty.farenzhang = this.trim(params.farenzhang);
_obusinessmenProperty.zhang_gov_file = this.trim(params.zhang_gov_file);
let _order = params._order;
_obusinessmenProperty.id = _order.busi_id;
let orderProperty = {};
orderProperty.id = _order.id;
orderProperty.status = this.trim(params.status);
try {
await this.db.transaction(async t => {
await this.obusinessmenDao.update(_obusinessmenProperty, t);
await this.dao.update(orderProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 银行开户中
* @param {*} params
* @id 订单ID
* @status String 下一个订单状态
*/
async backAccountOpening(params) {
let _order = params._order;
_order.status = this.trim(params.status);
try {
let res = await _order.save();
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(error);
}
}
/**
* 银行已开户
* @param {*} params
* @id 订单ID
* @status String 下一个订单状态
*/
async backAccountOpenComplete(params) {
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 状态码不能为空`);
}
if (!params.bank_name) {
return system.getResult(null, `参数错误 账户名称不能为空`);
}
if (!params.bank_no) {
return system.getResult(null, `参数错误 账户号不能为空`);
}
if (!params.bank) {
return system.getResult(null, `参数错误 开户行不能为空`);
}
// if (!params.bank_img) {
// return system.getResult(null, `参数错误 账户信息不能为空`);
// }
// if (!params.bank_gov_file) {
// return system.getResult(null, `参数错误 银行开户官方文件不能为空`);
// }
let _obusinessmenProperty = {};
_obusinessmenProperty.bank_name = this.trim(params.bank_name);
_obusinessmenProperty.bank_no = this.trim(params.bank_no);
_obusinessmenProperty.bank = this.trim(params.bank);
_obusinessmenProperty.bank_img = this.trim(params.bank_img);
_obusinessmenProperty.bank_gov_file = this.trim(params.bank_gov_file);
let _order = params._order;
_obusinessmenProperty.id = _order.busi_id;
let orderProperty = {};
orderProperty.id = _order.id;
orderProperty.status = this.trim(params.status);
try {
await this.db.transaction(async t => {
await this.obusinessmenDao.update(_obusinessmenProperty, t);
await this.dao.update(orderProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 税务报道中
* @param {*} params
* @id 订单ID
* @status String 下一个订单状态
*/
async taxReporting(params) {
let _order = params._order;
_order.status = this.trim(params.status);
try {
let res = await _order.save();
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(error);
}
}
/**
* 税务报道完成
* @param {*} params
* @id 订单ID
* @status String 下一个订单状态
*/
async taxReportComplete(params) {
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 状态码不能为空`);
}
if (!params.tax_reg_day) {
return system.getResult(null, `参数错误 税务登记日不能为空`);
}
if (!params.tax_org) {
return system.getResult(null, `参数错误 税务机构名称不能为空`);
}
// if (!params.ca_img) {
// return system.getResult(null, `参数错误 CA照片不能为空`);
// }
// if (!params.tax_gov_file) {
// return system.getResult(null, `参数错误 税务报道官方文件不能为空`);
// }
let _obusinessmenProperty = {};
_obusinessmenProperty.tax_reg_day = this.trim(params.tax_reg_day);
_obusinessmenProperty.tax_org = this.trim(params.tax_org);
_obusinessmenProperty.ca_img = this.trim(params.ca_img);
_obusinessmenProperty.tax_gov_file = this.trim(params.tax_gov_file);
let _order = params._order;
_obusinessmenProperty.id = _order.busi_id;
let orderProperty = {};
orderProperty.id = _order.id;
orderProperty.status = this.trim(params.status);
try {
await this.db.transaction(async t => {
await this.obusinessmenDao.update(_obusinessmenProperty, t);
await this.dao.update(orderProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 核定税种
* @param {*} params
* @id 订单ID
* @status String 下一个订单状态
*/
async taxCategoryDetermine(params) {
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 状态码不能为空`);
}
if (!params.common_tax_ladder) {
return system.getResult(null, `参数错误 普票个税阶梯不能为空`);
}
if (!params.common_other_ladder) {
return system.getResult(null, `参数错误 普票增值税、附加税阶梯不能为空`);
}
if (!params.special_tax_ladder) {
return system.getResult(null, `参数错误 专票个税阶梯不能为空`);
}
if (!params.special_other_ladder) {
return system.getResult(null, `参数错误 专票增值税、附加税阶梯不能为空`);
}
if (!params.add_value_up_type && this.TAXTYPE.indexOf(Number(params.add_value_up_type)) == -1) {
return system.getResult(null, `参数错误 增值税累计类型不能为空`);
}
if (!params.tax_up_type && this.TAXTYPE.indexOf(Number(params.tax_up_type)) == -1) {
return system.getResult(null, `参数错误 个税累计类型不能为空`);
}
let _obusinessmenProperty = {};
_obusinessmenProperty.common_tax_ladder = JSON.stringify(params.common_tax_ladder);
_obusinessmenProperty.common_other_ladder = JSON.stringify(params.common_other_ladder);
_obusinessmenProperty.special_tax_ladder = JSON.stringify(params.special_tax_ladder);
_obusinessmenProperty.special_other_ladder = JSON.stringify(params.special_other_ladder);
_obusinessmenProperty.add_value_up_type = this.trim(params.add_value_up_type);
_obusinessmenProperty.tax_up_type = this.trim(params.tax_up_type);
let _order = params._order;
_obusinessmenProperty.id = _order.busi_id;
let orderProperty = {};
orderProperty.id = _order.id;
orderProperty.status = this.trim(params.status);
try {
await this.db.transaction(async t => {
await this.obusinessmenDao.update(_obusinessmenProperty, t);
await this.dao.update(orderProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 交付商提交审核
* @param {*} params
* @id 订单ID
* @status String 下一个订单状态
*/
async submitAudit(params) {
let _order = params._order;
_order.status = this.trim(params.status);
try {
let res = await _order.save();
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(error);
}
}
/**
* 交付商订单交付
* @param {*} params
* @id String 订单ID
* @status String 订单状态
*/
async mailed(params) {
if (!params.id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 状态码不能为空`);
}
if (!params.deliver_mail_no) {
return system.getResult(null, `参数错误 交付商交付快递单号不能为空`);
}
if (!params.deliver_mail_img) {
return system.getResult(null, `参数错误 交付商交付快递单号图片不能为空`);
}
let oorderDeliverProperty = {};
oorderDeliverProperty.deliver_mail_no = this.trim(params.deliver_mail_no);
oorderDeliverProperty.deliver_mail_img = this.trim(params.deliver_mail_img);
let _order = params._order;
oorderDeliverProperty.id = _order.deliver_id;
let orderProperty = {};
orderProperty.status = this.trim(params.status);
orderProperty.id = _order.id;
try {
await this.db.transaction(async t => {
await this.oorderdeliverDao.update(oorderDeliverProperty, t);
await this.dao.update(orderProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息${error}`);
}
}
}
module.exports = OorderstatusService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
const moment = require("moment");
class PaymentService extends ServiceBase {
constructor() {
super("order", ServiceBase.getDaoName(PaymentService));
}
}
module.exports = PaymentService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
/**
* 订单产品表
*/
class OprocessService extends ServiceBase {
constructor() {
super("product", ServiceBase.getDaoName(OprocessService));
}
async allNames() {
let all = await this.dao.getAll("status, name");
return system.getResultSuccess(all);
}
}
module.exports = OprocessService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
/**
* 订单产品表
*/
class OproductService extends ServiceBase {
constructor() {
super("product", ServiceBase.getDaoName(OproductService));
this.oproductprocessDao = system.getObject("db.product.oproductprocessDao");
}
async productDics(params) {
let list = await this.dao.dics(params);
return system.getResultSuccess(list);
}
/**
* 更新订单状态
* @param {*} order_id
* @param {*} updateStatus
* @param {*} params
*/
async updateStatus(orderId, updateStatus, params) {
try {
let _order = this.iborderbaseDao.findById(orderId);
if(!_order){
return system.getResult(null,`系统错误 错误信息 ${error}`);
}
var statusObj = findStatus(_order.productId, _order.status);
// statusObj.next_status 存在不存在 updateStatus
this[statusObj.func](order, statusObj, params);
} catch (error) {
return system.getResult(null,`系统错误 错误信息 ${error}`);
}
}
// async setOrderStatus(orderList) {
// var productIds = [];
// var statues = [];
// list = SELECT * FROM o_product_process WHERE product_id IN(: productIds) AND statues IN(: statues)
// var map = {};
// for (var item of list) {
// map[item.product_id + "_" + item.status] = item;
// }
// for (var order of orderList) {
// order.status = map[order.product_id + "_" + order.status] || {};
// }
// }
}
module.exports = OproductService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
/**
* 订单产品表
*/
class OproductprocessService extends ServiceBase {
constructor() {
super("product", ServiceBase.getDaoName(OproductprocessService));
}
}
module.exports = OproductprocessService;
\ No newline at end of file
......@@ -153,8 +153,8 @@ class ServiceBase {
async delete(qobj) {
return this.dao.delete(qobj);
}
async create(qobj) {
return this.dao.create(qobj);
async create(qobj, t) {
return this.dao.create(qobj, t);
}
async update(qobj, tm = null) {
return this.dao.update(qobj, tm);
......@@ -268,5 +268,17 @@ class ServiceBase {
}
return o.toString().trim();
}
trimObject(o) {
if(!o) {
return;
}
for(var k in o) {
var v = o[k];
if(typeof v === "string") {
o[k] = this.trim(v);
}
}
}
}
module.exports = ServiceBase;
......@@ -168,12 +168,13 @@ class System {
static microsetting() {
var path = "/api/op/action/springboard";
if (settings.env == "dev") {
var domain = "http://192.168.18.237";
// var domain = "http://192.168.18.237";
var domain = "http://192.168.18.105";
return {
common: domain + ":3102" + path,
merchant: domain + ":3101" + path,
order: domain + ":3103" + path,
invoice: "" + path,
invoice: domain + "3105" + path,
payment: "" + path,
}
} else {
......
/**
* 计算发票费率
*/
module.exports=async params=>{
//1 组装参数
//2 调用发票服务
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ var settings={
db:10,
},
database:{
dbname : "xgg-order",
dbname : "xgg-order2",
user: "write",
password: "write",
config: {
......
......@@ -24,12 +24,12 @@ module.exports = function (app) {
return next();
}
if (!jsonUser) {
res.end(JSON.stringify({ status: -99, msg: "no login" }));
return;
} else {
redisClient.setWithEx(xggadminsid, jsonUser, 60 * 60 * 12);
}
// if (!jsonUser) {
// res.end(JSON.stringify({ status: -99, msg: "no login" }));
// return;
// } else {
// redisClient.setWithEx(xggadminsid, jsonUser, 60 * 60 * 12);
// }
req.loginUser = JSON.parse(jsonUser);
next();
});
......
......@@ -5,8 +5,8 @@
1. [用户签约](#businessmenSign)
1. [签约管理列表](#signList)
1. [个体户信息列表](#infoList)
1. [个体户签约](#signing)
1. [是否建账](#createAccount)
## **<a name="nameList"> 个体户nameList </a>**
[返回到目录](#menu)
......@@ -336,3 +336,41 @@
```
## **<a name="signing"> 个体户签约 </a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "createAccount",
"action_body": {
"credit_code": "1", //同意社会信用代码
"cost_rate": "5", //核定成本费用率
"add_value_up_type": "", //增值税累计类型
"tax_up_type": "", //个税累计类型
"service_begin_time": "1", //服务开始时间
"service_end_time": "5", //服务结束时间
"service_rate": "", //服务费比例
"tax_rate": "", //含税价百分比、
"sign_notes":"" //签约备注
}
}
```
## **<a name="createAccount"> 是否建账 </a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "signing",
"action_body": {
"credit_code": "1", //同意社会信用代码
}
}
```
\ No newline at end of file
<a name="menu">目录</a>
1. [新增订单](#createOrder)
1. [完善信息接口](#completedOrder)
1. [订单办理接口](#handling)
1. [订单列表](#orders)
## **<a name="createOrder"> 新增订单</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "createOrder",
"action_body": {
productType: 1, // 产品类型 1000注册订单 1010代开订单 1030代账订单 1040增值服务
productItems: [1050,1070,1100,1110], // 注册订单时填写产品项 1050注册 1070刻章 1100银行开户 1110税务报道
channelNo: "qifutong", // 渠道名称
thirdNo: "xxxxxxx", // 订单号 varchar(32)
price: 50000, // 订单价格(分) bigint 20
payType: 1 // 支付方式 1按次支付 2按年支付
notes: "", // 订单备注 随便写,200个字以内
legalName: "", // 联系人
legalMobile: "", // 联系电话
legalEmail: "", // 联系邮箱
invoiceType: "", // 代开订单时指定发票类型 10 普通发票 20 增值税专用发票 30 电子发票
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": null,
"requestid": "c179a24ec402454aa0e74c4333cc6eab"
}
```
## **<a name="completedOrder"> 完善信息接口</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "completedOrder",
"action_body": {
"orderId": "13699868075000706", //订单ID
"legalName": "president_nan", //法人名称
"legalMobile": "18833836395", //法人电话
"creditCode":"XXEIGIGKTI8989", //社会统一信用代码
"names":"driver baby", //个体户名称
"businessScope":"crateTanke", //经营范围
"productType":"1010" //商品类型 "1000" 注册订单 "1010" 代开订单 "1030" 代账订单 "1040" 增值服务
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": null,
"requestid": "9e1980f84d7d451797d682821e4b438e"
}
```
## **<a name="orders"> 订单列表</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "completedOrder",
"action_body": {
"currentPage": "1", //页码 非必填
"pageSize": "10", //记录条数 非必填
"id": "1", //发票ID 非必填
"productType":"1010" //商品类型 必填 "1000" 注册订单 "1010" 代开订单 "1030" 代账订单 "1040" 增值服务
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 1,
"rows": [
{
"id": "13699868075000706",
"merchant_id": null,
"businessmen_id": null,
"orderpay_id": null,
"price": 50000,
"status": "1000",
"notes": "by myself",
"orderDeliverId": "",
"legalName": "president_nan",
"legalMobile": "18833836395",
"names": "driver baby",
"creditCode": "XXEIGIGKTI8989",
"isBank": 0,
"businessScope": "crateTanke",
"isInfoComplete": 1,
"created_at": "2019-12-09 02:03:49",
"updated_at": "2019-12-09T03:42:40.000Z",
"deleted_at": null,
"version": 0,
"statusName": ""
}
]
},
"requestid": "e940f89920b4427f93ddbe9c2ff06856"
}
```
## **<a name="allList"> 全部订单</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "allOrderList",
"action_body": {
"currentPage": "1",
"pageSize": "5",
"merchantId": "", // 商户id
"orderId": "", // 订单id
"status": "", // 订单状态 1000未付款, 1010待处理, 1020执照办理中, 1030已出执照, 1040刻章办理中, 1050已刻章,
// 1060银行开户中, 1070银行已开户, 1080税务报道中, 1090已税务报道, 1100已完成
"createdBegin": "", // 创建时间开始
"createdEnd": "", // 创建时间结束
"assignBegin": "", // 分配时间开始
"assignEnd": "", // 分配时间结束
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 12,
"rows": [
{
"id": "13180527789003380", // 订单号\订单号
"merchant_id": "11064622752480048", // 商户id
"channelOrderNo": "xxxxxxxxx111", // 渠道订单号
"price": 300000, // 订单价格(分)
"legalName": "杨庆菊", // 法人姓名
"legalMobile": "杨庆菊手机号", // 法人手机号
"legalImg": "法人照片", // 法人照片
"idcard": "123身份证", // 身份证号码
"idcardFront": "在正面", // 身份证正面图
"idcardBack": "反面", // 身份证反面图
"bankNo": "2222", // 银行卡号
"bank": "开户行", // 开户行
"bankImg": "这是银行卡照片", // 银行卡照片
"names": "名称1,名称2,名称3", // 2~3个注册名称,逗号分割
"domicile_id":"" // 注册地id
"domicileName":"" // 注册地名称
"businessScope_id": "12218127596000645", // 经营范围id
"businessType": "物流信息类", // 经营范围
"businessScope": "国内物流信息服务;装", // 经营范围详情
"capital": "到底是多少", // 注册资本
"statusName": "未付款", // 订单状态名称
"status": "1000", // 订单状态
"ostatusName": "待处理", // 业务进度状态名称
"ostatus": "1030", // 业务进度状态
"assignTime": null, // 分配时间
"assignUcname": "吴经理", // 分配人
"created_at": "2019-10-05 06:57:28", // 创建时间
"deliverType": "", // 交付类型
"deliverNo": "", //
"deliverImg": "", //
"deliver": { // 交付商
"statusName": "待处理" // 办理状态名称
"status": "1020", // 办理状态
"deliverName": "开封交付商", // 交付商名称
"deliverDivide": 3311, // 交付商分成比例
}
},
...
]
},
"requestid": "ae2a9c2e2ff6497e8cc9fd2c7fac9fe8"
}
```
## **<a name="info"> 订单信息</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "orderInfo",
"action_body": {
"id": "13180527789003380"
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"id": "13180527789003380", // 订单号\订单号
"merchant_id": "11064622752480048", // 商户id
"channelOrderNo": "xxxxxxxxx111", // 渠道订单号
"price": 300000, // 订单价格(分)
"price_y": "3000", // 订单价格(元)
"legalName": "杨庆菊", // 法人姓名
"legalMobile": "杨庆菊手机号", // 法人手机号
"legalImg": "法人照片", // 法人照片
"idcard": "123身份证", // 身份证号码
"idcardFront": "在正面", // 身份证正面图
"idcardBack": "反面", // 身份证反面图
"bankNo": "2222", // 银行卡号
"bank": "开户行", // 开户行
"bankImg": "这是银行卡照片", // 银行卡照片
"names": "山驴比1,山驴比2,山驴比3", // 2~3个注册名称,逗号分割
"domicile_id":"" // 注册地id
"domicileName":"" // 注册地名称
"businessScope_id": "12218127596000645", // 经营范围id
"businessType": "太难了", // 经营范围
"businessScope": "太狠了", // 经营范围详情
"capital": "到底是多少", // 注册资本
"statusName": "未付款", // 订单状态名称
"status": "1000", // 订单状态
"assignTime": null, // 分配时间
"created_at": "2019-10-05 06:57:28", // 创建时间
},
"requestid": "721e93dbdfb54115a76bf32a4900cd6e"
}
```
## **<a name="edit"> 订单编辑</a>**
[返回到目录](#menu)
#### 接口说明 该接口只编辑商户id和订单价格,(商户id随时可编辑),(订单价格只有在 1000未付款状态时可编辑)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "orderAssign",
"action_body": {
"id": "13180532689003786",
"deliverId": "13120681466000118",
"deliverName": "杨庆菊交付商222",
"deliverDivide": 3311
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"id": "13180527789003380", // 订单号\订单号
"merchant_id": "11064622752480048", // 商户id
"channelOrderNo": "xxxxxxxxx111", // 渠道订单号
"price": 300000, // 订单价格(分)
"price_y": "3000", // 订单价格(元)
"legalName": "杨庆菊", // 法人姓名
"legalMobile": "杨庆菊手机号", // 法人手机号
"legalImg": "法人照片", // 法人照片
"idcard": "123身份证", // 身份证号码
"idcardFront": "在正面", // 身份证正面图
"idcardBack": "反面", // 身份证反面图
"bankNo": "2222", // 银行卡号
"bank": "开户行", // 开户行
"bankImg": "这是银行卡照片", // 银行卡照片
"names": "山驴比1,山驴比2,山驴比3", // 2~3个注册名称,逗号分割
"domicile_id":"" // 注册地id
"domicileName":"" // 注册地名称
"businessScope_id": "12218127596000645", // 经营范围id
"businessType": "太难了", // 经营范围
"businessScope": "太狠了", // 经营范围详情
"capital": "到底是多少", // 注册资本
"statusName": "未付款", // 订单状态名称
"status": "1000", // 订单状态
"assignTime": null, // 分配时间
"created_at": "2019-10-05 06:57:28", // 创建时间
},
"requestid": "721e93dbdfb54115a76bf32a4900cd6e"
}
```
## **<a name="pc-myorders"> 我的订单-pc</a>**
[返回到目录](#menu)
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"action_process": "test",
"action_type": "myOrderPage",
"action_body": {
"currentPage": "1",
"pageSize": "5",
"userId": "", // 用户id
"createdBegin": "", // 创建时间开始
"createdEnd": "", // 创建时间结束
}
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"data": {
"count": 12,
"rows": [
{
"id": "13180527789003380", // 订单号\订单号
"merchant_id": "11064622752480048", // 商户id
"channelOrderNo": "xxxxxxxxx111", // 渠道订单号
"price": 300000, // 订单价格(分)
"legalName": "杨庆菊", // 法人姓名
"legalMobile": "杨庆菊手机号", // 法人手机号
"legalImg": "法人照片", // 法人照片
"idcard": "123身份证", // 身份证号码
"idcardFront": "在正面", // 身份证正面图
"idcardBack": "反面", // 身份证反面图
"bankNo": "2222", // 银行卡号
"bank": "开户行", // 开户行
"bankImg": "这是银行卡照片", // 银行卡照片
"names": "山驴比1,山驴比2,山驴比3", // 2~3个注册名称,逗号分割
"domicile_id":"" // 注册地id
"domicileName":"" // 注册地名称
"domicile_id":"" // 注册地id
"domicileName":"" // 注册地名称
"businessScope_id": "12218127596000645", // 经营范围id
"businessType": "太难了", // 经营范围
"businessScope": "太狠了", // 经营范围详情
"capital": "到底是多少", // 注册资本
"statusName": "未付款", // 订单状态名称
"status": "1000", // 订单状态
"assignTime": null, // 分配时间
"created_at": "2019-10-05 06:57:28", // 创建时间
},
...domicile_id
]
},
"requestid": "ae2a9c2e2ff6497e8cc9fd2c7fac9fe8"
}
```
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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