From 20bf12dc209329b29ac96d01efabaa3a0ff30cb2 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期日, 26 一月 2025 17:27:31 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/qijisheng --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageListVo.java | 9 +- ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ExpressCompanyMap.java | 12 +++ ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java | 13 ++ ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java | 2 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java | 139 +++++++++++++++++++++++++++------- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/RechargeSetVO.java | 13 +++ ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java | 17 ++++ ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/ExpressDeliveryUtil.java | 3 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 11 ++ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RechargeSetController.java | 11 ++ 10 files changed, 190 insertions(+), 40 deletions(-) diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ExpressCompanyMap.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ExpressCompanyMap.java index cd89941..225682d 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ExpressCompanyMap.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ExpressCompanyMap.java @@ -32,4 +32,16 @@ public static String getCompanyNameByCode(String code) { return EXPRESS_COMPANY_MAP.get(code); } + + /** + * 根据快递公司名称获取编码 + */ + public static String getCodeByCompanyName(String companyName) { + for (Map.Entry<String, String> entry : EXPRESS_COMPANY_MAP.entrySet()) { + if (entry.getValue().equals(companyName)) { + return entry.getKey(); + } + } + return null; + } } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java index 6ac88b4..fd99cb2 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java @@ -117,6 +117,17 @@ return appUserService.getById(id); } + @PostMapping("/getBaseUserById") + public R<Map<String, Object>> getBaseUserById(@RequestParam("id") Long id) { + AppUser appUser = appUserService.getById(id); + Map<String, Object> map = new HashMap<>(); + map.put("id", appUser.getId()); + map.put("name", appUser.getName()); + map.put("phone", appUser.getPhone()); + return R.ok(map); + } + + @ResponseBody @PostMapping("/editAppUserById") public R<Void> editAppUserById(@RequestBody AppUser appUser) { diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java index 7d2aa24..e35bdb6 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java @@ -156,7 +156,7 @@ String content = data.getContent(); if (!content.equals("-1")){ if (amount.compareTo(new BigDecimal(content)) > 0){ - return R.fail("充值金额不能小于" + content + "元"); + return R.fail("充值金额不能大于" + content + "元"); } } } @@ -184,6 +184,21 @@ /** + * 获取充值上限金额 + */ + @GetMapping("rechargeLimit") + public R<BigDecimal> rechargeLimit(){ + R<BaseSetting> baseSetting = baseSettingClient.getBaseSetting(7); + BaseSetting data = baseSetting.getData(); + if (data != null){ + String content = data.getContent(); + return R.ok(new BigDecimal(content)); + } + return R.ok(new BigDecimal("-1")); + } + + + /** * 充值支付回调 * @param callback * @param response diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java index ef78283..1dd6cb4 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java @@ -30,6 +30,10 @@ import com.ruoyi.system.api.feignClient.SysUserClient; import com.ruoyi.system.api.model.LoginUser; import io.swagger.annotations.*; +import org.springframework.core.io.InputStreamResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -38,8 +42,10 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotBlank; import java.io.IOException; +import java.io.InputStream; import java.io.PrintWriter; import java.math.BigDecimal; +import java.net.URL; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDateTime; @@ -520,8 +526,10 @@ * 导入物流信息 */ @PostMapping("/importExpress") - public R importExpress(@RequestParam("file") MultipartFile file){ - orderService.importExpress(file); + public R importExpress(@RequestBody String url){ + JSONObject jsonObject = JSONObject.parseObject(url); + String url2 = jsonObject.getString("url"); + orderService.importExpress(url2); return R.ok(); } @@ -549,5 +557,6 @@ .eq(Order::getPayStatus, 2)); return R.ok(count); } + } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java index ce69e8f..7654f37 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java @@ -116,5 +116,5 @@ /** * 导入物流信息 */ - void importExpress(MultipartFile file); + void importExpress(String url); } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java index 1e6b3f8..cfc9dfc 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java @@ -1,10 +1,8 @@ package com.ruoyi.order.service.impl; -import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.account.api.feignClient.*; import com.ruoyi.account.api.model.*; @@ -22,21 +20,29 @@ import com.ruoyi.order.model.OrderBalancePayment; import com.ruoyi.order.model.OrderGood; import com.ruoyi.order.model.RefundPass; -import com.ruoyi.order.service.*; +import com.ruoyi.order.service.CommissionService; +import com.ruoyi.order.service.OrderBalancePaymentService; +import com.ruoyi.order.service.OrderService; +import com.ruoyi.order.service.RefundPassService; import com.ruoyi.order.util.ExpressDeliveryUtil; import com.ruoyi.order.util.payment.PaymentUtil; import com.ruoyi.order.util.payment.model.RefundCallbackResult; import com.ruoyi.order.util.payment.model.RefundResult; import com.ruoyi.order.util.vo.MapTrackKD100Vo; import com.ruoyi.order.util.vo.QueryKD100ListVo; -import com.ruoyi.order.util.vo.QueryKD100Vo; import com.ruoyi.order.vo.*; import com.ruoyi.other.api.domain.*; import com.ruoyi.other.api.feignClient.*; import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.feignClient.SysUserClient; import com.ruoyi.system.api.model.LoginUser; -import org.apache.poi.ss.usermodel.*; +import lombok.SneakyThrows; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -47,6 +53,8 @@ import java.io.InputStream; import java.math.BigDecimal; import java.math.RoundingMode; +import java.net.MalformedURLException; +import java.net.URL; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; @@ -116,7 +124,9 @@ @Resource private UserChangeLogClient userChangeLogClient; - + + @Resource + private RegionClient regionClient; @@ -363,7 +373,7 @@ } return pageInfo.setRecords(list); } - + /** @@ -426,7 +436,7 @@ JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); Integer waitTime = jsonObject.getInteger("waitTime"); redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(waitTime).toEpochSecond(ZoneOffset.UTC)); - + JSONObject jsonObject1 = JSON.parseObject(confirmDelivery.getCode()); String com = jsonObject1.getString("com"); String num = jsonObject1.getString("num"); @@ -436,6 +446,10 @@ order.setExpressResult(JSON.toJSONString(mapTrackKD100Vo)); this.updateById(order); return R.ok(); + } + + public static void main(String[] args) { + System.out.println(LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); } @@ -921,13 +935,95 @@ } } + @SneakyThrows @Override - public void importExpress(MultipartFile file) { - try (InputStream inputStream = file.getInputStream()) { - Workbook workbook = WorkbookFactory.create(inputStream); + @Transactional(rollbackFor = Exception.class) + public void importExpress(String url) { + URL url1 = new URL(url); + try (InputStream fileInputStream = url1.openStream()) { + Workbook workbook = new XSSFWorkbook(fileInputStream); Sheet sheet = workbook.getSheetAt(0); // 获取第一个Sheet int lastRowNum = sheet.getLastRowNum(); - for (int i = 1; i <= lastRowNum; i++) { + for (int i = 2; i <= lastRowNum; i++) { + Row row = sheet.getRow(i); + row.getCell(1).setCellType(CellType.STRING); + String orderNum = row.getCell(1).getStringCellValue(); + // 快递单号 + row.getCell(7).setCellType(CellType.STRING); + String expressNum = row.getCell(7).getStringCellValue(); + // 快递公司名称 + row.getCell(8).setCellType(CellType.STRING); + String expressName = row.getCell(8).getStringCellValue(); + // 省区划代码 + row.getCell(10).setCellType(CellType.STRING); + String provinceCode = row.getCell(10).getStringCellValue(); + // 市区划代码 + row.getCell(12).setCellType(CellType.STRING); + String cityCode = row.getCell(12).getStringCellValue(); + Order order = this.getOne(new LambdaQueryWrapper<Order>() + .eq(Order::getOrderNumber, orderNum) + ); + if (order == null){ + throw new ServiceException("订单不存在:"+orderNum, 500); + } + + Integer orderType = order.getOrderType(); + if (orderType != 2){ + throw new ServiceException("该订单:"+orderNum+"类型不为单品订单", 500); + } + if (order.getDistributionMode() != 2){ + throw new ServiceException("该订单:"+orderNum+"配送方式不为快递", 500); + } + Integer orderStatus = order.getOrderStatus(); + if (orderStatus != 1){ + throw new ServiceException("该订单:"+orderNum+"状态不为待发货", 500); + } + + String companyNameByCode = ExpressCompanyMap.getCodeByCompanyName(expressName); + if(StringUtils.isEmpty(companyNameByCode)){ + throw new ServiceException("快递公司名称错误:"+expressName, 500); + } + + R<Region> regionBiCode = regionClient.getRegionBiCode(provinceCode); + if (regionBiCode.getData() == null) { + throw new ServiceException("省份编码错误:"+provinceCode, 500); + } + R<Region> regionBiCode1 = regionClient.getRegionBiCode(cityCode); + if (regionBiCode1.getData() == null) { + throw new ServiceException("城市编码错误:"+cityCode, 500); + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("com", companyNameByCode); + jsonObject.put("num", expressNum); + ConfirmDelivery confirmDelivery =new ConfirmDelivery(); + confirmDelivery.setOrderId(order.getId()); + confirmDelivery.setCode(jsonObject.toJSONString()); + confirmDelivery.setDeliverProvince(regionBiCode.getData().getName()); + confirmDelivery.setDeliverProvinceCode(regionBiCode.getData().getCode()); + confirmDelivery.setDeliverCity(regionBiCode1.getData().getName()); + confirmDelivery.setDeliverCityCode(regionBiCode1.getData().getCode()); + confirmDelivery(confirmDelivery); + } + + } catch (IOException e) { + e.printStackTrace(); + throw new ServiceException(e.getMessage()); + } + + + } + + + public static void importExpress2(String filePath) throws MalformedURLException { + // 从网络地址读取 + URL url = new URL(filePath); + try (InputStream fileInputStream = url.openStream()) { + Workbook workbook = new XSSFWorkbook(fileInputStream); + + Sheet sheet = workbook.getSheetAt(0); // 获取第一个Sheet + int lastRowNum = sheet.getLastRowNum(); + + for (int i = 2; i <= lastRowNum; i++) { Row row = sheet.getRow(i); String orderNum = row.getCell(1).getStringCellValue(); // 快递单号 @@ -938,26 +1034,11 @@ String provinceCode = row.getCell(10).getStringCellValue(); // 市区划代码 String cityCode = row.getCell(12).getStringCellValue(); - Order order = this.getOne(new LambdaQueryWrapper<Order>() - .eq(Order::getOrderNumber, orderNum) - .eq(Order::getOrderType, 1) - .eq(Order::getDistributionMode,2) - .eq(Order::getOrderStatus, 1) - ); - if (order != null){ - JSONObject jsonObject = new JSONObject(); - jsonObject.put("com", expressName); - jsonObject.put("num", expressNum); - order.setExpressJson(jsonObject.toJSONString()); - order.setDeliverProvinceCode(provinceCode); - order.setDeliverCityCode(cityCode); - order.setOrderStatus(2); - this.updateById(order); - } } } catch (IOException e) { - throw new RuntimeException(e); + throw new ServiceException(e.getMessage()); } } + } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/ExpressDeliveryUtil.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/ExpressDeliveryUtil.java index 699a5e8..f636162 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/ExpressDeliveryUtil.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/ExpressDeliveryUtil.java @@ -102,7 +102,8 @@ public static void main(String[] args) { - ExpressDeliveryUtil.kd100MapTrack("zhongtong", "75617413683310", "湖南省长沙市", "四川省成都市"); + MapTrackKD100Vo mapTrackKD100Vo = ExpressDeliveryUtil.kd100MapTrack("zhongtong", "73543720196087", "湖南省长沙市", "四川省成都市"); + System.out.println(mapTrackKD100Vo); } } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageListVo.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageListVo.java index fdacd73..ffdb0e4 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageListVo.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderPageListVo.java @@ -19,6 +19,9 @@ @ApiModelProperty("订单编号") @Excel(name = "订单编号") private String code; + @ApiModelProperty("订单状态(1待发货2待收货3待使用4已完成5已取消6已退款7售后中8已评价)") + @Excel(name = "订单状态", readConverterExp = "1=待发货,2=待收货,3=待使用,4=已完成,5=已取消,6=已退款,7=售后中,8=已评价") + private Integer status; @ApiModelProperty("下单时间") @Excel(name = "下单时间") private String createTime; @@ -40,8 +43,6 @@ private BigDecimal orderMoney; @ApiModelProperty("订单积分") private BigDecimal point; - @ApiModelProperty("订单状态(1待发货2待收货3待使用4已完成5已取消6已退款7售后中8已评价)") - private Integer status; @ApiModelProperty("配送方式(1=自提,2=快递)") private Integer distributionMode; @ApiModelProperty("获得分佣") @@ -57,10 +58,10 @@ @Excel(name = "省") private String deliverProvince; // 市 - @Excel(name = "市") + @Excel(name = "省区划代码") private String deliverProvinceCode; // 省区划代码 - @Excel(name = "省区划代码") + @Excel(name = "市") private String deliverCity; // 市区划代码 @Excel(name = "市区划代码") diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RechargeSetController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RechargeSetController.java index b48222f..ca5ead3 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RechargeSetController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RechargeSetController.java @@ -11,10 +11,12 @@ import com.ruoyi.other.dto.RechargeDto; import com.ruoyi.other.service.BaseSettingService; import com.ruoyi.other.service.RechargeSetService; +import com.ruoyi.other.vo.RechargeSetVO; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.List; /** @@ -35,8 +37,13 @@ @GetMapping("/list") @ApiOperation(value = "充值设置查询", tags = {"后台"}) - public R<List<RechargeSet>> list() { - return R.ok(rechargeSetService.list()); + public R<RechargeSetVO> list() { + BaseSetting baseSetting = baseSettingService.getById(7); + List<RechargeSet> list = rechargeSetService.list(); + RechargeSetVO rechargeSetVO = new RechargeSetVO(); + rechargeSetVO.setLimit(new BigDecimal(baseSetting.getContent())); + rechargeSetVO.setRechargeSetList(list); + return R.ok(rechargeSetVO); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/RechargeSetVO.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/RechargeSetVO.java new file mode 100644 index 0000000..ca97f1f --- /dev/null +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/RechargeSetVO.java @@ -0,0 +1,13 @@ +package com.ruoyi.other.vo; + +import com.ruoyi.other.api.domain.RechargeSet; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class RechargeSetVO { + private BigDecimal limit; + private List<RechargeSet> rechargeSetList; +} -- Gitblit v1.7.1