支付逻辑修改
This commit is contained in:
parent
b8e517af31
commit
e8aeda055f
|
|
@ -90,7 +90,7 @@ public class AlipayNotifyController {
|
||||||
return "failure";
|
return "failure";
|
||||||
}
|
}
|
||||||
ParkingBillInfo parkingBillInfo = parkingBillInfoService.lambdaQuery()
|
ParkingBillInfo parkingBillInfo = parkingBillInfoService.lambdaQuery()
|
||||||
.eq(ParkingBillInfo::getBillCode, one.getBillCode())
|
.eq(ParkingBillInfo::getInUnid, one.getInUnid())
|
||||||
.last("limit 1")
|
.last("limit 1")
|
||||||
.one();
|
.one();
|
||||||
if (parkingBillInfo == null) {
|
if (parkingBillInfo == null) {
|
||||||
|
|
@ -103,6 +103,7 @@ public class AlipayNotifyController {
|
||||||
parkingBillInfo.setIsNotify(1);
|
parkingBillInfo.setIsNotify(1);
|
||||||
}
|
}
|
||||||
parkingBillInfo.setIsPay(1);
|
parkingBillInfo.setIsPay(1);
|
||||||
|
parkingBillInfo.setPhone(one.getPhone());
|
||||||
boolean b1 = parkingBillInfoService.updateById(parkingBillInfo);
|
boolean b1 = parkingBillInfoService.updateById(parkingBillInfo);
|
||||||
if (!b1) {
|
if (!b1) {
|
||||||
return "failure";
|
return "failure";
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,27 @@
|
||||||
package com.ruoyi.database.controller;
|
package com.ruoyi.database.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUserByPhone;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.PageUtils;
|
||||||
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
||||||
import com.ruoyi.database.domain.ParkingBillInfo;
|
import com.ruoyi.database.domain.ParkingBillInfo;
|
||||||
|
import com.ruoyi.database.domain.vo.ParkingBillInfoVO;
|
||||||
import com.ruoyi.database.service.ParkingBillInfoService;
|
import com.ruoyi.database.service.ParkingBillInfoService;
|
||||||
|
import com.ruoyi.framework.web.service.TokenService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RequestMapping("/ParkingBillInfo")
|
@RequestMapping("/ParkingBillInfo")
|
||||||
|
|
@ -22,15 +31,54 @@ import java.util.List;
|
||||||
public class ParkingBillInfoController extends BaseController {
|
public class ParkingBillInfoController extends BaseController {
|
||||||
|
|
||||||
private final ParkingBillInfoService parkingBillInfoService;
|
private final ParkingBillInfoService parkingBillInfoService;
|
||||||
|
private final TokenService tokenService;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("查询订单管理")
|
@ApiOperation("查询订单管理")
|
||||||
public TableDataInfo<ParkingBillInfo> list(ParkingBillInfo ParkingBillInfo) {
|
public TableDataInfo<ParkingBillInfo> list(ParkingBillInfo parkingBillInfo, HttpServletRequest request) {
|
||||||
startPage();
|
String phone = null;
|
||||||
QueryWrapper<ParkingBillInfo> queryWrapper = new QueryWrapper<>(ParkingBillInfo);
|
try {
|
||||||
|
LoginUserByPhone loginUserByPhone = tokenService.getLoginUserByPhone(request);
|
||||||
|
phone = loginUserByPhone.getPhone();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
PageUtils.startPage();
|
||||||
|
QueryWrapper<ParkingBillInfo> queryWrapper = new QueryWrapper<>(parkingBillInfo);
|
||||||
|
if (phone != null && !"".equals(phone)){
|
||||||
|
queryWrapper.eq("phone",phone);
|
||||||
|
}
|
||||||
|
Integer timeRange = parkingBillInfo.getTimeRange();
|
||||||
|
if (timeRange != null){
|
||||||
|
Date now = new Date();
|
||||||
|
|
||||||
|
if (timeRange == 1) { // 当天
|
||||||
|
// 获取当天开始和结束时间
|
||||||
|
Date beginOfDay = DateUtil.beginOfDay(now);
|
||||||
|
Date endOfDay = DateUtil.endOfDay(now);
|
||||||
|
queryWrapper.between("create_time", beginOfDay, endOfDay);
|
||||||
|
|
||||||
|
} else if (timeRange == 2) { // 一个月内
|
||||||
|
Date oneMonthAgo = DateUtil.offsetMonth(now, -1);
|
||||||
|
queryWrapper.ge("create_time", oneMonthAgo);
|
||||||
|
|
||||||
|
} else if (timeRange == 3) { // 三个月内
|
||||||
|
Date threeMonthsAgo = DateUtil.offsetMonth(now, -3);
|
||||||
|
queryWrapper.ge("create_time", threeMonthsAgo);
|
||||||
|
}
|
||||||
|
}
|
||||||
List<ParkingBillInfo> list = parkingBillInfoService.list(queryWrapper);
|
List<ParkingBillInfo> list = parkingBillInfoService.list(queryWrapper);
|
||||||
|
List<ParkingBillInfoVO> parkingBillInfoVOS = new ArrayList<>();
|
||||||
|
list.forEach(b -> {
|
||||||
|
ParkingBillInfoVO parkingBillInfoVO = new ParkingBillInfoVO();
|
||||||
|
BeanUtils.copyProperties(b, parkingBillInfoVO);
|
||||||
|
parkingBillInfoVO.setTotalCostYuan(b.getTotalCostYuan().toString() + "元");
|
||||||
|
parkingBillInfoVO.setPayMoneyYuan(b.getPayMoneyYuan().toString() + "元");
|
||||||
|
parkingBillInfoVO.setDeductMoneyYuan(b.getDeductMoneyYuan().toString() + "元");
|
||||||
|
parkingBillInfoVO.setParkPeriodTime(minutesToDHMS(b.getParkPeriodTime()));
|
||||||
|
parkingBillInfoVOS.add(parkingBillInfoVO);
|
||||||
|
});
|
||||||
long size = parkingBillInfoService.count(queryWrapper);
|
long size = parkingBillInfoService.count(queryWrapper);
|
||||||
return getDataTableEnhance(list,size);
|
return getDataTableEnhance(parkingBillInfoVOS,size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
|
|
@ -53,4 +101,17 @@ public class ParkingBillInfoController extends BaseController {
|
||||||
public AjaxResult delete(@RequestParam("idList") List<Long> idList) {
|
public AjaxResult delete(@RequestParam("idList") List<Long> idList) {
|
||||||
return toAjax(parkingBillInfoService.removeByIds(idList));
|
return toAjax(parkingBillInfoService.removeByIds(idList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String minutesToDHMS(int minutes) {
|
||||||
|
int days = minutes / 1440; // 1440 = 24 * 60
|
||||||
|
int hours = (minutes % 1440) / 60;
|
||||||
|
int mins = minutes % 60;
|
||||||
|
int secs = 0;
|
||||||
|
|
||||||
|
return days + "天" +
|
||||||
|
String.format("%02d", hours) + "小时" +
|
||||||
|
String.format("%02d", mins) + "分钟" +
|
||||||
|
String.format("%02d", secs) + "秒";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,8 @@ public class SmallProgramController extends BaseController {
|
||||||
@ApiOperation("根据车牌号查询缴费订单")
|
@ApiOperation("根据车牌号查询缴费订单")
|
||||||
@Transactional
|
@Transactional
|
||||||
public AjaxResult getOrder(String plateNo) {
|
public AjaxResult getOrder(String plateNo) {
|
||||||
ParkingBillInfo one = parkingBillInfoService.saveOrUpdateParkingBillInfo(plateNo);
|
String trim = plateNo.trim();
|
||||||
|
ParkingBillInfo one = parkingBillInfoService.saveOrUpdateParkingBillInfo(trim);
|
||||||
// ParkingBillInfo one = parkingBillInfoService.lambdaQuery()
|
// ParkingBillInfo one = parkingBillInfoService.lambdaQuery()
|
||||||
// .eq(ParkingBillInfo::getPlateNo, plateNo)
|
// .eq(ParkingBillInfo::getPlateNo, plateNo)
|
||||||
// .orderByDesc(ParkingBillInfo::getCreateTime)
|
// .orderByDesc(ParkingBillInfo::getCreateTime)
|
||||||
|
|
@ -60,6 +61,7 @@ public class SmallProgramController extends BaseController {
|
||||||
parkingBillInfoVO.setTotalCostYuan(one.getTotalCostYuan().toString() + "元");
|
parkingBillInfoVO.setTotalCostYuan(one.getTotalCostYuan().toString() + "元");
|
||||||
parkingBillInfoVO.setPayMoneyYuan(one.getPayMoneyYuan().toString() + "元");
|
parkingBillInfoVO.setPayMoneyYuan(one.getPayMoneyYuan().toString() + "元");
|
||||||
parkingBillInfoVO.setDeductMoneyYuan(one.getDeductMoneyYuan().toString() + "元");
|
parkingBillInfoVO.setDeductMoneyYuan(one.getDeductMoneyYuan().toString() + "元");
|
||||||
|
parkingBillInfoVO.setParkPeriodTime(minutesToDHMS(one.getParkPeriodTime()));
|
||||||
return AjaxResult.success(parkingBillInfoVO);
|
return AjaxResult.success(parkingBillInfoVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -122,6 +124,7 @@ public class SmallProgramController extends BaseController {
|
||||||
parkingBillInfoVO.setTotalCostYuan(b.getTotalCostYuan().toString() + "元");
|
parkingBillInfoVO.setTotalCostYuan(b.getTotalCostYuan().toString() + "元");
|
||||||
parkingBillInfoVO.setPayMoneyYuan(b.getPayMoneyYuan().toString() + "元");
|
parkingBillInfoVO.setPayMoneyYuan(b.getPayMoneyYuan().toString() + "元");
|
||||||
parkingBillInfoVO.setDeductMoneyYuan(b.getDeductMoneyYuan().toString() + "元");
|
parkingBillInfoVO.setDeductMoneyYuan(b.getDeductMoneyYuan().toString() + "元");
|
||||||
|
parkingBillInfoVO.setParkPeriodTime(minutesToDHMS(b.getParkPeriodTime()));
|
||||||
parkingBillInfoVOS.add(parkingBillInfoVO);
|
parkingBillInfoVOS.add(parkingBillInfoVO);
|
||||||
});
|
});
|
||||||
return AjaxResult.success(parkingBillInfoVOS);
|
return AjaxResult.success(parkingBillInfoVOS);
|
||||||
|
|
@ -220,6 +223,7 @@ public class SmallProgramController extends BaseController {
|
||||||
parkingBillPaymentInfo.setPhone(loginUserByPhone.getPhone());
|
parkingBillPaymentInfo.setPhone(loginUserByPhone.getPhone());
|
||||||
parkingBillPaymentInfo.setPayStatus(0);
|
parkingBillPaymentInfo.setPayStatus(0);
|
||||||
parkingBillPaymentInfo.setOrderId(generate);
|
parkingBillPaymentInfo.setOrderId(generate);
|
||||||
|
parkingBillPaymentInfo.setInUnid(one.getInUnid());
|
||||||
boolean b = parkingBillPaymentInfoService.saveOrUpdate(parkingBillPaymentInfo);
|
boolean b = parkingBillPaymentInfoService.saveOrUpdate(parkingBillPaymentInfo);
|
||||||
if (b) {
|
if (b) {
|
||||||
return AjaxResult.success(order);
|
return AjaxResult.success(order);
|
||||||
|
|
@ -279,4 +283,17 @@ public class SmallProgramController extends BaseController {
|
||||||
int random = ThreadLocalRandom.current().nextInt(1000, 9999);
|
int random = ThreadLocalRandom.current().nextInt(1000, 9999);
|
||||||
return phoneSuffix + timePart.substring(timePart.length() - 10) + random;
|
return phoneSuffix + timePart.substring(timePart.length() - 10) + random;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String minutesToDHMS(int minutes) {
|
||||||
|
int days = minutes / 1440; // 1440 = 24 * 60
|
||||||
|
int hours = (minutes % 1440) / 60;
|
||||||
|
int mins = minutes % 60;
|
||||||
|
int secs = 0;
|
||||||
|
|
||||||
|
return days + "天" +
|
||||||
|
String.format("%02d", hours) + "小时" +
|
||||||
|
String.format("%02d", mins) + "分钟" +
|
||||||
|
String.format("%02d", secs) + "秒";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public class WxPayNotifyController {
|
||||||
}
|
}
|
||||||
|
|
||||||
ParkingBillInfo parkingBillInfo = parkingBillInfoService.lambdaQuery()
|
ParkingBillInfo parkingBillInfo = parkingBillInfoService.lambdaQuery()
|
||||||
.eq(ParkingBillInfo::getBillCode, one.getBillCode())
|
.eq(ParkingBillInfo::getInUnid, one.getInUnid())
|
||||||
.last("limit 1")
|
.last("limit 1")
|
||||||
.one();
|
.one();
|
||||||
if (parkingBillInfo == null) {
|
if (parkingBillInfo == null) {
|
||||||
|
|
@ -86,6 +86,7 @@ public class WxPayNotifyController {
|
||||||
parkingBillInfo.setIsNotify(1);
|
parkingBillInfo.setIsNotify(1);
|
||||||
}
|
}
|
||||||
parkingBillInfo.setIsPay(1);
|
parkingBillInfo.setIsPay(1);
|
||||||
|
parkingBillInfo.setPhone(one.getPhone());
|
||||||
boolean b1 = parkingBillInfoService.updateById(parkingBillInfo);
|
boolean b1 = parkingBillInfoService.updateById(parkingBillInfo);
|
||||||
if (!b1){
|
if (!b1){
|
||||||
return WxPayNotifyResponse.fail("处理失败");
|
return WxPayNotifyResponse.fail("处理失败");
|
||||||
|
|
|
||||||
|
|
@ -175,4 +175,15 @@ public class ParkingBillInfo {
|
||||||
@ApiModelProperty("是否通知")
|
@ApiModelProperty("是否通知")
|
||||||
@Excel(name = "是否通知")
|
@Excel(name = "是否通知")
|
||||||
private Integer isNotify;
|
private Integer isNotify;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("手机号")
|
||||||
|
@Excel(name = "手机号")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@ApiModelProperty("时间范围 1:当天, 2:一个月, 3;3个月")
|
||||||
|
private Integer timeRange;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -129,4 +129,8 @@ public class ParkingBillPaymentInfo {
|
||||||
private String orderId;
|
private String orderId;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("入场记录唯一标识")
|
||||||
|
private String inUnid;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public class ParkingBillInfoVO {
|
||||||
/**
|
/**
|
||||||
* 停车时长(分钟)
|
* 停车时长(分钟)
|
||||||
*/
|
*/
|
||||||
private Integer parkPeriodTime;
|
private String parkPeriodTime;
|
||||||
|
|
||||||
|
|
||||||
private String totalCostYuan;
|
private String totalCostYuan;
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,7 @@ package com.ruoyi.database.service.impl;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.utils.bean.BeanUtils;
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
||||||
import com.ruoyi.database.domain.ParkingBill;
|
import com.ruoyi.database.domain.ParkingBill;
|
||||||
import com.ruoyi.database.domain.ParkingBillInfo;
|
import com.ruoyi.database.domain.ParkingBillInfo;
|
||||||
|
|
@ -38,12 +36,12 @@ public class ParkingBillInfoServiceImpl extends ServiceImpl<ParkingBillInfoMappe
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
JSONObject jsonObject = new JSONObject(parkingPaymentInfo);
|
JSONObject jsonObject = new JSONObject(parkingPaymentInfo);
|
||||||
String data = jsonObject.getJSONObject("data").toString();
|
JSONObject data = jsonObject.getJSONObject("data");
|
||||||
if(data==null){
|
if(data==null){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ParkingBill vehicleRecord = objectMapper.readValue(data, ParkingBill.class);
|
ParkingBill vehicleRecord = objectMapper.readValue(data.toString(), ParkingBill.class);
|
||||||
ParkingBillInfo parkingBillInfo = new ParkingBillInfo();
|
ParkingBillInfo parkingBillInfo = new ParkingBillInfo();
|
||||||
BeanUtils.copyProperties(vehicleRecord,parkingBillInfo);
|
BeanUtils.copyProperties(vehicleRecord,parkingBillInfo);
|
||||||
parkingBillInfo.setPayMoneyYuan(vehicleRecord.getPayMoneyYuan());
|
parkingBillInfo.setPayMoneyYuan(vehicleRecord.getPayMoneyYuan());
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- 日志存放路径 -->
|
<!-- 日志存放路径 -->
|
||||||
<property name="log.path" value="/home/project/qnyj/logs" />
|
<property name="log.path" value="/home/project/wisdomPark/logs" />
|
||||||
<!-- 日志输出格式 -->
|
<!-- 日志输出格式 -->
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue