| | |
| | | import com.mzl.flower.dto.response.flower.FlowerMarkupSpCgDTO; |
| | | import com.mzl.flower.dto.response.flower.FlowerMarkupSpCgListDTO; |
| | | import com.mzl.flower.entity.flower.FlowerMarkupSpCg; |
| | | import com.mzl.flower.entity.log.OperationRecord; |
| | | import com.mzl.flower.entity.partner.Partner; |
| | | import com.mzl.flower.mapper.flower.FlowerMarkupSpCgMapper; |
| | | import com.mzl.flower.mapper.log.OperationRecordMapper; |
| | | import com.mzl.flower.service.BaseService; |
| | | import com.mzl.flower.utils.IpUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | |
| | | @Autowired |
| | | private FlowerMarkupSpCgMapper spCgMapper; |
| | | |
| | | public void saveMarkupSpCg(FlowerMarkupSpCgSaveDTO dto){ |
| | | @Autowired |
| | | private OperationRecordMapper operationRecordMapper; |
| | | |
| | | public void saveMarkupSpCg(FlowerMarkupSpCgSaveDTO dto, HttpServletRequest request) throws IOException { |
| | | |
| | | Long cId = dto.getCategoryId(); |
| | | FlowerMarkupSpCg cg = spCgMapper.selectOne(new QueryWrapper<FlowerMarkupSpCg>() |
| | | .eq("partner_id", dto.getPartnerId()).eq("category_id", cId)); |
| | | String content = ""; |
| | | OperationRecord operationRecord = new OperationRecord(); |
| | | if(cg == null){ |
| | | cg = new FlowerMarkupSpCg(); |
| | | BeanUtils.copyProperties(dto, cg); |
| | | cg.setPartnerId(dto.getPartnerId()); |
| | | cg.create(SecurityUtils.getUserId()); |
| | | spCgMapper.insert(cg); |
| | | content = "新增合伙人商品分类加价:商品分类Id:【" + cg.getCategoryId() + "】,A级:【"+cg.getLevelA()+"】,B级:【" + cg.getLevelB() + "】,C级:【" + cg.getLevelC() + "】" + |
| | | ",D级:【"+dto.getLevelD()+"】,E级:【" + cg.getLevelE() + "】,O级:【" + cg.getLevelO() + "】"; |
| | | operationRecord.setFunction("新增合伙人商品分类加价"); |
| | | } else { |
| | | BeanUtils.copyProperties(dto, cg); |
| | | cg.update(SecurityUtils.getUserId()); |
| | | spCgMapper.updateById(cg); |
| | | content = "修改合伙人商品分类加价:id:【"+cg.getId()+"】,商品分类Id:【" + cg.getCategoryId() + "】,A级:【"+cg.getLevelA()+"】,B级:【" + cg.getLevelB() + "】,C级:【" + cg.getLevelC() + "】" + |
| | | ",D级:【"+dto.getLevelD()+"】,E级:【" + cg.getLevelE() + "】,O级:【" + cg.getLevelO() + "】"; |
| | | operationRecord.setFunction("修改合伙人商品分类加价"); |
| | | } |
| | | |
| | | markupCacheClient.addMarkupSpCg(dto.getPartnerId(), cId, cg); |
| | | operationRecord.setContent(content); |
| | | operationRecord.create(SecurityUtils.getUserId()); |
| | | operationRecord.setStatus("success"); |
| | | operationRecord.setModule("markup_s_p_cg"); |
| | | operationRecord.setIpAddress(IpUtil.getIpAddress(request)); |
| | | operationRecordMapper.insert(operationRecord); |
| | | } |
| | | |
| | | public void saveMarkupSpCgBatch(FlowerMarkupSpCgBatchSaveDTO dto) { |
| | | public void saveMarkupSpCgBatch(FlowerMarkupSpCgBatchSaveDTO dto,HttpServletRequest request) throws IOException { |
| | | List<Long> categoryIds = dto.getCategoryId(); |
| | | if (categoryIds == null || categoryIds.size() == 0) { |
| | | throw new ValidationException("分类列表不能为空"); |
| | |
| | | FlowerMarkupSpCgSaveDTO cg = new FlowerMarkupSpCgSaveDTO(); |
| | | BeanUtils.copyProperties(dto, cg); |
| | | cg.setCategoryId(categoryId); |
| | | saveMarkupSpCg(cg); |
| | | saveMarkupSpCg(cg,request); |
| | | } |
| | | } |
| | | public FlowerMarkupSpCgDTO getMarkupSpCg(Long categoryId){ |