| | |
| | | package com.yeshi.makemoney.app.controller.admin.goldcorn; |
| | | |
| | | import com.google.gson.*; |
| | | import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornGetRecordService; |
| | | import com.yeshi.makemoney.app.utils.SystemInfoUtil; |
| | | import com.yeshi.makemoney.app.utils.goldcorn.GoldCornUtil; |
| | | import com.yeshi.makemoney.app.vo.AcceptAdminData; |
| | | import com.yeshi.makemoney.app.vo.admin.goldcorn.GoldCornMoneyExchangeRateAdminVO; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.StringUtil; |
| | | import org.yeshi.utils.SystemUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import com.google.gson.reflect.TypeToken; |
| | |
| | | import javax.servlet.http.HttpSession; |
| | | import java.lang.reflect.Type; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.makemoney.app.entity.goldcorn.GoldCornMoneyExchangeRateRecord; |
| | | import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornMoneyExchangeRateRecordService; |
| | | import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornMoneyExchangeRateRecordQuery; |
| | | import org.yeshi.utils.statistic.BaseStatisticTimeQuery; |
| | | import org.yeshi.utils.statistic.StatisticNumberResult; |
| | | import org.yeshi.utils.statistic.StatisticTimeSpan; |
| | | |
| | | @Controller |
| | | @RequestMapping("admin/api/goldcorn/exchangerate") |
| | |
| | | |
| | | @Resource |
| | | private GoldCornMoneyExchangeRateRecordService goldCornMoneyExchangeRateRecordService; |
| | | |
| | | @Resource |
| | | private GoldCornGetRecordService goldCornGetRecordService; |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("add") |
| | | public String add(GoldCornMoneyExchangeRateAdminVO vo, HttpSession session) { |
| | | public String add(String day,String money, String validateTime, AcceptAdminData acceptAdminData) { |
| | | |
| | | if (StringUtil.isNullOrEmpty(money)) { |
| | | return JsonUtil.loadFalseResult("金额不能为空"); |
| | | } |
| | | |
| | | GoldCornMoneyExchangeRateAdminVO vo = new GoldCornMoneyExchangeRateAdminVO(); |
| | | vo.setDay(day); |
| | | vo.setValidateTime(validateTime); |
| | | //查询日期的金币数量 |
| | | BaseStatisticTimeQuery timeQuery = new BaseStatisticTimeQuery(); |
| | | timeQuery.setStartTime(GoldCornUtil.convertFormatDay(day)); |
| | | timeQuery.setEndTime(GoldCornUtil.convertFormatDay(day)); |
| | | timeQuery.setTimeSpan(StatisticTimeSpan.day); |
| | | List<StatisticNumberResult> list = goldCornGetRecordService.statistic(acceptAdminData.getSystem(), timeQuery); |
| | | if (list == null || list.size() == 0) { |
| | | return JsonUtil.loadFalseResult("统计出错"); |
| | | } |
| | | |
| | | long number = list.get(0).getNumber(); |
| | | //0.1的税 |
| | | vo.setRate(new BigDecimal(money).multiply(new BigDecimal("0.9")).divide(new BigDecimal(number),7, RoundingMode.FLOOR)); |
| | | try { |
| | | GoldCornMoneyExchangeRateRecord bean = vo.toEntity(SystemInfoUtil.getAdminSelectedSystem(session)); |
| | | GoldCornMoneyExchangeRateRecord bean = vo.toEntity(acceptAdminData.getSystem()); |
| | | goldCornMoneyExchangeRateRecordService.add(bean); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } catch (Exception e) { |