Commit 170c60cd by 孙亚楠

dd

parent 90508b49
const system = require("../../../system");
const Dao = require("../../dao.base");
class IInvoicestatusDao extends Dao {
constructor() {
super(Dao.getModelName(IInvoicestatusDao));
}
}
module.exports = IInvoicestatusDao;
...@@ -43,13 +43,14 @@ module.exports = (db, DataTypes) => { ...@@ -43,13 +43,14 @@ module.exports = (db, DataTypes) => {
mail_mobile: { type: DataTypes.STRING(20), allowNull: true, defaultValue: null, COMMENT: '邮寄电话' }, mail_mobile: { type: DataTypes.STRING(20), allowNull: true, defaultValue: null, COMMENT: '邮寄电话' },
mail_to: { type: DataTypes.STRING(20), allowNull: true, defaultValue: null, COMMENT: '邮寄人' }, mail_to: { type: DataTypes.STRING(20), allowNull: true, defaultValue: null, COMMENT: '邮寄人' },
statements: { type: DataTypes.STRING(45), allowNull: true, defaultValue: null, COMMENT: '结算单' }, statements: { type: DataTypes.STRING(45), allowNull: true, defaultValue: null, COMMENT: '结算单' },
invoice_img: { type: DataTypes.STRING(500), allowNull: true, defaultValue: null}, invoice_img: { type: DataTypes.STRING(500), allowNull: true, defaultValue: null,COMMENT:'发票图片'},
invoice_deliver_id:{ type: DataTypes.STRING(32), allowNull: true, defaultValue: null,comment:"交付id i_invoice_deliver 表ID" }, invoice_deliver_id:{ type: DataTypes.STRING(32), allowNull: true, defaultValue: null,comment:"交付id i_invoice_deliver 表ID" },
deliver_id:{ type: DataTypes.STRING(32), allowNull: true, defaultValue: null,comment:"交付商ID common下的交付商ID" }, deliver_id:{ type: DataTypes.STRING(32), allowNull: true, defaultValue: null,comment:"交付商ID common下的交付商ID" },
bd_id:{ type: DataTypes.STRING(32), allowNull: true, defaultValue: null ,comment:"业务员Id"}, bd_id:{ type: DataTypes.STRING(32), allowNull: true, defaultValue: null ,comment:"业务员Id"},
bd_path:{ type: DataTypes.STRING(200), allowNull: true, defaultValue: null ,comment:"业务员权限"}, bd_path:{ type: DataTypes.STRING(200), allowNull: true, defaultValue: null ,comment:"业务员权限"},
channel_id:{ type: DataTypes.STRING(32), allowNull: true ,delaultValue:'',comment:"渠道ID"}, channel_id:{ type: DataTypes.STRING(32), allowNull: true ,delaultValue:'',comment:"渠道ID"},
product_id:{ type: DataTypes.STRING(32), allowNull: true ,delaultValue:'',comment:"商品ID"}, product_id:{ type: DataTypes.STRING(32), allowNull: true ,delaultValue:'',comment:"商品ID"},
status: {type: DataTypes.INTEGER, field: 'status', allowNull: true,comment:'订单状态 业务进度' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW }, 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 }, updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, allowNull: true }, deleted_at: { type: DataTypes.DATE, allowNull: true },
......
...@@ -4,19 +4,19 @@ ...@@ -4,19 +4,19 @@
*/ */
module.exports = function (db, DataTypes) { module.exports = function (db, DataTypes) {
return db.define('iinvoiceinforeg', { return db.define('iinvoiceinforeg', {
invoice_id: { type: DataTypes.STRING, allowNull: true, comment: '订单号'}, // invoice_id: { type: DataTypes.STRING, allowNull: true, comment: '订单号' },
deliver_id: { type: DataTypes.STRING, allowNull: true, comment: '交付商id'}, deliver_id: { type: DataTypes.STRING, allowNull: true, comment: '交付商id' },
deliver_name: { type: DataTypes.STRING, allowNull: true, comment: '交付商名称'}, deliver_name: { type: DataTypes.STRING, allowNull: true, comment: '交付商名称' },
deliver_divide: { type: DataTypes.BIGINT, allowNull: true, comment: '订单分成'}, deliver_divide: { type: DataTypes.BIGINT, allowNull: true, comment: '订单分成' },
deliver_mail_addr: { type: DataTypes.STRING, allowNull: true, comment: '交付地址'}, deliver_mail_addr: { type: DataTypes.STRING, allowNull: true, comment: '交付地址' },
deliver_mail_to: { type: DataTypes.STRING, allowNull: true, comment: '收件人'}, deliver_mail_to: { type: DataTypes.STRING, allowNull: true, comment: '收件人' },
deliver_mail_mobile: { type: DataTypes.STRING, allowNull: true, comment: '联系电话'}, deliver_mail_mobile: { type: DataTypes.STRING, allowNull: true, comment: '联系电话' },
audit_content: { type: DataTypes.STRING, allowNull: true, comment: '交付审核内容'}, audit_content: { type: DataTypes.STRING, allowNull: true, comment: '交付审核内容 /审核备注' },
deliver_content: { type: DataTypes.STRING, allowNull: true, comment: '交付内容'}, deliver_content: { type: DataTypes.STRING, allowNull: true, comment: '交付内容' },
deliver_mail_no: { type: DataTypes.STRING, allowNull: true, comment: '交付商交付快递单号'}, deliver_mail_no: { type: DataTypes.STRING, allowNull: true, comment: '交付商交付快递单号' },
deliver_img: { type: DataTypes.STRING, allowNull: true, comment: '交接单'}, deliver_img: { type: DataTypes.STRING, allowNull: true, comment: '交接单' },
operator_id: { type: DataTypes.INTEGER, allowNull: true, comment: '交付商业务员id'}, operator_id: { type: DataTypes.INTEGER, allowNull: true, comment: '交付商业务员id' },
audit_result: { type: DataTypes.STRING, field: 'audit_result', allowNull: true,defaultValue:'', comment:'审核结果'},
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW }, 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 }, updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true }, deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true },
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
const moment = require('moment')
/**
* 发表申请表
*/
module.exports = (db, DataTypes) => {
return db.define("iinvoicestatus", {
// id: { type: DataTypes.STRING(32), allowNull: true, comment: "" },
channel_id: { type: DataTypes.STRING(32), allowNull: true, defaultValue: "", COMMENT: '渠道id' },
province: { type: DataTypes.STRING(10), allowNull: true, comment: "发票对应省份" },
invoice_type: { type: DataTypes.STRING(4), allowNull: true, comment: '发票类型 10 增值税专用发票 20 增值税普通发票 30 普通发票' },
invoice_join: { type: DataTypes.STRING(4), allowNull: true, comment: '发票联次 10 记账联 20 发票联 30 抵扣联 40 销售方次' },
invoice_no: { type: DataTypes.STRING(20), allowNull: true,delaultValue:"", comment: "发票代码" },
invoice_number: { type: DataTypes.STRING(20), allowNull: true,delaultValue:"", comment: "发票号码" },
invoice_time: { type: DataTypes.DATE, allowNull: true, delaultValue:null,comment: "开票日期" },
merchant_id: { type: DataTypes.STRING(32), allowNull: true, defaultValue: "", COMMENT: '购买方商户id' },
merchant_name: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '购买方名称' },
merchant_credit_code: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '购买方纳税人识别号' },
merchant_addr: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '购买方地址' },
merchant_mobile: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '购买方电话' },
merchant_bank: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '购买方开户行' },
merchant_account: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '银行账号' },
businessmen_type: { type: DataTypes.STRING(4), allowNull: true, defaultValue: "", COMMENT: '销售方类型 10 个体工商户 20 自然人' },
businessmen_id: { type: DataTypes.STRING(32), allowNull: false, COMMENT: '销售商id' },
businessmen_credit_code: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '销售方社会统一信用代码' },
businessmen_name: { type: DataTypes.STRING(45), allowNull: true, defaultValue: "" },
businessmen_addr: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '销售方地址' },
businessmen_mobile: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '销售方电话' },
businessmen_bank: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '销售方开户行' },
businessmen_account: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '销售方银行账号' },
apply_no: { type: DataTypes.STRING(45), allowNull: true, defaultValue: "", COMMENT: '发票申请编号' },
apply_time: { type: DataTypes.DATE, allowNull: true, defaultValue: null, COMMENT: '发票申请时间' },
invoice_amount: { type: DataTypes.INTEGER, allowNull: true, defaultValue: 0, COMMENT: '价税合计总金额' },
invoice_content: { type: DataTypes.STRING(300), allowNull: false, defaultValue: null, COMMENT: '开票内容' },
contract: { type: DataTypes.STRING(500), allowNull: true,delaultValue:"", COMMENT: '合同' },
personal_invoice_tax: { type: DataTypes.INTEGER, allowNull: false, defaultValue: null, COMMENT: '个税' },
additional_tax: { type: DataTypes.INTEGER, allowNull: false, defaultValue: null, COMMENT: '附加税' },
value_added_tax: { type: DataTypes.INTEGER, allowNull: false, defaultValue: null, COMMENT: '增值税' },
mail_addr: { type: DataTypes.STRING(200), allowNull: true, defaultValue: null, COMMENT: '邮寄地址' },
mail_mobile: { type: DataTypes.STRING(20), allowNull: true, defaultValue: null, COMMENT: '邮寄电话' },
mail_to: { type: DataTypes.STRING(20), allowNull: true, defaultValue: null, COMMENT: '邮寄人' },
statements: { type: DataTypes.STRING(45), allowNull: true, defaultValue: null, COMMENT: '结算单' },
invoice_img: { type: DataTypes.STRING(500), allowNull: true, defaultValue: null},
invoice_deliver_id:{ type: DataTypes.STRING(32), allowNull: true, defaultValue: null,comment:"交付id i_invoice_deliver 表ID" },
deliver_id:{ type: DataTypes.STRING(32), allowNull: true, defaultValue: null,comment:"交付商ID common下的交付商ID" },
bd_id:{ type: DataTypes.STRING(32), allowNull: true, defaultValue: null ,comment:"业务员Id"},
bd_path:{ type: DataTypes.STRING(200), allowNull: true, defaultValue: null ,comment:"业务员权限"},
channel_id:{ type: DataTypes.STRING(32), allowNull: true ,delaultValue:'',comment:"渠道ID"},
product_id:{ type: DataTypes.STRING(32), allowNull: true ,delaultValue:'',comment:"商品ID"},
status: {type: DataTypes.INTEGER, field: 'status', allowNull: true,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, allowNull: true },
}, {
timestamps: false,
paranoid: true,
tableName: 'i_invoice',
comment: '发票表',
charset: 'utf8',
collate: 'utf8_general_ci',
version: true
});
}
\ No newline at end of file
...@@ -128,14 +128,17 @@ class IInvoiceService extends ServiceBase { ...@@ -128,14 +128,17 @@ class IInvoiceService extends ServiceBase {
_invoice.mail_addr = this.trim(params.mail_addr) || ""; _invoice.mail_addr = this.trim(params.mail_addr) || "";
try { try {
await this.db.transaction(async t => {
_invoice = await this.dao.create(_invoice); _invoice = await this.dao.create(_invoice);
_iinvoiceinforeg = await this.iinvoiceinforegDao.create({id:_invoice.id},t);
let processList = await this.buildProcess(_invoice.product_id) || []; let processList = await this.buildProcess(_invoice.product_id) || [];
for(let process of processList) { for(let process of processList) {
process.invoice_id = _invoice.id; process.invoice_id = _invoice.id;
} }
await this.iinvoiceprocessDao.model.bulkCreate(processList); await this.iinvoiceprocessDao.model.bulkCreate(processList);
});
return system.getResult(`success`); return system.getResult(`success`);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
......
...@@ -8,4 +8,4 @@ class IInvoiceinforegService extends ServiceBase { ...@@ -8,4 +8,4 @@ class IInvoiceinforegService extends ServiceBase {
} }
module.exports = IInvoiceprocessService; module.exports = IInvoiceinforegService;
\ No newline at end of file \ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
/**
* 订单产品表
*/
class OorderstatusService extends ServiceBase {
constructor() {
super("invoice", ServiceBase.getDaoName(IInvoiceService));
this.iinvoicesummaryinfoDao = system.getObject("db.invoice.iinvoicesummaryinfoDao");
this.iinvoiceprocessDao = system.getObject("db.invoice.iinvoiceprocessDao");
this.iinvoiceinforegDao = system.getObject("db.invoice.iinvoiceinforegDao");
this.iinvoicedeliverDao = system.getObject("db.invoice.iinvoicedeliverDao");
this.iproductDao = system.getObject("db.product.iproductDao");
this.iprocessDao = system.getObject("db.product.iprocessDao");
this.iproductprocessDao = system.getObject("db.product.iproductprocessDao");
this.PALTFORM_DELIVER_AUDIT_SUCCESS_CODE="1070";
this.PALTFORM_DELIVER_AUDIT_FILE_CODE="1080";
this.RULE_INVOICE_TYPE =["10",'20','30']; //发票类型
this.RULE_BUSINESSMEN_TYPE=['10','20']; //销售方类型
}
/***************************************以下是订单处理的分发器***************************************************************** */
/**
* 验证订单状态
* @param params
* @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}>}
* @id 订单ID
* @status 订单下一个状态
* @other 其他参数
*/
async handleStatus(params) {
try {
let _invoice = await this.dao.findById(this.trim(params.invoice_id ));
if (!_invoice) {
return system.getResult(null, `发票不存在`);
}
let _invoiceStatus = await this.getInvoiceProcessStatus(_invoice.id, _invoice.status);
let nextList = JSON.parse(_invoiceStatus.next_status);
_invoiceStatus.next_status = nextList;
let flag = false;
let nextNames = [];
let nextName = "";
for (var nextItem of nextList) {
nextNames.push(nextItem.next_name);
if (nextItem.next_status == params.status) {
flag = true;
nextName = nextItem.next_name;
break;
}
}
if (!flag) {
nextNames = nextNames.join("或");
return system.getResult(null, `订单状态错误,下一订单状态应该是${nextNames}`);
}
params._invoice = _invoice;
params._invoiceStatus = _invoiceStatus;
params.nextName = nextName;
//调用对应的方法 TODO SOMETHING .....
// 调用func
return await this[_invoiceStatus.func](params);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 获取订单状态对象
* @param order_id
* @param status
* @returns {Promise<*|{}>}
*/
async getInvoiceProcessStatus(invoice_id, status) {
let map = await this.iinvoiceprocessDao.mapByInvoiceIdsAndStatus([invoice_id], [status]);
return map[invoice_id + "_" + status] || {};
}
/*******************************以下是订单处理进度(平台)**************************************************** */
/**
* 完善信息
* @param {*} params
* @contract
* @status
* @invoice_id
*/
async perfectInformation(params){
if(!params.invoice_id){
return system.getResult(null,`发票ID不能为空`);
}
if(!params.contract){
return system.getResult(null,`合同不能为空`);
}
try {
let _invoice = await this.findById(this.trim(params.invoice_id));
if(!_invoice){
return system.getResult(null,`发票不存在`);
}
_invoice.contract= this.trim(params.contract);
_invoice.status = this.trim(params.status);
let res = await _invoice.save();
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 分配业务员
* @param {*} params
* @invoice_id String 订单ID
* @bd_id String 业务员ID
* @status String 下一个状态码
* @bd_path String 业务员权限
*/
async platformAassignSalesman(params) {
if (!params.bd_id) {
return system.getResult(null, `参数错误 业务员ID不能为空`);
}
try {
//更新订单业务员
let _invoice = await this.findById(this.trim(params.invoice_id));
if (!_invoice) {
return system.getResult(null, `发票不存在不存在`);
}
_invoice.bd_id = this.trim(params.bd_id);
_invoice.status = this.trim(params.status);
_invoice.bd_path = this.trim(params.bd_path);
let res = await _invoice.save();
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 分配交付商
* @param {*} params
* @id String 订单ID
* @deliver_id String 交付商ID
* @deliver_name String 交付商名称
* @deliver_deliver String 交付商分成
* @status String 下一个状态码
*/
async assignDeliver(params) {
//参数验证
if (!params.invoice_id) {
return system.getResult(null, `参数错误 发票ID不能为空`);
}
if (!params.deliver_id) {
return system.getResult(null, `参数错误 交付商ID不能为空`);
}
if (!params.hasOwnProperty(`deliver_divide`)) {
return system.getResult(null, `参数错误 交付商分成不能为空`);
}
try {
let self = this;
await this.db.transaction(async t => {
//创建invoicedeliver记录
let _iinvoicedeliver = await self.iinvoicedeliverDao.create({
invoice_id: self.trim(params.invoice_id),
deliver_id: self.trim(params.deliver_id),
deliver_name: self.trim(params.deliver_name),
deliver_divide: self.trim(params.deliver_divide),
}, t);
//更新iinvoice发票记录
await self.dao.update({
deliver_id: _iinvoicedeliver.id,
id: self.trim(params.invoice_id),
status: self.trim(params.status)
}, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 平台交付审核(审核成功OR失败)
* @param {*} params
* @invoice_id String 订单ID
*
*/
async platformDeliverAudit(params) {
//参数验证
if (!params.invoice_id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 订单状态不能为空`);
}
let iinvoiceinforegProperty = {};
if (this.trim(params.status) == this.PALTFORM_DELIVER_AUDIT_SUCCESS_CODE) { //成功
if (!params.audit_content) {
return system.getResult(null, `参数错误 交付审核备注不能为空`);
}
if (!params.deliver_content) {
return system.getResult(null, `参数错误 交付内容注不能为空`);
}
if (!params.deliver_mail_addr) {
return system.getResult(null, `参数错误 交付地址不能为空`);
}
if (!params.deliver_mail_to) {
return system.getResult(null, `参数错误 收件人不能为空`);
}
if (!params.deliver_mail_mobile) {
return system.getResult(null, `参数错误 联系电话不能为空`);
}
iinvoiceinforegProperty.audit_content = this.trim(params.audit_content);
iinvoiceinforegProperty.deliver_content = this.trim(params.deliver_content);
iinvoiceinforegProperty.deliver_mail_addr = this.trim(params.deliver_mail_addr);
iinvoiceinforegProperty.deliver_mail_to = this.trim(params.deliver_mail_to);
iinvoiceinforegProperty.deliver_mail_mobile = this.trim(params.deliver_mail_mobile);
} else if (this.trim(params.status) == this.PALTFORM_DELIVER_AUDIT_FILE_CODE) {//失败
// todo somthing...
if (!this.trim(params.audit_content)) {
return system.getResult(null, `参数错误 交付审核备注不能为空`);
}
iinvoiceinforegProperty.audit_content = this.trim(params.audit_content);
} else {
return system.getResult(null, `参数错误 非法的订单状态`);
}
iinvoiceinforegProperty.id = params._invoice.deliver_id;
iinvoiceinforegProperty.audit_result = params.nextName;
let iinvoiceProperty = {};
iinvoiceProperty.id = params.invoice_id;
iinvoiceProperty.status = this.trim(params.status);
try {
let self = this;
await this.db.transaction(async t => {
//更新交付orderdeliver记录
await self.iinvoicedeliverDao.update(iinvoiceinforegProperty, t);
//更新oorder订单记录
await self.dao.update(iinvoiceProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 平台验收
* @param {*} params
*/
async deliveryAcceptance(params) {
let _invoice= params._invoice;
_invoice.status = this.trim(params.status);
try {
await _invoice.save();
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 客户交付
* @param {*} params
*/
async deliverCustomer(params) {
if (!params.invoice_id) {
return system.getResult(null, `参数错误 发票ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 发票状态不能为空`);
}
if (!params.deliver_mail_no) {
return system.getResult(null, `参数错误 客户快递单号不能为空`);
}
let iivoiceInforegProperty = {};
iivoiceInforegProperty.id = this.trim(params._order.id);
iivoiceInforegProperty.deliver_mail_no = this.trim(params.deliver_mail_no);
let iinvoiceProperty = {};
iinvoiceProperty.status = this.trim(params.status);
iinvoiceProperty.id = params._invoice.id;
try {
await this.db.transaction(async t => {
await this.oorderinforegDao.update(iivoiceInforegProperty, t);
await this.dao.update(iinvoiceProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 订单完成
* @param {*} params
*/
async orderComplete(params) {
let _invoice = params._invoice;
_invoice.status = this.trim(params.status);
try {
_invoice.save();
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**********************************以下是交付商订单业务处理******************************************************** */
/**
* 分配业务员(交付商)
* @param {*} params
* @id String 订单ID
* @operator_id String 业务员ID
* @status String 下一个状态码
*/
async deliverAssignSalesman(params) {
if (!params.operator_id) {
return system.getResult(null, `参数错误 业务员ID不能为空`);
}
try {
let _iinvoicedeliver = await this.iinvoicedeliverDao.model.findOne({
where: {
invoice_id: this.trim(params._invoice.id)
}
});
if (!_iinvoicedeliver) {
return system.getResult(null, `参数错误 订单交付信息不存在`);
}
let invoicedeliverProperty = {};
invoicedeliverProperty.operator_id = this.trim(params.operator_id);
invoicedeliverProperty.id = _iinvoicedeliver.id;
let invoiceProperty = {};
invoiceProperty.status = this.trim(params.status);
invoiceProperty.id = this.trim(params._invoice.id);
await this.db.transaction(async t => {
await this.oorderdeliverDao.update(invoicedeliverProperty, t);
await this.dao.update(invoiceProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 已经开具发票
* @param {*} params
* @invoice
*/
async invoiced(params){
let _invoice = params._invoice;
_invoice.invoice_no = this.trim(params.invoiceNo);
_invoice.invoice_img = this.trim(params.invoice_img);
_invoice.invoice_time = this.trim(params.invoice_time);
_invoice.invoice_number = this.trim(params.invoice_number);
_invoice.status = this.trim(params.nextStatus);
try {
await _invoice.save();
return system.getResultSuccess();
} catch (error) {
console.log( error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 交付商提交审核
* @param {*} params
* @id 订单ID
* @status String 下一个订单状态
*/
async submitAudit(params) {
let _invoice = params._invoice;
_invoice.status = this.trim(params.status);
try {
await _invoice.save();
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null,`系统错误 错误信息 ${error}`);
}
}
/**
* 交付商订单交付
* @param {*} params
* @invoice_id String 订单ID
* @status String 订单状态
*/
async delivered(params) {
if (!params.invoice_id) {
return system.getResult(null, `参数错误 发票ID不能为空`);
}
if (!params.status) {
return system.getResult(null, `参数错误 状态码不能为空`);
}
if (!params.deliver_mail_no) {
return system.getResult(null, `参数错误 交付商交付快递单号不能为空`);
}
if (!params.deliver_img) {
return system.getResult(null, `参数错误 交接单图片不能为空`);
}
let iinvoiceDeliverProperty = {};
iinvoiceDeliverProperty.deliver_mail_no = this.trim(params.deliver_mail_no);
iinvoiceDeliverProperty.deliver_img = this.trim(params.deliver_img);
let _invoice = params._invoice;
iinvoiceDeliverProperty.id = _invoice.deliver_id;
let invoiceProperty = {};
invoiceProperty.status = this.trim(params.status);
invoiceProperty.id = _order.id;
try {
await this.db.transaction(async t => {
await this.iinvoicedeliverDao.update(iinvoiceDeliverProperty, t);
await this.dao.update(invoiceProperty, t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息${error}`);
}
}
}
module.exports = OorderstatusService;
\ 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