| | |
| | | MallMemberCoupon mallMemberCoupon = new MallMemberCoupon(); |
| | | if(ObjectUtil.isNotEmpty(addOrderDto.getMemberCouponId())){ |
| | | Long memberCouponId = addOrderDto.getMemberCouponId(); |
| | | mallMemberCoupon = mallMemberCouponMapper.selectById(memberCouponId); |
| | | if(ObjectUtil.isEmpty(mallMemberCoupon)){ |
| | | throw new FebsException(mallMemberCoupon.getCouponName()+"无法使用"); |
| | | } |
| | | Integer state = mallMemberCoupon.getState(); |
| | | if(1 != state){ |
| | | throw new FebsException(mallMemberCoupon.getCouponName()+"无法使用"); |
| | | } |
| | | |
| | | mallMemberCoupon = ValidateEntityUtils.ensureColumnReturnEntity(memberCouponId, MallMemberCoupon::getId, mallMemberCouponMapper::selectOne, "优惠券不存在"); |
| | | ValidateEntityUtils.ensureEqual(mallMemberCoupon.getState(),1, "优惠券状态异常"); |
| | | List<AddOrderItemDto> items = addOrderDto.getItems(); |
| | | couponAmountMap = getCouponAmountMap(memberCouponId, items); |
| | | } |
| | |
| | | if (mallGoods.getStock() < item.getCnt()) { |
| | | throw new FebsException(mallGoods.getGoodsName() + "库存不足"); |
| | | } |
| | | |
| | | if (MallGoods.ISSALE_STATUS_DISABLED.equals(mallGoods.getIsSale())) { |
| | | throw new FebsException(mallGoods.getGoodsName() + "已下架"); |
| | | } |
| | | ValidateEntityUtils.ensureNotEqual(mallGoods.getIsSale(),MallGoods.ISSALE_STATUS_DISABLED, "商品已下架"); |
| | | // if (MallGoods.ISSALE_STATUS_DISABLED.equals(mallGoods.getIsSale())) { |
| | | // throw new FebsException(mallGoods.getGoodsName() + "已下架"); |
| | | // } |
| | | |
| | | BigDecimal amount = mallGoods.getScore().multiply(BigDecimal.valueOf(item.getCnt())); |
| | | orderItem.setAmount(amount); |
| | |
| | | } |
| | | } |
| | | |
| | | if (MallGoods.ISSALE_STATUS_DISABLED.equals(mallGoods.getIsSale())) { |
| | | throw new FebsException(mallGoods.getGoodsName() + "已下架"); |
| | | } |
| | | ValidateEntityUtils.ensureNotEqual(mallGoods.getIsSale(),MallGoods.ISSALE_STATUS_DISABLED, "商品已下架"); |
| | | //商品库存销量计算 |
| | | Integer goodsResult = mallGoodsMapper.upDateStockAndVolumeByGoodsId(mallGoods.getId(), item.getCnt()); |
| | | if(1 != goodsResult){ |
| | |
| | | public void cancelOrder(Long id) { |
| | | MallMember member = LoginUserUtil.getLoginUser(); |
| | | MallOrderInfo orderInfo = this.baseMapper.selectOrderByMemberIdAndId(member.getId(), id); |
| | | if (orderInfo == null || AppContants.DEL_FLAG_Y == orderInfo.getDelFlag()) { |
| | | throw new FebsException("订单不存在"); |
| | | } |
| | | ValidateEntityUtils.ensureNotEqual(orderInfo,null, "订单不存在"); |
| | | ValidateEntityUtils.ensureNotEqual(orderInfo.getDelFlag(),AppContants.DEL_FLAG_Y, "订单已删除"); |
| | | |
| | | if (OrderStatusEnum.WAIT_PAY.getValue() != orderInfo.getStatus() |
| | | && OrderStatusEnum.WAIT_SHIPPING.getValue() != orderInfo.getStatus() ) { |
| | | throw new FebsException("订单不是待付款或者待收货, 无法取消"); |
| | | } |
| | | |
| | | orderInfo.setStatus(OrderStatusEnum.CANCEL.getValue()); |
| | | orderInfo.setCancelType(MallOrderInfo.CANCEL_BY_SELF); |
| | | this.baseMapper.updateById(orderInfo); |
| | |
| | | |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), orderInfo.getAmount().negate(), MoneyFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.BALANCE.getValue(),"余额支付",2); |
| | | |
| | | agentProducer.sendOrderCoupon(orderInfo.getId()); |
| | | // agentProducer.sendOrderCoupon(orderInfo.getId()); |
| | | break; |
| | | case "4": |
| | | if (orderInfo.getOrderType() != 2) { |
| | |
| | | throw new FebsException("未设置支付密码"); |
| | | } |
| | | |
| | | if (!SecureUtil.md5(tradePwd).equals(mallMember.getTradePassword())) { |
| | | throw new FebsException("支付密码错误"); |
| | | } |
| | | ValidateEntityUtils.ensureEqual(SecureUtil.md5(tradePwd),mallMember.getTradePassword(),"支付密码错误"); |
| | | |
| | | // int reduce = memberWalletService.reduce(orderInfo.getAmount(), mallMember.getId(), field); |
| | | // if (reduce == 2) { |