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
e7dddb14
Commit
e7dddb14
authored
Dec 08, 2019
by
孙亚楠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dd
parent
3aabdf86
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
319 additions
and
47 deletions
+319
-47
.vscode/launch.json
+15
-0
xggsve-order/app/base/api/impl/op/action.js
+6
-3
xggsve-order/app/base/service/impl/order/iborderbaseSve.js
+44
-34
xggsve-order/app/base/service/impl/order/iborderdkSve.js
+243
-10
xggsve-order/app/base/utils/calInvoice.js
+11
-0
No files found.
.vscode/launch.json
0 → 100644
View file @
e7dddb14
{
//
使用
IntelliSense
了解相关属性。
//
悬停以查看现有属性的描述。
//
欲了解更多信息,请访问
:
https
:
//go.microsoft.com/fwlink/?linkid=
830387
"version"
:
"0.2.0"
,
"configurations"
:
[
{
"type"
:
"node"
,
"request"
:
"launch"
,
"name"
:
"启动程序"
,
"program"
:
"${workspaceFolder}/xggsve-order/main.js"
}
]
}
\ No newline at end of file
xggsve-order/app/base/api/impl/op/action.js
View file @
e7dddb14
...
@@ -40,15 +40,18 @@ class ActionAPI extends APIBase {
...
@@ -40,15 +40,18 @@ class ActionAPI extends APIBase {
var
opResult
=
null
;
var
opResult
=
null
;
switch
(
action_type
)
{
switch
(
action_type
)
{
// 订单
// 订单
case
"createOrder"
:
case
"createOrder"
:
//创建订单
opResult
=
await
this
.
iborderbaseSve
.
apiCreateOrder
(
action_body
);
opResult
=
await
this
.
iborderbaseSve
.
apiCreateOrder
(
action_body
);
break
;
break
;
case
"completedOrder"
:
case
"completedOrder"
:
//完善信息接口
opResult
=
await
this
.
iborderbaseSve
.
apiCompletedOrder
(
action_body
);
opResult
=
await
this
.
iborderbaseSve
.
apiCompletedOrder
(
action_body
);
break
;
break
;
case
"handling"
:
case
"handling"
:
//订单办理接口
opResult
=
await
this
.
iborderbaseSve
.
apiHandling
(
action_body
);
opResult
=
await
this
.
iborderbaseSve
.
apiHandling
(
action_body
);
break
;
break
;
case
"updPriceOrStatus"
:
//企服通 推送支付信息接口
opResult
=
await
this
.
iborderbaseSve
.
completedOrderInfo
(
action_body
);
break
;
case
"addOrder"
:
case
"addOrder"
:
opResult
=
await
this
.
iborderSve
.
apiAdd
(
action_body
);
opResult
=
await
this
.
iborderSve
.
apiAdd
(
action_body
);
break
;
break
;
...
...
xggsve-order/app/base/service/impl/order/iborderbaseSve.js
View file @
e7dddb14
...
@@ -31,34 +31,9 @@ class IborderbaseService extends ServiceBase {
...
@@ -31,34 +31,9 @@ class IborderbaseService extends ServiceBase {
*/
*/
async
apiCreateOrder
(
params
)
{
async
apiCreateOrder
(
params
)
{
this
.
trimObject
(
params
);
this
.
trimObject
(
params
);
// if(!params.productType){
// return system.getResult(null, `参数错误 产品类型错误`);
// }
// if(!params.productItems instanceof Array){
// return system.getResult(null, `参数错误 产品项目错误`);
// }
// if(!params.channelNo){
// return system.getResult(null, `参数错误 渠道名称错误`);
// }
if
(
!
params
.
thirdNo
)
{
if
(
!
params
.
thirdNo
)
{
return
system
.
getResult
(
null
,
`请传入订单id`
);
return
system
.
getResult
(
null
,
`请传入订单id`
);
}
}
// if(!Number(params.price)<0){
// return system.getResult(null, `参数错误 订单价格错误`);
// }
// if(!params.payType){
// return system.getResult(null, `参数错误 支付方式错误`);
// }
// if(!params.legalName){
// return system.getResult(null, `参数错误 联系人不能为空`);
// }
// if(!params.legalMobile){
// return system.getResult(null, `参数错误 联系电话不能为空`);
// }
// if(!params.invoiceType){
// return system.getResult(null, `参数错误 发票类型错误`);
// }
let
productType
=
this
.
trim
(
params
.
productTypes
);
let
productType
=
this
.
trim
(
params
.
productTypes
);
let
childSve
=
this
.
getService
(
productType
);
let
childSve
=
this
.
getService
(
productType
);
if
(
!
childSve
)
{
if
(
!
childSve
)
{
...
@@ -119,12 +94,6 @@ class IborderbaseService extends ServiceBase {
...
@@ -119,12 +94,6 @@ class IborderbaseService extends ServiceBase {
/**
/**
* 完善信息
* 完善信息
* @param {*} params
* @param {*} params
* legalName
* legalMobile
* names
* creditCode
* isBank
* businessScope
*/
*/
async
completedOrder
(
params
)
{
async
completedOrder
(
params
)
{
try
{
try
{
...
@@ -140,23 +109,64 @@ class IborderbaseService extends ServiceBase {
...
@@ -140,23 +109,64 @@ class IborderbaseService extends ServiceBase {
* @param {} params
* @param {} params
*/
*/
async
apiHandling
(
params
)
{
async
apiHandling
(
params
)
{
//1 检查个体户参数
try
{
//2 检查是否支付
let
childSve
=
this
.
getService
();
return
await
childSve
.
handling
(
params
);
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
}
/**
/**
* 更新base表
* 更新base表
* @param {*} params
* @param {*} params
* id //订单ID
* price //支付金额
* orderpayId //支付id
*/
*/
async
completedOrderInfo
(
params
,
t
)
{
async
completedOrderInfo
(
params
,
t
)
{
try
{
try
{
if
(
!
params
.
id
){
return
system
.
getResult
(
null
,
`参数错误 ID不能为空`
);
}
else
{
params
.
id
=
this
.
trim
(
params
.
id
);
}
if
(
params
.
price
<
0
){
return
system
.
getResult
(
null
,
`参数错误 支付金额非法`
);
}
else
{
params
.
price
=
Number
(
params
.
price
);
}
if
(
params
.
orderpayId
){
return
system
.
getResult
(
null
,
`参数错误 支付ID非法`
);
}
else
{
params
.
orderpay_id
=
orderpayId
;
}
let
_iborderbase
=
await
this
.
dao
.
findById
(
this
.
trim
(
params
.
id
));
if
(
!
_iborderbase
){
return
system
.
getResult
(
null
,
`订单不存在`
);
}
// 产品类型 1000注册订单 1010代开订单 1030代账订单
if
(
_iborderbase
.
productType
==
"1000"
){
// this.iborderdkSve.updateOrder()
return
system
.
getResult
(
null
,
`暂不支持 此类型商品`
);
}
else
if
(
_iborderbase
.
productType
==
"1010"
){
params
.
status
=
params
.
status
?
this
.
trim
(
params
.
status
):
"20"
;
await
this
.
iborderdkSve
.
updateOrder
(
params
);
}
else
if
(
_iborderbase
.
productType
==
"1030"
){
// this.iborderdkSve.updateOrder()
return
system
.
getResult
(
null
,
`暂不支持 此类型商品`
);
}
else
{
return
system
.
getResult
(
null
,
`当前订单类型不存在 请联系管理员`
);
}
return
await
this
.
dao
.
update
(
params
,
t
);
return
await
this
.
dao
.
update
(
params
,
t
);
}
catch
(
error
)
{
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
}
}
async
apiAdd
(
params
)
{
async
apiAdd
(
params
)
{
try
{
try
{
let
sve
=
this
.
getService
(
params
.
productType
);
let
sve
=
this
.
getService
(
params
.
productType
);
...
...
xggsve-order/app/base/service/impl/order/iborderdkSve.js
View file @
e7dddb14
...
@@ -2,7 +2,7 @@ const system = require("../../../system");
...
@@ -2,7 +2,7 @@ const system = require("../../../system");
const
ServiceBase
=
require
(
"../../sve.base"
)
const
ServiceBase
=
require
(
"../../sve.base"
)
const
settings
=
require
(
"../../../../config/settings"
)
const
settings
=
require
(
"../../../../config/settings"
)
const
moment
=
require
(
"moment"
);
const
moment
=
require
(
"moment"
);
const
calInvoice
=
require
(
"../../../utils/calInvoice"
);
class
IborderdkService
extends
ServiceBase
{
class
IborderdkService
extends
ServiceBase
{
constructor
()
{
constructor
()
{
super
(
"order"
,
ServiceBase
.
getDaoName
(
IborderdkService
));
super
(
"order"
,
ServiceBase
.
getDaoName
(
IborderdkService
));
...
@@ -46,15 +46,15 @@ class IborderdkService extends ServiceBase {
...
@@ -46,15 +46,15 @@ class IborderdkService extends ServiceBase {
* @param {*} params
* @param {*} params
* @param {*} t
* @param {*} t
*/
*/
async
updateOrder
(
params
,
t
)
{
async
updateOrder
(
params
,
t
)
{
try
{
try
{
if
(
!
params
.
id
)
{
if
(
!
params
.
id
)
{
return
system
.
getResult
(
null
,
`参数错误 ID 不能为空`
);
return
system
.
getResult
(
null
,
`参数错误 ID 不能为空`
);
}
}
this
.
trimObject
(
params
);
this
.
trimObject
(
params
);
return
await
this
.
dao
.
update
(
params
,
t
);
return
await
this
.
dao
.
update
(
params
,
t
);
}
catch
(
error
)
{
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
}
}
...
@@ -91,19 +91,23 @@ class IborderdkService extends ServiceBase {
...
@@ -91,19 +91,23 @@ class IborderdkService extends ServiceBase {
return
system
.
getResult
(
null
,
`参数错误 订单不存在`
);
return
system
.
getResult
(
null
,
`参数错误 订单不存在`
);
}
}
let
self
=
this
;
let
self
=
this
;
await
this
.
db
.
transaction
(
async
t
=>
{
//向参数中添加 是否完善信息标识
params
.
isInfoComplete
=
1
;
await
this
.
db
.
transaction
(
async
t
=>
{
//更新主表
//更新主表
await
self
.
iborderbaseDao
.
update
({
businessmen_id
:
self
.
trim
(
_businessmenRes
.
id
),
id
:
self
.
trim
(
params
.
id
)},
t
);
await
self
.
iborderbaseDao
.
update
({
businessmen_id
:
self
.
trim
(
_businessmenRes
.
id
),
id
:
self
.
trim
(
params
.
id
),
isInfoComplete
:
1
},
t
);
//更新子表
//更新子表
await
this
.
dao
.
update
(
params
,
t
);
await
this
.
dao
.
update
(
params
,
t
);
});
});
}
else
{
}
else
{
let
self
=
this
;
let
self
=
this
;
await
this
.
db
.
transaction
(
async
t
=>
{
await
this
.
db
.
transaction
(
async
t
=>
{
//如果不存在id 创建后更新
//如果不存在id 创建后更新
let
_businessment
=
await
this
.
businessmenDao
.
create
(
params
,
t
);
let
_businessment
=
await
this
.
businessmenDao
.
create
(
params
,
t
);
//更新主表
//更新主表
await
self
.
iborderbaseDao
.
update
({
businessmen_id
:
self
.
trim
(
_businessment
.
id
),
id
:
self
.
trim
(
params
.
id
)},
t
);
await
self
.
iborderbaseDao
.
update
({
businessmen_id
:
self
.
trim
(
_businessment
.
id
),
id
:
self
.
trim
(
params
.
id
),
isInfoComplete
:
1
},
t
);
//更新子表
//更新子表
await
this
.
dao
.
update
(
params
,
t
);
await
this
.
dao
.
update
(
params
,
t
);
});
});
...
@@ -113,6 +117,235 @@ class IborderdkService extends ServiceBase {
...
@@ -113,6 +117,235 @@ class IborderdkService extends ServiceBase {
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
}
}
/**
* 订单办理
* @param {} params
* businessmenId 个体户ID
* id 订单ID
*/
async
handing
(
params
)
{
try
{
//1 检查个体户是否签约
let
_businessmen
=
await
this
.
businessmenDao
.
findById
(
this
.
trim
(
params
.
businessmenId
));
if
(
!
_businessmen
.
signTime
)
{
return
system
.
getResult
(
null
,
`个体户未签约`
);
}
//2 检查是否支付
let
_iborderbase
=
await
this
.
iborderbaseDao
.
findById
(
this
.
trim
(
params
.
id
));
if
(
!
_iborderbase
.
payStatus
!=
"20"
)
{
return
system
.
getResult
(
null
,
`订单未支付`
);
}
//3 判断是按照年付费还是按照月付费
let
valueAddedTax
=
0
;
let
additionalTax
=
0
;
///**************************************************************** */
if
(
1
!=
1
){
//如果不是年付费 计算费用
let
invoiceParams
=
await
this
.
buildParamForCalInvoice
(
params
);
valueAddedTax
=
await
calInvoice
.
calculationValueAddedTax
(
invoiceParams
);
//填充 增值税参数
invoiceParams
.
valueAddedTax
=
valueAddedTax
;
additionalTax
=
await
calInvoice
.
calculationAdditionalTax
(
invoiceParams
);
//4 推送计算结果
}
else
{
//5 如果是不是按照年付款 直接更新订单金额
let
_arguments
=
{};
_arguments
.
price
=
Number
(
valueAddedTax
)
+
Number
(
additionalTax
);
let
updatePriceRes
=
await
this
.
updateOrder
(
_arguments
);
//6 提交发票申请
let
submitApplyInvoiceParams
=
await
this
.
buildParamForApplyInvoice
(
params
);
}
return
system
.
getResultSuccess
();
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
/**
* 创建计算发票所需的参数
*/
async
buildParamForCalInvoice
(
params
)
{
let
data
=
{
"businessmenCreditCode"
:
"111"
,
"businessmenType"
:
"10"
,
"calNames"
:
"valueAddedTax"
,
"valCalWay"
:
"1"
,
"businessmenId"
:
"12795594625000138"
,
"taxIncPriRat"
:
0.03
,
"invoiceTime"
:
"2019-11-26"
,
"invoiceAmount"
:
20000000
,
"perIncTaxRange"
:
[
{
"minValue"
:
0
,
"rate"
:
"5"
,
"quiCalDed"
:
0
,
"maxValue"
:
3000000
},
{
"minValue"
:
3000100
,
"rate"
:
"6"
,
"quiCalDed"
:
200000
,
"maxValue"
:
10000000
},
{
"minValue"
:
10000001
,
"rate"
:
"8"
,
"quiCalDed"
:
0
,
"maxValue"
:
214748364700
}
],
"valAddTaxRange"
:
[
{
"minValue"
:
0
,
"zengzhiRate"
:
"3"
,
"fujiaRate"
:
"12"
,
"maxValue"
:
3000000
},
{
"minValue"
:
3000100
,
"zengzhiRate"
:
"3"
,
"fujiaRate"
:
"15"
,
"maxValue"
:
10000000
},
{
"minValue"
:
10000001
,
"zengzhiRate"
:
"4"
,
"fujiaRate"
:
"16"
,
"maxValue"
:
214748364700
}
]
}
return
data
;
}
/**
* 创建申请发票所需的参数
* @param {*} params
*/
async
buildParamForApplyInvoice
(
params
){
let
data
=
{
"serviceRate"
:
4
,
"perCalWay"
:
"1"
,
"valCalWay"
:
"2"
,
"taxCostPriRat"
:
0.95
,
"taxIncPriRat"
:
1.50
,
"invoiceTime"
:
"2019-10-19"
,
"perIncTaxRange"
:
[
{
"minValue"
:
0
,
"rate"
:
"1"
,
"quiCalDed"
:
100000
,
"maxValue"
:
3000000
},
{
"minValue"
:
3000100
,
"rate"
:
"1.5"
,
"quiCalDed"
:
200000
,
"maxValue"
:
10000000
},
{
"minValue"
:
10000001
,
"rate"
:
"4.86"
,
"quiCalDed"
:
300000
,
"maxValue"
:
214748364700
}
],
"valAddTaxRange"
:
[
{
"minValue"
:
0
,
"zengzhiRate"
:
"1"
,
"fujiaRate"
:
"6"
,
"maxValue"
:
3000000
},
{
"minValue"
:
3000100
,
"zengzhiRate"
:
"2"
,
"fujiaRate"
:
"8"
,
"maxValue"
:
10000000
},
{
"minValue"
:
10000001
,
"zengzhiRate"
:
"3"
,
"fujiaRate"
:
"12"
,
"maxValue"
:
214748364700
}
],
"merchantId"
:
"11064622752480055"
,
"merchantAccount"
:
"driverBabyPublicAccount"
,
"merchantName"
:
"司机宝"
,
"merchantCreditCode"
:
"91110108MA008KB56P"
,
"merchantAddr"
:
"北京市海淀区北太平庄路18号3层3-0227"
,
"merchantMobile"
:
"010-5369854"
,
"merchantBank"
:
"110108022130868"
,
"businessmenId"
:
"110115023996882"
,
"businessmenCreditCode"
:
"91110115MA00HDC44L"
,
"businessName"
:
"北京富通勤国际贸易有限责任公司(个体工商)"
,
"isBank"
:
1
,
"taxAuthorities"
:
"北京大兴税务局"
,
"type"
:
20
,
"invoiceAmount"
:
4000000
,
"statements"
:
"wwww.baidu.com"
,
"contract"
:
"www.qq.com"
,
"applyNo"
:
"gongsibao-futong001"
,
"isInvalid"
:
2
,
"parentId"
:
null
,
"status"
:
"1000"
,
"customerStatus"
:
"1000"
,
"payWay"
:
"20"
,
"payAccount"
:
null
,
"isPay"
:
1
,
"mailAddr"
:
"北京市海淀区北太平庄路18号3层3-0227"
,
"mailMobile"
:
"18633923636"
,
"mailTo"
:
"赵彩红"
}
return
data
;
}
/**
* 更新订单金额 、订单的状态
* @param {*} params
* id 订单的ID
* price 订单的金额
* status 订单的状态
*/
async
updateOrder
(
params
){
try
{
if
(
!
params
.
id
){
return
system
.
getResult
(
null
,
`参数错误 ID不能为空`
);
}
let
_iborderbase
=
await
this
.
iborderbaseDao
.
findById
(
this
.
trim
(
params
.
id
));
if
(
!
_iborderbase
){
return
system
.
getResult
(
null
,
`订单不存在`
);
}
let
_iborderdk
=
await
this
.
_ibOrderDk
.
findById
(
this
.
trim
(
params
.
id
));
if
(
!
_iborderdk
){
return
system
.
getResult
(
null
,
`订单不存在`
);
}
let
updateDate
=
{};
if
(
params
.
status
){
updateDate
.
status
=
this
.
trim
(
params
.
status
);
}
if
(
params
.
price
){
updateDate
.
price
=
Number
(
params
.
price
||
0
);
}
let
self
=
this
;
let
res
=
await
this
.
dao
.
db
.
transaction
(
async
t
=>
{
//更新主表
await
self
.
_iborderbase
.
dao
.
update
(
updateDate
,
t
);
//更新子表
await
self
.
dao
.
update
(
updateDate
,
t
);
});
return
system
.
getResult
(
res
);
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
}
}
module
.
exports
=
IborderdkService
;
module
.
exports
=
IborderdkService
;
xggsve-order/app/base/utils/calInvoice.js
0 → 100644
View file @
e7dddb14
/**
* 计算发票费率
*/
module
.
exports
=
async
params
=>
{
//1 组装参数
//2 调用发票服务
}
\ 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