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

Commit 8d4960ba authored by jiangxiulong's avatar jiangxiulong

批量退款

parent 7f4b1097
......@@ -91,14 +91,13 @@ public class KylinOrderRefundBatchAdminController extends BaseController {
@ResponseBody
public AjaxResult refundBatchApply(RefundBatchApplyParam refundBatchApplyParam) {
try {
Boolean res = kylinRefundPerformancesAdminServiceImpl.refundBatchApply(refundBatchApplyParam);
if (res) {
ResponseDto res = kylinRefundPerformancesAdminServiceImpl.refundBatchApply(refundBatchApplyParam);
if (res.isSuccess()) {
return success();
} else {
return error("申请退款失败");
return error(res.getMessage());
}
} catch (Exception e) {
e.printStackTrace();
return error(e.getMessage());
}
}
......
......@@ -60,25 +60,35 @@
var options = {
data: result.performanceOrderStatisticalDao,
pagination: false,
columns: [{
checkbox: true
},
columns: [
{
field: 'title',
title: '票种名'
},
{
field: 'price',
title: '单价'
},
{
field: 'type',
title: '类型'
title: '类型',
formatter: function (value, row, index) {
var typeName = "";
switch (value) {
case 1:
typeName = "单日票";
break;
case 2:
typeName = "通票";
break;
}
return typeName;
}
},
{
field: 'useStart',
title: '适用时间'
},
{
field: 'price',
title: '单价'
},
{
field: 'saleGeneral',
title: '销售总数量'
......@@ -87,10 +97,6 @@
field: 'totalMemberNumber',
title: '会员销售数量'
},
{
field: 'surplusGeneral',
title: '库存数量'
},
{
field: 'totalPayingNumber',
title: '正在支付数量'
......@@ -103,6 +109,10 @@
field: 'totalSalePrice',
title: '销售额(元)'
},
{
field: 'surplusGeneral',
title: '库存数量'
},
{
field: 'totalExchange',
title: '兑换数量'
......
......@@ -45,7 +45,7 @@ public class KylinRefundExecuteServiceImpl {
@Autowired
private KylinOrderRefundsServiceImpl kylinOrderRefundsServiceImpl;
public void refundBatchApply(String targetId, String refundBatchId, String reason) throws Exception {
public void refundBatchApply(String targetId, String refundBatchId, String reason) {
RefundApplyParam refundApplyParam = new RefundApplyParam();
int count;
int limitNum = 100;
......
......@@ -55,31 +55,29 @@ public class KylinRefundPerformancesAdminServiceImpl {
@Autowired
RedisUtil redisUtil;
public Boolean refundBatchApply(RefundBatchApplyParam refundBatchApplyParam) throws Exception {
public ResponseDto refundBatchApply(RefundBatchApplyParam refundBatchApplyParam) {
String targetId = refundBatchApplyParam.getTargetId();
HashMap<String, Object> priceNum = kylinOrderTicketsMapper.getPriceNum(targetId);
Integer totalNum = 0;
if (null != priceNum) {
double totalPrice = Double.parseDouble(priceNum.get("total_price").toString());
totalNum = Integer.parseInt(priceNum.get("total_num").toString());
if (totalPrice <= 0 || totalNum <= 0) throw new Exception("当前演出暂无需要退款的订单,请确认后重试!");
// 查询需要退的金额和数量
String[] paymentTypeAlipay = {"APPALIPAY", "WAPALIPAY", "alipay"};
HashMap<String, Object> orderStatisAlipay = kylinOrderTicketsMapper.getPerformanceRefundOrderStatis(targetId, paymentTypeAlipay);
String[] paymentTypeWepay = {"APPWEPAY", "APPLETWEPAY", "WAPWEPAY", "JSWEPAY", "wepay"};
HashMap<String, Object> orderStatisWepay = kylinOrderTicketsMapper.getPerformanceRefundOrderStatis(targetId, paymentTypeWepay);
Double totalPriceRefundAlipay = 0.0;
Integer totalRefundNumberAlipay = 0;
Double totalPriceRefundWepay = 0.0;
Integer totalRefundNumberWepay = 0;
if (null != orderStatisAlipay || null != orderStatisWepay) {
totalPriceRefundAlipay = (Double) orderStatisAlipay.get("total_price_refund");
totalRefundNumberAlipay = (Integer) orderStatisAlipay.get("total_refund_number");
totalPriceRefundWepay = (Double) orderStatisWepay.get("total_price_refund");
totalRefundNumberWepay = (Integer) orderStatisWepay.get("total_refund_number");
if (totalPriceRefundAlipay <= 0 || totalPriceRefundWepay <= 0) {
return ResponseDto.failure("演出退款金额为0,无需退款");
}
} else {
throw new Exception("当前演出暂无需要退款的订单,请确认后重试!");
return ResponseDto.failure("演出暂无需要退款的订单");
}
// 汇总退款
/*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);*/
String[] paymentTypeAlipayArray = {"APPALIPAY", "WAPALIPAY", "alipay"};
Double totalAlipay = kylinOrderTicketsMapper.getTotalPrice(targetId, "price_actual", paymentTypeAlipayArray);
String[] paymentTypeWepayArray = {"APPWEPAY", "APPLETWEPAY", "WAPWEPAY", "JSWEPAY", "wepay"};
Double totalWepay = kylinOrderTicketsMapper.getTotalPrice(targetId, "price_actual", paymentTypeWepayArray);
KylinOrderRefundBatches refundBatchesInfo = kylinOrderRefundBatchesMapper.selectOne(
new QueryWrapper<KylinOrderRefundBatches>().eq("target_id", targetId).orderByDesc("refund_batch_id")
);
......@@ -94,12 +92,12 @@ public class KylinRefundPerformancesAdminServiceImpl {
createData.setRefundBatchId(refundBatchId);
createData.setTargetId(targetId);
createData.setStatus(KylinTableStatusConst.STATUS_APPLY);
createData.setTotalNum(totalNum);
if (null != totalAlipay) {
createData.setTotalAlipay(BigDecimal.valueOf(totalAlipay));
createData.setTotalNum(totalRefundNumberAlipay + totalRefundNumberWepay);
if (null != totalPriceRefundAlipay) {
createData.setTotalAlipay(BigDecimal.valueOf(totalPriceRefundAlipay));
}
if (null != totalWepay) {
createData.setTotalWepay(BigDecimal.valueOf(totalWepay));
if (null != totalPriceRefundWepay) {
createData.setTotalWepay(BigDecimal.valueOf(totalPriceRefundWepay));
}
createData.setCreatedAt(LocalDateTime.now());
......@@ -107,12 +105,12 @@ public class KylinRefundPerformancesAdminServiceImpl {
if (resNum > 0) {
// 开始执行批量提交审核 分批处理退款申请
kylinRefundExecuteServiceImpl.refundBatchApply(targetId, refundBatchId, refundBatchApplyParam.getReason());
return true;
return ResponseDto.success();
} else {
return false;
return ResponseDto.failure("操作失败");
}
} else {
throw new Exception("该演出已经提交过申请,请刷新申请列表查看");
return ResponseDto.failure("该演出已经提交过申请,请刷新申请列表查看");
}
}
......
......@@ -22,10 +22,7 @@ import java.util.Map;
public interface KylinOrderTicketsMapper extends BaseMapper<KylinOrderTickets> {
// 查询演出订单能退款的总金额和总订单数量
HashMap<String, Object> getPriceNum(String targetId);
// 查询微信、支付宝对应的订单金额、快递费金额
Double getTotalPrice(@Param("targetId") String targetId, @Param("selectFields") String selectFields, @Param("paymentType") String[] paymentType);
HashMap<String, Object> getPerformanceRefundOrderStatis(@Param("targetId") String targetId, @Param("paymentType") String[] paymentType);
// 获取订单和购票信息
List<KylinOrderTickets> getOrderList(@Param("targetId") String targetId, @Param("mid") int mid, @Param("limitNum") int limitNum);
......
......@@ -51,9 +51,9 @@
<result column="user_id" property="userId"/>
</resultMap>
<select id="getPriceNum" resultType="java.util.HashMap">
SELECT SUM(o.price_actual) as total_price, SUM(o.number) as total_num
<select id="getPerformanceRefundOrderStatis" resultType="java.util.HashMap">
SELECT
SUM(o.price_actual - o.price_refund) as total_price_refund, SUM(o.number - o.refund_number) as total_refund_number
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
......@@ -62,24 +62,12 @@
AND s.status=1
AND s.pay_status=1
AND o.coupon_type='no'
</where>
LIMIT 1
</select>
<select id="getTotalPrice" parameterType="java.lang.String" 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>
LIMIT 1
</select>
<select id="getOrderList" parameterType="java.lang.String"
resultType="com.liquidnet.service.kylin.entity.KylinOrderTickets">
......
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