diff --git a/src/main/java/com/gszc/controller/PcInvoiceController.java b/src/main/java/com/gszc/controller/PcInvoiceController.java index 3b89a04..0afbce9 100644 --- a/src/main/java/com/gszc/controller/PcInvoiceController.java +++ b/src/main/java/com/gszc/controller/PcInvoiceController.java @@ -27,18 +27,18 @@ public class PcInvoiceController { @PostMapping("/pcDisableInvoiceList") @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "String", paramType = "header") @ApiOperation(value = "待开票列表", notes = "待开票列表") - public Result pcDisableInvoiceList(Integer pageNum,Integer pageSize) { + public Result pcDisableInvoiceList(Integer pageNum,Integer pageSize,String copycatId) { - JSONObject invoiceList = invoiceService.pcDisableInvoiceList(pageNum,pageSize); + JSONObject invoiceList = invoiceService.pcDisableInvoiceList(pageNum,pageSize,copycatId); return ResultBuilder.withPayload(invoiceList).build(); } @PostMapping("/pcEnableInvoiceList") @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "String", paramType = "header") @ApiOperation(value = "已开票列表", notes = "已开票列表") - public Result pcEnableInvoiceList(Integer pageNum,Integer pageSize) { + public Result pcEnableInvoiceList(Integer pageNum,Integer pageSize,String copycatId) { - JSONObject invoiceList = invoiceService.pcEnableInvoiceList(pageNum,pageSize); + JSONObject invoiceList = invoiceService.pcEnableInvoiceList(pageNum,pageSize,copycatId); return ResultBuilder.withPayload(invoiceList).build(); } diff --git a/src/main/java/com/gszc/service/impl/InvoiceServiceImpl.java b/src/main/java/com/gszc/service/impl/InvoiceServiceImpl.java index 2b80d39..7eccb70 100644 --- a/src/main/java/com/gszc/service/impl/InvoiceServiceImpl.java +++ b/src/main/java/com/gszc/service/impl/InvoiceServiceImpl.java @@ -26,10 +26,11 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.UUID; +import java.util.stream.Collectors; /** *

- * 服务实现类 + * 服务实现类 *

* * @author ky @@ -54,7 +55,7 @@ public class InvoiceServiceImpl extends ServiceImpl impl @Autowired CountService countService; - public void addInvoice(Invoice invoice){ + public void addInvoice(Invoice invoice) { String id = Uuid8Utils.generateShortUUID(); invoice.setId(id); invoice.setStatusCode("disable"); @@ -78,20 +79,20 @@ public class InvoiceServiceImpl extends ServiceImpl impl invoiceMapper.insert(invoice); } - public List invoiceList(String userId,String type){ + public List invoiceList(String userId, String type) { List list = new ArrayList<>(); - JSONArray customs = customService.customList(userId,null); - for(int i = 0;i customId = new EntityWrapper().eq("custom_id", customs.getJSONObject(i).getJSONObject("custom").getString("id")); - if(null==type){ + if (null == type) { - }else if(type.equals("disable")){ - customId.eq("status_code","disable"); - }else if(type.equals("enable")){ - customId.eq("status_code","enable"); + } else if (type.equals("disable")) { + customId.eq("status_code", "disable"); + } else if (type.equals("enable")) { + customId.eq("status_code", "enable"); } List invoiceList = invoiceMapper.selectList(customId); - for(Invoice invoice:invoiceList){ + for (Invoice invoice : invoiceList) { invoice.setCustomName(customs.getJSONObject(i).getJSONObject("custom").getString("companyName")); invoice.setCustomType(customs.getJSONObject(i).getJSONObject("custom").getString("registerType")); String invoiceHeaderId = invoice.getInvoiceHeaderId(); @@ -100,32 +101,32 @@ public class InvoiceServiceImpl extends ServiceImpl impl invoice.setInvoiceHeaderName(invoiceHeader.getCompanyName()); invoice.setTaxCode(invoiceHeader.getTaxCode()); } - if(invoiceList.size()>0){ + if (invoiceList.size() > 0) { list.addAll(invoiceList); } } return list; } - public JSONObject invoiceDetail(String invoiceId){ + public JSONObject invoiceDetail(String invoiceId) { JSONObject jsonObject = new JSONObject(); Invoice invoice = invoiceMapper.selectById(invoiceId); String customId = invoice.getCustomId(); Custom custom = customMapper.selectById(customId); invoice.setCustomName(custom.getCompanyName()); InvoiceHeader invoiceHeader = invoiceHeaderMapper.selectById(invoice.getInvoiceHeaderId()); - jsonObject.put("invoice",invoice); - jsonObject.put("invoiceHeader",invoiceHeader); + jsonObject.put("invoice", invoice); + jsonObject.put("invoiceHeader", invoiceHeader); return jsonObject; } - public List invoiceHeaderList(String userId){ + public List invoiceHeaderList(String userId) { List invoiceHeaderList = invoiceHeaderMapper.selectList(new EntityWrapper().eq("mini_user_id", userId)); return invoiceHeaderList; } - public void addInvoiceHeader(InvoiceHeader invoiceHeader){ + public void addInvoiceHeader(InvoiceHeader invoiceHeader) { String uuid = UUID.randomUUID().toString(); invoiceHeader.setId(uuid); invoiceHeader.setCreateDate(new Date()); @@ -133,29 +134,43 @@ public class InvoiceServiceImpl extends ServiceImpl impl invoiceHeaderMapper.insert(invoiceHeader); } - public void updateInvoiceHeader(InvoiceHeader invoiceHeader){ + public void updateInvoiceHeader(InvoiceHeader invoiceHeader) { invoiceHeader.setModifyDate(new Date()); invoiceHeaderMapper.updateById(invoiceHeader); } - public void deleteInvoiceHeader(String invoiceHeaderId){ + public void deleteInvoiceHeader(String invoiceHeaderId) { - if(invoiceMapper.selectCount(new EntityWrapper().eq("invoice_header_id", invoiceHeaderId))>0){ + if (invoiceMapper.selectCount(new EntityWrapper().eq("invoice_header_id", invoiceHeaderId)) > 0) { throw new RuntimeException("抬头已被使用"); } invoiceHeaderMapper.deleteById(invoiceHeaderId); } - public InvoiceHeader invoiceHeaderDetail(String invoiceHeaderId){ + public InvoiceHeader invoiceHeaderDetail(String invoiceHeaderId) { InvoiceHeader invoiceHeader = invoiceHeaderMapper.selectById(invoiceHeaderId); return invoiceHeader; } - public JSONObject pcDisableInvoiceList(Integer pageNum,Integer pageSize){ - Integer count = invoiceMapper.selectCount(new EntityWrapper().eq("status_code", "disable")); - List invoiceList = invoiceMapper.selectPage(new RowBounds((pageNum-1)*pageSize,pageSize),new EntityWrapper().eq("status_code", "disable").orderBy("create_date",false)); + public JSONObject pcDisableInvoiceList(Integer pageNum, Integer pageSize, String copycatId) { + + Integer count = null; + List invoiceList; + + if (null == copycatId) { + count = invoiceMapper.selectCount(new EntityWrapper().eq("status_code", "disable")); + invoiceList = invoiceMapper.selectPage(new RowBounds((pageNum - 1) * pageSize, pageSize), new EntityWrapper().eq("status_code", "disable").orderBy("create_date", false)); + } else { + List customList = customMapper.selectList(new EntityWrapper().eq("copycat_id", copycatId)); + count = invoiceMapper.selectCount(new EntityWrapper().eq("status_code", "disable").in("custom_id", customList.stream().map(item -> + item.getId() + ).collect(Collectors.toList()))); + invoiceList = invoiceMapper.selectPage(new RowBounds((pageNum - 1) * pageSize, pageSize), new EntityWrapper().eq("status_code", "disable").in("custom_id", customList.stream().map(item -> + item.getId() + ).collect(Collectors.toList())).orderBy("create_date", false)); + } - for(Invoice invoice :invoiceList){ + for (Invoice invoice : invoiceList) { String invoiceHeaderId = invoice.getInvoiceHeaderId(); String customId = invoice.getCustomId(); Custom custom = customMapper.selectById(customId); @@ -164,15 +179,28 @@ public class InvoiceServiceImpl extends ServiceImpl impl invoice.setInvoiceHeaderName(invoiceHeader.getCompanyName()); } JSONObject jsonObject = new JSONObject(); - jsonObject.put("count",count); - jsonObject.put("invoiceList",invoiceList); + jsonObject.put("count", count); + jsonObject.put("invoiceList", invoiceList); return jsonObject; } - public JSONObject pcEnableInvoiceList(Integer pageNum,Integer pageSize){ - Integer count = invoiceMapper.selectCount(new EntityWrapper().eq("status_code", "enable")); - List invoiceList = invoiceMapper.selectPage(new RowBounds((pageNum-1)*pageSize,pageSize),new EntityWrapper().eq("status_code", "enable").orderBy("create_date",false)); - for(Invoice invoice :invoiceList){ + public JSONObject pcEnableInvoiceList(Integer pageNum, Integer pageSize, String copycatId) { + Integer count = null; + List invoiceList; + + if (null == copycatId) { + count = invoiceMapper.selectCount(new EntityWrapper().eq("status_code", "enable")); + invoiceList = invoiceMapper.selectPage(new RowBounds((pageNum - 1) * pageSize, pageSize), new EntityWrapper().eq("status_code", "enable").orderBy("create_date", false)); + } else { + List customList = customMapper.selectList(new EntityWrapper().eq("copycat_id", copycatId)); + count = invoiceMapper.selectCount(new EntityWrapper().eq("status_code", "enable").in("custom_id", customList.stream().map(item -> + item.getId() + ).collect(Collectors.toList()))); + invoiceList = invoiceMapper.selectPage(new RowBounds((pageNum - 1) * pageSize, pageSize), new EntityWrapper().eq("status_code", "enable").in("custom_id", customList.stream().map(item -> + item.getId() + ).collect(Collectors.toList())).orderBy("create_date", false)); + } + for (Invoice invoice : invoiceList) { String invoiceHeaderId = invoice.getInvoiceHeaderId(); String customId = invoice.getCustomId(); Custom custom = customMapper.selectById(customId); @@ -181,12 +209,12 @@ public class InvoiceServiceImpl extends ServiceImpl impl invoice.setInvoiceHeaderName(invoiceHeader.getCompanyName()); } JSONObject jsonObject = new JSONObject(); - jsonObject.put("count",count); - jsonObject.put("invoiceList",invoiceList); + jsonObject.put("count", count); + jsonObject.put("invoiceList", invoiceList); return jsonObject; } - public void invoiceConfirm(String invoiceId,String trackingCompany,String trackingCode,String trackingImg){ + public void invoiceConfirm(String invoiceId, String trackingCompany, String trackingCode, String trackingImg) { Invoice invoice = new Invoice(); invoice.setId(invoiceId); invoice.setStatusCode("enable"); @@ -198,13 +226,13 @@ public class InvoiceServiceImpl extends ServiceImpl impl invoiceMapper.updateById(invoice); } - public JSONObject trackingDetail(String trackingCompany,String trackingCode){ + public JSONObject trackingDetail(String trackingCompany, String trackingCode) { KdniaoTrackQueryAPI api = new KdniaoTrackQueryAPI(); JSONObject orderTracesByJson = new JSONObject(); try { - String orderTracesByJsonString = api.getOrderTracesByJson(trackingCompany, trackingCode); - orderTracesByJson = JSONObject.parseObject(orderTracesByJsonString); + String orderTracesByJsonString = api.getOrderTracesByJson(trackingCompany, trackingCode); + orderTracesByJson = JSONObject.parseObject(orderTracesByJsonString); } catch (Exception e) { e.printStackTrace(); return orderTracesByJson;