feat:zlb江体优化
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbPayOrder;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 15:11
|
||||
*/
|
||||
public interface IZlbOrderInfoManage extends IService<ZlbPayOrder> {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.mapper.ZlbOrderInfoMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbPayOrder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 15:11
|
||||
*/
|
||||
@Service
|
||||
public class ZlbOrderInfoManageImpl extends ServiceImpl<ZlbOrderInfoMapper, ZlbPayOrder> implements IZlbOrderInfoManage {
|
||||
}
|
||||
@@ -8,6 +8,8 @@ import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.exception.BusinessException;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||
import com.xiang.common.manage.jntyzx.zlb.IZlbOrderInfoManage;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbPayOrder;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
@@ -24,6 +26,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
@@ -40,6 +43,7 @@ public class ZlbOrderTask extends BaseScheduleTaskTemplate {
|
||||
private final ZlbTokenInfoService zlbTokenInfoService;
|
||||
private final JntyzxDingTalkFactory jntyzxDingTalkFactory;
|
||||
private final RedisTemplate redisTemplate;
|
||||
private final IZlbOrderInfoManage zlbOrderInfoManage;
|
||||
|
||||
public ZlbOrderTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
@@ -47,13 +51,15 @@ public class ZlbOrderTask extends BaseScheduleTaskTemplate {
|
||||
ZlbService zlbService,
|
||||
ZlbTokenInfoService zlbTokenInfoService,
|
||||
JntyzxDingTalkFactory jntyzxDingTalkFactory,
|
||||
RedisTemplate redisTemplate) {
|
||||
RedisTemplate redisTemplate,
|
||||
IZlbOrderInfoManage zlbOrderInfoManage) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.zlbUserInfoService = zlbUserInfoService;
|
||||
this.zlbService = zlbService;
|
||||
this.zlbTokenInfoService = zlbTokenInfoService;
|
||||
this.jntyzxDingTalkFactory = jntyzxDingTalkFactory;
|
||||
this.redisTemplate = redisTemplate;
|
||||
this.zlbOrderInfoManage = zlbOrderInfoManage;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,11 +104,15 @@ public class ZlbOrderTask extends BaseScheduleTaskTemplate {
|
||||
String tokenId = zlbTokenInfo.getTokenId();
|
||||
String secretKey = zlbService.getKey(tokenId, client);
|
||||
String siteOrderDetailsStr = zlbService.buildSiteOrder(zlbUserInfo, secretKey, day);
|
||||
if (StringUtils.isEmpty(siteOrderDetailsStr)) {
|
||||
log.info("构建订单参数异常:{}", siteOrderDetailsStr);
|
||||
throw new BusinessException("构建订单参数异常");
|
||||
}
|
||||
Map<String, String> headers = zlbService.getHeaders(zlbTokenInfo.getTokenId());
|
||||
String newOrderJson = zlbService.buildNewOrder(siteOrderDetailsStr, client);
|
||||
if (StringUtils.isBlank(newOrderJson)) {
|
||||
log.info("构建订单参数异常:{}", siteOrderDetailsStr);
|
||||
throw new BusinessException("");
|
||||
throw new BusinessException("构建订单参数异常");
|
||||
}
|
||||
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
|
||||
//计算9点到现在的时间差
|
||||
@@ -138,18 +148,26 @@ public class ZlbOrderTask extends BaseScheduleTaskTemplate {
|
||||
log.info("订单接口返回结果==> \n {}", response);
|
||||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
if (jsonObject.getInteger("code") == 200) {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "zlb订单接口下单返回成功请2分钟内付款√√√√√√场地号:" + placeName + "时间:" + siteTimeName);
|
||||
jntyzxDingTalkFactory.sendMsg(name + ":zlb订单接口下单返回成功请2分钟内付款√√√√√√场地号:" + placeName + "时间:" + siteTimeName);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
String orderId = data.getString("orderId");
|
||||
log.info("{}订单{}创建成功", name, orderId);
|
||||
String redisKey = ZlbUrlConstants.REDIS_PREFIX + "_" + orderId + "_" + name;
|
||||
redisTemplate.opsForValue().set(redisKey, name);
|
||||
redisTemplate.expire(redisKey, 120, TimeUnit.SECONDS);
|
||||
ZlbPayOrder zlbPayOrder = new ZlbPayOrder();
|
||||
zlbPayOrder.setName(name);
|
||||
zlbPayOrder.setDay(DateUtils.getDateFromDate(LocalDate.now().plusDays(1)));
|
||||
zlbPayOrder.setVenues("江体");
|
||||
zlbPayOrder.setPlaceName(placeName);
|
||||
zlbPayOrder.setTime(siteTimeName);
|
||||
zlbPayOrder.setIsPay(0);
|
||||
zlbOrderInfoManage.save(zlbPayOrder);
|
||||
return true;
|
||||
}
|
||||
if (jsonObject.getInteger("code") == 500) {
|
||||
if (jsonObject.getString("message").contains("已被售出")) {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "zlb订单接口下单返回失败❌❌❌场地号:" + placeName + "已被售出");
|
||||
jntyzxDingTalkFactory.sendMsg(name + ":zlb订单接口下单返回失败❌❌❌场地号:" + placeName + "已被售出");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user