admin
2019-11-25 e65037e672ecab852e2a6c5b242cdadfd1a58b33
Merge remote-tracking branch 'origin/div' into div

Conflicts:
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml
fanli/src/main/java/com/yeshi/fanli/service/impl/count/HongBaoV2CountServiceImpl.java
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java
1 文件已重命名
46个文件已修改
17个文件已添加
2477 ■■■■ 已修改文件
fanli/.classpath 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/redpack/RedPackAdminController.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/redpack/RedPackConfigAdminController.java 144 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/redpack/RedPackForbidAdminController2.java 182 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/redpack/RedPackRecordAdminController.java 149 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/BanLiShopController.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RedPackControllerV2.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackBalanceMapper.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackConfigMapper.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackDetailMapper.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackForbidMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackForbidRecordMapper.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgMoneyDetail.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackBalance.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackConfig.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackDetail.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackForbid.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackForbidRecord.java 123 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackWinInvite.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/redpack/RedPackConfigException.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/redpack/RedPackForbidException.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandInfoMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackBalanceMapper.xml 73 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackConfigMapper.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackDetailMapper.xml 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackForbidMapper.xml 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackForbidRecordMapper.xml 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackWinInviteMapper.xml 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/count/HongBaoV2CountServiceImpl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/MsgMoneyDetailServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/UserMoneyMsgNotificationServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackConfigServiceImpl.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackDetailServiceImpl.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java 47 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackForbidRecordServiceImpl.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackForbidServiceImpl.java 162 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java 210 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinNewUserServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderServiceImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackBalanceService.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackConfigService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackDetailService.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackForbidRecordService.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackForbidService.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackWinInviteService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java 69 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/redpack/RedPackBalanceVO.java 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/MyBatisProduce.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/TaoKeTest.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/config/SystemCouponServiceTest.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/config/Test_Brand.java 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/redpack/Test_RedPackWinInviteService.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/tlj/Test_IntegralTaskRecordService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/.classpath 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/src/main/java/org/yeshi/utils/DateUtil.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/.classpath
@@ -25,10 +25,6 @@
        </attributes>
    </classpathentry>
    <classpathentry kind="lib" path="libs/opush-server-sdk-1.0.3.jar"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_181"/>
    <classpathentry kind="output" path="target/classes"/>
</classpath>
fanli/src/main/java/com/yeshi/fanli/controller/admin/redpack/RedPackAdminController.java
File was renamed from fanli/src/main/java/com/yeshi/fanli/controller/admin/RedPackAdminController.java
@@ -1,4 +1,4 @@
package com.yeshi.fanli.controller.admin;
package com.yeshi.fanli.controller.admin.redpack;
import java.io.PrintWriter;
import java.math.BigDecimal;
@@ -17,7 +17,6 @@
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.common.AdminUser;
import com.yeshi.fanli.entity.redpack.RedPackExchange;
import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
import com.yeshi.fanli.service.AdminUserService;
import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
@@ -119,13 +118,7 @@
            return;
        }
        Long uid = exchange.getUid();
        BigDecimal balance;
        try {
            balance = redPackBalanceService.getBalance(uid);
        } catch (RedPackBalanceException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("该用户红包功能已被封禁"));
            return;
        }
        BigDecimal balance = redPackBalanceService.getBalance(uid);
        UserInfo userInfo = userInfoService.selectByPKey(uid);
        
        JSONObject data = new JSONObject();
fanli/src/main/java/com/yeshi/fanli/controller/admin/redpack/RedPackConfigAdminController.java
New file
@@ -0,0 +1,144 @@
package com.yeshi.fanli.controller.admin.redpack;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.entity.redpack.RedPackConfig;
import com.yeshi.fanli.exception.redpack.RedPackConfigException;
import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("admin/new/api/v1/redpack/config")
public class RedPackConfigAdminController {
    @Resource
    private RedPackConfigService redPackConfigService;
    /**
     * 保存信息
     *
     * @param callback
     * @param special
     * @param out
     */
    @RequestMapping(value = "save")
    public void save(String callback, RedPackConfig record,  PrintWriter out) {
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            String validTime = record.getValidTime();
            if (validTime != null && validTime.trim().length() > 0) {
                validTime = validTime.replaceAll("T", " ");
                record.setStartTime(format.parse(validTime));
            }
            redPackConfigService.save(record);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
        } catch (RedPackConfigException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
            e.printStackTrace();
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
        }
    }
     /**
     * 删除
     * @param callback
     * @param idArray
     * @param out
     */
    @RequestMapping(value = "delete")
    public void delete(String callback, String idArray, PrintWriter out) {
        try {
            if (StringUtil.isNullOrEmpty(idArray)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
                return;
            }
            Gson gson = new Gson();
            List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
            }.getType());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
                return;
            }
            redPackConfigService.delete(list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除数据"));
        } catch (Exception e) {
            e.printStackTrace();
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
        }
    }
    /**
     * 查询
     * @param callback
     * @param pageIndex
     * @param pageSize
     * @param key  模糊查询:说明、标识
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key, PrintWriter out) {
        try {
            if (pageIndex == null || pageIndex < 1)
                pageIndex = 1;
            if (pageSize == null || pageSize < 1)
                pageSize = Constant.PAGE_SIZE;
            List<RedPackConfig> list = redPackConfigService.query(pageIndex, pageSize, key);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            for (RedPackConfig redPackConfig: list) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
                Date startTime = redPackConfig.getStartTime();
                if (startTime == null) {
                    redPackConfig.setValidTime(sdf.format(startTime));
                } else {
                    redPackConfig.setValidTime(sdf.format(startTime));
                }
            }
            long count = redPackConfigService.count(key);
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls();
            Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("result_list", gson.toJson(list));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            e.printStackTrace();
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/admin/redpack/RedPackForbidAdminController2.java
New file
@@ -0,0 +1,182 @@
package com.yeshi.fanli.controller.admin.redpack;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.DateUtil;
import org.yeshi.utils.JsonUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.entity.common.AdminUser;
import com.yeshi.fanli.entity.redpack.RedPackForbidRecord;
import com.yeshi.fanli.exception.redpack.RedPackForbidException;
import com.yeshi.fanli.service.inter.redpack.RedPackForbidRecordService;
import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("admin/new/api/v1/redpack/forbid")
public class RedPackForbidAdminController2 {
    @Resource
    private RedPackForbidService redPackForbidService;
    @Resource
    private RedPackForbidRecordService redPackForbidRecordService;
    /**
     * 封禁用户
     *
     * @param callback
     * @param special
     * @param out
     */
    @RequestMapping(value = "save")
    public void save(String callback, RedPackForbidRecord record, HttpServletRequest request, PrintWriter out) {
        try {
            /* 检验是否登陆 */
            AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
            if (admin == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("当前登录已失效,请重新登录。"));
                return;
            }
            record.setAdminId(admin.getId());
            redPackForbidService.addForbid(record);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
        } catch (RedPackForbidException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
            e.printStackTrace();
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
        }
    }
    /**
     * 扣除红包
     *
     * @param callback
     * @param special
     * @param out
     */
    @RequestMapping(value = "deduct")
    public void deduct(String callback, RedPackForbidRecord record, HttpServletRequest request, PrintWriter out) {
        try {
            redPackForbidService.deduct(record);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
        } catch (RedPackForbidException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (DuplicateKeyException e) {
            e.printStackTrace();
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请一分钟后再试"));
        } catch (Exception e) {
            e.printStackTrace();
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
        }
    }
     /**
     * 删除
     * @param callback
     * @param idArray
     * @param out
     */
    @RequestMapping(value = "delete")
    public void delete(String callback, String idArray, PrintWriter out) {
        try {
            if (StringUtil.isNullOrEmpty(idArray)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
                return;
            }
            Gson gson = new Gson();
            List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
            }.getType());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
                return;
            }
            redPackForbidService.delete(list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除数据"));
        } catch (Exception e) {
            e.printStackTrace();
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
        }
    }
    /**
     * 查询
     * @param callback
     * @param pageIndex
     * @param pageSize
     * @param key  模糊查询:说明、标识
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer type, PrintWriter out) {
        try {
            if (pageIndex == null || pageIndex < 1)
                pageIndex = 1;
            if (pageSize == null || pageSize < 1)
                pageSize = Constant.PAGE_SIZE;
            List<RedPackForbidRecord> list = null;
            if (type == null || type == 1) {
                list = redPackForbidRecordService.query(pageIndex, pageSize, key);
            } else {
                list = redPackForbidRecordService.queryForbid(pageIndex, pageSize, key);
            }
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            Date date = new Date();
            for (RedPackForbidRecord record: list) {
                if (record.getType() == RedPackForbidRecord.TYPE_HUNDRED_YEAR) {
                    record.setSurplusTime("100年");
                } else {
                    int daysBetween = DateUtil.daysBetween(date, record.getEndTime());
                    if (daysBetween < 0)
                        daysBetween = 0;
                    record.setSurplusTime(daysBetween + "天");
                }
            }
            long count = redPackForbidRecordService.count(key);
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls();
            Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("result_list", gson.toJson(list));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            e.printStackTrace();
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/admin/redpack/RedPackRecordAdminController.java
New file
@@ -0,0 +1,149 @@
package com.yeshi.fanli.controller.admin.redpack;
import java.io.PrintWriter;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.entity.redpack.RedPackDetail;
import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
import com.yeshi.fanli.service.inter.redpack.RedPackExchangeService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.vo.redpack.RedPackBalanceVO;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("admin/new/api/v1/redpack/record")
public class RedPackRecordAdminController {
    @Resource
    private RedPackExchangeService redPackExchangeService;
    @Resource
    private RedPackBalanceService redPackBalanceService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private RedPackDetailService redPackDetailService;
    /**
     * 用户红包记录查询
     * @param callback
     * @param pageIndex
     * @param pageSize
     * @param key 搜索:暂只提供uid
     * @param state 状态:
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
            Integer order, PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
        }
        if (pageSize == null || pageSize < 1) {
            pageSize = Constant.PAGE_SIZE;
        }
        try {
            List<RedPackBalanceVO> list = redPackBalanceService.query((pageIndex - 1) * pageSize, pageSize, key, state, order);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未查找到相关信息"));
                return;
            }
            for (RedPackBalanceVO vo: list) {
                Long id = vo.getId();
                vo.setTodayWin(redPackDetailService.countWinMoneyByDate(id, 1));
                vo.setTheMonthWin(redPackDetailService.countWinMoneyByDate(id, 3));
                vo.setTodayreduce(redPackDetailService.countReduceMoneyByDate(id, 1));
                vo.setTheMonthreduce(redPackDetailService.countReduceMoneyByDate(id, 3));
                vo.setTotalreduce(redPackDetailService.countReduceMoneyByDate(id, 0));
            }
            long count = redPackBalanceService.count(key, state);
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls();
            Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("result_list", gson.toJson(list));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
    /**
     * 明细查询
     * @param callback
     * @param pageIndex
     * @param pageSize
     * @param key 搜索:暂只提供uid
     * @param type 类型:1赠送 2使用 3体现  4扣除
     * @param out
     */
    @RequestMapping(value = "queryDetail")
    public void queryDetail(String callback, Integer pageIndex, Integer pageSize, String key, Long uid, Integer type,
            PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
        }
        if (pageSize == null || pageSize < 1) {
            pageSize = Constant.PAGE_SIZE;
        }
        try {
            List<RedPackDetail> list = redPackDetailService.query((pageIndex - 1) * pageSize, pageSize, key, uid, type);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未查找到相关信息"));
                return;
            }
            if (type != null && type == 4) {
                for (RedPackDetail redPackDetail: list) {
                    redPackDetail.setBalance(redPackBalanceService.getBalance(redPackDetail.getUid()));
                }
            }
            long count = redPackDetailService.count(key, uid, type);
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls();
            Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("result_list", gson.toJson(list));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/BanLiShopController.java
@@ -15,7 +15,6 @@
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.redpack.RedPackBalance;
import com.yeshi.fanli.entity.shop.BanLiShopGoods;
import com.yeshi.fanli.entity.shop.BanLiShopGoodsSets;
import com.yeshi.fanli.entity.shop.BanLiShopGoodsSetsPay;
@@ -24,6 +23,7 @@
import com.yeshi.fanli.exception.shop.BanLiShopOrderException;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsService;
import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetPayService;
import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetService;
@@ -67,6 +67,9 @@
    @Resource
    private BanLiShopGoodsSetService banLiShopGoodsSetService;
    @Resource
    private RedPackForbidService redPackForbidService;
    /**
     * 商品列表
@@ -92,13 +95,7 @@
        }
        data.put("data", goodsList);
        data.put("count", count);
        RedPackBalance redPackBalance = redPackBalanceService.selectByPrimaryKey(uid);
        if (redPackBalance != null && redPackBalance.getState() == RedPackBalance.STATE_LOCKED) {
            data.put("redPackLock", true);
        } else {
            data.put("redPackLock", false);
        }
        data.put("redPackLock", redPackForbidService.verifyForbid(uid));
        
        if (!StringUtil.isNullOrEmpty(callback))
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
@@ -183,12 +180,8 @@
                    pay.setName(getPayName(pay.getPayType()));
                }
            }
        BigDecimal money = new BigDecimal(0);
        try {
            money = redPackBalanceService.getBalance(uid);
        } catch (RedPackBalanceException e) {
            e.printStackTrace();
        }
        BigDecimal money = redPackBalanceService.getBalance(uid);
        JSONObject data = new JSONObject();
        data.put("goods", goods);
        data.put("hongBaoBalance", money);
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java
@@ -63,7 +63,6 @@
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.entity.order.HongBaoOrder;
import com.yeshi.fanli.entity.redpack.RedPackBalance;
import com.yeshi.fanli.entity.system.BusinessSystem;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
@@ -91,6 +90,7 @@
import com.yeshi.fanli.service.inter.order.OrderService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinDetailService;
import com.yeshi.fanli.service.inter.user.AccountMessageService;
import com.yeshi.fanli.service.inter.user.BindRemindService;
@@ -231,7 +231,7 @@
    @Resource
    private BindRemindService bindRemindService;
    @Resource
    @Resource
    private RedPackBalanceService redPackBalanceService;
    @Resource
@@ -239,6 +239,9 @@
    @Resource
    private UserVIPInfoService userVIPInfoService;
    private RedPackForbidService redPackForbidService;
    private static final String PASSWORD_MAX_ERROR = "password_max_error";
    private static final String EXTRACT_MIN_MONEY = "extract_min_money";
@@ -2195,13 +2198,8 @@
            // 2.0.2 版本
            if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
                RedPackBalance redPackBalance = redPackBalanceService.selectByPrimaryKey(uid);
                if (redPackBalance != null && redPackBalance.getState() != null
                        && redPackBalance.getState() == RedPackBalance.STATE_LOCKED) {
                    data.put("redPackLock", RedPackBalance.STATE_LOCKED);
                } else {
                    data.put("redPackLock", RedPackBalance.STATE_INIT);
                }
                data.put("redPackLock", redPackForbidService.verifyForbid(uid));
            }
            out.print(JsonUtil.loadTrueResult(data));
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RedPackControllerV2.java
@@ -29,12 +29,10 @@
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.redpack.RedPackBalance;
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.RedPackBalanceException;
import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
@@ -43,6 +41,7 @@
import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
import com.yeshi.fanli.service.inter.redpack.RedPackExchangeService;
import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
import com.yeshi.fanli.service.inter.redpack.RedPackGiveRecordService;
import com.yeshi.fanli.service.inter.redpack.RedPackWinInviteService;
import com.yeshi.fanli.service.inter.redpack.RedPackWinNewUserService;
@@ -98,6 +97,9 @@
    
    @Resource
    private UserSystemCouponService userSystemCouponService;
    @Resource
    private RedPackForbidService redPackForbidService;
    /**
     * 统计
@@ -122,14 +124,7 @@
        BigDecimal yesterdayUse = zero;
        BigDecimal thisMonthUse = zero;
        BigDecimal lastMonthUse = zero;
        BigDecimal balance = null;
        try {
            balance = redPackBalanceService.getBalance(uid);
        } catch (RedPackBalanceException e) {
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
            return;
        }
        BigDecimal balance = redPackBalanceService.getBalance(uid);;
        if (balance == null) {
            balance = zero;
        } else {
@@ -395,21 +390,10 @@
        }
        JSONObject data = new JSONObject();
        try {
            data.put("balance", redPackBalanceService.getBalance(uid));
        } catch (RedPackBalanceException e) {
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
            return;
        }
        data.put("balance", redPackBalanceService.getBalance(uid));
        data.put("ruleLink", redPackConfigService.getValueByKey("invite_reward_rule_link"));
        data.put("shareLink", UserInviteUtil.getShareUrl(uid));
        RedPackBalance redPackBalance = redPackBalanceService.selectByPrimaryKey(uid);
        if (redPackBalance != null && redPackBalance.getState() == RedPackBalance.STATE_LOCKED) {
            data.put("redPackLock", true);
        } else {
            data.put("redPackLock", false);
        }
        data.put("redPackLock", redPackForbidService.verifyForbid(uid));
        UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
        if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java
@@ -177,7 +177,8 @@
     * @param endTime 结束时间
     * @return
     */
    BigDecimal getShareRewardByTeamUid(@Param("uid") Long uid, @Param("teamUid") Long teamUid, @Param("endTime") Date endTime);
    BigDecimal getOrderRewardByTeamUid(@Param("uid") Long uid, @Param("teamUid") Long teamUid, @Param("endTime") Date endTime);
    /**
     * 统计下级上个有效订单
@@ -186,6 +187,6 @@
     * @param endTime 结束时间
     * @return
     */
    BigDecimal getShareRewardByTeamUidLastMonth(@Param("uid") Long uid, @Param("teamUid") Long teamUid);
    BigDecimal getOrderRewardByTeamUidTheMonth(@Param("uid") Long uid, @Param("teamUid") Long teamUid);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackBalanceMapper.java
@@ -1,11 +1,13 @@
package com.yeshi.fanli.dao.mybatis.redpack;
import java.math.BigDecimal;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.redpack.RedPackBalance;
import com.yeshi.fanli.vo.redpack.RedPackBalanceVO;
public interface RedPackBalanceMapper extends BaseMapper<RedPackBalance> {
    
@@ -31,4 +33,33 @@
     * @return
     */
    RedPackBalance selectForUpdate(long id);
    /**
     * 商品列表查询
     *
     * @param key
     * @param state
     * @param start
     * @param count
     * @return
     */
    List<RedPackBalanceVO> query(@Param("start") long start,@Param("count") int count, @Param("key") String key,
            @Param("state") Integer state, @Param("order") Integer order);
    /**
     * 商品计数
     *
     * @param key
     * @param state
     * @return
     */
    long count(@Param("key") String key, @Param("state") Integer state);
    /**
     * 重置红包
     * @param id
     * @return
     */
    void resetRedPack(long id);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackConfigMapper.java
@@ -1,6 +1,7 @@
package com.yeshi.fanli.dao.mybatis.redpack;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
@@ -14,4 +15,24 @@
     * @return
     */
    RedPackConfig getByKey(@Param("key") String key,@Param("startTime")Date startTime);
    /**
     * 列表查询
     *
     * @param key
     * @param state
     * @param count
     * @return
     */
    List<RedPackConfig> query(@Param("start") long start,@Param("count") int count, @Param("key") String key);
    /**
     * 计数
     *
     * @param key
     * @param state
     * @return
     */
    long count(@Param("key") String key);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackDetailMapper.java
@@ -94,4 +94,46 @@
     * @return
     */
    Long selectCountByUidAndMaxCreateTime(@Param("uid") Long uid, @Param("date") Date date);
    /**
     * 根据日期类型统计获得金额
     * @param uid
     * @param dateType 1今日 、2昨日、3本月、4上月
     * @return
     */
    BigDecimal countWinMoneyByDate(@Param("uid")long uid, @Param("dateType")int dateType);
    /**
     * 根据日期类型统计消耗金额
     * @param uid
     * @param dateType 1今日 、2昨日、3本月、4上月
     * @return
     */
    BigDecimal countReduceMoneyByDate(@Param("uid")long uid, @Param("dateType")int dateType);
    /**
     * 列表查询
     *
     * @param key
     * @param state
     * @param start
     * @param count
     * @return
     */
    List<RedPackDetail> query(@Param("start") long start,@Param("count") int count,@Param("key") String key, @Param("uid") Long uid,
            @Param("type") Integer type);
    /**
     * 计数
     *
     * @param key
     * @param state
     * @return
     */
    long count(@Param("key") String key, @Param("uid") Long uid, @Param("type") Integer type);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackForbidMapper.java
New file
@@ -0,0 +1,8 @@
package com.yeshi.fanli.dao.mybatis.redpack;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.redpack.RedPackForbid;
public interface RedPackForbidMapper extends BaseMapper<RedPackForbid> {
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackForbidRecordMapper.java
New file
@@ -0,0 +1,52 @@
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.RedPackForbidRecord;
public interface RedPackForbidRecordMapper extends BaseMapper<RedPackForbidRecord> {
    /**
     * 列表查询
     *
     * @param key
     * @param state
     * @param start
     * @param count
     * @return
     */
    List<RedPackForbidRecord> query(@Param("start") long start,@Param("count") int count, @Param("key") String key);
    /**
     * 计数
     *
     * @param key
     * @param state
     * @return
     */
    long count(@Param("key") String key);
    /**
     * 列表查询
     *
     * @param key
     * @param state
     * @param start
     * @param count
     * @return
     */
    List<RedPackForbidRecord> queryForbid(@Param("start") long start,@Param("count") int count, @Param("key") String key);
    /**
     * 计数
     *
     * @param key
     * @param state
     * @return
     */
    long countForbid(@Param("key") String key);
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgMoneyDetail.java
@@ -41,7 +41,8 @@
        redPackTwoStageReward("第二阶段-递增奖励-好友完成订单"),
        redPackThreeStageReward("第三阶段-连续奖励-好友完成订单"),
        redPackUseSuccess("红包使用成功"),
        redPackUseFail("红包使用失败");
        redPackUseFail("红包使用失败"),
        redPackForbid("红包功能封禁");
        private final String desc;
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackBalance.java
@@ -14,21 +14,12 @@
 */
@Table("yeshi_ec_red_pack_balance")
public class RedPackBalance {
    // 初始0
    public final static int STATE_INIT = 0;
    // 红包功能关闭
    public final static int STATE_LOCKED = 1;
    // 用户id
    @Column(name = "rpb_uid")
    private Long id;
    // 余额
    @Column(name = "rpb_money")
    private BigDecimal money;
    // 状态
    @Column(name = "rpb_state")
    private Integer state;
    
    @Column(name = "rpb_create_time")
    private Date createTime;
@@ -67,13 +58,4 @@
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackConfig.java
@@ -37,6 +37,8 @@
    
    @Column(name = "rpc_update_time")
    private Date updateTime;
    private String validTime;
    public Long getId() {
        return id;
@@ -100,5 +102,13 @@
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getValidTime() {
        return validTime;
    }
    public void setValidTime(String validTime) {
        this.validTime = validTime;
    } 
}
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackDetail.java
@@ -18,7 +18,8 @@
public class RedPackDetail {
    public enum RedPackDetailTypeEnum {
        refund("红包退回", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        violation("红包涉嫌违规", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        deduct("红包涉嫌违规", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        forbid("涉嫌恶意机刷红包", "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"), 
@@ -81,6 +82,8 @@
    @Column(name = "rpd_display")
    private Boolean display;
    private BigDecimal balance;
    public Long getId() {
        return id;
    }
@@ -160,4 +163,12 @@
    public void setDisplay(Boolean display) {
        this.display = display;
    }
    public BigDecimal getBalance() {
        return balance;
    }
    public void setBalance(BigDecimal balance) {
        this.balance = balance;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackForbid.java
New file
@@ -0,0 +1,49 @@
package com.yeshi.fanli.entity.redpack;
import java.util.Date;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
/**
 * 红包封禁
 *
 * @author Administrator
 *
 */
@Table("yeshi_ec_red_pack_forbid")
public class RedPackForbid {
    @Column(name = "rpf_uid")
    private Long id;
    @Column(name = "rpf_end_time")
    private Date endTime;
    @Column(name = "rpf_create_time")
    private Date createTime;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackForbidRecord.java
New file
@@ -0,0 +1,123 @@
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_forbid_record")
public class RedPackForbidRecord {
    public static final int TYPE_ONE_MONTH = 1;
    public static final int TYPE_THREE_MONTH = 2;
    public static final int TYPE_SIX_MONTH = 3;
    public static final int TYPE_ONE_YEAR = 4;
    public static final int TYPE_HUNDRED_YEAR = 5;
    @Column(name = "rpv_id")
    private Long id;
    @Column(name = "rpv_uid")
    private Long uid;
    @Column(name = "rpv_money")
    private BigDecimal money;
    @Column(name = "rpv_date_type")
    private Integer type;
    @Column(name = "rpv_reason")
    private String reason;
    @Column(name = "rpv_end_time")
    private Date endTime;
    @Column(name = "rpv_admin_id")
    private Long adminId;
    @Column(name = "rpv_create_time")
    private Date createTime;
    // 剩余时间
    private String surplusTime;
    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 BigDecimal getMoney() {
        return money;
    }
    public void setMoney(BigDecimal money) {
        this.money = money;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public String getReason() {
        return reason;
    }
    public void setReason(String reason) {
        this.reason = reason;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getSurplusTime() {
        return surplusTime;
    }
    public void setSurplusTime(String surplusTime) {
        this.surplusTime = surplusTime;
    }
    public Long getAdminId() {
        return adminId;
    }
    public void setAdminId(Long adminId) {
        this.adminId = adminId;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackWinInvite.java
@@ -53,6 +53,10 @@
    @Column(name = "rwr_source")
    private Integer source;
    
    // 唯一标识
    @Column(name = "rwr_identify_code")
    private String identifyCode;
    // 订单号
    @Column(name = "rwr_order_no")
    private String orderNo;
@@ -134,4 +138,12 @@
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getIdentifyCode() {
        return identifyCode;
    }
    public void setIdentifyCode(String identifyCode) {
        this.identifyCode = identifyCode;
    }
}
fanli/src/main/java/com/yeshi/fanli/exception/redpack/RedPackConfigException.java
New file
@@ -0,0 +1,22 @@
package com.yeshi.fanli.exception.redpack;
import com.yeshi.fanli.exception.BaseException;
/**
 * 红包异常
 *
 * @author Administrator
 *
 */
public class RedPackConfigException extends BaseException {
    private static final long serialVersionUID = 1L;
    public RedPackConfigException(int code, String msg) {
        super(code, msg);
    }
    public RedPackConfigException() {
        super();
    }
}
fanli/src/main/java/com/yeshi/fanli/exception/redpack/RedPackForbidException.java
New file
@@ -0,0 +1,22 @@
package com.yeshi.fanli.exception.redpack;
import com.yeshi.fanli.exception.BaseException;
/**
 * 红包异常
 *
 * @author Administrator
 *
 */
public class RedPackForbidException extends BaseException {
    private static final long serialVersionUID = 1L;
    public RedPackForbidException(int code, String msg) {
        super(code, msg);
    }
    public RedPackForbidException() {
        super();
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandInfoMapper.xml
@@ -106,6 +106,7 @@
  <select id="listValidByCidToApp" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_brand_info d
    WHERE d.`bf_state` = 1 AND d.`bf_cid` = #{cid}  AND d.bf_goods_total <![CDATA[>=]]> 3
    ORDER BY d.`bf_weight` DESC
  </select>
  
  <select id="countValidByCid" resultType="Long">
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml
@@ -359,20 +359,21 @@
                AND (`hb_type` =5 OR `hb_type` =6 OR `hb_type` =7 OR `hb_type` =20 OR `hb_type`=21 OR `hb_type` =22 )
    </select>
     <select id="getShareRewardByTeamUid" resultType="BigDecimal">
     <select id="getOrderRewardByTeamUid" resultType="BigDecimal">
        SELECT SUM(v2.`hb_money`) FROM yeshi_ec_hongbao_v2 v2 
        LEFT JOIN yeshi_ec_hongbao_v2 p ON p.`hb_id` = v2.`hb_pid`
        WHERE v2.`hb_type` = 21 AND v2.`hb_state` = 3
        WHERE v2.`hb_state` = 3 AND (v2.`hb_type` = 6 OR v2.`hb_type` = 21)
            AND v2.`hb_uid` = #{uid} AND p.`hb_uid` = #{teamUid}
            AND v2.`hb_create_time`<![CDATA[<=]]> #{endTime}
    </select>
    
    <select id="getShareRewardByTeamUidLastMonth" resultType="BigDecimal">
    <select id="getOrderRewardByTeamUidTheMonth" resultType="BigDecimal">
        SELECT SUM(v2.`hb_money`) FROM yeshi_ec_hongbao_v2 v2 
        LEFT JOIN yeshi_ec_hongbao_v2 p ON p.`hb_id` = v2.`hb_pid`
        WHERE v2.`hb_type` = 21 AND v2.`hb_state` = 3
        WHERE  v2.`hb_state` = 3 AND (v2.`hb_type` = 6 OR v2.`hb_type` = 21)
            AND v2.`hb_uid` = #{uid} AND p.`hb_uid` = #{teamUid}
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(v2.`hb_create_time`, '%Y%m')) = 1
            AND DATE_FORMAT(CURDATE(), '%Y%m') = DATE_FORMAT(v2.`hb_get_time`, '%Y%m')
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackBalanceMapper.xml
@@ -5,43 +5,52 @@
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackBalance">
    <id column="rpb_uid" property="id" jdbcType="BIGINT"/>
    <result column="rpb_money" property="money" jdbcType="DECIMAL"/>
    <result column="rpb_state" property="state" jdbcType="INTEGER"/>
    <result column="rpb_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="rpb_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">rpb_uid,rpb_money,rpb_state,rpb_create_time,rpb_update_time</sql>
  <resultMap id="VOResultMap" type="com.yeshi.fanli.vo.redpack.RedPackBalanceVO">
    <id column="rpb_uid" property="id" jdbcType="BIGINT"/>
    <result column="rpb_money" property="money" jdbcType="DECIMAL"/>
    <result column="rpb_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="rpb_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <result column="giveMoney" property="giveMoney" jdbcType="DECIMAL"/>
    <result column="useMoney" property="useMoney" jdbcType="DECIMAL"/>
    <result column="exchangeMoney" property="exchangeMoney" jdbcType="DECIMAL"/>
    <result column="totalWin" property="totalWin" jdbcType="DECIMAL"/>
  </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_ec_red_pack_balance where rpb_uid = #{id,jdbcType=BIGINT}
  </select>
<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_state,rpb_create_time,rpb_update_time) values (#{id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <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>
      <if test="state != null">rpb_state,</if>
      <if test="createTime != null">rpb_create_time,</if>
      <if test="updateTime != null">rpb_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="money != null">#{money,jdbcType=DECIMAL},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</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.RedPackBalance">update yeshi_ec_red_pack_balance set rpb_money = #{money,jdbcType=DECIMAL},rpb_state = #{state,jdbcType=INTEGER},rpb_create_time = #{createTime,jdbcType=TIMESTAMP},rpb_update_time = #{updateTime,jdbcType=TIMESTAMP} where rpb_uid = #{id,jdbcType=BIGINT}</update>
  <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="state != null">rpb_state=#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">rpb_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">rpb_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where rpb_uid = #{id,jdbcType=BIGINT}
  </update>
  
  <update id="subRedPack">
   <update id="subRedPack">
      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>
@@ -51,9 +60,55 @@
      WHERE rpb_uid = #{id,jdbcType=BIGINT}
  </update>
    
  <update id="resetRedPack">
      UPDATE yeshi_ec_red_pack_balance SET rpb_money = 0,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_ec_red_pack_balance 
       WHERE rpb_uid = #{id,jdbcType=BIGINT} FOR UPDATE
  </select>
  
  <select id="query" resultMap="VOResultMap">
    SELECT b.*,IFNULL(dd.giveMoney,0)AS giveMoney,IFNULL(dd2.useMoney,0)AS useMoney ,IFNULL(dd3.exchangeMoney,0)AS exchangeMoney ,IFNULL(dd4.totalWin,0)AS totalWin  FROM `yeshi_ec_red_pack_balance` b
    LEFT JOIN (SELECT ABS(SUM(d.`rpd_money`)) AS giveMoney,d.`rpd_uid` FROM `yeshi_ec_red_pack_detail` d
            WHERE d.`rpd_type` = 'giveOthersSucceed' AND d.`rpd_uid` LIKE '${key}%')dd ON dd.rpd_uid = b.`rpb_uid`
    LEFT JOIN (SELECT ABS(SUM(d.`rpd_money`)) AS useMoney,d.`rpd_uid` FROM `yeshi_ec_red_pack_detail` d
            WHERE d.`rpd_type` = 'useByShopOrder' AND d.`rpd_uid` LIKE '${key}%')dd2 ON dd2.rpd_uid = b.`rpb_uid`
    LEFT JOIN (SELECT ABS(SUM(d.`rpd_money`)) AS exchangeMoney,d.`rpd_uid` FROM `yeshi_ec_red_pack_detail` d
            WHERE d.`rpd_type` = 'redExchangePass' AND d.`rpd_uid` LIKE '${key}%')dd3 ON dd3.rpd_uid = b.`rpb_uid`
    LEFT JOIN (SELECT ABS(SUM(d.`rpd_money`)) AS totalWin,d.`rpd_uid` FROM `yeshi_ec_red_pack_detail` d
            WHERE d.`rpd_type` IN('newUserReward','invite','increaseReward','seriesReward','giveOthersReceive') AND d.`rpd_uid` LIKE '${key}%')dd4 ON dd4.rpd_uid = b.`rpb_uid`
    WHERE b.`rpb_uid` LIKE '${key}%'
    <if test="state != null">
        AND b.rpb_state = #{state}
    </if>
    <if test="order == 0">
        ORDER BY b.rpb_money DESC
    </if>
    <if test="order == 1">
        ORDER BY dd.giveMoney DESC
    </if>
    <if test="order == 2">
        ORDER BY dd2.useMoney DESC
    </if>
    <if test="order == 3">
        ORDER BY dd3.exchangeMoney DESC
    </if>
    <if test="order == 4">
        ORDER BY dd4.totalWin DESC
    </if>
    LIMIT #{start},#{count}
  </select>
  <select id="count" resultType="Long">
      SELECT IFNULL(COUNT(rpb_uid),0) FROM yeshi_ec_red_pack_balance
    WHERE rpb_uid LIKE '${key}%'
      <if test="state != null">
        AND rpb_state = #{state}
     </if>
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackConfigMapper.xml
@@ -58,4 +58,15 @@
      WHERE t.`rpc_key` = #{key} and #{startTime} >= rpc_start_time 
      ORDER BY rpc_start_time DESC LIMIT 1
  </select>
  <select id="query" resultMap="BaseResultMap">
    SELECT * FROM `yeshi_ec_red_pack_config` t
    WHERE t.`rpc_name` LIKE '${key}%' OR t.`rpc_value` LIKE '${key}%'
    LIMIT #{start},#{count}
  </select>
  <select id="count" resultType="Long">
       SELECT IFNULL(COUNT(t.rpc_id),0) FROM yeshi_ec_red_pack_config t
     WHERE t.`rpc_name` LIKE '${key}%' OR t.`rpc_value` LIKE '${key}%'
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackDetailMapper.xml
@@ -161,4 +161,84 @@
    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>
  <select id="countReduceMoneyByDate" resultType="java.math.BigDecimal">
      SELECT IFNULL(SUM(t.`rpd_money`),0) FROM `yeshi_ec_red_pack_detail` t
    WHERE t.`rpd_uid` = #{uid}
         AND t.`rpd_type` IN ('redExchangePass','useByShopOrder','giveOthersSucceed')
        <if test="dateType == 1"> <!-- 今日  -->
            AND TO_DAYS(t.`rpd_create_time`) =  TO_DAYS(NOW());
        </if>
        <if test="dateType == 2"> <!-- 昨日  -->
          AND TO_DAYS(NOW()) - TO_DAYS(t.`rpd_create_time`) = 1
        </if>
           <if test="dateType == 3"> <!-- 本月  -->
          AND DATE_FORMAT(t.`rpd_create_time`, '%Y%m') =DATE_FORMAT(CURDATE(), '%Y%m')
        </if>
        <if test="dateType == 4"> <!--上月  -->
          AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),DATE_FORMAT(t.`rpd_create_time`, '%Y%m')) = 1
        </if>
  </select>
  <select id="countWinMoneyByDate" resultType="java.math.BigDecimal">
      SELECT IFNULL(SUM(t.`rpd_money`),0) FROM `yeshi_ec_red_pack_detail` t
    WHERE t.`rpd_uid` = #{uid}
         AND t.`rpd_type` IN ('newUserReward','invite','increaseReward','seriesReward','giveOthersReceive')
        <if test="dateType == 1"> <!-- 今日  -->
            AND TO_DAYS(t.`rpd_create_time`) =  TO_DAYS(NOW());
        </if>
        <if test="dateType == 2"> <!-- 昨日  -->
          AND TO_DAYS(NOW()) - TO_DAYS(t.`rpd_create_time`) = 1
        </if>
           <if test="dateType == 3"> <!-- 本月  -->
          AND DATE_FORMAT(t.`rpd_create_time`, '%Y%m') =DATE_FORMAT(CURDATE(), '%Y%m')
        </if>
        <if test="dateType == 4"> <!--上月  -->
          AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),DATE_FORMAT(t.`rpd_create_time`, '%Y%m')) = 1
        </if>
  </select>
  <select id="query" resultMap="BaseResultMap">
    SELECT * FROM `yeshi_ec_red_pack_detail` t
     WHERE t.`rpd_uid` LIKE '${key}%'
        <if test = "uid != null">
               AND t.`rpd_uid` = #{uid}
            </if>
        <if test = "type == 1">
            AND t.`rpd_type` = 'giveOthersSucceed'
        </if>
        <if test = "type == 2">
            AND t.`rpd_type` = 'useByShopOrder'
        </if>
        <if test = "type == 3">
            AND t.`rpd_type` = 'redExchangePass'
        </if>
        <if test = "type == 4">
            AND t.`rpd_type` = 'deduct'
        </if>
    ORDER BY t.`rpd_id` DESC
    LIMIT #{start},#{count}
  </select>
  <select id="count" resultType="Long">
      SELECT IFNULL(COUNT(t.rpd_id),0) FROM yeshi_ec_red_pack_detail t
    WHERE t.`rpd_uid` LIKE '${key}%'
        <if test = "uid != null">
               AND t.`rpd_uid` = #{uid}
            </if>
           <if test = "type == 1">
            AND t.`rpd_type` = 'giveOthersSucceed'
        </if>
        <if test = "type == 2">
            AND t.`rpd_type` = 'useByShopOrder'
        </if>
        <if test = "type == 3">
            AND t.`rpd_type` = 'redExchangePass'
        </if>
        <if test = "type == 4">
            AND t.`rpd_type` = 'deduct'
        </if>
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackForbidMapper.xml
New file
@@ -0,0 +1,35 @@
<?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.RedPackForbidMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackForbid">
    <id column="rpf_uid" property="id" jdbcType="BIGINT"/>
    <result column="rpf_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="rpf_create_time" property="createTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">rpf_uid,rpf_end_time,rpf_create_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_red_pack_forbid where rpf_uid = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_red_pack_forbid where rpf_uid = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackForbid" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_forbid (rpf_uid,rpf_end_time,rpf_create_time) values (#{id,jdbcType=BIGINT},#{endTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackForbid" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_forbid
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpf_uid,</if>
      <if test="endTime != null">rpf_end_time,</if>
      <if test="createTime != null">rpf_create_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackForbid">update yeshi_ec_red_pack_forbid set rpf_end_time = #{endTime,jdbcType=TIMESTAMP},rpf_create_time = #{createTime,jdbcType=TIMESTAMP} where rpf_uid = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackForbid">update yeshi_ec_red_pack_forbid
    <set>
      <if test="endTime != null">rpf_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">rpf_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
    </set> where rpf_uid = #{id,jdbcType=BIGINT}
  </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackForbidRecordMapper.xml
New file
@@ -0,0 +1,81 @@
<?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.RedPackForbidRecordMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackForbidRecord">
    <id column="rpv_id" property="id" jdbcType="BIGINT"/>
    <result column="rpv_uid" property="uid" jdbcType="BIGINT"/>
    <result column="rpv_money" property="money" jdbcType="DECIMAL"/>
    <result column="rpv_date_type" property="type" jdbcType="INTEGER"/>
    <result column="rpv_reason" property="reason" jdbcType="VARCHAR"/>
    <result column="rpv_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="rpv_admin_id" property="adminId" jdbcType="BIGINT"/>
    <result column="rpv_create_time" property="createTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">rpv_id,rpv_uid,rpv_money,rpv_date_type,rpv_reason,rpv_end_time,rpv_admin_id,rpv_create_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_red_pack_forbid_record where rpv_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_red_pack_forbid_record where rpv_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackForbidRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_forbid_record (rpv_id,rpv_uid,rpv_money,rpv_date_type,rpv_reason,rpv_end_time,rpv_admin_id,rpv_create_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=INTEGER},#{reason,jdbcType=VARCHAR},#{endTime,jdbcType=TIMESTAMP},#{adminId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackForbidRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_forbid_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpv_id,</if>
      <if test="uid != null">rpv_uid,</if>
      <if test="money != null">rpv_money,</if>
      <if test="type != null">rpv_date_type,</if>
      <if test="reason != null">rpv_reason,</if>
      <if test="endTime != null">rpv_end_time,</if>
      <if test="adminId != null">rpv_admin_id,</if>
      <if test="createTime != null">rpv_create_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="money != null">#{money,jdbcType=DECIMAL},</if>
      <if test="type != null">#{type,jdbcType=INTEGER},</if>
      <if test="reason != null">#{reason,jdbcType=VARCHAR},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="adminId != null">#{adminId,jdbcType=BIGINT},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackForbidRecord">update yeshi_ec_red_pack_forbid_record set rpv_uid = #{uid,jdbcType=BIGINT},rpv_money = #{money,jdbcType=DECIMAL},rpv_date_type = #{type,jdbcType=INTEGER},rpv_reason = #{reason,jdbcType=VARCHAR},rpv_end_time = #{endTime,jdbcType=TIMESTAMP},rpv_admin_id = #{adminId,jdbcType=BIGINT},rpv_create_time = #{createTime,jdbcType=TIMESTAMP} where rpv_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackForbidRecord">update yeshi_ec_red_pack_forbid_record
    <set>
      <if test="uid != null">rpv_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="money != null">rpv_money=#{money,jdbcType=DECIMAL},</if>
      <if test="type != null">rpv_date_type=#{type,jdbcType=INTEGER},</if>
      <if test="reason != null">rpv_reason=#{reason,jdbcType=VARCHAR},</if>
      <if test="endTime != null">rpv_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="adminId != null">rpv_admin_id=#{adminId,jdbcType=BIGINT},</if>
      <if test="createTime != null">rpv_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
    </set> where rpv_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="query" resultMap="BaseResultMap">
    SELECT * FROM `yeshi_ec_red_pack_forbid_record` t
    WHERE t.`rpv_uid` LIKE '${key}%'
    ORDER BY t.`rpv_create_time` DESC
    LIMIT #{start},#{count}
  </select>
  <select id="count" resultType="Long">
      SELECT IFNULL(COUNT(t.rpv_id),0) FROM yeshi_ec_red_pack_forbid_record t
    WHERE  t.`rpv_uid` LIKE '${key}%'
  </select>
  <select id="queryForbid" resultMap="BaseResultMap">
    SELECT * FROM `yeshi_ec_red_pack_forbid` d
    LEFT JOIN yeshi_ec_red_pack_forbid_record t1 ON t1.rpv_uid = d.`rpf_uid`
    WHERE d.`rpf_uid` LIKE '${key}%'
          AND t1.rpv_create_time IN(SELECT MAX(t2.rpv_create_time) FROM yeshi_ec_red_pack_forbid_record t2 WHERE t1.rpv_uid=t2.rpv_uid)
    ORDER BY d.`rpf_create_time` DESC
    LIMIT #{start},#{count}
  </select>
  <select id="countForbid" resultType="Long">
      SELECT IFNULL(COUNT(t.rpf_uid),0) FROM yeshi_ec_red_pack_forbid t
    WHERE  t.`rpf_uid` LIKE '${key}%'
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackWinInviteMapper.xml
@@ -1,6 +1,5 @@
<?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"/>
@@ -8,17 +7,18 @@
    <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_identify_code" property="identifyCode" jdbcType="VARCHAR"/>
    <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"/>
    <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>
  <sql id="Base_Column_List">rwr_id,rwr_uid,rwr_team_uid,rwr_money,rwr_type,rwr_source,rwr_identify_code,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="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_identify_code,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},#{identifyCode,jdbcType=VARCHAR},#{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>
@@ -27,6 +27,7 @@
      <if test="money != null">rwr_money,</if>
      <if test="type != null">rwr_type,</if>
      <if test="source != null">rwr_source,</if>
      <if test="identifyCode != null">rwr_identify_code,</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>
@@ -38,12 +39,13 @@
      <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="identifyCode != null">#{identifyCode,jdbcType=VARCHAR},</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="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_identify_code = #{identifyCode,jdbcType=VARCHAR},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>
@@ -51,6 +53,7 @@
      <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="identifyCode != null">rwr_identify_code=#{identifyCode,jdbcType=VARCHAR},</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>
@@ -65,6 +68,19 @@
  <select id="countByUidAndTeamUidAndType" resultType="Integer">
      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="getByUidAndTeamUidAndType" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_red_pack_win_invite d
    WHERE d.`rwr_uid` = #{uid} AND d.`rwr_team_uid` = #{teamUid} AND d.`rwr_type` = #{type}
    LIMIT 1
  </select>
  <select id="getByUidAndTeamUidAndTypeMonth" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_red_pack_win_invite d
    WHERE d.`rwr_uid` = #{uid} AND d.`rwr_team_uid` = #{teamUid} AND d.`rwr_type` = #{type}
          AND DATE_FORMAT(d.rwr_create_time,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
    LIMIT 1
  </select>
  
  <select id="getByUidAndTeamUidAndType" resultMap="BaseResultMap">
@@ -96,5 +112,4 @@
      SELECT IFNULL(SUM(d.`rwr_money`),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/count/HongBaoV2CountServiceImpl.java
@@ -297,13 +297,13 @@
        return hongBaoV2CountMapper.countAlreadyGetMoneyByUid(uid, typeList, minGetTime, maxGetTime);
    }
    @Override
    public BigDecimal getShareRewardByTeamUid(Long uid, Long teamUid, Date endTime) {
        return hongBaoV2CountMapper.getShareRewardByTeamUid(uid, teamUid, endTime);
    @Override
    public BigDecimal getOrderRewardByTeamUid(Long uid, Long teamUid, Date endTime) {
        return hongBaoV2CountMapper.getOrderRewardByTeamUid(uid, teamUid, endTime);
    }
    
    @Override
    public BigDecimal getShareRewardByTeamUidLastMonth(Long uid, Long teamUid) {
        return hongBaoV2CountMapper.getShareRewardByTeamUidLastMonth(uid, teamUid);
    public BigDecimal getOrderRewardByTeamUidTheMonth(Long uid, Long teamUid) {
        return hongBaoV2CountMapper.getOrderRewardByTeamUidTheMonth(uid, teamUid);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/MsgMoneyDetailServiceImpl.java
@@ -135,7 +135,8 @@
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackTwoStageReward
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackThreeStageReward
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackUseFail
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackUseSuccess) {
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackUseSuccess
                || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackForbid) {
            if (detail.getUser() == null)
                throw new MsgMoneyDetailException(2, "消息信息不全");
            detail.setCreateTime(new Date());
fanli/src/main/java/com/yeshi/fanli/service/impl/money/msg/UserMoneyMsgNotificationServiceImpl.java
@@ -318,8 +318,7 @@
    @Override
    public void inviteOrderSubSidy(Long uid, Date date, String from, BigDecimal money, BigDecimal balance) {
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createInviteOrderSubSidyMsg(uid, date, from, money, balance,
                null);
        MsgMoneyDetail detail = MsgMoneyDetailFactory.createInviteOrderSubSidyMsg(uid, date, from, money, balance, null);
        try {
            msgMoneyDetailService.addMsgMoneyDetail(detail);
        } catch (MsgMoneyDetailException e) {
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -1621,7 +1621,7 @@
    public BigDecimal getTotalRewardMoneyByOrderNoAndSourceType(String orderNo, Integer sourceType) {
        return commonOrderMapper.getTotalRewardMoneyByOrderNoAndSourceType(orderNo, sourceType);
    }
    @Override
    public long count24HValidOrderByUid(Long uid, Date minTime) {
        return commonOrderMapper.count24HValidOrderByUid(uid, minTime);
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java
@@ -2,6 +2,7 @@
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
@@ -14,6 +15,7 @@
import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
import com.yeshi.fanli.vo.redpack.RedPackBalanceVO;
@Service
public class RedPackBalanceServiceImpl implements RedPackBalanceService {
@@ -29,26 +31,14 @@
        return redPackBalanceMapper.selectByPrimaryKey(uid);
    }
    private void verify(RedPackBalance redPackBalance) throws RedPackBalanceException{
        if (redPackBalance == null)
            return;
        if (redPackBalance.getState() != null && redPackBalance.getState() == RedPackBalance.STATE_LOCKED)
            throw new RedPackBalanceException(1, "红包已封禁,感谢使用");
    }
    @Override
    public BigDecimal getBalance(Long uid) throws RedPackBalanceException{
    public BigDecimal getBalance(Long uid){
        if (uid == null || uid == 0)
            return new BigDecimal(0);
        
        RedPackBalance redPackBalance = redPackBalanceMapper.selectByPrimaryKey(uid);
        if (redPackBalance != null) {
            // 验证
            verify(redPackBalance);
            return redPackBalance.getMoney();
        }
        if (redPackBalance != null && redPackBalance.getMoney() != null)
            return redPackBalance.getMoney();
        return new BigDecimal(0);
    }
@@ -66,13 +56,10 @@
            redPackBalance = new RedPackBalance();
            redPackBalance.setId(uid);
            redPackBalance.setMoney(money);
            redPackBalance.setState(RedPackBalance.STATE_INIT);
            redPackBalance.setCreateTime(new Date());
            redPackBalance.setUpdateTime(new Date());
            redPackBalanceMapper.insertSelective(redPackBalance);
        } else {
            // 验证
            verify(redPackBalance);
            redPackBalanceMapper.addRedPack(uid, money);
        }
    }
@@ -91,11 +78,37 @@
        if (balance.getMoney().compareTo(money) < 0)
            throw new RedPackBalanceException(2, "红包余额不足");
        // 验证
        verify(balance);
        // 减少红包
        redPackBalanceMapper.subRedPack(uid, money);
    }
    @Override
    public RedPackBalance selectForUpdate(Long uid) {
        return redPackBalanceMapper.selectForUpdate(uid);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void resetRedPack(Long uid, RedPackDetail detail) throws RedPackBalanceException {
        if (uid == null || uid == 0 || detail == null)
            throw new RedPackBalanceException(1, "参数传递不完整");
        // 加入明细
        redPackDetailService.insertSelective(detail);
        // 重置
        redPackBalanceMapper.resetRedPack(uid);
    }
    @Override
    public List<RedPackBalanceVO> query(Integer start, Integer count, String key, Integer state,Integer order){
        return redPackBalanceMapper.query(start, count, key, state,order);
    }
    @Override
    public long count(String key, Integer state){
        return redPackBalanceMapper.count(key, state);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackConfigServiceImpl.java
@@ -1,6 +1,7 @@
package com.yeshi.fanli.service.impl.redpack;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
@@ -9,7 +10,9 @@
import com.yeshi.fanli.dao.mybatis.redpack.RedPackConfigMapper;
import com.yeshi.fanli.entity.redpack.RedPackConfig;
import com.yeshi.fanli.exception.redpack.RedPackConfigException;
import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
import com.yeshi.fanli.util.StringUtil;
@Service
public class RedPackConfigServiceImpl implements RedPackConfigService {
@@ -49,5 +52,50 @@
        }
        return null;
    }
    @Override
    public List<RedPackConfig> query(int page, int pageSize, String key) {
        return redPackConfigMapper.query((page - 1) * pageSize, pageSize, key);
    }
    @Override
    public long count(String key) {
        return redPackConfigMapper.count(key);
    }
    @Override
    public void save(RedPackConfig record) throws RedPackConfigException {
        String name = record.getName();
        if (StringUtil.isNullOrEmpty(name))
            throw new RedPackConfigException(1, "名称不能为空");
        if (StringUtil.isNullOrEmpty(record.getValue()))
            throw new RedPackConfigException(1, "值不能为空");
        if (StringUtil.isNullOrEmpty(record.getKey()))
            throw new RedPackConfigException(1, "标识不能为空");
        record.setUpdateTime(new Date());
        if (record.getId() == null) {
            record.setCreateTime(new Date());
            redPackConfigMapper.insert(record);
        } else {
            RedPackConfig resultObj = redPackConfigMapper.selectByPrimaryKey(record.getId());
            if (resultObj == null)
                throw new RedPackConfigException(1, "修改内容已不存在");
            record.setCreateTime(resultObj.getCreateTime());
            redPackConfigMapper.updateByPrimaryKey(record);
        }
    }
    @Override
    public void delete(List<Long> idsList) {
        if (idsList != null)
            for (Long id : idsList)
                redPackConfigMapper.deleteByPrimaryKey(id);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackDetailServiceImpl.java
@@ -219,4 +219,25 @@
        }
    }
    @Override
    public BigDecimal countWinMoneyByDate(long uid, int dateType) {
        return redPackDetailMapper.countWinMoneyByDate(uid, dateType);
    }
    @Override
    public BigDecimal countReduceMoneyByDate(long uid, int dateType) {
        return redPackDetailMapper.countReduceMoneyByDate(uid, dateType);
    }
    @Override
    public List<RedPackDetail> query(Integer start, Integer count, String key, Long uid, Integer type){
        return redPackDetailMapper.query(start, count, key, uid, type);
    }
    @Override
    public long count(String key,Long uid, Integer type){
        return redPackDetailMapper.count(key, uid, type);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java
@@ -21,7 +21,6 @@
import com.yeshi.fanli.entity.redpack.RedPackDetail;
import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackExchange;
import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.money.UserMoneyService;
@@ -30,6 +29,7 @@
import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
import com.yeshi.fanli.service.inter.redpack.RedPackExchangeService;
import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.factory.RedPackDetailFactory;
@@ -54,6 +54,9 @@
    
    @Resource
    private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
    @Resource
    private RedPackForbidService redPackForbidService;
    
    
    @Override
@@ -87,16 +90,13 @@
    public void exchangeCash(Long uid, BigDecimal amount) throws RedPackExchangeException {
        if (uid == null || amount == null)
            throw new RedPackExchangeException(1, "参数不正确");
        if(redPackForbidService.verifyForbid(uid))
            throw new RedPackExchangeException(1, "红包功能已被封禁");
        String extractBanlenMin = redPackConfigService.getValueByKey("extract_banlen_min");
    
        BigDecimal balance = null;
        try {
            balance = redPackBalanceService.getBalance(uid);
        } catch (RedPackBalanceException e1) {
            throw new RedPackExchangeException(1, e1.getMsg());
        }
        BigDecimal balance =  redPackBalanceService.getBalance(uid);
        if (balance == null || balance.compareTo(new BigDecimal(extractBanlenMin)) < 0)
            throw new RedPackExchangeException(1, "余额不足" + extractBanlenMin + "元");
        
@@ -143,6 +143,9 @@
        if (RedPackExchange.STATE_INIT != record.getState())
            throw new RedPackExchangeException(1,"该申请已被处理,请刷新");
        if(redPackForbidService.verifyForbid(record.getUid()))
            throw new RedPackExchangeException(1, "红包功能已被封禁");
        Date nowDate = new Date();
        record.setAuditId(admin.getId());
        record.setAuditTime(nowDate);
@@ -175,20 +178,18 @@
            throw new RedPackExchangeException(1,"更新提现明细出错");
        }
        
        try {
            //消息
            SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
            String beizu = "红包提现成功后请到“我的-账户余额”中查看";
            MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO();
            dto.setTitle("红包提现");
            dto.setTime(sd.format(record.getCreateTime()));
            dto.setHandle("人工审核" + sd.format(new Date()));
            dto.setMoney("¥" + record.getMoney().setScale(2));
            dto.setBalance("¥" + redPackBalanceService.getBalance(record.getUid()));
            userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackExchangePass, new Gson().toJson(dto), beizu);
        } catch (RedPackBalanceException e) {
            throw new RedPackExchangeException(1, e.getMsg());
        }
        //消息
        SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
        String beizu = "红包提现成功后请到“我的-账户余额”中查看";
        MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO();
        dto.setTitle("红包提现");
        dto.setTime(sd.format(record.getCreateTime()));
        dto.setHandle("人工审核" + sd.format(new Date()));
        dto.setMoney("¥" + record.getMoney().setScale(2));
        dto.setBalance("¥" + redPackBalanceService.getBalance(record.getUid()));
        userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackExchangePass, new Gson().toJson(dto), beizu);
    }
    
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackForbidRecordServiceImpl.java
New file
@@ -0,0 +1,45 @@
package com.yeshi.fanli.service.impl.redpack;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.redpack.RedPackForbidRecordMapper;
import com.yeshi.fanli.entity.redpack.RedPackForbidRecord;
import com.yeshi.fanli.service.inter.redpack.RedPackForbidRecordService;
@Service
public class RedPackForbidRecordServiceImpl implements RedPackForbidRecordService {
    @Resource
    private RedPackForbidRecordMapper redPackForbidRecordMapper;
    @Override
    public List<RedPackForbidRecord> query(int page, int pageSize, String key) {
        return redPackForbidRecordMapper.query((page - 1) * pageSize, pageSize, key);
    }
    @Override
    public long count(String key) {
        return redPackForbidRecordMapper.count(key);
    }
    @Override
    public List<RedPackForbidRecord> queryForbid(int page, int pageSize, String key) {
        return redPackForbidRecordMapper.queryForbid((page - 1) * pageSize, pageSize, key);
    }
    @Override
    public long countForbid(String key) {
        return redPackForbidRecordMapper.countForbid(key);
    }
    @Override
    public void insertSelective(RedPackForbidRecord record) {
        redPackForbidRecordMapper.insertSelective(record);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackForbidServiceImpl.java
New file
@@ -0,0 +1,162 @@
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.RedPackForbidMapper;
import com.yeshi.fanli.dto.msg.MsgRedPackExchangeContentDTO;
import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackBalance;
import com.yeshi.fanli.entity.redpack.RedPackForbid;
import com.yeshi.fanli.entity.redpack.RedPackForbidRecord;
import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
import com.yeshi.fanli.exception.redpack.RedPackDetailException;
import com.yeshi.fanli.exception.redpack.RedPackForbidException;
import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
import com.yeshi.fanli.service.inter.redpack.RedPackForbidRecordService;
import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
import com.yeshi.fanli.util.factory.RedPackDetailFactory;
@Service
public class RedPackForbidServiceImpl implements RedPackForbidService {
    @Resource
    private RedPackForbidMapper redPackForbidMapper;
    @Resource
    private RedPackForbidRecordService redPackForbidRecordService;
    @Resource
    private RedPackBalanceService redPackBalanceService;
    @Resource
    private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addForbid(RedPackForbidRecord record) throws RedPackForbidException {
        Long uid = record.getUid();
        if (uid == null || uid <= 0)
            throw new RedPackForbidException(1,"用户id不能为空");
        Integer type = record.getType();
        if (type == null)
            throw new RedPackForbidException(1,"封禁时间不能为空");
        String time = null;
        Date endTime = null;
        Date nowTime = new Date();
        if (type == RedPackForbidRecord.TYPE_ONE_MONTH) {
            time = "1个月";
            endTime = DateUtil.plusMonths(nowTime, 1);
        } else if (type == RedPackForbidRecord.TYPE_THREE_MONTH) {
            time = "3个月";
            endTime = DateUtil.plusMonths(nowTime, 3);
        } else if (type == RedPackForbidRecord.TYPE_SIX_MONTH) {
            time = "半年";
            endTime = DateUtil.plusMonths(nowTime, 6);
        } else if (type == RedPackForbidRecord.TYPE_ONE_YEAR) {
            time = "1年";
            endTime = DateUtil.plusYears(nowTime, 1);
        } else if (type == RedPackForbidRecord.TYPE_HUNDRED_YEAR) {
            time = "永久";
            endTime = DateUtil.plusYears(nowTime, 100);
        } else {
            throw new RedPackForbidException(1,"封禁时间类型不正确");
        }
        // 查询余额
        BigDecimal balance = new BigDecimal(0);
        RedPackBalance redPackBalance = redPackBalanceService.selectForUpdate(uid);
        if (redPackBalance != null && redPackBalance.getMoney() != null)
            balance = redPackBalance.getMoney();
        // 加入封禁
        RedPackForbid redPackForbid = new RedPackForbid();
        redPackForbid.setId(uid);
        redPackForbid.setEndTime(endTime);
        redPackForbid.setCreateTime(nowTime);
        redPackForbidMapper.insertSelective(redPackForbid);
        // 加入封禁记录
        record.setEndTime(endTime);
        record.setMoney(balance);
        record.setCreateTime(nowTime);
        redPackForbidRecordService.insertSelective(record);
        // 清空红包
        try {
            redPackBalanceService.resetRedPack(uid, RedPackDetailFactory.createForbid(record));
        } catch (RedPackBalanceException e) {
            throw new RedPackForbidException(1, e.getMsg());
        } catch (RedPackDetailException e) {
            throw new RedPackForbidException(1, e.getMsg());
        }
        //消息
        MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO();
        dto.setTime(time);
        dto.setReason("红包产生、使用、赠送环节涉嫌违规");
        dto.setHandle("清空所有红包余额");
        userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackForbid, new Gson().toJson(dto), "封禁信息无法申诉,请按照规则使用红包功能");
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deduct(RedPackForbidRecord record) throws RedPackForbidException {
        Long uid = record.getUid();
        if (uid == null || uid <= 0)
            throw new RedPackForbidException(1,"用户id不能为空");
        BigDecimal money = record.getMoney();
        if (money == null)
            throw new RedPackForbidException(1,"扣除金额不能为空");
        // 清空红包
        try {
            redPackBalanceService.subRedPack(uid, money, RedPackDetailFactory.createDeduct(record));
        } catch (RedPackBalanceException e) {
            throw new RedPackForbidException(1, e.getMsg());
        } catch (RedPackDetailException e) {
            throw new RedPackForbidException(1, e.getMsg());
        }
    }
    @Override
    public void delete(List<Long> idsList) {
        if (idsList != null)
            for (Long id : idsList)
                redPackForbidMapper.deleteByPrimaryKey(id);
    }
    @Override
    public boolean verifyForbid(Long uid) {
        if (uid != null) {
            RedPackForbid redPackForbid = redPackForbidMapper.selectByPrimaryKey(uid);
            if (redPackForbid != null) {
                if (redPackForbid.getEndTime() == null || redPackForbid.getEndTime().getTime() > java.lang.System.currentTimeMillis()) {
                    return true;
                } else {
                    // 时间已过,解除封禁
                    redPackForbidMapper.deleteByPrimaryKey(uid);
                    return false;
                }
            }
        }
        return false;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java
@@ -23,12 +23,12 @@
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.RedPackBalanceException;
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;
import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
import com.yeshi.fanli.service.inter.redpack.RedPackGiveRecordService;
import com.yeshi.fanli.service.inter.user.TokenRecordService;
import com.yeshi.fanli.util.Constant;
@@ -60,6 +60,9 @@
    @Resource
    private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
    @Resource
    private RedPackForbidService redPackForbidService;
    @Resource(name = "producer")
    private Producer producer;
@@ -118,18 +121,15 @@
        if (uid == null || amount == null)
            throw new RedPackGiveRecordException(1, "参数不正确");
        if(redPackForbidService.verifyForbid(uid))
            throw new RedPackGiveRecordException(1, "红包功能已被封禁");
        String giveMin = redPackConfigService.getValueByKey("give_money_min");
        String giveMax = redPackConfigService.getValueByKey("give_money_max");
        if (amount.compareTo(new BigDecimal(giveMin)) < 0 || amount.compareTo(new BigDecimal(giveMax)) > 0)
            throw new RedPackGiveRecordException(1, "赠送金额至少" + giveMin + "元至多" + giveMax + "元");
        BigDecimal balance = null;
        try {
            balance = redPackBalanceService.getBalance(uid);
        } catch (RedPackBalanceException e1) {
            throw new RedPackGiveRecordException(1, e1.getMsg());
        }
        BigDecimal balance = redPackBalanceService.getBalance(uid);
        if (balance == null || amount.compareTo(balance) > 0)
            throw new RedPackGiveRecordException(1, "余额不足");
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
@@ -18,6 +18,7 @@
import com.yeshi.fanli.entity.bus.user.UserActiveLog;
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.count.HongBaoV2CountService;
@@ -36,6 +37,7 @@
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
import com.yeshi.fanli.util.annotation.redpack.RedPackGetVersionLimit;
import com.yeshi.fanli.util.factory.RedPackDetailFactory;
@Service
@@ -43,103 +45,103 @@
    @Resource
    private RedPackWinInviteMapper redPackWinInviteMapper;
    @Resource
    private RedPackConfigService redPackConfigService;
    @Resource
    private RedPackBalanceService redPackBalanceService;
    @Resource
    private CommonOrderService  commonOrderService;
    private CommonOrderService commonOrderService;
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
    @Resource
    private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
    @Resource
    @Resource
    private UserInfoService userInfoService;
    @Resource
    @Resource
    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
    @Resource
    @Resource
    private IntegralTaskRecordService integralTaskRecordService;
    @Resource
    private UserActiveLogService userActiveLogService;
    @Resource
    private HongBaoV2CountService hongBaoV2CountService;
    @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);
    }
    @Override
    public BigDecimal getRewardMoney(Long uid) {
        return redPackWinInviteMapper.getRewardMoney(uid);
    }
    @Override
    @RequestSerializableByKeyService(key = "#teamUid")
    @Transactional(rollbackFor = Exception.class)
    public void inviteSucceedReward(Long teamUid) throws Exception{
    public void inviteSucceedReward(Long teamUid) throws Exception {
        // 是否在上线之后的邀请关系
        ThreeSale threeSale = threeSaleSerivce.getByWorkerIdAndTime(teamUid, Constant.RED_PACK_REWARD_TIME);
        if (threeSale == null)
            return;
        // 上级id
        Long bossId = threeSale.getBoss().getId();
        UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(bossId);
        if (activeLog == null)
            return;
        // 小于2.0.2版本不增加
        if (!VersionUtil.greaterThan_2_1("appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
                activeLog.getVersionCode()))
            return;
        // 同一队员奖励一次
        int totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(bossId, teamUid, RedPackWinInviteTypeEnum.oneStageReward.name());
        int totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(bossId, teamUid,
                RedPackWinInviteTypeEnum.oneStageReward.name());
        if (totalReward > 0)
            return;
        // 建立邀请关系时间超过20天
        Long succeedTime = threeSale.getSucceedTime();
        Date endDate = DateUtil.plusDayDate(Constant.ONE_STAGE_LIMIT_DAYS, new Date(succeedTime));
        if (endDate.getTime() < java.lang.System.currentTimeMillis())
            return;
        // 绑定电话号码和微信
        UserInfo userInfo = userInfoService.selectByPKey(teamUid);
        if (userInfo == null || StringUtil.isNullOrEmpty(userInfo.getPhone()) || StringUtil.isNullOrEmpty(userInfo.getWxOpenId()))
        if (userInfo == null || StringUtil.isNullOrEmpty(userInfo.getPhone())
                || StringUtil.isNullOrEmpty(userInfo.getWxOpenId()))
            return;
        // 授权淘宝
        UserExtraTaoBaoInfo taoBaoInfo = userExtraTaoBaoInfoService.getByUid(teamUid);
        if (taoBaoInfo == null || StringUtil.isNullOrEmpty(taoBaoInfo.getTaoBaoUid()))
            return;
        // 好友产生一笔返利订单(自购)且 24 小时内不失效;
        long validOrder = commonOrderService.count24HValidOrderByUid(teamUid, new Date(succeedTime));
        if (validOrder < 1)
        if (validOrder < 1)
            return;
        // 奖励金额
        BigDecimal money = Constant.ONE_STAGE_MONEY;
        // 获得红包
        RedPackWinInvite winInvite = new RedPackWinInvite();
        winInvite.setCreateTime(new Date());
@@ -148,92 +150,93 @@
        winInvite.setUid(bossId);
        winInvite.setTeamUid(teamUid);
        winInvite.setMoney(money);
        winInvite.setIdentifyCode(StringUtil.Md5(RedPackWinInviteTypeEnum.oneStageReward.name() + ":" + teamUid));
        redPackWinInviteMapper.insertSelective(winInvite);
        // 增加红包
        redPackBalanceService.addRedPack(bossId, money, RedPackDetailFactory.createInvite(winInvite));
        // 消息
        MsgRedPackTeamRewardContentDTO dto = new MsgRedPackTeamRewardContentDTO();
        dto.setNickName(userInfo.getNickName());
        dto.setPortrait(userInfo.getPortrait());
        userMoneyMsgNotificationService.teamRedPackRewardMsg(bossId, MsgTypeMoneyTypeEnum.redPackOneStageReward,
                money, "队员(好友)完成第一阶段", new Gson().toJson(dto));
        userMoneyMsgNotificationService.teamRedPackRewardMsg(bossId, MsgTypeMoneyTypeEnum.redPackOneStageReward, money,
                "队员(好友)完成第一阶段", new Gson().toJson(dto));
    }
    @RequestSerializableByKeyService(key = "#uid")
    @RedPackGetVersionLimit(uid = "#uid")
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void orderArriveReward(Long uid, Integer source, String orderNo) throws Exception {
    public void inviteOrderArriveReward(Long uid, Integer source, String orderNo) throws Exception {
        if (uid == null || source == null || StringUtil.isNullOrEmpty(orderNo))
            return;
        ThreeSale threeSale = threeSaleSerivce.getByWorkerIdAndTime(uid, Constant.RED_PACK_REWARD_TIME);
        if(threeSale == null)
        // 获取订单对应下单人
        List<CommonOrder> list = commonOrderService.listBySourceTypeAndOrderId(source, orderNo);
        if (list == null || list.isEmpty())
            return;
        bossReward(threeSale.getBoss().getId(), uid, source, orderNo);
    }
    /**
     * 上级奖励
     * @param uid
     * @param teamUid
     * @param source
     * @param orderNo
     * @throws Exception
     */
    @Transactional
    private void  bossReward(Long bossId, Long teamUid, Integer source, String orderNo)  throws Exception {
        UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(bossId);
        if (activeLog == null)
        CommonOrder commonOrder = list.get(0);
        if (commonOrder == null || commonOrder.getUserInfo() == null)
            return;
        // 小于2.0.2版本不增加
        if (!VersionUtil.greaterThan_2_1("appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
                activeLog.getVersionCode()))
        // 下单人id
        Long teamUid = commonOrder.getUserInfo().getId();
        if (teamUid == null)
            return;
        // 验证上下级关系
        ThreeSale threeSale = threeSaleSerivce.getByWorkerIdAndTime(teamUid, Constant.RED_PACK_REWARD_TIME);
        if (threeSale == null || threeSale.getBoss().getId().longValue() != uid.longValue())
            return;
        // 第一阶段(验证)
        RedPackWinInvite oneStage = redPackWinInviteMapper.getByUidAndTeamUidAndType(bossId, teamUid, RedPackWinInviteTypeEnum.oneStageReward.name());
        RedPackWinInvite oneStage = redPackWinInviteMapper.getByUidAndTeamUidAndType(uid, teamUid,
                RedPackWinInviteTypeEnum.oneStageReward.name());
        if (oneStage == null)
            return;
        // 第二阶段(验证)
        RedPackWinInvite twoStage = redPackWinInviteMapper.getByUidAndTeamUidAndType(bossId, teamUid, RedPackWinInviteTypeEnum.twoStageReward.name());
        RedPackWinInvite twoStage = redPackWinInviteMapper.getByUidAndTeamUidAndType(uid, teamUid,
                RedPackWinInviteTypeEnum.twoStageReward.name());
        if (twoStage == null) {
            twoStageRewardToBoss(bossId, teamUid, oneStage.getCreateTime(), source, orderNo);
            twoStageRewardToBoss(uid, teamUid, oneStage.getCreateTime(), source, orderNo);
            return;
        }
        }
        // 第三阶段
        threeStageRewardToBoss(bossId, teamUid, twoStage.getCreateTime(), source, orderNo);
        threeStageRewardToBoss(uid, teamUid, twoStage.getCreateTime(), source, orderNo);
    }
    /**
     *    上级奖励--第二阶段
     * 上级奖励--第二阶段
     *
     * @param uid
     * @param source
     * @param orderNo
     * @param bossId
     */
    @Transactional
    private void twoStageRewardToBoss(Long bossId, Long teamUid, Date oneStageTime, Integer source, String orderNo) throws Exception{
        // 第一阶段完成之后的90天内 ; 队友产生的订单中(自购+分享),邀请人累计产生≥1 元奖金
    private void twoStageRewardToBoss(Long bossId, Long teamUid, Date oneStageTime, Integer source, String orderNo)
            throws Exception {
        // 第一阶段完成之后的90天内 ; 队友产生的订单中(自购+分享),邀请人累计产生≥1 元奖金
        Date endDate = DateUtil.plusDayDate(Constant.TWO_STAGE_LIMIT_DAYS, oneStageTime);
        BigDecimal rewardMoney = hongBaoV2CountService.getShareRewardByTeamUid(bossId, teamUid, endDate);
        // 统计订单奖金 (“好友自购”和“好友分享”)
        BigDecimal rewardMoney = hongBaoV2CountService.getOrderRewardByTeamUid(bossId, teamUid, endDate);
        if (rewardMoney == null || rewardMoney.compareTo(Constant.TWO_STAGE_ORDER_REWARD_MIN) < 0)
            return;
        // 计算奖励
        BigDecimal money = Constant.TWO_STAGE_MONEY_MIN;
        long total = redPackWinInviteMapper.countByUidAndType(bossId, RedPackWinInviteTypeEnum.twoStageReward.name());
        if (total > 0 && total < Constant.TWO_STAGE_MONEY_ADD_NUM) {
            long num = total % Constant.TWO_STAGE_MONEY_ADD_NUM;
            money = MoneyBigDecimalUtil.add(money, MoneyBigDecimalUtil.mul(Constant.TWO_STAGE_MONEY_ADD, new BigDecimal(num)));
            money = MoneyBigDecimalUtil.add(money,
                    MoneyBigDecimalUtil.mul(Constant.TWO_STAGE_MONEY_ADD, new BigDecimal(num)));
        }
        // 获得红包记录
        RedPackWinInvite winInvite = new RedPackWinInvite();
        winInvite.setUid(bossId);
@@ -244,59 +247,64 @@
        winInvite.setCreateTime(new Date());
        winInvite.setUpdateTime(new Date());
        winInvite.setType(RedPackWinInviteTypeEnum.twoStageReward);
        winInvite.setIdentifyCode(StringUtil.Md5(RedPackWinInviteTypeEnum.twoStageReward.name() + ":" + teamUid));
        redPackWinInviteMapper.insertSelective(winInvite);
        // 4、增加红包
        redPackBalanceService.addRedPack(bossId, money, RedPackDetailFactory.createIncreaseReward(winInvite));
        // 5、消息
        UserInfo userInfo = userInfoService.selectByPKey(teamUid);
        MsgRedPackTeamRewardContentDTO dto = new MsgRedPackTeamRewardContentDTO();
        dto.setNickName(userInfo.getNickName());
        dto.setPortrait(userInfo.getPortrait());
        userMoneyMsgNotificationService.teamRedPackRewardMsg(bossId, MsgTypeMoneyTypeEnum.redPackTwoStageReward,
                money, "队员(好友)完成第二阶段", new Gson().toJson(dto));
        userMoneyMsgNotificationService.teamRedPackRewardMsg(bossId, MsgTypeMoneyTypeEnum.redPackTwoStageReward, money,
                "队员(好友)完成第二阶段", new Gson().toJson(dto));
    }
    /**
     * 上级奖励:次月开始产生满足条件的分享订单(分享订单实付款≥10元) 连续15个月 自然月获得(已到账)每月最高2元
     *
     * @param uid
     * @param source
     * @param orderNo
     * @param bossId
     */
    @Transactional
    private void threeStageRewardToBoss(Long bossId, Long teamUid,  Date twoStageTime, Integer source, String orderNo) throws Exception{
    private void threeStageRewardToBoss(Long bossId, Long teamUid, Date twoStageTime, Integer source, String orderNo)
            throws Exception {
        // 二、三阶段不可同月
        if (DateUtil.isSameMonth(twoStageTime, new Date()))
            return;
        // 是否已领取本月
        RedPackWinInvite threeStage = redPackWinInviteMapper.getByUidAndTeamUidAndTypeMonth(bossId, teamUid, RedPackWinInviteTypeEnum.threeStageReward.name());
        RedPackWinInvite threeStage = redPackWinInviteMapper.getByUidAndTeamUidAndTypeMonth(bossId, teamUid,
                RedPackWinInviteTypeEnum.threeStageReward.name());
        if (threeStage != null)
            return;
        // 已奖励次数
        int totalNum = redPackWinInviteMapper.countByUidAndTeamUidAndType(bossId, teamUid, RedPackWinInviteTypeEnum.threeStageReward.name());
        // 已奖励次数
        int totalNum = redPackWinInviteMapper.countByUidAndTeamUidAndType(bossId, teamUid,
                RedPackWinInviteTypeEnum.threeStageReward.name());
        if (totalNum >= Constant.THREE_STAGE_REWARD_MONTH)
            return;
        // 是否已间断
        int monthSpace = DateUtil.getMonthSpace(twoStageTime, new Date());
        if (monthSpace !=  totalNum + 1)
        if (monthSpace != totalNum + 1)
            return;
        // 每月给你累计产生≥2 元
        BigDecimal rewardMoney = hongBaoV2CountService.getShareRewardByTeamUidLastMonth(bossId, teamUid);
        // 统计本月获得奖金 (“好友自购”和“好友分享”)
        BigDecimal rewardMoney = hongBaoV2CountService.getOrderRewardByTeamUidTheMonth(bossId, teamUid);
        if (rewardMoney == null || rewardMoney.compareTo(Constant.THREE_STAGE_ORDER_REWARD_MIN) < 0)
            return;
        // 计算随机奖励
        double randomMoney = Constant.THREE_STAGE_RANDOM_MIN +  Math.random() * (Constant.THREE_STAGE_RANDOM_MAX - Constant.THREE_STAGE_RANDOM_MIN);
        double randomMoney = Constant.THREE_STAGE_RANDOM_MIN
                + Math.random() * (Constant.THREE_STAGE_RANDOM_MAX - Constant.THREE_STAGE_RANDOM_MIN);
        // 保留两位小数
        BigDecimal money = new BigDecimal(randomMoney).setScale(2, BigDecimal.ROUND_HALF_UP);
        // 3、获得红包记录
        RedPackWinInvite winInvite = new RedPackWinInvite();
        winInvite.setCreateTime(new Date());
@@ -307,18 +315,20 @@
        winInvite.setMoney(money);
        winInvite.setSource(source);
        winInvite.setOrderNo(orderNo);
        winInvite.setIdentifyCode(
                StringUtil.Md5(RedPackWinInviteTypeEnum.threeStageReward.name() + ":" + teamUid + "-" + monthSpace));
        redPackWinInviteMapper.insertSelective(winInvite);
        // 4、增加红包
        redPackBalanceService.addRedPack(bossId, money, RedPackDetailFactory.createSeriesReward(winInvite));
        // 消息
        UserInfo userInfo = userInfoService.selectByPKey(teamUid);
        MsgRedPackTeamRewardContentDTO dto = new MsgRedPackTeamRewardContentDTO();
        dto.setNickName(userInfo.getNickName());
        dto.setPortrait(userInfo.getPortrait());
        userMoneyMsgNotificationService.teamRedPackRewardMsg(bossId, MsgTypeMoneyTypeEnum.redPackThreeStageReward,
                money, "队员(好友)完成第三阶段连续[第"+ monthSpace + "个月]", new Gson().toJson(dto));
                money, "队员(好友)完成第三阶段连续[第" + monthSpace + "个月]", new Gson().toJson(dto));
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinNewUserServiceImpl.java
@@ -12,13 +12,13 @@
import com.yeshi.fanli.dao.mongodb.redpack.RedPackWinNewUserDao;
import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.push.DeviceActive;
import com.yeshi.fanli.entity.redpack.RedPackBalance;
import com.yeshi.fanli.entity.redpack.RedPackWinNewUser;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
import com.yeshi.fanli.service.inter.push.DeviceActiveService;
import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
import com.yeshi.fanli.service.inter.redpack.RedPackWinNewUserService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.util.Constant;
@@ -49,6 +49,9 @@
    @Resource
    private DeviceActiveService deviceActiveService;
    
    @Resource
    private RedPackForbidService redPackForbidService;
    
    @Override
    public boolean verifyHasReward(Long uid, String device) {
@@ -70,10 +73,8 @@
                return true; // 未超过时间
            }
            
            RedPackBalance redPackBalance = redPackBalanceService.selectByPrimaryKey(uid);
            if (redPackBalance != null && redPackBalance.getState() != null
                    && redPackBalance.getState() == RedPackBalance.STATE_LOCKED)
                return false;  // 红包封禁
            if(redPackForbidService.verifyForbid(uid))
                return false; // 红包封禁
            
            UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
            if (userInfoExtra == null || userInfoExtra.getFirstLoginTime() == null) 
fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopOrderServiceImpl.java
@@ -40,6 +40,7 @@
import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
import com.yeshi.fanli.service.inter.mq.MQUnSendInfoService;
import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsClassService;
import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsService;
import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetPayService;
@@ -90,6 +91,10 @@
    @Resource
    private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
    @Resource
    private RedPackForbidService redPackForbidService;
    @Transactional
    @Override
@@ -435,13 +440,11 @@
            throw new BanLiShopOrderException(22, "商品已下线");
        }
        if(redPackForbidService.verifyForbid(uid))
            throw new BanLiShopOrderException(25, "红包功能已被封禁");
        if (pay.getHongBaoPrice() != null && pay.getHongBaoPrice().compareTo(new BigDecimal(0)) > 0) {
            BigDecimal money = null;
            try {
                money = redPackBalanceService.getBalance(uid);
            } catch (RedPackBalanceException e) {
                throw new BanLiShopOrderException(25, "红包功能异常");
            }
            BigDecimal money = redPackBalanceService.getBalance(uid);
            if (money.compareTo(pay.getHongBaoPrice()) < 0) {
                throw new BanLiShopOrderException(24, "红包余额不足");
            }
fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java
@@ -184,21 +184,21 @@
    public long countAlreadyGetMoneyByUid(Long uid, List<Integer> typeList, Date minGetTime, Date maxGetTime);
    /**
     * 查询来源该下级成功分享奖金活动
    /**
     * 查询来源该下级成功分享 + 自购订单
     * @param uid
     * @param teamUid
     * @param endTime
     * @return
     */
    public BigDecimal getShareRewardByTeamUid(Long uid, Long teamUid, Date endTime);
    public BigDecimal getOrderRewardByTeamUid(Long uid, Long teamUid, Date endTime);
    /**
     * 统计下级上个有效订单
     * 统计该下级成功分享 + 自购订单
     * @param uid
     * @param teamUid 下级id
     * @return
     */
    public BigDecimal getShareRewardByTeamUidLastMonth(Long uid, Long teamUid);
    public BigDecimal getOrderRewardByTeamUidTheMonth(Long uid, Long teamUid);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackBalanceService.java
@@ -1,10 +1,12 @@
package com.yeshi.fanli.service.inter.redpack;
import java.math.BigDecimal;
import java.util.List;
import com.yeshi.fanli.entity.redpack.RedPackBalance;
import com.yeshi.fanli.entity.redpack.RedPackDetail;
import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
import com.yeshi.fanli.vo.redpack.RedPackBalanceVO;
public interface RedPackBalanceService {
@@ -20,7 +22,7 @@
     * @param uid
     * @return
     */
    public BigDecimal getBalance(Long uid) throws RedPackBalanceException;
    public BigDecimal getBalance(Long uid);
    
    /**
@@ -37,6 +39,31 @@
     */
    public void subRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException;
    /**
     * 后端查询列表
     * @param start
     * @param count
     * @param key
     * @param state
     * @param order
     * @return
     */
    public List<RedPackBalanceVO> query(Integer start, Integer count, String key, Integer state, Integer order);
    public long count(String key, Integer state);
    /**
     * 重置红包
     * @param uid
     * @param detail
     * @throws RedPackBalanceException
     */
    public void resetRedPack(Long uid, RedPackDetail detail) throws RedPackBalanceException;
    /**
     *  查询用于更新 + 枷锁
     * @param uid
     * @return
     */
    public RedPackBalance selectForUpdate(Long uid);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackConfigService.java
@@ -1,8 +1,10 @@
package com.yeshi.fanli.service.inter.redpack;
import java.util.Date;
import java.util.List;
import com.yeshi.fanli.entity.redpack.RedPackConfig;
import com.yeshi.fanli.exception.redpack.RedPackConfigException;
public interface RedPackConfigService {
@@ -27,4 +29,12 @@
    
    public String getValueByKey(String key, Date date);
    public void delete(List<Long> idsList);
    public List<RedPackConfig> query(int page, int pageSize, String key);
    public long count(String key);
    public void save(RedPackConfig record) throws RedPackConfigException;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackDetailService.java
@@ -66,6 +66,32 @@
     */
    public void changeDisplayByIdentifyCode(String code,boolean disPlay);
    /**
     * 统计获得
     * @param uid
     * @param dateType
     * @return
     */
    public BigDecimal countWinMoneyByDate(long uid, int dateType);
    /**
     * 统计减少
     * @param uid
     * @param dateType
     * @return
     */
    public BigDecimal countReduceMoneyByDate(long uid, int dateType);
    /**
     * 列表查询
     * @param startd
     * @param count
     * @param uid
     * @param type
     * @return
     */
    public List<RedPackDetail> query(Integer start, Integer count, String key, Long uid, Integer type);
    public long count(String key, Long uid, Integer type);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackForbidRecordService.java
New file
@@ -0,0 +1,32 @@
package com.yeshi.fanli.service.inter.redpack;
import java.util.List;
import com.yeshi.fanli.entity.redpack.RedPackForbidRecord;
public interface RedPackForbidRecordService {
    public void insertSelective(RedPackForbidRecord record);
    /**
     * 查询历史记录
     * @param page
     * @param pageSize
     * @param key
     * @return
     */
    public List<RedPackForbidRecord> query(int page, int pageSize, String key);
    public long count(String key);
    /**
     * 查询封禁用户
     * @param page
     * @param pageSize
     * @param key
     * @return
     */
    public List<RedPackForbidRecord> queryForbid(int page, int pageSize, String key);
    public long countForbid(String key);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackForbidService.java
New file
@@ -0,0 +1,36 @@
package com.yeshi.fanli.service.inter.redpack;
import java.util.List;
import com.yeshi.fanli.entity.redpack.RedPackForbidRecord;
import com.yeshi.fanli.exception.redpack.RedPackForbidException;
public interface RedPackForbidService {
    /**
     * 封禁用户
     * @param record
     */
    public void addForbid(RedPackForbidRecord record) throws RedPackForbidException;
    /**
     * 删除
     * @param idsList
     */
    public void delete(List<Long> idsList);
    /**
     * 扣除红包信息
     * @param record
     * @throws RedPackForbidException
     */
    public void deduct(RedPackForbidRecord record) throws RedPackForbidException;
    /**
     * 验证是否被封禁
     * @param uid
     * @return
     */
    public boolean verifyForbid(Long uid);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackWinInviteService.java
@@ -8,13 +8,13 @@
public interface RedPackWinInviteService {
    /**
     * 订单到账-相关奖励
     * 邀请订单到账-相关奖励
     * @param uid
     * @param inviteeUid
     * @param source
     * @param orderNo
     */
    public void orderArriveReward(Long uid, Integer source, String orderNo) throws Exception;
    public void inviteOrderArriveReward(Long uid, Integer source, String orderNo) throws Exception;
    /**
     * 查询获得记录
fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java
@@ -1,11 +1,13 @@
package com.yeshi.fanli.util.factory;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.yeshi.fanli.entity.redpack.RedPackDetail;
import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackExchange;
import com.yeshi.fanli.entity.redpack.RedPackForbidRecord;
import com.yeshi.fanli.entity.redpack.RedPackGiveRecord;
import com.yeshi.fanli.entity.redpack.RedPackWinInvite;
import com.yeshi.fanli.exception.redpack.RedPackDetailException;
@@ -80,7 +82,53 @@
        detail.setCreateTime(new Date());
        return detail;
    }
    /**
     * 红包封禁
     *
     * @param extract
     * @return
     */
    public static RedPackDetail createForbid(RedPackForbidRecord record) throws RedPackDetailException {
        if (record == null)
            throw new RedPackDetailException(1, "提现记录不能为空");
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(true);
        detail.setUid(record.getUid());
        detail.setDescInfo(record.getReason());
        detail.setMoney(new BigDecimal("-" + record.getMoney()));
        detail.setType(RedPackDetailTypeEnum.forbid);
        detail.setTitle(RedPackDetailTypeEnum.forbid.getDesc());
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.forbid.name() + ":" + record.getId()));
        detail.setCreateTime(new Date());
        return detail;
    }
    /**
     * 红包扣除
     *
     * @param extract
     * @return
     */
    public static RedPackDetail createDeduct(RedPackForbidRecord record) throws RedPackDetailException {
        if (record == null)
            throw new RedPackDetailException(1, "提现记录不能为空");
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(true);
        detail.setUid(record.getUid());
        detail.setDescInfo(record.getReason());
        detail.setMoney(new BigDecimal("-" + record.getMoney()));
        detail.setType(RedPackDetailTypeEnum.deduct);
        detail.setTitle(RedPackDetailTypeEnum.deduct.getDesc());
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.deduct.name() + ":" + record.getUid() + format.format(new Date())));
        detail.setCreateTime(new Date());
        return detail;
    }
    /**
     * 赠送好友明细
     * 
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java
@@ -741,20 +741,51 @@
            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.redPackForbid) { // 红包封禁消息
            if (StringUtil.isNullOrEmpty(msg.getContent()))
                return null;
            MsgRedPackExchangeContentDTO dto = new Gson().fromJson(msg.getContent(),
                    MsgRedPackExchangeContentDTO.class);
            if (dto == null)
                return null;
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getReason() + "", 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(dto.getHandle(), 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/img/tlj/icon_tlj.png", msg.getMsgType().getDesc(),
                    msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(), items);
        } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackOneStageReward
                || msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackTwoStageReward
                || msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackThreeStageReward) { // 红包邀请获得
            if (StringUtil.isNullOrEmpty(msg.getContent()))
                return null;
            MsgRedPackTeamRewardContentDTO dto = new Gson().fromJson(msg.getContent(), MsgRedPackTeamRewardContentDTO.class);
            MsgRedPackTeamRewardContentDTO dto = new Gson().fromJson(msg.getContent(),
                    MsgRedPackTeamRewardContentDTO.class);
            if (dto == null)
                return null;
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getNickName() + "", COLOR_CONTENT,dto.getPortrait()));
            contentList.add(new ClientTextStyleVO(dto.getNickName() + "", COLOR_CONTENT, dto.getPortrait()));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("被邀请人", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(msg.getStateDesc(), COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("红包进程", COLOR_TITLE), contentList));
@@ -766,7 +797,7 @@
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu(),
                    COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("备       注", COLOR_TITLE), contentList));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
            return new UserMsgVO("http://img.flqapp.com/img/tlj/icon_tlj.png", "红包提醒",
                    msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(), items);
@@ -802,21 +833,24 @@
            if (hongBaoPay) {
                contentList = new ArrayList<>();
                contentList
                        .add(new ClientTextStyleVO("¥"+dto.getHongBao().setScale(2).toString(), COLOR_HIGHLIGHT_CONTENT));
                contentList.add(
                        new ClientTextStyleVO("¥" + dto.getHongBao().setScale(2).toString(), COLOR_HIGHLIGHT_CONTENT));
                items.add(new CommonMsgItemVO(new ClientTextStyleVO("消耗红包", COLOR_TITLE), contentList));
            }
            if (moneyPay) {
                contentList = new ArrayList<>();
                contentList.add(new ClientTextStyleVO("¥"+dto.getMoney().setScale(2).toString(), COLOR_HIGHLIGHT_CONTENT));
                contentList.add(
                        new ClientTextStyleVO("¥" + dto.getMoney().setScale(2).toString(), COLOR_HIGHLIGHT_CONTENT));
                items.add(new CommonMsgItemVO(new ClientTextStyleVO("消耗现金", COLOR_TITLE), contentList));
            }
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO("人工审核["+ TimeUtil.getGernalTime(dto.getTime().getTime(),"yyyy.MM.dd HH:mm")+"]", COLOR_CONTENT));
            contentList.add(new ClientTextStyleVO(
                    "人工审核[" + TimeUtil.getGernalTime(dto.getTime().getTime(), "yyyy.MM.dd HH:mm") + "]",
                    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));
@@ -855,21 +889,22 @@
            if (hongBaoPay) {
                contentList = new ArrayList<>();
                contentList
                        .add(new ClientTextStyleVO("¥"+dto.getHongBao().setScale(2).toString(), COLOR_HIGHLIGHT_CONTENT));
                contentList.add(
                        new ClientTextStyleVO("¥" + dto.getHongBao().setScale(2).toString(), COLOR_HIGHLIGHT_CONTENT));
                items.add(new CommonMsgItemVO(new ClientTextStyleVO("消耗红包", COLOR_TITLE), contentList));
            }
            if (moneyPay) {
                contentList = new ArrayList<>();
                contentList.add(new ClientTextStyleVO("¥"+dto.getMoney().setScale(2).toString()+"[已原路退回]", COLOR_HIGHLIGHT_CONTENT));
                contentList.add(new ClientTextStyleVO("¥" + dto.getMoney().setScale(2).toString() + "[已原路退回]",
                        COLOR_HIGHLIGHT_CONTENT));
                items.add(new CommonMsgItemVO(new ClientTextStyleVO("消耗现金", COLOR_TITLE), contentList));
            }
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getReason(), 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));
@@ -991,13 +1026,13 @@
        } else if (msgType == MsgTypeInviteTypeEnum.inviteSucceed) {
            if (msg.getInviteUser() == null || msg.getInviteUser().getWorker() == null)
                return null;
            List<CommonMsgItemVO> items = new ArrayList<>();
            List<ClientTextStyleVO> contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(msg.getInviteUser().getWorker().getNickName() + "", COLOR_CONTENT,
                    msg.getInviteUser().getWorker().getPortrait()));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("被邀请人", COLOR_TITLE), contentList));
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO("邀请队员成功", COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("邀请状态", COLOR_TITLE), contentList));
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java
@@ -91,12 +91,13 @@
        } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiSeparateByOrderNo.name())) {// 订单到账(按订单号处理)
            OrderMoneyRecievedMQMsg orderMoneyRecievedMQMsg = new Gson().fromJson(new String(message.getBody()),
                    OrderMoneyRecievedMQMsg.class);
            if (orderMoneyRecievedMQMsg.getType() == OrderMoneyRecievedMQMsg.TYPE_ZIGOU
                    || orderMoneyRecievedMQMsg.getType() == OrderMoneyRecievedMQMsg.TYPE_SHARE) {
            if (orderMoneyRecievedMQMsg.getType() == OrderMoneyRecievedMQMsg.TYPE_INVITE) {
                if (!StringUtil.isNullOrEmpty(orderMoneyRecievedMQMsg.getOrderId())
                        && orderMoneyRecievedMQMsg.getUid() != null) {
                     try {
                         redPackWinInviteService.orderArriveReward(orderMoneyRecievedMQMsg.getUid(), orderMoneyRecievedMQMsg.getSourceType(), orderMoneyRecievedMQMsg.getOrderId());
                         redPackWinInviteService.inviteOrderArriveReward(orderMoneyRecievedMQMsg.getUid(),
                                 orderMoneyRecievedMQMsg.getSourceType(), orderMoneyRecievedMQMsg.getOrderId());
                     } catch (Exception e) {
                         e.printStackTrace();
                     }
fanli/src/main/java/com/yeshi/fanli/vo/redpack/RedPackBalanceVO.java
New file
@@ -0,0 +1,93 @@
package com.yeshi.fanli.vo.redpack;
import java.math.BigDecimal;
import com.yeshi.fanli.entity.redpack.RedPackBalance;
public class RedPackBalanceVO extends RedPackBalance {
    private BigDecimal giveMoney; // 赠送金额
    private BigDecimal useMoney; // 使用金额
    private BigDecimal exchangeMoney; // 体现金额
    private BigDecimal todayWin;
    private BigDecimal theMonthWin;
    private BigDecimal totalWin;
    private BigDecimal todayreduce;
    private BigDecimal theMonthreduce;
    private BigDecimal totalreduce;
    public BigDecimal getGiveMoney() {
        return giveMoney;
    }
    public void setGiveMoney(BigDecimal giveMoney) {
        this.giveMoney = giveMoney;
    }
    public BigDecimal getUseMoney() {
        return useMoney;
    }
    public void setUseMoney(BigDecimal useMoney) {
        this.useMoney = useMoney;
    }
    public BigDecimal getExchangeMoney() {
        return exchangeMoney;
    }
    public void setExchangeMoney(BigDecimal exchangeMoney) {
        this.exchangeMoney = exchangeMoney;
    }
    public BigDecimal getTodayWin() {
        return todayWin;
    }
    public void setTodayWin(BigDecimal todayWin) {
        this.todayWin = todayWin;
    }
    public BigDecimal getTheMonthWin() {
        return theMonthWin;
    }
    public void setTheMonthWin(BigDecimal theMonthWin) {
        this.theMonthWin = theMonthWin;
    }
    public BigDecimal getTotalWin() {
        return totalWin;
    }
    public void setTotalWin(BigDecimal totalWin) {
        this.totalWin = totalWin;
    }
    public BigDecimal getTodayreduce() {
        return todayreduce;
    }
    public void setTodayreduce(BigDecimal todayreduce) {
        this.todayreduce = todayreduce;
    }
    public BigDecimal getTheMonthreduce() {
        return theMonthreduce;
    }
    public void setTheMonthreduce(BigDecimal theMonthreduce) {
        this.theMonthreduce = theMonthreduce;
    }
    public BigDecimal getTotalreduce() {
        return totalreduce;
    }
    public void setTotalreduce(BigDecimal totalreduce) {
        this.totalreduce = totalreduce;
    }
}
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.shop.BanLiShopGoods;
import com.yeshi.fanli.entity.shop.BanLiShopOrderGoods;
import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo;
//@Ignore
public class MyBatisProduce {
    @Test
    public void test3() {
        MyBatisMapperUtil.createMapper(BanLiShopOrderGoods.class);
        MyBatisMapperUtil.createMapper(UserVIPInfo.class);
    }
    @Test
    public void test1() {
        ColumnParseUtil.parseColumn(BanLiShopGoods.class,
                "D:\\workspace\\fanli\\fanli-server\\fanli\\src\\main\\java\\com\\yeshi\\fanli\\mapping\\shop\\BanLiShopGoodsMapper.xml");
        ColumnParseUtil.parseColumn(UserInfoExtra.class,
                "D:\\workspace\\fanli\\fanli-server\\fanli\\src\\main\\java\\com\\yeshi\\fanli\\mapping\\user\\UserInfoExtraMapper.xml");
    }
}
fanli/src/test/java/org/fanli/TaoKeTest.java
@@ -14,6 +14,7 @@
import org.junit.Test;
import org.yeshi.utils.HttpUtil;
import com.taobao.api.request.ItemsGetRequest;
import com.yeshi.fanli.dao.mybatis.taobao.TBPidMapper;
import com.yeshi.fanli.dto.taobao.TaoLiJinDTO;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
@@ -35,8 +36,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,10 +50,11 @@
    @Test
    public void test1() {
        for (int i = 0; i < 10; i++) {
            String time = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMddHHmmssSSS");
            System.out.println(time);
        }
//        List<TaoBaoGoodsBrief> list=    TaoKeApiUtil.guessLikeByAuctionId(550439753563L,6);
//        System.out.println(list);
     TaoBaoUtil.getTBDetailImageWithSize(597016140493L);
//        System.out.println(goods);
//        DaTaoKeApiUtil.getGoodsDetailByGoodsId(558195316187L);
    }
    @Test
fanli/src/test/java/org/fanli/config/SystemCouponServiceTest.java
@@ -17,6 +17,15 @@
        
        SystemCouponService service = BeanUtil.getBean(SystemCouponService.class);
        
        new Thread(new Runnable() {
            @Override
            public void run() {
                // TODO Auto-generated method stub
            }
        });
        for (int i = 1; i < 61 ;i ++) {
            
            if (i==10) {
fanli/src/test/java/org/fanli/config/Test_Brand.java
New file
@@ -0,0 +1,70 @@
package org.fanli.config;
import java.util.Date;
import org.junit.Test;
import org.yeshi.utils.DateUtil;
import com.yeshi.fanli.entity.brand.BrandInfo;
import com.yeshi.fanli.service.inter.brand.BrandGoodsCaheService;
import com.yeshi.fanli.service.inter.brand.BrandInfoService;
import com.yeshi.fanli.util.BeanUtil;
import com.yeshi.fanli.util.ThreadUtil;
public class Test_Brand {
    public static void main(String[] args) {
        BrandInfoService service = BeanUtil.getBean(BrandInfoService.class);
        long count = service.countValidByCid(null);
        if (count == 0)
            return;
        for (int page = 0; page < (count / 50) + 1; page++) {
            int p = page;
            ThreadUtil.run(new Runnable() {
                public void run() {
                    service.addShopAndGoods(p*50, 50);
                }
            });
        }
    }
//    @Test
    public void addBrandGoods() {
        try {
            BrandGoodsCaheService service = BeanUtil.getBean(BrandGoodsCaheService.class);
            BrandInfo brandInfo = new BrandInfo();
            brandInfo.setId(50L);
            brandInfo.setName("GAP");
            brandInfo.setShopKey("GAP");
            brandInfo.setIcon("http://ec-1255749512.file.myqcloud.com/img/TaoBaoShop/2bb853de35d845da85b7b10df42424d4.jpeg");
            brandInfo.setSearchKey("GAP");
            service.addBrandGoods(brandInfo);
            System.out.println("test");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
//    @Test
    public void removeAgoByDate() {
        try {
            BrandInfoService service = BeanUtil.getBean(BrandInfoService.class);
            service.removeAgoByDate(DateUtil.reduceDay(1, new Date()));
            System.out.println("test");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
fanli/src/test/java/org/fanli/redpack/Test_RedPackWinInviteService.java
@@ -8,24 +8,24 @@
public class Test_RedPackWinInviteService {
    
//    @Test
    public void addBrandGoods() {
    @Test
    public void inviteOrderArriveReward() {
        try {
            RedPackWinInviteService service = BeanUtil.getBean(RedPackWinInviteService.class);
            service.orderArriveReward(4636763L, 1 ,"440456706868591243");
            System.out.println("test");
            service.inviteOrderArriveReward(974767L, 1 ,"471083872448382646");
            System.out.println("-------- 测试结束 ------------------");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    
    @Test
//    @Test
    public void inviteSucceedReward() {
        try {
            RedPackWinInviteService service = BeanUtil.getBean(RedPackWinInviteService.class);
            service.inviteSucceedReward(6196870L);
            System.out.println("test");
            service.inviteSucceedReward(3272184L);
            System.out.println("-------- 测试结束 ------------------");
        } catch (Exception e) {
            e.printStackTrace();
        }
fanli/src/test/java/org/fanli/tlj/Test_IntegralTaskRecordService.java
@@ -50,5 +50,7 @@
    
    
    
}
utils/.classpath
@@ -19,10 +19,6 @@
            <attribute name="org.eclipse.jst.component.nondependency" value=""/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_181"/>
    <classpathentry kind="output" path="target/classes"/>
</classpath>
utils/src/main/java/org/yeshi/utils/DateUtil.java
@@ -210,7 +210,34 @@
        ca.add(Calendar.DATE, num);
        return ca.getTime();
    }
    /**
     * 加上月份
     * @param currdate
     * @param num
     * @return
     */
    public static Date plusMonths(Date currdate, int num) {
        Calendar ca = Calendar.getInstance();
        ca.setTime(currdate);
        ca.add(Calendar.MONTH, num);
        return ca.getTime();
    }
    /**
     * 加上年份
     * @param currdate
     * @param num
     * @return
     */
    public static Date plusYears(Date currdate, int num) {
        Calendar ca = Calendar.getInstance();
        ca.setTime(currdate);
        ca.add(Calendar.YEAR, num);
        return ca.getTime();
    }
    /**
     * 指定日期减去天数后的日期
     * 
@@ -397,7 +424,7 @@
    }
    public static void main(String[] args) throws ParseException {
        System.out.println(getMonthSpace("2012-02", "2013-01"));
        System.out.println(getMonthSpace("2012-02", "2012-02"));
    }
}