| | |
| | | import com.mzl.flower.dto.response.flower.FlowerMarkupSpDTO; |
| | | import com.mzl.flower.dto.response.flower.FlowerMarkupSpListDTO; |
| | | import com.mzl.flower.entity.flower.FlowerMarkupSp; |
| | | import com.mzl.flower.entity.log.OperationRecord; |
| | | import com.mzl.flower.entity.partner.Partner; |
| | | import com.mzl.flower.mapper.flower.FlowerMarkupSpMapper; |
| | | 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.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.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | |
| | | @Autowired |
| | | private FlowerMarkupSpMapper spMapper; |
| | | |
| | | public void saveMarkupSp(FlowerMarkupSpSaveDTO dto){ |
| | | @Autowired |
| | | private OperationRecordMapper operationRecordMapper; |
| | | |
| | | public void saveMarkupSp(FlowerMarkupSpSaveDTO dto, HttpServletRequest request) throws IOException { |
| | | FlowerMarkupSp sp = spMapper.selectOne(new QueryWrapper<FlowerMarkupSp>() |
| | | .eq("partner_id", dto.getPartnerId()).eq("flower_id", dto.getFlowerId())); |
| | | String content = ""; |
| | | OperationRecord operationRecord = new OperationRecord(); |
| | | if(sp == null){ |
| | | sp = new FlowerMarkupSp(); |
| | | sp.setFlowerId(dto.getFlowerId()); |
| | |
| | | sp.setPartnerId(dto.getPartnerId()); |
| | | sp.create(SecurityUtils.getUserId()); |
| | | spMapper.insert(sp); |
| | | content = "新增合伙人加价:商品id:【" + dto.getFlowerId() + "】,合伙人id:【"+dto.getPartnerId()+"】,金额:【" + dto.getFee() + "】"; |
| | | operationRecord.setFunction("新增合伙人加价"); |
| | | } else { |
| | | sp.setFee(dto.getFee()); |
| | | sp.update(SecurityUtils.getUserId()); |
| | | spMapper.updateById(sp); |
| | | content = "修改合伙人加价:id:【"+sp.getId()+"】,商品id:【" + dto.getFlowerId() + "】,合伙人id:【"+dto.getPartnerId()+"】,金额:【" + dto.getFee() + "】"; |
| | | operationRecord.setFunction("修改合伙人加价"); |
| | | } |
| | | |
| | | markupCacheClient.addMarkupSp(dto.getPartnerId(), dto.getFlowerId(), sp); |
| | | operationRecord.create(SecurityUtils.getUserId()); |
| | | operationRecord.setStatus("success"); |
| | | operationRecord.setModule("markup_s_p"); |
| | | |
| | | operationRecord.setContent(content); |
| | | operationRecord.setIpAddress(IpUtil.getIpAddress(request)); |
| | | operationRecordMapper.insert(operationRecord); |
| | | } |
| | | |
| | | public void saveMarkupSpBatch(FlowerMarkupSpSaveBatchDTO dto,HttpServletRequest request) throws IOException { |
| | | List<Long> flowerIds = dto.getFlowerIds(); |
| | | if(flowerIds != null && flowerIds.size() > 0){ |
| | | for(Long flowerId : flowerIds){ |
| | | FlowerMarkupSpSaveDTO dt = new FlowerMarkupSpSaveDTO(); |
| | | dt.setFlowerId(flowerId); |
| | | dt.setPartnerId(dto.getPartnerId()); |
| | | dt.setFee(dto.getFee()); |
| | | |
| | | saveMarkupSp(dt,request); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public FlowerMarkupSpDTO getMarkupSp(Long flowerId){ |
| | |
| | | return dto; |
| | | } |
| | | |
| | | public Page<FlowerMarkupSpListDTO> selectMarkupSpFlowerList(Page page, FlowerMarkupSpQueryDTO dto){ |
| | | List<FlowerMarkupSpListDTO> ll = spMapper.selectMarkupSpFlowerList(page, dto.getPartnerId(), dto); |
| | | if(ll != null && ll.size() > 0){ |
| | | for(FlowerMarkupSpListDTO ss : ll){ |
| | | ss.setPrice(getFinalPriceForPartner(dto.getPartnerId(), ss.getCategory(), ss.getFlowerId(), ss.getPrice(), ss.getLevel())); |
| | | BigDecimal fee = ss.getFee(); |
| | | if (fee == null) { |
| | | fee = BigDecimal.ZERO; |
| | | } |
| | | ss.setSellPrice(ss.getPrice().add(fee)); |
| | | } |
| | | } |
| | | |
| | | page.setRecords(ll); |
| | | return page; |
| | | } |
| | | |
| | | public Page<FlowerMarkupSpListDTO> selectMarkupSpList(Page page, FlowerMarkupSpQueryDTO dto){ |
| | | |
| | | List<FlowerMarkupSpListDTO> ll = spMapper.selectMarkupSpList(page, dto.getPartnerId(), dto); |
| | | if(ll != null && ll.size() > 0){ |
| | | for(FlowerMarkupSpListDTO ss : ll){ |
| | | ss.setPrice(getFinalPriceForPartner(dto.getPartnerId(), ss.getCategory(), ss.getFlowerId(), ss.getPrice(), ss.getLevel())); |
| | | BigDecimal fee = ss.getFee(); |
| | | if (fee == null) { |
| | | fee = BigDecimal.ZERO; |
| | | } |
| | | ss.setSellPrice(ss.getPrice().add(fee)); |
| | | } |
| | | } |
| | | |