|
@@ -0,0 +1,81 @@
|
|
|
|
+package com.chelvc.cloud.vehicle.server.service.impl;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.ProfitRatioConfigDTO;
|
|
|
|
+import com.chelvc.cloud.vehicle.api.param.AddProfitRatioConfigParams;
|
|
|
|
+import com.chelvc.cloud.vehicle.api.param.EditProfitRatioConfigParams;
|
|
|
|
+import com.chelvc.cloud.vehicle.api.param.QueryProfitRatioConfigParam;
|
|
|
|
+import com.chelvc.cloud.vehicle.api.service.ProfitRatioConfigService;
|
|
|
|
+import com.chelvc.cloud.vehicle.server.dao.ProfitRatioConfigMapper;
|
|
|
|
+import com.chelvc.cloud.vehicle.server.entity.ProfitRatioConfig;
|
|
|
|
+import com.chelvc.framework.base.exception.ResourceUnavailableException;
|
|
|
|
+import com.chelvc.framework.common.model.Pagination;
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
+import org.apache.dubbo.config.annotation.DubboService;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+
|
|
|
|
+import java.util.Date;
|
|
|
|
+
|
|
|
|
+@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
|
|
|
+@DubboService(interfaceClass = com.chelvc.cloud.vehicle.api.service.ProfitRatioConfigService.class)
|
|
|
|
+public class ProfitRatioConfigServiceImpl extends ServiceImpl<ProfitRatioConfigMapper, ProfitRatioConfig> implements ProfitRatioConfigService {
|
|
|
|
+
|
|
|
|
+ private final ProfitRatioConfigMapper baseMapper;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void add(AddProfitRatioConfigParams params) {
|
|
|
|
+ ProfitRatioConfig config = new ProfitRatioConfig();
|
|
|
|
+ config.setRatio(params.getRatio());
|
|
|
|
+ config.setType(params.getType());
|
|
|
|
+ config.setNum(params.getNum());
|
|
|
|
+ config.setStatus(0);
|
|
|
|
+ config.setCreator(params.getUserId());
|
|
|
|
+ config.setCreateTime(new Date());
|
|
|
|
+ config.setUpdateTime(new Date());
|
|
|
|
+ config.setUpdater(params.getUserId());
|
|
|
|
+ baseMapper.insert(config);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void edit(EditProfitRatioConfigParams params) {
|
|
|
|
+ ProfitRatioConfig profitRatioConfig = baseMapper.selectById(params.getId());
|
|
|
|
+ if(profitRatioConfig == null){
|
|
|
|
+ throw new ResourceUnavailableException("参数错误");
|
|
|
|
+ }
|
|
|
|
+ profitRatioConfig.setRatio(params.getRatio());
|
|
|
|
+ profitRatioConfig.setNum(params.getNum());
|
|
|
|
+ profitRatioConfig.setStatus(params.getStatus());
|
|
|
|
+ profitRatioConfig.setUpdateTime(new Date());
|
|
|
|
+ profitRatioConfig.setUpdater(params.getUserId());
|
|
|
|
+ baseMapper.update(profitRatioConfig, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void delete(Long id) {
|
|
|
|
+ ProfitRatioConfig profitRatioConfig = baseMapper.selectById(id);
|
|
|
|
+ if(profitRatioConfig == null){
|
|
|
|
+ throw new ResourceUnavailableException("参数错误");
|
|
|
|
+ }
|
|
|
|
+ Integer status = profitRatioConfig.getStatus();
|
|
|
|
+ if(status == 0){
|
|
|
|
+ throw new ResourceUnavailableException("请先停用该配置");
|
|
|
|
+ }
|
|
|
|
+ baseMapper.deleteById(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Pagination<ProfitRatioConfigDTO> queryPageList(QueryProfitRatioConfigParam param, Integer pageNum, Integer pageSize) {
|
|
|
|
+ Page<ProfitRatioConfigDTO> page = new Page<>(pageNum, pageSize);
|
|
|
|
+ QueryWrapper<ProfitRatioConfig> wrapper = Wrappers.query();
|
|
|
|
+ wrapper.eq(param.getType() != null, "type", param.getType());
|
|
|
|
+ wrapper.eq(param.getStatus() != null, "status", param.getStatus());
|
|
|
|
+ wrapper.orderByAsc("ratio");
|
|
|
|
+ IPage<ProfitRatioConfigDTO> result = baseMapper.queryPageList(page, wrapper);
|
|
|
|
+ return Pagination.<ProfitRatioConfigDTO>builder().total(result.getTotal()).pages(result.getPages())
|
|
|
|
+ .records(result.getRecords()).build();
|
|
|
|
+ }
|
|
|
|
+}
|