From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HelpController.java | 328 ++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 220 insertions(+), 108 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HelpController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HelpController.java index df4d4ca..d25e55a 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HelpController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/HelpController.java @@ -1,108 +1,220 @@ -package com.yeshi.fanli.controller.client.v1; - -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.util.HashMap; -import java.util.Map; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.yeshi.fanli.entity.accept.AcceptData; -import com.yeshi.fanli.entity.bus.help.AppPageNotification; -import com.yeshi.fanli.service.inter.help.AppPageNotificationService; -import com.yeshi.fanli.util.Constant; -import com.yeshi.fanli.util.StringUtil; -import com.yeshi.fanli.util.VersionUtil; - -import org.yeshi.utils.HttpUtil; -import org.yeshi.utils.JsonUtil; - -@Controller -@RequestMapping("api/v1/help") -public class HelpController { - - @Resource - private AppPageNotificationService appPageNotificationService; - - /** - * 鑾峰彇app椤甸潰鐨勯�氱煡 - * - * @param acceptData - * @param type - * @param out - */ - @RequestMapping(value = "getAppPageNotification") - public void getAppPageNotification(AcceptData acceptData, String type, PrintWriter out) { - if (StringUtil.isNullOrEmpty(type)) { - out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼犵被鍨�")); - return; - } - - AppPageNotification ap = appPageNotificationService.getValidNotificationByTypeCache(type); - if ("home".equalsIgnoreCase(type) - && VersionUtil.smallerThan_1_5_1(acceptData.getPlatform(), acceptData.getVersion()) && ap != null) { - AppPageNotification no = new AppPageNotification(); - no.setContentUrl(""); - no.setMd5("111111111111111111"); - no.setPageName(ap.getPageName()); - no.setShow(true); - no.setType(ap.getType()); - no.setUpdateTime(ap.getUpdateTime()); - no.setCanClose(false); - no.setContent(String.format("灏婃暚鐨勭敤鎴凤紝涓烘洿鍔犲噯纭珮鏁堢殑涓轰綘杩斿埄銆佺渷閽憋紝璇峰崌绾у埌%s鏈�鏂扮増鏈�",Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()))); - Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); - out.print(JsonUtil.loadTrueResult(gson.toJson(no))); - return; - } - - // 娌℃湁閫氱煡 - if (ap == null || !ap.getShow()) { - out.print(JsonUtil.loadFalseResult(2, "鏃犻�氱煡")); - } else {// 鏈夐�氱煡 - Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); - out.print(JsonUtil.loadTrueResult(gson.toJson(ap))); - } - } - - @RequestMapping(value = "updateApp") - public void updateApp(AcceptData acceptData, PrintWriter out) { - Map<String, String> params = new HashMap<>(); - if ("android".equalsIgnoreCase(acceptData.getPlatform())) {// android鏇存柊 -// acceptData.setVersion("10"); - params.put("method", "update"); - params.put("Platform", "Android"); - params.put("Version", acceptData.getVersion()); - params.put("device ", acceptData.getDevice()); - params.put("time", System.currentTimeMillis() + ""); - params.put("Package", acceptData.getPackages()); - params.put("device", acceptData.getDevice()); - params.put("platform", "Android"); - params.put("key", "a3f390d88e4c41f2747bfa2f1b5f87db"); - params.put("versionCode", acceptData.getVersion() + ""); - } else {// IOS鏇存柊 - params.put("method", "update"); - params.put("Platform", "IOS"); - params.put("Version", acceptData.getVersion()); - params.put("device ", acceptData.getDevice()); - params.put("time", System.currentTimeMillis() + ""); - params.put("Package", acceptData.getPackages()); - params.put("device", acceptData.getDevice()); - params.put("platform", "IOS"); - params.put("key", "32bb90e8976aab5298d5da10fe66f21d"); - params.put("versionCode", acceptData.getVersion() + ""); - } - String url = "http://update.yeshitv.com:8090/update/update"; - String result = HttpUtil.post(url, params, null); - try { - out.print(new String(result.getBytes("ISO-8859-1"), "UTF-8")); - } catch (UnsupportedEncodingException e) { - out.print(result); - } - } - -} +package com.yeshi.fanli.controller.client.v1; + +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.Resource; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.yeshi.utils.JsonUtil; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.yeshi.fanli.dto.order.UserTeamLevel; +import com.yeshi.fanli.dto.order.UserTeamRate; +import com.yeshi.fanli.entity.accept.AcceptData; +import com.yeshi.fanli.entity.bus.help.AppPageNotification; +import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; +import com.yeshi.fanli.service.inter.help.AppPageNotificationService; +import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; +import com.yeshi.fanli.service.manger.AppUpdateManager; +import com.yeshi.fanli.util.Constant; +import org.yeshi.utils.MoneyBigDecimalUtil; +import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.VersionUtil; + +import net.sf.json.JSONObject; + +@Controller +@RequestMapping("api/v1/help") +public class HelpController { + + @Resource + private AppPageNotificationService appPageNotificationService; + + @Resource + private AppUpdateManager appUpdateManager; + + @Resource + private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; + + /** + * 鑾峰彇app椤甸潰鐨勯�氱煡 + * + * @param acceptData + * @param type + * @param out + */ + @RequestMapping(value = "getAppPageNotification") + public void getAppPageNotification(AcceptData acceptData, String type, PrintWriter out) { + if (StringUtil.isNullOrEmpty(type)) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼犵被鍨�")); + return; + } + + String platform = acceptData.getPlatform(); + String version = acceptData.getVersion(); + + AppPageNotification ap = appPageNotificationService.getValidNotificationByTypeCache(type, platform, + Integer.parseInt(version),acceptData.getSystem()); + if ("home".equalsIgnoreCase(type) && VersionUtil.smallerThan_1_5_1(platform, version) && ap != null) { + AppPageNotification no = new AppPageNotification(); + no.setContentUrl(""); + no.setMd5("111111111111111111"); + no.setPageName(ap.getPageName()); + no.setShow(true); + no.setType(ap.getType()); + no.setUpdateTime(ap.getUpdateTime()); + no.setCanClose(false); + no.setContent(String.format("灏婃暚鐨勭敤鎴凤紝涓烘洿鍔犲噯纭珮鏁堢殑涓轰綘杩斿埄銆佺渷閽憋紝璇峰崌绾у埌%s鏈�鏂扮増鏈�", Constant.getAppName(platform, version))); + Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); + out.print(JsonUtil.loadTrueResult(gson.toJson(no))); + return; + } + + // 娌℃湁閫氱煡 + if (ap == null || !ap.getShow()) { + out.print(JsonUtil.loadFalseResult(2, "鏃犻�氱煡")); + } else {// 鏈夐�氱煡 + Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); + out.print(JsonUtil.loadTrueResult(gson.toJson(ap))); + } + } + + @RequestMapping(value = "updateApp") + public void updateApp(AcceptData acceptData, PrintWriter out) { + if (Constant.IS_TEST) + acceptData.setVersion("20"); + String result = "{\"code\":1}";// appUpdateManager.getUpdateInfoCache(acceptData); + try { + out.print(new String(result.getBytes("ISO-8859-1"), "UTF-8")); + } catch (UnsupportedEncodingException e) { + out.print(result); + } + } + + @RequestMapping(value = "computeCommission") + public void computeCommission(AcceptData acceptData, String list, String money, String callback, PrintWriter out) { + + money = money.replace("楼", "").trim(); + + BigDecimal moneyBigDecial = null; + + try { + moneyBigDecial = new BigDecimal(money); + } catch (Exception e) { + + } + + if (moneyBigDecial == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璧勯噾鏍煎紡涓嶅")); + return; + } + + List<UserLevelEnum> levelList = new ArrayList<UserLevelEnum>(); + net.sf.json.JSONArray array = net.sf.json.JSONArray.fromObject(list); + for (int i = 0; i < array.size(); i++) + levelList.add(UserLevelEnum.valueOf(array.optString(i))); + + Collections.reverse(levelList); + + BigDecimal fanLiRate = orderHongBaoMoneyComputeService.getFanliRate(levelList.get(0), new Date(),acceptData.getSystem()); + + moneyBigDecial = MoneyBigDecimalUtil.divUp(moneyBigDecial.multiply(new BigDecimal(100)), fanLiRate); + + List<UserTeamLevel> bossList = new ArrayList<>(); + if (levelList.size() > 1) + for (int i = 1; i < levelList.size(); i++) { + bossList.add(new UserTeamLevel(10000L + i, levelList.get(i))); + } + + Date date = new Date(); + + List<UserTeamRate> rateList = null; + + Map<Long, UserTeamRate> teamRewardMap = new HashMap<>(); + Map<Long, UserTeamRate> teamReward2Map = new HashMap<>(); + Map<Long, UserTeamRate> teamDividentsMap = new HashMap<>(); + + // 璁$畻浜岀骇澶栧垎绾� + List<UserTeamRate> moreThan2LevelList = orderHongBaoMoneyComputeService + .getTeamRewardMoreThan2LevelRates(levelList.get(0), bossList, date,acceptData.getSystem()); + if (moreThan2LevelList != null) + for (UserTeamRate rate : moreThan2LevelList) { + teamReward2Map.put(rate.getUid(), rate); + } + + // 璁$畻涓�绾у閲� + if (bossList.size() >= 1) { + UserTeamRate rate = orderHongBaoMoneyComputeService.getTeamRewardRate(levelList.get(0), bossList, date, 1,acceptData.getSystem()); + if (rate != null) + teamRewardMap.put(rate.getUid(), rate); + } + // 璁$畻浜岀骇濂栭噾 + if (bossList.size() >= 2) { + UserTeamRate rate = orderHongBaoMoneyComputeService.getTeamRewardRate(levelList.get(0), bossList, date, 2,acceptData.getSystem()); + if (rate != null) + teamRewardMap.put(rate.getUid(), rate); + } + + // 璁$畻鍒嗙孩 + rateList = orderHongBaoMoneyComputeService.getTeamDividentsRates(levelList.get(0), bossList, date,acceptData.getSystem()); + if (rateList != null) + for (UserTeamRate rate : rateList) { + teamDividentsMap.put(rate.getUid(), rate); + } + + BigDecimal fanliRate = orderHongBaoMoneyComputeService.getFanliRate(levelList.get(0), date,acceptData.getSystem()); + + List<String> resultList = new ArrayList<>(); + + resultList.add( + "楼" + MoneyBigDecimalUtil.div(MoneyBigDecimalUtil.mul(moneyBigDecial, fanliRate), new BigDecimal(100))); + + for (int i = 0; i < bossList.size(); i++) { + // + String st = ""; + Long uid = bossList.get(i).getUid(); + + if (teamRewardMap.get(uid) == null) + st += "楼0"; + else + st += "楼" + MoneyBigDecimalUtil.div( + MoneyBigDecimalUtil.mul(moneyBigDecial, teamRewardMap.get(uid).getRate()), new BigDecimal(100)); + + st += "+"; + + if (teamReward2Map.get(uid) == null) + st += "楼0"; + else + st += "楼" + MoneyBigDecimalUtil.div( + MoneyBigDecimalUtil.mul(moneyBigDecial, teamReward2Map.get(uid).getRate()), + new BigDecimal(100)); + st += "+"; + + if (teamDividentsMap.get(uid) == null) + st += "楼0"; + else + st += "楼" + MoneyBigDecimalUtil.div( + MoneyBigDecimalUtil.mul(moneyBigDecial, teamDividentsMap.get(uid).getRate()), + new BigDecimal(100)); + resultList.add(st); + } + + Collections.reverse(resultList); + + JSONObject data = new JSONObject(); + data.put("list", resultList); + + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } + +} -- Gitblit v1.8.0