增加查看计费历史记录
This commit is contained in:
@@ -22,9 +22,12 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.bms.common.annotation.Log;
|
||||
import com.bms.common.constant.HttpStatus;
|
||||
import com.bms.common.core.controller.BaseController;
|
||||
import com.bms.common.core.domain.AjaxResult;
|
||||
import com.bms.common.core.page.PageDomain;
|
||||
import com.bms.common.core.page.TableDataInfo;
|
||||
import com.bms.common.core.page.TableSupport;
|
||||
import com.bms.common.enums.BusinessType;
|
||||
import com.bms.common.utils.DateUtils;
|
||||
import com.bms.common.utils.MessageUtils;
|
||||
@@ -54,6 +57,11 @@ import com.bms.price.domain.vo.TmsPriceQuoteRequest;
|
||||
import com.bms.price.domain.vo.TmsPriceQuoteResult;
|
||||
import com.bms.price.enums.BillTaskSuccessStatus;
|
||||
import com.bms.price.enums.BillTaskType;
|
||||
import com.bms.price.search.BillSearchPage;
|
||||
import com.bms.price.search.BillSyncSnapshot;
|
||||
import com.bms.price.search.EsBizLogSupport;
|
||||
import com.bms.price.search.EsLogType;
|
||||
import com.bms.price.search.IBillSearchStore;
|
||||
import com.bms.price.service.IPrcBillingTaskService;
|
||||
import com.bms.price.service.IPrcOrderBillService;
|
||||
import com.bms.price.service.ITmsPriceQuoteService;
|
||||
@@ -84,6 +92,9 @@ public class BillingController extends BaseController
|
||||
@Autowired
|
||||
private OrderBillProductCheckService orderBillProductCheckService;
|
||||
|
||||
@Autowired
|
||||
private IBillSearchStore billSearchStore;
|
||||
|
||||
/**
|
||||
* Historical quote list.
|
||||
*/
|
||||
@@ -355,6 +366,97 @@ public class BillingController extends BaseController
|
||||
return success(prcOrderBillService.getBill(billId));
|
||||
}
|
||||
|
||||
/**
|
||||
* ES BILL logs for this order (billing / upstream sync / fail snapshots).
|
||||
* bizId prefers transferNo then orderNo (same as write path).
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:bill') or @ss.hasPermi('price:orderBill:list')")
|
||||
@GetMapping("/bill/{billId}/history")
|
||||
public TableDataInfo billHistory(@PathVariable("billId") String billId)
|
||||
{
|
||||
if (StringUtils.isEmpty(billId))
|
||||
{
|
||||
return getDataTable(new ArrayList<BillSyncSnapshot>());
|
||||
}
|
||||
TmsPriceQuoteResult bill = prcOrderBillService.getBill(billId.trim());
|
||||
if (bill == null)
|
||||
{
|
||||
TableDataInfo empty = new TableDataInfo();
|
||||
empty.setCode(HttpStatus.SUCCESS);
|
||||
empty.setMsg("查询成功");
|
||||
empty.setRows(new ArrayList<BillSyncSnapshot>());
|
||||
empty.setTotal(0L);
|
||||
return empty;
|
||||
}
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
int pageNum = pageDomain.getPageNum() == null ? 1 : pageDomain.getPageNum().intValue();
|
||||
int pageSize = pageDomain.getPageSize() == null ? 10 : pageDomain.getPageSize().intValue();
|
||||
String primary = EsBizLogSupport.billBizId(bill.getTransferNo(), bill.getOrderNo());
|
||||
BillSearchPage page = billSearchStore.search(EsLogType.BILL, primary, null, pageNum, pageSize);
|
||||
// Also pull by orderNo when transferNo was used as bizId, so older orderNo-keyed rows appear.
|
||||
if (StringUtils.isNotEmpty(bill.getTransferNo()) && StringUtils.isNotEmpty(bill.getOrderNo())
|
||||
&& !bill.getTransferNo().trim().equalsIgnoreCase(bill.getOrderNo().trim())
|
||||
&& pageNum == 1)
|
||||
{
|
||||
BillSearchPage byOrder = billSearchStore.search(EsLogType.BILL, bill.getOrderNo().trim(), null, 1,
|
||||
Math.max(pageSize, 50));
|
||||
page = mergeBillHistory(page, byOrder, pageSize);
|
||||
}
|
||||
TableDataInfo rsp = new TableDataInfo();
|
||||
rsp.setCode(HttpStatus.SUCCESS);
|
||||
rsp.setMsg("查询成功");
|
||||
rsp.setRows(page.getRows());
|
||||
rsp.setTotal(page.getTotal());
|
||||
return rsp;
|
||||
}
|
||||
|
||||
private BillSearchPage mergeBillHistory(BillSearchPage primary, BillSearchPage secondary, int pageSize)
|
||||
{
|
||||
BillSearchPage out = new BillSearchPage();
|
||||
Map<String, BillSyncSnapshot> byId = new HashMap<String, BillSyncSnapshot>();
|
||||
if (primary != null && primary.getRows() != null)
|
||||
{
|
||||
for (BillSyncSnapshot row : primary.getRows())
|
||||
{
|
||||
if (row != null && StringUtils.isNotEmpty(row.getDocId()))
|
||||
{
|
||||
byId.put(row.getDocId(), row);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (secondary != null && secondary.getRows() != null)
|
||||
{
|
||||
for (BillSyncSnapshot row : secondary.getRows())
|
||||
{
|
||||
if (row != null && StringUtils.isNotEmpty(row.getDocId()) && !byId.containsKey(row.getDocId()))
|
||||
{
|
||||
byId.put(row.getDocId(), row);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<BillSyncSnapshot> merged = new ArrayList<BillSyncSnapshot>(byId.values());
|
||||
merged.sort((a, b) -> {
|
||||
String ta = a == null || a.getUpdateTime() == null ? "" : a.getUpdateTime();
|
||||
String tb = b == null || b.getUpdateTime() == null ? "" : b.getUpdateTime();
|
||||
return tb.compareTo(ta);
|
||||
});
|
||||
long total = Math.max(primary == null ? 0L : primary.getTotal(), merged.size());
|
||||
if (secondary != null)
|
||||
{
|
||||
total = Math.max(total, secondary.getTotal());
|
||||
}
|
||||
out.setTotal(total);
|
||||
if (merged.size() > pageSize)
|
||||
{
|
||||
out.setRows(new ArrayList<BillSyncSnapshot>(merged.subList(0, pageSize)));
|
||||
}
|
||||
else
|
||||
{
|
||||
out.setRows(merged);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund one receivable bill via billing task billType=REFUND.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user