admin
2019-03-19 861545cb18d326f95a6e4c36863674867c5cac99
删除LostOrderDao
1个文件已删除
5个文件已修改
295 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/LostOrderMapper.java 75 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/order/LostOrderDao.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/LostOrder.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/LostOrderMapper.xml 121 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/LostOrderServiceImpl.java 79 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/LostOrderService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/LostOrderMapper.java
@@ -5,13 +5,10 @@
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.bus.user.LostOrder;
public interface LostOrderMapper {
    LostOrder selectByPrimaryKey(Long id);
    int updateByPrimaryKeySelective(LostOrder record);
public interface LostOrderMapper extends BaseMapper<LostOrder> {
    /**
     * 通过订单号查询丢失订单
@@ -20,16 +17,18 @@
     * @return
     */
    List<LostOrder> selectByOrderId(String orderId);
    /**
     * 统计用户申诉次数
     *
     * @param uid
     * @return
     */
    Map<String, Object> countByUid(@Param("uid") Long uid);
    /**
     * 后端列表查询
     *
     * @param start
     * @param count
     * @param key
@@ -37,32 +36,76 @@
     */
    List<LostOrder> listQuery(@Param("start") long start, @Param("count") int count, @Param("key") String key,
            @Param("state") Integer state, @Param("handleType") Integer handleType);
    long countQuery(@Param("key") String key, @Param("state") Integer state, @Param("handleType") Integer handleType);
    /**
     * 统计申诉订单数量
     * @param type
     *
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countLostNum(@Param("dateType")Integer dateType,@Param("resultCode")Integer resultCode,
            @Param("year") String year, @Param("startTime")String startTime, @Param("endTime")String endTime);
    List<Map<String, Object>> countLostNum(@Param("dateType") Integer dateType, @Param("resultCode") Integer resultCode,
            @Param("year") String year, @Param("startTime") String startTime, @Param("endTime") String endTime);
    /**
     * 统计申诉成功订单金额
     * @param type
     *
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countAppealMoney(@Param("dateType")Integer dateType, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    List<Map<String, Object>> countAppealMoney(@Param("dateType") Integer dateType, @Param("year") String year,
            @Param("startTime") String startTime, @Param("endTime") String endTime);
    /**
     * 根据用户删除
     *
     * @param uid
     * @return
     */
    int deleteByUid(Long uid);
    /**
     *
     * @param uid
     * @param start
     * @param count
     * @return
     */
    List<LostOrder> listByUidOrderByCreateTimeDesc(@Param("uid") Long uid, @Param("start") long start,
            @Param("count") int count);
    /**
     * 获取用户订单数量
     *
     * @param uid
     * @return
     */
    long countAllByUid(Long uid);
    /**
     *
     * @param orderId
     * @param type
     * @param stateList
     * @return
     */
    List<LostOrder> listByOrderIdAndTypeAndState(@Param("orderId") String orderId, @Param("type") int type,
            @Param("stateList") List<Integer> stateList);
    /**
     * 处理失败
     *
     * @return
     */
    int processFail();
}
fanli/src/main/java/com/yeshi/fanli/dao/order/LostOrderDao.java
File was deleted
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/LostOrder.java
@@ -1,15 +1,14 @@
package com.yeshi.fanli.entity.bus.user;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
import com.google.gson.annotations.Expose;
@@ -20,9 +19,7 @@
 *
 * @date 2018年1月29日
 */
@Entity
@Table(name = "yeshi_ec_lost_order")
@org.yeshi.utils.mybatis.Table("yeshi_ec_lost_order")
@Table("yeshi_ec_lost_order")
public class LostOrder {
    public final static int RESULT_CODE_VERFING = 1;// 审核中
fanli/src/main/java/com/yeshi/fanli/mapping/order/LostOrderMapper.xml
@@ -40,6 +40,9 @@
            select="com.yeshi.fanli.dao.mybatis.order.OrderMapper.selectByPrimaryKey">
        </association>
    </resultMap>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_lost_order where id = #{id,jdbcType=BIGINT}
    </delete>
    <select id="selectByOrderId" resultMap="BaseResultMap"
        parameterType="java.lang.String">
@@ -70,19 +73,24 @@
    </update>
    <select id="countByUid" resultType="java.util.HashMap">
        SELECT IFNULL(COUNT(id), 0) AS total,IFNULL(SUM(CASE WHEN state = 1 THEN 1
        ELSE 0 END),0) AS totalPass,
        IFNULL(SUM(CASE WHEN state = 2 THEN 1 ELSE 0 END),0) AS totalReject
        SELECT IFNULL(COUNT(id), 0)
        AS total,IFNULL(SUM(CASE WHEN state = 1 THEN 1
        ELSE 0 END),0) AS
        totalPass,
        IFNULL(SUM(CASE WHEN state = 2 THEN 1 ELSE 0 END),0) AS
        totalReject
        FROM
        yeshi_ec_lost_order WHERE uid = #{uid};
    </select>
    <select id="listQuery" resultMap="AllResultMap">
        SELECT d.* FROM yeshi_ec_lost_order d
        left join yeshi_ec_user u on d.uid = u.id
        left join yeshi_ec_user u on
        d.uid = u.id
        WHERE 1=1
        <if test='key != null and key != ""'>
            AND (d.orderId like '%${key}%' or d.uid like '%${key}%' or u.nick_name
            AND (d.orderId like '%${key}%' or d.uid like '%${key}%' or
            u.nick_name
            like '%${key}%')
        </if>
        <if test='state != null'>
@@ -101,10 +109,12 @@
    <select id="countQuery" resultType="java.lang.Long">
        SELECT IFNULL(count(d.id),0) FROM yeshi_ec_lost_order d
        left join yeshi_ec_user u on d.uid = u.id
        left join
        yeshi_ec_user u on d.uid = u.id
        WHERE 1=1
        <if test='key != null and key != ""'>
            AND (d.orderId like '%${key}%' or d.uid like '%${key}%' or u.nick_name
            AND (d.orderId like '%${key}%' or d.uid like '%${key}%' or
            u.nick_name
            like '%${key}%')
        </if>
        <if test='state != null'>
@@ -122,7 +132,8 @@
    <select id="countLostNum" resultType="java.util.HashMap">
        SELECT COUNT(t.`id`) AS showValue,
        <if test="dateType == 1">
            FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') AS 'showDate'
            FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') AS
            'showDate'
        </if>
        <if test="dateType == 2">
            FROM_UNIXTIME(t.`createTime`/1000,'%m') AS 'showDate'
@@ -164,7 +175,8 @@
    <select id="countAppealMoney" resultType="java.util.HashMap">
        SELECT CAST(SUM(v.`hb_money`)AS DECIMAL(19,2)) AS showValue,
        <if test="dateType == 1">
            FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') AS 'showDate'
            FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') AS
            'showDate'
        </if>
        <if test="dateType == 2">
            FROM_UNIXTIME(t.`createTime`/1000,'%m') AS 'showDate'
@@ -205,5 +217,96 @@
        ORDER BY t.`createTime`
    </select>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.LostOrder"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_lost_order
        (id,orderId,type,state,createTime,handleTime,uid,oid,remake,judge,result_code)
        values
        (#{id,jdbcType=BIGINT},#{orderId,jdbcType=VARCHAR},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=BIGINT},#{handleTime,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{order.id,jdbcType=BIGINT},#{remake,jdbcType=VARCHAR},#{judge,jdbcType=VARCHAR},#{resultCode,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.LostOrder"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_lost_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="orderId != null">orderId,</if>
            <if test="type != null">type,</if>
            <if test="state != null">state,</if>
            <if test="createTime != null">createTime,</if>
            <if test="handleTime != null">handleTime,</if>
            <if test="userInfo != null">uid,</if>
            <if test="order != null">oid,</if>
            <if test="remake != null">remake,</if>
            <if test="judge != null">judge,</if>
            <if test="resultCode != null">result_code,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
            <if test="type != null">#{type,jdbcType=INTEGER},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="createTime != null">#{createTime,jdbcType=BIGINT},</if>
            <if test="handleTime != null">#{handleTime,jdbcType=BIGINT},</if>
            <if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if>
            <if test="order != null">#{order.id,jdbcType=BIGINT},</if>
            <if test="remake != null">#{remake,jdbcType=VARCHAR},</if>
            <if test="judge != null">#{judge,jdbcType=VARCHAR},</if>
            <if test="resultCode != null">#{resultCode,jdbcType=INTEGER},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.LostOrder">update
        yeshi_ec_lost_order set orderId = #{orderId,jdbcType=VARCHAR},type =
        #{type,jdbcType=INTEGER},state = #{state,jdbcType=INTEGER},createTime
        = #{createTime,jdbcType=BIGINT},handleTime =
        #{handleTime,jdbcType=BIGINT},uid = #{userInfo.id,jdbcType=BIGINT},oid
        =
        #{order.id,jdbcType=BIGINT},remake = #{remake,jdbcType=VARCHAR},judge
        =
        #{judge,jdbcType=VARCHAR},result_code =
        #{resultCode,jdbcType=INTEGER}
        where id = #{id,jdbcType=BIGINT}
    </update>
    <delete id="deleteByUid" parameterType="java.lang.Long">delete from
        yeshi_ec_lost_order where uid = #{0}
    </delete>
    <select id="listByUidOrderByCreateTimeDesc" resultMap="BaseResultMap">
        select *
        from yeshi_ec_lost_order where uid=#{uid} order by id desc limit
        #{start},#{count}
    </select>
    <select id="countAllByUid" resultType="java.lang.Long">
        select count(id) from
        yeshi_ec_lost_order where uid=#{0}
    </select>
    <select id="listByOrderIdAndTypeAndState" resultMap="BaseResultMap">
        select * from yeshi_ec_lost_order where orderId=#{orderId}
        <if test="type!=null">
            and type=#{type}
        </if>
        <if test="stateList!=null">
            <foreach collection="stateList" item="state" open="and ("
                close=")" separator=" or ">
                state=#{state}
            </foreach>
        </if>
    </select>
    <update id="processFail">
        UPDATE `yeshi_ec_lost_order` lo SET
        lo.`result_code`=3 WHERE lo.`state`=1
        AND lo.`result_code`=1 AND
        UNIX_TIMESTAMP()*1000- lo.`handleTime`>1000* 60 * 60 * 24 * 3
    </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/order/LostOrderServiceImpl.java
@@ -1,6 +1,6 @@
package com.yeshi.fanli.service.impl.order;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
@@ -10,10 +10,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yeshi.utils.NumberUtil;
import com.yeshi.fanli.dao.mybatis.order.LostOrderMapper;
import com.yeshi.fanli.dao.order.LostOrderDao;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.LostOrder;
import com.yeshi.fanli.entity.bus.user.Order;
@@ -31,9 +29,6 @@
    @Resource
    private HongBaoOrderService hongBaoOrderService;
    @Resource
    private LostOrderDao lostOrderDao;
    @Resource
    private LostOrderMapper lostOrderMapper;
@@ -75,9 +70,10 @@
        try {
            try {
                lostOrderwriteLock.lock();
                List<LostOrder> list = lostOrderDao.list(
                        "from LostOrder lo where lo.orderId= ? and lo.type = ? and (lo.state = 0 or lo.state = 1)", 0,
                        1, new Serializable[] { orderId, type });
                List<Integer> stateList = new ArrayList<>();
                stateList.add(0);
                stateList.add(1);
                List<LostOrder> list = lostOrderMapper.listByOrderIdAndTypeAndState(orderId, type, stateList);
                if (list.size() > 0) {
                    LostOrder find = list.get(0);
                    Integer state = find.getState();
@@ -106,7 +102,8 @@
            } else {
                lostOrder.setJudge("不匹配");
            }
            lostOrderDao.save(lostOrder);
            lostOrderMapper.insertSelective(lostOrder);
        } finally {
            lostOrderReadLock.unlock();
        }
@@ -152,49 +149,6 @@
    }
    @Override
    public List<LostOrder> findLostOrderList(String key, int page) {
        List<LostOrder> list;
        if (key == null || "".equals(key.trim())) {
            list = lostOrderDao.list("from LostOrder lo order by id desc", (page - 1) * Constant.PAGE_SIZE,
                    Constant.PAGE_SIZE, new Serializable[] {});
        } else {
            if (NumberUtil.isNumeric(key) && key.length() >= 18) {
                // long id = Long.parseLong(key);
                list = lostOrderDao.list("from LostOrder lo where lo.orderId like ? order by id desc",
                        (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, new Serializable[] { "%" + key + "%" });
            } else {
                list = lostOrderDao.list("from LostOrder lo where lo.userInfo.nickName like ? order by id desc",
                        (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, new Serializable[] { "%" + key + "%" });
            }
        }
        return list;
    }
    @Override
    public int getCount(String key) {
        int count = 0;
        if (key == null || "".equals(key.trim())) {
            count = (int) lostOrderDao.getCount("select count(*) from LostOrder");
        } else {
            if (NumberUtil.isNumeric(key) && key.length() >= 18) {
                // long id = Long.parseLong(key);
                count = (int) lostOrderDao.getCount("select count(*) from LostOrder lo where lo.orderId like ?",
                        new Serializable[] { "%" + key + "%" });
            } else {
                count = (int) lostOrderDao.getCount(
                        "select count(*) from LostOrder lo where lo.userInfo.nickName like ?",
                        new Serializable[] { "%" + key + "%" });
            }
        }
        return count;
    }
    @Override
    public LostOrder getOne(long id) {
        return lostOrderMapper.selectByPrimaryKey(id);
    }
@@ -202,14 +156,12 @@
    @Override
    public List<LostOrder> getLostOrderListByUid(Long uid, int page, int pageSize) {
        return lostOrderDao.list("from LostOrder lo where lo.userInfo.id=? order by lo.createTime desc",
                (page - 1) * pageSize, pageSize, new Serializable[] { uid });
        return lostOrderMapper.listByUidOrderByCreateTimeDesc(uid, (page - 1) * pageSize, pageSize);
    }
    @Override
    public long getLostOrderCountByUid(Long uid) {
        return lostOrderDao.getCount("select count(*)  from LostOrder lo where lo.userInfo.id=?",
                new Serializable[] { uid });
        return lostOrderMapper.countAllByUid(uid);
    }
    @Transactional
@@ -245,23 +197,18 @@
    @Override
    public void processFail() {
        // 订单申诉人工通过后,但是隔了3天还未处理成功就视为该订单申诉失败
        lostOrderDao.update(
                "update LostOrder lo set lo.resultCode=? where lo.state=1 and lo.resultCode=? and lo.handleTime<?",
                new Serializable[] { LostOrder.RESULT_CODE_FAIL, LostOrder.RESULT_CODE_VERFING,
                        System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 3L });
        lostOrderMapper.processFail();
    }
    @Override
    public void deleteLostOrder(long id) {
        LostOrder lostOrder = new LostOrder();
        lostOrder.setId(id);
        lostOrderDao.delete(lostOrder);
        lostOrderMapper.deleteByPrimaryKey(id);
    }
    @Override
    public void deleteLostOrderByUid(long uid) {
        lostOrderDao.update("delete from LostOrder lo where lo.userInfo.id=?", new Serializable[] { uid });
        lostOrderMapper.deleteByUid(uid);
    }
    @Override
fanli/src/main/java/com/yeshi/fanli/service/inter/order/LostOrderService.java
@@ -16,9 +16,6 @@
    void reject(LostOrder lostOrder);
    List<LostOrder> findLostOrderList(String key, int page);
    int getCount(String key);
    LostOrder getOne(long id);