@ -224,60 +224,134 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService {
editOrder ( tradeOrder ) ;
// 商户活动金活动
BsRebateActivity rebateActivity = rebateActivityService . getMerCurrentActivity ( mer . getMerNo ( ) ) ;
if ( rebateActivity ! = null & & rebateActivity . getEndTime ( ) . compareTo ( new Date ( ) ) > = 0 ) {
if ( rebateActivity . getActivityType ( ) . equals ( RebateActivityTypeEnum . type1 . getNumber ( ) ) ) {
if ( rebateActivity . getPreferentialType ( ) . equals ( RebateActivityPreferentialTypeEnum . type1 . getNumber ( ) ) ) {
// 达到满减门槛
if ( tradeOrder . getTradeAmount ( ) . compareTo ( rebateActivity . getCondition ( ) ) > = 0 ) {
tradeOrder . setRebateActivityPart ( true ) ;
tradeOrder . setRebateActivityId ( rebateActivity . getId ( ) ) ;
tradeOrder . setRebateActivityNo ( rebateActivity . getActivityNo ( ) ) ;
tradeOrder . setRebateActivityType ( rebateActivity . getActivityType ( ) ) ;
tradeOrder . setRebateActivityPreferentialType ( rebateActivity . getPreferentialType ( ) ) ;
tradeOrder . setRebateActivityPrice ( rebateActivity . getPrice ( ) ) ;
tradeOrder . setRebateActivityActualPrice ( rebateActivity . getPrice ( ) ) ;
tradeOrder . setTradeActualAmount ( tradeOrder . getTradeActualAmount ( ) . subtract ( tradeOrder . getRebateActivityActualPrice ( ) ) ) ;
if ( StringUtils . isNotBlank ( userPhone ) ) {
// 查询商户的活动金 优惠活动
BsRebateActivity rebateActivity = rebateActivityService . getMerCurrentActivity ( mer . getMerNo ( ) ) ;
if ( rebateActivity ! = null & & rebateActivity . getEndTime ( ) . compareTo ( new Date ( ) ) > = 0 ) {
// 优惠活动限制
if ( rebateActivity . getRestrictPartakeType ( ) . equals ( RebateActivityPartakeTypeEnum . type1 . getNumber ( ) ) ) {
// 查询用户交易次数
Calendar timeS = Calendar . getInstance ( ) ;
timeS . setTime ( new Date ( ) ) ;
timeS . set ( Calendar . HOUR_OF_DAY , 00 ) ;
timeS . set ( Calendar . MINUTE , 00 ) ;
timeS . set ( Calendar . SECOND , 00 ) ;
Calendar timeE = Calendar . getInstance ( ) ;
timeE . setTime ( new Date ( ) ) ;
timeE . set ( Calendar . HOUR_OF_DAY , 23 ) ;
timeE . set ( Calendar . MINUTE , 59 ) ;
timeE . set ( Calendar . SECOND , 59 ) ;
Integer userTrade = tradeOrderMapper . countUserTrade (
userPhone ,
DateUtil . format ( timeS . getTime ( ) , "yyyy-MM-dd HH:mm:ss" ) ,
DateUtil . format ( timeE . getTime ( ) , "yyyy-MM-dd HH:mm:ss" ) ) ;
if ( userTrade < rebateActivity . getRestrictPartakeNum ( ) ) {
if ( rebateActivity . getActivityType ( ) . equals ( RebateActivityTypeEnum . type1 . getNumber ( ) ) ) {
if ( rebateActivity . getPreferentialType ( ) . equals ( RebateActivityPreferentialTypeEnum . type1 . getNumber ( ) ) ) {
// 达到满减门槛
if ( tradeOrder . getTradeAmount ( ) . compareTo ( rebateActivity . getCondition ( ) ) > = 0 ) {
tradeOrder . setRebateActivityPart ( true ) ;
tradeOrder . setRebateActivityId ( rebateActivity . getId ( ) ) ;
tradeOrder . setRebateActivityNo ( rebateActivity . getActivityNo ( ) ) ;
tradeOrder . setRebateActivityType ( rebateActivity . getActivityType ( ) ) ;
tradeOrder . setRebateActivityPreferentialType ( rebateActivity . getPreferentialType ( ) ) ;
tradeOrder . setRebateActivityPrice ( rebateActivity . getPrice ( ) ) ;
tradeOrder . setRebateActivityActualPrice ( rebateActivity . getPrice ( ) ) ;
tradeOrder . setTradeActualAmount ( tradeOrder . getTradeActualAmount ( ) . subtract ( tradeOrder . getRebateActivityActualPrice ( ) ) ) ;
}
} else if ( rebateActivity . getPreferentialType ( ) . equals ( RebateActivityPreferentialTypeEnum . type2 . getNumber ( ) ) ) {
tradeOrder . setRebateActivityPart ( true ) ;
tradeOrder . setRebateActivityId ( rebateActivity . getId ( ) ) ;
tradeOrder . setRebateActivityNo ( rebateActivity . getActivityNo ( ) ) ;
tradeOrder . setRebateActivityType ( rebateActivity . getActivityType ( ) ) ;
tradeOrder . setRebateActivityPreferentialType ( rebateActivity . getPreferentialType ( ) ) ;
tradeOrder . setRebateActivityPrice ( rebateActivity . getPrice ( ) ) ;
tradeOrder . setRebateActivityActualPrice ( rebateActivity . getPrice ( ) ) ;
tradeOrder . setTradeActualAmount ( tradeOrder . getTradeActualAmount ( ) . subtract ( tradeOrder . getRebateActivityActualPrice ( ) ) ) ;
} else if ( rebateActivity . getPreferentialType ( ) . equals ( RebateActivityPreferentialTypeEnum . type3 . getNumber ( ) ) ) {
tradeOrder . setRebateActivityPart ( true ) ;
tradeOrder . setRebateActivityId ( rebateActivity . getId ( ) ) ;
tradeOrder . setRebateActivityNo ( rebateActivity . getActivityNo ( ) ) ;
tradeOrder . setRebateActivityType ( rebateActivity . getActivityType ( ) ) ;
tradeOrder . setRebateActivityPreferentialType ( rebateActivity . getPreferentialType ( ) ) ;
tradeOrder . setRebateActivityPrice ( rebateActivity . getPrice ( ) ) ;
// 优惠折扣
BigDecimal priceRate = tradeOrder . getRebateActivityPrice ( ) . divide ( new BigDecimal ( "10" ) ) . setScale ( 2 , BigDecimal . ROUND_DOWN ) ;
tradeOrder . setRebateActivityActualPrice ( tradeOrder . getTradeActualAmount ( ) . subtract ( tradeOrder . getTradeActualAmount ( ) . multiply ( priceRate ) . setScale ( 2 , BigDecimal . ROUND_HALF_UP ) ) ) ;
tradeOrder . setTradeActualAmount ( tradeOrder . getTradeActualAmount ( ) . subtract ( tradeOrder . getRebateActivityActualPrice ( ) ) ) ;
}
}
}
} else {
if ( rebateActivity . getActivityType ( ) . equals ( RebateActivityTypeEnum . type1 . getNumber ( ) ) ) {
if ( rebateActivity . getPreferentialType ( ) . equals ( RebateActivityPreferentialTypeEnum . type1 . getNumber ( ) ) ) {
// 达到满减门槛
if ( tradeOrder . getTradeAmount ( ) . compareTo ( rebateActivity . getCondition ( ) ) > = 0 ) {
tradeOrder . setRebateActivityPart ( true ) ;
tradeOrder . setRebateActivityId ( rebateActivity . getId ( ) ) ;
tradeOrder . setRebateActivityNo ( rebateActivity . getActivityNo ( ) ) ;
tradeOrder . setRebateActivityType ( rebateActivity . getActivityType ( ) ) ;
tradeOrder . setRebateActivityPreferentialType ( rebateActivity . getPreferentialType ( ) ) ;
tradeOrder . setRebateActivityPrice ( rebateActivity . getPrice ( ) ) ;
tradeOrder . setRebateActivityActualPrice ( rebateActivity . getPrice ( ) ) ;
tradeOrder . setTradeActualAmount ( tradeOrder . getTradeActualAmount ( ) . subtract ( tradeOrder . getRebateActivityActualPrice ( ) ) ) ;
}
} else if ( rebateActivity . getPreferentialType ( ) . equals ( RebateActivityPreferentialTypeEnum . type2 . getNumber ( ) ) ) {
tradeOrder . setRebateActivityPart ( true ) ;
tradeOrder . setRebateActivityId ( rebateActivity . getId ( ) ) ;
tradeOrder . setRebateActivityNo ( rebateActivity . getActivityNo ( ) ) ;
tradeOrder . setRebateActivityType ( rebateActivity . getActivityType ( ) ) ;
tradeOrder . setRebateActivityPreferentialType ( rebateActivity . getPreferentialType ( ) ) ;
tradeOrder . setRebateActivityPrice ( rebateActivity . getPrice ( ) ) ;
tradeOrder . setRebateActivityActualPrice ( rebateActivity . getPrice ( ) ) ;
tradeOrder . setTradeActualAmount ( tradeOrder . getTradeActualAmount ( ) . subtract ( tradeOrder . getRebateActivityActualPrice ( ) ) ) ;
} else if ( rebateActivity . getPreferentialType ( ) . equals ( RebateActivityPreferentialTypeEnum . type3 . getNumber ( ) ) ) {
tradeOrder . setRebateActivityPart ( true ) ;
tradeOrder . setRebateActivityId ( rebateActivity . getId ( ) ) ;
tradeOrder . setRebateActivityNo ( rebateActivity . getActivityNo ( ) ) ;
tradeOrder . setRebateActivityType ( rebateActivity . getActivityType ( ) ) ;
tradeOrder . setRebateActivityPreferentialType ( rebateActivity . getPreferentialType ( ) ) ;
tradeOrder . setRebateActivityPrice ( rebateActivity . getPrice ( ) ) ;
// 优惠折扣
BigDecimal priceRate = tradeOrder . getRebateActivityPrice ( ) . divide ( new BigDecimal ( "10" ) ) . setScale ( 2 , BigDecimal . ROUND_DOWN ) ;
tradeOrder . setRebateActivityActualPrice ( tradeOrder . getTradeActualAmount ( ) . subtract ( tradeOrder . getTradeActualAmount ( ) . multiply ( priceRate ) . setScale ( 2 , BigDecimal . ROUND_HALF_UP ) ) ) ;
tradeOrder . setTradeActualAmount ( tradeOrder . getTradeActualAmount ( ) . subtract ( tradeOrder . getRebateActivityActualPrice ( ) ) ) ;
}
}
}
if ( tradeOrder . getRebateActivityPart ( ) . equals ( true ) ) {
RebateActivityAccountTradeObject accountTradeObject = new RebateActivityAccountTradeObject ( ) ;
accountTradeObject . setTradeObjectType ( RebateActivityAccountObjectTypeEnum . type3 ) ;
accountTradeObject . setTradeObjectId ( tradeOrder . getId ( ) ) ;
accountTradeObject . setTradeObjectContent ( "创建交易" + tradeOrder . getOutTradeNo ( ) ) ;
Boolean activityAccount = rebateActivityAccountService . accountTrade (
tradeOrder . getRebateActivityNo ( ) ,
RebateActivityAccountTradeTypeEnum . type2 ,
tradeOrder . getRebateActivityActualPrice ( ) ,
accountTradeObject ) ;
if ( activityAccount . equals ( true ) ) {
editOrder ( tradeOrder ) ;
} else {
tradeOrder . setRebateActivityPart ( false ) ;
tradeOrder . setRebateActivityId ( null ) ;
tradeOrder . setRebateActivityNo ( null ) ;
tradeOrder . setRebateActivityType ( null ) ;
tradeOrder . setRebateActivityPreferentialType ( null ) ;
tradeOrder . setRebateActivityPrice ( null ) ;
tradeOrder . setRebateActivityActualPrice ( null ) ;
tradeOrder . setTradeActualAmount ( null ) ;
}
} else if ( rebateActivity . getPreferentialType ( ) . equals ( RebateActivityPreferentialTypeEnum . type2 . getNumber ( ) ) ) {
tradeOrder . setRebateActivityPart ( true ) ;
tradeOrder . setRebateActivityId ( rebateActivity . getId ( ) ) ;
tradeOrder . setRebateActivityNo ( rebateActivity . getActivityNo ( ) ) ;
tradeOrder . setRebateActivityType ( rebateActivity . getActivityType ( ) ) ;
tradeOrder . setRebateActivityPreferentialType ( rebateActivity . getPreferentialType ( ) ) ;
tradeOrder . setRebateActivityPrice ( rebateActivity . getPrice ( ) ) ;
tradeOrder . setRebateActivityActualPrice ( rebateActivity . getPrice ( ) ) ;
tradeOrder . setTradeActualAmount ( tradeOrder . getTradeActualAmount ( ) . subtract ( tradeOrder . getRebateActivityActualPrice ( ) ) ) ;
} else if ( rebateActivity . getPreferentialType ( ) . equals ( RebateActivityPreferentialTypeEnum . type3 . getNumber ( ) ) ) {
tradeOrder . setRebateActivityPart ( true ) ;
tradeOrder . setRebateActivityId ( rebateActivity . getId ( ) ) ;
tradeOrder . setRebateActivityNo ( rebateActivity . getActivityNo ( ) ) ;
tradeOrder . setRebateActivityType ( rebateActivity . getActivityType ( ) ) ;
tradeOrder . setRebateActivityPreferentialType ( rebateActivity . getPreferentialType ( ) ) ;
tradeOrder . setRebateActivityPrice ( rebateActivity . getPrice ( ) ) ;
// 优惠折扣
BigDecimal priceRate = tradeOrder . getRebateActivityPrice ( ) . divide ( new BigDecimal ( "10" ) ) . setScale ( 2 , BigDecimal . ROUND_DOWN ) ;
tradeOrder . setRebateActivityActualPrice ( tradeOrder . getTradeActualAmount ( ) . subtract ( tradeOrder . getTradeActualAmount ( ) . multiply ( priceRate ) . setScale ( 2 , BigDecimal . ROUND_HALF_UP ) ) ) ;
tradeOrder . setTradeActualAmount ( tradeOrder . getTradeActualAmount ( ) . subtract ( tradeOrder . getRebateActivityActualPrice ( ) ) ) ;
}
editOrder ( tradeOrder ) ;
}
if ( tradeOrder . getRebateActivityPart ( ) . equals ( true ) ) {
RebateActivityAccountTradeObject accountTradeObject = new RebateActivityAccountTradeObject ( ) ;
accountTradeObject . setTradeObjectType ( RebateActivityAccountObjectTypeEnum . type3 ) ;
accountTradeObject . setTradeObjectId ( tradeOrder . getId ( ) ) ;
accountTradeObject . setTradeObjectContent ( "创建交易" + tradeOrder . getOutTradeNo ( ) ) ;
rebateActivityAccountService . accountTrade (
tradeOrder . getRebateActivityNo ( ) ,
RebateActivityAccountTradeTypeEnum . type2 ,
tradeOrder . getRebateActivityActualPrice ( ) ,
accountTradeObject
) ;
}
}
Map < String , Object > returnParam = new HashMap < > ( ) ;