Commit 8e95945e authored by shangtx's avatar shangtx

feat: 我的信息

parent fb64b9b5
......@@ -52,7 +52,7 @@ public class CurrentUserIdResolver implements HandlerMethodArgumentResolver {
String parameterTypeName = parameter.getParameterType().getName();
if (ObjectUtils.isEmpty(currentUserId)) {
// 先确认jwt拦截器 是否将数据成功放到Request中
throw new ServiceException("CURRENT_USER_ID数据不存在");
return null;
} else if ("java.lang.Long".equals(parameterTypeName)) {
return Long.valueOf(currentUserId.toString());
} else if ("java.lang.Integer".equals(parameterTypeName)) {
......
......@@ -11,6 +11,7 @@ import lombok.Getter;
*/
public enum ServiceUserTypeEnum {
SALES(3, "销售"),
VALUATOR(2, "估价员: "),
......
package com.onsiteservice.miniapp.controller.category;
import com.onsiteservice.common.annotation.user.CurrentUserId;
import com.onsiteservice.core.result.Result;
import com.onsiteservice.miniapp.controller.category.vo.HomeViewVO;
import com.onsiteservice.miniapp.controller.category.vo.ServiceAreaVO;
......@@ -34,8 +35,8 @@ public class HomeCommonController {
@ApiOperation(value = "首页")
@GetMapping("home")
public Result<HomeViewVO> home() {
return homeCommonService.home();
public Result<HomeViewVO> home(@CurrentUserId Long userId) {
return homeCommonService.home(userId);
}
@ApiOperation(value = "地域树")
......
......@@ -26,4 +26,7 @@ public class HomeViewVO {
@ApiModelProperty("服务")
private List<ServiceCategoryVO> serviceList;
@ApiModelProperty("0 普通用户 1 客服 2 估价员 3 销售")
private Integer roleType;
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.onsiteservice.miniapp.controller.order;
import com.onsiteservice.common.annotation.user.CurrentUserId;
import com.onsiteservice.common.order.dto.*;
import com.onsiteservice.common.order.vo.OrderPayVO;
import com.onsiteservice.common.order.vo.ServiceOrderLogVO;
import com.onsiteservice.common.order.vo.ServiceOrderVO;
import com.onsiteservice.constant.enums.ServiceOrderOpSourceEnum;
......@@ -21,6 +22,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.Positive;
import java.util.List;
......@@ -133,4 +135,17 @@ public class ServiceOrderController {
}
/**
* 支付订单
*/
/* @PutMapping("/pay/{orderId}")
@ApiOperation(value = "发起支付")
public Result<OrderPayVO> pay(@ApiParam(value = "订单id", required = true) @PathVariable Long orderId, @CurrentUserId Long userId, HttpServletRequest request) {
HotelOrderPayVO result = hotelOrderService.pay(orderId, currentUserInfo, request);
if (null == result) {
fail("支付已超时");
}
return success(hotelOrderService.pay(orderId, currentUserInfo, request));
}*/
}
......@@ -2,17 +2,16 @@ package com.onsiteservice.miniapp.controller.user;
import com.onsiteservice.common.annotation.user.CurrentUserId;
import com.onsiteservice.core.result.Result;
import com.onsiteservice.core.result.ResultGenerator;
import com.onsiteservice.miniapp.controller.user.dto.BindPhoneDTO;
import com.onsiteservice.miniapp.controller.user.dto.SendCodeDTO;
import com.onsiteservice.miniapp.controller.user.vo.UserInfoVO;
import com.onsiteservice.miniapp.service.user.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.NonNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -42,6 +41,11 @@ public class UserController {
return userService.rebindPhone(dto, userId);
}
@ApiOperation("用户信息")
@GetMapping("/info")
public Result<UserInfoVO> getInfo(@CurrentUserId Long userId) {
return ResultGenerator.success(userService.getInfo(userId));
}
}
package com.onsiteservice.miniapp.controller.user.convert;
import com.onsiteservice.entity.user.User;
import com.onsiteservice.miniapp.controller.user.vo.UserInfoVO;
import org.mapstruct.Mapper;
@Mapper(componentModel = "spring")
public interface UserConvert {
UserInfoVO toUserVO(User user);
}
package com.onsiteservice.miniapp.controller.user.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.List;
@Data
public class UserInfoVO {
/**
* 主键
*/
@ApiModelProperty("主键")
private Long id;
/**
* 用户名
*/
@ApiModelProperty("用户名")
private String userName;
@ApiModelProperty("昵称")
private String nickName;
@ApiModelProperty("手机号")
private String phone;
@ApiModelProperty("邮箱")
private String email;
/**
* 头像
*/
@ApiModelProperty("头像")
private String avatar;
@ApiModelProperty("性别 0: 未知 1: 男 2: 女")
private Integer sex;
@ApiModelProperty("0 普通用户 1 客服 2 估价员 3 销售")
private Integer roleType;
@ApiModelProperty("订单信息")
private List<UserOrderInfoVO> orderInfo;
}
package com.onsiteservice.miniapp.controller.user.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
@Data
public class UserOrderInfoVO {
@ApiModelProperty("状态")
private String title;
@ApiModelProperty("数量")
private Long num;
}
......@@ -43,4 +43,7 @@ public class LoginDTO {
private String signature;
private String rawData;
@ApiModelProperty("分享者用户id")
private Long shareUserId;
}
......@@ -6,6 +6,7 @@ import com.onsiteservice.miniapp.controller.order.dto.PageServiceOrderDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @author 潘维吉
......@@ -16,4 +17,6 @@ public interface ServiceOrderBizMapper {
List<ServiceOrder> selectServiceOrderPage(@Param("dto") PageServiceOrderDTO dto, @Param("userId") Long userId);
Map<String, Long> getMyOrderNum(@Param("accountNo") Long userId);
}
......@@ -4,14 +4,17 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.onsiteservice.constant.constant.BizConstants;
import com.onsiteservice.constant.constant.RedisKeyConstants;
import com.onsiteservice.constant.enums.ServiceUserTypeEnum;
import com.onsiteservice.core.result.Result;
import com.onsiteservice.core.result.ResultGenerator;
import com.onsiteservice.dao.mapper.banner.BannerMapper;
import com.onsiteservice.dao.mapper.home.HomeNoticeMapper;
import com.onsiteservice.dao.mapper.service.ServiceAreaMapper;
import com.onsiteservice.dao.mapper.user.UserMapper;
import com.onsiteservice.entity.area.ServiceArea;
import com.onsiteservice.entity.banner.Banner;
import com.onsiteservice.entity.home.HomeNotice;
import com.onsiteservice.entity.user.User;
import com.onsiteservice.miniapp.controller.category.vo.*;
import com.onsiteservice.util.AttrCopyUtils;
import com.onsiteservice.util.tree.TreeUtils;
......@@ -49,8 +52,11 @@ public class HomeCommonService {
@Autowired
private StringRedisTemplate redisTemplate;
@Resource
private UserMapper userMapper;
public Result<HomeViewVO> home() {
public Result<HomeViewVO> home(Long userId) {
// 轮播图
List<Banner> bannerList = bannerMapper.selectAll();
List<BannerVO> bannerVOList = bannerList.parallelStream()
......@@ -70,11 +76,13 @@ public class HomeCommonService {
.bannerList(bannerVOList)
.noticeList(homeNoticeVOList)
.serviceList(serviceResult.getData())
.roleType(getRoleType(userId))
.build();
return ResultGenerator.success(homeViewVO);
}
public Result tree() {
String value = redisTemplate.opsForValue().get(RedisKeyConstants.SERVICE_AREA_TREE);
try {
......@@ -94,5 +102,14 @@ public class HomeCommonService {
return ResultGenerator.success(list);
}
private Integer getRoleType(Long userId) {
if(userId == null) {
return ServiceUserTypeEnum.USER.getId();
}
Condition condition = new Condition(User.class);
var user = userMapper.selectByPrimaryKey(userId);
return user.getRoleType();
}
}
......@@ -231,6 +231,11 @@ public class ServiceOrderBizService extends AbstractMapper<ServiceOrder> {
return result;
}
/**
* 生成支付参数
*/
/**
* 未派单订单 用户可实时退款
......
......@@ -9,8 +9,12 @@ import com.onsiteservice.core.result.ResultGenerator;
import com.onsiteservice.dao.common.AbstractMapper;
import com.onsiteservice.dao.mapper.user.UserMapper;
import com.onsiteservice.entity.user.User;
import com.onsiteservice.miniapp.controller.user.convert.UserConvert;
import com.onsiteservice.miniapp.controller.user.dto.BindPhoneDTO;
import com.onsiteservice.miniapp.controller.user.dto.SendCodeDTO;
import com.onsiteservice.miniapp.controller.user.vo.UserInfoVO;
import com.onsiteservice.miniapp.controller.user.vo.UserOrderInfoVO;
import com.onsiteservice.miniapp.mapper.order.ServiceOrderBizMapper;
import com.onsiteservice.util.RandomUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -20,6 +24,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Service
......@@ -33,6 +38,10 @@ public class UserService extends AbstractMapper<User> {
@Resource
private UserMapper userMapper;
@Resource
private UserConvert userConvert;
@Resource
private ServiceOrderBizMapper serviceOrderBizMapper;
public Result<String> sendCode(SendCodeDTO dto) {
......@@ -92,5 +101,20 @@ public class UserService extends AbstractMapper<User> {
return false;
}
/**
* 获取用户信息
*/
public UserInfoVO getInfo(Long userId) {
var user = userMapper.selectByPrimaryKey(userId);
var vo = userConvert.toUserVO(user);
// 获取订单状况
var numMap = serviceOrderBizMapper.getMyOrderNum(userId);
vo.setOrderInfo(List.of(
new UserOrderInfoVO("待支付", numMap.get("pay")),
new UserOrderInfoVO("待受理", numMap.get("handle")),
new UserOrderInfoVO("待派单", numMap.get("dispatch")),
new UserOrderInfoVO("已完成", numMap.get("finished"))
));
return vo;
}
}
......@@ -7,6 +7,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
import com.google.common.collect.ImmutableMap;
import com.onsiteservice.common.service.dto.MiniQrCodeDTO;
import com.onsiteservice.constant.enums.ServiceUserTypeEnum;
import com.onsiteservice.core.exception.ServiceException;
import com.onsiteservice.core.result.Result;
import com.onsiteservice.core.security.jwt.JwtManager;
......@@ -94,6 +95,7 @@ public class WeiXinService {
.openId(openId)
.avatar(avatarUrl)
.sex(Integer.parseInt(userInfo.getGender()))
.roleType(ServiceUserTypeEnum.USER.getId())
.build();
userService.insertSelective(user);
return toLogin(user, user.getId(), "注册成功");
......
......@@ -14,5 +14,14 @@
order by create_time asc
</select>
<select id="getMyOrderNum" resultType="java.util.Map">
select count(if(order_status = 3, id, null)) `pay`,
count(if(order_status = 1 or order_status = 2, id, null)) `handle`,
count(if(order_status = 4, id, null)) `dispatch`,
count(if(order_status = 6, id, null)) `finished`
from service_order
where account_no = #{accountNo}
</select>
</mapper>
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