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({
......
......@@ -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");
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 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")
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
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