Browse Source

新增订单过期时间配置

赵冬冬 4 years ago
parent
commit
14edcd8784

+ 25 - 0
carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/h5/facade/carbon/entity/OrderSetting.java

@@ -0,0 +1,25 @@
+package com.hcloud.microserver.h5.facade.carbon.entity;
+
+public class OrderSetting {
+    /** */
+    private Long id;
+
+    /** 正常订单超时时间(分)*/
+    private Integer normalOrderOvertime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Integer getNormalOrderOvertime() {
+        return normalOrderOvertime;
+    }
+
+    public void setNormalOrderOvertime(Integer normalOrderOvertime) {
+        this.normalOrderOvertime = normalOrderOvertime;
+    }
+}

+ 320 - 0
carbon-h5/carbon-h5-common/src/main/java/com/hcloud/microserver/h5/facade/carbon/entity/OrderSettingExample.java

@@ -0,0 +1,320 @@
+package com.hcloud.microserver.h5.facade.carbon.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class OrderSettingExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    public OrderSettingExample() {
+        oredCriteria = new ArrayList<Criteria>();
+    }
+
+    public void setOrderByClause(String orderByClause) {
+        this.orderByClause = orderByClause;
+    }
+
+    public String getOrderByClause() {
+        return orderByClause;
+    }
+
+    public void setDistinct(boolean distinct) {
+        this.distinct = distinct;
+    }
+
+    public boolean isDistinct() {
+        return distinct;
+    }
+
+    public List<Criteria> getOredCriteria() {
+        return oredCriteria;
+    }
+
+    public void or(Criteria criteria) {
+        oredCriteria.add(criteria);
+    }
+
+    public Criteria or() {
+        Criteria criteria = createCriteriaInternal();
+        oredCriteria.add(criteria);
+        return criteria;
+    }
+
+    public Criteria createCriteria() {
+        Criteria criteria = createCriteriaInternal();
+        if (oredCriteria.size() == 0) {
+            oredCriteria.add(criteria);
+        }
+        return criteria;
+    }
+
+    protected Criteria createCriteriaInternal() {
+        Criteria criteria = new Criteria();
+        return criteria;
+    }
+
+    public void clear() {
+        oredCriteria.clear();
+        orderByClause = null;
+        distinct = false;
+    }
+
+    protected abstract static class GeneratedCriteria {
+        protected List<Criterion> criteria;
+
+        protected GeneratedCriteria() {
+            super();
+            criteria = new ArrayList<Criterion>();
+        }
+
+        public boolean isValid() {
+            return criteria.size() > 0;
+        }
+
+        public List<Criterion> getAllCriteria() {
+            return criteria;
+        }
+
+        public List<Criterion> getCriteria() {
+            return criteria;
+        }
+
+        protected void addCriterion(String condition) {
+            if (condition == null) {
+                throw new RuntimeException("Value for condition cannot be null");
+            }
+            criteria.add(new Criterion(condition));
+        }
+
+        protected void addCriterion(String condition, Object value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value));
+        }
+
+        protected void addCriterion(String condition, Object value1, Object value2, String property) {
+            if (value1 == null || value2 == null) {
+                throw new RuntimeException("Between values for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value1, value2));
+        }
+
+        public Criteria andIdIsNull() {
+            addCriterion("id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIsNotNull() {
+            addCriterion("id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdEqualTo(Long value) {
+            addCriterion("id =", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotEqualTo(Long value) {
+            addCriterion("id <>", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThan(Long value) {
+            addCriterion("id >", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("id >=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThan(Long value) {
+            addCriterion("id <", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThanOrEqualTo(Long value) {
+            addCriterion("id <=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIn(List<Long> values) {
+            addCriterion("id in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotIn(List<Long> values) {
+            addCriterion("id not in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdBetween(Long value1, Long value2) {
+            addCriterion("id between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotBetween(Long value1, Long value2) {
+            addCriterion("id not between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andNormalOrderOvertimeIsNull() {
+            addCriterion("normal_order_overtime is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andNormalOrderOvertimeIsNotNull() {
+            addCriterion("normal_order_overtime is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andNormalOrderOvertimeEqualTo(Integer value) {
+            addCriterion("normal_order_overtime =", value, "normalOrderOvertime");
+            return (Criteria) this;
+        }
+
+        public Criteria andNormalOrderOvertimeNotEqualTo(Integer value) {
+            addCriterion("normal_order_overtime <>", value, "normalOrderOvertime");
+            return (Criteria) this;
+        }
+
+        public Criteria andNormalOrderOvertimeGreaterThan(Integer value) {
+            addCriterion("normal_order_overtime >", value, "normalOrderOvertime");
+            return (Criteria) this;
+        }
+
+        public Criteria andNormalOrderOvertimeGreaterThanOrEqualTo(Integer value) {
+            addCriterion("normal_order_overtime >=", value, "normalOrderOvertime");
+            return (Criteria) this;
+        }
+
+        public Criteria andNormalOrderOvertimeLessThan(Integer value) {
+            addCriterion("normal_order_overtime <", value, "normalOrderOvertime");
+            return (Criteria) this;
+        }
+
+        public Criteria andNormalOrderOvertimeLessThanOrEqualTo(Integer value) {
+            addCriterion("normal_order_overtime <=", value, "normalOrderOvertime");
+            return (Criteria) this;
+        }
+
+        public Criteria andNormalOrderOvertimeIn(List<Integer> values) {
+            addCriterion("normal_order_overtime in", values, "normalOrderOvertime");
+            return (Criteria) this;
+        }
+
+        public Criteria andNormalOrderOvertimeNotIn(List<Integer> values) {
+            addCriterion("normal_order_overtime not in", values, "normalOrderOvertime");
+            return (Criteria) this;
+        }
+
+        public Criteria andNormalOrderOvertimeBetween(Integer value1, Integer value2) {
+            addCriterion("normal_order_overtime between", value1, value2, "normalOrderOvertime");
+            return (Criteria) this;
+        }
+
+        public Criteria andNormalOrderOvertimeNotBetween(Integer value1, Integer value2) {
+            addCriterion("normal_order_overtime not between", value1, value2, "normalOrderOvertime");
+            return (Criteria) this;
+        }
+    }
+
+    public static class Criteria extends GeneratedCriteria {
+
+        protected Criteria() {
+            super();
+        }
+    }
+
+    public static class Criterion {
+        private String condition;
+
+        private Object value;
+
+        private Object secondValue;
+
+        private boolean noValue;
+
+        private boolean singleValue;
+
+        private boolean betweenValue;
+
+        private boolean listValue;
+
+        private String typeHandler;
+
+        public String getCondition() {
+            return condition;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object getSecondValue() {
+            return secondValue;
+        }
+
+        public boolean isNoValue() {
+            return noValue;
+        }
+
+        public boolean isSingleValue() {
+            return singleValue;
+        }
+
+        public boolean isBetweenValue() {
+            return betweenValue;
+        }
+
+        public boolean isListValue() {
+            return listValue;
+        }
+
+        public String getTypeHandler() {
+            return typeHandler;
+        }
+
+        protected Criterion(String condition) {
+            super();
+            this.condition = condition;
+            this.typeHandler = null;
+            this.noValue = true;
+        }
+
+        protected Criterion(String condition, Object value, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.typeHandler = typeHandler;
+            if (value instanceof List<?>) {
+                this.listValue = true;
+            } else {
+                this.singleValue = true;
+            }
+        }
+
+        protected Criterion(String condition, Object value) {
+            this(condition, value, null);
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.secondValue = secondValue;
+            this.typeHandler = typeHandler;
+            this.betweenValue = true;
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue) {
+            this(condition, value, secondValue, null);
+        }
+    }
+}

+ 31 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/dao/OrderSettingMapper.java

@@ -0,0 +1,31 @@
+package com.hcloud.microserver.h5.dao;
+
+import com.hcloud.microserver.h5.facade.carbon.entity.OrderSetting;
+import com.hcloud.microserver.h5.facade.carbon.entity.OrderSettingExample;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface OrderSettingMapper {
+    int countByExample(OrderSettingExample example);
+
+    int deleteByExample(OrderSettingExample example);
+
+    int deleteByPrimaryKey(Long id);
+
+    int insert(OrderSetting record);
+
+    int insertSelective(OrderSetting record);
+
+    List<OrderSetting> selectByExample(OrderSettingExample example);
+
+    OrderSetting selectByPrimaryKey(Long id);
+
+    int updateByExampleSelective(@Param("record") OrderSetting record, @Param("example") OrderSettingExample example);
+
+    int updateByExample(@Param("record") OrderSetting record, @Param("example") OrderSettingExample example);
+
+    int updateByPrimaryKeySelective(OrderSetting record);
+
+    int updateByPrimaryKey(OrderSetting record);
+}

+ 14 - 7
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/OrderInfoServiceImpl.java

@@ -8,10 +8,7 @@ import com.hcloud.microserver.h5.config.mq.service.impl.IMessageService;
 import com.hcloud.microserver.h5.dao.*;
 import com.hcloud.microserver.h5.events.CredentialInfoEvent;
 import com.hcloud.microserver.h5.events.CustomerCarbonValEvent;
-import com.hcloud.microserver.h5.facade.carbon.entity.GoodsInfo;
-import com.hcloud.microserver.h5.facade.carbon.entity.GoodsOrderDetail;
-import com.hcloud.microserver.h5.facade.carbon.entity.GoodsOrderInfo;
-import com.hcloud.microserver.h5.facade.carbon.entity.GoodsPayOrder;
+import com.hcloud.microserver.h5.facade.carbon.entity.*;
 import com.hcloud.microserver.h5.facade.carbon.entity.from.CreateOrderDetailFrom;
 import com.hcloud.microserver.h5.facade.carbon.entity.from.CreateOrderFrom;
 import com.hcloud.microserver.h5.facade.carbon.forms.*;
@@ -527,6 +524,9 @@ public class OrderInfoServiceImpl implements OrderInfoService {
     @Autowired
     private IMessageService messageService;
 
+    @Autowired
+    private OrderSettingMapper orderSettingMapper;
+
     @Override
     @Transactional
     public GoodsOrderInfo createOrder(CreateOrderFrom createOrderFrom) {
@@ -602,12 +602,19 @@ public class OrderInfoServiceImpl implements OrderInfoService {
         goodsOrderInfoMapper.insertSelective(goodsOrderInfo);
         //新增小定单
         goodsOrderDetailMapper.batchSaveOrderDetailList(dataList);
+        //发送到消息队列
+        pushRabbitMessage(orderId);
+        return goodsOrderInfo;
 
+    }
+
+    private void pushRabbitMessage(String orderId) {
         String message = "order-" + orderId;
         //延时消息队列
-        messageService.send(MQConstant.HELLO_QUEUE_NAME, message, 60000);
-        return goodsOrderInfo;
-
+        OrderSetting orderSetting = orderSettingMapper.selectByPrimaryKey(1L);
+        Integer normalOrderOvertime = orderSetting.getNormalOrderOvertime();
+        int outTime = normalOrderOvertime * 60000;
+        messageService.send(MQConstant.HELLO_QUEUE_NAME, message, outTime);
     }
 
     private void addGoodsOrderInfo(CustomerInfoForm customerInfo, String customerId, BigDecimal sumTotal, BigDecimal carbonTotal, String orderId, GoodsOrderInfo goodsOrderInfo) {

+ 164 - 0
carbon-h5/carbon-h5-service/src/main/resources/com/hcloud/microserver/h5/dao/OrderSettingMapper.xml

@@ -0,0 +1,164 @@
+<?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.hcloud.microserver.h5.dao.OrderSettingMapper" >
+  <resultMap id="BaseResultMap" type="com.hcloud.microserver.h5.facade.carbon.entity.OrderSetting" >
+    <id column="id" property="id" jdbcType="BIGINT" />
+    <result column="normal_order_overtime" property="normalOrderOvertime" jdbcType="INTEGER" />
+  </resultMap>
+  <sql id="Example_Where_Clause" >
+    <where >
+      <foreach collection="oredCriteria" item="criteria" separator="or" >
+        <if test="criteria.valid" >
+          <trim prefix="(" suffix=")" prefixOverrides="and" >
+            <foreach collection="criteria.criteria" item="criterion" >
+              <choose >
+                <when test="criterion.noValue" >
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue" >
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue" >
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue" >
+                  and ${criterion.condition}
+                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause" >
+    <where >
+      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
+        <if test="criteria.valid" >
+          <trim prefix="(" suffix=")" prefixOverrides="and" >
+            <foreach collection="criteria.criteria" item="criterion" >
+              <choose >
+                <when test="criterion.noValue" >
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue" >
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue" >
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue" >
+                  and ${criterion.condition}
+                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List" >
+    id, normal_order_overtime
+  </sql>
+  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.OrderSettingExample" >
+    select
+    <if test="distinct" >
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from t_order_setting
+    <if test="_parameter != null" >
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null" >
+      order by ${orderByClause}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
+    select 
+    <include refid="Base_Column_List" />
+    from t_order_setting
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
+    delete from t_order_setting
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.OrderSettingExample" >
+    delete from t_order_setting
+    <if test="_parameter != null" >
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.OrderSetting" >
+    insert into t_order_setting (id, normal_order_overtime)
+    values (#{id,jdbcType=BIGINT}, #{normalOrderOvertime,jdbcType=INTEGER})
+  </insert>
+  <insert id="insertSelective" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.OrderSetting" >
+    insert into t_order_setting
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="id != null" >
+        id,
+      </if>
+      <if test="normalOrderOvertime != null" >
+        normal_order_overtime,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="id != null" >
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="normalOrderOvertime != null" >
+        #{normalOrderOvertime,jdbcType=INTEGER},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.OrderSettingExample" resultType="java.lang.Integer" >
+    select count(*) from t_order_setting
+    <if test="_parameter != null" >
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map" >
+    update t_order_setting
+    <set >
+      <if test="record.id != null" >
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.normalOrderOvertime != null" >
+        normal_order_overtime = #{record.normalOrderOvertime,jdbcType=INTEGER},
+      </if>
+    </set>
+    <if test="_parameter != null" >
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map" >
+    update t_order_setting
+    set id = #{record.id,jdbcType=BIGINT},
+      normal_order_overtime = #{record.normalOrderOvertime,jdbcType=INTEGER}
+    <if test="_parameter != null" >
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.OrderSetting" >
+    update t_order_setting
+    <set >
+      <if test="normalOrderOvertime != null" >
+        normal_order_overtime = #{normalOrderOvertime,jdbcType=INTEGER},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.hcloud.microserver.h5.facade.carbon.entity.OrderSetting" >
+    update t_order_setting
+    set normal_order_overtime = #{normalOrderOvertime,jdbcType=INTEGER}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+</mapper>

+ 20 - 0
sql/表结构变化语句/更新sql.sql

@@ -83,3 +83,23 @@ ADD COLUMN `bank_code` varchar(300) NULL COMMENT '开户行机构代码' AFTER `
 ALTER TABLE `cq-carbon-platform-dev`.`t_collective_farmer`
 ADD COLUMN `bank_code` varchar(300) NULL COMMENT '银行机构代码' AFTER `phone`,
 ADD COLUMN `bank_status` int(2) NULL COMMENT '银行卡状态0-启用,1-禁用' AFTER `bank_code`;
+
+
+
+#新增订单时间过期配置表
+SET FOREIGN_KEY_CHECKS=0;
+
+-- ----------------------------
+-- Table structure for t_order_setting
+-- ----------------------------
+DROP TABLE IF EXISTS `t_order_setting`;
+CREATE TABLE `t_order_setting` (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT,
+  `normal_order_overtime` int(11) DEFAULT NULL COMMENT '正常订单超时时间(分)',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='订单设置表';
+
+-- ----------------------------
+-- Records of t_order_setting
+-- ----------------------------
+INSERT INTO `t_order_setting` VALUES ('1', '1');