Commit 3f36b210 by jinxin

接口修改

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