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
e0513e66
Commit
e0513e66
authored
Nov 12, 2020
by
Sxy
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gsb-icp-deliver' of gitlab.gongsibao.com:jiangyong/zhichan into gsb-icp-deliver
parents
dac8fa8f
01ae31e9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
123 additions
and
56 deletions
+123
-56
icp-deliver/app/base/controller/ctl.base.js
+0
-2
icp-deliver/app/base/controller/impl/auth/authCtl.js
+92
-11
icp-deliver/app/base/db/models/agriculture/servicebill.js
+8
-6
icp-deliver/app/base/service/impl/agriculture/servicebillSve.js
+16
-22
icp-deliver/app/base/utils/ydzClient.js
+7
-15
No files found.
icp-deliver/app/base/controller/ctl.base.js
View file @
e0513e66
...
...
@@ -17,8 +17,6 @@ class CtlBase {
return
system
.
getResult
(
up
);
}
async
create
(
pobj
,
qobj
,
req
)
{
console
.
log
(
'---------------------aaa------------------'
);
console
.
log
(
res
);
const
up
=
await
this
.
service
.
create
(
pobj
);
return
system
.
getResult
(
up
);
}
...
...
icp-deliver/app/base/controller/impl/auth/authCtl.js
View file @
e0513e66
var
system
=
require
(
"../../../system"
)
const
http
=
require
(
"http"
)
const
querystring
=
require
(
'querystring'
);
var
settings
=
require
(
"../../../../config/settings"
);
var
settings
=
require
(
"../../../../config/settings"
);
const
CtlBase
=
require
(
"../../ctl.base"
);
class
AuthCtl
extends
CtlBase
{
constructor
(){
super
(
"auth"
,
CtlBase
.
getServiceName
(
AuthCtl
));
const
axios
=
require
(
"axios"
);
class
AuthCtl
extends
CtlBase
{
constructor
()
{
super
(
"auth"
,
CtlBase
.
getServiceName
(
AuthCtl
));
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
}
async
saveAuths
(
pobj
,
query
,
req
)
{
var
auths
=
pobj
.
auths
;
var
xrtn
=
await
this
.
service
.
saveAuths
(
auths
,
pobj
.
app_id
,
pobj
.
company_id
);
async
saveAuths
(
pobj
,
query
,
req
)
{
var
auths
=
pobj
.
auths
;
var
xrtn
=
await
this
.
service
.
saveAuths
(
auths
,
pobj
.
app_id
,
pobj
.
company_id
);
return
system
.
getResult
(
xrtn
);
}
async
findAuthsByRoles
(
pobj
,
query
,
req
)
{
var
roleids
=
pobj
.
roleids
;
var
xrtn
=
await
this
.
service
.
findAuthsByRole
(
roleids
,
pobj
.
app_id
,
pobj
.
company_id
);
async
findAuthsByRoles
(
pobj
,
query
,
req
)
{
var
roleids
=
pobj
.
roleids
;
var
xrtn
=
await
this
.
service
.
findAuthsByRole
(
roleids
,
pobj
.
app_id
,
pobj
.
company_id
);
return
system
.
getResult
(
xrtn
);
}
/**
* 易代账获取初始化token
* @param {*} code
*/
async
getOpenToken
(
body
)
{
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/getToken`
const
ydzKey
=
settings
.
ydzKey
();
let
params
=
{
grantType
:
"authorization_code"
,
appKey
:
ydzKey
.
appKey
,
redirectUri
:
""
,
code
:
body
.
code
}
const
res
=
await
this
.
getRequest
(
url
,
params
);
if
(
res
.
data
.
code
==
200
)
{
let
ydzToken
=
{
access_token
:
res
.
data
.
result
.
access_token
,
refresh_token
:
res
.
data
.
result
.
refresh_token
}
const
addRedisResult
=
await
this
.
redisClient
.
setWithEx
(
'ydzToken'
,
JSON
.
stringify
(
ydzToken
),
6
*
24
*
60
*
60
);
// const getRedisResult = await this.redisClient.get('ydzToken');
return
system
.
getResult
(
addRedisResult
);
}
else
{
return
system
.
getResultFail
(
201
,
res
.
data
.
message
);
}
}
/**
* 刷新opentoken(access_token)
*/
async
refreshToken
()
{
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/refreshToken`
const
ydzKey
=
settings
.
ydzKey
();
const
getRedisResult
=
JSON
.
parse
(
await
this
.
redisClient
.
get
(
'ydzToken'
)).
refresh_token
;
let
params
=
{
grantType
:
"refresh_token"
,
appKey
:
ydzKey
.
appKey
,
refreshToken
:
getRedisResult
}
const
res
=
await
this
.
getRequest
(
url
,
params
);
if
(
res
.
data
.
code
==
200
)
{
let
ydzToken
=
{
access_token
:
res
.
data
.
result
.
access_token
,
refresh_token
:
res
.
data
.
result
.
refresh_token
}
const
addRedisResult
=
await
this
.
redisClient
.
setWithEx
(
'ydzToken'
,
JSON
.
stringify
(
ydzToken
),
6
*
24
*
60
*
60
);
// const getRedisResult = await this.redisClient.get('ydzToken');
return
system
.
getResult
(
addRedisResult
);
}
else
{
return
system
.
getResultFail
(
201
,
res
.
data
.
message
);
}
}
/**
* 公用get请求
* @param {*} url
* @param {*} data
*/
async
getRequest
(
url
,
data
=
{})
{
try
{
console
.
log
(
`
${
url
}
: 请求信息 ------- `
);
console
.
log
(
JSON
.
stringify
(
data
));
const
res
=
await
axios
.
get
(
url
,
{
params
:
data
,
headers
:
{
"Content-Type"
:
"application/json"
,
}
});
return
res
;
}
catch
(
err
)
{
console
.
log
(
`
${
url
}
: 返回错误信息 ------- `
);
console
.
log
(
err
)
throw
(
err
)
}
}
}
module
.
exports
=
AuthCtl
;
module
.
exports
=
AuthCtl
;
\ No newline at end of file
icp-deliver/app/base/db/models/agriculture/servicebill.js
View file @
e0513e66
...
...
@@ -65,13 +65,15 @@ module.exports = (db, DataTypes) => {
}
// companyInfo: { // 对象
// co
mpany
Name // 公司名称
// taxpayerType // 纳税性质 NORMAL_TAXPAYER 一般纳税人; SMALL_TAXPAYER 小规模纳税人
// co
rp
Name // 公司名称
// taxpayerType
Enum
// 纳税性质 NORMAL_TAXPAYER 一般纳税人; SMALL_TAXPAYER 小规模纳税人
// acctgSystemId // 会计制度 10001=2013 小企业会计准 则;10002=2007 企业会计准 则;10003=民间非营利组织会 计制度; 10004=工会会计制度
// companyForm // 企业形式 1 公司; 2 合伙企业; 3 个独; 4 个体工商户
// industry //所属行业
// taxpayerNumber // 税号
// companyArea // 公司区域
// enterpriseFormEnum // 企业形式:CORPORATION 公司;PARTNERSHIP_OR_SOLE 合伙企业/个独/个体工商户;OTHERS 其他企业"
// taxIndustryId //所属行业
// taxNo // 税号
// taxiationArea // 公司区域
// serviceTypeEnum //"服务类型:枚举型,包括ACCOUTING-记账服务、INDUSTRY_COMMERCE-工商服务、BOTH-记账与工商服务"
// taxClaimMethodEnum //申报方式:TAX_DECLARATION-税款申报;ZERO_DECLARATION-零申报;
// }
},
{
...
...
icp-deliver/app/base/service/impl/agriculture/servicebillSve.js
View file @
e0513e66
...
...
@@ -5,7 +5,6 @@ const System = require("../../../system");
const
moment
=
require
(
"moment"
);
const
TOQFT
=
require
(
"../../../utils/toQft"
);
class
ServicebillService
extends
ServiceBase
{
constructor
()
{
super
(
"agriculture"
,
ServiceBase
.
getDaoName
(
ServicebillService
));
...
...
@@ -58,7 +57,7 @@ class ServicebillService extends ServiceBase {
const
res
=
await
this
.
dao
.
update
(
obj
);
const
findOne
=
await
this
.
dao
.
findOne
({
id
:
obj
.
id
});
let
backData
=
{};
if
(
findOne
)
{
if
(
res
&&
findOne
)
{
backData
.
bizId
=
findOne
.
bizId
;
backData
.
auditResult
=
findOne
.
status
;
backData
.
orderNo
=
findOne
.
orderNo
;
...
...
@@ -92,33 +91,28 @@ class ServicebillService extends ServiceBase {
return
data
;
}
mappingYDZ
(
findService
)
{
let
setData
=
{
custName
:
findService
.
contactName
,
//客户名称
corpName
:
findService
.
companyInfo
.
companyName
,
//企业名称
taxiationArea
:
findService
.
companyInfo
.
companyArea
,
//报税地区
taxIndustryId
:
findService
.
companyInfo
.
industry
,
//行业
serviceTypeEnum
:
"ACCOUTING"
,
// 服务类型:枚举型,包括ACCOUTING-记账服务、INDUSTRY_COMMERCE-工商服务、BOTH-记账与工商服务。
taxNo
:
findService
.
companyInfo
.
taxpayerNumber
,
// 税号
accountantEmployeeId
:
findService
.
accountantAgentAccountId
,
//所属会计 易代账ID
taxClaimMethodEnum
:
"TAX_DECLARATION"
,
//申报方式:TAX_DECLARATION-税款申报;ZERO_DECLARATION-零申报;
isBuild
:
true
,
//是否建账
accountBook
:
{
name
:
`gsb_
${
findService
.
bizId
}
`
,
//账套名称
acctgSystemId
:
findService
.
companyInfo
.
acctgSystemId
,
//会计制度;包括:10001=2013小企业会计准则;10002=2007企业会计准则;10003=民间非营利组织会计制度;10004=工会会计制度
openingPeriod
:
moment
().
year
(),
//开账期间
taxpayerTypeEnum
:
findService
.
taxpayerType
,
//纳税性质,枚举包括:NORMAL_TAXPAYER=一般纳税人;SMALL_TAXPAYER=小规模纳税人
acctgTransGroupEnum
:
'ACCTG'
//凭证类别,枚举包括:ACCTG=记账凭证等;RECEIPT_PAYMENT_TRANSFER=收付转凭证
}
}
let
setData
=
{};
setData
.
accountBook
=
{};
for
(
let
key
in
findService
.
companyInfo
)
{
setData
[
key
]
=
findService
.
companyInfo
[
key
];
if
(
key
==
'acctgSystemId'
||
key
==
'taxpayerTypeEnum'
)
{
setData
.
accountBook
[
key
]
=
findService
.
companyInfo
[
key
];
}
}
setData
.
custName
=
findService
.
companyInfo
.
corpName
;
//客户名称
setData
.
accountantEmployeeId
=
findService
.
accountantAgentAccountId
;
//所属会计 易代账ID
setData
.
isBuild
=
true
;
setData
.
accountBook
.
name
=
findService
.
companyInfo
.
corpName
;
//账套名称
setData
.
accountBook
.
openingPeriod
=
`
${
moment
().
year
()}${
moment
().
month
()
+
1
}
`
;
//开账期间 当年当月,格式是 “YYYYMM”
return
setData
;
}
mappingSetToQiFuTong
(
setInfo
,
findService
)
{
let
toQFTSetData
=
{
bizId
:
findService
.
bizId
,
subjec
tId
:
setInfo
.
custId
,
cus
tId
:
setInfo
.
custId
,
bookId
:
setInfo
.
assocTenantId
,
bkDomainName
:
setInfo
.
bkDomainName
,
contactName
:
setInfo
.
customer
.
contact
Name
,
contactName
:
findService
.
companyInfo
.
company
Name
,
contactMobile
:
setInfo
.
customer
.
contactMobile
,
timeUnit
:
findService
.
timeUnit
,
quantity
:
findService
.
quantity
,
...
...
icp-deliver/app/base/utils/ydzClient.js
View file @
e0513e66
...
...
@@ -2,6 +2,7 @@ const axios = require("axios");
const
settings
=
require
(
"../../config/settings"
);
const
system
=
require
(
"../system"
);
const
ydzUrl
=
settings
.
ydzUrl
();
const
redisClient
=
system
.
getObject
(
"util.redisClient"
);
/**
* 请求易代账
...
...
@@ -10,27 +11,20 @@ const ydzUrl = settings.ydzUrl();
const
pushYiDaZhang
=
async
(
data
=
{})
=>
{
const
{
appKey
,
appSecret
}
=
settings
.
ydzKey
();
// const openToken = await getOpenTokenByAppKey(appKey, appSecret);
const
openToken
=
JSON
.
parse
(
await
redisClient
.
get
(
'ydzToken'
)).
access_token
;
console
.
log
(
'----------------------------open-----------------------'
);
console
.
log
(
openToken
);
const
header
=
{
"Content-Type"
:
"application/json"
,
"appKey"
:
appKey
,
"appSecret"
:
appSecret
,
"openToken"
:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NfdG9rZW4iOiJlYzQ4OTFjZS05OWIzLTQzNjAtYjMyMi04MzUyOWMxMGQ5ZjQiLCJzdWIiOiJpc3YiLCJhdWQiOiJpc3YiLCJuYmYiOjE2MDQ5NzgzOTksImFwcElkIjoiMTA2NSIsInNjb3BlIjoiYXV0aF9hbGwiLCJpc3MiOiJjaGFuamV0IiwiZXhwIjoxNjA1NDk2Nzk5LCJ1c2VySWQiOiI2MTAwMDQzMjU3NSIsImlhdCI6MTYwNDk3ODM5OSwib3JnSWQiOiI5MDAwMTIwNTYyNSIsIm9yZ0FjY291bnQiOiJ1MzEzbWN2czR5d2EifQ.gPpIvM75vL39RrcNNW3jWMw28z-5nj0JNOyHjA8LvGI"
"openToken"
:
openToken
}
const
manageId
=
await
getManageIdByOpenToken
(
header
);
const
pushYDZResult
=
await
postRequest
(
`
${
ydzUrl
}
/ydz/easyacctg/customer/create/
${
manageId
}
`
,
data
,
header
);
return
pushYDZResult
;
}
const
getOpenTokenByAppKey
=
async
(
appKey
,
appSecret
)
=>
{
const
data
=
await
this
.
postRequest
(
`
${
ydzUrl
}
/api/opreceive/accessAuth/getAppTokenByAppKey`
,
{
"Content-Type"
:
"application/json"
,
"appKey"
:
appKey
,
"appSecret"
:
appSecret
});
return
data
.
token
}
const
getManageIdByOpenToken
=
async
(
headers
)
=>
{
const
url
=
`
${
ydzUrl
}
/ydz/setup/openAccess/MainTenant/findMainTenant`
const
rs
=
await
getRequest
(
url
,
{},
headers
);
...
...
@@ -69,7 +63,7 @@ const postRequest = async(url, data, headers = {}) => {
}
}
catch
(
err
)
{
console
.
log
(
`
${
url
}
: 返回错误信息 ------- `
);
console
.
log
(
err
)
console
.
log
(
err
)
;
throw
(
err
)
}
}
...
...
@@ -85,7 +79,7 @@ const getRequest = async(url, data, headers = {}) => {
return
res
.
data
;
}
catch
(
err
)
{
console
.
log
(
`
${
url
}
: 返回错误信息 ------- `
);
console
.
log
(
err
)
console
.
log
(
err
)
;
throw
(
err
)
}
}
...
...
@@ -93,7 +87,6 @@ const getRequest = async(url, data, headers = {}) => {
module
.
exports
=
{
pushYiDaZhang
,
getManageIdByOpenToken
,
// getAppTokenByAppKey,
postRequest
,
getRequest
}
\ 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