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

Commit 8d4960ba authored by jiangxiulong's avatar jiangxiulong

批量退款

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