|
|
|
@ -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;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>
|
|
|
|
|
* 服务实现类
|
|
|
|
|
* 服务实现类
|
|
|
|
|
* </p>
|
|
|
|
|
*
|
|
|
|
|
* @author ky
|
|
|
|
@ -54,7 +55,7 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, Invoice> 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<InvoiceMapper, Invoice> impl
|
|
|
|
|
invoiceMapper.insert(invoice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Invoice> invoiceList(String userId,String type){
|
|
|
|
|
public List<Invoice> invoiceList(String userId, String type) {
|
|
|
|
|
List<Invoice> list = new ArrayList<>();
|
|
|
|
|
JSONArray customs = customService.customList(userId,null);
|
|
|
|
|
for(int i = 0;i<customs.size();i++){
|
|
|
|
|
JSONArray customs = customService.customList(userId, null);
|
|
|
|
|
for (int i = 0; i < customs.size(); i++) {
|
|
|
|
|
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")){
|
|
|
|
|
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<Invoice> 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<InvoiceMapper, Invoice> 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<InvoiceHeader> invoiceHeaderList(String userId){
|
|
|
|
|
public List<InvoiceHeader> invoiceHeaderList(String userId) {
|
|
|
|
|
|
|
|
|
|
List<InvoiceHeader> invoiceHeaderList = invoiceHeaderMapper.selectList(new EntityWrapper<InvoiceHeader>().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<InvoiceMapper, Invoice> 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<Invoice>().eq("invoice_header_id", invoiceHeaderId))>0){
|
|
|
|
|
if (invoiceMapper.selectCount(new EntityWrapper<Invoice>().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<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));
|
|
|
|
|
public JSONObject pcDisableInvoiceList(Integer pageNum, Integer pageSize, String copycatId) {
|
|
|
|
|
|
|
|
|
|
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 customId = invoice.getCustomId();
|
|
|
|
|
Custom custom = customMapper.selectById(customId);
|
|
|
|
@ -164,15 +179,28 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, Invoice> 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<Invoice>().eq("status_code", "enable"));
|
|
|
|
|
List<Invoice> invoiceList = invoiceMapper.selectPage(new RowBounds((pageNum-1)*pageSize,pageSize),new EntityWrapper<Invoice>().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<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 customId = invoice.getCustomId();
|
|
|
|
|
Custom custom = customMapper.selectById(customId);
|
|
|
|
@ -181,12 +209,12 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, Invoice> 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<InvoiceMapper, Invoice> 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;
|
|
|
|
|