记得上下班打卡 | git大法好,push需谨慎

Commit ad62a365 authored by zhoujianping's avatar zhoujianping

1.自动退款增加延迟

parent 54951284
......@@ -6,6 +6,7 @@ import com.liquidnet.service.kylin.dto.param.RefundApplyParam;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
import com.liquidnet.service.kylin.dto.param.RefundSearchParam;
import com.liquidnet.service.platform.service.refund.OrderRefundsCallbackServiceImpl;
import com.sun.org.apache.regexp.internal.RE;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -14,6 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* <p>
......@@ -44,7 +48,12 @@ public class OrderRefundCallbackController {
@ApiImplicitParam(type = "from", required = true, dataType = "String", name = "orderRefundsId", value = "orderRefundsId", example = "0")
})
public ResponseDto<String> automaticRefund(@RequestParam("orderRefundsId") @NotBlank(message = "退款id不能为空") String orderRefundsId) {
return orderRefundsCallbackServiceImpl.automaticRefund(orderRefundsId);
//延迟5秒执行
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler.schedule(() -> {
orderRefundsCallbackServiceImpl.automaticRefund(orderRefundsId);
}, 5, TimeUnit.SECONDS);
return ResponseDto.success("success");
}
@GetMapping(value = "failRefund")
......
......@@ -142,35 +142,33 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun
return "success";
}
public ResponseDto<String> automaticRefund(String orderRefundsId) {
KylinOrderRefunds refund = kylinOrderRefundsMapper.selectOne(
Wrappers.lambdaQuery(KylinOrderRefunds.class)
.eq(KylinOrderRefunds::getOrderRefundsId, orderRefundsId)
);
if(null==refund){
ResponseDto.failure("退款订单不存在");
}
KylinOrderTickets oderInfo = kylinOrderTicketsMapper.selectOne(
new QueryWrapper<KylinOrderTickets>()
.eq("order_tickets_id", refund.getOrderTicketsId())
);
BigDecimal refundPrice = refund.getPrice().add(refund.getPriceExpress());
MultiValueMap<String, String> params = new LinkedMultiValueMap();
params.add("code", oderInfo.getPayCode());
params.add("notifyUrl", refundNotify);
params.add("orderCode", oderInfo.getOrderCode());
params.add("orderRefundCode", refund.getOrderRefundCode());
params.add("paymentId", oderInfo.getPaymentId());
params.add("paymentType", oderInfo.getPaymentType());
params.add("price", String.valueOf(refundPrice));
params.add("priceTotal", String.valueOf(oderInfo.getPriceActual()));
params.add("reason", "按需退款");
MultiValueMap<String, String> headers = new LinkedMultiValueMap();
headers.add("Accept", "application/json;charset=UTF-8");
log.info("自动退款退款参数" + JsonUtils.toJson(params));
public void automaticRefund(String orderRefundsId) {
try {
KylinOrderRefunds refund = kylinOrderRefundsMapper.selectOne(
Wrappers.lambdaQuery(KylinOrderRefunds.class)
.eq(KylinOrderRefunds::getOrderRefundsId, orderRefundsId)
);
log.info("自动退款refund={}",refund.toString());
KylinOrderTickets oderInfo = kylinOrderTicketsMapper.selectOne(
new QueryWrapper<KylinOrderTickets>()
.eq("order_tickets_id", refund.getOrderTicketsId())
);
BigDecimal refundPrice = refund.getPrice().add(refund.getPriceExpress());
MultiValueMap<String, String> params = new LinkedMultiValueMap();
params.add("code", oderInfo.getPayCode());
params.add("notifyUrl", refundNotify);
params.add("orderCode", oderInfo.getOrderCode());
params.add("orderRefundCode", refund.getOrderRefundCode());
params.add("paymentId", oderInfo.getPaymentId());
params.add("paymentType", oderInfo.getPaymentType());
params.add("price", String.valueOf(refundPrice));
params.add("priceTotal", String.valueOf(oderInfo.getPriceActual()));
params.add("reason", "按需退款");
MultiValueMap<String, String> headers = new LinkedMultiValueMap();
headers.add("Accept", "application/json;charset=UTF-8");
log.info("调用自动退款参数" + JsonUtils.toJson(params));
String postResult = HttpUtil.post(refundApply, params, headers);
log.info("自动退款返参res" + postResult);
log.info("调用自动退款返参res" + postResult);
HashMap hashMapResult = JsonUtils.fromJson(postResult, HashMap.class);
Boolean success = (Boolean) hashMapResult.get("success");
if (!success) {
......@@ -192,12 +190,10 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun
Query.query(Criteria.where("orderRefundsId").is(refund.getOrderRefundsId())).getQueryObject(),
objectFail
);
ResponseDto.failure("fail");
}
}catch (Exception e){
log.info("自动退款请求pay失败e" + e.getMessage());
} catch (Exception e) {
log.error("自动退款请求pay失败e" + e.getMessage());
}
return ResponseDto.success("success");
}
public void failRefund(){
List<KylinOrderRefunds> kylinOrderRefunds = kylinOrderRefundsMapper.selectList(
......
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