yujian
2019-11-23 a364fbab598a45842d4b38d156e8b5e55f9513ad
红包封禁   + 后台管理
29个文件已修改
1 文件已重命名
17个文件已添加
2047 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/aspect/LoginAspect.java 2 ●●● 补丁 | 查看 | 原始文档 | 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 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RedPackControllerV2.java 30 ●●●● 补丁 | 查看 | 原始文档 | 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/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/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/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/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 141 ●●●●● 补丁 | 查看 | 原始文档 | 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/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/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/util/factory/RedPackDetailFactory.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/redpack/RedPackBalanceVO.java 93 ●●●●● 补丁 | 查看 | 原始文档 | 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/src/main/java/org/yeshi/utils/DateUtil.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/aspect/LoginAspect.java
@@ -35,7 +35,7 @@
    @Resource
    private AdminUserService adminUserService;
    @Around("execution(public * com.yeshi.fanli.controller.admin.*.*(..))")
//    @Around("execution(public * com.yeshi.fanli.controller.admin.*.*(..))")
    public Object verifyLoginState(ProceedingJoinPoint joinPoint) throws IOException {
        Signature signature = joinPoint.getSignature();
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;
@@ -90,7 +89,7 @@
import com.yeshi.fanli.service.inter.order.LostOrderService;
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,10 +230,10 @@
    private BindRemindService bindRemindService;
    
    @Resource
    private RedPackBalanceService redPackBalanceService;
    private UserRankService userRankService;
    
    @Resource
    private UserRankService userRankService;
    private RedPackForbidService redPackForbidService;
    
    private static final String PASSWORD_MAX_ERROR = "password_max_error";
@@ -2181,13 +2180,7 @@
            
            // 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/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/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/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/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/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,141 @@
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.yeshi.fanli.dao.mybatis.redpack.RedPackForbidMapper;
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.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;
    @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,"封禁时间不能为空");
        Date endTime = null;
        Date nowTime = new Date();
        if (type == RedPackForbidRecord.TYPE_ONE_MONTH) {
            endTime = DateUtil.plusMonths(nowTime, 1);
        } else if (type == RedPackForbidRecord.TYPE_THREE_MONTH) {
            endTime = DateUtil.plusMonths(nowTime, 3);
        } else if (type == RedPackForbidRecord.TYPE_SIX_MONTH) {
            endTime = DateUtil.plusMonths(nowTime, 6);
        } else if (type == RedPackForbidRecord.TYPE_ONE_YEAR) {
            endTime = DateUtil.plusYears(nowTime, 1);
        } else if (type == RedPackForbidRecord.TYPE_HUNDRED_YEAR) {
            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());
        }
    }
    @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/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/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/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/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/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/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"));
    }
}