diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighUserCardController.java b/hai-cweb/src/main/java/com/cweb/controller/HighUserCardController.java index 5fbf0bb2..55f80eae 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighUserCardController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighUserCardController.java @@ -132,7 +132,12 @@ public class HighUserCardController { List list = highUserCardService.getListByUser(userInfoModel.getHighUser().getId(), type); for (HighUserCard card : list) { card.setBalance(new BigDecimal("0")); - if (card.getType().equals(UserCardType.type3.getType())) { + if (card.getType().equals(UserCardType.type2.getType())) { + HighOilCard oilCard = oilCardService.getOilCardByCardNo(card.getCardNo()); + if (oilCard != null) { + card.setOilCard(oilCard); + } + } else if (card.getType().equals(UserCardType.type3.getType())) { HighFleetOilCard fleetOilCard = fleetOilCardService.getFleetOilCardByCardNo(card.getCardNo()); if (fleetOilCard != null) { card.setBalance(fleetOilCard.getAmount()); diff --git a/hai-order/src/main/java/com/web/controller/TestController.java b/hai-order/src/main/java/com/web/controller/TestController.java index 58b9019d..e33706a6 100644 --- a/hai-order/src/main/java/com/web/controller/TestController.java +++ b/hai-order/src/main/java/com/web/controller/TestController.java @@ -1 +1 @@ -package com.web.controller; import com.alibaba.fastjson.JSONObject; import com.hai.common.utils.*; import com.hai.config.HuiLianTongConfig; import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.entity.HighOrder; import com.hai.model.ResponseData; import com.hai.order.model.CreateOrderModel; import com.hai.order.service.OrderService; import com.hai.order.type.OrderStatus; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.rocketmq.client.producer.SendCallback; import org.apache.rocketmq.client.producer.SendResult; import org.apache.rocketmq.common.message.Message; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.integration.support.MessageBuilder; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.LinkedList; import java.util.List; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class TestController { private static Logger log = LoggerFactory.getLogger(TestController.class); @Autowired private RocketMQTemplate rocketMQTemplate; @Resource private OrderService orderService; @Resource private RedisUtil redisUtil; @Autowired private RedisTemplate redisTemplate; @RequestMapping(value = "/q", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData q(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = orderService.getOrderDetailByNo(orderNo); if (order != null) { // orderService.refundOrder(orderNo, DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss")); // order.setRefundTime(new Date()); // orderService.updateOrderData(order); return ResponseMsgUtil.success("修改成功"); } return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighUserCardController --> rocketMq() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rocketMq", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData rocketMq(@RequestParam(name = "topicGroup", required = true) String topicGroup, @RequestParam(name = "body", required = true) String body) { try { long startTime = System.currentTimeMillis(); // org.springframework.messaging.Message message = MessageBuilder.withPayload(order).build(); CreateOrderModel createOrder = new CreateOrderModel(); //发送对象消息 HighOrder order = rocketMQTemplate.sendAndReceive("order-topic:create", createOrder, HighOrder.class); System.out.println("订单号:" + order.getOrderNo()); // SendResult sendResult = rocketMQTemplate.syncSend("order-topic:create", message, 3000); /*List list = new LinkedList<>(); for (int i = 0; i <= 100;i++) { list.add(orderService.getDetailByOrderNo("HF2022080918014365701")); *//* list.add(orderService.getDetailByOrderNo("HF2022080918014365701"));*//* *//* updateUserWithRedisLock("coupon_" + couponKey, i+""); new Thread(() -> {*//* *//* redisTemplate.opsForValue().setIfAbsent("coupon_" + couponKey, i); System.out.println("加入数据" + i);*//* // redisTemplate.delete("coupon" + couponKey); // System.out.println("释放数据" + index); *//* });*//* }*/ System.out.println(System.currentTimeMillis() - startTime); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighUserCardController --> rocketMq() error!", e); return ResponseMsgUtil.exception(e); } } public void updateUserWithRedisLock(String couponKey, String value) throws InterruptedException { // 占分布式锁,去redis占坑 // 1. 分布式锁占坑 Boolean lock = redisTemplate.opsForValue().setIfAbsent("coupon" + couponKey, value); if(lock) { //加锁成功... // todo business System.out.println("加锁成功: " + value); redisTemplate.delete("coupon" + couponKey); //删除key,释放锁 } else { System.out.println("加锁失败"); /* Thread.sleep(100); // 加锁失败,重试 updateUserWithRedisLock("sysUser");*/ } } } \ No newline at end of file +package com.web.controller; import com.alibaba.fastjson.JSONObject; import com.hai.common.utils.*; import com.hai.config.HuiLianTongConfig; import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.entity.HighOrder; import com.hai.model.ResponseData; import com.hai.order.model.CreateOrderModel; import com.hai.order.service.OrderPaySuccessService; import com.hai.order.service.OrderService; import com.hai.order.service.impl.OrderPaySuccessServiceImpl; import com.hai.order.type.OrderStatus; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.rocketmq.client.producer.SendCallback; import org.apache.rocketmq.client.producer.SendResult; import org.apache.rocketmq.common.message.Message; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.integration.support.MessageBuilder; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.LinkedList; import java.util.List; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class TestController { private static Logger log = LoggerFactory.getLogger(TestController.class); @Autowired private RocketMQTemplate rocketMQTemplate; @Resource private OrderService orderService; @Resource private RedisUtil redisUtil; @Autowired private RedisTemplate redisTemplate; @Resource private OrderPaySuccessServiceImpl orderPaySuccessService = new OrderPaySuccessServiceImpl(); @RequestMapping(value = "/q", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData q(@RequestParam(name = "orderNo", required = true) String orderNo) { try { orderPaySuccessService.orderBusHandle(orderService.getOrderDetailByNo("2023110818090759160")); /* HighOrder order = orderService.getOrderDetailByNo(orderNo); if (order != null) { // orderService.refundOrder(orderNo, DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss")); // order.setRefundTime(new Date()); // orderService.updateOrderData(order); return ResponseMsgUtil.success("修改成功"); }*/ return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighUserCardController --> rocketMq() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rocketMq", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData rocketMq(@RequestParam(name = "topicGroup", required = true) String topicGroup, @RequestParam(name = "body", required = true) String body) { try { long startTime = System.currentTimeMillis(); // org.springframework.messaging.Message message = MessageBuilder.withPayload(order).build(); CreateOrderModel createOrder = new CreateOrderModel(); //发送对象消息 HighOrder order = rocketMQTemplate.sendAndReceive("order-topic:create", createOrder, HighOrder.class); System.out.println("订单号:" + order.getOrderNo()); // SendResult sendResult = rocketMQTemplate.syncSend("order-topic:create", message, 3000); /*List list = new LinkedList<>(); for (int i = 0; i <= 100;i++) { list.add(orderService.getDetailByOrderNo("HF2022080918014365701")); *//* list.add(orderService.getDetailByOrderNo("HF2022080918014365701"));*//* *//* updateUserWithRedisLock("coupon_" + couponKey, i+""); new Thread(() -> {*//* *//* redisTemplate.opsForValue().setIfAbsent("coupon_" + couponKey, i); System.out.println("加入数据" + i);*//* // redisTemplate.delete("coupon" + couponKey); // System.out.println("释放数据" + index); *//* });*//* }*/ System.out.println(System.currentTimeMillis() - startTime); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighUserCardController --> rocketMq() error!", e); return ResponseMsgUtil.exception(e); } } public void updateUserWithRedisLock(String couponKey, String value) throws InterruptedException { // 占分布式锁,去redis占坑 // 1. 分布式锁占坑 Boolean lock = redisTemplate.opsForValue().setIfAbsent("coupon" + couponKey, value); if(lock) { //加锁成功... // todo business System.out.println("加锁成功: " + value); redisTemplate.delete("coupon" + couponKey); //删除key,释放锁 } else { System.out.println("加锁失败"); /* Thread.sleep(100); // 加锁失败,重试 updateUserWithRedisLock("sysUser");*/ } } } \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/entity/HighUserCard.java b/hai-service/src/main/java/com/hai/entity/HighUserCard.java index 3055782f..3fcb0633 100644 --- a/hai-service/src/main/java/com/hai/entity/HighUserCard.java +++ b/hai-service/src/main/java/com/hai/entity/HighUserCard.java @@ -67,6 +67,19 @@ public class HighUserCard implements Serializable { */ private String contactName; + /** + * 油卡 + */ + private HighOilCard oilCard; + + public HighOilCard getOilCard() { + return oilCard; + } + + public void setOilCard(HighOilCard oilCard) { + this.oilCard = oilCard; + } + public BigDecimal getBalance() { return balance; } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOilCardRecordServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOilCardRecordServiceImpl.java index 04311f2a..1c3d25b6 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOilCardRecordServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOilCardRecordServiceImpl.java @@ -4,6 +4,7 @@ import com.hai.common.security.UserCenter; import com.hai.dao.HighOilCardRecordMapper; import com.hai.entity.HighOilCardRecord; import com.hai.entity.HighOilCardRecordExample; +import com.hai.enum_type.OilCardRecordSourceTypeEnum; import com.hai.model.HighUserModel; import com.hai.model.UserInfoModel; import com.hai.service.HighOilCardRecordService; @@ -30,15 +31,17 @@ public class HighOilCardRecordServiceImpl implements HighOilCardRecordService { oilCardRecord.setOpUserId(0L); oilCardRecord.setOpUserName("无"); - UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); - if (userInfoModel != null) { - oilCardRecord.setOpUserId(userInfoModel.getSecUser().getId()); - oilCardRecord.setOpUserName(userInfoModel.getSecUser().getUserName()); - } - HighUserModel userModel = userCenter.getSessionModel(HighUserModel.class); - if (userModel != null) { - oilCardRecord.setOpUserId(userModel.getHighUser().getId()); - oilCardRecord.setOpUserName(userModel.getHighUser().getName()); + if (!oilCardRecord.getSourceType().equals(OilCardRecordSourceTypeEnum.type5.getType())) { + UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); + if (userInfoModel != null) { + oilCardRecord.setOpUserId(userInfoModel.getSecUser().getId()); + oilCardRecord.setOpUserName(userInfoModel.getSecUser().getUserName()); + } + HighUserModel userModel = userCenter.getSessionModel(HighUserModel.class); + if (userModel != null) { + oilCardRecord.setOpUserId(userModel.getHighUser().getId()); + oilCardRecord.setOpUserName(userModel.getHighUser().getName()); + } } oilCardRecord.setCreateTime(new Date()); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 1c63a18d..f50b5732 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -369,7 +369,7 @@ public class HighOrderServiceImpl implements HighOrderService { } @Override - @Transactional(propagation = Propagation.REQUIRES_NEW) + @Transactional(propagation = Propagation.REQUIRED) public void updateOrder(HighOrder highOrder) { highOrderMapper.updateByPrimaryKey(highOrder);