luodangjia
2025-02-07 8ffeb751b3a694e8d1cb6a21bec855f6c49b31b6
修改物流信息导入模板
13个文件已修改
277 ■■■■■ 已修改文件
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java 164 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java
@@ -77,13 +77,22 @@
            public R<List<AppUser>> getAppUserByName(String name) {
                return R.fail("根据用户名称模糊搜索用户列表失败:" + cause.getMessage());
            }
            @Override
            public R<List<AppUser>> getAppUserByNameNoFilter(String name) {
                return R.fail("根据用户名称模糊搜索用户列表失败:" + cause.getMessage());
            }
            @Override
            public R<List<AppUser>> getAppUserByPhone(String phone) {
                return R.fail("根据用户电话模糊搜索用户列表失败:" + cause.getMessage());
            }
            @Override
            public R<List<AppUser>> getAppUserByPhoneNoFilter(String phone) {
                return R.fail("根据用户电话模糊搜索用户列表失败:" + cause.getMessage());
            }
            @Override
            public R<Void> addAppUserShop(AppUserShop appUserShop) {
                return R.fail("添加失败");
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java
@@ -70,6 +70,9 @@
    @PostMapping("/app-user/getAppUserByName")
    R<List<AppUser>> getAppUserByName(@RequestParam("name") String name);
    @GetMapping("/app-user/getAppUserByNameNoFilter")
    public R<List<AppUser>> getAppUserByNameNoFilter(@RequestParam("name") String name);
    /**
     * 根据用户电话模糊搜索用户列表
     * @param phone
@@ -78,6 +81,9 @@
    @PostMapping("/app-user/getAppUserByPhone")
    R<List<AppUser>> getAppUserByPhone(@RequestParam("phone") String phone);
    @GetMapping("/app-user/getAppUserByPhoneNoFilter")
    public R<List<AppUser>> getAppUserByPhoneNoFilter(@RequestParam("phone") String phone);
    @PostMapping("/app-user/getAppUserByPhone1")
    R<AppUser> getAppUserByPhone1(@RequestParam("phone") String phone);
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -37,6 +37,7 @@
import com.ruoyi.system.api.feignClient.SysUserClient;
import com.ruoyi.system.api.model.LoginUser;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
@@ -64,6 +65,7 @@
@Api(tags = {"登录注册-小程序"})
@RestController
@RequestMapping("/app-user")
@Slf4j
public class AppUserController extends BaseController {
    
    @Resource
@@ -528,6 +530,16 @@
                .like(AppUser::getName, name));
        return R.ok(list);
    }
    /**
     * 根据用户名称模糊搜索用户列表,不过滤状态
     */
    @GetMapping("/getAppUserByNameNoFilter")
    public R<List<AppUser>> getAppUserByNameNoFilter(@RequestParam("name") String name) {
        List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>()
                .like(AppUser::getName, name));
        return R.ok(list);
    }
    /**
     * 根据用户电话模糊搜索用户列表
@@ -539,6 +551,15 @@
    public R<List<AppUser>> getAppUserByPhone(@RequestParam("phone") String phone) {
        List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1)
                .like(AppUser::getPhone, phone));
        return R.ok(list);
    }
    /**
     * 更具用户电话模糊查询用户列表,不过滤状态
     */
    @GetMapping("/getAppUserByPhoneNoFilter")
    public R<List<AppUser>> getAppUserByPhoneNoFilter(@RequestParam("phone") String phone) {
        List<AppUser> list = appUserService.getAppUserByPhoneNoFilter(phone);
        return R.ok(list);
    }
@@ -675,7 +696,9 @@
        AppUser byId = appUserService.getById(id);
        byId.setStatus(status);
        appUserService.updateById(byId);
        loginout(id);
        if (status == 2){
            loginout(id);
        }
        return R.ok();
    }
@@ -684,6 +707,9 @@
        if (!CollectionUtils.isEmpty(keys)) {
            for (String key : keys) {
                LoginUser user = redisService.getCacheObject(key);
                if (user == null || user.getUserid() == null) {
                    continue;
                }
                if (user.getUserid().equals(userId)) {
                    redisService.deleteObject(key);
                    break;
@@ -836,7 +862,11 @@
    @ApiOperation(value = "用户列表-绑定下级列表", tags = {"管理后台"})
    public R<Page<AppUser>> bottom(Long id, Integer pageNum, Integer pageSize) {
        //绑定下级
        Page<AppUser> page = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).page(Page.of(pageNum, pageSize));
        Page<AppUser> page = appUserService.lambdaQuery()
                .eq(AppUser::getInviteUserId, id)
                .eq(AppUser::getDelFlag, 0)
                .eq(AppUser::getStatus, 1)
                .page(Page.of(pageNum, pageSize));
        return R.ok(page);
    }
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserMapper.java
@@ -41,6 +41,8 @@
    UserStatisticsDetail getUserStatisticsDetail(@Param("shopId") Integer shopId, @Param("userId") Set<Long> userIds);
    List<AppUser> getAppUserByPhoneNoFilter(@Param("phone") String phone);
    
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java
@@ -111,4 +111,6 @@
     * 定时任务关闭订单
     */
    void closeOrder();
    List<AppUser> getAppUserByPhoneNoFilter(String phone);
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java
@@ -1055,4 +1055,9 @@
            }
        }
    }
    @Override
    public List<AppUser> getAppUserByPhoneNoFilter(String phone) {
        return this.baseMapper.getAppUserByPhoneNoFilter(phone);
    }
}
ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml
@@ -169,4 +169,7 @@
        and tau.del_flag = 0
        </where>
    </select>
    <select id="getAppUserByPhoneNoFilter" resultType="com.ruoyi.account.api.model.AppUser">
        SELECT * FROM t_app_user  WHERE phone like CONCAT('%',#{phone},'%')
    </select>
</mapper>
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
@@ -246,7 +246,6 @@
        List<Order> list = orderService.lambdaQuery()
                .eq(Order::getAppUserId, appUserId)
                .eq(null != shopId && -1 != shopId, Order::getShopId, shopId)
                .eq(Order::getDistributionMode, 1)
                .eq(Order::getPayStatus, 2)
                .isNull(Order::getRefundStatus)
                .eq(Order::getDelFlag, 0)
@@ -269,10 +268,7 @@
        return R.ok(list);
    }
    
    @PostMapping("/confirmDelivery")
    @ApiOperation(value = "已发货操作", tags = {"管理后台-订单管理"})
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -60,6 +60,7 @@
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -310,78 +311,112 @@
     */
    @Override
    public PageInfo<OrderPageListVo> getOrderPageList(OrderPageList orderPageList) {
        Long userid = tokenService.getLoginUser().getUserid();
        SysUser sysUser = sysUserClient.getSysUser(userid).getData();
        if(2 == sysUser.getRoleType()){
        Long userId = tokenService.getLoginUser().getUserid();
        SysUser sysUser = sysUserClient.getSysUser(userId).getData();
        // 设置店铺ID
        if (sysUser.getRoleType() == 2) {
            orderPageList.setShopId(sysUser.getObjectId());
        }
        //搜索条件,用户姓名
        if(StringUtils.isNotEmpty(orderPageList.getUserName())){
            List<AppUser> data = appUserClient.getAppUserByName(orderPageList.getUserName()).getData();
            List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList());
            if (CollectionUtils.isEmpty(collect)){
                return new PageInfo<>();
            }
            if(null != orderPageList.getAppUserIds()){
                List<Long> appUserIds = orderPageList.getAppUserIds();
                appUserIds.addAll(collect);
                orderPageList.setAppUserIds(appUserIds);
            }else{
                orderPageList.setAppUserIds(collect);
            }
        }
        //搜索条件,用户电话
        if(StringUtils.isNotEmpty(orderPageList.getPhone())){
            List<AppUser> data = appUserClient.getAppUserByPhone(orderPageList.getPhone()).getData();
            List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList());
            if (CollectionUtils.isEmpty(collect)){
               return new PageInfo<>();
            }
            if(null != orderPageList.getAppUserIds()){
                List<Long> appUserIds = orderPageList.getAppUserIds();
                appUserIds.addAll(collect);
                orderPageList.setAppUserIds(appUserIds);
            }else{
                orderPageList.setAppUserIds(collect);
            }
        }
        // 处理用户姓名搜索条件
        processAppUserIds(orderPageList, orderPageList.getUserName(), appUserClient::getAppUserByNameNoFilter);
        // 处理用户电话搜索条件
        processAppUserIds(orderPageList, orderPageList.getPhone(), appUserClient::getAppUserByPhoneNoFilter);
        // 去重 appUserIds
        Optional.ofNullable(orderPageList.getAppUserIds())
                .ifPresent(ids -> orderPageList.setAppUserIds(ids.stream().distinct().collect(Collectors.toList())));
        log.error("orderPageList:"+orderPageList.getAppUserIds());
        // 分页查询订单列表
        PageInfo<OrderPageListVo> pageInfo = new PageInfo<>(orderPageList.getPageCurr(), orderPageList.getPageSize());
        List<OrderPageListVo> list = this.baseMapper.getOrderPageList(pageInfo, orderPageList);
        for (OrderPageListVo orderPageListVo : list) {
            Long appUserId = orderPageListVo.getAppUserId();
            AppUser appUser = appUserClient.getAppUserById(appUserId);
            if(null != appUser){
                orderPageListVo.setUserName(appUser.getName());
                orderPageListVo.setPhone(appUser.getPhone());
            }
            RefundPass one = refundPassService.getOne(new LambdaQueryWrapper<RefundPass>().eq(RefundPass::getOrderId, orderPageListVo.getId()).eq(RefundPass::getDelFlag, 0).last(" order by create_time desc limit 0,1"));
            orderPageListVo.setRefundPassId(null != one ? one.getId().toString() : null);
            // 平台分佣
            List<ShopBalanceStatement> data = shopBalanceStatementClient.getShopBalanceStatementList(Arrays.asList(1, 2, 3), Long.valueOf(orderPageListVo.getId())).getData();
            BigDecimal reduce = data.stream().map(ShopBalanceStatement::getVariableAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
            orderPageListVo.setGetCommission(reduce);
        // 处理订单列表中的每个订单
        list.forEach(this::processOrderPageListVo);
            String expressJson = orderPageListVo.getExpressJson();
            if (StringUtils.isNotEmpty(expressJson) && !expressJson.equals("NULL")){
                JSONObject jsonObject = null;
                try {
                    jsonObject = JSONObject.parseObject(expressJson);
                    String companyName = ExpressCompanyMap.getCompanyNameByCode(jsonObject.getString("com"));
                    orderPageListVo.setExpressCompany(companyName);
                    orderPageListVo.setExpressNum(jsonObject.getString("num"));
                } catch (Exception e) {
                }
            }
        }
        return pageInfo.setRecords(list);
    }
    private void processAppUserIds(OrderPageList orderPageList, String searchKey, Function<String, R<List<AppUser>>> userSearchFunction) {
        if (StringUtils.isNotEmpty(searchKey)) {
            List<Long> userIds = Optional.ofNullable(userSearchFunction.apply(searchKey).getData())
                    .orElse(Collections.emptyList())
                    .stream()
                    .map(AppUser::getId)
                    .collect(Collectors.toList());
            if (CollectionUtils.isEmpty(userIds)) {
                return;
            }
            List<Long> existingUserIds = orderPageList.getAppUserIds();
            if (existingUserIds != null) {
                if (!containsAny(existingUserIds, userIds)) {
                    return;
                }
                existingUserIds.addAll(userIds);
            } else {
                orderPageList.setAppUserIds(userIds);
            }
        }
    }
    private void processOrderPageListVo(OrderPageListVo orderPageListVo) {
        Long appUserId = orderPageListVo.getAppUserId();
        Optional.ofNullable(appUserClient.getAppUserById(appUserId))
                .ifPresent(appUser -> {
                    orderPageListVo.setUserName(appUser.getName());
                    orderPageListVo.setPhone(appUser.getPhone());
                });
        Optional.ofNullable(refundPassService.getOne(new LambdaQueryWrapper<RefundPass>()
                        .eq(RefundPass::getOrderId, orderPageListVo.getId())
                        .eq(RefundPass::getDelFlag, 0)
                        .orderByDesc(RefundPass::getCreateTime)
                        .last("limit 1")))
                .ifPresent(refundPass -> orderPageListVo.setRefundPassId(refundPass.getId().toString()));
        // 平台分佣
        BigDecimal commission = Optional.ofNullable(shopBalanceStatementClient.getShopBalanceStatementList(Arrays.asList(1, 2, 3), Long.valueOf(orderPageListVo.getId())).getData())
                .orElse(Collections.emptyList())
                .stream()
                .map(ShopBalanceStatement::getVariableAmount)
                .reduce(BigDecimal.ZERO, BigDecimal::add);
        orderPageListVo.setGetCommission(commission);
        // 处理快递信息
        Optional.ofNullable(orderPageListVo.getExpressJson())
                .filter(expressJson -> !expressJson.equals("NULL"))
                .ifPresent(expressJson -> {
                    try {
                        JSONObject jsonObject = JSONObject.parseObject(expressJson);
                        orderPageListVo.setExpressCompany(ExpressCompanyMap.getCompanyNameByCode(jsonObject.getString("com")));
                        orderPageListVo.setExpressNum(jsonObject.getString("num"));
                    } catch (Exception e) {
                    }
                });
    }
    /**
     * 判断两个列表中是否至少有一个相同的元素
     * 此方法用于检查两个长整型列表之间的元素交集
     * 主要解决的问题是确定两个列表是否有共同的元素,用于避免潜在的数据不一致或错误
     *
     * @param list1 第一个列表,包含一系列长整型数值
     * @param list2 第二个列表,同样包含一系列长整型数值
     * @return 返回一个布尔值,如果两个列表中至少有一个相同的元素,则返回true,否则返回false
     */
    private boolean containsAny(List<Long> list1, List<Long> list2) {
        return list1.stream().anyMatch(list2::contains) || list2.stream().anyMatch(list1::contains);
    }
@@ -457,10 +492,7 @@
        return R.ok();
    }
    public static void main(String[] args) {
        System.out.println(LocalDateTime.now().toEpochSecond(ZoneOffset.UTC));
    }
    
    /**
     * 取消订单操作
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/RefundPassServiceImpl.java
@@ -37,9 +37,8 @@
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -168,6 +167,30 @@
        }
        return pageInfo.setRecords(orderRefundPassList);
    }
//    public void processAppUserIds(List<Long> appUserIds , String searchKey, Function<String, R<List<AppUser>>> userSearchFunction){
//        if (StringUtils.isNotEmpty(searchKey)) {
//            List<Long> userIds = Optional.ofNullable(userSearchFunction.apply(searchKey).getData())
//                    .orElse(Collections.emptyList())
//                    .stream()
//                    .map(AppUser::getId)
//                    .collect(Collectors.toList());
//
//            if (CollectionUtils.isEmpty(userIds)) {
//                return;
//            }
//
//            List<Long> existingUserIds = orderPageList.getAppUserIds();
//            if (existingUserIds != null) {
//                if (!containsAny(existingUserIds, userIds)) {
//                    return;
//                }
//                existingUserIds.addAll(userIds);
//            } else {
//                orderPageList.setAppUserIds(userIds);
//            }
//        }
//    }
    
    
    /**
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -22,10 +22,10 @@
            <if test="status != null">
                <choose>
                    <when test="status == 4">
                        o.order_status in (4, 8)
                       and o.order_status in (4, 8)
                    </when>
                    <otherwise>
                        o.order_status = #{status}
                        and o.order_status = #{status}
                    </otherwise>
                </choose>
            </if>
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java
@@ -143,9 +143,6 @@
        if (shopDetailVO == null) {
            throw new ServiceException("查询店铺不存在");
        }
        if (shopDetailVO.getStatus().equals(2)){
            throw new ServiceException("店铺已冻结");
        }
        ShopScore one = shopScoreService.getOne(new LambdaQueryWrapper<ShopScore>().eq(ShopScore::getAppUserId, userid).eq(ShopScore::getShopId, shopId).last(" order by create_time desc limit 0, 1"));
        shopDetailVO.setMyScore(null == one ? BigDecimal.ZERO : one.getScore());
        // 计算距离
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml
@@ -47,10 +47,10 @@
            </if>
            <if test="goods.payMethod != null and goods.payMethod == 1 ">
                and tg.`cash_payment` = 1
                and tg.`cash_payment` = 1 and (tg.`point_payment` = 0 or tg.`point_payment` is null)
            </if>
            <if test="goods.payMethod != null and goods.payMethod == 2 ">
                and tg.`point_payment` = 1
                and tg.`point_payment` = 1 and (tg.`cash_payment` = 0 or tg.`cash_payment` is null)
            </if>
            <if test="goods.payMethod != null and goods.payMethod == 3 ">
                and (tg.`point_payment` = 1 and  tg.`cash_payment` = 1 )