@ -224,60 +224,134 @@ public class BsTradeOrderServiceImpl implements BsTradeOrderService {
editOrder ( tradeOrder ) ;
editOrder ( tradeOrder ) ;
// 商户活动金活动
if ( StringUtils . isNotBlank ( userPhone ) ) {
BsRebateActivity rebateActivity = rebateActivityService . getMerCurrentActivity ( mer . getMerNo ( ) ) ;
// 查询商户的活动金 优惠活动
if ( rebateActivity ! = null & & rebateActivity . getEndTime ( ) . compareTo ( new Date ( ) ) > = 0 ) {
BsRebateActivity rebateActivity = rebateActivityService . getMerCurrentActivity ( mer . getMerNo ( ) ) ;
if ( rebateActivity . getActivityType ( ) . equals ( RebateActivityTypeEnum . type1 . getNumber ( ) ) ) {
if ( rebateActivity ! = null & & rebateActivity . getEndTime ( ) . compareTo ( new Date ( ) ) > = 0 ) {
if ( rebateActivity . getPreferentialType ( ) . equals ( RebateActivityPreferentialTypeEnum . type1 . getNumber ( ) ) ) {
// 优惠活动限制
// 达到满减门槛
if ( rebateActivity . getRestrictPartakeType ( ) . equals ( RebateActivityPartakeTypeEnum . type1 . getNumber ( ) ) ) {
if ( tradeOrder . getTradeAmount ( ) . compareTo ( rebateActivity . getCondition ( ) ) > = 0 ) {
// 查询用户交易次数
tradeOrder . setRebateActivityPart ( true ) ;
Calendar timeS = Calendar . getInstance ( ) ;
tradeOrder . setRebateActivityId ( rebateActivity . getId ( ) ) ;
timeS . setTime ( new Date ( ) ) ;
tradeOrder . setRebateActivityNo ( rebateActivity . getActivityNo ( ) ) ;
timeS . set ( Calendar . HOUR_OF_DAY , 00 ) ;
tradeOrder . setRebateActivityType ( rebateActivity . getActivityType ( ) ) ;
timeS . set ( Calendar . MINUTE , 00 ) ;
tradeOrder . setRebateActivityPreferentialType ( rebateActivity . getPreferentialType ( ) ) ;
timeS . set ( Calendar . SECOND , 00 ) ;
tradeOrder . setRebateActivityPrice ( rebateActivity . getPrice ( ) ) ;
tradeOrder . setRebateActivityActualPrice ( rebateActivity . getPrice ( ) ) ;
Calendar timeE = Calendar . getInstance ( ) ;
tradeOrder . setTradeActualAmount ( tradeOrder . getTradeActualAmount ( ) . subtract ( tradeOrder . getRebateActivityActualPrice ( ) ) ) ;
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 < > ( ) ;
Map < String , Object > returnParam = new HashMap < > ( ) ;