md
This commit is contained in:
parent
a46a631310
commit
59b216b430
@ -80,9 +80,13 @@ public class EmisCommonController extends EmisBaseController
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IEmisPrintTplService emisPrintTplService;
|
private IEmisPrintTplService emisPrintTplService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IEmisSettleInvoiceChRecordService emisSettleInvoiceChRecordService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RedissonService redissonService;
|
RedissonService redissonService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取中心可用简单数
|
* 获取中心可用简单数
|
||||||
* @param prefix
|
* @param prefix
|
||||||
@ -478,7 +482,7 @@ public class EmisCommonController extends EmisBaseController
|
|||||||
// 加锁查询
|
// 加锁查询
|
||||||
redissonService.lock(lockKey,300);
|
redissonService.lock(lockKey,300);
|
||||||
try{
|
try{
|
||||||
emisBaseService.autoDoSmsSend();
|
emisSettleInvoiceChRecordService.autoDoQueryOpenBillStatus();
|
||||||
}catch(Exception ex){
|
}catch(Exception ex){
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
log.error("autoQueryInvoiceStatusTrigger exception:"+ex.getMessage());
|
log.error("autoQueryInvoiceStatusTrigger exception:"+ex.getMessage());
|
||||||
@ -486,7 +490,7 @@ public class EmisCommonController extends EmisBaseController
|
|||||||
log.error("autoQueryInvoiceStatusTrigger end");
|
log.error("autoQueryInvoiceStatusTrigger end");
|
||||||
|
|
||||||
redissonService.unlock(lockKey);
|
redissonService.unlock(lockKey);
|
||||||
return AjaxResult.success("发送成功");
|
return AjaxResult.success("成功");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,6 +50,8 @@ public class EmisSettleInvoiceChRecordController extends BaseController
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IEmisSettleInvoiceChRecordService emisSettleInvoiceChRecordService;
|
private IEmisSettleInvoiceChRecordService emisSettleInvoiceChRecordService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询渠道开票记录表列表
|
* 查询渠道开票记录表列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -40,6 +40,15 @@ public interface EmisSettleInvoiceChRecordMapper extends BaseMapper<EmisSettleIn
|
|||||||
public List<EmisSettleInvoiceChRecord> selectEmisSettleInvoiceChRecordList(EmisSettleInvoiceChRecord emisSettleInvoiceChRecord);
|
public List<EmisSettleInvoiceChRecord> selectEmisSettleInvoiceChRecordList(EmisSettleInvoiceChRecord emisSettleInvoiceChRecord);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取待查询状态的数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<EmisSettleInvoiceChRecord> selectWaitQueryStatusList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否重复
|
* 检查是否重复
|
||||||
*
|
*
|
||||||
|
|||||||
@ -78,4 +78,6 @@ public interface IEmisSettleInvoiceChRecordService
|
|||||||
public int deleteEmisSettleInvoiceChRecordById(Long id);
|
public int deleteEmisSettleInvoiceChRecordById(Long id);
|
||||||
|
|
||||||
public int sendHXToOpen(Long id) throws EmisBizError;
|
public int sendHXToOpen(Long id) throws EmisBizError;
|
||||||
|
|
||||||
|
public void autoDoQueryOpenBillStatus();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,22 +108,20 @@ public class EmisSettleInvoiceChRecordServiceImpl implements IEmisSettleInvoiceC
|
|||||||
|
|
||||||
EmisSettleInvoiceChRecord old=selectEmisSettleInvoiceChRecordById(id);
|
EmisSettleInvoiceChRecord old=selectEmisSettleInvoiceChRecordById(id);
|
||||||
|
|
||||||
// 0-未发送 1-开票中 2-开票成功 3-开票失败
|
if(old==null){
|
||||||
if(
|
throw new EmisBizError(EmisBizErrorType.FAIL,"航信开票记录不存在");
|
||||||
!"0".equals(old.getOpenChStatus())
|
}
|
||||||
&& !"3".equals(old.getOpenChStatus())
|
|
||||||
|
|
||||||
){
|
// 0-未发送 1-开票中 2-开票成功 3-开票失败
|
||||||
throw new EmisBizError(EmisBizErrorType.FAIL,"当前状态不允许发送");
|
if("1".equals(old.getOpenChStatus()) || "2".equals(old.getOpenChStatus()) ){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.FAIL,"航信开票中或已开票状态不允许发送开票");
|
||||||
}
|
}
|
||||||
|
|
||||||
EmisBaseInvoiceChInfo emisBaseInvoiceChInfo=emisBaseInvoiceChInfoMapper.selectEmisBaseInvoiceChInfoByTaxNo(old.getSalerCompanyTaxNo());
|
EmisBaseInvoiceChInfo emisBaseInvoiceChInfo=emisBaseInvoiceChInfoMapper.selectEmisBaseInvoiceChInfoByTaxNo(old.getSalerCompanyTaxNo());
|
||||||
|
|
||||||
|
|
||||||
HXOrderInfo order = new HXOrderInfo();
|
HXOrderInfo order = new HXOrderInfo();
|
||||||
String token=HXSdk.getToken(emisBaseInvoiceChInfo.getAppKey(),emisBaseInvoiceChInfo.getAppSecret());
|
String token=HXSdk.getToken(emisBaseInvoiceChInfo.getAppKey(),emisBaseInvoiceChInfo.getAppSecret());
|
||||||
|
|
||||||
// 91320104MA258WWMX2 丝路卡航(江苏)物流服务有限公司 4000251756 南京市秦淮区正学路1号南京晨光1865创意产业园F3幢1527号 交通银行股份有限公司南京新街口支行 320899991013001239978 2024-07-24 11:19:25 2024-07-24 11:45:21
|
|
||||||
order.setOrderNo(old.getReqNo());
|
order.setOrderNo(old.getReqNo());
|
||||||
order.setBuyerTaxNum(old.getCompanyTaxNo());
|
order.setBuyerTaxNum(old.getCompanyTaxNo());
|
||||||
order.setBuyerName(old.getCompanyName());
|
order.setBuyerName(old.getCompanyName());
|
||||||
@ -137,7 +135,6 @@ public class EmisSettleInvoiceChRecordServiceImpl implements IEmisSettleInvoiceC
|
|||||||
order.setWithTaxFlag( "1");
|
order.setWithTaxFlag( "1");
|
||||||
order.setShowBankAccountType("3");
|
order.setShowBankAccountType("3");
|
||||||
|
|
||||||
|
|
||||||
// 蓝票
|
// 蓝票
|
||||||
order.setInvoiceType("1");
|
order.setInvoiceType("1");
|
||||||
/*
|
/*
|
||||||
@ -205,10 +202,8 @@ public class EmisSettleInvoiceChRecordServiceImpl implements IEmisSettleInvoiceC
|
|||||||
newRecord.setId(old.getId());
|
newRecord.setId(old.getId());
|
||||||
newRecord.setOpenChStatus("1");
|
newRecord.setOpenChStatus("1");
|
||||||
emisSettleInvoiceChRecordMapper.updateEmisSettleInvoiceChRecord(newRecord);
|
emisSettleInvoiceChRecordMapper.updateEmisSettleInvoiceChRecord(newRecord);
|
||||||
|
// 更新状态为已发送状态
|
||||||
// 更新状态
|
updateEmisSettleInvoiceChRecord(newRecord);
|
||||||
updateChOpenBillStatus(newRecord.getReqNo());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
EmisSettleInvoiceChRecord newRecord=new EmisSettleInvoiceChRecord();
|
EmisSettleInvoiceChRecord newRecord=new EmisSettleInvoiceChRecord();
|
||||||
@ -220,32 +215,44 @@ public class EmisSettleInvoiceChRecordServiceImpl implements IEmisSettleInvoiceC
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateChOpenBillStatus(String reqNo){
|
|
||||||
|
|
||||||
EmisSettleInvoiceChRecord old=emisSettleInvoiceChRecordMapper.selectEmisSettleInvoiceChRecordByReqNo(reqNo);
|
public void autoDoQueryOpenBillStatus(){
|
||||||
|
|
||||||
EmisBaseInvoiceChInfo emisBaseInvoiceChInfo=emisBaseInvoiceChInfoMapper.selectEmisBaseInvoiceChInfoByTaxNo(old.getSalerCompanyTaxNo());
|
List<EmisSettleInvoiceChRecord> listWaitQuery=emisSettleInvoiceChRecordMapper.selectWaitQueryStatusList();
|
||||||
|
for (EmisSettleInvoiceChRecord itemRecord:listWaitQuery) {
|
||||||
|
try {
|
||||||
|
doQueryAndUpdateChOpenBillStatus(itemRecord);
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String token=HXSdk.getToken(emisBaseInvoiceChInfo.getAppKey(),emisBaseInvoiceChInfo.getAppSecret());
|
}
|
||||||
|
|
||||||
EmisSettleInvoiceChRecord updRecord = new EmisSettleInvoiceChRecord();
|
private void doQueryAndUpdateChOpenBillStatus(EmisSettleInvoiceChRecord itemRecord){
|
||||||
updRecord.setId(old.getId());
|
|
||||||
|
|
||||||
// 立即查询状态
|
EmisBaseInvoiceChInfo emisBaseInvoiceChInfo = emisBaseInvoiceChInfoMapper.selectEmisBaseInvoiceChInfoByTaxNo(itemRecord.getSalerCompanyTaxNo());
|
||||||
JSONObject jQRst=HXSdk.queryInvoiceResult(reqNo,token);
|
|
||||||
if( "00000".equals(jQRst.getString("code")) ){
|
|
||||||
JSONObject data=jQRst.getJSONObject("data");
|
|
||||||
JSONArray jInvoiceInfos=data.getJSONArray("invoiceInfos");
|
|
||||||
if(!CollectionUtils.isEmpty(jInvoiceInfos)) {
|
|
||||||
|
|
||||||
JSONObject item0 = jInvoiceInfos.getJSONObject(0);
|
String token = HXSdk.getToken(emisBaseInvoiceChInfo.getAppKey(), emisBaseInvoiceChInfo.getAppSecret());
|
||||||
if("00000".equals(item0.getString("returnStatus"))){
|
|
||||||
updRecord.setFilePath(item0.getString("pdfUrl"));
|
EmisSettleInvoiceChRecord updRecord = new EmisSettleInvoiceChRecord();
|
||||||
updRecord.setInvoiceNo(item0.getString("invoiceNo"));
|
updRecord.setId(itemRecord.getId());
|
||||||
|
|
||||||
|
// 立即查询状态
|
||||||
|
JSONObject jQRst = HXSdk.queryInvoiceResult(itemRecord.getReqNo(), token);
|
||||||
|
if ("00000".equals(jQRst.getString("code"))) {
|
||||||
|
JSONObject data = jQRst.getJSONObject("data");
|
||||||
|
JSONArray jInvoiceInfos = data.getJSONArray("invoiceInfos");
|
||||||
|
if (!CollectionUtils.isEmpty(jInvoiceInfos)) {
|
||||||
|
|
||||||
|
JSONObject item0 = jInvoiceInfos.getJSONObject(0);
|
||||||
|
if ("00000".equals(item0.getString("returnStatus"))) {
|
||||||
|
updRecord.setFilePath(item0.getString("pdfUrl"));
|
||||||
|
updRecord.setInvoiceNo(item0.getString("invoiceNo"));
|
||||||
// updRecord.setRemark(jQRst.toJSONString());
|
// updRecord.setRemark(jQRst.toJSONString());
|
||||||
updRecord.setOpenChStatus(item0.getString("status"));
|
updRecord.setOpenChStatus(item0.getString("status"));
|
||||||
|
|
||||||
updRecord.setOpenChStatusDesc("已查询开票");
|
updRecord.setOpenChStatusDesc("已查询开票");
|
||||||
/*
|
/*
|
||||||
status string Y 2 发票状态:
|
status string Y 2 发票状态:
|
||||||
0:待开票;
|
0:待开票;
|
||||||
@ -258,16 +265,16 @@ public class EmisSettleInvoiceChRecordServiceImpl implements IEmisSettleInvoiceC
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
updRecord.setOpenChStatus("-1");
|
updRecord.setOpenChStatus("-1");
|
||||||
updRecord.setOpenChStatusDesc(item0.getString("returnStatusMsg"));
|
updRecord.setOpenChStatusDesc(item0.getString("returnStatusMsg"));
|
||||||
}
|
}
|
||||||
|
emisSettleInvoiceChRecordMapper.updateEmisSettleInvoiceChRecord(updRecord);
|
||||||
|
|
||||||
emisSettleInvoiceChRecordMapper.updateEmisSettleInvoiceChRecord(updRecord);
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -160,6 +160,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
from emis_settle_invoice_ch_record a
|
from emis_settle_invoice_ch_record a
|
||||||
where a.req_no = #{ReqNo}
|
where a.req_no = #{ReqNo}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectWaitQueryStatusList" parameterType="String" resultMap="EmisSettleInvoiceChRecordResult">
|
||||||
|
select id, req_no, apply_seq_no, bl_ecinv, invoice_type, real_invoice_type, company_name, company_tax_no, company_tel, company_address, bank_name, bank_acc_no, contact, phone, tax_rate, open_money, email, saler_company_name, saler_company_tax_no, saler_company_tel, saler_company_address, saler_bank_name, saler_bank_acc_no, saler_contact, saler_phone, invoice_no, file_path, qr_path, op_man_code, op_date, op_site_code, open_ch_id, open_ch_status, open_ch_status_desc, open_com_code, ext_data, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
|
||||||
|
from emis_settle_invoice_ch_record a
|
||||||
|
where a.del_flag='0' and a.open_ch_status = '1'
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertEmisSettleInvoiceChRecord" parameterType="EmisSettleInvoiceChRecord" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertEmisSettleInvoiceChRecord" parameterType="EmisSettleInvoiceChRecord" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into emis_settle_invoice_ch_record
|
insert into emis_settle_invoice_ch_record
|
||||||
@ -308,11 +314,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteEmisSettleInvoiceChRecordById" parameterType="Long">
|
<delete id="deleteEmisSettleInvoiceChRecordById" parameterType="Long">
|
||||||
delete from emis_settle_invoice_ch_record where id = #{id}
|
update emis_settle_invoice_ch_record set del_flag='0' where id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteEmisSettleInvoiceChRecordByIds" parameterType="String">
|
<delete id="deleteEmisSettleInvoiceChRecordByIds" parameterType="String">
|
||||||
delete from emis_settle_invoice_ch_record where id in
|
update emis_settle_invoice_ch_record set del_flag='0' where id in
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user