修改获取公司信息

master
wujingtao 2 years ago
parent a921aa2053
commit aa2e1fbe22

@ -15,8 +15,8 @@ import com.baiye.modules.system.domain.CallDeduct;
import com.baiye.modules.system.domain.Clue;
import com.baiye.modules.system.domain.Company;
import com.baiye.modules.system.repository.CallDeductRepository;
import com.baiye.modules.system.repository.CompanyRepository;
import com.baiye.modules.system.service.CompanyService;
import com.baiye.modules.system.service.UserService;
import com.baiye.modules.telemarkting.dao.*;
import com.baiye.modules.telemarkting.entity.*;
import com.baiye.modules.telemarkting.entity.dto.*;
@ -24,7 +24,6 @@ import com.baiye.modules.telemarkting.httpRequest.AxbRequest;
import com.baiye.modules.telemarkting.httpRequest.DoubleCallReq;
import com.baiye.modules.telemarkting.httpRequest.RollCallReq;
import com.baiye.modules.telemarkting.service.TelephoneCallService;
import com.baiye.util.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@ -64,9 +63,8 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
private CompanyService companyService;
@Resource
private CallDeductRepository callDeductRepository;
@Resource
private CompanyRepository companyRepository;
private UserService userService;
@Override
public CommonResponse<String> doubleCallReq(TelephoneCallReqDTO doubleCallReq, Long companyId) {
@ -295,8 +293,8 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
AllCallInfo allCallInfo = allCallInfoRepository.findBySessionId(otherLeg);
// int status = DefaultNumberConstants.ONE_NUMBER;
if (ObjectUtil.isNotEmpty(allCallInfo)) {
// 相同说明是分机号的回调
if (sessionId.equals(otherLeg) && CharSequenceUtil.isNotBlank(rollCallBackDTO.getRecord_file_url())) {
//相同说明是分机号的回调
if (sessionId.equals(otherLeg) && StrUtil.isNotBlank(rollCallBackDTO.getRecord_file_url())) {
allCallInfoRepository.updateByRecord(DefaultNumberConstants.ONE_NUMBER, rollCallBackDTO.getRecord_file_url(), allCallInfo.getId());
} else {
//拨打线索号的回调
@ -306,7 +304,7 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
allCallInfoRepository.updateByDurationAndStatus(DefaultNumberConstants.TWO_NUMBER, Integer.valueOf(rollCallBackDTO.getDuration()), allCallInfo.getId());
//更新资源通话状态
CompletableFuture.runAsync(() -> updateSourceCallStatus(allCallInfo.getClueId(), DefaultNumberConstants.TWO_NUMBER));
// TODO 实时扣除话费
//TODO 实时扣除话费
callCostCount(allCallInfo.getMemberId(), allCallInfo.getClueId(), allCallInfo.getClueType(), Integer.valueOf(rollCallBackDTO.getDuration()), 2);
} else {
//更新资源通话状态
@ -341,45 +339,59 @@ public class TelephoneCallServiceImpl implements TelephoneCallService {
* @param callType 1- 2-
*/
public void callCostCount(Long memberId, Long clueId, Integer clueType, Integer duration, Integer callType) {
Long companyId = SecurityUtils.getCompanyId();
// Long companyId = SecurityUtils.getCompanyId();
Long companyId = userService.findUserInfo(memberId).getCompanyId();
Company company = companyService.findCompanyInfo(companyId);
double minDuration = dealDuration(duration);
CallDeduct callDeduct = new CallDeduct();
callDeduct.setDeductDuration((int) minDuration);
callDeduct.setClueId(clueId);
callDeduct.setMemberId(memberId);
callDeduct.setCompanyId(companyId);
callDeduct.setStatus(false);
callDeduct.setCreateTime(new Date());
callDeduct.setVersion(company.getVersion());
callDeduct.setType(DefaultNumberConstants.ONE_NUMBER);
//模板费用
double fee;
double fee = 0;
String typeStr;
if (callType == DefaultNumberConstants.ONE_NUMBER) {
//双呼
fee = company.getDoubleCallFee();
if (company.getDoubleCallFee() != null) {
fee = company.getDoubleCallFee();
}
typeStr = "双呼套餐";
} else {
//点呼
if (clueType == DefaultNumberConstants.THREE_NUMBER) {
fee = company.getTiktokCallFee();
if (company.getTiktokCallFee() != null) {
fee = company.getTiktokCallFee();
}
typeStr = "抖音套餐";
} else if (clueType == DefaultNumberConstants.FOUR_NUMBER) {
fee = company.getDeliveryCallFee();
if (company.getDeliveryCallFee() != null) {
fee = company.getDeliveryCallFee();
}
typeStr = "投流套餐";
} else if (clueType == DefaultNumberConstants.FIVE_NUMBER) {
fee = company.getTalkCallFee();
if (company.getTalkCallFee() != null) {
fee = company.getTalkCallFee();
}
typeStr = "拓客套餐";
} else {
fee = company.getRollCallFee();
if (company.getRollCallFee() != null) {
fee = company.getRollCallFee();
}
typeStr = "crm套餐";
}
}
double minDuration = dealDuration(duration);
double mul = NumberUtil.mul(minDuration, fee);
CallDeduct callDeduct = new CallDeduct();
callDeduct.setDeductDuration((int) minDuration);
callDeduct.setDeductAmount(mul);
callDeduct.setClueId(clueId);
callDeduct.setMemberId(memberId);
callDeduct.setCompanyId(companyId);
callDeduct.setStatus(false);
callDeduct.setComboType(typeStr);
callDeduct.setCreateTime(new Date());
callDeduct.setVersion(company.getVersion());
callDeduct.setType(DefaultNumberConstants.ONE_NUMBER);
CallDeduct save = callDeductRepository.save(callDeduct);
updateBalance(mul, companyId, company.getVersion(), save);
}

Loading…
Cancel
Save