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

Commit 825603c0 authored by anjiabin's avatar anjiabin

Merge branch 'dev' into test

parents 0964e8f6 b173b9da
......@@ -194,7 +194,6 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
ticketEntityIds, realRefundPriceList
);
// KylinOrderTicketVo vo = new KylinOrderTicketVo();
HashMap<String,Object> map = new HashMap<>();
map.put("isHaveRefundDetails",1);
BasicDBObject obj = new BasicDBObject("$set", mongoConverter.convertToMongoType(map));
......
......@@ -8,11 +8,14 @@ import com.liquidnet.client.admin.common.utils.StringUtils;
import com.liquidnet.client.admin.zhengzai.kylin.utils.DataUtils;
import com.liquidnet.client.admin.zhengzai.kylin.utils.MongoVoUtils;
import com.liquidnet.commons.lang.util.*;
import com.liquidnet.service.base.UserPathDto;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dto.param.RefundApplyParam;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderRefundEntitiesVo;
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.kylin.mapper.*;
import com.mongodb.BasicDBObject;
......@@ -21,6 +24,7 @@ import com.mongodb.client.model.ReturnDocument;
import com.mongodb.client.result.UpdateResult;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.MongoTemplate;
......@@ -105,11 +109,13 @@ public class KylinRefundsStatusServiceImpl {
// 订单状态表 和 缓存
KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus();
orderStatusTable.setStatus(KylinTableStatusConst.ORDER_STATUS3);
orderStatusTable.setUpdatedAt(LocalDateTime.now());
kylinOrderTicketStatusMapper.update(orderStatusTable, new UpdateWrapper<KylinOrderTicketStatus>()
.eq("order_id", orderTicketsId));
KylinOrderTicketVo kylinOrderTicketVo = new KylinOrderTicketVo();
kylinOrderTicketVo.setStatus(KylinTableStatusConst.ORDER_STATUS3);
kylinOrderTicketVo.setUpdatedAt(DateUtil.getNowTime());
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(),
......@@ -124,11 +130,13 @@ public class KylinRefundsStatusServiceImpl {
for (String v : ticketEntityIds) {
KylinOrderTicketEntities entitiesTable = new KylinOrderTicketEntities();
entitiesTable.setIsPayment(KylinTableStatusConst.ENTITIES_IS_PAYMENT2);
entitiesTable.setUpdatedAt(LocalDateTime.now());
kylinOrderTicketEntitiesMapper.update(entitiesTable, new UpdateWrapper<KylinOrderTicketEntities>()
.eq("order_ticket_entities_id", v));
KylinOrderTicketEntitiesVo kylinOrderTicketEntitiesVo = new KylinOrderTicketEntitiesVo();
kylinOrderTicketEntitiesVo.setIsPayment(KylinTableStatusConst.ENTITIES_IS_PAYMENT2);
kylinOrderTicketEntitiesVo.setUpdatedAt(DateUtil.getNowTime());
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(),
......@@ -172,6 +180,10 @@ public class KylinRefundsStatusServiceImpl {
}
kylinOrderRefunds.setCreatedAt(LocalDateTime.now());
int rows = kylinOrderRefundsMapper.insert(kylinOrderRefunds);
// 添加缓存
KylinOrderRefundsVo kylinOrderRefundsVo = new KylinOrderRefundsVo();
BeanUtils.copyProperties(kylinOrderRefunds, kylinOrderRefundsVo);
mongoTemplate.insert(kylinOrderRefundsVo, KylinOrderRefundsVo.class.getSimpleName());
// 退款入场人表
KylinOrderRefundEntities kylinOrderRefundEntities = new KylinOrderRefundEntities();
......@@ -183,6 +195,10 @@ public class KylinRefundsStatusServiceImpl {
kylinOrderRefundEntities.setOrderTicketEntitiesId(ticketEntityIds.get(i));
kylinOrderRefundEntities.setCreatedAt(LocalDateTime.now());
int rowsR = kylinOrderRefundsEntitiesMapper.insert(kylinOrderRefundEntities);
// 添加缓存
KylinOrderRefundEntitiesVo kylinOrderRefundEntitiesVo = new KylinOrderRefundEntitiesVo();
BeanUtils.copyProperties(kylinOrderRefundEntities, kylinOrderRefundEntitiesVo);
mongoTemplate.insert(kylinOrderRefundEntitiesVo, KylinOrderRefundEntitiesVo.class.getSimpleName());
}
return true;
......@@ -222,11 +238,13 @@ public class KylinRefundsStatusServiceImpl {
KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus();
orderStatusTable.setStatus(newStatus);
orderStatusTable.setUpdatedAt(LocalDateTime.now());
kylinOrderTicketStatusMapper.update(orderStatusTable, new UpdateWrapper<KylinOrderTicketStatus>()
.eq("order_id", orderTicketsId));
KylinOrderTicketVo kylinOrderTicketVo = new KylinOrderTicketVo();
kylinOrderTicketVo.setStatus(newStatus);
kylinOrderTicketVo.setUpdatedAt(DateUtil.getNowTime());
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(),
......@@ -258,6 +276,7 @@ public class KylinRefundsStatusServiceImpl {
}
KylinOrderTicketEntities entitiesTable = new KylinOrderTicketEntities();
entitiesTable.setIsPayment(newIsPayment);
entitiesTable.setUpdatedAt(LocalDateTime.now());
kylinOrderTicketEntitiesMapper.update(entitiesTable, new UpdateWrapper<KylinOrderTicketEntities>()
.eq("order_ticket_entities_id", entitiesId)
.eq("is_payment", KylinTableStatusConst.ENTITIES_IS_PAYMENT2)
......@@ -265,6 +284,7 @@ public class KylinRefundsStatusServiceImpl {
KylinOrderTicketEntitiesVo kylinOrderTicketEntitiesVo = new KylinOrderTicketEntitiesVo();
kylinOrderTicketEntitiesVo.setIsPayment(newIsPayment);
kylinOrderTicketEntitiesVo.setUpdatedAt(DateUtil.getNowTime());
BasicDBObject entitiesObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketEntitiesVo)));
Document entitiesDoc = mongoTemplate.getCollection(KylinOrderTicketEntitiesVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("orderTicketEntitiesId").is(entitiesId)).getQueryObject(),
......@@ -281,6 +301,15 @@ public class KylinRefundsStatusServiceImpl {
kylinOrderRefunds.setUpdatedAt(LocalDateTime.now());
kylinOrderRefundsMapper.update(kylinOrderRefunds, new UpdateWrapper<KylinOrderRefunds>()
.eq("order_refunds_id", orderRefundsId));
// 修改缓存
KylinOrderRefundsVo kylinOrderRefundsVo = new KylinOrderRefundsVo();
kylinOrderRefundsVo.setStatus(KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL);
kylinOrderRefundsVo.setUpdatedAt(LocalDateTime.now());
BasicDBObject object = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderRefundsVo)));
UpdateResult updateResult = mongoTemplate.getCollection(KylinOrderRefundsVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderRefundsId").is(orderRefundsId)).getQueryObject(),
object
);
}
return true;
......@@ -321,6 +350,7 @@ public class KylinRefundsStatusServiceImpl {
break;
}
kylinOrderRefunds.setUpdatedAt(LocalDateTime.now());
List<String> orderRefundIds = refundList.stream().map(
KylinOrderRefunds -> KylinOrderRefunds.getOrderRefundsId()).collect(Collectors.toList()
);
......@@ -328,6 +358,14 @@ public class KylinRefundsStatusServiceImpl {
kylinOrderRefunds,
new UpdateWrapper<KylinOrderRefunds>().in("order_refunds_id", orderRefundIds)
);
// 修改缓存
KylinOrderRefundsVo kylinOrderRefundsVo = new KylinOrderRefundsVo();
BeanUtils.copyProperties(kylinOrderRefunds, kylinOrderRefundsVo);
BasicDBObject object = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderRefundsVo)));
UpdateResult updateResult = mongoTemplate.getCollection(KylinOrderRefundsVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderRefundsId").in(orderRefundIds)).getQueryObject(),
object
);
return true;
}
......@@ -342,6 +380,7 @@ public class KylinRefundsStatusServiceImpl {
kylinOrderRefunds.setExecutorName(authName);
kylinOrderRefunds.setExecutorAt(LocalDateTime.now());
kylinOrderRefunds.setRefuse(refuse);
kylinOrderRefunds.setUpdatedAt(LocalDateTime.now());
for (KylinOrderRefunds refund : refundList) {
KylinOrderTickets oderInfo = kylinOrderTicketsMapper.selectOne(
......@@ -368,7 +407,15 @@ public class KylinRefundsStatusServiceImpl {
// 更新退款表
kylinOrderRefundsMapper.update(
kylinOrderRefunds,
new UpdateWrapper<KylinOrderRefunds>().in("order_refunds_id", refund.getOrderRefundsId())
new UpdateWrapper<KylinOrderRefunds>().eq("order_refunds_id", refund.getOrderRefundsId())
);
// 修改缓存
KylinOrderRefundsVo kylinOrderRefundsVo = new KylinOrderRefundsVo();
BeanUtils.copyProperties(kylinOrderRefunds, kylinOrderRefundsVo);
BasicDBObject object = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderRefundsVo)));
UpdateResult updateResult = mongoTemplate.getCollection(KylinOrderRefundsVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderRefundsId").is(refund.getOrderRefundsId())).getQueryObject(),
object
);
}
......@@ -496,15 +543,26 @@ public class KylinRefundsStatusServiceImpl {
kylinOrderRefunds,
new UpdateWrapper<KylinOrderRefunds>().in("order_refunds_id", refundInfo.getOrderRefundsId())
);
// 修改缓存
KylinOrderRefundsVo kylinOrderRefundsVo = new KylinOrderRefundsVo();
BeanUtils.copyProperties(kylinOrderRefunds, kylinOrderRefundsVo);
BasicDBObject object = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderRefundsVo)));
UpdateResult updateResult = mongoTemplate.getCollection(KylinOrderRefundsVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderRefundsId").is(refundInfo.getOrderRefundsId())).getQueryObject(),
object
);
if (refundInfo.getType() == KylinTableStatusConst.ORDER_REFUND_TYPE_APPLY) {
// 退还库存
for (String entitiesId : orderTicketEntitiesIdsArr) {
dataUtils.changeSurplusGeneral(entitiesId, 1);
KylinOrderTicketEntities entitiesInfo = kylinOrderTicketEntitiesMapper.selectOne(
new QueryWrapper<KylinOrderTicketEntities>().eq("order_ticket_entities_id", entitiesId)
);
dataUtils.changeBuyInfo(orderInfo.getUserId(), "", orderRelations.getPerformanceId(), entitiesInfo.getTicketId(), -1);
if (entitiesInfo.getIsPayment() == KylinTableStatusConst.ENTITIES_IS_PAYMENT3) {
dataUtils.changeSurplusGeneral(entitiesInfo.getTicketId(), 1);
log.info(UserPathDto.setData("changeBuyInfo", "UserId=" + orderInfo.getUserId() + "idCard=" + entitiesInfo.getEnterIdCode() + " PerformanceId=" + orderRelations.getPerformanceId() + " TicketId=" + entitiesInfo.getTicketId(), "info"));
dataUtils.changeBuyInfo(orderInfo.getUserId(), entitiesInfo.getEnterIdCode(), orderRelations.getPerformanceId(), entitiesInfo.getTicketId(), -1);
}
}
}
......
......@@ -74,8 +74,10 @@ public class GlobalAuthorityInterceptor extends HandlerInterceptorAdapter {
} catch (ExpiredJwtException expiredJwtEx) {
responseCode = TOKEN_INVALID;
log.error("Ex.ExpiredJwtException:{},responseCode:{}", expiredJwtEx.getMessage(), responseCode);
} catch (Exception ex) {
responseCode = TOKEN_ILLEGAL;
log.error("Ex.Exception:{},responseCode:{}", ex.getMessage(), responseCode);
}
} else {
responseCode = TOKEN_ILLEGAL;
......@@ -88,6 +90,7 @@ public class GlobalAuthorityInterceptor extends HandlerInterceptorAdapter {
}
if (StringUtils.isNotEmpty(responseCode)) {
this.responseHandler(response, responseCode);
log.warn("Authority failed:{},uri:[{}],authorization:{}", responseCode, uri, authorization);
return false;
}
if (StringUtils.isEmpty(currentUid)) {
......
package com.liquidnet.service.kylin.controller;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
import com.liquidnet.service.kylin.service.impl.OrderRefundsCallbackServiceImpl;
import com.liquidnet.service.kylin.service.impl.OrderRefundOvertimeServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -23,10 +22,10 @@ import org.springframework.web.bind.annotation.RestController;
@Api(tags = "前端-退款回调")
@RestController
@RequestMapping("refund")
public class OrderRefundCallbackController {
public class OrderRefundOvertimeController {
@Autowired
private OrderRefundsCallbackServiceImpl orderRefundsCallbackServiceImpl;
private OrderRefundOvertimeServiceImpl orderRefundOvertimeServiceImpl;
@PostMapping("apply")
@ApiOperation("超时退款")
......@@ -35,7 +34,7 @@ public class OrderRefundCallbackController {
})
public Boolean refundApply(@RequestParam() String orderTicketsId) {
try {
Boolean res = orderRefundsCallbackServiceImpl.refundApply(orderTicketsId);
Boolean res = orderRefundOvertimeServiceImpl.refundApply(orderTicketsId);
if (res) {
return true;
} else {
......@@ -46,10 +45,4 @@ public class OrderRefundCallbackController {
}
}
@PostMapping("callback")
@ApiOperation("退款回调")
public String refundCallback(RefundCallbackParam refundCallbackParam) {
String result = orderRefundsCallbackServiceImpl.refundCallback(refundCallbackParam);
return result;
}
}
package com.liquidnet.service.kylin.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.PageInfo;
import com.liquidnet.common.cache.redis.util.RedisUtil;
......@@ -31,16 +30,12 @@ import com.liquidnet.service.kylin.service.IKylinOrderTicketsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.service.kylin.utils.*;
import com.mongodb.BasicDBObject;
import com.mongodb.client.model.FindOneAndUpdateOptions;
import com.mongodb.client.model.ReturnDocument;
import com.mongodb.client.result.UpdateResult;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.AlibabaDamaiMevOpenBatchpushticketRequest;
import com.taobao.api.response.AlibabaDamaiMevOpenBatchpushticketResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.bson.Document;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -57,7 +52,6 @@ import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -108,7 +102,7 @@ public class KylinOrderTicketsServiceImpl extends ServiceImpl<KylinOrderTicketsM
@Autowired
private KylinOrderTicketRelationsMapper orderTicketRelationsMapper;
@Autowired
private OrderRefundsCallbackServiceImpl orderRefundsCallbackService;
private OrderRefundOvertimeServiceImpl orderRefundsCallbackService;
@Autowired
private KylinRefundsStatusServiceImpl refundsStatusService;
......
......@@ -6,9 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.liquidnet.common.mq.constant.MQConst;
import com.liquidnet.commons.lang.util.*;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.UserPathDto;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
import com.liquidnet.service.kylin.dto.vo.mongo.*;
import com.liquidnet.service.kylin.entity.*;
import com.liquidnet.service.kylin.mapper.*;
......@@ -17,7 +15,6 @@ import com.liquidnet.service.kylin.utils.MongoVoUtils;
import com.mongodb.BasicDBObject;
import com.mongodb.client.model.FindOneAndUpdateOptions;
import com.mongodb.client.model.ReturnDocument;
import com.mongodb.client.result.UpdateResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.bson.Document;
......@@ -32,10 +29,8 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
......@@ -49,9 +44,6 @@ import java.util.stream.Collectors;
@Service
public class KylinRefundsStatusServiceImpl {
@Autowired
private KylinOrderTicketsMapper kylinOrderTicketsMapper;
@Autowired
private KylinOrderTicketStatusMapper kylinOrderTicketStatusMapper;
......@@ -64,15 +56,9 @@ public class KylinRefundsStatusServiceImpl {
@Autowired
private KylinOrderRefundsEntitiesMapper kylinOrderRefundsEntitiesMapper;
@Autowired
private KylinOrderTicketRelationsMapper kylinOrderTicketRelationsMapper;
@Autowired
MongoTemplate mongoTemplate;
@Autowired
private MongoConverter mongoConverter;
@Autowired
private DataUtils dataUtils;
......@@ -81,145 +67,6 @@ public class KylinRefundsStatusServiceImpl {
@Autowired
private RabbitTemplate rabbitTemplate;
public boolean orderTicketRefunded(RefundCallbackParam refundCallbackParam, KylinOrderRefunds refundInfo) {
List<KylinOrderRefundEntities> refundEntities = kylinOrderRefundsEntitiesMapper.selectList(
new QueryWrapper<KylinOrderRefundEntities>().eq("order_refunds_id", refundInfo.getOrderRefundsId())
);
List<String> orderTicketEntitiesIdsArr = refundEntities.stream().map(KylinOrderTicketEntities -> KylinOrderTicketEntities.getOrderTicketEntitiesId()).collect(Collectors.toList());
String orderTicketsId = refundInfo.getOrderTicketsId();
KylinOrderTicketRelations orderRelations = kylinOrderTicketRelationsMapper.selectOne(
new QueryWrapper<KylinOrderTicketRelations>().eq("order_id", orderTicketsId)
);
// 更新数据
// 订单状态表
KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne(
new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId)
);
KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus();
int newStatus = 0;
if (refundCallbackParam.getRefund_price() + orderInfo.getPriceRefund().doubleValue() == orderInfo.getPriceActual().doubleValue()) {
newStatus = KylinTableStatusConst.ORDER_STATUS4;
} else {
newStatus = KylinTableStatusConst.ORDER_STATUS6;
}
orderStatusTable.setStatus(newStatus);
orderStatusTable.setUpdatedAt(LocalDateTime.now());
kylinOrderTicketStatusMapper.update(
orderStatusTable, new UpdateWrapper<KylinOrderTicketStatus>()
.eq("order_id", orderTicketsId)
);
// 入场人
double priceActual = orderInfo.getPriceActual().doubleValue();
double priceExpress = orderInfo.getPriceExpress().doubleValue();
int allEntitiesCount = kylinOrderTicketEntitiesMapper.selectCount(// 总入场人数量 排出未付款的 用来计算单入场人的价格
new QueryWrapper<KylinOrderTicketEntities>()
.eq("order_id", orderTicketsId)
.ne("is_payment", KylinTableStatusConst.ENTITIES_IS_PAYMENT0)
);
double onePrice = (priceActual - priceExpress) / allEntitiesCount;//单价
int refundNumber = 0;
for (String entitiesId : orderTicketEntitiesIdsArr) {
KylinOrderTicketEntities EntitiesInfo = kylinOrderTicketEntitiesMapper.selectOne(//已退完成的
new QueryWrapper<KylinOrderTicketEntities>()
.eq("order_ticket_entities_id", entitiesId)
);
BigDecimal refundedPrice = EntitiesInfo.getRefundPrice();
KylinOrderRefundEntities refundEntitiesInfo = kylinOrderRefundsEntitiesMapper.selectOne(
new QueryWrapper<KylinOrderRefundEntities>()
.eq("order_refunds_id", refundInfo.getOrderRefundsId())
.eq("order_ticket_entities_id", entitiesId)
);
KylinOrderTicketEntities entitiesTable = new KylinOrderTicketEntities();
double priceNew = refundEntitiesInfo.getRefundPrice().doubleValue() + refundedPrice.doubleValue();
int isPayment = 0;
if (priceNew == onePrice) {
isPayment = KylinTableStatusConst.ENTITIES_IS_PAYMENT3;
refundNumber++;
} else {
isPayment = KylinTableStatusConst.ENTITIES_IS_PAYMENT4;
}
entitiesTable.setIsPayment(isPayment);
entitiesTable.setUpdatedAt(LocalDateTime.now());
entitiesTable.setRefundPrice(BigDecimal.valueOf(priceNew));
Integer[] entitiesTableIsPayment = {KylinTableStatusConst.ENTITIES_IS_PAYMENT2, KylinTableStatusConst.ENTITIES_IS_PAYMENT4};
kylinOrderTicketEntitiesMapper.update(entitiesTable, new UpdateWrapper<KylinOrderTicketEntities>()
.eq("order_ticket_entities_id", entitiesId)
.in("is_payment", entitiesTableIsPayment)
);
HashMap<String, Object> EntitiesVo = new HashMap<>();
EntitiesVo.put("updatedAt", DateUtil.getNowTime());
EntitiesVo.put("refundPrice", BigDecimal.valueOf(priceNew));
EntitiesVo.put("isPayment", isPayment);
BasicDBObject EntitiesVov = new BasicDBObject("$set", mongoConverter.convertToMongoType(EntitiesVo));
UpdateResult updateResult = mongoTemplate.getCollection(KylinOrderTicketEntitiesVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderTicketEntitiesId").is(entitiesId)).getQueryObject(),
EntitiesVov
);
dataUtils.delOrderTicketEntitiesRedis(entitiesId);
}
// 订单表
double price = orderInfo.getPriceRefund().doubleValue() + refundCallbackParam.getRefund_price();
Integer num = orderInfo.getRefundNumber() + refundNumber;
KylinOrderTickets update = new KylinOrderTickets();
update.setRefundNumber(num);
update.setPriceRefund(BigDecimal.valueOf(price));
update.setUpdatedAt(LocalDateTime.now());
kylinOrderTicketsMapper.update(
update, new UpdateWrapper<KylinOrderTickets>()
.eq("order_tickets_id", orderTicketsId)
);
HashMap<String, Object> orderVo = new HashMap<>();
orderVo.put("updatedAt", DateUtil.getNowTime());
orderVo.put("priceRefund", BigDecimal.valueOf(price));
orderVo.put("status", newStatus);
orderVo.put("refundNumber", num);
BasicDBObject orderVov = new BasicDBObject("$set", mongoConverter.convertToMongoType(orderVo));
UpdateResult orderUpdateResult = mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("orderTicketsId").is(orderTicketsId)).getQueryObject(),
orderVov
);
dataUtils.delOrderTicketRedis(orderTicketsId);
mongoVoUtils.resetOrderListVo(orderInfo.getUserId(), 2, orderTicketsId, null);
// 退款单完成
KylinOrderRefunds kylinOrderRefunds = new KylinOrderRefunds();
kylinOrderRefunds.setStatus(KylinTableStatusConst.ORDER_REFUND_STATUS_REFUNDED);
kylinOrderRefunds.setRefundCode(refundCallbackParam.getRefund_code());
kylinOrderRefunds.setRefundType(refundCallbackParam.getRefund_type());
kylinOrderRefunds.setRefundId(refundCallbackParam.getRefund_id());
kylinOrderRefunds.setRefundAt(refundCallbackParam.getRefund_at());
kylinOrderRefunds.setUpdatedAt(LocalDateTime.now());
kylinOrderRefundsMapper.update(
kylinOrderRefunds,
new UpdateWrapper<KylinOrderRefunds>().in("order_refunds_id", refundInfo.getOrderRefundsId())
);
if (refundInfo.getType() == KylinTableStatusConst.ORDER_REFUND_TYPE_APPLY) {
// 退还库存
for (String entitiesId : orderTicketEntitiesIdsArr) {
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);
log.info(UserPathDto.setData("changeBuyInfo", "UserId=" + orderInfo.getUserId() + "idCard=" + entitiesInfo.getEnterIdCode() + " PerformanceId=" + orderRelations.getPerformanceId() + " TicketId=" + entitiesInfo.getTicketId(), "info"));
dataUtils.changeBuyInfo(orderInfo.getUserId(), entitiesInfo.getEnterIdCode(), orderRelations.getPerformanceId(), entitiesInfo.getTicketId(), -1);
}
}
}
return true;
}
public Boolean orderTicketRefunding(
KylinOrderTickets orderInfo, String orderTicketsId,
double RefundPriceExpress,
......
......@@ -3,10 +3,8 @@ package com.liquidnet.service.kylin.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dao.KylinOrderTicketEntitiesDao;
import com.liquidnet.service.kylin.dto.param.RefundApplyParam;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
import com.liquidnet.service.kylin.entity.*;
import com.liquidnet.service.kylin.mapper.*;
......@@ -33,7 +31,7 @@ import java.util.stream.Collectors;
*/
@Slf4j
@Service
public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefundsMapper, KylinOrderRefunds> implements IKylinOrderRefundsService {
public class OrderRefundOvertimeServiceImpl extends ServiceImpl<KylinOrderRefundsMapper, KylinOrderRefunds> implements IKylinOrderRefundsService {
@Autowired
private KylinRefundsStatusServiceImpl kylinRefundsStatusServiceImpl;
......@@ -43,9 +41,6 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun
@Autowired
private KylinOrderTicketsMapper kylinOrderTicketsMapper;
@Autowired
private KylinOrderTicketStatusMapper kylinOrderTicketStatusMapper;
@Autowired
private KylinOrderTicketEntitiesMapper kylinOrderTicketEntitiesMapper;
......@@ -58,51 +53,6 @@ public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefun
@Autowired
private DataUtils dataUtils;
public String refundCallback(RefundCallbackParam refundCallbackParam) {
KylinOrderRefunds refundInfo = kylinOrderRefundsMapper.selectOne(
new UpdateWrapper<KylinOrderRefunds>()
.eq("order_refund_code", refundCallbackParam.getOrder_refund_code())
);
if (refundInfo == null) {
log.info("Failed:{}.RefundController refundCallback: 退款订单查询失败,编号{}", "KylinOrderRefundsServiceImplRefundCallback", refundCallbackParam.getOrder_refund_code());
return "fail";
}
if (refundInfo.getStatus() == KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL) {
log.info("Failed:{}.RefundController refundCallback: 退款订单已取消,编号{}", "KylinOrderRefundsServiceImplRefundCallback", refundCallbackParam.getOrder_refund_code());
return "fail";
}
if (refundInfo.getStatus() == KylinTableStatusConst.ORDER_REFUND_STATUS_REFUNDED) {
log.info("Failed:{}.RefundController refundCallback: 退款订单已退款,编号{}", "KylinOrderRefundsServiceImplRefundCallback", refundCallbackParam.getOrder_refund_code());
return "success";
}
Integer status = refundCallbackParam.getStatus();
if (1 == status) { // 退款成功
boolean res = kylinRefundsStatusServiceImpl.orderTicketRefunded(refundCallbackParam, refundInfo);
if (res) {
return "success";
} else {
return "fail";
}
}
if (0 == status) { // 退款失败
KylinOrderRefunds kylinOrderRefunds = new KylinOrderRefunds();
kylinOrderRefunds.setStatus(KylinTableStatusConst.ORDER_REFUND_STATUS_ERROR);
kylinOrderRefunds.setRefundCode(refundCallbackParam.getRefund_code());
kylinOrderRefunds.setRefundType(refundCallbackParam.getRefund_type());
kylinOrderRefunds.setRefundId(refundCallbackParam.getRefund_id());
kylinOrderRefunds.setRefundAt(refundCallbackParam.getRefund_at());
kylinOrderRefunds.setRefundError(refundCallbackParam.getRefund_error());
kylinOrderRefunds.setUpdatedAt(LocalDateTime.now());
kylinOrderRefundsMapper.update(
kylinOrderRefunds,
new UpdateWrapper<KylinOrderRefunds>().eq("order_refund_code", refundCallbackParam.getOrder_refund_code())
);
}
return "success";
}
public Boolean refundApply(String orderTicketsId) {
KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne(
new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId)
......
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