ky 6 years ago
parent 04adca5e75
commit c14b0c2049

@ -27,18 +27,18 @@ public class PcInvoiceController {
@PostMapping("/pcDisableInvoiceList") @PostMapping("/pcDisableInvoiceList")
@ApiImplicitParam(name = "token", value = "token", required = true, dataType = "String", paramType = "header") @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "String", paramType = "header")
@ApiOperation(value = "待开票列表", notes = "待开票列表") @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(); return ResultBuilder.withPayload(invoiceList).build();
} }
@PostMapping("/pcEnableInvoiceList") @PostMapping("/pcEnableInvoiceList")
@ApiImplicitParam(name = "token", value = "token", required = true, dataType = "String", paramType = "header") @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "String", paramType = "header")
@ApiOperation(value = "已开票列表", notes = "已开票列表") @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(); return ResultBuilder.withPayload(invoiceList).build();
} }

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

Loading…
Cancel
Save