|
|
@ -2590,6 +2590,175 @@ public class AsBillSettelApplyService extends MybatisBaseService<AsBillSettelApp |
|
|
|
} |
|
|
|
|
|
|
|
public AsBillSettelApplyDetailsVo salesbillInit(String sid, String userSid, String orgPath) { |
|
|
|
return null; |
|
|
|
AsBillSettelApplyDetailsVo vo = new AsBillSettelApplyDetailsVo(); |
|
|
|
//新增初始化
|
|
|
|
//维修工单
|
|
|
|
//销售单
|
|
|
|
//维修工单
|
|
|
|
SmsSalesBillDetailsVo data = smsSalesBillFeign.fetchDetailsBySid(sid).getData(); |
|
|
|
if (null != data) { |
|
|
|
vo.setSourceBillDate(data.getCreateTime()); |
|
|
|
if (StringUtils.isNotBlank(data.getSalesName())) { |
|
|
|
vo.setWaitorName(data.getSalesName()); |
|
|
|
} |
|
|
|
vo.setBillType("销售单"); |
|
|
|
vo.setSubject(data.getSubject()); |
|
|
|
if (StringUtils.isNotBlank(data.getMobile())) { |
|
|
|
vo.setMobile(data.getMobile()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getVinNo())) { |
|
|
|
vo.setVinNo(data.getVinNo()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getVehMark())) { |
|
|
|
vo.setVehMark(data.getVehMark()); |
|
|
|
} |
|
|
|
SalesInvoiceVo invoiceVo = data.getInvoiceVo(); |
|
|
|
if (null != invoiceVo) { |
|
|
|
if (StringUtils.isNotBlank(invoiceVo.getIsInvoicing())) { |
|
|
|
vo.setIsInvoicing(invoiceVo.getIsInvoicing()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(invoiceVo.getTaxRate())) { |
|
|
|
vo.setTaxRate(invoiceVo.getTaxRate()); |
|
|
|
} |
|
|
|
} |
|
|
|
BigDecimal costAmount = BigDecimal.ZERO;//成本合计
|
|
|
|
BigDecimal profit = BigDecimal.ZERO;//总利润额
|
|
|
|
BigDecimal outAmount = BigDecimal.ZERO;//外出费
|
|
|
|
BigDecimal subsidyAmount = BigDecimal.ZERO;//厂家补助
|
|
|
|
BigDecimal rescueAmount = BigDecimal.ZERO;//施救费
|
|
|
|
BigDecimal outKPAmount = BigDecimal.ZERO;//外出费KP
|
|
|
|
BigDecimal subsidyKPAmount = BigDecimal.ZERO;//厂家补助KP
|
|
|
|
BigDecimal rescueKPAmount = BigDecimal.ZERO;//施救费KP
|
|
|
|
// BigDecimal sitemProfit = BigDecimal.ZERO;//维修项目利润
|
|
|
|
// BigDecimal goodsProfit = BigDecimal.ZERO;//维修用料利润
|
|
|
|
// BigDecimal otherProfit = BigDecimal.ZERO;//附件项目利润
|
|
|
|
// BigDecimal addProfit = BigDecimal.ZERO;//其他附加项目利润
|
|
|
|
if (StringUtils.isNotBlank(data.getGoodsAmount())) { |
|
|
|
vo.setGoodsAmount(data.getGoodsAmount()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getAddAmount())) { |
|
|
|
vo.setAddAmount(data.getAddAmount()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(data.getDiscountAmount())) { |
|
|
|
vo.setDiscountAmount(data.getDiscountAmount()); |
|
|
|
} |
|
|
|
List<SalesGoodsVo> goodsDetailsVos = data.getGoodsVos(); |
|
|
|
if (!goodsDetailsVos.isEmpty()) { |
|
|
|
List<SettleGoodsDetailsVo> goodsList = new ArrayList<>(); |
|
|
|
for (SalesGoodsVo g : goodsDetailsVos) { |
|
|
|
SettleGoodsDetailsVo v = new SettleGoodsDetailsVo(); |
|
|
|
BeanUtil.copyProperties(g, v); |
|
|
|
BigDecimal yingshou = BigDecimal.ZERO; //应收
|
|
|
|
BigDecimal youhui = BigDecimal.ZERO; //优惠
|
|
|
|
BigDecimal jiesuan = BigDecimal.ZERO; //结算
|
|
|
|
BigDecimal chengben = BigDecimal.ZERO; //成本
|
|
|
|
BigDecimal chengbenPrice = BigDecimal.ZERO; //成本单价
|
|
|
|
BigDecimal lirun = BigDecimal.ZERO; //利润
|
|
|
|
BigDecimal count = BigDecimal.ZERO; //数量
|
|
|
|
if (StringUtils.isNotBlank(g.getCount())) { |
|
|
|
count = new BigDecimal(g.getCount()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(g.getPrice())) { |
|
|
|
BigDecimal price = new BigDecimal(g.getPrice()); |
|
|
|
yingshou = price.multiply(count); |
|
|
|
v.setGoodsReceivableAmount(yingshou.toString()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(g.getDiscountAmount())) { |
|
|
|
youhui = new BigDecimal(g.getDiscountAmount()); |
|
|
|
} |
|
|
|
jiesuan = yingshou.subtract(youhui); |
|
|
|
v.setGoodsSettleAmount(jiesuan.toString()); |
|
|
|
//求成本
|
|
|
|
if (StringUtils.isNotBlank(g.getInventorySid())) { |
|
|
|
String inventorySid = g.getInventorySid(); |
|
|
|
WmsInventory inventory = wmsInventoryFeign.fetchEntityBySid(inventorySid).getData(); |
|
|
|
if (null != inventory) { |
|
|
|
if (null != inventory.getCost()) { |
|
|
|
chengbenPrice = inventory.getCost(); |
|
|
|
chengben = chengbenPrice.multiply(count); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
v.setGoodsCost(chengben.toString()); |
|
|
|
lirun = jiesuan.subtract(chengben); |
|
|
|
v.setGoodsPrint(lirun.toString()); |
|
|
|
costAmount = costAmount.add(chengben); |
|
|
|
profit = profit.add(lirun); |
|
|
|
goodsList.add(v); |
|
|
|
} |
|
|
|
vo.setGoodsDetailsVos(goodsList); |
|
|
|
} |
|
|
|
List<SmsAttachitemVo> aitemVos = data.getAitemVos(); |
|
|
|
if (!aitemVos.isEmpty()) { |
|
|
|
List<SettleAitemVo> aitemVoList = new ArrayList<>(); |
|
|
|
for (SmsAttachitemVo a : aitemVos) { |
|
|
|
SettleAitemVo v = new SettleAitemVo(); |
|
|
|
BeanUtil.copyProperties(a, v); |
|
|
|
BigDecimal yingshou = BigDecimal.ZERO; //应收
|
|
|
|
BigDecimal chengben = BigDecimal.ZERO; //成本
|
|
|
|
BigDecimal lirun = BigDecimal.ZERO; //利润
|
|
|
|
if (StringUtils.isNotBlank(a.getPrice())) { |
|
|
|
yingshou = new BigDecimal(a.getPrice()); |
|
|
|
v.setAitemReceivableAmount(yingshou.toString()); |
|
|
|
} |
|
|
|
//求成本
|
|
|
|
if (StringUtils.isNotBlank(a.getAitemsid())) { |
|
|
|
String aitemsid = a.getAitemsid(); |
|
|
|
AsServiceAttachItem attachItem = asServiceAttachItemService.fetchBySid(aitemsid); |
|
|
|
if (null != attachItem) { |
|
|
|
if (null != attachItem.getCost()) { |
|
|
|
chengben = attachItem.getCost(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
v.setAitemCost(chengben.toString()); |
|
|
|
lirun = yingshou.subtract(chengben); |
|
|
|
v.setAitemPrint(lirun.toString()); |
|
|
|
costAmount = costAmount.add(chengben); |
|
|
|
profit = profit.add(lirun); |
|
|
|
aitemVoList.add(v); |
|
|
|
} |
|
|
|
vo.setAitemVos(aitemVoList); |
|
|
|
} |
|
|
|
vo.setProfit(profit.toString()); |
|
|
|
vo.setCostAmount(costAmount.toString()); |
|
|
|
} |
|
|
|
//根据用户查询发起人、发起部门、发起日期为当前日期
|
|
|
|
String deptName = ""; |
|
|
|
String deptSid = ""; |
|
|
|
String useOrgSid = ""; |
|
|
|
if (StringUtils.isNotBlank(orgPath)) { |
|
|
|
List<String> split = Arrays.asList(orgPath.split("/")); |
|
|
|
if (split.size() > 1) { |
|
|
|
//获取本级sid获取本级部门信息
|
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(split.size() - 2)).getData(); |
|
|
|
SysOrganizationVo sysOrganization1 = sysOrganizationFeign.fetchBySid(split.get(split.size() - 1)).getData(); |
|
|
|
deptName = sysOrganization.getName() + "/" + sysOrganization1.getName(); |
|
|
|
deptName = sysOrganization1.getName(); |
|
|
|
deptSid = sysOrganization1.getSid(); |
|
|
|
} else { |
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(0)).getData(); |
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
deptName = sysOrganization.getName(); |
|
|
|
deptSid = sysOrganization.getSid(); |
|
|
|
} |
|
|
|
useOrgSid = sysStaffOrgFeign.getOrgSidByPath(orgPath).getData(); |
|
|
|
} |
|
|
|
//创建组织使用组织
|
|
|
|
ResultBean<SysOrganizationVo> organizationResultBean = sysOrganizationFeign.fetchBySid(useOrgSid); |
|
|
|
if (organizationResultBean.getData() != null) { |
|
|
|
vo.setUseOrgName(organizationResultBean.getData().getName()); |
|
|
|
} |
|
|
|
//根据用户sid查询人员姓名
|
|
|
|
ResultBean<SysUserVo> userVoResultBean = sysUserFeign.fetchBySid(userSid); |
|
|
|
vo.setDept(deptName); |
|
|
|
vo.setDeptSid(deptSid); |
|
|
|
vo.setCreateByName(userVoResultBean.getData().getName()); |
|
|
|
vo.setApplyDate(DateUtil.today()); |
|
|
|
vo.setOrgPath(orgPath); |
|
|
|
vo.setCreateBySid(userSid); |
|
|
|
vo.setUseOrgSid(useOrgSid); |
|
|
|
vo.setSourceBillType("0"); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
} |
|
|
|