Commit 11cc7d63 by jinxin

取消订单

parent 2b5420a1
...@@ -139,6 +139,10 @@ public interface LicenceOrderApiService { ...@@ -139,6 +139,10 @@ public interface LicenceOrderApiService {
* 查询开户信息 * 查询开户信息
*/ */
ServiceResponse<HashMap<String, String>> getAccountInfo(); ServiceResponse<HashMap<String, String>> getAccountInfo();
/**
* 取消企业微信订单
*/
ServiceResponse<Boolean> cancelQywxOrder(Long orderId,String wxEnterpriseId);
} }
...@@ -110,16 +110,12 @@ public class LicenceOrderController { ...@@ -110,16 +110,12 @@ public class LicenceOrderController {
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) { if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg()); return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
} }
String enterpriseId = loginUser.getEnterpriseId();
String wxEnterpriseId = loginUser.getWxEnterpriseId(); String wxEnterpriseId = loginUser.getWxEnterpriseId();
String clerkName = loginUser.getClerkName(); ServiceResponse<Boolean> response = licenceOrderApiService.cancelQywxOrder(orderId, wxEnterpriseId);
Boolean result = licenceOrderApiService.updateLicenceOrderType(orderId, 2, enterpriseId, wxEnterpriseId, clerkName, 1).getResult();
//微信退款
ServiceResponse<Boolean> response = licenceOrderApiService.wxRefund(orderId);
if (!response.isSuccess()) { if (!response.isSuccess()) {
return RestResponse.failure(response.getCode(), response.getMessage()); return RestResponse.failure(response.getCode(), response.getMessage());
} }
return RestResponse.successResult(result); return RestResponse.successResult(true);
} }
/** /**
......
...@@ -31,6 +31,7 @@ import com.gic.thirdparty.api.service.Pay4WXService; ...@@ -31,6 +31,7 @@ import com.gic.thirdparty.api.service.Pay4WXService;
import com.gic.wechat.api.dto.qywx.fee.CreateOrderResponseDTO; import com.gic.wechat.api.dto.qywx.fee.CreateOrderResponseDTO;
import com.gic.wechat.api.dto.qywx.fee.FeeOrderDeatilResponseDTO; import com.gic.wechat.api.dto.qywx.fee.FeeOrderDeatilResponseDTO;
import com.gic.wechat.api.dto.qywx.fee.qdto.CreateOrderQDTO; import com.gic.wechat.api.dto.qywx.fee.qdto.CreateOrderQDTO;
import com.gic.wechat.api.dto.qywx.response.QywxResponseDTO;
import com.gic.wechat.api.service.qywx.QywxOrderApiService; import com.gic.wechat.api.service.qywx.QywxOrderApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -317,12 +318,13 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService { ...@@ -317,12 +318,13 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
if (2 == order.getPayType()) { if (2 == order.getPayType()) {
return ServiceResponse.success(false); return ServiceResponse.success(false);
} }
RefundReqDataDTO reqData = new RefundReqDataDTO(order.getWxOrderId(), String.valueOf(orderId), null, String.valueOf(orderId), 1, RefundReqDataDTO reqData = new RefundReqDataDTO(order.getWxOrderId(), null, null, String.valueOf(orderId), 1,
1, null, null); 1, null, null);
RefundResDataDTO refund = pay4WXService.refund(reqData); RefundResDataDTO refund = pay4WXService.refund(reqData);
if (refund != null && "FAIL".equals(refund.getReturn_code())) { logger.info("微信订单退款返回信息:{}",JSON.toJSONString(refund));
if (refund != null && ("FAIL".equals(refund.getReturn_code()) || "FAIL".equals(refund.getResult_code()))) {
//微信退款失败 //微信退款失败
return ServiceResponse.failure(refund.getReturn_code(), refund.getReturn_msg()); return ServiceResponse.failure(refund.getResult_code(), refund.getErr_code_des());
} }
//更新微信订单状态 //更新微信订单状态
licenceOrderService.updateLicenceOrderType(order.getOrderId(), 4, order.getEnterpriseId(), order.getWxEnterpriseId(), "系统", 1); licenceOrderService.updateLicenceOrderType(order.getOrderId(), 4, order.getEnterpriseId(), order.getWxEnterpriseId(), "系统", 1);
...@@ -340,4 +342,29 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService { ...@@ -340,4 +342,29 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
return ServiceResponse.success(result); return ServiceResponse.success(result);
} }
@Override
public ServiceResponse<Boolean> cancelQywxOrder(Long orderId,String wxEnterpriseId) {
TabHaobanLicenceOrder order = licenceOrderService.getLicenceOrderDetail(orderId);
if (null == order) {
return ServiceResponse.failure("-9999", "订单id有误!");
}
//企业微信订单取消
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
return ServiceResponse.failure("-9999", "微信企业不存在!!");
}
String openCorpid = wxEnterpriseDTO.getOpenCorpid();
String serviceCorpid = config.getCorpid();
ServiceResponse<QywxResponseDTO> response = qywxOrderApiService.cancelOrder(serviceCorpid, openCorpid, order.getQywxOrderId());
logger.info("企业微信订单取消返回信息:{}",JSON.toJSONString(response));
if (response.isSuccess()){
//更新企业微信订单状态
updateLicenceOrderType(orderId, 2, order.getEnterpriseId(), wxEnterpriseId, order.getCreatorName(), 1);
//微信退款
wxRefund(orderId);
return ServiceResponse.success(true);
}
return ServiceResponse.failure(response.getCode(),response.getMessage());
}
} }
...@@ -47,7 +47,7 @@ public class LicenceOrderServiceTest { ...@@ -47,7 +47,7 @@ public class LicenceOrderServiceTest {
} }
@Test @Test
public void test5(){ public void test5(){
ServiceResponse<Boolean> booleanServiceResponse = licenceOrderApiService.wxRefund(513465761444937732L); ServiceResponse<Boolean> booleanServiceResponse = licenceOrderApiService.wxRefund(513736803677659139L);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment