Commit c496019a authored by cy's avatar cy

手动给用户添加查询点数

parent cbd95f25
...@@ -42,4 +42,13 @@ public interface UserLimitService { ...@@ -42,4 +42,13 @@ public interface UserLimitService {
* @return true or false * @return true or false
*/ */
R<Boolean> minusLimitUser(UserLimit userLimit); R<Boolean> minusLimitUser(UserLimit userLimit);
/**
* 给用户添加查询点数
* @param phone
* @param number
* @return
*/
R<Boolean> addPoint(String phone,Integer number);
} }
...@@ -15,6 +15,9 @@ import org.apache.commons.lang.StringUtils; ...@@ -15,6 +15,9 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
/** /**
* @author 86187 * @author 86187
*/ */
...@@ -43,6 +46,9 @@ public class UserLimitServiceImpl extends ServiceImpl<UserLimitMapper, UserLimit ...@@ -43,6 +46,9 @@ public class UserLimitServiceImpl extends ServiceImpl<UserLimitMapper, UserLimit
@Autowired @Autowired
private RefillCardMapper refillCardMapper; private RefillCardMapper refillCardMapper;
@Autowired
private UsersMapper usersMapper;
@Override @Override
public R<UserLimit> getByUserId(Integer userId) { public R<UserLimit> getByUserId(Integer userId) {
log.info("volunteer-service[]UserLimitServiceImpl[]getByUserId[]input.param.userId:" + userId); log.info("volunteer-service[]UserLimitServiceImpl[]getByUserId[]input.param.userId:" + userId);
...@@ -156,6 +162,8 @@ public class UserLimitServiceImpl extends ServiceImpl<UserLimitMapper, UserLimit ...@@ -156,6 +162,8 @@ public class UserLimitServiceImpl extends ServiceImpl<UserLimitMapper, UserLimit
return R.ok(1, false); return R.ok(1, false);
} }
@Override @Override
public R<Boolean> minusLimit(Integer userId) { public R<Boolean> minusLimit(Integer userId) {
log.info("volunteer-service[]UserLimitServiceImpl[]minusLimit[]input.param.userId:" + userId); log.info("volunteer-service[]UserLimitServiceImpl[]minusLimit[]input.param.userId:" + userId);
...@@ -188,4 +196,39 @@ public class UserLimitServiceImpl extends ServiceImpl<UserLimitMapper, UserLimit ...@@ -188,4 +196,39 @@ public class UserLimitServiceImpl extends ServiceImpl<UserLimitMapper, UserLimit
} }
return R.ok(1, false); return R.ok(1, false);
} }
@Override
public R<Boolean> addPoint(String phone, Integer number) {
if(StringUtils.isBlank(phone) || StringUtils.isBlank(number+"")){
return R.error("入参不能为空!");
}
HashMap<String, Object> map = new HashMap<>();
map.put("phone",phone);
User userInfo = usersMapper.selectOne(map);
if(null == userInfo){
return R.error("该账号不存在");
}
UserLimit userLimit = new UserLimit();
userLimit.setUserId(userInfo.getId());
QueryWrapper<UserLimit> userLim = new QueryWrapper<UserLimit>().eq("user_id", userInfo.getId());
UserLimit userLimitInfo = userLimitMapper.selectOne(userLim);
int add;
if(null==userLimitInfo){
userLimit.setTotalLimit(number);
userLimit.setUsableLimit(number);
userLimit.setCreateTime(new Date());
userLimit.setUpdateTime(new Date());
add = userLimitMapper.insert(userLimit);
}else{
userLimit.setId(userLimitInfo.getId());
userLimit.setTotalLimit(userLimitInfo.getTotalLimit()+number);
userLimit.setUsableLimit(userLimitInfo.getUsableLimit()+number);
userLimit.setUpdateTime(new Date());
add = userLimitMapper.updateById(userLimit);
}
if(add>0){
return R.ok(0, true);
}
return R.ok(1, false);
}
} }
...@@ -77,4 +77,5 @@ public class RefillCardController { ...@@ -77,4 +77,5 @@ public class RefillCardController {
return refillCardService.createExcel(batchNumber,response); return refillCardService.createExcel(batchNumber,response);
} }
} }
...@@ -7,6 +7,7 @@ import cn.wisenergy.model.vo.MinusLimitVo; ...@@ -7,6 +7,7 @@ import cn.wisenergy.model.vo.MinusLimitVo;
import cn.wisenergy.service.app.UserLimitService; import cn.wisenergy.service.app.UserLimitService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -64,5 +65,16 @@ public class UserLimitController { ...@@ -64,5 +65,16 @@ public class UserLimitController {
return userLimitService.minusLimit(minusLimitVo.getUserId()); return userLimitService.minusLimit(minusLimitVo.getUserId());
} }
@ApiOperation(value = "给用户添加查询点数",notes = "给用户添加查询点数",httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "phone",value = "号码",dataType="String"),
@ApiImplicitParam(name = "number",value = "充值点数",dataType="int")
})
@GetMapping("/addPoint")
public R<Boolean> addPoint(String phone,Integer number){
log.info("volunteer-service[]UserLimitController[]addPoint[]input.param.phone:"+phone+"number:"+number);
return userLimitService.addPoint(phone,number);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment