|
|
@ -31,6 +31,8 @@ import cn.hutool.core.date.DateUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.sms.biz.smsgoods.SmsGoods; |
|
|
|
import com.yxt.sms.biz.smsgoods.SmsGoodsService; |
|
|
|
import com.yxt.sms.biz.smssalesbill.*; |
|
|
|
import com.yxt.sms.biz.smssalesbilldetail.SmsSalesBillDetail; |
|
|
|
import com.yxt.sms.biz.smssalesbilldetail.SmsSalesBillDetailService; |
|
|
@ -80,6 +82,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -134,6 +137,8 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
private FmsReceivesettleFeign fmsReceivesettleFeign; |
|
|
|
@Autowired |
|
|
|
private SmsSalesReturnItemService smsSalesReturnItemService; |
|
|
|
@Autowired |
|
|
|
private SmsGoodsService smsGoodsService; |
|
|
|
private QueryWrapper<SmsSalesReturn> createQueryWrapper(SmsSalesReturnQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
@ -203,7 +208,7 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getUseOrgName())) { |
|
|
|
qw.like("s.useOrgName", query.getUseOrgName()); |
|
|
|
qw.like("ss.`name`", query.getUseOrgName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getDeptName())) { |
|
|
|
qw.like("s.deptName", query.getDeptName()); |
|
|
@ -215,7 +220,7 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
qw.like("s.billNo", query.getBillNo()); |
|
|
|
} |
|
|
|
String startDate = query.getStartDate(); |
|
|
|
String endDate = query.getStartDate(); |
|
|
|
String endDate = query.getEndDate(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(startDate), "date_format (s.createTime,'%Y-%m-%d') >= date_format('" + startDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(endDate), "date_format (s.createTime,'%Y-%m-%d') <= date_format('" + endDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
@ -538,21 +543,77 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
} |
|
|
|
vo.setSitemVos(sitemVos); |
|
|
|
} |
|
|
|
|
|
|
|
// List<GoodsDetailsVo> goodsDetailsVos = data.getGoodsDetailsVos();
|
|
|
|
// List<SmsGoodsDetailsVo> smsGoodsDetailsVos = new ArrayList<>();
|
|
|
|
// if (!goodsDetailsVos.isEmpty()) {
|
|
|
|
// for (GoodsDetailsVo goodsDetailsVo : goodsDetailsVos) {
|
|
|
|
// SmsGoodsDetailsVo smsGoodsDetailsVo = new SmsGoodsDetailsVo();
|
|
|
|
// BeanUtil.copyProperties(goodsDetailsVo, smsGoodsDetailsVo);
|
|
|
|
// //查询已退数量
|
|
|
|
// String goodsID = goodsDetailsVo.getGoodsID();
|
|
|
|
// String sumBackCount = baseMapper.selBackCountByGoodsID(goodsID, sid);
|
|
|
|
// smsGoodsDetailsVo.setReturnedCount(sumBackCount);
|
|
|
|
// smsGoodsDetailsVos.add(smsGoodsDetailsVo);
|
|
|
|
// }
|
|
|
|
// vo.setGoodsDetailsVos(smsGoodsDetailsVos);
|
|
|
|
// }
|
|
|
|
BigDecimal taxRate = BigDecimal.ZERO;//税率
|
|
|
|
boolean wxGoods = false; //维修领料是否为加税点项目
|
|
|
|
AsBusrepairBillInvoice invoice = asBusrepairBillFeign.fetchInvoiceBySid(sid); |
|
|
|
if (null != invoice) { |
|
|
|
if (StringUtils.isNotBlank(invoice.getTaxItems())) { |
|
|
|
String taxItem = invoice.getTaxItems(); |
|
|
|
if (taxItem.contains("维修用料")) { |
|
|
|
wxGoods = true; |
|
|
|
} |
|
|
|
if (null != invoice.getTaxRate()) { |
|
|
|
taxRate = invoice.getTaxRate(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
List<SmsGoodsDetailsVo> goodsDetailsVos = new ArrayList<>(); //商品信息
|
|
|
|
List<AsBusrepairInventorybillDetail> goodsDetails = asBusrepairBillFeign.fetchGoodsByBillSid(sid); |
|
|
|
if (!goodsDetails.isEmpty()) { |
|
|
|
DecimalFormat df2 =new DecimalFormat("#.00"); |
|
|
|
for (AsBusrepairInventorybillDetail goodsDetail : goodsDetails) { |
|
|
|
SmsGoodsDetailsVo goodsDetailsVo = new SmsGoodsDetailsVo(); |
|
|
|
BeanUtil.copyProperties(goodsDetail, goodsDetailsVo); |
|
|
|
String goodsLinkSid = goodsDetail.getSid(); |
|
|
|
goodsDetailsVo.setGoodsLinkSid(goodsLinkSid); |
|
|
|
BigDecimal constPrice = BigDecimal.ZERO; //销售价常量
|
|
|
|
BigDecimal count = BigDecimal.ZERO; //数量
|
|
|
|
if (null != goodsDetail.getCurrentCount()) { |
|
|
|
count = goodsDetail.getCurrentCount(); |
|
|
|
} |
|
|
|
goodsDetailsVo.setCount(String.valueOf(goodsDetail.getCurrentCount().intValue())); |
|
|
|
boolean isTaxRate = false; //进货价是否含税
|
|
|
|
SmsGoods smsGoods = smsGoodsService.fetchEntityByGoodsID(goodsDetail.getGoodsID()); |
|
|
|
if (null != smsGoods) { |
|
|
|
if (StringUtils.isNotBlank(smsGoods.getSupplierName())) { |
|
|
|
goodsDetailsVo.setBillObjName(smsGoods.getSupplierName()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (null != goodsDetail.getGoodsDetailsPrice()) { |
|
|
|
constPrice = goodsDetail.getGoodsDetailsPrice(); |
|
|
|
} |
|
|
|
if (goodsDetail.getIsTaxRate() != null) { |
|
|
|
if (goodsDetail.getIsTaxRate().intValue() == 1) { |
|
|
|
goodsDetailsVo.setPrice(constPrice.toString()); |
|
|
|
} else { |
|
|
|
if (wxGoods) { |
|
|
|
BigDecimal divide = taxRate.divide(new BigDecimal("100")); |
|
|
|
BigDecimal add = divide.add(new BigDecimal("1")); |
|
|
|
BigDecimal multiply = constPrice.multiply(add); |
|
|
|
goodsDetailsVo.setPrice(df2.format(multiply)); |
|
|
|
} else { |
|
|
|
goodsDetailsVo.setPrice(constPrice.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (wxGoods) { |
|
|
|
BigDecimal divide = taxRate.divide(new BigDecimal("100")); |
|
|
|
BigDecimal add = divide.add(new BigDecimal("1")); |
|
|
|
BigDecimal multiply = constPrice.multiply(add); |
|
|
|
goodsDetailsVo.setPrice(df2.format(multiply)); |
|
|
|
} else { |
|
|
|
goodsDetailsVo.setPrice(constPrice.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
String returnCount = smsSalesReturnDetailService.selSouceSidAndGoodLinkSid(sid,goodsLinkSid); |
|
|
|
BigDecimal rCount = new BigDecimal(returnCount); |
|
|
|
goodsDetailsVo.setReturnedCount(returnCount); |
|
|
|
if (rCount.compareTo(count) < 0) { |
|
|
|
goodsDetailsVos.add(goodsDetailsVo); |
|
|
|
} |
|
|
|
} |
|
|
|
vo.setGoodsDetailsVos(goodsDetailsVos); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (type.equals("1")) { |
|
|
|
//销售单
|
|
|
@ -561,6 +622,12 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
vo.setSourceBillNo(data.getBillNo()); |
|
|
|
vo.setBillType("销售单"); |
|
|
|
vo.setBillDate(data.getCreateTime()); |
|
|
|
if (null != data.getGoodsAmount()) { |
|
|
|
vo.setGoodsAmount(data.getGoodsAmount()); |
|
|
|
} |
|
|
|
if (null != data.getAddAmount()) { |
|
|
|
vo.setAddAmount(data.getAddAmount()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getSubject())) { |
|
|
|
vo.setSubject(data.getSubject()); |
|
|
|
} |
|
|
@ -590,17 +657,20 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
for (SalesGoodsVo goodsDetailsVo : goodsDetailsVos) { |
|
|
|
SmsGoodsDetailsVo smsGoodsDetailsVo = new SmsGoodsDetailsVo(); |
|
|
|
BeanUtil.copyProperties(goodsDetailsVo, smsGoodsDetailsVo); |
|
|
|
smsGoodsDetailsVo.setGoodsLinkSid(goodsDetailsVo.getSid()); |
|
|
|
String count = goodsDetailsVo.getCount(); |
|
|
|
BigDecimal totalCount = new BigDecimal(count); |
|
|
|
//查询已退数量
|
|
|
|
String goodsID = goodsDetailsVo.getGoodsID(); |
|
|
|
String sumBackCount = baseMapper.selBackCountByGoodsID(goodsID, sid); |
|
|
|
smsGoodsDetailsVo.setReturnedCount(sumBackCount); |
|
|
|
smsGoodsDetailsVos.add(smsGoodsDetailsVo); |
|
|
|
smsGoodsDetailsVos.add(smsGoodsDetailsVo); |
|
|
|
String returnCount = smsSalesReturnDetailService.selSouceSidAndGoodLinkSid(sid,goodsDetailsVo.getSid()); |
|
|
|
BigDecimal rCount = new BigDecimal(returnCount); |
|
|
|
smsGoodsDetailsVo.setReturnedCount(returnCount); |
|
|
|
if (rCount.compareTo(totalCount) < 0) { |
|
|
|
smsGoodsDetailsVos.add(smsGoodsDetailsVo); |
|
|
|
} |
|
|
|
} |
|
|
|
vo.setGoodsDetailsVos(smsGoodsDetailsVos); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return vo; |
|
|
|
} |
|
|
@ -627,6 +697,24 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
public ResultBean<String> saveBill(SmsSalesReturnNewDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String sid = ""; |
|
|
|
BigDecimal totalAmount = BigDecimal.ZERO; //合计金额
|
|
|
|
BigDecimal returnSumAmount = BigDecimal.ZERO; //退款总金额
|
|
|
|
BigDecimal goodsAmount = BigDecimal.ZERO; //退款总金额
|
|
|
|
if (StringUtils.isNotBlank(dto.getTotalAmount())) { |
|
|
|
totalAmount = new BigDecimal(dto.getTotalAmount()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getPayableAmount())) { |
|
|
|
returnSumAmount = new BigDecimal(dto.getPayableAmount()); |
|
|
|
} |
|
|
|
if (returnSumAmount.compareTo(totalAmount) > 0) { |
|
|
|
return rb.setMsg("整单退货金额不能大于销售金额"); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getGoodsAmount())) { |
|
|
|
goodsAmount = new BigDecimal(dto.getGoodsAmount()); |
|
|
|
} |
|
|
|
if (returnSumAmount.compareTo(BigDecimal.ZERO) <= 0) { |
|
|
|
return rb.setMsg("退货金额不能为0"); |
|
|
|
} |
|
|
|
List<SalesGoodsReturnVo> goodsVos = dto.getReturnGoods(); |
|
|
|
if (!goodsVos.isEmpty()) { |
|
|
|
for (SalesGoodsReturnVo goodsVo : goodsVos) { |
|
|
@ -637,18 +725,31 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
if (add.compareTo(currentCount) > 0) { |
|
|
|
return rb.setMsg("退货数量不能大于总数量"); |
|
|
|
} |
|
|
|
BigDecimal price = BigDecimal.ZERO; //合计金额
|
|
|
|
BigDecimal backPrice = BigDecimal.ZERO; //退款总金额
|
|
|
|
if (StringUtils.isNotBlank(goodsVo.getPrice())) { |
|
|
|
price = new BigDecimal(goodsVo.getPrice()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(goodsVo.getBackPrice())) { |
|
|
|
backPrice = new BigDecimal(goodsVo.getBackPrice()); |
|
|
|
} |
|
|
|
if (backPrice.compareTo(price) > 0) { |
|
|
|
return rb.setMsg("商品退货单价不能大于销售单价"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getSid())) { |
|
|
|
sid = dto.getSid(); |
|
|
|
SmsSalesReturn smsSalesReturn = fetchBySid(sid); |
|
|
|
BeanUtil.copyProperties(dto, smsSalesReturn, "id", "sid"); |
|
|
|
BeanUtil.copyProperties(dto, smsSalesReturn, "id", "sid","billType"); |
|
|
|
baseMapper.updateById(smsSalesReturn); |
|
|
|
smsSalesReturnDetailService.deleteByMainSid(sid); |
|
|
|
smsSalesReturnItemService.deleteByMainSid(sid); |
|
|
|
} else { |
|
|
|
SmsSalesReturn entity = new SmsSalesReturn(); |
|
|
|
sid = entity.getSid(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid","billType"); |
|
|
|
String applyCode = getApplyCode(dto.getCreateOrgSid()); |
|
|
|
entity.setBillNo(applyCode); |
|
|
|
entity.setNodeState("待提交"); |
|
|
@ -663,26 +764,56 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
smsSalesReturnDetailService.insert(detail); |
|
|
|
} |
|
|
|
} |
|
|
|
List<SalesItemsReturnVo> returnSitemVos = dto.getReturnSitemVos(); |
|
|
|
if (!returnSitemVos.isEmpty()) { |
|
|
|
for (SalesItemsReturnVo returnItem : returnSitemVos) { |
|
|
|
SmsSalesReturnItem detail = new SmsSalesReturnItem(); |
|
|
|
BeanUtil.copyProperties(returnItem, detail, "id", "sid"); |
|
|
|
detail.setBillSid(sid); |
|
|
|
List<String> staffList = returnItem.getStaffList(); |
|
|
|
List<String> staffNameList = returnItem.getStaffNameList(); |
|
|
|
StringBuffer sbSid = new StringBuffer(); |
|
|
|
StringBuffer sbName = new StringBuffer(); |
|
|
|
if (!staffList.isEmpty()) { |
|
|
|
for (int i = 0; i < staffList.size(); i++) { |
|
|
|
String s = staffList.get(i); |
|
|
|
String sName = staffNameList.get(i); |
|
|
|
sbSid.append(s).append(","); |
|
|
|
sbName.append(sName).append(","); |
|
|
|
} |
|
|
|
if (sbSid.length() > 0) { |
|
|
|
sbSid.delete(sbSid.length() - 1 ,sbSid.length()); |
|
|
|
detail.setRepairerSid(sbSid.toString()); |
|
|
|
} |
|
|
|
if (sbName.length() > 0) { |
|
|
|
sbName.delete(sbName.length() - 1 ,sbName.length()); |
|
|
|
detail.setRepairerName(sbName.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
smsSalesReturnItemService.insert(detail); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setData(sid); |
|
|
|
} |
|
|
|
|
|
|
|
public SmsSalesReturnNewDetailsVo fetchNewDetailsVoBySid(String sid) { |
|
|
|
SmsSalesReturnNewDetailsVo vo = new SmsSalesReturnNewDetailsVo(); |
|
|
|
SmsSalesReturn smsSalesReturn = fetchBySid(sid); |
|
|
|
String sourceBillSid = smsSalesReturn.getSourceBillSid(); |
|
|
|
if (null != smsSalesReturn) { |
|
|
|
BeanUtil.copyProperties(smsSalesReturn, vo); |
|
|
|
Integer type = smsSalesReturn.getBillType(); |
|
|
|
Integer type = smsSalesReturn.getType(); |
|
|
|
vo.setCreateTime(DateUtil.formatDate(smsSalesReturn.getCreateTime())); |
|
|
|
if (StringUtils.isNotBlank(smsSalesReturn.getProcInstId())) { |
|
|
|
vo.setInstanceId(smsSalesReturn.getProcInstId()); |
|
|
|
} |
|
|
|
if (type == 0) { |
|
|
|
//维修工单
|
|
|
|
AsBusrepairBillDetailsVo data = asBusrepairBillFeign.fetchDetailsBySid(smsSalesReturn.getSourceBillSid()).getData(); |
|
|
|
AsBusrepairBill data = asBusrepairBillFeign.fetchBySid(sourceBillSid); |
|
|
|
if (null != data) { |
|
|
|
vo.setSourceBillNo(data.getBillNo()); |
|
|
|
vo.setBillType(data.getBillType()); |
|
|
|
vo.setBillDate(data.getCreateDate()); |
|
|
|
vo.setBillDate(DateUtil.formatDate(data.getCreateTime())); |
|
|
|
if (StringUtils.isNotBlank(data.getSubject())) { |
|
|
|
vo.setSubject(data.getSubject()); |
|
|
|
} |
|
|
@ -695,48 +826,143 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
if (StringUtils.isNotBlank(data.getMobile())) { |
|
|
|
vo.setMobile(data.getMobile()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getVehMark())) { |
|
|
|
vo.setVehMark(data.getVehMark()); |
|
|
|
if (null != data.getHourAmount()) { |
|
|
|
vo.setHourAmount(data.getHourAmount().toString()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getVinNo())) { |
|
|
|
vo.setVinNo(data.getVinNo()); |
|
|
|
if (null != data.getGoodsAmount()) { |
|
|
|
vo.setGoodsAmount(data.getGoodsAmount().toString()); |
|
|
|
} |
|
|
|
SettleVo settleVo = data.getSettleVo(); |
|
|
|
if (null != settleVo) { |
|
|
|
vo.setSettleDate(settleVo.getSettleTime()); |
|
|
|
if (null != data.getAddAmount()) { |
|
|
|
vo.setAddAmount(data.getAddAmount().toString()); |
|
|
|
} |
|
|
|
List<SitemVo> sitemVos = data.getSitemVos(); |
|
|
|
List<SmsSitemVo> smsSitemVos = new ArrayList<>(); |
|
|
|
if (!sitemVos.isEmpty()) { |
|
|
|
for (SitemVo smsSitemVo : sitemVos) { |
|
|
|
SmsSitemVo sitemVo = new SmsSitemVo(); |
|
|
|
BeanUtil.copyProperties(smsSitemVo, sitemVo); |
|
|
|
smsSitemVos.add(sitemVo); |
|
|
|
AsBusrepairBillVech vech = asBusrepairBillFeign.fetchVehInfoByBillSid(sourceBillSid); |
|
|
|
if (null != vech) { |
|
|
|
if (StringUtils.isNotBlank(vech.getVehMark())) { |
|
|
|
vo.setVehMark(vech.getVehMark()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(vech.getVinNo())) { |
|
|
|
vo.setVinNo(vech.getVinNo()); |
|
|
|
} |
|
|
|
vo.setSitemVos(smsSitemVos); |
|
|
|
} |
|
|
|
List<GoodsDetailsVo> goodsDetailsVos = data.getGoodsDetailsVos(); |
|
|
|
List<SmsGoodsDetailsVo> smsGoodsDetailsVos = new ArrayList<>(); |
|
|
|
if (!goodsDetailsVos.isEmpty()) { |
|
|
|
for (GoodsDetailsVo goodsDetailsVo : goodsDetailsVos) { |
|
|
|
SmsGoodsDetailsVo smsGoodsDetailsVo = new SmsGoodsDetailsVo(); |
|
|
|
BeanUtil.copyProperties(goodsDetailsVo, smsGoodsDetailsVo); |
|
|
|
//查询已退数量
|
|
|
|
String goodsID = goodsDetailsVo.getGoodsID(); |
|
|
|
String sumBackCount = baseMapper.selBackCountByGoodsID(goodsID, sid); |
|
|
|
smsGoodsDetailsVo.setReturnedCount(sumBackCount); |
|
|
|
smsGoodsDetailsVos.add(smsGoodsDetailsVo); |
|
|
|
FmsReceivesettle receivesettle = fmsReceivesettleFeign.fetchBySourceSid(sourceBillSid).getData(); |
|
|
|
if (null != receivesettle) { |
|
|
|
vo.setSettleDate(DateUtil.formatDate(receivesettle.getSettleTime())); |
|
|
|
} |
|
|
|
List<SmsSitemVo> sitemVos = new ArrayList<>();// 维修项目
|
|
|
|
List<AsBusrepairBillSitem> sitems = asBusrepairBillFeign.fetchSitemByBillSid(sourceBillSid); |
|
|
|
if (!sitems.isEmpty()) { |
|
|
|
for (AsBusrepairBillSitem sitem : sitems) { |
|
|
|
SmsSalesReturnItem returnItem = smsSalesReturnItemService.selBySouceSidAndLinkSid(sourceBillSid,sitem.getSid()); |
|
|
|
if (null == returnItem) { |
|
|
|
SmsSitemVo sitemVo = new SmsSitemVo(); |
|
|
|
BeanUtil.copyProperties(sitem, sitemVo); |
|
|
|
sitemVo.setItemLinkSid(sitem.getSid()); |
|
|
|
List<AsBusrepairBillSitemRepairer> repairers = asBusrepairBillFeign.fetchSitemRepairerByBillSid(sourceBillSid, sitem.getServiceItemSid()); |
|
|
|
if (!repairers.isEmpty()) { |
|
|
|
List<String> staffList = new ArrayList<>(); //维修人员信息
|
|
|
|
List<String> staffNameList = new ArrayList<>(); //维修人员信息
|
|
|
|
for (AsBusrepairBillSitemRepairer repairer : repairers) { |
|
|
|
if (StringUtils.isNotBlank(repairer.getRepairerSid())) { |
|
|
|
staffList.add(repairer.getRepairerSid()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(repairer.getRepairerName())) { |
|
|
|
staffNameList.add(repairer.getRepairerName()); |
|
|
|
} |
|
|
|
} |
|
|
|
sitemVo.setStaffList(staffList); |
|
|
|
sitemVo.setStaffNameList(staffNameList); |
|
|
|
sitemVo.setRepairerName(String.join("、", staffNameList)); |
|
|
|
} |
|
|
|
sitemVos.add(sitemVo); |
|
|
|
} |
|
|
|
} |
|
|
|
vo.setGoodsDetailsVos(smsGoodsDetailsVos); |
|
|
|
vo.setSitemVos(sitemVos); |
|
|
|
} |
|
|
|
BigDecimal taxRate = BigDecimal.ZERO;//税率
|
|
|
|
boolean wxGoods = false; //维修领料是否为加税点项目
|
|
|
|
AsBusrepairBillInvoice invoice = asBusrepairBillFeign.fetchInvoiceBySid(sourceBillSid); |
|
|
|
if (null != invoice) { |
|
|
|
if (StringUtils.isNotBlank(invoice.getTaxItems())) { |
|
|
|
String taxItem = invoice.getTaxItems(); |
|
|
|
if (taxItem.contains("维修用料")) { |
|
|
|
wxGoods = true; |
|
|
|
} |
|
|
|
if (null != invoice.getTaxRate()) { |
|
|
|
taxRate = invoice.getTaxRate(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
List<SmsGoodsDetailsVo> goodsDetailsVos = new ArrayList<>(); //商品信息
|
|
|
|
List<AsBusrepairInventorybillDetail> goodsDetails = asBusrepairBillFeign.fetchGoodsByBillSid(sourceBillSid); |
|
|
|
if (!goodsDetails.isEmpty()) { |
|
|
|
DecimalFormat df2 =new DecimalFormat("#.00"); |
|
|
|
for (AsBusrepairInventorybillDetail goodsDetail : goodsDetails) { |
|
|
|
SmsGoodsDetailsVo goodsDetailsVo = new SmsGoodsDetailsVo(); |
|
|
|
BeanUtil.copyProperties(goodsDetail, goodsDetailsVo); |
|
|
|
String goodsLinkSid = goodsDetail.getSid(); |
|
|
|
goodsDetailsVo.setGoodsLinkSid(goodsLinkSid); |
|
|
|
BigDecimal constPrice = BigDecimal.ZERO; //销售价常量
|
|
|
|
BigDecimal count = BigDecimal.ZERO; //数量
|
|
|
|
if (null != goodsDetail.getCurrentCount()) { |
|
|
|
count = goodsDetail.getCurrentCount(); |
|
|
|
} |
|
|
|
goodsDetailsVo.setCount(String.valueOf(goodsDetail.getCurrentCount().intValue())); |
|
|
|
boolean isTaxRate = false; //进货价是否含税
|
|
|
|
SmsGoods smsGoods = smsGoodsService.fetchEntityByGoodsID(goodsDetail.getGoodsID()); |
|
|
|
if (null != smsGoods) { |
|
|
|
if (StringUtils.isNotBlank(smsGoods.getSupplierName())) { |
|
|
|
goodsDetailsVo.setBillObjName(smsGoods.getSupplierName()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (null != goodsDetail.getGoodsDetailsPrice()) { |
|
|
|
constPrice = goodsDetail.getGoodsDetailsPrice(); |
|
|
|
} |
|
|
|
if (goodsDetail.getIsTaxRate() != null) { |
|
|
|
if (goodsDetail.getIsTaxRate().intValue() == 1) { |
|
|
|
goodsDetailsVo.setPrice(constPrice.toString()); |
|
|
|
} else { |
|
|
|
if (wxGoods) { |
|
|
|
BigDecimal divide = taxRate.divide(new BigDecimal("100")); |
|
|
|
BigDecimal add = divide.add(new BigDecimal("1")); |
|
|
|
BigDecimal multiply = constPrice.multiply(add); |
|
|
|
goodsDetailsVo.setPrice(df2.format(multiply)); |
|
|
|
} else { |
|
|
|
goodsDetailsVo.setPrice(constPrice.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (wxGoods) { |
|
|
|
BigDecimal divide = taxRate.divide(new BigDecimal("100")); |
|
|
|
BigDecimal add = divide.add(new BigDecimal("1")); |
|
|
|
BigDecimal multiply = constPrice.multiply(add); |
|
|
|
goodsDetailsVo.setPrice(df2.format(multiply)); |
|
|
|
} else { |
|
|
|
goodsDetailsVo.setPrice(constPrice.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
String returnCount = smsSalesReturnDetailService.selSouceSidAndGoodLinkSid(sourceBillSid,goodsLinkSid); |
|
|
|
BigDecimal rCount = new BigDecimal(returnCount); |
|
|
|
goodsDetailsVo.setReturnedCount(returnCount); |
|
|
|
if (rCount.compareTo(count) < 0) { |
|
|
|
goodsDetailsVos.add(goodsDetailsVo); |
|
|
|
} |
|
|
|
} |
|
|
|
vo.setGoodsDetailsVos(goodsDetailsVos); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (type == 1) { |
|
|
|
//销售单
|
|
|
|
SmsSalesBillDetailsVo data = smsSalesBillService.fetchDetailsVoBySid(smsSalesReturn.getSourceBillSid()); |
|
|
|
SmsSalesBillDetailsVo data = smsSalesBillService.fetchDetailsVoBySid(sourceBillSid); |
|
|
|
if (null != data) { |
|
|
|
vo.setSourceBillNo(data.getBillNo()); |
|
|
|
vo.setBillType("销售单"); |
|
|
|
vo.setBillDate(data.getCreateTime()); |
|
|
|
if (null != data.getGoodsAmount()) { |
|
|
|
vo.setGoodsAmount(data.getGoodsAmount()); |
|
|
|
} |
|
|
|
if (null != data.getAddAmount()) { |
|
|
|
vo.setAddAmount(data.getAddAmount()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getSubject())) { |
|
|
|
vo.setSubject(data.getSubject()); |
|
|
|
} |
|
|
@ -749,6 +975,7 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
if (StringUtils.isNotBlank(data.getMobile())) { |
|
|
|
vo.setMobile(data.getMobile()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(data.getVehMark())) { |
|
|
|
vo.setVehMark(data.getVehMark()); |
|
|
|
} |
|
|
@ -765,12 +992,16 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
for (SalesGoodsVo goodsDetailsVo : goodsDetailsVos) { |
|
|
|
SmsGoodsDetailsVo smsGoodsDetailsVo = new SmsGoodsDetailsVo(); |
|
|
|
BeanUtil.copyProperties(goodsDetailsVo, smsGoodsDetailsVo); |
|
|
|
smsGoodsDetailsVo.setGoodsLinkSid(goodsDetailsVo.getSid()); |
|
|
|
String count = goodsDetailsVo.getCount(); |
|
|
|
BigDecimal totalCount = new BigDecimal(count); |
|
|
|
//查询已退数量
|
|
|
|
String goodsID = goodsDetailsVo.getGoodsID(); |
|
|
|
String sumBackCount = baseMapper.selBackCountByGoodsID(goodsID, sid); |
|
|
|
smsGoodsDetailsVo.setReturnedCount(sumBackCount); |
|
|
|
smsGoodsDetailsVos.add(smsGoodsDetailsVo); |
|
|
|
smsGoodsDetailsVos.add(smsGoodsDetailsVo); |
|
|
|
String returnCount = smsSalesReturnDetailService.selSouceSidAndGoodLinkSid(sourceBillSid,goodsDetailsVo.getSid()); |
|
|
|
BigDecimal rCount = new BigDecimal(returnCount); |
|
|
|
smsGoodsDetailsVo.setReturnedCount(returnCount); |
|
|
|
if (rCount.compareTo(totalCount) < 0) { |
|
|
|
smsGoodsDetailsVos.add(smsGoodsDetailsVo); |
|
|
|
} |
|
|
|
} |
|
|
|
vo.setGoodsDetailsVos(smsGoodsDetailsVos); |
|
|
|
} |
|
|
@ -786,6 +1017,25 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
} |
|
|
|
vo.setReturnGoods(returnGoods); |
|
|
|
} |
|
|
|
List<SmsSalesReturnItem> items = smsSalesReturnItemService.fetchByBillSid(sid); |
|
|
|
if (!items.isEmpty()) { |
|
|
|
List<SalesItemsReturnVo> returnSitemVos = new ArrayList<>(); //退货维修项目列表
|
|
|
|
for (SmsSalesReturnItem detail : items) { |
|
|
|
SalesItemsReturnVo returnVo = new SalesItemsReturnVo(); |
|
|
|
BeanUtil.copyProperties(detail, returnVo, "id", "sid"); |
|
|
|
String repairerSid = detail.getRepairerSid(); |
|
|
|
String repairerName = detail.getRepairerName(); |
|
|
|
String[] split = repairerSid.split(","); |
|
|
|
String[] split1 = repairerName.split(","); |
|
|
|
List<String> strsToList1= Arrays.asList(split); |
|
|
|
List<String> strsToList2= Arrays.asList(split1); |
|
|
|
returnVo.setStaffList(strsToList1); |
|
|
|
returnVo.setStaffNameList(strsToList2); |
|
|
|
returnSitemVos.add(returnVo); |
|
|
|
} |
|
|
|
vo.setReturnSitemVos(returnSitemVos); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return vo; |
|
|
|
} |
|
|
@ -801,6 +1051,9 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
for (String sid : sids) { |
|
|
|
smsSalesReturnDetailService.deleteByMainSid(sid); |
|
|
|
} |
|
|
|
for (String sid : sids) { |
|
|
|
smsSalesReturnItemService.deleteByMainSid(sid); |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
@ -823,6 +1076,11 @@ public class SmsSalesReturnService extends MybatisBaseService<SmsSalesReturnMapp |
|
|
|
} else { |
|
|
|
return rb.setMsg(resultBean.getMsg()); |
|
|
|
} |
|
|
|
String sourceBillSid = dto.getSourceBillSid(); |
|
|
|
int count = baseMapper.selectSubmitBySid(sourceBillSid); |
|
|
|
if (count > 0) { |
|
|
|
return rb.setMsg("所选单据为已经提交审批的数据,无法提交"); |
|
|
|
} |
|
|
|
smsSalesReturn = fetchBySid(businessSid); |
|
|
|
//创建BusinessVariables实体对象
|
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
|