修改凭证接口

This commit is contained in:
lvleigang 2024-11-06 13:55:53 +08:00
parent 4a0e2e0f53
commit e332567135
6 changed files with 139 additions and 33 deletions

View File

@ -10,5 +10,6 @@ import java.util.List;
public interface IBipArchivesDao extends IBaseDao<BipArchivesEntity, String> {
List<BipArchivesEntity> queryArchivesData(BipArchivesEntity archivesEntity);
List<BipArchivesEntity> queryArchivesDatays(BipArchivesEntity archivesEntity);
}

View File

@ -17,5 +17,9 @@ public class BipArchivesDaoImpl extends MybatisGenericDao<BipArchivesEntity,Stri
public List<BipArchivesEntity> queryArchivesData(BipArchivesEntity entity) {
List<BipArchivesEntity> o = super.query(getSqlIdPrifx() + "queryArchivesData", entity);
return o;
} @Override
public List<BipArchivesEntity> queryArchivesDatays(BipArchivesEntity entity) {
List<BipArchivesEntity> o = super.query(getSqlIdPrifx() + "queryArchivesDatays", entity);
return o;
}
}

View File

@ -50,5 +50,22 @@
</trim>
</select>
<select id="queryArchivesDatays" resultMap="get-ArchivesEntity-result"
parameterType="com.hzya.frame.bip.v3.v2207.entity.BipArchivesEntity">
select
right_code
from
<choose>
<when test="archivesType == '0012'.toString()"> sys_stock_control </when>
<when test="archivesType == '0006'.toString()"> sys_stock_control </when>
<when test="archivesType == '0004'.toString()"> sys_merchant_control </when>
</choose>
<trim prefix="where" prefixOverrides="and">
<if test="leftCode != null and leftCode != ''">and left_code = #{leftCode}</if>
<if test="leftOrg != null and leftOrg != ''">and left_org = #{leftOrg}</if>
and sts='Y'
</trim>
</select>
</mapper>

View File

@ -15,4 +15,5 @@ public interface IBipV32207BillService extends IBaseService<BipTokenVo,String>{
*/
SysExtensionApiEntity getBipBill(SysExtensionApiEntity entity);
SysExtensionApiEntity getBipBillYs(SysExtensionApiEntity entity);
}

View File

@ -1,8 +1,15 @@
package com.hzya.frame.bip.v3.v2207.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.bip.v3.v2207.dao.IBipArchivesDao;
import com.hzya.frame.bip.v3.v2207.entity.BipArchivesEntity;
import com.hzya.frame.bip.v3.v2207.entity.BipAss;
import com.hzya.frame.bip.v3.v2207.entity.BipTokenVo;
import com.hzya.frame.bip.v3.v2207.entity.BipVoucher;
import com.hzya.frame.bip.v3.v2207.entity.BipVoucherDetails;
import com.hzya.frame.bip.v3.v2207.service.IBipV32207BillService;
import com.hzya.frame.bip.v3.v2207.service.IBipV32207TokenService;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
@ -13,14 +20,19 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service(value = "BipV32207BillServiceImpl")
public class BipV32207BillServiceImpl extends BaseService<BipTokenVo, String> implements IBipV32207BillService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Resource
private IBipArchivesDao bipArchivesDao;
/**
*
* @content 此方法获取拼接单据动态加密heade参数动态传入
@ -59,4 +71,64 @@ public class BipV32207BillServiceImpl extends BaseService<BipTokenVo, String> im
}
return entity;
}
@Override
public SysExtensionApiEntity getBipBillYs(SysExtensionApiEntity entity) {
try {
String bodys = entity.getBodys();
BipVoucher voucher = JSONObject.parseObject(bodys, BipVoucher.class);
List<String> fzhs = Arrays.asList(new String[]{"0012", "0006", "0004"});
if (voucher.getDetails() != null && voucher.getDetails().size() > 0) {
for (int a = 0; a < voucher.getDetails().size(); a++) {
BipVoucherDetails voucherDetails = voucher.getDetails().get(a);
if (voucherDetails.getAss() != null && voucherDetails.getAss().size() > 0) {
for (int b = 0; b < voucherDetails.getAss().size(); b++) {
BipAss ass = voucherDetails.getAss().get(b);
if (ass.getChecktypecode() != null && !"".equals(ass.getChecktypecode())) {
//存在需要转换的
if (fzhs.contains(ass.getChecktypecode())) {
BipArchivesEntity archivesEntity = new BipArchivesEntity();
archivesEntity.setArchivesType(ass.getChecktypecode());
archivesEntity.setLeftCode(ass.getCheckvaluecode());
archivesEntity.setLeftOrg(voucher.getPk_corp());
List<BipArchivesEntity> archivesEntities = bipArchivesDao.queryArchivesData(archivesEntity);
if (archivesEntities != null && archivesEntities.size() > 0) {
ass.setCheckvaluecode(archivesEntities.get(0).getRightCode());
}
}
}
}
}
}
}
bodys = JSON.toJSONString(voucher);
entity.setBodys(bodys);
Map<String, String> headers = entity.getHeaders();
String client_id = headers.get("client_id");
//token信息
String access_token = headers.get("access_token");
//公钥
String pubKey = headers.get("pubKey");
StringBuffer sb = new StringBuffer();
sb.append(client_id);
String parm = entity.getBodys();
if (StringUtils.isNotBlank(parm)) {
sb.append(parm);
}
sb.append(pubKey);
// 签名
String sign = SHA256Util.getSHA256(sb.toString(), pubKey);
StringBuffer querys = new StringBuffer();
querys.append("access_token="+access_token);
querys.append("&signature="+sign);
querys.append("&client_id="+client_id);
entity.setQuerys(querys.toString());
headers.put("signature",sign);
// headers.put("content-type","application/x-www-form-urlencoded");
} catch (Exception e) {
e.printStackTrace();
}
return entity;
}
}