| | |
| | | import com.kuaidi100.sdk.contant.CompanyConstant; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.UserAddress; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | |
| | | import com.ruoyi.order.model.RefundPass; |
| | | import com.ruoyi.order.service.OrderService; |
| | | import com.ruoyi.order.service.RefundPassService; |
| | | import com.ruoyi.order.util.ExpressDeliveryUtil; |
| | | import com.ruoyi.order.util.vo.MapTrackKD100Vo; |
| | | import com.ruoyi.order.vo.*; |
| | | import com.ruoyi.other.api.domain.BaseSetting; |
| | | import com.ruoyi.other.api.domain.SystemConfig; |
| | | import com.ruoyi.other.api.feignClient.BaseSettingClient; |
| | | import com.ruoyi.other.api.feignClient.ShopClient; |
| | | import com.ruoyi.other.api.feignClient.SystemConfigClient; |
| | | import com.ruoyi.other.api.feignClient.TechnicianClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Resource |
| | | private SystemConfigClient systemConfigClient; |
| | | |
| | | |
| | | |
| | |
| | | refundPass.setPhone(jsonObject.getString("phone")); |
| | | refundPass.setAddress(jsonObject.getString("address")); |
| | | this.save(refundPass); |
| | | order.setOldOrderStatus(order.getOrderStatus()); |
| | | order.setOrderStatus(7); |
| | | orderService.updateById(order); |
| | | return R.ok(); |
| | |
| | | if(2 == sysUser.getRoleType()){ |
| | | shopId = sysUser.getObjectId(); |
| | | } |
| | | List<Long> appUserIds = new ArrayList<>(); |
| | | //搜索条件,用户姓名和电话 |
| | | if(StringUtils.isNotEmpty(refundPassListVo.getUserName()) || StringUtils.isNotEmpty(refundPassListVo.getPhone())){ |
| | | } |
| | | |
| | | //搜索条件,用户姓名 |
| | | if(StringUtils.isNotEmpty(refundPassListVo.getName())){ |
| | | List<AppUser> data = appUserClient.getAppUserByName(refundPassListVo.getName()).getData(); |
| | | List<AppUser> data = appUserClient.getAppUserByNameNoFilter(refundPassListVo.getName()).getData(); |
| | | List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | appUserIds.addAll(collect); |
| | | if (CollectionUtils.isEmpty(collect)){ |
| | | return new PageInfo<>(); |
| | | } |
| | | if(null != refundPassListVo.getAppUserIds()){ |
| | | List<Long> appUserIds = refundPassListVo.getAppUserIds(); |
| | | appUserIds.addAll(collect); |
| | | refundPassListVo.setAppUserIds(appUserIds); |
| | | }else{ |
| | | refundPassListVo.setAppUserIds(collect); |
| | | } |
| | | } |
| | | //搜索条件,用户电话 |
| | | if(StringUtils.isNotEmpty(refundPassListVo.getPhone())){ |
| | | List<AppUser> data = appUserClient.getAppUserByPhone(refundPassListVo.getPhone()).getData(); |
| | | List<AppUser> data = appUserClient.getAppUserByPhoneNoFilter(refundPassListVo.getPhone()).getData(); |
| | | List<Long> collect = data.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | appUserIds.addAll(collect); |
| | | if (CollectionUtils.isEmpty(collect)){ |
| | | return new PageInfo<>(); |
| | | } |
| | | |
| | | if(null != refundPassListVo.getAppUserIds()){ |
| | | List<Long> appUserIds = refundPassListVo.getAppUserIds(); |
| | | if (!containsAny(appUserIds,collect)) { |
| | | return new PageInfo<>(); |
| | | } |
| | | appUserIds.addAll(collect); |
| | | refundPassListVo.setAppUserIds(appUserIds); |
| | | }else{ |
| | | refundPassListVo.setAppUserIds(collect); |
| | | } |
| | | } |
| | | if (null != refundPassListVo.getAppUserIds()){ |
| | | refundPassListVo.setAppUserIds(refundPassListVo.getAppUserIds().stream().distinct().collect(Collectors.toList())); |
| | | } |
| | | |
| | | |
| | | |
| | | PageInfo<OrderRefundPassList> pageInfo = new PageInfo(refundPassListVo.getPageCurr(), refundPassListVo.getPageSize()); |
| | | List<OrderRefundPassList> orderRefundPassList = this.baseMapper.getOrderRefundPassList(pageInfo, refundPassListVo.getCode(), appUserIds, shopId, refundPassListVo.getRefundMethod(), refundPassListVo.getStatus()); |
| | | List<OrderRefundPassList> orderRefundPassList = this.baseMapper.getOrderRefundPassList(pageInfo, refundPassListVo.getCode(), refundPassListVo.getAppUserIds(), shopId, refundPassListVo.getRefundMethod(), refundPassListVo.getStatus()); |
| | | for (OrderRefundPassList refundPassList : orderRefundPassList) { |
| | | AppUser appUser = appUserClient.getAppUserById(refundPassList.getAppUserId()); |
| | | if(null != appUser){ |
| | |
| | | } |
| | | return pageInfo.setRecords(orderRefundPassList); |
| | | } |
| | | |
| | | /** |
| | | * 判断 list1 是否包含 list2 中的至少一个元素 |
| | | * |
| | | * @param list1 第一个列表 |
| | | * @param list2 第二个列表 |
| | | * @return 如果 list1 包含 list2 中的至少一个元素,返回 true;否则返回 false |
| | | */ |
| | | private boolean containsAny(List<Long> list1, List<Long> list2) { |
| | | // 将 list1 转换为 HashSet 以提高查询效率 |
| | | Set<Long> set1 = new HashSet<>(list1); |
| | | |
| | | // 遍历 list2,检查是否有元素存在于 set1 中 |
| | | for (Long element : list2) { |
| | | if (set1.contains(element)) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | // 如果没有找到共同元素,返回 false |
| | | return false; |
| | | } |
| | | |
| | | // 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); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | |
| | | /** |
| | |
| | | return R.fail("操作失败"); |
| | | } |
| | | refundPass.setStatus(2); |
| | | refundPass.setReceiveTime(LocalDateTime.now()); |
| | | //仅退款的售后需要将支付金额原路返回,然后再扣减支付获得的积分 |
| | | Order order = orderService.getById(refundPass.getOrderId()); |
| | | order.setOrderStatus(6); |
| | |
| | | } |
| | | return refundPassInfo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 定时查询快递信息 |
| | | */ |
| | | @Override |
| | | public void taskExpress() { |
| | | Set<Long> order_express = redisTemplate.opsForZSet().rangeByScore("order_refund_express", 0, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); |
| | | if(order_express.size() > 0){ |
| | | for (Long id : order_express) { |
| | | RefundPass refundPass = this.getById(id); |
| | | Order order = orderService.getById(refundPass.getOrderId()); |
| | | if(refundPass.getPassStatus() != 5){ |
| | | redisTemplate.opsForZSet().remove("order_refund_express", id); |
| | | continue; |
| | | } |
| | | String expressJson = refundPass.getCode(); |
| | | if(StringUtils.isEmpty(expressJson)){ |
| | | redisTemplate.opsForZSet().remove("order_refund_express", id); |
| | | continue; |
| | | } |
| | | //{"com":"jd","num":"JDV016336234367"} |
| | | JSONObject jsonObject1 = JSON.parseObject(refundPass.getCode()); |
| | | String com = jsonObject1.getString("com"); |
| | | String num = jsonObject1.getString("num"); |
| | | UserAddress userAddress = JSON.parseObject(order.getAddressJson(), UserAddress.class); |
| | | MapTrackKD100Vo mapTrackKD100Vo = ExpressDeliveryUtil.kd100MapTrack(com, num, userAddress.getProvince() + userAddress.getCity(), order.getDeliverProvince() + order.getDeliverCity()); |
| | | refundPass.setExpressResult(JSON.toJSONString(mapTrackKD100Vo)); |
| | | this.updateById(refundPass); |
| | | //延长时间x小时 |
| | | SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData(); |
| | | JSONObject jsonObject2 = JSON.parseObject(systemConfig.getContent()); |
| | | Integer waitTime = jsonObject2.getInteger("waitTime"); |
| | | redisTemplate.opsForZSet().add("order_refund_express", refundPass.getId(), LocalDateTime.now().plusHours(waitTime).toEpochSecond(ZoneOffset.UTC)); |
| | | } |
| | | } |
| | | } |
| | | } |