| | |
| | | //检查当前用户积分是否够 |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | Integer point = 0; |
| | | TAppUser user = appUserClient.getUserById(userId).getData(); |
| | | |
| | | if (exchangeDto.getGoodType()==1) { |
| | | //查询当前商品信息 |
| | |
| | | if (good.getLimitExchangeTimes() != -1 && count >= good.getLimitExchangeTimes()) { |
| | | return AjaxResult.error("当前用户已兑换"+count+"张"); |
| | | } |
| | | TAppUser user = appUserClient.getUserById(userId).getData(); |
| | | if (user.getPoints()<good.getRedeemPoints()){ |
| | | return AjaxResult.error("当前用户积分不足"); |
| | | } |
| | |
| | | Long count = orderClient.getExchangeById(exchangeDto.getGoodId(), userId,exchangeDto.getGoodType()).getData(); |
| | | if (coupon.getInventoryQuantity() != -1 && count >= coupon.getInventoryQuantity()) { |
| | | return AjaxResult.error("当前用户已到达兑换"+coupon+"次"); |
| | | } |
| | | if (user.getPoints()<point){ |
| | | return AjaxResult.error("当前用户积分不足"); |
| | | } |
| | | } |
| | | exchangeDto.setPoint(point); |
| | |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | TAppUser user = appUserClient.getUserById(userId).getData(); |
| | | boolean isVip = false; |
| | | if (user.getVipEndTime().isAfter(LocalDateTime.now())){ |
| | | if (user.getVipEndTime()!=null&&user.getVipEndTime().isAfter(LocalDateTime.now())){ |
| | | isVip = true; |
| | | } |
| | | //计算价格 |
| | |
| | | originalPrice = good.getVipPrice(); |
| | | } |
| | | } |
| | | orderPrice.add(originalPrice.multiply(BigDecimal.valueOf(exchangeDto.getNum()))); |
| | | orderPrice = orderPrice.add(originalPrice.multiply(BigDecimal.valueOf(exchangeDto.getNum()))); |
| | | }else { |
| | | TCoupon coupon = couponService.getById(exchangeDto.getGoodId()); |
| | | BigDecimal originalPrice = coupon.getPaymentAmount(); |
| | |
| | | originalPrice = coupon.getVipPaymentAmount(); |
| | | } |
| | | } |
| | | orderPrice.add(originalPrice); |
| | | orderPrice = orderPrice.add(originalPrice); |
| | | } |
| | | |
| | | exchangeDto.setOrderPrice(orderPrice); |
| | |
| | | payPrice = orderPrice.subtract(coupon.getDiscountAmount()); |
| | | discountPrice = coupon.getDiscountAmount(); |
| | | } |
| | | exchangeDto.setPayPrice(payPrice); |
| | | exchangeDto.setPayPrice(orderPrice); |
| | | exchangeDto.setDiscountPrice(discountPrice); |
| | | exchangeDto.setVipDiscount(vipDiscount); |
| | | exchangeDto.setUserId(userId); |
| | | //创建订单 |
| | | TShoppingOrder shopOrder = orderClient.shopCreate(exchangeDto).getData(); |
| | | if (exchangeDto.getPayMethod()==1) { |
| | | //调起支付 |
| | | PaymentOrder paymentOrder = new PaymentOrder(); |
| | | paymentOrder.setCode(shopOrder.getCode()); |
| | | paymentOrder.setAmount(shopOrder.getPaymentAmount()); |
| | | paymentOrder.setAmount(exchangeDto.getOrderPrice()); |
| | | paymentOrder.setOpenId(user.getWxOpenid()); |
| | | paymentOrder.setDescription("购买商品"); |
| | | return wxPaymentClient.orderPay(paymentOrder); |
| | | R<Map<String, Object>> mapR = wxPaymentClient.orderPay(paymentOrder); |
| | | return mapR; |
| | | }else { |
| | | //todo 罗 支付宝支付 |
| | | return R.ok(); |