| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | |
| | | import com.google.gson.stream.JsonReader;
|
| | | import com.google.gson.stream.JsonWriter;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.lable.QualityFactory;
|
| | | import com.yeshi.fanli.entity.bus.tlj.DeviceTaoLiJinRecord;
|
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail.TaoLiJinDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin;
|
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin.TaoLiJinOriginEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserMoneyExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserRank;
|
| | | import com.yeshi.fanli.entity.taobao.ShareHotGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | import com.yeshi.fanli.exception.tlj.UserTaoLiJinOriginException;
|
| | |
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
|
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService;
|
| | | import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService;
|
| | | import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
|
| | | import com.yeshi.fanli.service.inter.tlj.DeviceTaoLiJinRecordService;
|
| | | import com.yeshi.fanli.service.inter.tlj.GoodsTaoLiJinRateService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinDetailService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService;
|
| | |
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
|
| | | import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
|
| | | import com.yeshi.fanli.vo.tlj.TaoLiJinDetailVO;
|
| | | import com.yeshi.fanli.vo.user.UserTaoLiJinRecordVO;
|
| | |
| | | private QualityGoodsService qualityGoodsService;
|
| | |
|
| | | @Resource
|
| | | private GoodsTaoLiJinRateService goodsTaoLiJinRateService;
|
| | | |
| | | @Resource
|
| | | private DeviceTaoLiJinRecordService deviceTaoLiJinRecordService;
|
| | |
|
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | |
|
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | | @Resource
|
| | | private ShareHotGoodsService shareHotGoodsService;
|
| | | |
| | | |
| | | /**
|
| | | * 获取淘礼金分享记录
|
| | | *
|
| | |
| | | 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("content", "自购直接抵现,优惠真实可见!");
|
| | | data.put("type", 1);
|
| | | data.put("money", money.setScale(2).toString());
|
| | | data.put("usage", "领取成功,去“首页-分享爆款”使用>");
|
| | | data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("share_taolijin_goods"));
|
| | | data.put("usage", "领取成功,已存入“我的-推广红包”");
|
| | | data.put("jumpName", "去使用");
|
| | | data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("share_goods_hot"));
|
| | | data.put("tip", configTaoLiJinService.getValueByKey("hongbao_newbies_tip"));
|
| | | data.put("rules", configTaoLiJinService.getValueByKey("taolijin_rules"));
|
| | |
|
| | |
| | | data.put("content", "自购直接抵现,优惠真实可见!");
|
| | | data.put("type", 1);
|
| | | data.put("money", hasMoney.setScale(2).toString());
|
| | | data.put("usage", "领取成功,去“首页-分享爆款”使用>");
|
| | | data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("share_taolijin_goods"));
|
| | | data.put("usage", "领取成功,已存入“我的-推广红包”");
|
| | | data.put("jumpName", "去使用");
|
| | | data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("share_goods_hot"));
|
| | | data.put("tip", configTaoLiJinService.getValueByKey("hongbao_newbies_tip"));
|
| | |
|
| | | } else if(type.equals(TaoLiJinOriginEnum.rankWin.name())) {
|
| | |
| | | UserRank userRank = userInfoExtraService.gerUserRank(uid);
|
| | | if (userRank != null) {
|
| | | try {
|
| | | isRank = true;
|
| | | UserTaoLiJinOrigin origin = userTaoLiJinOriginService.addRankWinMoney(uid, userRank);
|
| | | hasMoney = origin.getMoney();
|
| | | isRank = true;
|
| | | } catch (UserTaoLiJinOriginException e) {
|
| | | if (e.getCode() != 2) {
|
| | | isRank = false;
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | return;
|
| | | }
|
| | |
| | | data.put("content", "推广红包,好友福利!");
|
| | | data.put("type", 2);
|
| | | data.put("money", "本月账户等级未达到\r\n继续加油");
|
| | | data.put("usage", "去“我的-账户等级”查看 >");
|
| | | data.put("jumpName", "去查看");
|
| | | data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("user_rank"));
|
| | | data.put("tip", configTaoLiJinService.getValueByKey("hongbao_rank_not_enough_tip"));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
| | | data.put("content", "推广红包,好友福利!");
|
| | | data.put("type", 1);
|
| | | data.put("money", hasMoney.setScale(2).toString());
|
| | | data.put("usage", "已存入“我的-推广红包”,去查看 >");
|
| | | data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("user_taolijin"));
|
| | | data.put("usage", "领取成功,已存入“我的-推广红包”");
|
| | | data.put("jumpName", "去使用");
|
| | | data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("share_goods_hot"));
|
| | | data.put("tip", configTaoLiJinService.getValueByKey("hongbao_rank_tip"));
|
| | | }
|
| | |
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getShareGoods", method = RequestMethod.POST)
|
| | | public void getShareGoods(AcceptData acceptData, Long uid, Integer page, PrintWriter out) {
|
| | | public void getShareGoods(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (page == null || page < 1) {
|
| | | page = 1;
|
| | | String day = TimeUtil.getGernalTime(java.lang.System.currentTimeMillis());
|
| | | List<ShareHotGoods> listHot = shareHotGoodsService.listByDay(day);
|
| | | if (listHot == null) {
|
| | | listHot = new ArrayList<ShareHotGoods>(); |
| | | }
|
| | |
|
| | | int pageSize = 10;
|
| | |
|
| | | List<QualityFactory> listFreeGoods = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
|
| | | if (listFreeGoods == null) {
|
| | | listFreeGoods = new ArrayList<QualityFactory>(); |
| | | }
|
| | | long count = listFreeGoods.size();
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | boolean isNewUser = userInfoExtraService.isNewUser(uid);
|
| | | if (isNewUser) {
|
| | | // 判定为老用户: 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。
|
| | | long countRecord = userTaoLiJinRecordService.countRecordByUid(uid);
|
| | | if (countRecord > 0) {
|
| | | isNewUser = false;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | for (QualityFactory qualityFactory : listFreeGoods) {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
|
| | | for (ShareHotGoods hotGoods : listHot) {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods();
|
| | | if (taoBaoGoodsBrief == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null);
|
| | | // 计算推广红包
|
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value");
|
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, taoBaoGoodsBrief);
|
| | |
|
| | | // 显示类型
|
| | | if (isNewUser) {
|
| | | extra.setMoneyType(1);
|
| | | } else {
|
| | | extra.setMoneyType(2);
|
| | | }
|
| | | |
| | | // 去掉标签
|
| | | extra.setLabels(null);
|
| | | |
| | | BigDecimal spreadMoney = goodsTaoLiJinRateService.getGoodsSpreadMoney(taoBaoGoodsBrief);
|
| | | // 推广红包 不能小于1
|
| | | if (spreadMoney.compareTo(new BigDecimal(1)) < 0) {
|
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | extra.setSpreadMoney("推广红包 ¥"+ spreadMoney);
|
| | | TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null);
|
| | | // 去掉标签
|
| | | extra.setLabels(null);
|
| | | |
| | | // 显示类型
|
| | | if (isNewUser) {
|
| | | extra.setMoneyType(1);
|
| | | extra.setSpreadMoney("推广红包 ¥"+ 1);
|
| | | } else {
|
| | | extra.setMoneyType(2);
|
| | | extra.setSpreadMoney("推广红包 ¥"+ spreadMoney);
|
| | | }
|
| | | array.add(gson.toJson(extra));
|
| | | }
|
| | |
|
| | | // 过期
|
| | | userTaoLiJinOriginService.overdueHongBao(uid);
|
| | | |
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | // 过期
|
| | | userTaoLiJinOriginService.overdueHongBao(uid);
|
| | | }
|
| | | });
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("count", array.size());
|
| | | data.put("list", array);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|