| | |
| | |
|
| | | 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 com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | |
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v1/help")
|
| | |
| | |
|
| | | @Resource
|
| | | private AppPageNotificationService appPageNotificationService;
|
| | |
|
| | | @Resource
|
| | | private AppUpdateManager appUpdateManager;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | /**
|
| | | * 获取app页面的通知
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | AppPageNotification ap = appPageNotificationService.getAppPageNotificationByTypeCache(type);
|
| | | if ("home".equalsIgnoreCase(type)
|
| | | && VersionUtil.smallerThan_1_5_1(acceptData.getPlatform(), acceptData.getVersion()) && ap != null) {
|
| | | String platform = acceptData.getPlatform();
|
| | | String version = acceptData.getVersion();
|
| | |
|
| | | AppPageNotification ap = appPageNotificationService.getValidNotificationByTypeCache(type, platform,
|
| | | Integer.parseInt(version));
|
| | | if ("home".equalsIgnoreCase(type) && VersionUtil.smallerThan_1_5_1(platform, version) && ap != null) {
|
| | | AppPageNotification no = new AppPageNotification();
|
| | | no.setContentUrl("");
|
| | | no.setMd5("111111111111111111");
|
| | |
| | | no.setType(ap.getType());
|
| | | no.setUpdateTime(ap.getUpdateTime());
|
| | | no.setCanClose(false);
|
| | | no.setContent("尊敬的用户,为更加准确高效的为你返利、省钱,请升级到返利券最新版本");
|
| | | no.setContent(String.format("尊敬的用户,为更加准确高效的为你返利、省钱,请升级到%s最新版本", Constant.getAppName(platform, version)));
|
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
| | | out.print(JsonUtil.loadTrueResult(gson.toJson(no)));
|
| | | return;
|
| | |
| | |
|
| | | @RequestMapping(value = "updateApp")
|
| | | public void updateApp(AcceptData acceptData, PrintWriter out) {
|
| | | Map<String, String> params = new HashMap<>();
|
| | | 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() + "");
|
| | | String url = "http://update.yeshitv.com:8090/update/update";
|
| | | String result = HttpUtil.post(url, params, null);
|
| | | out.print(result);
|
| | | if (Constant.IS_TEST)
|
| | | acceptData.setVersion("20");
|
| | | String result = 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;
|
| | | }
|
| | |
|
| | | moneyBigDecial = MoneyBigDecimalUtil.mul(moneyBigDecial, new BigDecimal("2.5"));
|
| | |
|
| | | 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);
|
| | |
|
| | | 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);
|
| | | 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);
|
| | | if (rate != null)
|
| | | teamRewardMap.put(rate.getUid(), rate);
|
| | | }
|
| | | // 计算二级奖金
|
| | | if (bossList.size() >= 2) {
|
| | | UserTeamRate rate = orderHongBaoMoneyComputeService.getTeamRewardRate(levelList.get(0), bossList, date, 2);
|
| | | if (rate != null)
|
| | | teamRewardMap.put(rate.getUid(), rate);
|
| | | }
|
| | |
|
| | | // 计算分红
|
| | | rateList = orderHongBaoMoneyComputeService.getTeamDividentsRates(levelList.get(0), bossList, date);
|
| | | if (rateList != null)
|
| | | for (UserTeamRate rate : rateList) {
|
| | | teamDividentsMap.put(rate.getUid(), rate);
|
| | | }
|
| | |
|
| | | BigDecimal fanliRate = orderHongBaoMoneyComputeService.getFanliRate(levelList.get(0), date);
|
| | |
|
| | | 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 (i < 2) {
|
| | | if (teamRewardMap.get(uid) == null)
|
| | | st += "¥0";
|
| | | else
|
| | | st += "¥" + MoneyBigDecimalUtil.div(
|
| | | MoneyBigDecimalUtil.mul(moneyBigDecial, teamRewardMap.get(uid).getRate()),
|
| | | new BigDecimal(100));
|
| | |
|
| | | st += "+";
|
| | | }
|
| | |
|
| | | if (i >= 2) {
|
| | |
|
| | | 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));
|
| | | }
|
| | |
|
| | | }
|