@ -85,6 +85,7 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
@Override
public JSONObject takeEncourageMoney ( String orderId , String visitorOpenId ) {
logger . info ( "=====takeEncourageMoney+" + orderId ) ;
JSONObject config = currentEncourageConfig ( ) ;
if ( config ! = null ) {
if ( customerEncourageMoneyAccessLogMapper . findByOrderId ( orderId ) ! = null ) {
@ -239,16 +240,22 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
Date toDate = config . getDate ( "to_date" ) ;
status . put ( "to" , DateFormatUtils . format ( toDate , "MM-dd" ) ) ;
JSONObject member = customerMembershipMapper . findByPaymentOpenId ( openid ) ;
JSONObject use = customerEncourageMoneyAccessLogMapper . sumMoney ( member . getString ( "memeber_id" ) , config . getString ( "event_id" ) ) ;
BigDecimal balance = BigDecimal . ZERO ;
if ( use ! = null ) {
balance = use . getBigDecimal ( "use_amount" ) ;
}
member . put ( "used_amount" , balance . setScale ( 2 , BigDecimal . ROUND_DOWN ) . toPlainString ( ) ) ;
if ( member ! = null ) {
status . put ( "member_info" , member ) ;
List < JSONObject > balanceLogs = customerMembershipMapper . listEncourageBalanceHistory ( fromDate , toDate , member . getString ( "member_id" ) ) ;
status . put ( "logs" , balanceLogs ) ;
BigDecimal usedAmount = customerEncourageMoneyUseLogMapper . sumUsed ( member . getString ( "member_id" ) , fromDate , toDate ) ;
member . put ( "used_amount" , usedAmount ) ;
// BigDecimal usedAmount = customerEncourageMoneyUseLogMapper.sumUsed(member.getString("member_id"), fromDate, toDate);
// member.put("used_amount", usedAmount);
} else {
member = new JSONObject ( ) ;
member . put ( "encourage_balance" , 0 ) ;
member . put ( "used_amount" , 0 ) ;
// member.put("used_amount", 0);
}
status . put ( "member" , member ) ;
return status ;