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

Commit 3217a4f1 authored by 胡佳晨's avatar 胡佳晨

订单修改收货地址,订单修改sku金额

parent c61886a4
......@@ -42,6 +42,7 @@ public class GoblinStatusConst {
ORDER_LOG_STATUS_14(14, "取消订单"),
ORDER_LOG_STATUS_15(15, "修改物流单号"),
ORDER_LOG_STATUS_16(16, "核销虚拟商品订单"),
ORDER_LOG_STATUS_17(17, "修改收货地址"),
ORDER_LOG_STATUS_21(21, "退款申请"),
ORDER_LOG_STATUS_22(22, "退款成功"),
......
......@@ -7,6 +7,7 @@ import com.liquidnet.service.goblin.dto.vo.GoblinStoreOrderListVo;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.Valid;
import java.math.BigDecimal;
public interface IGoblinStoreOrderService {
ResponseDto<PageInfo<GoblinStoreOrderListVo>> orderList(Integer page,
......@@ -20,4 +21,7 @@ public interface IGoblinStoreOrderService {
ResponseDto<GoblinStoreOrderListVo> orderDetails(String orderId);
ResponseDto<Boolean> changeAddress(String orderId, String expressContacts, String expressPhone, String expressAddressDetail);
ResponseDto<Boolean> changeSkuPrice(String orderId, String orderSkuId, BigDecimal price);
}
......@@ -208,6 +208,7 @@ public class MQConst {
GOBLIN_ORDER_CREATE_PAY("goblin:stream:order:create_pay", "group.order:create_pay", "订单创建&支付"),
GOBLIN_ORDER_AGAIN("goblin:stream:order:again", "group.order:again", "订单再次支付"),
GOBLIN_ORDER_CLOSE("goblin:stream:order:close", "group.order:close", "订单关闭"),
GOBLIN_STORE_ORDER_OPERA("goblin:stream:order:store", "group.order:store", "商铺订单操作"),
;
private final String key;
......
......@@ -2,8 +2,10 @@ package com.liquidnet.service.goblin.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
......@@ -17,7 +19,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class GoblinOrderOperationLog implements Serializable {
public class GoblinOrderOperationLog implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
......@@ -35,7 +37,7 @@ public class GoblinOrderOperationLog implements Serializable {
private String orderId;
/**
* 操作类型[1-确认付款|2-修改金额|3-发货|4-取消订单|5-修改物流单号|6-核销虚拟商品订单]
* 操作类型[1-确认付款|2-修改金额|3-发货|4-取消订单|5-修改物流单号|6-核销虚拟商品订单|7-修改收货地址]
*/
private Integer type;
......@@ -55,5 +57,14 @@ public class GoblinOrderOperationLog implements Serializable {
private String comment;
private static final GoblinOrderOperationLog obj = new GoblinOrderOperationLog();
public static GoblinOrderOperationLog getNew() {
try {
return (GoblinOrderOperationLog) obj.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return new GoblinOrderOperationLog();
}
}
......@@ -38,8 +38,6 @@ import java.util.List;
public class GoblinStoreOrderController {
@Autowired
IGoblinStoreOrderService goblinStoreOrderService;
@Autowired
GoblinRedisUtils goblinRedisUtils;
@ApiOperation(value = "订单列表")
@ApiImplicitParams({
......@@ -74,16 +72,16 @@ public class GoblinStoreOrderController {
return goblinStoreOrderService.orderDetails(orderId);
}
@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/price")
public ResponseDto<Boolean> changePrice(@RequestParam(value = "orderId", required = true) @Valid String 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/price")
// public ResponseDto<Boolean> changePrice(@RequestParam(value = "orderId", required = true) @Valid String orderId,
// @RequestParam(value = "orderId", required = true) @Valid BigDecimal price) {
// return ResponseDto.success();
// }
@ApiOperation(value = "修改sku价格")
@ApiImplicitParams({
......@@ -95,18 +93,22 @@ public class GoblinStoreOrderController {
public ResponseDto<Boolean> changeSkuPrice(@RequestParam(value = "orderId", required = true) @Valid String orderId,
@RequestParam(value = "orderSkuId", required = true) @Valid String orderSkuId,
@RequestParam(value = "orderId", required = true) @Valid BigDecimal price) {
return ResponseDto.success();
return goblinStoreOrderService.changeSkuPrice(orderId, orderSkuId, price);
}
@ApiOperation(value = "修改收货地址")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = false, dataType = "String", name = "orderId", value = "订单id"),
@ApiImplicitParam(type = "form", required = false, dataType = "String", name = "expressAddressDetail", value = "详细快递地址"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "orderId", value = "订单id"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "expressAddressDetail", value = "详细快递地址"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "expressContacts", value = "联系人"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "expressPhone", value = "联系人电话"),
})
@GetMapping(value = "change/address")
public ResponseDto<Boolean> changeAddress(@RequestParam(value = "orderId", required = true) @Valid String orderId,
@RequestParam(value = "expressContacts", required = true) @Valid String expressContacts,
@RequestParam(value = "expressPhone", required = true) @Valid String expressPhone,
@RequestParam(value = "expressAddressDetail", required = true) @Valid String expressAddressDetail) {
return ResponseDto.success();
return goblinStoreOrderService.changeAddress(orderId, expressContacts, expressPhone, expressAddressDetail);
}
@ApiOperation(value = "sku退款")
......
package com.liquidnet.service.goblin.service.impl.manage;
import com.github.pagehelper.PageInfo;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinOrderOperationLog;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreMoneyService;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreOrderService;
import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.ObjectUtil;
import com.liquidnet.service.goblin.util.QueueUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@Service
......@@ -26,6 +35,8 @@ public class GoblinStoreOrderServiceImpl implements IGoblinStoreOrderService {
GoblinRedisUtils redisUtils;
@Autowired
GoblinMongoUtils mongoUtils;
@Autowired
QueueUtils queueUtils;
@Override
public ResponseDto<PageInfo<GoblinStoreOrderListVo>> orderList(Integer page, String orderCode, Integer type, String cst, String cet, String expressContacts, String phone, Integer status) {
......@@ -110,4 +121,109 @@ public class GoblinStoreOrderServiceImpl implements IGoblinStoreOrderService {
vo.setStoreOrderListSkuVoList(orderListSkuVos);
return ResponseDto.success(vo);
}
@Override
public ResponseDto<Boolean> changeAddress(String orderId, String expressAddressDetail, String expressContacts, String expressPhone) {
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.getOrderAttrVo().setExpressAddressDetail(expressAddressDetail);
orderVo.getOrderAttrVo().setExpressContacts(expressContacts);
orderVo.getOrderAttrVo().setExpressPhone(expressPhone);
GoblinOrderOperationLog log = initLog(orderId, uid, now);
log.setType(GoblinStatusConst.Status.ORDER_LOG_STATUS_17.getValue());
log.setRemark("expressContacts=[" + expressContacts + "],expressPhone=[" + expressPhone + "],expressAddressDetail=[" + expressAddressDetail + "]");
//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.address",
expressContacts, expressPhone, expressAddressDetail, 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
public ResponseDto<Boolean> changeSkuPrice(String orderId, String orderSkuId, 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_0.getValue()) {
return ResponseDto.failure("已发货");
}
GoblinOrderSkuVo orderSkuVo = redisUtils.getGoblinOrderSkuVo(orderSkuId);
if (orderSkuVo == null) {
return ResponseDto.failure("不存在");
}
orderSkuVo.setPriceModify(price);
orderSkuVo.setPriceVoucher(orderSkuVo.getPriceVoucher().add(price));
orderSkuVo.setSkuPriceActual(orderSkuVo.getSkuPriceActual().multiply(price));
orderVo.setPriceModify(orderVo.getPriceModify().add(price));
orderVo.setPriceVoucher(orderVo.getPriceVoucher().add(price));
orderVo.setPriceActual(orderVo.getPriceActual().multiply(price));
GoblinOrderOperationLog log = initLog(orderId, uid, now);
log.setType(GoblinStatusConst.Status.ORDER_LOG_STATUS_12.getValue());
log.setRemark("orderSkuId=[" + orderSkuId + "],price=[" + price + "]");
//redis
redisUtils.setGoblinOrder(orderId, orderVo);
redisUtils.setGoblinOrderSku(orderSkuId, orderSkuVo);
//mongo
mongoUtils.updateGoblinStoreOrderVo(orderId, orderVo);
mongoUtils.updateGoblinOrderSkuVo(orderSkuId, orderSkuVo);
//mysql
LinkedList<String> sqls = CollectionUtil.linkedListString();
LinkedList<Object[]> sqlsOrder = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> sqlsOrderSku = CollectionUtil.linkedListObjectArr();
sqls.add(SqlMapping.get("goblin_order.store.orderPrice"));
sqls.add(SqlMapping.get("goblin_order.store.orderSkuPrice"));
sqlsOrder.add(new Object[]{
orderVo.getPriceModify(), orderVo.getPriceVoucher(), orderVo.getPriceActual(), now,
orderId, now, now
});
sqlsOrderSku.add(new Object[]{
orderSkuVo.getPriceModify(), orderSkuVo.getPriceVoucher(), orderSkuVo.getSkuPriceActual(), now,
orderSkuId, now, now
});
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_STORE_ORDER_OPERA.getKey(),
SqlMapping.gets(sqls, sqlsOrder, sqlsOrderSku));
return ResponseDto.success();
}
private GoblinOrderOperationLog initLog(String orderId, String uid, LocalDateTime now) {
GoblinOrderOperationLog log = GoblinOrderOperationLog.getNew();
log.setOrderId(orderId);
log.setOperationName(uid);
log.setOrderLogId(IDGenerator.nextTimeId2());
log.setCreatedAt(now);
return log;
}
}
......@@ -44,11 +44,12 @@ goblin.order.create.attr_insert=INSERT INTO goblin_order_attr (`order_attr_id`,`
goblin.order.create.sku_insert=INSERT INTO goblin_order_sku (`order_sku_id`,`order_id`,`spu_id`,`sku_id`,`num`,`sku_price`,`sku_price_actual`,`sku_name`,`sku_no`,`sku_image`,`sku_specs`,`price_voucher`,`created_at`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)
goblin_order.pay.order=UPDATE goblin_store_order SET payment_type = ? ,payment_id=?,pay_code = ? ,pay_time = ?,write_off_code = ? ,status = ? ,updated_at = ? WHERE order_id = ? and (updated_at <= ? or created_at = ? or updated_at is null)
goblin_order.pay.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.order=UPDATE goblin_store_order SET status = ? ,updated_at = ? 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.pay.again=UPDATE goblin_store_order SET pay_type = ? ,device_from = ? ,pay_code = ? 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)
#---- 订单关闭
\ No newline at end of file
#---- 商铺订单操作
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.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(?,?,?,?,?,?)
\ No newline at end of file
......@@ -65,7 +65,7 @@ public class DMCheckGoblinOrderTimeImpl extends ServiceImpl<GoblinStoreOrderMapp
List<String> orderIds = goblinRedisUtils.getUnPayGoblinOrderList(i + "");
for (String orderId : orderIds) {
GoblinStoreOrderVo orderVo = goblinRedisUtils.getGoblinOrder(orderId);
LocalDateTime expireTime = LocalDateTime.parse(orderVo.getCreatedAt(),DTF_YMD_HMS).plusMinutes(orderVo.getPayCountdownMinute() + 1);
LocalDateTime expireTime = LocalDateTime.parse(orderVo.getCreatedAt(), DTF_YMD_HMS).plusMinutes(orderVo.getPayCountdownMinute() + 1);
if (now.isAfter(expireTime) && orderVo.getStatus() == GoblinStatusConst.Status.ORDER_STATUS_0.getValue()) {//过期
LinkedList<String> sqls = CollectionUtil.linkedListString();
LinkedList<Object[]> sqlDataOrder = CollectionUtil.linkedListObjectArr();
......@@ -84,7 +84,7 @@ public class DMCheckGoblinOrderTimeImpl extends ServiceImpl<GoblinStoreOrderMapp
goblinRedisUtils.removeGoblinOrder(i + "", orderVo.getOrderId());
//mysql
sqlDataSku.add(new Object[]{
orderVo.getStatus(),now,orderVo.getOrderId(),now,now
orderVo.getStatus(), now, orderVo.getOrderId(), now, now
});
}
//订单
......@@ -93,11 +93,11 @@ public class DMCheckGoblinOrderTimeImpl extends ServiceImpl<GoblinStoreOrderMapp
goblinRedisUtils.setGoblinOrder(orderVo.getOrderId(), orderVo);
//mysql
sqlDataOrder.add(new Object[]{
orderVo.getStatus(),now,orderVo.getOrderId(),now,now
orderVo.getStatus(), now, now, orderVo.getOrderId(), now, now
});
//执行sql
queueUtils.sendMsgByGoblinRedis(MQConst.KylinQueue.SQL_ORDER_CLOSE.getKey(),
SqlMapping.gets(sqls, sqlDataOrder, sqlDataSku) );
SqlMapping.gets(sqls, sqlDataOrder, sqlDataSku));
}
}
}
......
#---- 订单关闭
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.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