Browse Source

账单页面优化,产品列表接口

lishiqiang 1 month atrás
parent
commit
f50bc3bd3e

+ 158 - 5
ship-module-ota/ship-module-ota-biz/src/main/java/com/yc/ship/module/ota/service/distributorrecharge/DistributorRechargeServiceImpl.java

@@ -32,6 +32,7 @@ import com.yc.ship.module.otc.api.store.dto.StoreInfoReqDTO;
 import com.yc.ship.module.otc.api.store.dto.StoreReqDTO;
 import com.yc.ship.module.otc.api.store.dto.StoreRespDTO;
 import com.yc.ship.module.otc.enums.StoreBalanceTypeEnum;
+import com.yc.ship.module.otc.enums.StoreCreditTypeEnum;
 import com.yc.ship.module.otc.enums.TradeModeEnum;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -423,23 +424,124 @@ public class DistributorRechargeServiceImpl implements DistributorRechargeServic
                             break;
                         case 5:
                         case 10:
-                            //预付款退款 定向库存退款
+                            break;
+                        case 20:
+                            //预付款退款 定向库存退款 导游代退失败回退预存款
                             beforeBalance = distributor.getBalance();
                             //交易后金额
                             afterBalance = beforeBalance.add(money);
                             AtomicBoolean isShareBalance = new AtomicBoolean(false);
-
-
-
+                            AtomicReference<StoreRespDTO> storeRespDTO = new AtomicReference<>();
+//                            if (rechargeReqDTO.getStoreId() != null){
+//                                StoreReqDTO reqDTO = this.convertStorePlatBalance(rechargeReqDTO.getStoreId(), tradeMode, money, Long.parseLong(rechargeReqDTO.getOrderId()), tradeType, rechargeReqDTO.getRefundId());
+//                                TenantUtils.execute(distributor.getAccountTenantId(), () -> {
+//                                    StoreInfoReqDTO storeData = storeApi.getStoreById(rechargeReqDTO.getStoreId()).getCheckedData();
+//                                    if(ObjectUtil.equals(storeData.getBalanceType(), StoreBalanceTypeEnum.FIXED.getType())){
+//                                        CommonResult<StoreRespDTO> storeResult = storeApi.storePlatTrade(reqDTO);
+//                                        Asserts.isTrue(storeResult.isSuccess(), storeResult.getMsg());
+//                                        storeRespDTO.set(storeResult.getCheckedData());
+//                                    }else{
+//                                        isShareBalance.set(true);
+//                                    }
+//                                });
+//                            }else{
+//                                isShareBalance.set(true);
+//                            }
+
+                            if(true){
+                                tradeName =(tradeType==10?"定向库存":"")+"余额退款金额:" + money + "元,退款到账后剩余余额" + afterBalance + "元";
+                                //操作账户资金
+                                flag = distributorService.addBalance(distributor.getId(), money);
+                            }else if(storeRespDTO.get()!=null){
+                                StoreRespDTO storeRsp = storeRespDTO.get();
+                                beforeBalance = storeRsp.getBeforeAmount();
+                                afterBalance = storeRsp.getAfterAmount();
+                                tradeName = (tradeType==10?"定向库存":"")+"余额退款金额:" + money + "元,退款到账后门店账户剩余余额" + storeRsp.getAfterAmount() + "元;";
+                                flag = true;
+                            }
                             break;
                         case 2:
-                            //授信账单还款充值
+                            AtomicBoolean isShareCredit = new AtomicBoolean(false);
+                            storeRespDTO = new AtomicReference<>();
+                            if (rechargeReqDTO.getStoreId() != null){
+                                //只充门店
+                                StoreReqDTO reqDTO = this.convertStorePlatCredit(rechargeReqDTO.getStoreId(), tradeMode, money, Long.parseLong(rechargeReqDTO.getOrderId()), tradeType, rechargeReqDTO.getRefundId());
+                                TenantUtils.execute(distributor.getAccountTenantId(), () -> {
+                                    StoreInfoReqDTO storeData = storeApi.getStoreById(rechargeReqDTO.getStoreId()).getCheckedData();
+                                    if(ObjectUtil.equals(storeData.getCreditType(), StoreCreditTypeEnum.FIXED.getType())) {
+                                        CommonResult<StoreRespDTO> storeResult = storeApi.storePlatTrade(reqDTO);
+                                        Asserts.isTrue(storeResult.isSuccess(), storeResult.getMsg());
+                                        storeRespDTO.set(storeResult.getCheckedData());
+                                    }else{
+                                        isShareCredit.set(true);
+                                    }
+                                });
+                            }else{
+                                isShareCredit.set(true);
+                            }
+                            if(isShareCredit.get()){
+                                //充平台
+                                beforeBalance = distributor.getSurplus();
+                                //退款后已用额度 = 当前已用额度 - 退款金额
+                                afterBalance = beforeBalance.subtract(money);
+                                //分销商授信额度
+                                BigDecimal payCredit = distributor.getPayCredit();
+                                if (payCredit != null) {
+                                    BigDecimal creditRemained = payCredit.subtract(afterBalance);
+                                    tradeName = "授信账单还款充值金额:" + money + "元,授信总额度" + payCredit + "元,充值后剩余额度" + creditRemained + "元;已用额度" + afterBalance + "元";
+
+                                } else {
+                                    tradeName = "授信账单还款充值金额:" + money + "元,授信总额度不限,充值后剩余额度不限;已用额度" + afterBalance + "元";
+                                }
+                                flag = distributorService.subSurplus(distributor.getId(), money);
+                            }else if(storeRespDTO.get()!=null){
+                                StoreRespDTO storeRsp = storeRespDTO.get();
+                                beforeBalance = storeRsp.getBeforeAmount();
+                                afterBalance = storeRsp.getAfterAmount();
+                                tradeName = "授信账单还款金额:" + money + "元,退款到账后门店已使用授信从" + storeRsp.getBeforeAmount() + "元;变为"+ storeRsp.getAfterAmount();
+                                flag = true;
+                            }
                             break;
                         case 8:
                             //授信退款
                             beforeBalance = distributor.getSurplus();
                             //退款后已用额度 = 当前已用额度 - 退款金额
                             afterBalance = beforeBalance.subtract(money);
+                            //分销商授信额度
+                            BigDecimal payCredit = distributor.getPayCredit();
+                            isShareCredit = new AtomicBoolean(false);
+                            storeRespDTO = new AtomicReference<>();
+                            if (rechargeReqDTO.getStoreId() != null){
+                                StoreReqDTO reqDTO = this.convertStorePlatCredit(rechargeReqDTO.getStoreId(), tradeMode, money, Long.parseLong(rechargeReqDTO.getOrderId()), tradeType, rechargeReqDTO.getRefundId());
+                                TenantUtils.execute(distributor.getAccountTenantId(), () -> {
+                                    StoreInfoReqDTO storeData = storeApi.getStoreById(rechargeReqDTO.getStoreId()).getCheckedData();
+                                    if(ObjectUtil.equals(storeData.getCreditType(), StoreCreditTypeEnum.FIXED.getType())){
+                                        CommonResult<StoreRespDTO> storeResult = storeApi.storePlatTrade(reqDTO);
+                                        Asserts.isTrue(storeResult.isSuccess(), storeResult.getMsg());
+                                        storeRespDTO.set(storeResult.getCheckedData());
+                                    }else{
+                                        isShareCredit.set(true);
+                                    }
+                                });
+                            }else{
+                                isShareCredit.set(true);
+                            }
+
+                            if(isShareCredit.get()){
+                                if (payCredit != null) {
+                                    BigDecimal creditRemained = payCredit.subtract(afterBalance);
+                                    tradeName = "授信退款金额:" + money + "元,授信总额度" + payCredit + "元,退款后剩余额度" + creditRemained + "元;已用额度" + afterBalance + "元";
+                                } else {
+                                    tradeName = "授信退款金额:" + money + "元,授信总额度不限,退款后剩余额度不限;已用额度" + afterBalance + "元";
+                                }
+                                flag = distributorService.subSurplus(distributor.getId(), money);
+                            }else if(storeRespDTO.get()!=null){
+                                StoreRespDTO storeRsp = storeRespDTO.get();
+                                beforeBalance = storeRsp.getBeforeAmount();
+                                afterBalance = storeRsp.getAfterAmount();
+                                tradeName = "授信退款金额:" + money + "元,退款到账后门店已使用授信从" + storeRsp.getBeforeAmount() + "元;变为"+ storeRsp.getAfterAmount();
+                                flag = true;
+                            }
 
                             break;
                         case 9:
@@ -572,6 +674,57 @@ public class DistributorRechargeServiceImpl implements DistributorRechargeServic
                     if (tradeType == DistributorTradeTypeEnum.CREDIT_TRANS.getType()) {
 
                         tradeMode = 2;
+                        //门店平台授信
+                        AtomicBoolean isShareCredit = new AtomicBoolean(false);
+                        AtomicReference<StoreRespDTO> storeRespDTO = new AtomicReference<>();
+//                        if (rechargeReqDTO.getStoreId() != null){
+//                            StoreReqDTO reqDTO = this.convertStorePlatCredit(rechargeReqDTO.getStoreId(), tradeMode, money, Long.parseLong(rechargeReqDTO.getOrderId()), tradeType, null);
+//                            TenantUtils.execute(distributor.getAccountTenantId(), () -> {
+//                                StoreInfoReqDTO storeData = storeApi.getStoreById(rechargeReqDTO.getStoreId()).getCheckedData();
+//                                if(ObjectUtil.equals(storeData.getCreditType(), StoreCreditTypeEnum.FIXED.getType())){
+//                                    CommonResult<StoreRespDTO> storeResult = storeApi.storePlatTrade(reqDTO);
+//                                    Asserts.isTrue(storeResult.isSuccess(), storeResult.getMsg());
+//                                    storeRespDTO.set(storeResult.getCheckedData());
+//                                }else if(ObjectUtil.equals(storeData.getCreditType(), StoreCreditTypeEnum.SHARE.getType())){
+//                                    isShareCredit.set(true);
+//                                }else {
+//                                    Asserts.isTrue(true,"该门店禁用授信支付方式");
+//                                }
+//
+//                            });
+//                        }else{
+//                            isShareCredit.set(true);
+//                        }
+                        if(true){
+                            Asserts.isTrue(isUseCredit, "分销商无授信交易权限!");
+                            // 授信总额
+                            BigDecimal payCredit = distributor.getPayCredit();
+                            // 交易前已使用额度
+                            beforeBalance = distributor.getSurplus();
+                            // 交易后已使用额度
+                            afterBalance = beforeBalance.add(money);
+                            if (payCredit != null) {
+                                if (afterBalance.compareTo(payCredit) > 0) {
+                                    if(originTradeType == DistributorTradeTypeEnum.BALANCE_TRANS.getType()){
+                                        throw exception0(11_028, "余额不足,交易失败!");
+                                    }else {
+                                        throw exception(CREDIT_INSUFFICIENT_FUNDS);
+                                    }
+
+                                }
+                                BigDecimal creditRemained = payCredit.subtract(afterBalance);
+                                tradeName = "授信消费金额:" + money + "元,授信总额度" + payCredit + "元,消费后剩余额度" + creditRemained + "元;已用额度" + afterBalance + "元";
+                            } else {
+                                tradeName = "授信消费金额:" + money + "元,授信总额度不限,消费后剩余额度不限;已用额度" + afterBalance + "元";
+                            }
+                            flag = distributorService.addSurplus(distributor.getId(), money);
+                        }else if(storeRespDTO.get()!=null){
+                            StoreRespDTO storeRsp = storeRespDTO.get();
+                            beforeBalance = storeRsp.getBeforeAmount();
+                            afterBalance = storeRsp.getAfterAmount();
+                            tradeName = "授信支付金额:" + money + "元,支付后门店已使用授信从" + storeRsp.getBeforeAmount() + "元;变为"+ storeRsp.getAfterAmount();
+                            flag = true;
+                        }
                     }
 
                     respDTO = new DistributorRechargeRespDTO();

+ 12 - 3
ship-module-ota/ship-module-ota-biz/src/main/java/com/yc/ship/module/ota/service/tradelog/TradeLogServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.yc.ship.framework.common.exception.ServiceException;
 import com.yc.ship.framework.common.pojo.PageResult;
 import com.yc.ship.framework.common.util.object.BeanUtils;
+import com.yc.ship.framework.security.core.LoginUser;
 import com.yc.ship.framework.tenant.core.util.TenantUtils;
 import com.yc.ship.module.ota.controller.admin.distributor.vo.LoginTypeRespVO;
 import com.yc.ship.module.ota.controller.admin.tradelog.vo.TradeLogPageReqVO;
@@ -16,6 +17,7 @@ import com.yc.ship.module.ota.dal.dataobject.tradelog.TradeLogDO;
 import com.yc.ship.module.ota.dal.mysql.tradelog.TradeLogMapper;
 import com.yc.ship.module.ota.enums.DistributorTradeTypeEnum;
 import com.yc.ship.module.ota.service.distributor.DistributorService;
+import com.yc.ship.module.ota.util.OtaAuthUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.redisson.api.RLock;
 import org.redisson.api.RedissonClient;
@@ -55,6 +57,9 @@ public class TradeLogServiceImpl implements TradeLogService {
     @Resource
     private DistributorService distributorService;
 
+    @Resource
+    private OtaAuthUtils otaAuthUtils;
+
     @Override
     public Long createTradeLog(TradeLogSaveReqVO createReqVO) {
         // 插入
@@ -115,11 +120,15 @@ public class TradeLogServiceImpl implements TradeLogService {
     @Override
     public PageResult<TradeLogDO> getTradeLogPage(TradeLogPageReqVO pageReqVO) {
         AtomicReference<PageResult<TradeLogDO>> pageResult = new AtomicReference<>();
-        LoginTypeRespVO getLoginType = distributorService.getLoginType();
+//        LoginTypeRespVO getLoginType = distributorService.getLoginType();
 //        if (getLoginType.getType() != 3) {
             // 旅行社端 或者 OTA端
-            if(pageReqVO.getDistributorId() == null) {
-                pageReqVO.setDistributorId(getLoginType.getDistributorId());
+//            if(pageReqVO.getDistributorId() == null) {
+//                pageReqVO.setDistributorId(getLoginType.getDistributorId());
+//            }
+            LoginUser loginUser = otaAuthUtils.getLoginUser();
+            if(loginUser!=null && loginUser.getDistributorId()!=null){
+                pageReqVO.setDistributorId(loginUser.getDistributorId());
             }
             TenantUtils.executeIgnore(() -> pageResult.set(getTradeLogPageData(pageReqVO)));
             return pageResult.get();

+ 128 - 0
ship-module-ota/ship-module-ota-biz/src/main/java/com/yc/ship/module/ota/util/OtaAuthUtils.java

@@ -0,0 +1,128 @@
+package com.yc.ship.module.ota.util;
+
+import cn.hutool.core.map.MapUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import com.yc.ship.framework.common.lang.Asserts;
+import com.yc.ship.framework.common.util.json.JsonUtils;
+import com.yc.ship.framework.security.core.LoginUser;
+import com.yc.ship.framework.security.core.util.SecurityFrameworkUtils;
+import com.yc.ship.framework.tenant.core.context.TenantContextHolder;
+import com.yc.ship.module.ota.api.OtaDistributorApi;
+import com.yc.ship.module.ota.api.dto.DistributorRespDTO;
+import com.yc.ship.module.otc.api.agency.AgencyAuthApi;
+import com.yc.ship.module.otc.api.agency.dto.AgencyUserLoginInfoReqDTO;
+import com.yc.ship.module.otc.api.agency.dto.AgencyUserLoginInfoRespDTO;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @Description :旅行社认证服务工具
+ * @Author :qsl
+ * @Date :2025/6/11 10:33
+ */
+@Component
+public class OtaAuthUtils {
+
+    @Resource
+    private AgencyAuthApi agencyAuthApi;
+
+    @Resource
+    private OtaDistributorApi otaDistributorApi;
+    @Resource
+    private StringRedisTemplate stringRedisTemplate;
+    private final static String AGENCY_LOGIN_INFO_KEY = "agency_login_info:%s:%s";
+    public final static String AGENCY_LOGIN_INFO = "agencyLoginInfo";
+    public final static String DISTRIBUTOR_LOGIN_INFO = "distributorLoginInfo";
+
+    public LoginUser getAgencyLoginUser(){
+        //获取当前登录用户
+        LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
+        if(loginUser!=null){
+            loginUser.setDistributorId(MapUtil.getLong(loginUser.getInfo(), LoginUser.INFO_KEY_DISTRIBUTOR_ID));
+            loginUser.setStoreId(MapUtil.getLong(loginUser.getInfo(), LoginUser.INFO_KEY_STORE_ID));
+        }
+        if(loginUser!=null && loginUser.getDistributorId()!=null) {
+            AgencyUserLoginInfoRespDTO agencyLoginInfo = getAgencyLoginInfoFromCache(loginUser.getId(), loginUser.getAccessToken());
+            if (agencyLoginInfo == null) {
+                AgencyUserLoginInfoReqDTO reqDTO = new AgencyUserLoginInfoReqDTO();
+                reqDTO.setUserId(loginUser.getId());
+                reqDTO.setAccessToken(loginUser.getAccessToken());
+                agencyLoginInfo = agencyAuthApi.getStoreSellerLoginInfo(reqDTO);
+                setAgencyLoginInfo(agencyLoginInfo, loginUser);
+            }
+            loginUser.setContext(AGENCY_LOGIN_INFO, agencyLoginInfo);
+        }
+        return loginUser;
+    }
+
+    public Long getLoginStoreId(){
+        return SecurityFrameworkUtils.getLoginStoreId();
+    }
+    public Long getLoginDistributorId(){
+        return SecurityFrameworkUtils.getLoginDistributorId();
+    }
+
+    public LoginUser getLoginUser(){
+        //获取当前登录用户
+        LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
+        AgencyUserLoginInfoRespDTO agencyLoginInfo = getAgencyLoginInfoFromCache(loginUser.getId(), loginUser.getAccessToken());
+        if(agencyLoginInfo == null){
+            AgencyUserLoginInfoReqDTO reqDTO = new AgencyUserLoginInfoReqDTO();
+            reqDTO.setUserId(loginUser.getId());
+            reqDTO.setAccessToken(loginUser.getAccessToken());
+            Long tenantId = TenantContextHolder.getTenantId();
+            try {
+                TenantContextHolder.setTenantId(loginUser.getTenantId());
+                agencyLoginInfo = agencyAuthApi.getStoreSellerLoginInfo(reqDTO);
+                setAgencyLoginInfo(agencyLoginInfo,loginUser);
+            }finally {
+                TenantContextHolder.setTenantId(tenantId);
+            }
+        }
+        loginUser.setContext(AGENCY_LOGIN_INFO,agencyLoginInfo);
+        return loginUser;
+    }
+
+    public DistributorRespDTO getLoginUserDistributorData(){
+        LoginUser loginUser = getDistributorLoginUser();
+        return loginUser.getContext(DISTRIBUTOR_LOGIN_INFO, DistributorRespDTO.class);
+    }
+
+    public LoginUser getDistributorLoginUser(){
+        //获取当前登录用户
+        LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
+        Asserts.isTrue(loginUser!=null,"无登录信息,请先登录");
+        DistributorRespDTO distributorRespDTO = getDistributorData(loginUser);
+        loginUser.setContext(DISTRIBUTOR_LOGIN_INFO,distributorRespDTO);
+        return loginUser;
+    }
+
+    @Cacheable(cacheNames = "getDistributorData#300",key="#loginUser.id")
+    public DistributorRespDTO getDistributorData(LoginUser loginUser){
+        AgencyUserLoginInfoReqDTO reqDTO = new AgencyUserLoginInfoReqDTO();
+        reqDTO.setUserId(loginUser.getId());
+        reqDTO.setAccessToken(loginUser.getAccessToken());
+        DistributorRespDTO distributorData = otaDistributorApi.getDistributorByLoginUserId(loginUser.getId());
+        return distributorData;
+    }
+
+
+    private AgencyUserLoginInfoRespDTO getAgencyLoginInfoFromCache(Long userId,String token){
+        String key = String.format(AGENCY_LOGIN_INFO_KEY, userId,token);
+        return JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key), AgencyUserLoginInfoRespDTO.class);
+    }
+
+    private void setAgencyLoginInfo(AgencyUserLoginInfoRespDTO agencyLoginInfo,LoginUser loginUser){
+        String key = String.format(AGENCY_LOGIN_INFO_KEY, loginUser.getId(),loginUser.getAccessToken());
+        stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(agencyLoginInfo), 600, TimeUnit.SECONDS);
+    }
+
+    private OtaAuthUtils getSelf(){
+        return SpringUtil.getBean(getClass());
+    }
+
+}

+ 2 - 0
ship-module-product/ship-module-product-api/src/main/java/com/yc/ship/module/product/api/ProductApi.java

@@ -13,6 +13,8 @@ public interface ProductApi {
 
     List<ProductSpuRespDTO> getProductListByTenantId( Long tenantId);
 
+    List<ProductSpuRespDTO> getAllProductList();
+
     List<ProductSpuRespDTO> getProductList(Collection<Long> ids);
 
 

+ 6 - 0
ship-module-product/ship-module-product-biz/src/main/java/com/yc/ship/module/product/api/ProductApiImpl.java

@@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -64,6 +65,11 @@ public class ProductApiImpl implements ProductApi {
         return productSpuService.getProductListByTenantId(tenantId).getData();
     }
 
+    @Override
+    public List<ProductSpuRespDTO> getAllProductList() {
+        return productSpuService.listAllSpu();
+    }
+
     @Override
     public List<ProductSpuRespDTO> getProductList(Collection<Long> ids) {
         List<ProductSpuDO> spuList = productSpuService.getProductList(ids);

+ 1 - 0
ship-module-product/ship-module-product-biz/src/main/java/com/yc/ship/module/product/dal/mysql/productSpu/ProductSpuMapper.java

@@ -45,6 +45,7 @@ public interface ProductSpuMapper extends BaseMapperX<ProductSpuDO> {
     }
 
     List<ProductSpuSimpleVO> selectSimpleList(@Param("param")ProductSpuPageReqVO reqVO);
+    List<ProductSpuSimpleVO> listAllSpu();
     List<ProductSpuSimpleVO> listByShipId(@Param("shipId")Long shipId);
     @TenantIgnore
     List<ProductSpuSimpleVO> selectPlatSimpleList(@Param("param")ProductSpuPageReqVO reqVO);

+ 2 - 0
ship-module-product/ship-module-product-biz/src/main/java/com/yc/ship/module/product/service/productSpu/ProductSpuService.java

@@ -93,6 +93,8 @@ public interface ProductSpuService {
 
     CommonResult<List<ProductSpuRespDTO>> getProductListByTenantId(Long tenantId);
 
+    List<ProductSpuRespDTO> listAllSpu();
+
     /**
      * 获得产品列表
      *

+ 6 - 0
ship-module-product/ship-module-product-biz/src/main/java/com/yc/ship/module/product/service/productSpu/ProductSpuServiceImpl.java

@@ -425,6 +425,12 @@ public class ProductSpuServiceImpl implements ProductSpuService {
         return success(BeanUtils.toBean(list, ProductSpuRespDTO.class));
     }
 
+    @Override
+    public List<ProductSpuRespDTO> listAllSpu() {
+        List<ProductSpuSimpleVO> list = productSpuMapper.listAllSpu();
+        return BeanUtils.toBean(list, ProductSpuRespDTO.class);
+    }
+
     @Override
     public List<ProductSpuDO> getProductList(Collection<Long> ids) {
         if (CollUtil.isEmpty(ids)) {

+ 23 - 0
ship-module-product/ship-module-product-biz/src/main/resources/mapper/productSpu/ProductSpuMapper.xml

@@ -305,6 +305,29 @@
         </if>
     </select>
 
+    <select id="listAllSpu" resultType="com.yc.ship.module.product.controller.admin.productSpu.spuVO.ProductSpuSimpleVO">
+        SELECT
+        distinct
+        ps.id,ps.product_name productName,
+        ps.product_code productCode,
+        ps.product_type productType,
+        ps.category_id categoryId,
+        pc.cate_name categoryName,
+        pc.sort_num cateSort,
+        ps.sale_price salePrice,
+        ps.cost_price costPrice,
+        ps.is_use isUse,
+        ps.day_num dayNum,
+        ps.sort_num sortNum
+        FROM
+        product_spu ps
+        inner join product_category pc on ps.category_id = pc.id
+        inner join product_basic_rule pbr on pbr.id = ps.id and pbr.deleted = 0
+        inner join product_spu_ship t3 on ps.id = t3.product_id
+        WHERE
+        ps.deleted = 0 AND ps.is_use = 1
+    </select>
+
     <select id="listByShipId" resultType="com.yc.ship.module.product.controller.admin.productSpu.spuVO.ProductSpuSimpleVO">
         SELECT
             distinct

+ 7 - 2
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/refund/impl/TradeRefundServiceImpl.java

@@ -231,7 +231,10 @@ public class TradeRefundServiceImpl implements TradeRefundService {
             }else {
                 tradeRefundRepositoryService.updateRefundStatus(refundAuditReqDTO.getRefundId(),RefundStatusEnum.PASS);
             }
-
+            CommonResult<?> commonResult = refundByPaymentType(refundDO.getId());
+            if(commonResult.isError()){
+                return CommonResult.error(commonResult.getCode(),commonResult.getMsg());
+            }
 //            TradeRefundBO tradeRefundBO =buildRefundOrderFromRefund(refundDO);
 //            CommonResult<?> supplerRefundResp = tradeSupplierService.refund(tradeRefundBO);
 //            if(supplerRefundResp.isError()){
@@ -288,7 +291,7 @@ public class TradeRefundServiceImpl implements TradeRefundService {
             if (lock.tryLock(60, 90, TimeUnit.SECONDS)) {
                 RefundDO refundDO = tradeRefundRepositoryService.getById(refundId);
                 //等待退款是正常流程,如是供应商退款失败需人工确认或者供应商还在退款审核中,则是是平台同意退款给游客,忽略供应商的退款状态
-                Asserts.isTrue(ObjectUtils.equalsAny(refundDO.getRefundStatus(),RefundStatusEnum.WAIT_REFUND.getStatus(),RefundStatusEnum.SUPPLIER_REFUND_MAN_HANDLE.getStatus(),RefundStatusEnum.SUPPLIER_REFUND_AUDITING.getStatus()),"退款单状态已变:{}",refundDO.getRefundStatus());
+//                Asserts.isTrue(ObjectUtils.equalsAny(refundDO.getRefundStatus(),RefundStatusEnum.WAIT_REFUND.getStatus(),RefundStatusEnum.SUPPLIER_REFUND_MAN_HANDLE.getStatus(),RefundStatusEnum.SUPPLIER_REFUND_AUDITING.getStatus()),"退款单状态已变:{}",refundDO.getRefundStatus());
                 //构建退款记录
                 List<RefundRecordDO> refundRecordDOList = buildRefundRecord(refundDO,REFUND_RECORD_TYPE_TRADE);
                 //变更为退款中
@@ -319,9 +322,11 @@ public class TradeRefundServiceImpl implements TradeRefundService {
                 }
             }
         }catch (ServiceException e){
+            e.printStackTrace();
             ExceptionUtils.log(log,"根据支付类型发起退款异常refundId:"+refundId,e);
             return CommonResult.error(e);
         } catch (Exception e){
+            e.printStackTrace();
             log.error("根据支付类型发起退款异常refundId:"+refundId,e);
         } finally {
             if(lock.isLocked() && lock.isHeldByCurrentThread()){