yujian
2019-10-14 3ac30b4c17cf071ce9c66a59c069ab83efae6d2d
Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div

# Conflicts:
# fanli/src/main/java/com/yeshi/fanli/entity/money/UserMoneyDetail.java
25个文件已修改
7个文件已添加
2392 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ElmeController.java 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/elme/ElmeHongBaoOrderMapMapper.java 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgMoneyDetail.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgOrderDetail.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/HongBaoV2.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/money/UserMoneyDetail.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/elme/ElmeHongBaoOrderMapException.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/elme/ElmeHongBaoOrderMapMapper.xml 177 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/elme/ElmeOrderMapper.xml 284 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2Mapper.xml 925 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/elme/ElmeHongBaoOrderMapServiceImpl.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/elme/ElmeOrderProcessServiceImpl.java 141 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/elme/ElmeOrderServiceImpl.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/BindingAccountServiceImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/UserMoneyMsgNotificationServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/msg/UserOrderMsgNotificationServiceImpl.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/elme/ElmeHongBaoOrderMapService.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/elme/ElmeOrderProcessService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/elme/ElmeOrderService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/money/msg/UserMoneyMsgNotificationService.java 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/OrderProcessService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/msg/UserOrderMsgNotificationService.java 61 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/Constant.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/elme/ElmeOrderUtil.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgMoneyDetailFactory.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgOrderDetailFactory.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/elme/ElmeUserOrderVO.java 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ElmeController.java
New file
@@ -0,0 +1,91 @@
package com.yeshi.fanli.controller.client.v1;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
import com.aliyuncs.unmarshaller.JsonUnmashaller;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap;
import com.yeshi.fanli.entity.elme.ElmeOrder;
import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.vo.elme.ElmeUserOrderVO;
import net.sf.json.JSONObject;
/**
 * 饿了么
 *
 * @author Administrator
 *
 */
@Controller
@RequestMapping("api/v1/elme")
public class ElmeController {
    @Resource
    private ElmeHongBaoOrderMapService elmeHongBaoOrderMapService;
    /**
     * 获取订单列表
     *
     * @param acceptData
     * @param uid
     * @param page
     * @param callback
     * @param out
     */
    @RequestMapping("getOrderList")
    public void getOrderList(AcceptData acceptData, Long uid, int page, String callback, PrintWriter out) {
        List<ElmeUserOrderVO> voList = new ArrayList<>();
        List<ElmeHongBaoOrderMap> list = elmeHongBaoOrderMapService.listByHongBaoUid(uid, page, Constant.PAGE_SIZE);
        if (list != null)
            for (ElmeHongBaoOrderMap map : list)
                voList.add(create(map));
        long count = elmeHongBaoOrderMapService.countByHongBaoUid(uid);
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("list", voList);
        if (!StringUtil.isNullOrEmpty(callback))
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
        else
            out.print(JsonUtil.loadTrueResult(data));
    }
    private ElmeUserOrderVO create(ElmeHongBaoOrderMap map) {
        HongBaoV2 hognBao = map.getHongBao();
        ElmeOrder order = map.getElmeOrder();
        ElmeUserOrderVO vo = new ElmeUserOrderVO();
        vo.setCreateTime(TimeUtil.getGernalTime(hognBao.getCreateTime().getTime(), "yyyy-MM-dd"));
        if (hognBao.getState() == HongBaoV2.STATE_BUKELINGQU || hognBao.getState() == HongBaoV2.STATE_KELINGQU)
            vo.setHongBaoState("未到账");
        else if (hognBao.getState() == HongBaoV2.STATE_SHIXIAO)
            vo.setHongBaoState("已失效");
        else
            vo.setHongBaoState("已到账");
        vo.setId(map.getId());
        vo.setMoney(hognBao.getMoney());
        vo.setOrderId(order.getOrderId());
        if (order.getPayMoney() == null || order.getPayMoney().compareTo(new BigDecimal(0)) <= 0)
            vo.setOrderState("未付款/已退款");
        else
            vo.setOrderState("已付款");
        vo.setOrderTime(TimeUtil.getGernalTime(order.getOrderDate().getTime(), "yyyy-MM-dd"));
        vo.setPayMoney(order.getPayMoney().toString());
        if (hognBao.getPreGetTime() != null)
            vo.setPreGetTime(TimeUtil.getGernalTime(hognBao.getPreGetTime().getTime(), "yyyy-MM-dd"));
        return vo;
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java
@@ -604,11 +604,6 @@
     */
    @RequestMapping(value = "getShareGoodsV2", method = RequestMethod.POST)
    public void getShareGoodsV2(AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        String day = TimeUtil.getGernalTime(java.lang.System.currentTimeMillis());
        List<ShareHotGoods> listHot = shareHotGoodsService.listByDay(day);
        if (listHot == null) {
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/elme/ElmeHongBaoOrderMapMapper.java
@@ -1,8 +1,46 @@
package com.yeshi.fanli.dao.mybatis.elme;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap;
public interface ElmeHongBaoOrderMapMapper extends BaseMapper<ElmeHongBaoOrderMap> {
package com.yeshi.fanli.dao.mybatis.elme;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap;
public interface ElmeHongBaoOrderMapMapper extends BaseMapper<ElmeHongBaoOrderMap> {
    /**
     * 根据红包ID检索
     *
     * @param hongBaoId
     * @return
     */
    ElmeHongBaoOrderMap selectByHongBaoId(Long hongBaoId);
    /**
     * 根据订单号检索
     *
     * @param orderId
     * @return
     */
    ElmeHongBaoOrderMap selectByOrderId(Long orderId);
    /**
     *
     * @param uid
     * @param start
     * @param count
     * @return
     */
    List<ElmeHongBaoOrderMap> listByHongBaoUid(@Param("uid") Long uid, @Param("start") long start,
            @Param("count") int count);
    /**
     * 根据红包用户ID计数
     *
     * @param uid
     * @return
     */
    long countByHongBaoUid(Long uid);
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgMoneyDetail.java
@@ -19,8 +19,9 @@
@Table("yeshi_ec_msg_money")
public class MsgMoneyDetail {
    public enum MsgTypeMoneyTypeEnum {
        share("分享奖金"), invite("邀请奖金"), fanli("返利到账"), extract("提现"), extractAutoWX("自动提现"), extractValid("提现账号验证"), shareWeiQuan(
                "分享奖金扣除"), inviteWeiQuan("邀请奖金扣除"), fanliWeiQuan("返利扣除"), orderReward("返利奖励"), systemEqualize("系统补齐");
                "分享奖金扣除"), inviteWeiQuan("邀请奖金扣除"), fanliWeiQuan("返利扣除"), orderReward("返利奖励"), systemEqualize("系统补齐"),fanliElme("返利到账");
        private final String desc;
        private MsgTypeMoneyTypeEnum(String desc) {
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgOrderDetail.java
@@ -22,7 +22,7 @@
    public final static int STATE_SX = 4;// 未付款/已退款
    public enum MsgTypeOrderTypeEnum {
        fanli("返利订单"), share("分享订单"), invite("邀请订单"), found("订单找回");
        fanli("返利订单"), share("分享订单"), invite("邀请订单"), found("订单找回"),elme("饿了么订单");
        private final String desc;
        private MsgTypeOrderTypeEnum(String desc) {
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/HongBaoV2.java
@@ -55,6 +55,9 @@
    // 金币兑换红包
    public final static int TYPE_EXCHANGE = 30;
    //饿了么红包
    public final static int TYPE_ELME=25;
    @Column(name = "hb_id")
    private Long id;
fanli/src/main/java/com/yeshi/fanli/entity/money/UserMoneyDetail.java
@@ -31,9 +31,11 @@
                        "http://apph5.yeshitv.com/apppage/flq_whyMoneyDel.html"), weiQuan("售后订单扣款", "http://img.flqapp.com/resource/money_detail/icon_fanli.png", "http://apph5.yeshitv.com/apppage/flq_whyMoneyDel.html"), systemEqualize("系统补齐", "http://img.flqapp.com/resource/money_detail/icon_system.png", ""), scoreConvert("金币兑换", "http://img.flqapp.com/resource/money_detail/icon_score.png",
                                ""), hongbao("官方红包", "http://img.flqapp.com/resource/money_detail/icon_hongbao.png", ""), hongbaoDeduct("红包退款", "http://img.flqapp.com/resource/money_detail/icon_hongbao.png",
                                        ""), buyScore("购买积分", "http://img.flqapp.com/resource/money_detail/icon_score.png", ""), extract("提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png",
                                                ""), extractVerify("提现验证", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""), extractReject("提现被拒", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""),orderReward("返利奖励金","http://img.flqapp.com/resource/money_detail/icon_order_reward.png",""),repeatStatistic("重复统计返利/奖金扣除","http://img.flqapp.com/resource/money_detail/icon_fanli.png",""),
                                extractAutoWX("自动提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""), extractAutoWXRefund("自动提现失败", "http://img.flqapp.com/resource/money_detail/icon_extract.png", "");
                                                ""), extractVerify("提现验证", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""), extractReject("提现被拒", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""),orderReward("返利奖励金","http://img.flqapp.com/resource/money_detail/icon_order_reward.png",""),repeatStatistic("重复统计返利/奖金扣除","http://img.flqapp.com/resource/money_detail/icon_fanli.png",""),
        elmeFanli("饿了么返利到账","http://img.flqapp.com/resource/money_detail/icon_fanli.png",""),
        extractAutoWX("自动提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""), extractAutoWXRefund("自动提现失败", "http://img.flqapp.com/resource/money_detail/icon_extract.png", "");
        private final String desc;
        private final String picture;
        private final String helpUrl;
fanli/src/main/java/com/yeshi/fanli/exception/elme/ElmeHongBaoOrderMapException.java
New file
@@ -0,0 +1,16 @@
package com.yeshi.fanli.exception.elme;
import com.yeshi.fanli.exception.BaseException;
public class ElmeHongBaoOrderMapException extends BaseException {
    private static final long serialVersionUID = 1L;
    public ElmeHongBaoOrderMapException(int code, String msg) {
        super(code, msg);
    }
    public ElmeHongBaoOrderMapException() {
        super();
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/elme/ElmeHongBaoOrderMapMapper.xml
@@ -1,66 +1,111 @@
<?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.yeshi.fanli.dao.mybatis.elme.ElmeHongBaoOrderMapMapper">
    <resultMap id="BaseResultMap"
        type="com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap">
        <id column="eoh_id" property="id" jdbcType="BIGINT" />
        <result column="eoh_create_time" property="createTime"
            jdbcType="TIMESTAMP" />
        <association property="elmeOrder" column="eoh_order_id">
            <id property="id" column="eoh_order_id" />
        </association>
        <association property="hongBao" column="eoh_hongbao_id">
            <id property="id" column="eoh_hongbao_id" />
        </association>
    </resultMap>
    <sql id="Base_Column_List">eoh_id,eoh_order_id,eoh_hongbao_id,eoh_create_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_elme_order_hongbao where eoh_id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_elme_order_hongbao where eoh_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_elme_order_hongbao
        (eoh_id,eoh_order_id,eoh_hongbao_id,eoh_create_time) values
        (#{id,jdbcType=BIGINT},#{elmeOrder.id,jdbcType=BIGINT},#{hongBao.id,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_elme_order_hongbao
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">eoh_id,</if>
            <if test="elmeOrder != null">eoh_order_id,</if>
            <if test="hongBao != null">eoh_hongbao_id,</if>
            <if test="createTime != null">eoh_create_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="elmeOrder != null">#{elmeOrder.id,jdbcType=BIGINT},</if>
            <if test="hongBao != null">#{hongBao.id,jdbcType=BIGINT},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap">update
        yeshi_ec_elme_order_hongbao set eoh_order_id =
        #{elmeOrder.id,jdbcType=BIGINT},eoh_hongbao_id =
        #{hongBao.id,jdbcType=BIGINT},eoh_create_time =
        #{createTime,jdbcType=TIMESTAMP} where eoh_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap">
        update yeshi_ec_elme_order_hongbao
        <set>
            <if test="elmeOrder != null">eoh_order_id=#{elmeOrder.id,jdbcType=BIGINT},</if>
            <if test="hongBao != null">eoh_hongbao_id=#{hongBao.id,jdbcType=BIGINT},</if>
            <if test="createTime != null">eoh_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
        </set>
        where eoh_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
<?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.yeshi.fanli.dao.mybatis.elme.ElmeHongBaoOrderMapMapper">
    <resultMap id="BaseResultMap"
        type="com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap">
        <id column="eoh_id" property="id" jdbcType="BIGINT" />
        <result column="eoh_create_time" property="createTime"
            jdbcType="TIMESTAMP" />
        <association property="elmeOrder" column="eoh_order_id"
            javaType="com.yeshi.fanli.entity.elme.ElmeOrder"
            select="com.yeshi.fanli.dao.mybatis.elme.ElmeOrderMapper.selectByPrimaryKey">
        </association>
        <association property="hongBao" column="eoh_hongbao_id"
            javaType="com.yeshi.fanli.entity.bus.user.HongBaoV2"
            select="com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper.selectByPrimaryKey">
        </association>
    </resultMap>
    <sql id="Base_Column_List">eoh_id,eoh_order_id,eoh_hongbao_id,eoh_create_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_elme_order_hongbao where eoh_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByHongBaoId" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_elme_order_hongbao where eoh_hongbao_id = #{0}
    </select>
    <select id="selectByOrderId" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_elme_order_hongbao where eoh_order_id = #{0}
    </select>
    <select id="listByHongBaoUid" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_elme_order_hongbao left join yeshi_ec_hongbao_v2 v on
        v.hb_id=eoh_hongbao_id where v.hb_uid = #{uid} order by eoh_id desc limit #{start},#{count}
    </select>
    <select id="countByHongBaoUid" resultType="java.lang.Long"
        parameterType="java.lang.Long">
        select
        count(eoh_id)
        from yeshi_ec_elme_order_hongbao left
        join yeshi_ec_hongbao_v2 v on
        v.hb_id=eoh_hongbao_id where v.hb_uid =
        #{0}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_elme_order_hongbao where eoh_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_elme_order_hongbao
        (eoh_id,eoh_order_id,eoh_hongbao_id,eoh_create_time) values
        (#{id,jdbcType=BIGINT},#{elmeOrder.id,jdbcType=BIGINT},#{hongBao.id,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_elme_order_hongbao
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">eoh_id,</if>
            <if test="elmeOrder != null">eoh_order_id,</if>
            <if test="hongBao != null">eoh_hongbao_id,</if>
            <if test="createTime != null">eoh_create_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="elmeOrder != null">#{elmeOrder.id,jdbcType=BIGINT},</if>
            <if test="hongBao != null">#{hongBao.id,jdbcType=BIGINT},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap">update
        yeshi_ec_elme_order_hongbao set eoh_order_id =
        #{elmeOrder.id,jdbcType=BIGINT},eoh_hongbao_id =
        #{hongBao.id,jdbcType=BIGINT},eoh_create_time =
        #{createTime,jdbcType=TIMESTAMP} where eoh_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap">
        update yeshi_ec_elme_order_hongbao
        <set>
            <if test="elmeOrder != null">eoh_order_id=#{elmeOrder.id,jdbcType=BIGINT},</if>
            <if test="hongBao != null">eoh_hongbao_id=#{hongBao.id,jdbcType=BIGINT},</if>
            <if test="createTime != null">eoh_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
        </set>
        where eoh_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/elme/ElmeOrderMapper.xml
@@ -1,138 +1,146 @@
<?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.yeshi.fanli.dao.mybatis.elme.ElmeOrderMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.elme.ElmeOrder">
        <id column="eo_id" property="id" jdbcType="BIGINT" />
        <result column="eo_channel_id" property="channelId" jdbcType="VARCHAR" />
        <result column="eo_channel_name" property="channelName"
            jdbcType="VARCHAR" />
        <result column="eo_track_pid" property="trackPid" jdbcType="VARCHAR" />
        <result column="eo_rid" property="rid" jdbcType="VARCHAR" />
        <result column="eo_order_date" property="orderDate" jdbcType="TIMESTAMP" />
        <result column="eo_order_id" property="orderId" jdbcType="VARCHAR" />
        <result column="eo_pay_money" property="payMoney" jdbcType="DECIMAL" />
        <result column="eo_city" property="city" jdbcType="VARCHAR" />
        <result column="eo_coupon_money" property="couponMoney"
            jdbcType="DECIMAL" />
        <result column="eo_newer_first_order" property="newerFirstOrder"
            jdbcType="INTEGER" />
        <result column="eo_newer_repay_order" property="newerRepayOrder"
            jdbcType="INTEGER" />
        <result column="eo_taoke_hongbao" property="taokeHongBao"
            jdbcType="INTEGER" />
        <result column="eo_shop_click" property="shopClick" jdbcType="INTEGER" />
        <result column="eo_recieve_coupon_7day_first_order" property="recieveCoupon7DayFirstOrder"
            jdbcType="INTEGER" />
        <result column="eo_settle" property="isSettle" jdbcType="BOOLEAN" />
        <result column="eo_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="eo_update_time" property="updateTime" jdbcType="TIMESTAMP" />
    </resultMap>
    <sql id="Base_Column_List">eo_id,eo_channel_id,eo_channel_name,eo_track_pid,eo_rid,eo_order_date,eo_order_id,eo_pay_money,eo_city,eo_coupon_money,eo_newer_first_order,eo_newer_repay_order,eo_taoke_hongbao,eo_shop_click,eo_recieve_coupon_7day_first_order,eo_settle,eo_create_time,eo_update_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_elme_order where eo_id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_elme_order where eo_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.elme.ElmeOrder"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_elme_order
        (eo_id,eo_channel_id,eo_channel_name,eo_track_pid,eo_rid,eo_order_date,eo_order_id,eo_pay_money,eo_city,eo_coupon_money,eo_newer_first_order,eo_newer_repay_order,eo_taoke_hongbao,eo_shop_click,eo_recieve_coupon_7day_first_order,eo_settle,eo_create_time,eo_update_time)
        values
        (#{id,jdbcType=BIGINT},#{channelId,jdbcType=VARCHAR},#{channelName,jdbcType=VARCHAR},#{trackPid,jdbcType=VARCHAR},#{rid,jdbcType=VARCHAR},#{orderDate,jdbcType=TIMESTAMP},#{orderId,jdbcType=VARCHAR},#{payMoney,jdbcType=DECIMAL},#{city,jdbcType=VARCHAR},#{couponMoney,jdbcType=DECIMAL},#{newerFirstOrder,jdbcType=INTEGER},#{newerRepayOrder,jdbcType=INTEGER},#{taokeHongBao,jdbcType=INTEGER},#{shopClick,jdbcType=INTEGER},#{recieveCoupon7DayFirstOrder,jdbcType=INTEGER},#{isSettle,jdbcType=BOOLEAN},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.elme.ElmeOrder"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_elme_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">eo_id,</if>
            <if test="channelId != null">eo_channel_id,</if>
            <if test="channelName != null">eo_channel_name,</if>
            <if test="trackPid != null">eo_track_pid,</if>
            <if test="rid != null">eo_rid,</if>
            <if test="orderDate != null">eo_order_date,</if>
            <if test="orderId != null">eo_order_id,</if>
            <if test="payMoney != null">eo_pay_money,</if>
            <if test="city != null">eo_city,</if>
            <if test="couponMoney != null">eo_coupon_money,</if>
            <if test="newerFirstOrder != null">eo_newer_first_order,</if>
            <if test="newerRepayOrder != null">eo_newer_repay_order,</if>
            <if test="taokeHongBao != null">eo_taoke_hongbao,</if>
            <if test="shopClick != null">eo_shop_click,</if>
            <if test="recieveCoupon7DayFirstOrder != null">eo_recieve_coupon_7day_first_order,</if>
            <if test="isSettle != null">eo_settle,</if>
            <if test="createTime != null">eo_create_time,</if>
            <if test="updateTime != null">eo_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="channelId != null">#{channelId,jdbcType=VARCHAR},</if>
            <if test="channelName != null">#{channelName,jdbcType=VARCHAR},</if>
            <if test="trackPid != null">#{trackPid,jdbcType=VARCHAR},</if>
            <if test="rid != null">#{rid,jdbcType=VARCHAR},</if>
            <if test="orderDate != null">#{orderDate,jdbcType=TIMESTAMP},</if>
            <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
            <if test="payMoney != null">#{payMoney,jdbcType=DECIMAL},</if>
            <if test="city != null">#{city,jdbcType=VARCHAR},</if>
            <if test="couponMoney != null">#{couponMoney,jdbcType=DECIMAL},</if>
            <if test="newerFirstOrder != null">#{newerFirstOrder,jdbcType=INTEGER},</if>
            <if test="newerRepayOrder != null">#{newerRepayOrder,jdbcType=INTEGER},</if>
            <if test="taokeHongBao != null">#{taokeHongBao,jdbcType=INTEGER},</if>
            <if test="shopClick != null">#{shopClick,jdbcType=INTEGER},</if>
            <if test="recieveCoupon7DayFirstOrder != null">#{recieveCoupon7DayFirstOrder,jdbcType=INTEGER},</if>
            <if test="isSettle != null">#{isSettle,jdbcType=BOOLEAN},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.elme.ElmeOrder">update
        yeshi_ec_elme_order set eo_channel_id =
        #{channelId,jdbcType=VARCHAR},eo_channel_name =
        #{channelName,jdbcType=VARCHAR},eo_track_pid =
        #{trackPid,jdbcType=VARCHAR},eo_rid =
        #{rid,jdbcType=VARCHAR},eo_order_date =
        #{orderDate,jdbcType=TIMESTAMP},eo_order_id =
        #{orderId,jdbcType=VARCHAR},eo_pay_money =
        #{payMoney,jdbcType=DECIMAL},eo_city =
        #{city,jdbcType=VARCHAR},eo_coupon_money =
        #{couponMoney,jdbcType=DECIMAL},eo_newer_first_order =
        #{newerFirstOrder,jdbcType=INTEGER},eo_newer_repay_order =
        #{newerRepayOrder,jdbcType=INTEGER},eo_taoke_hongbao =
        #{taokeHongBao,jdbcType=INTEGER},eo_shop_click =
        #{shopClick,jdbcType=INTEGER},eo_recieve_coupon_7day_first_order =
        #{recieveCoupon7DayFirstOrder,jdbcType=INTEGER},eo_settle =
        #{isSettle,jdbcType=BOOLEAN},eo_create_time =
        #{createTime,jdbcType=TIMESTAMP},eo_update_time =
        #{updateTime,jdbcType=TIMESTAMP} where eo_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.elme.ElmeOrder">
        update yeshi_ec_elme_order
        <set>
            <if test="channelId != null">eo_channel_id=#{channelId,jdbcType=VARCHAR},</if>
            <if test="channelName != null">eo_channel_name=#{channelName,jdbcType=VARCHAR},</if>
            <if test="trackPid != null">eo_track_pid=#{trackPid,jdbcType=VARCHAR},</if>
            <if test="rid != null">eo_rid=#{rid,jdbcType=VARCHAR},</if>
            <if test="orderDate != null">eo_order_date=#{orderDate,jdbcType=TIMESTAMP},</if>
            <if test="orderId != null">eo_order_id=#{orderId,jdbcType=VARCHAR},</if>
            <if test="payMoney != null">eo_pay_money=#{payMoney,jdbcType=DECIMAL},</if>
            <if test="city != null">eo_city=#{city,jdbcType=VARCHAR},</if>
            <if test="couponMoney != null">eo_coupon_money=#{couponMoney,jdbcType=DECIMAL},</if>
            <if test="newerFirstOrder != null">eo_newer_first_order=#{newerFirstOrder,jdbcType=INTEGER},
            </if>
            <if test="newerRepayOrder != null">eo_newer_repay_order=#{newerRepayOrder,jdbcType=INTEGER},
            </if>
            <if test="taokeHongBao != null">eo_taoke_hongbao=#{taokeHongBao,jdbcType=INTEGER},</if>
            <if test="shopClick != null">eo_shop_click=#{shopClick,jdbcType=INTEGER},</if>
            <if test="recieveCoupon7DayFirstOrder != null">eo_recieve_coupon_7day_first_order=#{recieveCoupon7DayFirstOrder,jdbcType=INTEGER},
            </if>
            <if test="isSettle != null">eo_settle=#{isSettle,jdbcType=BOOLEAN},</if>
            <if test="createTime != null">eo_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">eo_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where eo_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
<?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.yeshi.fanli.dao.mybatis.elme.ElmeOrderMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.elme.ElmeOrder">
        <id column="eo_id" property="id" jdbcType="BIGINT" />
        <result column="eo_channel_id" property="channelId" jdbcType="VARCHAR" />
        <result column="eo_channel_name" property="channelName"
            jdbcType="VARCHAR" />
        <result column="eo_track_pid" property="trackPid" jdbcType="VARCHAR" />
        <result column="eo_rid" property="rid" jdbcType="VARCHAR" />
        <result column="eo_order_date" property="orderDate" jdbcType="TIMESTAMP" />
        <result column="eo_order_id" property="orderId" jdbcType="VARCHAR" />
        <result column="eo_pay_money" property="payMoney" jdbcType="DECIMAL" />
        <result column="eo_city" property="city" jdbcType="VARCHAR" />
        <result column="eo_coupon_money" property="couponMoney"
            jdbcType="DECIMAL" />
        <result column="eo_newer_first_order" property="newerFirstOrder"
            jdbcType="INTEGER" />
        <result column="eo_newer_repay_order" property="newerRepayOrder"
            jdbcType="INTEGER" />
        <result column="eo_taoke_hongbao" property="taokeHongBao"
            jdbcType="INTEGER" />
        <result column="eo_shop_click" property="shopClick" jdbcType="INTEGER" />
        <result column="eo_recieve_coupon_7day_first_order" property="recieveCoupon7DayFirstOrder"
            jdbcType="INTEGER" />
        <result column="eo_settle" property="isSettle" jdbcType="BOOLEAN" />
        <result column="eo_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="eo_update_time" property="updateTime" jdbcType="TIMESTAMP" />
    </resultMap>
    <sql id="Base_Column_List">eo_id,eo_channel_id,eo_channel_name,eo_track_pid,eo_rid,eo_order_date,eo_order_id,eo_pay_money,eo_city,eo_coupon_money,eo_newer_first_order,eo_newer_repay_order,eo_taoke_hongbao,eo_shop_click,eo_recieve_coupon_7day_first_order,eo_settle,eo_create_time,eo_update_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_elme_order where eo_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByOrderId" resultMap="BaseResultMap"
        parameterType="java.lang.String">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_elme_order where eo_order_id = #{0}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_elme_order where eo_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.elme.ElmeOrder"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_elme_order
        (eo_id,eo_channel_id,eo_channel_name,eo_track_pid,eo_rid,eo_order_date,eo_order_id,eo_pay_money,eo_city,eo_coupon_money,eo_newer_first_order,eo_newer_repay_order,eo_taoke_hongbao,eo_shop_click,eo_recieve_coupon_7day_first_order,eo_settle,eo_create_time,eo_update_time)
        values
        (#{id,jdbcType=BIGINT},#{channelId,jdbcType=VARCHAR},#{channelName,jdbcType=VARCHAR},#{trackPid,jdbcType=VARCHAR},#{rid,jdbcType=VARCHAR},#{orderDate,jdbcType=TIMESTAMP},#{orderId,jdbcType=VARCHAR},#{payMoney,jdbcType=DECIMAL},#{city,jdbcType=VARCHAR},#{couponMoney,jdbcType=DECIMAL},#{newerFirstOrder,jdbcType=INTEGER},#{newerRepayOrder,jdbcType=INTEGER},#{taokeHongBao,jdbcType=INTEGER},#{shopClick,jdbcType=INTEGER},#{recieveCoupon7DayFirstOrder,jdbcType=INTEGER},#{isSettle,jdbcType=BOOLEAN},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.elme.ElmeOrder"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_elme_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">eo_id,</if>
            <if test="channelId != null">eo_channel_id,</if>
            <if test="channelName != null">eo_channel_name,</if>
            <if test="trackPid != null">eo_track_pid,</if>
            <if test="rid != null">eo_rid,</if>
            <if test="orderDate != null">eo_order_date,</if>
            <if test="orderId != null">eo_order_id,</if>
            <if test="payMoney != null">eo_pay_money,</if>
            <if test="city != null">eo_city,</if>
            <if test="couponMoney != null">eo_coupon_money,</if>
            <if test="newerFirstOrder != null">eo_newer_first_order,</if>
            <if test="newerRepayOrder != null">eo_newer_repay_order,</if>
            <if test="taokeHongBao != null">eo_taoke_hongbao,</if>
            <if test="shopClick != null">eo_shop_click,</if>
            <if test="recieveCoupon7DayFirstOrder != null">eo_recieve_coupon_7day_first_order,</if>
            <if test="isSettle != null">eo_settle,</if>
            <if test="createTime != null">eo_create_time,</if>
            <if test="updateTime != null">eo_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="channelId != null">#{channelId,jdbcType=VARCHAR},</if>
            <if test="channelName != null">#{channelName,jdbcType=VARCHAR},</if>
            <if test="trackPid != null">#{trackPid,jdbcType=VARCHAR},</if>
            <if test="rid != null">#{rid,jdbcType=VARCHAR},</if>
            <if test="orderDate != null">#{orderDate,jdbcType=TIMESTAMP},</if>
            <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
            <if test="payMoney != null">#{payMoney,jdbcType=DECIMAL},</if>
            <if test="city != null">#{city,jdbcType=VARCHAR},</if>
            <if test="couponMoney != null">#{couponMoney,jdbcType=DECIMAL},</if>
            <if test="newerFirstOrder != null">#{newerFirstOrder,jdbcType=INTEGER},</if>
            <if test="newerRepayOrder != null">#{newerRepayOrder,jdbcType=INTEGER},</if>
            <if test="taokeHongBao != null">#{taokeHongBao,jdbcType=INTEGER},</if>
            <if test="shopClick != null">#{shopClick,jdbcType=INTEGER},</if>
            <if test="recieveCoupon7DayFirstOrder != null">#{recieveCoupon7DayFirstOrder,jdbcType=INTEGER},</if>
            <if test="isSettle != null">#{isSettle,jdbcType=BOOLEAN},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.elme.ElmeOrder">update
        yeshi_ec_elme_order set eo_channel_id =
        #{channelId,jdbcType=VARCHAR},eo_channel_name =
        #{channelName,jdbcType=VARCHAR},eo_track_pid =
        #{trackPid,jdbcType=VARCHAR},eo_rid =
        #{rid,jdbcType=VARCHAR},eo_order_date =
        #{orderDate,jdbcType=TIMESTAMP},eo_order_id =
        #{orderId,jdbcType=VARCHAR},eo_pay_money =
        #{payMoney,jdbcType=DECIMAL},eo_city =
        #{city,jdbcType=VARCHAR},eo_coupon_money =
        #{couponMoney,jdbcType=DECIMAL},eo_newer_first_order =
        #{newerFirstOrder,jdbcType=INTEGER},eo_newer_repay_order =
        #{newerRepayOrder,jdbcType=INTEGER},eo_taoke_hongbao =
        #{taokeHongBao,jdbcType=INTEGER},eo_shop_click =
        #{shopClick,jdbcType=INTEGER},eo_recieve_coupon_7day_first_order =
        #{recieveCoupon7DayFirstOrder,jdbcType=INTEGER},eo_settle =
        #{isSettle,jdbcType=BOOLEAN},eo_create_time =
        #{createTime,jdbcType=TIMESTAMP},eo_update_time =
        #{updateTime,jdbcType=TIMESTAMP} where eo_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.elme.ElmeOrder">
        update yeshi_ec_elme_order
        <set>
            <if test="channelId != null">eo_channel_id=#{channelId,jdbcType=VARCHAR},</if>
            <if test="channelName != null">eo_channel_name=#{channelName,jdbcType=VARCHAR},</if>
            <if test="trackPid != null">eo_track_pid=#{trackPid,jdbcType=VARCHAR},</if>
            <if test="rid != null">eo_rid=#{rid,jdbcType=VARCHAR},</if>
            <if test="orderDate != null">eo_order_date=#{orderDate,jdbcType=TIMESTAMP},</if>
            <if test="orderId != null">eo_order_id=#{orderId,jdbcType=VARCHAR},</if>
            <if test="payMoney != null">eo_pay_money=#{payMoney,jdbcType=DECIMAL},</if>
            <if test="city != null">eo_city=#{city,jdbcType=VARCHAR},</if>
            <if test="couponMoney != null">eo_coupon_money=#{couponMoney,jdbcType=DECIMAL},</if>
            <if test="newerFirstOrder != null">eo_newer_first_order=#{newerFirstOrder,jdbcType=INTEGER},
            </if>
            <if test="newerRepayOrder != null">eo_newer_repay_order=#{newerRepayOrder,jdbcType=INTEGER},
            </if>
            <if test="taokeHongBao != null">eo_taoke_hongbao=#{taokeHongBao,jdbcType=INTEGER},</if>
            <if test="shopClick != null">eo_shop_click=#{shopClick,jdbcType=INTEGER},</if>
            <if test="recieveCoupon7DayFirstOrder != null">eo_recieve_coupon_7day_first_order=#{recieveCoupon7DayFirstOrder,jdbcType=INTEGER},
            </if>
            <if test="isSettle != null">eo_settle=#{isSettle,jdbcType=BOOLEAN},</if>
            <if test="createTime != null">eo_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">eo_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where eo_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2Mapper.xml
@@ -1,461 +1,464 @@
<?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.yeshi.fanli.dao.mybatis.HongBaoV2Mapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.HongBaoV2">
        <id column="hb_id" property="id" jdbcType="BIGINT" />
        <result column="hb_urank" property="urank" jdbcType="INTEGER" />
        <result column="hb_money" property="money" jdbcType="DECIMAL" />
        <result column="hb_type" property="type" jdbcType="INTEGER" />
        <result column="hb_state" property="state" jdbcType="INTEGER" />
        <result column="hb_version" property="version" jdbcType="INTEGER" />
        <result column="hb_beizhu" property="beizhu" jdbcType="VARCHAR" />
        <result column="hb_pre_get_time" property="preGetTime"
            jdbcType="TIMESTAMP" />
        <result column="hb_get_time" property="getTime" jdbcType="TIMESTAMP" />
        <result column="hb_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="hb_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <association property="userInfo" column="hb_uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="hb_uid" property="id" jdbcType="BIGINT" />
        </association>
        <association property="parent" column="hb_pid"
            javaType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
            <id column="hb_pid" property="id" jdbcType="BIGINT" />
        </association>
        <!-- <association property="userInfo" column="hb_uid" resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap"/> -->
    </resultMap>
    <resultMap id="BaseDTOResultMap" type="com.yeshi.fanli.dto.HongBaoDTO">
        <id column="hb_id" property="id" jdbcType="BIGINT" />
        <result column="hb_urank" property="urank" jdbcType="INTEGER" />
        <result column="hb_money" property="money" jdbcType="DECIMAL" />
        <result column="hb_type" property="type" jdbcType="INTEGER" />
        <result column="hb_state" property="state" jdbcType="INTEGER" />
        <result column="hb_version" property="version" jdbcType="INTEGER" />
        <result column="hb_beizhu" property="beizhu" jdbcType="VARCHAR" />
        <result column="hb_pre_get_time" property="preGetTime"
            jdbcType="TIMESTAMP" />
        <result column="hb_get_time" property="getTime" jdbcType="TIMESTAMP" />
        <result column="hb_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="hb_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="orderId" property="orderId" jdbcType="VARCHAR" />
        <result column="payMoney" property="payMoney" jdbcType="DECIMAL" />
        <result column="settlement" property="settlement" jdbcType="DECIMAL" />
        <association property="userInfo" column="hb_uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="hb_uid" property="id" jdbcType="BIGINT" />
        </association>
        <association property="parent" column="hb_pid"
            javaType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
            <id column="hb_pid" property="id" jdbcType="BIGINT" />
        </association>
    </resultMap>
    <sql id="Base_Column_List">hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT} for
        update
    </select>
    <select id="listChildrenById" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_hongbao_v2 where hb_pid = #{0}
    </select>
    <select id="listCanBalanceHongBaoByType" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        FROM yeshi_ec_hongbao_v2 h WHERE h.`hb_version`=2 AND
        h.`hb_type`=#{type} AND (h.`hb_state`=2) AND
        h.`hb_pre_get_time` IS NOT
        NULL AND h.`hb_pre_get_time`
        <![CDATA[ <]]>
        NOW() order by hb_pre_get_time desc limit #{count}
    </select>
    <!-- 获取用户奖金列表 -->
    <select id="listJiangJinByUid" resultMap="BaseDTOResultMap">
        SELECT
        hhh.*,co.`co_order_no` AS orderId,co.`co_payment` AS
        payMoney,co.`co_settlement` AS settlement FROM
        (
        SELECT
        hh.*,IF(h.`hb_id` IS NOT NULL,h.`hb_id`,hh.hb_id) AS hid FROM
        (
        SELECT
        h.* FROM yeshi_ec_hongbao_v2 h WHERE h.hb_uid=#{uid} and
        (h.`hb_type`=6 OR h.`hb_type`=7
        OR h.`hb_type`=20 OR h.`hb_type`=21 OR
        h.`hb_type`=22) AND
        h.`hb_version`=2 ORDER BY h.`hb_create_time` DESC
        limit #{start},#{count}
        ) hh
        LEFT JOIN yeshi_ec_hongbao_v2 h ON
        hh.hb_pid IS NOT NULL AND
        h.`hb_id`=hh.hb_pid
        ) hhh LEFT JOIN
        yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id`=hhh.hid
        LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
    </select>
    <!-- 获取用户奖金列表 -->
    <select id="countJiangJinByUid" resultType="java.lang.Long">
        SELECT count(h.hb_id)
        FROM yeshi_ec_hongbao_v2 h WHERE h.hb_uid=#{0} and (h.`hb_type`=6 OR
        h.`hb_type`=7
        OR h.`hb_type`=20 OR h.`hb_type`=21 OR h.`hb_type`=22)
        AND
        h.`hb_version`=2
    </select>
    <!-- 获取总的提成金额 -->
    <select id="getTotalTiChengMoney" resultType="java.math.BigDecimal"
        parameterType="java.lang.Long">
        SELECT IF(a.money IS NULL,0,a.money ) FROM (SELECT
        SUM(h.`hb_money`) AS money FROM `yeshi_ec_hongbao_v2` h WHERE
        h.`hb_uid`=#{0}
        AND h.`hb_state`=3 AND (h.`hb_type`=20 OR
        h.`hb_type`=21 OR h.`hb_type`=22 OR
        h.`hb_type`=6 OR h.`hb_type`=7)) a
    </select>
    <!-- 获取总的提成笔数 -->
    <select id="getTotalTiChengCount" resultType="java.lang.Integer"
        parameterType="java.lang.Long">
        SELECT
        count(*) FROM `yeshi_ec_hongbao_v2` h
        WHERE
        h.`hb_uid`=#{0} AND (h.`hb_type`=20 OR h.`hb_type`=21 OR
        h.`hb_type`=22 OR
        h.`hb_type`=6 OR h.`hb_type`=7)
    </select>
    <!-- 获取还未到账的提成金额 -->
    <select id="getUnGetTiChengMoney" resultType="java.math.BigDecimal"
        parameterType="java.lang.Long">
        SELECT IF(a.money IS NULL,0,a.money ) FROM (SELECT
        SUM(h.`hb_money`) AS money FROM `yeshi_ec_hongbao_v2` h WHERE
        h.`hb_uid`=#{0}
        AND (h.`hb_state`=1 OR h.hb_state=2 )AND
        (h.`hb_type`=20 OR h.`hb_type`=21 OR
        h.`hb_type`=22 OR h.`hb_type`=6 OR
        h.`hb_type`=7)) a
    </select>
    <select id="getTotalFanLiMoney" resultType="java.math.BigDecimal"
        parameterType="java.lang.Long">
        SELECT SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
        WHERE h.`hb_uid`=#{uid} AND h.`hb_type`=1 AND h.`hb_state`=3
    </select>
    <select id="getUnRecievedFanLiMoney" resultType="java.math.BigDecimal"
        parameterType="java.lang.Long">
        SELECT SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
        WHERE h.`hb_uid`=#{uid} AND h.`hb_type`=1 AND (h.`hb_state`=1 OR
        h.`hb_state`=2)
    </select>
    <select id="listUidCanBanlanceShareAndInvite" resultType="java.lang.Long"
        parameterType="java.lang.Integer">
        SELECT DISTINCT( h.`hb_uid`) FROM yeshi_ec_hongbao_v2 h
        WHERE
        (`hb_type`=6 OR
        `hb_type`=7 OR `hb_type`=20 OR `hb_type`=21 OR
        `hb_type`=22 ) AND
        `hb_version`=2 AND (hb_state=1 OR hb_state=2) AND
        hb_pre_get_time IS
        NOT NULL AND hb_pre_get_time>0 AND
        NOW()>=hb_pre_get_time limit #{0}
    </select>
    <select id="listCanBalanceHongBaoByTypeAndUid" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_hongbao_v2 where hb_uid=#{uid} and `hb_version`=2
        <foreach collection="types" item="type" open=" and ("
            separator=" or " close=")">
            hb_type =
            #{type}
        </foreach>
        and
        (hb_state=1 or hb_state=2) and
        hb_pre_get_time IS NOT NULL AND
        hb_pre_get_time>0 AND
        NOW()>=hb_pre_get_time limit
        #{start},#{count}
    </select>
    <select id="countCanBalanceHongBaoByTypeAndUid" resultType="java.lang.Long">
        select
        count(hb_id)
        from yeshi_ec_hongbao_v2 where hb_uid=#{uid} and
        `hb_version`=2
        <foreach collection="types" item="type" open=" and ("
            separator=" or " close=")">
            hb_type =
            #{type}
        </foreach>
        and
        (hb_state=1 or hb_state=2) and
        hb_pre_get_time IS NOT NULL AND
        hb_pre_get_time>0 AND
        NOW()>=hb_pre_get_time
    </select>
    <select id="countInviteOrderCountByUidAndSettleTime" resultType="java.lang.Long">
        SELECT COUNT(h.hb_id) FROM yeshi_ec_hongbao_v2 h LEFT JOIN
        yeshi_ec_hongbao_order ho ON h.`hb_pid`=ho.`ho_hongbao_id` LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE
        h.`hb_uid`=#{uid} and (h.`hb_type`=6 or h.`hb_type`=7 OR
        h.`hb_type`=21 OR h.`hb_type`=22) and co.`co_state`=#{state} and
        co.`co_settle_time` is not null and co.`co_settle_time`>=#{minDate}
        and #{maxDate}>co.`co_settle_time`;
    </select>
    <select id="countShareOrderCountByUidAndSettleTime" resultType="java.lang.Long">
        SELECT COUNT(h.hb_id) FROM yeshi_ec_hongbao_v2 h LEFT JOIN
        yeshi_ec_hongbao_order ho ON h.`hb_id`=ho.`ho_hongbao_id` LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE
        h.`hb_uid`=#{uid} and h.`hb_type`=20 and co.`co_state`=#{state} and
        co.`co_settle_time` is not null and co.`co_settle_time`>=#{minDate}
        and #{maxDate}>co.`co_settle_time`;
    </select>
    <select id="getUnRecievedMoneyWithCreateTime" resultType="java.math.BigDecimal">
        SELECT
        SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
        WHERE h.`hb_uid`=#{uid}
        AND (h.`hb_state`=1 OR
        h.`hb_state`=2) and hb_create_time>=#{minDate}
        and #{maxDate} > hb_create_time
    </select>
    <select id="getUnRecievedMoneyWithPreGetTime" resultType="java.math.BigDecimal">
        SELECT
        SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
        WHERE h.`hb_uid`=#{uid}
        AND (h.`hb_state`=1 OR
        h.`hb_state`=2) and hb_pre_get_time is not null
        and hb_pre_get_time>=#{minDate}
        and #{maxDate} > hb_pre_get_time
    </select>
    <select id="countByUidAndState" resultType="java.lang.Long">
        SELECT
        SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
        WHERE h.`hb_uid`=#{uid}
        AND h.`hb_state`=#{state}
    </select>
    <select id="computeMoneyByUidAndState" resultType="java.math.BigDecimal">
        SELECT
        SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
        WHERE
        h.`hb_uid`=#{uid}
        <if test="stateList!=null">
            <foreach collection="stateList" item="state" open=" and ("
                separator=" or " close=")">
                hb_state=#{state}
            </foreach>
        </if>
    </select>
    <select id="getUidByNear30DayShareSucceed" resultType="java.lang.Long">
        SELECT v2.`hb_uid` FROM yeshi_ec_hongbao_v2 v2
        WHERE v2.`hb_type` = 20
        AND v2.`hb_state`<![CDATA[<>]]>
        4
        AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <![CDATA[<=]]>DATE(v2.`hb_create_time`)
        GROUP BY v2.`hb_uid`
        ORDER BY v2.`hb_create_time`;
    </select>
    <select id="listByParentUidAndTypeAndState" resultMap="BaseResultMap">
        SELECT v.* FROM yeshi_ec_hongbao_v2 v LEFT JOIN yeshi_ec_hongbao_v2 p
        ON v.`hb_pid`=p.`hb_id` WHERE p.`hb_uid`=#{uid}
        <if test="typeList!=null">
            <foreach collection="typeList" item="type" open=" and ("
                separator=" or " close=")">
                v.hb_type=#{type}
            </foreach>
        </if>
        <if test="stateList!=null">
            <foreach collection="stateList" item="state" open=" and ("
                separator=" or " close=")">
                v.hb_state=#{state}
            </foreach>
        </if>
        limit #{start},#{count}
    </select>
    <select id="countByParentUidAndTypeAndState" resultType="java.lang.Long">
        SELECT count(v.hb_id) FROM yeshi_ec_hongbao_v2 v LEFT JOIN
        yeshi_ec_hongbao_v2 p
        ON v.`hb_pid`=p.`hb_id` WHERE p.`hb_uid`=#{uid}
        <if test="typeList!=null">
            <foreach collection="typeList" item="type" open=" and ("
                separator=" or " close=")">
                v.hb_type=#{type}
            </foreach>
        </if>
        <if test="stateList!=null">
            <foreach collection="stateList" item="state" open=" and ("
                separator=" or " close=")">
                v.hb_state=#{state}
            </foreach>
        </if>
    </select>
    <select id="listBySourceTypeAndTradeIdListAndUid" resultMap="BaseResultMap">
        SELECT a.* FROM
        (
            SELECT * FROM yeshi_ec_hongbao_v2 v WHERE v.`hb_uid`=#{uid}
        ) a
        LEFT JOIN
        (
        SELECT ho.`ho_hongbao_id` AS hbId FROM yeshi_ec_hongbao_order ho LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE
        co.`co_source_type`=#{sourceType}
        <if test="tradeIdList!=null">
            <foreach collection="tradeIdList" open=" and (" close=")"
                separator=" or " item="tradeId">
                co.co_trade_id=#{tradeId}
            </foreach>
        </if>
        )
        b
        ON a.hb_id=b.hbId OR a.hb_pid=b.hbId WHERE b.hbId >0
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_hongbao_v2
        (hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time)
        values
        (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{urank,jdbcType=INTEGER},#{parent.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{version,jdbcType=INTEGER},#{beizhu,jdbcType=VARCHAR},#{preGetTime,jdbcType=TIMESTAMP},#{getTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_hongbao_v2
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">hb_id,</if>
            <if test="userInfo != null">hb_uid,</if>
            <if test="urank != null">hb_urank,</if>
            <if test="parent != null">hb_pid,</if>
            <if test="money != null">hb_money,</if>
            <if test="type != null">hb_type,</if>
            <if test="state != null">hb_state,</if>
            <if test="version != null">hb_version,</if>
            <if test="beizhu != null">hb_beizhu,</if>
            <if test="preGetTime != null">hb_pre_get_time,</if>
            <if test="getTime != null">hb_get_time,</if>
            <if test="createTime != null">hb_create_time,</if>
            <if test="updateTime != null">hb_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if>
            <if test="urank != null">#{urank,jdbcType=INTEGER},</if>
            <if test="parent != null">#{parent.id,jdbcType=BIGINT},</if>
            <if test="money != null">#{money,jdbcType=DECIMAL},</if>
            <if test="type != null">#{type,jdbcType=INTEGER},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="version != null">#{version,jdbcType=INTEGER},</if>
            <if test="beizhu != null">#{beizhu,jdbcType=VARCHAR},</if>
            <if test="preGetTime != null">#{preGetTime,jdbcType=TIMESTAMP},</if>
            <if test="getTime != null">#{getTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2">update
        yeshi_ec_hongbao_v2 set hb_uid =
        #{userInfo.id,jdbcType=BIGINT},hb_urank =
        #{urank,jdbcType=INTEGER},hb_pid =
        #{parent.id,jdbcType=BIGINT},hb_money =
        #{money,jdbcType=DECIMAL},hb_type = #{type,jdbcType=INTEGER},hb_state
        = #{state,jdbcType=INTEGER},hb_version =
        #{version,jdbcType=INTEGER},hb_beizhu =
        #{beizhu,jdbcType=VARCHAR},hb_pre_get_time =
        #{preGetTime,jdbcType=TIMESTAMP},hb_get_time =
        #{getTime,jdbcType=TIMESTAMP},hb_create_time =
        #{createTime,jdbcType=TIMESTAMP},hb_update_time =
        #{updateTime,jdbcType=TIMESTAMP} where hb_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
        update yeshi_ec_hongbao_v2
        <set>
            <if test="userInfo != null">hb_uid=#{userInfo.id,jdbcType=BIGINT},</if>
            <if test="urank != null">hb_urank=#{urank,jdbcType=INTEGER},</if>
            <if test="parent != null">hb_pid=#{parent.id,jdbcType=BIGINT},</if>
            <if test="money != null">hb_money=#{money,jdbcType=DECIMAL},</if>
            <if test="type != null">hb_type=#{type,jdbcType=INTEGER},</if>
            <if test="state != null">hb_state=#{state,jdbcType=INTEGER},</if>
            <if test="version != null">hb_version=#{version,jdbcType=INTEGER},</if>
            <if test="beizhu != null">hb_beizhu=#{beizhu,jdbcType=VARCHAR},</if>
            <if test="preGetTime != null">hb_pre_get_time=#{preGetTime,jdbcType=TIMESTAMP},</if>
            <if test="getTime != null">hb_get_time=#{getTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">hb_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">hb_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where hb_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
<?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.yeshi.fanli.dao.mybatis.HongBaoV2Mapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.HongBaoV2">
        <id column="hb_id" property="id" jdbcType="BIGINT" />
        <result column="hb_urank" property="urank" jdbcType="INTEGER" />
        <result column="hb_money" property="money" jdbcType="DECIMAL" />
        <result column="hb_type" property="type" jdbcType="INTEGER" />
        <result column="hb_state" property="state" jdbcType="INTEGER" />
        <result column="hb_version" property="version" jdbcType="INTEGER" />
        <result column="hb_beizhu" property="beizhu" jdbcType="VARCHAR" />
        <result column="hb_pre_get_time" property="preGetTime"
            jdbcType="TIMESTAMP" />
        <result column="hb_get_time" property="getTime" jdbcType="TIMESTAMP" />
        <result column="hb_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="hb_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <association property="userInfo" column="hb_uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="hb_uid" property="id" jdbcType="BIGINT" />
        </association>
        <association property="parent" column="hb_pid"
            javaType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
            <id column="hb_pid" property="id" jdbcType="BIGINT" />
        </association>
        <!-- <association property="userInfo" column="hb_uid" resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap"/> -->
    </resultMap>
    <resultMap id="BaseDTOResultMap" type="com.yeshi.fanli.dto.HongBaoDTO">
        <id column="hb_id" property="id" jdbcType="BIGINT" />
        <result column="hb_urank" property="urank" jdbcType="INTEGER" />
        <result column="hb_money" property="money" jdbcType="DECIMAL" />
        <result column="hb_type" property="type" jdbcType="INTEGER" />
        <result column="hb_state" property="state" jdbcType="INTEGER" />
        <result column="hb_version" property="version" jdbcType="INTEGER" />
        <result column="hb_beizhu" property="beizhu" jdbcType="VARCHAR" />
        <result column="hb_pre_get_time" property="preGetTime"
            jdbcType="TIMESTAMP" />
        <result column="hb_get_time" property="getTime" jdbcType="TIMESTAMP" />
        <result column="hb_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="hb_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="orderId" property="orderId" jdbcType="VARCHAR" />
        <result column="payMoney" property="payMoney" jdbcType="DECIMAL" />
        <result column="settlement" property="settlement" jdbcType="DECIMAL" />
        <association property="userInfo" column="hb_uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="hb_uid" property="id" jdbcType="BIGINT" />
        </association>
        <association property="parent" column="hb_pid"
            javaType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
            <id column="hb_pid" property="id" jdbcType="BIGINT" />
        </association>
    </resultMap>
    <sql id="Base_Column_List">hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT} for
        update
    </select>
    <select id="listChildrenById" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_hongbao_v2 where hb_pid = #{0}
    </select>
    <select id="listCanBalanceHongBaoByType" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        FROM yeshi_ec_hongbao_v2 h WHERE h.`hb_version`=2 AND
        h.`hb_type`=#{type} AND (h.`hb_state`=2) AND
        h.`hb_pre_get_time` IS NOT
        NULL AND h.`hb_pre_get_time`
        <![CDATA[ <]]>
        NOW() order by hb_pre_get_time desc limit #{count}
    </select>
    <!-- 获取用户奖金列表 -->
    <select id="listJiangJinByUid" resultMap="BaseDTOResultMap">
        SELECT
        hhh.*,co.`co_order_no` AS orderId,co.`co_payment` AS
        payMoney,co.`co_settlement` AS settlement FROM
        (
        SELECT
        hh.*,IF(h.`hb_id` IS NOT NULL,h.`hb_id`,hh.hb_id) AS hid FROM
        (
        SELECT
        h.* FROM yeshi_ec_hongbao_v2 h WHERE h.hb_uid=#{uid} and
        (h.`hb_type`=6 OR h.`hb_type`=7
        OR h.`hb_type`=20 OR h.`hb_type`=21 OR
        h.`hb_type`=22) AND
        h.`hb_version`=2 ORDER BY h.`hb_create_time` DESC
        limit #{start},#{count}
        ) hh
        LEFT JOIN yeshi_ec_hongbao_v2 h ON
        hh.hb_pid IS NOT NULL AND
        h.`hb_id`=hh.hb_pid
        ) hhh LEFT JOIN
        yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id`=hhh.hid
        LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
    </select>
    <!-- 获取用户奖金列表 -->
    <select id="countJiangJinByUid" resultType="java.lang.Long">
        SELECT count(h.hb_id)
        FROM yeshi_ec_hongbao_v2 h WHERE h.hb_uid=#{0} and (h.`hb_type`=6 OR
        h.`hb_type`=7
        OR h.`hb_type`=20 OR h.`hb_type`=21 OR h.`hb_type`=22)
        AND
        h.`hb_version`=2
    </select>
    <!-- 获取总的提成金额 -->
    <select id="getTotalTiChengMoney" resultType="java.math.BigDecimal"
        parameterType="java.lang.Long">
        SELECT IF(a.money IS NULL,0,a.money ) FROM (SELECT
        SUM(h.`hb_money`) AS money FROM `yeshi_ec_hongbao_v2` h WHERE
        h.`hb_uid`=#{0}
        AND h.`hb_state`=3 AND (h.`hb_type`=20 OR
        h.`hb_type`=21 OR h.`hb_type`=22 OR
        h.`hb_type`=6 OR h.`hb_type`=7)) a
    </select>
    <!-- 获取总的提成笔数 -->
    <select id="getTotalTiChengCount" resultType="java.lang.Integer"
        parameterType="java.lang.Long">
        SELECT
        count(*) FROM `yeshi_ec_hongbao_v2` h
        WHERE
        h.`hb_uid`=#{0} AND (h.`hb_type`=20 OR h.`hb_type`=21 OR
        h.`hb_type`=22 OR
        h.`hb_type`=6 OR h.`hb_type`=7)
    </select>
    <!-- 获取还未到账的提成金额 -->
    <select id="getUnGetTiChengMoney" resultType="java.math.BigDecimal"
        parameterType="java.lang.Long">
        SELECT IF(a.money IS NULL,0,a.money ) FROM (SELECT
        SUM(h.`hb_money`) AS money FROM `yeshi_ec_hongbao_v2` h WHERE
        h.`hb_uid`=#{0}
        AND (h.`hb_state`=1 OR h.hb_state=2 )AND
        (h.`hb_type`=20 OR h.`hb_type`=21 OR
        h.`hb_type`=22 OR h.`hb_type`=6 OR
        h.`hb_type`=7)) a
    </select>
    <select id="getTotalFanLiMoney" resultType="java.math.BigDecimal"
        parameterType="java.lang.Long">
        SELECT SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
        WHERE h.`hb_uid`=#{uid} AND h.`hb_type`=1 AND h.`hb_state`=3
    </select>
    <select id="getUnRecievedFanLiMoney" resultType="java.math.BigDecimal"
        parameterType="java.lang.Long">
        SELECT SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
        WHERE h.`hb_uid`=#{uid} AND h.`hb_type`=1 AND (h.`hb_state`=1 OR
        h.`hb_state`=2)
    </select>
    <select id="listUidCanBanlanceShareAndInvite" resultType="java.lang.Long"
        parameterType="java.lang.Integer">
        SELECT DISTINCT( h.`hb_uid`) FROM yeshi_ec_hongbao_v2 h
        WHERE
        (`hb_type`=6 OR
        `hb_type`=7 OR `hb_type`=20 OR `hb_type`=21 OR
        `hb_type`=22 ) AND
        `hb_version`=2 AND (hb_state=1 OR hb_state=2) AND
        hb_pre_get_time IS
        NOT NULL AND hb_pre_get_time>0 AND
        NOW()>=hb_pre_get_time limit #{0}
    </select>
    <select id="listCanBalanceHongBaoByTypeAndUid" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_hongbao_v2 where `hb_version`=2
        <if test="uid!=null">
            and hb_uid=#{uid}
        </if>
        <foreach collection="types" item="type" open=" and ("
            separator=" or " close=")">
            hb_type =
            #{type}
        </foreach>
        and
        (hb_state=1 or hb_state=2) and
        hb_pre_get_time IS NOT NULL AND
        hb_pre_get_time>0 AND
        NOW()>=hb_pre_get_time limit
        #{start},#{count}
    </select>
    <select id="countCanBalanceHongBaoByTypeAndUid" resultType="java.lang.Long">
        select
        count(hb_id)
        from yeshi_ec_hongbao_v2 where hb_uid=#{uid} and
        `hb_version`=2
        <foreach collection="types" item="type" open=" and ("
            separator=" or " close=")">
            hb_type =
            #{type}
        </foreach>
        and
        (hb_state=1 or hb_state=2) and
        hb_pre_get_time IS NOT NULL AND
        hb_pre_get_time>0 AND
        NOW()>=hb_pre_get_time
    </select>
    <select id="countInviteOrderCountByUidAndSettleTime" resultType="java.lang.Long">
        SELECT COUNT(h.hb_id) FROM yeshi_ec_hongbao_v2 h LEFT JOIN
        yeshi_ec_hongbao_order ho ON h.`hb_pid`=ho.`ho_hongbao_id` LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE
        h.`hb_uid`=#{uid} and (h.`hb_type`=6 or h.`hb_type`=7 OR
        h.`hb_type`=21 OR h.`hb_type`=22) and co.`co_state`=#{state} and
        co.`co_settle_time` is not null and co.`co_settle_time`>=#{minDate}
        and #{maxDate}>co.`co_settle_time`;
    </select>
    <select id="countShareOrderCountByUidAndSettleTime" resultType="java.lang.Long">
        SELECT COUNT(h.hb_id) FROM yeshi_ec_hongbao_v2 h LEFT JOIN
        yeshi_ec_hongbao_order ho ON h.`hb_id`=ho.`ho_hongbao_id` LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE
        h.`hb_uid`=#{uid} and h.`hb_type`=20 and co.`co_state`=#{state} and
        co.`co_settle_time` is not null and co.`co_settle_time`>=#{minDate}
        and #{maxDate}>co.`co_settle_time`;
    </select>
    <select id="getUnRecievedMoneyWithCreateTime" resultType="java.math.BigDecimal">
        SELECT
        SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
        WHERE h.`hb_uid`=#{uid}
        AND (h.`hb_state`=1 OR
        h.`hb_state`=2) and hb_create_time>=#{minDate}
        and #{maxDate} > hb_create_time
    </select>
    <select id="getUnRecievedMoneyWithPreGetTime" resultType="java.math.BigDecimal">
        SELECT
        SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
        WHERE h.`hb_uid`=#{uid}
        AND (h.`hb_state`=1 OR
        h.`hb_state`=2) and hb_pre_get_time is not null
        and hb_pre_get_time>=#{minDate}
        and #{maxDate} > hb_pre_get_time
    </select>
    <select id="countByUidAndState" resultType="java.lang.Long">
        SELECT
        SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
        WHERE h.`hb_uid`=#{uid}
        AND h.`hb_state`=#{state}
    </select>
    <select id="computeMoneyByUidAndState" resultType="java.math.BigDecimal">
        SELECT
        SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h
        WHERE
        h.`hb_uid`=#{uid}
        <if test="stateList!=null">
            <foreach collection="stateList" item="state" open=" and ("
                separator=" or " close=")">
                hb_state=#{state}
            </foreach>
        </if>
    </select>
    <select id="getUidByNear30DayShareSucceed" resultType="java.lang.Long">
        SELECT v2.`hb_uid` FROM yeshi_ec_hongbao_v2 v2
        WHERE v2.`hb_type` = 20
        AND v2.`hb_state`<![CDATA[<>]]>
        4
        AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <![CDATA[<=]]>DATE(v2.`hb_create_time`)
        GROUP BY v2.`hb_uid`
        ORDER BY v2.`hb_create_time`;
    </select>
    <select id="listByParentUidAndTypeAndState" resultMap="BaseResultMap">
        SELECT v.* FROM yeshi_ec_hongbao_v2 v LEFT JOIN yeshi_ec_hongbao_v2 p
        ON v.`hb_pid`=p.`hb_id` WHERE p.`hb_uid`=#{uid}
        <if test="typeList!=null">
            <foreach collection="typeList" item="type" open=" and ("
                separator=" or " close=")">
                v.hb_type=#{type}
            </foreach>
        </if>
        <if test="stateList!=null">
            <foreach collection="stateList" item="state" open=" and ("
                separator=" or " close=")">
                v.hb_state=#{state}
            </foreach>
        </if>
        limit #{start},#{count}
    </select>
    <select id="countByParentUidAndTypeAndState" resultType="java.lang.Long">
        SELECT count(v.hb_id) FROM yeshi_ec_hongbao_v2 v LEFT JOIN
        yeshi_ec_hongbao_v2 p
        ON v.`hb_pid`=p.`hb_id` WHERE p.`hb_uid`=#{uid}
        <if test="typeList!=null">
            <foreach collection="typeList" item="type" open=" and ("
                separator=" or " close=")">
                v.hb_type=#{type}
            </foreach>
        </if>
        <if test="stateList!=null">
            <foreach collection="stateList" item="state" open=" and ("
                separator=" or " close=")">
                v.hb_state=#{state}
            </foreach>
        </if>
    </select>
    <select id="listBySourceTypeAndTradeIdListAndUid" resultMap="BaseResultMap">
        SELECT a.* FROM
        (
            SELECT * FROM yeshi_ec_hongbao_v2 v WHERE v.`hb_uid`=#{uid}
        ) a
        LEFT JOIN
        (
        SELECT ho.`ho_hongbao_id` AS hbId FROM yeshi_ec_hongbao_order ho LEFT JOIN
        yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE
        co.`co_source_type`=#{sourceType}
        <if test="tradeIdList!=null">
            <foreach collection="tradeIdList" open=" and (" close=")"
                separator=" or " item="tradeId">
                co.co_trade_id=#{tradeId}
            </foreach>
        </if>
        )
        b
        ON a.hb_id=b.hbId OR a.hb_pid=b.hbId WHERE b.hbId >0
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_hongbao_v2 where hb_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_hongbao_v2
        (hb_id,hb_uid,hb_urank,hb_pid,hb_money,hb_type,hb_state,hb_version,hb_beizhu,hb_pre_get_time,hb_get_time,hb_create_time,hb_update_time)
        values
        (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{urank,jdbcType=INTEGER},#{parent.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{version,jdbcType=INTEGER},#{beizhu,jdbcType=VARCHAR},#{preGetTime,jdbcType=TIMESTAMP},#{getTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_hongbao_v2
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">hb_id,</if>
            <if test="userInfo != null">hb_uid,</if>
            <if test="urank != null">hb_urank,</if>
            <if test="parent != null">hb_pid,</if>
            <if test="money != null">hb_money,</if>
            <if test="type != null">hb_type,</if>
            <if test="state != null">hb_state,</if>
            <if test="version != null">hb_version,</if>
            <if test="beizhu != null">hb_beizhu,</if>
            <if test="preGetTime != null">hb_pre_get_time,</if>
            <if test="getTime != null">hb_get_time,</if>
            <if test="createTime != null">hb_create_time,</if>
            <if test="updateTime != null">hb_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if>
            <if test="urank != null">#{urank,jdbcType=INTEGER},</if>
            <if test="parent != null">#{parent.id,jdbcType=BIGINT},</if>
            <if test="money != null">#{money,jdbcType=DECIMAL},</if>
            <if test="type != null">#{type,jdbcType=INTEGER},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="version != null">#{version,jdbcType=INTEGER},</if>
            <if test="beizhu != null">#{beizhu,jdbcType=VARCHAR},</if>
            <if test="preGetTime != null">#{preGetTime,jdbcType=TIMESTAMP},</if>
            <if test="getTime != null">#{getTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2">update
        yeshi_ec_hongbao_v2 set hb_uid =
        #{userInfo.id,jdbcType=BIGINT},hb_urank =
        #{urank,jdbcType=INTEGER},hb_pid =
        #{parent.id,jdbcType=BIGINT},hb_money =
        #{money,jdbcType=DECIMAL},hb_type = #{type,jdbcType=INTEGER},hb_state
        = #{state,jdbcType=INTEGER},hb_version =
        #{version,jdbcType=INTEGER},hb_beizhu =
        #{beizhu,jdbcType=VARCHAR},hb_pre_get_time =
        #{preGetTime,jdbcType=TIMESTAMP},hb_get_time =
        #{getTime,jdbcType=TIMESTAMP},hb_create_time =
        #{createTime,jdbcType=TIMESTAMP},hb_update_time =
        #{updateTime,jdbcType=TIMESTAMP} where hb_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.HongBaoV2">
        update yeshi_ec_hongbao_v2
        <set>
            <if test="userInfo != null">hb_uid=#{userInfo.id,jdbcType=BIGINT},</if>
            <if test="urank != null">hb_urank=#{urank,jdbcType=INTEGER},</if>
            <if test="parent != null">hb_pid=#{parent.id,jdbcType=BIGINT},</if>
            <if test="money != null">hb_money=#{money,jdbcType=DECIMAL},</if>
            <if test="type != null">hb_type=#{type,jdbcType=INTEGER},</if>
            <if test="state != null">hb_state=#{state,jdbcType=INTEGER},</if>
            <if test="version != null">hb_version=#{version,jdbcType=INTEGER},</if>
            <if test="beizhu != null">hb_beizhu=#{beizhu,jdbcType=VARCHAR},</if>
            <if test="preGetTime != null">hb_pre_get_time=#{preGetTime,jdbcType=TIMESTAMP},</if>
            <if test="getTime != null">hb_get_time=#{getTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">hb_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">hb_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where hb_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/elme/ElmeHongBaoOrderMapServiceImpl.java
New file
@@ -0,0 +1,63 @@
package com.yeshi.fanli.service.impl.elme;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.yeshi.fanli.dao.mybatis.elme.ElmeHongBaoOrderMapMapper;
import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap;
import com.yeshi.fanli.exception.elme.ElmeHongBaoOrderMapException;
import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService;
/**
 * 饿了么红包订单映射
 *
 * @author Administrator
 *
 */
@Service
public class ElmeHongBaoOrderMapServiceImpl implements ElmeHongBaoOrderMapService {
    @Resource
    private ElmeHongBaoOrderMapMapper elmeHongBaoOrderMapMapper;
    @Transactional
    @Override
    public void addHongBaoOrderMap(ElmeHongBaoOrderMap map) throws ElmeHongBaoOrderMapException {
        if (map.getElmeOrder() == null || map.getElmeOrder().getId() == null || map.getHongBao() == null
                || map.getHongBao().getId() == null)
            throw new ElmeHongBaoOrderMapException(1, "信息不完整");
        ElmeHongBaoOrderMap oldMap = elmeHongBaoOrderMapMapper.selectByOrderId(map.getElmeOrder().getId());
        if (oldMap != null)
            throw new ElmeHongBaoOrderMapException(2, "订单ID已经添加过映射");
        oldMap = elmeHongBaoOrderMapMapper.selectByHongBaoId(map.getHongBao().getId());
        if (oldMap != null)
            throw new ElmeHongBaoOrderMapException(3, "红包ID已经添加过映射");
        elmeHongBaoOrderMapMapper.insertSelective(map);
    }
    @Override
    public ElmeHongBaoOrderMap selectByOrderId(Long orderId) {
        return elmeHongBaoOrderMapMapper.selectByOrderId(orderId);
    }
    @Override
    public ElmeHongBaoOrderMap selectByHongBaoId(Long hongBaoId) {
        return elmeHongBaoOrderMapMapper.selectByHongBaoId(hongBaoId);
    }
    @Override
    public List<ElmeHongBaoOrderMap> listByHongBaoUid(Long uid, int page, int pageSize) {
        return elmeHongBaoOrderMapMapper.listByHongBaoUid(uid, (page - 1) * pageSize, pageSize);
    }
    @Override
    public long countByHongBaoUid(Long uid) {
        return elmeHongBaoOrderMapMapper.countByHongBaoUid(uid);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/elme/ElmeOrderProcessServiceImpl.java
New file
@@ -0,0 +1,141 @@
package com.yeshi.fanli.service.impl.elme;
import java.math.BigDecimal;
import java.util.Date;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap;
import com.yeshi.fanli.entity.elme.ElmeOrder;
import com.yeshi.fanli.exception.elme.ElmeHongBaoOrderMapException;
import com.yeshi.fanli.exception.elme.ElmeOrderException;
import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService;
import com.yeshi.fanli.service.inter.elme.ElmeOrderProcessService;
import com.yeshi.fanli.service.inter.elme.ElmeOrderService;
import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.order.msg.UserOrderMsgNotificationService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.elme.ElmeOrderUtil;
@Service
public class ElmeOrderProcessServiceImpl implements ElmeOrderProcessService {
    @Resource
    private ElmeOrderService elmeOrderService;
    @Resource
    private ElmeHongBaoOrderMapService elmeHongBaoOrderMapService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Resource
    private UserOrderMsgNotificationService userOrderMsgNotificationService;
    @Transactional
    @Override
    public void processOrder(ElmeOrder elmeOrder) throws ElmeOrderException {
        try {
            elmeOrderService.addOrder(elmeOrder);
        } catch (ElmeOrderException e) {
            return;
        }
        if (elmeOrder.getId() == null)
            return;
        // 查询订单是否存在
        ElmeHongBaoOrderMap map = elmeHongBaoOrderMapService.selectByOrderId(elmeOrder.getId());
        if (map == null)// 订单不存在
        {
            String rid = elmeOrder.getRid();
            if (StringUtil.isNullOrEmpty(rid))
                return;
            // 查询映射用户
            UserInfo user = userInfoService.selectByPKey(Long.parseLong(rid));
            if (user == null)
                return;
            // 制造hongbao
            HongBaoV2 hongBao = createHongBao(elmeOrder, user);
            hongBao.setUpdateTime(new Date());
            hongBaoV2Service.insertSelective(hongBao);
            // 添加红包映射
            ElmeHongBaoOrderMap newMap = new ElmeHongBaoOrderMap();
            newMap.setCreateTime(new Date());
            newMap.setElmeOrder(elmeOrder);
            newMap.setHongBao(hongBao);
            try {
                elmeHongBaoOrderMapService.addHongBaoOrderMap(newMap);
            } catch (ElmeHongBaoOrderMapException e) {
                throw new ElmeOrderException(e.getCode(), e.getMsg());
            }
            // 发送消息
            userOrderMsgNotificationService.orderElmeStatistic(user.getId(), elmeOrder.getOrderId(),
                    Constant.SOURCE_TYPE_ELME, elmeOrder.getPayMoney(), hongBao.getMoney(), hongBao.getState());
        } else {// 订单存在
            HongBaoV2 oldHongBao = hongBaoV2Service.selectByPrimaryKey(map.getHongBao().getId());
            if (oldHongBao == null)
                return;
            // 失效与到账状态的红包不需要修改
            if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
                return;
            HongBaoV2 hongBao = createHongBao(elmeOrder, null);
            if (hongBao.getState() != oldHongBao.getState()) {// 是否需要修改红包状态
                HongBaoV2 update = new HongBaoV2(oldHongBao.getId());
                update.setState(hongBao.getState());
                update.setPreGetTime(hongBao.getPreGetTime());
                update.setUpdateTime(new Date());
                hongBaoV2Service.updateByPrimaryKeySelective(update);
                // 发送消息
                userOrderMsgNotificationService.orderElmeStateChanged(oldHongBao.getUserInfo().getId(),
                        elmeOrder.getOrderId(), Constant.SOURCE_TYPE_ELME, elmeOrder.getPayMoney(), hongBao.getMoney(),
                        hongBao.getState());
            }
        }
    }
    private HongBaoV2 createHongBao(ElmeOrder elmeOrder, UserInfo userInfo) {
        BigDecimal fanliRate = hongBaoManageService.getFanLiRate(elmeOrder.getOrderDate().getTime());
        HongBaoV2 hongBao = new HongBaoV2();
        hongBao.setCreateTime(new Date());
        hongBao.setGetTime(null);
        hongBao.setMoney(MoneyBigDecimalUtil.div(
                MoneyBigDecimalUtil.mul(ElmeOrderUtil.getCommission(elmeOrder.getPayMoney()), fanliRate),
                new BigDecimal(100)));
        if (elmeOrder.getIsSettle() == true)
            hongBao.setPreGetTime(new Date(elmeOrder.getOrderDate().getTime() + 1000 * 60 * 60 * 24 * 15L));
        if (elmeOrder.getPayMoney().compareTo(new BigDecimal(0)) <= 0)
            hongBao.setState(HongBaoV2.STATE_SHIXIAO);
        else {
            if (elmeOrder.getIsSettle() == true) {
                hongBao.setState(HongBaoV2.STATE_KELINGQU);
            } else {
                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
            }
        }
        hongBao.setType(HongBaoV2.TYPE_ELME);
        if (userInfo != null)
            hongBao.setUrank(userInfo.getRank());
        hongBao.setUserInfo(userInfo);
        hongBao.setVersion(2);
        return hongBao;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/elme/ElmeOrderServiceImpl.java
@@ -30,6 +30,7 @@
                order.setUpdateTime(new Date());
            elmeOrderMapper.insertSelective(order);
        } else {
            order.setId(oldOrder.getId());
            // 更新付款金额,计算状态
            ElmeOrder update = new ElmeOrder();
            update.setId(oldOrder.getId());
@@ -39,4 +40,9 @@
            elmeOrderMapper.updateByPrimaryKeySelective(update);
        }
    }
    @Override
    public ElmeOrder selectByPrimaryKey(Long id) {
        return elmeOrderMapper.selectByPrimaryKey(id);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/BindingAccountServiceImpl.java
@@ -40,6 +40,7 @@
import com.yeshi.fanli.service.inter.user.UserAccountBindingHistoryService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
import net.sf.json.JSONObject;
@@ -283,10 +284,8 @@
        }
        AlipayAccountValidNormalHistory latest = alipayAccountValidNormalHistoryMapper.selectLatestByUid(uid);
        if (latest != null) {
            Calendar caLatest = Calendar.getInstance();
            caLatest.setTimeInMillis(latest.getCreateTime().getTime());
            Calendar nowLatest = Calendar.getInstance();
            if (caLatest.get(Calendar.MONTH) == nowLatest.get(Calendar.MONTH))// 上次更改和现在是同一个月
            if (TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM")
                    .equalsIgnoreCase(TimeUtil.getGernalTime(latest.getCreateTime().getTime(), "yyyy-MM")))// 上次更改和现在是同一年同一个月
                throw new BindingAccountException(2, "每月仅可修改1次提现账号,请下月再试吧。");
        }
        return true;
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/UserMoneyMsgNotificationServiceImpl.java
@@ -275,4 +275,14 @@
        }
    }
    @Override
    public void elmeFanli(Long uid, String orderId, BigDecimal money, BigDecimal balance) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createElmeFanliMsg(uid, orderId, money, balance, null);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -31,6 +31,8 @@
import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap;
import com.yeshi.fanli.entity.elme.ElmeOrder;
import com.yeshi.fanli.entity.jd.JDOrder;
import com.yeshi.fanli.entity.jd.JDOrderItem;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
@@ -48,6 +50,8 @@
import com.yeshi.fanli.exception.order.OrderItemException;
import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService;
import com.yeshi.fanli.service.inter.elme.ElmeOrderService;
import com.yeshi.fanli.service.inter.hongbao.AccountDetailsHongBaoMapService;
import com.yeshi.fanli.service.inter.money.UserMoneyService;
import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
@@ -1490,7 +1494,70 @@
                }
        }
    }
    public void elmeFanli() {
    }
    // 饿了么订单
    @Resource
    private ElmeHongBaoOrderMapService elmeHongBaoOrderMapService;
    @Resource
    private ElmeOrderService elmeOrderService;
    /**
     * 获取饿了么可以返利的红包
     *
     * @return
     */
    @Override
    public List<HongBaoV2> getCanBalanceElmeFanliHongBao() {
        List<Integer> list = new ArrayList<>();
        list.add(HongBaoV2.TYPE_ELME);
        return hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(list, null, 0, 1000);
    }
    @Override
    @Transactional
    public void elmeFanli(Long hongBaoId) {
        // 查询详情
        HongBaoV2 hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBaoId);
        if (hongBao.getType() == HongBaoV2.TYPE_ELME && hongBao.getState() == HongBaoV2.STATE_KELINGQU
                && hongBao.getPreGetTime() != null && System.currentTimeMillis() > hongBao.getPreGetTime().getTime()) {// 可以到账了
            // 判断用户状态
            UserInfo user = userInfoMapper.selectByPrimaryKey(hongBao.getUserInfo().getId());
            if (user == null || user.getState() != UserInfo.STATE_NORMAL)
                return;
            ElmeHongBaoOrderMap map = elmeHongBaoOrderMapService.selectByHongBaoId(hongBaoId);
            if (map == null)
                return;
            ElmeOrder order = elmeOrderService.selectByPrimaryKey(map.getElmeOrder().getId());
            if (order == null)
                return;
            // 到账,加数据
            HongBaoV2 update = new HongBaoV2(hongBao.getId());
            update.setUpdateTime(new Date());
            update.setGetTime(new Date());
            update.setState(HongBaoV2.STATE_YILINGQU);
            hongBaoV2Mapper.updateByPrimaryKeySelective(update);
            // 增加资金
            UserMoneyDetail detail = null;
            try {
                detail = UserMoneyDetailFactory.createElmeFanLi(hongBao.getUserInfo().getId(), order.getOrderId(),
                        hongBao.getId(), hongBao.getMoney());
            } catch (UserMoneyDetailException e) {
                e.printStackTrace();
            }
            userMoneyService.addUserMoney(hongBao.getUserInfo().getId(), hongBao.getMoney(), detail);
            BigDecimal balance = userInfoMapper.selectByPrimaryKey(hongBao.getUserInfo().getId()).getMyHongBao();
            // 添加消息
            userMoneyMsgNotificationService.elmeFanli(hongBao.getUserInfo().getId(), order.getOrderId(),
                    hongBao.getMoney(), balance);
        }
        // 返利到账
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/order/msg/UserOrderMsgNotificationServiceImpl.java
@@ -202,4 +202,30 @@
        }
    }
    @Override
    public void orderElmeStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
            int orderState) {
        MsgOrderDetail detail = MsgOrderDetailFactory.createElmeOrder(uid, orderId, orderType, orderState, payMoney,
                money, null);
        try {
            msgOrderDetailService.addMsgOrderDetail(detail,
                    (payMoney == null || payMoney.compareTo(new BigDecimal(0)) <= 0) ? false : true);
        } catch (MsgOrderDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void orderElmeStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
            int orderState) {
        MsgOrderDetail detail = MsgOrderDetailFactory.createElmeOrder(uid, orderId, orderType, orderState, payMoney,
                money, null);
        // 暂时不推送
        try {
            msgOrderDetailService.updateMsgOrderDetail(detail, false);
        } catch (MsgOrderDetailException e) {
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java
@@ -1306,7 +1306,7 @@
            if (newUser != null) {
                throw new UserAccountException(4, "该微信号已被其他帐号绑定");
            }
        } else if (wxUnionId.equals(wxUnionIdExist)) {
        } else if (wxUnionId.equalsIgnoreCase(wxUnionIdExist)) {
            throw new UserAccountException(3, "微信帐号一致无需更换");
        }
fanli/src/main/java/com/yeshi/fanli/service/inter/elme/ElmeHongBaoOrderMapService.java
New file
@@ -0,0 +1,56 @@
package com.yeshi.fanli.service.inter.elme;
import java.util.List;
import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap;
import com.yeshi.fanli.exception.elme.ElmeHongBaoOrderMapException;
/**
 * 饿了么红包订单映射
 *
 * @author Administrator
 *
 */
public interface ElmeHongBaoOrderMapService {
    /**
     * 添加映射
     *
     * @param map
     */
    public void addHongBaoOrderMap(ElmeHongBaoOrderMap map) throws ElmeHongBaoOrderMapException;
    /**
     * 根据订单ID查询
     *
     * @param orderId
     * @return
     */
    public ElmeHongBaoOrderMap selectByOrderId(Long orderId);
    /**
     * 根据hongBaoId查询
     *
     * @param hongBaoId
     * @return
     */
    public ElmeHongBaoOrderMap selectByHongBaoId(Long hongBaoId);
    /**
     * 根据红包用户ID检索
     *
     * @param uid
     * @param page
     * @param pageSize
     * @return
     */
    public List<ElmeHongBaoOrderMap> listByHongBaoUid(Long uid, int page, int pageSize);
    /**
     * 根据红包用户ID计数
     *
     * @param uid
     * @return
     */
    public long countByHongBaoUid(Long uid);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/elme/ElmeOrderProcessService.java
New file
@@ -0,0 +1,13 @@
package com.yeshi.fanli.service.inter.elme;
import com.yeshi.fanli.entity.elme.ElmeOrder;
import com.yeshi.fanli.exception.elme.ElmeOrderException;
public interface ElmeOrderProcessService {
    /**
     * 处理订单
     *
     * @param elmeOrder
     */
    public void processOrder(ElmeOrder elmeOrder) throws ElmeOrderException;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/elme/ElmeOrderService.java
@@ -16,4 +16,7 @@
     * @param order
     */
    public void addOrder(ElmeOrder order) throws ElmeOrderException;
    public ElmeOrder selectByPrimaryKey(Long id);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/money/msg/UserMoneyMsgNotificationService.java
@@ -52,7 +52,8 @@
     * @param money
     * @param balance
     */
    public void fanliOrderReceived(Long uid, String orderId,int orderType, int goodsCount, BigDecimal money, BigDecimal balance);
    public void fanliOrderReceived(Long uid, String orderId, int orderType, int goodsCount, BigDecimal money,
            BigDecimal balance);
    /**
     * 返利订单维权
@@ -62,7 +63,7 @@
     * @param money
     * @param balance
     */
    public void fanliOrderWeiQuan(Long uid, String orderId,int orderType, BigDecimal money, BigDecimal balance);
    public void fanliOrderWeiQuan(Long uid, String orderId, int orderType, BigDecimal money, BigDecimal balance);
    /**
     * 分享赚订单被统计
@@ -73,7 +74,8 @@
     * @param money
     * @param balance
     */
    public void shareOrderReceived(Long uid,int orderType, int orderCount, int goodsCount, BigDecimal money, BigDecimal balance);
    public void shareOrderReceived(Long uid, int orderType, int orderCount, int goodsCount, BigDecimal money,
            BigDecimal balance);
    /**
     * 分享订单维权
@@ -84,7 +86,7 @@
     * @param balance
     */
    public void shareOrderWeiQuan(Long uid, String orderId,int orderType, BigDecimal money, BigDecimal balance);
    public void shareOrderWeiQuan(Long uid, String orderId, int orderType, BigDecimal money, BigDecimal balance);
    /**
     * 邀请赚订单被统计
@@ -95,7 +97,8 @@
     * @param money
     * @param balance
     */
    public void inviteOrderReceived(Long uid,int orderType, int orderCount, int goodsCount, BigDecimal money, BigDecimal balance);
    public void inviteOrderReceived(Long uid, int orderType, int orderCount, int goodsCount, BigDecimal money,
            BigDecimal balance);
    /**
     * 邀请订单维权
@@ -105,7 +108,7 @@
     * @param money
     * @param balance
     */
    public void inviteOrderWeiQuan(Long uid, String orderId,int orderType, BigDecimal money, BigDecimal balance);
    public void inviteOrderWeiQuan(Long uid, String orderId, int orderType, BigDecimal money, BigDecimal balance);
    /**
     * 奖励订单到账
@@ -115,7 +118,7 @@
     * @param money
     * @param balance
     */
    public void orderReward(Long uid, String orderId,int orderType, BigDecimal money, BigDecimal balance);
    public void orderReward(Long uid, String orderId, int orderType, BigDecimal money, BigDecimal balance);
    /**
     * 系统补齐
@@ -128,10 +131,24 @@
    public void systemEqualize(Long uid, String reason, BigDecimal money, BigDecimal balance);
    /**
     * 饿了么返利到账
     *
     * @param uid
     * @param orderId
     * @param money
     * @param balance
     */
    public void elmeFanli(Long uid, String orderId, BigDecimal money, BigDecimal balance);
    /*
     * 自动提现消息-微信
     *
     * @param extractRecord
     *
     * @param stateDesc
     *
     * @param desc
     *
     * @param beiZhu
     */
    public void extractAuto(ExtractWeiXinRecord extractRecord, String stateDesc, String desc, String beiZhu);
fanli/src/main/java/com/yeshi/fanli/service/inter/order/OrderProcessService.java
@@ -123,4 +123,15 @@
     */
    public void doTaoBaoSellerNotPaid(TaoBaoOrder order);
    /**
     * 获取可以返利的饿了么红包
     * @return
     */
    public List<HongBaoV2> getCanBalanceElmeFanliHongBao();
    /**
     * 饿了么返利
     * @param hongBaoId
     */
    public void elmeFanli(Long hongBaoId);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/order/msg/UserOrderMsgNotificationService.java
@@ -21,8 +21,8 @@
     * @param orderState
     */
    public void orderFanLiStatistic(Long uid, String orderId,int orderType, BigDecimal payMoney, BigDecimal money, int goodsCount,
            int orderState);
    public void orderFanLiStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
            int goodsCount, int orderState);
    /**
     * 返利订单状态改变
@@ -33,7 +33,8 @@
     * @param money
     * @param orderState
     */
    public void orderFanLiStateChanged(Long uid, String orderId,int orderType, BigDecimal payMoney, BigDecimal money, int orderState);
    public void orderFanLiStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
            int orderState);
    /**
     * 分享订单统计
@@ -45,8 +46,8 @@
     * @param goodsCount
     * @param orderState
     */
    public void orderShareStatistic(Long uid, String orderId,int orderType, BigDecimal payMoney, BigDecimal money, int goodsCount,
            int orderState);
    public void orderShareStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
            int goodsCount, int orderState);
    /**
     * 分享订单状态改变
@@ -57,7 +58,8 @@
     * @param money
     * @param orderState
     */
    public void orderShareStateChanged(Long uid, String orderId,int orderType, BigDecimal payMoney, BigDecimal money, int orderState);
    public void orderShareStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
            int orderState);
    /**
     * 邀请订单统计
@@ -69,8 +71,8 @@
     * @param goodsCount
     * @param orderState
     */
    public void orderInviteStatistic(Long uid, String orderId,int orderType, BigDecimal payMoney, BigDecimal money, int goodsCount,
            int orderState);
    public void orderInviteStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
            int goodsCount, int orderState);
    /**
     * 邀请订单状态改变
@@ -81,11 +83,11 @@
     * @param money
     * @param orderState
     */
    public void orderInviteStateChanged(Long uid, String orderId,int orderType, BigDecimal payMoney, BigDecimal money,
    public void orderInviteStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
            int orderState);
    public void orderShareFirstLevelStatistic(Long uid, String orderId,int orderType, BigDecimal payMoney, BigDecimal money,
            int goodsCount, int orderState, String sourceUserName);
    public void orderShareFirstLevelStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney,
            BigDecimal money, int goodsCount, int orderState, String sourceUserName);
    /**
     * 分享订单状态改变
@@ -96,8 +98,8 @@
     * @param money
     * @param orderState
     */
    public void orderShareFirstLevelStateChanged(Long uid, String orderId,int orderType, BigDecimal payMoney, BigDecimal money,
            int orderState);
    public void orderShareFirstLevelStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney,
            BigDecimal money, int orderState);
    /**
     * 订单找回成功
@@ -108,7 +110,7 @@
     * @param money
     * @param orderType
     */
    public void orderFoundSuccess(Long uid, String orderId, BigDecimal payMoney, int orderType,Date happendDate);
    public void orderFoundSuccess(Long uid, String orderId, BigDecimal payMoney, int orderType, Date happendDate);
    /**
     * 订单找回失败
@@ -117,8 +119,35 @@
     * @param orderId
     * @param payMoney
     * @param goodsCount
     * @param orderType 1-淘宝
     * @param orderType
     *            1-淘宝
     */
    public void orderFoundFail(Long uid, String orderId, BigDecimal payMoney, int orderType,Date happendDate);
    public void orderFoundFail(Long uid, String orderId, BigDecimal payMoney, int orderType, Date happendDate);
    /**
     * 饿了么订单统计
     *
     * @param uid
     * @param orderId
     * @param orderType
     * @param payMoney
     * @param money
     * @param orderState
     */
    public void orderElmeStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
            int orderState);
    /**
     * 饿了么订单状态改变
     *
     * @param uid
     * @param orderId
     * @param orderType
     * @param payMoney
     * @param money
     * @param orderState
     */
    public void orderElmeStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
            int orderState);
}
fanli/src/main/java/com/yeshi/fanli/util/Constant.java
@@ -101,6 +101,8 @@
    public static final int SOURCE_TYPE_WPH = 4;
    // 来源-苏宁
    public static final int SOURCE_TYPE_SUNING = 5;
    // 来源-饿了么
    public static final int SOURCE_TYPE_ELME = 6;
    // 自购-返利
    public static final int TYPE_REBATE = 1;
@@ -254,6 +256,8 @@
            return "唯品会";
        case SOURCE_TYPE_SUNING:
            return "苏宁";
        case SOURCE_TYPE_ELME:
            return "饿了么";
        default:// 其他类型
            return "";
        }
fanli/src/main/java/com/yeshi/fanli/util/elme/ElmeOrderUtil.java
@@ -1,9 +1,17 @@
package com.yeshi.fanli.util.elme;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.yeshi.fanli.entity.elme.ElmeOrder;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.TimeUtil;
import jxl.Sheet;
import jxl.Workbook;
public class ElmeOrderUtil {
@@ -14,12 +22,76 @@
     * @return
     */
    public static List<ElmeOrder> parseOrder(InputStream input) {
        List<ElmeOrder> list = new ArrayList<>();
        try {
            jxl.Workbook rwb = Workbook.getWorkbook(input);
            Sheet sheet = rwb.getSheet(0);
            for (int r = 1; r < sheet.getRows(); r++) {
                ElmeOrder order = new ElmeOrder();
                for (int c = 0; c < sheet.getColumns(); c++) {
                    String content = sheet.getCell(c, r).getContents();
                    String columnName = sheet.getCell(c, 0).getContents().trim();
                    switch (columnName) {
                    case "渠道号":
                        order.setChannelId(content);
                        break;
                    case "渠道名称":
                        order.setChannelName(content);
                        break;
                    case "track_pid":
                        order.setTrackPid(content);
                        break;
                    case "rid":
                        order.setRid(content);
                        break;
                    case "订单日期":
                        order.setOrderDate(new Date(TimeUtil.convertToTimeTemp(content, "yyyy-MM-dd")));
                        break;
                    case "订单号":
                        order.setOrderId(content.replace("<", "").replace(">", ""));
                        break;
                    case "支付金额":
                        order.setPayMoney(new BigDecimal(content));
                        break;
                    case "下单城市":
                        order.setCity(content);
                        break;
                    case "用券金额":
                        order.setCouponMoney(new BigDecimal(content));
                        break;
                    case "是否新客首单":
                        order.setNewerFirstOrder(Integer.parseInt(content));
                        break;
                    case "是否新客复购单":
                        order.setNewerRepayOrder(Integer.parseInt(content));
                        break;
                    case "是否使用淘客红包":
                        order.setTaokeHongBao(Integer.parseInt(content));
                        break;
                    case "是否有在会场内该门店的点击记录":
                        order.setShopClick(Integer.parseInt(content));
                        break;
                    case "是否领券后7天内首单":
                        order.setRecieveCoupon7DayFirstOrder(Integer.parseInt(content));
                        break;
                    case "是否6结佣":
                        if ("是".equalsIgnoreCase(content))
                            order.setIsSettle(true);
                        else
                            order.setIsSettle(false);
                        break;
                    }
                }
                list.add(order);
            }
            rwb.close();
        } catch (Exception e) {
        }
        return list;
    }
        return null;
    public static BigDecimal getCommission(BigDecimal payMoney) {
        return MoneyBigDecimalUtil.mul(payMoney, new BigDecimal("0.06"));
    }
}
fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java
@@ -52,6 +52,41 @@
    }
    /**
     * 饿了么返利
     *
     * @param uid
     * @param orderId
     * @param hbId
     * @param money
     * @return
     * @throws UserMoneyDetailException
     */
    public static UserMoneyDetail createElmeFanLi(Long uid, String orderId, Long hbId, BigDecimal money)
            throws UserMoneyDetailException {
        if (StringUtil.isNullOrEmpty(orderId))
            throw new UserMoneyDetailException(1, "订单号为空");
        if (money == null)
            throw new UserMoneyDetailException(1, "返利金额为空");
        if (uid == null)
            throw new UserMoneyDetailException(1, "UID为空");
        UserMoneyDetail detail = new UserMoneyDetail();
        detail.setCreateTime(new Date());
        detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.elmeFanli.name() + "-" + hbId));
        detail.setMoney(money);
        detail.setTitle(UserMoneyDetailTypeEnum.elmeFanli.getDesc());
        detail.setType(UserMoneyDetailTypeEnum.elmeFanli);
        detail.setDescInfo("订单号:" + orderId);
        detail.setUpdateTime(new Date());
        detail.setUserInfo(new UserInfo(uid));
        detail.setOrderType(Constant.SOURCE_TYPE_ELME);
        return detail;
    }
    /**
     * 分享奖金到账
     * 
     * @param uid
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgMoneyDetailFactory.java
@@ -345,5 +345,23 @@
        detail.setUser(new UserInfo(uid));
        return detail;
    }
    public static MsgMoneyDetail createElmeFanliMsg(Long uid, String orderId, BigDecimal money, BigDecimal balance,
            String beiZhu) {
        if (money == null || money == null || uid == null)
            return null;
        MsgMoneyDetail detail = new MsgMoneyDetail();
        detail.setBalance(balance);
        detail.setBeiZhu(beiZhu);
        detail.setCreateTime(new Date());
        detail.setMoney(money);
        detail.setMsgType(MsgTypeMoneyTypeEnum.fanliElme);
        detail.setOrderId(orderId);
        detail.setRead(false);
        detail.setUser(new UserInfo(uid));
        return detail;
    }
}
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgOrderDetailFactory.java
@@ -134,5 +134,35 @@
        detail.setHappendDate(happendDate);
        return detail;
    }
    /**
     * 饿了么订单消息
     * @param uid
     * @param orderId
     * @param orderType
     * @param orderState
     * @param payMoney
     * @param money
     * @param beiZhu
     * @return
     */
    public static MsgOrderDetail createElmeOrder(Long uid, String orderId, int orderType,
            int orderState, BigDecimal payMoney, BigDecimal money, String beiZhu) {
        if (uid == null)
            return null;
        MsgOrderDetail detail = new MsgOrderDetail();
        detail.setBeiZhu(beiZhu);
        detail.setCreateTime(new Date());
        detail.setHongBaoMoney(money);
        detail.setOrderId(orderId);
        detail.setOrderType(orderType);
        detail.setPayMoney(payMoney);
        detail.setRead(false);
        detail.setState(orderState);
        detail.setType(MsgTypeOrderTypeEnum.elme);
        detail.setUser(new UserInfo(uid));
        return detail;
    }
}
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java
@@ -26,6 +26,7 @@
import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail.MsgTypeOtherTypeEnum;
import com.yeshi.fanli.entity.bus.user.BindingAccount;
import com.yeshi.fanli.entity.bus.user.Extract;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.util.Constant;
@@ -66,7 +67,6 @@
        List<CommonMsgItemVO> items = new ArrayList<>();
        List<ClientTextStyleVO> contentList = new ArrayList<>();
        if (msg.getType() == MsgTypeOrderTypeEnum.found) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(Constant.getSourceName(msg.getOrderType()), COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("渠道来源", COLOR_TITLE), contentList));
@@ -93,8 +93,43 @@
                    COLOR_HIGHLIGHT_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("找回金额", COLOR_TITLE), contentList));
        } else {
        } else if (msg.getType() == MsgTypeOrderTypeEnum.elme) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(Constant.getSourceName(msg.getOrderType()), COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("渠道来源", COLOR_TITLE), contentList));
            String orderId = msg.getOrderId();
            MsgTypeOrderTypeEnum type = msg.getType();
            if (type == MsgTypeOrderTypeEnum.invite || type == MsgTypeOrderTypeEnum.share) {
                orderId = UserUtil.filterOrderId(orderId);
            }
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(orderId, COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("订单号", COLOR_TITLE), contentList, false));
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(msg.getType().getDesc(), COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("订单类型", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            if (msg.getState() == HongBaoV2.STATE_BUKELINGQU||msg.getState() == HongBaoV2.STATE_KELINGQU)
                contentList.add(new ClientTextStyleVO("已付款", COLOR_HIGHLIGHT_CONTENT));
            else if (msg.getState() == HongBaoV2.STATE_SHIXIAO)
                contentList.add(new ClientTextStyleVO("未付款/已退款", COLOR_HIGHLIGHT_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("订单状态", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO("¥" + filterMoney(msg.getPayMoney()), COLOR_HIGHLIGHT_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("付款金额", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO("¥" + filterMoney(msg.getHongBaoMoney()), COLOR_HIGHLIGHT_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("返利金额", COLOR_TITLE), contentList));
            if (params != null)
                vo.setParams(params.toString());
        } else {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(Constant.getSourceName(msg.getOrderType()), COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("渠道来源", COLOR_TITLE), contentList));
@@ -287,6 +322,33 @@
            return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_msg_fanli.png", "返利到账",
                    msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(), items);
        } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.fanliElme) {
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO("饿了么", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("渠道来源", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            // 返利到账
            contentList.add(new ClientTextStyleVO(msg.getOrderId(), COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("订单号", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO("¥" + filterMoney(msg.getMoney()) + "", COLOR_HIGHLIGHT_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("返利金额", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO("¥" + filterMoney(msg.getBalance()) + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("账户余额", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu(),
                    COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
            return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_msg_fanli.png", "返利到账",
                    msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(), items);
        } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.invite || msg.getMsgType() == MsgTypeMoneyTypeEnum.share) {
            contentList = new ArrayList<>();
fanli/src/main/java/com/yeshi/fanli/vo/elme/ElmeUserOrderVO.java
New file
@@ -0,0 +1,94 @@
package com.yeshi.fanli.vo.elme;
import java.math.BigDecimal;
/**
 * 饿了么前端输出订单
 *
 * @author Administrator
 *
 */
public class ElmeUserOrderVO {
    private Long id;
    private String orderState;// 订单状态
    private String hongBaoState;// 红包状态
    private String orderId;// 订单号
    private String payMoney;// 支付金额
    private String orderTime;// 订单时间
    private String createTime;// 创建时间
    private String preGetTime;// 预计领取时间
    private BigDecimal money;// 返利金额
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getOrderState() {
        return orderState;
    }
    public void setOrderState(String orderState) {
        this.orderState = orderState;
    }
    public String getHongBaoState() {
        return hongBaoState;
    }
    public void setHongBaoState(String hongBaoState) {
        this.hongBaoState = hongBaoState;
    }
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    public String getPayMoney() {
        return payMoney;
    }
    public void setPayMoney(String payMoney) {
        this.payMoney = payMoney;
    }
    public String getOrderTime() {
        return orderTime;
    }
    public void setOrderTime(String orderTime) {
        this.orderTime = orderTime;
    }
    public String getCreateTime() {
        return createTime;
    }
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
    public String getPreGetTime() {
        return preGetTime;
    }
    public void setPreGetTime(String preGetTime) {
        this.preGetTime = preGetTime;
    }
    public BigDecimal getMoney() {
        return money;
    }
    public void setMoney(BigDecimal money) {
        this.money = money;
    }
}