Commit 3f36b210 by jinxin

接口修改

parent a5f4fdae
...@@ -107,6 +107,66 @@ public class LicenceOrderPageDTO implements Serializable { ...@@ -107,6 +107,66 @@ public class LicenceOrderPageDTO implements Serializable {
* 到期时间 * 到期时间
*/ */
private Date expireTime; private Date expireTime;
/**
* 企业微信支付时间
*/
private Date qywxPayTime;
/**
* gic商户Id
*/
private String enterpriseId;
/**
* gic品牌名称
*/
private String enterpriseName;
/**
* wx企业Id
*/
private String wxEnterpriseId;
/**
* 微信商户名称
*/
private String wxEnterpriseName;
public Date getQywxPayTime() {
return qywxPayTime;
}
public void setQywxPayTime(Date qywxPayTime) {
this.qywxPayTime = qywxPayTime;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getEnterpriseName() {
return enterpriseName;
}
public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getWxEnterpriseName() {
return wxEnterpriseName;
}
public void setWxEnterpriseName(String wxEnterpriseName) {
this.wxEnterpriseName = wxEnterpriseName;
}
public Date getExpireTime() { public Date getExpireTime() {
return expireTime; return expireTime;
......
...@@ -58,7 +58,16 @@ public class LicenceOrderPageQDTO extends BasePageInfo implements Serializable ...@@ -58,7 +58,16 @@ public class LicenceOrderPageQDTO extends BasePageInfo implements Serializable
* 创建人名称 * 创建人名称
*/ */
private String creatorName; private String creatorName;
/**
* 支付方式 1在线支付 2对公转账
*/
private Integer payType;
public Integer getPayType() {
return payType;
}
public void setPayType(Integer payType) {
this.payType = payType;
}
public String getEnterpriseId() { public String getEnterpriseId() {
return enterpriseId; return enterpriseId;
} }
......
...@@ -7,7 +7,6 @@ import com.gic.haoban.manage.api.dto.licence.LicenceOrderPageDTO; ...@@ -7,7 +7,6 @@ import com.gic.haoban.manage.api.dto.licence.LicenceOrderPageDTO;
import com.gic.haoban.manage.api.dto.qdto.licence.LicenceOrderPageQDTO; import com.gic.haoban.manage.api.dto.qdto.licence.LicenceOrderPageQDTO;
import com.gic.haoban.manage.api.dto.qdto.licence.LicenceOrderQDTO; import com.gic.haoban.manage.api.dto.qdto.licence.LicenceOrderQDTO;
import java.text.ParseException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -27,7 +26,7 @@ public interface LicenceOrderApiService { ...@@ -27,7 +26,7 @@ public interface LicenceOrderApiService {
* @param orderId 订单id * @param orderId 订单id
* @return LicenceOrderDTO * @return LicenceOrderDTO
*/ */
ServiceResponse<LicenceOrderDTO> getLicenceOrderDetail(Long orderId,Integer type); ServiceResponse<LicenceOrderDTO> getLicenceOrderDetail(Long orderId, Integer type);
/** /**
* 删除订单 * 删除订单
...@@ -61,7 +60,7 @@ public interface LicenceOrderApiService { ...@@ -61,7 +60,7 @@ public interface LicenceOrderApiService {
* @param wxFlag 1微信订单状态 0 企业微信订单状态 * @param wxFlag 1微信订单状态 0 企业微信订单状态
* @return * @return
*/ */
ServiceResponse<Boolean> updateLicenceOrderType(Long orderId, Integer type,String enterpriseId,String wxEnterpriseId,String creatorName,Integer wxFlag); ServiceResponse<Boolean> updateLicenceOrderType(Long orderId, Integer type, String enterpriseId, String wxEnterpriseId, String creatorName, Integer wxFlag);
/** /**
* 订单凭证上传 * 订单凭证上传
...@@ -70,7 +69,7 @@ public interface LicenceOrderApiService { ...@@ -70,7 +69,7 @@ public interface LicenceOrderApiService {
* @param voucher 凭证url * @param voucher 凭证url
* @return * @return
*/ */
ServiceResponse<Boolean> uploadLicenceOrderVoucher(Long orderId, String voucher,String enterpriseId,String wxEnterpriseId,String creatorName); ServiceResponse<Boolean> uploadLicenceOrderVoucher(Long orderId, String voucher, String enterpriseId, String wxEnterpriseId, String creatorName);
/** /**
* 订单支付接口 * 订单支付接口
...@@ -78,7 +77,7 @@ public interface LicenceOrderApiService { ...@@ -78,7 +77,7 @@ public interface LicenceOrderApiService {
* @param orderId 订单id * @param orderId 订单id
* @return * @return
*/ */
ServiceResponse<Boolean> payLicenceOrder(Long orderId,String wxEnterpriseId); ServiceResponse<String> payLicenceOrder(Long orderId, String wxEnterpriseId);
/** /**
* 查询企业是否存在订单未支付接口 * 查询企业是否存在订单未支付接口
...@@ -92,40 +91,46 @@ public interface LicenceOrderApiService { ...@@ -92,40 +91,46 @@ public interface LicenceOrderApiService {
* 微信通知回调接口 * 微信通知回调接口
*/ */
ServiceResponse<Boolean> wxCallBack(String params); ServiceResponse<Boolean> wxCallBack(String params);
/** /**
* 企业微信通知回调接口 * 企业微信通知回调接口
*/ */
ServiceResponse<Boolean> qywxCallBack(String params); ServiceResponse<Boolean> qywxCallBack(String params);
/** /**
* 保存微信交易信息 * 保存微信交易信息
* @param orderId 订单id *
* @param orderId 订单id
* @param transactionCode 订单编号 * @param transactionCode 订单编号
* @param prepayId 微信预支付id * @param prepayId 微信预支付id
* @param wxOrderId 微信支付id * @param wxOrderId 微信支付id
* @return * @return
*/ */
ServiceResponse<Boolean> saveTransactionCode(Long orderId, String transactionCode, String prepayId, String wxOrderId, Date payTime); ServiceResponse<Boolean> saveTransactionCode(Long orderId, String transactionCode, String prepayId, String wxOrderId, Date payTime);
/** /**
* 查询订单编号id * 查询订单编号id
* @param param 查询参数 *
* @param type 0 微信订单编号 1 企业微信订单编号 * @param param 查询参数
* @param type 0 微信订单编号 1 企业微信订单编号
* @param wxEnterpriseId * @param wxEnterpriseId
* @return * @return
*/ */
ServiceResponse<List<String>> getOrderIdList(String param,Integer type,String wxEnterpriseId); ServiceResponse<List<String>> getOrderIdList(String param, Integer type, String wxEnterpriseId);
/** /**
* 审核订单 * 审核订单
*
* @param orderId 订单id * @param orderId 订单id
* @param flag 是否通过 0 否 1是 * @param flag 是否通过 0 否 1是
* @param reason 不通过原因 * @param reason 不通过原因
* @return * @return
*/ */
ServiceResponse<Boolean> checkLicenceOrder(Long orderId,Integer flag,String reason,String enterpriseId,String wxEnterpriseId,String creatorName); ServiceResponse<Boolean> checkLicenceOrder(Long orderId, Integer flag, String reason, String enterpriseId, String wxEnterpriseId, String creatorName);
/** /**
* 微信退款 * 微信退款
*
* @return * @return
*/ */
ServiceResponse<Boolean> wxRefund(Long orderId); ServiceResponse<Boolean> wxRefund(Long orderId);
......
package com.gic.haoban.manage.web.controller; package com.gic.haoban.manage.web.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
...@@ -77,15 +78,26 @@ public class LicenceOrderController { ...@@ -77,15 +78,26 @@ 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(); String clerkName = loginUser.getClerkName();
LicenceOrderPageQDTO qdto = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderPageQO), LicenceOrderPageQDTO.class); LicenceOrderPageQDTO qdto = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderPageQO), LicenceOrderPageQDTO.class);
qdto.setEnterpriseId(enterpriseId);
qdto.setWxEnterpriseId(wxEnterpriseId); qdto.setWxEnterpriseId(wxEnterpriseId);
qdto.setCreatorName(clerkName); qdto.setCreatorName(clerkName);
ServiceResponse<Page<LicenceOrderPageDTO>> licenceOrderPage = licenceOrderApiService.getLicenceOrderPage(qdto); ServiceResponse<Page<LicenceOrderPageDTO>> licenceOrderPage = licenceOrderApiService.getLicenceOrderPage(qdto);
Page<LicenceOrderPageVO> result = PageHelperUtils.changePageToCurrentPage(licenceOrderPage.getResult(), LicenceOrderPageVO.class); Page<LicenceOrderPageVO> result = PageHelperUtils.changePageToCurrentPage(licenceOrderPage.getResult(), LicenceOrderPageVO.class);
if (CollUtil.isNotEmpty(result.getResult())) {
for (LicenceOrderPageVO vo : result.getResult()) {
//查询gic品牌名称
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(vo.getEnterpriseId());
if (ObjectUtil.isNotNull(enterpriseDTO)) {
vo.setEnterpriseName(enterpriseDTO.getEnterpriseName());
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(vo.getWxEnterpriseId());
if (ObjectUtil.isNotNull(wxEnterpriseDTO)) {
vo.setWxEnterpriseName(wxEnterpriseDTO.getCorpName());
}
}
}
return RestResponse.successResult(result); return RestResponse.successResult(result);
} }
...@@ -104,8 +116,8 @@ public class LicenceOrderController { ...@@ -104,8 +116,8 @@ public class LicenceOrderController {
Boolean result = licenceOrderApiService.updateLicenceOrderType(orderId, 2, enterpriseId, wxEnterpriseId, clerkName, 1).getResult(); Boolean result = licenceOrderApiService.updateLicenceOrderType(orderId, 2, enterpriseId, wxEnterpriseId, clerkName, 1).getResult();
//微信退款 //微信退款
ServiceResponse<Boolean> response = licenceOrderApiService.wxRefund(orderId); 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(result);
} }
...@@ -114,24 +126,28 @@ public class LicenceOrderController { ...@@ -114,24 +126,28 @@ public class LicenceOrderController {
* 支付订单 * 支付订单
*/ */
@RequestMapping("licence-order-pay") @RequestMapping("licence-order-pay")
public RestResponse<Boolean> payLicenceOrder(@RequestParam Long orderId) { public RestResponse<String> payLicenceOrder(@RequestParam Long orderId) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser(); WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
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());
} }
Boolean result = licenceOrderApiService.payLicenceOrder(orderId, loginUser.getWxEnterpriseId()).getResult(); ServiceResponse<String> response = licenceOrderApiService.payLicenceOrder(orderId, loginUser.getWxEnterpriseId());
return RestResponse.successResult(result); if (response.isSuccess()) {
return RestResponse.successResult(response.getResult());
}
return RestResponse.failure(response.getCode(), response.getMessage());
} }
/** /**
* 审核订单 * 审核订单
*
* @param orderId 订单id * @param orderId 订单id
* @param flag 是否通过 0 否 1是 * @param flag 是否通过 0 否 1是
* @param reason 不通过原因 * @param reason 不通过原因
* @return * @return
*/ */
@RequestMapping("licence-order-check") @RequestMapping("licence-order-check")
public RestResponse<Boolean> checkLicenceOrder(@RequestParam Long orderId,Integer flag,String reason) { public RestResponse<Boolean> checkLicenceOrder(@RequestParam Long orderId, Integer flag, String reason) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser(); WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
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());
...@@ -139,7 +155,7 @@ public class LicenceOrderController { ...@@ -139,7 +155,7 @@ public class LicenceOrderController {
String enterpriseId = loginUser.getEnterpriseId(); String enterpriseId = loginUser.getEnterpriseId();
String wxEnterpriseId = loginUser.getWxEnterpriseId(); String wxEnterpriseId = loginUser.getWxEnterpriseId();
String clerkName = loginUser.getClerkName(); String clerkName = loginUser.getClerkName();
Boolean result = licenceOrderApiService.checkLicenceOrder(orderId, flag, reason,enterpriseId, wxEnterpriseId, clerkName).getResult(); Boolean result = licenceOrderApiService.checkLicenceOrder(orderId, flag, reason, enterpriseId, wxEnterpriseId, clerkName).getResult();
return RestResponse.successResult(result); return RestResponse.successResult(result);
} }
......
...@@ -108,19 +108,26 @@ public class LicenceOrderPageVO implements Serializable { ...@@ -108,19 +108,26 @@ public class LicenceOrderPageVO implements Serializable {
* 创建人名称 * 创建人名称
*/ */
private String creatorName; private String creatorName;
/**
* 企业微信支付时间
*/
private Date qywxPayTime;
/**
* gic商户Id
*/
private String enterpriseId;
/** /**
* gic品牌名称 * gic品牌名称
*/ */
private String enterpriseName; private String enterpriseName;
/** /**
* 企业微信商户名称 * wx企业Id
*/ */
private String wxEnterpriseName; private String wxEnterpriseId;
/** /**
* 企业微信支付时间 * 微信商户名称
*/ */
private Date qywxPayTime; private String wxEnterpriseName;
} }
...@@ -29,16 +29,16 @@ import com.gic.thirdparty.api.dto.RefundReqDataDTO; ...@@ -29,16 +29,16 @@ import com.gic.thirdparty.api.dto.RefundReqDataDTO;
import com.gic.thirdparty.api.dto.RefundResDataDTO; import com.gic.thirdparty.api.dto.RefundResDataDTO;
import com.gic.thirdparty.api.service.Pay4WXService; 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.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 org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -72,22 +72,24 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService { ...@@ -72,22 +72,24 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
private WxEnterpriseService wxEnterpriseService; private WxEnterpriseService wxEnterpriseService;
@Autowired @Autowired
private Pay4WXService pay4WXService; private Pay4WXService pay4WXService;
@Autowired
private QywxUserApiService qywxUserApiService;
@Override @Override
public ServiceResponse<LicenceOrderDTO> getLicenceOrderDetail(Long orderId,Integer type) { public ServiceResponse<LicenceOrderDTO> getLicenceOrderDetail(Long orderId, Integer type) {
TabHaobanLicenceOrder licenceOrderDetail = licenceOrderService.getLicenceOrderDetail(orderId); TabHaobanLicenceOrder licenceOrderDetail = licenceOrderService.getLicenceOrderDetail(orderId);
if (licenceOrderDetail != null){ if (licenceOrderDetail != null) {
//查询订单进度表 //查询订单进度表
LicenceOrderDTO licenceOrderDTO = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderDetail), LicenceOrderDTO.class); LicenceOrderDTO licenceOrderDTO = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderDetail), LicenceOrderDTO.class);
List<TabHaobanLicenceOrderProgress> list = licenceOrderProgressService.getListByOrderId(orderId,type); List<TabHaobanLicenceOrderProgress> list = licenceOrderProgressService.getListByOrderId(orderId, type);
licenceOrderDTO.setOrderProgressList(EntityUtil.changeEntityListByJSON(LicenceOrderProgressDTO.class, list)); licenceOrderDTO.setOrderProgressList(EntityUtil.changeEntityListByJSON(LicenceOrderProgressDTO.class, list));
//查询gic品牌名称 //查询gic品牌名称
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(licenceOrderDTO.getEnterpriseId()); EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(licenceOrderDTO.getEnterpriseId());
if (ObjectUtil.isNotNull(enterpriseDTO)){ if (ObjectUtil.isNotNull(enterpriseDTO)) {
licenceOrderDTO.setEnterpriseName(enterpriseDTO.getEnterpriseName()); licenceOrderDTO.setEnterpriseName(enterpriseDTO.getEnterpriseName());
} }
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(licenceOrderDTO.getWxEnterpriseId()); WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(licenceOrderDTO.getWxEnterpriseId());
if (ObjectUtil.isNotNull(wxEnterpriseDTO)){ if (ObjectUtil.isNotNull(wxEnterpriseDTO)) {
logger.info("企业微信查询返回实体:{}", JSON.toJSONString(wxEnterpriseDTO)); logger.info("企业微信查询返回实体:{}", JSON.toJSONString(wxEnterpriseDTO));
licenceOrderDTO.setWxEnterpriseName(wxEnterpriseDTO.getCorpName()); licenceOrderDTO.setWxEnterpriseName(wxEnterpriseDTO.getCorpName());
} }
...@@ -118,53 +120,61 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService { ...@@ -118,53 +120,61 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
} }
@Override @Override
public ServiceResponse<Boolean> updateLicenceOrderType(Long orderId, Integer type,String enterpriseId,String wxEnterpriseId,String creatorName,Integer wxFlag) { public ServiceResponse<Boolean> updateLicenceOrderType(Long orderId, Integer type, String enterpriseId, String wxEnterpriseId, String creatorName, Integer wxFlag) {
licenceOrderService.updateLicenceOrderType(orderId,type,enterpriseId,wxEnterpriseId,creatorName,wxFlag); licenceOrderService.updateLicenceOrderType(orderId, type, enterpriseId, wxEnterpriseId, creatorName, wxFlag);
return ServiceResponse.success(true); return ServiceResponse.success(true);
} }
@Override @Override
public ServiceResponse<Boolean> uploadLicenceOrderVoucher(Long orderId, String voucher,String enterpriseId,String wxEnterpriseId,String creatorName) { public ServiceResponse<Boolean> uploadLicenceOrderVoucher(Long orderId, String voucher, String enterpriseId, String wxEnterpriseId, String creatorName) {
licenceOrderService.uploadLicenceOrderVoucher(orderId,voucher,enterpriseId,wxEnterpriseId,creatorName); licenceOrderService.uploadLicenceOrderVoucher(orderId, voucher, enterpriseId, wxEnterpriseId, creatorName);
return ServiceResponse.success(true); return ServiceResponse.success(true);
} }
@Override @Override
public ServiceResponse<Boolean> payLicenceOrder(Long orderId,String wxEnterpriseId) { public ServiceResponse<String> payLicenceOrder(Long orderId, String wxEnterpriseId) {
//企业微信下单 TabHaobanLicenceOrder order = licenceOrderService.getLicenceOrderDetail(orderId);
TabHaobanLicenceOrder licenceOrderDetail = licenceOrderService.getLicenceOrderDetail(orderId); if (order == null) {
if (licenceOrderDetail == null){ return ServiceResponse.failure("-9999", "参数有误!!");
return ServiceResponse.success(false);
} }
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
if (wxEnterpriseDTO == null){ if (wxEnterpriseDTO == null) {
return ServiceResponse.success(false); return ServiceResponse.failure("-9999", "微信企业不存在!!");
} }
String openCorpid = wxEnterpriseDTO.getOpenCorpid(); String openCorpid = wxEnterpriseDTO.getOpenCorpid();
String serviceCorpid = config.getCorpid(); String serviceCorpid = config.getCorpid();
//需要先判断是否已经下单,且订单失效的话重新下单
if (null != order.getQywxOrderId()) {
FeeOrderDeatilResponseDTO dto = qywxUserApiService.getOrder(openCorpid, serviceCorpid, order.getQywxOrderId());
if (null != dto && null != dto.getOrder() && dto.getOrder().getOrderStatus() != 3){
//企业微信订单有效,无需重复创建
return ServiceResponse.success(order.getQywxOrderId());
}
}
//创建企业微信订单
CreateOrderQDTO orderQDTO = new CreateOrderQDTO(); CreateOrderQDTO orderQDTO = new CreateOrderQDTO();
orderQDTO.setBaseCount(0); orderQDTO.setBaseCount(0);
orderQDTO.setExternalCount(licenceOrderDetail.getExternalContactCount()); orderQDTO.setExternalCount(order.getExternalContactCount());
orderQDTO.setBuyerUserid("kuangdongning"); orderQDTO.setBuyerUserid(config.getBuyerUserid());
if (licenceOrderDetail.getTimeType() == 1){ if (order.getTimeType() == 1) {
orderQDTO.setMonths(licenceOrderDetail.getTimeValue()); orderQDTO.setMonths(order.getTimeValue());
orderQDTO.setDays(0); orderQDTO.setDays(0);
}else { } else {
orderQDTO.setMonths(0); orderQDTO.setMonths(0);
orderQDTO.setDays(licenceOrderDetail.getTimeValue()); orderQDTO.setDays(order.getTimeValue());
} }
ServiceResponse<CreateOrderResponseDTO> newOrder = qywxOrderApiService.createNewOrder(serviceCorpid,openCorpid,orderQDTO); ServiceResponse<CreateOrderResponseDTO> newOrder = qywxOrderApiService.createNewOrder(serviceCorpid, openCorpid, orderQDTO);
logger.info("企业微信订单返回信息:{}",JSON.toJSONString(newOrder)); logger.info("企业微信订单返回信息:{}", JSON.toJSONString(newOrder));
if (newOrder.isSuccess()){ if (newOrder.isSuccess()) {
//更新企业微信订单状态,保存企业微信订单id //更新企业微信订单状态,保存企业微信订单id
CreateOrderResponseDTO result = newOrder.getResult(); CreateOrderResponseDTO result = newOrder.getResult();
licenceOrderService.updateLicenceOrderType(licenceOrderDetail.getOrderId(),0,licenceOrderDetail.getEnterpriseId(), licenceOrderService.updateLicenceOrderType(order.getOrderId(), 0, order.getEnterpriseId(),
licenceOrderDetail.getWxEnterpriseId(),"系统",0); order.getWxEnterpriseId(), "系统", 0);
licenceOrderService.saveQywxOrderId(licenceOrderDetail.getOrderId(),result.getOrderId()); licenceOrderService.saveQywxOrderId(order.getOrderId(), result.getOrderId());
return ServiceResponse.success(true); return ServiceResponse.success(result.getOrderId());
} }
return ServiceResponse.success(false); return ServiceResponse.failure(newOrder.getCode(), newOrder.getMessage());
} }
@Override @Override
...@@ -176,8 +186,8 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService { ...@@ -176,8 +186,8 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
@Override @Override
@Transactional(rollbackFor = RuntimeException.class) @Transactional(rollbackFor = RuntimeException.class)
public ServiceResponse<Boolean> wxCallBack(String params) { public ServiceResponse<Boolean> wxCallBack(String params) {
logger.info("接收微信回调参数:{}",params); logger.info("接收微信回调参数:{}", params);
if(StrUtil.isBlank(params)){ if (StrUtil.isBlank(params)) {
return ServiceResponse.success(false); return ServiceResponse.success(false);
} }
JSONObject object = JSONObject.parseObject(params, JSONObject.class); JSONObject object = JSONObject.parseObject(params, JSONObject.class);
...@@ -186,30 +196,30 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService { ...@@ -186,30 +196,30 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
String transactionId = object.getString("transactionId"); String transactionId = object.getString("transactionId");
String timeEnd = object.getString("timeEnd"); String timeEnd = object.getString("timeEnd");
TabHaobanLicenceOrder licenceOrder = licenceOrderService.selectByTransactionId(orderId); TabHaobanLicenceOrder licenceOrder = licenceOrderService.selectByTransactionId(orderId);
if (licenceOrder == null){ if (licenceOrder == null) {
logger.info("微信回调的订单编号:{}异常!!",orderId); logger.info("微信回调的订单编号:{}异常!!", orderId);
return ServiceResponse.success(false); return ServiceResponse.success(false);
} }
if (licenceOrder.getOrderStatus() == 1){ if (licenceOrder.getOrderStatus() == 1) {
//微信会多次回调 //微信会多次回调
logger.info("微信回调的订单已处理!"); logger.info("微信回调的订单已处理!");
return ServiceResponse.success(false); return ServiceResponse.success(false);
} }
Date payTime = DateUtil.strToDate(DateUtil.FORMAT_DATETIME_14, timeEnd); Date payTime = DateUtil.strToDate(DateUtil.FORMAT_DATETIME_14, timeEnd);
//更新订单状态 //更新订单状态
licenceOrderService.updateLicenceOrderType(licenceOrder.getOrderId(),1,licenceOrder.getEnterpriseId(),licenceOrder.getWxEnterpriseId(),"系统",1); licenceOrderService.updateLicenceOrderType(licenceOrder.getOrderId(), 1, licenceOrder.getEnterpriseId(), licenceOrder.getWxEnterpriseId(), "系统", 1);
//保存微信订单id //保存微信订单id
licenceOrderService.saveTransactionCode(licenceOrder.getOrderId(), null,null,transactionId,payTime); licenceOrderService.saveTransactionCode(licenceOrder.getOrderId(), null, null, transactionId, payTime);
//查询gic品牌名称 //查询gic品牌名称
String enterpriseName=""; String enterpriseName = "";
String wxEnterpriseName=""; String wxEnterpriseName = "";
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(licenceOrder.getEnterpriseId()); EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(licenceOrder.getEnterpriseId());
if (ObjectUtil.isNotNull(enterpriseDTO)){ if (ObjectUtil.isNotNull(enterpriseDTO)) {
enterpriseName=enterpriseDTO.getEnterpriseName(); enterpriseName = enterpriseDTO.getEnterpriseName();
} }
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(licenceOrder.getWxEnterpriseId()); WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(licenceOrder.getWxEnterpriseId());
if (ObjectUtil.isNotNull(wxEnterpriseDTO)){ if (ObjectUtil.isNotNull(wxEnterpriseDTO)) {
wxEnterpriseName=wxEnterpriseDTO.getCorpName(); wxEnterpriseName = wxEnterpriseDTO.getCorpName();
} }
String dateToStr = DateUtil.dateToStr(new Date(), DateUtil.FORMAT_DATETIME_19); String dateToStr = DateUtil.dateToStr(new Date(), DateUtil.FORMAT_DATETIME_19);
//发送钉钉消息通知 //发送钉钉消息通知
...@@ -219,17 +229,17 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService { ...@@ -219,17 +229,17 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
// 倒数第二个分隔符位置 // 倒数第二个分隔符位置
int secondLastIndex = host.lastIndexOf("/", lastIndex - 1); int secondLastIndex = host.lastIndexOf("/", lastIndex - 1);
String subHost = host.substring(0, secondLastIndex + 1); String subHost = host.substring(0, secondLastIndex + 1);
String url = subHost + "enterprise-operation/#/finance-config/wx-order-detail?tabId=wx_account_order&orderId="+orderId; String url = subHost + "enterprise-operation/#/finance-config/wx-order-detail?tabId=wx_account_order&orderId=" + orderId;
String msg = "标题:企微账号许可通知\n品牌名称:"+enterpriseName+"\n"+"企业名称:"+wxEnterpriseName+"\n"+"消息内容:"+dateToStr+ String msg = "标题:企微账号许可通知\n品牌名称:" + enterpriseName + "\n" + "企业名称:" + wxEnterpriseName + "\n" + "消息内容:" + dateToStr +
"订单编号为"+orderId+",请尽快处理!\n"+url; "订单编号为" + orderId + ",请尽快处理!\n" + url;
DingUtils.send(msg,"https://oapi.dingtalk.com/robot/send?access_token=63074c9fc1ac2c00aa62477facdf16e5fa2388cf6a621edba1fb05d6e55d031f",false); DingUtils.send(msg, "https://oapi.dingtalk.com/robot/send?access_token=63074c9fc1ac2c00aa62477facdf16e5fa2388cf6a621edba1fb05d6e55d031f", false);
return ServiceResponse.success(true); return ServiceResponse.success(true);
} }
@Override @Override
public ServiceResponse<Boolean> qywxCallBack(String params){ public ServiceResponse<Boolean> qywxCallBack(String params) {
logger.info("接收企业微信回调参数:{}",JSON.toJSONString(params)); logger.info("接收企业微信回调参数:{}", JSON.toJSONString(params));
if(StrUtil.isBlank(params)){ if (StrUtil.isBlank(params)) {
return ServiceResponse.success(false); return ServiceResponse.success(false);
} }
JSONObject object = JSONObject.parseObject(params, JSONObject.class); JSONObject object = JSONObject.parseObject(params, JSONObject.class);
...@@ -241,79 +251,82 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService { ...@@ -241,79 +251,82 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
TabHaobanLicenceOrder order = licenceOrderService.selectByQywxOrderId(orderId); TabHaobanLicenceOrder order = licenceOrderService.selectByQywxOrderId(orderId);
//将秒级时间戳转换位Date类型 //将秒级时间戳转换位Date类型
SimpleDateFormat formatter = new SimpleDateFormat(DateUtil.FORMAT_DATETIME_19); SimpleDateFormat formatter = new SimpleDateFormat(DateUtil.FORMAT_DATETIME_19);
String date_time = formatter.format(new Date(Long.valueOf(timeStamp)*1000L)); String date_time = formatter.format(new Date(Long.valueOf(timeStamp) * 1000L));
Date date = DateUtil.strToDate(date_time, DateUtil.FORMAT_DATETIME_19); Date date = DateUtil.strToDate(date_time, DateUtil.FORMAT_DATETIME_19);
if (order==null){ if (order == null) {
return ServiceResponse.success(false); return ServiceResponse.success(false);
} }
if ("license_pay_success".equals(infoType)){ if ("license_pay_success".equals(infoType)) {
if (order.getQywxPayTime() != null){ if (order.getQywxPayTime() != null) {
//该笔订单已处理 //该笔订单已处理
return ServiceResponse.success(false); return ServiceResponse.success(false);
} }
//更新企业微信订单状态 //更新企业微信订单状态
licenceOrderService.updateLicenceOrderType(order.getOrderId(), 1,order.getEnterpriseId(),order.getWxEnterpriseId(),"系统",0); licenceOrderService.updateLicenceOrderType(order.getOrderId(), 1, order.getEnterpriseId(), order.getWxEnterpriseId(), "系统", 0);
//记录支付时间 //记录支付时间
licenceOrderService.saveCallBackTime(order.getOrderId(),2,date); licenceOrderService.saveCallBackTime(order.getOrderId(), 2, date);
} }
if ("license_refund".equals(infoType)){ if ("license_refund".equals(infoType)) {
if (order.getQywxRefundTime() != null){ if (order.getQywxRefundTime() != null) {
//该笔订单已处理 //该笔订单已处理
return ServiceResponse.success(false); return ServiceResponse.success(false);
} }
//退款回调 订单状态,1:退款成功,2:退款被拒绝。 //退款回调 订单状态,1:退款成功,2:退款被拒绝。
if (orderStatus == 1){ if (orderStatus == 1) {
licenceOrderService.updateLicenceOrderType(order.getOrderId(), 6,order.getEnterpriseId(),order.getWxEnterpriseId(),"系统",0); licenceOrderService.updateLicenceOrderType(order.getOrderId(), 6, order.getEnterpriseId(), order.getWxEnterpriseId(), "系统", 0);
//记录退款时间 //记录退款时间
licenceOrderService.saveCallBackTime(order.getOrderId(),3,date); licenceOrderService.saveCallBackTime(order.getOrderId(), 3, date);
//微信退款 todo //微信退款,在线支付需要调用微信退款接口
if (order.getPayType() == 1){
wxRefund(order.getOrderId());
}
}else if (orderStatus == 2){ } else if (orderStatus == 2) {
licenceOrderService.updateLicenceOrderType(order.getOrderId(), 5,order.getEnterpriseId(),order.getWxEnterpriseId(),"系统",0); licenceOrderService.updateLicenceOrderType(order.getOrderId(), 5, order.getEnterpriseId(), order.getWxEnterpriseId(), "系统", 0);
//记录退款时间 //记录退款时间
licenceOrderService.saveCallBackTime(order.getOrderId(),3,date); licenceOrderService.saveCallBackTime(order.getOrderId(), 3, date);
} }
} }
return ServiceResponse.success(true); return ServiceResponse.success(true);
} }
@Override @Override
public ServiceResponse<Boolean> saveTransactionCode(Long orderId, String transactionCode, String prepayId, String wxOrderId,Date payTime) { public ServiceResponse<Boolean> saveTransactionCode(Long orderId, String transactionCode, String prepayId, String wxOrderId, Date payTime) {
licenceOrderService.saveTransactionCode(orderId,transactionCode,prepayId,wxOrderId,payTime); licenceOrderService.saveTransactionCode(orderId, transactionCode, prepayId, wxOrderId, payTime);
return ServiceResponse.success(true); return ServiceResponse.success(true);
} }
@Override @Override
public ServiceResponse<List<String>> getOrderIdList(String param, Integer type, String wxEnterpriseId) { public ServiceResponse<List<String>> getOrderIdList(String param, Integer type, String wxEnterpriseId) {
return ServiceResponse.success(licenceOrderService.getOrderIdList(param,type,wxEnterpriseId)); return ServiceResponse.success(licenceOrderService.getOrderIdList(param, type, wxEnterpriseId));
} }
@Override @Override
public ServiceResponse<Boolean> checkLicenceOrder(Long orderId, Integer flag, String reason,String enterpriseId,String wxEnterpriseId,String creatorName) { public ServiceResponse<Boolean> checkLicenceOrder(Long orderId, Integer flag, String reason, String enterpriseId, String wxEnterpriseId, String creatorName) {
licenceOrderService.checkLicenceOrder(orderId,flag,reason,enterpriseId,wxEnterpriseId,creatorName); licenceOrderService.checkLicenceOrder(orderId, flag, reason, enterpriseId, wxEnterpriseId, creatorName);
return ServiceResponse.success(true); return ServiceResponse.success(true);
} }
@Override @Override
public ServiceResponse<Boolean> wxRefund(Long orderId) { public ServiceResponse<Boolean> wxRefund(Long orderId) {
TabHaobanLicenceOrder order = licenceOrderService.getLicenceOrderDetail(orderId); TabHaobanLicenceOrder order = licenceOrderService.getLicenceOrderDetail(orderId);
if (null == order ){ if (null == order) {
return ServiceResponse.failure("-9999","订单id有误!"); return ServiceResponse.failure("-9999", "订单id有误!");
} }
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(), String.valueOf(orderId), 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())){ if (refund != null && "FAIL".equals(refund.getReturn_code())) {
//微信退款失败 //微信退款失败
return ServiceResponse.failure(refund.getReturn_code(),refund.getReturn_msg()); return ServiceResponse.failure(refund.getReturn_code(), refund.getReturn_msg());
} }
//更新微信订单状态 //更新微信订单状态
licenceOrderService.updateLicenceOrderType(order.getOrderId(), 4,order.getEnterpriseId(),order.getWxEnterpriseId(),"系统",1); licenceOrderService.updateLicenceOrderType(order.getOrderId(), 4, order.getEnterpriseId(), order.getWxEnterpriseId(), "系统", 1);
//记录支付时间 //记录支付时间
licenceOrderService.saveCallBackTime(order.getOrderId(),1,new Date()); licenceOrderService.saveCallBackTime(order.getOrderId(), 1, new Date());
return ServiceResponse.success(true); return ServiceResponse.success(true);
} }
......
...@@ -43,7 +43,7 @@ public class LicenceOrderServiceTest { ...@@ -43,7 +43,7 @@ public class LicenceOrderServiceTest {
} }
@Test @Test
public void test4(){ public void test4(){
ServiceResponse<Boolean> result = licenceOrderApiService.payLicenceOrder(512360219787935783L, "ca66a01b79474c40b3e7c7f93daf1a3b"); ServiceResponse<String> result = licenceOrderApiService.payLicenceOrder(512360219787935783L, "ca66a01b79474c40b3e7c7f93daf1a3b");
} }
@Test @Test
public void test5(){ public void test5(){
......
...@@ -127,7 +127,7 @@ public class LicenceOrderController { ...@@ -127,7 +127,7 @@ public class LicenceOrderController {
}else { }else {
time = licenceOrderQO.getTimeValue()+"天"; time = licenceOrderQO.getTimeValue()+"天";
} }
String logValue ="【购买企微许可账号】:企业员工账号"+licenceOrderQO.getExternalContactCount()+"个,时长"+time; String logValue ="【购买企微许可账号】:订单编号"+result+",企业员工账号"+licenceOrderQO.getExternalContactCount()+"个,时长"+time;
GicLogRecordEvaluationContext.putAttribute("logValue", logValue); GicLogRecordEvaluationContext.putAttribute("logValue", logValue);
return RestResponse.successResult(result); return RestResponse.successResult(result);
} }
...@@ -173,7 +173,7 @@ public class LicenceOrderController { ...@@ -173,7 +173,7 @@ public class LicenceOrderController {
String wxEnterpriseId = loginUser.getWxEnterpriseId(); String wxEnterpriseId = loginUser.getWxEnterpriseId();
String clerkName = loginUser.getClerkName(); String clerkName = loginUser.getClerkName();
Boolean result = licenceOrderApiService.updateLicenceOrderType(orderId, type, enterpriseId, wxEnterpriseId, clerkName, 1).getResult(); Boolean result = licenceOrderApiService.updateLicenceOrderType(orderId, type, enterpriseId, wxEnterpriseId, clerkName, 1).getResult();
String logValue ="【取消购买企微许可账号订单】:订单编号"+dto.getTransactionId()+",取消时间"+DateUtil.dateToStr(new Date(),DateUtil.FORMAT_DATETIME_19); String logValue ="【取消购买企微许可账号订单】:订单编号"+orderId+",取消时间"+DateUtil.dateToStr(new Date(),DateUtil.FORMAT_DATETIME_19);
GicLogRecordEvaluationContext.putAttribute("logValue", logValue); GicLogRecordEvaluationContext.putAttribute("logValue", logValue);
return RestResponse.successResult(result); return RestResponse.successResult(result);
} }
...@@ -198,7 +198,7 @@ public class LicenceOrderController { ...@@ -198,7 +198,7 @@ public class LicenceOrderController {
String wxEnterpriseId = loginUser.getWxEnterpriseId(); String wxEnterpriseId = loginUser.getWxEnterpriseId();
String clerkName = loginUser.getClerkName(); String clerkName = loginUser.getClerkName();
Boolean result = licenceOrderApiService.uploadLicenceOrderVoucher(orderId, voucher, enterpriseId, wxEnterpriseId, clerkName).getResult(); Boolean result = licenceOrderApiService.uploadLicenceOrderVoucher(orderId, voucher, enterpriseId, wxEnterpriseId, clerkName).getResult();
String logValue ="【上传购买企微许可账号支付凭证】:订单编号"+dto.getTransactionId()+",上传时间"+DateUtil.dateToStr(new Date(),DateUtil.FORMAT_DATETIME_19); String logValue ="【上传购买企微许可账号支付凭证】:订单编号"+orderId+",上传时间"+DateUtil.dateToStr(new Date(),DateUtil.FORMAT_DATETIME_19);
GicLogRecordEvaluationContext.putAttribute("logValue", logValue); GicLogRecordEvaluationContext.putAttribute("logValue", logValue);
return RestResponse.successResult(result); return RestResponse.successResult(result);
} }
......
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