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

Commit 4c55c0ed authored by 张国柄's avatar 张国柄

Merge remote-tracking branch 'origin/dev' into dev

parents 6cc4c219 86ddca9d
......@@ -6,13 +6,11 @@ import com.liquidnet.client.admin.common.core.controller.BaseController;
import com.liquidnet.client.admin.common.core.domain.AjaxResult;
import com.liquidnet.client.admin.common.core.page.TableDataInfo;
import com.liquidnet.client.admin.zhengzai.kylin.service.impl.KylinOrderRefundsServiceImpl;
import com.liquidnet.client.admin.zhengzai.kylin.service.impl.KylinOrderTicketsAdminServiceImpl;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dao.OrderRefundDao;
import com.liquidnet.service.kylin.dto.param.RefundApplyParam;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
import com.liquidnet.service.kylin.dto.param.RefundSearchParam;
import com.liquidnet.service.kylin.dto.vo.admin.OrderDetailsAdminVo;
import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderRefundsVo;
......@@ -42,21 +40,12 @@ public class KylinOrderRefundAdminController extends BaseController {
@Autowired
private KylinOrderRefundsServiceImpl kylinOrderRefundsServiceImpl;
@Autowired
private KylinOrderTicketsAdminServiceImpl kylinOrderTicketsAdminServiceImpl;
@RequiresPermissions("kylin:refund:view")
@GetMapping()
public String refund() {
return prefix + "/refund";
}
@PostMapping("callback")
public String refundCallback(RefundCallbackParam refundCallbackParam) {
String result = kylinOrderRefundsServiceImpl.refundCallback(refundCallbackParam);
return result;
}
@RequiresPermissions("kylin:refund:detail")
@GetMapping(value = "/details/{orderRefundId}")
public String detail(@PathVariable("orderRefundId") String orderRefundId, ModelMap mmap) {
......
package com.liquidnet.service.kylin.controller;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
import com.liquidnet.service.kylin.service.impl.OrderRefundsCallbackServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 退款回掉
* </p>
*
* @author jiangxiulong
* @since 2021-06-11 6:10 下午
*/
@Api(tags = "前端-退款回调")
@RestController
@RequestMapping("refund")
@Validated
public class OrderRefundCallbackController {
@Autowired
private OrderRefundsCallbackServiceImpl orderRefundsCallbackServiceImpl;
@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.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketEntitiesVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketVo;
import com.liquidnet.service.kylin.entity.KylinOrderRefunds;
import com.liquidnet.service.kylin.entity.KylinOrderTicketEntities;
import com.liquidnet.service.kylin.entity.KylinOrderTicketStatus;
import com.liquidnet.service.kylin.entity.KylinOrderTickets;
import com.liquidnet.service.kylin.mapper.KylinOrderRefundsMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketEntitiesMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketStatusMapper;
import com.liquidnet.service.kylin.mapper.KylinOrderTicketsMapper;
import com.liquidnet.service.kylin.utils.DataUtils;
import com.mongodb.BasicDBObject;
import com.mongodb.client.model.FindOneAndUpdateOptions;
import com.mongodb.client.model.ReturnDocument;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
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;
/**
* <p>
* 订单退款表 服务实现类 处理数据 退款后状态的变化
* </p>
*
* @author jiaangxiulong
* @since 2021-05-26
*/
@Slf4j
@Service
public class KylinRefundsStatusServiceImpl {
@Autowired
private KylinOrderTicketsMapper kylinOrderTicketsMapper;
@Autowired
private KylinOrderTicketStatusMapper kylinOrderTicketStatusMapper;
@Autowired
private KylinOrderRefundsMapper kylinOrderRefundsMapper;
@Autowired
private KylinOrderTicketEntitiesMapper kylinOrderTicketEntitiesMapper;
@Autowired
MongoTemplate mongoTemplate;
@Autowired
private DataUtils dataUtils;
public boolean orderTicketRefunded(RefundCallbackParam refundCallbackParam, KylinOrderRefunds refundInfo) {
String orderTicketEntitiesIds = refundInfo.getOrderTicketEntitiesIds();
String[] orderTicketEntitiesIdsArr = orderTicketEntitiesIds.split(",");
Integer EntitiesIdsCount = orderTicketEntitiesIdsArr.length;
String orderTicketsId = refundInfo.getOrderTicketsId();
// 更新数据
// 订单状态表
KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne(
new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId)
);
KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus();
int newStatus = 0;
if (EntitiesIdsCount + orderInfo.getRefundNumber() == orderInfo.getNumber()) {
newStatus = KylinTableStatusConst.ORDER_STATUS4;
} else {
newStatus = KylinTableStatusConst.ORDER_STATUS6;
}
orderStatusTable.setStatus(newStatus);
kylinOrderTicketStatusMapper.update(
orderStatusTable, new UpdateWrapper<KylinOrderTicketStatus>()
.eq("order_id", orderTicketsId)
);
// 订单表
double price = orderInfo.getPriceRefund().doubleValue() + refundInfo.getPrice().doubleValue();
Integer num = orderInfo.getRefundNumber() + EntitiesIdsCount;
KylinOrderTickets update = new KylinOrderTickets();
update.setRefundNumber(num);
update.setPriceRefund(BigDecimal.valueOf(price));
kylinOrderTicketsMapper.update(
update, new UpdateWrapper<KylinOrderTickets>()
.eq("order_tickets_id", orderTicketsId)
);
KylinOrderTicketVo kylinOrderTicketVoOrder = new KylinOrderTicketVo();
kylinOrderTicketVoOrder.setStatus(newStatus);
kylinOrderTicketVoOrder.setRefundNumber(num);
kylinOrderTicketVoOrder.setPriceRefund(BigDecimal.valueOf(price));
BasicDBObject orderEntitiesObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketVoOrder)));
Document docOrder = mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("orderTicketsId").is(orderTicketsId)).getQueryObject(),
orderEntitiesObject,
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
);
dataUtils.delOrderTicketRedis(orderTicketsId);
// 入场人
for (String entitiesId : orderTicketEntitiesIdsArr) {
KylinOrderTicketEntities entitiesTable = new KylinOrderTicketEntities();
// TODO: 2021/5/27 事物 and 部分退款
entitiesTable.setIsPayment(KylinTableStatusConst.ENTITIES_IS_PAYMENT3);
kylinOrderTicketEntitiesMapper.update(entitiesTable, new UpdateWrapper<KylinOrderTicketEntities>()
.eq("order_ticket_entities_id", entitiesId)
.eq("is_payment", KylinTableStatusConst.ENTITIES_IS_PAYMENT2)
);
KylinOrderTicketEntitiesVo kylinOrderTicketEntitiesVo = new KylinOrderTicketEntitiesVo();
kylinOrderTicketEntitiesVo.setIsPayment(KylinTableStatusConst.ENTITIES_IS_PAYMENT3);
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(),
entitiesObject,
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
);
dataUtils.delOrderTicketEntitiesRedis(entitiesId);
}
// 退款单完成
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.setRefundError(refundCallbackParam.getRefund_error());
kylinOrderRefundsMapper.update(
kylinOrderRefunds,
new UpdateWrapper<KylinOrderRefunds>().in("order_refunds_id", refundInfo.getOrderRefundsId())
);
if (refundInfo.getType() == KylinTableStatusConst.ORDER_REFUND_TYPE_APPLY) {
// 退还库存
for (String entitiesId : orderTicketEntitiesIdsArr) {
dataUtils.changeSurplusGeneral(entitiesId, 1);
}
}
return true;
}
}
package com.liquidnet.service.kylin.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dto.param.RefundCallbackParam;
import com.liquidnet.service.kylin.entity.KylinOrderRefunds;
import com.liquidnet.service.kylin.mapper.KylinOrderRefundsMapper;
import com.liquidnet.service.kylin.service.IKylinOrderRefundsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
/**
* <p>
* 订单退款表 服务实现类 处理逻辑判断
* </p>
*
* @author jiangxiulong
* @since 2021-05-26
*/
@Slf4j
@Service
public class OrderRefundsCallbackServiceImpl extends ServiceImpl<KylinOrderRefundsMapper, KylinOrderRefunds> implements IKylinOrderRefundsService {
@Autowired
private KylinRefundsStatusServiceImpl kylinRefundsStatusServiceImpl;
@Autowired
private KylinOrderRefundsMapper kylinOrderRefundsMapper;
@Autowired
MongoTemplate mongoTemplate;
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());
kylinOrderRefundsMapper.update(
kylinOrderRefunds,
new UpdateWrapper<KylinOrderRefunds>().eq("order_refund_code", refundCallbackParam.getOrder_refund_code())
);
}
return "success";
}
}
......@@ -454,4 +454,13 @@ public class DataUtils {
}
}
/**
* 删除订单redis
*
* @param orderEntitiesId
*/
public void delOrderTicketEntitiesRedis(String orderEntitiesId) {
redisUtil.del(KylinRedisConst.ORDER_ENTITIES + orderEntitiesId);
}
}
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