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

Commit 7aa78d53 authored by zhoujianping's avatar zhoujianping

Merge branch 'dev_user_refund' into container

parents 8ad3edd2 ad62a365
...@@ -6,6 +6,7 @@ import com.liquidnet.service.kylin.dto.param.RefundApplyParam; ...@@ -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.RefundCallbackParam;
import com.liquidnet.service.kylin.dto.param.RefundSearchParam; import com.liquidnet.service.kylin.dto.param.RefundSearchParam;
import com.liquidnet.service.platform.service.refund.OrderRefundsCallbackServiceImpl; 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.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
...@@ -14,6 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,6 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/** /**
* <p> * <p>
...@@ -44,7 +48,12 @@ public class OrderRefundCallbackController { ...@@ -44,7 +48,12 @@ public class OrderRefundCallbackController {
@ApiImplicitParam(type = "from", required = true, dataType = "String", name = "orderRefundsId", value = "orderRefundsId", example = "0") @ApiImplicitParam(type = "from", required = true, dataType = "String", name = "orderRefundsId", value = "orderRefundsId", example = "0")
}) })
public ResponseDto<String> automaticRefund(@RequestParam("orderRefundsId") @NotBlank(message = "退款id不能为空") String orderRefundsId) { 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") @GetMapping(value = "failRefund")
......
...@@ -142,35 +142,33 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun ...@@ -142,35 +142,33 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun
return "success"; return "success";
} }
public ResponseDto<String> automaticRefund(String orderRefundsId) { public void 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));
try { 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); String postResult = HttpUtil.post(refundApply, params, headers);
log.info("自动退款返参res" + postResult); log.info("调用自动退款返参res" + postResult);
HashMap hashMapResult = JsonUtils.fromJson(postResult, HashMap.class); HashMap hashMapResult = JsonUtils.fromJson(postResult, HashMap.class);
Boolean success = (Boolean) hashMapResult.get("success"); Boolean success = (Boolean) hashMapResult.get("success");
if (!success) { if (!success) {
...@@ -192,12 +190,10 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun ...@@ -192,12 +190,10 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun
Query.query(Criteria.where("orderRefundsId").is(refund.getOrderRefundsId())).getQueryObject(), Query.query(Criteria.where("orderRefundsId").is(refund.getOrderRefundsId())).getQueryObject(),
objectFail objectFail
); );
ResponseDto.failure("fail");
} }
}catch (Exception e){ } catch (Exception e) {
log.info("自动退款请求pay失败e" + e.getMessage()); log.error("自动退款请求pay失败e" + e.getMessage());
} }
return ResponseDto.success("success");
} }
public void failRefund(){ public void failRefund(){
List<KylinOrderRefunds> kylinOrderRefunds = kylinOrderRefundsMapper.selectList( 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