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

Commit 56cfa468 authored by zhoujianping's avatar zhoujianping

1.用户申请退款,自动触发退票

parent 60daa1d8
...@@ -34,6 +34,8 @@ import org.springframework.data.mongodb.core.query.Query; ...@@ -34,6 +34,8 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -69,7 +71,8 @@ public class KylinOrderTicketsRefundServiceImpl { ...@@ -69,7 +71,8 @@ public class KylinOrderTicketsRefundServiceImpl {
private Integer expressType; private Integer expressType;
@Value("${liquidnet.express.shunfeng.depositumInfo}") @Value("${liquidnet.express.shunfeng.depositumInfo}")
private String depositumInfo; private String depositumInfo;
@Value("${liquidnet.client.admin.platformUrl}")
private String platformUrl;
@Autowired @Autowired
private ShunfengSignUtils shunfengSignUtils; private ShunfengSignUtils shunfengSignUtils;
...@@ -269,7 +272,19 @@ public class KylinOrderTicketsRefundServiceImpl { ...@@ -269,7 +272,19 @@ public class KylinOrderTicketsRefundServiceImpl {
if (orderTicketVo.getGetTicketType().equals("express") && sendExpressType > 0) {// 快递票 if (orderTicketVo.getGetTicketType().equals("express") && sendExpressType > 0) {// 快递票
expressPlace(sendExpressType, expressNumber, expressContacts, expressPhone, sendExpressAddress, appointmentTime, orderTicketVo, performanceVo, orderRefundId); expressPlace(sendExpressType, expressNumber, expressContacts, expressPhone, sendExpressAddress, appointmentTime, orderTicketVo, performanceVo, orderRefundId);
} }
//电子票自动退款
if (orderTicketVo.getGetTicketType().equals("electronic")){
try {
MultiValueMap<String, String> params = new LinkedMultiValueMap();
params.add("orderRefundBatchesId", orderRefundId);
MultiValueMap<String, String> headers = new LinkedMultiValueMap();
headers.add("Accept", "application/json;charset=UTF-8");
log.info("触发自动退款参数" + JsonUtils.toJson(params));
HttpUtil.post(platformUrl+"/platform/refund/automaticRefund", params, headers);
}catch (Exception e){
log.error("触发自动退款接口失败orderRefundId={} Exception",orderRefundId,e);
}
}
HashMap<String, String> map = CollectionUtil.mapStringString(); HashMap<String, String> map = CollectionUtil.mapStringString();
map.put("orderRefundsId", orderRefundId); map.put("orderRefundsId", orderRefundId);
return ResponseDto.success(map); return ResponseDto.success(map);
......
package com.liquidnet.service.platform.controller.refund; package com.liquidnet.service.platform.controller.refund;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
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.platform.service.refund.OrderRefundsCallbackServiceImpl; import com.liquidnet.service.platform.service.refund.OrderRefundsCallbackServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* <p> * <p>
...@@ -34,6 +33,12 @@ public class OrderRefundCallbackController { ...@@ -34,6 +33,12 @@ public class OrderRefundCallbackController {
return result; return result;
} }
@PostMapping("automaticRefund")
@ApiOperation("用户自动退款")
public void automaticRefund(@RequestBody RefundApplyParam param) {
orderRefundsCallbackServiceImpl.automaticRefund(param);
}
@GetMapping("alipayActiveCallback") @GetMapping("alipayActiveCallback")
@ApiOperation("支付宝主动查询退款结果") @ApiOperation("支付宝主动查询退款结果")
public ResponseDto<String> alipayActiveCallback() { public ResponseDto<String> alipayActiveCallback() {
......
package com.liquidnet.service.platform.service.refund; package com.liquidnet.service.platform.service.refund;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.commons.lang.util.HttpUtil; import com.liquidnet.commons.lang.util.HttpUtil;
import com.liquidnet.commons.lang.util.JsonUtils; import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst; import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
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.vo.mongo.KylinOrderTicketVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinPerformanceVo;
import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderRefundsVo; import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderRefundsVo;
import com.liquidnet.service.kylin.entity.KylinOrderRefunds; import com.liquidnet.service.kylin.entity.KylinOrderRefunds;
import com.liquidnet.service.kylin.entity.KylinOrderTickets; import com.liquidnet.service.kylin.entity.KylinOrderTickets;
...@@ -56,6 +62,7 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun ...@@ -56,6 +62,7 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun
@Value("${liquidnet.service.platform.urls.ticketRefundNotify}") @Value("${liquidnet.service.platform.urls.ticketRefundNotify}")
private String refundNotify; private String refundNotify;
@Autowired @Autowired
private KylinRefundsStatusServiceImpl kylinRefundsStatusServiceImpl; private KylinRefundsStatusServiceImpl kylinRefundsStatusServiceImpl;
...@@ -134,6 +141,58 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun ...@@ -134,6 +141,58 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun
return "success"; return "success";
} }
public void automaticRefund(RefundApplyParam param) {
KylinOrderRefunds refund = kylinOrderRefundsMapper.selectOne(
Wrappers.lambdaQuery(KylinOrderRefunds.class)
.eq(KylinOrderRefunds::getOrderRefundsId, param.getOrderRefundBatchesId())
);
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 {
String postResult = HttpUtil.post(refundApply, params, headers);
log.info("自动退款返参res" + postResult);
HashMap hashMapResult = JsonUtils.fromJson(postResult, HashMap.class);
Boolean success = (Boolean) hashMapResult.get("success");
if (!success) {
String message = (String) hashMapResult.get("message");
log.info("自动退款pay返回失败" + message);
KylinOrderRefunds kylinOrderRefundsFail = new KylinOrderRefunds();
kylinOrderRefundsFail.setStatus(KylinTableStatusConst.ORDER_REFUND_STATUS_ERROR);
kylinOrderRefundsFail.setRefundError(message);
kylinOrderRefundsFail.setUpdatedAt(LocalDateTime.now());
kylinOrderRefundsMapper.update(
kylinOrderRefundsFail,
new UpdateWrapper<KylinOrderRefunds>().eq("order_refunds_id", refund.getOrderRefundsId())
);
// 修改缓存
KylinOrderRefundsVo kylinOrderRefundsVoFail = new KylinOrderRefundsVo();
BeanUtils.copyProperties(kylinOrderRefundsFail, kylinOrderRefundsVoFail);
BasicDBObject objectFail = new BasicDBObject("$set", mongoConverter.convertToMongoType(kylinOrderRefundsVoFail));
UpdateResult updateFailResult = mongoTemplate.getCollection(KylinOrderRefundsVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderRefundsId").is(refund.getOrderRefundsId())).getQueryObject(),
objectFail
);
}
}catch (Exception e){
log.info("自动退款请求pay失败e" + e.getMessage());
}
}
@Override @Override
public String getOrderRefundCode(String orderRefundCode, int type) { public String getOrderRefundCode(String orderRefundCode, int type) {
return null; return null;
......
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