From 81da61b828e29b7745e1382dfbbaeb685dc083ef Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 23 一月 2024 17:17:55 +0800 Subject: [PATCH] 抖音转链修改 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5PullNewController.java | 386 +++++++++++++++++++++++++++--------------------------- 1 files changed, 193 insertions(+), 193 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5PullNewController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5PullNewController.java index 21e550e..d7f22e1 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5PullNewController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5PullNewController.java @@ -1,194 +1,194 @@ -package com.yeshi.fanli.controller.client.v1.h5; - -import java.io.PrintWriter; -import java.lang.reflect.Type; -import java.math.BigDecimal; -import java.util.List; - -import javax.annotation.Resource; - -import com.yeshi.fanli.util.SystemInfoUtil; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.yeshi.utils.DateUtil; -import org.yeshi.utils.JsonUtil; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.yeshi.fanli.dto.ConfigParamsDTO; -import com.yeshi.fanli.entity.accept.AcceptData; -import com.yeshi.fanli.entity.bus.user.UserInfo; -import com.yeshi.fanli.entity.bus.user.UserRankings; -import com.yeshi.fanli.entity.goods.PullNewGoods; -import com.yeshi.fanli.service.inter.goods.PullNewGoodsService; -import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; -import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; -import com.yeshi.fanli.service.inter.redpack.RedPackConfigService; -import com.yeshi.fanli.service.inter.user.QrCodeService; -import com.yeshi.fanli.service.inter.user.UserInfoExtraService; -import com.yeshi.fanli.service.inter.user.UserInfoService; -import com.yeshi.fanli.service.inter.user.UserRankingsService; -import com.yeshi.fanli.util.Constant; -import com.yeshi.fanli.util.StringUtil; -import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; -import com.yeshi.fanli.util.factory.goods.TaoBaoGoodsFactory; -import com.yeshi.fanli.vo.user.PullNewRuleVO; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -@Controller -@RequestMapping("api/apph5/v1/pullNew") -public class AppH5PullNewController { - - @Resource - private PullNewGoodsService pullNewGoodsService; - - @Resource - private RedPackConfigService redPackConfigService; - - @Resource - private UserRankingsService userRankingsService; - - @Resource - private HongBaoManageService hongBaoManageService; - - @Resource - private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; - - @Resource - private QrCodeService qrCodeService; - - @Resource - private UserInfoService userInfoService; - - @Resource - private UserInfoExtraService userInfoExtraService; - - - - /** - * 鎷夋柊鍟嗗搧 - * - * @param acceptData - * @param callback - * @param uid - * @param page - * @param goodsType - * @param out - */ - @RequestMapping("getGoodsList") - public void getGoodsList(AcceptData acceptData, String callback, Long uid, Integer page, PrintWriter out) { - if (acceptData.getSystem() == null) - acceptData.setSystem(SystemInfoUtil.getSystem(acceptData)); - JSONArray array = new JSONArray(); - List<PullNewGoods> list = pullNewGoodsService.listQuery((page-1)*Constant.PAGE_SIZE, Constant.PAGE_SIZE); - if (list != null && list.size() > 0) { - Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); - ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), - acceptData.getVersion(),acceptData.getSystem()); - paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem())); - - for (PullNewGoods goods : list) { - array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(TaoBaoGoodsFactory.create(goods),paramsDTO))); - } - } - - - JSONObject data = new JSONObject(); - if (page == 1) { - String ruleStr = redPackConfigService.getValueByKey("pullnew_activity_rule"); - if (!StringUtil.isNullOrEmpty(ruleStr)) { - Type type = new TypeToken<PullNewRuleVO>() { - }.getType(); - PullNewRuleVO rule = new Gson().fromJson(ruleStr, type); - rule.setRuleName(DateUtil.getCurrentMonthChinese() + "鏈堟椿鍔ㄨ鍒�"); - data.put("rule", rule); - } - data.put("tip", redPackConfigService.getValueByKey("pullnew_page_tip")); - } - data.put("count", pullNewGoodsService.countQuery()); - data.put("list", array); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } - - /** - * 鎷夋柊鎺掕姒� - * - * @param acceptData - * @param callback - * @param uid - * @param page - * @param out - */ - @RequestMapping("getRankList") - public void getRankList(AcceptData acceptData, String callback, Long uid, PrintWriter out) { - if (acceptData.getSystem() == null) - acceptData.setSystem(SystemInfoUtil.getSystem(acceptData)); - JSONArray array = new JSONArray(); - List<UserRankings> list = userRankingsService.getRankList(0, 10); - if (list != null && list.size() > 0) { - for (UserRankings rank : list) { - JSONObject user = new JSONObject(); - user.put("nickName", rank.getNickName()); - user.put("portrait", rank.getPortrait()); - user.put("money", "楼 " + rank.getShareReward().setScale(2, BigDecimal.ROUND_DOWN)); - array.add(user); - } - } - JSONObject data = new JSONObject(); - data.put("count", array.size()); - data.put("list", array); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } - - /** - * 鍒涘缓鍒嗕韩鍥� - * - * @param acceptData - * @param callback - * @param uid - * @param out - */ - @RequestMapping("getShareImg") - public void getShareImg(AcceptData acceptData, String callback, Long uid, PrintWriter out) { - if (acceptData.getSystem() == null) - acceptData.setSystem(SystemInfoUtil.getSystem(acceptData)); - if (uid == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); - return; - } - - UserInfo userInfo = userInfoService.selectByPKey(uid); - if (userInfo == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ敤鎴蜂笉瀛樺湪")); - return; - } - - String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); - if (StringUtil.isNullOrEmpty(inviteCode)) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("閭�璇风爜鏈縺娲�")); - return; - } - - PullNewRuleVO rule = null; - String ruleStr = redPackConfigService.getValueByKey("pullnew_activity_rule"); - if (!StringUtil.isNullOrEmpty(ruleStr)) { - Type type = new TypeToken<PullNewRuleVO>() { - }.getType(); - rule = new Gson().fromJson(ruleStr, type); - rule.setRuleName(DateUtil.getCurrentMonthChinese() + "鏈堟椿鍔ㄨ鍒�"); - } - - String url = qrCodeService.drawPullNewPoster(uid, userInfo.getPortrait(), inviteCode, rule); - if (StringUtil.isNullOrEmpty(url)) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢熸垚鍒嗕韩鍥惧け璐�")); - return; - } - - JSONObject data = new JSONObject(); - data.put("imgUrl",url); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } +package com.yeshi.fanli.controller.client.v1.h5; + +import java.io.PrintWriter; +import java.lang.reflect.Type; +import java.math.BigDecimal; +import java.util.List; + +import javax.annotation.Resource; + +import com.yeshi.fanli.util.SystemInfoUtil; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.yeshi.utils.DateUtil; +import org.yeshi.utils.JsonUtil; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; +import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO; +import com.yeshi.fanli.entity.accept.AcceptData; +import com.yeshi.fanli.entity.bus.user.UserInfo; +import com.yeshi.fanli.entity.bus.user.UserRankings; +import com.yeshi.fanli.entity.goods.PullNewGoods; +import com.yeshi.fanli.service.inter.goods.PullNewGoodsService; +import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; +import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; +import com.yeshi.fanli.service.inter.redpack.RedPackConfigService; +import com.yeshi.fanli.service.inter.user.QrCodeService; +import com.yeshi.fanli.service.inter.user.UserInfoExtraService; +import com.yeshi.fanli.service.inter.user.UserInfoService; +import com.yeshi.fanli.service.inter.user.UserRankingsService; +import com.yeshi.fanli.util.Constant; +import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; +import com.yeshi.fanli.util.factory.goods.TaoBaoGoodsFactory; +import com.yeshi.fanli.vo.user.PullNewRuleVO; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +@Controller +@RequestMapping("api/apph5/v1/pullNew") +public class AppH5PullNewController { + + @Resource + private PullNewGoodsService pullNewGoodsService; + + @Resource + private RedPackConfigService redPackConfigService; + + @Resource + private UserRankingsService userRankingsService; + + @Resource + private HongBaoManageService hongBaoManageService; + + @Resource + private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; + + @Resource + private QrCodeService qrCodeService; + + @Resource + private UserInfoService userInfoService; + + @Resource + private UserInfoExtraService userInfoExtraService; + + + + /** + * 鎷夋柊鍟嗗搧 + * + * @param acceptData + * @param callback + * @param uid + * @param page + * @param goodsType + * @param out + */ + @RequestMapping("getGoodsList") + public void getGoodsList(AcceptData acceptData, String callback, Long uid, Integer page, PrintWriter out) { + if (acceptData.getSystem() == null) + acceptData.setSystem(SystemInfoUtil.getSystem(acceptData)); + JSONArray array = new JSONArray(); + List<PullNewGoods> list = pullNewGoodsService.listQuery((page-1)*Constant.PAGE_SIZE, Constant.PAGE_SIZE); + if (list != null && list.size() > 0) { + Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); + GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), + acceptData.getVersion(),acceptData.getSystem()); + paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem())); + + for (PullNewGoods goods : list) { + array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(TaoBaoGoodsFactory.create(goods),paramsDTO))); + } + } + + + JSONObject data = new JSONObject(); + if (page == 1) { + String ruleStr = redPackConfigService.getValueByKey("pullnew_activity_rule"); + if (!StringUtil.isNullOrEmpty(ruleStr)) { + Type type = new TypeToken<PullNewRuleVO>() { + }.getType(); + PullNewRuleVO rule = new Gson().fromJson(ruleStr, type); + rule.setRuleName(DateUtil.getCurrentMonthChinese() + "鏈堟椿鍔ㄨ鍒�"); + data.put("rule", rule); + } + data.put("tip", redPackConfigService.getValueByKey("pullnew_page_tip")); + } + data.put("count", pullNewGoodsService.countQuery()); + data.put("list", array); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } + + /** + * 鎷夋柊鎺掕姒� + * + * @param acceptData + * @param callback + * @param uid + * @param page + * @param out + */ + @RequestMapping("getRankList") + public void getRankList(AcceptData acceptData, String callback, Long uid, PrintWriter out) { + if (acceptData.getSystem() == null) + acceptData.setSystem(SystemInfoUtil.getSystem(acceptData)); + JSONArray array = new JSONArray(); + List<UserRankings> list = userRankingsService.getRankList(0, 10); + if (list != null && list.size() > 0) { + for (UserRankings rank : list) { + JSONObject user = new JSONObject(); + user.put("nickName", rank.getNickName()); + user.put("portrait", rank.getPortrait()); + user.put("money", "楼 " + rank.getShareReward().setScale(2, BigDecimal.ROUND_DOWN)); + array.add(user); + } + } + JSONObject data = new JSONObject(); + data.put("count", array.size()); + data.put("list", array); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } + + /** + * 鍒涘缓鍒嗕韩鍥� + * + * @param acceptData + * @param callback + * @param uid + * @param out + */ + @RequestMapping("getShareImg") + public void getShareImg(AcceptData acceptData, String callback, Long uid, PrintWriter out) { + if (acceptData.getSystem() == null) + acceptData.setSystem(SystemInfoUtil.getSystem(acceptData)); + if (uid == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } + + UserInfo userInfo = userInfoService.selectByPKey(uid); + if (userInfo == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇ョ敤鎴蜂笉瀛樺湪")); + return; + } + + String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); + if (StringUtil.isNullOrEmpty(inviteCode)) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("閭�璇风爜鏈縺娲�")); + return; + } + + PullNewRuleVO rule = null; + String ruleStr = redPackConfigService.getValueByKey("pullnew_activity_rule"); + if (!StringUtil.isNullOrEmpty(ruleStr)) { + Type type = new TypeToken<PullNewRuleVO>() { + }.getType(); + rule = new Gson().fromJson(ruleStr, type); + rule.setRuleName(DateUtil.getCurrentMonthChinese() + "鏈堟椿鍔ㄨ鍒�"); + } + + String url = qrCodeService.drawPullNewPoster(uid, userInfo.getPortrait(), inviteCode, rule); + if (StringUtil.isNullOrEmpty(url)) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢熸垚鍒嗕韩鍥惧け璐�")); + return; + } + + JSONObject data = new JSONObject(); + data.put("imgUrl",url); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } } \ No newline at end of file -- Gitblit v1.8.0