@ -6,6 +6,7 @@ import com.hai.common.exception.SysCode;
import com.hai.dao.HighDiscountUserRelMapper ;
import com.hai.dao.HighDiscountUserRelMapper ;
import com.hai.entity.* ;
import com.hai.entity.* ;
import com.hai.enum_type.DiscountPlatform ;
import com.hai.enum_type.DiscountPlatform ;
import com.hai.enum_type.DiscountUseScope ;
import com.hai.service.* ;
import com.hai.service.* ;
import org.apache.commons.collections4.MapUtils ;
import org.apache.commons.collections4.MapUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.commons.lang3.StringUtils ;
@ -46,6 +47,8 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic
@Resource
@Resource
private HighDiscountAgentCodeService highDiscountAgentCodeService ;
private HighDiscountAgentCodeService highDiscountAgentCodeService ;
@Resource
private SecConfigService secConfigService ;
@Override
@Override
@Transactional ( propagation = Propagation . REQUIRES_NEW , isolation = Isolation . SERIALIZABLE )
@Transactional ( propagation = Propagation . REQUIRES_NEW , isolation = Isolation . SERIALIZABLE )
@ -85,7 +88,12 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic
if ( discount . getReceiveNumber ( ) > 0 & & this . receiveDiscountCount ( userId , discount . getId ( ) ) . intValue ( ) > = discount . getReceiveNumber ( ) . intValue ( ) ) {
if ( discount . getReceiveNumber ( ) > 0 & & this . receiveDiscountCount ( userId , discount . getId ( ) ) . intValue ( ) > = discount . getReceiveNumber ( ) . intValue ( ) ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "优惠券已达到上线" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "优惠券已达到上线" ) ;
}
}
if ( discount . getUseScope ( ) . equals ( DiscountUseScope . type8 . getType ( ) ) ) {
SecConfig cqCnpcQuota = secConfigService . findByCodeType ( "CQ_CNPC_QUOTA" ) ;
if ( cqCnpcQuota ! = null & & highDiscountUserRelMapper . userReceiveLimitNumber ( userId , DiscountUseScope . type8 . getType ( ) ) . intValue ( ) > = Integer . parseInt ( cqCnpcQuota . getCodeValue ( ) ) ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "当日领取优惠券已达上限" ) ;
}
}
// 校验卡卷状态
// 校验卡卷状态
if ( rel . getHighDiscount ( ) . getStatus ( ) ! = 2 ) {
if ( rel . getHighDiscount ( ) . getStatus ( ) ! = 2 ) {
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "无法领取,优惠券已过期" ) ;
throw ErrorHelp . genException ( SysCode . System , ErrorCode . COMMON_ERROR , "无法领取,优惠券已过期" ) ;