Compare commits

...

11 Commits

Author SHA1 Message Date
xingze bc075b3ca6 自主授权地址配置提取 1 year ago
kk 1c86d8dc45 Merge remote-tracking branch 'origin/beta-prop-all' into beta-prop-all 1 year ago
kk e59751cd31 feature: 开票状态调整 1 year ago
xingze 8112090090 Merge branch 'xingze' into beta-prop-all 1 year ago
kk 011db55d8e feature: 签章服务调整 1 year ago
kk 1dee288f45 Merge branch 'beta' into beta-prop-all 1 year ago
kk 0c0af59d8b Merge branch 'beta' into beta-prop-all 1 year ago
kk a58b76218c Merge branch 'beta-all' into beta-prop-all 1 year ago
kk 57feb5766f 作废返回代码处理 2 years ago
kk 80c0d73fc8 批量查验加入收费逻辑 2 years ago
kk 59b268b365 Revert "红字信息表上传合并开发" 2 years ago
  1. 10
      jianshui-admin/src/main/java/com/jianshui/api/controller/http/income/v1/InvoiceCheckController.java
  2. 12
      jianshui-admin/src/main/resources/application-dev.yml
  3. 7
      jianshui-admin/src/main/resources/application-prod.yml
  4. 11
      jianshui-common/src/main/java/com/jianshui/common/config/JianshuiConfig.java
  5. 3
      jianshui-common/src/main/java/com/jianshui/common/constant/Constants.java
  6. 5
      jianshui-income/src/main/java/com/jianshui/income/service/impl/EleCheckInvoiceImpl.java
  7. 16
      jianshui-invoice-all/src/main/java/com/jianshui/invoiceall/service/impl/AutonomousSqServiceImpl.java
  8. 2
      jianshui-invoice-all/src/main/java/com/jianshui/invoiceall/service/impl/adapter/request/AisinoIncomeRequestAdapterImpl.java
  9. 2
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/AisinoInvoiceRequestAdapterImpl.java
  10. 15
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiServiceImpl.java
  11. 6
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java
  12. 4
      jianshui-invoice/src/main/java/com/jianshui/invoice/utils/BillDetailFormatUtil.java
  13. 13
      jianshui-invoice/src/main/java/com/jianshui/invoice/utils/elephant/ElephantUtils.java
  14. 3
      jianshui-system/src/main/java/com/jianshui/system/service/IServiceManageService.java
  15. 55
      jianshui-system/src/main/java/com/jianshui/system/service/impl/ServiceManageServiceImpl.java

@ -114,6 +114,16 @@ public class InvoiceCheckController {
ICheckInvoice incomeService = incomeServiceFactory.getService(serviceKey);
AjaxResult result = incomeService.checkInvoiceMultil(companyservice, invoiceCheck);
// 2023/11/30 新增扣费逻辑,成功就扣
if (result.isSuccess()) {
JSONObject resp = result.getJsonData();
Integer robUser = resp.getInteger("robUserMoney");
if (robUser != null && robUser >= 1) {
serviceManageService.companyConsume("income", companyservice.getCompanyid(),robUser);
}
}
String responseAdapterKey = serviceManageService.getResponseAdapterKey("income", companyservice.getCompanyid());
IIncomeResponseService incomeResponseService = incomeResponseFactory.getService(responseAdapterKey);
return incomeResponseService.response(result, companyservice, "check_multil");

@ -94,11 +94,13 @@ elephant_invoice_file: http://127.0.0.1:8081/invoice/fileUrl/
# 德才定制 放到数据库
#elephant_invoice_file_dc: http://127.0.0.1:8088/sdFile/
# 大象V6数电对应平台地址
#ele_url_v6: https://js.ele12.com/order-api
ele_url_v6: http://192.168.3.60:18108/order-api
ele_url_v6: https://js.ele12.com/order-api
#ele_url_v6: http://192.168.3.60:18108/order-api
#ele_url_v6: http://127.0.0.1:18108/order-api
# 大象纸票服务对应平台地址
ele_url: http://140.143.226.17:8087/order-api
#签章获取token
ele_url_qz: https://openapi.zncspt.com/api/authen/token
#logstash:
# host: 43.138.58.64:14560
# indexname: jianshui-dev
@ -106,4 +108,8 @@ invoice:
file:
save:
# 文件上传方式 0:数据库 1:oss 2:本地
type: 1
type: 1
# 自主授权相关配置
autonomous:
authorization:
callbackUrl: http://dev.goldentaxcloud.com:8081

@ -89,6 +89,7 @@ elephant_invoice_file: http://dev.goldentaxcloud.com:8081/invoice/fileUrl/
ele_url_v6: https://js.ele12.com/order-api
# 大象纸票服务对应平台地址
ele_url: http://140.143.226.17:8087/order-api
ele_url_qz: https://openapi.ele-cloud.com/api/
#logstash:
# host: 43.138.58.64:14560
# indexname: jianshui-prod
@ -96,4 +97,8 @@ invoice:
file:
save:
# 文件上传方式 0:数据库 1:oss 2:本地
type: 1
type: 1
# 自主授权相关配置
autonomous:
authorization:
callbackUrl: http://www.goldentaxcloud.com:8080

@ -1,5 +1,6 @@
package com.jianshui.common.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@ -33,6 +34,16 @@ public class JianshuiConfig
/** 验证码类型 */
private static String captchaType;
/** 自主授权回调地址 */
@Value("${autonomous.authorization.callbackUrl:}")
private String callbackUrl;
/** 自主授权回调地址 */
public String configCallbackUrl()
{
return callbackUrl + "/api/invoice_all/v1/autonomousAuthorization";
}
public String getName()
{
return name;

@ -189,7 +189,8 @@ public class Constants {
public static final String INVOICE_FILE_SAVE_TYPE = "invoice.file.save.type";
public static final String ESCAPE = "/";
public static final String QD_LOGIN = "http://zzsq.jcsk100.com/login/getLogin2";
public static final String SUBMIT_SMS = "http://zzsq.jcsk100.com/login/submitSms";
}

@ -311,8 +311,11 @@ public class EleCheckInvoiceImpl implements ICheckInvoice {
return AjaxResult.error(errorCode, errorString);
}
JSONObject result = new JSONObject();
result.put("robUserMoney", invoiceCheckList.size());
return new AjaxResult(200, "批次接收成功!", result);
return AjaxResult.success("批次接收成功!");
// return AjaxResult.success("批次接收成功!");
}
/**

@ -4,6 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jianshui.common.config.JianshuiConfig;
import com.jianshui.common.constant.Constants;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.core.domain.entity.Companyservice;
import com.jianshui.common.enums.ErrorCode;
@ -44,6 +46,8 @@ public class AutonomousSqServiceImpl implements AutonomousSqService {
private InvoiceAllLoginResultMapper invoiceAllLoginResultMapper;
@Autowired
private CompanyserviceMapper companyserviceMapper;
@Autowired
private JianshuiConfig jianshuiConfig;
/**
* 功能描述: 自主授权回调接口
@ -219,10 +223,10 @@ public class AutonomousSqServiceImpl implements AutonomousSqService {
try {
// 回调地址
inoviceAllQdLoginDTO.setLoginType("1");
inoviceAllQdLoginDTO.setCallback("http://www.goldentaxcloud.com:8081/api/invoice_all/v1/autonomousAuthorization");
log.info("全电登录接口,请求上游,地址:{},参数:{}", "http://zzsq.jcsk100.com/login/getLogin2", JSONUtil.toJsonStr(inoviceAllQdLoginDTO));
inoviceAllQdLoginDTO.setCallback(jianshuiConfig.configCallbackUrl());
log.info("全电登录接口,请求上游,地址:{},参数:{}", Constants.QD_LOGIN, JSONUtil.toJsonStr(inoviceAllQdLoginDTO));
Thread requestThread = new Thread(() -> {
HttpUtils.sendJsonPost("http://zzsq.jcsk100.com/login/getLogin2", inoviceAllQdLoginDTO);
HttpUtils.sendJsonPost(Constants.QD_LOGIN, inoviceAllQdLoginDTO);
});
requestThread.start();
// 用户信息封装
@ -240,7 +244,7 @@ public class AutonomousSqServiceImpl implements AutonomousSqService {
invoiceAllApiLog.setCreateTime(new Date());
invoiceAllApiLog.setCompany(companyservice.getSellertax());
invoiceAllApiLog.setIdentityId(companyservice.getIdentity());
invoiceAllApiLog.setUrl("http://zzsq.jcsk100.com/login/getLogin2");
invoiceAllApiLog.setUrl(Constants.QD_LOGIN);
invoiceAllApiLog.setSendMsg(JSONUtil.toJsonStr(inoviceAllQdLoginDTO));
invoiceAllApiLog.setRequestId(qqlsh);
allApiLogMapper.insert(invoiceAllApiLog);
@ -282,9 +286,9 @@ public class AutonomousSqServiceImpl implements AutonomousSqService {
if ("SMS".equals(invoiceAllLoginResult.getCode()) || "F000".equals(invoiceAllLoginResult.getCode())) {
try {
// 请求封装
log.info("自主授权短信提交接口,请求上游地址:{},入参:{}", "http://zzsq.jcsk100.com/login/submitSms", JSONUtil.toJsonStr(invoiceAllSubmitNoteDTO));
log.info("自主授权短信提交接口,请求上游地址:{},入参:{}", Constants.SUBMIT_SMS, JSONUtil.toJsonStr(invoiceAllSubmitNoteDTO));
Thread requestThread = new Thread(() -> {
HttpUtils.sendJsonPost("http://zzsq.jcsk100.com/login/submitSms", invoiceAllSubmitNoteDTO);
HttpUtils.sendJsonPost(Constants.SUBMIT_SMS,invoiceAllSubmitNoteDTO);
});
requestThread.start();
} catch (Exception e) {

@ -88,7 +88,7 @@ public class AisinoIncomeRequestAdapterImpl implements IInvoiceAllRequestService
// 平台解密
try {
// order = AisinoInvoiceDecryptUtil.decrypt(order, JKey);
order = AisinoInvoiceDecryptUtil.decrypt(order, JKey);
} catch (Exception e) {
e.printStackTrace();
throw new JianshuiParamErrorException(ErrorCode.DECRYPT_ERROR, companyservice, "invoiceall");

@ -105,7 +105,7 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
// 平台解密
try {
// TODO: 2023/9/20
// order = AisinoInvoiceDecryptUtil.decrypt(order, JKey);
order = AisinoInvoiceDecryptUtil.decrypt(order, JKey);
} catch (Exception e) {
e.printStackTrace();
throw new JianshuiParamErrorException(ErrorCode.DECRYPT_ERROR, companyservice, "invoice");

@ -1400,12 +1400,14 @@ public class ElephantInvoiceApiServiceImpl implements IInvoiceApiService {
} else if (StringUtils.isNotEmpty(fpdm) && StringUtils.isNotEmpty(fphm)) {
invoice = invoiceMapper.selectByFpdmFphm(companyservice.getCompanyid(), fpdm, fphm);
} else {
throw new JianshuiParamErrorException(ErrorCode.EMPTY_FPQQLSH, companyservice, "invoice");
// throw new JianshuiParamErrorException(ErrorCode.EMPTY_FPQQLSH, companyservice, "invoice");
return new HXResponse(ErrorCode.EMPTY_FPQQLSH.getCode(),ErrorCode.EMPTY_FPQQLSH.getMsg(), null, false);
}
//发票不存在
if (invoice == null) {
throw new JianshuiParamErrorException(ErrorCode.INVOICE_NOT_EXISTS, companyservice, "invoice");
// throw new JianshuiParamErrorException(ErrorCode.INVOICE_NOT_EXISTS, companyservice, "invoice");
return new HXResponse(ErrorCode.INVOICE_NOT_EXISTS.getCode(),ErrorCode.INVOICE_NOT_EXISTS.getMsg(), null, false);
}
// TODO 发票状态查询
@ -1427,20 +1429,23 @@ public class ElephantInvoiceApiServiceImpl implements IInvoiceApiService {
} catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) {
log.error("【销项发票】【大象接口】【发票作废】发票请求异常,请求报文{},销方信息{}", JSONUtil.parse(queryBody).toString(), JSONObject.toJSONString(companyservice));
e.printStackTrace();
throw new JianshuiServiceException("系统异常!");
// throw new JianshuiServiceException("系统异常!");
return new HXResponse("9999","系统异常!", null, false);
}
log.info("【销项发票】【大象发票】发票作废请求结果{}", queryResult.toString());
// 判断外层报文是否成功
if (queryResult.isError()) {
throw new JianshuiServiceException(queryResult.getMsg());
// throw new JianshuiServiceException(queryResult.getMsg());
return new HXResponse("9999",queryResult.getMsg(), null, false);
}
// 处理返回报文
JSONObject content = queryResult.getJsonData();
String ztdm = content.getString("ZTDM");
if (!StringUtils.equalsAny(ztdm, "040000")) {
return new HXResponse(content.getString("ZTXX"));
// return new HXResponse(content.getString("ZTXX"));
return new HXResponse("9999",content.getString("ZTXX"), null, false);
}
// TODO 发票作废通过接口查询
// // 获取作废状态

@ -529,7 +529,8 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
} else if (StringUtils.equals(ddzt, "031999")) {
invoice.setState(22); // "开票状态"
} else if (StringUtils.equals(ddzt, "032000")) {
invoice.setState(20); // "开票状态"
// invoice.setState(20); // "开票状态"
invoice.setState(21); // "开票状态"
} else if (StringUtils.equals(ddzt, "003000")) {
@ -2503,7 +2504,8 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
} else if (StringUtils.equals(ddzt, "031999")) {
invoice.setState(22); // "开票状态"
} else if (StringUtils.equals(ddzt, "032000")) {
invoice.setState(20); // "开票状态"
// invoice.setState(20); // "开票状态"
invoice.setState(21); // "开票状态"
} else if (StringUtils.equals(ddzt, "003000")) {

@ -145,9 +145,9 @@ public class BillDetailFormatUtil {
Integer fphxz = billDetail.getFphxz();
// TODO: 2023/11/16 这里被折扣行开票有问题,开票不传taxamt的话
// 如果是被折扣行,直接返回
if (fphxz != null && fphxz == 1) {
/*if (fphxz != null && fphxz == 1) {
return AjaxResult.error(300, "明细行为被折扣行");
}
}*/
//如果税率为空,直接返回
if (billDetail.getTaxrate() == null) {
return AjaxResult.error("税率为空", billDetail);

@ -64,11 +64,13 @@ public class ElephantUtils {
private static String ELE_URL_v6;
// 大象普通服务
private static String ELE_URL;
private static String ELE_URL_QZ;
static {
Environment environment = SpringUtils.getBean(Environment.class);
ELE_URL_v6 = environment.getProperty("ele_url_v6");
ELE_URL = environment.getProperty("ele_url");
ELE_URL_QZ = environment.getProperty("ele_url_qz");
}
@ -301,7 +303,9 @@ public class ElephantUtils {
url = ElephantConstants.DEV_HOST_LOCAL_V6_JingDongYun;
}*/
String url = ELE_URL;
// String url = ELE_URL;
log.info("所属签章服务,走配置文件地址,地址为{}",ELE_URL_QZ);
String url = ELE_URL_QZ;
JSONObject jsonObject = new JSONObject();
jsonObject.put("appKey", appkey);
@ -309,7 +313,7 @@ public class ElephantUtils {
Map<String, String> header = new HashMap<>();
header.put("Content-Type", "application/json");
String info = HttpUtils.sendJsonPost(url, jsonObject, header);
log.info("【销项】【大象接口】调用京东云,调用地址:{},入参:{},头信息:{},返回结果:{}",url,jsonObject,header,info);
log.info("【销项】【大象接口】签章调用京东云,调用地址:{},入参:{},头信息:{},返回结果:{}",url,jsonObject,header,info);
JSONObject obj = JSONObject.parseObject(info);
redisCache.setCacheObject(ElephantConstants.TOKEN_REDIS_KEY + "appkey:" + appkey, obj, (int) obj.get("expires_in") - 60, TimeUnit.SECONDS);
return (String) obj.get("access_token");
@ -473,6 +477,11 @@ public class ElephantUtils {
String host = ELE_URL;
/* if(ElephantConstants.SIGN.equals(uri) || ElephantConstants.SIGN_CREATE.equals(uri)|| ElephantConstants.SIGN_REGISTER.equals(uri)){
log.info("所属签章服务,走配置文件地址,地址为{}",ELE_URL_QZ);
uri = ELE_URL_QZ;
}*/
//kk TODO : 2023/9/5 大象接口迁京东云
//https://js.ele12.com/
// host = "https://js.ele12.com/order-api";

@ -88,6 +88,9 @@ public interface IServiceManageService {
*/
public AjaxResult companyConsume(String serviceKey, Long companyid);
/** 对指定服务进行消费减n */
public AjaxResult companyConsume(String serviceKey, Long companyid,int num);
/**
* 获得入口请求适配器
*

@ -164,6 +164,14 @@ public class ServiceManageServiceImpl implements IServiceManageService {
setCache(config);
}
/** 剩余次数减n */
private void subNumSurplus(ServiceManage config,int num ) {
config.setSurplus(config.getSurplus() - num);
// 更新记录
serviceManageMapper.updateSurplus(config);
setCache(config);
}
/**
* 清空缓存
*/
@ -262,6 +270,53 @@ public class ServiceManageServiceImpl implements IServiceManageService {
}
/** 扣费,根据传入的次数决定扣几次 */
@Override
public AjaxResult companyConsume(String serviceKey, Long companyid,int num) {
ServiceManage serviceManage = selectServiceManageByCompanyIdAndServiceKey(serviceKey, companyid);
if (serviceManage == null) {
throw new JianshuiNoServiceException("此销方未配置应用服务", serviceKey, companyid);
}
// 处理扣费逻辑
// 如果过期时间不为Null
Date expireTime = serviceManage.getExpireTime();
Date now = DateUtils.getNowDate();
// 如果过期了
if (expireTime != null) {
if (expireTime.getTime() < now.getTime()) {
throw new JianshuiServiceExpireException("服务已过期", serviceKey, companyid);
}
}
// 免费
if (StringUtils.equals("0", serviceManage.getServiceMode())) {
// 调用次数 -n
subNumSurplus(serviceManage,num);
return AjaxResult.success("消费成功");
}
// 预付费
if (StringUtils.equals("1", serviceManage.getServiceMode())) {
// 调用次数 -n
if (serviceManage.getSurplus() <= 0) {
throw new JianshuiServiceNoSurplusException("服务次数不足", serviceKey, companyid);
}
subNumSurplus(serviceManage,num);
return AjaxResult.success("消费成功");
}
// 定期结算
if (StringUtils.equals("2", serviceManage.getServiceMode())) {
subNumSurplus(serviceManage,num);
return AjaxResult.success("消费成功");
}
return AjaxResult.error("未知的消费模式");
}
/**
* 获得入口请求适配器
*

Loading…
Cancel
Save