|
|
@ -26,13 +26,16 @@ |
|
|
|
package com.yxt.anrui.scm.biz.scmcollectionrebate; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.date.DateTime; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.anrui.base.api.basemanufacturerbank.BaseManufacturerBankFeign; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebate.*; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebatedistribution.ScmCollectionRebateDistributionDetailsVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebateveh.ScmCollectionRebateVehDetailsVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebateveh.ScmCollectionRebateVehDto; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebate.ScmVehRebate; |
|
|
|
import com.yxt.anrui.scm.api.scmvehrebate.ScmVehRebateDetailsVo; |
|
|
|
import com.yxt.anrui.scm.biz.scmcollectionrebatedistribution.ScmCollectionRebateDistributionService; |
|
|
|
import com.yxt.anrui.scm.biz.scmcollectionrebateveh.ScmCollectionRebateVehService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
@ -40,12 +43,6 @@ import com.yxt.common.base.utils.PagerUtil; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebate.ScmCollectionRebate; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebate.ScmCollectionRebateQuery; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebate.ScmCollectionRebateVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebate.ScmCollectionRebateDetailsVo; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebate.ScmCollectionRebateDto; |
|
|
|
import com.yxt.anrui.scm.api.scmcollectionrebate.ScmCollectionRebateFeign; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -69,203 +66,249 @@ import java.util.List; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class ScmCollectionRebateService extends MybatisBaseService<ScmCollectionRebateMapper, ScmCollectionRebate> { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ScmCollectionRebateVehService scmCollectionRebateVehService; |
|
|
|
|
|
|
|
private QueryWrapper<ScmCollectionRebate> createQueryWrapper(ScmCollectionRebateQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
QueryWrapper<ScmCollectionRebate> qw = new QueryWrapper<>(); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<ScmCollectionRebateVo> listPageVo(PagerQuery<ScmCollectionRebateQuery> pq) { |
|
|
|
ScmCollectionRebateQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ScmCollectionRebate> qw = new QueryWrapper<>(); |
|
|
|
qw.eq("createOrgSid",query.getCreateOrgSid()); |
|
|
|
if (StringUtils.isNotBlank(query.getCollectionTypeKey())){ |
|
|
|
qw.eq("collectionTypeKey",query.getCollectionTypeKey()); |
|
|
|
} |
|
|
|
String collectionStartDate = query.getCollectionStartDate(); |
|
|
|
String collectionEndDate = query.getCollectionEndDate(); |
|
|
|
qw.apply(StringUtils.isNotBlank(collectionStartDate), "date_format (collectionDate,'%Y-%m-%d') >= date_format('" + collectionStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(collectionEndDate), "date_format (collectionDate,'%Y-%m-%d') <= date_format('" + collectionEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
String createStartTime = query.getCreateStartTime(); |
|
|
|
String createEndTime = query.getCreateEndTime(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(createStartTime), "date_format (createTime,'%Y-%m-%d') >= date_format('" + createStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(createEndTime), "date_format (createTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
IPage<ScmCollectionRebate> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ScmCollectionRebateVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<ScmCollectionRebateVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean saveOrUpdateDto(ScmCollectionRebateDto dto){ |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ScmCollectionRebateVehService scmCollectionRebateVehService; |
|
|
|
@Autowired |
|
|
|
private BaseManufacturerBankFeign baseManufacturerBankFeign; |
|
|
|
|
|
|
|
private QueryWrapper<ScmCollectionRebate> createQueryWrapper(ScmCollectionRebateQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
|
QueryWrapper<ScmCollectionRebate> qw = new QueryWrapper<>(); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<ScmCollectionRebateVo> listPageVo(PagerQuery<ScmCollectionRebateQuery> pq) { |
|
|
|
ScmCollectionRebateQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ScmCollectionRebate> qw = new QueryWrapper<>(); |
|
|
|
qw.eq("createOrgSid", query.getCreateOrgSid()); |
|
|
|
if (StringUtils.isNotBlank(query.getCollectionTypeKey())) { |
|
|
|
qw.eq("collectionTypeKey", query.getCollectionTypeKey()); |
|
|
|
} |
|
|
|
String collectionStartDate = query.getCollectionStartDate(); |
|
|
|
String collectionEndDate = query.getCollectionEndDate(); |
|
|
|
qw.apply(StringUtils.isNotBlank(collectionStartDate), "date_format (collectionDate,'%Y-%m-%d') >= date_format('" + collectionStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(collectionEndDate), "date_format (collectionDate,'%Y-%m-%d') <= date_format('" + collectionEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
String createStartTime = query.getCreateStartTime(); |
|
|
|
String createEndTime = query.getCreateEndTime(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(createStartTime), "date_format (createTime,'%Y-%m-%d') >= date_format('" + createStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(createEndTime), "date_format (createTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
IPage<ScmCollectionRebate> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ScmCollectionRebateVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<ScmCollectionRebateVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean saveOrUpdateDto(ScmCollectionRebateDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
List<ScmCollectionRebateVehDto> scmCollectionRebateVehs = dto.getScmCollectionRebateVehs(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
String s = this.insertByDto(dto); |
|
|
|
if (!scmCollectionRebateVehs.isEmpty()){ |
|
|
|
for (ScmCollectionRebateVehDto scmCollectionRebateVeh : scmCollectionRebateVehs) { |
|
|
|
scmCollectionRebateVeh.setMainSid(s); |
|
|
|
scmCollectionRebateVehService.insertByDto(scmCollectionRebateVeh); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setMsg("添加成功"); |
|
|
|
List<ScmCollectionRebateVehDto> scmCollectionRebateVehs = dto.getScmCollectionRebateVehs(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
String s = this.insertByDto(dto); |
|
|
|
if (!scmCollectionRebateVehs.isEmpty()) { |
|
|
|
for (ScmCollectionRebateVehDto scmCollectionRebateVeh : scmCollectionRebateVehs) { |
|
|
|
scmCollectionRebateVeh.setMainSid(s); |
|
|
|
scmCollectionRebateVehService.insertByDto(scmCollectionRebateVeh); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setMsg("添加成功"); |
|
|
|
} |
|
|
|
ScmCollectionRebate scmCollectionRebate = fetchBySid(dtoSid); |
|
|
|
if (scmCollectionRebate == null) { |
|
|
|
return rb.setMsg("该回款返利不存在"); |
|
|
|
} |
|
|
|
ScmCollectionRebate scmCollectionRebate = fetchBySid(dtoSid); |
|
|
|
if (scmCollectionRebate == null){ |
|
|
|
return rb.setMsg("该回款返利不存在"); |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
scmCollectionRebateVehService.delByMainSid(dtoSid); |
|
|
|
if (!scmCollectionRebateVehs.isEmpty()){ |
|
|
|
for (ScmCollectionRebateVehDto scmCollectionRebateVeh : scmCollectionRebateVehs) { |
|
|
|
scmCollectionRebateVeh.setMainSid(dtoSid); |
|
|
|
scmCollectionRebateVehService.updateByDto(scmCollectionRebateVeh); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setMsg("修改成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public String insertByDto(ScmCollectionRebateDto dto){ |
|
|
|
ScmCollectionRebate entity = new ScmCollectionRebate(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
entity.setState(0); |
|
|
|
baseMapper.insert(entity); |
|
|
|
return entity.getSid(); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(ScmCollectionRebateDto dto){ |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isNotBlank(dto.getUploadMoney())) { |
|
|
|
dto.setState("3"); |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
scmCollectionRebateVehService.delByMainSid(dtoSid); |
|
|
|
if (!scmCollectionRebateVehs.isEmpty()) { |
|
|
|
for (ScmCollectionRebateVehDto scmCollectionRebateVeh : scmCollectionRebateVehs) { |
|
|
|
scmCollectionRebateVeh.setMainSid(dtoSid); |
|
|
|
scmCollectionRebateVehService.insertByDto(scmCollectionRebateVeh); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setMsg("修改成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public String insertByDto(ScmCollectionRebateDto dto) { |
|
|
|
ScmCollectionRebate entity = new ScmCollectionRebate(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
entity.setState(0); |
|
|
|
baseMapper.insert(entity); |
|
|
|
return entity.getSid(); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(ScmCollectionRebateDto dto) { |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ScmCollectionRebate entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public ScmCollectionRebateDetailsVo fetchDetailsVoBySid(String sid){ |
|
|
|
ScmCollectionRebate entity = fetchBySid(sid); |
|
|
|
ScmCollectionRebateDetailsVo vo = new ScmCollectionRebateDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
} |
|
|
|
ScmCollectionRebate entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateWithholdingDateBySid(String collectionRebateSid) { |
|
|
|
baseMapper.updateWithholdingDateBySid(collectionRebateSid); |
|
|
|
} |
|
|
|
public ScmCollectionRebateDetailsVo fetchDetailsVoBySid(String sid) { |
|
|
|
ScmCollectionRebate entity = fetchBySid(sid); |
|
|
|
ScmCollectionRebateDetailsVo vo = new ScmCollectionRebateDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
public void updateState(String collectionRebateSid) { |
|
|
|
baseMapper.updateState(collectionRebateSid); |
|
|
|
} |
|
|
|
public void updateWithholdingDateBySid(String collectionRebateSid) { |
|
|
|
baseMapper.updateWithholdingDateBySid(collectionRebateSid); |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<ScmCollectionRebateVo> withApplyGetCollectionRebate(PagerQuery<ScmCollectionRebateQuery> pq) { |
|
|
|
ScmCollectionRebateQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ScmCollectionRebate> qw = new QueryWrapper<>(); |
|
|
|
qw.eq("brandSid",query.getBrandSid()); |
|
|
|
if (StringUtils.isNotBlank(query.getCollectionTypeKey())) { |
|
|
|
qw.eq("collectionTypeKey", query.getCollectionTypeKey()); |
|
|
|
} |
|
|
|
String collectionStartDate = query.getCollectionStartDate(); |
|
|
|
String collectionEndDate = query.getCollectionEndDate(); |
|
|
|
qw.apply(StringUtils.isNotBlank(collectionStartDate), "date_format (collectionDate,'%Y-%m-%d') >= date_format('" + collectionStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(collectionEndDate), "date_format (collectionDate,'%Y-%m-%d') <= date_format('" + collectionEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
String createStartTime = query.getCreateStartTime(); |
|
|
|
String createEndTime = query.getCreateEndTime(); |
|
|
|
qw.apply(StringUtils.isNotBlank(createStartTime), "date_format (createTime,'%Y-%m-%d') >= date_format('" + createStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(createEndTime), "date_format (createTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
qw.eq("createOrgSid", query.getCreateOrgSid()); |
|
|
|
qw.eq("state", 0); |
|
|
|
if (query.getSidList().size() > 0) { |
|
|
|
qw.notIn("sid", query.getSidList()); |
|
|
|
} |
|
|
|
IPage<ScmCollectionRebate> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ScmCollectionRebateVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<ScmCollectionRebateVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
public void updateState(String collectionRebateSid) { |
|
|
|
baseMapper.updateState(collectionRebateSid); |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<ScmCollectionRebateVo> checkApplyGetCollectionRebate(PagerQuery<ScmCollectionRebateQuery> pq) { |
|
|
|
ScmCollectionRebateQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ScmCollectionRebate> qw = new QueryWrapper<>(); |
|
|
|
if (StringUtils.isNotBlank(query.getCollectionTypeKey())) { |
|
|
|
qw.eq("collectionTypeKey", query.getCollectionTypeKey()); |
|
|
|
} |
|
|
|
String collectionStartDate = query.getCollectionStartDate(); |
|
|
|
String collectionEndDate = query.getCollectionEndDate(); |
|
|
|
qw.apply(StringUtils.isNotBlank(collectionStartDate), "date_format (collectionDate,'%Y-%m-%d') >= date_format('" + collectionStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(collectionEndDate), "date_format (collectionDate,'%Y-%m-%d') <= date_format('" + collectionEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
String createStartTime = query.getCreateStartTime(); |
|
|
|
String createEndTime = query.getCreateEndTime(); |
|
|
|
qw.apply(StringUtils.isNotBlank(createStartTime), "date_format (createTime,'%Y-%m-%d') >= date_format('" + createStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(createEndTime), "date_format (createTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
qw.eq("createOrgSid", query.getCreateOrgSid()); |
|
|
|
qw.ne("state", 0); |
|
|
|
IPage<ScmCollectionRebate> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ScmCollectionRebateVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
for (ScmCollectionRebateVo record : pagging.getRecords()) { |
|
|
|
//上传状态:未上传
|
|
|
|
if (StringUtils.isBlank(record.getUploadDate()) && StringUtils.isBlank(record.getUploadMoney())) { |
|
|
|
record.setUploadState("2"); |
|
|
|
} |
|
|
|
//上传状态:已上传
|
|
|
|
if (StringUtils.isNotBlank(record.getUploadDate()) && StringUtils.isNotBlank(record.getUploadMoney())) { |
|
|
|
record.setUploadState("3"); |
|
|
|
} |
|
|
|
} |
|
|
|
PagerVo<ScmCollectionRebateVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
public PagerVo<ScmCollectionRebateVo> withApplyGetCollectionRebate(PagerQuery<ScmCollectionRebateQuery> pq) { |
|
|
|
ScmCollectionRebateQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ScmCollectionRebate> qw = new QueryWrapper<>(); |
|
|
|
qw.eq("brandSid", query.getBrandSid()); |
|
|
|
if (StringUtils.isNotBlank(query.getCollectionTypeKey())) { |
|
|
|
qw.eq("collectionTypeKey", query.getCollectionTypeKey()); |
|
|
|
} |
|
|
|
String collectionStartDate = query.getCollectionStartDate(); |
|
|
|
String collectionEndDate = query.getCollectionEndDate(); |
|
|
|
qw.apply(StringUtils.isNotBlank(collectionStartDate), "date_format (collectionDate,'%Y-%m-%d') >= date_format('" + collectionStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(collectionEndDate), "date_format (collectionDate,'%Y-%m-%d') <= date_format('" + collectionEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
String createStartTime = query.getCreateStartTime(); |
|
|
|
String createEndTime = query.getCreateEndTime(); |
|
|
|
qw.apply(StringUtils.isNotBlank(createStartTime), "date_format (createTime,'%Y-%m-%d') >= date_format('" + createStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(createEndTime), "date_format (createTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
qw.eq("createOrgSid", query.getCreateOrgSid()); |
|
|
|
qw.eq("state", 0); |
|
|
|
if (query.getSidList().size() > 0) { |
|
|
|
qw.notIn("sid", query.getSidList()); |
|
|
|
} |
|
|
|
IPage<ScmCollectionRebate> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ScmCollectionRebateVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
for (ScmCollectionRebateVo record : pagging.getRecords()) { |
|
|
|
String brandSid = record.getBrandSid(); |
|
|
|
String manufaSaleChannelValue = record.getManufaSaleChannelValue(); |
|
|
|
String bankAccount = baseManufacturerBankFeign.selectBankAccount(brandSid, manufaSaleChannelValue).getData(); |
|
|
|
record.setManufaBankAccount(bankAccount); |
|
|
|
} |
|
|
|
PagerVo<ScmCollectionRebateVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<ScmCollectionRebateVo> checkApplyGetCollectionRebate(PagerQuery<ScmCollectionRebateQuery> pq) { |
|
|
|
ScmCollectionRebateQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ScmCollectionRebate> qw = new QueryWrapper<>(); |
|
|
|
if (StringUtils.isNotBlank(query.getCollectionTypeKey())) { |
|
|
|
qw.eq("collectionTypeKey", query.getCollectionTypeKey()); |
|
|
|
} |
|
|
|
String collectionStartDate = query.getCollectionStartDate(); |
|
|
|
String collectionEndDate = query.getCollectionEndDate(); |
|
|
|
qw.apply(StringUtils.isNotBlank(collectionStartDate), "date_format (collectionDate,'%Y-%m-%d') >= date_format('" + collectionStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(collectionEndDate), "date_format (collectionDate,'%Y-%m-%d') <= date_format('" + collectionEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
String createStartTime = query.getCreateStartTime(); |
|
|
|
String createEndTime = query.getCreateEndTime(); |
|
|
|
qw.apply(StringUtils.isNotBlank(createStartTime), "date_format (createTime,'%Y-%m-%d') >= date_format('" + createStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(createEndTime), "date_format (createTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
qw.eq("createOrgSid", query.getCreateOrgSid()); |
|
|
|
qw.ne("state", 0); |
|
|
|
IPage<ScmCollectionRebate> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ScmCollectionRebateVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
List<ScmCollectionRebateVo> records = pagging.getRecords(); |
|
|
|
for (ScmCollectionRebateVo record : records) { |
|
|
|
//上传状态:未上传
|
|
|
|
if (StringUtils.isBlank(record.getUploadDate()) && StringUtils.isBlank(record.getUploadMoney())) { |
|
|
|
record.setUploadState("2"); |
|
|
|
} |
|
|
|
//上传状态:已上传
|
|
|
|
if (StringUtils.isNotBlank(record.getUploadDate()) && StringUtils.isNotBlank(record.getUploadMoney())) { |
|
|
|
record.setUploadState("3"); |
|
|
|
} |
|
|
|
String withholdingDate = record.getWithholdingDate(); |
|
|
|
DateTime parse = DateUtil.parse(withholdingDate, "yyyy-MM-dd"); |
|
|
|
record.setWithholdingDate(parse.toString()); |
|
|
|
String brandSid = record.getBrandSid(); |
|
|
|
String manufaSaleChannelValue = record.getManufaSaleChannelValue(); |
|
|
|
String bankAccount = baseManufacturerBankFeign.selectBankAccount(brandSid, manufaSaleChannelValue).getData(); |
|
|
|
record.setManufaBankAccount(bankAccount); |
|
|
|
} |
|
|
|
PagerVo<ScmCollectionRebateVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<ScmCollectionRebateVo> checkApplyGetAlreadyUploadCollectionRebate(PagerQuery<ScmCollectionRebateQuery> pq) { |
|
|
|
ScmCollectionRebateQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ScmCollectionRebate> qw = new QueryWrapper<>(); |
|
|
|
if (StringUtils.isNotBlank(query.getCollectionTypeKey())) { |
|
|
|
qw.eq("collectionTypeKey", query.getCollectionTypeKey()); |
|
|
|
} |
|
|
|
String collectionStartDate = query.getCollectionStartDate(); |
|
|
|
String collectionEndDate = query.getCollectionEndDate(); |
|
|
|
qw.apply(StringUtils.isNotBlank(collectionStartDate), "date_format (collectionDate,'%Y-%m-%d') >= date_format('" + collectionStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(collectionEndDate), "date_format (collectionDate,'%Y-%m-%d') <= date_format('" + collectionEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
String createStartTime = query.getCreateStartTime(); |
|
|
|
String createEndTime = query.getCreateEndTime(); |
|
|
|
qw.apply(StringUtils.isNotBlank(createStartTime), "date_format (createTime,'%Y-%m-%d') >= date_format('" + createStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(createEndTime), "date_format (createTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
qw.eq("createOrgSid", query.getCreateOrgSid()); |
|
|
|
qw.eq("state", 3); |
|
|
|
if (query.getSidList().size() > 0) { |
|
|
|
qw.notIn("sid", query.getSidList()); |
|
|
|
} |
|
|
|
IPage<ScmCollectionRebate> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ScmCollectionRebateVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
for (ScmCollectionRebateVo record : pagging.getRecords()) { |
|
|
|
Date withholdingDate = record.getWithholdingDate(); |
|
|
|
int year = DateUtil.year(withholdingDate); |
|
|
|
int month = DateUtil.month(withholdingDate) + 1; |
|
|
|
String withholdingDateCopy = year + "年" + month + "月"; |
|
|
|
record.setWithholdingDateCopy(withholdingDateCopy); |
|
|
|
} |
|
|
|
PagerVo<ScmCollectionRebateVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
public PagerVo<ScmCollectionRebateVo> checkApplyGetAlreadyUploadCollectionRebate(PagerQuery<ScmCollectionRebateQuery> pq) { |
|
|
|
ScmCollectionRebateQuery query = pq.getParams(); |
|
|
|
QueryWrapper<ScmCollectionRebate> qw = new QueryWrapper<>(); |
|
|
|
if (StringUtils.isNotBlank(query.getCollectionTypeKey())) { |
|
|
|
qw.eq("collectionTypeKey", query.getCollectionTypeKey()); |
|
|
|
} |
|
|
|
String collectionStartDate = query.getCollectionStartDate(); |
|
|
|
String collectionEndDate = query.getCollectionEndDate(); |
|
|
|
qw.apply(StringUtils.isNotBlank(collectionStartDate), "date_format (collectionDate,'%Y-%m-%d') >= date_format('" + collectionStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(collectionEndDate), "date_format (collectionDate,'%Y-%m-%d') <= date_format('" + collectionEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
String withholdingStartDate = query.getWithholdingStartDate(); |
|
|
|
String withholdingEndDate = query.getWithholdingEndDate(); |
|
|
|
qw.apply(StringUtils.isNotBlank(withholdingStartDate), "date_format (withholdingDate,'%Y-%m-%d') >= date_format('" + withholdingStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(withholdingEndDate), "date_format (withholdingDate,'%Y-%m-%d') <= date_format('" + withholdingEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
qw.eq("createOrgSid", query.getCreateOrgSid()); |
|
|
|
qw.eq("state", 3); |
|
|
|
if (query.getSidList().size() > 0) { |
|
|
|
qw.notIn("sid", query.getSidList()); |
|
|
|
} |
|
|
|
IPage<ScmCollectionRebate> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<ScmCollectionRebateVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
for (ScmCollectionRebateVo record : pagging.getRecords()) { |
|
|
|
String withholdingDate = record.getWithholdingDate(); |
|
|
|
DateTime parse = DateUtil.parse(withholdingDate, "yyyy-MM-dd"); |
|
|
|
int year = DateUtil.year(parse); |
|
|
|
int month = DateUtil.month(parse) + 1; |
|
|
|
String withholdingDateCopy = year + "年" + month + "月"; |
|
|
|
record.setWithholdingDate(parse.toString()); |
|
|
|
record.setWithholdingDateCopy(withholdingDateCopy); |
|
|
|
String brandSid = record.getBrandSid(); |
|
|
|
String manufaSaleChannelValue = record.getManufaSaleChannelValue(); |
|
|
|
String bankAccount = baseManufacturerBankFeign.selectBankAccount(brandSid, manufaSaleChannelValue).getData(); |
|
|
|
record.setManufaBankAccount(bankAccount); |
|
|
|
} |
|
|
|
PagerVo<ScmCollectionRebateVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<ScmCollectionRebateDetailsVo> fetchAllDetailsVoBySid(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
ScmCollectionRebateDetailsVo scmCollectionRebateDetailsVo = fetchDetailsVoBySid(sid); |
|
|
|
List<ScmCollectionRebateVehDetailsVo> scmCollectionRebateVehDetailsVos = scmCollectionRebateVehService.fetchByMainSid(sid); |
|
|
|
scmCollectionRebateDetailsVo.setScmCollectionRebateVehs(scmCollectionRebateVehDetailsVos); |
|
|
|
return rb.success().setData(scmCollectionRebateDetailsVo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean stayCheckUpAgre(StayCheckUpAgre stayCheckUpAgre) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
List<String> sids = stayCheckUpAgre.getSids(); |
|
|
|
for (String sid : sids) { |
|
|
|
ScmCollectionRebate scmCollectionRebate = fetchBySid(sid); |
|
|
|
scmCollectionRebate.setUploadMoney(scmCollectionRebate.getEstimateRebate()); |
|
|
|
scmCollectionRebate.setUploadDate(stayCheckUpAgre.getUpDate()); |
|
|
|
scmCollectionRebate.setAdjustmentMoney("0"); |
|
|
|
saveOrUpdate(scmCollectionRebate); |
|
|
|
} |
|
|
|
return rb.success().setMsg("上传成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<ScmCollectionRebateDetailsVo> fetchAllDetailsVoBySid(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
ScmCollectionRebateDetailsVo scmCollectionRebateDetailsVo = fetchDetailsVoBySid(sid); |
|
|
|
List<ScmCollectionRebateVehDetailsVo> scmCollectionRebateVehDetailsVos = scmCollectionRebateVehService.fetchByMainSid(sid); |
|
|
|
scmCollectionRebateDetailsVo.setScmCollectionRebateVehs(scmCollectionRebateVehDetailsVos); |
|
|
|
return rb.success().setData(scmCollectionRebateDetailsVo); |
|
|
|
} |
|
|
|
public ResultBean<ScmCollectionRebateDetailsVo> stayCheckBySid(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
ScmCollectionRebateDetailsVo scmCollectionRebateDetailsVo = fetchDetailsVoBySid(sid); |
|
|
|
List<ScmCollectionRebateVehDetailsVo> scmCollectionRebateVehDetailsVos = scmCollectionRebateVehService.fetchByMainSid(sid); |
|
|
|
scmCollectionRebateDetailsVo.setScmCollectionRebateVehs(scmCollectionRebateVehDetailsVos); |
|
|
|
return rb.success().setData(scmCollectionRebateDetailsVo); |
|
|
|
} |
|
|
|
} |