Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
04a0b5e9
Commit
04a0b5e9
authored
Mar 10, 2020
by
王昆
Browse files
Options
Browse Files
Download
Plain Diff
gsb
parents
bfd813e2
94e5550a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
255 additions
and
7 deletions
+255
-7
xggsve-invoice/app/base/db/impl/invoice/iinvoiceDao.js
+6
-1
xggsve-invoice/app/base/db/models/invoice/iinvoice.js
+2
-2
xggsve-invoice/app/base/service/impl/invoice/iinvoiceSve.js
+247
-4
No files found.
xggsve-invoice/app/base/db/impl/invoice/iinvoiceDao.js
View file @
04a0b5e9
...
@@ -5,7 +5,6 @@ class IInvoiceDao extends Dao {
...
@@ -5,7 +5,6 @@ class IInvoiceDao extends Dao {
constructor
()
{
constructor
()
{
super
(
Dao
.
getModelName
(
IInvoiceDao
));
super
(
Dao
.
getModelName
(
IInvoiceDao
));
}
}
async
countByParams
(
params
)
{
async
countByParams
(
params
)
{
var
sql
=
[];
var
sql
=
[];
sql
.
push
(
"SELECT"
);
sql
.
push
(
"SELECT"
);
...
@@ -73,6 +72,12 @@ class IInvoiceDao extends Dao {
...
@@ -73,6 +72,12 @@ class IInvoiceDao extends Dao {
}
}
}
}
async
findByChannelAndApplyNo
(
channel_id
,
apply_no
){
let
sql
=
`select count(1) as total from i_invoice where channel_id = "
${
channel_id
}
" and apply_no = "
${
apply_no
}
"`
;
var
counts
=
await
this
.
customQuery
(
sql
);
return
counts
[
0
];
}
// /**
// /**
// * 红冲列表总计
// * 红冲列表总计
// * @param {*} params
// * @param {*} params
...
...
xggsve-invoice/app/base/db/models/invoice/iinvoice.js
View file @
04a0b5e9
...
@@ -47,11 +47,11 @@ module.exports = (db, DataTypes) => {
...
@@ -47,11 +47,11 @@ module.exports = (db, DataTypes) => {
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
,
comment
:
"渠道ID"
},
channel_id
:{
type
:
DataTypes
.
STRING
(
32
),
allowNull
:
true
,
delaultValue
:
''
,
comment
:
"渠道ID"
},
product_id
:{
type
:
DataTypes
.
STRING
(
32
),
allowNull
:
true
,
delaultValue
:
''
,
comment
:
"商品ID"
},
created_at
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
true
},
created_at
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
true
},
updated_at
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
true
},
updated_at
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
true
},
deleted_at
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
true
},
deleted_at
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
true
},
version
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
true
,
defaultValue
:
0
}
},
{
},
{
timestamps
:
true
,
timestamps
:
true
,
paranoid
:
true
,
paranoid
:
true
,
...
...
xggsve-invoice/app/base/service/impl/invoice/iinvoiceSve.js
View file @
04a0b5e9
...
@@ -14,6 +14,8 @@ class IInvoiceService extends ServiceBase {
...
@@ -14,6 +14,8 @@ class IInvoiceService extends ServiceBase {
this
.
iinvoiceprocessDao
=
system
.
getObject
(
"db.invoice.iinvoiceprocessDao"
);
this
.
iinvoiceprocessDao
=
system
.
getObject
(
"db.invoice.iinvoiceprocessDao"
);
this
.
iinvoiceinforegDao
=
system
.
getObject
(
"db.invoice.iinvoiceinforegDao"
);
this
.
iinvoiceinforegDao
=
system
.
getObject
(
"db.invoice.iinvoiceinforegDao"
);
this
.
iinvoicedeliverDao
=
system
.
getObject
(
"db.invoice.iinvoicedeliverDao"
);
this
.
iinvoicedeliverDao
=
system
.
getObject
(
"db.invoice.iinvoicedeliverDao"
);
this
.
RULE_INVOICE_TYPE
=
[
"10"
,
'20'
,
'30'
];
//发票类型
this
.
RULE_BUSINESSMEN_TYPE
=
[
'10'
,
'20'
];
//销售方类型
this
.
iproductDao
=
system
.
getObject
(
"db.product.iproductDao"
);
this
.
iproductDao
=
system
.
getObject
(
"db.product.iproductDao"
);
this
.
iprocessDao
=
system
.
getObject
(
"db.product.iprocessDao"
);
this
.
iprocessDao
=
system
.
getObject
(
"db.product.iprocessDao"
);
this
.
iproductprocessDao
=
system
.
getObject
(
"db.product.iproductprocessDao"
);
this
.
iproductprocessDao
=
system
.
getObject
(
"db.product.iproductprocessDao"
);
...
@@ -23,10 +25,252 @@ class IInvoiceService extends ServiceBase {
...
@@ -23,10 +25,252 @@ class IInvoiceService extends ServiceBase {
* 发票申请
* 发票申请
* @param {*} params
* @param {*} params
*/
*/
async
invoiceApply
(
params
)
{
async
invoiceApply
(
params
){
if
(
!
params
.
channel_id
){
return
system
.
getResult
(
null
,
`渠道ID不能为空`
);
}
if
(
!
params
.
apply_no
){
return
system
.
getResult
(
null
,
`发票申请编号不能为空`
);
}
try
{
let
invoiceExists
=
await
this
.
dao
.
findByChannelAndApplyNo
(
this
.
trim
(
params
.
channel_id
),
this
.
trim
(
params
.
apply_no
));
if
(
invoiceExists
.
total
!=
0
){
return
system
.
getResult
(
null
,
`发票编号已存在`
);
}
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误
${
error
}
`
);
}
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
.
invoice_content
){
return
system
.
getResult
(
null
,
`开票内容不能为空`
);
}
if
(
!
params
.
contract
){
return
system
.
getResult
(
null
,
`合同不能为空`
);
}
let
_invoice
=
{};
_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
.
invoice_amount
=
this
.
trim
(
params
.
invoice_amount
)
||
0
;
_invoice
.
invoice_content
=
this
.
trim
(
params
.
invoice_content
)
||
"服务费"
;
_invoice
.
contract
=
this
.
trim
(
params
.
contract
)
||
null
;
_invoice
.
personal_invoice_tax
=
this
.
trim
(
params
.
personal_invoice_tax
)
||
0
;
_invoice
.
additional_tax
=
this
.
trim
(
params
.
additional_tax
)
||
0
;
_invoice
.
value_added_tax
=
this
.
trim
(
params
.
value_added_tax
)
||
0
;
_invoice
.
product_id
=
this
.
trim
(
params
.
product_id
)
||
1
;
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
,
`购买方对公账户不能为空`
);
}
_invoice
.
merchant_id
=
this
.
trim
(
params
.
merchant_id
);
_invoice
.
merchant_name
=
this
.
trim
(
params
.
merchant_name
);
_invoice
.
merchant_credit_code
=
this
.
trim
(
params
.
merchant_credit_code
);
_invoice
.
merchant_addr
=
this
.
trim
(
params
.
merchant_addr
);
_invoice
.
merchant_mobile
=
this
.
trim
(
params
.
merchant_mobile
);
_invoice
.
merchant_bank
=
this
.
trim
(
params
.
merchant_bank
);
_invoice
.
merchant_account
=
this
.
trim
(
params
.
merchant_account
);
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
,
`销售方对公账户不能为空`
);
}
if
(
this
.
RULE_BUSINESSMEN_TYPE
.
indexOf
(
this
.
trim
(
params
.
businessmen_type
))
==-
1
){
return
system
.
getResult
(
null
,
`销售方类型错误`
);
}
_invoice
.
businessmen_type
=
this
.
trim
(
params
.
businessmen_type
);
_invoice
.
businessmen_id
=
this
.
trim
(
params
.
businessmen_id
);
_invoice
.
businessmen_credit_code
=
this
.
trim
(
params
.
businessmen_credit_code
)
||
0
;
_invoice
.
businessmen_name
=
this
.
trim
(
params
.
businessmen_name
);
_invoice
.
businessmen_addr
=
this
.
trim
(
params
.
businessmen_addr
);
_invoice
.
businessmen_mobile
=
this
.
trim
(
params
.
businessmen_mobile
);
_invoice
.
businessmen_bank
=
this
.
trim
(
params
.
businessmen_bank
);
_invoice
.
businessmen_account
=
this
.
trim
(
params
.
businessmen_account
);
_invoice
.
mail_to
=
this
.
trim
(
params
.
mail_to
)
||
""
;
_invoice
.
mail_mobile
=
this
.
trim
(
params
.
mail_mobile
)
||
""
;
_invoice
.
mail_addr
=
this
.
trim
(
params
.
mail_addr
)
||
""
;
try
{
await
this
.
dao
.
create
(
_invoice
);
return
system
.
getResult
(
`success`
);
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误`
);
}
}
}
//********************************************** 代码分隔 总统在上面写 *********************************************************** */
async
invoicePage
(
params
)
{
params
.
currentPage
=
Number
(
params
.
currentPage
||
1
);
params
.
pageSize
=
Number
(
params
.
pageSize
||
10
);
params
.
startRow
=
Number
((
params
.
currentPage
-
1
)
*
params
.
pageSize
);
let
total
=
await
this
.
dao
.
countByParams
(
params
);
if
(
total
==
0
)
{
return
{
count
:
0
,
rows
:
[]
};
}
let
list
=
await
this
.
dao
.
pageByParams
(
params
);
if
(
list
)
{
for
(
var
item
of
list
)
{
this
.
handleDate
(
item
,
[
'updated_at'
,
'created_at'
],
'YYYY-MM-DD HH:mm:ss'
);
}
//格式化订单产品
await
this
.
setDeliver
(
list
);
//格式化业务员
await
this
.
setStatus
(
list
);
await
this
.
setProduct
(
list
);
}
return
{
count
:
total
,
rows
:
list
};
}
/**
* 格式化订单产品
* @param {*} list
*/
async
setProduct
(
list
)
{
let
productIdList
=
[];
for
(
let
item
of
list
)
{
if
(
item
.
product_id
)
{
productIdList
.
push
(
item
.
product_id
);
}
}
let
productMap
=
await
this
.
iproductDao
.
mapByIds
(
productIdList
);
for
(
let
item
of
list
)
{
item
.
oproduct
=
productMap
[
item
.
product_id
]
||
{}
}
}
async
setDeliver
(
list
)
{
if
(
!
list
||
list
.
length
==
0
)
{
return
;
}
let
ids
=
[];
for
(
let
item
of
list
)
{
if
(
!
item
.
invoice_deliver_id
)
{
continue
;
}
ids
.
push
(
item
.
invoice_deliver_id
)
}
let
map
=
await
this
.
iinvoicedeliverDao
.
findMapByIds
(
ids
);
for
(
let
item
of
list
)
{
item
.
invoice_deliver
=
map
[
item
.
invoice_deliver_id
]
||
{};
}
}
/**
* 处理状态数据
* @param list
* @returns {Promise<void>}
*/
async
setStatus
(
list
)
{
let
ids
=
[];
let
statuses
=
[];
for
(
let
item
of
list
)
{
ids
.
push
(
item
.
id
);
statuses
.
push
(
item
.
status
);
}
let
map
=
await
this
.
iinvoiceprocessDao
.
mapByInvoiceIdsAndStatus
(
ids
,
statuses
);
for
(
let
item
of
list
)
{
let
key
=
item
.
id
+
"_"
+
item
.
status
;
let
v
=
map
[
key
]
||
{};
item
.
status_name
=
v
.
name
;
item
.
next_status
=
JSON
.
parse
(
v
.
next_status
||
"[]"
);
}
console
.
log
(
list
);
}
/**
* 构建产品流程对象
* @param productPid
* @param chooseProductIds
* @returns {Promise<void>}
*/
async
buildProcess
(
params
)
{
let
productPid
=
params
.
productPid
||
50010000
;
// 查询产品流程
let
productProcessList
=
await
this
.
iproductprocessDao
.
byProductPid
(
productPid
);
if
(
!
productProcessList
||
productProcessList
.
length
==
0
)
{
return
[];
}
let
invoiceProcessList
=
[];
// 批量查流程
let
processMap
=
await
this
.
iprocessDao
.
mapAll
();
for
(
let
productProcess
of
productProcessList
)
{
// 风还钻该处理每一个子项流程 变为 订单流程对象
let
process
=
processMap
[
productProcess
.
process_id
];
let
nextArr
=
this
.
trim
(
productProcess
.
next_status
).
split
(
","
);
let
nextStatus
=
[];
for
(
let
nextId
of
nextArr
)
{
nextId
=
Number
(
nextId
||
0
);
let
nextObj
=
processMap
[
nextId
];
if
(
!
nextObj
)
{
continue
;
}
nextStatus
.
push
({
next_status
:
nextObj
.
status
,
next_name
:
nextObj
.
name
});
}
let
orderProcess
=
{
product_id
:
productPid
,
name
:
process
.
name
,
status
:
process
.
status
,
func
:
productProcess
.
func
,
next_status
:
JSON
.
stringify
(
nextStatus
),
name1
:
productProcess
.
name1
,
name2
:
productProcess
.
name2
,
name3
:
productProcess
.
name3
,
name4
:
productProcess
.
name4
,
sort
:
productProcess
.
sort
,
autoIncrement
:
true
};
invoiceProcessList
.
push
(
orderProcess
);
}
// await this.iinvoiceprocessDao.model.bulkCreate(invoiceProcessList);
return
invoiceProcessList
;
}
}
}
module
.
exports
=
IInvoiceService
;
module
.
exports
=
IInvoiceService
;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment