Commit e84000ba by 王昆

dd

parent b5552d47
......@@ -55,7 +55,7 @@ class ActionAPI extends APIBase {
case "orderInfo": // 查订单信息
opResult = await this.oorderSve.info(action_body);
break;
case "orderInfoAll": // 查订单信息
case "orderInfoAll": // 查订单信息
opResult = await this.oorderSve.infoAll(action_body);
break;
......@@ -141,8 +141,8 @@ class ActionAPI extends APIBase {
case "saasOrderSveDeliver": // 订单信息
opResult = await this.saasorderSve.sveDeliver(action_body);
break;
case "saasOrderBusinessmen": // 订单信息
opResult = await this.saasorderSve.sveBusinessmen(action_body);
case "saasOrderBusinessmen": // 提送交付信息(建账和个体户完成后推送接口)
opResult = await this.saasorderSve.saveSaasOrderBusinessmen(action_body);
break;
case "saasOrderInfo": // 订单信息
opResult = await this.saasorderSve.info(action_body);
......@@ -174,6 +174,7 @@ class ActionAPI extends APIBase {
case "saasOrderDeliverBusinessmenPage": // 订单交付的个体户信息
opResult = await this.saasorderSve.businessmenPage(action_body);
break;
//******************************************************************** */
// // 订单
......
......@@ -119,7 +119,7 @@ class ObusinessmenDao extends Dao {
* @param {*} id
*/
async queryObusinessmenInfo(id){
let sql = `SELECT t1.source_no,t1.saas_deliver_api ,t2.* FROM o_order t1 INNER JOIN o_businessmen t2 ON t1.id = t2.order_id WHERE t1.id = :id `;
let sql = `SELECT t1.source_no,t1.saas_deliver_api ,t1.product_id,t1.merchant_id,t2.* FROM o_order t1 INNER JOIN o_businessmen t2 ON t1.id = t2.order_id WHERE t1.id = :id `;
let list = await this.customQuery(sql, {id: id}) || [];
if (list.length == 0) {
return {};
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class SaasorderbusinessmenDao extends Dao {
constructor() {
super(Dao.getModelName(SaasorderbusinessmenDao));
}
}
module.exports = SaasorderbusinessmenDao;
\ No newline at end of file
'use strict'
/**
* 订单信息明细表
*/
module.exports = function (db, DataTypes) {
return db.define('saasorderbusinessmen', {
saas_id: {type: DataTypes.STRING, field: 'saas_id', allowNull: true, defaultValue:'',comment:'saas_id' },
merchant_id: {type: DataTypes.STRING, field: 'merchant_id', allowNull: true, defaultValue:'',comment:'商户id' },
product_id: {type: DataTypes.INTEGER, field: 'product_id', allowNull: true, defaultValue:'',comment:'产品id' },
saas_order_id: {type: DataTypes.STRING, field: 'saas_order_id', allowNull: true, defaultValue:'',comment:'saas_order id' },
company_id: {type: DataTypes.STRING, field: 'company_id', allowNull: true, defaultValue:'',comment:'服务个体户企业id' },
customer_id: {type: DataTypes.STRING, field: 'customer_id', allowNull: true, defaultValue:'',comment:'服务个体户建账id' },
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:'业务员权限路径' },
province: { type: DataTypes.STRING, field: 'province', allowNull: true },
customer_id: { type: DataTypes.STRING, field: 'customer_id', allowNull: true },
create_account_time: { type: DataTypes.DATE, field: 'create_account_time', allowNull: true },
invoice_content: { type: DataTypes.STRING, field: 'invoice_content', allowNull: true },
},
// {
// underscore: true,
// paranoid: true,
// version: true,
// tableName: 'saas_order_businessmen',
// comment: '个体户表',
// });
{
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'saas_order_businessmen',
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}]
// }
]
});
}
......@@ -37,7 +37,7 @@ class ObusinessmenService extends ServiceBase {
}
/**
* saas 推送接口
* 查询 saas推送 相关的信息
* @param {*} params
*/
async queryObusinessmenInfo(params){
......
......@@ -9,7 +9,7 @@ class SaasOrderService extends ServiceBase {
this.saasorderbminfoDao = system.getObject("db.saas.saasorderbminfoDao");
this.saasorderpayDao = system.getObject("db.saas.saasorderpayDao");
this.saasorderdeliverinfoDao = system.getObject("db.saas.saasorderdeliverinfoDao");
this.saasorderbusinessmenDao = system.getObject("db.saas.saasorderbusinessmenDao");
this.redisClient = system.getObject("util.redisClient");
}
......@@ -177,7 +177,9 @@ class SaasOrderService extends ServiceBase {
bminfo.id = order.id;
bminfo.merchant_id = merchant_id;
await self.saasorderbminfoDao.create(bminfo, t);
await self.saasorderdeliverinfoDao.create({id: order.id}, t);
await self.saasorderdeliverinfoDao.create({
id: order.id
}, t);
return order;
});
return system.getResultSuccess(order);
......@@ -198,7 +200,10 @@ class SaasOrderService extends ServiceBase {
let self = this;
await this.db.transaction(async t => {
//创建orderdeliver记录
await self.dao.update({id: params.id, handle_status: 20}, t);
await self.dao.update({
id: params.id,
handle_status: 20
}, t);
await self.saasorderdeliverinfoDao.update({
id: params.id,
sve_deliver_express_no: params.sve_deliver_express_no,
......@@ -209,23 +214,63 @@ class SaasOrderService extends ServiceBase {
return system.getResultSuccess();
}
async sveBusinessmen(params) {
if (!params.id) {
return system.getResult("订单id不存在");
/**
* fn: 建账、订单完成 推送信息保存
* @param {*} params
*/
async saveSaasOrderBusinessmen(params) {
// if (!params.credit_code) {
// return system.getResult(null, `参数错误 统一社会信用代码不能不能为空`);
// }
try {
let order = await this.dao.findById(params.source_no);
if(!order) {
console.log(`${params.source_no}订单不存在`);
return system.getResult(null, `订单不存在`);
}
let saasorderbusinessmen = await this.saasorderbusinessmenDao.findById(this.trim(order.id));
if(saasorderbusinessmen) {
saasorderbusinessmen.saas_id = order.saas_id;
this.setBusinessmenProperty(saasorderbusinessmen, params);
await saasorderbusinessmen.save();
} else {
saasorderbusinessmen = {id: order.id};
this.setBusinessmenProperty(saasorderbusinessmen, params);
await this.saasorderbusinessmenDao.create(saasorderbusinessmen);
}
// let saasorderbusinessmenProperty = null;
// saasorderbusinessmenProperty.id = order.id
// if(saasorderbusinessmen) {
// await this.saasorderbusinessmenDao.update(saasorderbusinessmenProperty);
// }
// if(saasorderbusinessmen){
// //如果存在记录那就是 建账推送 只更新company_id 和customer_id 两个字段
// saasorderbusinessmenProperty.company_id = params.company_id;
// saasorderbusinessmenProperty.customer_id = params.customer_id;
// saasorderbusinessmenProperty.id = saveSaasOrderBusinessmen.id;
// await this.saasorderbusinessmenDao.update(saasorderbusinessmenProperty);
// }else{
// //如果不存在那就是订单完成时推送个体户信息,需要创建记录
// saasorderbusinessmenProperty = params;
// saasorderbusinessmenProperty.id = params.source_id;
// saasorderbusinessmenProperty.saas_order_id = params.order_id;
// await this.saasorderbusinessmenDao.model.create(saasorderbusinessmenProperty);
// }
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误`);
}
let self = this;
}
let deliver = await this.saasorderdeliverinfoDao.findById(params.id);
if (!deliver) {
return system.getResult("订单不存在");
setBusinessmenProperty(saasorderbusinessmen, params) {
for(let key in params) {
if(key == "id" || key == "created_at" || key == "updated_at" || key == "deleted_at"|| key == "version") {
continue;
}
saasorderbusinessmen[key] = params[key];
}
deliver.sve_businessmen_company_id = params.sve_businessmen_company_id;
deliver.sve_businessmen_customer_id = params.sve_businessmen_customer_id;
deliver.sve_businessmen_name = params.sve_businessmen_name;
deliver.sve_businessmen_credit_code = params.sve_businessmen_credit_code;
await deliver.save();
return system.getResultSuccess();
return saasorderbusinessmen;
}
async pageByCondition(params) {
......@@ -270,8 +315,7 @@ class SaasOrderService extends ServiceBase {
params.audit_status = status;
} else if (type == "30") {
params.handle_status = status;
} else {
}
} else {}
}
async setOrderStatus(rows) {
......@@ -384,7 +428,9 @@ class SaasOrderService extends ServiceBase {
return system.getResult(null, "订单已审核");
}
let _order = {id: id};
let _order = {
id: id
};
_order.audit_status = audit_status;
_order.handle_status = "10";
_order.audit_remark = this.trim(params.audit_remark);
......@@ -393,12 +439,16 @@ class SaasOrderService extends ServiceBase {
let _bminfo;
if (audit_status == "20") {
_deliverInfo = {id: id};
_deliverInfo = {
id: id
};
_deliverInfo.deliver_man = this.trim(params.deliver_man);
_deliverInfo.deliver_mobile = this.trim(params.deliver_mobile);
_deliverInfo.deliver_addr = this.trim(params.deliver_addr);
_bminfo = {id: id};
_bminfo = {
id: id
};
_bminfo.domicile_id = this.trim(params.domicile_id);
_bminfo.domicile_name = this.trim(params.domicile_name);
_bminfo.business_scope_id = this.trim(params.business_scope_id);
......@@ -452,10 +502,14 @@ class SaasOrderService extends ServiceBase {
return system.getResult(null, "该订单不允许交付");
}
let _order = {id: id};
let _order = {
id: id
};
_order.handle_status = "30";
let _deliverInfo = {id: id};
let _deliverInfo = {
id: id
};
_deliverInfo.deliver_express_no = deliver_express_no;
_deliverInfo.deliver_express_img = deliver_express_img;
let self = this;
......@@ -488,11 +542,15 @@ class SaasOrderService extends ServiceBase {
return;
}
let _order = {id: id};
let _order = {
id: id
};
_order.pay_status = "20";
_order.audit_status = "10";
let _deliverInfo = {id: id};
let _deliverInfo = {
id: id
};
_deliverInfo.merchant_deliver_man = this.trim(params.merchant_deliver_man);
_deliverInfo.merchant_deliver_mobile = this.trim(params.merchant_deliver_mobile);
_deliverInfo.merchant_deliver_addr = this.trim(params.merchant_deliver_addr);
......@@ -537,7 +595,7 @@ class SaasOrderService extends ServiceBase {
if (page.count == 0) {
return system.getResultSuccess(page);
}
params.attrs = ["id","sve_businessmen_company_id","sve_businessmen_customer_id","sve_businessmen_name","sve_businessmen_credit_code"];
params.attrs = ["id", "sve_businessmen_company_id", "sve_businessmen_customer_id", "sve_businessmen_name", "sve_businessmen_credit_code"];
page.rows = await this.saasorderdeliverinfoDao.listByCondition(params);
if (page.rows) {
for (var row of page.rows) {
......@@ -548,4 +606,4 @@ class SaasOrderService extends ServiceBase {
}
}
module.exports = SaasOrderService;
module.exports = SaasOrderService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class SaasorderbusinessmenService extends ServiceBase {
constructor() {
super("saas", ServiceBase.getDaoName(SaasorderbusinessmenService));
this.saasorderbminfoDao = system.getObject("db.saas.saasorderbminfoDao");
this.saasorderpayDao = system.getObject("db.saas.saasorderpayDao");
this.saasorderdeliverinfoDao = system.getObject("db.saas.saasorderdeliverinfoDao");
this.redisClient = system.getObject("util.redisClient");
}
}
module.exports = SaasorderbusinessmenService;
\ 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