| | |
| | | package com.ruoyi.order.service.impl; |
| | | |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import com.ruoyi.common.core.constant.ExpressCompanyMap; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.HttpUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.uuid.QRCodeGenerator; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.enums.OrderStatus; |
| | | import com.ruoyi.order.event.ConfirmDeliveryEvent; |
| | | import com.ruoyi.order.mapper.OrderGoodMapper; |
| | | import com.ruoyi.order.mapper.OrderMapper; |
| | | import com.ruoyi.order.model.Order; |
| | |
| | | import org.apache.poi.xssf.streaming.SXSSFWorkbook; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.jetbrains.annotations.Nullable; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import java.net.MalformedURLException; |
| | | import java.net.URL; |
| | | import java.time.LocalDateTime; |
| | | import java.time.OffsetDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | |
| | | |
| | | @Resource |
| | | private BalanceChangeRecordClient balanceChangeRecordClient; |
| | | |
| | | |
| | | @Resource |
| | | private UserPointClient userPointClient; |
| | |
| | | private ShopBalanceStatementClient shopBalanceStatementClient; |
| | | |
| | | @Resource |
| | | private ShopPointClient shopPointClient; |
| | | |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | private RegionClient regionClient; |
| | | @Resource |
| | | private AppUserGiveawayTemporaryClient appUserGiveawayTemporaryClient; |
| | | @Resource |
| | | private ShopGiveawayTemporaryClient shopGiveawayTemporaryClient; |
| | | @Resource |
| | | private ApplicationEventPublisher applicationEventPublisher; |
| | | |
| | | |
| | | @Override |
| | |
| | | } |
| | | // 优惠券 |
| | | String couponJson = order.getCouponJson(); |
| | | CouponInfo couponInfo = new CouponInfo(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | if (StringUtils.isNotEmpty(couponJson)) { |
| | | couponInfo = JSONObject.parseObject(couponJson, CouponInfo.class); |
| | | jsonObject = JSONObject.parseObject(couponJson); |
| | | } |
| | | |
| | | // 参与活动 |
| | |
| | | orderDetailVO.setOrderNumber(order.getOrderNumber()); |
| | | orderDetailVO.setCreateTime(order.getCreateTime()); |
| | | orderDetailVO.setTotalAmount(order.getTotalAmount()); |
| | | orderDetailVO.setCouponName(couponInfo.getCouponName()); |
| | | orderDetailVO.setCouponName(jsonObject.getString("couponName")); |
| | | orderDetailVO.setActivityName(orderActivityInfo.getActivityName()); |
| | | orderDetailVO.setCouponAmount(order.getDiscountTotalAmount()); |
| | | orderDetailVO.setExpressAmount(order.getExpressAmount()); |
| | |
| | | } |
| | | return orderDetailVO; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean check(Order order, Integer shopId, Long userId) { |
| | |
| | | JSONObject jsonObject = JSONObject.parseObject(content); |
| | | Long days = jsonObject.getLong("days"); |
| | | order.setOrderStatus(OrderStatus.COMPLETED.getCode()); |
| | | order.setIsCommission(0); |
| | | order.setAfterSaleTime(LocalDateTime.now().plusDays(days)); |
| | | order.setEndTime(LocalDateTime.now()); |
| | | order.setCancellerAppUserId(loginUserApplet.getUserid()); |
| | | if (StringUtils.isNotEmpty(technicianId) && !"null".equals(technicianId)) { |
| | | order.setTechnicianId(Integer.valueOf(technicianId)); |
| | | } |
| | | // TODO |
| | | orderMapper.updateById(order); |
| | | commissionService.calculationCommissionShop(order.getId()); |
| | | } |
| | | |
| | | |
| | |
| | | return r; |
| | | } |
| | | |
| | | /** |
| | | * 确认发货操作 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R confirmDelivery(ConfirmDelivery confirmDelivery) { |
| | | Order order = this.getById(confirmDelivery.getOrderId()); |
| | | if (1 == order.getPayStatus()) { |
| | | return R.fail("订单还未完成支付"); |
| | | } |
| | | if (1 == order.getOrderType() || null == order.getAddressJson()) { |
| | | return R.fail("该订单不支付快递配送"); |
| | | } |
| | | if (1 != order.getOrderStatus()) { |
| | | return R.fail("无效的操作"); |
| | | } |
| | | //添加快递号和修改订单状态 |
| | | order.setExpressJson(confirmDelivery.getCode()); |
| | | order.setDeliverProvince(confirmDelivery.getDeliverProvince()); |
| | | order.setDeliverProvinceCode(confirmDelivery.getDeliverProvinceCode()); |
| | | order.setDeliverCity(confirmDelivery.getDeliverCity()); |
| | | order.setDeliverCityCode(confirmDelivery.getDeliverCityCode()); |
| | | order.setDeliverDistrict(confirmDelivery.getDeliverDistrict()); |
| | | order.setDeliverDistrictCode(confirmDelivery.getDeliverDistrictCode()); |
| | | order.setOrderStatus(2); |
| | | //添加查询快递信息队列 |
| | | //一小时后定时查询快递信息 |
| | | SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData(); |
| | | 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"); |
| | | UserAddress userAddress = JSON.parseObject(order.getAddressJson(), UserAddress.class); |
| | | MapTrackKD100Vo mapTrackKD100Vo = ExpressDeliveryUtil.kd100MapTrack(com, num, order.getDeliverProvince() + order.getDeliverCity(), |
| | | userAddress.getProvince() + userAddress.getCity()); |
| | | order.setExpressResult(JSON.toJSONString(mapTrackKD100Vo)); |
| | | this.updateById(order); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | public R refundPayMoney(Order order) { |
| | | //开始退款 |
| | | Integer payMethod = order.getPayMethod(); |
| | | BigDecimal paymentAmount = order.getPaymentAmount(); |
| | | BigDecimal expressAmount = order.getExpressAmount() == null ? BigDecimal.ZERO : order.getExpressAmount(); |
| | | BigDecimal paymentAmount = order.getPaymentAmount().add(expressAmount); |
| | | AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); |
| | | if (1 == payMethod) { |
| | | //微信退款 |
| | |
| | | OrderBalancePayment orderBalancePayment = orderBalancePaymentService.getOne(new LambdaQueryWrapper<OrderBalancePayment>().eq(OrderBalancePayment::getOrderId, order.getId())); |
| | | BigDecimal balance = appUser.getBalance(); |
| | | if (null != orderBalancePayment) { |
| | | //回加红包金额 |
| | | appUser.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount().add(orderBalancePayment.getRedPacketAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | // appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | } |
| | | //回加账户余额 |
| | | appUser.setBalance(balance.add(paymentAmount).setScale(2, RoundingMode.HALF_EVEN)); |
| | | //扣减门店消费金额 |
| | | appUser.setShopAmount(appUser.getShopAmount().subtract(paymentAmount).setScale(2, RoundingMode.HALF_EVEN)); |
| | | //查询最后一次的消费订单 |
| | | Order order1 = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getAppUserId, order.getAppUserId()).eq(Order::getPayStatus, 2) |
| | |
| | | appUser.setLastShopTime(null); |
| | | } |
| | | |
| | | //构建账户余额流水明细 |
| | | //构建账户余额流水明细(账户支付订单的流水,不属于冻结数据) |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setAppUserId(order.getAppUserId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setChangeType(6); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | | balanceChangeRecord.setChangeAmount(paymentAmount); |
| | | balanceChangeRecord.setAfterAmount(appUser.getBalance()); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecord.setChangeDirection(1); |
| | | balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); |
| | | |
| | | |
| | | //退回获得的消费积分 |
| | | //需要先检查会员等级时候回回退,使用回退后的会员等级查询配置 |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | |
| | | UserPoint userPoint1 = new UserPoint(); |
| | | userPoint1.setType(1); |
| | | userPoint1.setAppUserId(appUser.getId()); |
| | |
| | | } |
| | | appUser.setTotalPoint(appUser.getTotalPoint() - shopPoint); |
| | | |
| | | //构建积分流水明细 |
| | | //构建积分流水明细(消费金额,不属于冻结数据) |
| | | if (shopPoint > 0) { |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(shopPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setChangeDirection(-1); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | appUserClient.editAppUserById(appUser); |
| | | |
| | | //降级检测 |
| | | if (1 < appUser.getVipId() && appUser.getVipId() < 4) { |
| | | appUserClient.vipDemotion(appUser.getId()); |
| | | } |
| | | //回退优惠券状态 |
| | | if (null != order.getUserCouponId()) { |
| | | UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData(); |
| | |
| | | if (3 == payMethod) { |
| | | //开始运费退款,积分支付,运费是单独进行支付的,所以需要单独退款 |
| | | if (null != order.getExpressAmount() && BigDecimal.ZERO.compareTo(order.getExpressAmount()) < 0) { |
| | | BigDecimal expressAmount = order.getExpressAmount(); |
| | | if (1 == order.getExpressPayMethod()) { |
| | | //微信退款 |
| | | RefundResult refund = PaymentUtil.refund(order.getOrderNumber(), "R" + order.getOrderNumber(), expressAmount.doubleValue(), "/order/order/refundExpressPayMoneyCallback"); |
| | |
| | | // appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | } |
| | | appUser.setBalance(balance.add(expressAmount).setScale(2, RoundingMode.HALF_EVEN)); |
| | | //构建账户余额流水明细 |
| | | //构建账户余额流水明细(消费支付的余额流水) |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setOrderId(order.getId()); |
| | | balanceChangeRecord.setAppUserId(order.getAppUserId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setChangeType(6); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | | balanceChangeRecord.setChangeAmount(expressAmount); |
| | | balanceChangeRecord.setAfterAmount(appUser.getBalance()); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecord.setChangeDirection(1); |
| | | balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); |
| | | } |
| | | } |
| | |
| | | } |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() + transferablePoint); |
| | | |
| | | //构建积分流水明细 |
| | | //构建积分流水明细(支付的积分,不属于冻结数据) |
| | | if (order.getPoint() > 0) { |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(11); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(order.getPoint()); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setChangeDirection(1); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | appUserClient.editAppUserById(appUser); |
| | |
| | | |
| | | order.setRefundStatus(2); |
| | | order.setRefundTime(LocalDateTime.now()); |
| | | |
| | | //生成反向冻结流水数据 |
| | | List<UserPointCopy> data2 = userPointClient.getUserPointCopy(order.getId(), Arrays.asList(2, 8, 9, 10, 14)).getData(); |
| | | for (UserPointCopy userPointCopy : data2) { |
| | | userPointCopy.setId(null); |
| | | userPointCopy.setCreateTime(LocalDateTime.now()); |
| | | userPointCopy.setChangeDirection(-1); |
| | | userPointClient.saveUserPointCopy(userPointCopy); |
| | | } |
| | | List<BalanceChangeRecordCopy> data3 = balanceChangeRecordClient.getBalanceChangeRecordCopy(order.getId(), Arrays.asList(4)).getData(); |
| | | for (BalanceChangeRecordCopy balanceChangeRecordCopy : data3) { |
| | | balanceChangeRecordCopy.setId(null); |
| | | balanceChangeRecordCopy.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecordCopy.setChangeDirection(-1); |
| | | balanceChangeRecordClient.saveBalanceChangeRecordCopy(balanceChangeRecordCopy); |
| | | } |
| | | List<ShopPointCopy> data = shopPointClient.getShopPointCopy(order.getId(), Arrays.asList(1, 2, 3)).getData(); |
| | | for (ShopPointCopy datum : data) { |
| | | datum.setId(null); |
| | | datum.setCreateTime(LocalDateTime.now()); |
| | | datum.setChangeDirection(-1); |
| | | shopPointClient.saveShopPointCopy(datum); |
| | | } |
| | | List<ShopBalanceStatementCopy> data1 = shopBalanceStatementClient.getShopBalanceStatementCopy(order.getId(), Arrays.asList(1, 2, 3)).getData(); |
| | | for (ShopBalanceStatementCopy shopBalanceStatementCopy : data1) { |
| | | shopBalanceStatementCopy.setId(null); |
| | | shopBalanceStatementCopy.setCreateTime(LocalDateTime.now()); |
| | | shopBalanceStatementCopy.setChangeDirection(-1); |
| | | shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy); |
| | | } |
| | | //删除用户和门店添加的汇总数据(冻结数据) |
| | | appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(order.getId()); |
| | | shopGiveawayTemporaryClient.delShopGiveawayTemporary(order.getId()); |
| | | |
| | | //降级检测 |
| | | if (1 < appUser.getVipId() && appUser.getVipId() < 4) { |
| | | appUserClient.vipDemotion(appUser.getId()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | if (shopPoint > 0) { |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(shopPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setChangeDirection(-1); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | appUserClient.editAppUserById(appUser); |
| | | |
| | | //降级检测 |
| | | if (1 < appUser.getVipId() && appUser.getVipId() < 4) { |
| | | appUserClient.vipDemotion(appUser.getId()); |
| | | } |
| | | |
| | | //回退优惠券状态 |
| | | if (null != order.getUserCouponId()) { |
| | | UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData(); |
| | | userCoupon.setUseTime(null); |
| | | userCouponClient.editReturnUse(userCoupon); |
| | | } |
| | | |
| | | //生成反向冻结流水数据 |
| | | List<UserPointCopy> data2 = userPointClient.getUserPointCopy(order.getId(), Arrays.asList(2, 8, 9, 10, 14)).getData(); |
| | | for (UserPointCopy userPointCopy : data2) { |
| | | userPointCopy.setId(null); |
| | | userPointCopy.setCreateTime(LocalDateTime.now()); |
| | | userPointCopy.setChangeDirection(-1); |
| | | userPointClient.saveUserPointCopy(userPointCopy); |
| | | } |
| | | List<BalanceChangeRecordCopy> data3 = balanceChangeRecordClient.getBalanceChangeRecordCopy(order.getId(), Arrays.asList(4)).getData(); |
| | | for (BalanceChangeRecordCopy balanceChangeRecordCopy : data3) { |
| | | balanceChangeRecordCopy.setId(null); |
| | | balanceChangeRecordCopy.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecordCopy.setChangeDirection(-1); |
| | | balanceChangeRecordClient.saveBalanceChangeRecordCopy(balanceChangeRecordCopy); |
| | | } |
| | | List<ShopPointCopy> data = shopPointClient.getShopPointCopy(order.getId(), Arrays.asList(1, 2, 3)).getData(); |
| | | for (ShopPointCopy datum : data) { |
| | | datum.setId(null); |
| | | datum.setCreateTime(LocalDateTime.now()); |
| | | datum.setChangeDirection(-1); |
| | | shopPointClient.saveShopPointCopy(datum); |
| | | } |
| | | List<ShopBalanceStatementCopy> data1 = shopBalanceStatementClient.getShopBalanceStatementCopy(order.getId(), Arrays.asList(1, 2, 3)).getData(); |
| | | for (ShopBalanceStatementCopy shopBalanceStatementCopy : data1) { |
| | | shopBalanceStatementCopy.setId(null); |
| | | shopBalanceStatementCopy.setCreateTime(LocalDateTime.now()); |
| | | shopBalanceStatementCopy.setChangeDirection(-1); |
| | | shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy); |
| | | } |
| | | //删除用户和门店添加的汇总数据(冻结数据) |
| | | appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(order.getId()); |
| | | shopGiveawayTemporaryClient.delShopGiveawayTemporary(order.getId()); |
| | | |
| | | //降级检测 |
| | | if (1 < appUser.getVipId() && appUser.getVipId() < 4) { |
| | | appUserClient.vipDemotion(appUser.getId()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | if (order.getPoint() > 0) { |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(11); |
| | | userPoint.setHistoricalPoint(lavePoint); |
| | | userPoint.setVariablePoint(order.getPoint()); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | | userPoint.setAppUserId(order.getAppUserId()); |
| | | userPoint.setObjectId(order.getId()); |
| | | userPoint.setChangeDirection(1); |
| | | userPointClient.saveUserPoint(userPoint); |
| | | } |
| | | return R.ok(); |
| | |
| | | if (order_express.size() > 0) { |
| | | for (Long id : order_express) { |
| | | Order order = this.getById(id); |
| | | if (order == null){ |
| | | redisTemplate.opsForZSet().remove("order_express", id); |
| | | continue; |
| | | } |
| | | if (order.getOrderStatus() != 2) { |
| | | redisTemplate.opsForZSet().remove("order_express", id); |
| | | continue; |
| | |
| | | } |
| | | } |
| | | |
| | | @SneakyThrows |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importExpress(String url) { |
| | | URL url1 = new URL(url); |
| | | URL url1 = null; |
| | | try { |
| | | url1 = new URL(url); |
| | | } catch (MalformedURLException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | try (InputStream fileInputStream = url1.openStream()) { |
| | | Workbook workbook = new XSSFWorkbook(fileInputStream); |
| | | Sheet sheet = workbook.getSheetAt(0); // 获取第一个Sheet |
| | |
| | | for (int i = 1; i <= lastRowNum; i++) { |
| | | Row row = sheet.getRow(i); |
| | | // 订单编号 |
| | | if (row.getCell(0) == null){ |
| | | throw new ServiceException("第" + i + "行订单编号为空", 500); |
| | | } |
| | | row.getCell(0).setCellType(CellType.STRING); |
| | | String orderNum = row.getCell(0).getStringCellValue(); |
| | | // 快递单号 |
| | | if (row.getCell(1) == null){ |
| | | throw new ServiceException("第" + i + "行快递单号为空", 500); |
| | | } |
| | | row.getCell(1).setCellType(CellType.STRING); |
| | | String expressNum = row.getCell(1).getStringCellValue(); |
| | | // 快递公司名称 |
| | | if (row.getCell(2) == null){ |
| | | throw new ServiceException("第" + i + "行快递公司为空", 500); |
| | | } |
| | | row.getCell(2).setCellType(CellType.STRING); |
| | | String expressName = row.getCell(2).getStringCellValue(); |
| | | // 省区划代码 |
| | | if (row.getCell(3) == null){ |
| | | throw new ServiceException("第" + i + "行省区划代码为空", 500); |
| | | } |
| | | row.getCell(3).setCellType(CellType.STRING); |
| | | String provinceCode = row.getCell(3).getStringCellValue(); |
| | | // 市区划代码 |
| | | if (row.getCell(4) == null){ |
| | | throw new ServiceException("第" + i + "行市区划代码为空", 500); |
| | | } |
| | | row.getCell(4).setCellType(CellType.STRING); |
| | | String cityCode = row.getCell(4).getStringCellValue(); |
| | | Order order = this.getOne(new LambdaQueryWrapper<Order>() |
| | |
| | | confirmDelivery.setDeliverProvinceCode(regionBiCode.getData().getCode()); |
| | | confirmDelivery.setDeliverCity(regionBiCode1.getData().getName()); |
| | | confirmDelivery.setDeliverCityCode(regionBiCode1.getData().getCode()); |
| | | confirmDelivery(confirmDelivery); |
| | | R r = confirmDelivery(confirmDelivery); |
| | | if (R.isError(r)) { |
| | | throw new ServiceException(r.getMsg(), 500); |
| | | } |
| | | } |
| | | |
| | | } catch (IOException e) { |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 确认发货操作 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R confirmDelivery(ConfirmDelivery confirmDelivery) { |
| | | Order order = this.getById(confirmDelivery.getOrderId()); |
| | | if (1 == order.getPayStatus()) { |
| | | return R.fail("订单还未完成支付"); |
| | | } |
| | | if (1 == order.getOrderType() || null == order.getAddressJson()) { |
| | | return R.fail("该订单不支付快递配送"); |
| | | } |
| | | if (1 != order.getOrderStatus()) { |
| | | return R.fail("无效的操作"); |
| | | } |
| | | //添加快递号和修改订单状态 |
| | | order.setExpressJson(confirmDelivery.getCode()); |
| | | order.setDeliverProvince(confirmDelivery.getDeliverProvince()); |
| | | order.setDeliverProvinceCode(confirmDelivery.getDeliverProvinceCode()); |
| | | order.setDeliverCity(confirmDelivery.getDeliverCity()); |
| | | order.setDeliverCityCode(confirmDelivery.getDeliverCityCode()); |
| | | order.setDeliverDistrict(confirmDelivery.getDeliverDistrict()); |
| | | order.setDeliverDistrictCode(confirmDelivery.getDeliverDistrictCode()); |
| | | order.setOrderStatus(2); |
| | | //添加查询快递信息队列 |
| | | //一小时后定时查询快递信息 |
| | | SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData(); |
| | | 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"); |
| | | UserAddress userAddress = JSON.parseObject(order.getAddressJson(), UserAddress.class); |
| | | MapTrackKD100Vo mapTrackKD100Vo = ExpressDeliveryUtil.kd100MapTrack(com, num, order.getDeliverProvince() + order.getDeliverCity(), |
| | | userAddress.getProvince() + userAddress.getCity()); |
| | | order.setExpressResult(JSON.toJSONString(mapTrackKD100Vo)); |
| | | this.updateById(order); |
| | | |
| | | // 发布事件 |
| | | applicationEventPublisher.publishEvent(new ConfirmDeliveryEvent(order.getId())); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | public static void importExpress2(String filePath) throws MalformedURLException { |
| | |
| | | public Integer getShopSaleNumByShopIds(List<Integer> shopIds, Integer type) { |
| | | return this.baseMapper.getShopSaleNumByShopIds(shopIds, type); |
| | | } |
| | | |
| | | @Override |
| | | public List<OrderExport> getOrderExportList(OrderPageList orderPageList) { |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询给定用户在给定门店核销的订单 |
| | | * @param shopId |
| | | * @param appUserId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Order> getOrderByAppUserIdsAndWriteOffShop(Integer shopId, Set<Long> appUserId) { |
| | | return this.baseMapper.getOrderByAppUserIdsAndWriteOffShop(shopId, appUserId); |
| | | } |
| | | } |