From e39865b79231c3716d320920e32b017ef5677c8f Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 18 十月 2024 13:41:46 +0800
Subject: [PATCH] 合并代码
---
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java | 118 +++++++++++++++++++++++++++++------------------------------
1 files changed, 58 insertions(+), 60 deletions(-)
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java
index 8dea47e..e2d28d5 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java
@@ -127,15 +127,15 @@
coupon = coupon.add(tActivityStatisticslVO.getCouponDiscountAmount());
stringBuilder.append("优惠券抵扣").append("+");
}
- if (tActivityStatisticslVO.getVipDiscountAmount()!=null
- &&
- (tActivityStatisticslVO.getCouponDiscountAmount().compareTo(BigDecimal.ZERO)>0)){
+ if (tActivityStatisticslVO.getVipDiscountAmount()!=null &&(tActivityStatisticslVO.getVipDiscountAmount().compareTo(BigDecimal.ZERO)>0)){
discount = discount.add(tActivityStatisticslVO.getVipDiscountAmount());
stringBuilder.append("会员抵扣").append("+");
}
- stringBuilder.deleteCharAt(stringBuilder.length()-1);
- tActivityStatisticslVO.setType(stringBuilder.toString());
- tActivityStatisticslVO.setTime(simpleDateFormat.format(tActivityStatisticslVO.getCreateTime()));
+ if (stringBuilder.length()>0){
+ stringBuilder.deleteCharAt(stringBuilder.length()-1);
+ tActivityStatisticslVO.setType(stringBuilder.toString());
+ }
+ tActivityStatisticslVO.setTime(tActivityStatisticslVO.getCreateTime());
break;
case 2:
StringBuilder stringBuilder1 = new StringBuilder();
@@ -155,7 +155,7 @@
}
stringBuilder1.deleteCharAt(stringBuilder1.length()-1);
tActivityStatisticslVO.setType(stringBuilder1.toString());
- tActivityStatisticslVO.setTime(simpleDateFormat.format(tActivityStatisticslVO.getCreateTime()));
+ tActivityStatisticslVO.setTime(tActivityStatisticslVO.getCreateTime());
break;
case 3:
// 会员订单 优惠金额大于0
@@ -165,19 +165,19 @@
vipActivity = vipActivity.add(tActivityStatisticslVO.getVipDiscountAmount());
}
tActivityStatisticslVO.setType("会员活动");
- tActivityStatisticslVO.setTime(simpleDateFormat.format(tActivityStatisticslVO.getCreateTime()));
+ tActivityStatisticslVO.setTime(tActivityStatisticslVO.getCreateTime());
break;
case 4:
// 赠送会员订单 如果支付金额为0 那么就是后台赠送的会员
if (tActivityStatisticslVO.getPaymentAmount().compareTo(BigDecimal.ZERO)==0){
grantVip = grantVip.add(tActivityStatisticslVO.getOrderAmount());
tActivityStatisticslVO.setType("赠送会员");
- tActivityStatisticslVO.setTime(simpleDateFormat.format(tActivityStatisticslVO.getCreateTime()));
+ tActivityStatisticslVO.setTime(tActivityStatisticslVO.getCreateTime());
}else{
// 赠送
grantVip = grantVip.add(tActivityStatisticslVO.getVipDiscountAmount());
tActivityStatisticslVO.setType("赠送会员");
- tActivityStatisticslVO.setTime(simpleDateFormat.format(tActivityStatisticslVO.getCreateTime()));
+ tActivityStatisticslVO.setTime(tActivityStatisticslVO.getCreateTime());
}
break;
}
@@ -255,7 +255,7 @@
TAppUserAddress userAddress = appUserAddressClient.getAppUserAddressById(shoppingOrder.getAppUserAddressId()).getData();
info.setConsignee(userAddress.getName());
info.setPhone(userAddress.getPhone());
- info.setAddress(userAddress.getProvince() + userAddress.getCity() + userAddress.getAddress());
+ info.setAddress(userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getAddress());
info.setExpressCompany(shoppingOrder.getExpressCompany());
info.setExpressNumber(shoppingOrder.getExpressNumber());
String name = "";
@@ -413,58 +413,56 @@
@Override
@GlobalTransactional(rollbackFor = Exception.class)//分布式事务
public AjaxResult cancelShoppingOrderWxRefund(String out_refund_no, String refund_id, String refund_status, String success_time) {
- if("SUCCESS".equals(refund_status)){
- TShoppingOrderRefund one = shoppingOrderRefundService.getOne(new LambdaQueryWrapper<TShoppingOrderRefund>().eq(TShoppingOrderRefund::getRefundCode, out_refund_no));
- one.setRefundStatus(2);
- one.setRefundSerialNumber(refund_id);
- one.setRefundTime(LocalDateTime.parse(success_time, DateTimeFormatter.ofPattern("yyyy-MM-DDTHH:mm:ss+TIMEZONE")));
- shoppingOrderRefundService.updateById(one);
- //判断是否需要回退库存
- TShoppingOrder shoppingOrder = this.getById(one.getShoppingOrderId());
- shoppingOrder.setStatus(4);
- shoppingOrder.setRefundCode(one.getRefundSerialNumber());
- shoppingOrder.setRefundAmount(one.getRefundAmount());
- shoppingOrder.setRefundStatus(2);
- shoppingOrder.setRefundTime(one.getRefundTime());
- this.updateById(shoppingOrder);
-
- //商品
- if(shoppingOrder.getOrderType() == 1){
- //redis锁 和支付使用同一个锁
- RedisLock redisLock = new RedisLock(redisTemplate, "SHOPPING_GOODS_LOCK", 5, 30000);
- try {
- redisLock.lock();
- TGoods goods = goodsClient.getGoodsById(shoppingOrder.getGoodsId()).getData();
- Integer inventory = goods.getInventory();
- if(-1 != inventory){
- goods.setInventory(inventory + shoppingOrder.getPurchaseQuantity());
- goodsClient.updateGoods(goods);
- }
- }catch (Exception e){
- e.printStackTrace();
- }finally {
- //解锁
- redisLock.unlock();
+ TShoppingOrderRefund one = shoppingOrderRefundService.getOne(new LambdaQueryWrapper<TShoppingOrderRefund>().eq(TShoppingOrderRefund::getRefundCode, out_refund_no));
+ one.setRefundStatus(2);
+ one.setRefundSerialNumber(refund_id);
+ one.setRefundTime(LocalDateTime.now());
+ shoppingOrderRefundService.updateById(one);
+ //判断是否需要回退库存
+ TShoppingOrder shoppingOrder = this.getById(one.getShoppingOrderId());
+ shoppingOrder.setStatus(4);
+ shoppingOrder.setRefundCode(one.getRefundSerialNumber());
+ shoppingOrder.setRefundAmount(one.getRefundAmount());
+ shoppingOrder.setRefundStatus(2);
+ shoppingOrder.setRefundTime(one.getRefundTime());
+ this.updateById(shoppingOrder);
+
+ //商品
+ if(shoppingOrder.getOrderType() == 1){
+ //redis锁 和支付使用同一个锁
+ RedisLock redisLock = new RedisLock(redisTemplate, "SHOPPING_GOODS_LOCK", 5, 30000);
+ try {
+ redisLock.lock();
+ TGoods goods = goodsClient.getGoodsById(shoppingOrder.getGoodsId()).getData();
+ Integer inventory = goods.getInventory();
+ if(-1 != inventory){
+ goods.setInventory(inventory + shoppingOrder.getPurchaseQuantity());
+ goodsClient.updateGoods(goods);
}
+ }catch (Exception e){
+ e.printStackTrace();
+ }finally {
+ //解锁
+ redisLock.unlock();
}
- //优惠券
- if(shoppingOrder.getOrderType() == 2){
- //redis锁 和支付使用同一个锁
- RedisLock redisLock = new RedisLock(redisTemplate, "SHOPPING_COUPON_LOCK", 5, 30000);
- try {
- redisLock.lock();
- TCoupon coupon = couponClient.getCouponById1(shoppingOrder.getCouponId()).getData();
- Integer inventory = coupon.getInventoryQuantity();
- if(-1 != inventory){
- coupon.setInventoryQuantity(inventory + shoppingOrder.getPurchaseQuantity());
- couponClient.updateCoupon(coupon);
- }
- }catch (Exception e){
- e.printStackTrace();
- }finally {
- //解锁
- redisLock.unlock();
+ }
+ //优惠券
+ if(shoppingOrder.getOrderType() == 2){
+ //redis锁 和支付使用同一个锁
+ RedisLock redisLock = new RedisLock(redisTemplate, "SHOPPING_COUPON_LOCK", 5, 30000);
+ try {
+ redisLock.lock();
+ TCoupon coupon = couponClient.getCouponById1(shoppingOrder.getCouponId()).getData();
+ Integer inventory = coupon.getInventoryQuantity();
+ if(-1 != inventory){
+ coupon.setInventoryQuantity(inventory + shoppingOrder.getPurchaseQuantity());
+ couponClient.updateCoupon(coupon);
}
+ }catch (Exception e){
+ e.printStackTrace();
+ }finally {
+ //解锁
+ redisLock.unlock();
}
}
return AjaxResult.success();
--
Gitblit v1.7.1