| | |
| | | } |
| | | |
| | | public Long insureOrder(InsureOrderDto model) { |
| | | long id = model.getId(); |
| | | ScoreOrder scoreOrderBefore = scoreOrderMapper.selectByPrimaryKey(id); |
| | | ScoreOrder scoreOrder = new ScoreOrder(); |
| | | scoreOrder.setId(model.getId()); |
| | | if(ScoreOrder.STATUS_DOING == scoreOrderBefore.getStatus()){ |
| | | scoreOrder.setStatus(ScoreOrder.STATUS_DONE); |
| | | } |
| | | // scoreOrder.setStatus(ScoreOrder.STATUS_DONE); |
| | | scoreOrder.setIsFinish(ScoreOrder.ISFINISH_YES); |
| | | scoreOrder.setVoucherImg(CollUtil.join(model.getVoucherImgs(),",")); |
| | |
| | | } |
| | | |
| | | AccountInfo accountInfo = accountInfoMapper.selectAccountInfoByUserId(addGoodsOrderDto.getUserId()); |
| | | log.info("积分:{}", accountInfo.getCollectScore()); |
| | | if (accountInfo.getCollectScore() == null) { |
| | | throw new RestException(-3, "积分不足"); |
| | | } |
| | | |
| | | BigDecimal totalPrice = sku.getPresentPrice().multiply(BigDecimal.valueOf(addGoodsOrderDto.getCnt())); |
| | | BigDecimal score = new BigDecimal(accountInfo.getCollectScore()); |
| | | log.info("积分:{}", score); |
| | | log.info("积分1:{}", totalPrice); |
| | | if (score.compareTo(totalPrice) < 0) { |
| | | throw new RestException(-3, "积分不足"); |
| | | } |
| | |
| | | scoreDetails.setType(ScoreDetails.SCORE_TYPE_SHOPPING); |
| | | scoreDetails.setOriginalScore(score); |
| | | scoreDetails.setCurrentScore(remianScore); |
| | | scoreDetails.setChangeScore(totalPrice); |
| | | scoreDetails.setChangeScore(totalPrice.negate()); |
| | | scoreDetails.setCreatedTime(new Date()); |
| | | scoreDetailsMapper.insert(scoreDetails); |
| | | |
| | | sku.setStock(sku.getStock() - addGoodsOrderDto.getCnt()); |
| | | sku.setQuantity(sku.getQuantity() - addGoodsOrderDto.getCnt()); |
| | | sku.setQuantity(sku.getQuantity() + addGoodsOrderDto.getCnt()); |
| | | scoreGoodsSkuMapper.updateByPrimaryKey(sku); |
| | | } |
| | | |
| | |
| | | throw new RestException(-3, "暂不能确认收货"); |
| | | } |
| | | |
| | | scoreOrderMapper.updateOrderStatus(id, ScoreOrder.STATUS_DOING, userId); |
| | | if (ScoreOrder.ISFINISH_YES.equals(order.getIsFinish())) { |
| | | scoreOrderMapper.updateOrderStatus(id, ScoreOrder.STATUS_DONE, userId); |
| | | } else { |
| | | scoreOrderMapper.updateOrderStatus(id, ScoreOrder.STATUS_DOING, userId); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void cancelOrder(Long id, String userId) { |