| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.util.ArrayList;
|
| | |
| | | import com.google.gson.JsonPrimitive;
|
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | import com.google.gson.TypeAdapter;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | 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.UserTaoLiJinDetail.TaoLiJinDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserRank;
|
| | | import com.yeshi.fanli.entity.integral.CodePublishRecord;
|
| | |
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.integral.CodePublishRecordService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralDetailService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralExchangeService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralTaskClassService;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.vo.integral.DailySignVO;
|
| | | import com.yeshi.fanli.vo.integral.ExchangeTipVO;
|
| | | import com.yeshi.fanli.vo.integral.IntegralDetailVO;
|
| | | import com.yeshi.fanli.vo.integral.IntegralTaskClassVO;
|
| | | import com.yeshi.fanli.vo.user.UserInfoExtraVO;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private IntegralExchangeRecordService integralExchangeRecordService;
|
| | | |
| | | @Resource
|
| | | private IntegralDetailService integralDetailService;
|
| | |
|
| | | @Resource
|
| | | private CodePublishRecordService codePublishRecordService;
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | List<IntegralTaskRecord> list = integralTaskRecordService.listNotReceived(5, uid);
|
| | | int count = 5;
|
| | | if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
|
| | | count = Integer.MAX_VALUE;
|
| | | }
|
| | | |
| | | List<IntegralTaskRecord> list = integralTaskRecordService.listNotReceived(count, uid);
|
| | | if (list == null) {
|
| | | list = new ArrayList<IntegralTaskRecord>();
|
| | | }
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "receiveGoldCoin", method = RequestMethod.POST)
|
| | | public void receiveGoldCoin(AcceptData acceptData, Long uid, String ids, String gids, PrintWriter out) {
|
| | | public void receiveGoldCoin(AcceptData acceptData, Long uid, Integer type, String ids, String gids, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | Gson gson = new Gson();
|
| | | Set<Long> idList = gson.fromJson(ids, new TypeToken<HashSet<Long>>() {
|
| | | }.getType());
|
| | | if (idList == null || idList.size() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("领取id不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | |
|
| | | try {
|
| | | Integer goldCoin = integralTaskRecordService.receiveGoldCoin(uid, idList);
|
| | | // 全部领取
|
| | | if (type != null && type == 1) {
|
| | | Integer goldCoin = integralTaskRecordService.receiveGoldCoinALL(uid);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("goldCoin", goldCoin);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | } |
| | |
|
| | | // 部分领取
|
| | | Gson gson = new Gson();
|
| | | Set<Long> idList = gson.fromJson(ids, new TypeToken<HashSet<Long>>() {
|
| | | }.getType());
|
| | | if (idList == null || idList.size() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("领取id不能为空"));
|
| | | return;
|
| | | }
|
| | | Integer goldCoin = integralTaskRecordService.receiveGoldCoin(uid, idList);
|
| | | Set<Long> gidList = gson.fromJson(gids, new TypeToken<HashSet<Long>>() {}.getType());
|
| | | List<IntegralTaskRecord> list = null;
|
| | | if (gidList != null && gidList.size() > 0) {
|
| | |
| | | }
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson2 = gsonBuilder.create();
|
| | |
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("goldCoin", goldCoin);
|
| | | data.put("list", gson2.toJson(list));
|
| | |
| | | if (list == null)
|
| | | list = new ArrayList<IntegralExchange>();
|
| | |
|
| | | Long count = integralExchangeService.countValid();
|
| | | //Long count = integralExchangeService.countValid();
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson = gsonBuilder.create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("goldCoin", extraVO.getGoldCoin() + "枚");
|
| | | data.put("count", count);
|
| | | data.put("count", list.size());
|
| | | data.put("list", gson.toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
| | | return gson;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 明细详情
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param index
|
| | | * List最末的主键ID
|
| | | * @param year
|
| | | * 年份
|
| | | * @param month
|
| | | * 月份
|
| | | * @param type 统计类型 0全部 1
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getDetails")
|
| | | public void getDetails(AcceptData acceptData, Long uid, Long index, Integer year, Integer month, Integer type,
|
| | | 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<IntegralDetailVO> list = integralDetailService.listDetailForClient(uid, index, date);
|
| | | // 统计总条数
|
| | | long count = integralDetailService.countDetailForClient(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"));
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | Gson gson = gsonBuilder.create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("data", gson.toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | }
|