|
|
@ -8,6 +8,7 @@ import com.bnyer.common.core.utils.uuid.IdUtils; |
|
|
import com.bnyer.img.mapper.CdkLogMapper; |
|
|
import com.bnyer.img.mapper.CdkLogMapper; |
|
|
import com.bnyer.img.mapper.PaintCdkMapper; |
|
|
import com.bnyer.img.mapper.PaintCdkMapper; |
|
|
import com.bnyer.img.service.PaintCdkService; |
|
|
import com.bnyer.img.service.PaintCdkService; |
|
|
|
|
|
import com.bnyer.img.service.StableDiffusionService; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
@ -25,6 +26,9 @@ public class PaintCdkServiceImpl implements PaintCdkService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private CdkLogMapper cdkLogMapper; |
|
|
private CdkLogMapper cdkLogMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private StableDiffusionService stableDiffusionService; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void generatorCdk(String source,int paintNum) { |
|
|
public void generatorCdk(String source,int paintNum) { |
|
|
@ -53,19 +57,21 @@ public class PaintCdkServiceImpl implements PaintCdkService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void useCdk(String cdk, String source,Long userId) { |
|
|
public void useCdk(String cdk, String source,Long userId,String appType) { |
|
|
//检查cdk是否被使用过
|
|
|
//检查cdk是否被使用过
|
|
|
PaintCdk paintCdk = checkCdk(cdk, source); |
|
|
PaintCdk paintCdk = checkCdk(cdk, source); |
|
|
if(paintCdk == null){ |
|
|
if(paintCdk == null){ |
|
|
throw new ServiceException("该兑换码已被使用!"); |
|
|
throw new ServiceException("该兑换码不存在或已被使用!"); |
|
|
}else{ |
|
|
}else{ |
|
|
//TODO 增加用户绘画次数
|
|
|
//增加用户绘画次数
|
|
|
|
|
|
stableDiffusionService.addPlatformUserAiPaintNum(appType,source,userId,paintCdk.getPaintNum()); |
|
|
//修改cdk状态
|
|
|
//修改cdk状态
|
|
|
paintCdk.setIsUse("1"); |
|
|
paintCdk.setIsUse("1"); |
|
|
paintCdkMapper.updateById(paintCdk); |
|
|
paintCdkMapper.updateById(paintCdk); |
|
|
//写入使用记录
|
|
|
//写入使用记录
|
|
|
CdkLog cdkLog = new CdkLog(); |
|
|
CdkLog cdkLog = new CdkLog(); |
|
|
cdkLog.setCreateTime(new Date()); |
|
|
cdkLog.setCreateTime(new Date()); |
|
|
|
|
|
cdkLog.setPaintNum(paintCdk.getPaintNum()); |
|
|
cdkLog.setSource(source); |
|
|
cdkLog.setSource(source); |
|
|
cdkLog.setIsShow("1"); |
|
|
cdkLog.setIsShow("1"); |
|
|
cdkLog.setCdk(cdk); |
|
|
cdkLog.setCdk(cdk); |
|
|
|