Browse Source

立即兑换

pull/22/head
wanghaoran 1 year ago
parent
commit
88e44c3428
4 changed files with 40 additions and 7 deletions
  1. +0
    -2
      tuoheng-api/src/main/java/com/tuoheng/api/controller/GoodsController.java
  2. +15
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/entity/domain/UserPointsDetail.java
  3. +1
    -1
      tuoheng-api/src/main/java/com/tuoheng/api/entity/request/ExchangeRequest.java
  4. +24
    -4
      tuoheng-api/src/main/java/com/tuoheng/api/service/impl/GoodsServiceImpl.java

+ 0
- 2
tuoheng-api/src/main/java/com/tuoheng/api/controller/GoodsController.java View File

@@ -44,8 +44,6 @@ public class GoodsController {
return goodsService.merchantInfo(goodsQuery);
}



/**
* 立即兑换
*

+ 15
- 0
tuoheng-api/src/main/java/com/tuoheng/api/entity/domain/UserPointsDetail.java View File

@@ -72,6 +72,21 @@ public class UserPointsDetail extends BaseEntity implements Serializable {
*/
private Integer exchangeFlag;

/**
* 商品ID
*/
private Integer goodsId;

/**
* 商品积分
*/
private Integer goodsPoints;

/**
* 商品数量
*/
private Integer goodsCount;

/**
* 商铺信息
*/

+ 1
- 1
tuoheng-api/src/main/java/com/tuoheng/api/entity/request/ExchangeRequest.java View File

@@ -18,7 +18,7 @@ public class ExchangeRequest {
private Integer goodsId;

/**
* 商品id
* 商品数量
*/
private Integer goodsCount;
}

+ 24
- 4
tuoheng-api/src/main/java/com/tuoheng/api/service/impl/GoodsServiceImpl.java View File

@@ -15,6 +15,7 @@ import com.tuoheng.api.mapper.MerchantMapper;
import com.tuoheng.api.mapper.UserPointsDetailMapper;
import com.tuoheng.api.mapper.WestreamUserMapper;
import com.tuoheng.api.service.IGoodsService;
import com.tuoheng.api.utils.PointsTitleConstants;
import com.tuoheng.common.common.BaseServiceImpl;
import com.tuoheng.common.utils.CommonUtils;
import com.tuoheng.common.utils.JsonResult;
@@ -24,6 +25,8 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
@Slf4j
public class GoodsServiceImpl extends BaseServiceImpl<GoodsMapper, Goods> implements IGoodsService {
@@ -121,12 +124,29 @@ public class GoodsServiceImpl extends BaseServiceImpl<GoodsMapper, Goods> implem
return JsonResult.error("用户积分不足!");
}

UserPointsDetail userPointsDetail = new UserPointsDetail();
userPointsDetail.setChangeName(goods.getGoodsName()+"*"+exchangeRequest.getGoodsCount());
Merchant merchant = merchantMapper.selectById(goods.getMerchantId());

BeanUtils.copyProperties(exchangeRequest,userPointsDetail);
UserPointsDetail userPointsDetail = new UserPointsDetail();
userPointsDetail.setNickname(westreamUser.getNickname());
userPointsDetail.setChangeName(goods.getGoodsName());
userPointsDetail.setPointsChange(exchangePoints);
userPointsDetail.setPointsTime(new Date());
userPointsDetail.setType(1);
if(ObjectUtil.isNotNull(merchant)){
userPointsDetail.setOperatorId(merchant.getUserId());
userPointsDetail.setOperatorName(merchant.getShopsName());
}
userPointsDetail.setCreateTime(new Date());
userPointsDetail.setExchangeFlag(0);
userPointsDetail.setGoodsPoints(goods.getGoodsPoints());
BeanUtils.copyProperties(exchangeRequest, userPointsDetail);
userPointsDetailMapper.insert(userPointsDetail);
return null;

//更新用户积分
westreamUser.setMallPoints(residuePoints);
westreamUserMapper.updateById(westreamUser);

return JsonResult.success();
}

}

Loading…
Cancel
Save