|
|
@@ -2,17 +2,32 @@ package com.usoftchina.saas.money.service.impl;
|
|
|
|
|
|
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.commons.dto.ListReqDTO;
|
|
|
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
|
|
|
+import com.usoftchina.saas.commons.po.Status;
|
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
+import com.usoftchina.saas.context.SpringContextHolder;
|
|
|
+import com.usoftchina.saas.exception.BizException;
|
|
|
+import com.usoftchina.saas.money.b2b.dto.APCheck;
|
|
|
import com.usoftchina.saas.money.mapper.ApcheckMapper;
|
|
|
import com.usoftchina.saas.money.po.Apcheck;
|
|
|
import com.usoftchina.saas.money.po.ApcheckDetail;
|
|
|
import com.usoftchina.saas.money.po.ApcheckForm;
|
|
|
import com.usoftchina.saas.money.service.ApcheckService;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
+import com.usoftchina.saas.utils.JsonUtils;
|
|
|
+import com.usoftchina.saas.utils.StringUtils;
|
|
|
+import com.usoftchina.saas.utils.http.HttpUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -22,9 +37,17 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class ApcheckServiceImpl implements ApcheckService{
|
|
|
|
|
|
+ @Value("${b2b.baseUrl.common}")
|
|
|
+ private String replyUrl;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ApcheckMapper apcheckMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CompanyApi companyApi;
|
|
|
+
|
|
|
+ private static final String URI = "/erp/sale/APCheck/reply?access_id=";
|
|
|
+
|
|
|
@Override
|
|
|
public PageInfo<Apcheck> getListData(PageRequest page, ListReqDTO req) {
|
|
|
PageHelper.startPage(page.getNumber(), page.getSize());
|
|
|
@@ -55,4 +78,38 @@ public class ApcheckServiceImpl implements ApcheckService{
|
|
|
saleFormDTO.setItems(items);
|
|
|
return saleFormDTO;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void action(Long id, Status confirmed) {
|
|
|
+ if (StringUtils.isEmpty(id)) {
|
|
|
+ throw new BizException(BizExceptionCode.NULL_DATA);
|
|
|
+ }
|
|
|
+ Apcheck main = apcheckMapper.selectByPrimaryKey(id);
|
|
|
+ //传至b2b
|
|
|
+ if (null != main) {
|
|
|
+ Long companyid = BaseContextHolder.getCompanyId();
|
|
|
+ companyid = 334l;
|
|
|
+ APCheck b2bCheck = new APCheck();
|
|
|
+ b2bCheck.setAc_code(main.getAc_code());
|
|
|
+ b2bCheck.setAc_b2bid(main.getAc_b2bid());
|
|
|
+ b2bCheck.setAc_confirmstatus(confirmed.getDisplay());
|
|
|
+ List<APCheck> replies = new ArrayList<APCheck>();
|
|
|
+ replies.add(b2bCheck);
|
|
|
+ HashMap<String, String> params = new HashMap<String, String>();
|
|
|
+ params.put("data", JsonUtils.toJsonString(replies));
|
|
|
+ Result<CompanyDTO> result = companyApi.getCompanyById(companyid);
|
|
|
+ if (result.isSuccess()) {
|
|
|
+ try {
|
|
|
+ HttpUtil.Response response = HttpUtil.sendPostRequest(replyUrl + URI + result.getData().getUu(), params, true, result.getData().getAccessKey());
|
|
|
+ if (response.getStatusCode() == HttpStatus.OK.value()) {
|
|
|
+ //更新本地状态
|
|
|
+ apcheckMapper.updateStatus(confirmed.getDisplay(), confirmed.name(), main.getAc_b2bid());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|