| | |
| | | if (goodType==1){ |
| | | TGoods byId = goodsService.getById(id); |
| | | if (byId==null||byId.getStatus()==2){ |
| | | return R.fail(2,"内容不存在"); |
| | | return R.fail(2,"该商品已不存在"); |
| | | } |
| | | // List<Integer> data = orderClient.getSalesCountByGoodsId(String.valueOf(id)).getData(); |
| | | // for (int i = 0; i < list.size(); i++) { |
| | |
| | | else { |
| | | TCoupon byId = couponService.getById(id); |
| | | if (byId==null||byId.getStatus()==2){ |
| | | return R.fail(2,"内容不存在"); |
| | | return R.fail(2,"该商品已不存在"); |
| | | } |
| | | return R.ok(byId); |
| | | } |
| | |
| | | return AjaxResult.error("当前用户已兑换"+count+"张"); |
| | | }else { |
| | | //减少库存 |
| | | good.setInventory(good.getInventory()-exchangeDto.getNum()); |
| | | goodsService.updateById(good); |
| | | if (good.getInventory()!=-1) { |
| | | good.setInventory(good.getInventory() - exchangeDto.getNum()); |
| | | goodsService.updateById(good); |
| | | } |
| | | } |
| | | if (user.getPoints()<good.getRedeemPoints()){ |
| | | return AjaxResult.error("当前用户积分不足"); |
| | |
| | | if (coupon.getInventoryQuantity() != -1 && count >= coupon.getInventoryQuantity()) { |
| | | return AjaxResult.error("当前用户已到达兑换"+coupon+"次"); |
| | | }else { |
| | | coupon.setInventoryQuantity(coupon.getInventoryQuantity()-1); |
| | | couponService.updateById(coupon); |
| | | if (coupon.getInventoryQuantity()!=-1) { |
| | | coupon.setInventoryQuantity(coupon.getInventoryQuantity() - 1); |
| | | couponService.updateById(coupon); |
| | | } |
| | | } |
| | | |
| | | |