This commit is contained in:
linfso 2024-07-26 09:13:01 +08:00
parent dd3130b649
commit c192c5968b
4 changed files with 68 additions and 4 deletions

View File

@ -28,6 +28,9 @@ public interface EmisSettleInvoiceChRecordMapper extends BaseMapper<EmisSettleIn
*/
public EmisSettleInvoiceChRecord selectEmisSettleInvoiceChRecordById(Long id);
public EmisSettleInvoiceChRecord selectEmisSettleInvoiceChRecordByReqNo(String reqNo);
/**
* 查询列表
*

View File

@ -29,8 +29,9 @@ import org.springframework.stereotype.Service;
import com.xdadan.erp.emis.domain.EmisSettleInvoiceChRecord;
import com.xdadan.erp.emis.mapper.EmisSettleInvoiceChRecordMapper;
import com.xdadan.erp.emis.service.IEmisSettleInvoiceChRecordService;
import org.springframework.util.CollectionUtils;
/**
/**
* 渠道开票记录表Service业务层处理
*
* @author linfso
@ -193,7 +194,6 @@ public class EmisSettleInvoiceChRecordServiceImpl implements IEmisSettleInvoiceC
goodsList.add(goodsItem);
}
order.setDetailInfos(goodsList);
JSONObject jRst =HXSdk.asyncOpenBillReceive(order,token);
// 更新开票状态
@ -202,6 +202,10 @@ public class EmisSettleInvoiceChRecordServiceImpl implements IEmisSettleInvoiceC
newRecord.setId(old.getId());
newRecord.setOpenChStatus("1");
emisSettleInvoiceChRecordMapper.updateEmisSettleInvoiceChRecord(newRecord);
// 更新状态
updateChOpenBillStatus(newRecord.getReqNo(),token);
}
else{
EmisSettleInvoiceChRecord newRecord=new EmisSettleInvoiceChRecord();
@ -210,11 +214,60 @@ public class EmisSettleInvoiceChRecordServiceImpl implements IEmisSettleInvoiceC
newRecord.setOpenChStatusDesc(jRst.getString("message"));
emisSettleInvoiceChRecordMapper.updateEmisSettleInvoiceChRecord(newRecord);
}
return 1;
}
private void updateChOpenBillStatus(String reqNo){
EmisSettleInvoiceChRecord old=emisSettleInvoiceChRecordMapper.selectEmisSettleInvoiceChRecordByReqNo(reqNo);
EmisBaseInvoiceChInfo emisBaseInvoiceChInfo=emisBaseInvoiceChInfoMapper.selectEmisBaseInvoiceChInfoByTaxNo(old.getSalerCompanyTaxNo());
String token=HXSdk.getToken(emisBaseInvoiceChInfo.getAppKey(),emisBaseInvoiceChInfo.getAppSecret());
EmisSettleInvoiceChRecord updRecord = new EmisSettleInvoiceChRecord();
updRecord.setId(old.getId());
// 立即查询状态
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);
if("00000".equals(item0.getString("returnStatus"))){
updRecord.setFilePath(item0.getString("pdfUrl"));
updRecord.setInvoiceNo(item0.getString("invoiceNo"));
// updRecord.setRemark(jQRst.toJSONString());
updRecord.setOpenChStatus(item0.getString("status"));
updRecord.setOpenChStatusDesc("已查询开票");
/*
status string Y 2 发票状态:
0:待开票;
1:开票中;
2:开票完成;
3:发票已作废 ;
4:发票已红冲-全额 ;
5:发票已红冲-部分;
6:开票失败;
*/
}else{
updRecord.setOpenChStatus("-1");
updRecord.setOpenChStatusDesc(item0.getString("returnStatusMsg"));
}
emisSettleInvoiceChRecordMapper.updateEmisSettleInvoiceChRecord(updRecord);
}
}
}
/**
* 修改渠道开票记录表
*

View File

@ -417,5 +417,7 @@ APP Secret:8962fd753b054da88409b18743a6e7c0
JSONObject jRstObj=HXSdk.queryInvoiceResult("TST2024072400-2",token);
System.out.println(jRstObj.toJSONString());
//{"code":"00000","data":{"invoiceInfos":[{"listFlag":"N","naturalPersonFlag":"0","buyerBankAccount":"320899991013001239978","pushMode":"-1","exTaxAmount":1.00,"returnStatus":"E9638","buyerAddress":"南京市秦淮区正学路1号南京晨光1865创意产业园F3幢1527号","salerBank":"中国工商银行南京市新街口支行","invoiceType":"1","model":"normal","showBankAccountType":"0","specificFactor":"0","buyerBank":"交通银行股份有限公司南京新街口支行","orderNo":"TST2024072400-2","deliverEmail":"linfso@126.com","salerBankAccount":"4301010009100803890","withTaxFlag":"1","salerNaturalPersonFlag":"0","taxAmount":0.00,"orderDate":"2024-07-24 16:50:38","status":"0","buyerTel":"4000251756","salerName":"江苏探路者国际物流有限公司","orderAmount":1.00,"buyerTaxNum":"91320104MA258WWMX2","invoiceLine":"p","salerTel":"025-85657080","returnStatusMsg":"第1条明细中零税率标识为非零税率时,税率不能为0%","buyerName":"丝路卡航(江苏)物流服务有限公司","salerAddress":"南京市秦淮区正学路1号南京晨光1865创意产业园F3幢1137号","invoiceSerialNum":"1816033232493576194","salerTaxNum":"9132010469040698XG"}]},"success":true,"message":"请求成功"}
}
}

View File

@ -154,6 +154,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from emis_settle_invoice_ch_record a
where a.id = #{id}
</select>
<select id="selectEmisSettleInvoiceChRecordByReqNo" 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.req_no = #{ReqNo}
</select>
<insert id="insertEmisSettleInvoiceChRecord" parameterType="EmisSettleInvoiceChRecord" useGeneratedKeys="true" keyProperty="id">
insert into emis_settle_invoice_ch_record