| | |
| | | package com.taoke.autopay.controller.admin; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.taoke.autopay.dto.UserSubmitKeyLimitDto; |
| | | import com.taoke.autopay.entity.SystemConfigKeyEnum; |
| | | import com.taoke.autopay.service.SystemConfigService; |
| | | import com.taoke.autopay.service.UserSettingService; |
| | | import com.taoke.autopay.vo.admin.IgnoreAgentOrderSettingVO; |
| | | import com.taoke.autopay.vo.admin.PayMoneySettingsVO; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | 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 javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | | @RequestMapping("/admin/api/settings") |
| | |
| | | SystemConfigKeyEnum[] keys = new SystemConfigKeyEnum[]{ |
| | | SystemConfigKeyEnum.DY_ORDER_MAX_PAY_COUNT_DEFAULT, |
| | | SystemConfigKeyEnum.KS_ORDER_MAX_PAY_COUNT_DEFAULT, |
| | | SystemConfigKeyEnum.ORDER_MAX_SUBMIT_COUNT_DEFAULT |
| | | SystemConfigKeyEnum.ORDER_MAX_SUBMIT_COUNT_DEFAULT, |
| | | SystemConfigKeyEnum.ALIPAY_KEY_VERIFY |
| | | }; |
| | | JSONObject data = new JSONObject(); |
| | | for (SystemConfigKeyEnum key : keys) { |
| | |
| | | SystemConfigKeyEnum[] keys = new SystemConfigKeyEnum[]{ |
| | | SystemConfigKeyEnum.DY_ORDER_MAX_PAY_COUNT_DEFAULT, |
| | | SystemConfigKeyEnum.KS_ORDER_MAX_PAY_COUNT_DEFAULT, |
| | | SystemConfigKeyEnum.ORDER_MAX_SUBMIT_COUNT_DEFAULT |
| | | SystemConfigKeyEnum.ORDER_MAX_SUBMIT_COUNT_DEFAULT, |
| | | SystemConfigKeyEnum.ALIPAY_KEY_VERIFY |
| | | }; |
| | | for (SystemConfigKeyEnum key : keys) { |
| | | String val = request.getParameter(key.getKey()); |
| | |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("setPayMoneyAndTime") |
| | | public String setPayMoneyAndTime(String startSubmitTime, String endSubmitTime) { |
| | | if (StringUtil.isNullOrEmpty(startSubmitTime)) { |
| | | return JsonUtil.loadFalseResult("未上传开始时间"); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(endSubmitTime)) { |
| | | return JsonUtil.loadFalseResult("未上传结束时间"); |
| | | } |
| | | // 设置时间,用逗号分隔 |
| | | systemConfigService.setValue(SystemConfigKeyEnum.KEY_SUBMIT_TIME_RANGE, startSubmitTime + "," + endSubmitTime); |
| | | systemConfigService.clearCache(); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getPayMoneyAndTime") |
| | | public String getPayMoneyAndTime() { |
| | | PayMoneySettingsVO vo = new PayMoneySettingsVO(); |
| | | vo.setMoneys(new ArrayList<>()); |
| | | // 设置时间,用逗号分隔 |
| | | String value = systemConfigService.getValue(SystemConfigKeyEnum.KEY_SUBMIT_TIME_RANGE); |
| | | if (StringUtil.isNullOrEmpty(value)) { |
| | | vo.setStartSubmitTime(""); |
| | | vo.setEndSubmitTime(""); |
| | | } else { |
| | | vo.setStartSubmitTime(value.split(",")[0]); |
| | | vo.setEndSubmitTime(value.split(",")[1]); |
| | | } |
| | | return JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(vo)); |
| | | } |
| | | |
| | | @Resource |
| | | private UserSettingService userSettingService; |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getUserSubmitKeyCountSetting") |
| | | public String getUserSubmitKeyCountSetting() { |
| | | List<UserSubmitKeyLimitDto> list = userSettingService.getUserSubmitKeyCountList(false); |
| | | return JsonUtil.loadTrueResult(new Gson().toJson(list)); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("setUserSubmitKeyCount") |
| | | public String setUserSubmitKeyCount(String value) { |
| | | List<UserSubmitKeyLimitDto> list = new Gson().fromJson(value, new TypeToken<List<UserSubmitKeyLimitDto>>() { |
| | | }.getType()); |
| | | userSettingService.setUserSubmitKeyCount(list); |
| | | return JsonUtil.loadTrueResult(new Gson().toJson(list)); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getTimeoutPayDevices") |
| | | public String getTimeoutPayDevices() { |
| | | String value = systemConfigService.getValue(SystemConfigKeyEnum.RE_EXCUTE_PAY_CLIENTS); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("timeout_devices", value); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("setTimeoutPayDevices") |
| | | public String setTimeoutPayDevices(String timeout_devices) { |
| | | timeout_devices = timeout_devices.trim(); |
| | | List<Long> idList = new ArrayList<>(); |
| | | String[] sts = timeout_devices.split(","); |
| | | for (String st : sts) { |
| | | st = st.trim(); |
| | | if (!StringUtil.isNullOrEmpty(st)) { |
| | | idList.add(Long.parseLong(st)); |
| | | } |
| | | } |
| | | String st = StringUtil.concat(idList, ","); |
| | | systemConfigService.setValue(SystemConfigKeyEnum.RE_EXCUTE_PAY_CLIENTS, st); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getForbiddenSubmitCitys") |
| | | public String getForbiddenSubmitCitys() { |
| | | String value = systemConfigService.getValue(SystemConfigKeyEnum.FORBIDDEN_SUBMIT_CITYS); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("citys", value); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("setForbiddenSubmitCitys") |
| | | public String setForbiddenSubmitCitys(String citys) { |
| | | systemConfigService.setValue(SystemConfigKeyEnum.FORBIDDEN_SUBMIT_CITYS, citys); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("getIgnoreAgentOrderSetting") |
| | | public String getIgnoreAgentOrderSetting() { |
| | | String value = systemConfigService.getValue(SystemConfigKeyEnum.IGNORE_AGENT_ORDER_SETTING); |
| | | IgnoreAgentOrderSettingVO vo = new IgnoreAgentOrderSettingVO(); |
| | | if (!StringUtil.isNullOrEmpty(value)) { |
| | | vo = new Gson().fromJson(value, IgnoreAgentOrderSettingVO.class); |
| | | } |
| | | return JsonUtil.loadTrueResult(vo); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("setIgnoreAgentOrderSetting") |
| | | public String setIgnoreAgentOrderSetting(IgnoreAgentOrderSettingVO vo) { |
| | | systemConfigService.setValue(SystemConfigKeyEnum.IGNORE_AGENT_ORDER_SETTING, new Gson().toJson(vo)); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | |
| | | } |