|
@@ -5,6 +5,8 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.qmrb.system.common.result.PageResult;
|
|
|
import com.qmrb.system.common.result.Result;
|
|
@@ -14,6 +16,8 @@ import com.qmrb.system.framework.security.util.SecurityUtils;
|
|
|
import com.qmrb.system.mq.PickCarProducer;
|
|
|
import com.qmrb.system.pojo.dto.LoginParam;
|
|
|
import com.qmrb.system.pojo.dto.UserParam;
|
|
|
+import com.qmrb.system.pojo.entity.BarnRecord;
|
|
|
+import com.qmrb.system.pojo.entity.Contract;
|
|
|
import com.qmrb.system.pojo.entity.Order;
|
|
|
import com.qmrb.system.pojo.entity.ToolWxConfig;
|
|
|
import com.qmrb.system.pojo.form.BarnRecordForm;
|
|
@@ -75,17 +79,18 @@ public class OrderController extends CommonController {
|
|
|
|
|
|
@Autowired
|
|
|
private ToolWxConfigService toolWxConfigService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private PickCarProducer pickCarProducer;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
@Autowired
|
|
|
private IBarnRecordService barnRecordService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private ICarParkChargingRulesService rulesService;
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
@Value("${pickCarProducer.topic}")
|
|
|
private String topic;
|
|
|
@Value("${pickCarProducer.tags}")
|
|
@@ -100,16 +105,16 @@ public class OrderController extends CommonController {
|
|
|
Page<PayOrderVO> result = orderService.getPage(queryParams);
|
|
|
return PageResult.success(result);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Operation(summary = "订单表分页列表", security = {@SecurityRequirement(name = "Authorization")})
|
|
|
@GetMapping("/getPageByUserId")
|
|
|
public PageResult<PayOrderVO> getPageByUserId(
|
|
|
@ParameterObject PayOrderQuery queryParams
|
|
|
) {
|
|
|
queryParams.setUserId(SecurityUtils.getUserId() != null ? SecurityUtils.getUserId().toString() : "");
|
|
|
- if(StrUtil.isNotBlank(queryParams.getUserId())){
|
|
|
+ if (StrUtil.isNotBlank(queryParams.getUserId())) {
|
|
|
Page<PayOrderVO> pageResult = orderService.getPageByUserId(queryParams);
|
|
|
- if(CollectionUtil.isNotEmpty(pageResult.getRecords())){
|
|
|
+ if (CollectionUtil.isNotEmpty(pageResult.getRecords())) {
|
|
|
List<PayOrderVO> list = pageResult.getRecords().stream().map(item -> {
|
|
|
Integer amountsPayable = item.getAmountsPayable();
|
|
|
if (amountsPayable != null) {
|
|
@@ -121,7 +126,7 @@ public class OrderController extends CommonController {
|
|
|
}
|
|
|
return PageResult.success(pageResult);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return PageResult.success(null);
|
|
|
}
|
|
|
|
|
@@ -150,7 +155,7 @@ public class OrderController extends CommonController {
|
|
|
@Parameter(description = "订单表ID") @PathVariable Long id,
|
|
|
@RequestBody @Validated PayOrderForm form) {
|
|
|
|
|
|
- boolean result = orderService.updateForm(id,form);
|
|
|
+ boolean result = orderService.updateForm(id, form);
|
|
|
return Result.judge(result);
|
|
|
}
|
|
|
|
|
@@ -159,7 +164,7 @@ public class OrderController extends CommonController {
|
|
|
public Result<?> deleteUsers(
|
|
|
@Parameter(description = "订单表ID,多个以英文逗号(,)分割") @PathVariable String ids
|
|
|
) {
|
|
|
- if(StrUtil.isBlank(ids)) {
|
|
|
+ if (StrUtil.isBlank(ids)) {
|
|
|
return Result.failed(ResultCode.PARAM_ERROR, "删除的订单表数据为空");
|
|
|
}
|
|
|
// 逻辑删除
|
|
@@ -171,56 +176,65 @@ public class OrderController extends CommonController {
|
|
|
|
|
|
/**
|
|
|
* 根据code获取openId,session_key,用于支付
|
|
|
+ *
|
|
|
* @param loginVO
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/wxLogin")
|
|
|
- public CommonResult<WxLoginVO> wxLogin(@RequestBody WxLoginVO loginVO){
|
|
|
- return process(() -> orderService.getOpenId(toolWxConfigService.findConf(),loginVO));
|
|
|
+ public CommonResult<WxLoginVO> wxLogin(@RequestBody WxLoginVO loginVO) {
|
|
|
+ return process(() -> orderService.getOpenId(toolWxConfigService.findConf(), loginVO));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取当前默认用户信息
|
|
|
+ *
|
|
|
* @param userParam
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/getMyInfo")
|
|
|
- public CommonResult<UserInfo> getMyInfo(UserParam userParam){
|
|
|
+ public CommonResult<UserInfo> getMyInfo(UserParam userParam) {
|
|
|
return process(() -> userService.getMyInfo(userParam));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 微信小程序登录
|
|
|
+ *
|
|
|
* @param loginParam
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/wxMpLogin")
|
|
|
- public CommonResult<UserInfo> wxMpLogin(LoginParam loginParam){
|
|
|
+ public CommonResult<UserInfo> wxMpLogin(LoginParam loginParam) {
|
|
|
return process(() -> userService.wxMpLogin(loginParam));
|
|
|
}
|
|
|
|
|
|
|
|
|
@PostMapping("/createOrder")
|
|
|
- public CommonResult<ReCreateOrderVO> createOrder(@RequestBody ToCreateOrderVO toCreatOrderVO){
|
|
|
+ public CommonResult<ReCreateOrderVO> createOrder(@RequestBody ToCreateOrderVO toCreatOrderVO) {
|
|
|
Long id = IdUtil.getSnowflake().nextId();
|
|
|
toCreatOrderVO.setOutTradeNo(id.toString());
|
|
|
- //订单入库
|
|
|
+ // 根据停车记录id获取车牌号
|
|
|
+ List<BarnRecord> barnRecordList = barnRecordService.list(new LambdaQueryWrapper<BarnRecord>().eq(BarnRecord::getId, toCreatOrderVO.getGoodId())
|
|
|
+ .orderByDesc(BarnRecord::getCreateTime));
|
|
|
+ // 订单入库
|
|
|
orderService.save(new Order().setAmountsPayable(toCreatOrderVO.getTotal())
|
|
|
.setPayDescription(toCreatOrderVO.getDescription())
|
|
|
- .setId(id)
|
|
|
- .setGoodId(toCreatOrderVO.getGoodId())
|
|
|
- .setGoodsName(toCreatOrderVO.getDescription())
|
|
|
- .setPayStatus(SystemConstant.NUM_ZERO));
|
|
|
- return process(() -> orderService.createOrder(toolWxConfigService.findConf(),toCreatOrderVO));
|
|
|
+ .setId(id)
|
|
|
+ .setGoodId(toCreatOrderVO.getGoodId())
|
|
|
+ .setGoodsName(toCreatOrderVO.getDescription())
|
|
|
+ .setPayStatus(SystemConstant.NUM_ZERO)
|
|
|
+ .setPlateNumber(barnRecordList.get(0).getCarNumber())
|
|
|
+ );
|
|
|
+ return process(() -> orderService.createOrder(toolWxConfigService.findConf(), toCreatOrderVO));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/refundOrder")
|
|
|
- public CommonResult<String> refundOrder(@RequestParam("outTradeNo") String outTradeNo){
|
|
|
+ public CommonResult<String> refundOrder(@RequestParam("outTradeNo") String outTradeNo) {
|
|
|
return process(() -> orderService.refundOrder(toolWxConfigService.findConf(), orderService.getById(outTradeNo)));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 支付回调给微信确认
|
|
|
+ *
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
@@ -228,16 +242,16 @@ public class OrderController extends CommonController {
|
|
|
public String wechatCallback(HttpServletRequest request) {
|
|
|
ToolWxConfig wxConfig = toolWxConfigService.findConf();
|
|
|
log.info("微信退款回调通知调用=============================");
|
|
|
- Map<String,String> result = new HashMap(SystemConstant.NUM_16);
|
|
|
+ Map<String, String> result = new HashMap(SystemConstant.NUM_16);
|
|
|
result.put("code", "FAIL");
|
|
|
- result.put("message","失败");
|
|
|
+ result.put("message", "失败");
|
|
|
try {
|
|
|
- //微信回调信息校验
|
|
|
+ // 微信回调信息校验
|
|
|
// 构建request,传入必要参数
|
|
|
Notification notification = WxPayUtil.verifyBack(request, wxConfig);
|
|
|
- log.info("=================微信验证签名成功=======成功时间=={}=====",notification.getCreateTime());
|
|
|
+ log.info("=================微信验证签名成功=======成功时间=={}=====", notification.getCreateTime());
|
|
|
notification.getSummary();
|
|
|
- if(SystemConstant.PAY_SUCCESS.equals(notification.getSummary())){
|
|
|
+ if (SystemConstant.PAY_SUCCESS.equals(notification.getSummary())) {
|
|
|
if (orderService.verifyCreateOrder(notification.getDecryptData())) {
|
|
|
log.info("==============================微信退款成功订单=====================================");
|
|
|
result.put("code", WXOrderConstant.WX_BACK_OK);
|
|
@@ -247,17 +261,18 @@ public class OrderController extends CommonController {
|
|
|
} catch (ValidationException | ParseException | IOException e) {
|
|
|
log.error("微信支付回调失败验证" + e);
|
|
|
}
|
|
|
- log.info("微信返回结果"+result);
|
|
|
+ log.info("微信返回结果" + result);
|
|
|
return JSONUtil.toJsonStr(result);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/closeOrder")
|
|
|
public void closeOrder(@RequestParam("outTradeNo") String outTradeNo) {
|
|
|
- orderService.closeOrder(toolWxConfigService.findConf(),outTradeNo);
|
|
|
+ orderService.closeOrder(toolWxConfigService.findConf(), outTradeNo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据岗亭端停车记录数据计费取车
|
|
|
+ *
|
|
|
* @param id
|
|
|
* @param openId
|
|
|
* @return
|
|
@@ -274,35 +289,35 @@ public class OrderController extends CommonController {
|
|
|
@ParameterObject String openId,
|
|
|
@ParameterObject Boolean isMonthlyCardMode
|
|
|
) throws MQBrokerException, RemotingException, UnsupportedEncodingException, InterruptedException, MQClientException {
|
|
|
- //todo 调用计费模块,计算是否有应付费用
|
|
|
+ // todo 调用计费模块,计算是否有应付费用
|
|
|
BigDecimal pendingAmount = BigDecimal.ZERO;
|
|
|
BarnRecordForm formData = barnRecordService.getFormData(id);
|
|
|
- if(formData != null){
|
|
|
+ if (formData != null) {
|
|
|
// 计算未支付金额
|
|
|
- pendingAmount = rulesService.calcuExpenses(formData.getId(),formData.getCarNumber(),isMonthlyCardMode);
|
|
|
+ pendingAmount = rulesService.calcuExpenses(formData.getId(), formData.getCarNumber(), isMonthlyCardMode);
|
|
|
}
|
|
|
- if(formData != null && pendingAmount.compareTo(BigDecimal.ZERO) >0){
|
|
|
+ if (formData != null && pendingAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
ToCreateOrderVO toCreateOrderVO = new ToCreateOrderVO();
|
|
|
- log.error("待收金额:"+pendingAmount.toString());
|
|
|
+ log.error("待收金额:" + pendingAmount.toString());
|
|
|
toCreateOrderVO.setTotal(pendingAmount.multiply(new BigDecimal(100)).intValue());
|
|
|
toCreateOrderVO.setDescription("停车缴费");
|
|
|
toCreateOrderVO.setOpenId(openId);
|
|
|
Long orderId = IdUtil.getSnowflake().nextId();
|
|
|
toCreateOrderVO.setOutTradeNo(orderId.toString());
|
|
|
- //订单入库
|
|
|
+ // 订单入库
|
|
|
orderService.save(new Order().setAmountsPayable(toCreateOrderVO.getTotal())
|
|
|
.setPayDescription(toCreateOrderVO.getDescription())
|
|
|
.setId(orderId)
|
|
|
.setGoodId(id)
|
|
|
.setGoodsName(toCreateOrderVO.getDescription())
|
|
|
.setPayStatus(SystemConstant.NUM_ZERO));
|
|
|
- return process(() -> orderService.createOrder(toolWxConfigService.findConf(),toCreateOrderVO));
|
|
|
- }else if(formData != null && pendingAmount.compareTo(BigDecimal.ZERO) <= 0){
|
|
|
+ return process(() -> orderService.createOrder(toolWxConfigService.findConf(), toCreateOrderVO));
|
|
|
+ } else if (formData != null && pendingAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
HashMap<String, Object> paramsMap = new HashMap<>();
|
|
|
- paramsMap.put("channelId",formData.getBarnId());
|
|
|
- paramsMap.put("carNumber",formData.getCarNumber());
|
|
|
+ paramsMap.put("channelId", formData.getBarnId());
|
|
|
+ paramsMap.put("carNumber", formData.getCarNumber());
|
|
|
// 发送取车指令
|
|
|
- pickCarProducer.send(topic,tags, JSONUtil.toJsonStr(paramsMap));
|
|
|
+ pickCarProducer.send(topic, tags, JSONUtil.toJsonStr(paramsMap));
|
|
|
}
|
|
|
return CommonResult.success(null);
|
|
|
}
|
|
@@ -312,14 +327,14 @@ public class OrderController extends CommonController {
|
|
|
ToolWxConfig wxConfig = toolWxConfigService.findConf();
|
|
|
Map result = new HashMap();
|
|
|
result.put("code", "FAIL");
|
|
|
- result.put("message","失败");
|
|
|
+ result.put("message", "失败");
|
|
|
try {
|
|
|
- //微信回调信息校验
|
|
|
+ // 微信回调信息校验
|
|
|
// 构建request,传入必要参数
|
|
|
Notification notification = WxPayUtil.verifyBack(request, wxConfig);
|
|
|
log.info("=================微信验证签名成功=======成功时间=={}=====", notification.getCreateTime());
|
|
|
// 根据退款返回结果 更新订单状态 返回结果
|
|
|
- if(orderService.updateRefundOrder(notification.getDecryptData())){
|
|
|
+ if (orderService.updateRefundOrder(notification.getDecryptData())) {
|
|
|
log.info("==============================微信退款成功订单=====================================");
|
|
|
result.put("code", WXOrderConstant.WX_BACK_OK);
|
|
|
result.put("message", "退款回调成功");
|