admin
2019-11-05 cd4d7c2ff85d68aebec276073020224b5de56415
Merge remote-tracking branch 'origin/div' into div

Conflicts:
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java
10个文件已添加
53个文件已修改
1 文件已重命名
2055 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/aspect/VersionLimitAspect.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ConfigController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RedPackControllerV2.java 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/IntegralTaskRecordMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderCountMapper.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackGiveRecordMapper.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackWinInviteMapper.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/msg/MsgRedPackAddContentDTO.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/msg/MsgRedPackGiveContentDTO.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgMoneyDetail.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackBalance.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackConfig.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackDetail.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackExchange.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackGiveRecord.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 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/RedPackJob.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandInfoMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralTaskRecordMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderCountMapper.xml 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackBalanceMapper.xml 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackConfigMapper.xml 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackDetailMapper.xml 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackExchangeMapper.xml 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackGiveRecordMapper.xml 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackWinInviteMapper.xml 82 ●●●●● 补丁 | 查看 | 原始文档 | 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 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandShopCaheServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/count/CommonOrderCountServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/MsgMoneyDetailServiceImpl.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/UserMoneyMsgNotificationServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java 21 ●●●● 补丁 | 查看 | 原始文档 | 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/RedPackGiveRecordServiceImpl.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java 347 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponActivateServiceImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralTaskRecordServiceImpl.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderCountService.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackGiveRecordService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackWinInviteService.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserInfoExtraService.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponActivateService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/integral/IntegralTaskRecordService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/Constant.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/annotation/redpack/RedPackGetVersionLimit.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/mybatishandler/redpack/RedPackWinInviteTypeEnumHandler.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/redpack/RedPackWinInviteVO.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/MyBatisProduce.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/TaoKeTest.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/src/main/java/org/yeshi/utils/DateUtil.java 102 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/aspect/VersionLimitAspect.java
File was renamed from fanli/src/main/java/com/yeshi/fanli/aspect/integral/IntegralGetVersionLimitAspect.java
@@ -1,4 +1,4 @@
package com.yeshi.fanli.aspect.integral;
package com.yeshi.fanli.aspect;
import java.lang.reflect.Method;
@@ -22,10 +22,11 @@
import com.yeshi.fanli.service.inter.user.UserActiveLogService;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.annotation.integral.IntegralGetVersionLimit;
import com.yeshi.fanli.util.annotation.redpack.RedPackGetVersionLimit;
@Component
@Aspect
public class IntegralGetVersionLimitAspect {
public class VersionLimitAspect {
    @Resource
    private UserActiveLogService userActiveLogService;
@@ -46,7 +47,7 @@
        return expression.getValue(context).toString();
    }
    @Around("execution(public * com.yeshi.fanli.service.impl.user.integral.*.*(..))")
    @Around("execution(public * com.yeshi.fanli.service.impl..*.*(..))")
    public Object requestSerializable(ProceedingJoinPoint joinPoint) throws Throwable {
        Signature signature = joinPoint.getSignature();
        MethodSignature methodSignature = (MethodSignature) signature;
@@ -62,8 +63,22 @@
                    UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(Long.parseLong(uid));
                    if (activeLog != null) {
                        // 小于1.6.5版本不增加积分
                        if (!VersionUtil.greaterThan_1_6_5(
                                "appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
                        if (!VersionUtil.greaterThan_1_6_5("appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
                                activeLog.getVersionCode()))
                            return null;
                    }
                }
            }
            if (realMethod.isAnnotationPresent(RedPackGetVersionLimit.class)) {
                RedPackGetVersionLimit rs = realMethod.getAnnotation(RedPackGetVersionLimit.class);
                String key = rs.uid();
                String uid = generateKeyBySpEL(key, joinPoint);
                if (uid != null && NumberUtil.isNumeric(uid)) {
                    UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(Long.parseLong(uid));
                    if (activeLog != null) {
                        // 小于2.0.2版本不增加积分
                        if (!VersionUtil.greaterThan_2_0_2("appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
                                activeLog.getVersionCode()))
                            return null;
                    }
fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java
@@ -3,6 +3,7 @@
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -19,6 +20,7 @@
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.controller.admin.utils.AdminUtils;
import com.yeshi.fanli.dto.ChartTDO;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.money.UserMoneyDebt;
import com.yeshi.fanli.entity.money.UserMoneyDebt.UserMoneyDebtTypeEnum;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
@@ -28,6 +30,7 @@
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack;
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
import com.yeshi.fanli.exception.order.CommonOrderException;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
import com.yeshi.fanli.service.inter.count.TaoBaoOrderCountService;
import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
@@ -92,6 +95,10 @@
    @Resource
    private UserSystemCouponRecordService userSystemCouponRecordService;
    @Resource
    private ConfigService configService;
    /**
     * 统计历史订单-淘宝订单
@@ -146,7 +153,7 @@
    @RequestMapping(value = "getUserOrderList")
    public void getUserOrderList(String callback, Integer pageIndex, Integer pageSize, Integer keyType, String key,
            Integer state, Integer type, Integer orderState, String startTime, String endTime, Integer sourceType,
            PrintWriter out) {
            Integer riskType, PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
@@ -168,13 +175,44 @@
        }
        try {
            Date minTime = null;
            BigDecimal money = null;
            List<Long> listShopId = null;
            List<Long> listGoodsId = null;
            // 风险
            if (riskType != null && !StringUtil.isNullOrEmpty(key) && keyType!= null && keyType == 2) {
                long uid = Long.parseLong(key);
                // 查询同店铺商品,同商品订单超过一定数量的
                List<Integer> typeList = new ArrayList<>();
                typeList.add(HongBaoV2.TYPE_ZIGOU);
                if (riskType == 1) {
                    listGoodsId = commonOrderCountService.getSameGoodsOrderByUidAndHongBaoType(typeList, uid,
                            Integer.parseInt(configService.get("admin_min_same_goods_order_count")));
                    if (listGoodsId == null || listGoodsId.isEmpty()) {
                        JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无同商品订单"));
                        return;
                    }
                } else if (riskType == 2) {
                    listShopId  = commonOrderCountService.getSameShopOrderByUidAndHongBaoType(typeList, uid,
                            Integer.parseInt(configService.get("admin_min_same_shop_order_count")));
                    if (listShopId == null || listShopId.isEmpty()) {
                        JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无同店铺订单"));
                        return;
                    }
                } else if (riskType == 3) {
                    money = new BigDecimal(100);
                    minTime = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 180L);
                }
            }
            // 查询列表
            List<CommonOrderVO> list = commonOrderService.listQuery((pageIndex - 1) * pageSize, pageSize, keyType, key,
                    state, type, orderState, startTime, endTime, sourceType);
                    state, type, orderState, startTime, endTime, sourceType, listShopId, listGoodsId, minTime, money);
            // 统计总数
            long count = commonOrderService.countQuery(keyType, key, state, type, orderState, startTime, endTime,
                    sourceType);
                    sourceType, listShopId, listGoodsId, minTime, money);
            // 查询是否维权
            for (CommonOrderVO order : list) {
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ConfigController.java
@@ -254,7 +254,7 @@
            
            if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
                // 我的界面banner
                List<SwiperPicture> banner = swiperPictureService.getByBannerCard("index_top");
                List<SwiperPicture> banner = swiperPictureService.getByBannerCard("my_interface_banner");
                if (banner == null)
                    banner = new ArrayList<SwiperPicture>();
                data.put("banner", JsonUtil.getApiCommonGson().toJson(banner));
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java
@@ -228,7 +228,7 @@
        long nextTime = nowTime + 1000 * 60 * 60L;// 默认为1小时
        if (nextPos < dtoList.size()) {
            nextTime = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(nowTime, "yyyyMM") + dtoList.get(nextPos),
            nextTime = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(nowTime, "yyyyMM") + dtoList.get(nextPos).getTime(),
                    "yyyyMMddHH");
        }
@@ -354,7 +354,6 @@
    @RequestMapping("getSpikTime")
    public void getSpikTime(AcceptData acceptData, PrintWriter out) {
        List<DingDongTime> timeList = DaTaoKeUtil.getDingDongQiangTime(Calendar.getInstance());
        List<SpikeTimeVO> list = new ArrayList<SpikeTimeVO>();
        for (int i = 0; i < timeList.size(); i++) {
            SpikeTimeVO spikeTime1 = new SpikeTimeVO();
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RedPackControllerV2.java
@@ -26,8 +26,12 @@
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackExchange;
import com.yeshi.fanli.entity.redpack.RedPackWinInvite;
import com.yeshi.fanli.entity.redpack.RedPackWinInvite.RedPackWinInviteTypeEnum;
import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
@@ -35,8 +39,14 @@
import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
import com.yeshi.fanli.service.inter.redpack.RedPackExchangeService;
import com.yeshi.fanli.service.inter.redpack.RedPackGiveRecordService;
import com.yeshi.fanli.service.inter.redpack.RedPackWinInviteService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.vo.redpack.RedPackDetailVO;
import com.yeshi.fanli.vo.redpack.RedPackWinInviteVO;
import net.sf.json.JSONObject;
@@ -58,9 +68,19 @@
    
    @Resource    
    private RedPackExchangeService redPackExchangeService;
    @Resource
    private RedPackWinInviteService redPackWinInviteService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    /**
     * 统计淘礼金
     * 统计
     * 
     * @param acceptData
     * @param uid
@@ -278,4 +298,77 @@
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
        }
    }
    /**
     * 红包邀请进度
     * @param acceptData
     * @param page
     * @param uid
     * @param out
     */
    @RequestMapping(value = "getRewardList", method = RequestMethod.POST)
    public void getRewardList(AcceptData acceptData, Integer page, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        if (page == null || page < 1) {
            out.print(JsonUtil.loadFalseResult(1, "页码不正确"));
            return;
        }
        List<RedPackWinInviteVO> list = new ArrayList<RedPackWinInviteVO>();
        List<RedPackWinInvite> listRecord = redPackWinInviteService.getRewardList((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
        if (listRecord != null && !listRecord.isEmpty()) {
            for (RedPackWinInvite record: listRecord) {
                UserInfo user = null;
                RedPackWinInviteVO winVO = new RedPackWinInviteVO();
                RedPackWinInviteTypeEnum type = record.getType();
                if (RedPackWinInviteTypeEnum.newUserReward == type) {
                    user = userInfoService.selectByPKey(uid);
                } else {
                    user = userInfoService.selectByPKey(record.getTeamUid());
                }
                winVO.setPortrait(user.getPortrait());
                winVO.setNickName(user.getNickName());
                winVO.setDesc(type.getDesc());
                winVO.setMoney(record.getMoney().toString());
                list.add(winVO);
            }
        }
        JSONObject data = new JSONObject();
        data.put("count", redPackWinInviteService.countRewardRecord(uid));
        data.put("list", JsonUtil.getApiCommonGson().toJson(list));
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 用户基础信息
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "getBasicInfo", method = RequestMethod.POST)
    public void getBasicInfo(AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        JSONObject data = new JSONObject();
        data.put("balance", redPackBalanceService.getBalance(uid));
        data.put("ruleLink", redPackConfigService.getValueByKey("invite_reward_rule_link"));
        UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
        if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
            data.put("inviteCode", userInfoExtra.getInviteCode());
        } else {
            data.put("inviteCode", "");
        }
        out.print(JsonUtil.loadTrueResult(data));
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/IntegralTaskRecordMapper.java
@@ -149,4 +149,11 @@
     */
    List<IntegralTaskRecord> listByUidAndTaskId(@Param("uid") Long uid, @Param("taskId") Long taskId,
            @Param("start") long start, @Param("count") int count);
    /**
     * 统计总金币
     * @param uid
     * @return
     */
    long getTotalGoldCoinByUid(@Param("uid") Long uid);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderCountMapper.java
@@ -86,4 +86,29 @@
     */
    long countSameGoodsOrderByUidAndHongBaoType(@Param("typeList") List<Integer> typeList, @Param("uid") Long uid,
            @Param("minSameGoodsOrderCount") int minSameGoodsOrderCount);
    /**
     * 查询用户在同一店铺购买超过一定数量商品的店铺id
     *
     * @param typeList
     *            -红包类型
     * @param uid
     *            -用户ID
     * @param minSameShopGoodsCount
     *            -同一店铺买的最小订单数
     * @return
     */
    List<Long> getSameShopOrderByUidAndHongBaoType(@Param("typeList") List<Integer> typeList, @Param("uid") Long uid,
            @Param("minSameShopGoodsCount") int minSameShopGoodsCount);
    /**
     * 查询用户购买相同商品超过一定的订单数量的商品id
     * @param typeList
     * @param uid
     * @param minSameGoodsOrderCount
     * @return
     */
    List<Long> getSameGoodsOrderByUidAndHongBaoType(@Param("typeList") List<Integer> typeList, @Param("uid") Long uid,
            @Param("minSameGoodsOrderCount") int minSameGoodsOrderCount);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderMapper.java
@@ -174,7 +174,9 @@
    List<CommonOrderVO> listQuery(@Param("start") long start, @Param("count") int count,
            @Param("keyType") Integer keyType, @Param("key") String key, @Param("state") Integer state,
            @Param("type") Integer type, @Param("orderState") Integer orderState, @Param("startTime") String startTime,
            @Param("endTime") String endTime, @Param("source") Integer source);
            @Param("endTime") String endTime, @Param("source") Integer source,
            @Param("listShopId")List<Long> listShopId, @Param("listGoodsId")List<Long> listGoodsId,
            @Param("minTime")Date minTime, @Param("money")BigDecimal money);
    /**
     * 订单列表查询(不包含子订单)
@@ -201,7 +203,9 @@
     */
    long countQuery(@Param("keyType") Integer keyType, @Param("key") String key, @Param("state") Integer state,
            @Param("type") Integer type, @Param("orderState") Integer orderState, @Param("startTime") String startTime,
            @Param("endTime") String endTime, @Param("source") Integer source);
            @Param("endTime") String endTime, @Param("source") Integer source,
            @Param("listShopId")List<Long> listShopId, @Param("listGoodsId")List<Long> listGoodsId,
            @Param("minTime")Date minTime, @Param("money")BigDecimal money);
    long countQueryWithNoChild(@Param("keyType") Integer keyType, @Param("key") String key,
            @Param("state") Integer state, @Param("type") Integer type, @Param("orderState") Integer orderState,
@@ -300,4 +304,15 @@
     */
    List<CommonOrder> listByUid(@Param("uid")Long uid,@Param("stateList") List<Integer> stateList,@Param("start") long start,@Param("count") int count);
    /**
     * 查询首笔有效到账订单
     * @param uid
     * @param typeHB 类型: 1自购  2分享 3邀请
     * @param typeDate 日期类型: 3本月 4上月
     * @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/RedPackGiveRecordMapper.java
@@ -1,8 +1,18 @@
package com.yeshi.fanli.dao.mybatis.redpack;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.redpack.RedPackGiveRecord;
public interface RedPackGiveRecordMapper extends BaseMapper<RedPackGiveRecord> {
    /**
     * 口令失效
     * @param token
     * @return
     */
    List<RedPackGiveRecord> overdueList(@Param("count") int count);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackWinInviteMapper.java
New file
@@ -0,0 +1,40 @@
package com.yeshi.fanli.dao.mybatis.redpack;
import java.util.List;
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);
    /**
     * 统计用户、下级、类型的数量
     * @param uid
     * @param type
     * @return
     */
    long countByUidAndTeamUidAndType(@Param("uid")Long uid,@Param("teamUid")Long teamUid, @Param("type")String type);
    /**
     * 查询用户记录
     * @param start
     * @param count
     * @return
     */
    List<RedPackWinInvite> getRewardList(@Param("start")int start, @Param("count")int count, @Param("uid")Long uid);
    Long countRewardRecord(@Param("uid")Long uid);
}
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/dto/msg/MsgRedPackGiveContentDTO.java
@@ -11,6 +11,7 @@
    private String title; // 标题
    private String userInfo; // 用户信息
    private String time; // 时间
    private String giveTime; // 赠送时间
    private String money; // 金额
    public String getTitle() {
@@ -44,4 +45,12 @@
    public void setMoney(String money) {
        this.money = money;
    }
    public String getGiveTime() {
        return giveTime;
    }
    public void setGiveTime(String giveTime) {
        this.giveTime = giveTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgMoneyDetail.java
@@ -34,8 +34,13 @@
        subSidy("额外补贴"),
        redPackGiveOff("赠送红包完成"),
        redPackReceiveOff("赠送红包领取"),
        redPackGiveBack("红包退回"),
        redPackExchangePass("红包提现成功"),
        redPackExchangeReject("红包提现失败");
        redPackExchangeReject("红包提现失败"),
        redPackNewUserReward("新人奖励-完成首笔订单"),
        redPackInviteSucceed("立得现金-成功邀请好友"),
        redPackFirstSharedOrder("递增奖励-好友完成订单"),
        redPackMonthSharedOrder("连续奖励-好友完成订单");
        private final String desc;
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackBalance.java
@@ -12,7 +12,7 @@
 * @author Administrator
 *
 */
@Table("yeshi_red_pack_balance")
@Table("yeshi_ec_red_pack_balance")
public class RedPackBalance {
    // 用户id
    @Column(name = "rpb_uid")
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackConfig.java
@@ -11,7 +11,7 @@
 * @author Administrator
 *
 */
@Table("yeshi_red_pack_config")
@Table("yeshi_ec_red_pack_config")
public class RedPackConfig {
    @Column(name = "rpc_id")
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackDetail.java
@@ -14,22 +14,21 @@
 * @author Administrator
 *
 */
@Table("yeshi_red_pack_detail")
@Table("yeshi_ec_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"),
        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"),
        violation("红包涉嫌违规", "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"),
        giveOthers("红包赠送待领取中", "http://img.flqapp.com/resource/msg/icon_hongbao_give.png"),
        giveOthersSucceed("红包赠送领取成功", "http://img.flqapp.com/resource/msg/icon_hongbao_give.png"),
        giveOthersFail("红包赠送超时退回", "http://img.flqapp.com/resource/msg/icon_hongbao_give.png"),
        giveOthersReceive("好友赠送", "http://img.flqapp.com/resource/msg/icon_hongbao_give.png"),
        useByShopOrder("商城订单使用", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        shopOrderDrawBack("商城订单退回", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        violation("红包涉嫌违规", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        giveOthers("红包赠送待领取中", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        giveOthersSucceed("红包赠送领取成功", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        giveOthersFail("红包赠送超时退回", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        giveOthersReceive("好友赠送", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        redExchange("红包提现中", "http://img.flqapp.com/resource/msg/icon_hongbao_tixian.png"),
        redExchangePass("红包提现成功", "http://img.flqapp.com/resource/msg/icon_hongbao_tixian.png"),
        redExchangeReject("红包提现失败", "http://img.flqapp.com/resource/msg/icon_hongbao_tixian.png");
@@ -70,8 +69,8 @@
    @Column(name = "rpd_type")
    private RedPackDetailTypeEnum type;
    @Expose
    @Column(name = "rpd_desc")
    private String desc;
    @Column(name = "rpd_desc_info")
    private String descInfo;
    @Expose
    @Column(name = "rpd_remark")
    private String remark;
@@ -122,12 +121,12 @@
        this.type = type;
    }
    public String getDesc() {
        return desc;
    public String getDescInfo() {
        return descInfo;
    }
    public void setDesc(String desc) {
        this.desc = desc;
    public void setDescInfo(String descInfo) {
        this.descInfo = descInfo;
    }
    public String getRemark() {
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackExchange.java
@@ -12,7 +12,7 @@
 * @author Administrator
 *
 */
@Table("yeshi_red_pack_exchange")
@Table("yeshi_ec_red_pack_exchange")
public class RedPackExchange {
    public static final int STATE_INIT = 0;
    public static final int STATE_SUCCESS = 1;
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackGiveRecord.java
@@ -12,7 +12,7 @@
 * @author Administrator
 *
 */
@Table("yeshi_red_pack_give_record")
@Table("yeshi_ec_red_pack_give_record")
public class RedPackGiveRecord {
    // 未领取
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_ec_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
@@ -35,24 +35,9 @@
        if (count == 0)
            return;
        for (int page = 1; page < (count / 100) + 1; page++) {
            brandInfoService.addShopAndGoods((page - 1) * 100, 100);
        for (int page = 0; page < (count / 80) + 1; page++) {
            brandInfoService.addShopAndGoods(page * 80, 80);
        }
    }
    
    /**
     * 清理前一天的
     */
//    @Scheduled(cron = "0 10 0 * * ? ")
    public void removeAgoByDate() {
        if (!Constant.IS_TASK)
            return;
        try {
            brandInfoService.removeAgoByDate(DateUtil.reduceDay(1, new Date()));
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/job/RedPackJob.java
New file
@@ -0,0 +1,41 @@
package com.yeshi.fanli.job;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.yeshi.fanli.entity.redpack.RedPackGiveRecord;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.redpack.RedPackGiveRecordService;
import com.yeshi.fanli.util.Constant;
@Component
public class RedPackJob {
    @Resource
    private RedPackGiveRecordService redPackGiveRecordService;
    /**
     * 每天一个小时更新退回
     */
    @Scheduled(cron = "0 0 0/1 * * ? ")
    public void overdue() {
        if (!Constant.IS_TASK)
            return;
        try {
            for (int i = 0; i < 100; i++) {
                List<RedPackGiveRecord> overdueList = redPackGiveRecordService.overdueList(500);
                if (overdueList == null || overdueList.size() == 0) {
                    break;
                }
                redPackGiveRecordService.overdue(overdueList);
            }
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandInfoMapper.xml
@@ -114,7 +114,7 @@
          AND d.bf_goods_total <![CDATA[>=]]> 3
  </select>
  
   <select id="listValidAll" resultMap="BaseResultMap">
  <select id="listValidAll" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_brand_info d
    WHERE d.`bf_state` = 1
    LIMIT ${start},${count}
fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralTaskRecordMapper.xml
@@ -239,5 +239,10 @@
            and #{maxTime}>ir_create_time
        </if>
    </select>
    <select id="getTotalGoldCoinByUid" resultType="Long">
        select IFNULL(SUM(ir_gold_coin),0) from yeshi_ec_integral_task_record
        where ir_uid=#{uid}
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderCountMapper.xml
@@ -188,7 +188,11 @@
        (
            SELECT a.*,COUNT(*) AS num FROM 
            (
                SELECT co.*,COUNT(*) AS c,g.`cog_shop_id` AS shopId FROM yeshi_ec_common_order co LEFT JOIN yeshi_ec_hongbao_order ho ON co.`co_id`=ho.`ho_order_id` LEFT JOIN yeshi_ec_hongbao_v2 v ON v.`hb_id`=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order_goods g  ON co.`co_order_goods_id`=g.`cog_id`  WHERE  co.`co_uid`=#{uid}
                SELECT co.*,COUNT(*) AS c,g.`cog_shop_id` AS shopId FROM yeshi_ec_common_order co
                LEFT JOIN yeshi_ec_hongbao_order ho ON co.`co_id`=ho.`ho_order_id`
                LEFT JOIN yeshi_ec_hongbao_v2 v ON v.`hb_id`=ho.`ho_hongbao_id`
                LEFT JOIN yeshi_ec_common_order_goods g  ON co.`co_order_goods_id`=g.`cog_id`
                WHERE  co.`co_uid`=#{uid}  AND g.`cog_shop_id` <![CDATA[<>]]> 725677994  <!-- 天猫超市 -->
                <if test="typeList!=null">
                    <foreach collection="typeList" item="type" open=" and (" separator=" or " close=")">
                        v.`hb_type`=#{type}
@@ -207,7 +211,58 @@
        (
            SELECT a.goodsId,COUNT(*) AS c FROM
            (
                SELECT co.`co_order_goods_id` AS goodsId,co.`co_order_no` FROM yeshi_ec_common_order co LEFT JOIN yeshi_ec_hongbao_order ho ON co.`co_id`=ho.`ho_order_id` LEFT JOIN yeshi_ec_hongbao_v2 v ON v.`hb_id`=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order_goods g  ON co.`co_order_goods_id`=g.`cog_id`  WHERE co.`co_uid`=#{uid}
                SELECT co.`co_order_goods_id` AS goodsId,co.`co_order_no` FROM yeshi_ec_common_order co
                LEFT JOIN yeshi_ec_hongbao_order ho ON co.`co_id`=ho.`ho_order_id`
                LEFT JOIN yeshi_ec_hongbao_v2 v ON v.`hb_id`=ho.`ho_hongbao_id`
                LEFT JOIN yeshi_ec_common_order_goods g  ON co.`co_order_goods_id`=g.`cog_id`
                WHERE co.`co_uid`=#{uid} AND g.`cog_shop_id` <![CDATA[<>]]> 725677994  <!-- 天猫超市 -->
                <if test="typeList!=null">
                    <foreach collection="typeList" item="type" open=" and (" separator=" or " close=")">
                        v.`hb_type`=#{type}
                    </foreach>
                </if>
                AND v.`hb_id` IS NOT NULL
                AND (co.`co_state`=1 OR  co.`co_state`=2 OR co.`co_state`=3)
                GROUP BY co.`co_order_no`,co.`co_order_goods_id`
            ) a GROUP BY goodsId
        ) b WHERE b.c>=#{minSameGoodsOrderCount}
    </select>
    <select id="getSameShopOrderByUidAndHongBaoType" resultType="Long">
        SELECT b.shopId FROM
        (
            SELECT a.*,COUNT(*) AS num FROM
            (
                SELECT co.*,COUNT(*) AS c,g.`cog_shop_id` AS shopId FROM yeshi_ec_common_order co
                LEFT JOIN yeshi_ec_hongbao_order ho ON co.`co_id`=ho.`ho_order_id`
                LEFT JOIN yeshi_ec_hongbao_v2 v ON v.`hb_id`=ho.`ho_hongbao_id`
                LEFT JOIN yeshi_ec_common_order_goods g  ON co.`co_order_goods_id`=g.`cog_id`
                WHERE  co.`co_uid`=#{uid} AND g.`cog_shop_id` <![CDATA[<>]]> 725677994  <!-- 天猫超市 -->
                <if test="typeList!=null">
                    <foreach collection="typeList" item="type" open=" and (" separator=" or " close=")">
                        v.`hb_type`=#{type}
                    </foreach>
                </if>
                AND v.`hb_id` IS NOT NULL
                AND (co.`co_state`=1 OR  co.`co_state`=2 OR co.`co_state`=3)
                AND g.`cog_shop_id`>0 GROUP BY co.`co_order_no`,co.`co_source_type`
            ) a GROUP BY a.shopId
        ) b WHERE b.num>=#{minSameShopGoodsCount};
    </select>
    <select id="getSameGoodsOrderByUidAndHongBaoType" resultType="Long">
        SELECT b.goodsId FROM
        (
            SELECT a.goodsId,COUNT(*) AS c FROM
            (
                SELECT co.`co_order_goods_id` AS goodsId,co.`co_order_no` FROM yeshi_ec_common_order co
                LEFT JOIN yeshi_ec_hongbao_order ho ON co.`co_id`=ho.`ho_order_id`
                LEFT JOIN yeshi_ec_hongbao_v2 v ON v.`hb_id`=ho.`ho_hongbao_id`
                LEFT JOIN yeshi_ec_common_order_goods g  ON co.`co_order_goods_id`=g.`cog_id`
                WHERE co.`co_uid`=#{uid} AND g.`cog_shop_id` <![CDATA[<>]]> 725677994  <!-- 天猫超市 -->
                <if test="typeList!=null">
                    <foreach collection="typeList" item="type" open=" and (" separator=" or " close=")">
                        v.`hb_type`=#{type}
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
@@ -815,6 +815,11 @@
        <!-- 红包状态 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        <if test="listShopId != null">
            LEFT JOIN yeshi_ec_common_order_goods g  ON co.`co_order_goods_id`=g.`cog_id`
        </if>
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
@@ -828,6 +833,20 @@
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        <if test="listGoodsId != null">
            <foreach collection="listGoodsId" item="goodsId" open=" and (" separator=" or " close=")">
                co.`co_order_goods_id` =#{goodsId}
            </foreach>
        </if>
        <if test="listShopId != null">
            <foreach collection="listShopId" item="shopId" open=" and (" separator=" or " close=")">
                g.`cog_shop_id` =#{shopId}
            </foreach>
        </if>
        <if test="minTime != null"> <!-- 高风险订单 -->
            AND co.`co_third_create_time`>#{minTime} AND <![CDATA[ (co.`co_estimate`>=  ${money} OR co.`co_eIncome`> ${money})]]>
        </if>
        ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} ) A LEFT
        JOIN yeshi_ec_user u ON u.id = A.hb_uid
    </select>
@@ -846,8 +865,7 @@
        <include refid="SELECT_HONGBAO_STATE" />
        <!-- 红包状态 -->
        )hb ON hb.hb_id=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co
        ON co.`co_id`=ho.`ho_order_id`
        LEFT JOIN yeshi_ec_common_order co    ON co.`co_id`=ho.`ho_order_id`
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
@@ -875,6 +893,9 @@
        <!-- 红包状态 -->
        )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
        LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
        <if test="listShopId != null">
            LEFT JOIN yeshi_ec_common_order_goods g  ON co.`co_order_goods_id`=g.`cog_id`
        </if>
        WHERE hb.hb_id IS NOT NULL
        <include refid="SELECT_PARAM_ORDER_STATE" />
        <!-- 订单状态 -->
@@ -888,6 +909,20 @@
        </if>
        <!-- 订单来源 -->
        <if test="source != null">AND co.co_source_type = #{source}</if>
        <if test="listGoodsId != null">
            <foreach collection="listGoodsId" item="goodsId" open=" and (" separator=" or " close=")">
                co.`co_order_goods_id` =#{goodsId}
            </foreach>
        </if>
        <if test="listShopId != null">
            <foreach collection="listShopId" item="shopId" open=" and (" separator=" or " close=")">
                g.`cog_shop_id` =#{shopId}
            </foreach>
        </if>
        <if test="minTime != null"> <!-- 高风险订单 -->
            AND co.`co_third_create_time`>#{minTime} AND <![CDATA[ (co.`co_estimate`>=  ${money} OR co.`co_eIncome`> ${money})]]>
        </if>
    </select>
@@ -972,6 +1007,29 @@
        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(co.`co_create_time`,'%Y%m') =    DATE_FORMAT(CURDATE(),'%Y%m')
            </if>
            <if test="typeDate == 4"> <!-- 上月 -->
                AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),DATE_FORMAT(co.`co_create_time`, '%Y%m')) = 1
            </if>
        ORDER BY co.`co_id`
        LIMIT 1
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackBalanceMapper.xml
@@ -10,11 +10,11 @@
  </resultMap>
  <sql id="Base_Column_List">rpb_uid,rpb_money,rpb_create_time,rpb_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_red_pack_balance where rpb_uid = #{id,jdbcType=BIGINT}
    <include refid="Base_Column_List"/>from yeshi_ec_red_pack_balance where rpb_uid = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_balance where rpb_uid = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_balance (rpb_uid,rpb_money,rpb_create_time,rpb_update_time) values (#{id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_balance
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_red_pack_balance where rpb_uid = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_balance (rpb_uid,rpb_money,rpb_create_time,rpb_update_time) values (#{id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_balance
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpb_uid,</if>
      <if test="money != null">rpb_money,</if>
@@ -28,8 +28,8 @@
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance">update yeshi_red_pack_balance set rpb_money = #{money,jdbcType=DECIMAL},rpb_create_time = #{createTime,jdbcType=TIMESTAMP},rpb_update_time = #{updateTime,jdbcType=TIMESTAMP} where rpb_uid = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance">update yeshi_red_pack_balance
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance">update yeshi_ec_red_pack_balance set rpb_money = #{money,jdbcType=DECIMAL},rpb_create_time = #{createTime,jdbcType=TIMESTAMP},rpb_update_time = #{updateTime,jdbcType=TIMESTAMP} where rpb_uid = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance">update yeshi_ec_red_pack_balance
    <set>
      <if test="money != null">rpb_money=#{money,jdbcType=DECIMAL},</if>
      <if test="createTime != null">rpb_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
@@ -38,17 +38,17 @@
  </update>
  
  <update id="subRedPack">
      update yeshi_red_pack_balance SET rpb_money = rpb_money - #{money,jdbcType=DECIMAL},rpb_update_time = NOW()
      update yeshi_ec_red_pack_balance SET rpb_money = rpb_money - #{money,jdbcType=DECIMAL},rpb_update_time = NOW()
      WHERE rpb_uid = #{id,jdbcType=BIGINT}
  </update>
    
  <update id="addRedPack">
      UPDATE yeshi_red_pack_balance SET rpb_money = rpb_money + #{money,jdbcType=DECIMAL},rpb_update_time = NOW()
      UPDATE yeshi_ec_red_pack_balance SET rpb_money = rpb_money + #{money,jdbcType=DECIMAL},rpb_update_time = NOW()
      WHERE rpb_uid = #{id,jdbcType=BIGINT}
  </update>
    
  <select id="selectForUpdate" resultMap="BaseResultMap" parameterType="java.lang.Long">
       SELECT <include refid="Base_Column_List"/> FROM yeshi_red_pack_balance
       SELECT <include refid="Base_Column_List"/> FROM yeshi_ec_red_pack_balance
       WHERE rpb_uid = #{id,jdbcType=BIGINT} FOR UPDATE
  </select>
  
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackConfigMapper.xml
@@ -14,11 +14,11 @@
  </resultMap>
  <sql id="Base_Column_List">rpc_id,rpc_name,rpc_key,rpc_value,rpc_remark,rpc_start_time,rpc_create_time,rpc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_red_pack_config where rpc_id = #{id,jdbcType=BIGINT}
    <include refid="Base_Column_List"/>from yeshi_ec_red_pack_config where rpc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_config where rpc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_config (rpc_id,rpc_name,rpc_key,rpc_value,rpc_remark,rpc_start_time,rpc_create_time,rpc_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{key,jdbcType=VARCHAR},#{value,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{startTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_config
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_red_pack_config where rpc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_config (rpc_id,rpc_name,rpc_key,rpc_value,rpc_remark,rpc_start_time,rpc_create_time,rpc_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{key,jdbcType=VARCHAR},#{value,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{startTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_config
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpc_id,</if>
      <if test="name != null">rpc_name,</if>
@@ -40,8 +40,8 @@
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig">update yeshi_red_pack_config set rpc_name = #{name,jdbcType=VARCHAR},rpc_key = #{key,jdbcType=VARCHAR},rpc_value = #{value,jdbcType=VARCHAR},rpc_remark = #{remark,jdbcType=VARCHAR},rpc_start_time = #{startTime,jdbcType=TIMESTAMP},rpc_create_time = #{createTime,jdbcType=TIMESTAMP},rpc_update_time = #{updateTime,jdbcType=TIMESTAMP} where rpc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig">update yeshi_red_pack_config
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig">update yeshi_ec_red_pack_config set rpc_name = #{name,jdbcType=VARCHAR},rpc_key = #{key,jdbcType=VARCHAR},rpc_value = #{value,jdbcType=VARCHAR},rpc_remark = #{remark,jdbcType=VARCHAR},rpc_start_time = #{startTime,jdbcType=TIMESTAMP},rpc_create_time = #{createTime,jdbcType=TIMESTAMP},rpc_update_time = #{updateTime,jdbcType=TIMESTAMP} where rpc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig">update yeshi_ec_red_pack_config
    <set>
      <if test="name != null">rpc_name=#{name,jdbcType=VARCHAR},</if>
      <if test="key != null">rpc_key=#{key,jdbcType=VARCHAR},</if>
@@ -54,7 +54,7 @@
  </update>
  
  <select id="getByKey" resultMap="BaseResultMap">
      SELECT * FROM yeshi_red_pack_config t
      SELECT * FROM yeshi_ec_red_pack_config t
      WHERE t.`rpc_key` = #{key} and #{startTime} >= rpc_start_time 
      ORDER BY rpc_start_time DESC LIMIT 1
  </select>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackDetailMapper.xml
@@ -8,7 +8,7 @@
    <result column="rpd_uid" property="uid" jdbcType="BIGINT"/>
    <result column="rpd_money" property="money" jdbcType="DECIMAL"/>
    <result column="rpd_title" property="title" jdbcType="VARCHAR"/>
    <result column="rpd_desc" property="desc" jdbcType="VARCHAR"/>
    <result column="rpd_desc_info" property="descInfo" jdbcType="VARCHAR"/>
    <result column="rpd_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="rpd_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="rpd_display" property="display" jdbcType="VARCHAR"/>
@@ -21,13 +21,13 @@
        <result column="dateFormate" property="dateFormate" jdbcType="VARCHAR" />
  </resultMap>
  
  <sql id="Base_Column_List">rpd_id,rpd_identify_code,rpd_uid,rpd_money,rpd_title,rpd_type,rpd_desc,rpd_remark,rpd_create_time,rpd_display</sql>
  <sql id="Base_Column_List">rpd_id,rpd_identify_code,rpd_uid,rpd_money,rpd_title,rpd_type,rpd_desc_info,rpd_remark,rpd_create_time,rpd_display</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_red_pack_detail where rpd_id = #{id,jdbcType=BIGINT}
    <include refid="Base_Column_List"/>from yeshi_ec_red_pack_detail where rpd_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_detail where rpd_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_detail (rpd_id,rpd_identify_code,rpd_uid,rpd_money,rpd_title,rpd_type,rpd_desc,rpd_remark,rpd_create_time,rpd_display) values (#{id,jdbcType=BIGINT},,#{identifyCode,jdbcType=VARCHAR}#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{title,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{desc,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{display,jdbcType=VARCHAR})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_detail
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_red_pack_detail where rpd_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_detail (rpd_id,rpd_identify_code,rpd_uid,rpd_money,rpd_title,rpd_type,rpd_desc_info,rpd_remark,rpd_create_time,rpd_display) values (#{id,jdbcType=BIGINT},,#{identifyCode,jdbcType=VARCHAR}#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{title,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{descInfo,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{display,jdbcType=VARCHAR})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_detail
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpd_id,</if>
      <if test="identifyCode != null">rpd_identify_code,</if>
@@ -35,7 +35,7 @@
      <if test="money != null">rpd_money,</if>
      <if test="title != null">rpd_title,</if>
      <if test="type != null">rpd_type,</if>
      <if test="desc != null">rpd_desc,</if>
      <if test="descInfo != null">rpd_desc_info,</if>
      <if test="remark != null">rpd_remark,</if>
      <if test="createTime != null">rpd_create_time,</if>
      <if test="display != null">rpd_display,</if>
@@ -47,21 +47,21 @@
      <if test="money != null">#{money,jdbcType=DECIMAL},</if>
      <if test="title != null">#{title,jdbcType=VARCHAR},</if>
      <if test="type != null">#{type,jdbcType=VARCHAR},</if>
      <if test="desc != null">#{desc,jdbcType=VARCHAR},</if>
      <if test="descInfo != null">#{descInfo,jdbcType=VARCHAR},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="display != null">#{display,jdbcType=VARCHAR},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail">update yeshi_red_pack_detail set rpd_identify_code = #{identifyCode,jdbcType=VARCHAR},rpd_uid = #{uid,jdbcType=BIGINT},rpd_money = #{money,jdbcType=DECIMAL},rpd_title = #{title,jdbcType=VARCHAR},rpd_type = #{type,jdbcType=VARCHAR},rpd_desc = #{desc,jdbcType=VARCHAR},rpd_remark = #{remark,jdbcType=VARCHAR},rpd_create_time = #{createTime,jdbcType=TIMESTAMP} where rpd_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail">update yeshi_red_pack_detail
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail">update yeshi_ec_red_pack_detail set rpd_identify_code = #{identifyCode,jdbcType=VARCHAR},rpd_uid = #{uid,jdbcType=BIGINT},rpd_money = #{money,jdbcType=DECIMAL},rpd_title = #{title,jdbcType=VARCHAR},rpd_type = #{type,jdbcType=VARCHAR},rpd_desc_info = #{descInfo,jdbcType=VARCHAR},rpd_remark = #{remark,jdbcType=VARCHAR},rpd_create_time = #{createTime,jdbcType=TIMESTAMP} where rpd_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail">update yeshi_ec_red_pack_detail
    <set>
      <if test="identifyCode != null">rpd_identify_code=#{identifyCode,jdbcType=VARCHAR},</if>
      <if test="uid != null">rpd_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="money != null">rpd_money=#{money,jdbcType=DECIMAL},</if>
      <if test="title != null">rpd_title=#{title,jdbcType=VARCHAR},</if>
      <if test="type != null">rpd_type=#{type,jdbcType=VARCHAR},</if>
      <if test="desc != null">rpd_desc=#{desc,jdbcType=VARCHAR},</if>
      <if test="descInfo != null">rpd_desc_info=#{descInfo,jdbcType=VARCHAR},</if>
      <if test="remark != null">rpd_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="createTime != null">rpd_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="display != null">rpd_display=#{display,jdbcType=VARCHAR},</if>
@@ -69,12 +69,12 @@
  </update>
  
  <select id="getByIdentifyCode" resultMap="BaseResultMap">
      SELECT * FROM `yeshi_red_pack_detail` t
      SELECT * FROM `yeshi_ec_red_pack_detail` t
    WHERE t.`rpd_identify_code` = #{identifyCode}
  </select>
  
  <select id="countUseMoneyByDate" resultType="java.math.BigDecimal">
      SELECT IFNULL(SUM(t.`rpd_money`),0) FROM `yeshi_red_pack_detail` t
      SELECT IFNULL(SUM(t.`rpd_money`),0) FROM `yeshi_ec_red_pack_detail` t
    WHERE t.rpd_display = 1 AND t.`rpd_money` <![CDATA[<]]> 0 AND t.`rpd_uid` = #{uid} AND t.`rpd_type` <![CDATA[<>]]> 'violation'
        <if test="dateType == 1"> <!-- 今日  -->
            AND TO_DAYS(t.`rpd_create_time`) =  TO_DAYS(NOW());
@@ -92,7 +92,7 @@
  
  
  <select id="countAddMoneyByDate" resultType="java.math.BigDecimal">
      SELECT IFNULL(SUM(t.`rpd_money`),0) FROM `yeshi_red_pack_detail` t
      SELECT IFNULL(SUM(t.`rpd_money`),0) FROM `yeshi_ec_red_pack_detail` t
    WHERE t.rpd_display = 1 AND t.`rpd_money` <![CDATA[>]]> 0  AND t.`rpd_uid` = #{uid} AND  t.`rpd_type`<![CDATA[<>]]>'refund'
        <if test="dateType == 1"> <!-- 今日  -->
            AND TO_DAYS(t.`rpd_create_time`) =  TO_DAYS(NOW());
@@ -109,16 +109,16 @@
  </select>
  
  <select id="selectByMaxCreateTime" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List" /> FROM yeshi_red_pack_detail t
    SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_red_pack_detail t
    WHERE t.rpd_display = 1 AND t.`rpd_uid`=#{uid} AND t.`rpd_create_time`<![CDATA[<=]]> #{date} 
    ORDER BY t.`rpd_create_time` DESC,t.rpd_id DESC
    LIMIT #{count}
  </select>
  
  <select id="selectByUidWithIndexId" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List" />    FROM yeshi_red_pack_detail t
    SELECT <include refid="Base_Column_List" />    FROM yeshi_ec_red_pack_detail t
    WHERE t.rpd_display = 1 AND t.`rpd_uid`=#{uid}
        AND t.`rpd_create_time`<![CDATA[<=]]>(SELECT rpd_create_time FROM yeshi_red_pack_detail WHERE rpd_id =#{id})
        AND t.`rpd_create_time`<![CDATA[<=]]>(SELECT rpd_create_time FROM yeshi_ec_red_pack_detail WHERE rpd_id =#{id})
    ORDER BY t.`rpd_create_time` DESC,t.rpd_id DESC
    LIMIT #{count}
  </select>
@@ -130,13 +130,13 @@
                SELECT c.time AS dateFormate , IF(a.money IS NULL,0,a.money) AS income ,IF(b.money IS NULL,0,b.money) AS expend
                FROM (SELECT  #{item} AS `time`) c 
                LEFT JOIN (SELECT DATE_FORMAT(d.`rpd_create_time`,'%Y-%m') AS `time`,SUM(d.`rpd_money`)AS money
                               FROM `yeshi_red_pack_detail` d
                               FROM `yeshi_ec_red_pack_detail` d
                               WHERE d.rpd_display = 1 AND d.`rpd_uid`=#{uid} AND  d.`rpd_money`<![CDATA[>=]]>0 AND DATE_FORMAT(d.`rpd_create_time`,'%Y-%m')=#{item} 
                               GROUP BY DATE_FORMAT(d.`rpd_create_time`,'%Y-%m')
                               ) a ON a.time=c.time
                LEFT JOIN(SELECT DATE_FORMAT(d.`rpd_create_time`,'%Y-%m') AS `time`,SUM(d.`rpd_money`) AS money
                              FROM `yeshi_red_pack_detail` d
                              FROM `yeshi_ec_red_pack_detail` d
                            WHERE d.rpd_display = 1 AND d.`rpd_uid`=#{uid} AND d.`rpd_money` <![CDATA[<]]>0 AND DATE_FORMAT(d.`rpd_create_time`,'%Y-%m')=#{item} 
                              GROUP BY DATE_FORMAT(d.`rpd_create_time`,'%Y-%m')
                              ) b ON c.time=b.time
@@ -145,20 +145,20 @@
  </select>
  
  <select id="selectCountByUid" resultType="java.lang.Long"  parameterType="java.lang.Long">
    SELECT count(rpd_id) FROM yeshi_red_pack_detail
    SELECT count(rpd_id) FROM yeshi_ec_red_pack_detail
    WHERE rpd_display = 1 AND rpd_uid=#{uid}
  </select>
  
  <select id="selectMonthCountByUid" resultType="java.lang.Integer">
    SELECT COUNT(*) FROM 
            (SELECT * FROM yeshi_red_pack_detail d
            (SELECT * FROM yeshi_ec_red_pack_detail d
             WHERE d.rpd_display = 1 AND d.`rpd_uid`=#{uid} AND d.`rpd_create_time` <![CDATA[<=]]> #{date} 
             GROUP BY DATE_FORMAT(d.`rpd_create_time`,'%y-%m')
             ) a
  </select>
  
  <select id="selectCountByUidAndMaxCreateTime" resultType="java.lang.Long">
    SELECT count(rpd_id) FROM yeshi_red_pack_detail
    SELECT count(rpd_id) FROM yeshi_ec_red_pack_detail
    WHERE rpd_display = 1 AND rpd_uid=#{uid} and `rpd_create_time`<![CDATA[<=]]>#{date}
 </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackExchangeMapper.xml
@@ -14,11 +14,11 @@
  </resultMap>
  <sql id="Base_Column_List">rpe_id,rpe_uid,rpe_money,rpe_state,rpe_audit_id,rpe_reason,rpe_audit_time,rpe_create_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_red_pack_exchange where rpe_id = #{id,jdbcType=BIGINT}
    <include refid="Base_Column_List"/>from yeshi_ec_red_pack_exchange where rpe_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_exchange where rpe_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_exchange (rpe_id,rpe_uid,rpe_money,rpe_state,rpe_audit_id,rpe_reason,rpe_audit_time,rpe_create_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{state,jdbcType=INTEGER},#{auditId,jdbcType=BIGINT},#{reason,jdbcType=VARCHAR},#{auditTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_exchange
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_red_pack_exchange where rpe_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_exchange (rpe_id,rpe_uid,rpe_money,rpe_state,rpe_audit_id,rpe_reason,rpe_audit_time,rpe_create_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{state,jdbcType=INTEGER},#{auditId,jdbcType=BIGINT},#{reason,jdbcType=VARCHAR},#{auditTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_exchange
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpe_id,</if>
      <if test="uid != null">rpe_uid,</if>
@@ -40,8 +40,8 @@
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange">update yeshi_red_pack_exchange set rpe_uid = #{uid,jdbcType=BIGINT},rpe_money = #{money,jdbcType=DECIMAL},rpe_state = #{state,jdbcType=INTEGER},rpe_audit_id = #{auditId,jdbcType=BIGINT},rpe_reason = #{reason,jdbcType=VARCHAR},rpe_audit_time = #{auditTime,jdbcType=TIMESTAMP},rpe_create_time = #{createTime,jdbcType=TIMESTAMP} where rpe_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange">update yeshi_red_pack_exchange
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange">update yeshi_ec_red_pack_exchange set rpe_uid = #{uid,jdbcType=BIGINT},rpe_money = #{money,jdbcType=DECIMAL},rpe_state = #{state,jdbcType=INTEGER},rpe_audit_id = #{auditId,jdbcType=BIGINT},rpe_reason = #{reason,jdbcType=VARCHAR},rpe_audit_time = #{auditTime,jdbcType=TIMESTAMP},rpe_create_time = #{createTime,jdbcType=TIMESTAMP} where rpe_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange">update yeshi_ec_red_pack_exchange
    <set>
      <if test="uid != null">rpe_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="money != null">rpe_money=#{money,jdbcType=DECIMAL},</if>
@@ -54,7 +54,7 @@
  </update>
  
  <select id="query" resultMap="BaseResultMap">
      SELECT * FROM yeshi_red_pack_exchange d
      SELECT * FROM yeshi_ec_red_pack_exchange d
    WHERE 1=1 
        <if test="key != null and key != ''">
            AND d.rpe_uid = #{key}
@@ -67,7 +67,7 @@
  </select>
  
  <select id="count" resultType="Long">
      SELECT IFNULL(COUNT(rpe_id),0) FROM yeshi_red_pack_exchange d
      SELECT IFNULL(COUNT(rpe_id),0) FROM yeshi_ec_red_pack_exchange d
    WHERE 1=1 
        <if test="key != null and key != ''">
            AND d.rpe_uid = #{key}
@@ -78,12 +78,12 @@
  </select>
  
  <select id="countByUidAndState" resultType="Long">
    SELECT IFNULL(COUNT(d.rpe_id),0) FROM yeshi_red_pack_exchange d
    SELECT IFNULL(COUNT(d.rpe_id),0) FROM yeshi_ec_red_pack_exchange d
    WHERE d.rpe_uid = #{uid} AND d.`rpe_state` = #{state}
  </select>
  
  <select id="countMoneyByUidAndState" resultType="BigDecimal">
      SELECT IFNULL(SUM(d.rpe_money),0) FROM yeshi_red_pack_exchange d
      SELECT IFNULL(SUM(d.rpe_money),0) FROM yeshi_ec_red_pack_exchange d
    WHERE d.rpe_uid = #{uid} AND d.`rpe_state` = #{state}
  </select>
  
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackGiveRecordMapper.xml
@@ -14,11 +14,11 @@
  </resultMap>
  <sql id="Base_Column_List">rpgr_id,rpgr_money,rpgr_give_uid,rpgr_give_time,rpgr_end_time,rpgr_receive_uid,rpgr_receive_time,rpgr_state</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_red_pack_give_record where rpgr_id = #{id,jdbcType=BIGINT}
    <include refid="Base_Column_List"/>from yeshi_ec_red_pack_give_record where rpgr_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_give_record where rpgr_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_give_record (rpgr_id,rpgr_money,rpgr_give_uid,rpgr_give_time,rpgr_end_time,rpgr_receive_uid,rpgr_receive_time,rpgr_state) values (#{id,jdbcType=BIGINT},#{amount,jdbcType=DECIMAL},#{giveUid,jdbcType=BIGINT},#{giveTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{receiveUid,jdbcType=BIGINT},#{receiveTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_give_record
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_red_pack_give_record where rpgr_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_give_record (rpgr_id,rpgr_money,rpgr_give_uid,rpgr_give_time,rpgr_end_time,rpgr_receive_uid,rpgr_receive_time,rpgr_state) values (#{id,jdbcType=BIGINT},#{amount,jdbcType=DECIMAL},#{giveUid,jdbcType=BIGINT},#{giveTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{receiveUid,jdbcType=BIGINT},#{receiveTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_give_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpgr_id,</if>
      <if test="amount != null">rpgr_money,</if>
@@ -40,8 +40,8 @@
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord">update yeshi_red_pack_give_record set rpgr_money = #{amount,jdbcType=DECIMAL},rpgr_give_uid = #{giveUid,jdbcType=BIGINT},rpgr_give_time = #{giveTime,jdbcType=TIMESTAMP},rpgr_end_time = #{endTime,jdbcType=TIMESTAMP},rpgr_receive_uid = #{receiveUid,jdbcType=BIGINT},rpgr_receive_time = #{receiveTime,jdbcType=TIMESTAMP},rpgr_state = #{state,jdbcType=INTEGER} where rpgr_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord">update yeshi_red_pack_give_record
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord">update yeshi_ec_red_pack_give_record set rpgr_money = #{amount,jdbcType=DECIMAL},rpgr_give_uid = #{giveUid,jdbcType=BIGINT},rpgr_give_time = #{giveTime,jdbcType=TIMESTAMP},rpgr_end_time = #{endTime,jdbcType=TIMESTAMP},rpgr_receive_uid = #{receiveUid,jdbcType=BIGINT},rpgr_receive_time = #{receiveTime,jdbcType=TIMESTAMP},rpgr_state = #{state,jdbcType=INTEGER} where rpgr_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord">update yeshi_ec_red_pack_give_record
    <set>
      <if test="amount != null">rpgr_money=#{amount,jdbcType=DECIMAL},</if>
      <if test="giveUid != null">rpgr_give_uid=#{giveUid,jdbcType=BIGINT},</if>
@@ -52,4 +52,11 @@
      <if test="state != null">rpgr_state=#{state,jdbcType=INTEGER},</if>
    </set> where rpgr_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="overdueList" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_red_pack_give_record
    WHERE rpgr_state = 0 AND rpgr_end_time IS NOT NULL AND rpgr_end_time <![CDATA[<]]> NOW()
    LIMIT #{count}
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackWinInviteMapper.xml
New file
@@ -0,0 +1,82 @@
<?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_ec_red_pack_win_invite where rwr_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_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_ec_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_ec_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_ec_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_ec_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_ec_red_pack_win_invite d
    WHERE d.`rwr_uid` = #{uid} AND d.`rwr_type` = #{type}
  </select>
  <select id="countByUidAndTeamUidAndType" resultType="Long">
      SELECT IFNULL(COUNT(d.`rwr_id`),0) FROM yeshi_ec_red_pack_win_invite d
    WHERE d.`rwr_uid` = #{uid} AND d.`rwr_team_uid` = #{teamUid} AND d.`rwr_type` = #{type}
  </select>
  <select id="getRewardList" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_red_pack_win_invite d
    WHERE d.`rwr_uid` = #{uid}
    ORDER BY d.`rwr_id` DESC
    LIMIT #{start},#{count}
  </select>
  <select id="countRewardRecord" resultType="Long">
      SELECT IFNULL(COUNT(d.`rwr_id`),0) FROM yeshi_ec_red_pack_win_invite d
    WHERE d.`rwr_uid` = #{uid}
  </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
@@ -118,8 +118,11 @@
            } else {
                record.setIcon(resultObj.getIcon());
            }
            record.setGoodsTotal(resultObj.getGoodsTotal());
            if (state == 0){
                record.setGoodsTotal(0);
            } else {
                record.setGoodsTotal(resultObj.getGoodsTotal());
            }
            record.setCreateTime(resultObj.getCreateTime());
            record.setUpdateTime(new Date());
            brandInfoMapper.updateByPrimaryKey(record);
@@ -255,8 +258,35 @@
        
        // 删除店铺
        brandShopCaheService.removeAgoByDate(date);
        long count = brandInfoMapper.countValidByCid(null);
        if (count == 0)
            return;
        for (int page = 0; page < (count / 100) + 1; page++) {
            updateTotalGoods(page * 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/count/CommonOrderCountServiceImpl.java
@@ -251,4 +251,14 @@
        return commonOrderCountMapper.countSameGoodsOrderByUidAndHongBaoType(typeList, uid, minSameGoodsOrderCount);
    }
    @Override
    public List<Long> getSameShopOrderByUidAndHongBaoType(List<Integer> typeList, Long uid, int minSameShopGoodsCount) {
        return commonOrderCountMapper.getSameShopOrderByUidAndHongBaoType(typeList, uid, minSameShopGoodsCount);
    }
    @Override
    public List<Long> getSameGoodsOrderByUidAndHongBaoType(List<Integer> typeList, Long uid, int minSameGoodsOrderCount) {
        return commonOrderCountMapper.getSameGoodsOrderByUidAndHongBaoType(typeList, uid, minSameGoodsOrderCount);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/MsgMoneyDetailServiceImpl.java
@@ -11,6 +11,7 @@
import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail;
import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
import com.yeshi.fanli.exception.msg.MsgMoneyDetailException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.money.msg.MsgMoneyDetailService;
import com.yeshi.fanli.service.inter.msg.UserMsgReadStateService;
import com.yeshi.fanli.util.Constant;
@@ -127,14 +128,23 @@
                msgMoneyDetailMapper.updateByPrimaryKeySelective(update);
            }
        } else if (detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackGiveOff
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackReceiveOff
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackGiveBack
                || 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());
            detail.setUpdateTime(new Date());
            detail.setRead(false);
            msgMoneyDetailMapper.insertSelective(detail);
            System.out.println("1-insertSelective执行数据。。。。。。。。。。" + detail.getId());
            LogHelper.test("1-insertSelective执行数据。。。。。。。。。。" + detail.getId());
        } else if (detail.getMsgType() == MsgTypeMoneyTypeEnum.subSidy) {
            if (detail.getMoney() == null || detail.getUser() == null)
                throw new MsgMoneyDetailException(2, "消息信息不全");
@@ -145,6 +155,8 @@
        }
        userMsgReadStateService.addMoneyMsgUnReadCount(detail.getUser().getId(), 1);
        System.out.println("1-insertSelective执行数据完成。。。。。。。。。。");
        LogHelper.test("2-insertSelective执行数据。。。。。。。。。。" + detail.getId());
    }
    @Override
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/UserMoneyMsgNotificationServiceImpl.java
@@ -286,7 +286,6 @@
        }
    }
    
    @Async
    @Override
    public void redPackMsg(Long uid, MsgTypeMoneyTypeEnum type, String content, String beiZhu) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createRedPackMsg(uid, type, content, beiZhu);
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -275,11 +275,11 @@
        }
        boolean rewardOrder = false;
        int type = 1; // 1 常规跳转页面 2弹出选项(奖励券)
        if (rewardSuccess) {
            // 奖励成功
            rewardOrder = true;
            if (!VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
                rewardOrder = true; //奖励成功 2.0.2 消失
            }
        } else if (hasRewardCoupon && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType
                && HongBaoV2.STATE_YILINGQU == hongBaoState) {
            // 有可用的奖励券 、非免单订单 、且已到账的 、返利订单
@@ -1177,7 +1177,8 @@
    @Override
    public List<CommonOrderVO> listQuery(long start, int count, Integer keyType, String key, Integer state,
            Integer type, Integer orderState, String startTime, String endTime, Integer source)
            Integer type, Integer orderState, String startTime, String endTime, Integer source,List<Long> listShopId,
            List<Long> listGoodsId, Date minTime, BigDecimal money)
            throws CommonOrderException {
        List<CommonOrderVO> list = null;
@@ -1185,10 +1186,11 @@
        if (StringUtil.isNullOrEmpty(key) || keyType == 1) {// 搜索框无值或者按订单号搜索时都只搜索主订单
            list = commonOrderMapper.listQueryWithNoChild(start, count, keyType, key, state, type, orderState,
                    startTime, endTime, source);
        } else
        } else {
            list = commonOrderMapper.listQuery(start, count, keyType, key, state, type, orderState, startTime, endTime,
                    source);
                    source, listShopId, listGoodsId, minTime, money);
        }
        if (list == null) {
            list = new ArrayList<CommonOrderVO>();
        }
@@ -1372,12 +1374,15 @@
    @Override
    public long countQuery(Integer keyType, String key, Integer state, Integer type, Integer orderState,
            String startTime, String endTime, Integer source) throws CommonOrderException {
            String startTime, String endTime, Integer source, List<Long> listShopId, List<Long> listGoodsId,
            Date minTime, BigDecimal money) throws CommonOrderException {
        if (StringUtil.isNullOrEmpty(key) || keyType == 1) {// 搜索框无值或者按订单号搜索时都只搜索主订单
            return commonOrderMapper.countQueryWithNoChild(keyType, key, state, type, orderState, startTime, endTime,
                    source);
        } else
            return commonOrderMapper.countQuery(keyType, key, state, type, orderState, startTime, endTime, source);
        } else {
            return commonOrderMapper.countQuery(keyType, key, state, type, orderState, startTime, endTime, source, listShopId,
                    listGoodsId, minTime,money);
        }
    }
    @Override
@@ -1573,4 +1578,22 @@
        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 firstValidOrderLastMonthByUidAndType(Long uid, Integer type) {
        return commonOrderMapper.firstValidOrderByUid(uid, type, 4);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java
@@ -32,12 +32,11 @@
    @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 redPackBalance.getMoney();
        return new BigDecimal(0);
    }
@@ -65,8 +64,18 @@
            throw new RedPackBalanceException(1, "参数传递不完整");
        // 加入明细
        redPackDetailService.insertSelective(detail);
        // 减少红包
        redPackBalanceMapper.addRedPack(uid, money);
        // 添加红包
        RedPackBalance redPackBalance = redPackBalanceMapper.selectForUpdate(uid);
        if (redPackBalance == null) {
            redPackBalance = new RedPackBalance();
            redPackBalance.setId(uid);
            redPackBalance.setMoney(money);
            redPackBalance.setCreateTime(new Date());
            redPackBalance.setUpdateTime(new Date());
            redPackBalanceMapper.insertSelective(redPackBalance);
        } else {
            redPackBalanceMapper.addRedPack(uid, money);
        }
    }
    @Override
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/RedPackGiveRecordServiceImpl.java
@@ -1,7 +1,9 @@
package com.yeshi.fanli.service.impl.redpack;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
@@ -9,13 +11,17 @@
import org.springframework.transaction.annotation.Transactional;
import org.yeshi.utils.DateUtil;
import com.google.gson.Gson;
import com.yeshi.fanli.dao.mybatis.redpack.RedPackGiveRecordMapper;
import com.yeshi.fanli.dto.msg.MsgRedPackGiveContentDTO;
import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
import com.yeshi.fanli.entity.bus.user.TokenRecord;
import com.yeshi.fanli.entity.bus.user.TokenRecord.TokenTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackDetail;
import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackGiveRecord;
import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
@@ -45,6 +51,9 @@
    @Resource
    private RedPackDetailService redPackDetailService;
    
    @Resource
    private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
    
    @Override
    public RedPackGiveRecord selectByPrimaryKey(Long id) {
@@ -56,6 +65,38 @@
        redPackGiveRecordMapper.updateByPrimaryKeySelective(record);
    }
    
    @Override
    public List<RedPackGiveRecord> overdueList(int count) {
        return redPackGiveRecordMapper.overdueList(count);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void overdue(List<RedPackGiveRecord> list) throws Exception {
        if (list == null || list.size() == 0)
            return;
        SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
        RedPackGiveRecord updateRecord = null;
        for (RedPackGiveRecord giveRecord: list) {
            updateRecord = new RedPackGiveRecord();
            updateRecord.setId(giveRecord.getId());
            updateRecord.setState(1);
            redPackGiveRecordMapper.updateByPrimaryKeySelective(updateRecord);
            // 退回红包
            redPackBalanceService.addRedPack(giveRecord.getGiveUid(), giveRecord.getAmount(), RedPackDetailFactory.createGiveOthersFail(giveRecord));
            // 退回消息
            MsgRedPackGiveContentDTO givedto = new MsgRedPackGiveContentDTO();
            givedto.setTitle("你赠送的红包未被成功领取");
            givedto.setMoney("¥" + giveRecord.getAmount().setScale(2));
            givedto.setTime(sd.format(new Date()));
            givedto.setGiveTime(sd.format(giveRecord.getGiveTime()));
            userMoneyMsgNotificationService.redPackMsg(giveRecord.getGiveUid(), MsgTypeMoneyTypeEnum.redPackGiveBack, new Gson().toJson(givedto), "请到我的-红包查看");
        }
    }
    
    
    @Override
@@ -104,7 +145,7 @@
            tips = tips.replace("{APP名称}", projectChineseName);
        }
        tips = tips.replace("{口令}", token).replace("{下载链接}", redPackConfigService.getValueByKey("app_down_link")).replace("{面额}",
                amount.toString());
                amount.setScale(2).toString());
        
        // 减少红包
        try {
@@ -128,7 +169,7 @@
        if (endTime != null && endTime.getTime() < now.getTime())
            throw new RedPackGiveRecordException(1, "红包已失效了");
        
        giveRecord.setGiveUid(uid);
        giveRecord.setReceiveUid(uid);
        giveRecord.setReceiveTime(now);
        giveRecord.setState(RedPackGiveRecord.STATE_RECEIVE);
        // 领取人增加红包
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
New file
@@ -0,0 +1,347 @@
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.UserExtraTaoBaoInfo;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.order.CommonOrder;
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.UserInfoService;
import com.yeshi.fanli.service.inter.user.integral.IntegralTaskRecordService;
import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
import com.yeshi.fanli.util.annotation.redpack.RedPackGetVersionLimit;
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;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
    @Resource
    private IntegralTaskRecordService integralTaskRecordService;
    @Override
    public List<RedPackWinInvite> getRewardList(int start, int count, Long uid) {
        return redPackWinInviteMapper.getRewardList(start, count, uid);
    }
    @Override
    public Long countRewardRecord(Long uid) {
        return redPackWinInviteMapper.countRewardRecord(uid);
    }
    @RedPackGetVersionLimit(uid = "#uid")
    @RequestSerializableByKeyService(key = "#uid")
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void orderArriveReward(Long uid, Integer source, String orderNo) throws Exception {
        if (uid == null || source == null || orderNo == null)
            return;
        // 上一级的奖励
        UserInfo boss = threeSaleSerivce.getBoss(uid);
        if(boss != null) {
            firstReward(uid, source, orderNo);
            bossReward(boss.getId(), uid, source, orderNo);
        }
    }
    /**
     * 上级奖励
     * @param uid
     * @param teamUid
     * @param source
     * @param orderNo
     * @throws Exception
     */
    @RedPackGetVersionLimit(uid = "#uid")
    @Transactional
    private void  bossReward(Long uid, Long teamUid, Integer source, String orderNo)  throws Exception {
        firstSharedOrderRewardToBoss(uid, teamUid, source, orderNo);
        firstSharedOrderRewardTheMonthToBoss(uid, teamUid, source, orderNo);
    }
    /**
     * 被邀请人下首单返利(下单就给):
     * 完成首笔订单 (已到账) 首单=不限制金额、不限制商品、不限制数量、不限制订单类型)
     * @param uid
     * @param source
     * @param orderNo
     * @param bossId
     */
    @Transactional
    private void firstReward(Long uid, Integer source, String orderNo) throws Exception{
        // 奖励一次
        long total = redPackWinInviteMapper.countByUidAndType(uid, RedPackWinInviteTypeEnum.newUserReward.name());
        if (total > 0)
            return;
        // 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{
        // 同一队员奖励一次
        long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(uid, inviteeUid, RedPackWinInviteTypeEnum.firstSharedOrder.name());
        if (totalReward > 0)
            return;
        // 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.firstValidOrderLastMonthByUidAndType(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), "红包可用于购买会员");
    }
    @RequestSerializableByKeyService(key = "#uid")
    @Override
    @Transactional
    public void inviteSucceedReward(Long uid) throws Exception{
        // 验证是否存在上级
        UserInfo boss = threeSaleSerivce.getBoss(uid);
        if(boss == null)
            return;
        // 同一队员奖励一次
        long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(boss.getId(), uid, RedPackWinInviteTypeEnum.inviteSucceed.name());
        if (totalReward > 0)
            return;
        // 1、绑定电话号码
        UserInfo userInfo = userInfoService.selectByPKey(uid);
        if (userInfo == null || StringUtil.isNullOrEmpty(userInfo.getPhone()))
            return;
        // 2、授权淘宝
        UserExtraTaoBaoInfo taoBaoInfo = userExtraTaoBaoInfoService.getByUid(uid);
        if (taoBaoInfo == null || StringUtil.isNullOrEmpty(taoBaoInfo.getTaoBaoUid()))
            return;
        boolean finishTask = false;
        // 3.1、产生任意有效订单(无需到账)
        CommonOrder commonOrder = commonOrderService.selectLatestValidByUid(uid);
        if (commonOrder != null)
            finishTask = true;
        // 3.2、单位时间类累计产生≥200金币
        if (!finishTask) {
            long totalGoldCoin = integralTaskRecordService.getTotalGoldCoinByUid(uid);
            if (totalGoldCoin >= Constant.RED_PACK_GOLD_COIN)
                finishTask = true;
        }
        // 3.3、成功邀请一个好友
        if (!finishTask) {
            long countTeam = threeSaleSerivce.countSuccessFirstTeam(uid);
            if (countTeam >= 1)
                finishTask = true;
        }
        if (finishTask) {
            // 奖励金额
            BigDecimal money = new BigDecimal(redPackConfigService.getValueByKey("invite_succeed"));
            // 获得红包记录
            RedPackWinInvite winInvite = new RedPackWinInvite();
            winInvite.setCreateTime(new Date());
            winInvite.setUpdateTime(new Date());
            winInvite.setType(RedPackWinInviteTypeEnum.inviteSucceed);
            winInvite.setUid(boss.getId());
            winInvite.setTeamUid(uid);
            winInvite.setMoney(money);
            redPackWinInviteMapper.insertSelective(winInvite);
            // 增加红包
            redPackBalanceService.addRedPack(boss.getId(), money, RedPackDetailFactory.createInvite(winInvite));
            // 消息
            MsgRedPackAddContentDTO dto = new MsgRedPackAddContentDTO();
            dto.setTitle("红包增加");
            dto.setMoney("¥" + money.setScale(2));
            dto.setBalance("¥" + redPackBalanceService.getBalance(boss.getId()).setScale(2));
            userMoneyMsgNotificationService.redPackMsg(boss.getId(), MsgTypeMoneyTypeEnum.redPackInviteSucceed, new Gson().toJson(dto), "红包可用于购买会员");
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
@@ -171,7 +171,7 @@
                state = true;
                UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
                if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
                    tips.add("确认领取后,你将成为赠送者的一级队员;");
                    tips.add("确认领取后,你将成为赠送人的一级队员;");
                    tips.add("获赠的免单券,需要激活后才能使用,详情参见免单券激活规则;");
                    tips.add("成功领取后,请到“我的-福利中心”查看。");
                } else {
@@ -207,7 +207,7 @@
                state = true;
                UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
                if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
                    tips.add("确认领取后,你将成为赠送者的一级队员;");
                    tips.add("确认领取后,你将成为赠送人的一级队员;");
                    tips.add("板栗快省奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;");
                    tips.add("成功领取后,请到“我的-福利中心”中查看。");
                } else {
@@ -238,7 +238,7 @@
                state = true;
                UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
                if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
                    tips.add("确认领取后,你将成为增值的一级队员;");
                    tips.add("确认领取后,你将成为赠送人的一级队员;");
                    tips.add("红包可提现,可购买折扣商品;");
                    tips.add("成功领取后,请到“我的-红包”中查看。");
                } else {
@@ -507,7 +507,7 @@
            try {
                msg = "领取红包成功,请到[我的-红包]中查看";
                // 领取红包、更新记录
                RedPackGiveRecord giveRecord = redPackGiveRecordService.receiveFriendsGive(uidToken, Long.parseLong(identify));
                RedPackGiveRecord giveRecord = redPackGiveRecordService.receiveFriendsGive(uid, Long.parseLong(identify));
                // 消息 + 队员
                executor.execute(new Runnable() {
                    @Override
@@ -534,7 +534,7 @@
                        dto.setUserInfo("昵称:" + giveUserName + " ID:" + giveUid);
                        dto.setTime(sd.format(giveRecord.getGiveTime()));
                        dto.setMoney("¥" + giveRecord.getAmount().setScale(2));
                        userMoneyMsgNotificationService.redPackMsg(giveUid, MsgTypeMoneyTypeEnum.redPackReceiveOff, new Gson().toJson(dto), beiZhu);
                        userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackReceiveOff, new Gson().toJson(dto), beiZhu);
                        
                        // 赠送人消息
                        String userName = "无";
@@ -542,7 +542,7 @@
                        if (user != null && !StringUtil.isNullOrEmpty(user.getNickName()))
                            userName = user.getNickName();
                        MsgRedPackGiveContentDTO givedto = new MsgRedPackGiveContentDTO();
                        givedto.setTitle("红包领取");
                        givedto.setTitle("红包赠送");
                        givedto.setUserInfo("昵称:" + userName + " ID:" + uid);
                        givedto.setTime(sd.format(new Date()));
                        givedto.setMoney("¥" + giveRecord.getAmount().setScale(2));
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java
@@ -193,6 +193,7 @@
        userInfoExtra.setFirstLoginTime(new Date());
        userInfoExtra.setCreateTime(new Date());
        userInfoExtra.setUpdateTime(new Date());
        userInfoExtra.setActiveTime(new Date());
        userInfoExtraMapper.insertSelective(userInfoExtra);
    }
@@ -662,7 +663,13 @@
    public UserInfoExtra getUserInfoExtra(Long uid) {
        return userInfoExtraMapper.getInfoExtraByUid(uid);
    }
    @Override
    public UserInfoExtra getUserALLInfo(Long uid) {
        return userInfoExtraMapper.gerUserRank(uid);
    }
    @Override
    public UserInfoExtra getByUidForUpdate(Long uid) {
        return userInfoExtraMapper.getByUidForUpdate(uid);
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponActivateServiceImpl.java
@@ -1,5 +1,7 @@
package com.yeshi.fanli.service.impl.user;
import java.util.Date;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@@ -26,6 +28,17 @@
    }
    
    @Override
    public void addActivateRecord(Long id) {
        UserSystemCouponActivate record = new UserSystemCouponActivate();
        record.setId(id);
        record.setCount(0);
        record.setState(UserSystemCouponActivate.STATE_INIT);
        record.setCreateTime(new Date());
        record.setUpdateTime(new Date());
        userSystemCouponActivateMapper.insertSelective(record);
    }
    @Override
    public void updateByPrimaryKeySelective(UserSystemCouponActivate record) {
        userSystemCouponActivateMapper.updateByPrimaryKeySelective(record);
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -287,8 +287,11 @@
        userCoupon.setEndTime(endTime);
        userCoupon.setCreateTime(new Date());
        userCoupon.setUpdateTime(new Date());
        // 插入数据库
        insertSelective(userCoupon);
        userSystemCouponMapper.insertSelective(userCoupon);
        if(coupon.getType() == CouponTypeEnum.freeCoupon) {
            userSystemCouponActivateService.addActivateRecord(userCoupon.getId());
        }
        executor.execute(new Runnable() {
            @Override
@@ -875,7 +878,7 @@
            Order order = orderService.findOrderByOrderIdAndType(orderNo, sourceType);
            if (order == null)
                return;
                throw new UserSystemCouponException(1, "该订单不存在");
            /* 奖金计算 以及相关红包信息处理 */
@@ -903,7 +906,8 @@
                }, null);
                System.out.println(result);
            } catch (Exception e) {
                throw new Exception();
                e.printStackTrace();
                throw e;
            }
        }
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralTaskRecordServiceImpl.java
@@ -375,6 +375,14 @@
        return integralTaskRecordMapper.listByUidAndTaskId(uid, taskId, (page - 1) * count, count);
    }
    @Override
    public long getTotalGoldCoinByUid(Long uid) {
        return integralTaskRecordMapper.getTotalGoldCoinByUid(uid);
    }
    @Async()
    @Override
    public void firstRebateOrderRewardBoss(Long uid, Long originUid, String beizu) {
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderCountService.java
@@ -4,8 +4,6 @@
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dto.ChartTDO;
public interface CommonOrderCountService {
@@ -113,4 +111,28 @@
     */
    long countSameGoodsOrderByUidAndHongBaoType(List<Integer> typeList, Long uid, int minSameGoodsOrderCount);
    /**
     * 查询用户在同一店铺购买超过一定数量商品的店铺id
     *
     * @param typeList
     *            -红包类型
     * @param uid
     *            -用户ID
     * @param minSameShopGoodsCount
     *            -同一店铺买的最小订单数
     * @return
     */
    List<Long> getSameShopOrderByUidAndHongBaoType(List<Integer> typeList, Long uid, int minSameShopGoodsCount);
    /**
     * 查询用户购买相同商品超过一定的订单数量的商品id
     *
     * @param typeList
     * @param uid
     * @param minSameGoodsOrderCount
     * @return
     */
    List<Long> getSameGoodsOrderByUidAndHongBaoType(List<Integer> typeList, Long uid, int minSameGoodsOrderCount);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java
@@ -223,11 +223,13 @@
     */
    public List<CommonOrderVO> listQuery(long start, int count, Integer keyType, String key, Integer state,
            Integer type, Integer orderState, String startTime, String endTime, Integer source)
            Integer type, Integer orderState, String startTime, String endTime, Integer source,
            List<Long> listShopId, List<Long> listGoodsId, Date minTime, BigDecimal money)
            throws CommonOrderException;
    public long countQuery(Integer keyType, String key, Integer state, Integer type, Integer orderState,
            String startTime, String endTime, Integer source) throws CommonOrderException;
            String startTime, String endTime, Integer source,
            List<Long> listShopId, List<Long> listGoodsId,Date minTime, BigDecimal money) throws CommonOrderException;
    /**
     * 查询订单
@@ -303,5 +305,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 firstValidOrderLastMonthByUidAndType(Long uid, Integer type);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackGiveRecordService.java
@@ -1,6 +1,7 @@
package com.yeshi.fanli.service.inter.redpack;
import java.math.BigDecimal;
import java.util.List;
import com.yeshi.fanli.entity.redpack.RedPackGiveRecord;
import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
@@ -37,5 +38,15 @@
     */
    public RedPackGiveRecord receiveFriendsGive(Long uid, Long id) throws RedPackGiveRecordException;
    /**
     * 查询需要退回的
     * @param count
     * @return
     */
    public List<RedPackGiveRecord> overdueList(int count);
    // 退回红包
    public void overdue(List<RedPackGiveRecord> list) throws Exception;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackWinInviteService.java
New file
@@ -0,0 +1,41 @@
package com.yeshi.fanli.service.inter.redpack;
import java.util.List;
import com.yeshi.fanli.entity.redpack.RedPackWinInvite;
public interface RedPackWinInviteService {
    /**
     * 订单到账-相关奖励
     * @param uid
     * @param inviteeUid
     * @param source
     * @param orderNo
     */
    public void orderArriveReward(Long uid, Integer source, String orderNo) throws Exception;
    /**
     * 查询获得记录
     * @param start
     * @param count
     * @param uid
     * @return
     */
    public List<RedPackWinInvite> getRewardList(int start, int count, Long uid);
    /**
     * 统计条数
     * @param uid
     * @return
     */
    public Long countRewardRecord(Long uid);
    /**
     * 邀请成功奖励
     * @param uid
     * @throws Exception
     */
    public void inviteSucceedReward(Long uid) throws Exception;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserInfoExtraService.java
@@ -160,6 +160,13 @@
     *开启自动提现: 更新超过期限的
     * @param days
     */
    void updateAutoExtract(@Param("days")Integer days);
    public void updateAutoExtract(@Param("days")Integer days);
    /**
     * 返回用户所有相关额外信息
     * @param uid
     * @return
     */
    public UserInfoExtra getUserALLInfo(Long uid);
    
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponActivateService.java
@@ -24,4 +24,10 @@
     */
    public void updateByPrimaryKeySelective(UserSystemCouponActivate record);
    /**
     * 创建记录
     * @param id
     */
    public void addActivateRecord(Long id);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/integral/IntegralTaskRecordService.java
@@ -186,4 +186,11 @@
     */
    public List<IntegralTaskRecord> getSign7DaysRecord(long uid, Long cid);
    /**
     * 统计总金币
     * @param uid
     * @return
     */
    public long getTotalGoldCoinByUid(Long uid);
}
fanli/src/main/java/com/yeshi/fanli/util/Constant.java
@@ -122,6 +122,19 @@
    // 微信自动提现最低余额
    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;
    // 红包奖励-单位时间类累计产生≥200金币
    public static final long RED_PACK_GOLD_COIN = 200;
    public static WXGZConfig wxGZConfig;
    // 短信验证码配置
fanli/src/main/java/com/yeshi/fanli/util/annotation/redpack/RedPackGetVersionLimit.java
New file
@@ -0,0 +1,22 @@
package com.yeshi.fanli.util.annotation.redpack;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
 * 红包获得版本控制器
 *
 * @author Administrator
 *
 */
@Documented
@Target(ElementType.METHOD)
@Inherited
@Retention(RetentionPolicy.RUNTIME)
public @interface RedPackGetVersionLimit {
    String uid();
}
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;
@@ -24,7 +25,7 @@
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(false);
        detail.setDesc("等待人工审核");
        detail.setDescInfo( "等待人工审核");
        detail.setUid(exchange.getUid());
        detail.setMoney(new BigDecimal("-" + exchange.getMoney()));
        detail.setType(RedPackDetailTypeEnum.redExchange);
@@ -50,7 +51,7 @@
        RedPackDetail detail = new RedPackDetail();
        detail.setId(id);
        detail.setDisplay(true);
        detail.setDesc("请到账户余额中查看");
        detail.setDescInfo("请到账户余额中查看");
        detail.setType(RedPackDetailTypeEnum.redExchangePass);
        detail.setTitle(RedPackDetailTypeEnum.redExchangePass.getDesc());
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchangePass.name() + ":" + exchange.getId()));
@@ -72,7 +73,7 @@
        detail.setDisplay(false);
        detail.setUid(exchange.getUid());
        detail.setMoney(exchange.getMoney());
        detail.setDesc("红包产生过程中涉嫌违规");
        detail.setDescInfo("红包产生过程中涉嫌违规");
        detail.setTitle(RedPackDetailTypeEnum.redExchangeReject.getDesc());
        detail.setType(RedPackDetailTypeEnum.redExchangeReject);
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchangeReject.name() + ":" + exchange.getId()));
@@ -187,7 +188,101 @@
        detail.setTitle(title);
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.useByShopOrder.name() + "-" + orderId));
        detail.setCreateTime(new Date());
        detail.setDesc(setName);
        detail.setDescInfo(setName);
        return detail;
    }
    /**
     *  新人奖励
     * @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.setDescInfo("完成首笔订单");
        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.setDescInfo("成功邀请好友");
        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.setDescInfo("好友完成订单");
        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.setDescInfo("好友完成订单");
        detail.setTitle(RedPackDetailTypeEnum.seriesReward.getDesc());
        detail.setType(RedPackDetailTypeEnum.seriesReward);
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.seriesReward.name() + ":" + winInvite.getId()));
        detail.setCreateTime(new Date());
        return detail;
    }
    
@@ -206,9 +301,8 @@
        detail.setTitle(title);
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.shopOrderDrawBack.name() + "-" + orderId));
        detail.setCreateTime(new Date());
        detail.setDesc(setName);
        detail.setDescInfo(setName);
        return detail;
    }
}
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java
@@ -14,6 +14,7 @@
import com.yeshi.fanli.dto.msg.MsgOtherRewardIntegralDTO;
import com.yeshi.fanli.dto.msg.MsgOtherSystemGiveDTO;
import com.yeshi.fanli.dto.msg.MsgOtherTaoLiJinContentDTO;
import com.yeshi.fanli.dto.msg.MsgRedPackAddContentDTO;
import com.yeshi.fanli.dto.msg.MsgRedPackExchangeContentDTO;
import com.yeshi.fanli.dto.msg.MsgRedPackGiveContentDTO;
import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail;
@@ -610,7 +611,7 @@
                    COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
            return new UserMsgVO("http://img.flqapp.com/resource/money_detail/icon_system.png",
            return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_hongbao_give.png",
                    dto.getTitle(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
                    items);
        } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackGiveOff) { // 红包被成功领取
@@ -638,8 +639,40 @@
                    COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
            return new UserMsgVO("http://img.flqapp.com/resource/money_detail/icon_system.png",
            return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_hongbao_give.png",
                    dto.getTitle(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
                    items);
        } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackGiveBack) { // 红包未被领取退回
            if (StringUtil.isNullOrEmpty(msg.getContent()))
                return null;
            MsgRedPackGiveContentDTO dto = new Gson().fromJson(msg.getContent(), MsgRedPackGiveContentDTO.class);
            if (dto == null)
                return null;
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getTitle() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("赠送类别", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getMoney() + "", COLOR_HIGHLIGHT_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("赠送金额", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getGiveTime() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("赠送时间", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getTime() + "", 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_hongbao_give.png",
                    MsgTypeMoneyTypeEnum.redPackGiveBack.getDesc(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
                    items);
        } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackExchangePass) { // 红包提现成功
            if (StringUtil.isNullOrEmpty(msg.getContent()))
@@ -650,7 +683,7 @@
                return null;
            
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(MsgTypeMoneyTypeEnum.redPackExchangePass.getDesc() + "", COLOR_CONTENT));
            contentList.add(new ClientTextStyleVO(msg.getMsgType().getDesc() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("类别", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
@@ -674,7 +707,7 @@
                    COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
            
            return new UserMsgVO("http://img.flqapp.com/resource/money_detail/icon_system.png",
            return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_hongbao_tixian.png",
                    dto.getTitle(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
                    items);
        } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackExchangeReject) { // 红包提现拒绝
@@ -686,7 +719,7 @@
                return null;
            
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(MsgTypeMoneyTypeEnum.redPackExchangePass.getDesc() + "", COLOR_CONTENT));
            contentList.add(new ClientTextStyleVO(msg.getMsgType().getDesc() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("类别", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
@@ -710,7 +743,38 @@
                    COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
            return new UserMsgVO("http://img.flqapp.com/resource/money_detail/icon_system.png",
            return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_hongbao_tixian.png",
                    dto.getTitle(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
                    items);
        } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackNewUserReward
                || msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackInviteSucceed
                || msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackFirstSharedOrder
                || msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackMonthSharedOrder) { // 红包邀请获得
            if (StringUtil.isNullOrEmpty(msg.getContent()))
                return null;
            MsgRedPackAddContentDTO dto = new Gson().fromJson(msg.getContent(), MsgRedPackAddContentDTO.class);
            if (dto == null)
                return null;
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(msg.getMsgType().getDesc() + "", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("增加原因", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getMoney() + "", COLOR_HIGHLIGHT_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("金        额", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getBalance() + "", COLOR_HIGHLIGHT_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/img/tlj/icon_tlj.png",
                    dto.getTitle(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
                    items);
        }
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());
    }
}
fanli/src/main/java/com/yeshi/fanli/vo/redpack/RedPackWinInviteVO.java
New file
@@ -0,0 +1,48 @@
package com.yeshi.fanli.vo.redpack;
import java.io.Serializable;
import com.google.gson.annotations.Expose;
public class RedPackWinInviteVO implements Serializable{
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    @Expose
    private String nickName;
    @Expose
    private String portrait;
    @Expose
    private String money;
    @Expose
    private String desc;
    public String getNickName() {
        return nickName;
    }
    public void setNickName(String nickName) {
        this.nickName = nickName;
    }
    public String getPortrait() {
        return portrait;
    }
    public void setPortrait(String portrait) {
        this.portrait = portrait;
    }
    public String getMoney() {
        return money;
    }
    public void setMoney(String money) {
        this.money = money;
    }
    public String getDesc() {
        return desc;
    }
    public void setDesc(String desc) {
        this.desc = desc;
    }
}
fanli/src/test/java/org/fanli/MyBatisProduce.java
@@ -4,21 +4,21 @@
import org.yeshi.utils.mybatis.ColumnParseUtil;
import org.yeshi.utils.mybatis.MyBatisMapperUtil;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.order.HongBaoV2SettleTemp;
import com.yeshi.fanli.entity.shop.BanLiShopOrder;
import com.yeshi.fanli.entity.shop.BanLiShopOrderGoods;
//@Ignore
public class MyBatisProduce {
    @Test
    public void test3() {
        MyBatisMapperUtil.createMapper(HongBaoV2SettleTemp.class);
        MyBatisMapperUtil.createMapper(BanLiShopOrderGoods.class);
    }
    @Test
    public void test1() {
        ColumnParseUtil.parseColumn(HongBaoV2.class,
                "D:\\workspace\\fanli\\fanli-server\\fanli\\src\\main\\java\\com\\yeshi\\fanli\\mapping\\hongbao\\HongBaoV2Mapper.xml");
        ColumnParseUtil.parseColumn(BanLiShopOrder.class,
                "D:\\workspace\\fanli\\fanli-server\\fanli\\src\\main\\java\\com\\yeshi\\fanli\\mapping\\shop\\BanLiShopOrderMapper.xml");
    }
}
fanli/src/test/java/org/fanli/TaoKeTest.java
@@ -35,8 +35,8 @@
import com.yeshi.fanli.util.BeanUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TaoBaoConstant;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import net.sf.json.JSONArray;
@@ -49,18 +49,18 @@
    @Test
    public void test1() {
        String url = TaoKeApiUtil.officialActivityConvert("19507100253", "1539329391766", "20211660");
        System.out.println(TaoBaoUtil.filterTaoToken(TaoKeApiUtil.getTKToken(
                "http://ec-1255749512.file.myqcloud.com/img/FloatAD/a43fdefe735c41f4955a261d43870ff8.png", "淘口令",
                url)));
        for (int i = 0; i < 10; i++) {
            String time = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMddHHmmssSSS");
            System.out.println(time);
        }
    }
    @Test
    public void test2() {
        String link = TaoKeApiUtil.officialActivityConvert("87140050199", "1571120794546", "20211660");
        System.out.println(TaoKeApiUtil.getTKToken("http://","母婴预售",link));
        //https://s.click.taobao.com/t?e=m%3D2%26s%3DW%2Fys7R71JXMcQipKwQzePCperVdZeJviyK8Cckff7TVRAdhuF14FMXC%2FEJQELlNo5x%2BIUlGKNpVpS9y0ojX%2FfMsvmRQfeMsreH9%2FasRClvq63GoCXmcqkTiRUN2xVR4GdesO8XD8dsNdITvXwTxvKDqJgCOacH%2BU%2FVJqtNeEg5OOvkjnk315zzvflh4%2Fhqj8BmyXDtEFdgwjGkouqJtJeds5wF0j1Yhhp1953%2FcnpLUV6UUID4c8TeTEWJdP8jmRdTEuB5K8MGvkLv1nNhnYz%2FB0z8qlrv%2Bjr%2B%2FiM5RbEEle7auY0HPYWszlTEcWhO9mli2vZjCuAmyG1kYtrC7hgcEnE%2FQxigjMfFc2hYciEyAdpuz3kb9JWJVVX36lFeRKtwLUkdbL0syg%2BG8%2FlCRQJ1YlOPkYHNIul3paqKYwK75NNUki5Nwcg2GYz3Bez8Z8OusR9%2BDFlSU%2BcenL13XDY2hrrfx7OMbmkUtLKDKbz1CCoC2zoKs%2FmnEqY%2Bakgpmw&pvid=24980167&union_lens=lensId:0b013a8d_0cec_16df214d979_38a1
        System.out.println(TaoKeApiUtil.getTKToken("http://", "母婴预售", link));
        // https://s.click.taobao.com/t?e=m%3D2%26s%3DW%2Fys7R71JXMcQipKwQzePCperVdZeJviyK8Cckff7TVRAdhuF14FMXC%2FEJQELlNo5x%2BIUlGKNpVpS9y0ojX%2FfMsvmRQfeMsreH9%2FasRClvq63GoCXmcqkTiRUN2xVR4GdesO8XD8dsNdITvXwTxvKDqJgCOacH%2BU%2FVJqtNeEg5OOvkjnk315zzvflh4%2Fhqj8BmyXDtEFdgwjGkouqJtJeds5wF0j1Yhhp1953%2FcnpLUV6UUID4c8TeTEWJdP8jmRdTEuB5K8MGvkLv1nNhnYz%2FB0z8qlrv%2Bjr%2B%2FiM5RbEEle7auY0HPYWszlTEcWhO9mli2vZjCuAmyG1kYtrC7hgcEnE%2FQxigjMfFc2hYciEyAdpuz3kb9JWJVVX36lFeRKtwLUkdbL0syg%2BG8%2FlCRQJ1YlOPkYHNIul3paqKYwK75NNUki5Nwcg2GYz3Bez8Z8OusR9%2BDFlSU%2BcenL13XDY2hrrfx7OMbmkUtLKDKbz1CCoC2zoKs%2FmnEqY%2Bakgpmw&pvid=24980167&union_lens=lensId:0b013a8d_0cec_16df214d979_38a1
    }
    @Test
pom.xml
@@ -531,14 +531,26 @@
            <artifactId>thumbnailator</artifactId>
            <version>0.4.8</version>
        </dependency>
        <!-- RocketMQ -->
        <dependency>
            <groupId>com.aliyun.openservices</groupId>
            <artifactId>ons-client</artifactId>
            <version>1.8.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.apache.rocketmq</groupId>
            <artifactId>rocketmq-client</artifactId>
            <version>4.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.rocketmq</groupId>
            <artifactId>rocketmq-acl</artifactId>
            <version>4.5.1</version>
        </dependency>
        <!-- 分步式任务 -->
        <dependency>
            <groupId>com.xuxueli</groupId>
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"));
    }
}