Commit 65647a75 by 魏文甫

update

1 parent 0437f8ba
...@@ -2,9 +2,7 @@ package com.server.utils; ...@@ -2,9 +2,7 @@ package com.server.utils;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.*;
import java.util.Date;
import java.util.TimeZone;
/** /**
* @author ZMS * @author ZMS
...@@ -196,9 +194,28 @@ public class DateUtils { ...@@ -196,9 +194,28 @@ public class DateUtils {
return myCal.compareTo(compareCal); return myCal.compareTo(compareCal);
} }
/**
* 获取当月所有天
*
* @return
*/
public static List<String> getDayListOfMonth() {
List<String> list = new ArrayList<String>();
Calendar aCalendar = Calendar.getInstance(Locale.CHINA);
int year = aCalendar.get(Calendar.YEAR);//年份
int month = aCalendar.get(Calendar.MONTH) + 1;//月份
int day = aCalendar.getActualMaximum(Calendar.DATE);
for (int i = 1; i <= day; i++) {
String aDate = (month < 10 ? (("0") + month) : month) + "/" + (i < 10 ? ("0" + i) : i);
list.add(aDate);
}
return list;
}
public static void main(String[] args) {
public static void main(String[] args) {
List<String> list = getDayListOfMonth();
System.out.println(list);
} }
......
...@@ -12,10 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -12,10 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* Created by 豆腐干Sama on 2018/12/6. * Created by 豆腐干Sama on 2018/12/6.
...@@ -95,12 +92,34 @@ public class UserServiceImpl implements UserService { ...@@ -95,12 +92,34 @@ public class UserServiceImpl implements UserService {
@Override @Override
public Map<String, Object> signInList(TKzyUser loginUser) { public Map<String, Object> signInList(TKzyUser loginUser) {
//List<String> dayList = getDayListOfMonth();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd");
Map<String, Object> param = new HashMap<String, Object>(); Map<String, Object> param = new HashMap<String, Object>();
param.put("userId", loginUser.getId()); param.put("userId", loginUser.getId());
param.put("month", simpleDateFormat.format(new Date())); param.put("month", simpleDateFormat.format(new Date()));
List<Map<String, Object>> list = integralMapper.signInList(param); List<Map<String, Object>> list = integralMapper.signInList(param);
List<String> hasSignDay = new ArrayList<>();
for (Map<String, Object> map : list) {
String dd = (String) map.get("days");
String[] _D = dd.split("/");
String ymd = _D[0] + "/" + (_D[1].startsWith("0") ? (_D[1].substring(1, _D[1].length())) : _D[1]) + "/" + (_D[2].startsWith("0") ? (_D[2].substring(0, _D[2].length())) : _D[2]);
hasSignDay.add(ymd);
}
/*List<Map<String, Object>> daysList = new ArrayList<>();
Map<String, Object> flag = null;
for (String everyDay : dayList) {
flag = new HashMap<>();
flag.put("day", everyDay);
if (hasSignDay.contains(everyDay)) {
flag.put("signFlag", 1);
} else {
flag.put("signFlag", 0);
}
daysList.add(flag);
}*/
Map<String, Object> param2 = new HashMap<String, Object>(); Map<String, Object> param2 = new HashMap<String, Object>();
...@@ -111,7 +130,8 @@ public class UserServiceImpl implements UserService { ...@@ -111,7 +130,8 @@ public class UserServiceImpl implements UserService {
Map<String, Object> dataMap = new HashMap<>(); Map<String, Object> dataMap = new HashMap<>();
dataMap.put("list", list); dataMap.put("list", list);
dataMap.put("todaySign", todaySign); dataMap.put("todaySign", todaySign);
return ResultMapUtil.returnMap("1", "", list); dataMap.put("daysList", hasSignDay);
return ResultMapUtil.returnMap("1", "", dataMap);
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
SELECT SELECT
t.id, t.id,
t.create_dt AS createDt, t.create_dt AS createDt,
date_format(t.create_dt,'%Y/%m/%d') AS days,
t.integral t.integral
FROM FROM
t_kzy_user_integral_flowing t t_kzy_user_integral_flowing t
...@@ -24,7 +25,7 @@ ...@@ -24,7 +25,7 @@
WHERE WHERE
t.source_type = 1 t.source_type = 1
AND t.user_id = #{userId,jdbcType=BIGINT} AND t.user_id = #{userId,jdbcType=BIGINT}
AND DATE_FORMAT(t.create_dt, '%Y-%m-%') = #{today,jdbcType=VARCHAR} AND DATE_FORMAT(t.create_dt, '%Y-%m-%d') = #{today,jdbcType=VARCHAR}
ORDER BY t.id DESC limit 0,1 ORDER BY t.id DESC limit 0,1
</select> </select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!