admin
2019-10-29 54ae34b91644b02c422b41197ae6ce33f4e3ca57
Merge remote-tracking branch 'origin/div' into div

Conflicts:
fanli/src/main/java/com/yeshi/fanli/entity/money/UserMoneyDetail.java
42个文件已添加
33个文件已修改
4448 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/RedPackAdminController.java 222 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ConfigController.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RedPackControllerV2.java 281 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCouponControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/brand/BrandGoodsCaheDao.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/brand/BrandShopCaheDao.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackBalanceMapper.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackConfigMapper.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackDetailMapper.java 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackExchangeMapper.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackGiveRecordMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponActivateMapper.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponMapper.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/TokenRecord.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCouponActivate.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/money/UserMoneyDetail.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackBalance.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackConfig.java 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackDetail.java 164 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackExchange.java 138 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackGiveRecord.java 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/redpack/RedPackBalanceException.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/redpack/RedPackDetailException.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/redpack/RedPackExchangeException.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/redpack/RedPackGiveRecordException.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/BrandInfoJob.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/TaoLiJinJob.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/UserInfoMapper.xml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackBalanceMapper.xml 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackConfigMapper.xml 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackDetailMapper.xml 160 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackExchangeMapper.xml 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackGiveRecordMapper.xml 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponActivateMapper.xml 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponMapper.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandShopCaheServiceImpl.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractServiceImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 482 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackConfigServiceImpl.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackDetailServiceImpl.java 213 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java 186 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponActivateServiceImpl.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java 170 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandGoodsCaheService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandInfoService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandShopCaheService.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackBalanceService.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackConfigService.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackDetailService.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackExchangeService.java 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackGiveRecordService.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponActivateService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/TimeUtil.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/ShopInfoVOFactory.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/mybatishandler/redpack/RedPackDetailTypeEnumHandler.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/goods/SpikeTimeVO.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/msg/ClientTextStyleVO.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/redpack/RedPackDetailVO.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/redpack/RedPackMonthVO.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/ehcache.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/resource/env-dev/constant.properties 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/MyBatisProduce.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/test/java/org/fanli/TaoKeTest.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/src/main/java/org/yeshi/utils/entity/wx/RedPackRecord.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/src/main/java/org/yeshi/utils/wx/WXRedPackUtil.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java
@@ -22,11 +22,11 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.yeshi.utils.CsvUtil;
import org.yeshi.utils.DateUtil;
import org.yeshi.utils.IPUtil;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.entity.wx.RedPackRecord;
import org.yeshi.utils.wx.WXRedPackUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -1165,7 +1165,7 @@
        }
        try {
            List<RedPackRecord> list = CsvUtil.getCsvData(file, RedPackRecord.class);
            List<RedPackRecord> list = WXRedPackUtil.readCsv(file.getInputStream());
            extractService.updateManualExtractRecord(list);
            out.print(JsonUtil.loadTrueResult("上传成功"));
        } catch (ExtractException e) {
@@ -1174,6 +1174,15 @@
            e.printStackTrace();
            out.print(JsonUtil.loadFalseResult("上传失败"));
        }
    }
    public static String getValue(String[] item,int index){
        if(item.length > index){
            String value = item[index];
            return value;
        }
        return "";
    }
    /**
@@ -1225,5 +1234,5 @@
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/admin/RedPackAdminController.java
New file
@@ -0,0 +1,222 @@
package com.yeshi.fanli.controller.admin;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
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.bus.user.UserInfo;
import com.yeshi.fanli.entity.common.AdminUser;
import com.yeshi.fanli.entity.redpack.RedPackExchange;
import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
import com.yeshi.fanli.service.AdminUserService;
import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
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 net.sf.json.JSONObject;
@Controller
@RequestMapping("admin/new/api/v1/redpack")
public class RedPackAdminController {
    @Resource
    private RedPackExchangeService redPackExchangeService;
    @Resource
    private RedPackBalanceService redPackBalanceService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private AdminUserService adminUserService;
    /**
     *
     * @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, PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
        }
        if (pageSize == null || pageSize < 1) {
            pageSize = Constant.PAGE_SIZE;
        }
        try {
            List<RedPackExchange> list = redPackExchangeService.query((pageIndex - 1) * pageSize, pageSize, key, state);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            for (RedPackExchange redPackExchange: list) {
                UserInfo userInfo = userInfoService.selectByPKey(redPackExchange.getUid());
                redPackExchange.setPortrait(userInfo.getPortrait());
                redPackExchange.setNickName(userInfo.getNickName());
                Long auditId = redPackExchange.getAuditId();
                if(auditId != null) {
                    AdminUser adminUser = adminUserService.selectByPrimaryKey(auditId);
                    if (adminUser != null) {
                        redPackExchange.setAuditName(adminUser.getName());
                    }
                }
            }
            long count = redPackExchangeService.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 id
     * @param out
     */
    @RequestMapping(value = "getApplyInfo")
    public void getAuditInfo(String callback, Long id, PrintWriter out) {
        RedPackExchange exchange = redPackExchangeService.selectByPrimaryKey(id);
        if (exchange == null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("申请记录不存在"));
            return;
        }
        Long uid = exchange.getUid();
        BigDecimal balance = redPackBalanceService.getBalance(uid);
        UserInfo userInfo = userInfoService.selectByPKey(uid);
        List<Long> listCount = redPackExchangeService.countState(uid);
        List<BigDecimal> listMoney = redPackExchangeService.countMoneyState(uid);
        JSONObject data = new JSONObject();
        data.put("exchange", exchange);
        data.put("userInfo", userInfo);
        data.put("countInit", listCount.get(0));
        data.put("countSucceed", listCount.get(1));
        data.put("countReject",  listCount.get(2));
        data.put("balance", balance);
        data.put("moneyInit", listMoney.get(0));
        data.put("moneySucceed", listMoney.get(1));
        data.put("moneyReject",  listMoney.get(2));
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
    /**
     * 允许提现
     * @param callback
     * @param id
     * @param code
     * @param out
     * @param request
     */
    @RequestMapping(value = "passExchange")
    public void passExchange(String callback, Long id, String code, PrintWriter out, HttpServletRequest request) {
        try {
            /* 检验是否登陆 */
            AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
            if (admin == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。"));
                return;
            }
            /* 检验是否通过验证 */
            String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT);
            if (!"1".equals(codeType)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(3, "邮箱验证未通过"));
                return;
            }
            /* 允许提现 操作 */
            redPackExchangeService.passExchange(id, admin);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
        } catch (RedPackExchangeException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
            return;
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
            return;
        }
    }
    /**
     * 拒绝提现
     * @param callback
     * @param id
     * @param code
     * @param reason
     * @param out
     * @param request
     */
    @RequestMapping(value = "rejectExchange")
    public void rejectExchange(String callback, Long id, String code, String reason, PrintWriter out,
            HttpServletRequest request) {
        try {
            /* 检验是否登陆 */
            AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
            if (admin == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆"));
                return;
            }
            /* 检验是否通过验证 */
            String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT);
            if (!"1".equals(codeType)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(3, "邮箱验证未通过"));
                return;
            }
            // 编码转换
            reason = URLDecoder.decode(reason, "UTF-8");
            redPackExchangeService.rejectExchange(id, reason, admin);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("拒绝成功"));
        } catch (RedPackExchangeException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
            return;
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
            return;
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ConfigController.java
@@ -1,6 +1,8 @@
package com.yeshi.fanli.controller.client.v1;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
@@ -12,6 +14,7 @@
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
import com.yeshi.fanli.entity.bus.user.UserActiveLog;
import com.yeshi.fanli.entity.config.AppHomeFloatImg;
@@ -19,6 +22,7 @@
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.homemodule.FloatADService;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
import com.yeshi.fanli.service.inter.msg.MsgDeviceReadStateService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
@@ -28,6 +32,7 @@
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.ThreadUtil;
import com.yeshi.fanli.util.VersionUtil;
import net.sf.json.JSONObject;
@@ -67,6 +72,10 @@
    @Resource
    private UserActiveLogService userActiveLogService;
    @Resource
    private SwiperPictureService swiperPictureService;
    /**
     * s 首页配置信息
@@ -242,6 +251,14 @@
            JSONObject source = JSONObject.fromObject(configService.getByVersion("taobao_cart_jump_detail",
                    acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion())));
            data.put("taoBaoCart", source);
            if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
                // 我的界面banner
                List<SwiperPicture> banner = swiperPictureService.getByBannerCard("index_top");
                if (banner == null)
                    banner = new ArrayList<SwiperPicture>();
                data.put("banner", JsonUtil.getApiCommonGson().toJson(banner));
            }
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("获取失败"));
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/BrandControllerV2.java
@@ -349,7 +349,7 @@
     * @param acceptData
     * @param out
     */
    @RequestMapping(value = "getList", method = RequestMethod.POST)
//    @RequestMapping(value = "getList", method = RequestMethod.POST)
    public void getList(AcceptData acceptData, Integer page, Long cid, Long uid, PrintWriter out) {
        if (page == null || page < 1) {
            out.print(JsonUtil.loadFalseResult("页码不正确"));
@@ -391,7 +391,7 @@
     * @param acceptData
     * @param out
     */
    @RequestMapping(value = "getShopInfoV2", method = RequestMethod.POST)
//    @RequestMapping(value = "getShopInfoV2", method = RequestMethod.POST)
    public void getShopInfoV2(AcceptData acceptData, Integer page, Long id, Long uid, PrintWriter out) {
        
        if (id == null) {
@@ -551,7 +551,7 @@
     *            精选1, 足迹列表2
     * @param out
     */
    @RequestMapping(value = "getHistoryV2", method = RequestMethod.POST)
//    @RequestMapping(value = "getHistoryV2", method = RequestMethod.POST)
    public void getHistoryV2(AcceptData acceptData, Integer page, Long uid, Integer type, PrintWriter out) {
        if (type == null) {
            out.print(JsonUtil.loadFalseResult("类型不正确"));
@@ -623,7 +623,7 @@
     * @param acceptData
     * @param out
     */
    @RequestMapping(value = "getListV3", method = RequestMethod.POST)
    @RequestMapping(value = "getList", method = RequestMethod.POST)
    public void getListV3(AcceptData acceptData, Integer page, Long cid, Long uid, PrintWriter out) {
        if (page == null || page < 1) {
            out.print(JsonUtil.loadFalseResult("页码不正确"));
@@ -666,7 +666,7 @@
     * @param acceptData
     * @param out
     */
    @RequestMapping(value = "getShopInfoV3", method = RequestMethod.POST)
    @RequestMapping(value = "getShopInfoV2", method = RequestMethod.POST)
    public void getShopInfoV3(AcceptData acceptData, Integer page, Long id, Long uid, PrintWriter out) {
        if (id == null) {
            out.print(JsonUtil.loadFalseResult("缺失店铺id"));
@@ -739,7 +739,7 @@
     *            精选1, 足迹列表2
     * @param out
     */
    @RequestMapping(value = "getHistoryV3", method = RequestMethod.POST)
    @RequestMapping(value = "getHistoryV2", method = RequestMethod.POST)
    public void getHistoryV3(AcceptData acceptData, Integer page, Long uid, Integer type, PrintWriter out) {
        if (type == null) {
            out.print(JsonUtil.loadFalseResult("类型不正确"));
@@ -762,6 +762,7 @@
        List<BrandInfo> list = new ArrayList<BrandInfo>();
        if (listRecord != null && listRecord.size() > 0) {
            for (BrandInfoRecord history : listRecord) {
                if (history.getBrandInfo() != null)
                list.add(history.getBrandInfo());
            }
        }
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java
@@ -61,6 +61,7 @@
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.fanli.vo.goods.OtherInfo;
import com.yeshi.fanli.vo.goods.SpikeTimeVO;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
import com.yeshi.fanli.vo.search.SearchKeyTOPVO;
import com.yeshi.fanli.vo.search.SearchKeyVO;
@@ -247,7 +248,14 @@
            }
        }
        JumpDetailV2 jumpDetail = jumpDetailV2Service.getByTypeCache("web");
        JumpDetailV2 jumpDetail = null;
        if(VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
            jumpDetail = jumpDetailV2Service.getByTypeCache("spike_goods_list");
        } else {
            jumpDetail = jumpDetailV2Service.getByTypeCache("web");
        }
        if (array == null) {
            array = new JSONArray();
@@ -334,6 +342,100 @@
        return root;
    }
    /**
     * 限时秒杀列表
     * @param acceptData
     * @param page
     * @param auctionId
     * @param time
     * @param out
     */
    @RequestMapping("getSpikTime")
    public void getSpikTime(AcceptData acceptData, PrintWriter out) {
        List<SpikeTimeVO> list = new ArrayList<SpikeTimeVO>();
        SpikeTimeVO spikeTime1 = new SpikeTimeVO();
        spikeTime1.setTime("08:00");
        spikeTime1.setState("进行中");
        spikeTime1.setRequestTime("2408");
        SpikeTimeVO spikeTime2 = new SpikeTimeVO();
        spikeTime2.setTime("10:00");
        spikeTime2.setState("进行中");
        spikeTime2.setChecked(true);
        spikeTime2.setRequestTime("2410");
        SpikeTimeVO spikeTime3 = new SpikeTimeVO();
        spikeTime3.setTime("13:00");
        spikeTime3.setState("即将开始");
        spikeTime3.setRequestTime("2413");
        SpikeTimeVO spikeTime4 = new SpikeTimeVO();
        spikeTime4.setTime("15:00");
        spikeTime4.setState("即将开始");
        spikeTime4.setRequestTime("2415");
        list.add(spikeTime1);
        list.add(spikeTime2);
        list.add(spikeTime3);
        list.add(spikeTime4);
        JSONObject data = new JSONObject();
        data.put("count", list.size());
        data.put("list", list);
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 限时秒杀列表
     * @param acceptData
     * @param page
     * @param auctionId
     * @param time
     * @param out
     */
    @RequestMapping("getSpikeGoodsList")
    public void getSpikeGoodsList(AcceptData acceptData, Integer page, Long goodsId, String qtime, PrintWriter out) {
        List<DaTaoKeDetailV2> detailList0 = daTaoKeGoodsDetailV2Service.getDingDongQiangData(qtime);
        if (detailList0 == null)
            detailList0 = new ArrayList<>();
        List<DaTaoKeDetailV2> detailList = new ArrayList<>();
        detailList.addAll(detailList0);
        JSONArray array = new JSONArray();
        if (page == 1 && goodsId != null && detailList != null) {
            for (int i = 0; i < detailList.size(); i++) {
                if (detailList.get(i).getGoodsId().longValue() == goodsId) {
                    DaTaoKeDetailV2 goods = detailList.get(i);
                    detailList.remove(i);
                    detailList.add(0, goods);
                    break;
                }
            }
        }
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
        if (detailList != null) {
            BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
            BigDecimal shareRate = hongBaoManageService.getShareRate();
            for (DaTaoKeDetailV2 detail : detailList) {
                array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(TaoBaoUtil.convert(detail), null, fanLiRate, shareRate)));
            }
        }
        JSONObject data = new JSONObject();
        data.put("count", detailList.size());
        data.put("list", array);
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 金币兑换信息
     * 
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RedPackControllerV2.java
New file
@@ -0,0 +1,281 @@
package com.yeshi.fanli.controller.client.v2;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
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.springframework.web.bind.annotation.RequestMethod;
import org.yeshi.utils.JsonUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackExchange;
import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
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.RedPackExchangeService;
import com.yeshi.fanli.service.inter.redpack.RedPackGiveRecordService;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.vo.redpack.RedPackDetailVO;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("api/v2/redpack")
public class RedPackControllerV2 {
    @Resource
    private RedPackConfigService redPackConfigService;
    @Resource
    private RedPackBalanceService redPackBalanceService;
    @Resource
    private RedPackDetailService redPackDetailService;
    @Resource
    private RedPackGiveRecordService redPackGiveRecordService;
    @Resource
    private RedPackExchangeService redPackExchangeService;
    /**
     * 统计淘礼金
     *
     * @param acceptData
     * @param uid
     * @param out
     */
    @RequestMapping(value = "countInfo", method = RequestMethod.POST)
    public void countInfo(AcceptData acceptData, Long uid, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        BigDecimal zero = new BigDecimal(0);
        BigDecimal todayWin = zero;
        BigDecimal yesterdayWin = zero;
        BigDecimal thisMonthWin = zero;
        BigDecimal lastMonthWin = zero;
        BigDecimal todayUse = zero;
        BigDecimal yesterdayUse = zero;
        BigDecimal thisMonthUse = zero;
        BigDecimal lastMonthUse = zero;
        BigDecimal balance = redPackBalanceService.getBalance(uid);
        if (balance == null) {
            balance = zero;
        } else {
            // 获得
            todayWin = redPackDetailService.countAddMoneyByDate(uid, 1);
            yesterdayWin = redPackDetailService.countAddMoneyByDate(uid, 2);
            thisMonthWin = redPackDetailService.countAddMoneyByDate(uid, 3);
            lastMonthWin = redPackDetailService.countAddMoneyByDate(uid, 4);
            // 消耗
            todayUse = redPackDetailService.countUseMoneyByDate(uid, 1);
            if (todayUse == null || todayUse.compareTo(zero) > 0) {
                todayUse = zero;
            }
            yesterdayUse = redPackDetailService.countUseMoneyByDate(uid, 2);
            if (yesterdayUse == null || yesterdayUse.compareTo(zero) > 0) {
                yesterdayUse = zero;
            }
            thisMonthUse = redPackDetailService.countUseMoneyByDate(uid, 3);
            if (thisMonthUse == null || thisMonthUse.compareTo(zero) > 0) {
                thisMonthUse = zero;
            }
            lastMonthUse = redPackDetailService.countUseMoneyByDate(uid, 4);
            if (lastMonthUse == null || lastMonthUse.compareTo(zero) > 0) {
                lastMonthUse = zero;
            }
        }
        List<String> tips = new ArrayList<String>();
        tips.add("红包余额≥20元后可提现,当前余额不足,请继续加油哦!");
        tips.add("你也可以选择使用红包,享受给力折扣。");
        String giveMin = redPackConfigService.getValueByKey("give_money_min");
        String giveMax = redPackConfigService.getValueByKey("give_money_max");
        // 正在提现金额
        BigDecimal extractingMoney = redPackExchangeService.countMoneyByState(uid, RedPackExchange.STATE_INIT);
        JSONObject data = new JSONObject();
        data.put("balance", balance.setScale(2).toString());
        data.put("helpLink", redPackConfigService.getValueByKey("desc_help_link"));
        data.put("giveMin", giveMin);
        data.put("giveMax", giveMax);
        data.put("giveDesc", "注:红包赠送金额至少" + giveMin + "元至多" + giveMax + "元");
        if (extractingMoney != null && extractingMoney.compareTo(zero) > 0)
            data.put("extractingInfo", "提现中:¥" + extractingMoney.setScale(2));
        data.put("extractShortage", tips);
        data.put("extractMin", redPackConfigService.getValueByKey("extract_money_min"));
        data.put("extractMax", redPackConfigService.getValueByKey("extract_money_max"));
        data.put("extractBanlenMin", redPackConfigService.getValueByKey("extract_banlen_min"));
        data.put("extractDesc", "注:3个工作日内完成审核,红包提现成功后将会进入到余额。");
        data.put("useLink", redPackConfigService.getValueByKey("use_link"));
        data.put("todayWin", todayWin.setScale(2).toString());
        data.put("yesterdayWin", yesterdayWin.setScale(2).toString());
        data.put("thisMonthWin", thisMonthWin.setScale(2).toString());
        data.put("lastMonthWin", lastMonthWin.setScale(2).toString());
        data.put("todayUse", todayUse.setScale(2).toString().replaceAll("-", ""));
        data.put("yesterdayUse", yesterdayUse.setScale(2).toString().replaceAll("-", ""));
        data.put("thisMonthUse", thisMonthUse.setScale(2).toString().replaceAll("-", ""));
        data.put("lastMonthUse", lastMonthUse.setScale(2).toString().replaceAll("-", ""));
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 明细详情列表
     *
     * @param acceptData
     * @param uid
     * @param index      List最末的主键ID
     * @param year       年份
     * @param month      月份
     * @param out
     */
    @RequestMapping(value = "getMoneyDetails")
    public void getMoneyDetails(AcceptData acceptData, Long uid, Long index, Integer year, Integer month,
            PrintWriter out) {
        if (uid == null || uid == 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        if ((year == null && month != null) || (year != null && month == null)) {
            out.print(JsonUtil.loadFalseResult(1, "日期不完整"));
            return;
        }
        Date date = null;
        if (year != null && month != null) {
            date = new Date(TimeUtil.convertToTimeTemp(year + "-" + month, "yyyy-M"));
            Calendar ca = Calendar.getInstance();
            ca.setTime(date);
            ca.add(Calendar.MONTH, 1);
            date = new Date(ca.getTimeInMillis() - 1);
        }
        // 查询列表
        List<RedPackDetailVO> list = redPackDetailService.listUserMoneyDetailForClient(uid, index, date);
        // 统计总条数
        long count = redPackDetailService.countUserMoneyDetailForClient(uid, index, date);
        GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
        gsonBuilder.registerTypeAdapter(RedPackDetailTypeEnum.class, new TypeAdapter<RedPackDetailTypeEnum>() {
            @Override
            public RedPackDetailTypeEnum read(JsonReader arg0) throws IOException {
                return null;
            }
            @Override
            public void write(JsonWriter out, RedPackDetailTypeEnum arg1) throws IOException {
                out.beginObject();
                out.name("portrait").value(arg1.getPicture());
                out.endObject();
            }
        }).registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
            @Override
            public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
                if (value == null) {
                    return new JsonPrimitive("");
                } else {
                    return new JsonPrimitive(TimeUtil.getGernalTime(value.getTime(), "yyyy.MM.dd HH:mm"));
                }
            }
        }).registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
            @Override
            public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
                if (value == null) {
                    return new JsonPrimitive("");
                } else {
                    // 保留2位小数
                    value = value.setScale(2);
                    return new JsonPrimitive(value.toString());
                }
            }
        });
        Gson gson = gsonBuilder.create();
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("data", gson.toJson(list));
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 赠送红包
     *
     * @param acceptData
     * @param uid
     * @param amount
     * @param out
     */
    @RequestMapping(value = "giving", method = RequestMethod.POST)
    public void giving(AcceptData acceptData, Long uid, BigDecimal amount, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        try {
            String tips = redPackGiveRecordService.giving(uid, amount);
            out.print(JsonUtil.loadTrueResult(tips));
        } catch (RedPackGiveRecordException e) {
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
        }
    }
    /**
     * 转换红包为真实金钱
     * @param acceptData
     * @param uid
     * @param amount
     * @param out
     */
    @RequestMapping(value = "exchangeCash", method = RequestMethod.POST)
    public void exchangeCash(AcceptData acceptData, Long uid, BigDecimal amount, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        try {
            redPackExchangeService.exchangeCash(uid, amount);
            out.print(JsonUtil.loadTrueResult("提现申请成功"));
        } catch (RedPackExchangeException e) {
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCouponControllerV2.java
@@ -110,7 +110,7 @@
    
            long count = UserSystemCouponService.countUserCouponList(uid);
            
            List<UserSystemCouponVO> resultList = UserSystemCouponService.getCouponList((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
            List<UserSystemCouponVO> resultList = UserSystemCouponService.getCouponList(acceptData,(page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
            if (resultList == null) {
                resultList = new ArrayList<UserSystemCouponVO>();
            }
fanli/src/main/java/com/yeshi/fanli/dao/brand/BrandGoodsCaheDao.java
@@ -63,6 +63,18 @@
    
    
    /**
     * 品牌id
     * @param brandId
     */
    public void removeByBrandId(Long brandId) {
        Query query = new Query();
        query.addCriteria(Criteria.where("brandId").lt(brandId));
        mongoTemplate.remove(query, BrandGoodsCahe.class);
    }
    /**
     * 删除根据时间
     * 
     * @param id
@@ -79,4 +91,17 @@
            );
        mongoTemplate.remove(query, BrandGoodsCahe.class);
    }
    /**
     * 删除根据时间
     *
     * @param id
     * @return
     */
    public void removeAgoByDate(Date createTime) {
        Query query = new Query();
        query.addCriteria(Criteria.where("createTime").lt(createTime));
        mongoTemplate.remove(query, BrandGoodsCahe.class);
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/brand/BrandShopCaheDao.java
@@ -58,6 +58,17 @@
    
    
    /**
     * 品牌id
     * @param brandId
     */
    public void removeByBrandId(Long brandId) {
        Query query = new Query();
        query.addCriteria(Criteria.where("brandId").lt(brandId));
        mongoTemplate.remove(query, BrandShopCahe.class);
    }
    /**
     * 删除根据时间
     * 
     * @param id
@@ -74,4 +85,16 @@
            );
        mongoTemplate.remove(query, BrandShopCahe.class);
    }
    /**
     * 删除根据时间
     *
     * @param id
     * @return
     */
    public void removeAgoByDate(Date createTime) {
        Query query = new Query();
        query.addCriteria(Criteria.where("createTime").lt(createTime));
        mongoTemplate.remove(query, BrandShopCahe.class);
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackBalanceMapper.java
New file
@@ -0,0 +1,34 @@
package com.yeshi.fanli.dao.mybatis.redpack;
import java.math.BigDecimal;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.redpack.RedPackBalance;
public interface RedPackBalanceMapper extends BaseMapper<RedPackBalance> {
    /**
     *    减掉用户红包金额
     * @param id
     * @param money
     */
    void subRedPack(@Param("id") long id, @Param("money") BigDecimal money);
    /**
     *   增加用户红包金额
     * @param id
     * @param money
     */
    void addRedPack(@Param("id") long id, @Param("money") BigDecimal money);
    /**
     * 查询用于更新余额-锁定
     * @param id
     * @return
     */
    RedPackBalance selectForUpdate(long id);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackConfigMapper.java
New file
@@ -0,0 +1,17 @@
package com.yeshi.fanli.dao.mybatis.redpack;
import java.util.Date;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.redpack.RedPackConfig;
public interface RedPackConfigMapper extends BaseMapper<RedPackConfig> {
    /**
     * 根据key值查询
     * @param key
     * @return
     */
    RedPackConfig getByKey(@Param("key") String key,@Param("startTime")Date startTime);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackDetailMapper.java
New file
@@ -0,0 +1,97 @@
package com.yeshi.fanli.dao.mybatis.redpack;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.redpack.RedPackDetail;
import com.yeshi.fanli.vo.redpack.RedPackMonthVO;
public interface RedPackDetailMapper extends BaseMapper<RedPackDetail> {
    /**
     * 查询明细
     * @param identifyCode
     * @return
     */
    RedPackDetail getByIdentifyCode(@Param("identifyCode")String identifyCode);
    /**
     * 根据日期类型统计获得金额
     * @param uid
     * @param dateType 1今日 、2昨日、3本月、4上月
     * @return
     */
    BigDecimal countAddMoneyByDate(@Param("uid")long uid, @Param("dateType")int dateType);
    /**
     * 根据日期类型统计消耗金额
     * @param uid
     * @param dateType 1今日 、2昨日、3本月、4上月
     * @return
     */
    BigDecimal countUseMoneyByDate(@Param("uid")long uid, @Param("dateType")int dateType);
    /**
     * 按最大的创建时间和用户ID检索列表
     *
     * @param uid
     * @param date
     * @return
     */
    List<RedPackDetail> selectByMaxCreateTime(@Param("uid") Long uid, @Param("date") Date date, @Param("count") int count);
    /**
     * 通过用户ID和返回的最大时间的详情ID来获取下一页的数据
     *
     * @param uid
     * @param id
     * @param count
     * @return
     */
    List<RedPackDetail> selectByUidWithIndexId(@Param("uid") Long uid, @Param("id") Long id, @Param("count") int count);
    /**
     * 统计某个月份的收入与支出
     *
     * @param uid
     * @param dateFormat
     * @return
     */
    List<RedPackMonthVO> selectMonthMoneyByUid(@Param("uid") Long uid, @Param("dateFormat") List<String> dateFormat);
    /**
     * 获取用户总共有多少记录数据
     *
     * @param uid
     * @return
     */
    Long selectCountByUid(@Param("uid") Long uid);
    /**
     * 按用户ID和最大时间检索月份的数量
     *
     * @param uid
     * @param maxDate
     * @return
     */
    int selectMonthCountByUid(@Param("uid") Long uid, @Param("date") Date maxDate);
    /**
     * 按最大的创建时间和用户ID检索数量
     *
     * @param uid
     * @param date
     * @return
     */
    Long selectCountByUidAndMaxCreateTime(@Param("uid") Long uid, @Param("date") Date date);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackExchangeMapper.java
New file
@@ -0,0 +1,49 @@
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.RedPackExchange;
public interface RedPackExchangeMapper extends BaseMapper<RedPackExchange> {
    /**
     * 查询提现信息
     * @param start
     * @param count
     * @param key
     * @param state
     * @return
     */
    List<RedPackExchange> query(@Param("start")Integer start, @Param("count") Integer count,
            @Param("key") String key, @Param("state") Integer state);
    Long count(@Param("key") String key, @Param("state") Integer state);
    /**
     * 统计各个状态
     * @param uid
     * @return
     */
    List<Long> countState(@Param("uid") long uid);
    /**
     * 统计各个状态金额
     * @param uid
     * @return
     */
    List<BigDecimal> countMoneyState(@Param("uid") long uid);
    /**
     * 统计状态金额
     * @param uid
     * @return
     */
    BigDecimal countMoneyByState(@Param("uid") Long uid, @Param("state") Integer state);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/redpack/RedPackGiveRecordMapper.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.RedPackGiveRecord;
public interface RedPackGiveRecordMapper extends BaseMapper<RedPackGiveRecord> {
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponActivateMapper.java
New file
@@ -0,0 +1,17 @@
package com.yeshi.fanli.dao.mybatis.user;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.bus.user.UserSystemCouponActivate;
public interface UserSystemCouponActivateMapper extends BaseMapper<UserSystemCouponActivate> {
    /**
     * 添加数量
     * @param id
     * @param count
     */
    void addCount(@Param("id")Long id, @Param("count") Integer count);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponMapper.java
@@ -122,4 +122,13 @@
     */
    List<UserSystemCoupon> getFreeCouponByType(@Param("uid") Long uid, @Param("type") String type);
    
    /**
     *  查询需要激活的免券
     * @param uid
     * @param source
     * @return
     */
    List<UserSystemCoupon> getNeedActivateFreeCouponByType(@Param("uid") Long uid, @Param("type") String type);
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/TokenRecord.java
@@ -16,7 +16,7 @@
    
    // 口令类型
    public enum TokenTypeEnum {
        freeCoupon("免单券"), rebatePercentCoupon("返利比提成奖励券"),taoLiJin("推广红包"), ;
        freeCoupon("免单券"), rebatePercentCoupon("返利比提成奖励券"),taoLiJin("推广红包"),redPack("红包") ;
        private final String desc;
        private TokenTypeEnum(String desc) {
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCouponActivate.java
New file
@@ -0,0 +1,84 @@
package com.yeshi.fanli.entity.bus.user;
import java.util.Date;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
/**
 * 券激活进度
 * @author Administrator
 *
 */
@Table("yeshi_ec_user_system_coupon_activate")
public class UserSystemCouponActivate {
    // 初始
    public final static int STATE_INIT = 0;
    // 激活完成
    public final static int STATE_END = 1;
    // 用户券id
    @Column(name = "usca_id")
    private Long id;
    // 已完成数量
    @Column(name = "usca_count")
    private Integer count;
    // 激活状态
    @Column(name = "usca_state")
    private Integer state;
    // 创建时间
    @Column(name = "usca_create_time")
    private Date createTime;
    // 更新时间
    @Column(name = "usca_update_time")
    private Date updateTime;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Integer getCount() {
        return count;
    }
    public void setCount(Integer count) {
        this.count = count;
    }
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/money/UserMoneyDetail.java
@@ -53,6 +53,7 @@
        orderReward("返利奖励金", "http://img.flqapp.com/resource/money_detail/icon_order_reward.png", ""),
        repeatStatistic("重复统计返利/奖金扣除", "http://img.flqapp.com/resource/money_detail/icon_fanli.png", ""),
        elmeFanli("饿了么返利到账", "http://img.flqapp.com/resource/money_detail/icon_fanli.png", ""),
        redPackExchange("红包提现到余额", "http://img.flqapp.com/resource/money_detail/icon_score.png", ""),
        extractAutoWX("自动提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""),
        extractAutoWXRefund("自动提现失败", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""),
        subsidy("额外补贴", "http://img.flqapp.com/resource/msg/icon_msg_subsidy.png", "");
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackBalance.java
New file
@@ -0,0 +1,61 @@
package com.yeshi.fanli.entity.redpack;
import java.math.BigDecimal;
import java.util.Date;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
/**
 * 红包余额
 *
 * @author Administrator
 *
 */
@Table("yeshi_red_pack_balance")
public class RedPackBalance {
    // 用户id
    @Column(name = "rpb_uid")
    private Long id;
    // 余额
    @Column(name = "rpb_money")
    private BigDecimal money;
    @Column(name = "rpb_create_time")
    private Date createTime;
    @Column(name = "rpb_update_time")
    private Date updateTime;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public BigDecimal getMoney() {
        return money;
    }
    public void setMoney(BigDecimal money) {
        this.money = money;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackConfig.java
New file
@@ -0,0 +1,104 @@
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_red_pack_config")
public class RedPackConfig {
    @Column(name = "rpc_id")
    private Long id;
    @Column(name = "rpc_name")
    private String name; // 名称
    @Column(name = "rpc_key")
    private String key; // 唯一值
    @Column(name = "rpc_value")
    private String value; // 值
    @Column(name = "rpc_remark")
    private String remark; // 备注
    @Column(name = "rpc_start_time")
    private Date startTime; // 开始使用时间
    @Column(name = "rpc_create_time")
    private Date createTime;
    @Column(name = "rpc_update_time")
    private Date updateTime;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getKey() {
        return key;
    }
    public void setKey(String key) {
        this.key = key;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackDetail.java
New file
@@ -0,0 +1,164 @@
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;
import com.google.gson.annotations.Expose;
/**
 * 红包明细
 *
 * @author Administrator
 *
 */
@Table("yeshi_red_pack_detail")
public class RedPackDetail {
    public enum RedPackDetailTypeEnum {
        invite("立得现金", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        newUserReward("新人奖励", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        increaseReward("递增奖励", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        seriesReward("连续奖励", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        refund("红包退回", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        videoRecharge("视频会员充值", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        musicRecharge("音乐会员充值", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        violation("红包涉嫌违规", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        giveOthers("红包赠送待领取中", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        giveOthersSucceed("红包赠送领取成功", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        giveOthersFail("红包赠送超时退回", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        redExchange("红包提现中", "http://img.flqapp.com/resource/money_detail/icon_score.png"),
        redExchangePass("红包提现成功", "http://img.flqapp.com/resource/money_detail/icon_score.png"),
        redExchangeReject("红包提现失败", "http://img.flqapp.com/resource/money_detail/icon_score.png");
        private final String desc;
        private final String picture;
        private RedPackDetailTypeEnum(String desc, String picture) {
            this.desc = desc;
            this.picture = picture;
        }
        public String getDesc() {
            return desc;
        }
        public String getPicture() {
            return picture;
        }
    }
    @Expose
    @Column(name = "rpd_id")
    private Long id;
    // 唯一标识
    @Column(name = "rpd_identify_code")
    private String identifyCode;
    @Expose
    @Column(name = "rpd_uid")
    private Long uid;
    @Expose
    @Column(name = "rpd_money")
    private BigDecimal money;
    @Expose
    @Column(name = "rpd_title")
    private String title;
    @Expose
    @Column(name = "rpd_type")
    private RedPackDetailTypeEnum type;
    @Expose
    @Column(name = "rpd_desc")
    private String desc;
    @Expose
    @Column(name = "rpd_remark")
    private String remark;
    @Expose
    @Column(name = "rpd_create_time")
    private Date createTime;
    // 是否显示
    @Column(name = "rpd_display")
    private Boolean display;
    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 String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public RedPackDetailTypeEnum getType() {
        return type;
    }
    public void setType(RedPackDetailTypeEnum type) {
        this.type = type;
    }
    public String getDesc() {
        return desc;
    }
    public void setDesc(String desc) {
        this.desc = desc;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getIdentifyCode() {
        return identifyCode;
    }
    public void setIdentifyCode(String identifyCode) {
        this.identifyCode = identifyCode;
    }
    public Boolean getDisplay() {
        return display;
    }
    public void setDisplay(Boolean display) {
        this.display = display;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackExchange.java
New file
@@ -0,0 +1,138 @@
package com.yeshi.fanli.entity.redpack;
import java.math.BigDecimal;
import java.util.Date;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
/**
 * 红包转换现金
 *
 * @author Administrator
 *
 */
@Table("yeshi_red_pack_exchange")
public class RedPackExchange {
    public static final int STATE_INIT = 0;
    public static final int STATE_SUCCESS = 1;
    public static final int STATE_REJECT = 2;
    @Column(name = "rpe_id")
    private Long id;
    // 用户id
    @Column(name = "rpe_uid")
    private Long uid;
    // 金额
    @Column(name = "rpe_money")
    private BigDecimal money;
    // 状态:0初始 1成功 2拒绝
    @Column(name = "rpe_state")
    private Integer state;
    // 审核人id
    @Column(name = "rpe_audit_id")
    private Long auditId;
    // 审核原因
    @Column(name = "rpe_reason")
    private String reason;
    // 审核时间
    @Column(name = "rpe_audit_time")
    private Date auditTime;
    // 申请时间
    @Column(name = "rpe_create_time")
    private Date createTime;
    private  String portrait;// 头像
    private  String nickName;// 昵称
    private  String auditName;// 审核人
    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 getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
    public Long getAuditId() {
        return auditId;
    }
    public void setAuditId(Long auditId) {
        this.auditId = auditId;
    }
    public String getReason() {
        return reason;
    }
    public void setReason(String reason) {
        this.reason = reason;
    }
    public Date getAuditTime() {
        return auditTime;
    }
    public void setAuditTime(Date auditTime) {
        this.auditTime = auditTime;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getPortrait() {
        return portrait;
    }
    public void setPortrait(String portrait) {
        this.portrait = portrait;
    }
    public String getNickName() {
        return nickName;
    }
    public void setNickName(String nickName) {
        this.nickName = nickName;
    }
    public String getAuditName() {
        return auditName;
    }
    public void setAuditName(String auditName) {
        this.auditName = auditName;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackGiveRecord.java
New file
@@ -0,0 +1,112 @@
package com.yeshi.fanli.entity.redpack;
import java.math.BigDecimal;
import java.util.Date;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
/**
 * 红包赠送记录
 *
 * @author Administrator
 *
 */
@Table("yeshi_red_pack_give_record")
public class RedPackGiveRecord {
    // 未领取
    public final static int STATE_INIT = 0;
    // 已领取
    public final static int STATE_RECEIVE = 1;
    // 已过期 退回
    public final static int STATE_OVERDUE = 2;
    @Column(name = "rpgr_id")
    private Long id;
    // 面额
    @Column(name = "rpgr_money")
    private BigDecimal amount;
    // 赠送uid
    @Column(name = "rpgr_give_uid")
    private Long giveUid;
    // 赠送时间
    @Column(name = "rpgr_give_time")
    private Date giveTime;
    // 赠送结束时间
    @Column(name = "rpgr_end_time")
    private Date endTime;
    // 领取uid
    @Column(name = "rpgr_receive_uid")
    private Long receiveUid;
    // 领取时间
    @Column(name = "rpgr_receive_time")
    private Date receiveTime;
    // 状态:0初始 1已领取 2已退回
    @Column(name = "rpgr_state")
    private Integer state;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public BigDecimal getAmount() {
        return amount;
    }
    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }
    public Long getGiveUid() {
        return giveUid;
    }
    public void setGiveUid(Long giveUid) {
        this.giveUid = giveUid;
    }
    public Date getGiveTime() {
        return giveTime;
    }
    public void setGiveTime(Date giveTime) {
        this.giveTime = giveTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public Long getReceiveUid() {
        return receiveUid;
    }
    public void setReceiveUid(Long receiveUid) {
        this.receiveUid = receiveUid;
    }
    public Date getReceiveTime() {
        return receiveTime;
    }
    public void setReceiveTime(Date receiveTime) {
        this.receiveTime = receiveTime;
    }
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
}
fanli/src/main/java/com/yeshi/fanli/exception/redpack/RedPackBalanceException.java
New file
@@ -0,0 +1,22 @@
package com.yeshi.fanli.exception.redpack;
import com.yeshi.fanli.exception.BaseException;
/**
 * 红包异常
 *
 * @author Administrator
 *
 */
public class RedPackBalanceException extends BaseException {
    private static final long serialVersionUID = 1L;
    public RedPackBalanceException(int code, String msg) {
        super(code, msg);
    }
    public RedPackBalanceException() {
        super();
    }
}
fanli/src/main/java/com/yeshi/fanli/exception/redpack/RedPackDetailException.java
New file
@@ -0,0 +1,22 @@
package com.yeshi.fanli.exception.redpack;
import com.yeshi.fanli.exception.BaseException;
/**
 * 红包明细异常
 *
 * @author Administrator
 *
 */
public class RedPackDetailException extends BaseException {
    private static final long serialVersionUID = 1L;
    public RedPackDetailException(int code, String msg) {
        super(code, msg);
    }
    public RedPackDetailException() {
        super();
    }
}
fanli/src/main/java/com/yeshi/fanli/exception/redpack/RedPackExchangeException.java
New file
@@ -0,0 +1,22 @@
package com.yeshi.fanli.exception.redpack;
import com.yeshi.fanli.exception.BaseException;
/**
 * 红包提现异常
 *
 * @author Administrator
 *
 */
public class RedPackExchangeException extends BaseException {
    private static final long serialVersionUID = 1L;
    public RedPackExchangeException(int code, String msg) {
        super(code, msg);
    }
    public RedPackExchangeException() {
        super();
    }
}
fanli/src/main/java/com/yeshi/fanli/exception/redpack/RedPackGiveRecordException.java
New file
@@ -0,0 +1,22 @@
package com.yeshi.fanli.exception.redpack;
import com.yeshi.fanli.exception.BaseException;
/**
 * 红包赠送异常
 *
 * @author Administrator
 *
 */
public class RedPackGiveRecordException extends BaseException {
    private static final long serialVersionUID = 1L;
    public RedPackGiveRecordException(int code, String msg) {
        super(code, msg);
    }
    public RedPackGiveRecordException() {
        super();
    }
}
fanli/src/main/java/com/yeshi/fanli/job/BrandInfoJob.java
@@ -1,10 +1,13 @@
package com.yeshi.fanli.job;
import java.util.Date;
import javax.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.yeshi.utils.DateUtil;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.brand.BrandInfoService;
import com.yeshi.fanli.util.Constant;
@@ -37,4 +40,19 @@
        }
    }
    /**
     * 清理前一天的
     */
//    @Scheduled(cron = "0 10 0 * * ? ")
    public void removeAgoByDate() {
        if (!Constant.IS_TASK)
            return;
        try {
            brandInfoService.removeAgoByDate(DateUtil.reduceDay(1, new Date()));
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/job/TaoLiJinJob.java
@@ -138,8 +138,8 @@
     */
    @Scheduled(cron = "0 1 5 * * ? ")
    public void autoAddTLJBuyGoods2() {
        if (!Constant.IS_TASK)
            return;
        // if (!Constant.IS_TASK)
        // return;
        LogHelper.test("自购立减开始选品");
        String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd");
        // 重试3次
fanli/src/main/java/com/yeshi/fanli/mapping/UserInfoMapper.xml
@@ -705,8 +705,10 @@
        SELECT u.* FROM `yeshi_ec_user_info_extra` t
        LEFT JOIN  `yeshi_ec_user` u ON u.`id` = t.`uie_uid`
        WHERE t.`uie_auto_extract` = 1 AND t.uie_active_time <![CDATA[>=]]> #{beganDate} AND  t.uie_active_time <![CDATA[<]]> #{endDate}
            AND (t.`uie_mark` IS NULL OR t.`uie_mark` = '')
            AND u.`state` = 0 AND u.`my_hongBao` <![CDATA[>=]]> #{money} 
            AND u.`wx_open_id` IS NOT NULL AND LENGTH(TRIM(u.`wx_open_id`)) <![CDATA[>]]> 0
            AND u.`wx_open_id` NOT LIKE 'o_b9%'
        LIMIT #{start},#{count}
    </select>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackBalanceMapper.xml
New file
@@ -0,0 +1,55 @@
<?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.RedPackBalanceMapper">
  <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_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_create_time,rpb_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_red_pack_balance where rpb_uid = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_balance where rpb_uid = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_balance (rpb_uid,rpb_money,rpb_create_time,rpb_update_time) values (#{id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_balance
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpb_uid,</if>
      <if test="money != null">rpb_money,</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="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_red_pack_balance set rpb_money = #{money,jdbcType=DECIMAL},rpb_create_time = #{createTime,jdbcType=TIMESTAMP},rpb_update_time = #{updateTime,jdbcType=TIMESTAMP} where rpb_uid = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackBalance">update yeshi_red_pack_balance
    <set>
      <if test="money != null">rpb_money=#{money,jdbcType=DECIMAL},</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 yeshi_red_pack_balance SET rpb_money = rpb_money - #{money,jdbcType=DECIMAL},rpb_update_time = NOW()
      WHERE rpb_uid = #{id,jdbcType=BIGINT}
  </update>
  <update id="addRedPack">
      UPDATE yeshi_red_pack_balance SET rpb_money = rpb_money + #{money,jdbcType=DECIMAL},rpb_update_time = NOW()
      WHERE rpb_uid = #{id,jdbcType=BIGINT}
  </update>
  <select id="selectForUpdate" resultMap="BaseResultMap" parameterType="java.lang.Long">
       SELECT <include refid="Base_Column_List"/> FROM yeshi_red_pack_balance
       WHERE rpb_uid = #{id,jdbcType=BIGINT} FOR UPDATE
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackConfigMapper.xml
New file
@@ -0,0 +1,61 @@
<?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.RedPackConfigMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackConfig">
    <id column="rpc_id" property="id" jdbcType="BIGINT"/>
    <result column="rpc_name" property="name" jdbcType="VARCHAR"/>
    <result column="rpc_key" property="key" jdbcType="VARCHAR"/>
    <result column="rpc_value" property="value" jdbcType="VARCHAR"/>
    <result column="rpc_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="rpc_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="rpc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="rpc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">rpc_id,rpc_name,rpc_key,rpc_value,rpc_remark,rpc_start_time,rpc_create_time,rpc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_red_pack_config where rpc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_config where rpc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_config (rpc_id,rpc_name,rpc_key,rpc_value,rpc_remark,rpc_start_time,rpc_create_time,rpc_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{key,jdbcType=VARCHAR},#{value,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{startTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_config
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpc_id,</if>
      <if test="name != null">rpc_name,</if>
      <if test="key != null">rpc_key,</if>
      <if test="value != null">rpc_value,</if>
      <if test="remark != null">rpc_remark,</if>
      <if test="startTime != null">rpc_start_time,</if>
      <if test="createTime != null">rpc_create_time,</if>
      <if test="updateTime != null">rpc_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="name != null">#{name,jdbcType=VARCHAR},</if>
      <if test="key != null">#{key,jdbcType=VARCHAR},</if>
      <if test="value != null">#{value,jdbcType=VARCHAR},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
      <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig">update yeshi_red_pack_config set rpc_name = #{name,jdbcType=VARCHAR},rpc_key = #{key,jdbcType=VARCHAR},rpc_value = #{value,jdbcType=VARCHAR},rpc_remark = #{remark,jdbcType=VARCHAR},rpc_start_time = #{startTime,jdbcType=TIMESTAMP},rpc_create_time = #{createTime,jdbcType=TIMESTAMP},rpc_update_time = #{updateTime,jdbcType=TIMESTAMP} where rpc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig">update yeshi_red_pack_config
    <set>
      <if test="name != null">rpc_name=#{name,jdbcType=VARCHAR},</if>
      <if test="key != null">rpc_key=#{key,jdbcType=VARCHAR},</if>
      <if test="value != null">rpc_value=#{value,jdbcType=VARCHAR},</if>
      <if test="remark != null">rpc_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="startTime != null">rpc_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">rpc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">rpc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where rpc_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="getByKey" resultMap="BaseResultMap">
      SELECT * FROM yeshi_red_pack_config t
      WHERE t.`rpc_key` = #{key} and #{startTime} >= rpc_start_time
      ORDER BY rpc_start_time DESC LIMIT 1
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackDetailMapper.xml
New file
@@ -0,0 +1,160 @@
<?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.RedPackDetailMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackDetail">
    <id column="rpd_id" property="id" jdbcType="BIGINT"/>
    <result column="rpd_identify_code" property="identifyCode" jdbcType="VARCHAR"/>
    <result column="rpd_uid" property="uid" jdbcType="BIGINT"/>
    <result column="rpd_money" property="money" jdbcType="DECIMAL"/>
    <result column="rpd_title" property="title" jdbcType="VARCHAR"/>
    <result column="rpd_desc" property="desc" jdbcType="VARCHAR"/>
    <result column="rpd_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="rpd_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="rpd_display" property="display" jdbcType="VARCHAR"/>
    <result column="rpd_type" property="type" typeHandler="com.yeshi.fanli.util.mybatishandler.redpack.RedPackDetailTypeEnumHandler"/>
  </resultMap>
  <resultMap id="UserMonthMoneyMap" type="com.yeshi.fanli.vo.redpack.RedPackMonthVO">
        <result column="expend" property="expend" jdbcType="DECIMAL" />
        <result column="income" property="income" jdbcType="DECIMAL" />
        <result column="dateFormate" property="dateFormate" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List">rpd_id,rpd_identify_code,rpd_uid,rpd_money,rpd_title,rpd_type,rpd_desc,rpd_remark,rpd_create_time,rpd_display</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_red_pack_detail where rpd_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_detail where rpd_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_detail (rpd_id,rpd_identify_code,rpd_uid,rpd_money,rpd_title,rpd_type,rpd_desc,rpd_remark,rpd_create_time,rpd_display) values (#{id,jdbcType=BIGINT},,#{identifyCode,jdbcType=VARCHAR}#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{title,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{desc,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{display,jdbcType=VARCHAR})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_detail
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpd_id,</if>
      <if test="identifyCode != null">rpd_identify_code,</if>
      <if test="uid != null">rpd_uid,</if>
      <if test="money != null">rpd_money,</if>
      <if test="title != null">rpd_title,</if>
      <if test="type != null">rpd_type,</if>
      <if test="desc != null">rpd_desc,</if>
      <if test="remark != null">rpd_remark,</if>
      <if test="createTime != null">rpd_create_time,</if>
      <if test="display != null">rpd_display,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="identifyCode != null">#{identifyCode,jdbcType=VARCHAR},</if>
      <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
      <if test="money != null">#{money,jdbcType=DECIMAL},</if>
      <if test="title != null">#{title,jdbcType=VARCHAR},</if>
      <if test="type != null">#{type,jdbcType=VARCHAR},</if>
      <if test="desc != null">#{desc,jdbcType=VARCHAR},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="display != null">#{display,jdbcType=VARCHAR},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail">update yeshi_red_pack_detail set rpd_identify_code = #{identifyCode,jdbcType=VARCHAR},rpd_uid = #{uid,jdbcType=BIGINT},rpd_money = #{money,jdbcType=DECIMAL},rpd_title = #{title,jdbcType=VARCHAR},rpd_type = #{type,jdbcType=VARCHAR},rpd_desc = #{desc,jdbcType=VARCHAR},rpd_remark = #{remark,jdbcType=VARCHAR},rpd_create_time = #{createTime,jdbcType=TIMESTAMP} where rpd_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackDetail">update yeshi_red_pack_detail
    <set>
      <if test="identifyCode != null">rpd_identify_code=#{identifyCode,jdbcType=VARCHAR},</if>
      <if test="uid != null">rpd_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="money != null">rpd_money=#{money,jdbcType=DECIMAL},</if>
      <if test="title != null">rpd_title=#{title,jdbcType=VARCHAR},</if>
      <if test="type != null">rpd_type=#{type,jdbcType=VARCHAR},</if>
      <if test="desc != null">rpd_desc=#{desc,jdbcType=VARCHAR},</if>
      <if test="remark != null">rpd_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="createTime != null">rpd_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="display != null">rpd_display=#{display,jdbcType=VARCHAR},</if>
    </set> where rpd_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="countUseMoneyByDate" resultType="java.math.BigDecimal">
      SELECT IFNULL(SUM(t.`rpd_money`),0) FROM `yeshi_red_pack_detail` t
    WHERE t.`rpd_money` <![CDATA[<]]> 0 AND t.`rpd_uid` = #{uid} AND t.`rpd_type` <![CDATA[<>]]> 'violation'
        <if test="dateType == 1"> <!-- 今日  -->
            AND TO_DAYS(t.`rpd_create_time`) =  TO_DAYS(NOW());
        </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="countAddMoneyByDate" resultType="java.math.BigDecimal">
      SELECT IFNULL(SUM(t.`rpd_money`),0) FROM `yeshi_red_pack_detail` t
    WHERE t.`rpd_money` <![CDATA[>]]> 0  AND t.`rpd_uid` = #{uid} AND  t.`rpd_type`<![CDATA[<>]]>'refund'
        <if test="dateType == 1"> <!-- 今日  -->
            AND TO_DAYS(t.`rpd_create_time`) =  TO_DAYS(NOW());
        </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="selectByMaxCreateTime" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List" /> FROM yeshi_red_pack_detail t
    WHERE t.`rpd_uid`=#{uid} AND t.`rpd_create_time`<![CDATA[<=]]> #{date}
    ORDER BY t.`rpd_create_time` DESC,t.rpd_id DESC
    LIMIT #{count}
  </select>
  <select id="selectByUidWithIndexId" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List" />    FROM yeshi_red_pack_detail t
    WHERE t.`rpd_uid`=#{uid}
        AND t.`rpd_create_time`<![CDATA[<=]]>(SELECT rpd_create_time FROM yeshi_red_pack_detail WHERE rpd_id =#{id})
    ORDER BY t.`rpd_create_time` DESC,t.rpd_id DESC
    LIMIT #{count}
  </select>
  <select id="selectMonthMoneyByUid" resultMap="UserMonthMoneyMap">
        <foreach collection="dateFormat" index="index" item="item"
            separator="UNION ALL">
            <trim prefix="(" suffix=")">
                SELECT c.time AS dateFormate , IF(a.money IS NULL,0,a.money) AS income ,IF(b.money IS NULL,0,b.money) AS expend
                FROM (SELECT  #{item} AS `time`) c
                LEFT JOIN (SELECT DATE_FORMAT(d.`rpd_create_time`,'%Y-%m') AS `time`,SUM(d.`rpd_money`)AS money
                               FROM `yeshi_red_pack_detail` d
                               WHERE d.`rpd_uid`=#{uid} AND  d.`rpd_money`<![CDATA[>=]]>0 AND DATE_FORMAT(d.`rpd_create_time`,'%Y-%m')=#{item}
                               GROUP BY DATE_FORMAT(d.`rpd_create_time`,'%Y-%m')
                               ) a ON a.time=c.time
                LEFT JOIN(SELECT DATE_FORMAT(d.`rpd_create_time`,'%Y-%m') AS `time`,SUM(d.`rpd_money`) AS money
                              FROM `yeshi_red_pack_detail` d
                            WHERE d.`rpd_uid`=#{uid} AND d.`rpd_money` <![CDATA[<]]>0 AND DATE_FORMAT(d.`rpd_create_time`,'%Y-%m')=#{item}
                              GROUP BY DATE_FORMAT(d.`rpd_create_time`,'%Y-%m')
                              ) b ON c.time=b.time
           </trim>
       </foreach>
  </select>
  <select id="selectCountByUid" resultType="java.lang.Long"  parameterType="java.lang.Long">
    SELECT count(rpd_id) FROM yeshi_red_pack_detail
    WHERE rpd_uid=#{uid}
  </select>
  <select id="selectMonthCountByUid" resultType="java.lang.Integer">
    SELECT COUNT(*) FROM
            (SELECT * FROM yeshi_red_pack_detail d
             WHERE d.`rpd_uid`=#{uid} AND d.`rpd_create_time` <![CDATA[<=]]> #{date}
             GROUP BY DATE_FORMAT(d.`rpd_create_time`,'%y-%m')
             ) a
  </select>
  <select id="selectCountByUidAndMaxCreateTime" resultType="java.lang.Long">
    SELECT count(rpd_id) FROM yeshi_red_pack_detail
    WHERE rpd_uid=#{uid} and `rpd_create_time`<![CDATA[<=]]>#{date}
 </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackExchangeMapper.xml
New file
@@ -0,0 +1,99 @@
<?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.RedPackExchangeMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackExchange">
    <id column="rpe_id" property="id" jdbcType="BIGINT"/>
    <result column="rpe_uid" property="uid" jdbcType="BIGINT"/>
    <result column="rpe_money" property="money" jdbcType="DECIMAL"/>
    <result column="rpe_state" property="state" jdbcType="INTEGER"/>
    <result column="rpe_audit_id" property="auditId" jdbcType="BIGINT"/>
    <result column="rpe_reason" property="reason" jdbcType="VARCHAR"/>
    <result column="rpe_audit_time" property="auditTime" jdbcType="TIMESTAMP"/>
    <result column="rpe_create_time" property="createTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">rpe_id,rpe_uid,rpe_money,rpe_state,rpe_audit_id,rpe_reason,rpe_audit_time,rpe_create_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_red_pack_exchange where rpe_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_exchange where rpe_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_exchange (rpe_id,rpe_uid,rpe_money,rpe_state,rpe_audit_id,rpe_reason,rpe_audit_time,rpe_create_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{state,jdbcType=INTEGER},#{auditId,jdbcType=BIGINT},#{reason,jdbcType=VARCHAR},#{auditTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_exchange
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpe_id,</if>
      <if test="uid != null">rpe_uid,</if>
      <if test="money != null">rpe_money,</if>
      <if test="state != null">rpe_state,</if>
      <if test="auditId != null">rpe_audit_id,</if>
      <if test="reason != null">rpe_reason,</if>
      <if test="auditTime != null">rpe_audit_time,</if>
      <if test="createTime != null">rpe_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="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="auditId != null">#{auditId,jdbcType=BIGINT},</if>
      <if test="reason != null">#{reason,jdbcType=VARCHAR},</if>
      <if test="auditTime != null">#{auditTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange">update yeshi_red_pack_exchange set rpe_uid = #{uid,jdbcType=BIGINT},rpe_money = #{money,jdbcType=DECIMAL},rpe_state = #{state,jdbcType=INTEGER},rpe_audit_id = #{auditId,jdbcType=BIGINT},rpe_reason = #{reason,jdbcType=VARCHAR},rpe_audit_time = #{auditTime,jdbcType=TIMESTAMP},rpe_create_time = #{createTime,jdbcType=TIMESTAMP} where rpe_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackExchange">update yeshi_red_pack_exchange
    <set>
      <if test="uid != null">rpe_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="money != null">rpe_money=#{money,jdbcType=DECIMAL},</if>
      <if test="state != null">rpe_state=#{state,jdbcType=INTEGER},</if>
      <if test="auditId != null">rpe_audit_id=#{auditId,jdbcType=BIGINT},</if>
      <if test="reason != null">rpe_reason=#{reason,jdbcType=VARCHAR},</if>
      <if test="auditTime != null">rpe_audit_time=#{auditTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">rpe_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
    </set> where rpe_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="query" resultMap="BaseResultMap">
      SELECT * FROM yeshi_red_pack_exchange d
    WHERE 1=1
        <if test="key != null and key != ''">
            AND d.rpe_uid = #{key}
        </if>
         <if test="state != null ">
            AND d.rpe_state = #{state}
        </if>
    ORDER BY d.`rpe_state`,d.`rpe_create_time`
    LIMIT #{start},#{count}
  </select>
  <select id="count" resultType="Long">
      SELECT IFNULL(COUNT(rpe_id),0) FROM yeshi_red_pack_exchange d
    WHERE 1=1
        <if test="key != null and key != ''">
            AND d.rpe_uid = #{key}
        </if>
         <if test="state != null ">
            AND d.rpe_state = #{state}
        </if>
  </select>
  <select id="countState" resultType="Long">
      SELECT IFNULL(COUNT(d.rpe_id),0) FROM yeshi_red_pack_exchange d
    WHERE d.rpe_uid = #{uid}
    GROUP BY d.`rpe_state`
    ORDER BY d.`rpe_state`
  </select>
  <select id="countMoneyState" resultType="BigDecimal">
      SELECT IFNULL(SUM(d.rpe_money),0) FROM yeshi_red_pack_exchange d
    WHERE d.rpe_uid = #{uid}
    GROUP BY d.`rpe_state`
    ORDER BY d.`rpe_state`
  </select>
  <select id="countMoneyByState" resultType="BigDecimal">
      SELECT IFNULL(SUM(d.rpe_money),0) FROM yeshi_red_pack_exchange d
    WHERE d.rpe_uid = #{uid} AND d.`rpe_state` = #{state}
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackGiveRecordMapper.xml
New file
@@ -0,0 +1,55 @@
<?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.RedPackGiveRecordMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackGiveRecord">
    <id column="rpgr_id" property="id" jdbcType="BIGINT"/>
    <result column="rpgr_money" property="amount" jdbcType="DECIMAL"/>
    <result column="rpgr_give_uid" property="giveUid" jdbcType="BIGINT"/>
    <result column="rpgr_give_time" property="giveTime" jdbcType="TIMESTAMP"/>
    <result column="rpgr_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="rpgr_receive_uid" property="receiveUid" jdbcType="BIGINT"/>
    <result column="rpgr_receive_time" property="receiveTime" jdbcType="TIMESTAMP"/>
    <result column="rpgr_state" property="state" jdbcType="INTEGER"/>
  </resultMap>
  <sql id="Base_Column_List">rpgr_id,rpgr_money,rpgr_give_uid,rpgr_give_time,rpgr_end_time,rpgr_receive_uid,rpgr_receive_time,rpgr_state</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_red_pack_give_record where rpgr_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_red_pack_give_record where rpgr_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_give_record (rpgr_id,rpgr_money,rpgr_give_uid,rpgr_give_time,rpgr_end_time,rpgr_receive_uid,rpgr_receive_time,rpgr_state) values (#{id,jdbcType=BIGINT},#{amount,jdbcType=DECIMAL},#{giveUid,jdbcType=BIGINT},#{giveTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{receiveUid,jdbcType=BIGINT},#{receiveTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_red_pack_give_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpgr_id,</if>
      <if test="amount != null">rpgr_money,</if>
      <if test="giveUid != null">rpgr_give_uid,</if>
      <if test="giveTime != null">rpgr_give_time,</if>
      <if test="endTime != null">rpgr_end_time,</if>
      <if test="receiveUid != null">rpgr_receive_uid,</if>
      <if test="receiveTime != null">rpgr_receive_time,</if>
      <if test="state != null">rpgr_state,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="amount != null">#{amount,jdbcType=DECIMAL},</if>
      <if test="giveUid != null">#{giveUid,jdbcType=BIGINT},</if>
      <if test="giveTime != null">#{giveTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="receiveUid != null">#{receiveUid,jdbcType=BIGINT},</if>
      <if test="receiveTime != null">#{receiveTime,jdbcType=TIMESTAMP},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord">update yeshi_red_pack_give_record set rpgr_money = #{amount,jdbcType=DECIMAL},rpgr_give_uid = #{giveUid,jdbcType=BIGINT},rpgr_give_time = #{giveTime,jdbcType=TIMESTAMP},rpgr_end_time = #{endTime,jdbcType=TIMESTAMP},rpgr_receive_uid = #{receiveUid,jdbcType=BIGINT},rpgr_receive_time = #{receiveTime,jdbcType=TIMESTAMP},rpgr_state = #{state,jdbcType=INTEGER} where rpgr_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackGiveRecord">update yeshi_red_pack_give_record
    <set>
      <if test="amount != null">rpgr_money=#{amount,jdbcType=DECIMAL},</if>
      <if test="giveUid != null">rpgr_give_uid=#{giveUid,jdbcType=BIGINT},</if>
      <if test="giveTime != null">rpgr_give_time=#{giveTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">rpgr_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="receiveUid != null">rpgr_receive_uid=#{receiveUid,jdbcType=BIGINT},</if>
      <if test="receiveTime != null">rpgr_receive_time=#{receiveTime,jdbcType=TIMESTAMP},</if>
      <if test="state != null">rpgr_state=#{state,jdbcType=INTEGER},</if>
    </set> where rpgr_id = #{id,jdbcType=BIGINT}
  </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponActivateMapper.xml
New file
@@ -0,0 +1,50 @@
<?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.user.UserSystemCouponActivateMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.UserSystemCouponActivate">
    <id column="usca_id" property="id" jdbcType="BIGINT"/>
    <result column="usca_count" property="count" jdbcType="INTEGER"/>
    <result column="usca_state" property="state" jdbcType="INTEGER"/>
    <result column="usca_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="usca_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">usca_id,usca_count,usca_state,usca_create_time,usca_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_user_system_coupon_activate where usca_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_user_system_coupon_activate where usca_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCouponActivate" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_system_coupon_activate (usca_id,usca_count,usca_state,usca_create_time,usca_update_time) values (#{id,jdbcType=BIGINT},#{count,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCouponActivate" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_system_coupon_activate
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">usca_id,</if>
      <if test="count != null">usca_count,</if>
      <if test="state != null">usca_state,</if>
      <if test="createTime != null">usca_create_time,</if>
      <if test="updateTime != null">usca_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="count != null">#{count,jdbcType=INTEGER},</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.bus.user.UserSystemCouponActivate">update yeshi_ec_user_system_coupon_activate set usca_count = #{count,jdbcType=INTEGER},usca_state = #{state,jdbcType=INTEGER},usca_create_time = #{createTime,jdbcType=TIMESTAMP},usca_update_time = #{updateTime,jdbcType=TIMESTAMP} where usca_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCouponActivate">update yeshi_ec_user_system_coupon_activate
    <set>
      <if test="count != null">usca_count=#{count,jdbcType=INTEGER},</if>
      <if test="state != null">usca_state=#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">usca_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">usca_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where usca_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="addCount">
      UPDATE yeshi_ec_user_system_coupon_activate
      SET usca_count = usca_count + #{count},usca_update_time = NOW()
      WHERE usca_id = #{id}
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponMapper.xml
@@ -221,4 +221,12 @@
    LEFT JOIN `yeshi_ec_system_coupon` c ON t.`usc_coupon_id` = c.`sc_id`
    WHERE t.usc_uid = #{uid} AND c.`sc_type`= #{type} 
  </select>
  <select id="getNeedActivateFreeCouponByType" resultMap="BaseResultMap">
     SELECT * FROM `yeshi_ec_user_system_coupon` t
    LEFT JOIN `yeshi_ec_system_coupon` c ON t.`usc_coupon_id` = c.`sc_id`
    WHERE t.usc_uid = #{uid} AND c.`sc_type`= #{type}  AND (t.usc_state_activate = 0 OR t.usc_state_activate is null)
    ORDER BY usc_id
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java
@@ -81,6 +81,10 @@
        filter.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
        TaoBaoSearchResult searchResult = TaoKeApiUtil.searchWuLiao(filter);
        
        // 删除店铺
        brandShopCaheService.removeByDateAndType(brandInfo.getId(), 11, date);
        // 组织商品 + 添加店铺
        int count = 0;
        if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null 
                && searchResult.getTaoBaoGoodsBriefs().size() > 0) {
@@ -110,6 +114,7 @@
                }
            }
        }
        // 删除之前的
        brandGoodsCaheDao.removeByDate(brandInfo.getId(), 1 , date);
         
@@ -132,6 +137,10 @@
        JDSearchResult result = null;
        String way = configService.get("jd_api_search_key");
        Date date = new Date();
        // 删除店铺
        brandShopCaheService.removeByDateAndType(brandInfo.getId(), 20, date);
        for (int i=0; i < 2;i ++) {
            if ("1".equals(way)) {
                JDFilter filterAPI = new JDFilter();
@@ -152,9 +161,9 @@
                result = JDUtil.searchByKey(jdfilter);
            }
            
            if (result != null) {
            if (result != null && result.getGoodsList() != null && result.getGoodsList().size() > 0) {
                boolean addShop = true;
                List<JDGoods> goodsList = result.getGoodsList();
                if (goodsList != null && goodsList.size() > 0) {
                    for (JDGoods goods : goodsList) {
                        BrandGoodsCahe brandGoods = new BrandGoodsCahe();
                        brandGoods.setBrandId(brandInfo.getId());
@@ -164,17 +173,19 @@
                        brandGoods.setCreateTime(date);
                        brandGoodsCaheDao.insert(brandGoods);
                        
                        if (count == 0) {
                            JDShopInfo shopInfo = goods.getShopInfo();
                            if(shopInfo != null) {
                    if (addShop && shopInfo != null) {
                        // 包含该品牌名称
                        String shopName = shopInfo.getShopName();
                        if (!StringUtil.isNullOrEmpty(shopName) && shopName.contains(brandInfo.getName())) {
                                brandShopCaheService.addBrandShopJD(brandInfo, shopInfo);
                            addShop = false;
                            }
                        }
                        
                        count ++;
                        if (count >= 50) {
                            break;
                        }
                    }
                }
            }
@@ -202,9 +213,11 @@
        pddfilter.setPage(1);
        pddfilter.setPageSize(100);
        pddfilter.setSortType(6);
        Date date = new Date();
        int count = 0;
        PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
        int count = 0;
        Date date = new Date();
        if (result != null) {
            List<PDDGoodsDetail> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
@@ -223,14 +236,14 @@
                }
            }
        }
        // 删除之前
        brandGoodsCaheDao.removeByDate(brandInfo.getId(), 3, date);
        // 删除之前店铺
        brandShopCaheService.removeByDateAndType(brandInfo.getId(), 30, date);
        // 添加店铺
        brandShopCaheService.addBrandShopPDD(brandInfo);
        
        // 删除之前
        brandGoodsCaheDao.removeByDate(brandInfo.getId(), 3, date);
        return count;
    }
    
    
@@ -243,4 +256,14 @@
    public long countByBrandId(Long brandId){
        return brandGoodsCaheDao.countByBrandId(brandId);
    }
    @Override
    public void removeAgoByDate(Date createTime) {
        brandGoodsCaheDao.removeAgoByDate(createTime);
    }
    @Override
    public void removeByBrandId(Long brandId) {
        brandGoodsCaheDao.removeByBrandId(brandId);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java
@@ -122,6 +122,17 @@
            record.setCreateTime(resultObj.getCreateTime());
            record.setUpdateTime(new Date());
            brandInfoMapper.updateByPrimaryKey(record);
            if (state == 0){
                executor.execute(new Runnable() {
                    @Override
                    public void run() {
                        brandGoodsCaheService.removeByBrandId(id);
                        brandShopCaheService.removeByBrandId(id);
                    }
                });
            }
        }
        if (state == 1) {
@@ -160,6 +171,16 @@
    
    @Override
    public int deleteBatchByPrimaryKey(List<Long> list) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                for (Long id: list) {
                    brandGoodsCaheService.removeByBrandId(id);
                    brandShopCaheService.removeByBrandId(id);
                }
            }
        });
        return brandInfoMapper.deleteBatchByPrimaryKey(list);
    }
@@ -225,6 +246,18 @@
        return brandClassShopService.countBrandShopinfo(cid);
    }
    @Override
    public void removeAgoByDate(Date date) {
        // 删除商品
        brandGoodsCaheService.removeAgoByDate(date);
        // 删除店铺
        brandShopCaheService.removeAgoByDate(date);
    }
    @Override
    public void addShopAndGoods(long start, int count) {
        List<BrandInfo> list = brandInfoMapper.listValidAll(start, count);
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandShopCaheServiceImpl.java
@@ -43,16 +43,11 @@
        if (taoBaoShop == null)
            return true;
        
        Date date = new Date();
        BrandShopCahe brandShop = new BrandShopCahe();
        brandShop.setBrandId(brandId);
        brandShop.setShop(ShopInfoVOFactory.convertTaoBaoShop(taoBaoShop));
        brandShop.setCreateTime(date);
        brandShop.setCreateTime(new Date());
        brandShopCaheDao.insert(brandShop);
        // 删除店铺
        brandShopCaheDao.removeByDate(brandId, 11, date);
        return false;
    }
    
@@ -65,16 +60,13 @@
     */
    @Override
    public void addBrandShopJD(BrandInfo brandInfo, JDShopInfo shopInfo) {
        Date date = new Date();
        ShopInfoVO shopInfoVO = ShopInfoVOFactory.convertJDShop(shopInfo);
        shopInfoVO.setShopIcon(brandInfo.getIcon());
        BrandShopCahe brandShop = new BrandShopCahe();
        brandShop.setBrandId(brandInfo.getId());
        brandShop.setShop(shopInfoVO);
        brandShop.setCreateTime(date);
        brandShop.setCreateTime(new Date());
        brandShopCaheDao.save(brandShop);
        brandShopCaheDao.removeByDate(brandInfo.getId(), 20, date);
    }
    
    
@@ -96,36 +88,34 @@
        pddfilter.setPageSize(100);
        pddfilter.setSortType(6);
        pddfilter.setMerchantType(3);
        PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
        if (result != null) {
        if (result != null && result.getGoodsList() != null && result.getGoodsList().size() > 0) {
            boolean addShop = true;
            List<PDDGoodsDetail> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
                for (PDDGoodsDetail goods : goodsList) {
                // 包含店铺id 、包含品牌名称
                    String mallName = goods.getMallName();
                    if(goods.getMallId() != null && !StringUtil.isNullOrEmpty(mallName) && mallName.contains(brandInfo.getName())){
                if(addShop && !StringUtil.isNullOrEmpty(mallName) && mallName.contains(brandInfo.getName())
                        && goods.getMallId() != null){
                        shopInfoVO = new ShopInfoVO();
                        shopInfoVO.setId(goods.getMallId().toString());
                        shopInfoVO.setShopName(mallName);
                    addShop = false;
                        break;
                    }
                }
            }
        }
        
        if (shopInfoVO != null) {
            shopInfoVO.setShopIcon(brandInfo.getIcon());
            shopInfoVO.setUserType(30);
            shopInfoVO.setShopLink("https://mobile.yangkeduo.com/mall_page.html?mall_id=" + shopInfoVO.getId());
            Date date = new Date();
            BrandShopCahe brandShop = new BrandShopCahe();
            brandShop.setBrandId(brandInfo.getId());
            brandShop.setShop(shopInfoVO);
            brandShop.setCreateTime(date);
            brandShop.setCreateTime(new Date());
            brandShopCaheDao.insert(brandShop);
            brandShopCaheDao.removeByDate(brandInfo.getId(), 30, date);
        }
    }
    
@@ -135,4 +125,22 @@
    public List<BrandShopCahe> getByBrandId(Long brandId){
        return brandShopCaheDao.getByBrandId(brandId);
    }
    @Override
    public void removeAgoByDate(Date createTime) {
        brandShopCaheDao.removeAgoByDate(createTime);
    }
    @Override
    public void removeByBrandId(Long brandId) {
        brandShopCaheDao.removeByBrandId(brandId);
    }
    @Override
    public void removeByDateAndType(Long brandId, int type, Date date) {
        brandShopCaheDao.removeByDate(brandId, type, date);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/money/extract/ExtractServiceImpl.java
@@ -1164,15 +1164,14 @@
        String billno = redPackRecord.getBillno();
        if (!StringUtil.isNullOrEmpty(billno)) {
            updeteRecord.setBillno(billno.replace("`", ""));
            updeteRecord.setBillno(billno.replace("`", "").replace("'", ""));
        }
        String detailno = redPackRecord.getDetailno();
        if (!StringUtil.isNullOrEmpty(detailno)) {
            updeteRecord.setDetailno(detailno.replace("`", ""));
            updeteRecord.setDetailno(detailno.replace("`", "").replace("'", ""));
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        String rcvTime = redPackRecord.getRcvTime();
        if (!StringUtil.isNullOrEmpty(rcvTime)) {
            try {
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -1,7 +1,6 @@
package com.yeshi.fanli.service.impl.order;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -201,413 +200,6 @@
        return listOrder;
    }
    @Override
    public Map<String, BigDecimal> countHistoryOrder(Long uid, Integer day, Integer source) {
        return commonOrderMapper.countHistoryOrder(uid, day, source);
    }
    @Override
    public long countBonusOrderNumber(Long uid, Integer type, Integer day, String startTime, String endTime,
            Integer source) {
        return commonOrderMapper.countBonusOrderNumber(uid, type, day, startTime, endTime, source);
    }
    @Override
    public BigDecimal countBonusOrderMoney(Long uid, Integer type, Integer day, String startTime, String endTime,
            Integer source) {
        return commonOrderMapper.countBonusOrderMoney(uid, type, day, startTime, endTime, source);
    }
    @Override
    public Map<String, Object> countBonusOrderMoneyAndNumber(Long uid, Integer type, Integer day, String startTime,
            String endTime, Integer source) {
        return commonOrderMapper.countBonusOrderMoneyAndNumber(uid, type, day, startTime, endTime, source);
    }
    @Override
    public Long countUserOrderToApp(Long uid, Integer type, String startTime, String endTime,
            Integer day, Integer source, Integer state, Integer stateOrder) {
        return commonOrderMapper.countUserOrderToApp(uid, type, startTime, endTime, day, source, state, stateOrder);
    }
    private BigDecimal getWeiQuanMoney(List<TaoBaoWeiQuanOrder> listWQ, int sourceType, Long uid) {
        BigDecimal weiQuanMoney = new BigDecimal(0);
        if (listWQ != null && listWQ.size() > 0) {
            for (TaoBaoWeiQuanOrder weiQuanOrder : listWQ) {
                String tradeId = weiQuanOrder.getOrderItemId();
                // 查询红包
                List<String> tradeList = new ArrayList<>();
                tradeList.add(tradeId);
                List<HongBaoV2> hongBaoList = hongBaoV2Service.listBySourceTypeAndTradeIdListAndUid(sourceType, uid,
                        tradeList);
                if (hongBaoList != null && hongBaoList.size() > 0) {
                    CommonOrder commonOrder = commonOrderMapper.selectBySourceTypeAndTradeId(sourceType, tradeId);
                    if (commonOrder != null && commonOrder.getSettlement().compareTo(new BigDecimal(0)) > 0) {
                        BigDecimal wqMoney = MoneyBigDecimalUtil
                                .mul(hongBaoList.get(0).getMoney(), weiQuanOrder.getMoney())
                                .divide(commonOrder.getSettlement(), 2, BigDecimal.ROUND_UP);
                        if (wqMoney.compareTo(hongBaoList.get(0).getMoney()) > 0)
                            wqMoney = hongBaoList.get(0).getMoney();
                        weiQuanMoney = weiQuanMoney.add(wqMoney);
                    }
                }
            }
        }
        return weiQuanMoney;
    }
    public void listDataFactory(AcceptData acceptData, List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods,
            Long uid) {
        List<String> listTB = new ArrayList<String>();
        List<String> listJD = new ArrayList<String>();
        List<String> listPDD = new ArrayList<String>();
        for (CommonOrderVO commonOrderVO : listOrder) {
            Integer sourceType = commonOrderVO.getSourceType();
            if (sourceType == null) {
                continue;
            } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
                listTB.add(commonOrderVO.getOrderNo());
            } else if (sourceType == Constant.SOURCE_TYPE_JD) {
                listJD.add(commonOrderVO.getOrderNo());
            } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
                listPDD.add(commonOrderVO.getOrderNo());
            }
        }
        List<UserSystemCouponRecord> listRecordTB = null;
        if (listTB.size() > 0) {
            listRecordTB = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_TAOBAO, listTB);
        }
        List<UserSystemCouponRecord> listRecordJD = null;
        if (listJD.size() > 0) {
            listRecordJD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_JD, listJD);
        }
        List<UserSystemCouponRecord> listRecordPDD = null;
        if (listPDD.size() > 0) {
            listRecordPDD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_PDD, listPDD);
        }
        /* 组合商品信息 */
        for (CommonOrderVO commonOrder : listGoods) {
            CommonOrderGoods goods = commonOrder.getCommonOrderGoods();
            if (goods == null) {
                continue;
            }
            String orderNo1 = commonOrder.getOrderNo();
            Integer sourceType = commonOrder.getSourceType();
            for (CommonOrderVO order : listOrder) {
                String orderNo2 = order.getOrderNo();
                Integer sourceType2 = order.getSourceType();
                // 来源、订单号相同
                if (sourceType.equals(sourceType2) && orderNo1.equals(orderNo2)) {
                    // 加入商品信息
                    List<CommonOrderGoodsVO> listOrderGoods = order.getListOrderGoods();
                    CommonOrderGoodsVO commonGoodsVO = new CommonOrderGoodsVO();
                    try {
                        PropertyUtils.copyProperties(commonGoodsVO, goods);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    commonGoodsVO.setGoodsType(sourceType2);
                    String picture = commonGoodsVO.getPicture();
                    if (!StringUtil.isNullOrEmpty(picture) && !picture.contains("320x320")) {
                        commonGoodsVO.setPicture(TbImgUtil.getTBSize320Img(picture));
                    }
                    Integer hongBaoType = order.getHongBaoType();
                    // 邀请订单信息保护
                    if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
                            || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
                            || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
                        Map<String, String> titleMap = new HashMap<String, String>();
                        titleMap.put("content", "为保障用户隐私,商品信息已隐藏!");
                        titleMap.put("fontColor", "#888888");
                        titleMap.put("bottomColor", "#E9E9E9");
                        commonGoodsVO.setTitle(null);
                        commonGoodsVO.setGoodsTitle(titleMap);
                    }
                    // 购买数量
                    commonGoodsVO.setActualCount(commonOrder.getTotalCount() + "件");
                    BigDecimal totalSettlement = commonOrder.getTotalSettlement();
                    if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) {
                        totalSettlement = commonOrder.getTotalPayment();
                    }
                    // 实付款
                    commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement);
                    Integer orderType = order.getOrderType();
                    if (orderType == null) {
                        String shopType = commonGoodsVO.getShopType();
                        if (CommonOrderGoodsVO.TYPE_TAOBAO.equalsIgnoreCase(shopType)) {
                            order.setOrderType(1);
                        } else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) {
                            order.setOrderType(2);
                        }
                    }
                    listOrderGoods.add(commonGoodsVO);
                    break;
                }
            }
        }
        SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
        SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd");
        // 是否存在奖励券
        // boolean hasRewardCoupon =
        // userSystemCouponService.hasRewardCoupon(uid);
        boolean hasRewardCoupon = userSystemCouponService.getIncludeNotExchange(uid);
        boolean exchangeCoupon = userSystemCouponService.getIncludeExchange(uid);
        // 2019.8.1开始返回维权信息
        Date august = null;
        try {
            august = TimeUtil.parse("2019-08-01");
        } catch (ParseException e) {
            e.printStackTrace();
        }
        /* 组织订单状态 等信息 */
        for (CommonOrderVO order : listOrder) {
            Date thirdCreateTime = order.getThirdCreateTime();
            if (thirdCreateTime != null) {
                order.setDownTime("下单时间:" + format.format(thirdCreateTime));
                order.setObtainTime(thirdCreateTime.getTime());
            }
            Date settleTime = order.getSettleTime();
            if (settleTime != null) {
                order.setReceiveTime("收货时间:" + format.format(settleTime));
            }
            Integer sourceType2 = order.getSourceType();
            if (sourceType2 == Constant.SOURCE_TYPE_TAOBAO) {
                Integer orderType = order.getOrderType();
                if (orderType == null) {
                    order.setOrderType(1);
                }
            } else if (sourceType2 == Constant.SOURCE_TYPE_JD) {
                order.setOrderType(3);
            } else if (sourceType2 == Constant.SOURCE_TYPE_PDD) {
                order.setOrderType(4);
            }
            /* 订单状态 转换处理 */
            String orderStateContent = "";
            Map<String, String> orderStateMap = new HashMap<String, String>();
            // 订单状态
            Integer orderState = order.getState();
            // 红包状态
            Integer hongBaoState = order.getHongBaoState();
            Integer stateWholeOrder = order.getStateWholeOrder();
            if (CommonOrder.STATE_WHOLE_ORDER_BUFENYOUXIAO == stateWholeOrder) {
                // 整个订单部分失效:判断真实状态 订单、红包
                CommonOrderVO buFenOrder = commonOrderMapper.getBuFenOrderState(uid, order.getOrderNo());
                if (buFenOrder != null) {
                    // 有效的订单状态
                    orderState = buFenOrder.getState();
                    // 有效的红包状态
                    hongBaoState = buFenOrder.getHongBaoState();
                }
            }
            BigDecimal hongBao = order.getHongBao();
            if (hongBao == null) {
                hongBao = new BigDecimal(0);
            }
            if (CommonOrder.STATE_FK == orderState) {
                orderStateContent = "已付款";
            } else if (CommonOrder.STATE_JS == orderState) {
                orderStateContent = "已收货";
            } else if (CommonOrder.STATE_SX == orderState) {
                orderStateContent = "未付款/已退款";
            } else if (CommonOrder.STATE_WQ == orderState) {
                orderStateContent = "已维权";
                Integer sourceType = order.getSourceType();
                if (sourceType != null && sourceType == Constant.SOURCE_TYPE_TAOBAO) {
                    /* 订单维权 判断是否全部维权 */
                    List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper
                            .selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
                    boolean isPart = false;// 默认失效
                    BigDecimal weiQuanMoney = getWeiQuanMoney(listWQ, sourceType, uid);
                    if (!VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
                        if (isPart) {
                            hongBaoState = HongBaoV2.STATE_BUFENSHIXIAO; // 部分失效
                        } else {
                            hongBaoState = HongBaoV2.STATE_SHIXIAO; // 全部失效
                        }
                    } else {
                        // 2019.8.1 返回维权信息
                        if (settleTime != null && august != null && settleTime.getTime() > august.getTime()) {
                            orderStateContent = "维权成功";
                            WeiQuanInfo weiQuanInfo = new WeiQuanInfo();
                            weiQuanInfo.setOldHongBao("¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
                            // if (isPart) {
                            weiQuanInfo
                                    .setWqHongBao("维权:-¥" + weiQuanMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
                            hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney);
                            // } else {
                            // weiQuanInfo
                            // .setWqHongBao("维权:-¥" + weiQuanMoney.setScale(2,
                            // BigDecimal.ROUND_DOWN).toString());
                            // hongBao = MoneyBigDecimalUtil.sub(hongBao,
                            // weiQuanMoney);
                            // }
                            order.setWeiQuanInfo(weiQuanInfo);
                        }
                    }
                }
            }
            orderStateMap.put("content", orderStateContent);
            orderStateMap.put("fontColor", "#666666");
            order.setOrderState(orderStateMap);
            String hongbaoInfo = "";
            // 订单标识
            List<String> signList = new ArrayList<String>();
            Integer hongBaoType = order.getHongBaoType();
            if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) { // 自购
                hongbaoInfo = "返利";
                order.setOrderOrigin("1");
                order.setHongBaoTypePic(CommonOrder.TYPE_FANLI);
                signList.add(CommonOrder.TYPE_FANLI);
            } else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) { // 分享
                hongbaoInfo = "奖金";
                order.setOrderOrigin("2");
                order.setHongBaoTypePic(CommonOrder.TYPE_SHARE);
                signList.add(CommonOrder.TYPE_SHARE);
            } else if (HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
                // 邀请订单 (下级的分享订单)
                hongbaoInfo = "奖金";
                order.setOrderOrigin("3");
                order.setHongBaoTypePic(CommonOrder.TYPE_INVITE);
                signList.add(CommonOrder.TYPE_INVITE);
            } else if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
                    || HongBaoV2.TYPE_ERJI == hongBaoType) {  // 邀请订单
                hongbaoInfo = "奖金";
                order.setOrderOrigin("3");
                order.setHongBaoTypePic(CommonOrder.TYPE_INVITE);
                signList.add(CommonOrder.TYPE_INVITE);
                // 版本区分:2-0-2
                if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
                    InviteOrderSubsidy orderSubsidy = inviteOrderSubsidyService.getByOrderNoAndType(uid, order.getOrderNo(), sourceType2);
                    if (orderSubsidy != null) {
                        ClientTextStyleVO subsidyInfo = new ClientTextStyleVO();
                        if (orderSubsidy.getState() == InviteOrderSubsidy.STATE_SUBSIDIZED) {
                            subsidyInfo.setColor("#E5005C");
                            subsidyInfo.setContent("已补贴¥" + orderSubsidy.getMoney());
                        } else {
                            subsidyInfo.setColor("#888888");
                            subsidyInfo.setContent("补贴¥" + orderSubsidy.getMoney());
                            // 解释信息(问号)
                            List<String> subsidyList = new ArrayList<String>();
                            subsidyList.add("额外补贴能否获得由系统算法自动判断,人为无法干涉;");
                            subsidyList.add("额外补贴到账时间以及金额请以实际到账为准;");
                            subsidyList.add("额外补贴产生后将会在消息-资金消息中提醒你。");
                            order.setSubsidyList(subsidyList);
                        }
                        order.setSubsidy(subsidyInfo);
                    }
                }
            }
            String hongBaoDate = null;
            String hongBaoState_Str = "";
            String hongbaoInfoFontColor = "#E5005C";
            String stateContent = "";
            String stateFontColor = "#E5005C";
            Integer orderHongBaoState = null;
            if (HongBaoV2.STATE_KELINGQU == hongBaoState || HongBaoV2.STATE_BUKELINGQU == hongBaoState) {
                orderHongBaoState = 1;
                stateContent = "未到账";
                hongBaoState_Str = "预估";
                Date preAccountTime = order.getPreAccountTime();
                if (preAccountTime != null)
                    hongBaoDate = "预计到账时间:" + formatday.format(preAccountTime);
            } else if (HongBaoV2.STATE_YILINGQU == hongBaoState) {
                orderHongBaoState = 3;
                stateContent = "已到账";
                Date accountTime = order.getAccountTime();
                if (accountTime != null)
                    hongBaoDate = "到账时间:" + formatday.format(accountTime);
            } else if (HongBaoV2.STATE_BUFENSHIXIAO == hongBaoState) {
                stateContent = "部分失效";
                orderHongBaoState = 3;
                Date accountTime = order.getAccountTime();
                if (accountTime != null)
                    hongBaoDate = "到账时间:" + formatday.format(accountTime);
            } else if (HongBaoV2.STATE_SHIXIAO == hongBaoState) {
                orderHongBaoState = 4;
                stateContent = "已失效";
                hongbaoInfoFontColor = "#888888";
            }
            order.setHongBaoState(orderHongBaoState);
            order.setHongBaoDate(hongBaoDate);
            if (!StringUtil.isNullOrEmpty(order.getStateDesc()))
                stateContent = stateContent + "-" + order.getStateDesc();
            Map<String, String> stateMap = new HashMap<String, String>();
            stateMap.put("content", stateContent);
            stateMap.put("fontColor", stateFontColor);
            order.setAccountState(stateMap);
            hongbaoInfo = hongBaoState_Str + hongbaoInfo;
            Map<String, String> hongBaoMap = new HashMap<String, String>();
            hongBaoMap.put("content", hongbaoInfo + " ¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
            hongBaoMap.put("fontColor", hongbaoInfoFontColor);
            order.setHongBaoInfo(hongBaoMap);
            Integer sourceType = order.getSourceType();
            // 非自购的订单 不显示返利、免单详情
            if (HongBaoV2.TYPE_ZIGOU != hongBaoType) {
                order.setSignList(signList);
            } else {
                // 奖励订单、免单 使用记录
                if (sourceType == null) {
                    setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType, null,
                            signList, acceptData);
                } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
                    setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType,
                            listRecordTB, signList, acceptData);
                } else if (sourceType == Constant.SOURCE_TYPE_JD) {
                    setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType,
                            listRecordJD, signList, acceptData);
                } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
                    setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType,
                            listRecordPDD, signList, acceptData);
                }
            }
            // 分享、邀请 隐藏订单号
            if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType || HongBaoV2.TYPE_YAOQING == hongBaoType
                    || HongBaoV2.TYPE_YIJI == hongBaoType || HongBaoV2.TYPE_ERJI == hongBaoType
                    || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
                order.setOrderNo(UserUtil.filterOrderId(order.getOrderNo()));
            }
        }
    }
    /**
     * 订单: 免单标识 奖励标识
@@ -707,7 +299,7 @@
                    Date thirdCreateTime = order.getThirdCreateTime();
                    if (thirdCreateTime != null) {
                        long downOrderTime = thirdCreateTime.getTime();
                        long limitDate = Long.parseLong("1573315200000"); // TODO 日期待确定2019-11-10
                        long limitDate = Long.parseLong("1571760000000"); // TODO 日期待确定2019-11-10
                        if (downOrderTime > limitDate) {
                            newEdition = true;
                            Date endDay = DateUtil.plusDayDate(4, thirdCreateTime);
@@ -752,9 +344,13 @@
                    rewardStyleVO.setColor("#E5005C");
                    rewardStyleVO.setBottomColor("#FFDCEA");
                    if (!newEdition) {
                        if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
                            rewardStyleVO.setContent("使用奖励券 >");
                        } else {
                        rewardStyleVO.setContent("返利奖励 >");
                        }
                    } else if (canUse) {
                        rewardStyleVO.setContent("返利奖励 ");
                        rewardStyleVO.setContent("使用奖励券");
                        
                        ClientTextStyleVO txt1 = new ClientTextStyleVO();
                        txt1.setContent("剩");
@@ -765,6 +361,7 @@
                        txt2.setContent(num);
                        txt2.setColor("#E5005C");
                        txt2.setBottomColor("#FFDCEA");
                        txt2.setFontSize("1.33");
                        
                        ClientTextStyleVO txt3 = new ClientTextStyleVO();
                        txt3.setContent(unit + "关闭 >");
@@ -1065,12 +662,13 @@
                    InviteOrderSubsidy orderSubsidy = inviteOrderSubsidyService.getByOrderNoAndType(uid, order.getOrderNo(), sourceType);
                    if (orderSubsidy != null) {
                        ClientTextStyleVO subsidyInfo = new ClientTextStyleVO();
                        subsidyInfo.setContent("(补贴¥" + orderSubsidy.getMoney() + ")");
                        if (orderSubsidy.getState() == InviteOrderSubsidy.STATE_SUBSIDIZED) {
                            subsidyInfo.setColor("#E5005C");
                            subsidyInfo.setContent("已补贴¥" + orderSubsidy.getMoney());
                        } else {
                            subsidyInfo.setColor("#888888");
                            subsidyInfo.setContent("补贴¥" + orderSubsidy.getMoney());
                        }
                        order.setSubsidy(subsidyInfo);
                            
                            // 解释信息(问号)
                            List<String> subsidyList = new ArrayList<String>();
@@ -1078,8 +676,6 @@
                            subsidyList.add("额外补贴到账时间以及金额请以实际到账为准;");
                            subsidyList.add("额外补贴产生后将会在消息-资金消息中提醒你。");
                            order.setSubsidyList(subsidyList);
                        }
                        order.setSubsidy(subsidyInfo);
                    }
                }
            }
@@ -1173,6 +769,64 @@
        }
    }
    
    @Override
    public Map<String, BigDecimal> countHistoryOrder(Long uid, Integer day, Integer source) {
        return commonOrderMapper.countHistoryOrder(uid, day, source);
    }
    @Override
    public long countBonusOrderNumber(Long uid, Integer type, Integer day, String startTime, String endTime,
            Integer source) {
        return commonOrderMapper.countBonusOrderNumber(uid, type, day, startTime, endTime, source);
    }
    @Override
    public BigDecimal countBonusOrderMoney(Long uid, Integer type, Integer day, String startTime, String endTime,
            Integer source) {
        return commonOrderMapper.countBonusOrderMoney(uid, type, day, startTime, endTime, source);
    }
    @Override
    public Map<String, Object> countBonusOrderMoneyAndNumber(Long uid, Integer type, Integer day, String startTime,
            String endTime, Integer source) {
        return commonOrderMapper.countBonusOrderMoneyAndNumber(uid, type, day, startTime, endTime, source);
    }
    @Override
    public Long countUserOrderToApp(Long uid, Integer type, String startTime, String endTime,
            Integer day, Integer source, Integer state, Integer stateOrder) {
        return commonOrderMapper.countUserOrderToApp(uid, type, startTime, endTime, day, source, state, stateOrder);
    }
    private BigDecimal getWeiQuanMoney(List<TaoBaoWeiQuanOrder> listWQ, int sourceType, Long uid) {
        BigDecimal weiQuanMoney = new BigDecimal(0);
        if (listWQ != null && listWQ.size() > 0) {
            for (TaoBaoWeiQuanOrder weiQuanOrder : listWQ) {
                String tradeId = weiQuanOrder.getOrderItemId();
                // 查询红包
                List<String> tradeList = new ArrayList<>();
                tradeList.add(tradeId);
                List<HongBaoV2> hongBaoList = hongBaoV2Service.listBySourceTypeAndTradeIdListAndUid(sourceType, uid,
                        tradeList);
                if (hongBaoList != null && hongBaoList.size() > 0) {
                    CommonOrder commonOrder = commonOrderMapper.selectBySourceTypeAndTradeId(sourceType, tradeId);
                    if (commonOrder != null && commonOrder.getSettlement().compareTo(new BigDecimal(0)) > 0) {
                        BigDecimal wqMoney = MoneyBigDecimalUtil
                                .mul(hongBaoList.get(0).getMoney(), weiQuanOrder.getMoney())
                                .divide(commonOrder.getSettlement(), 2, BigDecimal.ROUND_UP);
                        if (wqMoney.compareTo(hongBaoList.get(0).getMoney()) > 0)
                            wqMoney = hongBaoList.get(0).getMoney();
                        weiQuanMoney = weiQuanMoney.add(wqMoney);
                    }
                }
            }
        }
        return weiQuanMoney;
    }
    
    @Override
    public List<CommonOrder> listBySourceTypeAndOrderId(int sourceType, String orderId) {
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java
New file
@@ -0,0 +1,85 @@
package com.yeshi.fanli.service.impl.redpack;
import java.math.BigDecimal;
import java.util.Date;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.yeshi.fanli.dao.mybatis.redpack.RedPackBalanceMapper;
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.service.inter.redpack.RedPackBalanceService;
import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
@Service
public class RedPackBalanceServiceImpl implements RedPackBalanceService {
    @Resource
    private RedPackBalanceMapper redPackBalanceMapper;
    @Resource
    private RedPackDetailService redPackDetailService;
    @Override
    public RedPackBalance selectByPrimaryKey(Long uid) {
        return redPackBalanceMapper.selectByPrimaryKey(uid);
    }
    @Override
    public BigDecimal getBalance(Long uid) {
        if (uid == null || uid == 0)
            return null;
        RedPackBalance redPackBalance = redPackBalanceMapper.selectByPrimaryKey(uid);
        if (redPackBalance != null)
            return redPackBalance.getMoney();
        return null;
    }
    @Override
    public void addRedPack(Long uid, BigDecimal money) {
        if (uid == null || uid == 0 || money == null)
            return;
        RedPackBalance redPackBalance = redPackBalanceMapper.selectForUpdate(uid);
        if (redPackBalance == null) {
            redPackBalance = new RedPackBalance();
            redPackBalance.setId(uid);
            redPackBalance.setMoney(money);
            redPackBalance.setCreateTime(new Date());
            redPackBalance.setUpdateTime(new Date());
            redPackBalanceMapper.insertSelective(redPackBalance);
        } else {
            redPackBalanceMapper.addRedPack(uid, money);
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException {
        if (uid == null || uid == 0 || money == null ||  detail == null)
            throw new RedPackBalanceException(1, "参数传递不完整");
        // 加入明细
        redPackDetailService.insertSelective(detail);
        // 减少红包
        redPackBalanceMapper.addRedPack(uid, money);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void subRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException {
        if (uid == null || uid == 0 || money == null ||  detail == null)
            throw new RedPackBalanceException(1, "参数传递不完整");
        // 加入明细
        redPackDetailService.insertSelective(detail);
        // 减少红包
        redPackBalanceMapper.subRedPack(uid, money);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackConfigServiceImpl.java
New file
@@ -0,0 +1,53 @@
package com.yeshi.fanli.service.impl.redpack;
import java.util.Date;
import javax.annotation.Resource;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.redpack.RedPackConfigMapper;
import com.yeshi.fanli.entity.redpack.RedPackConfig;
import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
@Service
public class RedPackConfigServiceImpl implements RedPackConfigService {
    @Resource
    private RedPackConfigMapper redPackConfigMapper;
    @Override
    public RedPackConfig getByKey(String key) {
        return redPackConfigMapper.getByKey(key, new Date());
    }
    @Override
    @Cacheable(value = "redpackCache", key = "'getValueByKey-' + #key")
    public String getValueByKey(String key) {
        RedPackConfig config = redPackConfigMapper.getByKey(key, new Date());
        if (config != null) {
            return config.getValue();
        }
        return null;
    }
    @Override
    public RedPackConfig getByKey(String key, Date date) {
        if (date == null)
            return getByKey(key);
        return redPackConfigMapper.getByKey(key, date);
    }
    @Override
    public String getValueByKey(String key, Date date) {
        if (date == null)
            return getValueByKey(key);
        RedPackConfig config = redPackConfigMapper.getByKey(key, date);
        if (config != null) {
            return config.getValue();
        }
        return null;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackDetailServiceImpl.java
New file
@@ -0,0 +1,213 @@
package com.yeshi.fanli.service.impl.redpack;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.redpack.RedPackDetailMapper;
import com.yeshi.fanli.entity.redpack.RedPackDetail;
import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.vo.redpack.RedPackDetailVO;
import com.yeshi.fanli.vo.redpack.RedPackMonthVO;
@Service
public class RedPackDetailServiceImpl implements RedPackDetailService {
    @Resource
    private RedPackDetailMapper redPackDetailMapper;
    @Override
    public void insertSelective(RedPackDetail record) {
        redPackDetailMapper.insertSelective(record);
    }
    @Override
    public void updateByPrimaryKeySelective(RedPackDetail record) {
        redPackDetailMapper.updateByPrimaryKeySelective(record);
    }
    @Override
    public RedPackDetail getByIdentifyCode(String identifyCode) {
        return redPackDetailMapper.getByIdentifyCode(identifyCode);
    }
    @Override
    public BigDecimal countAddMoneyByDate(long uid, int dateType) {
        return redPackDetailMapper.countAddMoneyByDate(uid, dateType);
    }
    @Override
    public BigDecimal countUseMoneyByDate(long uid, int dateType) {
        return redPackDetailMapper.countUseMoneyByDate(uid, dateType);
    }
    @Override
    public List<RedPackDetailVO> listUserMoneyDetailForClient(Long uid, Long detailId, Date maxTime) {
        List<RedPackDetailVO> finalList = new ArrayList<>();
        List<RedPackDetail> list = null;
        if (detailId == null) {// 首次请求
            if (maxTime == null)// 没有筛选时间
            {
                list = redPackDetailMapper.selectByMaxCreateTime(uid,
                        new Date(System.currentTimeMillis() + 1000 * 60 * 60L), 20);
            } else {// 筛选了时间
                list = redPackDetailMapper.selectByMaxCreateTime(uid, maxTime, 20);
            }
            if (list != null && list.size() > 0) {
                Calendar calendar = Calendar.getInstance();
                calendar.setTimeInMillis(list.get(0).getCreateTime().getTime());
                RedPackDetailVO vo = new RedPackDetailVO();
                vo.setMonth(new RedPackMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1));
                finalList.add(vo);
            } else {
                if (maxTime != null) {//
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTimeInMillis(maxTime.getTime());
                    RedPackDetailVO vo = new RedPackDetailVO();
                    vo.setMonth(new RedPackMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1));
                    vo.getMonth().setExpend("0");
                    vo.getMonth().setIncome("0");
                    finalList.add(vo);
                }
            }
        } else {// 二次请求
            int size = 21;
            List<RedPackDetail> tempList = redPackDetailMapper.selectByUidWithIndexId(uid, detailId, size);
            Set<Date> dateSet = new HashSet<>();// 用于储存是否在同一时间上面(精确到秒)
            if (tempList.size() > 0) {
                for (RedPackDetail umd : tempList) {
                    dateSet.add(umd.getCreateTime());
                }
                List<RedPackDetail> tempList2 = new ArrayList<>();
                while (dateSet.size() == 1 && tempList2.size() != tempList.size() && size < 40) {// 只有一个时间点的数据
                    tempList = tempList2;
                    size += 10;
                    tempList2 = redPackDetailMapper.selectByUidWithIndexId(uid, detailId, size);
                    dateSet.clear();
                    for (RedPackDetail umd : tempList2) {
                        dateSet.add(umd.getCreateTime());
                    }
                }
                if (tempList2.size() > 0)
                    tempList = tempList2;
            }
            for (int i = 0; i < tempList.size(); i++) {
                if (tempList.get(i).getId().longValue() == detailId) {
                    tempList.remove(i);
                    break;
                } else {
                    tempList.remove(i);
                    i--;
                }
            }
            list = tempList;
        }
        if (list != null) {
            if (detailId != null && list.size() > 0) {
                RedPackDetail umd = redPackDetailMapper.selectByPrimaryKey(detailId);
                if (!TimeUtil.getGernalTime(umd.getCreateTime().getTime(), "yyyy-MM")
                        .equalsIgnoreCase(TimeUtil.getGernalTime(list.get(0).getCreateTime().getTime(), "yyyy-MM"))) {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTimeInMillis(list.get(0).getCreateTime().getTime());
                    RedPackDetailVO vo = new RedPackDetailVO();
                    vo.setMonth(new RedPackMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1));
                    finalList.add(vo);
                }
            }
            for (int i = 0; i < list.size(); i++) {
                if (i > 0 && !TimeUtil.getGernalTime(list.get(i - 1).getCreateTime().getTime(), "yyyy-MM")
                        .equalsIgnoreCase(TimeUtil.getGernalTime(list.get(i).getCreateTime().getTime(), "yyyy-MM"))) {// 本条数据与上条数据不是同一月则插入月份
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTimeInMillis(list.get(i).getCreateTime().getTime());
                    RedPackDetailVO vo = new RedPackDetailVO();
                    vo.setMonth(new RedPackMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1));
                    finalList.add(vo);
                }
                RedPackDetailVO vo = new RedPackDetailVO();
                vo.setDetail(list.get(i));
                finalList.add(vo);
            }
        }
        // 统计月资金
        Map<Integer, RedPackDetailVO> monthMap = new TreeMap<>();
        if (finalList.size() > 1)
            for (int i = 0; i < finalList.size(); i++) {
                if (finalList.get(i).getMonth() != null)
                    monthMap.put(i, finalList.get(i));
            }
        if (!monthMap.isEmpty()) {
            List<String> dateFormat = new ArrayList<>();
            Iterator<Integer> keys = monthMap.keySet().iterator();
            while (keys.hasNext()) {
                Integer key = keys.next();
                String date = "";
                date += monthMap.get(key).getMonth().getYear();
                date += "-";
                date += (monthMap.get(key).getMonth().getMonth() + "").length() < 2
                        ? "0" + monthMap.get(key).getMonth().getMonth() : monthMap.get(key).getMonth().getMonth();
                dateFormat.add(date);
            }
            List<RedPackMonthVO> voList = redPackDetailMapper.selectMonthMoneyByUid(uid, dateFormat);
            int p = 0;
            keys = monthMap.keySet().iterator();
            while (keys.hasNext()) {
                Integer key = keys.next();
                BigDecimal expend = new BigDecimal(voList.get(p).getExpend());
                BigDecimal income = new BigDecimal(voList.get(p).getIncome());
                // 去除支出负号
                finalList.get(key).getMonth().setExpend(expend.setScale(2).toString().replace("-", ""));
                finalList.get(key).getMonth().setIncome(income.setScale(2).toString());
                p++;
            }
        }
        return finalList;
    }
    @Override
    public long countUserMoneyDetailForClient(Long uid, Long detailId, Date maxTime) {
        long monthCount = 0L;
        long detailCount = 0L;
        // 未通过时间筛选,查询所有
        if (maxTime == null) {
            detailCount = redPackDetailMapper.selectCountByUid(uid);
            // 用于表示当前所有
            monthCount = redPackDetailMapper.selectMonthCountByUid(uid, new Date(System.currentTimeMillis() + 1000 * 60 * 60L));
        } else {// 通过时间筛选了的,需要查询所有
            detailCount = redPackDetailMapper.selectCountByUidAndMaxCreateTime(uid, maxTime);
            monthCount = redPackDetailMapper.selectMonthCountByUid(uid, maxTime);
        }
        return monthCount + detailCount;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java
New file
@@ -0,0 +1,186 @@
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 com.yeshi.fanli.dao.mybatis.redpack.RedPackExchangeMapper;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.common.AdminUser;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
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.RedPackExchangeException;
import com.yeshi.fanli.service.inter.money.UserMoneyService;
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.RedPackExchangeService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.factory.RedPackDetailFactory;
@Service
public class RedPackExchangeServiceImpl implements RedPackExchangeService {
    @Resource
    private RedPackExchangeMapper redPackExchangeMapper;
    @Resource
    private RedPackConfigService redPackConfigService;
    @Resource
    private RedPackBalanceService redPackBalanceService;
    @Resource
    private UserMoneyService userMoneyService;
    @Resource
    private RedPackDetailService redPackDetailService;
    @Override
    public List<RedPackExchange> query(Integer start, Integer count, String key, Integer state){
        return redPackExchangeMapper.query(start, count, key, state);
    }
    @Override
    public Long count(String key, Integer state){
        return redPackExchangeMapper.count(key, state);
    }
    @Override
    public List<Long> countState(long uid){
        return redPackExchangeMapper.countState(uid);
    }
    @Override
    public List<BigDecimal> countMoneyState(long uid){
        return redPackExchangeMapper.countMoneyState(uid);
    }
    @Override
    public BigDecimal countMoneyByState(Long uid, Integer state){
        return redPackExchangeMapper.countMoneyByState(uid, state);
    }
    @Override
    public RedPackExchange selectByPrimaryKey(long id){
        return redPackExchangeMapper.selectByPrimaryKey(id);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void exchangeCash(Long uid, BigDecimal amount) throws RedPackExchangeException {
        if (uid == null || amount == null)
            throw new RedPackExchangeException(1, "参数不正确");
        String extractBanlenMin = redPackConfigService.getValueByKey("extract_banlen_min");
        BigDecimal balance = redPackBalanceService.getBalance(uid);
        if (balance == null || balance.compareTo(new BigDecimal(extractBanlenMin)) < 0)
            throw new RedPackExchangeException(1, "余额不足" + extractBanlenMin + "元");
        if (balance.compareTo(amount) < 0)
            throw new RedPackExchangeException(1, "提现余额不足");
        String moneyMin = redPackConfigService.getValueByKey("extract_money_min");
        String moneyMax = redPackConfigService.getValueByKey("extract_money_max");
        if (amount.compareTo(new BigDecimal(moneyMin)) < 0 || amount.compareTo(new BigDecimal(moneyMax)) > 0)
            throw new RedPackExchangeException(1, "提现金额至少" + moneyMin + "元至多" + moneyMax + "元");
        Date nowDate = new Date();
        // 提现申请
        RedPackExchange exchange = new RedPackExchange();
        exchange.setUid(uid);
        exchange.setMoney(amount);
        exchange.setState(RedPackExchange.STATE_INIT);
        exchange.setCreateTime(nowDate);
        redPackExchangeMapper.insertSelective(exchange);
        // 减少红包
        try {
            redPackBalanceService.subRedPack(uid, amount, RedPackDetailFactory.createExchange(exchange));
        } catch (Exception e) {
            throw new RedPackExchangeException(1, "红包信息异常");
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void passExchange(final long id, AdminUser admin) throws RedPackExchangeException {
        RedPackExchange record = redPackExchangeMapper.selectByPrimaryKey(id);
        if (record == null)
            throw new RedPackExchangeException(1,"申请记录已不存在");
        if (RedPackExchange.STATE_INIT == record.getState())
            throw new RedPackExchangeException(1,"该申请已被处理,请刷新");
        Date nowDate = new Date();
        record.setAuditId(admin.getId());
        record.setAuditTime(nowDate);
        record.setState(RedPackExchange.STATE_SUCCESS);
        redPackExchangeMapper.updateByPrimaryKeySelective(record);
        // 资金明细-添加资金
        UserMoneyDetail detail = new UserMoneyDetail();
        detail.setCreateTime(new Date());
        detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.redPackExchange.name() + ":" + record.getId()));
        detail.setMoney(record.getMoney());
        detail.setType(UserMoneyDetailTypeEnum.redPackExchange);
        detail.setTitle(UserMoneyDetailTypeEnum.redPackExchange.getDesc());
        detail.setDescInfo("于"+ TimeUtil.formatDate(record.getCreateTime()) +"提现");
        detail.setUpdateTime(new Date());
        detail.setUserInfo(new UserInfo(record.getUid()));
        // 添加资金
        userMoneyService.addUserMoney(record.getUid(), record.getMoney(), detail);
        try {
            String identifyCode = StringUtil.Md5(RedPackDetailTypeEnum.redExchangePass.name() + ":" + record.getId());
            RedPackDetail redPackDetail = redPackDetailService.getByIdentifyCode(identifyCode);
            RedPackDetail updateDetail = RedPackDetailFactory.updateExchangePass(redPackDetail.getId(), record);
            redPackDetailService.updateByPrimaryKeySelective(updateDetail);
        } catch (Exception e) {
            throw new RedPackExchangeException(1,"更新提现明细出错");
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void rejectExchange(long id, String reason, AdminUser admin) throws RedPackExchangeException {
        RedPackExchange record = redPackExchangeMapper.selectByPrimaryKey(id);
        if (record == null)
            throw new RedPackExchangeException(1,"申请记录已不存在");
        if (RedPackExchange.STATE_INIT == record.getState())
            throw new RedPackExchangeException(1,"该申请已被处理,请刷新");
        record.setReason(reason);
        record.setAuditTime(new Date());
        record.setAuditId(admin.getId());
        record.setState(RedPackExchange.STATE_REJECT);
        redPackExchangeMapper.updateByPrimaryKeySelective(record);
        // 退回红包
        try {
            redPackBalanceService.addRedPack(record.getUid(), record.getMoney(), RedPackDetailFactory.createExchange(record));
        } catch (Exception e) {
            throw new RedPackExchangeException(1, "红包退回时出错");
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java
New file
@@ -0,0 +1,98 @@
package com.yeshi.fanli.service.impl.redpack;
import java.math.BigDecimal;
import java.util.Date;
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.RedPackGiveRecordMapper;
import com.yeshi.fanli.entity.bus.user.TokenRecord;
import com.yeshi.fanli.entity.bus.user.TokenRecord.TokenTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackGiveRecord;
import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
import com.yeshi.fanli.service.inter.redpack.RedPackGiveRecordService;
import com.yeshi.fanli.service.inter.user.TokenRecordService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.TokenUtil;
import com.yeshi.fanli.util.factory.RedPackDetailFactory;
@Service
public class RedPackGiveRecordServiceImpl implements RedPackGiveRecordService {
    @Resource
    private RedPackGiveRecordMapper redPackGiveRecordMapper;
    @Resource
    private RedPackConfigService redPackConfigService;
    @Resource
    private RedPackBalanceService redPackBalanceService;
    @Resource
    private TokenRecordService tokenRecordService;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String giving(Long uid, BigDecimal amount) throws RedPackGiveRecordException {
        if (uid == null || amount == null)
            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 = redPackBalanceService.getBalance(uid);
        if (balance == null || amount.compareTo(balance) > 0)
            throw new RedPackGiveRecordException(1, "余额不足");
        Date nowDate = new Date();
        // 赠送记录
        RedPackGiveRecord giveRecord = new RedPackGiveRecord();
        giveRecord.setAmount(amount);
        giveRecord.setGiveUid(uid);
        giveRecord.setState(RedPackGiveRecord.STATE_INIT);
        giveRecord.setGiveTime(nowDate);
        giveRecord.setEndTime(DateUtil.plusDayDate(Constant.GIVE_DAYS, new Date()));
        redPackGiveRecordMapper.insertSelective(giveRecord);
        // 口令记录
        TokenRecord tokenRecord = new TokenRecord();
        tokenRecord.setUid(uid);
        tokenRecord.setIdentify(giveRecord.getId() + "");
        tokenRecord.setType(TokenTypeEnum.redPack);
        tokenRecord.setStartTime(nowDate);
        tokenRecord.setEndTime(DateUtil.plusDayDate(Constant.TOKEN_DAYS, new Date()));
        tokenRecord.setState(0);
        tokenRecordService.insertSelective(tokenRecord);
        // 创建口令
        String token = TokenUtil.createToken(tokenRecord.getId());
        tokenRecord.setToken(token);
        tokenRecordService.updateByPrimaryKeySelective(tokenRecord);
        String tips = redPackConfigService.getValueByKey("give_tips");
        String projectChineseName = Constant.systemCommonConfig.getProjectChineseName();
        while (tips.contains("{APP名称}")) {
            tips = tips.replace("{APP名称}", projectChineseName);
        }
        tips = tips.replace("{口令}", token).replace("{下载链接}", redPackConfigService.getValueByKey("app_down_link")).replace("{面额}",
                amount.setScale(0).toString());
        // 减少红包
        try {
            redPackBalanceService.subRedPack(uid, amount, RedPackDetailFactory.createGiveOthers(giveRecord, null, RedPackDetailTypeEnum.giveOthers));
        } catch (Exception e) {
            throw new RedPackGiveRecordException(1, "红包创建失败");
        }
        return tips;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponActivateServiceImpl.java
New file
@@ -0,0 +1,60 @@
package com.yeshi.fanli.service.impl.user;
import java.util.Date;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.user.UserSystemCouponActivateMapper;
import com.yeshi.fanli.entity.bus.user.UserSystemCouponActivate;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponActivateService;
@Service
public class UserSystemCouponActivateServiceImpl implements UserSystemCouponActivateService{
    @Resource
    private UserSystemCouponActivateMapper userSystemCouponActivateMapper;
    @Resource
    private ConfigService configService;
    @Override
    public boolean addActivateCount(Long cpid, int limitNum) {
        UserSystemCouponActivate coupon = userSystemCouponActivateMapper.selectByPrimaryKey(cpid);
        if (coupon != null) {
            userSystemCouponActivateMapper.addCount(cpid, 1);
            coupon.setCount(coupon.getCount() + 1);
        } else {
            coupon = new UserSystemCouponActivate();
            coupon.setId(cpid);
            coupon.setCount(1);
            coupon.setState(UserSystemCouponActivate.STATE_INIT);
            coupon.setCreateTime(new Date());
            coupon.setUpdateTime(new Date());
            userSystemCouponActivateMapper.insertSelective(coupon);
        }
        // 是否满足激活条件
        Integer state = coupon.getState();
        if (state != UserSystemCouponActivate.STATE_END && coupon.getCount().intValue() >= limitNum) {
            UserSystemCouponActivate record = new UserSystemCouponActivate();
            record.setId(coupon.getId());
            record.setState(UserSystemCouponActivate.STATE_END);
            userSystemCouponActivateMapper.updateByPrimaryKeySelective(record);
            return true;
        }
        return false;
    }
    @Override
    public int getActivateCount(Long id) {
        UserSystemCouponActivate coupon = userSystemCouponActivateMapper.selectByPrimaryKey(id);
        if (coupon != null)
            return coupon.getCount();
        return 0;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -48,7 +48,6 @@
import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.exception.money.UserMoneyDetailException;
import com.yeshi.fanli.exception.order.HongBaoException;
import com.yeshi.fanli.exception.user.UserInfoExtraException;
import com.yeshi.fanli.exception.user.UserSystemCouponException;
import com.yeshi.fanli.log.LogHelper;
@@ -69,6 +68,7 @@
import com.yeshi.fanli.service.inter.user.TokenRecordService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponActivateService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponGiveRecordService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
@@ -81,7 +81,6 @@
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
import com.yeshi.fanli.util.factory.msg.MsgOtherSystemGiveDTOFactory;
import com.yeshi.fanli.util.rocketmq.MQTagConstant;
import com.yeshi.fanli.util.rocketmq.MQTopicName;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
@@ -170,6 +169,10 @@
    @Resource(name = "orderTransactionProducer")
    private TransactionProducer orderTransactionProducer;
    @Resource
    private UserSystemCouponActivateService userSystemCouponActivateService;
    @Override
    public int insertSelective(UserSystemCoupon record) {
@@ -1721,7 +1724,7 @@
    @Transactional
    @Override
    public List<UserSystemCouponVO> getCouponList(long start, int count, Long uid)
    public List<UserSystemCouponVO> getCouponList(AcceptData acceptData, long start, int count, Long uid)
            throws UserSystemCouponException, Exception {
        // 过期券
@@ -1816,15 +1819,12 @@
                        listTip.add("满足条件后,系统将自动激活,并在消息-其它消息中提醒。");
                        userCouponVO.setTips(listTip);
                        userCouponVO.setPopup(true);
                        // 验证是否已累计3单
                        executor.execute(new Runnable() {
                            @Override
                            public void run() {
                                freeCouponActivate(userCouponVO.getId(), uid, userCouponVO.getCreateTime());
                        // 统计待激活数量
                        if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
                            int activateCount = userSystemCouponActivateService.getActivateCount(userCouponVO.getId());
                            String activateNum = configService.get("free_coupon_activate_num");
                            userCouponVO.setCouponEffect("(" + activateCount + "/"+ Integer.parseInt(activateNum) +")待激活");
                            }
                        });
                    } else if (CouponTypeEnum.welfareFreeCoupon == type) {
                        jumpBtn = new HashMap<String, Object>();
                        if (inviteCode != null && inviteCode.trim().length() > 0) {
@@ -2099,80 +2099,6 @@
        return userCouponVO;
    }
    /**
     * 免单券激活
     *
     * @param uid
     */
    public void freeCouponActivate(Long id, Long uid, Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long count = commonOrderCountService.countValidOrderByDate(uid, sdf.format(date));
        String activateNum = configService.get("free_coupon_activate_num");
        int num = Integer.parseInt(activateNum);
        if (count >= num) {
            UserSystemCoupon coupon = userSystemCouponMapper.selectByPrimaryKey(id);
            if (coupon == null || coupon.getState() != UserSystemCoupon.STATE_CAN_USE
                    || coupon.getStateActivated() != 0)
                return;
            Date nowDate = new Date();
            Date endTime2 = coupon.getEndTime();
            if (endTime2 != null && endTime2.getTime() <= nowDate.getTime())
                return;
            SystemCoupon systemCoupon = coupon.getSystemCoupon();
            if (systemCoupon == null)
                return;
            systemCoupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId());
            if (systemCoupon == null || systemCoupon.getType() != CouponTypeEnum.freeCoupon)
                return;
            try {
                Integer expiryDay = systemCoupon.getExpiryDay();
                String endDay = DateUtil.plusDay(expiryDay - 1, nowDate);
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                if (endDay != null && endDay.trim().length() > 0) {
                    endDay += " 23:59:59";
                }
                Date endTime = format.parse(endDay);
                UserSystemCoupon userCoupon = new UserSystemCoupon();
                userCoupon.setId(coupon.getId());
                userCoupon.setStateActivated(1);
                userCoupon.setEndTime(endTime);
                userCoupon.setStartTime(nowDate);
                userCoupon.setUpdateTime(new Date());
                userSystemCouponMapper.updateByPrimaryKeySelective(userCoupon);
                // 赠送记录
                UserSystemCouponGiveRecord giveRecord = userSystemCouponGiveRecordService.getByReceiveId(id);
                if (giveRecord == null)
                    return;
                Long giveUid = giveRecord.getGiveUid();
                UserInfo userInfo = userInfoService.selectByPKey(giveUid);
                if (userInfo == null)
                    return;
                String beiZhu = "请到我的-福利中心中查看";
                SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
                MsgOtherCouponActivateDTO msgOther = new MsgOtherCouponActivateDTO();
                msgOther.setTitle("免单券激活");
                msgOther.setType("免单券系统已自动激活");
                msgOther.setExplain("满足" + systemCoupon.getActivateDay() + "天内产生" + num + "笔已到账返利订单");
                msgOther.setGiveUser("昵称:" + userInfo.getNickName() + " ID:" + giveUid);
                msgOther.setReceiveTime(sd.format(giveRecord.getReceiveTime()));
                msgOther.setValidityTime(expiryDay + "天");
                userOtherMsgNotificationService.giveCouponActivateMsg(uid, beiZhu, msgOther);
            } catch (Exception e) {
                e.printStackTrace();
                LogHelper.errorDetailInfo(e);
            }
        }
    }
    @Transactional
    @Override
@@ -2516,4 +2442,78 @@
        return userSystemCouponMapper.getFreeCouponByType(uid, type);
    }
    @Override
    @Transactional
    public void activateFreeCoupon(Long uid) {
        List<UserSystemCoupon> list = userSystemCouponMapper.getNeedActivateFreeCouponByType(uid, CouponTypeEnum.freeCoupon.name());
        if (list == null || list.size() == 0)
            return;
        UserSystemCoupon coupon = list.get(0);
        Date nowDate = new Date();
        Date endTime2 = coupon.getEndTime();
        if (endTime2 != null && endTime2.getTime() <= nowDate.getTime())
            return; // 已失效
        SystemCoupon systemCoupon = coupon.getSystemCoupon();
        if (systemCoupon == null)
            return; // 券已不存在
        systemCoupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId());
        if (systemCoupon == null || systemCoupon.getType() != CouponTypeEnum.freeCoupon)
            return; // 券类型不匹配
        // 添加激活数量
        String activateNum = configService.get("free_coupon_activate_num");
        boolean activate = userSystemCouponActivateService.addActivateCount(coupon.getId(), Integer.parseInt(activateNum));
        // 激活券
        if (activate) {
            try {
                Integer expiryDay = systemCoupon.getExpiryDay();
                String endDay = DateUtil.plusDay(expiryDay - 1, nowDate);
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                if (endDay != null && endDay.trim().length() > 0) {
                    endDay += " 23:59:59";
                }
                Date endTime = format.parse(endDay);
                UserSystemCoupon userCoupon = new UserSystemCoupon();
                userCoupon.setId(coupon.getId());
                userCoupon.setStateActivated(1);
                userCoupon.setEndTime(endTime);
                userCoupon.setStartTime(nowDate);
                userCoupon.setUpdateTime(new Date());
                userSystemCouponMapper.updateByPrimaryKeySelective(userCoupon);
                // 赠送记录
                UserSystemCouponGiveRecord giveRecord = userSystemCouponGiveRecordService.getByReceiveId(coupon.getId());
                if (giveRecord == null)
                    return;
                Long giveUid = giveRecord.getGiveUid();
                UserInfo userInfo = userInfoService.selectByPKey(giveUid);
                if (userInfo == null)
                    return;
                String beiZhu = "请到我的-福利中心中查看";
                SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
                MsgOtherCouponActivateDTO msgOther = new MsgOtherCouponActivateDTO();
                msgOther.setTitle("免单券激活");
                msgOther.setType("免单券系统已自动激活");
                msgOther.setExplain("满足" + systemCoupon.getActivateDay() + "天内产生" + activateNum + "笔已到账返利订单");
                msgOther.setGiveUser("昵称:" + userInfo.getNickName() + " ID:" + giveUid);
                msgOther.setReceiveTime(sd.format(giveRecord.getReceiveTime()));
                msgOther.setValidityTime(expiryDay + "天");
                userOtherMsgNotificationService.giveCouponActivateMsg(uid, beiZhu, msgOther);
            } catch (Exception e) {
                e.printStackTrace();
                LogHelper.errorDetailInfo(e);
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandGoodsCaheService.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.service.inter.brand;
import java.util.Date;
import java.util.List;
import com.yeshi.fanli.entity.brand.BrandGoodsCahe;
@@ -24,6 +25,10 @@
     */
    public List<BrandGoodsCahe> getByBrandId(int start, int count, Long brandId);
    public void removeByBrandId(Long brandId);
    /**
     * 统计品牌商品数量
     * @param brandId
@@ -31,4 +36,10 @@
     */
    public long countByBrandId(Long brandId);
    /**
     * 删除之前的
     * @param createTime
     */
    public void removeAgoByDate(Date createTime);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandInfoService.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.service.inter.brand;
import java.util.Date;
import java.util.List;
import org.springframework.web.multipart.MultipartFile;
@@ -104,4 +105,11 @@
    public long countValidByCid(Long cid);
    /**
     * 删除之前的
     * @param date
     */
    public void removeAgoByDate(Date date);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandShopCaheService.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.service.inter.brand;
import java.util.Date;
import java.util.List;
import com.yeshi.fanli.dto.jd.JDShopInfo;
@@ -43,4 +44,15 @@
     */
    public void addBrandShopPDD(BrandInfo brandInfo);
    /**
     * 删除之前的
     * @param createTime
     */
    public void removeAgoByDate(Date createTime);
    public void removeByBrandId(Long brandId);
    public void removeByDateAndType(Long brandId, int type, Date date);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackBalanceService.java
New file
@@ -0,0 +1,48 @@
package com.yeshi.fanli.service.inter.redpack;
import java.math.BigDecimal;
import com.yeshi.fanli.entity.redpack.RedPackBalance;
import com.yeshi.fanli.entity.redpack.RedPackDetail;
import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
public interface RedPackBalanceService {
    /**
     * 查询用户余额信息
     * @param uid
     * @return
     */
    public RedPackBalance selectByPrimaryKey(Long uid);
    /**
     * 获取用户余额
     * @param uid
     * @return
     */
    public BigDecimal getBalance(Long uid);
    /**
     *     添加红包
     * @param uid
     * @param money
     */
    public void addRedPack(Long uid, BigDecimal money);
    /**
     *     添加红包
     * @param uid
     * @param money
     */
    public void addRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException;
    /**
     * 减少红包
     * @param uid
     * @param money
     */
    public void subRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackConfigService.java
New file
@@ -0,0 +1,30 @@
package com.yeshi.fanli.service.inter.redpack;
import java.util.Date;
import com.yeshi.fanli.entity.redpack.RedPackConfig;
public interface RedPackConfigService {
    /**
     * 根据key值查询
     *
     * @param key
     * @return
     */
    public RedPackConfig getByKey(String key);
    /**
     * 根据key值 获取value
     *
     * @param key
     * @return
     */
    public String getValueByKey(String key);
    public RedPackConfig getByKey(String key, Date date);
    public String getValueByKey(String key, Date date);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackDetailService.java
New file
@@ -0,0 +1,63 @@
package com.yeshi.fanli.service.inter.redpack;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.yeshi.fanli.entity.redpack.RedPackDetail;
import com.yeshi.fanli.vo.redpack.RedPackDetailVO;
public interface RedPackDetailService {
    /**
     * 查询明细记录
     * @param uid
     * @param detailId
     * @param maxTime
     * @return
     */
    public List<RedPackDetailVO> listUserMoneyDetailForClient(Long uid, Long detailId, Date maxTime);
    public long countUserMoneyDetailForClient(Long uid, Long detailId, Date maxTime);
    /**
     *  创建明细
     * @param record
     */
    public void insertSelective(RedPackDetail record);
    /**
     * 更新明细
     * @param record
     */
    public void updateByPrimaryKeySelective(RedPackDetail record);
    /**
     * 根据日期类型统计获得金额
     * @param uid
     * @param dateType 1今日 、2昨日、3本月、4上月
     * @return
     */
    public BigDecimal countAddMoneyByDate(long uid, int dateType);
    /**
     * 根据日期类型统计消耗金额
     * @param uid
     * @param dateType 1今日 、2昨日、3本月、4上月
     * @return
     */
    public BigDecimal countUseMoneyByDate(long uid, int dateType);
    /**
     * 根据唯一标识查询
     * @param identifyCode
     * @return
     */
    public RedPackDetail getByIdentifyCode(String identifyCode);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackExchangeService.java
New file
@@ -0,0 +1,79 @@
package com.yeshi.fanli.service.inter.redpack;
import java.math.BigDecimal;
import java.util.List;
import com.yeshi.fanli.entity.common.AdminUser;
import com.yeshi.fanli.entity.redpack.RedPackExchange;
import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
public interface RedPackExchangeService {
    /**
     * 提现转换现金
     * @param uid
     * @param amount
     * @throws RedPackExchangeException
     */
    public void exchangeCash(Long uid, BigDecimal amount) throws RedPackExchangeException;
    /**
     * 后台查询
     * @param start
     * @param count
     * @param key
     * @param state
     * @return
     */
    public List<RedPackExchange> query(Integer start, Integer count, String key, Integer state);
    public Long count(String key, Integer state);
    /**
     * 统计各个状态
     * @param uid
     * @return
     */
    public List<Long> countState(long uid);
    /**
     * 统计各个状态金额
     * @param uid
     * @return
     */
    public List<BigDecimal> countMoneyState(long uid);
    /**
     * 获取申请
     * @param id
     * @return
     */
    public RedPackExchange selectByPrimaryKey(long id);
    /**
     * 提现通过
     * @param id
     * @param admin
     * @throws RedPackExchangeException
     */
    public void passExchange(long id, AdminUser admin) throws RedPackExchangeException;
    /**
     * 提现拒绝
     * @param id
     * @param reason
     * @param admin
     * @throws RedPackExchangeException
     */
    public void rejectExchange(long id, String reason, AdminUser admin) throws RedPackExchangeException;
    /**
     * 统计状态
     * @param uid
     * @param state
     * @return
     */
    public BigDecimal countMoneyByState(Long uid, Integer state);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/redpack/RedPackGiveRecordService.java
New file
@@ -0,0 +1,19 @@
package com.yeshi.fanli.service.inter.redpack;
import java.math.BigDecimal;
import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
public interface RedPackGiveRecordService {
    /**
     * 赠送红包
     * @param uid
     * @param amount
     * @return
     * @throws RedPackGiveRecordException
     */
    public String giving(Long uid, BigDecimal amount) throws RedPackGiveRecordException;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponActivateService.java
New file
@@ -0,0 +1,20 @@
package com.yeshi.fanli.service.inter.user;
public interface UserSystemCouponActivateService {
    /**
     * 更新待激活数量,并返回是否可以激活
     * @param cpid  用户券id
     * @param num   限制数量
     * @return
     */
    public boolean addActivateCount(Long cpid, int num);
    /**
     * 查询满足条件的数量
     * @param id
     * @return
     */
    public int getActivateCount(Long id);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponService.java
@@ -238,7 +238,7 @@
     * @throws UserSystemCouponException
     * @throws Exception
     */
    public List<UserSystemCouponVO> getCouponList(long start, int count, Long uid) throws UserSystemCouponException, Exception;
    public List<UserSystemCouponVO> getCouponList(AcceptData acceptData, long start, int count, Long uid) throws UserSystemCouponException, Exception;
    
    /**
@@ -326,4 +326,10 @@
     */
    public List<UserSystemCoupon> getFreeCouponByType(Long uid, String type);
    /**
     * 激活免单券---订单已到账      TODO 待调用
     * @param uid
     */
    public void activateFreeCoupon(Long uid);
}
fanli/src/main/java/com/yeshi/fanli/util/TimeUtil.java
@@ -102,6 +102,12 @@
        }
        return 0;
    }
    public static String formatDate(Date time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm");
        String date = sdf.format(time);
        return date;
    }
    public static long convertToTimeTemp(String st, String format) {
        Date date = new Date();
fanli/src/main/java/com/yeshi/fanli/util/factory/RedPackDetailFactory.java
New file
@@ -0,0 +1,104 @@
package com.yeshi.fanli.util.factory;
import java.math.BigDecimal;
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.RedPackGiveRecord;
import com.yeshi.fanli.exception.redpack.RedPackDetailException;
import com.yeshi.fanli.util.StringUtil;
public class RedPackDetailFactory {
    /**
     *  红包提现
     *
     * @param extract
     * @return
     */
    public static RedPackDetail createExchange(RedPackExchange exchange) throws RedPackDetailException {
        if (exchange == null)
            throw new RedPackDetailException(1, "提现记录不能为空");
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(false);
        detail.setDesc( "等待人工审核");
        detail.setUid(exchange.getUid());
        detail.setMoney(new BigDecimal("-" + exchange.getMoney()));
        detail.setType(RedPackDetailTypeEnum.redExchange);
        detail.setTitle(RedPackDetailTypeEnum.redExchange.getDesc());
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchange.name() + ":" + exchange.getId()));
        detail.setCreateTime(new Date());
        return detail;
    }
    /**
     *  红包提现通过
     *
     * @param extract
     * @return
     */
    public static RedPackDetail updateExchangePass(Long id, RedPackExchange exchange) throws RedPackDetailException {
        if (id == null)
            throw new RedPackDetailException(1, "明细ID不能为空");
        if (exchange == null)
            throw new RedPackDetailException(1, "提现记录不能为空");
        RedPackDetail detail = new RedPackDetail();
        detail.setId(id);
        detail.setDisplay(true);
        detail.setDesc("请到账户余额中查看");
        detail.setType(RedPackDetailTypeEnum.redExchangePass);
        detail.setTitle(RedPackDetailTypeEnum.redExchangePass.getDesc());
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchangePass.name() + ":" + exchange.getId()));
        return detail;
    }
    /**
     *  红包提现拒绝
     *
     * @param extract
     * @return
     */
    public static RedPackDetail createExchangeReject(RedPackExchange exchange) throws RedPackDetailException {
        if (exchange == null)
            throw new RedPackDetailException(1, "提现记录不能为空");
        // 红包明细- 退回红包
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(false);
        detail.setUid(exchange.getUid());
        detail.setMoney(exchange.getMoney());
        detail.setDesc("红包产生过程中涉嫌违规");
        detail.setTitle(RedPackDetailTypeEnum.redExchangeReject.getDesc());
        detail.setType(RedPackDetailTypeEnum.redExchangeReject);
        detail.setIdentifyCode(StringUtil.Md5(RedPackDetailTypeEnum.redExchangeReject.name() + ":" + exchange.getId()));
        detail.setCreateTime(new Date());
        return detail;
    }
    public static RedPackDetail createGiveOthers(RedPackGiveRecord giveRecord, String desc, RedPackDetailTypeEnum type) throws RedPackDetailException {
        if (giveRecord == null || type == null)
            throw new RedPackDetailException(1, "提现记录、类型不能为空");
        // 红包明细- 退回红包
        RedPackDetail detail = new RedPackDetail();
        detail.setDisplay(true);
        detail.setUid(giveRecord.getGiveUid());
        detail.setMoney(giveRecord.getAmount());
        detail.setDesc(desc);
        detail.setType(type);
        detail.setTitle(type.getDesc());
        detail.setIdentifyCode(StringUtil.Md5(type.name() + ":" + giveRecord.getId()));
        detail.setCreateTime(new Date());
        return detail;
    }
}
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java
@@ -384,6 +384,18 @@
            goodsInfo = loadYuShouInfo(goodsInfo, goods, pid, fanLiRate, shareRate);
        }
        if (Constant.IS_TEST) {
            // 添加标签
            List<ClientTextStyleVO> labels = goodsInfo.getLabels();
            if (labels == null)
                labels = new ArrayList<>();
            labels.add(new ClientTextStyleVO("预售", "#FF2B4E"));
            labels.add(new ClientTextStyleVO("爆款", "#FF2B4E"));
            labels.add(new ClientTextStyleVO("超级划算", "#FF2B4E"));
            goodsInfo.setLabels(labels);
        }
        return goodsInfo;
    }
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/ShopInfoVOFactory.java
@@ -7,6 +7,7 @@
import com.yeshi.fanli.entity.taobao.TaoBaoShop;
import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.vo.goods.ShopInfoVO;
@@ -58,6 +59,12 @@
        } else {
            shopInfoVO.setShopIcon(shop.getShopIcon());
        }
        String shopLink = shop.getShopLink();
        if (StringUtil.isNullOrEmpty(shopLink))
            shopLink = TaoBaoUtil.getShopLink(shop.getId());
        shopInfoVO.setShopLink(shopLink);
        return shopInfoVO;
    }
    
fanli/src/main/java/com/yeshi/fanli/util/mybatishandler/redpack/RedPackDetailTypeEnumHandler.java
New file
@@ -0,0 +1,54 @@
package com.yeshi.fanli.util.mybatishandler.redpack;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
public class RedPackDetailTypeEnumHandler extends BaseTypeHandler<RedPackDetailTypeEnum> {
    @Override
    public RedPackDetailTypeEnum getNullableResult(ResultSet arg0, String arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            return RedPackDetailTypeEnum.valueOf(key);
        }
    }
    @Override
    public RedPackDetailTypeEnum getNullableResult(ResultSet arg0, int arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            // 根据数据库中的key值,定位SexEnum子类
            return RedPackDetailTypeEnum.valueOf(key);
        }
    }
    @Override
    public RedPackDetailTypeEnum getNullableResult(CallableStatement arg0, int arg1) throws SQLException {
        String key = arg0.getString(arg1);
        if (arg0.wasNull()) {
            return null;
        } else {
            // 根据数据库中的key值,定位SexEnum子类
            return RedPackDetailTypeEnum.valueOf(key);
        }
    }
    @Override
    public void setNonNullParameter(PreparedStatement arg0, int arg1, RedPackDetailTypeEnum arg2, JdbcType arg3)
            throws SQLException {
        arg0.setString(arg1, arg2.name());
    }
}
fanli/src/main/java/com/yeshi/fanli/vo/goods/SpikeTimeVO.java
New file
@@ -0,0 +1,50 @@
package com.yeshi.fanli.vo.goods;
import com.google.gson.annotations.Expose;
public class SpikeTimeVO {
    // 显示时间
    @Expose
    private String time;
    // 状态
    @Expose
    private String state;
    // 选中
    @Expose
    private boolean checked;
    @Expose
    private String requestTime;
    public String getTime() {
        return time;
    }
    public void setTime(String time) {
        this.time = time;
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
    public boolean isChecked() {
        return checked;
    }
    public void setChecked(boolean checked) {
        this.checked = checked;
    }
    public String getRequestTime() {
        return requestTime;
    }
    public void setRequestTime(String requestTime) {
        this.requestTime = requestTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/vo/msg/ClientTextStyleVO.java
@@ -17,6 +17,9 @@
    private String bottomColor;
    @Expose
    private String img;
    @Expose
    private String fontSize = "1"; // 字体倍数
    public ClientTextStyleVO(String content, String color) {
        this.content = content;
@@ -74,4 +77,12 @@
    public void setBottomColor(String bottomColor) {
        this.bottomColor = bottomColor;
    }
    public String getFontSize() {
        return fontSize;
    }
    public void setFontSize(String fontSize) {
        this.fontSize = fontSize;
    }
}
fanli/src/main/java/com/yeshi/fanli/vo/redpack/RedPackDetailVO.java
New file
@@ -0,0 +1,35 @@
package com.yeshi.fanli.vo.redpack;
import java.io.Serializable;
import com.google.gson.annotations.Expose;
import com.yeshi.fanli.entity.redpack.RedPackDetail;
public class RedPackDetailVO implements Serializable{
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    @Expose
    private RedPackMonthVO month;
    @Expose
    private RedPackDetail detail;
    public RedPackMonthVO getMonth() {
        return month;
    }
    public void setMonth(RedPackMonthVO month) {
        this.month = month;
    }
    public RedPackDetail getDetail() {
        return detail;
    }
    public void setDetail(RedPackDetail detail) {
        this.detail = detail;
    }
}
fanli/src/main/java/com/yeshi/fanli/vo/redpack/RedPackMonthVO.java
New file
@@ -0,0 +1,72 @@
package com.yeshi.fanli.vo.redpack;
import java.io.Serializable;
import com.google.gson.annotations.Expose;
public class RedPackMonthVO implements Serializable{
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    @Expose
    private int year;// 年份
    @Expose
    private int month;// 月
    @Expose
    private String expend;// 支出
    @Expose
    private String income;// 收入
    private String dateFormate;
    public String getDateFormate() {
        return dateFormate;
    }
    public void setDateFormate(String dateFormate) {
        this.dateFormate = dateFormate;
    }
    public RedPackMonthVO(int year, int month) {
        this.year = year;
        this.month = month;
    }
    public RedPackMonthVO() {
    }
    public int getYear() {
        return year;
    }
    public void setYear(int year) {
        this.year = year;
    }
    public int getMonth() {
        return month;
    }
    public void setMonth(int month) {
        this.month = month;
    }
    public String getExpend() {
        return expend;
    }
    public void setExpend(String expend) {
        this.expend = expend;
    }
    public String getIncome() {
        return income;
    }
    public void setIncome(String income) {
        this.income = income;
    }
}
fanli/src/main/resource/ehcache.xml
@@ -268,5 +268,11 @@
        timeToLiveSeconds="1800" overflowToDisk="true"
        memoryStoreEvictionPolicy="LRU" />
        <!-- 红包缓存缓存 -->
    <cache name="redpackCache" maxElementsInMemory="1000"
        maxElementsOnDisk="10000" eternal="false" timeToIdleSeconds="1800"
        timeToLiveSeconds="1800" overflowToDisk="true"
        memoryStoreEvictionPolicy="LRU" />
</ehcache>
fanli/src/main/resource/env-dev/constant.properties
@@ -1,3 +1,3 @@
task =false
outnetwork =false
test =false
test =true
fanli/src/test/java/org/fanli/MyBatisProduce.java
@@ -4,23 +4,21 @@
import org.yeshi.utils.mybatis.ColumnParseUtil;
import org.yeshi.utils.mybatis.MyBatisMapperUtil;
import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap;
import com.yeshi.fanli.entity.elme.ElmeOrder;
import com.yeshi.fanli.entity.push.DeviceActive;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.order.HongBaoV2SettleTemp;
//@Ignore
public class MyBatisProduce {
    @Test
    public void test3() {
        MyBatisMapperUtil.createMapper(ElmeOrder.class);
        MyBatisMapperUtil.createMapper(ElmeHongBaoOrderMap.class);
        MyBatisMapperUtil.createMapper(HongBaoV2SettleTemp.class);
    }
    @Test
    public void test1() {
        ColumnParseUtil.parseColumn(DeviceActive.class,
                "D:\\workspace\\fanli\\fanli-server\\fanli\\src\\main\\java\\com\\yeshi\\fanli\\mapping\\push\\DeviceActiveMapper.xml");
        ColumnParseUtil.parseColumn(HongBaoV2.class,
                "D:\\workspace\\fanli\\fanli-server\\fanli\\src\\main\\java\\com\\yeshi\\fanli\\mapping\\hongbao\\HongBaoV2Mapper.xml");
    }
}
fanli/src/test/java/org/fanli/TaoKeTest.java
@@ -49,26 +49,18 @@
    @Test
    public void test1() {
        System.out.println(TaoBaoUtil.filterTaoToken("¥RuPdYM9Knxe¥"));
        String url = TaoKeApiUtil.officialActivityConvert("19507100253", "1539329391766", "20211660");
        System.out.println(TaoBaoUtil.filterTaoToken(TaoKeApiUtil.getTKToken(
                "http://ec-1255749512.file.myqcloud.com/img/FloatAD/a43fdefe735c41f4955a261d43870ff8.png", "淘口令",
                url)));
    }
    @Test
    public void test2() {
        String link = TaoKeApiUtil.officialActivityConvert("87140050199", "1571120794546", "20211660");
        System.out.println(TaoKeApiUtil.getTKToken("http://","母婴预售",link));
        //https://s.click.taobao.com/t?e=m%3D2%26s%3DW%2Fys7R71JXMcQipKwQzePCperVdZeJviyK8Cckff7TVRAdhuF14FMXC%2FEJQELlNo5x%2BIUlGKNpVpS9y0ojX%2FfMsvmRQfeMsreH9%2FasRClvq63GoCXmcqkTiRUN2xVR4GdesO8XD8dsNdITvXwTxvKDqJgCOacH%2BU%2FVJqtNeEg5OOvkjnk315zzvflh4%2Fhqj8BmyXDtEFdgwjGkouqJtJeds5wF0j1Yhhp1953%2FcnpLUV6UUID4c8TeTEWJdP8jmRdTEuB5K8MGvkLv1nNhnYz%2FB0z8qlrv%2Bjr%2B%2FiM5RbEEle7auY0HPYWszlTEcWhO9mli2vZjCuAmyG1kYtrC7hgcEnE%2FQxigjMfFc2hYciEyAdpuz3kb9JWJVVX36lFeRKtwLUkdbL0syg%2BG8%2FlCRQJ1YlOPkYHNIul3paqKYwK75NNUki5Nwcg2GYz3Bez8Z8OusR9%2BDFlSU%2BcenL13XDY2hrrfx7OMbmkUtLKDKbz1CCoC2zoKs%2FmnEqY%2Bakgpmw&pvid=24980167&union_lens=lensId:0b013a8d_0cec_16df214d979_38a1
        TaoBaoGoodsBrief goods = null;
        try {
            goods = TaoKeApiUtil.searchGoodsDetail(601535036423L);
            // goods = TaoKeApiUtil.searchGoodsDetail(601535036423L, new
            // TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY,
            // TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
            // TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
        } catch (TaobaoGoodsDownException e2) {
            e2.printStackTrace();
        }
        System.out.println(goods);
        // goods = TaoKeApiUtil.searchGoodsDetail(auctionId);
    }
    @Test
utils/src/main/java/org/yeshi/utils/entity/wx/RedPackRecord.java
@@ -9,7 +9,7 @@
 */
public class RedPackRecord {
    // openId
    @CsvBindByName(column = "用户openid", required = true)
    @CsvBindByName(column = "用户openid")
    private String openId;
    // 交易订单号
    @CsvBindByName(column = "商户订单号")
utils/src/main/java/org/yeshi/utils/wx/WXRedPackUtil.java
New file
@@ -0,0 +1,74 @@
package org.yeshi.utils.wx;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.yeshi.utils.entity.wx.RedPackRecord;
public class WXRedPackUtil {
    public static List<RedPackRecord> readCsv(InputStream inStream) throws Exception {
        List<RedPackRecord> list = new ArrayList<RedPackRecord>();
        RedPackRecord record = null;
        BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, "GBK"));
        // 换成你的文件名
        // BufferedReader reader=new BufferedReader(new InputStreamReader(new
        // FileInputStream(path),"GBK"));
        String line = null;
        // 第一行信息,为标题信息,不用,如果需要,注释掉
        reader.readLine();
        while ((line = reader.readLine()) != null) {
            // CSV格式文件为逗号分隔符文件,这里根据逗号切分
            String item[] = line.split(",");
            // 用户openid
            String openId = getValue(item, 3);
            if (openId == null || openId.trim().length() == 0)
                break;
            record = new RedPackRecord();
            record.setOpenId(openId);
            record.setSendTime(getCsvDate(getValue(item, 0))); // 发送时间
            record.setDetailno(getValue(item, 10)); // 红包订单号
            record.setBillno(getValue(item, 11)); // 商户订单号
            String status = getValue(item, 6);
            if (status != null && status.trim().length() > 0) {
                record.setStatus(status);
                if ("已领取".equals(status)) {
                    record.setRcvTime(getCsvDate(getValue(item, 7)));
                } else if ("过期未领退款".equals(status)) {
                    record.setRcvTime(getCsvDate(getValue(item, 8)));
                }
            }
            list.add(record);
        }
        return list;
    }
    public static String getValue(String[] item, int index) {
        if (item != null && item.length > index) {
            String value = item[index];
            return value;
        }
        return null;
    }
    public static String getCsvDate(String item) throws Exception {
        if (item == null || item.trim().length() == 0)
            return null;
        if (item.indexOf("/") > 0) {
            item = item.replaceAll("/", "-");
        } else if (item.indexOf("年") > 0) {
            item = item.replaceAll("年", "-").replaceAll("月", "-").replaceAll("日", "");
        }
        return item;
    }
}