|
@@ -10,7 +10,6 @@ import com.qs.mp.common.enums.GoodsStatusEnum;
|
|
|
import com.qs.mp.common.enums.PrizeStorageInTypeEnum;
|
|
|
import com.qs.mp.common.enums.PrizeStorageStatusEnum;
|
|
|
import com.qs.mp.common.exception.ServiceException;
|
|
|
-import com.qs.mp.common.utils.StringUtils;
|
|
|
import com.qs.mp.system.service.id.BizIdGenerator;
|
|
|
import com.qs.mp.user.domain.UserCoin;
|
|
|
import com.qs.mp.user.domain.UserExchangeOrder;
|
|
@@ -53,7 +52,7 @@ public class UserExchangeOrderServiceImpl extends ServiceImpl<UserExchangeOrderM
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public void exchange(Long userId, Long goodsId, Long skuId, int orderNum) {
|
|
|
+ public boolean exchange(Long userId, Long goodsId, Long skuId, int orderNum) {
|
|
|
int orderAmt = 0;
|
|
|
Goods goods = goodsService.getById(goodsId);
|
|
|
GoodsSku goodsSku = new GoodsSku();
|
|
@@ -74,7 +73,7 @@ public class UserExchangeOrderServiceImpl extends ServiceImpl<UserExchangeOrderM
|
|
|
// 盲豆余额校验
|
|
|
UserCoin userCoin = userCoinService.getById(userId);
|
|
|
if (null == userCoin.getCoin() || userCoin.getCoin() < orderAmt) {
|
|
|
- throw new ServiceException(ErrorCodeEnum.ERROR_CODE_1021);
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
// 生成兑换订单
|
|
@@ -118,5 +117,7 @@ public class UserExchangeOrderServiceImpl extends ServiceImpl<UserExchangeOrderM
|
|
|
.set(Goods::getExchangedQty, goods.getExchangedQty() + orderNum)
|
|
|
.eq(Goods::getGoodsId, goodsId).eq(Goods::getQuantity, goods.getQuantity()).eq(Goods::getExchangedQty, goods.getExchangedQty()));
|
|
|
Assert.isTrue(updateGoods, "兑换商品更新GOODS库存失败。goodsId:" + goodsId );
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|