Browse Source

无车月账单交易查询

xusonglin 5 years ago
parent
commit
1c66c1a42d

+ 5 - 1
src/main/java/com/jkcredit/invoice/hub/controller/rest/forward/ForwardResource.java

@@ -8,6 +8,7 @@ import com.jkcredit.invoice.hub.enums.ApiResponseCodeEnum;
 import com.jkcredit.invoice.hub.service.apiCarFree.ApiCarFreeService;
 import com.jkcredit.invoice.hub.service.apiCompany.ApiCompanyService;
 import com.jkcredit.invoice.hub.service.apiUser.ApiUserService;
+import com.jkcredit.invoice.hub.service.apiWayBillCountQuery.WayBillCountQueryService;
 import com.jkcredit.invoice.hub.spi.lang.exception.ServiceException;
 import com.jkcredit.invoice.hub.spi.rest.data.ApiRequestParam;
 import com.jkcredit.invoice.hub.spi.rest.data.ApiResponseData;
@@ -33,7 +34,8 @@ public class ForwardResource extends RestResource {
     ApiCompanyService apiCompanyService;
     @Autowired
     ApiCarFreeService apiCarFreeService;
-
+    @Autowired
+    WayBillCountQueryService wayBillCountQueryService;
     @PostMapping("/rest")
     public ApiResponseData forwardRequest(@RequestBody ApiRequestParam param) {
         // todo 确定余额控制是在上传还是每个接口
@@ -67,6 +69,8 @@ public class ForwardResource extends RestResource {
                 return apiCarFreeService.wayBillHistoryStart(JSON.parseObject(JSON.toJSONString(param.getData())));
             } else if (param.getApi().equals(CommonConstant.WAY_BILL_HISTORY_END)) {
                 return apiCarFreeService.wayBillHistoryEnd(JSON.parseObject(JSON.toJSONString(param.getData())));
+            } else if (param.getApi().equals(CommonConstant.WAY_BILL_COUNT_QUERY)) {
+                return wayBillCountQueryService.wayBillCountQuery(JSON.parseObject(JSON.toJSONString(param.getData())));
             } else {
                 return ApiResponseData.failure(ApiResponseCodeEnum.CODE_1080.getValue(), ApiResponseCodeEnum.CODE_1080.getDesc());
             }

+ 25 - 0
src/main/java/com/jkcredit/invoice/hub/model/dto/wayBillCountQuery/WayBillCountQueryDto.java

@@ -0,0 +1,25 @@
+package com.jkcredit.invoice.hub.model.dto.wayBillCountQuery;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @description:
+ * @author: xusonglin
+ * @create: 2020/1/17 23:01
+ * @version: V1.0
+ **/
+@Data
+public class WayBillCountQueryDto implements Serializable {
+    private static final long serialVersionUID = -4707224547873979134L;
+    @NotNull(message = "税号")
+    private String taxCode;
+    @NotNull(message = "交易匹配月份不能为空")
+    private String tradeMonth;
+    @NotNull(message = "查询页码不能为空")
+    private Integer pageNo;
+
+
+}

+ 119 - 0
src/main/java/com/jkcredit/invoice/hub/model/po/searchInvoiceResult/SearchInvoiceResultPo.java

@@ -0,0 +1,119 @@
+package com.jkcredit.invoice.hub.model.po.searchInvoiceResult;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.ToString;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @description:
+ * @author: xusonglin
+ * @create: 2020/1/17 22:47
+ * @version: V1.0
+ **/
+@Entity
+@Data
+@ToString
+@TableName("h_search_invoice_result")
+public class SearchInvoiceResultPo implements Serializable {
+    private static final long serialVersionUID = -1890028406584147117L;
+    @Id
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    // 发票号码
+    private String invoiceNum;
+
+    // 发票代码
+    private String invoiceCode;
+
+    // 开票时间
+    private String invoiceMakeTime;
+
+    // 下载地址
+    private String invoiceUrl;
+
+    // 发票模板url
+    private String invoiceHtmlUrl;
+
+    // 入口收费站
+    private String enStation;
+
+    // 出口收费站
+    private String exStation;
+
+    // 交易时间
+    private String exTime;
+
+    // 交易金额
+    private Long fee;
+
+    // 税额
+    private Long totalTaxAmount;
+
+    // 车牌号
+    private String plateNum;
+
+    // 车型
+    private int vehicleType;
+
+    // 运单编号
+    private String waybillNum;
+
+    // 运单状态
+    private int waybillStatus;
+
+    // 运单开始时间
+    private String waybillStartTime;
+
+    // 运单结束时间
+    private String waybillEndTime;
+
+    // 价税合计
+    private Long totalAmount;
+
+    // 税率
+    private double taxRate;
+
+    // 发票种类
+    private String invoiceType;
+
+    // 金额
+    private Long amount;
+
+    // 销方名称
+    private String sellerName;
+
+    // 销方税号
+    private String sellerTaxpayerCode;
+
+    // 交易id
+    private String transactionId;
+
+    // 用户id
+    private Long userId;
+
+    // 创建时间
+    private Date createTime;
+
+    // 交易匹配时间
+    private String tradeMatchTime;
+
+    // 购方名称
+    private String buyerName;
+
+    // 购方税号
+    private String buyerTaxpayerCode;
+
+    // 更新时间
+    private Date updateTime;
+
+    // 删除标记
+    private Integer activated;
+}

+ 6 - 6
src/main/java/com/jkcredit/invoice/hub/service/apiCarFree/ApiCarFreeServiceImpl.java

@@ -75,7 +75,7 @@ public class ApiCarFreeServiceImpl extends BaseService implements ApiCarFreeServ
             log.error("[-vehicleRegisterQuery-] 错误信息:" + se.getMessage());
             throw new ServiceException(se.getMessage());
         }
-        return analyzeApiResult(result);
+        return analyzeApiResultItems(result);
     }
 
     @Override
@@ -111,7 +111,7 @@ public class ApiCarFreeServiceImpl extends BaseService implements ApiCarFreeServ
             log.error("[-vehicleRegister-] 错误信息:" + se.getMessage());
             throw new ServiceException(se.getMessage());
         }
-        return analyzeApiResult(result);
+        return analyzeApiResultItems(result);
     }
 
     @Override
@@ -161,7 +161,7 @@ public class ApiCarFreeServiceImpl extends BaseService implements ApiCarFreeServ
             log.error("[-wayBillStart-] 错误信息:" + se.getMessage());
             throw new ServiceException(se.getMessage());
         }
-        return analyzeApiResult(result);
+        return analyzeApiResultItems(result);
     }
 
     @Override
@@ -203,7 +203,7 @@ public class ApiCarFreeServiceImpl extends BaseService implements ApiCarFreeServ
             log.error("[-wayBillEnd-] 错误信息:" + se.getMessage());
             throw new ServiceException(se.getMessage());
         }
-        return analyzeApiResult(result);
+        return analyzeApiResultItems(result);
     }
 
     @Override
@@ -253,7 +253,7 @@ public class ApiCarFreeServiceImpl extends BaseService implements ApiCarFreeServ
             log.error("[-wayBillHistoryStart-] 错误信息:" + se.getMessage());
             throw new ServiceException(se.getMessage());
         }
-        return analyzeApiResult(result);
+        return analyzeApiResultItems(result);
     }
 
     @Override
@@ -294,6 +294,6 @@ public class ApiCarFreeServiceImpl extends BaseService implements ApiCarFreeServ
             log.error("[-wayBillHistoryEnd-] 错误信息:" + se.getMessage());
             throw new ServiceException(se.getMessage());
         }
-        return analyzeApiResult(result);
+        return analyzeApiResultItems(result);
     }
 }

+ 2 - 2
src/main/java/com/jkcredit/invoice/hub/service/apiCompany/ApiCompanyServiceImpl.java

@@ -62,7 +62,7 @@ public class ApiCompanyServiceImpl extends BaseService implements ApiCompanyServ
             log.error("[-companyQuery-] 错误信息:" + se.getMessage());
             throw new ServiceException(se.getMessage());
         }
-        return analyzeApiResult(result);
+        return analyzeApiResultItems(result);
     }
 
     @Override
@@ -109,6 +109,6 @@ public class ApiCompanyServiceImpl extends BaseService implements ApiCompanyServ
             log.error("[-companyAdd-] 错误信息:" + se.getMessage());
             throw new ServiceException(se.getMessage());
         }
-        return analyzeApiResult(result);
+        return analyzeApiResultItems(result);
     }
 }

+ 15 - 0
src/main/java/com/jkcredit/invoice/hub/service/apiWayBillCountQuery/WayBillCountQueryService.java

@@ -0,0 +1,15 @@
+package com.jkcredit.invoice.hub.service.apiWayBillCountQuery;
+
+import com.alibaba.fastjson.JSONObject;
+import com.jkcredit.invoice.hub.spi.rest.data.ApiResponseData;
+
+/**
+ * @description:
+ * @author: xusonglin
+ * @create: 2020/1/17 22:57
+ * @version: V1.0
+ **/
+public interface WayBillCountQueryService {
+    // 月账单交易查询
+    ApiResponseData wayBillCountQuery(JSONObject param);
+}

+ 66 - 0
src/main/java/com/jkcredit/invoice/hub/service/apiWayBillCountQuery/WayBillCountQueryServiceImpl.java

@@ -0,0 +1,66 @@
+package com.jkcredit.invoice.hub.service.apiWayBillCountQuery;
+
+import cn.com.taiji.common.manager.net.http.binclient.ApiRequestException;
+import cn.com.taiji.sdk.comm.ETCCommHelper;
+import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillCountQueryRequest;
+import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillCountQueryResponse;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.jkcredit.invoice.hub.constant.CommonConstant;
+import com.jkcredit.invoice.hub.enums.ApiResponseCodeEnum;
+import com.jkcredit.invoice.hub.model.dto.wayBillCountQuery.WayBillCountQueryDto;
+import com.jkcredit.invoice.hub.service.base.BaseService;
+import com.jkcredit.invoice.hub.spi.lang.exception.ServiceException;
+import com.jkcredit.invoice.hub.spi.rest.data.ApiResponseData;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+
+/**
+ * @description:
+ * @author: xusonglin
+ * @create: 2020/1/17 22:58
+ * @version: V1.0
+ **/
+@Service
+@Slf4j
+public class WayBillCountQueryServiceImpl extends BaseService implements WayBillCountQueryService {
+    @Override
+    public ApiResponseData wayBillCountQuery(JSONObject param) {
+        long costTimeStart = System.currentTimeMillis();
+        String result;
+
+        try {
+            WayBillCountQueryDto dto = JSON.toJavaObject(param, WayBillCountQueryDto.class);
+            validate(dto);
+
+            WaybillCountQueryRequest request = new WaybillCountQueryRequest();
+            request.setCompanyNum(CommonConstant.COMPANY_NUMBER);
+            request.setTaxCode(dto.getTaxCode());
+            request.setWaybillSource(1);
+            request.setTradeMonth(dto.getTradeMonth());
+            request.setPageNo(dto.getPageNo());
+            String fileName = request.getFilename();
+
+            // 调用upload 发送数据
+            WaybillCountQueryResponse response = ETCCommHelper.upload(fileName, request, WaybillCountQueryResponse.class);
+
+            result = response.toJson();
+            long costTimeEnd = System.currentTimeMillis();
+            log.info("[-apiWayBillCountQuery-] result is " + result.replaceAll("\r|\n", "") + " , request is "
+                    + param + ",costtime=" + (costTimeEnd - costTimeStart) + ",startTime=" + costTimeStart
+                    + ",endTime=" + costTimeEnd);
+        } catch (IOException e) {
+            log.error("[-apiWayBillCountQuery-] 网络异常 " + e);
+            throw new ServiceException(CommonConstant.QUERY_FAILED);
+        } catch (ApiRequestException apie) {
+            log.error("[-apiWayBillCountQuery-] 错误信息:" + apie.getMessage());
+            throw new ApiRequestException(apie.getMessage(), ApiResponseCodeEnum.CODE_200.getValue());
+        } catch (ServiceException se) {
+            log.error("[-apiWayBillCountQuery-] 错误信息:" + se.getMessage());
+            throw new ServiceException(se.getMessage());
+        }
+        return ApiResponseData.success(ApiResponseCodeEnum.CODE_200.getValue(), result);
+    }
+}

+ 1 - 2
src/main/java/com/jkcredit/invoice/hub/service/base/BaseService.java

@@ -39,7 +39,7 @@ public class BaseService {
         }
     }
 
-    protected ApiResponseData analyzeApiResult(String result) {
+    protected ApiResponseData analyzeApiResultItems(String result) {
         try {
             JSONObject jsonObject = JSON.parseObject(result);
             String item = jsonObject.getString("items");
@@ -49,5 +49,4 @@ public class BaseService {
             throw new com.jkcredit.invoice.hub.spi.lang.exception.ServiceException(CommonConstant.QUERY_FAILED);
         }
     }
-
 }