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

Commit cc0cbf69 authored by jiangxiulong's avatar jiangxiulong

支付前演出票接口 and refund

parent 3d0e62cc
......@@ -20,31 +20,48 @@ public class KylinTableStatusConst {
public static final Integer STATUS_TARGET_TYPE = 1; // 演出
// 退款
public static final Integer ORDER_REFUND_STATUS_APPLY = 0; // 客服(待审核),用户(正在退款)
public static final Integer ORDER_REFUND_STATUS_APPROVED = 1; // 客服(已通过),用户(正在退款)
public static final Integer ORDER_REFUND_STATUS_CANCEL = 2; // 客服(已取消),用户(取消退款,恢复正常订单)
public static final Integer ORDER_REFUND_STATUS_REFUNDING = 3; // 客服(正在退款),用户(正在退款)
public static final Integer ORDER_REFUND_STATUS_REFUNDED = 4; // 客服(退款成功),用户(完成退款,部分退款为正常订单,全额退款为退款订单)
public static final Integer ORDER_REFUND_STATUS_REJECT = 5; // 客服(被审核员驳回),用户(正在退款)
public static final Integer ORDER_REFUND_STATUS_ERROR = 6; // 客服(退款失败),用户(正在退款)
public static final Integer ORDER_REFUND_STATUS_UNFILLED = 7; // 客服(等待退款),用户(正在退款)
public static final Integer ORDER_REFUND_STATUS_REFUSE = 8; // 客服(被执行员拒绝),用户(正在退款)
public static final Integer ORDER_REFUND_STATUS_APPLY = 0; // 客服(待审核),用户(正在退款)
public static final Integer ORDER_REFUND_STATUS_APPROVED = 1; // 客服(已通过),用户(正在退款)
public static final Integer ORDER_REFUND_STATUS_CANCEL = 2; // 客服(已取消),用户(取消退款,恢复正常订单)
public static final Integer ORDER_REFUND_STATUS_REFUNDING = 3; // 客服(正在退款),用户(正在退款)
public static final Integer ORDER_REFUND_STATUS_REFUNDED = 4; // 客服(退款成功),用户(完成退款,部分退款为正常订单,全额退款为退款订单)
public static final Integer ORDER_REFUND_STATUS_REJECT = 5; // 客服(被审核员驳回),用户(正在退款)
public static final Integer ORDER_REFUND_STATUS_ERROR = 6; // 客服(退款失败),用户(正在退款)
public static final Integer ORDER_REFUND_STATUS_UNFILLED = 7; // 客服(等待退款),用户(正在退款)
public static final Integer ORDER_REFUND_STATUS_REFUSE = 8; // 客服(被执行员拒绝),用户(正在退款)
public static final Integer ORDER_REFUND_TYPE_APPLY = 0; // 人工申请类型的退款,可以取消退款,退款完成需返还库存
public static final Integer ORDER_REFUND_TYPE_AUTO = 1; // 自动申请类型的退款,无法取消退款,退款完成不返还库存
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 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 STATUS_WAIT_CLOSE = 5; // 待关闭
// 订单转赠状态
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("操作出错");
}
}
}
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.commons.lang.util.IDGenerator;
import com.liquidnet.service.kylin.constant.KylinRedisConst;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dto.vo.KylinPerformanceVo;
import com.liquidnet.service.kylin.entity.KylinRefundBatches;
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.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
/**
* <p>
* 后台退款 服务实现类
* status 0待付款,1已付款,2已关闭,3正在退款,4已退款, 5待关闭
* pay_status 支付状态:0未支付 1已支付 2支付失败等
* </p>
*
* @author jiangxiulong
* @since 2021-05-25 11:26 上午
*/
@Service
public class KylinRefundPerformancesAdminServiceImpl {
@Autowired
private KylinOrderTicketsMapper kylinOrderTicketsMapper;
@Autowired
private KylinRefundBatchesMapper kylinRefundBatchesMapper;
@Autowired
private KylinRefundExecuteServiceImpl kylinRefundExecuteServiceImpl;
@Autowired
RedisUtil redisUtil;
public Boolean refundBatchApply(String targetId, Integer targetType, Integer authId, String authName, HashMap<String, Object> OtherParam) throws Exception {
HashMap<String, Object> priceNum = kylinOrderTicketsMapper.getPriceNum(targetId);
Double totalPrice = (Double) priceNum.get("total_price");
Integer totalNum = (Integer) priceNum.get("total_num");
if (totalPrice < 0 || totalNum < 0) throw new Exception("当前演出暂无需要退款的订单,请确认后重试!");
// 汇总退款
String[] paymentTypeAlipayArray = {"APPALIPAY", "WAPALIPAY", "alipay"};
double totalRefundAlipay = kylinOrderTicketsMapper.getTotalPrice(targetId, "price_actual", paymentTypeAlipayArray);
String[] paymentTypeWepayArray = {"APPWEPAY", "APPLETWEPAY", "WAPWEPAY", "JSWEPAY", "wepay"};
double totalRefundWepay = kylinOrderTicketsMapper.getTotalPrice(targetId, "price_actual", paymentTypeWepayArray);
double totalPriceExpressAlipay = kylinOrderTicketsMapper.getTotalPrice(targetId, "price_express", paymentTypeAlipayArray);
double totalPriceExpressWepay = kylinOrderTicketsMapper.getTotalPrice(targetId, "price_express", paymentTypeWepayArray);
KylinRefundBatches refundBatchesInfo = kylinRefundBatchesMapper.selectOne(
new UpdateWrapper<KylinRefundBatches>().eq("target_id", targetId).eq("target_type", targetType).orderByDesc("refund_batch_id")
);
if (refundBatchesInfo.getRefundBatchId().isEmpty() || refundBatchesInfo.getStatus() == KylinTableStatusConst.STATUS_CANCEL || refundBatchesInfo.getStatus() == KylinTableStatusConst.STATUS_FINANCE_ADOPT) {
// 添加演出退款记录
KylinPerformanceVo performancesInfo = (KylinPerformanceVo) redisUtil.hget(KylinRedisConst.PERFORMANCES, targetId);
String refundBatchId = IDGenerator.nextSnowId().toString();
KylinRefundBatches createData = new KylinRefundBatches();
createData.setRefundBatchId(refundBatchId);
createData.setTargetTitle(performancesInfo.getTitle());
createData.setTotalPrice(BigDecimal.valueOf(totalPrice));
createData.setTotalNum(totalNum);
createData.setTotalRefundAlipay(BigDecimal.valueOf(totalRefundAlipay));
createData.setTotalRefundWepay(BigDecimal.valueOf(totalRefundWepay));
createData.setTotalPriceExpressAlipay(BigDecimal.valueOf(totalPriceExpressAlipay));
createData.setTotalPriceExpressWepay(BigDecimal.valueOf(totalPriceExpressWepay));
createData.setApplicantId(authId);
createData.setApplicantName(authName);
createData.setStatus(KylinTableStatusConst.STATUS_APPLY);
createData.setApplicantAt(LocalDateTime.now());
int resNum = kylinRefundBatchesMapper.insert(createData);
if (resNum > 0) {
// 开始执行批量提交审核 分批处理退款申请
kylinRefundExecuteServiceImpl.refundBatchApply(targetId, refundBatchId, OtherParam);
return true;
} else {
return false;
}
} else {
throw new Exception("该演出已经提交过申请,请刷新申请列表查看");
}
}
public Boolean refundBatchReapply(String refundBatchId, String remark, HashMap<String, Object> otherParam) throws Exception {
Integer[] paymentTypeAlipayArray = {KylinTableStatusConst.STATUS_OPERATE_REJECT, KylinTableStatusConst.STATUS_FINANCE_REJECT};
KylinRefundBatches refundBatchesInfo = kylinRefundBatchesMapper.selectOne(
new UpdateWrapper<KylinRefundBatches>().eq("refund_batch_id", refundBatchId).in("status", paymentTypeAlipayArray)
);
if (!refundBatchesInfo.getRefundBatchId().isEmpty()) {
// 开始执行批量提交审核 分批处理退款申请
kylinRefundExecuteServiceImpl.refundBatchStatus(refundBatchId, otherParam);
KylinRefundBatches params = new KylinRefundBatches();
params.setStatus(KylinTableStatusConst.STATUS_APPLY);
params.setRemark(remark);
kylinRefundBatchesMapper.update(params, new UpdateWrapper<KylinRefundBatches>().eq("refund_batch_id", refundBatchId));
return true;
} else {
throw new Exception("当前状态下不允许此操作");
}
}
public Boolean refundBatchCancel(String refundBatchId, HashMap<String, Object> otherParam) throws Exception {
Integer[] paymentTypeAlipayArray = {KylinTableStatusConst.STATUS_APPLY, KylinTableStatusConst.STATUS_OPERATE_REJECT, KylinTableStatusConst.STATUS_OPERATE_ADOPT, KylinTableStatusConst.STATUS_FINANCE_REJECT};
KylinRefundBatches refundBatchesInfo = kylinRefundBatchesMapper.selectOne(
new UpdateWrapper<KylinRefundBatches>().eq("refund_batch_id", refundBatchId).in("status", paymentTypeAlipayArray)
);
if (!refundBatchesInfo.getRefundBatchId().isEmpty()) {
// 开始执行批量提交审核 分批处理退款申请
kylinRefundExecuteServiceImpl.refundBatchStatus(refundBatchId, otherParam);
KylinRefundBatches params = new KylinRefundBatches();
params.setStatus(KylinTableStatusConst.STATUS_CANCEL);
kylinRefundBatchesMapper.update(params, new UpdateWrapper<KylinRefundBatches>().eq("refund_batch_id", refundBatchId));
return true;
} else {
throw new Exception("当前状态下不允许此操作");
}
}
public Boolean refundBatchReview(String refundBatchId, HashMap<String, Object> otherParam) throws Exception {
Integer batchStatus = (Integer) otherParam.get("status");
Integer updateStatus = 0;
if (KylinTableStatusConst.STATUS_OPERATE_REJECT == batchStatus) {// 驳回
updateStatus = KylinTableStatusConst.ORDER_REFUND_STATUS_REJECT;
} else if (KylinTableStatusConst.STATUS_OPERATE_ADOPT == batchStatus) {// 通过
updateStatus = KylinTableStatusConst.ORDER_REFUND_STATUS_APPROVED;
}
Integer[] paymentTypeAlipayArray = {KylinTableStatusConst.STATUS_APPLY};
KylinRefundBatches refundBatchesInfo = kylinRefundBatchesMapper.selectOne(
new UpdateWrapper<KylinRefundBatches>().eq("refund_batch_id", refundBatchId).in("status", paymentTypeAlipayArray)
);
if (!refundBatchesInfo.getRefundBatchId().isEmpty()) {
// 开始执行批量提交审核 分批处理退款申请
otherParam.put("status", updateStatus);
kylinRefundExecuteServiceImpl.refundBatchStatus(refundBatchId, otherParam);
KylinRefundBatches params = new KylinRefundBatches();
params.setStatus(batchStatus);
params.setReject((String) otherParam.get("reject"));
params.setAuditorId(2);
params.setAuditorName("2222");
params.setAuditorAt(LocalDateTime.now());
kylinRefundBatchesMapper.update(params, new UpdateWrapper<KylinRefundBatches>().eq("refund_batch_id", refundBatchId));
return true;
} else {
throw new Exception("当前状态下不允许此操作");
}
}
public Boolean refundBatchExecute(String refundBatchId, HashMap<String, Object> otherParam) throws Exception {
Integer batchStatus = (Integer) otherParam.get("status");
Integer updateStatus = 0;
if (KylinTableStatusConst.STATUS_FINANCE_REJECT == batchStatus) {// 驳回
updateStatus = KylinTableStatusConst.ORDER_REFUND_STATUS_REFUSE;
} else if (KylinTableStatusConst.STATUS_FINANCE_ADOPT == batchStatus) {// 通过
updateStatus = KylinTableStatusConst.ORDER_REFUND_STATUS_UNFILLED;
}
Integer[] paymentTypeAlipayArray = {KylinTableStatusConst.STATUS_APPLY};
KylinRefundBatches refundBatchesInfo = kylinRefundBatchesMapper.selectOne(
new UpdateWrapper<KylinRefundBatches>().eq("refund_batch_id", refundBatchId).in("status", paymentTypeAlipayArray)
);
if (!refundBatchesInfo.getRefundBatchId().isEmpty()) {
// 开始执行批量提交审核 分批处理退款申请
otherParam.put("status", updateStatus);
kylinRefundExecuteServiceImpl.refundBatchStatus(refundBatchId, otherParam);
KylinRefundBatches params = new KylinRefundBatches();
params.setStatus(batchStatus);
params.setRefuse((String) otherParam.get("refuse"));
params.setExecutorId(2);
params.setExecutorName("2222");
params.setExecutorAt(LocalDateTime.now());
kylinRefundBatchesMapper.update(params, new UpdateWrapper<KylinRefundBatches>().eq("refund_batch_id", refundBatchId));
return true;
} else {
throw new Exception("当前状态下不允许此操作");
}
}
}
package com.liquidnet.service.kylin.service.impl.admin;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.JsonNode;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dto.vo.KylinBannersVo;
import com.liquidnet.service.kylin.dto.vo.KylinOrderTicketEntitiesVo;
import com.liquidnet.service.kylin.dto.vo.KylinOrderTicketVo;
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.KylinOrderTicketStatusMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketsMapper;
import com.liquidnet.service.kylin.utils.DataUtils;
import com.mongodb.BasicDBObject;
import com.mongodb.client.model.FindOneAndUpdateOptions;
import com.mongodb.client.model.ReturnDocument;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpException;
import org.bson.Document;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* <p>
* 退款表 服务实现类
* </p>
*
* @author jiaangxiulong
* @since 2021-05-26
*/
@Service
public class KylinRefundsStatusServiceImpl {
@Autowired
private KylinOrderTicketsMapper kylinOrderTicketsMapper;
@Autowired
private KylinOrderTicketStatusMapper kylinOrderTicketStatusMapper;
@Autowired
private KylinOrderRefundsMapper kylinOrderRefundsMapper;
@Autowired
private KylinOrderTicketEntitiesMapper kylinOrderTicketEntitiesMapper;
@Autowired
MongoTemplate mongoTemplate;
public Boolean orderTicketRefunding(String orderTicketsId, String refundData, String reason, String orderRefundBatchesId) throws HttpException {
// 处理数据
String authId = "434";
String authName = "sss";
JsonNode refundDataJson = JsonUtils.fromJson(refundData, JsonNode.class);
JsonNode ticketEntityIds = refundDataJson.get("ticketEntityIds");
double RefundpriceExpress = refundDataJson.get("RefundpriceExpress").doubleValue();
KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne(
new UpdateWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId)
);
KylinOrderTicketStatus orderStatus = kylinOrderTicketStatusMapper.selectOne(
new UpdateWrapper<KylinOrderTicketStatus>().eq("order_id", orderTicketsId)
);
int thisOrderStatus = orderStatus.getStatus();
int thisPayStatus = orderStatus.getPayStatus();
double priceExpress = orderInfo.getPriceExpress().doubleValue();
double priceActual = orderInfo.getPriceActual().doubleValue();
// todo 转增是否能退
// 订单状态需已付款
if (thisOrderStatus != KylinTableStatusConst.ORDER_STATUS1) {
throw new HttpException("订单状态信息有误");
}
// 订单支付状态需为已支付
if (thisPayStatus != KylinTableStatusConst.ORDER_PAY_STATUS1) {
throw new HttpException("订单支付信息有误");
}
// 传的快递费不能大于实际的快递费
if (RefundpriceExpress > priceExpress) {
throw new HttpException("快递费不能大于实际的快递费");
}
// 该订单正在退款或已有退款
QueryWrapper<com.liquidnet.service.kylin.entity.KylinOrderRefunds> refundingCountQuery = new QueryWrapper<KylinOrderRefunds>()
.eq("order_tickets_id", orderTicketsId)
.ne("status", KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL);
for (JsonNode v : ticketEntityIds) {
refundingCountQuery.like("order_ticket_entities_ids", v);
}
int refundingCount = kylinOrderRefundsMapper.selectCount(refundingCountQuery);
if (refundingCount > 0) {
throw new HttpException("该订单正在退款或已有退款");
}
// 该订单的入场人未付款/正在退款/已退款
// TODO: 2021/5/27 出票未出票不知是否要处理
QueryWrapper<KylinOrderTicketEntities> notPayCountQuery = new QueryWrapper<KylinOrderTicketEntities>()
.in("order_ticket_entities_id", ticketEntityIds)
.in("is_payment", new Integer[]{
KylinTableStatusConst.ENTITIES_IS_PAYMENT0,
KylinTableStatusConst.ENTITIES_IS_PAYMENT2,
KylinTableStatusConst.ENTITIES_IS_PAYMENT3});
int notPayCount = kylinOrderTicketEntitiesMapper.selectCount(notPayCountQuery);
// 选择退款的入场人是否正确
// TODO: 2021/5/27 出票未出票不知是否要处理
QueryWrapper<KylinOrderTicketEntities> choiceCountQuery = new QueryWrapper<KylinOrderTicketEntities>()
.eq("order_id", orderTicketsId)
.eq("is_payment", KylinTableStatusConst.ENTITIES_IS_PAYMENT1)
.in("order_ticket_entities_id", ticketEntityIds);
int choiceCount = kylinOrderTicketEntitiesMapper.selectCount(choiceCountQuery);
int ticketEntityCount = ticketEntityIds.size();
if (choiceCount < 0 || choiceCount != ticketEntityCount) {
throw new HttpException("入场人订单有误或不存在");
}
// 本次退款总金额
// 总入场人数量 排出未付款的 用来计算单入场人的价格
int allEntitiesCount = kylinOrderTicketEntitiesMapper.selectCount(
new QueryWrapper<KylinOrderTicketEntities>()
.eq("order_id", orderTicketsId)
.ne("is_payment", KylinTableStatusConst.ENTITIES_IS_PAYMENT0)
);
double refundTotalPrice = RefundpriceExpress + ((priceActual - priceExpress) / allEntitiesCount * ticketEntityCount);
// 更新数据
// 订单状态表
KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus();
// TODO: 2021/5/27 事物 and 部分退款
orderStatusTable.setStatus(KylinTableStatusConst.ORDER_STATUS3);
kylinOrderTicketStatusMapper.update(orderStatusTable, new UpdateWrapper<KylinOrderTicketStatus>()
.eq("order_ticket_status_id", orderTicketsId));
KylinOrderTicketVo kylinOrderTicketVo = new KylinOrderTicketVo();
kylinOrderTicketVo.setStatus(KylinTableStatusConst.ORDER_STATUS3);
BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketVo)));
Document orderDoc = mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("orderTicketsId").is(orderTicketsId)).getQueryObject(),
orderObject,
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
);
new DataUtils().delOrderTicketRedis(orderTicketsId);
// 入场人
for (JsonNode v : ticketEntityIds) {
KylinOrderTicketEntities entitiesTable = new KylinOrderTicketEntities();
// TODO: 2021/5/27 事物 and 部分退款
entitiesTable.setIsPayment(KylinTableStatusConst.ENTITIES_IS_PAYMENT2);
kylinOrderTicketEntitiesMapper.update(entitiesTable, new UpdateWrapper<KylinOrderTicketEntities>()
.eq("order_ticket_entities_id", v));
KylinOrderTicketEntitiesVo kylinOrderTicketEntitiesVo = new KylinOrderTicketEntitiesVo();
kylinOrderTicketEntitiesVo.setIsPayment(KylinTableStatusConst.ORDER_STATUS3);
BasicDBObject entitiesObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketEntitiesVo)));
Document entitiesDoc = mongoTemplate.getCollection(KylinOrderTicketEntitiesVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("orderTicketEntitiesId").is(v)).getQueryObject(),
entitiesObject,
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
);
new DataUtils().delOrderTicketEntitiesRedis(v.toString());
}
// 退款明细
KylinOrderRefunds kylinOrderRefunds = new KylinOrderRefunds();
String orderRefundsId = IDGenerator.nextSnowId().toString();
kylinOrderRefunds.setOrderRefundsId(orderRefundsId);
kylinOrderRefunds.setOrderTicketsId(orderTicketsId);
kylinOrderRefunds.setOrderRefundBatchesId(orderRefundBatchesId);
Integer refundCount = kylinOrderRefundsMapper.selectCount(
new QueryWrapper<KylinOrderRefunds>()
.eq("order_tickets_id", orderTicketsId)
);
String orderRefundCode = orderInfo.getOrderCode();
String codeNum = StringUtils.leftPad(String.valueOf(refundCount), 3, "0");
kylinOrderRefunds.setOrderRefundCode(orderRefundCode + codeNum);
kylinOrderRefunds.setPrice(BigDecimal.valueOf(refundTotalPrice));
kylinOrderRefunds.setStatus(KylinTableStatusConst.ORDER_REFUND_STATUS_APPLY);
kylinOrderRefunds.setType(0);
kylinOrderRefunds.setApplicantId(authId);
kylinOrderRefunds.setApplicantName(authName);
kylinOrderRefunds.setApplicantAt(LocalDateTime.now());
kylinOrderRefunds.setReason(reason);
// TODO: 2021/5/27 判断tyoe
if (RefundpriceExpress > 0) {
kylinOrderRefunds.setRefundType("all");
} else {
kylinOrderRefunds.setRefundType("ticket");
}
kylinOrderRefunds.setOrderTicketEntitiesIds(ticketEntityIds.toString());
kylinOrderRefunds.setCreatedAt(LocalDateTime.now());
return true;
}
}
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