| | |
| | | import com.mzl.flower.mapper.point.CustomerPointDetailMapper; |
| | | import com.mzl.flower.mapper.point.CustomerPointMapper; |
| | | import com.mzl.flower.service.BaseService; |
| | | import com.mzl.flower.service.payment.RedisLockService; |
| | | import com.mzl.flower.utils.DateUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | |
| | | private final CustomerPointDetailMapper customerPointDetailMapper; |
| | | |
| | | private final RedisLockService redisLockService; |
| | | |
| | | public CustomerPointService(CustomerPointMapper customerPointMapper, CustomerPointDetailMapper customerPointDetailMapper) { |
| | | |
| | | public CustomerPointService(CustomerPointMapper customerPointMapper, CustomerPointDetailMapper customerPointDetailMapper, RedisLockService redisLockService) { |
| | | this.customerPointMapper = customerPointMapper; |
| | | this.customerPointDetailMapper = customerPointDetailMapper; |
| | | this.redisLockService = redisLockService; |
| | | } |
| | | |
| | | public Page<CustomerPointDTO> queryPage(QueryCustomerPointDTO dto, Page page) { |
| | |
| | | } |
| | | |
| | | public void updateCustomerPoint(CustomerPointDetail detail) { |
| | | boolean lock = redisLockService.getObjectLock("LOCK_KEY_CUSTOMER_POINT_", detail.getUserId()); |
| | | if(!lock){ |
| | | return; |
| | | } |
| | | try { |
| | | CustomerPoint point = customerPointMapper.selectOne(new LambdaQueryWrapper<CustomerPoint>() |
| | | .eq(CustomerPoint::getCustomerId, detail.getCustomerId())); |
| | | boolean isAdd = false; |
| | |
| | | }else{ |
| | | customerPointMapper.updateById(point); |
| | | } |
| | | |
| | | }finally { |
| | | redisLockService.releaseObjectLock("LOCK_KEY_CUSTOMER_POINT_", detail.getUserId()); |
| | | } |
| | | } |
| | | |
| | | public void deductionPoint(ChangePointDTO dto) { |