记得上下班打卡 | git大法好,push需谨慎

Commit 26ba85bb authored by jiangxiulong's avatar jiangxiulong

Merge branch 'test'

parents 784bb9b1 5f14fc0b
......@@ -76,4 +76,40 @@ public class DragonConstant {
this.message = message;
}
}
/**
* MYSQL_REDIS_QUEUE
*/
public enum mysqlRedisQueueEnum{
DRAGON_PAY_KEY("dragon-pay","同步数据-支付"),
DRAGON_REFUND_KEY ("dragon-refund","同步数据-退款"),
DRAGON_PAY_GROUP("dragon-pay-group","同步数据-支付-组"),
DRAGON_REFUND_GROUP ("dragon-refund-group","同步数据-退款-组");
private String code;
private String message;
mysqlRedisQueueEnum(String code, String message) {
this.code = code;
this.message = message;
}
}
/**
* CHANNEL_REDIS_QUEUE
*/
public enum channelRedisQueueEnum{
WECHAT_PAY_KEY("wechat-pay","微信-支付-回调"),
WECHAT_REFUND_KEY("wechat-pay","微信-退款-回调"),
ALIPAY_PAY_KEY("alipay-pay","支付宝-支付-回调"),
ALIPAY_REFUND_KEY ("alipay-refund","支付宝-退款-回调"),
WECHAT_PAY_GROUP("wechat-pay-group","微信-支付-回调-组"),
WECHAT_REFUND_GROUP("wechat-pay-group","微信-退款-回调-组"),
ALIPAY_PAY_GROUP("alipay-pay-group","支付宝-支付-回调-组"),
ALIPAY_REFUND_GROUP ("alipay-refund-group","支付宝-退款-回调-组");
private String code;
private String message;
channelRedisQueueEnum(String code, String message) {
this.code = code;
this.message = message;
}
}
}
package com.liquidnet.service.dragon.service;
public interface IDragonOrdersService {
void sendRedisQueue();
}
......@@ -75,7 +75,7 @@ public class PerformancesExpressController extends BaseController {
@RequiresPermissions("kylin:performancesExpress:placeOrder")
@PostMapping("/placeOrder")
@ResponseBody
public AjaxResult placeOrder(PerformanceExpressSearchAdminParam performanceExpressSearchAdminParam) throws Exception {
public AjaxResult placeOrder(PerformanceExpressSearchAdminParam performanceExpressSearchAdminParam) {
ResponseDto res = performancesExpressServiceImpl.placeOrder(performanceExpressSearchAdminParam);
try {
if (res.isSuccess()) {
......
......@@ -93,10 +93,12 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
String orderTicketsId = refundApplyParam.getOrderTicketsId();
List<String> ticketEntityIds = refundApplyParam.getTicketEntityIds();
List<Double> entitiesPrice = refundApplyParam.getEntitiesPrice();
Double RefundPriceExpress = refundApplyParam.getRefundPriceExpress();
if (null == RefundPriceExpress) {
RefundPriceExpress = 0.0;
Double RefundPriceExpressDouble = refundApplyParam.getRefundPriceExpress();
if (null == RefundPriceExpressDouble) {
RefundPriceExpressDouble = 0.0;
}
BigDecimal RefundPriceExpress = BigDecimal.valueOf(RefundPriceExpressDouble);
KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne(
new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId)
......@@ -106,7 +108,7 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
);
int thisOrderStatus = orderStatus.getStatus();
int thisPayStatus = orderStatus.getPayStatus();
double priceExpress = orderInfo.getPriceExpress().doubleValue();
BigDecimal priceExpress = orderInfo.getPriceExpress();
// todo 转增是否能退
// 订单状态需已付款
......@@ -127,11 +129,11 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
refundPriceExpressSum = 0.0;
}
if (null == refundApplyParam.getOrderRefundBatchesId() || refundApplyParam.getOrderRefundBatchesId().isEmpty()) { // 不是批量退款
if (RefundPriceExpress > (priceExpress - refundPriceExpressSum)) {
if (RefundPriceExpress.compareTo(priceExpress.subtract(BigDecimal.valueOf(refundPriceExpressSum))) > 0) {
return ResponseDto.failure("快递费不能大于实际减去已退的快递费");
}
} else {
RefundPriceExpress = priceExpress - refundPriceExpressSum;
RefundPriceExpress = priceExpress.subtract(BigDecimal.valueOf(refundPriceExpressSum));
}
// todo 出票未出票
......@@ -148,18 +150,18 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
}
// 该订单正在退款或已有退款 因支持填入价格所有取消判断
// 各个入场人订单填写的退款金额是否正确
double priceActual = orderInfo.getPriceActual().doubleValue();
BigDecimal priceActual = orderInfo.getPriceActual();
int allEntitiesCount = kylinOrderTicketEntitiesMapper.selectCount(// 总入场人数量 排出未付款的 用来计算单入场人的价格
new QueryWrapper<KylinOrderTicketEntities>()
.eq("order_id", orderTicketsId)
.ne("is_payment", KylinTableStatusConst.ENTITIES_IS_PAYMENT0)
);
double onePrice = (priceActual - priceExpress) / allEntitiesCount;//单价
BigDecimal onePrice = priceActual.subtract(priceExpress).divide(BigDecimal.valueOf(allEntitiesCount));//单价
List<Double> realRefundPriceList = new ArrayList<>();
if (null == refundApplyParam.getOrderRefundBatchesId() || refundApplyParam.getOrderRefundBatchesId().isEmpty()) { // 不是批量退款
for (int i = 0; i <= ticketEntityIds.size() - 1; i++) {
Double price = entitiesPrice.get(i);
if (price < 0) {
BigDecimal price = BigDecimal.valueOf(entitiesPrice.get(i));
if (price.compareTo(BigDecimal.ZERO) <= 0) {
return ResponseDto.failure(ErrorMapping.get("20021"));
} else {
Double refundedPrice = kylinOrderTicketEntitiesMapper.getRefundEntitiesPrice(//已退
......@@ -170,7 +172,7 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
if (null == refundedPrice) {
refundedPrice = 0.0;
}
if (price > (onePrice - refundedPrice)) {
if (price.compareTo(onePrice.subtract(BigDecimal.valueOf(refundedPrice))) > 0) {
return ResponseDto.failure("超过可退款金额");
}
}
......@@ -187,9 +189,9 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
if (null == refundedPrice) {
refundedPrice = 0.0;
}
Double price = onePrice - refundedPrice; // 计算可退金额
if (price > 0) {
realRefundPriceList.add(price);
BigDecimal price = onePrice.subtract(BigDecimal.valueOf(refundedPrice)); // 计算可退金额
if (price.compareTo(BigDecimal.ZERO) > 0) {
realRefundPriceList.add(price.doubleValue());
ticketEntityIdsNew.add(ticketEntityIds.get(i));
}
}
......@@ -199,7 +201,7 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
boolean res = kylinRefundsStatusServiceImpl.orderTicketRefunding(
refundApplyParam, orderInfo, orderTicketsId,
RefundPriceExpress,
RefundPriceExpress.doubleValue(),
ticketEntityIds, realRefundPriceList
);
......
......@@ -73,7 +73,11 @@ public class KylinRefundExecuteServiceImpl {
if (order.getPriceExpress() != null) {
refundApplyParam.setRefundPriceExpress(order.getPriceExpress().doubleValue());
}
ResponseDto res = kylinOrderRefundsServiceImpl.refundApply(refundApplyParam);
try {
ResponseDto res = kylinOrderRefundsServiceImpl.refundApply(refundApplyParam);
} catch (Exception e) {
}
}
count = orderList.size();
......@@ -133,7 +137,7 @@ public class KylinRefundExecuteServiceImpl {
List<KylinOrderRefunds> refundList = kylinOrderRefundsMapper.getRefundList(whereType, refundBatchId, whereStatus, mid, limitNum);
List<String> refundIds = null;
if (refundList != null && refundList.size()>0) {
if (refundList != null && refundList.size() > 0) {
refundIds = refundList.stream().map(KylinOrderRefunds -> KylinOrderRefunds.getOrderRefundsId()).collect(Collectors.toList());
RefundApplyParam refundApplyParam = new RefundApplyParam();
......@@ -145,11 +149,15 @@ public class KylinRefundExecuteServiceImpl {
if (null != refundBatchApplyParam.getReject()) {
refundApplyParam.setReject(refundBatchApplyParam.getReject());
}
ResponseDto res = kylinOrderRefundsServiceImpl.refundCheckStatus(refundApplyParam);
try {
ResponseDto res = kylinOrderRefundsServiceImpl.refundCheckStatus(refundApplyParam);
} catch (Exception e) {
}
}
count = refundList.size();
if (count > 0){
if (count > 0) {
KylinOrderRefunds lastInfo = refundList.get(count - 1);
if (lastInfo != null) {
mid = lastInfo.getMid();
......
......@@ -202,6 +202,13 @@ public class KylinRefundsStatusServiceImpl {
mongoTemplate.insert(kylinOrderRefundEntitiesVo, KylinOrderRefundEntitiesVo.class.getSimpleName());
}
List<String> orderRefundIds = new ArrayList<>();
orderRefundIds.add(orderRefundsId);
List<String> orderIds = new ArrayList<>();
orderIds.add(orderTicketsId);
dataUtils.delOrderRefundVo(orderRefundIds);
dataUtils.delOrderRefundVoByOrderId(orderIds);
return true;
}
......@@ -474,14 +481,14 @@ public class KylinRefundsStatusServiceImpl {
);
// 入场人
double priceActual = orderInfo.getPriceActual().doubleValue();
double priceExpress = orderInfo.getPriceExpress().doubleValue();
BigDecimal priceActual = orderInfo.getPriceActual();
BigDecimal priceExpress = orderInfo.getPriceExpress();
int allEntitiesCount = kylinOrderTicketEntitiesMapper.selectCount(// 总入场人数量 排出未付款的 用来计算单入场人的价格
new QueryWrapper<KylinOrderTicketEntities>()
.eq("order_id", orderTicketsId)
.ne("is_payment", KylinTableStatusConst.ENTITIES_IS_PAYMENT0)
);
double onePrice = (priceActual - priceExpress) / allEntitiesCount;//单价
BigDecimal onePrice = priceActual.subtract(priceExpress).divide(BigDecimal.valueOf(allEntitiesCount));//单价
int refundNumber = 0;
for (String entitiesId : orderTicketEntitiesIdsArr) {
KylinOrderTicketEntities EntitiesInfo = kylinOrderTicketEntitiesMapper.selectOne(//已退完成的
......@@ -497,9 +504,9 @@ public class KylinRefundsStatusServiceImpl {
);
KylinOrderTicketEntities entitiesTable = new KylinOrderTicketEntities();
double priceNew = refundEntitiesInfo.getRefundPrice().doubleValue() + refundedPrice.doubleValue();
BigDecimal priceNew = refundEntitiesInfo.getRefundPrice().add(refundedPrice);
int isPayment = 0;
if (priceNew == onePrice) {
if (priceNew.compareTo(onePrice) == 0) {
isPayment = KylinTableStatusConst.ENTITIES_IS_PAYMENT3;
refundNumber++;
} else {
......@@ -507,7 +514,7 @@ public class KylinRefundsStatusServiceImpl {
}
entitiesTable.setIsPayment(isPayment);
entitiesTable.setUpdatedAt(LocalDateTime.now());
entitiesTable.setRefundPrice(BigDecimal.valueOf(priceNew));
entitiesTable.setRefundPrice(priceNew);
Integer[] entitiesTableIsPayment = {KylinTableStatusConst.ENTITIES_IS_PAYMENT2, KylinTableStatusConst.ENTITIES_IS_PAYMENT4};
kylinOrderTicketEntitiesMapper.update(entitiesTable, new UpdateWrapper<KylinOrderTicketEntities>()
.eq("order_ticket_entities_id", entitiesId)
......@@ -516,7 +523,7 @@ public class KylinRefundsStatusServiceImpl {
HashMap<String, Object> EntitiesVo = new HashMap<>();
EntitiesVo.put("updatedAt", DateUtil.getNowTime());
EntitiesVo.put("refundPrice", BigDecimal.valueOf(priceNew));
EntitiesVo.put("refundPrice", priceNew);
EntitiesVo.put("isPayment", isPayment);
BasicDBObject EntitiesVov = new BasicDBObject("$set", mongoConverter.convertToMongoType(EntitiesVo));
UpdateResult updateResult = mongoTemplate.getCollection(KylinOrderTicketEntitiesVo.class.getSimpleName()).updateOne(
......
......@@ -121,7 +121,7 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
return voList;
}
public ResponseDto placeOrder(PerformanceExpressSearchAdminParam performanceExpressSearchAdminParam) throws Exception {
public ResponseDto placeOrder(PerformanceExpressSearchAdminParam performanceExpressSearchAdminParam) {
List<String> ids = performanceExpressSearchAdminParam.getIds();
for (String orderTicketsId : ids) {
// 已经存在未取消的下单数据过滤掉
......@@ -179,7 +179,7 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
hBody.put("dAddress", orderInfo.getExpressAddress());
// 生成签名并请求
String result = shunfengSignUtils.generateSignatureAndRequestTest(hBody, "/public/order/v1/placeOrder");
String result = shunfengSignUtils.generateSignatureAndRequestNew(hBody, "/public/order/v1/placeOrder");
System.out.println(result);
HashMap hashMap = new HashMap();
try {
......@@ -283,11 +283,11 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
.notIn("express_status", expressStatus)
);
if (null != orderExpressInfo) {
HashMap<String, Object> hBody = new HashMap<>();
Map<String, String> hBody = new HashMap<>();
hBody.put("orderId", orderExpressInfo.getOrderExpressCode());
// 生成签名并请求
String result = shunfengSignUtils.generateSignatureAndRequest(hBody, "/public/order/v1/cancelOrder");
String result = shunfengSignUtils.generateSignatureAndRequestNew(hBody, "/public/order/v1/cancelOrder");
HashMap hashMap = JsonUtils.fromJson(result, HashMap.class);
System.out.println(result);
if (hashMap.get("succ").equals("fail")) {
......@@ -329,12 +329,12 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
.notIn("express_status", expressStatus)
);
if (null != orderExpressInfo) {
HashMap<String, Object> hBody = new HashMap<>();
Map<String, String> hBody = new HashMap<>();
hBody.put("orderId", orderExpressInfo.getOrderExpressCode());
hBody.put("searchType", 1); //查询类型:1,正向单查询,传入的orderid为正向定单号,2,退货单查询,传入的orderid为退货原始订单号
hBody.put("searchType", "1"); //查询类型:1,正向单查询,传入的orderid为正向定单号,2,退货单查询,传入的orderid为退货原始订单号
// 生成签名并请求
String result = shunfengSignUtils.generateSignatureAndRequest(hBody, "/public/order/v1/getResult");
String result = shunfengSignUtils.generateSignatureAndRequestNew(hBody, "/public/order/v1/getResult");
HashMap hashMap = JsonUtils.fromJson(result, HashMap.class);
System.out.println(result);
if (hashMap.get("succ").equals("fail")) {
......@@ -375,7 +375,7 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId)
);
if (null != orderExpressInfo) {
HashMap<String, Object> hBody = new HashMap<>();
Map<String, String> hBody = new HashMap<>();
hBody.put("jProvince", jProvince);
hBody.put("jCity", jCity);
hBody.put("jAddress", jAddress);
......@@ -383,12 +383,12 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
hBody.put("dProvince", orderInfo.getProvince());
hBody.put("dCity", orderInfo.getCity());
hBody.put("dAddress", orderInfo.getExpressAddress());
hBody.put("expressType", expressType);
hBody.put("expressType", expressType.toString());
// hBody.put("parcelWeighs", 2.00);
// hBody.put("volume", "10,10,20");
// 生成签名并请求
String result = shunfengSignUtils.generateSignatureAndRequest(hBody, "/public/order/v1/getFreight");
String result = shunfengSignUtils.generateSignatureAndRequestNew(hBody, "/public/order/v1/getFreight");
HashMap hashMap = JsonUtils.fromJson(result, HashMap.class);
System.out.println(result);
if (hashMap.get("succ").equals("fail")) {
......@@ -420,11 +420,11 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
.notIn("express_status", expressStatus)
);
if (null != orderExpressInfo) {
HashMap<String, Object> hBody = new HashMap<>();
Map<String, String> hBody = new HashMap<>();
hBody.put("orderId", orderExpressInfo.getOrderExpressCode());
// 生成签名并请求
String result = shunfengSignUtils.generateSignatureAndRequest(hBody, "/public/order/v1/getListFreight");
String result = shunfengSignUtils.generateSignatureAndRequestNew(hBody, "/public/order/v1/getListFreight");
HashMap hashMap = JsonUtils.fromJson(result, HashMap.class);
System.out.println(result);
if (hashMap.get("succ").equals("fail")) {
......@@ -462,11 +462,11 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
.notIn("express_status", expressStatus)
);
if (null != orderExpressInfo) {
HashMap<String, Object> hBody = new HashMap<>();
Map<String, String> hBody = new HashMap<>();
hBody.put("orderId", orderExpressInfo.getOrderExpressCode());
// 生成签名并请求
String result = shunfengSignUtils.generateSignatureAndRequest(hBody, "/public/order/v1/listOrderRoute");
String result = shunfengSignUtils.generateSignatureAndRequestNew(hBody, "/public/order/v1/listOrderRoute");
HashMap hashMap = JsonUtils.fromJson(result, HashMap.class);
System.out.println(result);
if (hashMap.get("succ").equals("fail")) {
......@@ -499,7 +499,7 @@ public class PerformancesExpressServiceImpl extends ServiceImpl<KylinOrderExpres
}
// @Async
public void batchPlaceOrder(String performanceId) throws Exception {
public void batchPlaceOrder(String performanceId) {
int count;
int limitNum = 10;
int mid = 0;
......
......@@ -2,6 +2,7 @@ package com.liquidnet.client.admin.zhengzai.kylin.utils;
import com.liquidnet.client.admin.common.utils.StringUtils;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.KeyManagementException;
......@@ -13,6 +14,7 @@ import java.util.Map;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
......@@ -29,11 +31,14 @@ import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
/**
* author:
* date:
* time:
* description: HttpClient调用Https接口封装.
* <p>
* HttpClientUtils
* </p>
*
* @author jiangxiulong
* @since 2021-07-07
*/
@Component
public class HttpClientUtils {
......
package com.liquidnet.client.admin.zhengzai.kylin.utils;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.UserPathDto;
import com.liquidnet.service.kylin.entity.KylinOrderExpress;
import com.liquidnet.service.kylin.mapper.KylinOrderExpressMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
......@@ -57,15 +55,12 @@ public class ShunfengSignUtils {
*/
private final static Long CHECK_TIME = 600000L;
@Autowired
private KylinOrderExpressMapper kylinOrderExpressMapper;
/**
* 生成签名并请求
* @param hbody 请求body
* @return
*/
public String generateSignatureAndRequestTest(Map<String, String> hbody, String url) throws Exception {
public String generateSignatureAndRequestNew(Map<String, String> hbody, String url) {
long currentTimeMillis = System.currentTimeMillis(); // 时间戳
String timestamp = currentTimeMillis + "";
hbody.put("companyId", APP_ID);
......@@ -79,21 +74,25 @@ public class ShunfengSignUtils {
headers.put("sign", sign);
headers.put("Content-Type", "application/json;charset=utf-8");
headers.put("Accept", "application/json");
// CloseableHttpClient client = HttpClients.createDefault();
Map<String, String> querys = new HashMap<>();
HttpResponse httpResponse = HttpClientUtils.doPost(URL, url, "", headers, querys, hbody);
System.out.println(httpResponse);
if (httpResponse.getStatusLine().getStatusCode() == 200) {
System.out.println("发送请求成功");
HttpEntity entity = httpResponse.getEntity();
// 发送响应且编码UTF8!!!
return EntityUtils.toString(entity, "utf-8");
try {
HttpResponse httpResponse = HttpClientUtils.doPost(URL, url, "", headers, querys, body);
if (httpResponse.getStatusLine().getStatusCode() == 200) {
System.out.println("发送请求成功");
HttpEntity entity = httpResponse.getEntity();
// 发送响应且编码UTF8!!!
return EntityUtils.toString(entity, "utf-8");
}
} catch (Exception e) {
System.out.println("发送请求失败");
e.printStackTrace();
return e.getMessage();
}
return "error";
return null;
}
/**
* 生成签名并请求
* 生成签名并请求 线上Received fatal alert:handshake_failure 废弃
* @param hbody 请求body
* @return
*/
......@@ -191,47 +190,4 @@ public class ShunfengSignUtils {
return Base64.encodeBase64URLSafeString(bytes);
}
/**
* 接收请求且验签(可在控制层调用此方法)
* @param params 接收请求参数
* @param request 接收请求
* @return
*/
public boolean receiveRequestAndCheckSign(String params, HttpServletRequest request) {
// 请求方APPID
String sendAppId = request.getHeader("sendAppId");
// 请求方时间戳
String timestamp = request.getHeader("timestamp");
// 请求方签名
String sign = request.getHeader("sign");
if (StringUtils.isBlank(sendAppId)) {
System.out.println("参数sendAppId不能为空");
return false;
}
if (StringUtils.isBlank(timestamp)) {
System.out.println("参数timestamp不能为空");
return false;
}
if (StringUtils.isBlank(sign)) {
System.out.println("参数sign不能为空");
return false;
}
// 校验签名是否过期
long requestTime = Long.parseLong(timestamp);
long now = System.currentTimeMillis();
if (Math.abs(now - requestTime) > CHECK_TIME) {
System.out.println("签名过期!");
return false;
}
// 请求方参数+请求方时间戳+SK 生成签名
String thisSign = genSign(timestamp, params);
// 获取的签名和请求方签名比较是否一致
if (!thisSign.equals(sign)) {
System.out.println("签名错误");
return false;
}
return true;
}
}
package com.liquidnet.service.dragon.config;
import com.liquidnet.service.dragon.receiver.RedisReceiver;
import com.liquidnet.service.dragon.receiver.RedisPayReceiver;
import com.liquidnet.service.dragon.receiver.RedisRefundReceiver;
import lombok.var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
......@@ -18,18 +19,62 @@ import java.time.Duration;
public class RedisStreamConfig {
@Autowired
private RedisReceiver redisReceiver;
private RedisPayReceiver redisPayReceiver;
@Autowired
private RedisRefundReceiver redisRefundReceiver;
@Bean
public Subscription subscriptionPay0(RedisConnectionFactory factory) {
var options = StreamMessageListenerContainer
.StreamMessageListenerContainerOptions
.builder()
.pollTimeout(Duration.ofMillis(1))
.build();
var listenerContainer = StreamMessageListenerContainer.create(factory, options);
var subscription = listenerContainer.receiveAutoAck(Consumer.from("dragon-pay-group", "dragon-pay-0"),
StreamOffset.create("dragon-pay", ReadOffset.lastConsumed()), redisPayReceiver);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionPay1(RedisConnectionFactory factory) {
var options = StreamMessageListenerContainer
.StreamMessageListenerContainerOptions
.builder()
.pollTimeout(Duration.ofMillis(1))
.build();
var listenerContainer = StreamMessageListenerContainer.create(factory, options);
var subscription = listenerContainer.receiveAutoAck(Consumer.from("dragon-pay-group", "dragon-pay-1"),
StreamOffset.create("dragon-pay", ReadOffset.lastConsumed()), redisPayReceiver);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionRefund0(RedisConnectionFactory factory) {
var options = StreamMessageListenerContainer
.StreamMessageListenerContainerOptions
.builder()
.pollTimeout(Duration.ofMillis(1))
.build();
var listenerContainer = StreamMessageListenerContainer.create(factory, options);
var subscription = listenerContainer.receiveAutoAck(Consumer.from("dragon-refund-group", "dragon-refund-0"),
StreamOffset.create("dragon-refund", ReadOffset.lastConsumed()), redisRefundReceiver);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscription(RedisConnectionFactory factory){
public Subscription subscriptionRefund1(RedisConnectionFactory factory) {
var options = StreamMessageListenerContainer
.StreamMessageListenerContainerOptions
.builder()
.pollTimeout(Duration.ofSeconds(1))
.pollTimeout(Duration.ofMillis(1))
.build();
var listenerContainer = StreamMessageListenerContainer.create(factory,options);
var subscription = listenerContainer.receiveAutoAck(Consumer.from("group-1","consumer-1"),
StreamOffset.create("mystream", ReadOffset.lastConsumed()),redisReceiver);
var listenerContainer = StreamMessageListenerContainer.create(factory, options);
var subscription = listenerContainer.receiveAutoAck(Consumer.from("dragon-refund-group", "dragon-refund-1"),
StreamOffset.create("dragon-refund", ReadOffset.lastConsumed()), redisRefundReceiver);
listenerContainer.start();
return subscription;
}
......
package com.liquidnet.service.dragon.controller;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.dragon.service.IDragonOrdersService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("pay")
public class PayController {
@Autowired
IDragonOrdersService dragonOrdersService;
@PostMapping("pre")
@ApiOperation("发送测试redis")
@ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<String> checkCanOrder() {
dragonOrdersService.sendRedisQueue();
return ResponseDto.success();
}
}
......@@ -7,11 +7,11 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public class RedisReceiver implements StreamListener<String, MapRecord<String, String, String>> {
public class RedisPayReceiver implements StreamListener<String, MapRecord<String, String, String>> {
@Override
public void onMessage(MapRecord<String, String, String> message) {
log.info("接受到来自redis的消息");
log.info("接受到来自redis PAY 的消息");
System.out.println("message id "+message.getId());
System.out.println("stream "+message.getStream());
System.out.println("body "+message.getValue());
......
package com.liquidnet.service.dragon.receiver;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.stream.StreamListener;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class RedisRefundReceiver implements StreamListener<String, MapRecord<String, String, String>> {
@Override
public void onMessage(MapRecord<String, String, String> message) {
log.info("接受到来自redis REFUND 的消息");
System.out.println("message id "+message.getId());
System.out.println("stream "+message.getStream());
System.out.println("body "+message.getValue());
}
}
......@@ -20,7 +20,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
try {
HashMap<String ,String> map = new HashMap<>();
map.put("message","测试 redis 订阅信息1");
MapRecord<String, String, String> record = StreamRecords.mapBacked(map).withStreamKey("mystream");
MapRecord<String, String, String> record = StreamRecords.mapBacked(map).withStreamKey("dragon-refund");
stringRedisTemplate.opsForStream().add(record);
}catch (Exception e){
e.printStackTrace();
......
package com.liquidnet.service.dragon.service.impl;
import com.liquidnet.service.dragon.service.IDragonOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.HashMap;
@Service
public class DragonOrdersServiceImpl implements IDragonOrdersService {
@Autowired
StringRedisTemplate stringRedisTemplate;
@Override
public void sendRedisQueue() {
try {
HashMap<String ,String> map = new HashMap<>();
map.put("message","测试 redis 订阅信息1");
MapRecord<String, String, String> record = StreamRecords.mapBacked(map).withStreamKey("dragon-pay");
stringRedisTemplate.opsForStream().add(record);
}catch (Exception e){
e.printStackTrace();
}
}
}
......@@ -105,14 +105,14 @@ public class KylinRefundsStatusServiceImpl {
);
// 入场人
double priceActual = orderInfo.getPriceActual().doubleValue();
double priceExpress = orderInfo.getPriceExpress().doubleValue();
BigDecimal priceActual = orderInfo.getPriceActual();
BigDecimal priceExpress = orderInfo.getPriceExpress();
int allEntitiesCount = kylinOrderTicketEntitiesMapper.selectCount(// 总入场人数量 排出未付款的 用来计算单入场人的价格
new QueryWrapper<KylinOrderTicketEntities>()
.eq("order_id", orderTicketsId)
.ne("is_payment", KylinTableStatusConst.ENTITIES_IS_PAYMENT0)
);
double onePrice = (priceActual - priceExpress) / allEntitiesCount;//单价
BigDecimal onePrice = priceActual.subtract(priceExpress).divide(BigDecimal.valueOf(allEntitiesCount));//单价
int refundNumber = 0;
for (String entitiesId : orderTicketEntitiesIdsArr) {
KylinOrderTicketEntities EntitiesInfo = kylinOrderTicketEntitiesMapper.selectOne(//已退完成的
......@@ -128,9 +128,9 @@ public class KylinRefundsStatusServiceImpl {
);
KylinOrderTicketEntities entitiesTable = new KylinOrderTicketEntities();
double priceNew = refundEntitiesInfo.getRefundPrice().doubleValue() + refundedPrice.doubleValue();
BigDecimal priceNew = refundEntitiesInfo.getRefundPrice().add(refundedPrice);
int isPayment = 0;
if (priceNew == onePrice) {
if (priceNew.compareTo(onePrice) == 0) {
isPayment = KylinTableStatusConst.ENTITIES_IS_PAYMENT3;
refundNumber++;
} else {
......@@ -138,7 +138,7 @@ public class KylinRefundsStatusServiceImpl {
}
entitiesTable.setIsPayment(isPayment);
entitiesTable.setUpdatedAt(LocalDateTime.now());
entitiesTable.setRefundPrice(BigDecimal.valueOf(priceNew));
entitiesTable.setRefundPrice(priceNew);
Integer[] entitiesTableIsPayment = {KylinTableStatusConst.ENTITIES_IS_PAYMENT2, KylinTableStatusConst.ENTITIES_IS_PAYMENT4};
kylinOrderTicketEntitiesMapper.update(entitiesTable, new UpdateWrapper<KylinOrderTicketEntities>()
.eq("order_ticket_entities_id", entitiesId)
......@@ -147,7 +147,7 @@ public class KylinRefundsStatusServiceImpl {
HashMap<String, Object> EntitiesVo = new HashMap<>();
EntitiesVo.put("updatedAt", DateUtil.getNowTime());
EntitiesVo.put("refundPrice", BigDecimal.valueOf(priceNew));
EntitiesVo.put("refundPrice", priceNew);
EntitiesVo.put("isPayment", isPayment);
BasicDBObject EntitiesVov = new BasicDBObject("$set", mongoConverter.convertToMongoType(EntitiesVo));
UpdateResult updateResult = mongoTemplate.getCollection(KylinOrderTicketEntitiesVo.class.getSimpleName()).updateOne(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment