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

Commit 539ed3c2 authored by jiangxiulong's avatar jiangxiulong

批量退款初步

parent 813f6960
package com.liquidnet.service.kylin.constant;
/**
* <p>
* Kylin表状态常量定义
* </p>
*
* @author jiangxiulong
* @since 2021-05-25 6:38 下午
*/
public class KylinTableStatusConst {
// 批量退款
public static final Integer STATUS_APPLY = 1; // 1申请退款
public static final Integer STATUS_CANCEL = 2; // 2取消退款
public static final Integer STATUS_OPERATE_REJECT = 3; // 3运营驳回审核
public static final Integer STATUS_OPERATE_ADOPT = 4; // 4运营通过审核
public static final Integer STATUS_FINANCE_REJECT = 5; // 5财务驳回审核
public static final Integer STATUS_FINANCE_ADOPT = 6; // 6财务通过审核
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_TYPE_APPLY = 0; // 人工申请类型的退款,可以取消退款,退款完成需返还库存
public static final Integer ORDER_REFUND_TYPE_AUTO = 1; // 自动申请类型的退款,无法取消退款,退款完成不返还库存
}
package com.liquidnet.service.kylin.service;
import com.liquidnet.service.kylin.entity.KylinRefundBatches;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 批量退款表 服务类
* </p>
*
* @author liquidnet
* @since 2021-05-25
*/
public interface IKylinRefundBatchesService extends IService<KylinRefundBatches> {
}
package com.liquidnet.service.kylin.service;
import com.liquidnet.service.kylin.entity.KylinRefunds;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 退款表 服务类
* </p>
*
* @author liquidnet
* @since 2021-05-26
*/
public interface IKylinRefundsService extends IService<KylinRefunds> {
}
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;
/**
* <p>
* 批量退款表
* </p>
*
* @author liquidnet
* @since 2021-05-25
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class KylinRefundBatches implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "mid", type = IdType.AUTO)
private Integer mid;
/**
* refund_batch_id
*/
private String refundBatchId;
/**
* 目标id target_type=1为演出id
*/
private String targetId;
/**
* 目标名称 target_type=1为演出名称
*/
private String targetTitle;
/**
* 目标类型 1演出
*/
private Integer targetType;
/**
* 批量退款状态 1申请退款 2取消退款 3运营驳回审核 4运营通过审核 5财务驳回审核 6财务通过审核
*/
private Integer status;
/**
* 批量退款总金额
*/
private BigDecimal totalPrice;
/**
* 实际批量退款总金额
*/
private BigDecimal realTotalPrice;
/**
* 批量退款总数量
*/
private Integer totalNum;
/**
* 实际批量退款总数量
*/
private Integer realTotalNum;
/**
* 申请时支付宝需退款总金额
*/
private BigDecimal totalRefundAlipay;
/**
* 申请时微信需退款总金额
*/
private BigDecimal totalRefundWepay;
/**
* 快递费总金额支付宝
*/
private BigDecimal totalPriceExpressAlipay;
/**
* 快递费总金额微信
*/
private BigDecimal totalPriceExpressWepay;
/**
* 批量退款原因
*/
private String reason;
/**
* 批量退款备注
*/
private String remark;
/**
* 驳回原因
*/
private String reject;
/**
* 回绝原因
*/
private String refuse;
/**
* 批量申请人id
*/
private Integer applicantId;
/**
* 批量申请人名称
*/
private String applicantName;
/**
* 批量申请时间
*/
private LocalDateTime applicantAt;
/**
* 批量审核人id
*/
private Integer auditorId;
/**
* 批量审核人名称
*/
private String auditorName;
/**
* 批量审核时间
*/
private LocalDateTime auditorAt;
/**
* 批量执行人id
*/
private Integer executorId;
/**
* 批量执行人名称
*/
private String executorName;
/**
* 批量执行时间
*/
private LocalDateTime executorAt;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
}
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;
/**
* <p>
* 退款表
* </p>
*
* @author liquidnet
* @since 2021-05-26
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class KylinRefunds implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "mid", type = IdType.AUTO)
private Integer mid;
/**
* refunds_id
*/
private String refundsId;
/**
* 商户id
*/
private String merchantId;
/**
* 退款状态: 0请求退款 2取消退款 1审核通过 5驳回退款 7等待退款 3正在退款 4完成退款 6退款失败
*/
private Integer status;
/**
* 退款差异: 0申请退款返还库存 1自动退款无法取消退款不返还库存
*/
private Integer type;
/**
* 订单id
*/
private String orderId;
/**
* 订单类型 order_product 商品订单 , order_ticket 票务订单
*/
private String orderType;
/**
* 订单中心订单号,这里方便查询
*/
private String orderCode;
/**
* 退款内容,演出title,商品title,这里方便查询
*/
private String orderTitle;
/**
* 退款手机号,这里方便查询
*/
private String orderMobile;
/**
* 支付中心支付单号,用于申请退款
*/
private String payCode;
/**
* 退款编号
*/
private String orderRefundCode;
/**
* 退款总金额
*/
private BigDecimal price;
/**
* 退款原因
*/
private String reason;
/**
* 退款备注
*/
private String remark;
/**
* 驳回原因
*/
private String reject;
/**
* 回绝原因
*/
private String refuse;
/**
* 退款中心退款编号
*/
private String refundCode;
/**
* 退款类型
*/
private String refundType;
/**
* 成功退款时间
*/
private LocalDateTime refundAt;
/**
* 第三方退款编号
*/
private String refundId;
/**
* 退款失败原因
*/
private String refundError;
/**
* 申请人id
*/
private Integer applicantId;
/**
* 申请人名称
*/
private String applicantName;
/**
* 申请时间
*/
private LocalDateTime applicantAt;
/**
* 审核人id
*/
private Integer auditorId;
/**
* 审核人名称
*/
private String auditorName;
/**
* 审核时间
*/
private LocalDateTime auditorAt;
/**
* 执行人id
*/
private Integer executorId;
/**
* 执行人名称
*/
private String executorName;
/**
* 执行时间
*/
private LocalDateTime executorAt;
/**
* 批量退款id
*/
private Integer batchId;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
/**
* 支付类型
*/
private String paymentType;
}
...@@ -3,14 +3,25 @@ package com.liquidnet.service.kylin.mapper; ...@@ -3,14 +3,25 @@ package com.liquidnet.service.kylin.mapper;
import com.liquidnet.service.kylin.entity.KylinOrderTickets; import com.liquidnet.service.kylin.entity.KylinOrderTickets;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.HashMap;
import java.util.List;
/** /**
* <p> * <p>
* 订单 Mapper 接口 * 订单 Mapper 接口
* </p> * </p>
* *
* @author liquidnet * @author jiangxiulong
* @since 2021-05-20 * @since 2021-05-25 14:00 下午
*/ */
public interface KylinOrderTicketsMapper extends BaseMapper<KylinOrderTickets> { public interface KylinOrderTicketsMapper extends BaseMapper<KylinOrderTickets> {
// 查询演出订单能退款的总金额和总订单数量
HashMap<String, Object> getPriceNum(String targetId);
// 查询微信、支付宝对应的订单金额、快递费金额
Double getTotalPrice(String targetId, String selectFields, String[] paymentType);
// 获取订单和购票信息
List getOrderEntities(String targetId, int mid, int limitNum);
} }
package com.liquidnet.service.kylin.mapper;
import com.liquidnet.service.kylin.entity.KylinRefundBatches;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 批量退款表 Mapper 接口
* </p>
*
* @author liquidnet
* @since 2021-05-25
*/
public interface KylinRefundBatchesMapper extends BaseMapper<KylinRefundBatches> {
}
package com.liquidnet.service.kylin.mapper;
import com.liquidnet.service.kylin.entity.KylinRefunds;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* <p>
* 退款表 Mapper 接口
* </p>
*
* @author liquidnet
* @since 2021-05-26
*/
public interface KylinRefundsMapper extends BaseMapper<KylinRefunds> {
List<KylinRefunds> getRefundList(Integer whereType, String refundBatchId, Integer[] whereStatus, int mid, int limitNum);
}
...@@ -2,4 +2,46 @@ ...@@ -2,4 +2,46 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!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.KylinOrderTicketsMapper"> <mapper namespace="com.liquidnet.service.kylin.mapper.KylinOrderTicketsMapper">
<select id="getPriceNum" resultType="java.util.HashMap">
SELECT SUM('o.price_actual') as total_price, SUM('o.number') as total_num
FROM kylin_order_tickets AS o
JOIN kylin_order_ticket_relations AS r ON r.order_id = o.order_tickets_id
JOIN kylin_order_ticket_status AS s ON s.order_id = o.order_tickets_id
<where>
r.performance_id=#{targetId}
AND s.status=1
AND s.pay_status=1
AND o.coupon_type='no'
</where>
</select>
<select id="getTotalPrice" resultType="java.lang.Double">
SELECT SUM(${selectFields})
FROM kylin_order_tickets AS o
JOIN kylin_order_ticket_relations AS r ON r.order_id = o.order_tickets_id
JOIN kylin_order_ticket_status AS s ON s.order_id = o.order_tickets_id
<where>
r.performance_id=#{targetId}
AND s.status=1
AND s.pay_status=1
AND o.coupon_type='no'
AND o.payment_type IN
<foreach collection="paymentType" item="payment_type" index="index" open="(" close=")" separator=",">
#{payment_type}
</foreach>
</where>
</select>
<select id="getOrderEntities" resultType="java.util.List">
SELECT o.mid, order_tickets_id, number, price_actual, performance_title
FROM kylin_order_tickets AS o
JOIN kylin_order_ticket_relations AS r ON r.order_id = o.order_tickets_id
JOIN kylin_order_ticket_status AS s ON s.order_id = o.order_tickets_id
<where>
r.performance_id=#{targetId}
AND s.status=1
AND s.pay_status=1
AND o.coupon_type='no'
AND o.mid>#{mid}
</where>
LIMIT #{limitNum}
</select>
</mapper> </mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!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.KylinRefundBatchesMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!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.KylinRefundsMapper">
<select id="getRefundList" resultType="com.liquidnet.service.kylin.entity.KylinRefunds">
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>
</mapper>
...@@ -643,4 +643,90 @@ insert into `kylin_buy_notice` (`buy_notice_id`, `img_url`, `message`, `status`, ...@@ -643,4 +643,90 @@ insert into `kylin_buy_notice` (`buy_notice_id`, `img_url`, `message`, `status`,
`updated_at`, `title`) `updated_at`, `title`)
values ('12', 'http://img-zhengzai-tv.oss-cn-hangzhou.aliyuncs.com/partner/2019/01/21/5c456d9482fb9.png', values ('12', 'http://img-zhengzai-tv.oss-cn-hangzhou.aliyuncs.com/partner/2019/01/21/5c456d9482fb9.png',
'电子票购票人须持本人身份证原件和订单二维码验票入场。请不要将身份证信息和订单二维码提供给他人,因此导致的损失,主办方/平台方不承担任何责任。', '1', '0', '2019-01-29 13:51:42', '电子票购票人须持本人身份证原件和订单二维码验票入场。请不要将身份证信息和订单二维码提供给他人,因此导致的损失,主办方/平台方不承担任何责任。', '1', '0', '2019-01-29 13:51:42',
'2019-01-29 13:51:42', '凭身份证原件兑票'); '2019-01-29 13:51:42', '凭身份证原件兑票');
\ No newline at end of file
# 批量退款表
drop TABLE if exists `kylin_refund_batches`;
CREATE TABLE `kylin_refund_batches`
(
`mid` int unsigned NOT NULL AUTO_INCREMENT,
`refund_batch_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'refund_batch_id',
`target_id` varchar(255) NOT NULL DEFAULT '' COMMENT '目标id target_type=1为演出id',
`target_title` varchar(255) NOT NULL DEFAULT '' COMMENT '目标名称 target_type=1为演出名称',
`target_type` tinyint NOT NULL DEFAULT '1' COMMENT '目标类型 1演出',
`status` tinyint NOT NULL DEFAULT '1' COMMENT '批量退款状态 1申请退款 2取消退款 3运营驳回审核 4运营通过审核 5财务驳回审核 6财务通过审核',
`total_price` decimal(11, 2) NOT NULL DEFAULT '0.00' COMMENT '批量退款总金额',
`real_total_price` decimal(11, 2) NOT NULL DEFAULT '0.00' COMMENT '实际批量退款总金额',
`total_num` int NOT NULL DEFAULT '0' COMMENT '批量退款总数量',
`real_total_num` int NOT NULL DEFAULT '0' COMMENT '实际批量退款总数量',
`total_refund_alipay` decimal(11, 2) NOT NULL DEFAULT '0.00' COMMENT '申请时支付宝需退款总金额',
`total_refund_wepay` decimal(11, 2) NOT NULL DEFAULT '0.00' COMMENT '申请时微信需退款总金额',
`total_price_express_alipay` decimal(11, 2) NOT NULL DEFAULT '0.00' COMMENT '快递费总金额支付宝',
`total_price_express_wepay` decimal(11, 2) NOT NULL DEFAULT '0.00' COMMENT '快递费总金额微信',
`reason` varchar(200) NOT NULL DEFAULT '' COMMENT '批量退款原因',
`remark` varchar(200) NOT NULL DEFAULT '' COMMENT '批量退款备注',
`reject` varchar(200) NOT NULL DEFAULT '' COMMENT '驳回原因',
`refuse` varchar(200) NOT NULL DEFAULT '' COMMENT '回绝原因',
`applicant_id` int NOT NULL DEFAULT '0' COMMENT '批量申请人id',
`applicant_name` varchar(100) NOT NULL DEFAULT '' COMMENT '批量申请人名称',
`applicant_at` timestamp NULL DEFAULT NULL COMMENT '批量申请时间',
`auditor_id` int NOT NULL DEFAULT '0' COMMENT '批量审核人id',
`auditor_name` varchar(100) NOT NULL DEFAULT '' COMMENT '批量审核人名称',
`auditor_at` timestamp NULL DEFAULT NULL COMMENT '批量审核时间',
`executor_id` int NOT NULL DEFAULT '0' COMMENT '批量执行人id',
`executor_name` varchar(100) NOT NULL DEFAULT '' COMMENT '批量执行人名称',
`executor_at` timestamp NULL DEFAULT NULL COMMENT '批量执行时间',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
KEY `kylin_refund_batch_id_index` (`refund_batch_id`),
PRIMARY KEY (`mid`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci COMMENT '批量退款表';
# 退款表
drop TABLE if exists `kylin_refunds`;
CREATE TABLE `kylin_refunds`
(
`mid` int unsigned NOT NULL AUTO_INCREMENT,
`refunds_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'refunds_id',
`merchant_id` varchar(255) NOT NULL DEFAULT '' COMMENT '商户id',
`status` tinyint NOT NULL DEFAULT '0' COMMENT '退款状态: 0请求退款 2取消退款 1审核通过 5驳回退款 7等待退款 3正在退款 4完成退款 6退款失败',
`type` tinyint NOT NULL DEFAULT '0' COMMENT '退款差异: 0申请退款返还库存 1自动退款无法取消退款不返还库存',
`order_id` varchar(255) NOT NULL DEFAULT '' COMMENT '订单id',
`order_type` varchar(50) NOT NULL DEFAULT '' COMMENT '订单类型 order_product 商品订单 , order_ticket 票务订单',
`order_code` varchar(50) NOT NULL COMMENT '订单中心订单号,这里方便查询',
`order_title` varchar(200) NOT NULL DEFAULT '' COMMENT '退款内容,演出title,商品title,这里方便查询',
`order_mobile` varchar(20) NOT NULL DEFAULT '' COMMENT '退款手机号,这里方便查询',
`pay_code` varchar(50) NOT NULL COMMENT '支付中心支付单号,用于申请退款',
`order_refund_code` varchar(50) NOT NULL COMMENT '退款编号',
`price` decimal(10, 2) NOT NULL DEFAULT '0.00' COMMENT '退款总金额',
`reason` varchar(200) NOT NULL DEFAULT '' COMMENT '退款原因',
`remark` varchar(200) NOT NULL DEFAULT '' COMMENT '退款备注',
`reject` varchar(200) NOT NULL DEFAULT '' COMMENT '驳回原因',
`refuse` varchar(200) NOT NULL DEFAULT '' COMMENT '回绝原因',
`refund_code` varchar(50) DEFAULT NULL COMMENT '退款中心退款编号',
`refund_type` varchar(20) DEFAULT NULL COMMENT '退款类型',
`refund_at` timestamp NULL DEFAULT NULL COMMENT '成功退款时间',
`refund_id` varchar(50) DEFAULT NULL COMMENT '第三方退款编号',
`refund_error` varchar(100) DEFAULT NULL COMMENT '退款失败原因',
`applicant_id` int NOT NULL DEFAULT '0' COMMENT '申请人id',
`applicant_name` varchar(100) NOT NULL DEFAULT '' COMMENT '申请人名称',
`applicant_at` timestamp NULL DEFAULT NULL COMMENT '申请时间',
`auditor_id` int NOT NULL DEFAULT '0' COMMENT '审核人id',
`auditor_name` varchar(100) NOT NULL DEFAULT '' COMMENT '审核人名称',
`auditor_at` timestamp NULL DEFAULT NULL COMMENT '审核时间',
`executor_id` int NOT NULL DEFAULT '0' COMMENT '执行人id',
`executor_name` varchar(100) NOT NULL DEFAULT '' COMMENT '执行人名称',
`executor_at` timestamp NULL DEFAULT NULL COMMENT '执行时间',
`batch_id` varchar(255) NOT NULL DEFAULT '' COMMENT '批量退款id',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`payment_type` varchar(20) NOT NULL DEFAULT '' COMMENT '支付类型',
PRIMARY KEY (`mid`),
UNIQUE KEY `kylin_refunds_order_refund_code_unique` (`order_refund_code`),
KEY `kylin_refunds_id_index` (`refunds_id`),
KEY `kylin_refunds_order_id_index` (`order_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci COMMENT ='退款表'
\ No newline at end of file
package com.liquidnet.service.kylin.controller.admin;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.dto.param.BannersParam;
import com.liquidnet.service.kylin.service.impl.admin.KylinRefundPerformancesAdminServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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 KylinRefundAdminController {
@Autowired
private KylinRefundPerformancesAdminServiceImpl kylinRefundPerformancesAdminServiceImpl;
@PostMapping("")
@ApiOperation("创建banner")
public ResponseDto<Object> create(@RequestBody @Validated BannersParam bannersParam) {
return ResponseDto.success();
/*Boolean res = kylinRefundAdminServiceImpl.create(bannersParam);
if (res) {
return ResponseDto.success();
} else {
return ResponseDto.failure("添加banner失败");
}*/
}
}
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 KylinRefundBatchAdminController {
@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("审核失败");
}
}
}
package com.liquidnet.service.kylin.controller.admin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 退款表 前端控制器
* </p>
*
* @author liquidnet
* @since 2021-05-26
*/
@RestController
@RequestMapping("/kylin-refunds")
public class KylinRefundsController {
}
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.KylinOrderTicketEntitiesMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketsMapper;
import com.liquidnet.service.kylin.mapper.KylinRefundBatchesMapper;
import com.liquidnet.service.kylin.mapper.KylinRefundsMapper;
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 extends ServiceImpl<KylinRefundBatchesMapper, KylinRefundBatches> implements IKylinRefundBatchesService {
@Autowired
private KylinOrderTicketsMapper kylinOrderTicketsMapper;
@Autowired
private KylinRefundsMapper kylinRefundsMapper;
@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<KylinRefunds> refundList = kylinRefundsMapper.getRefundList(whereType, refundBatchId, whereStatus, mid, limitNum);
List<String> refundIds = null;
if (!refundList.isEmpty()) {
for (KylinRefunds v : refundList) {
String refundId = v.getRefundId();
refundIds.add(refundId);
}
// 请求php接口
kylinRefundHttpSubmitServiceImpl.httpStatus(refundIds, otherParam);
}
count = refundList.size();
KylinRefunds 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 extends ServiceImpl<KylinRefundBatchesMapper, KylinRefundBatches> implements IKylinRefundBatchesService {
@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.liquidnet.service.kylin.entity.KylinRefunds;
import com.liquidnet.service.kylin.mapper.KylinRefundsMapper;
import com.liquidnet.service.kylin.service.IKylinRefundsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 退款表 服务实现类
* </p>
*
* @author liquidnet
* @since 2021-05-26
*/
@Service
public class KylinRefundsServiceImpl extends ServiceImpl<KylinRefundsMapper, KylinRefunds> implements IKylinRefundsService {
}
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