|
|
@@ -1,71 +1,150 @@
|
|
|
package com.sckw.payment.service;
|
|
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.model.page.PageRes;
|
|
|
+import com.sckw.core.utils.BeanUtils;
|
|
|
+import com.sckw.core.utils.CollectionUtils;
|
|
|
+import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.payment.dao.KwpSettlementTradeMapper;
|
|
|
import com.sckw.payment.model.KwpSettlementTrade;
|
|
|
import com.sckw.payment.model.constant.SettlementEnum;
|
|
|
-import com.sckw.payment.model.dto.SettlementLogisticsDto;
|
|
|
+import com.sckw.payment.model.constant.TradeUnitType;
|
|
|
+import com.sckw.payment.model.dto.ISettlement;
|
|
|
+import com.sckw.payment.model.dto.SettlementPurchaseDto;
|
|
|
+import com.sckw.payment.model.dto.SettlementSellDto;
|
|
|
import com.sckw.payment.model.dto.SettlementTradeDto;
|
|
|
-import com.sckw.payment.model.dto.SettlementWalletDto;
|
|
|
import com.sckw.payment.model.vo.req.SettlementReq;
|
|
|
+import com.sckw.payment.model.vo.req.SettlementTradeReq;
|
|
|
import com.sckw.payment.model.vo.res.SettlementLogisticsStatusCountVo;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
+import com.sckw.payment.model.vo.res.SettlementSumVo;
|
|
|
+import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.system.api.model.dto.res.SysDictResDto;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* @author xucaiqin
|
|
|
* @date 2023-07-10 16:38:36
|
|
|
*/
|
|
|
@Service
|
|
|
-@AllArgsConstructor
|
|
|
public class KwpSettlementTradeService {
|
|
|
- private final KwpSettlementTradeMapper settlementTradeMapper;
|
|
|
+ @Resource
|
|
|
+ private KwpSettlementTradeMapper settlementTradeMapper;
|
|
|
+ @DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
+ private RemoteSystemService remoteSystemService;
|
|
|
+
|
|
|
+ public KwpSettlementTrade getById(Long id) {
|
|
|
+ return settlementTradeMapper.selectById(id);
|
|
|
+ }
|
|
|
|
|
|
public void save(KwpSettlementTrade kwpSettlementTrade) {
|
|
|
settlementTradeMapper.insert(kwpSettlementTrade);
|
|
|
}
|
|
|
|
|
|
- public PageRes<SettlementTradeDto> pageListCollection(SettlementReq settlementReq) {
|
|
|
-// //todo 查询缓存,获取客户企业id
|
|
|
-// String keywords = settlementReq.getKeywords();
|
|
|
-// if (StringUtils.isNotBlank(keywords)) {
|
|
|
-// System.out.println("关键之:" + keywords);
|
|
|
-// }
|
|
|
-// PageHelper.startPage(settlementReq.getPage(), settlementReq.getPageSize());
|
|
|
-//
|
|
|
-// List<SettlementLogisticsDto> kwpLedgerLogisticsList = settlementOfflineMapper.pageSelect(settlementReq);
|
|
|
-//
|
|
|
-// return new PageRes<>(new PageInfo<>(kwpLedgerLogisticsList));
|
|
|
+ private void changeDict(List<ISettlement> list) {
|
|
|
+ //字典等数据转换
|
|
|
+ Map<String, SysDictResDto> dictResDtoMap = remoteSystemService.queryDictMapByType(DictTypeEnum.TRADE_TYPE.getType());
|
|
|
+ for (ISettlement iSettlement : list) {
|
|
|
+ Integer trading = iSettlement.getTrading();
|
|
|
+ SysDictResDto sysDictResDto = dictResDtoMap.get(String.valueOf(trading));
|
|
|
+ if (Objects.nonNull(sysDictResDto)) {
|
|
|
+ iSettlement.setTradingLabel(sysDictResDto.getLabel());
|
|
|
+ }
|
|
|
+ iSettlement.setStatusLabel(SettlementEnum.getStatusDesc(iSettlement.getStatus()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public PageRes<ISettlement> pageListCollection(SettlementTradeReq settlementReq) {
|
|
|
+ settlementReq.setEntId(LoginUserHolder.getEntId());
|
|
|
+ PageHelper.startPage(settlementReq.getPage(), settlementReq.getPageSize());
|
|
|
+ List<SettlementTradeDto> kwpLedgerLogisticsList = settlementTradeMapper.pageSelect(settlementReq);
|
|
|
+ if (!CollectionUtils.isEmpty(kwpLedgerLogisticsList)) {
|
|
|
+ //根据企业类型进行对应的数据
|
|
|
+ if (Objects.equals(settlementReq.getUnitType(), TradeUnitType.PURCHASE)) {
|
|
|
+ List<SettlementPurchaseDto> list = kwpLedgerLogisticsList.stream().map(a -> {
|
|
|
+ SettlementPurchaseDto settlementSellDto = new SettlementPurchaseDto();
|
|
|
+ BeanUtils.copyProperties(a, settlementSellDto);
|
|
|
+ settlementSellDto.setActualPrice(settlementSellDto.changePrice(a.getActualPrice()));
|
|
|
+ settlementSellDto.setTotalPrice(settlementSellDto.changePrice(a.getTotalPrice()));
|
|
|
+ settlementSellDto.setWaitPrice(settlementSellDto.changePrice(a.getWaitPrice()));
|
|
|
+ return settlementSellDto;
|
|
|
+ }).toList();
|
|
|
+ List<ISettlement> ledgerShipperDto = new ArrayList<>(list);
|
|
|
+ changeDict(ledgerShipperDto);
|
|
|
+ return new PageRes<>(new PageInfo<>(ledgerShipperDto));
|
|
|
+ }
|
|
|
+ if (Objects.equals(settlementReq.getUnitType(), TradeUnitType.SELL)) {
|
|
|
+ List<SettlementSellDto> list = kwpLedgerLogisticsList.stream().map(a -> {
|
|
|
+ SettlementSellDto settlementSellDto = new SettlementSellDto();
|
|
|
+ BeanUtils.copyProperties(a, settlementSellDto);
|
|
|
+ settlementSellDto.setActualPrice(settlementSellDto.changePrice(a.getActualPrice()));
|
|
|
+ settlementSellDto.setTotalPrice(settlementSellDto.changePrice(a.getTotalPrice()));
|
|
|
+ settlementSellDto.setWaitPrice(settlementSellDto.changePrice(a.getWaitPrice()));
|
|
|
+ return settlementSellDto;
|
|
|
+ }).toList();
|
|
|
+ List<ISettlement> ledgerShipperDto = new ArrayList<>(list);
|
|
|
+ changeDict(ledgerShipperDto);
|
|
|
+ return new PageRes<>(new PageInfo<>(ledgerShipperDto));
|
|
|
+ }
|
|
|
+ }
|
|
|
return new PageRes<>(new PageInfo<>());
|
|
|
}
|
|
|
|
|
|
- public SettlementLogisticsStatusCountVo getCountListCollection(SettlementReq settlementReq) {
|
|
|
- SettlementLogisticsStatusCountVo settlementLogisticsStatusCountVos = new SettlementLogisticsStatusCountVo();
|
|
|
- //总
|
|
|
-// settlementReq.setStatus(null);
|
|
|
-// settlementLogisticsStatusCountVos.setAllCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
|
|
|
-//
|
|
|
-// //待结算
|
|
|
-// settlementReq.setStatus(SettlementEnum.WAITING_PAYMENT.getStatus());
|
|
|
-// settlementLogisticsStatusCountVos.setWaitingPaymentCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
|
|
|
-//
|
|
|
-// //部分结算
|
|
|
-// settlementReq.setStatus(SettlementEnum.PARTIAL_PAYMENT.getStatus());
|
|
|
-// settlementLogisticsStatusCountVos.setPartialPaymentCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
|
|
|
-//
|
|
|
-// //全部结算
|
|
|
-// settlementReq.setStatus(SettlementEnum.ALL_PAYMENT.getStatus());
|
|
|
-// settlementLogisticsStatusCountVos.setAllPaymentCount(settlementLogisticsMapper.getCountListCollection(settlementReq));
|
|
|
+ public SettlementLogisticsStatusCountVo getCount(SettlementTradeReq settlementReq) {
|
|
|
+ return settlementTradeMapper.countOrder(settlementReq);
|
|
|
+ }
|
|
|
|
|
|
- return settlementLogisticsStatusCountVos;
|
|
|
+ /**
|
|
|
+ * 表尾统计数据
|
|
|
+ *
|
|
|
+ * @param settlementReq
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public SettlementSumVo getCountListCollection(SettlementTradeReq settlementReq) {
|
|
|
+ return settlementTradeMapper.sumMoney(settlementReq);
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<SettlementTradeDto> selectList(List<Long> ids) {
|
|
|
- return null;
|
|
|
+ public List<ISettlement> selectList(List<Long> ids, int unitType) {
|
|
|
+ List<SettlementTradeDto> kwpSettlementTrades = settlementTradeMapper.selectByIds(ids);
|
|
|
+ if (!CollectionUtils.isEmpty(kwpSettlementTrades)) {
|
|
|
+ //根据企业类型进行对应的数据
|
|
|
+ if (unitType == TradeUnitType.PURCHASE) {
|
|
|
+ List<SettlementPurchaseDto> list = kwpSettlementTrades.stream().map(a -> {
|
|
|
+ SettlementPurchaseDto settlementSellDto = new SettlementPurchaseDto();
|
|
|
+ BeanUtils.copyProperties(a, settlementSellDto);
|
|
|
+ settlementSellDto.setActualPrice(settlementSellDto.changePrice(a.getActualPrice()));
|
|
|
+ settlementSellDto.setTotalPrice(settlementSellDto.changePrice(a.getTotalPrice()));
|
|
|
+ settlementSellDto.setWaitPrice(settlementSellDto.changePrice(a.getWaitPrice()));
|
|
|
+ return settlementSellDto;
|
|
|
+ }).toList();
|
|
|
+ List<ISettlement> ledgerShipperDto = new ArrayList<>(list);
|
|
|
+ changeDict(ledgerShipperDto);
|
|
|
+ return ledgerShipperDto;
|
|
|
+ }
|
|
|
+ if (unitType == TradeUnitType.SELL) {
|
|
|
+ List<SettlementSellDto> list = kwpSettlementTrades.stream().map(a -> {
|
|
|
+ SettlementSellDto settlementSellDto = new SettlementSellDto();
|
|
|
+ BeanUtils.copyProperties(a, settlementSellDto);
|
|
|
+ settlementSellDto.setActualPrice(settlementSellDto.changePrice(a.getActualPrice()));
|
|
|
+ settlementSellDto.setTotalPrice(settlementSellDto.changePrice(a.getTotalPrice()));
|
|
|
+ settlementSellDto.setWaitPrice(settlementSellDto.changePrice(a.getWaitPrice()));
|
|
|
+ return settlementSellDto;
|
|
|
+ }).toList();
|
|
|
+ List<ISettlement> ledgerShipperDto = new ArrayList<>(list);
|
|
|
+ changeDict(ledgerShipperDto);
|
|
|
+ return ledgerShipperDto;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
/**
|