Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wenHuaBu_adminServer
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
node_server
wenHuaBu_adminServer
Commits
2e762403
Commit
2e762403
authored
Mar 19, 2024
by
lixinming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
e9189687
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
49 deletions
+44
-49
cost.ts
src/biz/member/cost.ts
+30
-48
enum.ts
src/config/enum.ts
+10
-0
errorEnum.ts
src/config/errorEnum.ts
+3
-1
model.ts
src/data/models/model.ts
+1
-0
No files found.
src/biz/member/cost.ts
View file @
2e762403
...
...
@@ -2,17 +2,16 @@
* 收费
*/
import
{
ORDERSTATE
,
PAYMENTTYPE
}
from
"../../config/enum"
;
import
{
ORDERSTATE
,
PAYMENTTYPE
,
WEICHARTPAYSTATE
}
from
"../../config/enum"
;
import
{
TABLEENUM
}
from
"../../data/models/model"
;
import
{
findOnce
}
from
"../../data/select"
;
import
{
eccEnumValue
}
from
"../../util/verificationEnum"
;
import
{
update
}
from
"../portal/fenZhiJiGou/jiGouGuanLi"
;
import
*
as
path
from
"path"
;
const
WxPay
=
require
(
'wechatpay-node-v3'
);
import
*
as
fs
from
'fs'
;
import
{
BizError
}
from
"../../util/bizError"
;
import
{
ERRORENUM
}
from
"../../config/errorEnum"
;
import
{
generateWXOrderId
}
from
"../../tools/system"
;
import
{
generateWXOrderId
,
successResult
}
from
"../../tools/system"
;
import
{
updateOneData
}
from
"../../data/update"
;
import
moment
=
require
(
"moment"
);
...
...
@@ -34,13 +33,14 @@ const pay = new WxPay({
export
async
function
placeAnOrder
({
id
})
{
let
orderInfo
=
await
findOnce
(
TABLEENUM
.
订单表
,
{
id
},
[
"id"
,
"loginId"
,
"userId"
,
"memberCategory"
,
"money"
,
"orderCycleStart"
,
"orderCycleEnd"
]);
if
(
!
orderInfo
||
!
orderInfo
.
id
)
throw
new
BizError
(
ERRORENUM
.
订单不存在
);
if
(
orderInfo
.
state
!=
ORDERSTATE
.
已支付
)
throw
new
BizError
(
ERRORENUM
.
该订单已支付
);
if
(
orderInfo
.
state
==
ORDERSTATE
.
已支付
)
throw
new
BizError
(
ERRORENUM
.
该订单已支付
);
if
(
orderInfo
.
weChartState
!=
WEICHARTPAYSTATE
.
未提交
)
throw
new
BizError
(
ERRORENUM
.
该订单正在支付
);
/**生成 out_trade_no */
let
out_trade_no
=
generateWXOrderId
(
orderInfo
.
memberCategory
,
orderInfo
.
userId
);
let
desc
=
`
${
orderInfo
.
loginId
}
_
${
moment
(
orderInfo
.
orderCycleStart
).
format
(
"YYYY-MM-DD"
)}
至
${
moment
(
orderInfo
.
orderCycleEnd
).
format
(
"YYYY-MM-DD"
)}
`
;
await
updateOneData
(
TABLEENUM
.
订单表
,
{
id
},
{
weChartPR
:
out_trade_no
,
paymentMethod
:
PAYMENTTYPE
.
微信支付
});
await
updateOneData
(
TABLEENUM
.
订单表
,
{
id
},
{
weChartPR
:
out_trade_no
,
paymentMethod
:
PAYMENTTYPE
.
微信支付
,
weChartState
:
WEICHARTPAYSTATE
.
未支付
});
/**请求参数 */
const
Param
=
{
appid
:
AppId
,
...
...
@@ -54,62 +54,44 @@ export async function placeAnOrder({id}) {
};
const
result
=
await
pay
.
transactions_native
(
Param
);
if
(
result
.
status
!=
200
)
throw
new
BizError
(
ERRORENUM
.
调起微信支付失败
);
return
{
code_url
:
result
.
code_url
};
return
{
code_url
:
result
.
code_url
,
weChartPR
:
out_trade_no
};
}
/**
* 订单查询状态【前端调用】
*/
export
async
function
orderState
({
orderId
})
{
const
result
=
await
pay
.
query
({
out_trade_no
:
'1609914303237'
});
export
async
function
orderState
({
id
,
weChartPR
})
{
let
orderInfo
=
await
findOnce
(
TABLEENUM
.
订单表
,
{
id
,
weChartPR
},
[
"id"
]);
if
(
!
orderInfo
||
!
orderInfo
.
id
)
throw
new
BizError
(
ERRORENUM
.
订单不存在
);
if
(
orderInfo
.
state
==
ORDERSTATE
.
已支付
)
{
return
{
state
:
WEICHARTPAYSTATE
.
已支付
,
msg
:
"已支付"
};
//已支付
}
const
result
=
await
pay
.
query
({
out_trade_no
:
weChartPR
});
if
(
result
.
status
!=
200
&&
result
.
status
!=
204
)
throw
new
BizError
(
ERRORENUM
.
查看微信支付状态失败
);
if
(
result
.
trade_state
==
'CLOSED'
)
{
await
updateOneData
(
TABLEENUM
.
订单表
,
{
id
},
{
weChartState
:
WEICHARTPAYSTATE
.
未支付
});
return
{
state
:
WEICHARTPAYSTATE
.
未提交
,
msg
:
"订单已关闭"
};
}
return
{
state
:
WEICHARTPAYSTATE
.
未支付
,
msg
:
result
.
trade_state_desc
};
}
/**
* 关闭订单【前端调用】
*/
export
async
function
orderClose
()
{
}
// var initConfig = {
// partnerKey: "<partnerkey>",
// appId: "<appid>",
// mchId: "<mchid>",
// notifyUrl: "<notifyurl>",
// pfx: fs.readFileSync("<location-of-your-apiclient-cert.p12>")
// };
// var payment = new Payment(initConfig);
// /**
// * 订单列表
// * @param param0
// */
// export async function orderList({userId}) {
// }
// /**发起支付接口 */
// /**支付状态更新接口 给微信用 */
// /**订单状态查询 */
export
async
function
orderClose
({
id
,
weChartPR
})
{
let
orderInfo
=
await
findOnce
(
TABLEENUM
.
订单表
,
{
id
,
weChartPR
},
[
"id"
]);
if
(
!
orderInfo
||
!
orderInfo
.
id
)
throw
new
BizError
(
ERRORENUM
.
订单不存在
);
await
pay
.
close
(
weChartPR
);
/**
* 发起支付
* @param param0
*/
export
async
function
initiationPay
({
userId
,
id
,
paymentType
})
{
eccEnumValue
(
"发起支付"
,
"支付方式"
,
PAYMENTTYPE
,
paymentType
);
await
updateOneData
(
TABLEENUM
.
订单表
,
{
id
},
{
weChartState
:
WEICHARTPAYSTATE
.
未支付
});
if
(
id
==
PAYMENTTYPE
.
线下支付
)
{
return
successResult
();
}
}
else
{
//线上支付
let
orderInfo
=
await
findOnce
(
TABLEENUM
.
订单表
,
{
id
});
/**清除微信支付订单 */
// await update(TABLEENUM);
}
}
\ No newline at end of file
// export async function
\ No newline at end of file
src/config/enum.ts
View file @
2e762403
...
...
@@ -540,4 +540,13 @@ export enum ADMINLV {
会费管理
,
发票管理
,
权限管理
}
/**
* 微信支付状态
*/
export
enum
WEICHARTPAYSTATE
{
未提交
=
0
,
未支付
,
已支付
}
\ No newline at end of file
src/config/errorEnum.ts
View file @
2e762403
...
...
@@ -37,10 +37,12 @@ export enum ERRORENUM {
该用户已在宽限期内
,
该订单已支付
,
调起微信支付失败
,
查看微信支付状态失败
,
订单不存在
,
发票已开具不可重复提交
,
请求已被退回请重新申请
,
不满足重新请求条件
不满足重新请求条件
,
该订单正在支付
,
}
export
enum
ERRORCODEENUM
{
...
...
src/data/models/model.ts
View file @
2e762403
...
...
@@ -449,6 +449,7 @@ const ModelArray = [
offlinePaymentUrl
:{
type
:
'String'
,
default
:
""
},
//转账图片
memberCategory
:
'Number'
,
//会员类别 枚举 MEMBERTYPE
weChartPR
:{
type
:
'String'
,
default
:
""
},
//微信订单号 微信支付用
weChartState
:
'Number'
,
//微信支付状态 WEICHARTPAYSTATE
// membershipFeesType:'Number',//会费类别 枚举
invoiceAdd
:
'String'
,
//发票图片地址
isFirst
:{
type
:
'Boolean'
,
default
:
true
},
//首次订单
...
...
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