Commit 98101b0b by 孙亚楠

dd

parent 0f59cd59
......@@ -15,7 +15,7 @@ module.exports = function (db, DataTypes) {
deliver_content: { type: DataTypes.STRING, allowNull: true, comment: '交付内容' },
deliver_mail_no: { 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 },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
......
......@@ -4,16 +4,28 @@
*/
module.exports = function (db, DataTypes) {
return db.define('iinvoicesummaryinfo', {
invoice_id : { type: DataTypes.STRING, allowNull: true, comment: '发票id'},
invoice_type : { type: DataTypes.STRING, allowNull: true, comment: '发票类型'},
summary_content : { type: DataTypes.STRING, allowNull: true, comment: '摘要内容'},
specification : { type: DataTypes.STRING, allowNull: true, comment: '规格型号'},
unit : { type: DataTypes.STRING, allowNull: true, comment: '单位'},
number : { type: DataTypes.INTEGER, allowNull: true, comment: '数量'},
unit_price : { type: DataTypes.INTEGER, allowNull: true, comment: '单价'},
amount : { type: DataTypes.INTEGER, allowNull: true, comment: '金额'},
tax_rate : { type: DataTypes.INTEGER, allowNull: true, comment: '税率'},
tax_amount : { type: DataTypes.INTEGER, allowNull: true, comment: '税额'},
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_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_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: '销售方银行账号' },
summary:{ type: DataTypes.TEXT, 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 },
......
......@@ -45,9 +45,9 @@ class IInvoiceService extends ServiceBase {
if(this.RULE_INVOICE_TYPE.indexOf(this.trim(params.invoice_type)) ==-1){
return system.getResult(null,`发票类型不存在`);
}
if(!params.apply_time){
return system.getResult(null,`发票申请时间错误`);
}
// if(!params.apply_time){
// return system.getResult(null,`发票申请时间错误`);
// }
if(!params.invoice_content){
return system.getResult(null,`开票内容不能为空`);
}
......@@ -59,7 +59,7 @@ class IInvoiceService extends ServiceBase {
_invoice.channel_id = this.trim(params.channel_id);
_invoice.apply_no = this.trim(params.apply_no);
_invoice.invoice_type = this.trim(params.invoice_type);
_invoice.apply_time = this.trim(params.apply_time);
_invoice.apply_time = this.trim(params.apply_time) || new Date();
_invoice.invoice_amount = this.trim(params.invoice_amount) || 0;
_invoice.invoice_content = this.trim(params.invoice_content) || "服务费";
_invoice.contract = this.trim(params.contract) || null;
......@@ -131,14 +131,17 @@ class IInvoiceService extends ServiceBase {
await this.db.transaction(async t => {
_invoice = await this.dao.create(_invoice,t);
await this.iinvoiceinforegDao.create({id:_invoice.id},t);
await this.iinvoicesummaryinfoDao.create({id:_invoice.id},t);
});
let processList = await this.buildProcess(_invoice.product_id) || [];
for(let process of processList) {
process.invoice_id = _invoice.id;
}
_invoice.status = processList[0].status;
await _invoice.save();
let invoiceProperty = {};
invoiceProperty.status = processList[0].status;
invoiceProperty.id = _invoice.id;
await this.dao.update(invoiceProperty,t);
return system.getResult(`success`);
} catch (error) {
......
......@@ -4,7 +4,7 @@ const ServiceBase = require("../../sve.base")
/**
* 订单产品表
*/
class OorderstatusService extends ServiceBase {
class IinvoicestatusService extends ServiceBase {
constructor() {
super("invoice", ServiceBase.getDaoName(IInvoiceService));
......@@ -19,6 +19,7 @@ class OorderstatusService extends ServiceBase {
this.PALTFORM_DELIVER_AUDIT_FILE_CODE="1080";
this.RULE_INVOICE_TYPE =["10",'20','30']; //发票类型
this.RULE_BUSINESSMEN_TYPE=['10','20']; //销售方类型
this.RULE_INVOICE_JOIN=['10','20','30','40']; //发票联次
}
/***************************************以下是订单处理的分发器***************************************************************** */
......@@ -195,7 +196,7 @@ class OorderstatusService extends ServiceBase {
* @invoice_id String 订单ID
*
*/
async platformDeliverAudit(params) {
async deliverAudit(params) {
//参数验证
if (!params.invoice_id) {
return system.getResult(null, `参数错误 订单ID不能为空`);
......@@ -236,7 +237,7 @@ class OorderstatusService extends ServiceBase {
} else {
return system.getResult(null, `参数错误 非法的订单状态`);
}
iinvoiceinforegProperty.id = params._invoice.deliver_id;
iinvoiceinforegProperty.id = params._invoice.id;
iinvoiceinforegProperty.audit_result = params.nextName;
let iinvoiceProperty = {};
iinvoiceProperty.id = params.invoice_id;
......@@ -257,16 +258,110 @@ class OorderstatusService extends ServiceBase {
}
}
/**
* 平台验收
* @param {*} params
*/
async deliveryAcceptance(params) {
if(!params.province){
return system.getResult(null,`发票省份不能为空`);
}
if(this.RULE_INVOICE_TYPE.indexOf(this.trim(params.invoice_type)) ==-1){
return system.getResult(null,`发票类型不存在`);
}
if(this.RULE_INVOICE_JOIN.indexOf(this.trim(params.invoice_join)) ==-1){
return system.getResult(null,`发票联次不存在`);
}
if(!params.invoice_no){
return system.getResult(null,`发票号码错误`);
}
if(!params.invoice_number){
return system.getResult(null,`开票内不能为空`);
}
if(!params.invoice_time){
return system.getResult(null,`开票日期不能为空`);
}
if(!params.merchant_name){
return system.getResult(null,`购买方名称不能为空`);
}
if(!params.merchant_credit_code){
return system.getResult(null,`购买方社会统一信用代码不能为空`);
}
if(!params.merchant_addr){
return system.getResult(null,`购买方地址不能为空`);
}
if(!params.merchant_mobile){
return system.getResult(null,`购买方电话不能为空`);
}
if(!params.merchant_bank){
return system.getResult(null,`购买方开户行不能为空`);
}
if(!params.merchant_account){
return system.getResult(null,`购买方对公账户不能为空`);
}
if(!params.businessmen_name){
return system.getResult(null,`销售方名称不能为空`);
}
if(!params.businessmen_credit_code){
return system.getResult(null,`销售方社会统一信用代码不能为空`);
}
if(!params.businessmen_addr){
return system.getResult(null,`销售方地址不能为空`);
}
if(!params.businessmen_mobile){
return system.getResult(null,`销售方电话不能为空`);
}
if(!params.businessmen_bank){
return system.getResult(null,`销售方开户行不能为空`);
}
if(!params.businessmen_account){
return system.getResult(null,`销售方对公账户不能为空`);
}
let _invoice= params._invoice;
_invoice.status = this.trim(params.status);
let _iinvoicesummaryinfoBean = await this.iinvoicesummaryinfoDao.dao.findById(_invoice.id);
if(!_iinvoicesummaryinfoBean){
return system.getResult(null, `系统错误 ,当前摘要信息不存在`);
}
let _iinvoicesummaryinfoProperty = {};
_iinvoicesummaryinfoProperty.province = this.trim(params.province);
_iinvoicesummaryinfoProperty.invoice_type = this.trim(params.invoice_type);
_iinvoicesummaryinfoProperty.invoice_join = this.trim(params.invoice_join);
_iinvoicesummaryinfoProperty.invoice_no = this.trim(params.invoice_no);
_iinvoicesummaryinfoProperty.invoice_number = this.trim(params.invoice_number);
_iinvoicesummaryinfoProperty.invoice_time = this.trim(params.invoice_time);
_iinvoicesummaryinfoProperty.merchant_id = this.trim(params.merchant_id);
_iinvoicesummaryinfoProperty.merchant_name = this.trim(params.merchant_name);
_iinvoicesummaryinfoProperty.merchant_credit_code = this.trim(params.merchant_credit_code);
_iinvoicesummaryinfoProperty.merchant_addr = this.trim(params.merchant_addr);
_iinvoicesummaryinfoProperty.merchant_mobile = this.trim(params.merchant_mobile);
_iinvoicesummaryinfoProperty.merchant_bank = this.trim(params.merchant_bank);
_iinvoicesummaryinfoProperty.merchant_account = this.trim(params.merchant_account);
_iinvoicesummaryinfoProperty.businessmen_type = this.trim(params.businessmen_type);
_iinvoicesummaryinfoProperty.businessmen_id = this.trim(params.businessmen_id);
_iinvoicesummaryinfoProperty.businessmen_credit_code = this.trim(params.businessmen_credit_code);
_iinvoicesummaryinfoProperty.businessmen_name = this.trim(params.businessmen_name);
_iinvoicesummaryinfoProperty.businessmen_addr = this.trim(params.businessmen_addr);
_iinvoicesummaryinfoProperty.businessmen_mobile = this.trim(params.businessmen_mobile);
_iinvoicesummaryinfoProperty.businessmen_bank = this.trim(params.businessmen_bank);
_iinvoicesummaryinfoProperty.businessmen_account = this.trim(params.businessmen_account);
_iinvoicesummaryinfoProperty.summary = JSON.stringify(params.summary) ;
_iinvoicesummaryinfoProperty.id = _invoice.id;
let _invoiceProperty={};
_invoiceProperty.status = this.trim(params.status);
_invoiceProperty.id = _invoice.id;
try {
await _invoice.save();
await this.db.transaction(async t=>{
await this.dao.update(_invoiceProperty,t);
await this.iinvoicesummaryinfoDao.update(_iinvoicesummaryinfoProperty,t);
});
return system.getResultSuccess();
} catch (error) {
console.log(error);
......@@ -451,12 +546,22 @@ class OorderstatusService extends ServiceBase {
}
}
/**
* 平台审核失败
* @param {*} params
*/
async deliverReject(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}`);
}
}
}
module.exports = OorderstatusService;
\ No newline at end of file
module.exports = IinvoicestatusService;
\ 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