| | |
| | | return BigDecimal.ZERO; |
| | | } |
| | | String rateStr = systemDictDataBiz.queryByCode(Constants.OPERATION_CONFIG, Constants.OP_INSURANCE_RATE).getCode(); |
| | | BigDecimal rate = new BigDecimal(rateStr); |
| | | BigDecimal rate = new BigDecimal(rateStr).divide(new BigDecimal("100"), 4, BigDecimal.ROUND_HALF_UP); |
| | | return declaredValue.multiply(rate).setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | |
| | |
| | | List<Category> categories = categoryMapper.selectBatchIds(categoryIds); |
| | | Map<Integer, String> categoryNameMap = new HashMap<>(); |
| | | Map<Integer, String> categoryDetailMap = new HashMap<>(); |
| | | Map<Integer, String> categoryOtherFieldMap = new HashMap<>(); |
| | | for (Category c : categories) { |
| | | categoryNameMap.put(c.getId(), c.getName()); |
| | | categoryDetailMap.put(c.getId(), c.getDetail()); |
| | | categoryOtherFieldMap.put(c.getId(),c.getOtherField()); |
| | | } |
| | | |
| | | // 计算每项物品费用:小计 = 单价 × 数量 × 天数 |
| | |
| | | ItemPriceVO vo = new ItemPriceVO(); |
| | | vo.setCategoryId(item.getCategoryId()); |
| | | vo.setCategoryName(categoryNameMap.getOrDefault(item.getCategoryId(), "")); |
| | | vo.setDetail(categoryDetailMap.get(item.getCategoryId())); |
| | | vo.setDetail(categoryOtherFieldMap.get(item.getCategoryId())); |
| | | vo.setQuantity(item.getQuantity()); |
| | | vo.setUnitPrice(unitPrice); |
| | | vo.setLocallyPrice(unitPrice); |
| | |
| | | List<Category> categories = categoryMapper.selectBatchIds(categoryIds); |
| | | Map<Integer, String> categoryNameMap = new HashMap<>(); |
| | | Map<Integer, String> categoryDetailMap = new HashMap<>(); |
| | | Map<Integer, String> categoryOtherFieldMap = new HashMap<>(); |
| | | for (Category c : categories) { |
| | | categoryNameMap.put(c.getId(), c.getName()); |
| | | categoryDetailMap.put(c.getId(), c.getDetail()); |
| | | categoryOtherFieldMap.put(c.getId(),c.getOtherField()); |
| | | } |
| | | |
| | | // 3. 逐项计算运费:起步价 + 超出部分阶梯价 |
| | |
| | | ItemPriceVO vo = new ItemPriceVO(); |
| | | vo.setCategoryId(item.getCategoryId()); |
| | | vo.setCategoryName(categoryNameMap.getOrDefault(item.getCategoryId(), "")); |
| | | vo.setDetail(categoryDetailMap.get(item.getCategoryId())); |
| | | vo.setDetail(categoryOtherFieldMap.get(item.getCategoryId())); |
| | | vo.setQuantity(item.getQuantity()); |
| | | vo.setUnitPrice(unitPrice); |
| | | vo.setLocallyPrice(locallyPrice); |
| | |
| | | item.setLuggageName(d.getLuggageName()); |
| | | item.setLuggageDetail(d.getLuggageDetail()); |
| | | item.setNum(d.getNum()); |
| | | double unitPriceYuan = d.getUnitPrice() != null ? Constants.getFormatMoney(d.getUnitPrice()) : 0; |
| | | item.setUnitPriceYuan(unitPriceYuan); |
| | | item.setSubtotal(unitPriceYuan * (d.getNum() != null ? d.getNum() : 0)); |
| | | long unitPriceFen = d.getUnitPrice() != null ? d.getUnitPrice() : 0L; |
| | | item.setUnitPrice(unitPriceFen); |
| | | item.setSubtotal(unitPriceFen * (d.getNum() != null ? d.getNum() : 0)); |
| | | items.add(item); |
| | | } |
| | | } |
| | |
| | | vo.setCode(o.getCode()); |
| | | vo.setType(o.getType()); |
| | | vo.setStatus(o.getStatus()); |
| | | vo.setStatusName(Constants.OrderStatus.getDescByKey(o.getStatus(), |
| | | Constants.equalsInteger(o.getType(), Constants.ZERO)?o.getType():Objects.nonNull(o.getTakeShopId())?Constants.ONE:Constants.TWO) |
| | | ); |
| | | vo.setCreateTime(o.getCreateTime()); |
| | | vo.setExpectedTakeTime(o.getExpectedTakeTime()); |
| | | vo.setMemberVerifyCode(o.getMemberVerifyCode()); |
| | | |
| | | // 存件门店(关联查询直接取值) |
| | | vo.setDepositShopId(o.getDepositShopId()); |
| | | vo.setDepositShopName(o.getDepositShopName()); |
| | | vo.setDepositShopLinkName(o.getDepositShopLinkName()); |
| | | vo.setDepositShopPhone(o.getDepositShopLinkPhone()); |
| | | |
| | | // 取件信息:有取件门店取门店,无则取用户自选取件点 |
| | | if (o.getTakeShopId() != null) { |
| | | vo.setTakeShopId(o.getTakeShopId()); |
| | | vo.setTakeShopName(o.getTakeShopName()); |
| | | vo.setTakeShopAddress(o.getTakeShopAddress()); |
| | | } else { |
| | |
| | | // 费用(分) |
| | | vo.setDeclaredFee(o.getDeclaredFee()); |
| | | vo.setEstimatedAmount(o.getEstimatedAmount()); |
| | | |
| | | // 评价状态 |
| | | vo.setCommentStatus(o.getCommentStatus()); |
| | | |
| | | // 查询物品明细(一次查询,同时用于物品列表和逾期计算) |
| | | List<OrdersDetail> details = ordersDetailMapper.selectList( |
| | |
| | | vo.setCode(o.getCode()); |
| | | vo.setType(o.getType()); |
| | | vo.setStatus(o.getStatus()); |
| | | vo.setStatusName(Constants.OrderStatus.getDescByKey(o.getStatus(), |
| | | Constants.equalsInteger(o.getType(), Constants.ZERO)?o.getType():Objects.nonNull(o.getTakeShopId())?Constants.ONE:Constants.TWO) |
| | | ); |
| | | vo.setCreateTime(o.getCreateTime()); |
| | | vo.setExpectedTakeTime(o.getExpectedTakeTime()); |
| | | |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | |
| | | // 仅异地寄存可取消 |
| | | if (!Constants.equalsInteger(order.getType(), Constants.ONE)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "仅异地寄存订单可取消"); |
| | | } |
| | | |
| | | Integer status = order.getStatus(); |
| | | if (status == null) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "订单状态异常"); |
| | |
| | | |
| | | Date now = new Date(); |
| | | |
| | | // 待支付:直接取消 |
| | | // 待支付:直接取消(不限订单类型) |
| | | if (Constants.equalsInteger(status, Constants.OrderStatus.waitPay.getStatus())) { |
| | | order.setStatus(Constants.OrderStatus.cancelled.getStatus()); |
| | | order.setCancelTime(now); |
| | |
| | | return; |
| | | } |
| | | |
| | | // 待寄存:直接取消,全额退款 |
| | | // 待寄存:直接取消,全额退款(不限订单类型) |
| | | if (Constants.equalsInteger(status, Constants.OrderStatus.waitDeposit.getStatus())) { |
| | | // 记录退款信息 |
| | | OrdersRefund refund = new OrdersRefund(); |
| | |
| | | return; |
| | | } |
| | | |
| | | // 已寄存/已接单:仅异地寄存可取消 |
| | | if (!Constants.equalsInteger(order.getType(), Constants.ONE)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "仅异地寄存订单可取消"); |
| | | } |
| | | |
| | | // 已寄存/已接单:进入取消中状态 |
| | | if (Constants.equalsInteger(status, Constants.OrderStatus.deposited.getStatus()) |
| | | || Constants.equalsInteger(status, Constants.OrderStatus.accepted.getStatus())) { |
| | |
| | | // 通知存件门店:退款申请 |
| | | if (order.getDepositShopId() != null) { |
| | | sendShopNotice(order.getDepositShopId(), Constants.ShopOrderNotify.REFUNDING, orderId, |
| | | "orderNo", order.getCode()); |
| | | } |
| | | // 通知司机:订单退款中(已接单情况下司机需停止服务) |
| | | if (order.getAcceptDriver() != null && Constants.equalsInteger(order.getStatus(), Constants.OrderStatus.accepted.getStatus())) { |
| | | sendDriverNotice(order.getAcceptDriver(), Constants.DriverOrderNotify.REFUNDING, orderId, |
| | | "orderNo", order.getCode()); |
| | | } |
| | | return; |
| | |
| | | if (order.getTakeShopId() != null) { |
| | | sendShopNotice(order.getTakeShopId(), notify, order.getId(), params); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 发送司机站内信通知 |
| | | */ |
| | | private void sendDriverNotice(Integer driverId, Constants.DriverOrderNotify notify, Integer orderId, String... params) { |
| | | DriverInfo driver = driverInfoMapper.selectById(driverId); |
| | | if (driver == null || driver.getMemberId() == null) { |
| | | return; |
| | | } |
| | | Notice notice = new Notice(); |
| | | notice.setUserType(1); // 1=司机 |
| | | notice.setUserId(driver.getMemberId()); |
| | | notice.setTitle(notify.getTitle()); |
| | | notice.setContent(notify.format(params)); |
| | | notice.setObjId(orderId); |
| | | notice.setObjType(0); // 0=订单 |
| | | notice.setStatus(0); // 0=未读 |
| | | notice.setIsdeleted(Constants.ZERO); |
| | | notice.setCreateDate(new Date()); |
| | | noticeService.create(notice); |
| | | } |
| | | |
| | | @Override |
| | |
| | | "orderNo", order.getCode(), |
| | | "amount", String.valueOf(Constants.getFormatMoney( |
| | | order.getTotalAmount() != null ? order.getTotalAmount() : 0L))); |
| | | |
| | | // 通知司机:订单已结算 |
| | | if (order.getAcceptDriver() != null) { |
| | | sendDriverNotice(order.getAcceptDriver(), Constants.DriverOrderNotify.SETTLED, order.getId(), |
| | | "orderNo", order.getCode(), |
| | | "amount", String.valueOf(Constants.getFormatMoney( |
| | | order.getDriverFee() != null ? order.getDriverFee() : 0L))); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | // 通知存件门店和取件门店:订单已评价 |
| | | notifyBothShops(order, Constants.ShopOrderNotify.EVALUATED, |
| | | "orderNo", order.getCode()); |
| | | |
| | | // 通知司机:订单已评价 |
| | | if (order.getAcceptDriver() != null) { |
| | | sendDriverNotice(order.getAcceptDriver(), Constants.DriverOrderNotify.EVALUATED, order.getId(), |
| | | "orderNo", order.getCode()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | notifyBothShops(order, Constants.ShopOrderNotify.FINISHED, |
| | | "orderNo", order.getCode(), |
| | | "settleDays", settleDays != null ? settleDays : "7"); |
| | | // 通知司机:订单已完成 |
| | | if (order.getAcceptDriver() != null) { |
| | | sendDriverNotice(order.getAcceptDriver(), Constants.DriverOrderNotify.FINISHED, order.getId(), |
| | | "orderNo", order.getCode(), |
| | | "settleDays", settleDays != null ? settleDays : "7"); |
| | | } |
| | | } else { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "当前订单状态不允许核销"); |
| | | } |
| | |
| | | notifyBothShops(order, Constants.ShopOrderNotify.FINISHED, |
| | | "orderNo", order.getCode(), |
| | | "settleDays", settleDays != null ? settleDays : "7"); |
| | | // 通知司机:订单已完成 |
| | | if (order.getAcceptDriver() != null) { |
| | | sendDriverNotice(order.getAcceptDriver(), Constants.DriverOrderNotify.FINISHED, order.getId(), |
| | | "orderNo", order.getCode(), |
| | | "settleDays", settleDays != null ? settleDays : "7"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | notifyBothShops(order, Constants.ShopOrderNotify.FINISHED, |
| | | "orderNo", order.getCode(), |
| | | "settleDays", settleDays != null ? settleDays : "7"); |
| | | // 通知司机:订单已完成 |
| | | if (order.getAcceptDriver() != null) { |
| | | sendDriverNotice(order.getAcceptDriver(), Constants.DriverOrderNotify.FINISHED, order.getId(), |
| | | "orderNo", order.getCode(), |
| | | "settleDays", settleDays != null ? settleDays : "7"); |
| | | } |
| | | } |
| | | |
| | | @Override |