|
|
|
@ -8,6 +8,8 @@ import com.hai.entity.*; |
|
|
|
|
import com.hai.service.*; |
|
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.TransactionDefinition; |
|
|
|
|
import org.springframework.transaction.annotation.Isolation; |
|
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
@ -41,7 +43,7 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic |
|
|
|
|
private HighDiscountAgentCodeService highDiscountAgentCodeService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
|
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW,isolation= Isolation.SERIALIZABLE) |
|
|
|
|
public void receiveDiscount(Long userId, Long codeId) { |
|
|
|
|
|
|
|
|
|
// 查询优惠券二维码
|
|
|
|
@ -54,6 +56,8 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic |
|
|
|
|
if(code.getStatus() != 1) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "二维码不存在或已被领取"); |
|
|
|
|
} |
|
|
|
|
code.setStatus(2); |
|
|
|
|
highDiscountAgentCodeService.updateCode(code); |
|
|
|
|
|
|
|
|
|
// 查询优惠券信息
|
|
|
|
|
HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(code.getDiscountAgentId()); |
|
|
|
@ -65,9 +69,9 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic |
|
|
|
|
|
|
|
|
|
// 校验卡卷状态
|
|
|
|
|
if (rel.getHighDiscount().getStatus() != 2) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡券已下架"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法领取,优惠券已过期"); |
|
|
|
|
} |
|
|
|
|
if (rel.getStockCount() <= 0) { |
|
|
|
|
/* if (rel.getStockCount() <= 0) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.DISCOUNT_STOCK_COUNT_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -76,7 +80,7 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic |
|
|
|
|
example.createCriteria().andUserIdEqualTo(userId).andDiscountIdEqualTo(rel.getDiscountId()).andStatusEqualTo(1); |
|
|
|
|
if (highDiscountUserRelMapper.selectByExample(example).size() > 0) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "重复领取卡券,请使用后再进行领取"); |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
HighDiscountUserRel userRel = new HighDiscountUserRel(); |
|
|
|
|
userRel.setDiscountId(rel.getDiscountId()); |
|
|
|
|