Commit c7508fad by 魏文甫

Merge branch 'wei_master' into '105'

update

See merge request !10
2 parents 77871fef 4efb2b99
package com.server.web.common.mapping;
import java.util.List;
import java.util.Map;
/**
* Created by weiwenfu@163.com on 2020/3/13 下午 4:09.
*/
public interface IntegralMapper {
List<Map<String, Object>> signInList(Map<String, Object> param);
}
......@@ -149,6 +149,7 @@ public class TKzyCourseServiceImpl implements TKzyCourseService {
courseMap.put("endDt", tKzyCourse.getEndDt());
courseMap.put("picUrl", tKzyCourse.getPicUrl());
courseMap.put("liveUrl", tKzyCourse.getLiveUrl());
courseMap.put("courseType", tKzyCourse.getCourseType());
resultMap.put("data", courseMap);
return resultMap;
......
package com.server.web.common.service.Impl;
import com.server.utils.ResultMapUtil;
import com.server.web.common.mapper.TKzyUserIntegralFlowingMapper;
import com.server.web.common.mapper.TKzyUserMapper;
import com.server.web.common.mapping.IntegralMapper;
import com.server.web.common.model.TKzyUser;
import com.server.web.common.model.TKzyUserIntegralFlowing;
import com.server.web.common.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by 豆腐干Sama on 2018/12/6.
*/
@Service
public class UserServiceImpl implements UserService {
@Autowired
private TKzyUserMapper tKzyUserMapper;
@Autowired
private TKzyUserIntegralFlowingMapper tKzyUserIntegralFlowingMapper;
@Autowired
private IntegralMapper integralMapper;
@Override
public void save(TKzyUser user) {
}
@Override
public Map signIn(TKzyUser loginUser) {
if (loginUser == null || loginUser.getId() == null) {
return ResultMapUtil.returnMap("0", "请先登录!", null);
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
if (loginUser.getLastSignDt() != null && simpleDateFormat.format(loginUser.getLastSignDt()).equals(simpleDateFormat.format(new Date()))) {
return ResultMapUtil.returnMap("0", "您已签到!", null);
}
TKzyUserIntegralFlowing tKzyUserIntegralFlowing = new TKzyUserIntegralFlowing();
tKzyUserIntegralFlowing.setCreateDt(new Date());
tKzyUserIntegralFlowing.setSourceType(1);
tKzyUserIntegralFlowing.setType(1);
if (loginUser.getIntegral() == null) {
loginUser.setIntegral(0);
}
if (loginUser.getSignInCount() == null) {
loginUser.setSignInCount(0);
}
if (loginUser.getSignInCount() <= 2) {
loginUser.setIntegral(loginUser.getIntegral() + 1);
loginUser.setSignInCount(loginUser.getSignInCount() + 1);
tKzyUserIntegralFlowing.setIntegral(1);
} else if (loginUser.getSignInCount() == 3) {
loginUser.setIntegral(loginUser.getIntegral() + 3);
loginUser.setSignInCount(loginUser.getSignInCount() + 1);
tKzyUserIntegralFlowing.setIntegral(3);
} else if (loginUser.getSignInCount() == 4) {
loginUser.setIntegral(loginUser.getIntegral() + 3);
loginUser.setSignInCount(loginUser.getSignInCount() + 1);
tKzyUserIntegralFlowing.setIntegral(1);
} else if (loginUser.getSignInCount() == 5) {
loginUser.setIntegral(loginUser.getIntegral() + 5);
loginUser.setSignInCount(1);
tKzyUserIntegralFlowing.setIntegral(5);
} else {
loginUser.setIntegral(1);
loginUser.setSignInCount(1);
tKzyUserIntegralFlowing.setIntegral(1);
}
loginUser.setLastSignDt(new Date());
tKzyUserMapper.updateByPrimaryKeySelective(loginUser);
tKzyUserIntegralFlowingMapper.insertSelective(tKzyUserIntegralFlowing);
return ResultMapUtil.returnMap("1", "操作成功!", null);
}
@Override
public Map<String, Object> signInList(TKzyUser loginUser) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
Map<String, Object> param = new HashMap<String, Object>();
param.put("userId", loginUser.getId());
param.put("month", simpleDateFormat.format(new Date()));
List<Map<String, Object>> list = integralMapper.signInList(param);
return ResultMapUtil.returnMap("1", "", list);
}
}
......@@ -2,9 +2,15 @@ package com.server.web.common.service;
import com.server.web.common.model.TKzyUser;
import java.util.Map;
/**
* Created by 豆腐干Sama on 2018/12/6.
*/
public interface UserService {
void save(TKzyUser user);
Map<String, Object> signIn(TKzyUser loginUser);
Map<String, Object> signInList(TKzyUser loginUser);
}
package com.server.web.controller;
import com.server.utils.ResultMapUtil;
import com.server.utils.SendSMSUtil;
import com.server.utils.VerifyCodeUtils;
import com.server.web.common.model.TKzyUser;
import com.server.web.common.model.TKzyUserExample;
import com.server.web.common.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
......@@ -21,6 +24,8 @@ import java.util.concurrent.TimeUnit;
@RestController
@RequestMapping(value = BaseController.WX_NAMESPACE + "/user", produces = "application/json")
public class UserController extends BaseController {
@Autowired
UserService userService;
@GetMapping("/userData")
......@@ -69,7 +74,7 @@ public class UserController extends BaseController {
user.setWxOpenid(wxOpenId);
user.setCreateDt(new Date());
user.setUserCategory(userCategory==null?null:Integer.valueOf(userCategory));
user.setUserCategory(userCategory == null ? null : Integer.valueOf(userCategory));
user.setFullName(fullName);
user.setPhone(phone);
user.setStatus(1);
......@@ -210,6 +215,36 @@ public class UserController extends BaseController {
}
}
/**
* 签到
*
* @param request
* @return
*/
@GetMapping("/signIn")
public Map<String, Object> signIn(HttpServletRequest request) {
TKzyUser loginUser = getLoginUser(request);
if (loginUser == null || loginUser.getId() == null) {
return ResultMapUtil.returnMap("0", "请先登录!", null);
}
return userService.signIn(loginUser);
}
/**
* 签到日历
*
* @param request
* @return
*/
@GetMapping("/signInList")
public Map<String, Object> signInList(HttpServletRequest request) {
TKzyUser loginUser = getLoginUser(request);
if (loginUser == null || loginUser.getId() == null) {
return ResultMapUtil.returnMap("0", "请先登录!", null);
}
return userService.signInList(loginUser);
}
public static String generateVerifyCode(int verifySize) {
String sources = "ABCDEFGHJKMNPQRSTUVWXYZ2345689";
int codesLen = sources.length();
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.server.web.common.mapping.IntegralMapper">
<select id="signInList" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT
t.id,
t.create_dt AS t.createDt,
t.integral
FROM
t_kzy_user_integral_flowing t
WHERE
t.source_type = 1
AND t.user_id = #{userId,jdbcType=BIGINT}
AND DATE_FORMAT(t.create_dt, '%Y-%m') = #{month,jdbcType=VARCHAR}
</select>
</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!