luodangjia
2024-10-18 31f88974457d1d5cca726bdf8b05234eabc267fa
Merge remote-tracking branch 'origin/master'
3个文件已修改
109 ■■■■■ 已修改文件
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingGunServiceImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java 96 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingGunServiceImpl.java
@@ -4,6 +4,9 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.chargingPile.api.dto.TChargingGunDTO;
import com.ruoyi.chargingPile.api.feignClient.SiteClient;
import com.ruoyi.chargingPile.api.model.Site;
import com.ruoyi.chargingPile.api.model.TAccountingStrategy;
import com.ruoyi.chargingPile.api.model.TChargingGun;
import com.ruoyi.chargingPile.api.model.TChargingPile;
import com.ruoyi.chargingPile.api.query.TChargingGunQuery;
@@ -11,6 +14,7 @@
import com.ruoyi.chargingPile.domain.SiteMenu;
import com.ruoyi.chargingPile.mapper.TChargingGunMapper;
import com.ruoyi.chargingPile.service.IPartnerService;
import com.ruoyi.chargingPile.service.TAccountingStrategyService;
import com.ruoyi.chargingPile.service.TChargingGunService;
import com.ruoyi.chargingPile.service.TChargingPileService;
import com.ruoyi.common.core.enums.status.ChargingGunModeEnum;
@@ -65,6 +69,9 @@
    
    @Resource
    private SendMessageClient sendMessageClient;
    @Resource
    private SiteClient siteClient;
    
    
@@ -99,6 +106,10 @@
            tChargingGunVO.setAuthQueryInfo(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.CHARGING_GUN_QUERY_INFO));
            tChargingGunVO.setAuthUpdate(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.CHARGING_GUN_UPDATE));
            tChargingGunVO.setAuthViewRates(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.CHARGING_GUN_VIEW_RATES));
            if(null == tChargingGunVO.getAccountingStrategyId()){
                Site site = siteClient.getSiteByIds(Arrays.asList(tChargingGunVO.getSiteId())).getData().get(0);
                tChargingGunVO.setAccountingStrategyId(site.getAccountingStrategyId());
            }
        }
        pageInfo.setRecords(list);
        return pageInfo;
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -318,6 +318,8 @@
    @Override
    public List<MyChargingOrderList> getNoInvoicedOrder(GetNoInvoicedOrder query) {
        Long appUserId = tokenService.getLoginUserApplet().getUserId();
        query.setPageCurr((query.getPageCurr() - 1) * query.getPageSize());
        List<TChargingOrder> orderList = this.baseMapper.getNoInvoicedOrder(appUserId, query.getMonth(), query.getPageCurr(), query.getPageSize());
        List<MyChargingOrderList> list = new ArrayList<>();
        for (TChargingOrder tChargingOrder : orderList) {
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java
@@ -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();