diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/OmsApplication.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/OmsApplication.java index 052a9f641..33b4372bd 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/OmsApplication.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/OmsApplication.java @@ -4,12 +4,11 @@ import com.youlai.mall.pms.api.SkuFeignClient; import com.youlai.mall.ums.api.MemberFeignClient; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.transaction.annotation.EnableTransactionManagement; -@SpringBootApplication(exclude = DataSourceAutoConfiguration.class) +@SpringBootApplication @EnableDiscoveryClient @EnableFeignClients(basePackageClasses = { MemberFeignClient.class, SkuFeignClient.class}) @EnableTransactionManagement diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/ThreadPoolConfig.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/ThreadPoolConfig.java index b58d14da5..6ce56e142 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/ThreadPoolConfig.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/config/ThreadPoolConfig.java @@ -10,7 +10,7 @@ import java.util.concurrent.TimeUnit; /** - * 线程池配置 + * 自定义订单线程池 * * @author haoxr * @date 2022/2/13 @@ -20,6 +20,6 @@ public class ThreadPoolConfig { @Bean public ThreadPoolExecutor threadPoolExecutor() { - return new ThreadPoolExecutor(50, 500, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10000), new NamedThreadFactory("订单线程")); + return new ThreadPoolExecutor(50, 500, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10000), new NamedThreadFactory("oms")); } } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/constant/OmsConstants.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/constant/OmsConstants.java index 074f8045c..a6af14b6b 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/constant/OmsConstants.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/constant/OmsConstants.java @@ -14,10 +14,5 @@ public interface OmsConstants { String ORDER_SN_PREFIX = "order:sn:"; - /** - * 释放锁lua脚本 - */ - String RELEASE_LOCK_LUA_SCRIPT = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end"; - } diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/OrderController.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/OrderController.java index 395f89d3d..aa2dec1c5 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/OrderController.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/controller/app/OrderController.java @@ -16,6 +16,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; @@ -40,7 +41,6 @@ public class OrderController { return PageResult.success(result); } - /** * 订单确认 → 进入创建订单页面 *

@@ -52,27 +52,21 @@ public class OrderController { */ @ApiOperation("订单确认") @PostMapping("/_confirm") - public Result confirm( - @RequestParam(required = false) Long skuId - ) { - OrderConfirmVO result = orderService.confirm(skuId); + public Result confirmOrder(@RequestParam(required = false) Long skuId) { + OrderConfirmVO result = orderService.confirmOrder(skuId); return Result.success(result); } @ApiOperation("订单提交") @PostMapping("/_submit") - public Result submit(@Valid @RequestBody OrderSubmitForm orderSubmitForm) { - OrderSubmitVO result = orderService.submit(orderSubmitForm); + public Result submitOrder(@RequestBody @Validated OrderSubmitForm orderSubmitForm) { + OrderSubmitVO result = orderService.submitOrder(orderSubmitForm); return Result.success(result); } @ApiOperation("订单支付") @PostMapping("/{orderId}/_pay") - @ApiImplicitParams({ - @ApiImplicitParam(name = "orderId", value = "订单ID", paramType = "path", dataType = "Long"), - @ApiImplicitParam(name = "payType", value = "支付方式", paramType = "query", dataType = "Integer"), - @ApiImplicitParam(name = "appId", value = "小程序appId", paramType = "query", dataType = "String") - }) + @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单ID", paramType = "path", dataType = "Long"), @ApiImplicitParam(name = "payType", value = "支付方式", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "appId", value = "小程序appId", paramType = "query", dataType = "String")}) public Result pay(@PathVariable Long orderId, Integer payType, String appId) { PayTypeEnum payTypeEnum = IBaseEnum.getEnumByValue(payType, PayTypeEnum.class); diff --git a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOrderService.java b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOrderService.java index f35c85b27..0f165144b 100644 --- a/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOrderService.java +++ b/mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/IOrderService.java @@ -31,12 +31,12 @@ public interface IOrderService extends IService { * @param skuId 直接购买必填,购物车结算不填 * @return */ - OrderConfirmVO confirm(Long skuId); + OrderConfirmVO confirmOrder(Long skuId); /** * 订单提交 */ - OrderSubmitVO submit(OrderSubmitForm orderSubmitForm) ; + OrderSubmitVO submitOrder(OrderSubmitForm orderSubmitForm) ; /** * 订单支付 diff --git a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/MemberAddressFeignClient.java b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/MemberAddressFeignClient.java deleted file mode 100644 index 6bd9aa230..000000000 --- a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/MemberAddressFeignClient.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.youlai.mall.ums.api; - -import com.youlai.common.result.Result; -import com.youlai.mall.ums.dto.MemberAddressDTO; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; - -import java.util.List; - -/** - * 会员地址 Feign 客户端 - * - * @author haoxr - * @date 2022/2/12 - */ -@FeignClient(name = "mall-ums", contextId = "address") -public interface MemberAddressFeignClient { - - /** - * 获取当前会员地址列表 - * - * @return - */ - @GetMapping("/app-api/v1/addresses") - Result> listCurrMemberAddresses(); - -} - - diff --git a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/MemberFeignClient.java b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/MemberFeignClient.java index 098a5e736..d954759fd 100644 --- a/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/MemberFeignClient.java +++ b/mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/MemberFeignClient.java @@ -2,12 +2,15 @@ package com.youlai.mall.ums.api; import com.youlai.common.result.Result; import com.youlai.mall.pms.pojo.vo.ProductHistoryVO; +import com.youlai.mall.ums.dto.MemberAddressDTO; import com.youlai.mall.ums.dto.MemberAuthDTO; import com.youlai.mall.ums.dto.MemberDTO; import com.youlai.mall.ums.dto.MemberInfoDTO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.*; +import java.util.List; + @FeignClient(name = "mall-ums", contextId = "member") public interface MemberFeignClient { @@ -58,6 +61,16 @@ public interface MemberFeignClient { @GetMapping("/app-api/v1/members/mobile/{mobile}") Result loadUserByMobile(@PathVariable String mobile); + + /** + * 获取会员地址列表 + * + * @param memberId + * @return + */ + @GetMapping("/app-api/v1/members/{memberId}/addresses") + Result> listMemberAddresses(@PathVariable Long memberId); + /** * 「实验室」修改会员余额 * diff --git a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/UmsMemberController.java b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/UmsMemberController.java index 6d13db509..aceabd0ba 100644 --- a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/UmsMemberController.java +++ b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/admin/UmsMemberController.java @@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.youlai.common.constant.GlobalConstants; import com.youlai.common.result.PageResult; import com.youlai.common.result.Result; -import com.youlai.mall.ums.dto.MemberDTO; import com.youlai.mall.ums.dto.MemberInfoDTO; import com.youlai.mall.ums.pojo.entity.UmsMember; import com.youlai.mall.ums.service.IUmsMemberService; @@ -29,7 +28,7 @@ public class UmsMemberController { @ApiOperation(value = "会员分页列表") @GetMapping - public PageResult listMembersWithPage( + public PageResult listPageMembers( @ApiParam("页码") Long pageNum, @ApiParam("每页数量") Long pageSize, @ApiParam("会员昵称") String nickName @@ -57,15 +56,16 @@ public class UmsMemberController { return Result.judge(status); } - @ApiOperation(value = "选择性修改会员") - @PatchMapping("/{id}") - public Result patch( - @ApiParam("会员ID") @PathVariable Long id, + @ApiOperation(value = "修改会员状态") + @PatchMapping("/{memberId}/status") + public Result updateMemberStatus( + @ApiParam("会员ID") @PathVariable Long memberId, @RequestBody UmsMember member ) { - boolean status = memberService.update(new LambdaUpdateWrapper() - .eq(UmsMember::getId, id) - .set(member.getStatus() != null, UmsMember::getStatus, member.getStatus()) + boolean status = memberService.update( + new LambdaUpdateWrapper() + .eq(UmsMember::getId, memberId) + .set(UmsMember::getStatus, member.getStatus()) ); return Result.judge(status); } diff --git a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/app/MemberController.java b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/app/MemberController.java index 1676b3b17..ed5017bb6 100644 --- a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/app/MemberController.java +++ b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/app/MemberController.java @@ -6,6 +6,7 @@ import com.youlai.common.result.Result; import com.youlai.common.result.ResultCode; import com.youlai.common.web.utils.MemberUtils; import com.youlai.mall.pms.pojo.vo.ProductHistoryVO; +import com.youlai.mall.ums.dto.MemberAddressDTO; import com.youlai.mall.ums.dto.MemberAuthDTO; import com.youlai.mall.ums.dto.MemberDTO; import com.youlai.mall.ums.pojo.entity.UmsMember; @@ -18,6 +19,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import java.util.Collections; +import java.util.List; import java.util.Set; @Api(tags = "「移动端」会员管理") @@ -30,14 +32,9 @@ public class MemberController { @ApiOperation(value = "根据会员ID获取openid") @GetMapping("/{memberId}/openid") - public Result getMemberById( - @ApiParam("会员ID") @PathVariable Long memberId - ) { - UmsMember member = memberService.getOne( - new LambdaQueryWrapper() - .eq(UmsMember::getId, memberId) - .select(UmsMember::getOpenid) - ); + public Result getMemberById(@ApiParam("会员ID") @PathVariable Long memberId) { + UmsMember member = memberService.getOne(new LambdaQueryWrapper() + .eq(UmsMember::getId, memberId).select(UmsMember::getOpenid)); String openid = member.getOpenid(); return Result.success(openid); } @@ -51,8 +48,8 @@ public class MemberController { @ApiOperation(value = "获取登录会员信息") @GetMapping("/me") - public Result getCurrentMemberInfo() { - MemberVO memberVO = memberService.getCurrentMemberInfo(); + public Result getCurrMemberInfo() { + MemberVO memberVO = memberService.getCurrMemberInfo(); return Result.success(memberVO); } @@ -62,8 +59,7 @@ public class MemberController { Long memberId = MemberUtils.getMemberId(); boolean result = memberService.update(new LambdaUpdateWrapper() .setSql("balance = balance - " + balances) - .eq(UmsMember::getId, memberId) - ); + .eq(UmsMember::getId, memberId)); return Result.judge(result); } @@ -89,9 +85,7 @@ public class MemberController { @ApiOperation(value = "根据 openid 获取会员认证信息") @GetMapping("/openid/{openid}") - public Result getByOpenid( - @ApiParam("微信身份标识") @PathVariable String openid - ) { + public Result getByOpenid(@ApiParam("微信身份标识") @PathVariable String openid) { MemberAuthDTO memberAuthInfo = memberService.getByOpenid(openid); if (memberAuthInfo == null) { return Result.failed(ResultCode.USER_NOT_EXIST); @@ -102,20 +96,23 @@ public class MemberController { /** * 根据手机号获取会员认证信息 * - * @param mobile + * @param mobile 手机号码 * @return */ @GetMapping("/mobile/{mobile}") - public Result getByMobile( - @ApiParam("手机号码") @PathVariable String mobile - ) { - MemberAuthDTO memberAuthInfo = memberService.getByMobile(mobile); + public Result getMemberByMobile(@ApiParam("手机号码") @PathVariable String mobile) { + MemberAuthDTO memberAuthInfo = memberService.getMemberByMobile(mobile); if (memberAuthInfo == null) { return Result.failed(ResultCode.USER_NOT_EXIST); } return Result.success(memberAuthInfo); } - + @ApiOperation("获取会员地址列表") + @GetMapping("/{memberId}/addresses") + public Result> listMemberAddress(@ApiParam("会员ID") @PathVariable Long memberId) { + List addresses = memberService.listMemberAddress(memberId); + return Result.success(addresses); + } } diff --git a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/service/IUmsMemberService.java b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/service/IUmsMemberService.java index bd182f6f1..b4c74272d 100644 --- a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/service/IUmsMemberService.java +++ b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/service/IUmsMemberService.java @@ -5,12 +5,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.youlai.mall.pms.pojo.vo.ProductHistoryVO; +import com.youlai.mall.ums.dto.MemberAddressDTO; import com.youlai.mall.ums.dto.MemberAuthDTO; import com.youlai.mall.ums.dto.MemberDTO; import com.youlai.mall.ums.dto.MemberInfoDTO; import com.youlai.mall.ums.pojo.entity.UmsMember; import com.youlai.mall.ums.pojo.vo.MemberVO; +import java.util.List; import java.util.Set; /** @@ -41,7 +43,7 @@ public interface IUmsMemberService extends IService { * @param mobile * @return */ - MemberAuthDTO getByMobile(String mobile); + MemberAuthDTO getMemberByMobile(String mobile); /** * 新增会员 @@ -56,9 +58,16 @@ public interface IUmsMemberService extends IService { * * @return */ - MemberVO getCurrentMemberInfo(); - + MemberVO getCurrMemberInfo(); + /** + * 获取会员地址列表 + * + * @param memberId + * @return + */ + List listMemberAddress(Long memberId); + /** * 「实验室」修改会员余额 * @@ -84,4 +93,7 @@ public interface IUmsMemberService extends IService { * @return */ MemberInfoDTO getMemberInfo(Long memberId); + + + } diff --git a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/service/impl/UmsMemberServiceImpl.java b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/service/impl/UmsMemberServiceImpl.java index 6bb7a4b30..423cc3533 100644 --- a/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/service/impl/UmsMemberServiceImpl.java +++ b/mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/service/impl/UmsMemberServiceImpl.java @@ -11,15 +11,20 @@ import com.youlai.common.constant.GlobalConstants; import com.youlai.common.web.utils.MemberUtils; import com.youlai.mall.pms.pojo.vo.ProductHistoryVO; import com.youlai.mall.ums.constant.UmsConstants; +import com.youlai.mall.ums.convert.AddressConvert; import com.youlai.mall.ums.convert.MemberConvert; +import com.youlai.mall.ums.dto.MemberAddressDTO; import com.youlai.mall.ums.dto.MemberAuthDTO; import com.youlai.mall.ums.dto.MemberDTO; import com.youlai.mall.ums.dto.MemberInfoDTO; import com.youlai.mall.ums.mapper.UmsMemberMapper; +import com.youlai.mall.ums.pojo.entity.UmsAddress; import com.youlai.mall.ums.pojo.entity.UmsMember; import com.youlai.mall.ums.pojo.vo.MemberVO; +import com.youlai.mall.ums.service.IUmsAddressService; import com.youlai.mall.ums.service.IUmsMemberService; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -35,11 +40,15 @@ import java.util.Set; */ @Service @RequiredArgsConstructor +@Slf4j public class UmsMemberServiceImpl extends ServiceImpl implements IUmsMemberService { private final RedisTemplate redisTemplate; private final MemberConvert memberConvert; + private final AddressConvert addressConvert; + private final IUmsAddressService addressService; + @Override public IPage list(Page page, String nickname) { List list = this.baseMapper.list(page, nickname); @@ -90,7 +99,7 @@ public class UmsMemberServiceImpl extends ServiceImpl() .eq(UmsMember::getMobile, mobile) .select(UmsMember::getId, @@ -126,7 +135,7 @@ public class UmsMemberServiceImpl extends ServiceImpl() .eq(UmsMember::getId, memberId) @@ -142,6 +151,25 @@ public class UmsMemberServiceImpl extends ServiceImpl listMemberAddress(Long memberId) { + log.info("memberId:{}", MemberUtils.getMemberId()); + + List entities = addressService.list( + new LambdaQueryWrapper() + .eq(UmsAddress::getMemberId, memberId) + ); + + List list = addressConvert.entity2DTO(entities); + return list; + } + /** * 「实验室」修改会员余额