|
|
@@ -33,11 +33,20 @@ public class UserGalaxyCoinServiceImpl implements UserGalaxyCoinService {
|
|
|
@Override
|
|
|
public void sendGalaxyCoinRecord(Long userId, Integer galaxyCoin, String remark, Boolean isLottery) {
|
|
|
if (!isLottery) {
|
|
|
- sendGalaxyCoinHandle(userId, null, galaxyCoin, remark, true);
|
|
|
+ sendGalaxyCoinHandle(userId, null, galaxyCoin, remark, true, true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void sendGalaxyCoinHandle(Long userId, Long orderId, Integer galaxyCoin, String remark, Boolean isRecord) {
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @param orderId
|
|
|
+ * @param galaxyCoin
|
|
|
+ * @param remark
|
|
|
+ * @param isRecord 是否记录
|
|
|
+ * @param available 该笔银河币是否可用
|
|
|
+ */
|
|
|
+ public void sendGalaxyCoinHandle(Long userId, Long orderId, Integer galaxyCoin, String remark, Boolean isRecord, Boolean available) {
|
|
|
if (galaxyCoin <= 0) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -54,7 +63,7 @@ public class UserGalaxyCoinServiceImpl implements UserGalaxyCoinService {
|
|
|
.eq(User::getGalaxyCoin, userGalaxyCoin));
|
|
|
if (update == 1) {
|
|
|
if (isRecord) {
|
|
|
- recordUseRecord(userId, orderId, BigDecimal.valueOf(galaxyCoin), remark);
|
|
|
+ recordUseRecord(userId, orderId, BigDecimal.valueOf(galaxyCoin), remark, available);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
@@ -65,7 +74,7 @@ public class UserGalaxyCoinServiceImpl implements UserGalaxyCoinService {
|
|
|
* 记录银河币详情
|
|
|
*/
|
|
|
@Override
|
|
|
- public void recordUseRecord(Long orderId, Long userId, BigDecimal galaxyCoin, String remark) {
|
|
|
+ public void recordUseRecord(Long orderId, Long userId, BigDecimal galaxyCoin, String remark, Boolean available) {
|
|
|
UserGalaxyCoinRecord userGalaxyCoinRecord = new UserGalaxyCoinRecord();
|
|
|
userGalaxyCoinRecord.setOrderId(orderId);
|
|
|
userGalaxyCoinRecord.setUserId(userId);
|
|
|
@@ -80,7 +89,8 @@ public class UserGalaxyCoinServiceImpl implements UserGalaxyCoinService {
|
|
|
userGalaxyCoinRecord.setExpiryTime(DateUtil.endOfYear(DateTime.now()));
|
|
|
}
|
|
|
//下单 标记该笔银河币记录为已使用
|
|
|
- if (StrUtil.equals(PointsRecordConst.ORDER, remark)) {
|
|
|
+ //该银河币是否可用
|
|
|
+ if (!available) {
|
|
|
userGalaxyCoinRecord.setIsUsed(Boolean.TRUE);
|
|
|
//下单时,剩余是0
|
|
|
userGalaxyCoinRecord.setRemainGalaxyCoin(BigDecimal.ZERO);
|
|
|
@@ -104,7 +114,23 @@ public class UserGalaxyCoinServiceImpl implements UserGalaxyCoinService {
|
|
|
return;
|
|
|
}
|
|
|
//发送银河币
|
|
|
- sendGalaxyCoinHandle(userId, orderId, galaxyCoin.intValue(), PointsRecordConst.ORDER_REFUND, true);
|
|
|
+ sendGalaxyCoinHandle(userId, orderId, galaxyCoin.intValue(), PointsRecordConst.ORDER_REFUND, true, true);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void subOrderGenerateGalaxyCoin(Long orderId) {
|
|
|
+ UserGalaxyCoinRecord userGalaxyCoinRecord = userGalaxyCoinRecordMapper.selectOne(Wrappers.lambdaQuery(UserGalaxyCoinRecord.class)
|
|
|
+ .eq(UserGalaxyCoinRecord::getOrderId, orderId)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (userGalaxyCoinRecord != null) {
|
|
|
+ BigDecimal remainGalaxyCoin = userGalaxyCoinRecord.getRemainGalaxyCoin();
|
|
|
+ if (remainGalaxyCoin.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ //扣除记录 对应的银河币不可用
|
|
|
+ sendGalaxyCoinHandle(userGalaxyCoinRecord.getUserId(), orderId, remainGalaxyCoin.negate().intValue(), PointsRecordConst.ORDER_REFUND_SUB, true, false);
|
|
|
+ userGalaxyCoinRecord.setRemainGalaxyCoin(BigDecimal.ZERO);
|
|
|
+ userGalaxyCoinRecord.setIsUsed(Boolean.TRUE);
|
|
|
+ userGalaxyCoinRecordMapper.updateById(userGalaxyCoinRecord);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|