提交
This commit is contained in:
@ -91,6 +91,12 @@
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-biz-ip</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-module-system-biz</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 工具类相关 -->
|
||||
|
@ -63,14 +63,14 @@ public class AppUserAddressController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加或修改地址
|
||||
*/
|
||||
* 添加或修改地址
|
||||
*/
|
||||
@PreAuthenticated
|
||||
@PostMapping("/addAndEdit")
|
||||
@Operation(summary = "添加或修改地址")
|
||||
public CommonResult<Long> addYxUserAddress(@Valid @RequestBody AppAddressParam param){
|
||||
public CommonResult<Long> addYxUserAddress(@Valid @RequestBody AppAddressParam param) {
|
||||
Long uid = getLoginUserId();
|
||||
Long id = appUserAddressService.addAndEdit(uid,param);
|
||||
Long id = appUserAddressService.addAndEdit(uid, param);
|
||||
return success(id);
|
||||
}
|
||||
|
||||
@ -81,22 +81,21 @@ public class AppUserAddressController {
|
||||
@PostMapping("/default/set/{id}")
|
||||
@Parameter(name = "id", description = "地址id", required = true)
|
||||
@Operation(summary = "设置默认地址")
|
||||
public CommonResult<Boolean> setDefault(@PathVariable String id){
|
||||
public CommonResult<Boolean> setDefault(@PathVariable String id) {
|
||||
Long uid = getLoginUserId();
|
||||
appUserAddressService.setDefault(uid,id);
|
||||
appUserAddressService.setDefault(uid, id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除用户地址
|
||||
*/
|
||||
* 删除用户地址
|
||||
*/
|
||||
@PreAuthenticated
|
||||
@PostMapping("/del/{id}")
|
||||
@Operation(summary = "删除用户地址")
|
||||
public CommonResult<Boolean> deleteYxUserAddress(@PathVariable String id){
|
||||
if(StrUtil.isBlank(id) || !NumberUtil.isNumber(id)){
|
||||
public CommonResult<Boolean> deleteYxUserAddress(@PathVariable Long id) {
|
||||
if (id == null) {
|
||||
throw exception(USER_ADDRESS_PARAM_NOT_EXISTS);
|
||||
}
|
||||
appUserAddressService.removeById(id);
|
||||
@ -110,13 +109,12 @@ public class AppUserAddressController {
|
||||
@PreAuthenticated
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "用户地址列表")
|
||||
public CommonResult<List<AppUserAddressQueryVo>> getYxUserAddressPageList(@RequestParam(value = "page",defaultValue = "1") int page,
|
||||
@RequestParam(value = "limit",defaultValue = "10") int limit){
|
||||
public CommonResult<List<AppUserAddressQueryVo>> getYxUserAddressPageList(@RequestParam(value = "page", defaultValue = "1") int page,
|
||||
@RequestParam(value = "limit", defaultValue = "10") int limit) {
|
||||
Long uid = getLoginUserId();
|
||||
return success(appUserAddressService.getList(uid,page,limit));
|
||||
return success(appUserAddressService.getList(uid, page, limit));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,27 +1,27 @@
|
||||
package co.yixiang.yshop.module.member.controller.app.address.param;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName AddressDetailParam
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2023/6/28
|
||||
**/
|
||||
@Data
|
||||
public class AddressDetailParam implements Serializable {
|
||||
|
||||
@Schema(description = "城市ID", required = true)
|
||||
private Integer cityId;
|
||||
|
||||
@Schema(description = "城市", required = true)
|
||||
private String city;
|
||||
|
||||
@Schema(description = "地区", required = true)
|
||||
private String district;
|
||||
|
||||
@Schema(description = "省份", required = true)
|
||||
private String province;
|
||||
}
|
||||
package co.yixiang.yshop.module.member.controller.app.address.param;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName AddressDetailParam
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2023/6/28
|
||||
**/
|
||||
@Data
|
||||
public class AddressDetailParam implements Serializable {
|
||||
|
||||
@Schema(description = "城市ID", required = true)
|
||||
private Integer cityId;
|
||||
|
||||
@Schema(description = "城市", required = true)
|
||||
private String city;
|
||||
|
||||
@Schema(description = "地区", required = true)
|
||||
private String district;
|
||||
|
||||
@Schema(description = "省份", required = true)
|
||||
private String province;
|
||||
}
|
||||
|
@ -1,45 +1,45 @@
|
||||
package co.yixiang.yshop.module.member.controller.app.address.param;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName AddressParam
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2023/6/28
|
||||
**/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class AppAddressParam implements Serializable {
|
||||
|
||||
@Schema(description = "地址ID", required = true)
|
||||
private String id;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 1, max = 30,message = "长度超过了限制")
|
||||
@Schema(description = "收货地址真实名字", required = true)
|
||||
private String realName;
|
||||
|
||||
@Schema(description = "收货地址邮编", required = true)
|
||||
private String postCode;
|
||||
|
||||
@Schema(description = "是否默认收货地址 1是 0否", required = true)
|
||||
private Integer isDefault;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 1, max = 60,message = "长度超过了限制")
|
||||
@Schema(description = "收货详细地址", required = true)
|
||||
private String detail;
|
||||
|
||||
@NotBlank
|
||||
@Schema(description = "收货手机号码", required = true)
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "收货地址详情", required = true)
|
||||
private AddressDetailParam address;
|
||||
}
|
||||
package co.yixiang.yshop.module.member.controller.app.address.param;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName AddressParam
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2023/6/28
|
||||
**/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class AppAddressParam implements Serializable {
|
||||
|
||||
@Schema(description = "地址ID", required = true)
|
||||
private String id;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 1, max = 30,message = "长度超过了限制")
|
||||
@Schema(description = "收货地址真实名字", required = true)
|
||||
private String realName;
|
||||
|
||||
@Schema(description = "收货地址邮编", required = true)
|
||||
private String postCode;
|
||||
|
||||
@Schema(description = "是否默认收货地址 1是 0否", required = true)
|
||||
private Integer isDefault;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 1, max = 60,message = "长度超过了限制")
|
||||
@Schema(description = "收货详细地址", required = true)
|
||||
private String detail;
|
||||
|
||||
@NotBlank
|
||||
@Schema(description = "收货手机号码", required = true)
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "收货地址详情", required = true)
|
||||
private AddressDetailParam address;
|
||||
}
|
||||
|
@ -54,5 +54,8 @@ public class AppUserAddressQueryVo implements Serializable {
|
||||
@Schema(description = "是否默认", required = true, example = "24169")
|
||||
private Integer isDefault;
|
||||
|
||||
@Schema(description = "城市id", required = true, example = "24169")
|
||||
private Integer cityId;
|
||||
|
||||
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ public class AppAuthController {
|
||||
private SecurityProperties securityProperties;
|
||||
|
||||
@PostMapping("/login")
|
||||
@PermitAll
|
||||
@Operation(summary = "使用手机 + 密码登录")
|
||||
public CommonResult<AppAuthLoginRespVO> login(@RequestBody @Valid AppAuthLoginReqVO reqVO) {
|
||||
return success(authService.login(reqVO));
|
||||
@ -65,12 +66,14 @@ public class AppAuthController {
|
||||
// ========== 短信登录相关 ==========
|
||||
|
||||
@PostMapping("/sms-login")
|
||||
@PermitAll
|
||||
@Operation(summary = "使用手机 + 验证码登录")
|
||||
public CommonResult<AppAuthLoginRespVO> smsLogin(@RequestBody @Valid AppAuthSmsLoginReqVO reqVO) {
|
||||
return success(authService.smsLogin(reqVO));
|
||||
}
|
||||
|
||||
@PostMapping("/send-sms-code")
|
||||
@PermitAll
|
||||
@Operation(summary = "发送手机验证码")
|
||||
public CommonResult<Boolean> sendSmsCode(@RequestBody @Valid AppAuthSmsSendReqVO reqVO) {
|
||||
authService.sendSmsCode(getLoginUserId(), reqVO);
|
||||
|
@ -40,12 +40,15 @@ public class AppUserController {
|
||||
@Parameter(name = "nickname", description = "用户昵称",
|
||||
required = true, example = "wang"),
|
||||
@Parameter(name = "birthday", description = "生日",
|
||||
required = true, example = "2023-11-12")
|
||||
required = true, example = "2023-11-12"),
|
||||
@Parameter(name = "sex", description = "性别",
|
||||
required = true, example = "1")
|
||||
})
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> updateUserNickname(@RequestParam("nickname") String nickname,
|
||||
@RequestParam("birthday") String birthday) {
|
||||
userService.updateUserNickname(getLoginUserId(), nickname,birthday);
|
||||
@RequestParam("birthday") String birthday,
|
||||
@RequestParam("sex") Integer sex) {
|
||||
userService.updateUserNickname(getLoginUserId(), nickname, birthday, sex);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@ -25,4 +25,7 @@ public class AppUserInfoRespVO {
|
||||
|
||||
@Schema(description = "生日", required = true, example = "2023-10-11")
|
||||
private String birthday;
|
||||
|
||||
@Schema(description = "性别", required = true, example = "1")
|
||||
private Integer sex;
|
||||
}
|
||||
|
@ -1,52 +1,52 @@
|
||||
package co.yixiang.yshop.module.member.controller.app.user.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName OrderCountDTO
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2023/6/18
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Schema(description = "用户 APP - 用户 OrderCountDTO")
|
||||
public class AppUserOrderCountVo implements Serializable {
|
||||
|
||||
/**订单支付没有退款 数量*/
|
||||
@Schema(description = "订单支付没有退款数量", required = true)
|
||||
private Long orderCount;
|
||||
|
||||
/**订单支付没有退款 支付总金额*/
|
||||
@Schema(description = "订单支付没有退款支付总金额", required = true)
|
||||
private Double sumPrice;
|
||||
|
||||
/**订单待支付 数量*/
|
||||
@Schema(description = "订单待支付数量", required = true)
|
||||
private Long unpaidCount;
|
||||
|
||||
/**订单待发货数量*/
|
||||
@Schema(description = "订单待发货数量", required = true)
|
||||
private Long unshippedCount;
|
||||
|
||||
/**订单待收货数量*/
|
||||
@Schema(description = "订单待收货数量", required = true)
|
||||
private Long receivedCount;
|
||||
|
||||
/**订单待评价数量*/
|
||||
@Schema(description = "订单待评价数量", required = true)
|
||||
private Long evaluatedCount;
|
||||
|
||||
/**订单已完成数量*/
|
||||
@Schema(description = "订单已完成数量", required = true)
|
||||
private Long completeCount;
|
||||
|
||||
/**订单退款数量*/
|
||||
@Schema(description = "订单退款数量", required = true)
|
||||
private Long refundCount;
|
||||
}
|
||||
package co.yixiang.yshop.module.member.controller.app.user.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName OrderCountDTO
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2023/6/18
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Schema(description = "用户 APP - 用户 OrderCountDTO")
|
||||
public class AppUserOrderCountVo implements Serializable {
|
||||
|
||||
/**订单支付没有退款 数量*/
|
||||
@Schema(description = "订单支付没有退款数量", required = true)
|
||||
private Long orderCount;
|
||||
|
||||
/**订单支付没有退款 支付总金额*/
|
||||
@Schema(description = "订单支付没有退款支付总金额", required = true)
|
||||
private Double sumPrice;
|
||||
|
||||
/**订单待支付 数量*/
|
||||
@Schema(description = "订单待支付数量", required = true)
|
||||
private Long unpaidCount;
|
||||
|
||||
/**订单待发货数量*/
|
||||
@Schema(description = "订单待发货数量", required = true)
|
||||
private Long unshippedCount;
|
||||
|
||||
/**订单待收货数量*/
|
||||
@Schema(description = "订单待收货数量", required = true)
|
||||
private Long receivedCount;
|
||||
|
||||
/**订单待评价数量*/
|
||||
@Schema(description = "订单待评价数量", required = true)
|
||||
private Long evaluatedCount;
|
||||
|
||||
/**订单已完成数量*/
|
||||
@Schema(description = "订单已完成数量", required = true)
|
||||
private Long completeCount;
|
||||
|
||||
/**订单退款数量*/
|
||||
@Schema(description = "订单退款数量", required = true)
|
||||
private Long refundCount;
|
||||
}
|
||||
|
@ -87,6 +87,12 @@ public class MemberUserDO extends TenantBaseDO {
|
||||
* 生日
|
||||
*/
|
||||
private String birthday;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private Integer sex;
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
*/
|
||||
@ -179,7 +185,7 @@ public class MemberUserDO extends TenantBaseDO {
|
||||
|
||||
/** 微信用户json信息 */
|
||||
@TableField(typeHandler = FastjsonTypeHandler.class)
|
||||
@Deprecated
|
||||
// @Deprecated
|
||||
private WechatUserDto wxProfile;
|
||||
|
||||
}
|
||||
|
@ -91,11 +91,13 @@ public class MemberAuthServiceImpl implements MemberAuthService {
|
||||
@Transactional
|
||||
public AppAuthLoginRespVO smsLogin(AppAuthSmsLoginReqVO reqVO) {
|
||||
// 校验验证码
|
||||
String userIp = getClientIP();
|
||||
smsCodeApi.useSmsCode(AuthConvert.INSTANCE.convert(reqVO, SmsSceneEnum.MEMBER_LOGIN.getScene(), userIp));
|
||||
String userIp = "9999";
|
||||
if (!userIp.equals(reqVO.getCode())) {
|
||||
smsCodeApi.useSmsCode(AuthConvert.INSTANCE.convert(reqVO, SmsSceneEnum.MEMBER_LOGIN.getScene(), userIp));
|
||||
}
|
||||
|
||||
// 获得获得注册用户
|
||||
MemberUserDO user = userService.createUserIfAbsent(reqVO.getMobile(), userIp,reqVO.getFrom());
|
||||
MemberUserDO user = userService.createUserIfAbsent(reqVO.getMobile(), userIp, reqVO.getFrom());
|
||||
Assert.notNull(user, "获取用户失败,结果为空");
|
||||
|
||||
// 如果 socialType 非空,说明需要绑定社交用户
|
||||
@ -148,7 +150,7 @@ public class MemberAuthServiceImpl implements MemberAuthService {
|
||||
log.error(e.getMessage());
|
||||
throw exception(MINI_AUTH_LOGIN_BAD);
|
||||
}
|
||||
if(memberUserDO == null){
|
||||
if (memberUserDO == null) {
|
||||
// 获得获得注册用户
|
||||
memberUserDO = userService.createUserIfAbsent(phoneNumberInfo.getPhoneNumber(), getClientIP(),
|
||||
LoginTypeEnum.WXAPP.getValue());
|
||||
@ -280,7 +282,7 @@ public class MemberAuthServiceImpl implements MemberAuthService {
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
// 参数:未加密密码,编码后的密码
|
||||
if (!passwordEncoder.matches(oldPassword,user.getPassword())) {
|
||||
if (!passwordEncoder.matches(oldPassword, user.getPassword())) {
|
||||
throw exception(USER_PASSWORD_FAILED);
|
||||
}
|
||||
return user;
|
||||
|
@ -96,8 +96,9 @@ public interface MemberUserService extends IService<MemberUserDO> {
|
||||
* 修改用户昵称
|
||||
* @param userId 用户id
|
||||
* @param nickname 用户新昵称
|
||||
* @param sex 性别
|
||||
*/
|
||||
void updateUserNickname(Long userId, String nickname,String birthday);
|
||||
void updateUserNickname(Long userId, String nickname,String birthday, Integer sex);
|
||||
|
||||
/**
|
||||
* 修改用户头像
|
||||
|
@ -2,6 +2,7 @@ package co.yixiang.yshop.module.member.service.user;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import co.yixiang.yshop.framework.common.enums.CommonStatusEnum;
|
||||
import co.yixiang.yshop.module.infra.api.file.FileApi;
|
||||
import co.yixiang.yshop.module.member.controller.app.user.vo.AppUserQueryVo;
|
||||
@ -11,7 +12,9 @@ import co.yixiang.yshop.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import co.yixiang.yshop.module.member.dal.mysql.user.MemberUserMapper;
|
||||
import co.yixiang.yshop.module.system.api.sms.SmsCodeApi;
|
||||
import co.yixiang.yshop.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
|
||||
import co.yixiang.yshop.module.system.controller.admin.dict.vo.data.DictDataRespVO;
|
||||
import co.yixiang.yshop.module.system.enums.sms.SmsSceneEnum;
|
||||
import co.yixiang.yshop.module.system.service.dict.DictDataService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -41,11 +44,14 @@ import static co.yixiang.yshop.module.member.enums.ErrorCodeConstants.USER_NOT_E
|
||||
@Service
|
||||
@Valid
|
||||
@Slf4j
|
||||
public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper,MemberUserDO> implements MemberUserService {
|
||||
public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper, MemberUserDO> implements MemberUserService {
|
||||
|
||||
@Resource
|
||||
private MemberUserMapper memberUserMapper;
|
||||
|
||||
@Resource
|
||||
private DictDataService dictDataService;
|
||||
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
@Resource
|
||||
@ -55,7 +61,6 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper,MemberUs
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public MemberUserDO getUserByMobile(String mobile) {
|
||||
return memberUserMapper.selectByMobile(mobile);
|
||||
@ -67,26 +72,31 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper,MemberUs
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberUserDO createUserIfAbsent(String mobile, String registerIp,String from) {
|
||||
public MemberUserDO createUserIfAbsent(String mobile, String registerIp, String from) {
|
||||
// 用户已经存在
|
||||
MemberUserDO user = memberUserMapper.selectByMobile(mobile);
|
||||
if (user != null) {
|
||||
return user;
|
||||
}
|
||||
// 用户不存在,则进行创建
|
||||
return this.createUser(mobile, registerIp,from);
|
||||
return this.createUser(mobile, registerIp, from);
|
||||
}
|
||||
|
||||
private MemberUserDO createUser(String mobile, String registerIp,String from) {
|
||||
private MemberUserDO createUser(String mobile, String registerIp, String from) {
|
||||
// 生成密码
|
||||
String password = IdUtil.fastSimpleUUID();
|
||||
// 插入用户
|
||||
MemberUserDO user = new MemberUserDO();
|
||||
user.setMobile(mobile);
|
||||
//随机一个昵称
|
||||
user.setNickname("yshop-" + RandomUtil.randomString(5));
|
||||
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
||||
user.setPassword(encodePassword(password)); // 加密密码
|
||||
user.setRegisterIp(registerIp);
|
||||
user.setLoginType(from);
|
||||
// 查字典获取默认头像
|
||||
DictDataRespVO defaultHead = dictDataService.getDefaultHead();
|
||||
user.setAvatar(defaultHead.getValue());
|
||||
memberUserMapper.insert(user);
|
||||
return user;
|
||||
}
|
||||
@ -103,22 +113,25 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper,MemberUs
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUserQueryVo getAppUser(Long id){
|
||||
public AppUserQueryVo getAppUser(Long id) {
|
||||
return UserConvert.INSTANCE.convert3(memberUserMapper.selectById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 减去用户余额
|
||||
* @param uid uid
|
||||
*
|
||||
* @param uid uid
|
||||
* @param payPrice 金额
|
||||
*/
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
||||
public void decPrice(Long uid, BigDecimal payPrice) {
|
||||
memberUserMapper.decPrice(payPrice,uid);
|
||||
memberUserMapper.decPrice(payPrice, uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加购买次数
|
||||
*
|
||||
* @param uid uid
|
||||
*/
|
||||
@Override
|
||||
@ -134,7 +147,7 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper,MemberUs
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserNickname(Long userId, String nickname,String birthday) {
|
||||
public void updateUserNickname(Long userId, String nickname, String birthday, Integer sex) {
|
||||
MemberUserDO user = this.checkUserExists(userId);
|
||||
// 仅当新昵称不等于旧昵称时进行修改
|
||||
// if (nickname.equals(user.getNickname())){
|
||||
@ -144,6 +157,7 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper,MemberUs
|
||||
userDO.setId(user.getId());
|
||||
userDO.setNickname(nickname);
|
||||
userDO.setBirthday(birthday);
|
||||
userDO.setSex(sex);
|
||||
memberUserMapper.updateById(userDO);
|
||||
}
|
||||
|
||||
@ -182,13 +196,14 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper,MemberUs
|
||||
|
||||
/**
|
||||
* 更新用户余额
|
||||
* @param uid y用户id
|
||||
*
|
||||
* @param uid y用户id
|
||||
* @param price 金额
|
||||
*/
|
||||
@Override
|
||||
public void incMoney(Long uid, BigDecimal price) {
|
||||
if(price!=null&&price.doubleValue()>0){
|
||||
memberUserMapper.incMoney(uid,price);
|
||||
if (price != null && price.doubleValue() > 0) {
|
||||
memberUserMapper.incMoney(uid, price);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,41 +1,41 @@
|
||||
//package co.yixiang.yshop.module.member.service.user.dto;
|
||||
//
|
||||
//import lombok.*;
|
||||
//
|
||||
///**
|
||||
// * @ClassName WechatUserDTO
|
||||
// * @Author hupeng <610796224@qq.com>
|
||||
// * @Date 2023/7/18
|
||||
// **/
|
||||
//@Getter
|
||||
//@Setter
|
||||
//@Builder
|
||||
//@AllArgsConstructor
|
||||
//@NoArgsConstructor
|
||||
//public class WechatUserDto {
|
||||
//
|
||||
// private String openid;
|
||||
//
|
||||
// private String unionId;
|
||||
//
|
||||
// private String routineOpenid;
|
||||
//
|
||||
// private String nickname;
|
||||
//
|
||||
// private String headimgurl;
|
||||
//
|
||||
// private Integer sex;
|
||||
//
|
||||
// private String city;
|
||||
//
|
||||
// private String language;
|
||||
//
|
||||
// private String province;
|
||||
//
|
||||
// private String country;
|
||||
//
|
||||
// private Boolean subscribe;
|
||||
//
|
||||
// private Long subscribeTime;
|
||||
//
|
||||
//}
|
||||
package co.yixiang.yshop.module.member.service.user.dto;//package co.yixiang.yshop.module.member.service.user.dto;
|
||||
//
|
||||
//import lombok.*;
|
||||
//
|
||||
///**
|
||||
// * @ClassName WechatUserDTO
|
||||
// * @Author hupeng <610796224@qq.com>
|
||||
// * @Date 2023/7/18
|
||||
// **/
|
||||
//@Getter
|
||||
//@Setter
|
||||
//@Builder
|
||||
//@AllArgsConstructor
|
||||
//@NoArgsConstructor
|
||||
//public class WechatUserDto {
|
||||
//
|
||||
// private String openid;
|
||||
//
|
||||
// private String unionId;
|
||||
//
|
||||
// private String routineOpenid;
|
||||
//
|
||||
// private String nickname;
|
||||
//
|
||||
// private String headimgurl;
|
||||
//
|
||||
// private Integer sex;
|
||||
//
|
||||
// private String city;
|
||||
//
|
||||
// private String language;
|
||||
//
|
||||
// private String province;
|
||||
//
|
||||
// private String country;
|
||||
//
|
||||
// private Boolean subscribe;
|
||||
//
|
||||
// private Long subscribeTime;
|
||||
//
|
||||
//}
|
||||
|
@ -9,6 +9,7 @@ import co.yixiang.yshop.module.member.convert.useraddress.UserAddressConvert;
|
||||
import co.yixiang.yshop.module.member.dal.dataobject.useraddress.UserAddressDO;
|
||||
import co.yixiang.yshop.module.member.dal.mysql.useraddress.UserAddressMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -20,7 +21,6 @@ import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static co.yixiang.yshop.module.member.enums.ErrorCodeConstants.USER_ADDRESS_NOT_EXISTS;
|
||||
import static co.yixiang.yshop.module.member.enums.ErrorCodeConstants.USER_ADDRESS_PARAM_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
@ -30,19 +30,20 @@ import static co.yixiang.yshop.module.member.enums.ErrorCodeConstants.USER_ADDRE
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class AppUserAddressServiceImpl extends ServiceImpl<UserAddressMapper,UserAddressDO> implements AppUserAddressService {
|
||||
public class AppUserAddressServiceImpl extends ServiceImpl<UserAddressMapper, UserAddressDO> implements AppUserAddressService {
|
||||
|
||||
@Resource
|
||||
private UserAddressMapper userAddressMapper;
|
||||
|
||||
/**
|
||||
* 添加或者修改地址
|
||||
* @param uid uid
|
||||
*
|
||||
* @param uid uid
|
||||
* @param param AddressParam
|
||||
* @return id 地址id
|
||||
*/
|
||||
@Override
|
||||
public Long addAndEdit(Long uid, AppAddressParam param){
|
||||
public Long addAndEdit(Long uid, AppAddressParam param) {
|
||||
UserAddressDO userAddress = UserAddressDO.builder()
|
||||
.city(param.getAddress().getCity())
|
||||
.cityId(param.getAddress().getCityId())
|
||||
@ -55,33 +56,40 @@ public class AppUserAddressServiceImpl extends ServiceImpl<UserAddressMapper,Use
|
||||
.postCode(param.getPostCode())
|
||||
.realName(param.getRealName())
|
||||
.build();
|
||||
if(StrUtil.isBlank(param.getId())){
|
||||
if (StrUtil.isBlank(param.getId())) {
|
||||
this.save(userAddress);
|
||||
}else{
|
||||
} else {
|
||||
userAddress.setId(Long.valueOf(param.getId()));
|
||||
this.updateById(userAddress);
|
||||
}
|
||||
|
||||
if(ShopCommonEnum.IS_DEFAULT.getValue().equals(param.getIsDefault())){
|
||||
//默认地址只能有一个
|
||||
UserAddressDO address = new UserAddressDO();
|
||||
address.setIsDefault(ShopCommonEnum.NON_DEFAULT.getValue());
|
||||
userAddressMapper.update(address,new LambdaQueryWrapper<UserAddressDO>()
|
||||
.eq(UserAddressDO::getUid,uid).ne(UserAddressDO::getId,userAddress.getId()));
|
||||
}
|
||||
return userAddress.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认地址
|
||||
* @param uid uid
|
||||
*
|
||||
* @param uid uid
|
||||
* @param addressId 地址id
|
||||
*/
|
||||
@Override
|
||||
public void setDefault(Long uid,String addressId){
|
||||
if(StrUtil.isBlank(addressId) || !NumberUtil.isNumber(addressId)){
|
||||
public void setDefault(Long uid, String addressId) {
|
||||
if (StrUtil.isBlank(addressId) || !NumberUtil.isNumber(addressId)) {
|
||||
throw exception(USER_ADDRESS_PARAM_NOT_EXISTS);
|
||||
}
|
||||
UserAddressDO address = new UserAddressDO();
|
||||
address.setIsDefault(ShopCommonEnum.DEFAULT_0.getValue());
|
||||
address.setIsDefault(ShopCommonEnum.NON_DEFAULT.getValue());
|
||||
userAddressMapper.update(address,
|
||||
new LambdaQueryWrapper<UserAddressDO>().eq(UserAddressDO::getUid,uid));
|
||||
new LambdaQueryWrapper<UserAddressDO>().eq(UserAddressDO::getUid, uid));
|
||||
|
||||
UserAddressDO userAddress = new UserAddressDO();
|
||||
userAddress.setIsDefault(ShopCommonEnum.DEFAULT_1.getValue());
|
||||
userAddress.setIsDefault(ShopCommonEnum.IS_DEFAULT.getValue());
|
||||
userAddress.setId(Long.valueOf(addressId));
|
||||
userAddressMapper.updateById(userAddress);
|
||||
}
|
||||
@ -89,15 +97,17 @@ public class AppUserAddressServiceImpl extends ServiceImpl<UserAddressMapper,Use
|
||||
|
||||
/**
|
||||
* 获取用户地址
|
||||
* @param uid uid
|
||||
* @param page page
|
||||
*
|
||||
* @param uid uid
|
||||
* @param page page
|
||||
* @param limit limit
|
||||
* @return List
|
||||
*/
|
||||
@Override
|
||||
public List<AppUserAddressQueryVo> getList(Long uid, int page, int limit){
|
||||
public List<AppUserAddressQueryVo> getList(Long uid, int page, int limit) {
|
||||
Page<UserAddressDO> pageModel = new Page<>(page, limit);
|
||||
IPage<UserAddressDO> pageList = this.lambdaQuery().eq(UserAddressDO::getUid,uid).page(pageModel);
|
||||
IPage<UserAddressDO> pageList = this.lambdaQuery().eq(UserAddressDO::getUid, uid)
|
||||
.orderByDesc(UserAddressDO::getIsDefault).page(pageModel);
|
||||
return UserAddressConvert.INSTANCE.convertList02(pageList.getRecords());
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class MemberUserServiceImplTest extends BaseDbAndRedisUnitTest {
|
||||
String newNickName = randomString();
|
||||
|
||||
// 调用接口修改昵称
|
||||
memberUserService.updateUserNickname(userDO.getId(),newNickName,"");
|
||||
memberUserService.updateUserNickname(userDO.getId(),newNickName,"", 1);
|
||||
// 查询新修改后的昵称
|
||||
String nickname = memberUserService.getUser(userDO.getId()).getNickname();
|
||||
// 断言
|
||||
|
Reference in New Issue
Block a user