admin
2021-05-25 8257c0333f96aeedecef1c205b42802dbf1c5930
订单修改
9个文件已修改
1个文件已添加
409 ■■■■■ 已修改文件
facade-vip/src/main/java/com/ks/vip/pojo/DO/VipOrder.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
facade-vip/src/main/java/com/ks/vip/service/VipCenterService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
facade-vip/src/main/java/com/ks/vip/service/VipOrederService.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-vip/src/main/java/com/ks/vip/mapper/VipOrderMapper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-vip/src/main/java/com/ks/vip/pojo/mybatishandler/OrderTypeEnumHandler.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-vip/src/main/java/com/ks/vip/query/VipOrderQuery.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-vip/src/main/java/com/ks/vip/service/remote/VipCenterServiceImpl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-vip/src/main/java/com/ks/vip/service/remote/VipOrderPayServiceImpl.java 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-vip/src/main/java/com/ks/vip/service/remote/VipOrderServiceImpl.java 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-vip/src/main/resources/mapper/VipOrderMapper.xml 230 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
facade-vip/src/main/java/com/ks/vip/pojo/DO/VipOrder.java
@@ -1,5 +1,6 @@
package com.ks.vip.pojo.DO;
import com.ks.vip.pojo.Enums.OrderTypeEnum;
import org.yeshi.utils.generater.mybatis.Column;
import org.yeshi.utils.generater.mybatis.Table;
@@ -22,7 +23,7 @@
    private Long id;
    @Column(name = "o_type")
    private String type;
    private OrderTypeEnum type;
    @Column(name = "o_combo_id")
    private Long comboId;
@@ -74,11 +75,11 @@
        this.id = id;
    }
    public String getType() {
    public OrderTypeEnum getType() {
        return type;
    }
    public void setType(String type) {
    public void setType(OrderTypeEnum type) {
        this.type = type;
    }
facade-vip/src/main/java/com/ks/vip/service/VipCenterService.java
@@ -30,10 +30,10 @@
     *
     * @param uid
     * @param gradeId
     * @param validDays
     * @param validHours
     * @param orderId
     */
    public void saveVipCenter(String uid, Long gradeId, Integer validDays, Long orderId);
    public void saveVipCenter(String uid, Long gradeId, Integer validHours, Long orderId);
    /**
facade-vip/src/main/java/com/ks/vip/service/VipOrederService.java
@@ -19,6 +19,13 @@
   public void delete(Long id);
   public void addOrderByWatchVideo(String uid, Long gradeId, Integer validDays) throws VipOrderException;
   public void addOrderByWatchVideo(String uid, Long gradeId, Integer hour) throws VipOrderException;
   /**
    * 是否可以
    * @param uid
    * @return
    */
   public boolean canAddOrderByWatchVideo(String uid);
}
service-vip/src/main/java/com/ks/vip/mapper/VipOrderMapper.java
@@ -2,6 +2,7 @@
import com.ks.lib.common.dao.BaseMapper;
import com.ks.vip.pojo.DO.VipOrder;
import com.ks.vip.pojo.Enums.OrderTypeEnum;
import com.ks.vip.query.VipOrderQuery;
import org.apache.ibatis.annotations.Param;
@@ -26,6 +27,6 @@
     * @param type
     * @return
     */
    long countByTypeAndUid(@Param("uid") String uid, @Param("type") String type);
    long countByTypeAndUid(@Param("uid") String uid, @Param("type") OrderTypeEnum type);
}
service-vip/src/main/java/com/ks/vip/pojo/mybatishandler/OrderTypeEnumHandler.java
New file
@@ -0,0 +1,53 @@
package com.ks.vip.pojo.mybatishandler;
import com.ks.vip.pojo.Enums.OrderTypeEnum;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class OrderTypeEnumHandler extends BaseTypeHandler<OrderTypeEnum> {
    @Override
    public OrderTypeEnum getNullableResult(ResultSet arg0, String arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            return OrderTypeEnum.valueOf(key);
        }
    }
    @Override
    public OrderTypeEnum getNullableResult(ResultSet arg0, int arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            // 根据数据库中的key值,定位SexEnum子类
            return OrderTypeEnum.valueOf(key);
        }
    }
    @Override
    public OrderTypeEnum getNullableResult(CallableStatement arg0, int arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            // 根据数据库中的key值,定位SexEnum子类
            return OrderTypeEnum.valueOf(key);
        }
    }
    @Override
    public void setNonNullParameter(PreparedStatement arg0, int arg1, OrderTypeEnum arg2, JdbcType arg3)
            throws SQLException {
        arg0.setString(arg1, arg2.name());
    }
}
service-vip/src/main/java/com/ks/vip/query/VipOrderQuery.java
@@ -2,6 +2,9 @@
import com.ks.lijin.query.BaseDaoQuery;
import com.ks.vip.pojo.Enums.OrderTypeEnum;
import java.util.Date;
public class VipOrderQuery extends BaseDaoQuery {
@@ -16,6 +19,10 @@
    //状态
    public Integer state;
    // 订单类型
    public String type;
    public OrderTypeEnum type;
    //订单创建时间
    public Date maxCreateTime;
    public Date minCreateTime;
}
service-vip/src/main/java/com/ks/vip/service/remote/VipCenterServiceImpl.java
@@ -79,18 +79,18 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveVipCenter(String uid, Long gradeId, Integer validDays, Long orderId) {
    public void saveVipCenter(String uid, Long gradeId, Integer validHours, Long orderId) {
        VipCenterRecord record = new VipCenterRecord();
        VipCenter vipCenter = vipCenterMapper.selectForUpdate(uid);
        if (vipCenter == null) {
            Date startTime = new Date();
            Date endTime = DateUtil.plusDayDate(validDays, startTime);
            Date endTime = new Date(startTime.getTime() + 1000 * 60 * 60L * validHours);
            vipCenter.setUid(uid);
            vipCenter.setGradeId(gradeId);
            vipCenter.setStartTime(startTime);
            vipCenter.setEndTime(DateUtil.plusDayDate(validDays, new Date()));
            vipCenter.setEndTime(endTime);
            vipCenter.setCreateTime(new Date());
            vipCenterMapper.insertSelective(vipCenter);
@@ -104,10 +104,10 @@
            long nowTime = java.lang.System.currentTimeMillis();
            if (gradeId.longValue() == oldGradeId.longValue() && vipCenter.getEndTime().getTime() > nowTime) {
                // 上次会员还未已结束
                endTime = DateUtil.plusDayDate(validDays, vipCenter.getEndTime());
                endTime = new Date(vipCenter.getEndTime().getTime() + 1000 * 60 * 60L * validHours);
            } else {
                startTime = new Date();
                endTime = DateUtil.plusDayDate(validDays, startTime);
                endTime = new Date(startTime.getTime() + 1000 * 60 * 60L * validHours);
            }
            vipCenter.setStartTime(startTime);
            vipCenter.setEndTime(endTime);
service-vip/src/main/java/com/ks/vip/service/remote/VipOrderPayServiceImpl.java
@@ -46,16 +46,16 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public PayWayInfoDTO addOrderByBuy(VipOrderDTO t) throws VipOrderException {
        if(t.getComboId() == null || t.getComboId() <= 0){
        if (t.getComboId() == null || t.getComboId() <= 0) {
            throw new VipOrderException(1, "套餐ID不能为空");
        }
        if(StringUtil.isNullOrEmpty(t.getUid())){
        if (StringUtil.isNullOrEmpty(t.getUid())) {
            throw new VipOrderException(1, "用户ID不能为空");
        }
        if(t.getPayWay() == null){
        if (t.getPayWay() == null) {
            throw new VipOrderException(1, "付款方式不能为空");
        }
        if(StringUtil.isNullOrEmpty(t.getThreeOrderId())){
        if (StringUtil.isNullOrEmpty(t.getThreeOrderId())) {
            throw new VipOrderException(1, "付款订单号不能为空");
        }
@@ -66,10 +66,10 @@
        }
        // 判断订单类型: 首单、续费
        String orderType = OrderTypeEnum.buyNewly.name();
        OrderTypeEnum orderType = OrderTypeEnum.buyNewly;
        long count = vipOrderMapper.countByTypeAndUid(t.getUid(), orderType);
        if(count > 0) {
            orderType = OrderTypeEnum.buyRenew.name();
        if (count > 0) {
            orderType = OrderTypeEnum.buyRenew;
        }
        // 插入订单信息
@@ -109,7 +109,7 @@
                        return new PayWayInfoDTO(PayWayEnum.weChat.getWay(), PayUtil.getPaySuccessUrl(orderId));
                    }
                    String formWX = PayUtil.createWXOrder(orderId, null, orderId, order.getPayMoney() ,goodsTitle);
                    String formWX = PayUtil.createWXOrder(orderId, null, orderId, order.getPayMoney(), goodsTitle);
                    //暂存2分钟
                    String idWX = StringUtil.Md5(UUID.randomUUID().toString() + "#" + System.currentTimeMillis());
                    redisManager.cacheCommonString(formWX, formWX, 120);
@@ -134,7 +134,7 @@
            case "alipay":  //支付宝
                AlipayTradeQueryResponse res = null;
                try {
                    res = AlipayH5PayUtil.queryOrder(PayUtil.getAlipayApp(), id+"" , null);
                    res = AlipayH5PayUtil.queryOrder(PayUtil.getAlipayApp(), id + "", null);
                    //支付成功
                    if (res.isSuccess() && "TRADE_SUCCESS".equalsIgnoreCase(res.getTradeStatus())) {
                        try {
@@ -148,7 +148,7 @@
                }
            case "weChat": //微信
                try {
                    WXPayOrderInfoV3 info = WXPayV3Util.getPayOrderInfo(id+"" , PayUtil.getWXAPP());
                    WXPayOrderInfoV3 info = WXPayV3Util.getPayOrderInfo(id + "", PayUtil.getWXAPP());
                    if (info != null && info.getTrade_state().equalsIgnoreCase("SUCCESS")) {
                        paySuccess(order);
                        return order;
@@ -158,11 +158,12 @@
                }
        }
        return null;
     }
    }
    /**
     * 支付成功更新处理
     *
     * @param order
     * @return
     */
@@ -177,22 +178,22 @@
        Integer validDays = vipCombo.getValidDays();
        // 判断订单类型
        String orderType = OrderTypeEnum.buyNewly.name();
        OrderTypeEnum orderType = OrderTypeEnum.buyNewly;
        long count = vipOrderMapper.countByTypeAndUid(order.getUid(), orderType);
        if(count > 0) {
            orderType = OrderTypeEnum.buyRenew.name();
        if (count > 0) {
            orderType = OrderTypeEnum.buyRenew;
        }
        // order.setThreeOrderId(); TODO
         order.setState(VipOrder.STATE_PAY);
         order.setPayTime(new Date());
         order.setUpdateTime(new Date());
         vipOrderMapper.updateByPrimaryKeySelective(order);
        order.setState(VipOrder.STATE_PAY);
        order.setPayTime(new Date());
        order.setUpdateTime(new Date());
        vipOrderMapper.updateByPrimaryKeySelective(order);
         // 更新等级
         vipCenterService.saveVipCenter(order.getUid(), vipCombo.getGradeId(), validDays, order.getId() );
        // 更新等级
        vipCenterService.saveVipCenter(order.getUid(), vipCombo.getGradeId(), validDays * 24, order.getId());
         return order;
     }
        return order;
    }
}
service-vip/src/main/java/com/ks/vip/service/remote/VipOrderServiceImpl.java
@@ -14,9 +14,12 @@
import com.ks.vip.service.VipOrederService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yeshi.utils.DateUtil;
import org.yeshi.utils.StringUtil;
import org.yeshi.utils.TimeUtil;
import javax.annotation.Resource;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
@@ -34,12 +37,12 @@
    @Override
    public void insertSelective(VipOrder t){
    public void insertSelective(VipOrder t) {
        vipOrderMapper.insertSelective(t);
    }
    @Override
    public void updateByPrimaryKeySelective(VipOrder t){
    public void updateByPrimaryKeySelective(VipOrder t) {
        vipOrderMapper.updateByPrimaryKeySelective(t);
    }
@@ -73,28 +76,44 @@
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addOrderByWatchVideo(String uid, Long gradeId, Integer validDays) throws VipOrderException {
        if(StringUtil.isNullOrEmpty(uid)){
    public void addOrderByWatchVideo(String uid, Long gradeId, Integer hour) throws VipOrderException {
        if (StringUtil.isNullOrEmpty(uid)) {
            throw new VipOrderException(1, "用户ID不能为空");
        }
        if(gradeId == null){
        if (gradeId == null) {
            throw new VipOrderException(1, "等级ID不能为空");
        }
        if(validDays == null || validDays.longValue() <= 0){
            throw new VipOrderException(1, "有效天数不能为空");
        if (hour == null || hour.longValue() <= 0) {
            throw new VipOrderException(1, "有效小时数不能为空");
        }
        if (!canAddOrderByWatchVideo(uid)) {
            throw new VipOrderException(1, "今日次数已经用完");
        }
        // 插入订单信息  唯一性处理TODO
        VipOrder newOrder = new VipOrder();
        newOrder.setUid(uid);
        newOrder.setType(OrderTypeEnum.watchVideo.name());
        newOrder.setType(OrderTypeEnum.watchVideo);
        newOrder.setCreateTime(new Date());
        vipOrderMapper.insertSelective(newOrder);
        // 更新等级
        vipCenterService.saveVipCenter(uid, gradeId, validDays,newOrder.getId() );
        vipCenterService.saveVipCenter(uid, gradeId, hour, newOrder.getId());
    }
    @Override
    public boolean canAddOrderByWatchVideo(String uid) {
        long now = System.currentTimeMillis();
        VipOrderQuery vipOrderQuery = new VipOrderQuery();
        vipOrderQuery.uid = uid;
        vipOrderQuery.type = OrderTypeEnum.watchVideo;
        vipOrderQuery.minCreateTime = new Date(TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(now, "yyyy-MM-dd"), "yyyy-MM-dd"));
        vipOrderQuery.maxCreateTime = DateUtil.plusDayDate(1, vipOrderQuery.minCreateTime);
        long count = vipOrderMapper.count(vipOrderQuery);
        //TODO 写入配置信息
        return count < 5;
    }
}
service-vip/src/main/resources/mapper/VipOrderMapper.xml
@@ -2,129 +2,137 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ks.vip.mapper.VipOrderMapper">
  <resultMap id="BaseResultMap" type="com.ks.vip.pojo.DO.VipOrder">
    <id column="o_id" property="id" jdbcType="BIGINT"/>
    <result column="o_type" property="type" jdbcType="VARCHAR"/>
    <result column="o_combo_id" property="comboId" jdbcType="BIGINT"/>
    <result column="o_uid" property="uid" jdbcType="VARCHAR"/>
    <result column="o_three_order_id" property="threeOrderId" jdbcType="VARCHAR"/>
    <result column="o_pay_money" property="payMoney" jdbcType="DECIMAL"/>
    <result column="o_pay_time" property="payTime" jdbcType="TIMESTAMP"/>
    <result column="o_pay_account" property="payAccount" jdbcType="VARCHAR"/>
    <result column="o_pay_way" property="payWay" jdbcType="VARCHAR"/>
    <result column="o_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="o_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="o_state" property="state" jdbcType="INTEGER"/>
    <result column="o_creator_id" property="creatorId" jdbcType="BIGINT"/>
    <result column="o_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="o_updator_id" property="updatorId" jdbcType="BIGINT"/>
    <result column="o_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">o_id,o_type,o_combo_id,o_uid,o_three_order_id,o_pay_money,o_pay_time,o_pay_account,o_pay_way,o_end_time,o_start_time,o_state,o_creator_id,o_create_time,o_updator_id,o_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from vip_order where o_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from vip_order where o_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.ks.vip.pojo.DO.VipOrder" useGeneratedKeys="true" keyProperty="id">insert into vip_order (o_id,o_type,o_combo_id,o_uid,o_three_order_id,o_pay_money,o_pay_time,o_pay_account,o_pay_way,o_end_time,o_start_time,o_state,o_creator_id,o_create_time,o_updator_id,o_update_time) values (#{id,jdbcType=BIGINT},#{type,jdbcType=VARCHAR},#{comboId,jdbcType=BIGINT},#{uid,jdbcType=VARCHAR},#{threeOrderId,jdbcType=VARCHAR},#{payMoney,jdbcType=DECIMAL},#{payTime,jdbcType=TIMESTAMP},#{payAccount,jdbcType=VARCHAR},#{payWay,jdbcType=VARCHAR},#{endTime,jdbcType=TIMESTAMP},#{startTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER},#{creatorId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updatorId,jdbcType=BIGINT},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.ks.vip.pojo.DO.VipOrder" useGeneratedKeys="true" keyProperty="id">insert into vip_order
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">o_id,</if>
      <if test="type != null">o_type,</if>
      <if test="comboId != null">o_combo_id,</if>
      <if test="uid != null">o_uid,</if>
      <if test="threeOrderId != null">o_three_order_id,</if>
      <if test="payMoney != null">o_pay_money,</if>
      <if test="payTime != null">o_pay_time,</if>
      <if test="payAccount != null">o_pay_account,</if>
      <if test="payWay != null">o_pay_way,</if>
      <if test="endTime != null">o_end_time,</if>
      <if test="startTime != null">o_start_time,</if>
      <if test="state != null">o_state,</if>
      <if test="creatorId != null">o_creator_id,</if>
      <if test="createTime != null">o_create_time,</if>
      <if test="updatorId != null">o_updator_id,</if>
      <if test="updateTime != null">o_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="type != null">#{type,jdbcType=VARCHAR},</if>
      <if test="comboId != null">#{comboId,jdbcType=BIGINT},</if>
      <if test="uid != null">#{uid,jdbcType=VARCHAR},</if>
      <if test="threeOrderId != null">#{threeOrderId,jdbcType=VARCHAR},</if>
      <if test="payMoney != null">#{payMoney,jdbcType=DECIMAL},</if>
      <if test="payTime != null">#{payTime,jdbcType=TIMESTAMP},</if>
      <if test="payAccount != null">#{payAccount,jdbcType=VARCHAR},</if>
      <if test="payWay != null">#{payWay,jdbcType=VARCHAR},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="creatorId != null">#{creatorId,jdbcType=BIGINT},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updatorId != null">#{updatorId,jdbcType=BIGINT},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.ks.vip.pojo.DO.VipOrder">update vip_order set o_type = #{type,jdbcType=VARCHAR},o_combo_id = #{comboId,jdbcType=BIGINT},o_uid = #{uid,jdbcType=VARCHAR},o_three_order_id = #{threeOrderId,jdbcType=VARCHAR},o_pay_money = #{payMoney,jdbcType=DECIMAL},o_pay_time = #{payTime,jdbcType=TIMESTAMP},o_pay_account = #{payAccount,jdbcType=VARCHAR},o_pay_way = #{payWay,jdbcType=VARCHAR},o_end_time = #{endTime,jdbcType=TIMESTAMP},o_start_time = #{startTime,jdbcType=TIMESTAMP},o_state = #{state,jdbcType=INTEGER},o_creator_id = #{creatorId,jdbcType=BIGINT},o_create_time = #{createTime,jdbcType=TIMESTAMP},o_updator_id = #{updatorId,jdbcType=BIGINT},o_update_time = #{updateTime,jdbcType=TIMESTAMP} where o_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.ks.vip.pojo.DO.VipOrder">update vip_order
    <set>
      <if test="type != null">o_type=#{type,jdbcType=VARCHAR},</if>
      <if test="comboId != null">o_combo_id=#{comboId,jdbcType=BIGINT},</if>
      <if test="uid != null">o_uid=#{uid,jdbcType=VARCHAR},</if>
      <if test="threeOrderId != null">o_three_order_id=#{threeOrderId,jdbcType=VARCHAR},</if>
      <if test="payMoney != null">o_pay_money=#{payMoney,jdbcType=DECIMAL},</if>
      <if test="payTime != null">o_pay_time=#{payTime,jdbcType=TIMESTAMP},</if>
      <if test="payAccount != null">o_pay_account=#{payAccount,jdbcType=VARCHAR},</if>
      <if test="payWay != null">o_pay_way=#{payWay,jdbcType=VARCHAR},</if>
      <if test="endTime != null">o_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="startTime != null">o_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="state != null">o_state=#{state,jdbcType=INTEGER},</if>
      <if test="creatorId != null">o_creator_id=#{creatorId,jdbcType=BIGINT},</if>
      <if test="createTime != null">o_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updatorId != null">o_updator_id=#{updatorId,jdbcType=BIGINT},</if>
      <if test="updateTime != null">o_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where o_id = #{id,jdbcType=BIGINT}
  </update>
    <resultMap id="BaseResultMap" type="com.ks.vip.pojo.DO.VipOrder">
        <id column="o_id" property="id" jdbcType="BIGINT"/>
        <result column="o_type" property="type" typeHandler="com.ks.vip.pojo.mybatishandler.OrderTypeEnumHandler"/>
        <result column="o_combo_id" property="comboId" jdbcType="BIGINT"/>
        <result column="o_uid" property="uid" jdbcType="VARCHAR"/>
        <result column="o_three_order_id" property="threeOrderId" jdbcType="VARCHAR"/>
        <result column="o_pay_money" property="payMoney" jdbcType="DECIMAL"/>
        <result column="o_pay_time" property="payTime" jdbcType="TIMESTAMP"/>
        <result column="o_pay_account" property="payAccount" jdbcType="VARCHAR"/>
        <result column="o_pay_way" property="payWay" jdbcType="VARCHAR"/>
        <result column="o_end_time" property="endTime" jdbcType="TIMESTAMP"/>
        <result column="o_start_time" property="startTime" jdbcType="TIMESTAMP"/>
        <result column="o_state" property="state" jdbcType="INTEGER"/>
        <result column="o_creator_id" property="creatorId" jdbcType="BIGINT"/>
        <result column="o_create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="o_updator_id" property="updatorId" jdbcType="BIGINT"/>
        <result column="o_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">o_id,o_type,o_combo_id,o_uid,o_three_order_id,o_pay_money,o_pay_time,o_pay_account,o_pay_way,o_end_time,o_start_time,o_state,o_creator_id,o_create_time,o_updator_id,o_update_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/>from vip_order where o_id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.Long">delete from vip_order where o_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.ks.vip.pojo.DO.VipOrder" useGeneratedKeys="true"
            keyProperty="id">insert into vip_order (o_id,o_type,o_combo_id,o_uid,o_three_order_id,o_pay_money,o_pay_time,o_pay_account,o_pay_way,o_end_time,o_start_time,o_state,o_creator_id,o_create_time,o_updator_id,o_update_time) values (#{id,jdbcType=BIGINT},#{type,jdbcType=VARCHAR},#{comboId,jdbcType=BIGINT},#{uid,jdbcType=VARCHAR},#{threeOrderId,jdbcType=VARCHAR},#{payMoney,jdbcType=DECIMAL},#{payTime,jdbcType=TIMESTAMP},#{payAccount,jdbcType=VARCHAR},#{payWay,jdbcType=VARCHAR},#{endTime,jdbcType=TIMESTAMP},#{startTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER},#{creatorId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updatorId,jdbcType=BIGINT},#{updateTime,jdbcType=TIMESTAMP})</insert>
    <insert id="insertSelective" parameterType="com.ks.vip.pojo.DO.VipOrder" useGeneratedKeys="true" keyProperty="id">
        insert into vip_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">o_id,</if>
            <if test="type != null">o_type,</if>
            <if test="comboId != null">o_combo_id,</if>
            <if test="uid != null">o_uid,</if>
            <if test="threeOrderId != null">o_three_order_id,</if>
            <if test="payMoney != null">o_pay_money,</if>
            <if test="payTime != null">o_pay_time,</if>
            <if test="payAccount != null">o_pay_account,</if>
            <if test="payWay != null">o_pay_way,</if>
            <if test="endTime != null">o_end_time,</if>
            <if test="startTime != null">o_start_time,</if>
            <if test="state != null">o_state,</if>
            <if test="creatorId != null">o_creator_id,</if>
            <if test="createTime != null">o_create_time,</if>
            <if test="updatorId != null">o_updator_id,</if>
            <if test="updateTime != null">o_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="type != null">#{type,jdbcType=VARCHAR},</if>
            <if test="comboId != null">#{comboId,jdbcType=BIGINT},</if>
            <if test="uid != null">#{uid,jdbcType=VARCHAR},</if>
            <if test="threeOrderId != null">#{threeOrderId,jdbcType=VARCHAR},</if>
            <if test="payMoney != null">#{payMoney,jdbcType=DECIMAL},</if>
            <if test="payTime != null">#{payTime,jdbcType=TIMESTAMP},</if>
            <if test="payAccount != null">#{payAccount,jdbcType=VARCHAR},</if>
            <if test="payWay != null">#{payWay,jdbcType=VARCHAR},</if>
            <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="creatorId != null">#{creatorId,jdbcType=BIGINT},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updatorId != null">#{updatorId,jdbcType=BIGINT},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
            parameterType="com.ks.vip.pojo.DO.VipOrder">update vip_order set o_type = #{type,jdbcType=VARCHAR},o_combo_id = #{comboId,jdbcType=BIGINT},o_uid = #{uid,jdbcType=VARCHAR},o_three_order_id = #{threeOrderId,jdbcType=VARCHAR},o_pay_money = #{payMoney,jdbcType=DECIMAL},o_pay_time = #{payTime,jdbcType=TIMESTAMP},o_pay_account = #{payAccount,jdbcType=VARCHAR},o_pay_way = #{payWay,jdbcType=VARCHAR},o_end_time = #{endTime,jdbcType=TIMESTAMP},o_start_time = #{startTime,jdbcType=TIMESTAMP},o_state = #{state,jdbcType=INTEGER},o_creator_id = #{creatorId,jdbcType=BIGINT},o_create_time = #{createTime,jdbcType=TIMESTAMP},o_updator_id = #{updatorId,jdbcType=BIGINT},o_update_time = #{updateTime,jdbcType=TIMESTAMP} where o_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.ks.vip.pojo.DO.VipOrder">update vip_order
        <set>
            <if test="type != null">o_type=#{type,jdbcType=VARCHAR},</if>
            <if test="comboId != null">o_combo_id=#{comboId,jdbcType=BIGINT},</if>
            <if test="uid != null">o_uid=#{uid,jdbcType=VARCHAR},</if>
            <if test="threeOrderId != null">o_three_order_id=#{threeOrderId,jdbcType=VARCHAR},</if>
            <if test="payMoney != null">o_pay_money=#{payMoney,jdbcType=DECIMAL},</if>
            <if test="payTime != null">o_pay_time=#{payTime,jdbcType=TIMESTAMP},</if>
            <if test="payAccount != null">o_pay_account=#{payAccount,jdbcType=VARCHAR},</if>
            <if test="payWay != null">o_pay_way=#{payWay,jdbcType=VARCHAR},</if>
            <if test="endTime != null">o_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="startTime != null">o_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="state != null">o_state=#{state,jdbcType=INTEGER},</if>
            <if test="creatorId != null">o_creator_id=#{creatorId,jdbcType=BIGINT},</if>
            <if test="createTime != null">o_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updatorId != null">o_updator_id=#{updatorId,jdbcType=BIGINT},</if>
            <if test="updateTime != null">o_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where o_id = #{id,jdbcType=BIGINT}
    </update>
  <!-- 非模板 -->
  <sql id="listWhere">
    <if test="query.id!=null">and o_id=#{query.id}</if>
    <if test="query.type!=null">and o_type=#{query.type}</if>
    <if test="query.comboId!=null">and comboId=#{query.comboId}</if>
    <if test="query.uid!=null">and o_uid=#{query.uid}</if>
    <if test="query.threeOrderId!=null">and o_three_order_id=#{query.threeOrderId}</if>
    <if test="query.state!=null">and o_state=#{query.state}</if>
  </sql>
    <!-- 非模板 -->
    <sql id="listWhere">
        <if test="query.id!=null">and o_id=#{query.id}</if>
        <if test="query.type!=null">and o_type=#{query.type}</if>
        <if test="query.comboId!=null">and comboId=#{query.comboId}</if>
        <if test="query.uid!=null">and o_uid=#{query.uid}</if>
        <if test="query.threeOrderId!=null">and o_three_order_id=#{query.threeOrderId}</if>
        <if test="query.state!=null">and o_state=#{query.state}</if>
        <if test="query.minCreateTime!=null">and o_create_time>=#{query.minCreateTime}</if>
        <if test="query.maxCreateTime!=null">and #{query.maxCreateTime} >o_create_time</if>
    </sql>
  <select id="listByPage" resultMap="BaseResultMap">
    select <include refid="Base_Column_List"/>  from vip_order
    where 1=1
    <include refid="listWhere"/>
    limit #{query.start},#{query.count}
  </select>
    <select id="listByPage" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from vip_order
        where 1=1
        <include refid="listWhere"/>
        limit #{query.start},#{query.count}
    </select>
  <select id="count" resultType="java.lang.Long">
    select count(*) from vip_order
    where 1=1
    <include refid="listWhere"/>
  </select>
    <select id="count" resultType="java.lang.Long">
        select count(*) from vip_order
        where 1=1
        <include refid="listWhere"/>
    </select>
  <select id="getByThreeOrderId" resultMap="BaseResultMap">
    select <include refid="Base_Column_List"/>  from vip_order
    where o_three_order_id=#{query.threeOrderId}
  </select>
    <select id="getByThreeOrderId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from vip_order
        where o_three_order_id=#{query.threeOrderId}
    </select>
  <select id="countByTypeAndUid" resultType="Long">
    <select id="countByTypeAndUid" resultType="Long">
    select IFNULL(count(o_id),0)  from vip_order
    where o_uid = #{uid} and o_type=#{type}
  </select>
</mapper>