yujian
2019-08-21 b0d445fda153e5dac63ad66c8b74191601f0a4ef
兑换免单券 提示语修改
7个文件已修改
85 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/IntegralExchangeRecordMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralExchangeRecordMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeRecordServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/integral/IntegralExchangeRecordService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java
@@ -407,6 +407,7 @@
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
        }
    }
    /**
     * 兑换金币
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/IntegralExchangeRecordMapper.java
@@ -13,6 +13,6 @@
     * @param list
     * @return
     */
    long countRecordByUid(@Param("exchangeId") Long exchangeId, @Param("uid") Long uid);
    long countRecordByUid(@Param("exchangeId") Long exchangeId, @Param("uid") Long uid, @Param("today") Integer today);
    
}
fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralExchangeRecordMapper.xml
@@ -39,6 +39,7 @@
  
  <select id="countRecordByUid" resultType="Long">
      SELECT IFNULL(COUNT(er_id),0) FROM yeshi_ec_integral_exchange_record
    WHERE er_uid = #{uid} AND er_exchange_id = #{exchangeId} AND TO_DAYS(er_create_time) = TO_DAYS(NOW())
    WHERE er_uid = #{uid} AND er_exchange_id = #{exchangeId}
        <if test="today = 1">AND TO_DAYS(er_create_time) = TO_DAYS(NOW())</if>
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeRecordServiceImpl.java
@@ -66,7 +66,7 @@
            Long id = exchange.getId();
            if (type == ExchangeTypeEnum.freeCouponBuy) {
                // 注:因自购免单券,一个用户只能兑换一次,则当前用户一旦兑换成功,自购免单券兑换入口永久在当前用户金币兑换列表中消失。
                long num = integralExchangeRecordMapper.countRecordByUid(id, uid);
                long num = integralExchangeRecordMapper.countRecordByUid(id, uid, null);
                if (num >= 1) {
                    listValid.remove(i);
                    i --;
@@ -100,7 +100,7 @@
                continue;
            
            // 今日兑换情况
            long num = integralExchangeRecordMapper.countRecordByUid(id, uid);
            long num = integralExchangeRecordMapper.countRecordByUid(id, uid, null);
            Integer upperLimit = exchange.getUpperLimit();
            if (upperLimit == null) {
                progress = progress.replace("{已兑换}", num + "").replace("/{上限数}", "");
@@ -113,8 +113,8 @@
    }
    
    @Override
    public long countRecordByUid(long exchangeid, Long uid){
        return integralExchangeRecordMapper.countRecordByUid(exchangeid, uid);
    public long countRecordByUid(long exchangeid, Long uid, Integer today){
        return integralExchangeRecordMapper.countRecordByUid(exchangeid, uid, today);
    }
    
    @Override
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java
@@ -21,6 +21,7 @@
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.exception.integral.IntegralExchangeException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
import com.yeshi.fanli.service.inter.integral.CodePublishRecordService;
import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService;
@@ -45,6 +46,9 @@
    
    @Resource
    private IntegralExchangeMapper integralExchangeMapper;
    @Resource
    private ConfigService configService;
    
    @Resource
    private UserInfoExtraService userInfoExtraService;
@@ -111,15 +115,22 @@
        exchangeTip.setId(id);
        ExchangeTypeEnum type = exchange.getType();
        if (ExchangeTypeEnum.inviteCodeActivate == type) {
            //exchangeTip.setTip("注:兑换成功后请到“消息-系统消息”查看");
            //exchangeTip.setGoldCoin(goldCoin + "金币");
            exchangeTip.setType(type.name());
            return exchangeTip;
        }
        
        long exchangeCount = 0;
        if (ExchangeTypeEnum.freeCouponBuy == type) {
            exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, null);
            if (exchangeCount >= 1) {
                throw new IntegralExchangeException(1, "自购免单券,仅能兑换一次");
            }
        }
        Integer upperLimit = exchange.getUpperLimit();
        if (upperLimit != null) { // 是否有限制每日次数
            long exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid);
            Integer today = 1;
            exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, today);
            if (exchangeCount >= upperLimit) {
                throw new IntegralExchangeException(1, "今日兑换已达上限");
            }
@@ -175,12 +186,22 @@
        if (exchange == null)
            throw new IntegralExchangeException(1, "兑换方式不存在");
        ExchangeTypeEnum type = exchange.getType();
        long exchangeCount = 0;
        if (ExchangeTypeEnum.freeCouponBuy == type) {
            exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, null);
            if (exchangeCount >= 1) {
                throw new IntegralExchangeException(1, "自购免单券,仅能兑换一次");
            }
        }
        Integer upperLimit = exchange.getUpperLimit();
        if (upperLimit != null) {  // 是否有限制每日次数
            exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid);
            Integer today = 1;
            exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, today);
            if (exchangeCount >= upperLimit) {
                throw new IntegralExchangeException(1, "今日兑换已达上限");
                throw new IntegralExchangeException(1, "兑换已达上限");
            }
        }
        
@@ -191,17 +212,22 @@
        }
        
        String thing = "";
        int couponNews = 0;
        try {
            ExchangeTypeEnum type = exchange.getType();
            if (ExchangeTypeEnum.freeCouponBuy == type) {
                thing = "自购免单券";
                userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, null);
                couponNews = 1;
            } else if (ExchangeTypeEnum.freeCouponGive == type) {
                thing = "赠送免单券";
                userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, null);
                couponNews = 1;
            } else if (ExchangeTypeEnum.rebatePercentCoupon == type) {
                thing = "奖励免单券";
                userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(10));
                String percent = configService.get("exchange_rebate_percent");
                userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent));
                couponNews = 1;
            } else if (ExchangeTypeEnum.inviteCodePublish == type) {
                thing = "邀请码发布卡";
                if(codePublishRecordService.countValidRecord(uid) > 0)
@@ -244,10 +270,14 @@
            int surplus = goldCoinHas.intValue() - goldCoin.intValue();
            exchange.setUserGoldCoin(surplus + "枚");
            
            // 更新金币
            // 更新金币 + 福利中心消息数
            if (extraVO.getCouponNews() != null && extraVO.getCouponNews() > 0)
                couponNews = couponNews + extraVO.getCouponNews();
            UserInfoExtraVO extraUpdate = new UserInfoExtraVO();
            extraUpdate.setId(extraVO.getId());
            extraUpdate.setGoldCoin(surplus);
            extraUpdate.setCouponNews(couponNews);
            userInfoExtraService.saveUserInfoExtra(extraUpdate);
            
            // 添加兑换记录
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -1,7 +1,6 @@
package com.yeshi.fanli.service.impl.user;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -1268,31 +1267,9 @@
            UserSystemCoupon userSystemCoupon = couponRecord.getUserSystemCoupon();
            int expiryDay = 15;
            SystemCoupon systemCoupon = userSystemCoupon.getSystemCoupon();
            SystemCoupon coupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId());
            if (coupon != null) {
                expiryDay = coupon.getExpiryDay();
            }
            // 结束日期
            Date endTime = null;
            try {
                // 今天在内  减去一天
                String endDay = DateUtil.plusDay(expiryDay - 1, new Date());
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                endTime = format.parse(endDay);
            } catch (ParseException e) {
                e.printStackTrace();
            }
            // 状态初始化
            userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
            userSystemCoupon.setUseTime(null);
            // 有效期时间重新定义
            userSystemCoupon.setStartTime(new Date());
            userSystemCoupon.setEndTime(endTime);
            userSystemCoupon.setUpdateTime(new Date());
            userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
        }
fanli/src/main/java/com/yeshi/fanli/service/inter/integral/IntegralExchangeRecordService.java
@@ -21,7 +21,7 @@
     * @param uid
     * @return
     */
    public long countRecordByUid(long exchangeid, Long uid);
    public long countRecordByUid(long exchangeid, Long uid, Integer today);
    /**
     * 添加兑换记录