|
@@ -15,6 +15,7 @@ import com.qs.mp.common.enums.TicketPrizeTypeEnum;
|
|
|
import com.qs.mp.common.exception.ServiceException;
|
|
|
import com.qs.mp.user.domain.UserPrizeStorage;
|
|
|
import com.qs.mp.user.domain.param.UserPrizeRecoveryCreateParam;
|
|
|
+import com.qs.mp.user.domain.vo.PrizeRecoverySettleVO;
|
|
|
import com.qs.mp.user.service.IUserCoinService;
|
|
|
import com.qs.mp.user.service.IUserPrizeStorageService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -49,52 +50,24 @@ public class PrizeRecoveryServiceImpl extends ServiceImpl<PrizeRecoveryMapper, P
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void convert(Long userId, UserPrizeRecoveryCreateParam userPrizeRecoveryCreateParam) {
|
|
|
-// UserPrizeStorage userPrizeStorage = userPrizeStorageService.getOne(new LambdaQueryWrapper<UserPrizeStorage>()
|
|
|
-// .eq(UserPrizeStorage::getUserId, userId)
|
|
|
-// .eq(UserPrizeStorage::getStorageId, userPrizeRecoveryCreateParam.getStorageId()));
|
|
|
-// if (Objects.isNull(userPrizeStorage)) {
|
|
|
-// throw new ServiceException("奖品不存在");
|
|
|
-// }
|
|
|
-// if (!PrizeStorageStatusEnum.NOT_DISTRIBUTED.equals(userPrizeStorage.getStatus())) {
|
|
|
-// throw new ServiceException("仅待提货的奖品才可未收回");
|
|
|
-// }
|
|
|
-// if (!PrizeStorageInTypeEnum.TICKET_CASHED.equals(userPrizeStorage.getInType())) {
|
|
|
-// throw new ServiceException("仅盲票兑奖的奖品才可未收回");
|
|
|
-// }
|
|
|
-// if (!TicketPrizeTypeEnum.GOODS.equals(userPrizeRecoveryCreateParam.getPrizeType())) {
|
|
|
-// throw new ServiceException("仅实物奖品才可未收回");
|
|
|
-// }
|
|
|
-//
|
|
|
-// Goods goods = goodsService.getById(userPrizeRecoveryCreateParam.getRefId());
|
|
|
-// if (Objects.isNull(goods)) {
|
|
|
-// throw new ServiceException("商品信息不存在");
|
|
|
-// }
|
|
|
-//
|
|
|
-// PrizeRecovery prizeRecovery = new PrizeRecovery();
|
|
|
-// BeanUtils.copyProperties(userPrizeRecoveryCreateParam, prizeRecovery);
|
|
|
-// prizeRecovery.setUserId(userId);
|
|
|
-// prizeRecovery.setDiscountRate(goods.getDiscountRate());
|
|
|
-// int refundNum = BigDecimal.valueOf(goods.getExchangePrice()).multiply(goods.getDiscountRate()).divide(BigDecimal.valueOf(100), 1, RoundingMode.HALF_UP).intValue();
|
|
|
-// prizeRecovery.setReturnCoin(refundNum);
|
|
|
-//
|
|
|
-//
|
|
|
-// // 更新用户奖品状态
|
|
|
-// boolean rtn = userPrizeStorageService.update(new LambdaUpdateWrapper<UserPrizeStorage>()
|
|
|
-// .set(UserPrizeStorage::getStatus, PrizeStorageStatusEnum.RECOVERY)
|
|
|
-// .eq(UserPrizeStorage::getUserId, userId)
|
|
|
-// .eq(UserPrizeStorage::getStorageId, userPrizeRecoveryCreateParam.getStorageId())
|
|
|
-// .eq(UserPrizeStorage::getStatus, PrizeStorageStatusEnum.NOT_DISTRIBUTED));
|
|
|
-//
|
|
|
-// Assert.isTrue(rtn, "更新奖品状态失败。storageId:" + userPrizeRecoveryCreateParam.getStorageId());
|
|
|
-//
|
|
|
-//
|
|
|
-// // 发放盲豆
|
|
|
-// userCoinService.produce(userId, refundNum, prizeRecovery.getId().toString(), CoinLogTypeEnum.RECOVERY);
|
|
|
-//
|
|
|
-//
|
|
|
-// this.save(prizeRecovery);
|
|
|
+ public void submitRecovery(Long userId, PrizeRecoverySettleVO settleVO) {
|
|
|
+ PrizeRecovery prizeRecovery = new PrizeRecovery();
|
|
|
+ BeanUtils.copyProperties(settleVO, prizeRecovery);
|
|
|
+ prizeRecovery.setUserId(userId);
|
|
|
|
|
|
+ // 更新用户奖品状态
|
|
|
+ boolean rtn = userPrizeStorageService.update(new LambdaUpdateWrapper<UserPrizeStorage>()
|
|
|
+ .set(UserPrizeStorage::getStatus, PrizeStorageStatusEnum.RECOVERY)
|
|
|
+ .eq(UserPrizeStorage::getUserId, userId)
|
|
|
+ .eq(UserPrizeStorage::getStorageId, settleVO.getStorageId())
|
|
|
+ .eq(UserPrizeStorage::getStatus, PrizeStorageStatusEnum.NOT_DISTRIBUTED));
|
|
|
+
|
|
|
+ Assert.isTrue(rtn, "更新奖品状态失败。storageId:" + settleVO.getStorageId());
|
|
|
+
|
|
|
+ // 发放盲豆
|
|
|
+ userCoinService.produce(userId, settleVO.getRefundCoin(), prizeRecovery.getId().toString(), CoinLogTypeEnum.RECOVERY);
|
|
|
+
|
|
|
+ this.save(prizeRecovery);
|
|
|
|
|
|
}
|
|
|
}
|