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

Commit 52740aa2 authored by 胡佳晨's avatar 胡佳晨

order 迁移 增加 退款

parent 2360534e
package com.liquidnet.service.order.controller;
import com.liquidnet.service.order.service.impl.OrderRefundOvertimeServiceImpl;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 退款回掉
* </p>
*
* @author jiangxiulong
* @since 2021-06-11 6:10 下午
*/
@Api(tags = "前端-退款回调")
@RestController
@RequestMapping("refund")
public class OrderRefundOvertimeController {
@Autowired
private OrderRefundOvertimeServiceImpl orderRefundOvertimeServiceImpl;
@PostMapping("apply")
@ApiOperation("超时退款")
@ApiImplicitParams({
@ApiImplicitParam(type = "body", dataType = "String", name = "orderTicketsId", value = "订单ID", required = true),
})
public Boolean refundApply(@RequestParam() String orderTicketsId) {
try {
Boolean res = orderRefundOvertimeServiceImpl.refundApply(orderTicketsId);
if (res) {
return true;
} else {
return false;
}
} catch (Exception e) {
return false;
}
}
}
package com.liquidnet.service.order.service.impl;
import com.liquidnet.service.kylin.service.IKylinOrderRefundPicService;
import org.springframework.stereotype.Service;
@Service
public class KylinOrderRefundPicServiceImpl implements IKylinOrderRefundPicService {
}
......@@ -92,10 +92,10 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
private RabbitTemplate rabbitTemplate;
@Autowired
private TaobaoTicketUtils taobaoTicketUtils;
// @Autowired
// private OrderRefundOvertimeServiceImpl orderRefundsCallbackService;
// @Autowired
// private KylinRefundsStatusServiceImpl refundsStatusService;
@Autowired
private OrderRefundOvertimeServiceImpl orderRefundsCallbackService;
@Autowired
private KylinRefundsStatusServiceImpl refundsStatusService;
ArrayList<Integer> canBuyStatus = new ArrayList() {{
......
package com.liquidnet.service.order.service.impl;
import com.alibaba.fastjson.JSON;
import com.liquidnet.common.mq.constant.MQConst;
import com.liquidnet.commons.lang.util.CollectionUtil;
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.base.SqlMapping;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderRefundEntitiesVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderRefundPicVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketEntitiesVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketVo;
import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderRefundsVo;
import com.liquidnet.service.kylin.entity.*;
import com.liquidnet.service.order.utils.DataUtils;
import com.liquidnet.service.order.utils.MongoVoUtils;
import com.mongodb.BasicDBObject;
import com.mongodb.client.result.UpdateResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
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.util.LinkedList;
import java.util.List;
/**
* <p>
* 订单退款表 服务实现类 处理数据 退款后状态的变化
* </p>
*
* @author jiaangxiulong
* @since 2021-05-26
*/
@Slf4j
@Service
public class KylinRefundsStatusServiceImpl {
@Autowired
MongoTemplate mongoTemplate;
@Autowired
private DataUtils dataUtils;
@Autowired
private MongoVoUtils mongoVoUtils;
@Autowired
private RabbitTemplate rabbitTemplate;
public Boolean orderTicketRefunding(
KylinOrderTicketVo 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();
// 更新数据
// 订单状态表 和 缓存
LocalDateTime nowTime = LocalDateTime.now();
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(nowTime);
KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus();
orderStatusTable.setStatus(KylinTableStatusConst.ORDER_STATUS3);
orderStatusTable.setUpdatedAt(nowTime);
/*kylinOrderTicketStatusMapper.update(orderStatusTable, new UpdateWrapper<KylinOrderTicketStatus>()
.eq("order_id", orderTicketsId));*/
KylinOrderTicketVo kylinOrderTicketVo = new KylinOrderTicketVo();
kylinOrderTicketVo.setStatus(KylinTableStatusConst.ORDER_STATUS3);
kylinOrderTicketVo.setUpdatedAt(nowTimeStr);
BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketVo)));
UpdateResult orderResult = mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderTicketsId").is(orderTicketsId)).getQueryObject(),
orderObject
);
dataUtils.delOrderTicketRedis(orderTicketsId);
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderTicketsId, null);
// 订单入场人表 和 缓存
KylinOrderTicketEntities entitiesTable = new KylinOrderTicketEntities();
entitiesTable.setIsPayment(KylinTableStatusConst.ENTITIES_IS_PAYMENT2);
entitiesTable.setUpdatedAt(nowTime);
KylinOrderTicketEntitiesVo kylinOrderTicketEntitiesVo = new KylinOrderTicketEntitiesVo();
kylinOrderTicketEntitiesVo.setIsPayment(KylinTableStatusConst.ENTITIES_IS_PAYMENT2);
kylinOrderTicketEntitiesVo.setUpdatedAt(nowTimeStr);
BasicDBObject entitiesObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketEntitiesVo)));
LinkedList<Object[]> sqlsDataB = new LinkedList<>();
for (String v : ticketEntityIds) {
sqlsDataB.add(new Object[]{
entitiesTable.getIsPayment(), entitiesTable.getUpdatedAt(), v, orderInfo.getChangeDate(), orderInfo.getChangeDate()
});
/*kylinOrderTicketEntitiesMapper.update(entitiesTable, new UpdateWrapper<KylinOrderTicketEntities>()
.eq("order_ticket_entities_id", v));*/
UpdateResult entitiesResult = mongoTemplate.getCollection(KylinOrderTicketEntitiesVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderTicketEntitiesId").is(v)).getQueryObject(),
entitiesObject
);
dataUtils.delOrderTicketEntitiesRedis(v);
}
// 退款明细
KylinOrderRefunds kylinOrderRefunds = new KylinOrderRefunds();
String orderRefundsId = IDGenerator.nextSnowId();
kylinOrderRefunds.setOrderRefundsId(orderRefundsId);
kylinOrderRefunds.setOrderTicketsId(orderTicketsId);
String orderRefundCode = orderInfo.getOrderCode();
String codeNum = StringUtils.leftPad(String.valueOf(5), 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_AUTO);
kylinOrderRefunds.setApplicantId(authId);
kylinOrderRefunds.setApplicantName(authName);
kylinOrderRefunds.setApplicantAt(nowTime);
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(nowTime);
/*int rows = kylinOrderRefundsMapper.insert(kylinOrderRefunds);*/
KylinOrderRefundsVo orderRefundsVo = new KylinOrderRefundsVo();
BeanUtils.copyProperties(kylinOrderRefunds,orderRefundsVo);
mongoTemplate.insert(orderRefundsVo, KylinOrderRefundsVo.class.getSimpleName());
// 退款入场人表
KylinOrderRefundEntities kylinOrderRefundEntities = new KylinOrderRefundEntities();
kylinOrderRefundEntities.setOrderRefundsId(orderRefundsId);
kylinOrderRefundEntities.setCreatedAt(LocalDateTime.now());
LinkedList<Object[]> sqlsDataD = new LinkedList<>();
for (int i = 0; i <= ticketEntityIds.size() - 1; i++) {
String orderRefundsEntitiesId = IDGenerator.nextSnowId();
kylinOrderRefundEntities.setOrderRefundsEntitiesId(orderRefundsEntitiesId);
kylinOrderRefundEntities.setRefundPrice(BigDecimal.valueOf(entitiesPrice.get(i)));
kylinOrderRefundEntities.setOrderTicketEntitiesId(ticketEntityIds.get(i));
sqlsDataD.add(new Object[]{
kylinOrderRefundEntities.getOrderRefundsEntitiesId(), kylinOrderRefundEntities.getOrderRefundsId(), kylinOrderRefundEntities.getRefundPrice(),
kylinOrderRefundEntities.getOrderTicketEntitiesId(), kylinOrderRefundEntities.getCreatedAt()
});
/*int rowsR = kylinOrderRefundsEntitiesMapper.insert(kylinOrderRefundEntities);*/
KylinOrderRefundEntitiesVo orderRefundEntitiesVo = new KylinOrderRefundEntitiesVo();
BeanUtils.copyProperties(kylinOrderRefundEntities,orderRefundEntitiesVo);
mongoTemplate.insert(orderRefundEntitiesVo,KylinOrderRefundEntitiesVo.class.getSimpleName());
}
//mq更改数据库
LinkedList<String> sqls = new LinkedList<>();
LinkedList<Object[]> sqlsDataA = new LinkedList<>();
LinkedList<Object[]> sqlsDataC = new LinkedList<>();
sqls.add(SqlMapping.get("kylin_order_ticket_status.overtimeRefund"));
sqls.add(SqlMapping.get("kylin_order_ticket_entities.overtimeRefund"));
sqls.add(SqlMapping.get("kylin_order_refund.overtimeRefund"));
sqls.add(SqlMapping.get("kylin_order_refund_entities.overtimeRefund"));
sqlsDataA.add(new Object[]{
orderStatusTable.getStatus(), orderStatusTable.getUpdatedAt(), orderInfo.getOrderTicketsId(), orderInfo.getChangeDate(), orderInfo.getChangeDate()
});
sqlsDataC.add(new Object[]{
kylinOrderRefunds.getOrderRefundsId(), kylinOrderRefunds.getOrderTicketsId(), kylinOrderRefunds.getOrderRefundCode(),
kylinOrderRefunds.getPrice(), kylinOrderRefunds.getPriceExpress(), kylinOrderRefunds.getStatus(),
kylinOrderRefunds.getType(), kylinOrderRefunds.getApplicantId(), kylinOrderRefunds.getApplicantName(),
kylinOrderRefunds.getApplicantAt(), kylinOrderRefunds.getReason(),
kylinOrderRefunds.getRefundCate(), kylinOrderRefunds.getCreatedAt()
});
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL_ORDER_OVERTIME_REFUND, MQConst.ROUTING_KEY_SQL_ORDER_OVERTIME_REFUND,
SqlMapping.gets(sqls, sqlsDataA, sqlsDataB, sqlsDataC, sqlsDataD));
return true;
}
public String userOrderTicketRefunding(
KylinOrderTicketVo orderInfo,
double refundPrice,
String orderEntitiesId,
String reason,
String picList,
String uid,
String username,
int refundCount
) {
try {
LocalDateTime time = LocalDateTime.now();
String strTime = DateUtil.Formatter.yyyyMMddHHmmss.format(time);
// 订单状态表 和 缓存
KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus();
orderStatusTable.setStatus(KylinTableStatusConst.ORDER_STATUS3);
orderStatusTable.setUpdatedAt(time);
KylinOrderTicketVo kylinOrderTicketVo = new KylinOrderTicketVo();
kylinOrderTicketVo.setStatus(KylinTableStatusConst.ORDER_STATUS3);
kylinOrderTicketVo.setUpdatedAt(DateUtil.Formatter.yyyyMMddHHmmss.format(time));
BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketVo)));
mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderTicketsId").is(orderInfo.getOrderTicketsId())).getQueryObject(),
orderObject
);
dataUtils.delOrderTicketRedis(orderInfo.getOrderTicketsId());
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderInfo.getOrderTicketsId(), null);
// 订单入场人表 和 缓存
KylinOrderTicketEntities entitiesTable = new KylinOrderTicketEntities();
entitiesTable.setIsPayment(KylinTableStatusConst.ENTITIES_IS_PAYMENT2);
entitiesTable.setUpdatedAt(time);
KylinOrderTicketEntitiesVo kylinOrderTicketEntitiesVo = new KylinOrderTicketEntitiesVo();
kylinOrderTicketEntitiesVo.setIsPayment(KylinTableStatusConst.ENTITIES_IS_PAYMENT2);
kylinOrderTicketEntitiesVo.setUpdatedAt(strTime);
BasicDBObject entitiesObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketEntitiesVo)));
mongoTemplate.getCollection(KylinOrderTicketEntitiesVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderTicketEntitiesId").is(orderEntitiesId)).getQueryObject(),
entitiesObject
);
dataUtils.delOrderTicketEntitiesRedis(orderEntitiesId);
// 退款明细
KylinOrderRefunds kylinOrderRefunds = new KylinOrderRefunds();
String orderRefundsId = IDGenerator.nextSnowId();
kylinOrderRefunds.setOrderRefundsId(orderRefundsId);
kylinOrderRefunds.setOrderTicketsId(orderInfo.getOrderTicketsId());
String orderRefundCode = orderInfo.getOrderCode();
String codeNum = StringUtils.leftPad(String.valueOf(refundCount), 3, "0");
kylinOrderRefunds.setOrderRefundCode(orderRefundCode.concat(codeNum));
kylinOrderRefunds.setPrice(BigDecimal.valueOf(refundPrice));
kylinOrderRefunds.setPriceExpress(orderInfo.getPriceExpress());
kylinOrderRefunds.setStatus(KylinTableStatusConst.ORDER_REFUND_STATUS_APPLY);
kylinOrderRefunds.setType(KylinTableStatusConst.ORDER_REFUND_TYPE_APPLY);
kylinOrderRefunds.setApplicantId(uid);
kylinOrderRefunds.setApplicantName(username);
kylinOrderRefunds.setApplicantAt(time);
kylinOrderRefunds.setReason(reason);
if (orderInfo.getPriceExpress().doubleValue() > 0 && refundPrice > 0) {
kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE3);
} else if (orderInfo.getPriceExpress().doubleValue() > 0) {
kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE2);
} else if (refundPrice > 0) {
kylinOrderRefunds.setRefundCate(KylinTableStatusConst.ORDER_REFUND_CATE1);
}
kylinOrderRefunds.setCreatedAt(time);
KylinOrderRefundsVo orderRefundsVo = new KylinOrderRefundsVo();
BeanUtils.copyProperties(kylinOrderRefunds,orderRefundsVo);
orderRefundsVo.setCreatedAt(time);
orderRefundsVo.setApplicantAt(time);
mongoTemplate.insert(orderRefundsVo, KylinOrderRefundsVo.class.getSimpleName());
// 退款入场人表
KylinOrderRefundEntities kylinOrderRefundEntities = new KylinOrderRefundEntities();
String orderRefundsEntitiesId = IDGenerator.nextSnowId();
kylinOrderRefundEntities.setOrderRefundsEntitiesId(orderRefundsEntitiesId);
kylinOrderRefundEntities.setOrderRefundsId(orderRefundsId);
kylinOrderRefundEntities.setRefundPrice(BigDecimal.valueOf(refundPrice));
kylinOrderRefundEntities.setOrderTicketEntitiesId(orderEntitiesId);
kylinOrderRefundEntities.setCreatedAt(time);
KylinOrderRefundEntitiesVo orderRefundEntitiesVo = new KylinOrderRefundEntitiesVo();
BeanUtils.copyProperties(kylinOrderRefundEntities,orderRefundEntitiesVo);
orderRefundEntitiesVo.setCreatedAt(strTime);
mongoTemplate.insert(orderRefundEntitiesVo,KylinOrderRefundEntitiesVo.class.getSimpleName());
//退款图片
KylinOrderRefundPic orderRefundPic = new KylinOrderRefundPic();
orderRefundPic.setRefundPicId(IDGenerator.nextSnowId());
orderRefundPic.setOrderRefundsId(kylinOrderRefunds.getOrderRefundsId());
orderRefundPic.setPicUrl(picList);
orderRefundPic.setCreatedAt(time);
KylinOrderRefundPicVo orderRefundPicVo = new KylinOrderRefundPicVo();
BeanUtils.copyProperties(orderRefundPic,orderRefundPicVo);
orderRefundPicVo.setCreatedAt(strTime);
mongoTemplate.insert(orderRefundPicVo,KylinOrderRefundPicVo.class.getSimpleName());
dataUtils.delOrderRefundVoByOrderId(orderInfo.getOrderTicketsId());
//MQ
LinkedList<String> sqls = new LinkedList<>();
LinkedList<Object[]> sqlsDataA = new LinkedList<>();
LinkedList<Object[]> sqlsDataB = new LinkedList<>();
LinkedList<Object[]> sqlsDataC = new LinkedList<>();
LinkedList<Object[]> sqlsDataD = new LinkedList<>();
LinkedList <Object[]> sqlsDataE = new LinkedList<>();
sqls.add(SqlMapping.get("kylin_order_ticket_status.refund"));
sqls.add(SqlMapping.get("kylin_order_ticket_entities.refund"));
sqls.add(SqlMapping.get("kylin_order_refund.refund"));
sqls.add(SqlMapping.get("kylin_order_refund_entities.refund"));
sqls.add(SqlMapping.get("kylin_order_refund_pic.refund"));
sqlsDataA.add(new Object[]{
orderStatusTable.getStatus(), orderStatusTable.getUpdatedAt(), orderInfo.getOrderTicketsId(), orderInfo.getChangeDate(), orderInfo.getChangeDate()
});
sqlsDataB.add(new Object[]{
entitiesTable.getIsPayment(), entitiesTable.getUpdatedAt(), orderEntitiesId, orderInfo.getChangeDate(), orderInfo.getChangeDate()
});
sqlsDataC.add(new Object[]{
kylinOrderRefunds.getOrderRefundsId(), kylinOrderRefunds.getOrderTicketsId(), kylinOrderRefunds.getOrderRefundCode(),
kylinOrderRefunds.getPrice(), kylinOrderRefunds.getPriceExpress(), kylinOrderRefunds.getStatus(),
kylinOrderRefunds.getType(), kylinOrderRefunds.getApplicantId(), kylinOrderRefunds.getApplicantName(),
kylinOrderRefunds.getApplicantAt(), kylinOrderRefunds.getReason(),
kylinOrderRefunds.getRefundCate(), kylinOrderRefunds.getCreatedAt()
});
sqlsDataD.add(new Object[]{
kylinOrderRefundEntities.getOrderRefundsEntitiesId(), kylinOrderRefundEntities.getOrderRefundsId(), kylinOrderRefundEntities.getRefundPrice(),
kylinOrderRefundEntities.getOrderTicketEntitiesId(), kylinOrderRefundEntities.getCreatedAt()
});
sqlsDataE.add(new Object[]{
orderRefundPic.getOrderRefundsId(), orderRefundPic.getOrderRefundsId(), orderRefundPic.getPicUrl(), orderRefundPic.getCreatedAt()
});
//TODO 生成新QUERY
rabbitTemplate.convertAndSend(MQConst.EXCHANGES_LIQUIDNET_SQL_ORDER_REFUND, MQConst.ROUTING_KEY_SQL_ORDER_REFUND,
SqlMapping.gets(sqls, sqlsDataA, sqlsDataB, sqlsDataC, sqlsDataD, sqlsDataE));
return kylinOrderRefunds.getOrderRefundsId();
}catch (Exception e){
e.printStackTrace();
return "";
}
}
}
package com.liquidnet.service.order.service.impl;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketEntitiesVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketVo;
import com.liquidnet.service.kylin.service.IKylinOrderRefundsService;
import com.liquidnet.service.order.utils.DataUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
* 订单退款表 服务实现类 处理逻辑判断
* </p>
*
* @author jiangxiulong
* @since 2021-05-26
*/
@Slf4j
@Service
public class OrderRefundOvertimeServiceImpl implements IKylinOrderRefundsService {
@Autowired
private KylinRefundsStatusServiceImpl kylinRefundsStatusServiceImpl;
@Autowired
MongoTemplate mongoTemplate;
@Autowired
private DataUtils dataUtils;
public Boolean refundApply(String orderTicketsId) {
KylinOrderTicketVo orderInfo = dataUtils.getOrderTicketVo(orderTicketsId);
// 快递费 未进行判断
Double RefundPriceExpress = orderInfo.getPriceExpress().doubleValue();
double priceActual = orderInfo.getPriceActual().doubleValue();
double priceExpress = orderInfo.getPriceExpress().doubleValue();
// 查询订单入场人
List<KylinOrderTicketEntitiesVo> entitiesList = orderInfo.getEntitiesVoList();
if (!CollectionUtil.isEmpty(entitiesList)) {
int allEntitiesCount = entitiesList.size();// 总入场人数量 排出未付款的 用来计算单入场人的价格
double onePrice = (priceActual - priceExpress) / allEntitiesCount;//单价
for (KylinOrderTicketEntitiesVo entities : entitiesList) {
entities.setCanRefundedPrice(BigDecimal.valueOf(onePrice));
}
}
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 (KylinOrderTicketEntitiesVo entitiesInfo : entitiesList) {
// 因固定状态为未支付 所以无需判断 entitiesInfo.getIsPayment() == KylinTableStatusConst.ENTITIES_IS_PAYMENT3
dataUtils.changeSurplusGeneral(entitiesInfo.getTicketId(), 1);
dataUtils.changeBuyInfo(orderInfo.getUserId(), entitiesInfo.getEnterIdCode(), orderInfo.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