陶杰
2024-09-02 1c8b2509fe7d990fd0b9f9ed6b338c6203d54758
src/main/java/com/mzl/flower/service/point/PointGoodsService.java
@@ -24,6 +24,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.util.List;
@Service
@@ -70,8 +71,14 @@
        return p.getId();
    }
    public void deletePointGoods(Long id){
        pointGoodsMapper.deleteById(id);
    public void deletePointGoods(String idStr){
        List<String> ids = splitParam(idStr);
        if (ids != null && ids.size() > 0) {
            for(String idd : ids) {
                Long id = Long.parseLong(idd);
                pointGoodsMapper.deleteById(id);
            }
        }
    }
    public Page<PointGoodsListDTO> selectGoodsList(Page page, PointGoodsQueryDTO dto){
@@ -93,15 +100,21 @@
        return dto;
    }
    public void updateStatus(Long id, String status){
        PointGoods p = pointGoodsMapper.selectById(id);
        if(p == null){
            throw new ValidationException("商品未找到");
        }
    public void updateStatus(String idStr, String status){
        List<String> ids = splitParam(idStr);
        if(ids != null && ids.size() > 0) {
            for(String idd : ids) {
                Long id = Long.parseLong(idd);
                PointGoods p = pointGoodsMapper.selectById(id);
                if (p == null) {
                    continue;
                }
        p.setStatus(status);
        p.update(SecurityUtils.getUserId());
        pointGoodsMapper.updateById(p);
                p.setStatus(status);
                p.update(SecurityUtils.getUserId());
                pointGoodsMapper.updateById(p);
            }
        }
    }
    public synchronized void exchangeGoods(ExchangeGoodsDTO dto) {
@@ -147,6 +160,8 @@
        detail.setPoint(record.getTotalPoint());
        detail.setChangeType(Constants.POINT_CHANGE_TYPE.reduce.name());
        detail.setType(Constants.POINT_TYPE.exchange.name());
        detail.setRecordDate(LocalDate.now());
        detail.setRemarks(record.getName());
        detail.create(SecurityUtils.getUserId());
        customerPointDetailMapper.insert(detail);