Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
V
volunteer_service
Project
Project
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
licc
volunteer_service
Commits
91921606
Commit
91921606
authored
Apr 01, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化查询方案
parent
6e0b4a2b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
151 additions
and
3 deletions
+151
-3
SchemeServiceImpl.java
...java/cn/wisenergy/service/app/impl/SchemeServiceImpl.java
+3
-3
SubCodeUtil.java
.../src/main/java/cn/wisenergy/service/util/SubCodeUtil.java
+35
-0
TestWxPayController.java
...senergy/web/admin/controller/app/TestWxPayController.java
+113
-0
No files found.
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/SchemeServiceImpl.java
View file @
91921606
...
...
@@ -232,6 +232,9 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
list
=
getVolunteerList
(
list
,
totalResult
);
}
//排序
list
.
sort
(
Comparator
.
comparing
(
Volunteer:
:
getLowestMark
).
reversed
());
//5判断是否展示全部方案
if
(
queryVo
.
getIsShowAll
()
==
0
)
{
List
<
Volunteer
>
result
;
...
...
@@ -243,7 +246,6 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
volunteerVo
.
setUserId
(
user
.
getId
());
//设置查询时间
SetQueryTime
(
result
);
result
.
sort
(
Comparator
.
comparing
(
Volunteer:
:
getLowestMark
).
reversed
());
volunteerVo
.
setVolunteers
(
result
);
return
R
.
ok
(
volunteerVo
);
}
...
...
@@ -254,8 +256,6 @@ public class SchemeServiceImpl extends ServiceImpl<SchemeMapper, SchemeInfo> imp
return
R
.
error
(
bool
.
getMessage
());
}
//排序
list
.
sort
(
Comparator
.
comparing
(
Volunteer:
:
getLowestMark
).
reversed
());
volunteerVo
.
setUserId
(
user
.
getId
());
assert
bool
!=
null
;
volunteerVo
.
setRecordId
(
bool
.
getData
());
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/util/SubCodeUtil.java
0 → 100644
View file @
91921606
package
cn
.
wisenergy
.
service
.
util
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
* @author 86187
*/
public
class
SubCodeUtil
{
/**
* 获取现在时间
* @return返回字符串格式yyyyMMddHHmmss
*/
public
static
String
getStringDate
()
{
Date
currentTime
=
new
Date
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
String
dateString
=
formatter
.
format
(
currentTime
);
System
.
out
.
println
(
"TIME:::"
+
dateString
);
return
dateString
;
}
/**
* 由年月日时分秒+3位随机数
* 生成流水号
* @return
*/
public
static
String
getNum
(){
String
t
=
getStringDate
();
int
x
=(
int
)(
Math
.
random
()*
900
)+
100
;
String
serial
=
t
+
x
;
return
serial
;
}
}
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/TestWxPayController.java
0 → 100644
View file @
91921606
package
cn
.
wisenergy
.
web
.
admin
.
controller
.
app
;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.service.util.SubCodeUtil
;
import
cn.wisenergy.service.wxpay.WxCommon
;
import
com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse
;
import
com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult
;
import
com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult
;
import
com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest
;
import
com.github.binarywang.wxpay.config.WxPayConfig
;
import
com.github.binarywang.wxpay.exception.WxPayException
;
import
com.github.binarywang.wxpay.service.WxPayService
;
import
com.github.binarywang.wxpay.service.impl.WxPayServiceImpl
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.io.IOUtils
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
/**
* @author 86187
*/
@Api
(
tags
=
"测试微信支付-管理员登录"
)
@RestController
@RequestMapping
(
"/pay"
)
@Slf4j
public
class
TestWxPayController
{
/**
* 产生订单接口
*
* @param payType 支付类型
* @param id 支付信息id
* @return
* @throws WxPayException
*/
@RequestMapping
(
value
=
"/generatePay/{payType}/{id}"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
@ApiOperation
(
value
=
"微信统一下单接口1"
)
public
R
generatePay2
(
@ApiParam
(
required
=
true
)
@PathVariable
(
value
=
"payType"
)
String
payType
,
@ApiParam
(
required
=
true
)
@PathVariable
(
value
=
"id"
)
String
id
)
throws
WxPayException
{
String
tradeNo
=
SubCodeUtil
.
getNum
();
String
busId
=
"123131313"
;
Integer
fee
=
1
;
WxPayUnifiedOrderRequest
.
WxPayUnifiedOrderRequestBuilder
builder
=
WxPayUnifiedOrderRequest
.
newBuilder
();
WxPayUnifiedOrderRequest
request
=
builder
.
body
(
payType
)
.
totalFee
(
fee
).
outTradeNo
(
tradeNo
)
.
productId
(
"1000000123"
)
.
spbillCreateIp
(
"0.0.0.0"
)
.
tradeType
(
"NATIVE"
).
build
();
request
.
setSignType
(
"MD5"
);
WxPayService
wxPayService
=
getWxPayService
();
WxPayNativeOrderResult
o
=
wxPayService
.
createOrder
(
request
);
System
.
out
.
println
(
o
.
toString
());
return
R
.
ok
(
o
);
}
/**
* 接收支付返回的消息
*
* @param
*/
@RequestMapping
(
value
=
"/parseOrderNotifyResult"
,
method
=
RequestMethod
.
POST
)
@ApiOperation
(
value
=
"接收支付返回的消息"
)
@ResponseBody
public
String
parseOrderNotifyResult
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
System
.
out
.
println
(
"============支付回调开始"
);
try
{
String
xmlResult
=
IOUtils
.
toString
(
request
.
getInputStream
(),
request
.
getCharacterEncoding
());
WxPayService
wxPayService
=
getWxPayService
();
WxPayOrderNotifyResult
result
=
wxPayService
.
parseOrderNotifyResult
(
xmlResult
);
System
.
out
.
println
(
result
.
toString
());
// 结果正确
String
orderId
=
result
.
getOutTradeNo
();
String
tradeNo
=
result
.
getTransactionId
();
//String totalFee = WxPayBaseResult.feeToYuan(result.getTotalFee());
//自己处理订单的业务逻辑,需要判断订单是否已经支付过,否则可能会重复调用
System
.
out
.
println
(
"============支付回调结束"
);
return
WxPayNotifyResponse
.
success
(
"处理成功!"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"微信回调结果异常,异常原因{}"
+
e
.
getMessage
());
return
WxPayNotifyResponse
.
fail
(
e
.
getMessage
());
}
}
/**
* 加载配置文件,生成微信payservice对象
*
* @return
*/
private
WxPayService
getWxPayService
()
{
WxPayConfig
payConfig
=
new
WxPayConfig
();
String
app_id
=
"wx39c84a7da8e71c32"
;
String
mchid
=
"1605798036"
;
String
private_key
=
"yHG21lRpqil1X3fWG0VFytxFuXzxIpRd"
;
// payConfig.setAppId(WxCommon.APP_ID);
// payConfig.setMchId(WxCommon.MCHID);
// payConfig.setMchKey(WxCommon.PRIVATE_KEY);
payConfig
.
setAppId
(
app_id
);
payConfig
.
setMchId
(
mchid
);
payConfig
.
setMchKey
(
private_key
);
payConfig
.
setNotifyUrl
(
WxCommon
.
NOTIFY_URL
);
WxPayService
wxPayService
=
new
WxPayServiceImpl
();
wxPayService
.
setConfig
(
payConfig
);
return
wxPayService
;
}
}
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