|
|
|
@ -6,8 +6,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.xujie.common.utils.PageUtils; |
|
|
|
import com.xujie.modules.supplier.data.PurQuotationDetailData; |
|
|
|
import com.xujie.modules.supplier.data.PurQuotationReplyHistData; |
|
|
|
import com.xujie.modules.supplier.data.PurQuotationHeaderData; |
|
|
|
import com.xujie.modules.supplier.entity.PurQuotationDetail; |
|
|
|
import com.xujie.modules.supplier.entity.PurQuotationHeader; |
|
|
|
import com.xujie.modules.supplier.entity.PurQuotationReplyHist; |
|
|
|
import com.xujie.modules.supplier.mapper.PurQuotationDetailMapper; |
|
|
|
import com.xujie.modules.supplier.mapper.PurQuotationHeaderMapper; |
|
|
|
import com.xujie.modules.supplier.mapper.PurQuotationReplyHistMapper; |
|
|
|
import com.xujie.modules.supplier.service.IPurQuotationReplyHistService; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
@ -33,6 +37,9 @@ public class PurQuotationReplyHistServiceImpl extends ServiceImpl<PurQuotationRe |
|
|
|
@Autowired |
|
|
|
private PurQuotationDetailMapper purQuotationDetailMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private PurQuotationHeaderMapper purQuotationHeaderMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void saveModel(PurQuotationReplyHist model){ |
|
|
|
@ -53,6 +60,7 @@ public class PurQuotationReplyHistServiceImpl extends ServiceImpl<PurQuotationRe |
|
|
|
|
|
|
|
model.setCreatedDate(new Date()); |
|
|
|
baseMapper.insert(model); |
|
|
|
promoteHeaderToQuoted(model.getOrderNo(), model.getSite()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -101,6 +109,58 @@ public class PurQuotationReplyHistServiceImpl extends ServiceImpl<PurQuotationRe |
|
|
|
purQuotationDetailMapper.updatePurDetailStatus(purQuoDetailData); |
|
|
|
//更新报价状态 |
|
|
|
baseMapper.updateById(model); |
|
|
|
if (Objects.equals("已接受", model.getStatus())) { |
|
|
|
closeHeaderIfAllDetailsAccepted(model.getOrderNo(), model.getSite()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 任一条明细报价后,主表由待报价变为已报价 |
|
|
|
*/ |
|
|
|
private void promoteHeaderToQuoted(String orderNo, String site) { |
|
|
|
PurQuotationHeaderData headerQuery = new PurQuotationHeaderData(); |
|
|
|
headerQuery.setOrderNo(orderNo); |
|
|
|
headerQuery.setSite(site); |
|
|
|
List<PurQuotationHeaderData> headers = purQuotationHeaderMapper.getListByModel(headerQuery); |
|
|
|
if (CollectionUtils.isEmpty(headers)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
PurQuotationHeaderData header = headers.get(0); |
|
|
|
if (!Objects.equals("待报价", header.getStatus())) { |
|
|
|
return; |
|
|
|
} |
|
|
|
PurQuotationHeader update = new PurQuotationHeader(); |
|
|
|
update.setId(header.getId()); |
|
|
|
update.setStatus("已报价"); |
|
|
|
purQuotationHeaderMapper.updateById(update); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 全部明细已接受时,主表自动关闭(仅更新主表状态) |
|
|
|
*/ |
|
|
|
private void closeHeaderIfAllDetailsAccepted(String orderNo, String site) { |
|
|
|
PurQuotationDetail detailQuery = new PurQuotationDetail(); |
|
|
|
detailQuery.setOrderNo(orderNo); |
|
|
|
detailQuery.setSite(site); |
|
|
|
List<PurQuotationDetailData> details = purQuotationDetailMapper.getListByModel(detailQuery); |
|
|
|
if (CollectionUtils.isEmpty(details)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
boolean allAccepted = details.stream().allMatch(d -> Objects.equals("已接受", d.getStatus())); |
|
|
|
if (!allAccepted) { |
|
|
|
return; |
|
|
|
} |
|
|
|
PurQuotationHeaderData headerQuery = new PurQuotationHeaderData(); |
|
|
|
headerQuery.setOrderNo(orderNo); |
|
|
|
headerQuery.setSite(site); |
|
|
|
List<PurQuotationHeaderData> headers = purQuotationHeaderMapper.getListByModel(headerQuery); |
|
|
|
if (CollectionUtils.isEmpty(headers)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
PurQuotationHeader update = new PurQuotationHeader(); |
|
|
|
update.setId(headers.get(0).getId()); |
|
|
|
update.setStatus("已关闭"); |
|
|
|
purQuotationHeaderMapper.updateById(update); |
|
|
|
} |
|
|
|
|
|
|
|
} |