|
@@ -14,18 +14,22 @@ import com.zanxiang.common.utils.bean.BeanUtils;
|
|
|
import com.zanxiang.manage.domain.dto.PromoAccountDTO;
|
|
|
import com.zanxiang.manage.domain.dto.PromoMediaDTO;
|
|
|
import com.zanxiang.manage.domain.params.PromoAccountAddUpdateParam;
|
|
|
+import com.zanxiang.manage.domain.params.PromoAccountAssignParam;
|
|
|
import com.zanxiang.manage.domain.params.PromoAccountListParam;
|
|
|
import com.zanxiang.manage.domain.vo.PromoAccountChoiceVO;
|
|
|
import com.zanxiang.manage.domain.vo.PromoAccountListVO;
|
|
|
import com.zanxiang.manage.domain.vo.PromoPitcherChoiceVO;
|
|
|
+import com.zanxiang.manage.service.PromoAccountLogService;
|
|
|
import com.zanxiang.manage.service.PromoAccountService;
|
|
|
import com.zanxiang.manage.service.PromoMediaService;
|
|
|
import com.zanxiang.mybatis.entity.PromoAccount;
|
|
|
+import com.zanxiang.mybatis.entity.PromoAccountLog;
|
|
|
import com.zanxiang.mybatis.mapper.PromoAccountMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.Collections;
|
|
@@ -47,6 +51,9 @@ public class PromoAccountServiceImpl extends ServiceImpl<PromoAccountMapper, Pro
|
|
|
@Autowired
|
|
|
private PromoMediaService promoMediaService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PromoAccountLogService promoAccountLogService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询推广媒体列表
|
|
|
*
|
|
@@ -94,6 +101,7 @@ public class PromoAccountServiceImpl extends ServiceImpl<PromoAccountMapper, Pro
|
|
|
* @return : 返回结果
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean addOrUpdate(PromoAccountAddUpdateParam param) {
|
|
|
Long id = param.getId();
|
|
|
//更新
|
|
@@ -130,7 +138,7 @@ public class PromoAccountServiceImpl extends ServiceImpl<PromoAccountMapper, Pro
|
|
|
throw new BaseException("推广账号id已经存在");
|
|
|
}
|
|
|
//创建
|
|
|
- return super.save(PromoAccount.builder()
|
|
|
+ PromoAccount promoAccount = PromoAccount.builder()
|
|
|
.account(param.getAccount())
|
|
|
.name(param.getName())
|
|
|
.pitcherGroupId(param.getPitcherGroupId())
|
|
@@ -144,7 +152,43 @@ public class PromoAccountServiceImpl extends ServiceImpl<PromoAccountMapper, Pro
|
|
|
.isDelete(DeleteEnum.NO.getCode())
|
|
|
.createTime(LocalDateTime.now())
|
|
|
.updateTime(LocalDateTime.now())
|
|
|
- .build());
|
|
|
+ .build();
|
|
|
+ super.save(promoAccount);
|
|
|
+ return promoAccountLogService.create(promoAccount);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 帐户分配
|
|
|
+ *
|
|
|
+ * @param param 参数
|
|
|
+ * @return {@link Boolean}
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean accountAssign(PromoAccountAssignParam param) {
|
|
|
+ PromoAccount promoAccount = super.getById(param.getId());
|
|
|
+ if (promoAccount == null) {
|
|
|
+ throw new BaseException("参数错误, 推广账号信息不存在");
|
|
|
+ }
|
|
|
+ //生成指派记录
|
|
|
+ if (!Objects.equals(promoAccount.getPitcherId(), param.getPitcherId())) {
|
|
|
+ promoAccountLogService.assignUpdate(param);
|
|
|
+ } else {
|
|
|
+ //投手没变, 开始时间更新
|
|
|
+ promoAccountLogService.update(new LambdaUpdateWrapper<PromoAccountLog>()
|
|
|
+ .set(PromoAccountLog::getStartTime, param.getStartTime())
|
|
|
+ .set(PromoAccountLog::getPitcherGroupId, param.getPitcherGroupId())
|
|
|
+ .set(PromoAccountLog::getUpdateTime, LocalDateTime.now())
|
|
|
+ .eq(PromoAccountLog::getAccountId, param.getId())
|
|
|
+ .isNull(PromoAccountLog::getEndTime));
|
|
|
+ }
|
|
|
+ //账号更新
|
|
|
+ promoAccount.setPitcherId(param.getPitcherId());
|
|
|
+ promoAccount.setPitcherName(param.getPitcherName());
|
|
|
+ promoAccount.setPitcherGroupId(param.getPitcherGroupId());
|
|
|
+ promoAccount.setPitcherGroupName(param.getPitcherGroupName());
|
|
|
+ promoAccount.setRemark(param.getRemark());
|
|
|
+ promoAccount.setUpdateTime(LocalDateTime.now());
|
|
|
+ return super.updateById(promoAccount);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -155,6 +199,7 @@ public class PromoAccountServiceImpl extends ServiceImpl<PromoAccountMapper, Pro
|
|
|
* @return : 返回更新结果
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean statusUpdate(Long id, Integer status) {
|
|
|
return super.update(new LambdaUpdateWrapper<PromoAccount>()
|
|
|
.set(PromoAccount::getStatus, status)
|