提交代码

dev-discount
胡锐 3 years ago
parent 8095947d14
commit 110308fe99
  1. 64
      hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java
  2. 30
      hai-service/src/main/java/com/hai/common/utils/DateUtil.java

@ -6,8 +6,11 @@ import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.AESEncodeUtil;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.CommonSysConst;
import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.config.UnionPayConfig;
import com.hai.config.WxOrderConfig;
import com.hai.dao.HighGasOrderRefundMapper;
import com.hai.entity.HighChildOrder;
@ -30,6 +33,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.security.*;
import java.text.SimpleDateFormat;
import java.util.*;
@Controller
@ -81,13 +85,69 @@ public class TuanYouController {
if (order.getOrderStatus() == 2 || order.getOrderStatus() == 3 || order.getOrderStatus() == 6) {
// 退单结果 true:成功 false:失败
if (object.getBoolean("refundResult") == true && order != null) {
OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), order.getPayRealPrice(), order.getPayRealPrice());
if(orderRefundModel.getResult_code().equals("SUCCESS")) {
if (order.getPayType() == 2) {
OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), order.getPayRealPrice(), order.getPayRealPrice());
if(orderRefundModel.getResult_code().equals("SUCCESS")) {
order.setOrderStatus(4);
order.setRefundTime(new Date());
order.setRefundPrice(order.getPayRealPrice());
highOrderService.updateOrderDetail(order);
}
} else if (order.getPayType() == 4) {
String refundOrderNo = String.valueOf(System.currentTimeMillis());
JSONObject refund = HuiLianTongUnionCardConfig.refund(refundOrderNo, order.getPaySerialNo());
if(!refund.getString("respCode").equals("0000")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR,refund.getString("respMessage"));
}
JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(refund.getString("data"));
if (consumptionResult.getBoolean("success") != true) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "交易失败!"+consumptionResult.getString("message"));
}
order.setOrderStatus(4);
order.setRefundTime(new Date());
order.setRefundPrice(order.getPayRealPrice());
highOrderService.updateOrderDetail(order);
} else if (order.getPayType() == 5) {
Calendar startTime = Calendar.getInstance();
startTime.set(Calendar.HOUR_OF_DAY, 00);
startTime.set(Calendar.MINUTE, 00);
startTime.set(Calendar.SECOND, 00);
Calendar endTime = Calendar.getInstance();
startTime.set(Calendar.HOUR_OF_DAY, 23);
startTime.set(Calendar.MINUTE, 59);
startTime.set(Calendar.SECOND, 59);
// 订单是否处于当日的订单
if (DateUtil.isEffectiveDate(order.getPayTime(), startTime.getTime(), endTime.getTime())) {
// 订单撤销
JSONObject refund = UnionPayConfig.cancel(order.getOrderNo(), order.getPaySerialNo());
if (!refund.getString("resultcode").equals("00")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("respMessage"));
}
order.setOrderStatus(4);
order.setRefundTime(new Date());
order.setRefundPrice(order.getPayRealPrice());
highOrderService.updateOrderDetail(order);
} else {
// 订单退款
JSONObject refund = UnionPayConfig.zwrefund(order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue());
if (!refund.getString("resultcode").equals("00")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("respMessage"));
}
order.setOrderStatus(4);
order.setRefundTime(new Date());
order.setRefundPrice(order.getPayRealPrice());
highOrderService.updateOrderDetail(order);
}
}
} else if (!object.getBoolean("refundResult") == true && order != null) {
order.setOrderStatus(7);
order.setRefusalRefundContent(object.getString("refundFailReason"));

@ -731,6 +731,36 @@ public class DateUtil {
}
/**
* 判断当前时间是否在[startTime, endTime]区间注意时间格式要一致
*
* @param nowTime 当前时间
* @param startTime 开始时间
* @param endTime 结束时间
* @return
* @author jqlin
*/
public static boolean isEffectiveDate(Date nowTime, Date startTime, Date endTime) {
if (nowTime.getTime() == startTime.getTime()
|| nowTime.getTime() == endTime.getTime()) {
return true;
}
Calendar date = Calendar.getInstance();
date.setTime(nowTime);
Calendar begin = Calendar.getInstance();
begin.setTime(startTime);
Calendar end = Calendar.getInstance();
end.setTime(endTime);
if (date.after(begin) && date.before(end)) {
return true;
} else {
return false;
}
}
public static void main(String[] args) throws Exception {

Loading…
Cancel
Save