|
|
@@ -18,6 +18,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Objects;
|
|
|
@@ -37,7 +38,7 @@ public class AdServiceImpl implements AdService {
|
|
|
* 保存广告记录
|
|
|
*/
|
|
|
@Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Transactional
|
|
|
public Result<?> saveRecord(DyzAdRecordParam param) {
|
|
|
YtDyzUser user = appUserMapper.selectPrimaryKey(param.getUserId());
|
|
|
if(Objects.isNull(user)){
|
|
|
@@ -46,6 +47,21 @@ public class AdServiceImpl implements AdService {
|
|
|
if(!UserStatusEnum.NORMAL.getCode().equals(user.getUserStatus())){
|
|
|
return new Result<>(StatusCode.ACCESS_ERR,"当前用户处于风控中");
|
|
|
}
|
|
|
+ saveRecordAndChangeUser(param, user);
|
|
|
+ //调用风控广告校验
|
|
|
+ Result<?> result = riskFeign.checkAdRisk(param.getUserId(),param.getRevenue());
|
|
|
+ if(result.getCode()!=200){
|
|
|
+ throw new CustomerException(result.getMessage());
|
|
|
+ }
|
|
|
+ return Result.resultOk(RepMessage.SAVE_SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存记录
|
|
|
+ * 始终创建新的事务以保障子方法的独立事务
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
|
|
|
+ public void saveRecordAndChangeUser(DyzAdRecordParam param,YtDyzUser user) {
|
|
|
//增加广告记录
|
|
|
YtDyzAdRecord adRecord = new YtDyzAdRecord();
|
|
|
BeanUtils.copyProperties(param, adRecord);
|
|
|
@@ -58,11 +74,5 @@ public class AdServiceImpl implements AdService {
|
|
|
dyzUser.setTotalVideo(Objects.isNull(user.getTotalVideo())?1:(user.getTotalVideo()+1));
|
|
|
dyzUser.setTotalIncome(user.getTotalIncome().add(param.getRevenue()));
|
|
|
appUserMapper.updateUser(dyzUser);
|
|
|
- //调用风控广告校验
|
|
|
- Result<?> result = riskFeign.checkAdRisk(param.getUserId(),param.getRevenue());
|
|
|
- if(result.getCode()!=200){
|
|
|
- throw new CustomerException(result.getMessage());
|
|
|
- }
|
|
|
- return Result.resultOk(RepMessage.SAVE_SUCCESS);
|
|
|
}
|
|
|
}
|