Browse Source

订单状态

yangyb 3 tuần trước cách đây
mục cha
commit
051efb61b7

+ 15 - 3
mall-api/src/main/java/com/txz/mall/constants/Constants.java

@@ -392,8 +392,6 @@ public class Constants {
     public static final String ORDER_TASK_REDIS_KEY_AFTER_CANCEL_BY_USER = "alterOrderCancelByUser"; // 用户取消订单后续操作
     public static final String ORDER_TASK_REDIS_KEY_AFTER_REFUND_BY_USER = "alterOrderRefundByUser"; // 用户订单退款后续操作
 
-    public static final String ORDER_STATUS_CACHE_CREATE_ORDER = "cache_key_create_order";
-
     //支付方式
     public static final String PAY_TYPE_WE_CHAT = "weixin"; //微信支付
     public static final String PAY_TYPE_YUE = "yue"; //余额支付
@@ -413,7 +411,21 @@ public class Constants {
 
 
     //订单操作类型
-    public static final String ORDER_STATUS_STR_SPIKE_KEY = "send"; //待收货 KEY
+    public static final String ORDER_STATUS_CREATE_ORDER = "create_order"; //创建订单
+    public static final String ORDER_STATUS_REMOVE_ORDER = "remove_order"; //删除订单
+    public static final String ORDER_STATUS_CANCEL_ORDER = "cancel_order"; //取消订单
+    public static final String ORDER_STATUS_PAY_ORDER = "pay_order"; //支付订单
+    public static final String ORDER_STATUS_APPLY_REFUND = "apply_refund"; //申请退款
+    public static final String ORDER_STATUS_DELIVERY_ORDER = "delivery"; // 发货
+    public static final String ORDER_STATUS_RECEIVE_ORDER = "receive"; //收货
+    public static final String ORDER_STATUS_SPIKE_ORDER = "send"; //待收货 KEY
+
+    public static final String ORDER_STATUS_OPEN_ORDER = "open";// 开团
+    public static final String ORDER_STATUS_PINK_ORDER = "pink";// 拼团
+    public static final String ORDER_STATUS_PINK_FAIL_ORDER = "pink_fail";// 拼团失败
+    public static final String ORDER_STATUS_PINK_SUCCESS_ORDER = "pink_success"; // 拼团成功
+
+
     public static final String ORDER_LOG_REFUND_PRICE = "refund_price"; //退款
     public static final String ORDER_LOG_EXPRESS = "express"; //快递
     public static final String ORDER_LOG_DELIVERY = "delivery"; //送货

+ 123 - 0
mall-api/src/main/java/com/txz/mall/dto/StoreOrderStatusDTO.java

@@ -0,0 +1,123 @@
+/*
+ *
+ * StoreOrderStatusDTO.java
+ * Copyright(C) 2017-2020 fendo公司
+ * @date 2025-07-25
+ */
+package com.txz.mall.dto;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class StoreOrderStatusDTO implements Serializable {
+    /**
+     * m_store_order_status
+     */
+    private static final long serialVersionUID = 1L;
+    /**
+     *
+     */
+    private Long id;
+    /**
+     * 订单id
+     */
+    private Integer oid;
+    /**
+     * 操作类型
+     */
+    private String changeType;
+    /**
+     * 操作备注
+     */
+    private String changeMessage;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * @return id
+     */
+    public Long getId() {
+        return id;
+    }
+
+    /**
+     * @param id
+     */
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    /**
+     * 订单id
+     *
+     * @return oid 订单id
+     */
+    public Integer getOid() {
+        return oid;
+    }
+
+    /**
+     * 订单id
+     *
+     * @param oid 订单id
+     */
+    public void setOid(Integer oid) {
+        this.oid = oid;
+    }
+
+    /**
+     * 操作类型
+     *
+     * @return change_type 操作类型
+     */
+    public String getChangeType() {
+        return changeType;
+    }
+
+    /**
+     * 操作类型
+     *
+     * @param changeType 操作类型
+     */
+    public void setChangeType(String changeType) {
+        this.changeType = changeType;
+    }
+
+    /**
+     * 操作备注
+     *
+     * @return change_message 操作备注
+     */
+    public String getChangeMessage() {
+        return changeMessage;
+    }
+
+    /**
+     * 操作备注
+     *
+     * @param changeMessage 操作备注
+     */
+    public void setChangeMessage(String changeMessage) {
+        this.changeMessage = changeMessage;
+    }
+
+    /**
+     * 创建时间
+     *
+     * @return create_time 创建时间
+     */
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    /**
+     * 创建时间
+     *
+     * @param createTime 创建时间
+     */
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+}

+ 27 - 0
mall-interface/src/main/java/com/txz/mall/service/StoreOrderStatusServiceClient.java

@@ -0,0 +1,27 @@
+package com.txz.mall.service;
+
+
+import com.txz.mall.dto.*;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+import java.util.List;
+
+
+@FeignClient("mall")
+public interface StoreOrderStatusServiceClient {
+
+	@RequestMapping( value = {"/store/order/status/add"}, method = {RequestMethod.POST} )
+    public Result add(@RequestBody StoreOrderStatusDPO storeOrderStatus,@RequestParam("userId") Long userId);
+
+	@RequestMapping( value = {"/store/order/status/delete"}, method = {RequestMethod.POST} )
+	public Result delete(@RequestParam("id") Integer id,@RequestParam("userId") Long userId);
+
+	@RequestMapping( value = {"/store/order/status/update"}, method = {RequestMethod.POST} )
+	public Result update(@RequestBody StoreOrderStatusDPO storeOrderStatus,@RequestParam("userId") Long userId);
+
+	@RequestMapping( value = {"/store/order/status/detail"}, method = {RequestMethod.POST} )
+	public Result<StoreOrderStatusDPO> detail(@RequestParam("id") Integer id,@RequestParam("userId") Long userId);
+
+	@RequestMapping( value = {"/store/order/status/list"}, method = {RequestMethod.POST} )
+	public Result<List<StoreOrderStatusDPO>> list(@RequestBody StoreOrderStatusDPO storeOrderStatus, @RequestParam("page") Integer page, @RequestParam("size") Integer size,@RequestParam("userId") Long userId);
+}

+ 122 - 0
mall-service/src/main/java/com/txz/mall/controller/StoreOrderStatusController.java

@@ -0,0 +1,122 @@
+package com.txz.mall.controller;
+
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.txz.mall.core.Result;
+import com.txz.mall.core.ResultCode;
+import com.txz.mall.model.StoreOrderStatus;
+import com.txz.mall.service.StoreOrderStatusService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.*;
+import tk.mybatis.mapper.entity.Condition;
+import tk.mybatis.mapper.entity.Example.Criteria;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by CodeGenerator on 2025/07/25.
+ */
+@Api(tags = "[后台]storeOrderStatus管理")
+@RestController
+@RequestMapping("/store/order/status")
+public class StoreOrderStatusController {
+
+    private static Logger log = LoggerFactory.getLogger(StoreOrderStatusController.class);
+
+    @Resource
+    private StoreOrderStatusService storeOrderStatusService;
+
+    @PostMapping("/add")
+    @ApiOperation(value = "storeOrderStatus新增")
+    public Result add(@RequestBody StoreOrderStatus storeOrderStatus) {
+        if (storeOrderStatus == null) {
+            return Result.fail(ResultCode.OBJECT_IS_NULL);
+        }
+        try {
+            storeOrderStatus.setCreateTime(new Date());
+//            storeOrderStatus.setCreateUserId(userId);
+            storeOrderStatusService.save(storeOrderStatus);
+        } catch (Exception e) {
+            log.error("新增对象操作异常e:{}", e);
+            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+        }
+        return Result.success();
+    }
+
+    @PostMapping("/delete")
+    @ApiOperation(value = "storeOrderStatus删除")
+    public Result delete(@RequestParam Long id) {
+        if (id == null) {
+            return Result.fail(ResultCode.ID_IS_NULL);
+        }
+        try {
+            StoreOrderStatus storeOrderStatus = new StoreOrderStatus();
+            storeOrderStatus.setId(id);
+            storeOrderStatusService.update(storeOrderStatus);
+        } catch (Exception e) {
+            log.error("删除对象操作异常e:{}", e);
+            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+        }
+        return Result.success();
+    }
+
+    @PostMapping("/update")
+    @ApiOperation(value = "storeOrderStatus更新")
+    public Result update(@RequestBody StoreOrderStatus storeOrderStatus) {
+        if (storeOrderStatus == null) {
+            return Result.fail(ResultCode.OBJECT_IS_NULL);
+        }
+        if (storeOrderStatus.getId() == null) {
+            return Result.fail(ResultCode.ID_IS_NULL);
+        }
+        try {
+//            storeOrderStatus.setUpdateUserId(userId);
+            storeOrderStatusService.update(storeOrderStatus);
+        } catch (Exception e) {
+            log.error("更新对象操作异常e:{}", e);
+            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+        }
+        return Result.success();
+    }
+
+    @PostMapping("/detail")
+    @ApiOperation(value = "storeOrderStatus获取详情")
+    public Result<StoreOrderStatus> detail(@RequestParam Long id) {
+        if (id == null) {
+            return Result.fail(ResultCode.ID_IS_NULL);
+        }
+        StoreOrderStatus storeOrderStatus = null;
+        try {
+            storeOrderStatus = storeOrderStatusService.findById(id);
+        } catch (Exception e) {
+            log.error("查询对象操作异常e:{}", e);
+            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+        }
+        return Result.success(storeOrderStatus);
+    }
+
+    @PostMapping("/list")
+    @ApiOperation(value = "storeOrderStatus获取列表")
+    public Result<List<StoreOrderStatus>> list(@RequestBody StoreOrderStatus storeOrderStatus, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
+        PageHelper.startPage(page, size);
+
+        Condition condition = new Condition(storeOrderStatus.getClass());
+        Criteria criteria = condition.createCriteria();
+        criteria.andEqualTo("isDelete", 0);
+        condition.setOrderByClause("create_time DESC");
+        PageInfo pageInfo = null;
+        try {
+            List<StoreOrderStatus> list = storeOrderStatusService.findByCondition(condition);
+            pageInfo = new PageInfo(list);
+        } catch (Exception e) {
+            log.error("查询对象操作异常e:{}", e);
+            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+        }
+        return Result.success(pageInfo);
+    }
+}

+ 7 - 0
mall-service/src/main/java/com/txz/mall/dao/StoreOrderStatusMapper.java

@@ -0,0 +1,7 @@
+package com.txz.mall.dao;
+
+import com.txz.mall.core.Mapper;
+import com.txz.mall.model.StoreOrderStatus;
+
+public interface StoreOrderStatusMapper extends Mapper<StoreOrderStatus> {
+}

+ 40 - 0
mall-service/src/main/java/com/txz/mall/model/StoreOrderStatus.java

@@ -0,0 +1,40 @@
+package com.txz.mall.model;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.util.Date;
+
+@Data
+@Table(name = "m_store_order_status")
+public class StoreOrderStatus {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
+    /**
+     * 订单id
+     */
+    private Long oid;
+
+    /**
+     * 操作类型
+     */
+    @Column(name = "change_type")
+    private String changeType;
+
+    /**
+     * 操作备注
+     */
+    @Column(name = "change_message")
+    private String changeMessage;
+
+    /**
+     * 创建时间
+     */
+    @Column(name = "create_time")
+    private Date createTime;
+
+
+}

+ 21 - 0
mall-service/src/main/java/com/txz/mall/service/StoreOrderStatusService.java

@@ -0,0 +1,21 @@
+package com.txz.mall.service;
+
+import com.txz.mall.core.Service;
+import com.txz.mall.model.StoreOrderStatus;
+
+
+/**
+ * Created by CodeGenerator on 2025/07/25.
+ */
+public interface StoreOrderStatusService extends Service<StoreOrderStatus> {
+
+    /**
+     * 添加订单日志
+     *
+     * @param orderId 订单id
+     * @param type    类型
+     * @param message 备注
+     * @return Boolean
+     */
+    void createLog(Long orderId, String type, String message);
+}

+ 2 - 1
mall-service/src/main/java/com/txz/mall/service/impl/StoreOrderServiceImpl.java

@@ -53,6 +53,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
     private final StoreProductService storeProductService;
     private final StorePinkService storePinkService;
     private final CifUserDubboServiceClient userDubboServiceClient;
+    private final StoreOrderStatusService storeOrderStatusService;
     private RedisUtil redisUtil;
 
     @Override
@@ -1024,7 +1025,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
 //        // 保存购物车商品详情
 //        storeOrderInfoService.saveOrderInfos(storeOrderInfos);
 //        // 生成订单日志
-//        storeOrderStatusService.createLog(storeOrder.getId(), Constants.ORDER_STATUS_CACHE_CREATE_ORDER, "订单生成");
+        storeOrderStatusService.createLog(storeOrder.getId(), Constants.ORDER_STATUS_CREATE_ORDER, "订单生成");
 //
 //        // 清除购物车数据
 //        if (CollUtil.isNotEmpty(orderInfoVo.getCartIdList())) {

+ 33 - 0
mall-service/src/main/java/com/txz/mall/service/impl/StoreOrderStatusServiceImpl.java

@@ -0,0 +1,33 @@
+package com.txz.mall.service.impl;
+
+import com.txz.mall.core.AbstractService;
+import com.txz.mall.dao.StoreOrderStatusMapper;
+import com.txz.mall.model.StoreOrderStatus;
+import com.txz.mall.service.StoreOrderStatusService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.Date;
+
+
+/**
+ * Created by CodeGenerator on 2025/07/25.
+ */
+@Service
+@Transactional
+public class StoreOrderStatusServiceImpl extends AbstractService<StoreOrderStatus> implements StoreOrderStatusService {
+    @Resource
+    private StoreOrderStatusMapper storeOrderStatusMapper;
+
+    @Override
+    public void createLog(Long orderId, String type, String message) {
+        StoreOrderStatus storeOrderStatus = new StoreOrderStatus();
+        storeOrderStatus.setOid(orderId);
+        storeOrderStatus.setChangeType(type);
+        storeOrderStatus.setChangeMessage(message);
+        storeOrderStatus.setCreateTime(new Date());
+        save(storeOrderStatus);
+    }
+
+}

+ 14 - 0
mall-service/src/main/resources/mapper/StoreOrderStatusMapper.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.txz.mall.dao.StoreOrderStatusMapper">
+    <resultMap id="BaseResultMap" type="com.txz.mall.model.StoreOrderStatus">
+        <!--
+          WARNING - @mbg.generated
+        -->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="oid" jdbcType="INTEGER" property="oid"/>
+        <result column="change_type" jdbcType="VARCHAR" property="changeType"/>
+        <result column="change_message" jdbcType="VARCHAR" property="changeMessage"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+    </resultMap>
+</mapper>