yujian
2019-10-31 2a3e411612bf75b81a8789127a714b5c5e28bc43
红包获得
17个文件已修改
7个文件已添加
926 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackWinInviteMapper.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/msg/MsgRedPackAddContentDTO.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgMoneyDetail.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackDetail.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackWinInvite.java 137 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/BrandInfoJob.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackWinInviteMapper.xml 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandShopCaheServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/MsgMoneyDetailServiceImpl.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java 233 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackWinInviteService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/Constant.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/mybatishandler/redpack/RedPackWinInviteTypeEnumHandler.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/src/main/java/org/yeshi/utils/DateUtil.java 102 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java
@@ -355,6 +355,12 @@
    @RequestMapping("getSpikTime")
    public void getSpikTime(AcceptData acceptData, PrintWriter out) {
        List<SpikeTimeVO> list = new ArrayList<SpikeTimeVO>();
        SpikeTimeVO spikeTime0 = new SpikeTimeVO();
        spikeTime0.setTime("00:00");
        spikeTime0.setState("进行中");
        spikeTime0.setRequestTime("2400");
        SpikeTimeVO spikeTime1 = new SpikeTimeVO();
        spikeTime1.setTime("08:00");
        spikeTime1.setState("进行中");
@@ -376,10 +382,37 @@
        spikeTime4.setState("即将开始");
        spikeTime4.setRequestTime("2415");
        
        SpikeTimeVO spikeTime5 = new SpikeTimeVO();
        spikeTime5.setTime("17:00");
        spikeTime5.setState("即将开始");
        spikeTime5.setRequestTime("2417");
        SpikeTimeVO spikeTime6 = new SpikeTimeVO();
        spikeTime6.setTime("19:00");
        spikeTime6.setState("即将开始");
        spikeTime6.setRequestTime("2419");
        SpikeTimeVO spikeTime7 = new SpikeTimeVO();
        spikeTime7.setTime("20:00");
        spikeTime7.setState("即将开始");
        spikeTime7.setRequestTime("2420");
        SpikeTimeVO spikeTime8 = new SpikeTimeVO();
        spikeTime8.setTime("21:00");
        spikeTime8.setState("即将开始");
        spikeTime8.setRequestTime("2421");
        list.add(spikeTime0);
        list.add(spikeTime1);
        list.add(spikeTime2);
        list.add(spikeTime3);
        list.add(spikeTime4);
        list.add(spikeTime5);
        list.add(spikeTime6);
        list.add(spikeTime7);
        list.add(spikeTime8);
        
        JSONObject data = new JSONObject();
        data.put("count", list.size());
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java
@@ -300,4 +300,14 @@
     */
    List<CommonOrder> listByUid(@Param("uid")Long uid,@Param("stateList") List<Integer> stateList,@Param("start") long start,@Param("count") int count);
    /**
     * 查询首笔有效到账订单
     * @param uid
     * @param type 类型: 1自购  2分享 3邀请
     * @return
     */
    CommonOrderVO firstValidOrderByUid(@Param("uid") Long uid, @Param("typeHB") Integer typeHB,
            @Param("typeDate") Integer typeDate);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackWinInviteMapper.java
New file
@@ -0,0 +1,17 @@
package com.yeshi.fanli.dao.mybatis.redpack;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.redpack.RedPackWinInvite;
public interface RedPackWinInviteMapper extends BaseMapper<RedPackWinInvite> {
    /**
     * 统计用户类型的数量
     * @param uid
     * @param type
     * @return
     */
    long countByUidAndType(@Param("uid")Long uid, @Param("type")String type);
}
fanli/src/main/java/com/yeshi/fanli/dto/msg/MsgRedPackAddContentDTO.java
New file
@@ -0,0 +1,37 @@
package com.yeshi.fanli.dto.msg;
/**
 * 红包增加相关消息
 *
 * @author Administrator
 *
 */
public class MsgRedPackAddContentDTO {
    private String title; // 标题
    private String money; // 金额
    private String balance; // 余额
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getMoney() {
        return money;
    }
    public void setMoney(String money) {
        this.money = money;
    }
    public String getBalance() {
        return balance;
    }
    public void setBalance(String balance) {
        this.balance = balance;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgMoneyDetail.java
@@ -35,7 +35,11 @@
        redPackGiveOff("赠送红包完成"),
        redPackReceiveOff("赠送红包领取"),
        redPackExchangePass("红包提现成功"),
        redPackExchangeReject("红包提现失败");
        redPackExchangeReject("红包提现失败"),
        redPackNewUserReward("新人奖励-完成首笔订单"),
        redPackInviteSucceed("立得现金-成功邀请好友"),
        redPackFirstSharedOrder("递增奖励-好友完成订单"),
        redPackMonthSharedOrder("连续奖励-好友完成订单");
        private final String desc;
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackDetail.java
@@ -17,8 +17,8 @@
@Table("yeshi_red_pack_detail")
public class RedPackDetail {
    public enum RedPackDetailTypeEnum {
        invite("立得现金", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        newUserReward("新人奖励", "http://img.flqapp.com/img/tlj/icon_tlj.png"), 
        invite("立得现金", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        increaseReward("递增奖励", "http://img.flqapp.com/img/tlj/icon_tlj.png"), 
        seriesReward("连续奖励", "http://img.flqapp.com/img/tlj/icon_tlj.png"), 
        refund("红包退回", "http://img.flqapp.com/img/tlj/icon_tlj.png"), 
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackWinInvite.java
New file
@@ -0,0 +1,137 @@
package com.yeshi.fanli.entity.redpack;
import java.math.BigDecimal;
import java.util.Date;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
/**
 * 红包获得记录-邀请相关
 *
 * @author Administrator
 *
 */
@Table("yeshi_red_pack_win_invite")
public class RedPackWinInvite {
    public enum RedPackWinInviteTypeEnum {
        newUserReward("首次使用板栗快省新人奖励"),
        inviteSucceed("成功邀请好友立得现金"),
        firstSharedOrder("完成分享订单递增奖励"),
        monthSharedOrder("完成分享订单连续奖励");
        private final String desc;
        private RedPackWinInviteTypeEnum(String desc) {
            this.desc = desc;
        }
        public String getDesc() {
            return desc;
        }
    }
    @Column(name = "rwr_id")
    private Long id;
    // 用户id
    @Column(name = "rwr_uid")
    private Long uid;
    // 队员id
    @Column(name = "rwr_team_uid")
    private Long teamUid;
    // 余额
    @Column(name = "rwr_money")
    private BigDecimal money;
    // 类型
    @Column(name = "rwr_type")
    private RedPackWinInviteTypeEnum type;
    // 订单来源
    @Column(name = "rwr_source")
    private Integer source;
    // 订单号
    @Column(name = "rwr_order_no")
    private String orderNo;
    @Column(name = "rwr_create_time")
    private Date createTime;
    @Column(name = "rwr_update_time")
    private Date updateTime;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getUid() {
        return uid;
    }
    public void setUid(Long uid) {
        this.uid = uid;
    }
    public Long getTeamUid() {
        return teamUid;
    }
    public void setTeamUid(Long teamUid) {
        this.teamUid = teamUid;
    }
    public BigDecimal getMoney() {
        return money;
    }
    public void setMoney(BigDecimal money) {
        this.money = money;
    }
    public RedPackWinInviteTypeEnum getType() {
        return type;
    }
    public void setType(RedPackWinInviteTypeEnum type) {
        this.type = type;
    }
    public Integer getSource() {
        return source;
    }
    public void setSource(Integer source) {
        this.source = source;
    }
    public String getOrderNo() {
        return orderNo;
    }
    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/job/BrandInfoJob.java
@@ -43,7 +43,7 @@
    /**
     * 清理前一天的
     */
//    @Scheduled(cron = "0 10 0 * * ? ")
//    @Scheduled(cron = "0 30 0 * * ? ")
    public void removeAgoByDate() {
        if (!Constant.IS_TASK)
            return;
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
@@ -972,6 +972,26 @@
        limit #{start},#{count}
    </select>
    <select id="firstValidOrderByUid"  resultMap="ResultMap">
        SELECT co.*,v2.`hb_get_time` AS accountTime FROM yeshi_ec_hongbao_order ho
        LEFT JOIN yeshi_ec_hongbao_v2 v2 ON IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        WHERE v2.hb_id IS NOT NULL AND v2.`hb_uid` = #{uid} AND v2.`hb_state` = 3
            <if test="typeHB == 1"> <!-- 自购订单 -->
                AND (v2.hb_type =1 or v2.hb_type =2)
            </if>
            <if test="typeHB == 2"> <!-- 分享订单 -->
                AND v2.`hb_type` = 20
            </if>
            <if test="typeHB == 3">  <!-- 邀请订单 -->
                AND (v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 OR
                v2.`hb_type` = 21 OR v2.`hb_type` = 22)
            </if>
            <if test="typeDate == 3"> <!-- 本月 -->
                AND DATE_FORMAT(v2.`hb_get_time`,'%Y%m') =    DATE_FORMAT(CURDATE(),'%Y%m')
            </if>
        ORDER BY co.`co_id`
        LIMIT 1
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackWinInviteMapper.xml
New file
@@ -0,0 +1,65 @@
<?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.redpack.RedPackWinInviteMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackWinInvite">
    <id column="rwr_id" property="id" jdbcType="BIGINT"/>
    <result column="rwr_uid" property="uid" jdbcType="BIGINT"/>
    <result column="rwr_team_uid" property="teamUid" jdbcType="BIGINT"/>
    <result column="rwr_money" property="money" jdbcType="DECIMAL"/>
    <result column="rwr_source" property="source" jdbcType="INTEGER"/>
    <result column="rwr_order_no" property="orderNo" jdbcType="VARCHAR"/>
    <result column="rwr_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="rwr_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <result column="rwr_type" property="type" typeHandler="com.yeshi.fanli.util.mybatishandler.redpack.RedPackWinInviteTypeEnumHandler"/>
  </resultMap>
  <sql id="Base_Column_List">rwr_id,rwr_uid,rwr_team_uid,rwr_money,rwr_type,rwr_source,rwr_order_no,rwr_create_time,rwr_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_red_pack_win_invite where rwr_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_win_invite where rwr_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackWinInvite" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_win_invite (rwr_id,rwr_uid,rwr_team_uid,rwr_money,rwr_type,rwr_source,rwr_order_no,rwr_create_time,rwr_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{teamUid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=VARCHAR},#{source,jdbcType=INTEGER},#{orderNo,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackWinInvite" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_win_invite
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rwr_id,</if>
      <if test="uid != null">rwr_uid,</if>
      <if test="teamUid != null">rwr_team_uid,</if>
      <if test="money != null">rwr_money,</if>
      <if test="type != null">rwr_type,</if>
      <if test="source != null">rwr_source,</if>
      <if test="orderNo != null">rwr_order_no,</if>
      <if test="createTime != null">rwr_create_time,</if>
      <if test="updateTime != null">rwr_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
      <if test="teamUid != null">#{teamUid,jdbcType=BIGINT},</if>
      <if test="money != null">#{money,jdbcType=DECIMAL},</if>
      <if test="type != null">#{type,jdbcType=VARCHAR},</if>
      <if test="source != null">#{source,jdbcType=INTEGER},</if>
      <if test="orderNo != null">#{orderNo,jdbcType=VARCHAR},</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.redpack.RedPackWinInvite">update yeshi_red_pack_win_invite set rwr_uid = #{uid,jdbcType=BIGINT},rwr_team_uid = #{teamUid,jdbcType=BIGINT},rwr_money = #{money,jdbcType=DECIMAL},rwr_type = #{type,jdbcType=VARCHAR},rwr_source = #{source,jdbcType=INTEGER},rwr_order_no = #{orderNo,jdbcType=VARCHAR},rwr_create_time = #{createTime,jdbcType=TIMESTAMP},rwr_update_time = #{updateTime,jdbcType=TIMESTAMP} where rwr_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackWinInvite">update yeshi_red_pack_win_invite
    <set>
      <if test="uid != null">rwr_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="teamUid != null">rwr_team_uid=#{teamUid,jdbcType=BIGINT},</if>
      <if test="money != null">rwr_money=#{money,jdbcType=DECIMAL},</if>
      <if test="type != null">rwr_type=#{type,jdbcType=VARCHAR},</if>
      <if test="source != null">rwr_source=#{source,jdbcType=INTEGER},</if>
      <if test="orderNo != null">rwr_order_no=#{orderNo,jdbcType=VARCHAR},</if>
      <if test="createTime != null">rwr_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">rwr_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where rwr_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="countByUidAndType" resultType="Long">
      SELECT IFNULL(COUNT(d.`rwr_id`),0) FROM yeshi_red_pack_win_invite d
    WHERE d.`rwr_uid` = #{uid} AND d.`rwr_type` = #{type}
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java
@@ -141,6 +141,8 @@
        // 删除店铺
        brandShopCaheService.removeByDateAndType(brandInfo.getId(), 20, date);
        
        boolean addShop = true;
        for (int i=0; i < 2;i ++) {
            if ("1".equals(way)) {
                JDFilter filterAPI = new JDFilter();
@@ -162,7 +164,6 @@
            }
            
            if (result != null && result.getGoodsList() != null && result.getGoodsList().size() > 0) {
                boolean addShop = true;
                List<JDGoods> goodsList = result.getGoodsList();
                for (JDGoods goods : goodsList) {
                    BrandGoodsCahe brandGoods = new BrandGoodsCahe();
@@ -178,8 +179,8 @@
                        // 包含该品牌名称
                        String shopName = shopInfo.getShopName();
                        if (!StringUtil.isNullOrEmpty(shopName) && shopName.contains(brandInfo.getName())) {
                            brandShopCaheService.addBrandShopJD(brandInfo, shopInfo);
                            addShop = false;
                            brandShopCaheService.addBrandShopJD(brandInfo, shopInfo);
                        }
                    }
                    
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java
@@ -255,8 +255,35 @@
        
        // 删除店铺
        brandShopCaheService.removeAgoByDate(date);
        long count = brandInfoMapper.countValidByCid(null);
        if (count == 0)
            return;
        for (int page = 1; page < (count / 100) + 1; page++) {
            updateTotalGoods((page - 1) * 100, 100);
        }
    }
    /**
     * 更新商品数量
     * @param start
     * @param count
     */
    private void updateTotalGoods(long start, int count) {
        List<BrandInfo> list = brandInfoMapper.listValidAll(start, count);
        if (list == null || list.size() == 0)
            return;
        for (BrandInfo brandInfo : list) {
            long goodsTotal = brandGoodsCaheService.countByBrandId(brandInfo.getId());
            BrandInfo updateInfo = new BrandInfo();
            updateInfo.setId(brandInfo.getId());
            updateInfo.setGoodsTotal((int)goodsTotal);
            brandInfoMapper.updateByPrimaryKeySelective(updateInfo);
        }
    }
    
    
    @Override
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandShopCaheServiceImpl.java
@@ -62,11 +62,12 @@
    public void addBrandShopJD(BrandInfo brandInfo, JDShopInfo shopInfo) {
        ShopInfoVO shopInfoVO = ShopInfoVOFactory.convertJDShop(shopInfo);
        shopInfoVO.setShopIcon(brandInfo.getIcon());
        BrandShopCahe brandShop = new BrandShopCahe();
        brandShop.setBrandId(brandInfo.getId());
        brandShop.setShop(shopInfoVO);
        brandShop.setCreateTime(new Date());
        brandShopCaheDao.save(brandShop);
        brandShopCaheDao.insert(brandShop);
    }
    
    
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/MsgMoneyDetailServiceImpl.java
@@ -128,7 +128,11 @@
            }
        } else if (detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackGiveOff
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackExchangePass
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackExchangeReject) {
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackExchangeReject
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackNewUserReward
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackInviteSucceed
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackFirstSharedOrder
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackMonthSharedOrder) {
            if (detail.getUser() == null)
                throw new MsgMoneyDetailException(2, "消息信息不全");
            detail.setCreateTime(new Date());
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -1573,4 +1573,23 @@
        return commonOrderList.get(0);
    }
    @Override
    public CommonOrderVO firstValidOrderByUid(Long uid) {
        return commonOrderMapper.firstValidOrderByUid(uid, null, null);
    }
    @Override
    public CommonOrderVO firstValidOrderByUidAndType(Long uid, Integer type) {
        return commonOrderMapper.firstValidOrderByUid(uid, type, null);
    }
    @Override
    public CommonOrderVO firstValidOrderTheMonthByUidAndType(Long uid, Integer type) {
        return commonOrderMapper.firstValidOrderByUid(uid, type, 3);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java
@@ -32,13 +32,13 @@
    @Override
    public BigDecimal getBalance(Long uid) {
        if (uid == null || uid == 0)
            return null;
            return new BigDecimal(0);
        
        RedPackBalance redPackBalance = redPackBalanceMapper.selectByPrimaryKey(uid);
        if (redPackBalance != null)
            return redPackBalance.getMoney();
        
        return null;
        return new BigDecimal(0);
    }
    
    
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java
@@ -7,7 +7,6 @@
import javax.annotation.Resource;
import org.omg.CORBA.LongHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
New file
@@ -0,0 +1,233 @@
package com.yeshi.fanli.service.impl.redpack;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yeshi.utils.DateUtil;
import com.google.gson.Gson;
import com.yeshi.fanli.dao.mybatis.redpack.RedPackWinInviteMapper;
import com.yeshi.fanli.dto.msg.MsgRedPackAddContentDTO;
import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.redpack.RedPackWinInvite;
import com.yeshi.fanli.entity.redpack.RedPackWinInvite.RedPackWinInviteTypeEnum;
import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
import com.yeshi.fanli.service.inter.order.CommonOrderService;
import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
import com.yeshi.fanli.service.inter.redpack.RedPackWinInviteService;
import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.factory.RedPackDetailFactory;
import com.yeshi.fanli.vo.order.CommonOrderVO;
@Service
public class RedPackWinInviteServiceImpl implements RedPackWinInviteService {
    @Resource
    private RedPackWinInviteMapper redPackWinInviteMapper;
    @Resource
    private RedPackConfigService redPackConfigService;
    @Resource
    private RedPackBalanceService redPackBalanceService;
    @Resource
    private CommonOrderService  commonOrderService;
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
    @Resource
    private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void orderArriveReward(Long uid, Integer source, String orderNo) throws Exception {
        if (uid == null || source == null || orderNo == null)
            return;
        // 自己的奖励
        firstReward(uid, source, orderNo);
        // 上一级的奖励
        UserInfo boss = threeSaleSerivce.getBoss(uid);
        if(boss != null) {
            firstSharedOrderRewardToBoss(boss.getId(), uid, source, orderNo);
            firstSharedOrderRewardTheMonthToBoss(boss.getId(), uid, source, orderNo);
        }
    }
    /**
     *   新人奖励:完成首笔订单 (已到账) 首单=不限制金额、不限制商品、不限制数量、不限制订单类型)
     * @param uid
     * @param source
     * @param orderNo
     * @param bossId
     */
    @Transactional
    private void firstReward(Long uid, Integer source, String orderNo) throws Exception{
        // 1、判断是否用户首个订单
        CommonOrderVO order = commonOrderService.firstValidOrderByUid(uid);
        if (order == null || source == order.getSourceType() || orderNo.equals(order.getOrderNo()))
            return;
        // 金额
        BigDecimal money = new BigDecimal(redPackConfigService.getValueByKey("new_user_first_order"));
        // 3、获得红包记录
        RedPackWinInvite winInvite = new RedPackWinInvite();
        winInvite.setCreateTime(new Date());
        winInvite.setUpdateTime(new Date());
        winInvite.setType(RedPackWinInviteTypeEnum.newUserReward);
        winInvite.setUid(uid);
        winInvite.setTeamUid(null);
        winInvite.setMoney(money);
        winInvite.setSource(source);
        winInvite.setOrderNo(orderNo);
        redPackWinInviteMapper.insertSelective(winInvite);
        // 4、增加红包
        redPackBalanceService.addRedPack(uid, money, RedPackDetailFactory.createNewUserReward(winInvite));
        //消息
        MsgRedPackAddContentDTO dto = new MsgRedPackAddContentDTO();
        dto.setTitle("红包增加");
        dto.setMoney("¥" + money.setScale(2));
        dto.setBalance("¥" + redPackBalanceService.getBalance(uid).setScale(2));
        userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackNewUserReward, new Gson().toJson(dto), "红包可用于购买会员");
    }
    /**
     * 上级奖励:被邀请人完成首笔分享订单 (已到账)
     * @param uid
     * @param source
     * @param orderNo
     * @param bossId
     */
    @Transactional
    private void firstSharedOrderRewardToBoss(Long uid, Long inviteeUid, Integer source, String orderNo) throws Exception{
        // 1、判断是否是改用户首个分享订单
        CommonOrderVO order = commonOrderService.firstValidOrderByUidAndType(inviteeUid, 2);
        if (order == null || source == order.getSourceType() || orderNo.equals(order.getOrderNo()))
            return;
        // 2、判断是第几个人
        long total = redPackWinInviteMapper.countByUidAndType(uid, RedPackWinInviteTypeEnum.firstSharedOrder.name());
        // 计算应增加红包金额
        BigDecimal money = new BigDecimal(redPackConfigService.getValueByKey("first_shared_order"));
        long num = total % 9;
        if (num > 0) {
            BigDecimal addMoney = new BigDecimal(redPackConfigService.getValueByKey("first_shared_order_add"));
            money = MoneyBigDecimalUtil.add(money, MoneyBigDecimalUtil.mul(addMoney, new BigDecimal(num)));
        }
        // 3、获得红包记录
        RedPackWinInvite winInvite = new RedPackWinInvite();
        winInvite.setCreateTime(new Date());
        winInvite.setUpdateTime(new Date());
        winInvite.setType(RedPackWinInviteTypeEnum.firstSharedOrder);
        winInvite.setUid(uid);
        winInvite.setTeamUid(inviteeUid);
        winInvite.setMoney(money);
        winInvite.setSource(source);
        winInvite.setOrderNo(orderNo);
        redPackWinInviteMapper.insertSelective(winInvite);
        // 4、增加红包
        redPackBalanceService.addRedPack(uid, money, RedPackDetailFactory.createIncreaseReward(winInvite));
        // 5、消息
        MsgRedPackAddContentDTO dto = new MsgRedPackAddContentDTO();
        dto.setTitle("红包增加");
        dto.setMoney("¥" + money.setScale(2));
        dto.setBalance("¥" + redPackBalanceService.getBalance(uid).setScale(2));
        userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackFirstSharedOrder, new Gson().toJson(dto), "红包可用于购买会员");
    }
    /**
     * 上级奖励:次月开始产生满足条件的分享订单(分享订单实付款≥10元) 连续15个月 自然月获得(已到账)每月最高2元
     * @param uid
     * @param source
     * @param orderNo
     * @param bossId
     */
    @Transactional
    private void firstSharedOrderRewardTheMonthToBoss(Long uid, Long inviteeUid, Integer source, String orderNo) throws Exception{
        // 1、判断是否是本月首单
        CommonOrderVO order = commonOrderService.firstValidOrderTheMonthByUidAndType(inviteeUid, 2);
        if (order == null || source == order.getSourceType() || orderNo.equals(order.getOrderNo()) ||
                order.getAccountTime() == null)
            return;
        // 分享订单实付款≥10元
        if (order.getPayment() == null || order.getPayment().compareTo(Constant.RED_PACK_PAY_MIN) < 0)
            return;
        // 查询首单奖励时间
        CommonOrderVO firstorder = commonOrderService.firstValidOrderByUidAndType(inviteeUid, 2);
        if (firstorder == null || firstorder.getAccountTime() == null)
            return;
        // 第一次到账的次月开始连续15个月 自然月获得(已到账)
        int monthSpace = DateUtil.getMonthSpace( order.getAccountTime(), firstorder.getAccountTime());
        if (monthSpace == 0 || monthSpace > Constant.RED_PACK_REWARd_MONTH)
            return;
        // 计算随机奖励
        double randomMoney = Constant.RED_PACK_RANDOM_MIN +  Math.random() * (Constant.RED_PACK_RANDOM_MAX - Constant.RED_PACK_RANDOM_MIN);
        // 保留两位小数
        BigDecimal money = new BigDecimal(randomMoney).setScale(2, BigDecimal.ROUND_HALF_UP);
        // 3、获得红包记录
        RedPackWinInvite winInvite = new RedPackWinInvite();
        winInvite.setCreateTime(new Date());
        winInvite.setUpdateTime(new Date());
        winInvite.setType(RedPackWinInviteTypeEnum.monthSharedOrder);
        winInvite.setUid(uid);
        winInvite.setTeamUid(inviteeUid);
        winInvite.setMoney(money);
        winInvite.setSource(source);
        winInvite.setOrderNo(orderNo);
        redPackWinInviteMapper.insertSelective(winInvite);
        // 4、增加红包
        redPackBalanceService.addRedPack(uid, money, RedPackDetailFactory.createSeriesReward(winInvite));
        //消息
        MsgRedPackAddContentDTO dto = new MsgRedPackAddContentDTO();
        dto.setTitle("红包增加");
        dto.setMoney("¥" + money.setScale(2));
        dto.setBalance("¥" + redPackBalanceService.getBalance(uid).setScale(2));
        userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackMonthSharedOrder, new Gson().toJson(dto), "红包可用于购买会员");
    }
    public List<RedPackWinInvite> getRewardList() {
        return null;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java
@@ -303,5 +303,29 @@
     * @return
     */
    public CommonOrder selectLatestValidByUid(Long uid);
    /**
     * 查询首笔有效订单
     * @param uid
     * @return
     */
    public CommonOrderVO firstValidOrderByUid(Long uid);
    /**
     * 查询首笔有效订单
     * @param uid
     * @param type 类型: 1自购  2分享 3邀请
     * @return
     */
    public CommonOrderVO firstValidOrderByUidAndType(Long uid, Integer type);
    /**
     * 查询是否本月到账订单
     * @param uid
     * @param type 类型: 1自购  2分享 3邀请
     * @return
     */
    public CommonOrderVO firstValidOrderTheMonthByUidAndType(Long uid, Integer type);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackWinInviteService.java
New file
@@ -0,0 +1,14 @@
package com.yeshi.fanli.service.inter.redpack;
public interface RedPackWinInviteService {
    /**
     * 订单到账-相关奖励
     * @param uid
     * @param inviteeUid
     * @param source
     * @param orderNo
     */
    public void orderArriveReward(Long uid, Integer source, String orderNo) throws Exception;
}
fanli/src/main/java/com/yeshi/fanli/util/Constant.java
@@ -122,6 +122,15 @@
    // 微信自动提现最低余额
    public static final int AUTO_EXTRACT_MIN_SURPLUS = 2;
    // 红包奖励随机范围
    public static final double RED_PACK_RANDOM_MIN = 0.5;
    public static final double RED_PACK_RANDOM_MAX = 2;
    // 红包奖励订单实付款最低
    public static final BigDecimal RED_PACK_PAY_MIN = new BigDecimal("10");
    // 红包奖励分享订单连续奖励月数
    public static final int RED_PACK_REWARd_MONTH = 15;
    public static WXGZConfig wxGZConfig;
    // 短信验证码配置
fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java
@@ -7,6 +7,7 @@
import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackExchange;
import com.yeshi.fanli.entity.redpack.RedPackGiveRecord;
import com.yeshi.fanli.entity.redpack.RedPackWinInvite;
import com.yeshi.fanli.exception.redpack.RedPackDetailException;
import com.yeshi.fanli.util.StringUtil;
@@ -167,5 +168,98 @@
    }
    
    
    /**
     *  新人奖励
     * @param winInvite
     * @return
     * @throws RedPackDetailException
     */
    public static RedPackDetail createNewUserReward(RedPackWinInvite winInvite) throws RedPackDetailException {
        if (winInvite == null)
            throw new RedPackDetailException(1, "获得记录不能为空");
        // 红包明细- 退回红包
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(true);
        detail.setUid(winInvite.getUid());
        detail.setMoney(winInvite.getMoney());
        detail.setDesc("完成首笔订单");
        detail.setTitle(RedPackDetailTypeEnum.newUserReward.getDesc());
        detail.setType(RedPackDetailTypeEnum.newUserReward);
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.newUserReward.name() + ":" + winInvite.getId()));
        detail.setCreateTime(new Date());
        return detail;
    }
    /**
     * 立得现金
     * @param winInvite
     * @return
     * @throws RedPackDetailException
     */
    public static RedPackDetail createInvite(RedPackWinInvite winInvite) throws RedPackDetailException {
        if (winInvite == null)
            throw new RedPackDetailException(1, "获得记录不能为空");
        // 红包明细- 退回红包
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(true);
        detail.setUid(winInvite.getUid());
        detail.setMoney(winInvite.getMoney());
        detail.setDesc("成功邀请好友");
        detail.setTitle(RedPackDetailTypeEnum.invite.getDesc());
        detail.setType(RedPackDetailTypeEnum.invite);
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.invite.name() + ":" + winInvite.getId()));
        detail.setCreateTime(new Date());
        return detail;
    }
    /**
     * 递增奖励 + 好友完成分享订单
     * @param winInvite
     * @return
     * @throws RedPackDetailException
     */
    public static RedPackDetail createIncreaseReward(RedPackWinInvite winInvite) throws RedPackDetailException {
        if (winInvite == null)
            throw new RedPackDetailException(1, "获得记录不能为空");
        // 红包明细- 退回红包
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(true);
        detail.setUid(winInvite.getUid());
        detail.setMoney(winInvite.getMoney());
        detail.setDesc("好友完成订单");
        detail.setTitle(RedPackDetailTypeEnum.increaseReward.getDesc());
        detail.setType(RedPackDetailTypeEnum.increaseReward);
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.increaseReward.name() + ":" + winInvite.getId()));
        detail.setCreateTime(new Date());
        return detail;
    }
    /**
     * 连续奖励 + 好友完成分享订单
     * @param winInvite
     * @return
     * @throws RedPackDetailException
     */
    public static RedPackDetail createSeriesReward(RedPackWinInvite winInvite) throws RedPackDetailException {
        if (winInvite == null)
            throw new RedPackDetailException(1, "获得记录不能为空");
        // 红包明细- 退回红包
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(true);
        detail.setUid(winInvite.getUid());
        detail.setMoney(winInvite.getMoney());
        detail.setDesc("好友完成订单");
        detail.setTitle(RedPackDetailTypeEnum.seriesReward.getDesc());
        detail.setType(RedPackDetailTypeEnum.seriesReward);
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.seriesReward.name() + ":" + winInvite.getId()));
        detail.setCreateTime(new Date());
        return detail;
    }
}
fanli/src/main/java/com/yeshi/fanli/util/mybatishandler/redpack/RedPackWinInviteTypeEnumHandler.java
New file
@@ -0,0 +1,54 @@
package com.yeshi.fanli.util.mybatishandler.redpack;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import com.yeshi.fanli.entity.redpack.RedPackWinInvite.RedPackWinInviteTypeEnum;
public class RedPackWinInviteTypeEnumHandler extends BaseTypeHandler<RedPackWinInviteTypeEnum> {
    @Override
    public RedPackWinInviteTypeEnum getNullableResult(ResultSet arg0, String arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            return RedPackWinInviteTypeEnum.valueOf(key);
        }
    }
    @Override
    public RedPackWinInviteTypeEnum getNullableResult(ResultSet arg0, int arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            // 根据数据库中的key值,定位SexEnum子类
            return RedPackWinInviteTypeEnum.valueOf(key);
        }
    }
    @Override
    public RedPackWinInviteTypeEnum getNullableResult(CallableStatement arg0, int arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            // 根据数据库中的key值,定位SexEnum子类
            return RedPackWinInviteTypeEnum.valueOf(key);
        }
    }
    @Override
    public void setNonNullParameter(PreparedStatement arg0, int arg1, RedPackWinInviteTypeEnum arg2, JdbcType arg3)
            throws SQLException {
        arg0.setString(arg1, arg2.name());
    }
}
utils/src/main/java/org/yeshi/utils/DateUtil.java
@@ -54,7 +54,7 @@
        if (day > 0) {
            datatime = day + "天" + hour + "时" + min + "分";
        } else {
            if (hour > 0 ) {
            if (hour > 0) {
                datatime = hour + "时" + min + "分";
            } else {
                if (min < 0)
@@ -65,19 +65,18 @@
        return datatime;
    }
    public static DateInfo dateDiff3(long startTime, long endTime) throws Exception {
        long nm = 1000 * 60;// 一分钟的毫秒数
        long nh = 1000 * 60 * 60;// 一小时的毫秒数
        long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数
        // 获得两个时间的毫秒时间差异
        long diff = endTime - startTime;
        int day = (int) (diff / nd);// 计算差多少天
        long hour = diff % nd / nh;// 计算差多少小时
        long minute = diff % nd % nh / nm;// 计算差多少分钟
        long second =(diff/1000-day*24*60*60-hour*60*60-minute*60); // 计算差多少秒
        long second = (diff / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60); // 计算差多少秒
        DateInfo dateInfo = new DateInfo();
        dateInfo.setDay(day);
@@ -86,7 +85,7 @@
        dateInfo.setSecond(second);
        return dateInfo;
    }
    /**
     * 通过时间秒毫秒数判断两个时间的间隔
     * 
@@ -138,29 +137,28 @@
        }
    }
    /**
     * 判断是否同一个月
     *
     * @param date1
     * @param date2
     * @return
     */
    public static boolean isSameMonth(Date date1, Date date2) {
        Calendar calendar1 = Calendar.getInstance();
        calendar1.setTime(date1);
        Calendar calendar2 = Calendar.getInstance();
        calendar2.setTime(date2);
        int year1 = calendar1.get(Calendar.YEAR);
        int year2 = calendar2.get(Calendar.YEAR);
        int month1 = calendar1.get(Calendar.MONTH);
        int month2 = calendar2.get(Calendar.MONTH);
        System.out.println(year1 + "  " + month1);
        System.out.println(year2 + "  " + month2);
        return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR) && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH);
    }
        Calendar calendar1 = Calendar.getInstance();
        calendar1.setTime(date1);
        Calendar calendar2 = Calendar.getInstance();
        calendar2.setTime(date2);
        int year1 = calendar1.get(Calendar.YEAR);
        int year2 = calendar2.get(Calendar.YEAR);
        int month1 = calendar1.get(Calendar.MONTH);
        int month2 = calendar2.get(Calendar.MONTH);
        System.out.println(year1 + "  " + month1);
        System.out.println(year2 + "  " + month2);
        return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR)
                && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH);
    }
    /**
     * 指定日期加上天数后的日期
     * 
@@ -197,7 +195,7 @@
        return format.format(ca.getTime());
    }
    /**
     * 指定日期加上天数后的日期
     * 
@@ -212,7 +210,6 @@
        ca.add(Calendar.DATE, num);
        return ca.getTime();
    }
    /**
     * 指定日期减去天数后的日期
@@ -254,7 +251,7 @@
        return ca.getTime();
    }
    /**
     * 指定日期减去天数后的日期
     * 
@@ -294,13 +291,12 @@
        return Integer.parseInt(String.valueOf(between_days));
    }
    /**
     * 字符串日期格式的计算
     * 
     * @param smdate
     * @param bdate
     * @return  单位天数
     * @return 单位天数
     * @throws ParseException
     */
    public static int daysBetween2(Date minDate, Date maxDate) throws ParseException {
@@ -308,7 +304,6 @@
        return daysBetween(sdf.format(minDate), sdf.format(maxDate));
    }
    /**
     * 字符串日期格式的计算
     * 
@@ -359,29 +354,50 @@
    /**
     * 随机减去几分钟
     *
     * @param date
     * @param min 随机添加的分钟数
     * @param min  随机添加的分钟数
     * @return
     */
    public static Date reduceRandomMinute(Date date , int min) {
    public static Date reduceRandomMinute(Date date, int min) {
        long rand = (long) (Math.random() * 1000 * 60 * min);
        long time = date.getTime() - rand;
        return new Date(time);
    }
    /**
     * @param args
     * @throws ParseException format() 对日期进行格式化处理 parse() 将日期设置为date类型
     */
    public static void main(String[] args) throws ParseException {
        // TODO Auto-generated method stub
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date d1 = sdf.parse("2016-09-08 00:00:00");
        Date d2 = sdf.parse("2016-09-08 00:00:00");
        System.out.println(daysBetween(d1, d2));
        System.out.println(daysBetween("2016-09-08 10:10:10", "2016-09-29 00:00:00"));
    /**
     * 计算两时间月差
     *
     * @param startDate <String>
     * @param endDate <String>
     * @return int
     * @throws ParseException
     */
    public static int getMonthSpace(String startDate, String endDate) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
        return getMonthSpace(sdf.parse(startDate), sdf.parse(endDate));
    }
    /**
     * 计算两时间月差
     *
     * @param startDate <String>
     * @param endDate <String>
     * @return int
     * @throws ParseException
     */
    public static int getMonthSpace(Date startDate, Date endDate) {
        Calendar start = Calendar.getInstance();
        Calendar end = Calendar.getInstance();
        start.setTime(startDate);
        end.setTime(endDate);
        int result = end.get(Calendar.MONTH) - start.get(Calendar.MONTH);
        int month = (end.get(Calendar.YEAR) - start.get(Calendar.YEAR)) * 12;
        return Math.abs(month + result);
    }
    public static void main(String[] args) throws ParseException {
        System.out.println(getMonthSpace("2012-02", "2013-01"));
    }
}