admin
2019-09-29 6f14a131b39c8fc44b29b6130c4e2002bbf2d3ca
返利奖励券H5接口增加
7个文件已修改
109 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5CouponController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/jd/JDOrderItemMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralExchangeServiceImpl.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/integral/IntegralExchangeRecordService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/integral/IntegralExchangeService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5CouponController.java
@@ -16,11 +16,13 @@
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.lable.QualityFactory;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.exception.taobao.TaoKeApiException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
@@ -46,6 +48,9 @@
    @Resource
    private UserSystemCouponService userSystemCouponService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @RequestMapping("getMianDanGoodsList")
    public void getMianDanGoodsList(AcceptData acceptData, PrintWriter out, int page, int pageSize, String callback) {
@@ -166,6 +171,8 @@
        }
        // 获取免单券数量
        long couponCount = userSystemCouponService.countUsableRewardCoupon(uid);
        UserInfoExtra extraInfo=userInfoExtraService.getUserInfoExtra(uid);
        long integralCount=extraInfo!=null?extraInfo.getGoldCoin():0L;
        JSONObject userJson = new JSONObject();
        userJson.put("nickName", user.getNickName());
        userJson.put("portrait", user.getPortrait());
@@ -174,6 +181,7 @@
        JSONObject data = new JSONObject();
        data.put("user", userJson);
        data.put("couponCount", couponCount);
        data.put("integralCount", integralCount);
        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
    }
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java
@@ -392,6 +392,28 @@
        out.print(JsonUtil.loadTrueResult(data));
    }
    @RequestMapping(value = "getExchangeDetail")
    public void getExchangeDetail(AcceptData acceptData, Long id, String callback, PrintWriter out) {
        if (id == null || id <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "兑换ID有误"));
            return;
        }
        IntegralExchange exchange = integralExchangeService.selectByPrimaryKey(id);
        if (exchange != null) {
            GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
            Gson gson = gsonBuilder.create();
            if (StringUtil.isNullOrEmpty(callback))
                out.print(JsonUtil.loadTrueResult(gson.toJson(exchange)));
            else
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(gson.toJson(exchange))));
        } else {
            if (StringUtil.isNullOrEmpty(callback))
                out.print(JsonUtil.loadFalseResult("未找到"));
            else
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未找到")));
        }
    }
    /**
     * 兑换金币检验
     * 
@@ -400,8 +422,8 @@
     * @param id
     * @param out
     */
    @RequestMapping(value = "verifyExchange", method = RequestMethod.POST)
    public void verifyExchange(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
    @RequestMapping(value = "verifyExchange")
    public void verifyExchange(AcceptData acceptData, Long uid, Long id, String callback, PrintWriter out) {
        try {
            ExchangeTipVO exchange = integralExchangeService.verifyExchange(uid, id);
@@ -409,9 +431,17 @@
            Gson gson = gsonBuilder.create();
            JSONObject data = new JSONObject();
            data.put("result", gson.toJson(exchange));
            if (StringUtil.isNullOrEmpty(callback)) {
            out.print(JsonUtil.loadTrueResult(data));
            } else {
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
            }
        } catch (IntegralExchangeException e) {
            if (StringUtil.isNullOrEmpty(callback)) {
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
            } else {
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, e.getMsg())));
            }
        }
    }
@@ -424,8 +454,8 @@
     * @param out
     */
    @RequestSerializableByKey(key = "'integralexchange-'+#uid")
    @RequestMapping(value = "exchange", method = RequestMethod.POST)
    public void exchange(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
    @RequestMapping(value = "exchange")
    public void exchange(AcceptData acceptData, Long uid, Long id, String callback, PrintWriter out) {
        try {
            IntegralExchange exchange = integralExchangeService.exchange(uid, id);
@@ -437,9 +467,15 @@
            JSONObject data = new JSONObject();
            data.put("result", gson.toJson(exchange));
            data.put("goldCoin", extraVO.getGoldCoin() + "枚");
            if (StringUtil.isNullOrEmpty(callback))
            out.print(JsonUtil.loadTrueResult(data));
            else
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
        } catch (IntegralExchangeException e) {
            if (StringUtil.isNullOrEmpty(callback))
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
            else
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, e.getMsg())));
        }
    }
fanli/src/main/java/com/yeshi/fanli/mapping/jd/JDOrderItemMapper.xml
@@ -272,7 +272,7 @@
    <select id="countOrderNumber" resultType="java.util.HashMap">
        SELECT IFNULL(COUNT(`joi_id`),0) AS showValue,
        <include refid="Column_DateType" />
        FROM `yeshi_ec_jd_order_item` left join yeshi_ec_jd_order on jo_order_id=joi_order_id  WHERE jo_order_time IS NOT NULL
        FROM `yeshi_ec_jd_order_item` left join yeshi_ec_jd_order on jo_order_id=joi_order_id  WHERE jo_order_time IS NOT NULL and joi_valid_code!=2
        <include refid="Count_Select_DateType" />
        <include refid="Count_Group_DateType" />
        ORDER BY jo_order_time
fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralExchangeServiceImpl.java
@@ -86,6 +86,10 @@
    @Resource
    private IntegralDetailService integralDetailService;
    
    @Override
    public IntegralExchange selectByPrimaryKey(Long id) {
        return integralExchangeMapper.selectByPrimaryKey(id);
    }
    @Override
    public List<IntegralExchange> listValidCache(long start, int count){
@@ -96,7 +100,6 @@
    public Long countValid(){
        return integralExchangeMapper.countValid();
    }
    
    @Override
    public ExchangeTipVO verifyExchange(Long uid, Long id) throws IntegralExchangeException{
@@ -117,7 +120,6 @@
        Integer state = exchange.getState();
        if (state == null || state != 1)
            throw new IntegralExchangeException(1, "兑换活动未开启");
        
        Integer goldCoin = exchange.getGoldCoin();
        
@@ -230,25 +232,29 @@
        boolean once = false; // 兑换一次是否消失
        try {
            if (ExchangeTypeEnum.freeCouponBuy == type) {
                List<UserSystemCoupon> listCoupon = userSystemCouponService.getFreeCouponByType(uid, CouponTypeEnum.freeCouponBuy.name());
                List<UserSystemCoupon> listCoupon = userSystemCouponService.getFreeCouponByType(uid,
                        CouponTypeEnum.freeCouponBuy.name());
                if (listCoupon != null && listCoupon.size() > 0)
                    throw new IntegralExchangeException(1, "自购免单券,仅能兑换一次");
                
                thing = "自购免单券";
                thingNum = "1张";
                userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponBuy.name(), UserSystemCoupon.SOURCE_EXCHANGE, null);
                userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponBuy.name(),
                        UserSystemCoupon.SOURCE_EXCHANGE, null);
                once = true; 
                couponNews = 1;
            } else if (ExchangeTypeEnum.freeCouponGive == type) {
                thing = "赠送免单券";
                thingNum = "1张";
                userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponGive.name(), UserSystemCoupon.SOURCE_EXCHANGE, null);
                userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponGive.name(),
                        UserSystemCoupon.SOURCE_EXCHANGE, null);
                couponNews = 1;
            } else if (ExchangeTypeEnum.rebatePercentCoupon == type) {
                thing = "返利奖励券";
                thingNum = "1张";
                String percent = configService.get("exchange_rebate_percent");
                userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent));
                userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(),
                        UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent));
                couponNews = 1;
            } else if (ExchangeTypeEnum.inviteCodePublish == type) {
                thing = "邀请码发布卡";
@@ -292,7 +298,8 @@
            exchangeCount ++;
            String progress = exchange.getProgress();
            if (!StringUtil.isNullOrEmpty(progress))
                progress = progress.replace("{已兑换}",exchangeCount + "").replace("{上限数}", exchange.getUpperLimit() + "");
                progress = progress.replace("{已兑换}", exchangeCount + "").replace("{上限数}",
                        exchange.getUpperLimit() + "");
            exchange.setProgress(progress);
            
            // 剩余金币
@@ -346,7 +353,6 @@
        }
    }
    
    @Override
    public ExchangeTipVO verifyInviteCode(Long uid, Long id) throws IntegralExchangeException{
        if (uid == null || uid <= 0)
@@ -387,7 +393,6 @@
        return exchangeTip;
    }
    
    @Override
    public String exchangeInviteCode(Long uid, Long id) throws IntegralExchangeException {
        if (uid == null || uid <= 0)
@@ -415,7 +420,6 @@
        Integer goldCoinHas = extraVO.getGoldCoin();
        if (goldCoin.intValue() > goldCoinHas.intValue())
            throw new IntegralExchangeException(1, "当前账户中可用金币不足,无法兑换该奖品!");
        
        try {
            UserInfoExtraVO inviteExtra = userInfoExtraService.getInfoExtraVOByUid(record.getUid());
@@ -470,4 +474,5 @@
            throw new IntegralExchangeException(1, "兑换失败");
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/integral/IntegralExchangeRecordService.java
@@ -14,6 +14,7 @@
     * @return
     */
    public List<IntegralExchange> listExchange(long start, int count, Long uid);
    /**
     * 今日任务统计
fanli/src/main/java/com/yeshi/fanli/service/inter/user/integral/IntegralExchangeService.java
@@ -7,6 +7,13 @@
import com.yeshi.fanli.vo.integral.ExchangeTipVO;
public interface IntegralExchangeService {
    /**
     * 根据主键查询
     * @param id
     * @return
     */
    public IntegralExchange selectByPrimaryKey(Long id);
    /**
     * 查询有效的
fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -791,11 +791,14 @@
                    Map<String, Order> map = PlaceOrderCMQManager.getInstance()
                            .consumeQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL, 16);
                    if (map != null) {
                        // 是否是首单
                        for (Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
                            try {
                                String key = its.next();
                                Order order = map.get(key);
                                // 是否是首单
                                if (isFirstValidOrder(order.getOrderId(), order.getOrderType(),
                                        order.getUserInfo().getId())) {
                                // 统计订单下的用户所获得的返利金额
                                List<CommonOrder> list = commonOrderService
                                        .listBySourceTypeAndOrderId(order.getOrderType(), order.getOrderId());
@@ -837,8 +840,8 @@
                                    // 获取上两级数据
                                    UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId());
                                    if (boss != null) {// 判断上级的红包
                                        if (hongBaoMoney.get(boss.getId()) == null
                                                || hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
                                            if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId())
                                                    .compareTo(new BigDecimal("0")) <= 0) {
                                            // 补偿金币
                                            integralTaskRecordService.firstSharerOrderRewardBoss(boss.getId(),
                                                    order.getUserInfo().getId(), null);
@@ -848,8 +851,8 @@
                                } else {// 自购订单
                                    UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId());
                                    if (boss != null) {// 判断上级的红包
                                        if (hongBaoMoney.get(boss.getId()) == null
                                                || hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
                                            if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId())
                                                    .compareTo(new BigDecimal("0")) <= 0) {
                                            // 补偿金币1级
                                            integralTaskRecordService.firstRebateOrderRewardBoss(boss.getId(),
                                                    order.getUserInfo().getId(), null);
@@ -857,11 +860,12 @@
                                        boss = threeSaleSerivce.getBoss(boss.getId());
                                        if (boss != null) {// 判断上级的红包
                                            if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId())
                                                    .compareTo(new BigDecimal("0")) <= 0) {
                                                if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney
                                                        .get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
                                                // 补偿金币2级
                                                integralTaskRecordService.firstRebateOrderRewardBossSuper(boss.getId(),
                                                        order.getUserInfo().getId(), null);
                                                    integralTaskRecordService.firstRebateOrderRewardBossSuper(
                                                            boss.getId(), order.getUserInfo().getId(), null);
                                                }
                                            }
                                        }
                                    }