| | |
| | | |
| | | import com.google.gson.*; |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | import com.yeshi.makemoney.app.entity.goldcorn.GoldCornConsumeType; |
| | | import com.yeshi.makemoney.app.exception.goldcorn.GoldCornSettleRecordException; |
| | | import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornConsumeRecordService; |
| | | import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornSettleService; |
| | | import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornConsumeRecordQuery; |
| | | import com.yeshi.makemoney.app.utils.goldcorn.GoldCornUtil; |
| | | import com.yeshi.makemoney.app.vo.AcceptAdminData; |
| | | import net.sf.json.JSONArray; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.lang.reflect.Type; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | @Resource |
| | | private GoldCornSettleService goldCornSettleService; |
| | | |
| | | @Resource |
| | | private GoldCornConsumeRecordService goldCornConsumeRecordService; |
| | | |
| | | private Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | |
| | | @Override |
| | | public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) { |
| | | return date == null ? new JsonPrimitive("") : new JsonPrimitive(TimeUtil.getGernalTime(date.getTime(), "yyyy.MM.dd HH:mm")); |
| | | } |
| | | }).create(); |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("list") |
| | | public String list(GoldCornSettleRecordQuery query, int page, int limit) { |
| | | List<GoldCornSettleRecord> list = goldCornSettleRecordService.list(query, page, limit); |
| | | long count = goldCornSettleRecordService.count(query); |
| | | JSONObject data = new JSONObject(); |
| | | Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | |
| | | @Override |
| | | public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) { |
| | | return date == null ? new JsonPrimitive("") : new JsonPrimitive(TimeUtil.getGernalTime(date.getTime(), "yyyy.MM.dd HH:mm")); |
| | | } |
| | | }).create(); |
| | | |
| | | data.put("list", gson.toJson(list)); |
| | | data.put("count", count); |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("update") |
| | | public String update(GoldCornSettleRecord bean, HttpSession session) { |
| | | if (bean.getId() == null) { |
| | | @RequestMapping("refresh") |
| | | public String refresh(String id, AcceptAdminData acceptAdminData) { |
| | | if (id == null) { |
| | | return JsonUtil.loadFalseResult("ID不能为空"); |
| | | |
| | | } |
| | | try { |
| | | goldCornSettleRecordService.update(bean); |
| | | } catch (Exception e) { |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | | |
| | | GoldCornSettleRecord record = goldCornSettleRecordService.get(id); |
| | | if (record == null) { |
| | | return JsonUtil.loadFalseResult("记录不存在"); |
| | | } |
| | | return JsonUtil.loadTrueResult(""); |
| | | |
| | | GoldCornConsumeRecordQuery query = new GoldCornConsumeRecordQuery(); |
| | | query.setType(GoldCornConsumeType.changeMoney); |
| | | query.setEventId(id); |
| | | |
| | | BigDecimal money = goldCornConsumeRecordService.sumMoney(query); |
| | | Long userCount = goldCornConsumeRecordService.count(query); |
| | | |
| | | GoldCornSettleRecord update = new GoldCornSettleRecord(); |
| | | update.setId(id); |
| | | update.setTotalMoney(money); |
| | | update.setSettledUserCount(userCount); |
| | | goldCornSettleRecordService.update(update); |
| | | record.setTotalMoney(money); |
| | | record.setSettledUserCount(userCount); |
| | | return JsonUtil.loadTrueResult(gson.toJson(record)); |
| | | } |
| | | |
| | | |