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

Commit 2316adb9 authored by jiangxiulong's avatar jiangxiulong

取消要判断改成已付款/退款中/部分退款 订单和订单入场人表

parent 8fab60d0
...@@ -191,15 +191,35 @@ public class KylinRefundsStatusServiceImpl { ...@@ -191,15 +191,35 @@ public class KylinRefundsStatusServiceImpl {
String orderRefundsId = refundInfo.getOrderRefundsId(); String orderRefundsId = refundInfo.getOrderRefundsId();
// 更新数据 // 更新数据
// 订单状态表 // 订单状态表 判断是退到正在退款 已付款 部分退款?(取消,完成,失败)
int newStatus = 0;
Integer[] whereRefundingCount = {KylinTableStatusConst.ORDER_STATUS2, KylinTableStatusConst.ORDER_STATUS4, KylinTableStatusConst.ORDER_STATUS6};
int refundingCount = kylinOrderRefundsMapper.selectCount(
new QueryWrapper<KylinOrderRefunds>().eq("order_tickets_id", orderTicketsId)
.notIn("status", whereRefundingCount)
.ne("order_refunds_id", orderRefundsId)
);
if (refundingCount > 0) { // 存在其他正在退款的订单
newStatus = KylinTableStatusConst.ORDER_STATUS3;
} else {
KylinOrderTickets orderInfo = kylinOrderTicketsMapper.selectOne(
new QueryWrapper<KylinOrderTickets>().eq("order_tickets_id", orderTicketsId)
);
if (orderInfo.getRefundNumber() > 0) { // 已经有退完的 那就是部分退款了
newStatus = KylinTableStatusConst.ORDER_STATUS6;
} else {
newStatus = KylinTableStatusConst.ORDER_STATUS1;
}
}
KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus(); KylinOrderTicketStatus orderStatusTable = new KylinOrderTicketStatus();
// TODO: 如果原来是部分退款? orderStatusTable.setStatus(newStatus);
orderStatusTable.setStatus(KylinTableStatusConst.ORDER_STATUS1);
kylinOrderTicketStatusMapper.update(orderStatusTable, new UpdateWrapper<KylinOrderTicketStatus>() kylinOrderTicketStatusMapper.update(orderStatusTable, new UpdateWrapper<KylinOrderTicketStatus>()
.eq("order_id", orderTicketsId)); .eq("order_id", orderTicketsId));
KylinOrderTicketVo kylinOrderTicketVo = new KylinOrderTicketVo(); KylinOrderTicketVo kylinOrderTicketVo = new KylinOrderTicketVo();
kylinOrderTicketVo.setStatus(KylinTableStatusConst.ORDER_STATUS1); kylinOrderTicketVo.setStatus(newStatus);
BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketVo))); BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketVo)));
Document orderDoc = mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).findOneAndUpdate( Document orderDoc = mongoTemplate.getCollection(KylinOrderTicketVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("orderTicketsId").is(orderTicketsId)).getQueryObject(), Query.query(Criteria.where("orderTicketsId").is(orderTicketsId)).getQueryObject(),
...@@ -214,15 +234,30 @@ public class KylinRefundsStatusServiceImpl { ...@@ -214,15 +234,30 @@ public class KylinRefundsStatusServiceImpl {
// 入场人 // 入场人
for (String entitiesId : orderTicketEntitiesIdsArr) { for (String entitiesId : orderTicketEntitiesIdsArr) {
// 订单状态表 判断是退到正在退款 已付款 部分退款?(取消,完成,失败)
int newIsPayment = 0;
int refundingEntitiesCount = kylinOrderRefundsMapper.selectEntitiesCount(orderTicketsId, whereRefundingCount, orderRefundsId, entitiesId);
if (refundingEntitiesCount > 0) { // 存在其他正在退款的该入场人订单
newIsPayment = KylinTableStatusConst.ENTITIES_IS_PAYMENT2;
} else {
KylinOrderTicketEntities entitiesInfo = kylinOrderTicketEntitiesMapper.selectOne(
new QueryWrapper<KylinOrderTicketEntities>().eq("order_ticket_entities_id", entitiesId)
);
if (entitiesInfo.getRefundPrice().doubleValue() > 0) { // 已经有退完的 那就是部分退款了
newIsPayment = KylinTableStatusConst.ENTITIES_IS_PAYMENT4;
} else {
newIsPayment = KylinTableStatusConst.ENTITIES_IS_PAYMENT1;
}
}
KylinOrderTicketEntities entitiesTable = new KylinOrderTicketEntities(); KylinOrderTicketEntities entitiesTable = new KylinOrderTicketEntities();
entitiesTable.setIsPayment(KylinTableStatusConst.ENTITIES_IS_PAYMENT1); entitiesTable.setIsPayment(newIsPayment);
kylinOrderTicketEntitiesMapper.update(entitiesTable, new UpdateWrapper<KylinOrderTicketEntities>() kylinOrderTicketEntitiesMapper.update(entitiesTable, new UpdateWrapper<KylinOrderTicketEntities>()
.eq("order_ticket_entities_id", entitiesId) .eq("order_ticket_entities_id", entitiesId)
.eq("is_payment", KylinTableStatusConst.ENTITIES_IS_PAYMENT2) .eq("is_payment", KylinTableStatusConst.ENTITIES_IS_PAYMENT2)
); );
KylinOrderTicketEntitiesVo kylinOrderTicketEntitiesVo = new KylinOrderTicketEntitiesVo(); KylinOrderTicketEntitiesVo kylinOrderTicketEntitiesVo = new KylinOrderTicketEntitiesVo();
kylinOrderTicketEntitiesVo.setIsPayment(KylinTableStatusConst.ENTITIES_IS_PAYMENT1); kylinOrderTicketEntitiesVo.setIsPayment(newIsPayment);
BasicDBObject entitiesObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketEntitiesVo))); BasicDBObject entitiesObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(kylinOrderTicketEntitiesVo)));
Document entitiesDoc = mongoTemplate.getCollection(KylinOrderTicketEntitiesVo.class.getSimpleName()).findOneAndUpdate( Document entitiesDoc = mongoTemplate.getCollection(KylinOrderTicketEntitiesVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("orderTicketEntitiesId").is(entitiesId)).getQueryObject(), Query.query(Criteria.where("orderTicketEntitiesId").is(entitiesId)).getQueryObject(),
......
...@@ -39,4 +39,11 @@ public interface KylinOrderRefundsMapper extends BaseMapper<KylinOrderRefunds> { ...@@ -39,4 +39,11 @@ public interface KylinOrderRefundsMapper extends BaseMapper<KylinOrderRefunds> {
@Param("orderTicketsId") String orderTicketsId, @Param("orderTicketsId") String orderTicketsId,
@Param("orderRefundStatusCancel") Integer orderRefundStatusCancel @Param("orderRefundStatusCancel") Integer orderRefundStatusCancel
); );
int selectEntitiesCount(
@Param("orderTicketsId") String orderTicketsId,
@Param("whereRefundingCount") Integer[] whereRefundingCount,
@Param("orderRefundsId") String orderRefundsId,
@Param("entitiesId") String entitiesId
);
} }
...@@ -69,4 +69,18 @@ ...@@ -69,4 +69,18 @@
AND status != ${orderRefundStatusCancel} AND status != ${orderRefundStatusCancel}
</where> </where>
</select> </select>
<select id="selectEntitiesCount" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM kylin_order_refunds AS a
JOIN kylin_order_refund_entities AS b ON a.order_refunds_id = b.order_refunds_id
<where>
AND a.order_tickets_id = #{orderTicketsId}
AND a.order_refunds_id != #{orderRefundsId}
AND a.status NOT IN
<foreach collection="whereRefundingCount" item="statusWhere" index="index" open="(" close=")" separator=",">
${statusWhere}
</foreach>
AND b.order_ticket_entities_id = #{entitiesId}
</where>
</select>
</mapper> </mapper>
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