| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | 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 org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.JsonElement;
|
| | | import com.google.gson.JsonPrimitive;
|
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | import com.google.gson.TypeAdapter;
|
| | | 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.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.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.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | 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.UserTaoLiJinDetailService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserMoneyExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | 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;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v2/taolijin")
|
| | | public class TaoLiJinControllerV2 {
|
| | |
|
| | | @Resource
|
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private ShareGoodsService shareGoodsService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private ShareGoodsTextTemplateService shareGoodsTextTemplateService;
|
| | |
|
| | | @Resource
|
| | | private BusinessEmergent110Service businessEmergent110Service;
|
| | |
|
| | | @Resource
|
| | | private MonitorService monitorService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | | |
| | | @Resource
|
| | | private UserTaoLiJinOriginService userTaoLiJinOriginService;
|
| | | |
| | | @Resource
|
| | | private UserTaoLiJinDetailService userTaoLiJinDetailService;
|
| | | |
| | | @Resource
|
| | | private UserMoneyExtraService userMoneyExtraService;
|
| | | |
| | | @Resource
|
| | | private ConfigTaoLiJinService configTaoLiJinService;
|
| | | |
| | | @Resource
|
| | | private QualityGoodsService qualityGoodsService;
|
| | | |
| | | @Resource
|
| | | private DeviceTaoLiJinRecordService deviceTaoLiJinRecordService;
|
| | |
|
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | | |
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | | @Resource
|
| | | private ShareHotGoodsService shareHotGoodsService;
|
| | | |
| | | |
| | | /**
|
| | | * 获取淘礼金分享记录
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param page
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getShareRecord", method = RequestMethod.POST)
|
| | | public void getShareRecord(AcceptData acceptData, Long uid, Integer page, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (page == null || page < 1) {
|
| | | page = 1;
|
| | | }
|
| | |
|
| | | long count = 0;
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | List<UserTaoLiJinRecordVO> list = userTaoLiJinRecordService.getRecordByUid((page - 1) * pageSize, pageSize, uid);
|
| | |
|
| | | if (list == null) {
|
| | | list = new ArrayList<UserTaoLiJinRecordVO>();
|
| | | } else if (list.size() > 0) {
|
| | | count = userTaoLiJinRecordService.countRecordByUid(uid);
|
| | | }
|
| | | |
| | | |
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | gsonBuilder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
|
| | | @Override
|
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | return new JsonPrimitive(TimeUtil.getGernalTime(value.getTime(), "yyyy.MM.dd HH:mm"));
|
| | | }
|
| | | }
|
| | | });
|
| | | |
| | | Gson gson = gsonBuilder.create();
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("list", gson.toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 统计淘礼金
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "countHongBao", method = RequestMethod.POST)
|
| | | public void countHongBao(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | // 过期
|
| | | userTaoLiJinOriginService.overdueHongBao(uid);
|
| | | |
| | | // 我的淘礼金
|
| | | BigDecimal tlj = null;
|
| | | UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid);
|
| | | if (userMoneyExtra != null) {
|
| | | tlj = userMoneyExtra.getTlj();
|
| | | } else {
|
| | | tlj = new BigDecimal(0);
|
| | | }
|
| | | |
| | | |
| | | // 今日分享个数
|
| | | long countShare = userTaoLiJinRecordService.countTodayNum(uid);
|
| | | |
| | | // 获得
|
| | | BigDecimal todayWin = userTaoLiJinOriginService.countMoneyByDate(uid, 1);
|
| | | BigDecimal yesterdayWin = userTaoLiJinOriginService.countMoneyByDate(uid, 2);
|
| | | BigDecimal thisMonthWin = userTaoLiJinOriginService.countMoneyByDate(uid, 3);
|
| | | BigDecimal lastMonthWin = userTaoLiJinOriginService.countMoneyByDate(uid, 4);
|
| | |
|
| | | // 消耗
|
| | | BigDecimal todayUse = userTaoLiJinDetailService.countUseMoneyByDate(uid, 1);
|
| | | BigDecimal yesterdayUse = userTaoLiJinDetailService.countUseMoneyByDate(uid, 2);
|
| | | BigDecimal thisMonthUse = userTaoLiJinDetailService.countUseMoneyByDate(uid, 3);
|
| | | BigDecimal lastMonthUse = userTaoLiJinDetailService.countUseMoneyByDate(uid, 4);
|
| | |
|
| | | // 问号链接
|
| | | String helpLink = configTaoLiJinService.getValueByKey("hongbao_help_link");
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("tlj", tlj.setScale(2).toString());
|
| | | data.put("helpLink", helpLink);
|
| | | data.put("countShare", countShare);
|
| | | data.put("todayWin", todayWin.setScale(2).toString());
|
| | | data.put("yesterdayWin", yesterdayWin.setScale(2).toString());
|
| | | data.put("thisMonthWin", thisMonthWin.setScale(2).toString());
|
| | | data.put("lastMonthWin", lastMonthWin.setScale(2).toString());
|
| | | data.put("todayUse", todayUse.setScale(2).toString().replaceAll("-", ""));
|
| | | data.put("yesterdayUse", yesterdayUse.setScale(2).toString().replaceAll("-", ""));
|
| | | data.put("thisMonthUse", thisMonthUse.setScale(2).toString().replaceAll("-", ""));
|
| | | data.put("lastMonthUse", lastMonthUse.setScale(2).toString().replaceAll("-", ""));
|
| | | |
| | | |
| | | // IOS 分享个数
|
| | | ClientTextStyleVO textVo1 = new ClientTextStyleVO();
|
| | | textVo1.setContent("今日创建分享");
|
| | | textVo1.setColor("#888888");
|
| | | ClientTextStyleVO textVo2 = new ClientTextStyleVO();
|
| | | textVo2.setContent(countShare + "");
|
| | | textVo2.setColor("#E5005C");
|
| | | ClientTextStyleVO textVo3 = new ClientTextStyleVO();
|
| | | textVo3.setContent("个");
|
| | | textVo3.setColor("#888888");
|
| | | |
| | | List<ClientTextStyleVO> listCountShare = new ArrayList<ClientTextStyleVO>();
|
| | | listCountShare.add(textVo1);
|
| | | listCountShare.add(textVo2);
|
| | | listCountShare.add(textVo3);
|
| | | data.put("listShare", listCountShare);
|
| | | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 获取淘礼金明细详情
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param index
|
| | | * List最末的主键ID
|
| | | * @param year
|
| | | * 年份
|
| | | * @param month
|
| | | * 月份
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getMoneyDetails")
|
| | | public void getMoneyDetails(AcceptData acceptData, Long uid, Long index, Integer year, Integer month,
|
| | | PrintWriter out) {
|
| | | if (uid == null || uid == 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if ((year == null && month != null) || (year != null && month == null)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "日期不完整"));
|
| | | return;
|
| | | }
|
| | |
|
| | | Date date = null;
|
| | |
|
| | | if (year != null && month != null) {
|
| | | date = new Date(TimeUtil.convertToTimeTemp(year + "-" + month, "yyyy-M"));
|
| | | Calendar ca = Calendar.getInstance();
|
| | | ca.setTime(date);
|
| | | ca.add(Calendar.MONTH, 1);
|
| | | date = new Date(ca.getTimeInMillis() - 1);
|
| | | }
|
| | | |
| | | // 查询列表
|
| | | List<TaoLiJinDetailVO> list = userTaoLiJinDetailService.listUserMoneyDetailForClient(uid, index, date);
|
| | | // 统计总条数
|
| | | long count = userTaoLiJinDetailService.countUserMoneyDetailForClient(uid, index, date);
|
| | | |
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | gsonBuilder.registerTypeAdapter(TaoLiJinDetailTypeEnum.class, new TypeAdapter<TaoLiJinDetailTypeEnum>() {
|
| | | @Override
|
| | | public TaoLiJinDetailTypeEnum read(JsonReader arg0) throws IOException {
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void write(JsonWriter out, TaoLiJinDetailTypeEnum arg1) throws IOException {
|
| | | out.beginObject();
|
| | | out.name("portrait").value(arg1.getPicture());
|
| | | out.endObject();
|
| | | }
|
| | | }).registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
|
| | | @Override
|
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | 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("count", count);
|
| | | data.put("data", gson.toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 红包领取详情
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param type
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getHongbaoDetails", method = RequestMethod.POST)
|
| | | public void getHongbaoDetails(AcceptData acceptData, Long uid, String type, PrintWriter out) {
|
| | | |
| | | if (StringUtil.isNullOrEmpty(type)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "类型不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | // 用户未登录时 设备领取新红包
|
| | | if (uid == null || uid <= 0) {
|
| | | BigDecimal money = null;
|
| | | DeviceTaoLiJinRecord deviceRecord = deviceTaoLiJinRecordService.getByDevice(acceptData.getDevice());
|
| | | if (deviceRecord != null) {
|
| | | // 已领取
|
| | | money = deviceRecord.getMoney();
|
| | | } else {
|
| | | String value = configTaoLiJinService.getValueByKey("hongbao_newbies");
|
| | | if (StringUtil.isNullOrEmpty(value)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "系统红包不存在"));
|
| | | return;
|
| | | }
|
| | | money = new BigDecimal(value);
|
| | | deviceTaoLiJinRecordService.save(acceptData.getDevice(), money);
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("icon", configTaoLiJinService.getValueByKey("taolijin_system_icon"));
|
| | | data.put("title", "新人红包");
|
| | | data.put("content", "自购直接抵现,优惠真实可见!");
|
| | | data.put("type", 1);
|
| | | data.put("money", money.setScale(2).toString());
|
| | | 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("newbies_rules_link"));
|
| | | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | } |
| | | |
| | | |
| | | // 登录用户
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("icon", configTaoLiJinService.getValueByKey("taolijin_system_icon"));
|
| | | |
| | | if (type.equals(TaoLiJinOriginEnum.newbiesWin.name())) {
|
| | | BigDecimal hasMoney = null;
|
| | | UserTaoLiJinOrigin userTaoLiJin = userTaoLiJinOriginService.getByUidAndOrigin(uid, type);
|
| | | if (userTaoLiJin != null) { // 已领取
|
| | | hasMoney = userTaoLiJin.getMoney();
|
| | | } else {
|
| | | try {
|
| | | UserTaoLiJinOrigin origin = userTaoLiJinOriginService.addNewbiesWinMoney(uid);
|
| | | hasMoney = origin.getMoney();
|
| | | } catch (UserTaoLiJinOriginException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | return;
|
| | | }
|
| | | }
|
| | | |
| | | data.put("title", "新人红包");
|
| | | data.put("content", "自购直接抵现,优惠真实可见!");
|
| | | data.put("type", 1);
|
| | | data.put("money", hasMoney.setScale(2).toString());
|
| | | 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("newbies_rules_link"));
|
| | | |
| | | } else if(type.equals(TaoLiJinOriginEnum.rankWin.name())) {
|
| | | boolean isRank = false;
|
| | | BigDecimal hasMoney = null;
|
| | | UserTaoLiJinOrigin userTaoLiJin = userTaoLiJinOriginService.getRankByThisMonth(uid, type);
|
| | | if (userTaoLiJin != null) { // 已领取
|
| | | isRank = true;
|
| | | hasMoney = userTaoLiJin.getMoney();
|
| | | } else {
|
| | | isRank = false;
|
| | | UserRank userRank = userInfoExtraService.gerUserRank(uid);
|
| | | if (userRank != null) {
|
| | | try {
|
| | | 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;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | // 等级不足
|
| | | if (!isRank) {
|
| | | data.put("title", "账户等级福利");
|
| | | data.put("content", "推广红包,好友福利!");
|
| | | data.put("type", 2);
|
| | | data.put("money", "本月账户等级未达到\r\n继续加油");
|
| | | data.put("jumpName", "去查看");
|
| | | data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("user_rank"));
|
| | | data.put("tip", configTaoLiJinService.getValueByKey("hongbao_rank_not_enough_tip"));
|
| | | data.put("rules", configTaoLiJinService.getValueByKey("rank_rules_link"));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | } else {
|
| | | data.put("title", "账户等级福利");
|
| | | data.put("content", "推广红包,好友福利!");
|
| | | data.put("type", 1);
|
| | | data.put("money", hasMoney.setScale(2).toString());
|
| | | data.put("usage", "领取成功,已存入“我的-推广红包”");
|
| | | data.put("jumpName", "去使用");
|
| | | data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("share_goods_hot"));
|
| | | data.put("tip", configTaoLiJinService.getValueByKey("hongbao_rank_tip"));
|
| | | data.put("rules", configTaoLiJinService.getValueByKey("rank_rules_link"));
|
| | | }
|
| | | |
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(1, "类型不匹配"));
|
| | | return;
|
| | | }
|
| | | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 分享爆款商品-限于淘礼金
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getShareGoods", method = RequestMethod.POST)
|
| | | public void getShareGoods(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | String day = TimeUtil.getGernalTime(java.lang.System.currentTimeMillis());
|
| | | List<ShareHotGoods> listHot = shareHotGoodsService.listByDay(day);
|
| | | if (listHot == null) {
|
| | | listHot = new ArrayList<ShareHotGoods>(); |
| | | }
|
| | | |
| | | |
| | | 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 (ShareHotGoods hotGoods : listHot) {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods();
|
| | | if (taoBaoGoodsBrief == null) {
|
| | | continue;
|
| | | }
|
| | | |
| | | // 计算推广红包
|
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value");
|
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, taoBaoGoodsBrief);
|
| | | |
| | | // 推广红包 不能小于1
|
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) {
|
| | | continue;
|
| | | }
|
| | | |
| | | 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));
|
| | | }
|
| | | |
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | // 过期
|
| | | userTaoLiJinOriginService.overdueHongBao(uid);
|
| | | }
|
| | | });
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", array.size());
|
| | | data.put("list", array);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | }
|
| | | package com.yeshi.fanli.controller.client.v2; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.lang.reflect.Type; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | 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 org.yeshi.utils.DateUtil; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.JsonElement; |
| | | import com.google.gson.JsonPrimitive; |
| | | import com.google.gson.JsonSerializationContext; |
| | | import com.google.gson.JsonSerializer; |
| | | import com.google.gson.TypeAdapter; |
| | | import com.google.gson.stream.JsonReader; |
| | | import com.google.gson.stream.JsonWriter; |
| | | import com.yeshi.fanli.dto.ConfigParamsDTO; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail.TaoLiJinDetailTypeEnum; |
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinNewbies; |
| | | import com.yeshi.fanli.entity.bus.user.UserMoneyExtra; |
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.fanli.entity.taobao.ShareHotGoods; |
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods; |
| | | import com.yeshi.fanli.entity.taobao.TLJFreeBuyGoods; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBriefExtra; |
| | | import com.yeshi.fanli.exception.user.UserInfoException; |
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service; |
| | | import com.yeshi.fanli.service.inter.config.ConfigService; |
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService; |
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService; |
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService; |
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService; |
| | | import com.yeshi.fanli.service.inter.money.UserMoneyExtraService; |
| | | import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service; |
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService; |
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; |
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; |
| | | import com.yeshi.fanli.service.inter.redpack.UserTaoLiJinNewbiesService; |
| | | import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService; |
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService; |
| | | import com.yeshi.fanli.service.inter.taobao.TLJFreeBuyGoodsService; |
| | | import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService; |
| | | 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.service.inter.user.UserInfoExtraService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService; |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.TaoBaoConstant; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoLiJinUtil; |
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO; |
| | | import com.yeshi.fanli.vo.goods.MoneyInfoVO; |
| | | import com.yeshi.fanli.vo.goods.OtherInfo; |
| | | import com.yeshi.goods.facade.entity.taobao.TLJBuyHongBaoVO; |
| | | import com.yeshi.fanli.vo.homemodule.BannerVO; |
| | | import com.yeshi.common.vo.ClientTextStyleVO; |
| | | import com.yeshi.fanli.vo.redpack.TaoLiJinWinDetailVO; |
| | | import com.yeshi.fanli.vo.tlj.ReduceHongBao; |
| | | import com.yeshi.fanli.vo.tlj.SpreadHongBao; |
| | | import com.yeshi.fanli.vo.tlj.TaoLiJinDetailVO; |
| | | import com.yeshi.fanli.vo.user.UserTaoLiJinRecordVO; |
| | | |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/v2/taolijin") |
| | | public class TaoLiJinControllerV2 { |
| | | |
| | | @Resource |
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private ShareGoodsService shareGoodsService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private UserShareGoodsRecordService userShareGoodsRecordService; |
| | | |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | |
| | | @Resource |
| | | private ShareGoodsTextTemplateService shareGoodsTextTemplateService; |
| | | |
| | | @Resource |
| | | private BusinessEmergent110Service businessEmergent110Service; |
| | | |
| | | @Resource |
| | | private MonitorService monitorService; |
| | | |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | @Resource |
| | | private UserTaoLiJinOriginService userTaoLiJinOriginService; |
| | | |
| | | @Resource |
| | | private UserTaoLiJinDetailService userTaoLiJinDetailService; |
| | | |
| | | @Resource |
| | | private UserMoneyExtraService userMoneyExtraService; |
| | | |
| | | @Resource |
| | | private ConfigTaoLiJinService configTaoLiJinService; |
| | | |
| | | @Resource |
| | | private QualityGoodsService qualityGoodsService; |
| | | |
| | | @Resource |
| | | private JumpDetailV2Service jumpDetailV2Service; |
| | | |
| | | @Resource(name = "taskExecutor") |
| | | private TaskExecutor executor; |
| | | |
| | | @Resource |
| | | private ShareHotGoodsService shareHotGoodsService; |
| | | |
| | | @Resource |
| | | private TLJBuyGoodsService tljBuyGoodsService; |
| | | |
| | | @Resource |
| | | private SwiperPictureService swiperPictureService; |
| | | |
| | | @Resource |
| | | private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService; |
| | | |
| | | @Resource |
| | | private TLJFreeBuyGoodsService tljFreeBuyGoodsService; |
| | | |
| | | @Resource |
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; |
| | | |
| | | /** |
| | | * 获取淘礼金分享记录 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param page |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getShareRecord", method = RequestMethod.POST) |
| | | public void getShareRecord(AcceptData acceptData, Long uid, Integer page, PrintWriter out) { |
| | | if (uid == null || uid <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if (page == null || page < 1) { |
| | | page = 1; |
| | | } |
| | | |
| | | int pageSize = Constant.PAGE_SIZE; |
| | | List<UserTaoLiJinRecordVO> list = userTaoLiJinRecordService.getRecordByUid((page - 1) * pageSize, pageSize, |
| | | uid); |
| | | if (list == null) { |
| | | list = new ArrayList<UserTaoLiJinRecordVO>(); |
| | | } |
| | | |
| | | long count = userTaoLiJinRecordService.countShareRecordByUid(uid); |
| | | |
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); |
| | | gsonBuilder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | @Override |
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | return new JsonPrimitive(TimeUtil.getGernalTime(value.getTime(), "yyyy.MM.dd HH:mm")); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | Gson gson = gsonBuilder.create(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", count); |
| | | data.put("list", gson.toJson(list)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 统计淘礼金 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "countHongBao", method = RequestMethod.POST) |
| | | public void countHongBao(AcceptData acceptData, Long uid, PrintWriter out) { |
| | | if (uid == null || uid <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | // 过期 -取消收回 |
| | | // userTaoLiJinOriginService.overdueHongBao(uid); |
| | | |
| | | // 我的淘礼金 |
| | | BigDecimal tlj = null; |
| | | UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid); |
| | | if (userMoneyExtra != null) { |
| | | tlj = userMoneyExtra.getTlj(); |
| | | } else { |
| | | tlj = new BigDecimal(0); |
| | | } |
| | | |
| | | // 今日分享个数 |
| | | long countShare = userTaoLiJinRecordService.countTodayNum(uid); |
| | | |
| | | // 获得 |
| | | BigDecimal todayWin = userTaoLiJinOriginService.countMoneyByDate(uid, 1); |
| | | BigDecimal yesterdayWin = userTaoLiJinOriginService.countMoneyByDate(uid, 2); |
| | | BigDecimal thisMonthWin = userTaoLiJinOriginService.countMoneyByDate(uid, 3); |
| | | BigDecimal lastMonthWin = userTaoLiJinOriginService.countMoneyByDate(uid, 4); |
| | | |
| | | BigDecimal zero = new BigDecimal(0); |
| | | // 消耗 |
| | | BigDecimal todayUse = userTaoLiJinDetailService.countUseMoneyByDate(uid, 1); |
| | | if (todayUse == null || todayUse.compareTo(zero) > 0) { |
| | | todayUse = zero; |
| | | } |
| | | |
| | | BigDecimal yesterdayUse = userTaoLiJinDetailService.countUseMoneyByDate(uid, 2); |
| | | if (yesterdayUse == null || yesterdayUse.compareTo(zero) > 0) { |
| | | yesterdayUse = zero; |
| | | } |
| | | BigDecimal thisMonthUse = userTaoLiJinDetailService.countUseMoneyByDate(uid, 3); |
| | | if (thisMonthUse == null || thisMonthUse.compareTo(zero) > 0) { |
| | | thisMonthUse = zero; |
| | | } |
| | | BigDecimal lastMonthUse = userTaoLiJinDetailService.countUseMoneyByDate(uid, 4); |
| | | if (lastMonthUse == null || lastMonthUse.compareTo(zero) > 0) { |
| | | lastMonthUse = zero; |
| | | } |
| | | |
| | | String giveMin = configTaoLiJinService.getValueByKey("give_min_amount"); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("tlj", tlj.setScale(2).toString()); |
| | | data.put("giveMin", giveMin); |
| | | data.put("giveTip", "注:赠送推广红包金额至少" + giveMin + "元"); |
| | | data.put("helpLink", configTaoLiJinService.getValueByKey("hongbao_help_link")); |
| | | data.put("countShare", countShare); |
| | | data.put("todayWin", todayWin.setScale(2).toString()); |
| | | data.put("yesterdayWin", yesterdayWin.setScale(2).toString()); |
| | | data.put("thisMonthWin", thisMonthWin.setScale(2).toString()); |
| | | data.put("lastMonthWin", lastMonthWin.setScale(2).toString()); |
| | | data.put("todayUse", todayUse.setScale(2).toString().replaceAll("-", "")); |
| | | data.put("yesterdayUse", yesterdayUse.setScale(2).toString().replaceAll("-", "")); |
| | | data.put("thisMonthUse", thisMonthUse.setScale(2).toString().replaceAll("-", "")); |
| | | data.put("lastMonthUse", lastMonthUse.setScale(2).toString().replaceAll("-", "")); |
| | | |
| | | // IOS 分享个数 |
| | | ClientTextStyleVO textVo1 = new ClientTextStyleVO(); |
| | | textVo1.setContent("今日创建分享"); |
| | | textVo1.setColor("#888888"); |
| | | ClientTextStyleVO textVo2 = new ClientTextStyleVO(); |
| | | textVo2.setContent(countShare + ""); |
| | | textVo2.setColor("#E5005C"); |
| | | ClientTextStyleVO textVo3 = new ClientTextStyleVO(); |
| | | textVo3.setContent("个"); |
| | | textVo3.setColor("#888888"); |
| | | |
| | | List<ClientTextStyleVO> listCountShare = new ArrayList<ClientTextStyleVO>(); |
| | | listCountShare.add(textVo1); |
| | | listCountShare.add(textVo2); |
| | | listCountShare.add(textVo3); |
| | | data.put("listShare", listCountShare); |
| | | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 获取淘礼金明细详情 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param index |
| | | * List最末的主键ID |
| | | * @param year |
| | | * 年份 |
| | | * @param month |
| | | * 月份 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getMoneyDetails") |
| | | public void getMoneyDetails(AcceptData acceptData, Long uid, Long index, Integer year, Integer month, |
| | | PrintWriter out) { |
| | | if (uid == null || uid == 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if ((year == null && month != null) || (year != null && month == null)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "日期不完整")); |
| | | return; |
| | | } |
| | | |
| | | Date date = null; |
| | | |
| | | if (year != null && month != null) { |
| | | date = new Date(TimeUtil.convertToTimeTemp(year + "-" + month, "yyyy-M")); |
| | | Calendar ca = Calendar.getInstance(); |
| | | ca.setTime(date); |
| | | ca.add(Calendar.MONTH, 1); |
| | | date = new Date(ca.getTimeInMillis() - 1); |
| | | } |
| | | |
| | | // 查询列表 |
| | | List<TaoLiJinDetailVO> list = userTaoLiJinDetailService.listUserMoneyDetailForClient(uid, index, date); |
| | | // 统计总条数 |
| | | long count = userTaoLiJinDetailService.countUserMoneyDetailForClient(uid, index, date); |
| | | |
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); |
| | | gsonBuilder.registerTypeAdapter(TaoLiJinDetailTypeEnum.class, new TypeAdapter<TaoLiJinDetailTypeEnum>() { |
| | | @Override |
| | | public TaoLiJinDetailTypeEnum read(JsonReader arg0) throws IOException { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public void write(JsonWriter out, TaoLiJinDetailTypeEnum arg1) throws IOException { |
| | | out.beginObject(); |
| | | out.name("portrait").value(arg1.getPicture()); |
| | | out.endObject(); |
| | | } |
| | | }).registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | @Override |
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | 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("count", count); |
| | | data.put("data", gson.toJson(list)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 分享爆款商品-限于淘礼金 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getShareGoods", method = RequestMethod.POST) |
| | | public void getShareGoods(AcceptData acceptData, Long uid, PrintWriter out) { |
| | | if (uid == null || uid <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | String day = TimeUtil.getGernalTime(java.lang.System.currentTimeMillis()); |
| | | List<ShareHotGoods> listHot = shareHotGoodsService.listByDay(day); |
| | | if (listHot == null) { |
| | | listHot = new ArrayList<ShareHotGoods>(); |
| | | } |
| | | |
| | | 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.getTLJShareRate(System.currentTimeMillis(),acceptData.getSystem()); |
| | | for (ShareHotGoods hotGoods : listHot) { |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods(); |
| | | if (taoBaoGoodsBrief == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 计算推广红包 |
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date()); |
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, taoBaoGoodsBrief); |
| | | |
| | | // 推广红包 不能小于1 |
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { |
| | | continue; |
| | | } |
| | | |
| | | 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)); |
| | | } |
| | | |
| | | /* |
| | | * // 过期 -取消收回 executor.execute(new Runnable() { |
| | | * |
| | | * @Override public void run() { |
| | | * userTaoLiJinOriginService.overdueHongBao(uid); } }); |
| | | */ |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", array.size()); |
| | | data.put("list", array); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 分享爆款商品-限于淘礼金 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getShareGoodsV2", method = RequestMethod.POST) |
| | | public void getShareGoodsV2(AcceptData acceptData, Long uid, PrintWriter out) { |
| | | String day = TimeUtil.getGernalTime(java.lang.System.currentTimeMillis()); |
| | | List<ShareHotGoods> listHot = shareHotGoodsService.listByDay(day); |
| | | if (listHot == null) { |
| | | listHot = new ArrayList<ShareHotGoods>(); |
| | | } |
| | | |
| | | JSONArray array = new JSONArray(); |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); |
| | | |
| | | // 取消新人自购 |
| | | boolean isNewUser = false;// userInfoExtraService.isNewUser(uid); |
| | | if (isNewUser) { |
| | | // 判定为老用户: 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。 |
| | | long countRecord = userTaoLiJinRecordService.countRecordByUid(uid); |
| | | if (countRecord > 0) { |
| | | isNewUser = false; |
| | | } |
| | | } |
| | | |
| | | ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(),acceptData.getSystem()); |
| | | |
| | | for (ShareHotGoods hotGoods : listHot) { |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods(); |
| | | if (taoBaoGoodsBrief == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 计算推广红包 |
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date()); |
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, taoBaoGoodsBrief); |
| | | |
| | | // 推广红包 不能小于1 |
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { |
| | | continue; |
| | | } |
| | | |
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO); |
| | | |
| | | // 大于1.6.5的才会显示福利价 |
| | | if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | if (detailVO.getCouponPrice() != null && detailVO.getCouponPrice().compareTo(new BigDecimal(0)) > 0) |
| | | detailVO.setCouponPrice(detailVO.getCouponPrice().subtract(spreadMoney)); |
| | | else |
| | | detailVO.setZkPrice(detailVO.getZkPrice().subtract(spreadMoney)); |
| | | } |
| | | |
| | | // 去掉标签 |
| | | detailVO.setLabels(null); |
| | | |
| | | MoneyInfoVO moneyInfo = detailVO.getMoneyInfo(); |
| | | OtherInfo otherInfo = new OtherInfo(); |
| | | SpreadHongBao spreadHongBao = new SpreadHongBao(); |
| | | |
| | | // 显示类型 |
| | | if (isNewUser) { |
| | | moneyInfo.setMoneyType(1); |
| | | spreadHongBao.setName("推广红包"); |
| | | spreadHongBao.setMoney(" ¥1"); |
| | | } else { |
| | | moneyInfo.setMoneyType(2); |
| | | spreadHongBao.setName("推广红包"); |
| | | spreadHongBao.setMoney(" ¥" + spreadMoney); |
| | | } |
| | | detailVO.setMoneyInfo(moneyInfo); |
| | | otherInfo.setSpreadHongBao(spreadHongBao); |
| | | detailVO.setOtherInfo(otherInfo); |
| | | |
| | | array.add(gson.toJson(detailVO)); |
| | | } |
| | | |
| | | /* |
| | | * executor.execute(new Runnable() { |
| | | * |
| | | * @Override public void run() { // 过期 |
| | | * userTaoLiJinOriginService.overdueHongBao(uid); } }); |
| | | */ |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", array.size()); |
| | | data.put("list", array); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 分享爆款商品-限于淘礼金 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getBuyGoods", method = RequestMethod.POST) |
| | | public void getBuyGoods(AcceptData acceptData, int page, PrintWriter out) { |
| | | |
| | | String day = TimeUtil.getGernalTime(java.lang.System.currentTimeMillis()); |
| | | List<TLJBuyGoods> listHot = tljBuyGoodsService.listByDay(day); |
| | | if (listHot == null) { |
| | | listHot = new ArrayList<TLJBuyGoods>(); |
| | | } |
| | | |
| | | JSONArray array = new JSONArray(); |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); |
| | | |
| | | BigDecimal proportion = TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE; |
| | | for (TLJBuyGoods hotGoods : listHot) { |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods(); |
| | | if (taoBaoGoodsBrief == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 计算推广红包 |
| | | BigDecimal spreadMoney = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, proportion,true); |
| | | |
| | | // 推广红包 不能小于1 |
| | | if (spreadMoney.compareTo(new BigDecimal(1.0)) < 0) { |
| | | continue; |
| | | } |
| | | |
| | | TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), |
| | | null); |
| | | // 去掉标签 |
| | | extra.setLabels(null); |
| | | |
| | | String hongBao = spreadMoney.toString(); |
| | | TLJBuyHongBaoVO vo = new TLJBuyHongBaoVO(); |
| | | vo.setLeft(hotGoods.getLeftHongBaoCount()); |
| | | vo.setMoney(hongBao); |
| | | vo.setTagName("付款立减 ¥" + hongBao); |
| | | vo.setTip(""); |
| | | vo.setTotal(hotGoods.getTotalHongBaoCount()); |
| | | extra.setTljBuyHongBao(vo); |
| | | // 显示类型 |
| | | extra.setMoneyType(2); |
| | | extra.setSpreadMoney("付款立减 ¥" + spreadMoney); |
| | | |
| | | array.add(gson.toJson(extra)); |
| | | } |
| | | |
| | | if (page > 1) |
| | | array.clear(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", array.size()); |
| | | data.put("list", array); |
| | | if (page == 1) { |
| | | List<BannerVO> bannerList = swiperPictureService.getByBannerCardAndVersion("zigoulijian_banner", |
| | | acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()); |
| | | |
| | | if (bannerList != null && bannerList.size() > 0) |
| | | data.put("topPicture", bannerList.get(0).getSrc()); |
| | | else |
| | | data.put("topPicture", ""); |
| | | |
| | | data.put("ruleUrl", configService.getValue(ConfigKeyEnum.zigoulijianRule.getKey(),acceptData.getSystem())); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 分享爆款商品-限于淘礼金 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getBuyGoodsV2", method = RequestMethod.POST) |
| | | public void getBuyGoodsV2(AcceptData acceptData, int page, PrintWriter out) { |
| | | |
| | | String day = TimeUtil.getGernalTime(java.lang.System.currentTimeMillis()); |
| | | List<TLJBuyGoods> listHot = tljBuyGoodsService.listByDay(day); |
| | | if (listHot == null) { |
| | | listHot = new ArrayList<TLJBuyGoods>(); |
| | | } |
| | | |
| | | JSONArray array = new JSONArray(); |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); |
| | | |
| | | BigDecimal proportion = TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE; |
| | | ConfigParamsDTO paramsDTO = new ConfigParamsDTO(proportion, proportion, Constant.MAX_REWARD_RATE, |
| | | hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem())); |
| | | for (TLJBuyGoods hotGoods : listHot) { |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods(); |
| | | if (taoBaoGoodsBrief == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 计算推广红包 |
| | | BigDecimal spreadMoney = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, proportion,true); |
| | | |
| | | // 推广红包 不能小于1 |
| | | if (spreadMoney.compareTo(new BigDecimal(1.0)) < 0) { |
| | | continue; |
| | | } |
| | | |
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO); |
| | | |
| | | // 大于1.6.5的才会显示福利价 |
| | | if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | if (detailVO.getCouponPrice() != null && detailVO.getCouponPrice().compareTo(new BigDecimal(0)) > 0) |
| | | detailVO.setCouponPrice(detailVO.getCouponPrice().subtract(spreadMoney)); |
| | | else |
| | | detailVO.setZkPrice(detailVO.getZkPrice().subtract(spreadMoney)); |
| | | } |
| | | |
| | | // 去掉标签 |
| | | detailVO.setLabels(null); |
| | | |
| | | MoneyInfoVO moneyInfo = detailVO.getMoneyInfo(); |
| | | moneyInfo.setMoneyType(2); |
| | | detailVO.setMoneyInfo(moneyInfo); |
| | | |
| | | String hongBao = spreadMoney.toString(); |
| | | ReduceHongBao vo = new ReduceHongBao(); |
| | | vo.setLeft(hotGoods.getLeftHongBaoCount()); |
| | | vo.setMoney(" ¥" + hongBao); |
| | | vo.setName("付款立减 "); |
| | | vo.setTip(""); |
| | | vo.setTotal(hotGoods.getTotalHongBaoCount()); |
| | | |
| | | OtherInfo otherInfo = new OtherInfo(); |
| | | otherInfo.setReduceHongBao(vo); |
| | | detailVO.setOtherInfo(otherInfo); |
| | | |
| | | array.add(gson.toJson(detailVO)); |
| | | } |
| | | |
| | | if (page > 1) |
| | | array.clear(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", array.size()); |
| | | data.put("list", array); |
| | | if (page == 1) { |
| | | List<BannerVO> bannerList = swiperPictureService.getByBannerCardAndVersion("zigoulijian_banner", |
| | | acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()); |
| | | |
| | | if (bannerList != null && bannerList.size() > 0) |
| | | data.put("topPicture", bannerList.get(0).getSrc()); |
| | | else |
| | | data.put("topPicture", ""); |
| | | |
| | | data.put("ruleUrl", configService.getValue(ConfigKeyEnum.zigoulijianRule.getKey(),acceptData.getSystem())); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 赠送淘礼金 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param amount |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "giveTLJ", method = RequestMethod.POST) |
| | | public void giveTLJ(AcceptData acceptData, Long uid, BigDecimal amount, PrintWriter out) { |
| | | out.print(JsonUtil.loadFalseResult(1, "抱歉,推广红包相关功能已下线!")); |
| | | } |
| | | |
| | | /** |
| | | * 新人红包详情 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getWinDetail", method = RequestMethod.POST) |
| | | public void getWinDetail(AcceptData acceptData, Long uid, PrintWriter out) { |
| | | if (uid == null || uid <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | TaoLiJinWinDetailVO winDetail = userTaoLiJinNewbiesService.receiveReward(uid); |
| | | if (winDetail == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "红包已被抢光")); |
| | | return; |
| | | } |
| | | |
| | | // 2、顶部轮播图 |
| | | List<BannerVO> oldtopPicList = swiperPictureService.getByBannerCardAndVersion( |
| | | "redpack_win_detail_banner", acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()); |
| | | List<BannerVO> topPicList = new ArrayList<>(); |
| | | if (oldtopPicList != null && oldtopPicList.size() > 0) |
| | | topPicList.addAll(oldtopPicList); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("detail", JsonUtil.getApiCommonGson().toJson(winDetail)); |
| | | data.put("banner", JsonUtil.getApiCommonGson().toJson(topPicList)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult(1, "红包已被抢光啦")); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 新人免单列表 |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "gerFreeList") |
| | | public void gerFreeList(String callback, AcceptData acceptData, int page, Long uid, PrintWriter out) { |
| | | if (uid == null || uid <= 0) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | String day = TimeUtil.getGernalTime(java.lang.System.currentTimeMillis()); |
| | | List<TLJFreeBuyGoods> listFree = tljFreeBuyGoodsService.listByDay(day); |
| | | if (listFree == null) { |
| | | listFree = new ArrayList<TLJFreeBuyGoods>(); |
| | | } |
| | | |
| | | JSONArray array = new JSONArray(); |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); |
| | | |
| | | ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(),acceptData.getSystem()); |
| | | |
| | | for (TLJFreeBuyGoods freeGoods : listFree) { |
| | | TaoBaoGoodsBrief goods = freeGoods.getGoods(); |
| | | if (goods == null) |
| | | continue; |
| | | |
| | | // 计算券后价 1<= n <= 2 |
| | | BigDecimal couplePrice = TaoBaoUtil.getAfterUseCouplePrice(goods); |
| | | if (couplePrice.compareTo(new BigDecimal(1.0)) < 0 && couplePrice.compareTo(new BigDecimal(2.0)) > 0) |
| | | continue; |
| | | |
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO); |
| | | |
| | | // 专属标签 |
| | | List<ClientTextStyleVO> labels = new ArrayList<ClientTextStyleVO>(); |
| | | labels.add(new ClientTextStyleVO("新人专属", "#FE0014")); |
| | | labels.add(new ClientTextStyleVO("实付0元", "#FF9600")); |
| | | detailVO.setLabels(labels); |
| | | array.add(gson.toJson(detailVO)); |
| | | } |
| | | |
| | | if (page > 1) |
| | | array.clear(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", array.size()); |
| | | data.put("list", array); |
| | | if (page == 1) { |
| | | try { |
| | | data.put("portrait", userInfoService.getUserInfo(uid).getPortrait()); |
| | | } catch (UserInfoException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, e.getMsg())); |
| | | return; |
| | | } |
| | | |
| | | String state = "已过期"; |
| | | BigDecimal balance = new BigDecimal(0); |
| | | UserTaoLiJinNewbies winDetail = userTaoLiJinNewbiesService.selectByPrimaryKey(uid); |
| | | if (winDetail != null) { |
| | | balance = winDetail.getMoney(); |
| | | if (winDetail.getEndTime().getTime() > java.lang.System.currentTimeMillis()) { |
| | | try { |
| | | String remaining = DateUtil.dateDiff2(new Date(), winDetail.getEndTime()); |
| | | if (!remaining.equals("0分")) |
| | | state = "剩" + remaining + "过期"; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | String rule = configTaoLiJinService.getValueByKey("new_user_free_buy_list_rule"); |
| | | rule = rule.replace("{链接}", configService.getValue(ConfigKeyEnum.customerServiceLink.getKey(),acceptData.getSystem())); |
| | | |
| | | data.put("state", state); |
| | | data.put("balance", "新人红包:" + balance.setScale(2) + "元"); |
| | | data.put("rule", rule); |
| | | } |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | } |