|
|
@@ -3,6 +3,8 @@ package com.usoftchina.saas.document.service.impl;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.usoftchina.saas.account.api.CompanyApi;
|
|
|
+import com.usoftchina.saas.account.dto.CompanyDTO;
|
|
|
import com.usoftchina.saas.base.Result;
|
|
|
import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
|
|
|
import com.usoftchina.saas.commons.api.MaxnumberService;
|
|
|
@@ -29,8 +31,14 @@ import com.usoftchina.saas.exception.BizException;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
import com.usoftchina.saas.utils.CollectionUtils;
|
|
|
import com.usoftchina.saas.utils.DateUtils;
|
|
|
+import com.usoftchina.saas.utils.JsonUtils;
|
|
|
import com.usoftchina.saas.utils.RegexpUtils;
|
|
|
+import com.usoftchina.saas.utils.http.HttpUtil;
|
|
|
+import com.usoftchina.saas.utils.http.HttpUtil.Response;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
@@ -59,6 +67,12 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
|
|
|
private DataImportMapper dataImportMapper;
|
|
|
@Autowired
|
|
|
private VendorkindService vendorkindService;
|
|
|
+ @Autowired
|
|
|
+ private CompanyApi companyApi;
|
|
|
+ @Value("${b2b.baseUrl.common}")
|
|
|
+ private String b2bUrl;
|
|
|
+
|
|
|
+ private static final Logger LOGGER = LoggerFactory.getLogger(VendorServiceImpl.class);
|
|
|
|
|
|
@Override
|
|
|
public PageInfo<VendorDTO> getVendorsByCondition(PageRequest page, ListReqDTO listReqDTO) {
|
|
|
@@ -236,6 +250,15 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
|
|
|
main.setVe_beginprepayamount(vendortpl.getVe_beginprepayamount());
|
|
|
}
|
|
|
|
|
|
+ //启用B2B对账
|
|
|
+ if (StringUtils.isEmpty(oldVendor.getVe_uu()) && !StringUtils.isEmpty(main.getVe_uu())){
|
|
|
+ try {
|
|
|
+ enableApCheck(main.getVe_uu());
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOGGER.info("请求B2B对账启用接口失败!, time={}", DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
getMapper().updateByPrimaryKeySelective(main);
|
|
|
if (items.size() > 0) {
|
|
|
List<Vendorcontact> updateItems = new ArrayList<Vendorcontact>();
|
|
|
@@ -312,6 +335,27 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
|
|
|
return generateMsgObj(main.getId(), ve_code);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 启用B2B对账
|
|
|
+ * @param ve_uu
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private void enableApCheck(String ve_uu) throws Exception {
|
|
|
+ CompanyDTO companyDTO = companyApi.getCompanyById(BaseContextHolder.getCompanyId()).getData();
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.put("venduu", ve_uu);
|
|
|
+ map.put("custuu", companyDTO.getUu());
|
|
|
+ map.put("apcheck", 1);
|
|
|
+ Map<String, String> params = new HashMap<String, String>();
|
|
|
+ params.put("data", JsonUtils.toJsonString(map));
|
|
|
+ Response response = HttpUtil.sendPostRequest(b2bUrl + "/erp/vendor/apcheck?access_id=" + companyDTO.getUu(), params, true, companyDTO.getAccessKey());
|
|
|
+ if (response.getStatusCode() == 200){
|
|
|
+ LOGGER.info("供应商UU={},启用B2B对账成功!", ve_uu);
|
|
|
+ }else {
|
|
|
+ LOGGER.info("供应商UU={},启用B2B对账失败!,原因={}", ve_uu, response.getResponseText());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 删除主从表数据
|
|
|
* @param id
|