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

Commit cc0cbf69 authored by jiangxiulong's avatar jiangxiulong

支付前演出票接口 and refund

parent 3d0e62cc
......@@ -33,18 +33,35 @@ public class KylinTableStatusConst {
public static final Integer ORDER_REFUND_TYPE_APPLY = 0; // 人工申请类型的退款,可以取消退款,退款完成需返还库存
public static final Integer ORDER_REFUND_TYPE_AUTO = 1; // 自动申请类型的退款,无法取消退款,退款完成不返还库存
/**
* 订单状态表状态
*/
// 订单状态
public static final Integer STATUS_UNPAID = 0; // 待付款
public static final Integer STATUS_PAID = 1; // 已付款
public static final Integer STATUS_CLOSE = 2; // 已关闭
public static final Integer STATUS_DELETE = -1; // 关闭后用户主动删除
public static final Integer STATUS_REFUND = 3; // 正在退款
public static final Integer STATUS_REFUNDED = 4; // 已退款
public static final Integer STATUS_WAIT_CLOSE = 5; // 待关闭
public static final Integer ORDER_STATUS0 = 0; // 待付款
public static final Integer ORDER_STATUS1 = 1; // 已付款
public static final Integer ORDER_STATUS2 = 2; // 已关闭
public static final Integer ORDER_STATUS3 = 3; // 正在退款
public static final Integer ORDER_STATUS4 = 4; // 已退款
public static final Integer ORDER_STATUS5 = 5; // 待关闭
public static final Integer ORDER_STATUS6 = 6; // 部分退款
// 支付状态
public static final Integer ORDER_PAY_STATUS0 = 0; // 未支付
public static final Integer ORDER_PAY_STATUS1 = 1; // 已支付
public static final Integer ORDER_PAY_STATUS2 = 2; // 支付不失败
// 转增
public static final Integer ORDER_TRANSFER_STATUS0 = 0; // 未转移
public static final Integer ORDER_TRANSFER_STATUS1 = 1; // 收到他人转赠
public static final Integer ORDER_TRANSFER_STATUS2 = 2; // 已转赠给他人
// 订单转赠状态
public static final Integer TRANSFER_STATUS_NONE = 0; // 无
public static final Integer TRANSFER_STATUS_ACCEPT = 1; // 接受
public static final Integer TRANSFER_STATUS_GRANT = 2; // 赠予
/**
* 入场人表状态
*/
// 支付状态
public static final Integer ENTITIES_IS_PAYMENT0 = 0; // 未支付
public static final Integer ENTITIES_IS_PAYMENT1 = 1; // 已支付
public static final Integer ENTITIES_IS_PAYMENT2 = 2; // 退款中
public static final Integer ENTITIES_IS_PAYMENT3 = 3; // 已退款
// 出票状态
public static final Integer ENTITIES_STATUS0 = 0; // 未出票
public static final Integer ENTITIES_STATUS1 = 1; // 已出票
}
package com.liquidnet.service.kylin.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
......@@ -17,7 +14,7 @@ import lombok.EqualsAndHashCode;
* </p>
*
* @author jiangxiulong
* @since 2021-05-26
* @since 2021-05-27
*/
@Data
@EqualsAndHashCode(callSuper = false)
......@@ -34,128 +31,128 @@ public class KylinOrderRefunds implements Serializable {
private String orderRefundsId;
/**
* 演出 id
* 票务订单id
*/
private String performanceId;
private String orderTicketsId;
/**
* 商户id
* 退款编号
*/
private String merchantId;
private String orderRefundCode;
/**
* 票务订单id
* 批量退款id
*/
private String orderId;
private String orderRefundBatchesId;
/**
* 商品订单id
* 退款中心退款编号
*/
private String matterId;
private String refundCode;
/**
* 管理员id
* 成功退款时间
*/
private String adminId;
private LocalDateTime refundAt;
/**
* 管理员名称
* 第三方退款编号
*/
private String adminName;
private String refundId;
/**
* 退款原因
* 退款失败原因
*/
private String reason;
private String refundError;
/**
* 批次从1开始
* 退款总金额
*/
private Integer batch;
private BigDecimal price;
/**
* 下单方式
* 退款状态: 0请求退款 2取消退款 1审核通过 5驳回退款 7等待退款 3正在退款 4完成退款 6退款失败
*/
private String orderType;
private Integer status;
/**
* 选择支付方式
* 退款差异: 0申请退款返还库存 1自动退款无法取消退款不返还库存
*/
private String payType;
private Integer type;
/**
* 实际支付方式
* 申请人id
*/
private String paymentType;
private String applicantId;
/**
* 订单入场人/搭售款式表
* 申请人名称
*/
private String refundTable;
private String applicantName;
/**
* 票务/商品/快递费
* 申请时间
*/
private String refundType;
private LocalDateTime applicantAt;
/**
* 订单入场人/搭售款式表 id
* 退款原因
*/
private String refundTableId;
private String reason;
/**
* 演出/商品 id
* 审核人id
*/
private String refundTypeParentId;
private String auditorId;
/**
* 票种/款式 id
* 审核人名称
*/
private String refundTypeId;
private String auditorName;
/**
* 2关闭或者取消退款3正在退款,4已退款
* 审核时间
*/
private Integer refundStatus;
private LocalDateTime auditorAt;
/**
* 数量
* 驳回原因
*/
private Integer refundNumber;
private String reject;
/**
* 退款金额 快递费有可能为负,意思是补差价
* 执行人id
*/
private BigDecimal refundPrice;
private String executorId;
/**
* 使用了兑换券/优惠券/无使用
* 执行人名称
*/
private String couponType;
private String executorName;
/**
* 优惠券id
* 执行时间
*/
private String couponId;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
private LocalDateTime executorAt;
/**
* 退款备注
* 回绝原因
*/
private String refundRemark;
private String refuse;
/**
* 退款单号
* 票务/快递费/票和快递费
*/
private String refundCode;
private String refundType;
/**
* 退款表refunds的id
* 订单入场人/搭售款式表 id 多个 ,分割
*/
private String refundId;
private String orderTicketEntitiesIds;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
}
package com.liquidnet.service.kylin.mapper;
import com.liquidnet.service.kylin.entity.KylinOrderRefunds;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liquidnet.service.kylin.entity.KylinOrderRefunds;
import java.util.List;
/**
* <p>
......@@ -13,4 +15,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface KylinOrderRefundsMapper extends BaseMapper<KylinOrderRefunds> {
List<KylinOrderRefunds> getRefundList(Integer whereType, String refundBatchId, Integer[] whereStatus, int mid, int limitNum);
double refundedTotalPrice(String orderTicketsId);
}
......@@ -2,4 +2,28 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.liquidnet.service.kylin.mapper.KylinOrderRefundsMapper">
<select id="getRefundList" resultType="com.liquidnet.service.kylin.entity.KylinOrderRefunds">
SELECT refunds_id
FROM kylin_refunds
<where>
r.performance_id=#{targetId}
AND type=#{whereType}
AND batch_id=#{refundBatchId}
AND o.mid>#{mid}
AND status IN
<foreach collection="whereStatus" item="status" index="index" open="(" close=")" separator=",">
#{status}
</foreach>
</where>
LIMIT #{limitNum}
</select>
<select id="refundedTotalPrice" resultType="java.lang.Double">
SELECT SUM('price')
FROM kylin_order_refunds
<where>
order_tickets_id=#{orderTicketsId}
AND status IN (3, 4)
</where>
LIMIT #{limitNum}
</select>
</mapper>
package com.liquidnet.service.kylin.controller.admin;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.service.impl.admin.KylinOrderRefundsServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 后台单订单退款 服务实现类
* </p>
*
* @author jiangxiulong
* @since 2021-05-25 10:58 上午
*/
@Api(tags = "后端-单订单退款")
@RestController
@RequestMapping("admin/refund")
public class KylinOrderRefundAdminController {
@Autowired
private KylinOrderRefundsServiceImpl kylinOrderRefundsServiceImpl;
@PostMapping("apply")
@ApiOperation("申请退款")
@ApiImplicitParams({
@ApiImplicitParam(type = "body", dataType = "String", name = "orderTicketsId", value = "订单id", required = true),
@ApiImplicitParam(type = "body", dataType = "String", name = "orderRefundBatchesId", value = "批量id"),
@ApiImplicitParam(type = "body", dataType = "String", name = "refundData", value = "退款数据"),
@ApiImplicitParam(type = "body", dataType = "String", name = "reason", value = "备注", required = true)
})
public ResponseDto<Object> refundApply(
@RequestBody String orderTicketsId,
@RequestBody String orderRefundBatchesId,
@RequestBody String refundData,
@RequestBody String reason
) {
try {
Boolean res = kylinOrderRefundsServiceImpl.refundApply(orderTicketsId, reason, orderRefundBatchesId, refundData);
if (res) {
return ResponseDto.success();
} else {
return ResponseDto.failure("申请退款失败");
}
} catch (Exception e) {
return ResponseDto.failure(e.getMessage());
}
}
}
package com.liquidnet.service.kylin.controller.admin;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.service.impl.admin.KylinRefundPerformancesAdminServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
/**
* <p>
* 后台按演出批量退款 服务实现类
* </p>
*
* @author jiangxiulong
* @since 2021-05-25 11:07 上午
*/
@Api(tags = "后端-批量退款")
@RestController
@RequestMapping("admin/refundBatch")
public class KylinOrderRefundBatchAdminController {
@Autowired
private KylinRefundPerformancesAdminServiceImpl kylinRefundPerformancesAdminServiceImpl;
@PostMapping("apply")
@ApiOperation("申请演出退款")
@ApiImplicitParams({
@ApiImplicitParam(type = "body", dataType = "String", name = "targetId", value = "ID targetType=1为演出id", required = true),
@ApiImplicitParam(type = "body", dataType = "Integer", name = "targetType", value = "类型 1演出", required = true),
@ApiImplicitParam(type = "body", dataType = "String", name = "reason", value = "申请备注", required = true),
})
public ResponseDto<Object> refundBatchApply(
@RequestBody String targetId,
@RequestBody Integer targetType,
@RequestBody String reason
) {
Integer authId = 1;
String authName = "jxl";
String token = "22adsd34tt";
HashMap<String, Object> otherParam = new HashMap();
otherParam.put("token", token);
otherParam.put("reason", reason);
try {
if (1 == targetType) {
Boolean res = kylinRefundPerformancesAdminServiceImpl.refundBatchApply(targetId, targetType, authId, authName, otherParam);
if (res) {
return ResponseDto.success();
} else {
return ResponseDto.failure("申请演出退款失败");
}
} else {
return ResponseDto.failure("参数错误");
}
} catch (Exception e) {
return ResponseDto.failure(e.getMessage());
}
}
@PostMapping("reapply")
@ApiOperation("再次提交审核")
@ApiImplicitParams({
@ApiImplicitParam(type = "body", dataType = "String", name = "refundBatchId", value = "refundBatchId 批量id", required = true),
@ApiImplicitParam(type = "body", dataType = "String", name = "remark", value = "再次提交备注", required = true),
})
public ResponseDto<Object> refundBatchApply(
@RequestBody String refundBatchId,
@RequestBody String remark
) throws Exception {
String token = "22adsd34tt";
HashMap<String, Object> otherParam = new HashMap();
otherParam.put("token", token);
otherParam.put("type", "reapply");
Boolean res = kylinRefundPerformancesAdminServiceImpl.refundBatchReapply(refundBatchId, remark, otherParam);
if (res) {
return ResponseDto.success();
} else {
return ResponseDto.failure("提交审核失败");
}
}
@PostMapping("cancel")
@ApiOperation("取消退款")
@ApiImplicitParams({
@ApiImplicitParam(type = "body", dataType = "String", name = "refundBatchId", value = "refundBatchId 批量id", required = true)
})
public ResponseDto<Object> refundBatchCancel(
@RequestBody String refundBatchId
) throws Exception {
String token = "22adsd34tt";
HashMap<String, Object> otherParam = new HashMap();
otherParam.put("token", token);
otherParam.put("type", "cancel");
Boolean res = kylinRefundPerformancesAdminServiceImpl.refundBatchCancel(refundBatchId, otherParam);
if (res) {
return ResponseDto.success();
} else {
return ResponseDto.failure("取消退款失败");
}
}
@PostMapping("review")
@ApiOperation("审核/驳回")
@ApiImplicitParams({
@ApiImplicitParam(type = "body", dataType = "String", name = "refundBatchId", value = "refundBatchId 批量id", required = true),
@ApiImplicitParam(type = "body", dataType = "Integer", name = "status", value = "状态 3运营驳回审核 4运营通过审核", required = true),
@ApiImplicitParam(type = "body", dataType = "String", name = "reject", value = "备注", required = true)
})
public ResponseDto<Object> refundBatchReview(
@RequestBody String refundBatchId,
@RequestBody Integer status,
@RequestBody String reject
) throws Exception {
String token = "22adsd34tt";
HashMap<String, Object> otherParam = new HashMap();
otherParam.put("token", token);
otherParam.put("type", "review");
otherParam.put("status", status);
otherParam.put("reject", reject);
Boolean res = kylinRefundPerformancesAdminServiceImpl.refundBatchReview(refundBatchId, otherParam);
if (res) {
return ResponseDto.success();
} else {
return ResponseDto.failure("审核失败");
}
}
@PostMapping("execute")
@ApiOperation("执行退款/拒绝退款")
@ApiImplicitParams({
@ApiImplicitParam(type = "body", dataType = "String", name = "refundBatchId", value = "refundBatchId 批量id", required = true),
@ApiImplicitParam(type = "body", dataType = "Integer", name = "status", value = "状态 5财务驳回审核 6财务通过审核", required = true),
@ApiImplicitParam(type = "body", dataType = "String", name = "refuse", value = "备注", required = true)
})
public ResponseDto<Object> refundBatchExecute(
@RequestBody String refundBatchId,
@RequestBody Integer status,
@RequestBody String refuse
) throws Exception {
String token = "22adsd34tt";
HashMap<String, Object> otherParam = new HashMap();
otherParam.put("token", token);
otherParam.put("type", "execute");
otherParam.put("status", status);
otherParam.put("refuse", refuse);
Boolean res = kylinRefundPerformancesAdminServiceImpl.refundBatchExecute(refundBatchId, otherParam);
if (res) {
return ResponseDto.success();
} else {
return ResponseDto.failure("审核失败");
}
}
}
......@@ -45,6 +45,9 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private DataUtils dataUtils;
public HashMap<String, Object> localList(
String timeStart, int days, String title, String cityName, int type,
Integer isDiscount, Integer isAdvance, Integer isExclusive,
......@@ -210,7 +213,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
public KylinPerformanceVo detail(String performancesId, double latitudeFrom, double longitudeFrom) {
KylinPerformanceVo performancesInfo = new DataUtils().getPerformanceVo(performancesId);
KylinPerformanceVo performancesInfo = dataUtils.getPerformanceVo(performancesId);
String roadShowId = performancesInfo.getRoadShowId();
List<KylinPerformanceVo> roadList = new ArrayList();
......@@ -310,7 +313,7 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
partner.setTicketList(ticketList);
}
KylinPerformanceVo performancesInfo = new DataUtils().getPerformanceVo(performancesId);
KylinPerformanceVo performancesInfo = dataUtils.getPerformanceVo(performancesId);
HashMap<String, Object> info = new HashMap();
info.put("city_name", performancesInfo.getCityName());
info.put("field_name", performancesInfo.getFieldName());
......@@ -405,8 +408,8 @@ public class KylinPerformancesServiceImpl extends ServiceImpl<KylinPerformancesM
}
public PayDetailVo payDetail(String performancesId, String ticketsId) {
KylinPerformanceVo performancesInfo = new DataUtils().getPerformanceVo(performancesId);
KylinTicketVo ticketVo = new DataUtils().getTicketVo(ticketsId);
KylinPerformanceVo performancesInfo = dataUtils.getPerformanceVo(performancesId);
KylinTicketVo ticketVo = dataUtils.getTicketVo(ticketsId);
PayDetailVo payDetailVo = new PayDetailVo();
payDetailVo.setPerformanceInfo(performancesInfo);
......
package com.liquidnet.service.kylin.service.impl.admin;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.entity.KylinOrderRefunds;
import com.liquidnet.service.kylin.entity.KylinOrderTickets;
import com.liquidnet.service.kylin.mapper.KylinOrderRefundsMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketsMapper;
import com.liquidnet.service.kylin.service.IKylinOrderRefundsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* <p>
* 订单退款表 服务实现类
* </p>
*
* @author jiangxiulong
* @since 2021-05-26
*/
@Service
public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsMapper, KylinOrderRefunds> implements IKylinOrderRefundsService {
@Autowired
private KylinOrderTicketsMapper kylinOrderTicketsMapper;
@Autowired
private KylinRefundsStatusServiceImpl kylinRefundsStatusServiceImpl;
public Boolean refundApply(String orderTicketsId, String reason, String orderRefundBatchesId, String refundData) throws Exception {
int count = 0;
count = kylinOrderTicketsMapper.selectCount(
new UpdateWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId).eq("coupon_type2", "full")
);
if (count > 0) {
throw new Exception("使用满减券 暂不能退款");
}
boolean res = kylinRefundsStatusServiceImpl.orderTicketRefunding(orderTicketsId, refundData, reason, orderRefundBatchesId);
if (res) {
return true;
} else {
return false;
}
}
}
package com.liquidnet.service.kylin.service.impl.admin;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.entity.*;
import com.liquidnet.service.kylin.mapper.KylinOrderRefundsMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketEntitiesMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketsMapper;
import com.liquidnet.service.kylin.mapper.KylinRefundBatchesMapper;
import com.liquidnet.service.kylin.service.IKylinRefundBatchesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
/**
* <p>
* 后台退款 服务实现类
* </p>
*
* @author jiangxiulong
* @since 2021-05-25 19:50 下午
*/
@Service
public class KylinRefundExecuteServiceImpl {
@Autowired
private KylinOrderTicketsMapper kylinOrderTicketsMapper;
@Autowired
private KylinOrderRefundsMapper kylinOrderRefundsMapper;
@Autowired
private KylinOrderTicketEntitiesMapper kylinOrderTicketEntitiesMapper;
@Autowired
RedisUtil redisUtil;
@Autowired
private KylinRefundHttpSubmitServiceImpl kylinRefundHttpSubmitServiceImpl;
@Async
public void refundBatchApply(String targetId, String refundBatchId, HashMap<String, Object> otherParam) throws Exception {
int count;
int limitNum = 100;
int mid = 0;
do {
List<KylinOrderTickets> orderList = kylinOrderTicketsMapper.getOrderEntities(targetId, mid, limitNum);
for (KylinOrderTickets v : orderList) {
List<KylinOrderTicketEntities> entitiesList = kylinOrderTicketEntitiesMapper.selectList(
new UpdateWrapper<KylinOrderTicketEntities>().eq("order_id", v.getOrderTicketsId())
.eq("is_payment", "yes")
);
// 请求php接口
kylinRefundHttpSubmitServiceImpl.httpApply(v, entitiesList, otherParam, refundBatchId);
}
count = orderList.size();
KylinOrderTickets lastInfo = orderList.get(count - 1);
mid = lastInfo.getMid();
} while (count >= limitNum);
}
@Async
public void refundBatchStatus(String refundBatchId, HashMap<String, Object> otherParam) throws Exception {
// 处理查询订单状态
Integer[] whereStatus = {};
Integer whereType = KylinTableStatusConst.ORDER_REFUND_TYPE_APPLY;
switch ((String) otherParam.get("type")) {
case "reapply":
whereStatus = new Integer[]{KylinTableStatusConst.ORDER_REFUND_STATUS_REJECT, KylinTableStatusConst.ORDER_REFUND_STATUS_REFUSE};
break;
case "cancel":
whereStatus = new Integer[]{KylinTableStatusConst.ORDER_REFUND_STATUS_APPLY, KylinTableStatusConst.ORDER_REFUND_STATUS_REJECT, KylinTableStatusConst.ORDER_REFUND_STATUS_REFUSE};
break;
case "review":
if (otherParam.get("status") == KylinTableStatusConst.ORDER_REFUND_STATUS_APPROVED) { // 通过申请
whereStatus = new Integer[]{KylinTableStatusConst.ORDER_REFUND_STATUS_APPLY, KylinTableStatusConst.ORDER_REFUND_STATUS_REJECT, KylinTableStatusConst.ORDER_REFUND_STATUS_REFUSE};
}
if (otherParam.get("status") == KylinTableStatusConst.ORDER_REFUND_STATUS_REJECT) { // 驳回申请
whereStatus = new Integer[]{KylinTableStatusConst.ORDER_REFUND_STATUS_APPLY, KylinTableStatusConst.ORDER_REFUND_STATUS_APPROVED, KylinTableStatusConst.ORDER_REFUND_STATUS_REFUSE};
}
break;
case "execute":
if (otherParam.get("status") == KylinTableStatusConst.ORDER_REFUND_STATUS_UNFILLED) { // 执行退款
whereStatus = new Integer[]{KylinTableStatusConst.ORDER_REFUND_STATUS_APPROVED, KylinTableStatusConst.ORDER_REFUND_STATUS_REFUSE, KylinTableStatusConst.ORDER_REFUND_STATUS_ERROR};
}
if (otherParam.get("status") == KylinTableStatusConst.ORDER_REFUND_STATUS_REFUSE) { // 拒绝退款
whereStatus = new Integer[]{KylinTableStatusConst.ORDER_REFUND_STATUS_APPROVED, KylinTableStatusConst.ORDER_REFUND_STATUS_ERROR};
}
break;
default:
throw new Exception("type异常,无法操作");
}
int count;
int limitNum = 1;
int mid = 0;
do {
List<KylinOrderRefunds> refundList = kylinOrderRefundsMapper.getRefundList(whereType, refundBatchId, whereStatus, mid, limitNum);
List<String> refundIds = null;
if (!refundList.isEmpty()) {
for (KylinOrderRefunds v : refundList) {
String refundId = v.getRefundId();
refundIds.add(refundId);
}
// 请求php接口
kylinRefundHttpSubmitServiceImpl.httpStatus(refundIds, otherParam);
}
count = refundList.size();
KylinOrderRefunds lastInfo = refundList.get(count - 1);
mid = lastInfo.getMid();
} while (count >= limitNum);
}
}
package com.liquidnet.service.kylin.service.impl.admin;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.JsonNode;
import com.liquidnet.commons.lang.util.HttpUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.kylin.entity.KylinOrderTicketEntities;
import com.liquidnet.service.kylin.entity.KylinOrderTickets;
import com.liquidnet.service.kylin.entity.KylinRefundBatches;
import com.liquidnet.service.kylin.mapper.KylinRefundBatchesMapper;
import com.liquidnet.service.kylin.service.IKylinRefundBatchesService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* <p>
* 后台退款 服务实现类
* </p>
*
* @author jiangxiulong
* @since 2021-05-26 13:00 下午
*/
@Service
public class KylinRefundHttpSubmitServiceImpl {
@Async
public void httpApply(KylinOrderTickets orderInfo, List<KylinOrderTicketEntities> entitiesList, HashMap<String, Object> otherParam, String refundBatchId) throws Exception {
String postUrl = "apply";
// 构造退款数据
List<String> ticketEntityIds = null;
if (!entitiesList.isEmpty()) {
for (KylinOrderTicketEntities v : entitiesList) {
String orderTicketsId = v.getOrderTicketEntitiesId();
ticketEntityIds.add(orderTicketsId);
}
}
HashMap<String, Object> refundData = new HashMap();
refundData.put("ticket_entity_ids", ticketEntityIds);
refundData.put("matter_items", new ArrayList()); //搭售不处理
if (ticketEntityIds.isEmpty()) {
throw new Exception("查询详情出错");
}
// 发起退款申请
MultiValueMap<String, String> headers = new LinkedMultiValueMap();
headers.add("Authorization", otherParam.get("token").toString());
MultiValueMap<String, String> formParams = new LinkedMultiValueMap();
formParams.add("order_type", "order_ticket");
formParams.add("order_id", orderInfo.getOrderTicketsId());
formParams.add("batch_id", refundBatchId);
formParams.add("reason", otherParam.get("reason").toString());
formParams.add("refund_data", JsonUtils.toJson(refundData));
/*HashMap<String, Object> postParams = new HashMap();
postParams.put("headers", headers);
postParams.put("form_params", formParams);*/
// 请求提审接口参数
String postResult = HttpUtil.post(postUrl, formParams, headers);
JsonNode postResultNew = JsonUtils.fromJson(postResult, JsonNode.class);
// 请求提审接口结果
if (postResultNew.get("message").toString() != "OK") {
throw new Exception("申请退款出错");
}
}
@Async
public void httpStatus(List<String> refundIds, HashMap<String, Object> otherParam) throws Exception {
String postUrl = "reapply";
// 发起退款申请
MultiValueMap<String, String> headers = new LinkedMultiValueMap();
headers.add("Authorization", otherParam.get("token").toString());
MultiValueMap<String, String> formParams = new LinkedMultiValueMap();
formParams.put("ids", refundIds);
String reject = otherParam.get("reject").toString();
if (reject.isEmpty()) reject = "";
String refuse = otherParam.get("refuse").toString();
if (refuse.isEmpty()) refuse = "";
String status = (String) otherParam.get("status");
if (status.isEmpty()) status = "0";
formParams.add("reject", reject);
formParams.add("status", status);
formParams.add("refuse", refuse);
// 请求提审接口参数
String postResult = HttpUtil.post(postUrl, formParams, headers);
JsonNode postResultNew = JsonUtils.fromJson(postResult, JsonNode.class);
// 请求提审接口结果
if (postResultNew.get("message").toString() != "OK") {
throw new Exception("操作出错");
}
}
}
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