|
|
@@ -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),"兑换失败");
|