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

Commit 713acbd7 authored by 胡佳晨's avatar 胡佳晨

取消订单

parent f1570f7d
...@@ -21,6 +21,10 @@ public interface IGoblinStoreOrderService { ...@@ -21,6 +21,10 @@ public interface IGoblinStoreOrderService {
ResponseDto<GoblinStoreOrderListVo> orderDetails(String orderId); ResponseDto<GoblinStoreOrderListVo> orderDetails(String orderId);
ResponseDto<Boolean> orderCancel(String orderId);
ResponseDto<Boolean> changeExpressPrice(String orderId, BigDecimal price);
ResponseDto<Boolean> changeAddress(String orderId, String expressContacts, String expressPhone, String expressAddressDetail); ResponseDto<Boolean> changeAddress(String orderId, String expressContacts, String expressPhone, String expressAddressDetail);
ResponseDto<Boolean> changeSkuPrice(String orderId, String orderSkuId, BigDecimal price); ResponseDto<Boolean> changeSkuPrice(String orderId, String orderSkuId, BigDecimal price);
......
package com.liquidnet.service.consumer.goblin.config;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.goblin.receiver.ConsumerGoblinOrderCloseRdsReceiver;
import com.liquidnet.service.consumer.goblin.receiver.ConsumerGoblinStoreOrderRdsReceiver;
import lombok.var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.stream.Consumer;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.ReadOffset;
import org.springframework.data.redis.connection.stream.StreamOffset;
import org.springframework.data.redis.stream.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription;
import java.time.Duration;
@Configuration
public class ConsumerGoblinStoreOrderRedisStreamConfig {
@Autowired
ConsumerGoblinStoreOrderRdsReceiver consumerGoblinStoreOrderRdsReceiver;
private StreamMessageListenerContainer<String, MapRecord<String, String, String>> buildStreamMessageListenerContainer(RedisConnectionFactory factory) {
var options = StreamMessageListenerContainer
.StreamMessageListenerContainerOptions
.builder()
.pollTimeout(Duration.ofMillis(1))
.build();
return StreamMessageListenerContainer.create(factory, options);
}
/**
* 缺票登记
*
* @param listenerContainer
* @param t
* @return
*/
private Subscription receiveGoblinStoreOrder(StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer, int t) {
return listenerContainer.receiveAutoAck(
Consumer.from(MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getGroup(), MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.name() + t),
StreamOffset.create(MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(), ReadOffset.lastConsumed()), consumerGoblinStoreOrderRdsReceiver
);
}
/* —————————————————————————— | —————————————————————————— | —————————————————————————— */
/* -------------------------------------------------------- | 缺票登记 */
@Bean
public Subscription subscriptionGoblinStoreOrder(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveGoblinStoreOrder(listenerContainer, 1);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionGoblinStoreOrder2(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveGoblinStoreOrder(listenerContainer, 2);
listenerContainer.start();
return subscription;
}
@Bean
public Subscription subscriptionGoblinStoreOrder3(RedisConnectionFactory factory) {
var listenerContainer = this.buildStreamMessageListenerContainer(factory);
var subscription = receiveGoblinStoreOrder(listenerContainer, 3);
listenerContainer.start();
return subscription;
}
/* -------------------------------------------------------- | */
}
package com.liquidnet.service.consumer.goblin.receiver;
import com.liquidnet.service.base.constant.MQConst;
import org.springframework.stereotype.Component;
@Component
public class ConsumerGoblinStoreOrderRdsReceiver extends AbstractSqlRedisReceiver {
@Override
protected String getRedisStreamKey() {
return MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey();
}
@Override
protected String getRedisStreamGroup() {
return MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getGroup();
}
}
...@@ -72,16 +72,25 @@ public class GoblinStoreOrderController { ...@@ -72,16 +72,25 @@ public class GoblinStoreOrderController {
return goblinStoreOrderService.orderDetails(orderId); return goblinStoreOrderService.orderDetails(orderId);
} }
// @ApiOperation(value = "修改订单价格") @ApiOperation(value = "取消订单")
// @ApiImplicitParams({ @ApiImplicitParams({
// @ApiImplicitParam(type = "form", required = false, dataType = "String", name = "orderId", value = "订单id"), @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "orderId", value = "订单id"),
// @ApiImplicitParam(type = "form", required = false, dataType = "BigDecimal", name = "price", value = "退款金额"), })
// }) @GetMapping(value = "cancel")
// @GetMapping(value = "change/price") public ResponseDto<Boolean> orderCancel(@RequestParam(value = "orderId", required = true) @Valid String orderId) {
// public ResponseDto<Boolean> changePrice(@RequestParam(value = "orderId", required = true) @Valid String orderId, return goblinStoreOrderService.orderCancel(orderId);
// @RequestParam(value = "orderId", required = true) @Valid BigDecimal price) { }
// return ResponseDto.success();
// } @ApiOperation(value = "修改快递价格")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = false, dataType = "String", name = "orderId", value = "订单id"),
@ApiImplicitParam(type = "form", required = false, dataType = "BigDecimal", name = "price", value = "快递金额"),
})
@GetMapping(value = "change/expressPrice")
public ResponseDto<Boolean> changeExpressPrice(@RequestParam(value = "orderId", required = true) @Valid String orderId,
@RequestParam(value = "orderId", required = true) @Valid BigDecimal price) {
return goblinStoreOrderService.changeExpressPrice(orderId, price);
}
@ApiOperation(value = "修改sku价格") @ApiOperation(value = "修改sku价格")
@ApiImplicitParams({ @ApiImplicitParams({
......
...@@ -122,6 +122,84 @@ public class GoblinStoreOrderServiceImpl implements IGoblinStoreOrderService { ...@@ -122,6 +122,84 @@ public class GoblinStoreOrderServiceImpl implements IGoblinStoreOrderService {
return ResponseDto.success(vo); return ResponseDto.success(vo);
} }
@Override
public ResponseDto<Boolean> orderCancel(String orderId) {
String uid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now();
String nowStr = DateUtil.getNowTime();
GoblinStoreInfoVo storeInfoVo = redisUtils.getStoreInfoVoByUid(uid);
if (storeInfoVo == null) {
return ResponseDto.failure("无法查看");
}
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(orderId);
if (orderVo == null || !orderVo.getStoreId().equals(storeInfoVo.getStoreId())) {
return ResponseDto.failure("无法查看");
}
orderVo.setStatus(GoblinStatusConst.Status.ORDER_STATUS_5.getValue());
orderVo.setCancelReason("商铺取消");
orderVo.setCancelTime(nowStr);
GoblinOrderOperationLog log = initLog(orderId, uid, now);
log.setType(GoblinStatusConst.Status.ORDER_LOG_STATUS_14.getValue());
log.setRemark("商铺取消订单");
//redis
redisUtils.setGoblinOrder(orderId, orderVo);
//mongo
mongoUtils.updateGoblinStoreOrderVo(orderId, orderVo);
//mysql
queueUtils.sendMsgByRedis(
MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.get("goblin_order.store.cancel",
orderVo.getStatus(), now, orderVo.getCancelReason(), now,
orderId, now, now
)
);
return ResponseDto.success();
}
@Override
public ResponseDto<Boolean> changeExpressPrice(String orderId, BigDecimal price) {
String uid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now();
GoblinStoreInfoVo storeInfoVo = redisUtils.getStoreInfoVoByUid(uid);
if (storeInfoVo == null) {
return ResponseDto.failure("无法查看");
}
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(orderId);
if (orderVo == null || !orderVo.getStoreId().equals(storeInfoVo.getStoreId())) {
return ResponseDto.failure("无法查看");
}
if (orderVo.getStatus() == GoblinStatusConst.Status.ORDER_STATUS_3.getValue()) {
return ResponseDto.failure("已发货");
}
orderVo.setPriceModify(orderVo.getPriceModify().add(price));
orderVo.setPriceVoucher(orderVo.getPriceVoucher().add(price));
orderVo.setPriceActual(orderVo.getPriceActual().multiply(price));
orderVo.setPriceExpress(price);
GoblinOrderOperationLog log = initLog(orderId, uid, now);
log.setType(GoblinStatusConst.Status.ORDER_LOG_STATUS_17.getValue());
log.setRemark("expressPress=[" + price + "]");
//redis
redisUtils.setGoblinOrder(orderId, orderVo);
//mongo
mongoUtils.updateGoblinStoreOrderVo(orderId, orderVo);
//mysql
queueUtils.sendMsgByRedis(
MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.get("goblin_order.store.orderExpressPrice",
orderVo.getPriceModify(), orderVo.getPriceVoucher(), orderVo.getPriceActual(), orderVo.getPriceExpress(), now,
orderId, now, now
)
);
//添加日志
queueUtils.sendMsgByRedis(
MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.get("goblin_order.store.log",
log.getOrderLogId(), log.getOrderId(), log.getType(), log.getRemark(), log.getOperationName(), now
)
);
return ResponseDto.success();
}
@Override @Override
public ResponseDto<Boolean> changeAddress(String orderId, String expressAddressDetail, String expressContacts, String expressPhone) { public ResponseDto<Boolean> changeAddress(String orderId, String expressAddressDetail, String expressContacts, String expressPhone) {
String uid = CurrentUtil.getCurrentUid(); String uid = CurrentUtil.getCurrentUid();
...@@ -214,7 +292,13 @@ public class GoblinStoreOrderServiceImpl implements IGoblinStoreOrderService { ...@@ -214,7 +292,13 @@ public class GoblinStoreOrderServiceImpl implements IGoblinStoreOrderService {
}); });
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(), queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.gets(sqls, sqlsOrder, sqlsOrderSku)); SqlMapping.gets(sqls, sqlsOrder, sqlsOrderSku));
//添加日志
queueUtils.sendMsgByRedis(
MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.get("goblin_order.store.log",
log.getOrderLogId(), log.getOrderId(), log.getType(), log.getRemark(), log.getOperationName(), now
)
);
return ResponseDto.success(); return ResponseDto.success();
} }
......
...@@ -49,7 +49,9 @@ goblin_order.pay.again=UPDATE goblin_store_order SET pay_type = ? ,device_from = ...@@ -49,7 +49,9 @@ goblin_order.pay.again=UPDATE goblin_store_order SET pay_type = ? ,device_from =
#---- 订单绑定[正在下单] #---- 订单绑定[正在下单]
goblin_order.zhengzai.bind=UPDATE goblin_store_order SET uid = ? ,updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null) goblin_order.zhengzai.bind=UPDATE goblin_store_order SET uid = ? ,updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
#---- 商铺订单操作 #---- 商铺订单操作
goblin_order.store.cancel=UPDATE goblin_store_order SET status = ? ,cancel_time = ? , cancel_reason = ? , updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_order.store.address=UPDATE goblin_order_attr SET express_contacts = ? ,express_address_detail = ? , express_phone = ? , updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null) goblin_order.store.address=UPDATE goblin_order_attr SET express_contacts = ? ,express_address_detail = ? , express_phone = ? , updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_order.store.orderPrice=UPDATE goblin_store_order SET price_modify = ? ,price_voucher = ? , price_actual = ? , updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null) goblin_order.store.orderPrice=UPDATE goblin_store_order SET price_modify = ? ,price_voucher = ? , price_actual = ? , updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_order.store.orderSkuPrice=UPDATE goblin_order_sku SET price_modify = ? ,price_voucher = ? , sku_price_actual = ? , updated_at = ? WHERE order_sku_id = ? and (updated_at <= ? or created_at = ? or updated_at is null) goblin_order.store.orderSkuPrice=UPDATE goblin_order_sku SET price_modify = ? ,price_voucher = ? , sku_price_actual = ? , updated_at = ? WHERE order_sku_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_order.store.log = INSERT INTO goblin_order_operation_log (`order_log_id`,`order_id`,`type`,`remark`,`operation_name`,`created_at`) VALUES(?,?,?,?,?,?) goblin_order.store.log = INSERT INTO goblin_order_operation_log (`order_log_id`,`order_id`,`type`,`remark`,`operation_name`,`created_at`) VALUES(?,?,?,?,?,?)
goblin_order.store.orderExpressPrice=UPDATE goblin_store_order SET price_modify = ? ,price_voucher = ? , price_actual = ? ,price_express = ? , updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
...@@ -93,7 +93,7 @@ public class DMCheckGoblinOrderTimeImpl extends ServiceImpl<GoblinStoreOrderMapp ...@@ -93,7 +93,7 @@ public class DMCheckGoblinOrderTimeImpl extends ServiceImpl<GoblinStoreOrderMapp
goblinRedisUtils.setGoblinOrder(orderVo.getOrderId(), orderVo); goblinRedisUtils.setGoblinOrder(orderVo.getOrderId(), orderVo);
//mysql //mysql
sqlDataOrder.add(new Object[]{ sqlDataOrder.add(new Object[]{
orderVo.getStatus(), now, now, orderVo.getOrderId(), now, now orderVo.getStatus(), now, now, "超时关闭", orderVo.getOrderId(), now, now
}); });
//执行sql //执行sql
queueUtils.sendMsgByGoblinRedis(MQConst.KylinQueue.SQL_ORDER_CLOSE.getKey(), queueUtils.sendMsgByGoblinRedis(MQConst.KylinQueue.SQL_ORDER_CLOSE.getKey(),
......
#---- 订单关闭 #---- 订单关闭
goblin_order.close.order=UPDATE goblin_store_order SET status = ? ,updated_at = ? , cancel_time = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null) goblin_order.close.order=UPDATE goblin_store_order SET status = ? ,updated_at = ? , cancel_time = ? , cancel_reason=? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_order.close.sku=UPDATE goblin_order_sku SET status = ? ,updated_at = ? WHERE order_sku_id = ? and (updated_at <= ? or created_at = ? or updated_at is null) goblin_order.close.sku=UPDATE goblin_order_sku SET status = ? ,updated_at = ? WHERE order_sku_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
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