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

Commit 4a8d8229 authored by jiangxiulong's avatar jiangxiulong

refund 主动

parent 1db8f473
...@@ -12,7 +12,6 @@ import com.liquidnet.service.kylin.constant.KylinTableStatusConst; ...@@ -12,7 +12,6 @@ import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dao.OrderRefundDao; import com.liquidnet.service.kylin.dao.OrderRefundDao;
import com.liquidnet.service.kylin.dto.param.RefundApplyParam; import com.liquidnet.service.kylin.dto.param.RefundApplyParam;
import com.liquidnet.service.kylin.dto.param.RefundSearchParam; 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; import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderRefundsVo;
import com.liquidnet.service.kylin.dto.vo.returns.RefundOrderDetailsVo; import com.liquidnet.service.kylin.dto.vo.returns.RefundOrderDetailsVo;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
...@@ -191,11 +190,11 @@ public class KylinOrderRefundAdminController extends BaseController { ...@@ -191,11 +190,11 @@ public class KylinOrderRefundAdminController extends BaseController {
@ResponseBody @ResponseBody
public AjaxResult refundCompleted(RefundApplyParam refundApplyParam) { public AjaxResult refundCompleted(RefundApplyParam refundApplyParam) {
try { try {
Boolean res = kylinOrderRefundsServiceImpl.refundCompleted(refundApplyParam); ResponseDto res = kylinOrderRefundsServiceImpl.refundCompleted(refundApplyParam);
if (res) { if (res.isSuccess()) {
return success(); return success();
} else { } else {
return error("关闭订单失败"); return error(res.getMessage());
} }
} catch (Exception e) { } catch (Exception e) {
return error(e.getMessage()); return error(e.getMessage());
......
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
var entitiesPrice = $.table.selectColumns("price"); var entitiesPrice = $.table.selectColumns("price");
data.push({"name":"entitiesPrice","value":entitiesPrice}); data.push({"name":"entitiesPrice","value":entitiesPrice});
console.log(data) console.log(data)
// $.operate.save(prefix + "/apply", data); $.operate.save(prefix + "/apply", data);
} }
} }
</script> </script>
......
package com.liquidnet.client.admin.zhengzai.kylin.service.impl; package com.liquidnet.client.admin.zhengzai.kylin.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.liquidnet.client.admin.common.utils.DateUtils;
import com.liquidnet.client.admin.common.utils.ShiroUtils;
import com.liquidnet.client.admin.zhengzai.kylin.utils.DataUtils;
import com.liquidnet.commons.lang.util.BeanUtil; import com.liquidnet.commons.lang.util.BeanUtil;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst; import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
...@@ -11,6 +15,7 @@ import com.liquidnet.service.kylin.dao.KylinOrderRefundsEntitiesDao; ...@@ -11,6 +15,7 @@ import com.liquidnet.service.kylin.dao.KylinOrderRefundsEntitiesDao;
import com.liquidnet.service.kylin.dao.KylinOrderTicketEntitiesDao; import com.liquidnet.service.kylin.dao.KylinOrderTicketEntitiesDao;
import com.liquidnet.service.kylin.dao.OrderRefundDao; import com.liquidnet.service.kylin.dao.OrderRefundDao;
import com.liquidnet.service.kylin.dto.param.RefundApplyParam; 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.param.RefundSearchParam;
import com.liquidnet.service.kylin.dto.vo.admin.OrderDetailsAdminVo; import com.liquidnet.service.kylin.dto.vo.admin.OrderDetailsAdminVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketEntitiesVo; import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketEntitiesVo;
...@@ -27,7 +32,10 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -27,7 +32,10 @@ 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.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
...@@ -68,6 +76,7 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM ...@@ -68,6 +76,7 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
public ResponseDto refundApply(RefundApplyParam refundApplyParam) { public ResponseDto refundApply(RefundApplyParam refundApplyParam) {
String orderTicketsId = refundApplyParam.getOrderTicketsId(); String orderTicketsId = refundApplyParam.getOrderTicketsId();
List<String> ticketEntityIds = refundApplyParam.getTicketEntityIds(); List<String> ticketEntityIds = refundApplyParam.getTicketEntityIds();
List<BigDecimal> entitiesPrice = refundApplyParam.getEntitiesPrice();
Double RefundPriceExpress = refundApplyParam.getRefundPriceExpress(); Double RefundPriceExpress = refundApplyParam.getRefundPriceExpress();
if (null == RefundPriceExpress) { if (null == RefundPriceExpress) {
RefundPriceExpress = 0.0; RefundPriceExpress = 0.0;
...@@ -132,6 +141,15 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM ...@@ -132,6 +141,15 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
} }
} }
/*public Boolean refundPrice(List<String> ticketEntityIds, List<BigDecimal> entitiesPrice, String orderTicketsId) {
// 该订单的所有退款单
List<KylinOrderRefunds> refundList = kylinOrderRefundsMapper.selectList(
new QueryWrapper<KylinOrderRefunds>()
.eq("order_tickets_id", orderTicketsId)
.ne("status", KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL)
);
}*/
public ResponseDto refundCheckStatus(RefundApplyParam refundApplyParam) { public ResponseDto refundCheckStatus(RefundApplyParam refundApplyParam) {
String type = refundApplyParam.getType(); String type = refundApplyParam.getType();
List<String> orderRefundsIdList = refundApplyParam.getIds(); List<String> orderRefundsIdList = refundApplyParam.getIds();
...@@ -203,8 +221,51 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM ...@@ -203,8 +221,51 @@ public class KylinOrderRefundsServiceImpl extends ServiceImpl<KylinOrderRefundsM
} }
} }
public Boolean refundCompleted(RefundApplyParam refundApplyParam) { public ResponseDto refundCompleted(RefundApplyParam refundApplyParam) {
return false; List<String> orderRefundsIdList = refundApplyParam.getIds();
KylinOrderRefunds refundInfo = kylinOrderRefundsMapper.selectOne(
new QueryWrapper<KylinOrderRefunds>()
.in("order_refunds_id", orderRefundsIdList)
);
if (null == refundInfo) {
return ResponseDto.failure("退款订单查询失败");
}
if (refundInfo.getStatus() == KylinTableStatusConst.ORDER_REFUND_STATUS_CANCEL) {
return ResponseDto.failure("退款订单已取消");
}
if (refundInfo.getStatus() == KylinTableStatusConst.ORDER_REFUND_STATUS_REFUNDED) {
return ResponseDto.failure("退款订单已完成");
}
RefundCallbackParam refundCallbackParam = new RefundCallbackParam();
refundCallbackParam.setRefund_code(refundInfo.getRefundCode());
refundCallbackParam.setRefund_price(refundInfo.getPrice().doubleValue());
refundCallbackParam.setRefund_type("UNKNOWN");
refundCallbackParam.setRefund_id(refundInfo.getRefundId());
refundCallbackParam.setRefund_at(DateUtils.dateTimeNow());
refundCallbackParam.setRefund_error(refundInfo.getRefundError());
boolean res = kylinRefundsStatusServiceImpl.orderTicketRefunded(refundCallbackParam, refundInfo);
if (res) {
String authId = ShiroUtils.getUserId().toString();
String authName = ShiroUtils.getLoginName();
KylinOrderRefunds kylinOrderRefunds = new KylinOrderRefunds();
if (refundInfo.getAuditorId().isEmpty()) {
kylinOrderRefunds.setAuditorAt(LocalDateTime.now());
kylinOrderRefunds.setAuditorId(authId);
kylinOrderRefunds.setAuditorName(authName);
}
kylinOrderRefunds.setExecutorAt(LocalDateTime.now());
kylinOrderRefunds.setExecutorId(authId);
kylinOrderRefunds.setExecutorName(authName);
kylinOrderRefundsMapper.update(
kylinOrderRefunds,
new UpdateWrapper<KylinOrderRefunds>().in("order_refunds_id", refundInfo.getOrderRefundsId())
);
return ResponseDto.success();
} else {
return ResponseDto.failure("fail");
}
} }
public KylinOrderRefundsVo detail(String orderRefundId) { public KylinOrderRefundsVo detail(String orderRefundId) {
......
...@@ -12,6 +12,7 @@ import com.liquidnet.commons.lang.util.IDGenerator; ...@@ -12,6 +12,7 @@ import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.JsonUtils; import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst; import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dto.param.RefundApplyParam; import com.liquidnet.service.kylin.dto.param.RefundApplyParam;
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.KylinOrderTicketEntitiesVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketVo; import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderTicketVo;
import com.liquidnet.service.kylin.entity.KylinOrderRefunds; import com.liquidnet.service.kylin.entity.KylinOrderRefunds;
...@@ -328,4 +329,96 @@ public class KylinRefundsStatusServiceImpl { ...@@ -328,4 +329,96 @@ public class KylinRefundsStatusServiceImpl {
return true; return true;
} }
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;
}
} }
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