|
|
@ -26,21 +26,34 @@ |
|
|
|
package com.yxt.anrui.buscenter.biz.bussalesorderdeposit; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.anrui.buscenter.api.busdeposit.BusDeposit; |
|
|
|
import com.yxt.anrui.buscenter.api.busdepositfictitious.BusDepositFictitious; |
|
|
|
import com.yxt.anrui.buscenter.api.busmaindeposit.BusMainDeposit; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrder; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorderdeposit.BusSalesOrderDeposit; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorderdeposit.BusSalesOrderDepositDetailsVo; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorderdeposit.BusSalesOrderDepositDto; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorderdeposit.app.AppBusSalesOrderDepositListVo; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorderdeposit.app.AppBusSalesOrderDepositVo; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorderdeposit.app.*; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorderprice.BusSalesOrderPrice; |
|
|
|
import com.yxt.anrui.buscenter.biz.busdeposit.BusDepositService; |
|
|
|
import com.yxt.anrui.buscenter.biz.busdepositfictitious.BusDepositFictitiousService; |
|
|
|
import com.yxt.anrui.buscenter.biz.bussalesorder.BusSalesOrderService; |
|
|
|
import com.yxt.anrui.buscenter.biz.bussalesorderprice.BusSalesOrderPriceService; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserInfoVo; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
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 org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
@ -69,6 +82,10 @@ public class BusSalesOrderDepositService extends MybatisBaseService<BusSalesOrde |
|
|
|
private BusDepositFictitiousService busDepositFictitiousService; |
|
|
|
@Autowired |
|
|
|
private BusSalesOrderPriceService busSalesOrderPriceService; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private BusDepositService busDepositService; |
|
|
|
|
|
|
|
public String saveOrderDepo(BusSalesOrderDepositDto busSalesOrderDepositDto, String sid) { |
|
|
|
BusSalesOrderDeposit busSalesOrderDeposit = new BusSalesOrderDeposit(); |
|
|
@ -131,6 +148,12 @@ public class BusSalesOrderDepositService extends MybatisBaseService<BusSalesOrde |
|
|
|
String payPath = listVo.getPayPath(); |
|
|
|
List<String> stringList = Arrays.asList(payPath.split(",")); |
|
|
|
listVo.setEntrustImage(stringList); |
|
|
|
//根据销售订单
|
|
|
|
if (!busSalesOrder.getCustomerName().equals(listVo.getName())) { |
|
|
|
listVo.setShowImage(true); |
|
|
|
} else { |
|
|
|
listVo.setShowImage(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
vo.setVirtualOrderList(listVos); |
|
|
@ -140,4 +163,95 @@ public class BusSalesOrderDepositService extends MybatisBaseService<BusSalesOrde |
|
|
|
} |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public ResultBean saveDepositInfo(AppBusSalesOrderDepositDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String salesOrderSid = dto.getSalesOrderSid(); |
|
|
|
//查询销售订单是否存在
|
|
|
|
BusSalesOrder busSalesOrder = busSalesOrderService.fetchBySid(salesOrderSid); |
|
|
|
if (busSalesOrder == null) { |
|
|
|
return rb.setMsg("该销售订单单据不存在"); |
|
|
|
} |
|
|
|
BusSalesOrderDeposit busSalesOrderDeposit = baseMapper.selectByOrderSid(salesOrderSid); |
|
|
|
String depositSid = ""; |
|
|
|
if (busSalesOrderDeposit == null) { |
|
|
|
busSalesOrderDeposit = new BusSalesOrderDeposit(); |
|
|
|
BeanUtil.copyProperties(dto, busSalesOrderDeposit, "sid"); |
|
|
|
depositSid = busSalesOrderDeposit.getSid(); |
|
|
|
baseMapper.insert(busSalesOrderDeposit); |
|
|
|
} else { |
|
|
|
depositSid = busSalesOrderDeposit.getSid(); |
|
|
|
BeanUtil.copyProperties(dto, busSalesOrderDeposit, "sid"); |
|
|
|
baseMapper.updateById(busSalesOrderDeposit); |
|
|
|
} |
|
|
|
List<AppBusSalesOrderDepositListVo> list = busDepositFictitiousService.getList(depositSid); |
|
|
|
list.parallelStream().filter(Objects::nonNull).collect(Collectors.toList()); |
|
|
|
if (list.size() > 0) { |
|
|
|
busDepositFictitiousService.deleteByDepositSid(depositSid); |
|
|
|
} |
|
|
|
//若缴纳方式为订金结转
|
|
|
|
if ("02".equals(dto.getDepositTypeKey())) { |
|
|
|
List<AppBusSalesOrderDepositListDto> listVos = dto.getVirtualOrderList(); |
|
|
|
listVos.parallelStream().filter(Objects::nonNull).collect(Collectors.toList()); |
|
|
|
for (AppBusSalesOrderDepositListDto listDto : listVos) { |
|
|
|
//查询付款人是否和客户一样
|
|
|
|
BusDeposit busDeposit = busDepositService.selectByBillSid(listDto.getDepositBillSid()); |
|
|
|
if (!busSalesOrder.getCustomerName().equals(busDeposit.getDraweeName())) { |
|
|
|
if (listDto.getEntrustImage().isEmpty()) { |
|
|
|
return rb.setMsg("选择的虚拟订金单中有付款人与该客户不一致,请上传款项支付委托书"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
BusDepositFictitious busDepositFictitious = new BusDepositFictitious(); |
|
|
|
BeanUtil.copyProperties(listDto, busDepositFictitious, "sid"); |
|
|
|
busDepositFictitious.setDepositSid(depositSid); |
|
|
|
busDepositFictitious.setPayPath(StringUtils.join(listDto.getEntrustImage(), ",")); |
|
|
|
busDepositFictitiousService.save(busDepositFictitious); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setMsg("保存成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<AppDepositListVo> getDepositList(PagerQuery<AppDepositListQuery> pagerQuery) { |
|
|
|
AppDepositListQuery query = pagerQuery.getParams(); |
|
|
|
QueryWrapper<BusMainDeposit> qw = createDepositPageWrapper(query); |
|
|
|
IPage<BusMainDeposit> page = PagerUtil.queryToPage(pagerQuery); |
|
|
|
IPage<AppDepositListVo> pagging = baseMapper.getDepositList(page, qw, query.getName()); |
|
|
|
List<AppDepositListVo> list = pagging.getRecords(); |
|
|
|
list.parallelStream().filter(Objects::nonNull).collect(Collectors.toList()); |
|
|
|
if (!list.isEmpty()) { |
|
|
|
for (AppDepositListVo vo : list) { |
|
|
|
String deposit = vo.getDeposit(); |
|
|
|
String useDeposit = vo.getUsePeposit(); |
|
|
|
if (StringUtils.isNotBlank(deposit)) { |
|
|
|
if (StringUtils.isNotBlank(useDeposit)) { |
|
|
|
vo.setRemainderMoney((new BigDecimal(deposit).subtract(new BigDecimal(useDeposit))).toString()); |
|
|
|
} else { |
|
|
|
vo.setRemainderMoney(deposit); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
PagerVo<AppDepositListVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<BusMainDeposit> createDepositPageWrapper(AppDepositListQuery query) { |
|
|
|
QueryWrapper<BusMainDeposit> qw = new QueryWrapper<>(); |
|
|
|
if (query != null) { |
|
|
|
if (query.getSidList().size() > 0) { |
|
|
|
qw.notIn("bmd.sid", query.getSidList()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getUserSid())) { |
|
|
|
ResultBean<SysUserInfoVo> resultBean = sysUserFeign.selectUserInfoByUserSid(query.getUserSid()); |
|
|
|
if (resultBean.getSuccess()) { |
|
|
|
qw.eq("bd.staffSid", resultBean.getData().getStaffSid()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
qw.eq("bd.state", 1); |
|
|
|
qw.eq("bmd.depositBillTypeKey", "01"); |
|
|
|
return qw; |
|
|
|
} |
|
|
|
} |