New file |
| | |
| | | package com.yeshi.fanli.controller.client;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | 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.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.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
|
| | | import com.yeshi.fanli.service.inter.user.UserMoneyDetailService;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.vo.money.UserMoneyDetailHistoryVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 账户系统
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller
|
| | | @RequestMapping("api/v1/usermoney")
|
| | | public class UserMoneyController {
|
| | |
|
| | | @Resource
|
| | | private UserMoneyDetailService userMoneyDetailService;
|
| | |
|
| | | /**
|
| | | * 新版资金详情(1.4.9)
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param index
|
| | | * List最末的主键ID
|
| | | * @param year
|
| | | * 年份
|
| | | * @param month
|
| | | * 月份
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getUserMoneyDetailList")
|
| | | public void getUserMoneyDetailList(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"));
|
| | | }
|
| | | List<UserMoneyDetailHistoryVO> list = userMoneyDetailService.listUserMoneyDetailForClient(uid, index, date);
|
| | | long count = userMoneyDetailService.countUserMoneyDetailForClient(uid, index, date);
|
| | | GsonBuilder gsonBuilder = JsonUtil.getConvertBigDecimalToStringBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation();
|
| | | gsonBuilder.registerTypeAdapter(UserMoneyDetailTypeEnum.class, new TypeAdapter<UserMoneyDetailTypeEnum>() {
|
| | | @Override
|
| | | public UserMoneyDetailTypeEnum read(JsonReader arg0) throws IOException {
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void write(JsonWriter out, UserMoneyDetailTypeEnum arg1) throws IOException {
|
| | | out.beginObject();
|
| | | out.name("portrait").value(arg1.getPicture());
|
| | | out.name("helpUrl").value(arg1.getHelpUrl());
|
| | | 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("data", gson.toJson(list));
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | }
|