话费和补量

master
wjt 1 year ago
parent 21bdfeccf2
commit 8760312b1b

@ -113,6 +113,8 @@ public class DefaultNumberConstants {
* 20
*/
public static final int TWENTY_NUMBER = 20;
public static final int TWENTY_ONE = 21;
/**
* 23
*/
@ -126,6 +128,7 @@ public class DefaultNumberConstants {
*/
public static final int THIRTY = 30;
public static final int FORTY_EIGHT = 48;
/**
* 60
*/

@ -2,6 +2,8 @@ package com.baiye.feign;
import com.baiye.feign.callback.SourceClueClientFallback;
import com.baiye.http.CommonResponse;
import com.baiye.model.dto.CallClueDTO;
import com.baiye.model.dto.ClueDto;
import com.baiye.model.dto.ClueQueryCriteria;
import com.baiye.model.dto.DistributeResponseDTO;
import com.baiye.model.vo.ResSourceLabel;
@ -56,6 +58,10 @@ public interface SourceClueClient {
@GetMapping(API_PREFIX + "/queryDetails")
ResponseEntity<Clue> queryDetails(@RequestParam("clueId") Long clueId);
@ApiOperation("查询资源详情")
@GetMapping(API_PREFIX + "/queryDetailsByClueType")
ResponseEntity<CallClueDTO> queryDetailsByClueType(@RequestParam("clueId") Long clueId, @RequestParam("clueType") Integer clueType);
@ApiOperation("查询资源标签")
@PostMapping(API_PREFIX + "/findSourceLabel")
ResponseEntity<List<ResSourceLabel>> findSourceLabel(@RequestBody List<Long> clueIds);

@ -2,6 +2,8 @@ package com.baiye.feign.callback;
import com.baiye.feign.SourceClueClient;
import com.baiye.http.CommonResponse;
import com.baiye.model.dto.CallClueDTO;
import com.baiye.model.dto.ClueDto;
import com.baiye.model.dto.ClueQueryCriteria;
import com.baiye.model.dto.DistributeResponseDTO;
import com.baiye.model.vo.ResSourceLabel;
@ -53,6 +55,11 @@ public class SourceClueClientFallback implements SourceClueClient {
return null;
}
@Override
public ResponseEntity<CallClueDTO> queryDetailsByClueType(Long clueId, Integer clueType) {
return null;
}
@Override
public ResponseEntity<List<ResSourceLabel>> findSourceLabel(List<Long> clueIds) {
return null;

@ -40,11 +40,10 @@ public class ChannelResourceAssignController {
@GetMapping("/assign")
@ApiOperation("配量")
public CommonResponse<Object> assignNum(@RequestParam("channelId") Long channelId, @RequestParam("assignNum") Integer assignNum) {
return channelResourceAssignService.assignNum(channelId, assignNum);
public CommonResponse<Object> assignNum(@RequestParam("channelId") Long channelId, @RequestParam(value = "assignNum", required = false) Integer assignNum, @RequestParam(value = "assignBill", required = false) Integer assignBill) {
return channelResourceAssignService.assignNum(channelId, assignNum, assignBill);
}
@GetMapping("/report")
@ApiOperation("统计")
public CommonResponse<Object> report() {

@ -38,8 +38,10 @@ public class CustomManageController {
@GetMapping("/assign")
@ApiOperation("配量")
public CommonResponse<Object> assignNum(@RequestParam("customId") Long customId, @RequestParam("assignNum") Integer assignNum) {
return customManageService.assignNum(customId, assignNum);
public CommonResponse<Object> assignNum(@RequestParam("customId") Long customId,
@RequestParam(value = "assignNum", required = false) Integer assignNum,
@RequestParam(value = "assignBill", required = false) Integer assignBill) {
return customManageService.assignNum(customId, assignNum, assignBill);
}
@ApiOperation("查询任务(分页)")

@ -89,13 +89,13 @@ public class ChannelCustom implements Serializable {
@Column(name = "custom_limit_num")
private Integer customLimitNum;
// @ApiModelProperty(value = "总话费")
// @Column(name = "total_phone_bill")
// private Integer totalPhoneBill;
//
// @ApiModelProperty(value = "剩余话费")
// @Column(name = "surplus_phone_bill")
// private Integer surplusPhoneBill;
@ApiModelProperty(value = "总话费")
@Column(name = "total_phone_bill")
private Integer totalPhoneBill;
@ApiModelProperty(value = "剩余话费")
@Column(name = "surplus_phone_bill")
private Integer surplusPhoneBill;
@ApiModelProperty(value = "子账号")
@Transient
@ -119,8 +119,8 @@ public class ChannelCustom implements Serializable {
this.setType(1);
this.setTotalNum(0);
this.setSurplusNum(0);
// this.setTotalPhoneBill(0);
// this.setSurplusPhoneBill(0);
this.setTotalPhoneBill(0);
this.setSurplusPhoneBill(0);
this.setStatus(1);
this.setActivationCode(null);
this.setCreateTime(DateUtil.date());
@ -138,8 +138,8 @@ public class ChannelCustom implements Serializable {
this.setType(2);
this.setTotalNum(0);
this.setSurplusNum(0);
// this.setTotalPhoneBill(0);
// this.setSurplusPhoneBill(0);
this.setTotalPhoneBill(0);
this.setSurplusPhoneBill(0);
this.setStatus(1);
String activeCode = "by" + NumUtil.getFourNum(parentId.intValue()) + DateUtil.format(DateUtil.date(), "MMdd") + RandomUtil.randomString(4);
this.setActivationCode(activeCode);
@ -148,6 +148,8 @@ public class ChannelCustom implements Serializable {
this.setParentId(parentId);
this.setUserId(userId);
this.setPhone(phone);
this.setCustomLimitNum(100);
this.setChannelLimitNum(1);
return this;
}
}

@ -32,6 +32,10 @@ public class ChannelResourceAssign implements Serializable {
@Column(name = "assign_num")
private Integer assignNum;
@ApiModelProperty(value = "分配话费")
@Column(name = "assign_bill")
private Integer assignBill;
@ApiModelProperty(value = "分配人id")
@Column(name = "assign_by")
private Long assignBy;
@ -44,9 +48,10 @@ public class ChannelResourceAssign implements Serializable {
@Column(name = "create_time")
private Date createTime;
public ChannelResourceAssign addChannelResourceAssign(Long channelId, Integer assignNum, Long assignBy, String assignName) {
public ChannelResourceAssign addChannelResourceAssign(Long channelId, Long assignBy, String assignName) {
this.setChannelId(channelId);
this.setAssignNum(assignNum);
this.setAssignNum(0);
this.setAssignBill(0);
this.setAssignBy(assignBy);
this.setAssignName(assignName);
this.setCreateTime(DateUtil.date());

@ -46,7 +46,33 @@ public class CustomReportVo {
*/
private Integer customSurplusNum = 0;
public CustomReportVo addCustomReportVo(Integer totalNum, Integer surplusNum, Integer assignNum, Integer channelNum, Integer channelTotalNum, Integer channelSurplusNum, Integer customNum, Integer customTotalNum, Integer customSurplusNum) {
/**
*
*/
private Integer totalBill = 0;
/**
*
*/
private Integer surplusBill = 0;
/**
*
*/
private Integer assignBill = 0;
// /**
// * 渠道商总分配数
// */
// private Integer channelTotalBill = 0;
// /**
// * 直客总分钟数
// */
// private Integer customTotalBill = 0;
// /**
// * 直客剩余可分配数
// */
// private Integer customSurplusBill = 0;
public CustomReportVo addCustomReportVo(Integer totalNum, Integer surplusNum, Integer assignNum, Integer channelNum, Integer channelTotalNum, Integer channelSurplusNum, Integer customNum, Integer customTotalNum, Integer customSurplusNum,
Integer totalBill, Integer surplusBill, Integer assignBill) {
this.setTotalNum(totalNum);
this.setSurplusNum(surplusNum);
this.setAssignNum(assignNum);
@ -56,6 +82,12 @@ public class CustomReportVo {
this.setCustomNum(customNum);
this.setCustomTotalNum(customTotalNum);
this.setCustomSurplusNum(customSurplusNum);
this.setTotalBill(totalBill);
this.setSurplusBill(surplusBill);
this.setAssignBill(assignBill);
// this.setChannelTotalBill(channelTotalBill);
// this.setCustomTotalBill(customTotalBill);
// this.setCustomSurplusBill(customSurplusBill);
return this;
}
}

@ -122,6 +122,18 @@ public interface ChannelCustomRepository extends JpaRepository<ChannelCustom, Lo
@Query("UPDATE ChannelCustom set surplusNum = surplusNum - ?2 where userId = ?1")
void updateQuantity(Long userId, Integer number);
/**
*
*
* @param userId
* @param bill
*/
@Modifying
@Query("UPDATE ChannelCustom set surplusPhoneBill = surplusPhoneBill - ?2 where userId = ?1")
Integer updateSurplusBill(Long userId, Integer bill);
@Query("select surplusPhoneBill from ChannelCustom where userId = ?1")
Integer findSurplusPhoneBillByUserId(Long userId);
/**
*
*
@ -137,10 +149,11 @@ public interface ChannelCustomRepository extends JpaRepository<ChannelCustom, Lo
*
* @param id
* @param surplusNum
* @param bill
*/
@Modifying
@Query("UPDATE ChannelCustom set surplusNum = surplusNum + ?2 where id = ?1")
void updateSurplusNum(Long id, Integer surplusNum);
@Query("UPDATE ChannelCustom set surplusNum = surplusNum + ?2 ,surplusPhoneBill=surplusPhoneBill + ?3 where id = ?1")
void updateSurplusNum(Long id, Integer surplusNum, Integer bill);
/**
* id

@ -33,11 +33,12 @@ public interface ChannelResourceAssignService {
/**
*
*
* @param customId id
* @param assignNum
* @param customId id
* @param assignNum
* @param assignBill
* @return
*/
CommonResponse<Object> assignNum(Long customId, Integer assignNum);
CommonResponse<Object> assignNum(Long customId, Integer assignNum, Integer assignBill);
/**
*

@ -27,9 +27,10 @@ public interface CustomManageService {
*
* @param customId id
* @param assignNum
* @param assignNum
* @return
*/
CommonResponse<Object> assignNum(Long customId, Integer assignNum);
CommonResponse<Object> assignNum(Long customId, Integer assignNum, Integer assignBill);
/**
*

@ -95,7 +95,7 @@ public class ChannelManageServiceImpl implements ChannelManageService {
if (DateUtil.compare(dateTime, startTime, "yyyy-MM-dd") >= 0) {
weekNum += 1;
}
if (DateUtil.compare(dateTime, yesterday, "yyyy-MM-dd") >= 0) {
if (DateUtil.compare(dateTime, yesterday, "yyyy-MM-dd") == 0) {
dayNum += 1;
}
}
@ -149,9 +149,11 @@ public class ChannelManageServiceImpl implements ChannelManageService {
channelCustom.setStatus(3);
channelCustom.setSurplusNum(0);
//返回话费
int bill = channelCustom.getSurplusPhoneBill();
channelCustom.setSurplusPhoneBill(0);
list.add(channelCustom);
if (channelCustom.getParentId() != null) {
channelCustomRepository.updateSurplusNum(channelCustom.getParentId(), num);
channelCustomRepository.updateSurplusNum(channelCustom.getParentId(), num, bill);
}
}
channelCustomRepository.saveAll(list);
@ -174,46 +176,4 @@ public class ChannelManageServiceImpl implements ChannelManageService {
}
channelCustomRepository.save(channelCustomNew);
}
/**
*
*
* @param ids
*/
@Transactional(rollbackFor = Exception.class)
public void forbiddenAll(Set<Long> ids) {
List<ChannelCustom> list = new ArrayList<>();
List<ChannelCustom> channelCustoms = channelCustomRepository.findAllById(ids);
for (ChannelCustom channelCustom : channelCustoms) {
int num = 0;
num = disableChannelById(channelCustom, list, num);
//增加父渠道商的余量
if (channelCustom.getParentId() != null) {
channelCustomRepository.updateSurplusNum(channelCustom.getParentId(), num);
}
}
channelCustomRepository.saveAll(list);
//同步
List<Long> userIdByIds = channelCustomRepository.findUserIdByIds(ids);
userService.updateUserStatusByCompanyId(false, userIdByIds);
}
private Integer disableChannelById(ChannelCustom custom, List<ChannelCustom> channelCustoms, Integer num) {
//禁用自己
custom.setStatus(3);
custom.setSurplusNum(0);
custom.setTotalNum(0);
channelCustoms.add(custom);
num += custom.getSurplusNum();
//代理商
if (custom.getType() == 1) {
List<ChannelCustom> byParentId = channelCustomRepository.findByParentId(custom.getId());
if (CollUtil.isNotEmpty(byParentId)) {
for (ChannelCustom channelCustom : byParentId) {
num += disableChannelById(channelCustom, channelCustoms, num);
}
}
}
return num;
}
}

@ -55,16 +55,27 @@ public class ChannelResourceAssignServiceImpl implements ChannelResourceAssignSe
@Override
@Transactional(rollbackFor = Exception.class)
public CommonResponse<Object> assignNum(Long customId, Integer assignNum) {
public CommonResponse<Object> assignNum(Long customId, Integer assignNum, Integer assignBill) {
if (assignBill == null && assignNum == null) {
return CommonResponse.createByErrorMessage("请选择正确充值数量");
}
ChannelCustom channelCustom = channelCustomRepository.findById(customId).orElse(new ChannelCustom());
//配量记录
ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(null, customId, channelCustom.getChannelName());
//增加客户的总量和余量
channelCustom.setTotalNum(channelCustom.getTotalNum() + assignNum);
channelCustom.setSurplusNum(channelCustom.getSurplusNum() + assignNum);
if (assignNum != null && assignNum > 0) {
channelCustom.setTotalNum(channelCustom.getTotalNum() + assignNum);
channelCustom.setSurplusNum(channelCustom.getSurplusNum() + assignNum);
channelResourceAssign.setAssignNum(assignNum);
}
if (assignBill != null) {
channelCustom.setTotalPhoneBill(channelCustom.getTotalPhoneBill() + assignBill);
channelCustom.setSurplusPhoneBill(channelCustom.getSurplusPhoneBill() + assignBill);
channelResourceAssign.setAssignBill(assignBill);
}
channelCustom.setPurchaseTime(DateUtil.date());
channelCustomRepository.save(channelCustom);
//配量记录
ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(null, assignNum, customId, channelCustom.getChannelName());
channelResourceAssignRepository.save(channelResourceAssign);
return CommonResponse.createBySuccess();
}
@ -76,25 +87,34 @@ public class ChannelResourceAssignServiceImpl implements ChannelResourceAssignSe
int totalNum = 0;
int yesterdayNum = 0;
int todayNum = 0;
int totalBill = 0;
int yesterdayBill = 0;
int todayBill = 0;
DateTime date = DateUtil.parseDate(DateUtil.today());
DateTime yesterday = DateUtil.offsetDay(date, -1);
for (ChannelResourceAssign channelResourceAssign : all) {
//总分配数
totalNum += channelResourceAssign.getAssignNum();
totalBill += channelResourceAssign.getAssignBill();
Date createTime = channelResourceAssign.getCreateTime();
//今日日
if (DateUtil.compare(createTime, date, "yyyy-MM-dd") >= 0) {
if (DateUtil.compare(createTime, date, "yyyy-MM-dd") == 0) {
todayNum += channelResourceAssign.getAssignNum();
todayBill += channelResourceAssign.getAssignBill();
}
//昨日
if (DateUtil.compare(createTime, yesterday, "yyyy-MM-dd") >= 0) {
if (DateUtil.compare(createTime, yesterday, "yyyy-MM-dd") == 0) {
yesterdayNum += channelResourceAssign.getAssignNum();
yesterdayBill += channelResourceAssign.getAssignBill();
}
}
Map<String, Integer> map = new HashMap<>(3);
map.put("totalNum", totalNum);
map.put("yesterdayNum", yesterdayNum);
map.put("todayNum", todayNum);
map.put("totalBill", totalBill);
map.put("yesterdayBill", yesterdayBill);
map.put("todayBill", todayBill);
return CommonResponse.createBySuccess(map);
}
}

@ -93,23 +93,23 @@ public class CustomManageServiceImpl implements CustomManageService {
channelCustom.setStatus(DefaultNumberConstants.TWO_NUMBER);
//设置分配
if (channelCustom.getTotalNum() != null && channelCustom.getTotalNum() > 0) {
// if (channelCustom.getType() == DefaultNumberConstants.ONE_NUMBER) {
// if (channelCustom.getTotalNum() < DefaultNumberConstants.TEN_THOUSAND) {
// return CommonResponse.createByErrorMessage("渠道商账号最低分配1万");
// }
// } else {
// if (channelCustom.getTotalNum() < DefaultNumberConstants.ONE_THOUSAND) {
// return CommonResponse.createByErrorMessage("直客账号最低分配1000");
// }
// }
if (parent.getSurplusNum() == null || parent.getSurplusNum() < channelCustom.getTotalNum()) {
return CommonResponse.createByErrorMessage("可分配的余量不足");
if (channelCustom.getTotalNum() != null && channelCustom.getTotalPhoneBill() != null) {
if (channelCustom.getTotalNum() != null && channelCustom.getTotalNum() > 0) {
if (parent.getSurplusNum() == null || parent.getSurplusNum() < channelCustom.getTotalNum()) {
return CommonResponse.createByErrorMessage("可分配的余量不足");
}
channelCustom.setSurplusNum(channelCustom.getTotalNum());
//减掉渠道商余量
parent.setSurplusNum(parent.getSurplusNum() - channelCustom.getTotalNum());
}
if (channelCustom.getTotalPhoneBill() != null && channelCustom.getTotalPhoneBill() > 0) {
if (parent.getSurplusPhoneBill() == null || parent.getSurplusPhoneBill() < channelCustom.getTotalPhoneBill()) {
return CommonResponse.createByErrorMessage("可分配的话费不足");
}
channelCustom.setSurplusPhoneBill(channelCustom.getTotalPhoneBill());
parent.setSurplusPhoneBill(parent.getSurplusPhoneBill() - channelCustom.getSurplusPhoneBill());
}
channelCustom.setSurplusNum(channelCustom.getTotalNum());
channelCustom.setPurchaseTime(DateUtil.date());
//减掉渠道商余量
parent.setSurplusNum(parent.getSurplusNum() - channelCustom.getTotalNum());
channelCustomRepository.save(parent);
}
@ -142,10 +142,21 @@ public class CustomManageServiceImpl implements CustomManageService {
channelCustom.setCustomLimitNum(100);
}
channelCustom.setCreateTime(DateUtil.date());
channelCustom.setCustomLimitNum(100);
channelCustom.setChannelLimitNum(1);
channelCustomRepository.save(channelCustom);
ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(parent.getId(), channelCustom.getId(), channelCustom.getChannelName());
boolean flag = false;
if (channelCustom.getSurplusNum() != null && channelCustom.getSurplusNum() > 0) {
//分配记录
ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(parent.getId(), channelCustom.getTotalNum(), channelCustom.getId(), channelCustom.getChannelName());
channelResourceAssign.setAssignNum(channelCustom.getSurplusNum());
flag = true;
}
if (channelCustom.getSurplusPhoneBill() != null && channelCustom.getSurplusPhoneBill() > 0) {
channelResourceAssign.setAssignBill(channelCustom.getSurplusPhoneBill());
flag = true;
}
if (flag) {
channelResourceAssignRepository.save(channelResourceAssign);
}
return CommonResponse.createBySuccess();
@ -153,30 +164,36 @@ public class CustomManageServiceImpl implements CustomManageService {
@Override
@Transactional(rollbackFor = Exception.class)
public CommonResponse<Object> assignNum(Long customId, Integer assignNum) {
public CommonResponse<Object> assignNum(Long customId, Integer assignNum, Integer assignBill) {
if (assignBill == null && assignNum == null) {
return CommonResponse.createByErrorMessage("请选择正确充值数量");
}
ChannelCustom channelCustom = channelCustomRepository.findById(customId).orElse(new ChannelCustom());
ChannelCustom parent = channelCustomRepository.findById(channelCustom.getParentId()).orElse(new ChannelCustom());
//添加分配记录
ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(parent.getId(), customId, channelCustom.getChannelName());
int parentSurplusNum = parent.getSurplusNum();
// if (channelCustom.getType() == DefaultNumberConstants.ONE_NUMBER) {
// if (assignNum < DefaultNumberConstants.TEN_THOUSAND) {
// return CommonResponse.createByErrorMessage("渠道商账号最低分配1万");
// }
// } else {
// if (assignNum < DefaultNumberConstants.ONE_THOUSAND) {
// return CommonResponse.createByErrorMessage("直客账号最低分配1000");
// }
// }
if (parentSurplusNum < assignNum) {
return CommonResponse.createByErrorMessage("可分配的余量不足");
int parentSurplusBill = parent.getSurplusPhoneBill();
if (assignNum != null) {
if (parentSurplusNum < assignNum) {
return CommonResponse.createByErrorMessage("可分配的余量不足");
}
parent.setSurplusNum(parentSurplusNum - assignNum);
channelCustom.setTotalNum(channelCustom.getTotalNum() + assignNum);
channelCustom.setSurplusNum(channelCustom.getSurplusNum() + assignNum);
channelResourceAssign.setAssignNum(assignNum);
}
if (assignBill != null) {
if (parentSurplusBill < assignBill) {
return CommonResponse.createByErrorMessage("可分配的话费不足");
}
parent.setSurplusPhoneBill(parentSurplusBill - assignBill);
channelCustom.setTotalPhoneBill(channelCustom.getTotalPhoneBill() + assignBill);
channelCustom.setSurplusPhoneBill(channelCustom.getSurplusPhoneBill() + assignBill);
channelResourceAssign.setAssignBill(assignBill);
}
//扣减父级渠道商的余量
parent.setSurplusNum(parentSurplusNum - assignNum);
//增加客户的总量和余量
channelCustom.setTotalNum(channelCustom.getTotalNum() + assignNum);
channelCustom.setSurplusNum(channelCustom.getSurplusNum() + assignNum);
channelCustom.setPurchaseTime(DateUtil.date());
//添加分配记录
ChannelResourceAssign channelResourceAssign = new ChannelResourceAssign().addChannelResourceAssign(parent.getId(), assignNum, customId, channelCustom.getChannelName());
channelResourceAssignRepository.save(channelResourceAssign);
channelCustomRepository.save(parent);
channelCustomRepository.save(channelCustom);
@ -269,6 +286,10 @@ public class CustomManageServiceImpl implements CustomManageService {
int surplusNum = channelCustomByUserId.getSurplusNum();
int assignNum = totalNum - surplusNum;
int totalBill = channelCustomByUserId.getTotalPhoneBill();
int surplusBill = channelCustomByUserId.getSurplusPhoneBill();
int assignBill = totalBill - surplusBill;
List<ChannelCustom> channelCustoms = channelCustomRepository.findByParentId(channelCustomByUserId.getId());
int channelNum = 0;
int channelTotalNum = 0;
@ -288,7 +309,8 @@ public class CustomManageServiceImpl implements CustomManageService {
customSurplusNum += channelCustom.getSurplusNum();
}
}
CustomReportVo customReportVo = new CustomReportVo().addCustomReportVo(totalNum, surplusNum, assignNum, channelNum, channelTotalNum, channelSurplusNum, customNum, customTotalNum, customSurplusNum);
CustomReportVo customReportVo = new CustomReportVo().addCustomReportVo(totalNum, surplusNum, assignNum, channelNum, channelTotalNum, channelSurplusNum, customNum, customTotalNum, customSurplusNum,
totalBill, surplusBill, assignBill);
return CommonResponse.createBySuccess(customReportVo);
}
@ -331,12 +353,14 @@ public class CustomManageServiceImpl implements CustomManageService {
@Transactional(rollbackFor = Exception.class)
public void deleteByUserId(Long userId) {
ChannelCustom byUserId = channelCustomRepository.findByUserId(userId);
Integer num = 0;
int num = 0;
int bill = 0;
if (byUserId.getType() == 2) {
num = byUserId.getSurplusNum();
bill = byUserId.getSurplusPhoneBill();
channelCustomRepository.deleteByUserId(userId);
}
channelCustomRepository.updateSurplusNum(byUserId.getParentId(), num);
channelCustomRepository.updateSurplusNum(byUserId.getParentId(), num, bill);
}
@ -360,13 +384,15 @@ public class CustomManageServiceImpl implements CustomManageService {
ChannelCustom custom = channelCustomRepository.findByUserId(userId);
List<ChannelCustom> channelCustoms = new ArrayList<>();
List<Integer> num = new ArrayList<>();
disableChannelById(custom, channelCustoms, num);
List<Integer> bill = new ArrayList<>();
disableChannelById(custom, channelCustoms, num, bill);
//禁用
channelCustomRepository.saveAll(channelCustoms);
//增加父渠道商的余量
if (custom.getParentId() != null) {
Integer integer = num.stream().reduce(Integer::sum).orElse(0);
channelCustomRepository.updateSurplusNum(custom.getParentId(), integer);
int integer = num.stream().reduce(Integer::sum).orElse(0);
int integer1 = bill.stream().reduce(Integer::sum).orElse(0);
channelCustomRepository.updateSurplusNum(custom.getParentId(), integer, integer1);
}
return channelCustoms.stream().map(ChannelCustom::getUserId).collect(Collectors.toList());
}
@ -379,10 +405,13 @@ public class CustomManageServiceImpl implements CustomManageService {
}
}
private void disableChannelById(ChannelCustom custom, List<ChannelCustom> channelCustoms, List<Integer> num) {
private void disableChannelById(ChannelCustom custom, List<ChannelCustom> channelCustoms, List<Integer> num, List<Integer> bill) {
num.add(custom.getSurplusNum());
bill.add(custom.getSurplusPhoneBill());
custom.setStatus(3);
custom.setSurplusNum(0);
custom.setSurplusPhoneBill(0);
custom.setTotalPhoneBill(0);
custom.setTotalNum(0);
channelCustoms.add(custom);
//代理商
@ -390,7 +419,7 @@ public class CustomManageServiceImpl implements CustomManageService {
List<ChannelCustom> byParentId = channelCustomRepository.findByParentId(custom.getId());
if (CollUtil.isNotEmpty(byParentId)) {
for (ChannelCustom channelCustom : byParentId) {
disableChannelById(channelCustom, channelCustoms, num);
disableChannelById(channelCustom, channelCustoms, num, bill);
}
}
}

@ -28,4 +28,7 @@ public class Clue extends BaseClue {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ApiModelProperty(value = "线索分配人")
@Transient
private Long memberId;
}

@ -252,3 +252,4 @@ public class CompanyServiceImpl implements CompanyService {
return PageUtil.toPage(comboVOList, page.getTotalElements());
}
}

@ -764,6 +764,7 @@ public class UserServiceImpl implements UserService {
ChannelCustom custom = customManageService.findByUserId(user.getId());
if (custom != null) {
convert.setSurplusNum(custom.getSurplusNum());
convert.setSurplusBill(custom.getSurplusPhoneBill());
}
}
OrganizeUser organizeUser = organizeUserRepository.findByUserId(user.getId());

@ -48,6 +48,10 @@ public class TelephoneCallController {
@PostMapping("/telephone/req")
@ApiOperation("拨打电话")
public CommonResponse<TelephoneCallStopDTO> doubleCallReq(@Validated @RequestBody TelephoneCallReqDTO telephoneCallReqDTO) {
int hour = DateUtil.hour(DateUtil.date(), true);
if (hour < DefaultNumberConstants.EIGHT_NUMBER || hour >= DefaultNumberConstants.TWENTY_ONE) {
return CommonResponse.createByErrorMessage("请在8点-21点之间拨打电话");
}
//判断账号是否到期
Date expirationTime = userService.findExpirationTimeByUserId(SecurityUtils.getCurrentUserId());
if (ObjectUtil.isNull(expirationTime)
@ -66,9 +70,10 @@ public class TelephoneCallController {
if (ObjectUtil.isNull(organize) || ObjectUtil.isNull(company)) {
return CommonResponse.createByErrorMessage("缺失小组信息或公司信息");
}
if (company.getUserBalance() == null || company.getUserBalance() <= 0) {
return CommonResponse.createByErrorMessage("余额不足,请充值后使用");
}
// if (company.getUserBalance() == null || company.getUserBalance() <= 0) {
// return CommonResponse.createByErrorMessage("余额不足,请充值后使用");
// }
if (organize.getCallMode() == null) {
return CommonResponse.createByErrorMessage("请指定呼叫方式后使用");
}

@ -50,11 +50,16 @@ public class ClueBoost {
@ApiModelProperty(value = "创建时间")
private Date createTime;
@Column(name = "update_time")
@ApiModelProperty(value = "修改时间")
private Date updateTime;
public ClueBoost addClueBoost(Long clueId, Long memberId, Integer clueType, Long whichUserId) {
this.setClueId(clueId);
this.setMemberId(memberId);
this.setClueType(clueType);
this.setCreateTime(DateUtil.date());
this.setUpdateTime(DateUtil.date());
this.setWhichUserId(whichUserId);
this.setStatus(false);
return this;

@ -28,6 +28,10 @@ public class ClueBoostRecord {
@ApiModelProperty(value = "线索id")
private Long whichUserId;
@Column(name = "boost_num")
@ApiModelProperty(value = "补量数")
private Integer boostNum;
@Column(name = "create_time")
@ApiModelProperty(value = "创建时间")
private Date createTime;

@ -30,7 +30,7 @@ public class ClueBoostDTO {
private Date lastTime;
private Long memberId;
private Long whichUserId;
private Integer clueType;
/**
@ -38,9 +38,10 @@ public class ClueBoostDTO {
*/
private Boolean status;
public ClueBoostDTO addClueBoostDTO(Long clueId, Long memberId, Integer clueType, Boolean status) {
public ClueBoostDTO addClueBoostDTO(Long clueId, Long memberId, Long whichUserId, Integer clueType, Boolean status) {
this.setClueId(clueId);
this.setMemberId(memberId);
this.setWhichUserId(whichUserId);
this.setClueType(clueType);
this.setStatus(status);
return this;

@ -4,11 +4,9 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.feign.SourceClueClient;
import com.baiye.model.dto.UserDto;
import com.baiye.modules.agent.repository.ChannelCustomRepository;
import com.baiye.modules.system.domain.User;
import com.baiye.modules.system.repository.UserRepository;
import com.baiye.modules.telemarkting.dao.ClueBoostRecordRepository;
import com.baiye.modules.telemarkting.dao.ClueBoostRepository;
import com.baiye.modules.telemarkting.entity.ClueBoost;
@ -55,8 +53,6 @@ public class ClueBoostServiceImpl implements ClueBoostService {
private ChannelCustomRepository channelCustomRepository;
@Resource
private ClueBoostRecordRepository clueBoostRecordRepository;
@Resource
private UserRepository userRepository;
@Override
public Object queryAll(ClueBoostQueryCriteria clueBoostQueryCriteria, Pageable pageable) {
@ -72,9 +68,11 @@ public class ClueBoostServiceImpl implements ClueBoostService {
Integer integer = clueBoostRepository.updateStatusByIds(true, ids);
Long currentUserId = SecurityUtils.getCurrentUserId();
channelCustomRepository.updateSurplusNumByUserId(currentUserId, integer);
ClueBoostRecord clueBoostRecord = new ClueBoostRecord();
clueBoostRecord.setWhichUserId(currentUserId);
clueBoostRecord.setCreateTime(DateUtil.date());
clueBoostRecord.setBoostNum(integer);
clueBoostRecordRepository.save(clueBoostRecord);
}
@ -94,24 +92,22 @@ public class ClueBoostServiceImpl implements ClueBoostService {
//上一次拨打距离当前时间间隔1小时
Date lastTime = clueBoost.getLastTime();
long betweenLast = DateUtil.between(lastTime, DateUtil.date(), DateUnit.HOUR);
if (betweenLast < 1) {
if (betweenLast < DefaultNumberConstants.ONE_NUMBER) {
return;
}
//第一次拨打后 24小时内需2通
Date firstTime = clueBoost.getFirstTime();
long betweenFirst = DateUtil.between(firstTime, DateUtil.date(), DateUnit.HOUR);
Integer callNum = clueBoost.getCallNum();
if (betweenFirst <= 24) {
if (betweenFirst <= DefaultNumberConstants.TWENTY_FOUR) {
clueBoost.setCallNum(callNum + 1);
clueBoost.setLastTime(DateUtil.date());
redisUtils.set(KEY + clueBoostDTO.getClueId(), clueBoost, 48 - betweenFirst, TimeUnit.HOURS);
return;
} else if (betweenFirst < 48) {
if (callNum >= 2) {
} else if (betweenFirst < DefaultNumberConstants.FORTY_EIGHT) {
if (callNum >= DefaultNumberConstants.TWO_NUMBER) {
//满足补量
User user = userRepository.findById(clueBoost.getMemberId()).orElseGet(User::new);
Long whichUserId = user.getWhichUserId();
ClueBoost clueBoostNew = new ClueBoost().addClueBoost(clueBoost.getClueId(), clueBoost.getMemberId(), clueBoost.getClueType(), whichUserId);
ClueBoost clueBoostNew = new ClueBoost().addClueBoost(clueBoost.getClueId(), clueBoost.getMemberId(), clueBoost.getClueType(), clueBoostDTO.getWhichUserId());
// 修改线索为冻结
sourceClueClient.updateTalkClueFreeze(clueBoost.getClueId(), true);
clueBoostRepository.save(clueBoostNew);

@ -11,12 +11,17 @@ import com.baiye.constant.DefaultNumberConstants;
import com.baiye.exception.BadRequestException;
import com.baiye.feign.SourceClueClient;
import com.baiye.http.CommonResponse;
import com.baiye.model.dto.CallClueDTO;
import com.baiye.model.dto.ClueDto;
import com.baiye.model.dto.UserDto;
import com.baiye.model.enums.CallStatusEnum;
import com.baiye.modules.agent.repository.ChannelCustomRepository;
import com.baiye.modules.platform.domain.CallDeduct;
import com.baiye.modules.platform.domain.Clue;
import com.baiye.modules.platform.domain.Company;
import com.baiye.modules.platform.repository.CallDeductRepository;
import com.baiye.modules.platform.service.CompanyService;
import com.baiye.modules.system.domain.User;
import com.baiye.modules.system.service.UserService;
import com.baiye.modules.telemarkting.dao.*;
import com.baiye.modules.telemarkting.entity.*;
@ -70,6 +75,9 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
@Resource
private ApplicationContext applicationContext;
@Resource
private ChannelCustomRepository channelCustomRepository;
@Override
public CommonResponse<TelephoneCallStopDTO> doubleCallReq(TelephoneCallReqDTO doubleCallReq, Long companyId) {
String requestId = RandomUtil.randomString(10);
@ -124,8 +132,10 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
callClueRepository.updateByStatus(status, userDate);
allCallInfo.setStatus(status);
allCallInfoRepository.save(allCallInfo);
UserDto user = userService.findById(allCallInfo.getMemberId());
Long whichUserId = user.getWhichUserId();
//实时扣费
callCostCount(allCallInfo.getMemberId(), allCallInfo.getClueId(), allCallInfo.getClueType(), allCallInfo.getDuration(), DefaultNumberConstants.TWO_NUMBER);
callCostCount(allCallInfo.getMemberId(), allCallInfo.getClueId(), allCallInfo.getClueType(), allCallInfo.getDuration(), DefaultNumberConstants.TWO_NUMBER, whichUserId);
//更新资源通话状态
CompletableFuture.runAsync(() -> updateSourceCallStatus(userDate, DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueType()));
} else {
@ -175,6 +185,13 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
@Override
public CommonResponse<TelephoneCallStopDTO> rollCallReq(TelephoneCallReqDTO telephoneCallReqDTO, Long companyId) {
//检查余量
UserDto user = userService.findById(telephoneCallReqDTO.getMemberId());
Long whichUserId = user.getWhichUserId();
Integer surplusPhoneBillByUserId = channelCustomRepository.findSurplusPhoneBillByUserId(whichUserId);
if (surplusPhoneBillByUserId == null || surplusPhoneBillByUserId <= 0) {
return CommonResponse.createByErrorMessage("话费不足");
}
String requestId = RandomUtil.randomString(10);
telephoneCallReqDTO.setRequestId(requestId);
if (telephoneCallReqDTO.getDisplay() == null || telephoneCallReqDTO.getTelA() == null) {
@ -219,9 +236,9 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
}
//获取被叫号
Clue body;
CallClueDTO body;
try {
body = sourceClueClient.queryDetails(Long.parseLong(telephoneCallReqDTO.getUserData())).getBody();
body = sourceClueClient.queryDetailsByClueType(Long.parseLong(telephoneCallReqDTO.getUserData()), telephoneCallReqDTO.getClueType()).getBody();
} catch (Exception e) {
log.error("获取被叫号错误:{},time:{} ", e.getMessage(), DateUtil.now());
throw new BadRequestException("呼叫失败");
@ -230,6 +247,9 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
log.error("未获取到号码");
return CommonResponse.createByErrorMessage("未获取到号码");
}
if (body.getMemberId() == null) {
return CommonResponse.createByErrorMessage("线索未分配,请刷新后重试");
}
telephoneCallReqDTO.setTelB("474" + telephoneCallReqDTO.getDisplay() + body.getNid());
//请求呼叫
String reqId = rollCallReq.startReq(telephoneCallReqDTO);
@ -273,6 +293,8 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
allCallInfoRepository.updateByRecord(DefaultNumberConstants.ONE_NUMBER, rollCallBackDTO.getRecord_file_url(), allCallInfo.getId());
} else {
log.info("被叫回调-点呼otherLeg:{},详情:{}", otherLeg, rollCallBackDTO);
UserDto user = userService.findById(allCallInfo.getMemberId());
Long whichUserId = user.getWhichUserId();
boolean status;
//拨打线索号的回调
if (StrUtil.isNotBlank(rollCallBackDTO.getCallee_answer_time())) {
@ -282,7 +304,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
//更新资源通话状态
CompletableFuture.runAsync(() -> updateSourceCallStatus(allCallInfo.getClueId(), DefaultNumberConstants.TWO_NUMBER, allCallInfo.getClueType()));
//实时扣除话费
callCostCount(allCallInfo.getMemberId(), allCallInfo.getClueId(), allCallInfo.getClueType(), Integer.valueOf(rollCallBackDTO.getDuration()), 2);
callCostCount(allCallInfo.getMemberId(), allCallInfo.getClueId(), allCallInfo.getClueType(), Integer.valueOf(rollCallBackDTO.getDuration()), 2, whichUserId);
status = true;
} else {
//更新资源通话状态
@ -290,7 +312,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
status = false;
}
if (Arrays.asList(ClueTypeConstants.TOKER_TYPE).contains(allCallInfo.getClueType())) {
ClueBoostDTO clueBoostDTO = new ClueBoostDTO().addClueBoostDTO(allCallInfo.getClueId(), allCallInfo.getMemberId(), allCallInfo.getClueType(), null);
ClueBoostDTO clueBoostDTO = new ClueBoostDTO().addClueBoostDTO(allCallInfo.getClueId(), allCallInfo.getMemberId(), whichUserId, allCallInfo.getClueType(), null);
clueBoostDTO.setStatus(status);
applicationContext.publishEvent(clueBoostDTO);
}
@ -323,73 +345,74 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
* @param duration
* @param callType 1- 2-
*/
public void callCostCount(Long memberId, Long clueId, Integer clueType, Integer duration, Integer callType) {
// Long companyId = SecurityUtils.getCompanyId();
public void callCostCount(Long memberId, Long clueId, Integer clueType, Integer duration, Integer callType, Long whichUserId) {
Long companyId = userService.findUserInfo(memberId).getCompanyId();
Company company = companyService.findCompanyInfo(companyId);
double minDuration = dealDuration(duration);
// Company company = companyService.findById(companyId);
int minDuration = dealDuration(duration);
CallDeduct callDeduct = new CallDeduct();
callDeduct.setDeductDuration((int) minDuration);
callDeduct.setDeductDuration(minDuration);
callDeduct.setClueId(clueId);
callDeduct.setMemberId(memberId);
callDeduct.setCompanyId(companyId);
callDeduct.setStatus(false);
callDeduct.setCreateTime(new Date());
callDeduct.setVersion(company.getVersion());
callDeduct.setVersion(0);
callDeduct.setType(DefaultNumberConstants.ONE_NUMBER);
//模板费用
double fee = 0;
String typeStr;
if (callType == DefaultNumberConstants.ONE_NUMBER) {
//双呼
if (company.getDoubleCallFee() != null) {
fee = company.getDoubleCallFee();
}
typeStr = "双呼套餐";
} else {
//点呼
if (clueType == DefaultNumberConstants.THREE_NUMBER) {
if (company.getTiktokCallFee() != null) {
fee = company.getTiktokCallFee();
}
typeStr = "抖音套餐";
} else if (clueType == DefaultNumberConstants.FOUR_NUMBER) {
if (company.getDeliveryCallFee() != null) {
fee = company.getDeliveryCallFee();
}
typeStr = "投流套餐";
} else if (clueType == DefaultNumberConstants.FIVE_NUMBER) {
if (company.getTalkCallFee() != null) {
fee = company.getTalkCallFee();
}
typeStr = "拓客套餐";
} else {
if (company.getRollCallFee() != null) {
fee = company.getRollCallFee();
}
typeStr = "crm套餐";
}
}
// double fee = 0;
// String typeStr;
// if (callType == DefaultNumberConstants.ONE_NUMBER) {
// //双呼
// if (company.getDoubleCallFee() != null) {
// fee = company.getDoubleCallFee();
// }
// typeStr = "双呼套餐";
// } else {
// //点呼
// if (clueType == DefaultNumberConstants.THREE_NUMBER) {
// if (company.getTiktokCallFee() != null) {
// fee = company.getTiktokCallFee();
// }
// typeStr = "抖音套餐";
// } else if (clueType == DefaultNumberConstants.FOUR_NUMBER) {
// if (company.getDeliveryCallFee() != null) {
// fee = company.getDeliveryCallFee();
// }
// typeStr = "投流套餐";
// } else if (clueType == DefaultNumberConstants.FIVE_NUMBER) {
// if (company.getTalkCallFee() != null) {
// fee = company.getTalkCallFee();
// }
// typeStr = "拓客套餐";
// } else {
// if (company.getRollCallFee() != null) {
// fee = company.getRollCallFee();
// }
// typeStr = "crm套餐";
// }
// }
double mul = NumberUtil.mul(minDuration, fee);
callDeduct.setDeductAmount(mul);
callDeduct.setComboType(typeStr);
// double mul = NumberUtil.mul(minDuration, fee);
// callDeduct.setDeductAmount(mul);
callDeduct.setDeductAmount(0.0);
callDeduct.setComboType("话费");
CallDeduct save = callDeductRepository.save(callDeduct);
updateBalance(mul, companyId, company.getVersion(), save);
// updateBalance(mul, companyId, company.getVersion(), save, whichUserId);
updateBalance(save, whichUserId, minDuration);
}
private void updateBalance(Double mul, Long companyId, Integer version, CallDeduct save) {
int num = companyService.updateBalanceOptimistic(mul, companyId, version);
private void updateBalance(CallDeduct save, Long whichUserId, Integer bill) {
// int num = companyService.updateBalanceOptimistic(mul, companyId, version);
int num = channelCustomRepository.updateSurplusBill(whichUserId, bill);
if (num > 0) {
save.setVersion(version);
save.setStatus(true);
callDeductRepository.save(save);
} else {
updateBalance(mul, companyId, version + 1, save);
}
// else {
// updateBalance(mul, companyId, version + 1, save);
// }
}
/**
@ -398,9 +421,9 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
* @param duration
* @return
*/
private double dealDuration(int duration) {
private Integer dealDuration(int duration) {
if (duration <= DefaultNumberConstants.SIXTY) {
return 1.00;
return 1;
} else {
//余数
int i = duration % 60;
@ -408,7 +431,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
int q = duration / 60;
if (i > 0) {
return NumberUtil.add(q, 1);
return q + 1;
} else {
return q;
}

@ -0,0 +1,24 @@
package com.baiye.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* @author wjt
* @date 2023/5/19
*/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class CallClueDTO {
@ApiModelProperty(value = "nid")
private String nid;
@ApiModelProperty(value = "所属组员id")
private Long memberId;
}

@ -83,4 +83,7 @@ public class ClueQueryCriteria {
@ApiModelProperty(value = "是否是业务管理员查询, 判断是否加密字段")
private Boolean isAdmin = false;
@ApiModelProperty(value = "是否冻结")
private Boolean isFreeze;
}

@ -98,4 +98,6 @@ public class UserDto extends BaseDTO implements Serializable {
private String jobNumber;
private Integer surplusNum;
private Integer surplusBill;
}

@ -92,6 +92,12 @@ public class ClueController {
return new ResponseEntity<>(clueService.queryDetails(clueId), HttpStatus.OK);
}
@ApiOperation("查询资源详情")
@GetMapping("/queryDetailsByClueType")
public ResponseEntity<CallClueDTO> queryDetailsByClueType(@RequestParam("clueId") Long clueId, @RequestParam("clueType") Integer clueType) {
return new ResponseEntity<>(clueService.queryDetailsByClueType(clueId,clueType), HttpStatus.OK);
}
@ApiOperation("更新资源信息")
@PostMapping("/update")
@Inner(value = false)

@ -5,13 +5,12 @@ import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.baiye.constant.AdPlatFormConstants;
import com.baiye.constant.ClueTypeConstants;
import com.baiye.constant.KeyFieldConstants;
import com.baiye.exception.BadRequestException;
import com.baiye.feign.TaskClient;
import com.baiye.model.dto.ClueDto;
import com.baiye.model.dto.ClueQueryCriteria;
import com.baiye.model.dto.PublicCluePoolDto;
import com.baiye.model.dto.PublicCluePoolQueryCriteria;
import com.baiye.model.dto.*;
import com.baiye.model.vo.ResSourceLabel;
import com.baiye.module.service.dto.ClueTalkDTO;
import com.baiye.util.AESUtils;
@ -192,6 +191,9 @@ public class ClueJpa {
if (userId != null) {
sql.append("and c.create_by = :userId ");
}
if (clueQueryCriteria.getIsFreeze() != null) {
sql.append("and cm.is_freeze = :isFreeze ");
}
//拼接最后加入时间排序,没加id排序出现数据重复问题(注意空格)
sql.append("ORDER BY c.create_time desc ,c.id ");
@ -264,6 +266,9 @@ public class ClueJpa {
if (userId != null) {
query.setParameter("userId", userId);
}
if (clueQueryCriteria.getIsFreeze() != null) {
query.setParameter("isFreeze", clueQueryCriteria.getIsFreeze());
}
query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
return query.getResultList();
}
@ -551,4 +556,39 @@ public class ClueJpa {
}
return clueDtoList;
}
/**
* 线
*
* @param clueId
* @return
*/
@Transactional(rollbackOn = Exception.class)
public CallClueDTO queryDetailsByClueType(Long clueId, Integer clueType) {
StringBuilder sql = null;
if (Arrays.asList(ClueTypeConstants.SCREEN_TYPE).contains(clueType)) {
sql = new StringBuilder("select tc.nid as nid ,tcm.member_id as memberId " +
"from tb_clue_middle as tcm left join tb_clue as tc on tcm.clue_id =tc.id where tc.id =:clueId ");
} else if (Arrays.asList(ClueTypeConstants.TOKER_TYPE).contains(clueType)) {
sql = new StringBuilder("select tc.nid as nid ,tcm.member_id as memberId " +
"from tb_clue_talk as tcm left join tb_clue as tc on tcm.clue_id =tc.id where tc.id =:clueId ");
}
assert sql != null;
Query query = entityManager.createNativeQuery(sql.toString());
query.setParameter("clueId", clueId);
query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
List list = query.getResultList();
if (CollUtil.isNotEmpty(list) && list.size() > 0) {
Map row = (Map) list.get(0);
CallClueDTO clueDto = new CallClueDTO();
String s = (String) row.get("nid");
String nid = AESUtils.decrypt(s, AdPlatFormConstants.AD_PLATFORM);
clueDto.setNid(nid);
BigInteger memberId = (BigInteger) row.get("memberId");
clueDto.setMemberId(memberId.longValue());
return clueDto;
}
return null;
}
}

@ -28,7 +28,7 @@ public class ClueTalk extends BaseClueMiddle {
@ApiModelProperty(value = "是否冻结")
@Column(name = "is_freeze")
private Boolean isFreeze;
private Boolean isFreeze = false;
@Transient
private String clueName;

@ -88,6 +88,8 @@ public interface ClueService {
*/
Clue queryDetails(Long clueId);
CallClueDTO queryDetailsByClueType(Long clueId, Integer clueType);
/**
*
*/
@ -188,6 +190,7 @@ public interface ClueService {
/**
* 线
*
* @param clueId
* @param isFreeze
*/

@ -439,6 +439,11 @@ public class ClueServiceImpl implements ClueService {
return clueRepository.findById(clueId).orElseGet(Clue::new);
}
@Override
public CallClueDTO queryDetailsByClueType(Long clueId, Integer clueType) {
return clueJpa.queryDetailsByClueType(clueId, clueType);
}
@Override
public List<ResSourceLabel> findSourceLabel(List<Long> clueIds) {
return clueJpa.findSourceLabel(clueIds);

Loading…
Cancel
Save