Skip to content

Commit 6d87da9

Browse files
committed
V1.4
1 parent 5b92e4f commit 6d87da9

File tree

6 files changed

+208
-5
lines changed

6 files changed

+208
-5
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ V免签 是基于SpringBoot 2.1.1 实现的一套免签支付程序,主要包
4545

4646
4747
## 更新记录
48+
49+
+ v1.4(2019.02.26)
50+
+ 增加订单删除功能
51+
+ 增加一键删除过期订单功能
52+
+ 增加一键删除7天前订单功能
53+
+ 增加PHP异步回调示例代码,请在 API说明->回调参数说明 中参考使用
54+
4855
+ v1.3(2019.02.25)
4956
+ 修复监控端安卓7.0以上系统监控App闪退问题
5057
+ 修复监控端检测服务状态无法正确检测是否正常问题

src/main/java/com/vone/mq/controller/AdminController.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,29 @@ public CommonRes getMain(HttpSession session){
172172
return adminService.getMain();
173173
}
174174

175+
@RequestMapping("/admin/delOrder")
176+
public CommonRes delOrder(HttpSession session,Long id){
177+
if (session.getAttribute("login")==null){
178+
return ResUtil.error("未登录");
179+
}
180+
181+
return adminService.delOrder(id);
182+
}
183+
184+
@RequestMapping("/admin/delGqOrder")
185+
public CommonRes delGqOrder(HttpSession session){
186+
if (session.getAttribute("login")==null){
187+
return ResUtil.error("未登录");
188+
}
189+
190+
return adminService.delGqOrder();
191+
}
192+
@RequestMapping("/admin/delLastOrder")
193+
public CommonRes delLastOrder(HttpSession session){
194+
if (session.getAttribute("login")==null){
195+
return ResUtil.error("未登录");
196+
}
197+
198+
return adminService.delLastOrder();
199+
}
175200
}

src/main/java/com/vone/mq/dao/PayOrderDao.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,15 @@ public interface PayOrderDao extends JpaRepository<PayOrder,Long>, JpaSpecifica
5252

5353
@Query(value = "select sum(price) from pay_order where state = ?1", nativeQuery = true)
5454
double getCountMoney(int state);
55+
56+
57+
@Transactional
58+
int deleteByState(int state);
59+
60+
61+
@Transactional
62+
@Modifying
63+
@Query(value = "delete from pay_order where create_date<?1", nativeQuery = true)
64+
int deleteByAfterCreateDate(String date);
65+
5566
}

src/main/java/com/vone/mq/service/AdminService.java

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,29 @@ public CommonRes getMain(){
192192
todaySuccessOrder += todaySuccessOrder2;
193193

194194
int todayCloseOrder = payOrderDao.getTodayCount(startDate,endDate,-1);//当日失败订单
195-
double todayMoney = payOrderDao.getTodayCountMoney(startDate,endDate,1);
196-
double todayMoney2 = payOrderDao.getTodayCountMoney(startDate,endDate,2);
195+
196+
double todayMoney;
197+
double todayMoney2;
198+
try {
199+
todayMoney = payOrderDao.getTodayCountMoney(startDate,endDate,1);
200+
todayMoney2 = payOrderDao.getTodayCountMoney(startDate,endDate,2);
201+
}catch (Exception e){
202+
todayMoney = 0;
203+
todayMoney2 = 0;
204+
}
205+
197206
todayMoney = Arith.add(todayMoney,todayMoney2);
198207

199208
int countOrder = payOrderDao.getCount(1);
200-
double countMoney = payOrderDao.getCountMoney(1);
201-
double countMoney2 = payOrderDao.getCountMoney(2);
209+
double countMoney;
210+
double countMoney2;
211+
try {
212+
countMoney = payOrderDao.getCountMoney(1);
213+
countMoney2 = payOrderDao.getCountMoney(2);
214+
}catch (Exception e){
215+
countMoney = 0;
216+
countMoney2 = 0;
217+
}
202218
countMoney = Arith.add(countMoney,countMoney2);
203219

204220

@@ -238,6 +254,21 @@ public CommonRes delPayQrcode(Long id){
238254
payQrcodeDao.deleteById(id);
239255
return ResUtil.success();
240256
}
257+
public CommonRes delOrder(Long id){
258+
payOrderDao.deleteById(id);
259+
return ResUtil.success();
260+
}
261+
public CommonRes delGqOrder(){
262+
payOrderDao.deleteByState(-1);
263+
return ResUtil.success();
264+
}
265+
266+
public CommonRes delLastOrder(){
267+
payOrderDao.deleteByAfterCreateDate(String.valueOf(new Date().getTime()-7*86400*1000));
268+
return ResUtil.success();
269+
}
270+
271+
241272
public static String md5(String text) {
242273
//加密后的字符串
243274
String encodeStr= DigestUtils.md5DigestAsHex(text.getBytes());

src/main/webapp/admin/orderlist.html

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,20 @@
3030
</div>
3131
</div>
3232

33+
<script type="text/html" id="toolbarDemo">
34+
<div class="layui-btn-container">
35+
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delGq">删除所有过期订单</button>
36+
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delLast">删除七天前订单</button>
3337

38+
</div>
39+
</script>
3440
<table id="demo" lay-filter="test"></table>
3541

3642
<script type="text/html" id="barDemo">
3743
<a class="layui-btn layui-btn-xs" lay-event="bd">补单</a>
3844
<a class="layui-btn layui-btn-xs" lay-event="info">详情</a>
45+
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
46+
3947
</script>
4048

4149

@@ -63,6 +71,7 @@
6371
elem: '#demo'
6472
,height: 'full-160'
6573
,url: '/admin/getOrders'
74+
,toolbar: '#toolbarDemo'
6675
,where: {
6776
state:$("#state").val(),
6877
type:$("#type").val()
@@ -146,6 +155,32 @@
146155

147156

148157

158+
});
159+
160+
console.log(data.id);
161+
});
162+
}else if(layEvent === 'del'){
163+
layer.confirm('确定要删除订单吗?', function(index){
164+
layer.msg('操作中', {
165+
icon: 16
166+
,shade: 0.01
167+
});
168+
169+
$.post("/admin/delOrder","id="+data.id,function (data) {
170+
if (data.code==1){
171+
layer.msg("操作成功!");
172+
myTable.reload({
173+
where: {
174+
state:$("#state").val(),
175+
type:$("#type").val()
176+
}
177+
});
178+
}else{
179+
layer.msg(data.msg);
180+
}
181+
182+
183+
149184
});
150185

151186
console.log(data.id);
@@ -172,6 +207,64 @@
172207

173208
});
174209

210+
211+
//头工具栏事件
212+
table.on('toolbar(test)', function(obj){
213+
var checkStatus = table.checkStatus(obj.config.id);
214+
switch(obj.event){
215+
case 'delGq':
216+
layer.confirm('确定要删除所有过期订单吗?', function(index){
217+
layer.msg('操作中', {
218+
icon: 16
219+
,shade: 0.01
220+
});
221+
222+
$.post("/admin/delGqOrder",function (data) {
223+
if (data.code==1){
224+
layer.msg("操作成功!");
225+
myTable.reload({
226+
where: {
227+
state:$("#state").val(),
228+
type:$("#type").val()
229+
}
230+
});
231+
}else{
232+
layer.msg(data.msg);
233+
}
234+
235+
});
236+
237+
});
238+
239+
break;
240+
case 'delLast':
241+
layer.confirm('确定要删除七天前的所有订单吗?', function(index){
242+
layer.msg('操作中', {
243+
icon: 16
244+
,shade: 0.01
245+
});
246+
247+
$.post("/admin/delLastOrder",function (data) {
248+
if (data.code==1){
249+
layer.msg("操作成功!");
250+
myTable.reload({
251+
where: {
252+
state:$("#state").val(),
253+
type:$("#type").val()
254+
}
255+
});
256+
}else{
257+
layer.msg(data.msg);
258+
}
259+
260+
});
261+
262+
});
263+
break;
264+
};
265+
});
266+
267+
175268
form.render();
176269

177270
});

src/main/webapp/api.html

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,8 +759,41 @@ <h2 class="layui-colla-title">回调参数说明</h2>
759759
</tbody>
760760
</table>
761761

762+
763+
762764
</blockquote>
763765

766+
<pre class="layui-code">
767+
768+
&lt;?php
769+
770+
ini_set(&quot;error_reporting&quot;,&quot;E_ALL &amp; ~E_NOTICE&quot;);
771+
772+
$key = &quot;83d551f0b3609781a22536ca2658473d&quot;;//通讯密钥
773+
774+
775+
$payId = $_GET[&#x27;payId&#x27;];//商户订单号
776+
$param = $_GET[&#x27;param&#x27;];//创建订单的时候传入的参数
777+
$type = $_GET[&#x27;type&#x27;];//支付方式 :微信支付为1 支付宝支付为2
778+
$price = $_GET[&#x27;price&#x27;];//订单金额
779+
$reallyPrice = $_GET[&#x27;reallyPrice&#x27;];//实际支付金额
780+
$sign = $_GET[&#x27;sign&#x27;];//校验签名,计算方式 = md5(payId + param + type + price + reallyPrice + 通讯密钥)
781+
782+
//开始校验签名
783+
$_sign = md5($payId . $param . $type . $price . $reallyPrice . $key);
784+
if ($_sign != $sign) {
785+
echo &quot;error_sign&quot;;//sign校验不通过
786+
exit();
787+
}
788+
789+
790+
echo &quot;success&quot;;
791+
//继续业务流程
792+
//echo &quot;商户订单号:&quot;.$payId .&quot;&lt;br&gt;自定义参数:&quot;. $param .&quot;&lt;br&gt;支付方式:&quot;. $type .&quot;&lt;br&gt;订单金额:&quot;. $price .&quot;&lt;br&gt;实际支付金额:&quot;. $reallyPrice;
793+
794+
?&gt;
795+
</pre>
796+
764797
</div>
765798
</div>
766799
</div>
@@ -775,9 +808,12 @@ <h2 class="layui-colla-title">回调参数说明</h2>
775808

776809

777810
<script>
778-
layui.use(['element'], function(){
811+
layui.use(['element','code'], function(){
779812
var element = layui.element;
780813
layui.element.render();
814+
layui.code({
815+
title: 'PHP回调示例代码'
816+
});
781817

782818
});
783819
</script>

0 commit comments

Comments
 (0)