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
f94a386a
Commit
f94a386a
authored
Jan 10, 2020
by
庄冰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pay
parent
564fd580
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
245 additions
and
1 deletions
+245
-1
igirl-channel/app/base/api/impl/action/tmOrder.js
+3
-0
igirl-channel/app/base/db/cache/ZxPayLocker.js
+28
-0
igirl-channel/app/base/service/impl/dborder/orderSve.js
+214
-1
No files found.
igirl-channel/app/base/api/impl/action/tmOrder.js
View file @
f94a386a
...
...
@@ -248,6 +248,9 @@ class TmOrderAPI extends APIBase {
case
"subGsbOrderInfo"
:
//提交公司宝订单信息
opResult
=
await
this
.
orderSve
.
gsbOrderInfo
(
pobj
,
req
);
break
;
case
"checkPayStatusTl"
:
//检查通联支付状态
opResult
=
await
this
.
orderSve
.
checkPayStatusTl
(
action_body
);
break
;
default
:
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
break
;
...
...
igirl-channel/app/base/db/cache/ZxPayLocker.js
0 → 100644
View file @
f94a386a
const
CacheBase
=
require
(
"../cache.base"
);
const
system
=
require
(
"../../system"
);
const
settings
=
require
(
"../../../config/settings"
);
class
ZxPayLocker
extends
CacheBase
{
constructor
()
{
super
();
this
.
prefix
=
"zxPayLocker:"
;
}
desc
()
{
return
"应用中缓存访问token"
;
}
prefix
()
{
return
"zxPayLocker:"
;
}
async
init
(
tradekey
)
{
const
key
=
this
.
prefix
+
tradekey
;
return
this
.
redisClient
.
rpushWithEx
(
key
,
"1"
,
1800
);
}
async
enter
(
tradekey
)
{
const
key
=
this
.
prefix
+
tradekey
;
return
this
.
redisClient
.
rpop
(
key
);
}
async
release
(
tradekey
)
{
const
key
=
this
.
prefix
+
tradekey
;
return
this
.
redisClient
.
rpushWithEx
(
key
,
"1"
,
1800
);
}
}
module
.
exports
=
ZxPayLocker
;
igirl-channel/app/base/service/impl/dborder/orderSve.js
View file @
f94a386a
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
const
settings
=
require
(
"../../../../config/settings"
);
class
OrderService
extends
ServiceBase
{
constructor
()
{
super
(
"dborder"
,
ServiceBase
.
getDaoName
(
OrderService
));
...
...
@@ -14,6 +13,7 @@ class OrderService extends ServiceBase {
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
fqReqUrl
=
"https://yunfuapi.gongsibao.com"
;
//线上域名
// this.fqReqUrl = "https://yunfuapi-dev.gongsibao.com";//dev域名
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
}
async
addOrderAndDelivery
(
action_body
,
pobj
,
req
)
{
...
...
@@ -752,5 +752,217 @@ class OrderService extends ServiceBase {
});
}
}
//-------------------------通联支付------start---------------------------------------------------------
//获取center-channel token
async
getCenterChannelToken
(
app
){
var
pobj
=
{
"actionType"
:
"getAppTokenByHosts"
,
"actionBody"
:{
"appkey"
:
app
.
uappKey
,
"secret"
:
app
.
appSecret
}
};
var
url
=
settings
.
centerChannelUrl
()
+
"web/auth/accessAuth/getAppTokenByHosts"
;
var
rtn
=
await
this
.
restClient
.
execPost
(
pobj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPost is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
}
async
getTlPayQrCode
(){
}
async
checkPayStatusTl
(
obj
)
{
//通联支付状态验证
var
wxPayOrderCode
=
obj
.
wxPayOrderCode
||
""
;
var
aliPayOrderCode
=
obj
.
aliPayOrderCode
||
""
;
var
app
=
obj
.
app
;
if
(
!
app
){
return
system
.
getResultFail
(
-
100
,
"渠道参数错误"
);
}
var
comanyId
=
app
.
uAppId
;
var
opType
=
obj
.
op_type
;
var
orderCode
=
obj
.
orderCode
;
if
(
!
wxPayOrderCode
||
!
aliPayOrderCode
||
!
comanyId
||
!
opType
||
!
orderCode
)
{
return
system
.
getResultFail
(
-
101
,
"参数错误"
);
}
var
orderInfo
=
await
this
.
dao
.
model
.
findOne
({
where
:{
orderNo
:
orderCode
,
app_id
:
app
.
id
},
raw
:
true
});
if
(
!
orderInfo
)
{
return
system
.
getResultFail
(
-
102
,
"订单数据不存在"
);
}
if
(
orderInfo
.
orderPayStatus
==
"yfk"
)
{
return
system
.
getResultSuccess
({
orderPayStatus
:
"yfk"
});
}
var
payTrxid
=
opType
==
"wx"
?
wxPayOrderCode
:
aliPayOrderCode
;
var
opComanyId
=
comanyId
;
var
payStatus
=
await
this
.
queryTlPayOrder
(
app
,
payTrxid
);
//查询通联支付状态
if
(
payStatus
&&
payStatus
.
status
==
0
&&
payStatus
.
data
&&
payStatus
.
data
.
trxstatus
==
"0000"
)
{
payStatus
.
data
.
client_ip
=
obj
.
client_ip
||
""
;
let
attachList
=
[];
if
(
payStatus
.
data
.
reqsn
.
indexOf
(
"_"
)
>=
0
)
{
attachList
=
payStatus
.
data
.
reqsn
.
split
(
"_"
);
}
else
{
attachList
.
push
(
payStatus
.
data
.
reqsn
);
}
if
(
attachList
.
length
!=
2
)
{
return
system
.
getResultFail
(
-
103
,
"reqsn参数错误,没有_标识"
);
}
payStatus
.
data
.
out_trade_no
=
attachList
[
0
];
payStatus
.
data
.
company_id
=
attachList
[
1
];
//修改并返回订单支付状态,创建收款单
return
await
this
.
opBackNotify
(
payStatus
.
data
,
"queryTlPayOrder面回调"
,
app
);
}
else
if
(
payStatus
&&
payStatus
.
code
==
1
&&
payStqueryTlPayOrders
.
data
.
trxstatus
==
"3045"
)
{
return
system
.
getResultFail
(
-
104
,
"超时未支付,queryTlPayOrder新页面"
);
}
return
system
.
getResultFail
(
-
104
,
"请及时支付"
);
}
//查询通联支付订单
async
queryTlPayOrder
(
app
,
payTrxid
){
var
token
=
""
;
var
tokenRes
=
await
this
.
getCenterChannelToken
(
app
);
if
(
tokenRes
&&
tokenRes
.
status
==
0
&&
tokenRes
.
data
){
token
=
tokenRes
.
data
.
token
;
}
if
(
!
token
){
return
system
.
getResultFail
(
-
99
,
"获取token失败"
);
}
var
url
=
settings
.
centerChannelUrl
()
+
"web/payment/paymentApi/springBoard"
;
var
pobj
=
{
"actionType"
:
"queryOrder"
,
"actionBody"
:
{
"uapp_id"
:
app
.
uAppId
,
"trxid"
:
payTrxid
}
};
var
rtn
=
await
this
.
execClient
.
execPushDataPost
(
pobj
,
url
,
token
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPost is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
}
//操作回调业务逻辑
async
opBackNotify
(
getParams
,
opDesc
,
app
)
{
try
{
//日志记录
this
.
logCtl
.
info
({
op
:
"igirl-channel/app/base/service/impl/dborder/orderSve/opBackNotify"
,
content
:
JSON
.
stringify
(
getParams
),
clientIp
:
getParams
.
client_ip
||
""
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
":支付回调信息====="
+
opDesc
+
",method="
+
getParams
.
trxcode
});
//获取充值业务锁
var
locker
=
await
this
.
cacheManager
[
"ZxPayLocker"
].
enter
(
getParams
.
trxid
);
if
(
locker
&&
locker
==
"1"
)
{
if
(
getParams
.
trxcode
==
"VSP501"
)
{
getParams
.
req_accountType
=
"wx"
;
}
else
{
getParams
.
req_accountType
=
"alipay"
;
}
return
await
this
.
notifyOpDb
(
getParams
,
app
);
}
else
{
// await this.cacheManager["ZxPayLocker"].release(getParams.trxid);//---测试时放开
this
.
logCtl
.
info
({
appid
:
app
.
id
,
appkey
:
app
.
uappKey
,
op
:
"igirl-channel/app/base/service/impl/dborder/orderSve/opBackNotify"
,
content
:
"参数="
+
JSON
.
stringify
(
getParams
),
clientIp
:
getParams
.
client_ip
||
""
,
optitle
:
"通联回调操作频繁---太频繁了,太频繁了"
});
return
system
.
getResultFail
(
-
200
,
"中信回调操作频繁---太频繁了,太频繁了"
);
}
}
catch
(
e
)
{
await
this
.
cacheManager
[
"ZxPayLocker"
].
release
(
getParams
.
trxid
);
throw
new
Error
(
e
.
stack
);
}
}
/*
返回值:
-430:对应的业务支付订单号暂无
-450:对应的订单支付金额不符
-480:订单状态有误
其余为事务处理会抛出异常
*/
async
notifyOpDb
(
obj
,
app
)
{
var
accountType
=
"other"
;
if
(
obj
.
req_accountType
==
"wx"
)
{
accountType
=
"wx"
;
}
if
(
obj
.
req_accountType
==
"alipay"
)
{
accountType
=
"alipay"
;
}
var
account_type_list
=
uiconfig
.
config
.
pdict
.
accountType
;
var
account_type_name
=
account_type_list
[
obj
.
req_accountType
];
obj
.
account_type_name
=
account_type_name
;
var
sqlWheres
=
{
orderNo
:
obj
.
out_trade_no
,
app_id
:
app
.
id
};
var
orderItem
=
await
this
.
dao
.
model
.
findOne
({
where
:
sqlWheres
,
raw
:
true
});
if
(
!
orderItem
)
{
return
system
.
getResultFail
(
-
430
,
"对应的业务支付订单号暂无"
);
}
if
(
Number
(
orderItem
.
totalSum
*
100
)
!=
Number
(
obj
.
trxamt
))
{
return
system
.
getResultFail
(
-
450
,
"对应的订单支付金额不符"
);
}
if
(
orderItem
.
orderPayStatus
!=
"dfk"
)
{
return
system
.
getResultFail
(
-
480
,
"订单状态有误"
);
}
var
self
=
this
;
await
this
.
db
.
transaction
(
async
function
(
t
)
{
// 订单付款状态dfk: 待付款, zfpz: 已上传支付凭证, yfk: 已付款, ddqx: 订单取消, tkclz: 退款处理中, bfytk: 部分已退款, ytk: 已退款,zfshbtg:支付审核不通过
var
putParams
=
{
orderPayStatus
:
"yfk"
,
payDate
:
obj
.
fintime
};
await
self
.
orderDao
.
updateByWhere
(
putParams
,
{
where
:
sqlWheres
},
t
);
//订单流程log
self
.
orderflowDao
.
create
({
app_id
:
app
.
id
,
isShow
:
1
,
createuser_id
:
orderItem
.
createuser_id
,
sourceOrderNo
:
orderItem
.
orderNo
,
opContent
:
"订单已成功支付,方式为"
+
account_type_name
,
},
t
);
//帐户类型( 支付类型):cash: 现金, bank: 银行 ,wx:微信,alipay:支付宝,other:其它
var
orderReceiptVoucherObj
=
{
uapp_id
:
app
.
uAppId
,
sourceOrderNo
:
orderItem
.
orderNo
,
// 来源单号
accountType
:
accountType
,
payDate
:
obj
.
fintime
,
//支付时间
totalSum
:
orderItem
.
totalSum
,
//订单总额
wxPayOrderCode
:
obj
.
trxid
,
//业务微信支付订单号
aliPayOrderCode
:
obj
.
trxid
,
//业务支付宝支付订单号
busPayOrderCode
:
obj
.
trxid
,
//业务支付订单号
auditStatus
:
"tg"
};
var
orderReceiptVoucher
=
await
self
.
orderReceiptVoucherDao
.
create
(
orderReceiptVoucherObj
,
t
);
var
resdata
=
{
"busPayOrderCode"
:
obj
.
trxid
,
"code"
:
orderItem
.
orderNo
,
"app_id"
:
app
.
id
,
"sveItemCode"
:
orderItem
.
itemCode
,
"sveItemName"
:
orderItem
.
itemName
,
"totalSum"
:
orderItem
.
totalSum
,
"orderPayStatus"
:
"yfk"
,
}
return
system
.
getResultSuccess
(
resdata
);
});
}
//-------------------------通联支付------end---------------------------------------------------------
}
module
.
exports
=
OrderService
;
// var task = new OrderService();
// var app={
// id:2,uappKey:"201911131657",uAppId:9,appSecret:"eeb18393aade40149287b024d8ba0850"
// };
// task.queryTlPayOrder(app,"112094120001042656").then(d=>{
// console.log(d,"result----------------------------------");
// })
\ 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