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

Commit 968bd1a9 authored by jiangxiulong's avatar jiangxiulong

platform refund app 去掉

parent b173b9da
...@@ -105,7 +105,6 @@ public class OrderRefundOvertimeServiceImpl extends ServiceImpl<KylinOrderRefund ...@@ -105,7 +105,6 @@ public class OrderRefundOvertimeServiceImpl extends ServiceImpl<KylinOrderRefund
List<String> ticketEntityIds = entitiesList.stream().map(KylinOrderTicketEntities -> KylinOrderTicketEntities.getOrderTicketEntitiesId()).collect(Collectors.toList()); List<String> ticketEntityIds = entitiesList.stream().map(KylinOrderTicketEntities -> KylinOrderTicketEntities.getOrderTicketEntitiesId()).collect(Collectors.toList());
List<Double> entitiesPrice = entitiesList.stream().map(KylinOrderTicketEntities -> KylinOrderTicketEntities.getCanRefundedPrice().doubleValue()).collect(Collectors.toList()); List<Double> entitiesPrice = entitiesList.stream().map(KylinOrderTicketEntities -> KylinOrderTicketEntities.getCanRefundedPrice().doubleValue()).collect(Collectors.toList());
boolean res = kylinRefundsStatusServiceImpl.orderTicketRefunding( boolean res = kylinRefundsStatusServiceImpl.orderTicketRefunding(
orderInfo, orderTicketsId, orderInfo, orderTicketsId,
RefundPriceExpress, RefundPriceExpress,
......
...@@ -3,13 +3,10 @@ package com.liquidnet.service.platform.controller.refund; ...@@ -3,13 +3,10 @@ package com.liquidnet.service.platform.controller.refund;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam; import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
import com.liquidnet.service.platform.service.refund.OrderRefundsCallbackServiceImpl; import com.liquidnet.service.platform.service.refund.OrderRefundsCallbackServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
...@@ -28,24 +25,6 @@ public class OrderRefundCallbackController { ...@@ -28,24 +25,6 @@ public class OrderRefundCallbackController {
@Autowired @Autowired
private OrderRefundsCallbackServiceImpl orderRefundsCallbackServiceImpl; private OrderRefundsCallbackServiceImpl orderRefundsCallbackServiceImpl;
@PostMapping("apply")
@ApiOperation("超时退款")
@ApiImplicitParams({
@ApiImplicitParam(type = "body", dataType = "String", name = "orderTicketsId", value = "订单ID", required = true),
})
public Boolean refundApply(@RequestParam() String orderTicketsId) {
try {
Boolean res = orderRefundsCallbackServiceImpl.refundApply(orderTicketsId);
if (res) {
return true;
} else {
return false;
}
} catch (Exception e) {
return false;
}
}
@PostMapping("callback") @PostMapping("callback")
@ApiOperation("退款回调") @ApiOperation("退款回调")
public String refundCallback(RefundCallbackParam refundCallbackParam) { public String refundCallback(RefundCallbackParam refundCallbackParam) {
......
...@@ -223,110 +223,6 @@ public class KylinRefundsStatusServiceImpl { ...@@ -223,110 +223,6 @@ public class KylinRefundsStatusServiceImpl {
return true; return true;
} }
public Boolean orderTicketRefunding(
KylinOrderTickets orderInfo, String orderTicketsId,
double RefundPriceExpress,
List<String> ticketEntityIds, List<Double> entitiesPrice
) {
if (CollectionUtil.isEmpty(ticketEntityIds)) {
return false;
}
// 基础数据
String authId = "";
String authName = "system_overtime_order_refund";
String reason = "订单支付超时自动退款";
// 本次退款票总金额
double entitiesPriceSum = entitiesPrice.stream().mapToDouble(Double::doubleValue).sum();
// TODO: 2021/5/27 事物 and 部分退款
// 更新数据
// 订单状态表 和 缓存
KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus();
orderStatusTable.setStatus(KylinTableStatusConst.ORDER_STATUS3);
kylinOrderTicketStatusMapper.update(orderStatusTable, new UpdateWrapper<KylinOrderTicketStatus>()
.eq("order_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)
);
dataUtils.delOrderTicketRedis(orderTicketsId);
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderTicketsId, null);
// 订单入场人表 和 缓存
for (String v : ticketEntityIds) {
KylinOrderTicketEntities entitiesTable = new KylinOrderTicketEntities();
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.ENTITIES_IS_PAYMENT2);
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)
);
dataUtils.delOrderTicketEntitiesRedis(v);
}
// 退款明细
KylinOrderRefunds kylinOrderRefunds = new KylinOrderRefunds();
String orderRefundsId = IDGenerator.nextSnowId();
kylinOrderRefunds.setOrderRefundsId(orderRefundsId);
kylinOrderRefunds.setOrderTicketsId(orderTicketsId);
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.concat(codeNum));
kylinOrderRefunds.setPrice(BigDecimal.valueOf(entitiesPriceSum));
kylinOrderRefunds.setPriceExpress(BigDecimal.valueOf(RefundPriceExpress));
kylinOrderRefunds.setStatus(KylinTableStatusConst.ORDER_REFUND_STATUS_APPLY);
kylinOrderRefunds.setType(KylinTableStatusConst.ORDER_REFUND_TYPE_APPLY);
kylinOrderRefunds.setApplicantId(authId);
kylinOrderRefunds.setApplicantName(authName);
kylinOrderRefunds.setApplicantAt(LocalDateTime.now());
kylinOrderRefunds.setType(1);
kylinOrderRefunds.setReason(reason);
if (RefundPriceExpress > 0 && entitiesPriceSum > 0) {
kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE3);
} else if (RefundPriceExpress > 0) {
kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE2);
} else if (entitiesPriceSum > 0) {
kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE1);
}
kylinOrderRefunds.setCreatedAt(LocalDateTime.now());
int rows = kylinOrderRefundsMapper.insert(kylinOrderRefunds);
// 退款入场人表
KylinOrderRefundEntities kylinOrderRefundEntities = new KylinOrderRefundEntities();
for (int i = 0; i <= ticketEntityIds.size() - 1; i++) {
String orderRefundsEntitiesId = IDGenerator.nextSnowId();
kylinOrderRefundEntities.setOrderRefundsEntitiesId(orderRefundsEntitiesId);
kylinOrderRefundEntities.setOrderRefundsId(orderRefundsId);
kylinOrderRefundEntities.setRefundPrice(BigDecimal.valueOf(entitiesPrice.get(i)));
kylinOrderRefundEntities.setOrderTicketEntitiesId(ticketEntityIds.get(i));
kylinOrderRefundEntities.setCreatedAt(LocalDateTime.now());
int rowsR = kylinOrderRefundsEntitiesMapper.insert(kylinOrderRefundEntities);
}
return true;
}
public Boolean userOrderTicketRefunding( public Boolean userOrderTicketRefunding(
KylinOrderTicketVo orderInfo, KylinOrderTicketVo orderInfo,
double refundPrice, double refundPrice,
......
package com.liquidnet.service.platform.service.refund; package com.liquidnet.service.platform.service.refund;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst; import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dao.KylinOrderTicketEntitiesDao;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam; import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
import com.liquidnet.service.kylin.entity.KylinOrderRefunds; import com.liquidnet.service.kylin.entity.KylinOrderRefunds;
import com.liquidnet.service.kylin.entity.KylinOrderTicketEntities;
import com.liquidnet.service.kylin.entity.KylinOrderTicketRelations;
import com.liquidnet.service.kylin.entity.KylinOrderTickets;
import com.liquidnet.service.kylin.mapper.*; import com.liquidnet.service.kylin.mapper.*;
import com.liquidnet.service.kylin.service.IKylinOrderRefundsService; import com.liquidnet.service.kylin.service.IKylinOrderRefundsService;
import com.liquidnet.service.platform.utils.DataUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
...@@ -41,21 +31,9 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun ...@@ -41,21 +31,9 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun
@Autowired @Autowired
private KylinOrderRefundsMapper kylinOrderRefundsMapper; private KylinOrderRefundsMapper kylinOrderRefundsMapper;
@Autowired
private KylinOrderTicketsMapper kylinOrderTicketsMapper;
@Autowired
private KylinOrderTicketEntitiesMapper kylinOrderTicketEntitiesMapper;
@Autowired
private KylinOrderTicketRelationsMapper kylinOrderTicketRelationsMapper;
@Autowired @Autowired
MongoTemplate mongoTemplate; MongoTemplate mongoTemplate;
@Autowired
private DataUtils dataUtils;
public String refundCallback(RefundCallbackParam refundCallbackParam) { public String refundCallback(RefundCallbackParam refundCallbackParam) {
KylinOrderRefunds refundInfo = kylinOrderRefundsMapper.selectOne( KylinOrderRefunds refundInfo = kylinOrderRefundsMapper.selectOne(
new UpdateWrapper<KylinOrderRefunds>() new UpdateWrapper<KylinOrderRefunds>()
...@@ -101,78 +79,4 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun ...@@ -101,78 +79,4 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun
return "success"; return "success";
} }
public Boolean refundApply(String orderTicketsId) {
KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne(
new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId)
);
KylinOrderTicketRelations orderRelations = kylinOrderTicketRelationsMapper.selectOne(
new QueryWrapper<KylinOrderTicketRelations>().eq("order_id", orderTicketsId)
);
// 传的快递费不能大于实际的快递费=(支付的快递费-已退的快递费)
Double refundPriceExpressSum = kylinOrderRefundsMapper.RefundPriceExpressSum(// 已退快递费
orderTicketsId,
KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL
);
if (null == refundPriceExpressSum) {
refundPriceExpressSum = 0.0;
}
Double RefundPriceExpress = orderInfo.getPriceExpress().doubleValue() - refundPriceExpressSum;
// 查询订单入场人
List<KylinOrderTicketEntitiesDao> entitiesListTemp = kylinOrderTicketEntitiesMapper.getOvertimeRefundEntitiesList(orderTicketsId);
List<KylinOrderTicketEntitiesDao> entitiesList = new ArrayList<>();
if(entitiesListTemp.size() > 0) {
double priceActual = orderInfo.getPriceActual().doubleValue();
double priceExpress = orderInfo.getPriceExpress().doubleValue();
int allEntitiesCount = kylinOrderTicketEntitiesMapper.selectCount(// 总入场人数量 排出未付款的 用来计算单入场人的价格
new QueryWrapper<KylinOrderTicketEntities>()
.eq("order_id", orderInfo.getOrderTicketsId())
// .ne("is_payment", KylinTableStatusConst.ENTITIES_IS_PAYMENT0)
);
double onePrice = (priceActual - priceExpress) / allEntitiesCount;//单价
for (KylinOrderTicketEntitiesDao entities : entitiesListTemp) {
Double refundedPrice = kylinOrderTicketEntitiesMapper.getRefundEntitiesPrice(//已退 包含退款中
orderInfo.getOrderTicketsId(),
KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL,
entities.getOrderTicketEntitiesId()
);
double canRefundedPrice;
if (null != refundedPrice) {
canRefundedPrice = onePrice - refundedPrice;
} else {
canRefundedPrice = onePrice;
}
entities.setCanRefundedPrice(BigDecimal.valueOf(canRefundedPrice));
if (canRefundedPrice > 0) { // 退款中但是可退款金额为0不展示
entitiesList.add(entities);
}
}
}
List<String> ticketEntityIds = entitiesList.stream().map(KylinOrderTicketEntities -> KylinOrderTicketEntities.getOrderTicketEntitiesId()).collect(Collectors.toList());
List<Double> entitiesPrice = entitiesList.stream().map(KylinOrderTicketEntities -> KylinOrderTicketEntities.getCanRefundedPrice().doubleValue()).collect(Collectors.toList());
boolean res = kylinRefundsStatusServiceImpl.orderTicketRefunding(
orderInfo, orderTicketsId,
RefundPriceExpress,
ticketEntityIds, entitiesPrice
);
if (res) {
// 超时直接退还库存
for (String entitiesId : ticketEntityIds) {
KylinOrderTicketEntities entitiesInfo = kylinOrderTicketEntitiesMapper.selectOne(
new QueryWrapper<KylinOrderTicketEntities>().eq("order_ticket_entities_id", entitiesId)
);
if (entitiesInfo.getIsPayment() == KylinTableStatusConst.ENTITIES_IS_PAYMENT3) {
dataUtils.changeSurplusGeneral(entitiesInfo.getTicketId(), 1);
dataUtils.changeBuyInfo(orderInfo.getUserId(), entitiesInfo.getEnterIdCode(), orderRelations.getPerformanceId(), entitiesInfo.getTicketId(), -1);
}
}
return true;
} else {
return false;
}
}
} }
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