|
|
@@ -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(); |
|
|
|
} |
|
|
|
|
|
|
|
} |