| | |
| | | point.setTotalPoint(0); |
| | | point.setUsedPoint(0); |
| | | point.setExpiredPoint(0); |
| | | point.setDeductionPoint(0); |
| | | point.create(SecurityUtils.getUserId()); |
| | | } |
| | | |
| | | if(POINT_CHANGE_TYPE.add.name().equals(detail.getChangeType())){ |
| | | point.setTotalPoint(point.getTotalPoint() + detail.getPoint()); |
| | | point.setUsedPoint(point.getUsedPoint() + detail.getUsePoint()); |
| | | point.setExpiredPoint(point.getExpiredPoint() + detail.getExpiredPoint()); |
| | | }else if(POINT_CHANGE_TYPE.reduce.name().equals(detail.getChangeType())){ |
| | | // if(point.getTotalPoint()!= null && point.getTotalPoint()!=0 && point.getTotalPoint()>= detail.getPoint()){ |
| | | // point.setTotalPoint(point.getTotalPoint() - detail.getPoint()); |
| | | // }else{ |
| | | // //积分不足,直接清0 |
| | | // point.setTotalPoint(0); |
| | | // } |
| | | point.setTotalPoint(point.getTotalPoint() - detail.getPoint()); |
| | | Integer detailPoint = detail.getPoint(); |
| | | if(POINT_TYPE.deduction.name().equals(detail.getType())){ //积分扣减 |
| | | Integer balancePoint = point.getTotalPoint() - point.getUsedPoint()-point.getExpiredPoint()-point.getDeductionPoint();//可用积分 |
| | | balancePoint = balancePoint.intValue()>0?balancePoint.intValue():0; |
| | | if(balancePoint.intValue() >= detail.getPoint().intValue()){ |
| | | point.setDeductionPoint(point.getDeductionPoint() + detail.getPoint()); |
| | | }else{ |
| | | //积分不足,直接清0 |
| | | point.setDeductionPoint(point.getDeductionPoint() + balancePoint); |
| | | detail.setPoint(balancePoint); |
| | | detail.setRemarks(detail.getRemarks()+",当前积分不足"+detailPoint+",实际扣除积分"+balancePoint); |
| | | } |
| | | } |
| | | } |
| | | if(isAdd){ |
| | | customerPointMapper.insert(point); |
| | |
| | | detail.setChangeType(POINT_CHANGE_TYPE.reduce.name()); |
| | | detail.setType(POINT_TYPE.deduction.name()); |
| | | detail.create(SecurityUtils.getUserId()); |
| | | customerPointDetailMapper.insert(detail); |
| | | |
| | | //更新汇总表 |
| | | updateCustomerPoint(detail); |
| | | |
| | | customerPointDetailMapper.insert(detail); |
| | | } |
| | | |
| | | public void consumptionPoint(BigDecimal orderAmount, String orderNo,String userId) { |