From 9f09e749e7198051b9af6c2421336a80b58b79a4 Mon Sep 17 00:00:00 2001 From: 喻健 <喻健@Admin> Date: 星期三, 19 十二月 2018 16:33:12 +0800 Subject: [PATCH] 当日提现成功超过100元 返回高危标识 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java | 105 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 88 insertions(+), 17 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java index 94a1890..2d3f951 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java @@ -1,5 +1,6 @@ package com.yeshi.fanli.service.impl.user; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -19,15 +20,20 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.yeshi.fanli.dao.mybatis.user.UserGoodsStorageMapper; +import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum; import com.yeshi.fanli.entity.bus.user.UserGoodsStorage; import com.yeshi.fanli.entity.goods.CommonGoods; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.exception.goods.CommonGoodsException; +import com.yeshi.fanli.exception.share.UserShareGoodsRecordException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.exception.user.UserGoodsStorageException; +import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.goods.CommonGoodsService; import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; import com.yeshi.fanli.service.inter.user.UserGoodsStorageService; +import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService; +import com.yeshi.fanli.util.MoneyBigDecimalUtil; import com.yeshi.fanli.util.RedisManager; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.factory.CommonGoodsFactory; @@ -43,6 +49,9 @@ private RedisManager redisManager; @Resource + private ConfigService configService; + + @Resource private CommonGoodsService commonGoodsService; @Resource @@ -50,6 +59,11 @@ @Resource private UserGoodsStorageMapper userGoodsStorageMapper; + + @Resource + private UserShareGoodsRecordService userShareGoodsRecordService; + @Resource + private HongBaoManageService hongBaoManageService; @Override public int deleteByPrimaryKey(Long id) { @@ -115,6 +129,11 @@ @Override public long countQueryByUid(Long uid) { return userGoodsStorageMapper.countQueryByUid(uid); + } + + @Override + public void updateShareState(Long shareId) { + userGoodsStorageMapper.updateShareState(shareId); } @Override @@ -193,13 +212,10 @@ long nd = 1000 * 24 * 60 * 60; List<CommonGoods> listUpadteCommonGoods = new ArrayList<CommonGoods>(); + BigDecimal rate = manageService.getFanLiRate(); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); - Map<String, String> map = manageService.convertMap(); - String proportion = map.get("hongbao_goods_proportion"); - String fcRate = map.get("hongbao_fc_ratio"); - for (UserGoodsStorage userGoodsStorage : listStorage) { CommonGoods commonGoods = userGoodsStorage.getCommonGoods(); @@ -217,20 +233,28 @@ if (goodsState != null && (goodsState != 1 || !goodsState.equals(1))) { Date updateTime = commonGoods.getUpdateTime(); if (updateTime != null) { - long diff = nowDate.getTime() - updateTime.getTime(); // 璁$畻宸灏戝皬鏃� + long diff = nowDate.getTime() - updateTime.getTime(); + long day = diff / nd; long hour = diff % nd / nh; - if (hour > 1 ) { + if (hour > 1 || day > 0 ) { try { if (commonGoods.getGoodsType() == CommonGoods.GOODS_TYPE_TB) { goodsBrief = redisManager.getTaoBaoGoodsBrief(commonGoods.getGoodsId()); - goodsBrief.setState(0); + goodsState = 0; + goodsBrief.setState(goodsState); + + CommonGoods upadeteCommonGoods = CommonGoodsFactory.create(goodsBrief); + upadeteCommonGoods.setState(goodsState); + upadeteCommonGoods.setId(commonGoods.getId()); + listUpadteCommonGoods.add(upadeteCommonGoods); } } catch (TaobaoGoodsDownException e) { // 宸蹭笅鏋� goodsState = 1; - commonGoods.setState(1); + commonGoods.setState(goodsState); + listUpadteCommonGoods.add(commonGoods); e.printStackTrace(); } } @@ -239,27 +263,23 @@ if (goodsBrief == null) { goodsBrief = TaoBaoUtil.convert(commonGoods); - } else { - CommonGoods upadeteCommonGoods = CommonGoodsFactory.create(goodsBrief); - upadeteCommonGoods.setState(goodsState); - listUpadteCommonGoods.add(upadeteCommonGoods); - } + } // 鍒ゆ柇鏄惁宸插垎浜� Integer state = userGoodsStorage.getState(); int shared = UserGoodsStorage.STATE_SHARED; if (state != null && (state == shared || state.equals(shared))) { - if (goodsState != 1 || goodsState.equals(1)) { + if (goodsState != 1 || !goodsState.equals(1)) { goodsBrief.setState(2); // 宸插垎浜姸鎬� } } // 鏀瑰彉鍥剧墖灏哄 - String pictUrl = commonGoods.getPicture(); + String pictUrl = goodsBrief.getPictUrl(); if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) { - commonGoods.setPicture(TbImgUtil.getTBSize320Img(pictUrl)); + goodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl)); } - String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, fcRate, null)); + String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, rate.toString(), null)); dataObject.put("storageId", userGoodsStorage.getId()); dataObject.put("goods", json); @@ -297,4 +317,55 @@ } return state; } + + @Override + public JSONObject shareGoods(Long uid, List<Long> listStorageID) + throws UserGoodsStorageException, UserShareGoodsRecordException { + + List<UserGoodsStorage> listStorage = userGoodsStorageMapper.listQueryByIds(listStorageID); + if (listStorage == null || listStorage.size() == 0) { + throw new UserGoodsStorageException(1, "閫夊搧搴撳晢鍝佷笉瀛樺湪"); + } + + + List<UserGoodsStorage> listResult = new ArrayList<UserGoodsStorage>(); + // 杩樺師椤哄簭 鐢ㄤ簬鍒跺浘 + for (Long sid: listStorageID) { + for (UserGoodsStorage torage: listStorage) { + Long id = torage.getId(); + if (sid == id || sid.equals(id)) { + listResult.add(torage); + break; + } + } + } + + + BigDecimal totalMoney = new BigDecimal(0.00); + List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>(); + + String rateStr = hongBaoManageService.get("hongbao_goods_proportion"); + + for (UserGoodsStorage userGoodsStorage: listResult) { + CommonGoods commonGoods = userGoodsStorage.getCommonGoods(); + TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods); + listGoodsBrief.add(goodsBrief); + + BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goodsBrief, new BigDecimal(rateStr)); + totalMoney = MoneyBigDecimalUtil.add(totalMoney, money); + } + + String revenue = listGoodsBrief.size() + "涓晢鍝侀浼板垎浜閲戯細楼"+totalMoney; + + Map<String,Object> map = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.storage, + null, listGoodsBrief); + + JSONObject data = new JSONObject(); + data.put("revenue", revenue); + data.put("shareId", map.get("shareId")); + data.put("shareImg", map.get("loadResult")); + data.put("notifyDesc", configService.get("goods_share_multiple_notify")); + + return data; + } } -- Gitblit v1.8.0