Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

silent před 4 roky
rodič
revize
3b5be1a4db

+ 2 - 2
src/main/java/org/springblade/gateway/point_gateway/controller/PointExchangeController.java

@@ -23,10 +23,10 @@ public class PointExchangeController {
 	//积分兑换商品
 	@PostMapping("/exchange")
 	@ApiOperation("积分兑换")
-	public R<Boolean> exchange(@ApiParam(value = "用户ID",required = true) @RequestParam Long uid,
+	public R<Boolean> exchange(@ApiParam(value = "手机号",required = true) @RequestParam String phone,
 						   @ApiParam(value = "商品ID",required = true) @RequestParam Long goodsId,
 						   @ApiParam(value = "收获地址ID",required = false) @RequestParam Long addressId){
-		return R.status(pointExchangeService.exchange(uid,goodsId,addressId));
+		return R.status(pointExchangeService.exchange(phone,goodsId,addressId));
 
 	}
 }

+ 2 - 2
src/main/java/org/springblade/gateway/point_gateway/service/PointExchangeService.java

@@ -3,11 +3,11 @@ package org.springblade.gateway.point_gateway.service;
 public interface PointExchangeService {
 	/**
 	 * 积分兑换商品
-	 * @param uid 用户id
+	 * @param phone 手机号
 	 * @param goodsId 商品id
 	 * @param addressId 收货地址id
 	 * @return
 	 */
-	boolean exchange(Long uid, Long goodsId, Long addressId);
+	boolean exchange(String phone, Long goodsId, Long addressId);
 }
 

+ 5 - 4
src/main/java/org/springblade/gateway/point_gateway/service/impl/PointExchangeServiceImpl.java

@@ -1,5 +1,6 @@
 package org.springblade.gateway.point_gateway.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import io.jsonwebtoken.lang.Assert;
 import org.springblade.gateway.point_gateway.enums.PointTypeEnum;
 import org.springblade.gateway.point_gateway.excetion.PointException;
@@ -33,9 +34,9 @@ public class PointExchangeServiceImpl implements PointExchangeService {
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public boolean exchange(Long uid, Long goodsId, Long addressId) {
+	public boolean exchange(String phone, Long goodsId, Long addressId) {
 
-		LoginUser user = loginUserService.getById(uid);
+		LoginUser user = loginUserService.getOne(new LambdaQueryWrapper<LoginUser>().eq(LoginUser::getPhone,phone));
 		Assert.notNull(user,"用户不存在");
 		PointGoods goods = pointGoodsService.getById(goodsId);
 		Assert.notNull(goods,"商品不存在");
@@ -54,7 +55,7 @@ public class PointExchangeServiceImpl implements PointExchangeService {
 
 		//添加商品记录表
 		GoodsRecord goodsRecord = new GoodsRecord();
-		goodsRecord.setUserId(uid);
+		goodsRecord.setUserId(user.getId());
 		goodsRecord.setPointGoodsId(goodsId);
 		goodsRecord.setAddressId(addressId);
 		goodsRecord.setType(GoodsRecordType.POINT_GOODS_EXCHANGE);
@@ -64,7 +65,7 @@ public class PointExchangeServiceImpl implements PointExchangeService {
 		//添加积分消费
 		PointRecord pointRecord = new PointRecord();
 		pointRecord.setPoint(goods.getPoint());
-		pointRecord.setUserId(uid);
+		pointRecord.setUserId(user.getId());
 		pointRecord.setPointGoodsId(goodsId);
 		pointRecord.setPointType(PointTypeEnum.PUFA_POINT_EXCHANGE);
 		Assert.isTrue(pointRecordService.save(pointRecord),"兑换失败");