|
@@ -0,0 +1,140 @@
|
|
|
+package com.iotechn.unimall.admin.api.tourism.impl;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import com.iotechn.unimall.core.exception.AppServiceException;
|
|
|
+import com.iotechn.unimall.core.exception.ExceptionDefinition;
|
|
|
+import org.apache.ibatis.session.RowBounds;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
+import com.baomidou.mybatisplus.mapper.Wrapper;
|
|
|
+import com.iotechn.unimall.core.exception.ServiceException;
|
|
|
+import com.iotechn.unimall.data.util.ExcelUtil;
|
|
|
+import com.iotechn.unimall.data.mapper.PhoneRecordInfoMapper;
|
|
|
+import com.iotechn.unimall.data.domain.PhoneRecordInfo;
|
|
|
+import com.iotechn.unimall.admin.api.tourism.IPhoneRecordInfoService;
|
|
|
+import com.iotechn.unimall.data.model.Page;
|
|
|
+import java.util.Date;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 拨打电话记录Service业务层处理
|
|
|
+ *
|
|
|
+ * @author jlb
|
|
|
+ * @date 2023-06-25
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class PhoneRecordInfoServiceImpl implements IPhoneRecordInfoService{
|
|
|
+ @Autowired
|
|
|
+ private PhoneRecordInfoMapper phoneRecordInfoMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean add(PhoneRecordInfo phoneRecordInfo) throws ServiceException {
|
|
|
+ Date now = new Date();
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ //一小时之前的时间
|
|
|
+ calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1);
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String time=df.format(calendar.getTime());
|
|
|
+ Calendar calendar1 = Calendar.getInstance();
|
|
|
+ //一天前的时间
|
|
|
+ calendar1.setTime(now);
|
|
|
+ calendar1.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
+ String time1=df.format(calendar1.getTime());
|
|
|
+ List<PhoneRecordInfo> phoneRecordInfoList=phoneRecordInfoMapper.selectList(new EntityWrapper<PhoneRecordInfo>()
|
|
|
+ .eq("phone",phoneRecordInfo.getPhone())
|
|
|
+ .eq("common_id",phoneRecordInfo.getCommonId())
|
|
|
+ .gt("gmt_create",time));
|
|
|
+ if (phoneRecordInfoList.size()>10){
|
|
|
+ throw new AppServiceException(ExceptionDefinition.OPERATE_FREQUENTLY_ERROR);
|
|
|
+ }
|
|
|
+ List<PhoneRecordInfo> phoneRecordInfoList1=phoneRecordInfoMapper.selectList(new EntityWrapper<PhoneRecordInfo>()
|
|
|
+ .eq("phone",phoneRecordInfo.getPhone())
|
|
|
+ .eq("common_id",phoneRecordInfo.getCommonId())
|
|
|
+ .gt("gmt_create",time1));
|
|
|
+ if (phoneRecordInfoList1.size()>20){
|
|
|
+ throw new AppServiceException(ExceptionDefinition.OPERATE_FREQUENTLY_ERROR);
|
|
|
+ }
|
|
|
+ phoneRecordInfo.setGmtCreate(now);
|
|
|
+ phoneRecordInfo.setGmtUpdate(now);
|
|
|
+ return phoneRecordInfoMapper.insert(phoneRecordInfo)>0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<PhoneRecordInfo> list(Long commonId,String phone,Date gmtCreate,Date gmtUpdate,Long deleteFlag, Integer page, Integer limit)throws ServiceException {
|
|
|
+ Wrapper<PhoneRecordInfo> wrapper = new EntityWrapper<PhoneRecordInfo>();
|
|
|
+ if (!StringUtils.isEmpty(commonId)) {
|
|
|
+ wrapper.eq("common_id", commonId);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(phone)) {
|
|
|
+ wrapper.eq("phone", phone);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(gmtCreate)) {
|
|
|
+ wrapper.eq("gmt_create", gmtCreate);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(gmtUpdate)) {
|
|
|
+ wrapper.eq("gmt_update", gmtUpdate);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(deleteFlag)) {
|
|
|
+ wrapper.eq("delete_flag", deleteFlag);
|
|
|
+ }
|
|
|
+ wrapper.eq("delete_flag", 0);
|
|
|
+ List<PhoneRecordInfo> list = phoneRecordInfoMapper.selectPage(new RowBounds((page - 1) * limit, limit), wrapper);
|
|
|
+ Integer count = phoneRecordInfoMapper.selectCount(wrapper);
|
|
|
+ return new Page<PhoneRecordInfo>(list, page, limit, count);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean delete(String id) {
|
|
|
+ String[] ids = String.valueOf(id).split(",");
|
|
|
+ for (String tt:ids) {
|
|
|
+ PhoneRecordInfo tmp = phoneRecordInfoMapper.selectById(Long.parseLong(tt));
|
|
|
+ if(tmp != null){
|
|
|
+ tmp.setDeleteFlag(1l);
|
|
|
+ phoneRecordInfoMapper.updateById(tmp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean update(PhoneRecordInfo phoneRecordInfo) throws ServiceException {
|
|
|
+ Date now = new Date();
|
|
|
+ phoneRecordInfo.setGmtUpdate(now);
|
|
|
+ return phoneRecordInfoMapper.updateById(phoneRecordInfo)>0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PhoneRecordInfo get(Long id) throws ServiceException {
|
|
|
+ return phoneRecordInfoMapper.selectById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String export(Long commonId,String phone,Date gmtCreate,Date gmtUpdate,Long deleteFlag, Integer page, Integer limit)throws ServiceException {
|
|
|
+ Wrapper<PhoneRecordInfo> wrapper = new EntityWrapper<PhoneRecordInfo>();
|
|
|
+ if (!StringUtils.isEmpty(commonId)) {
|
|
|
+ wrapper.eq("common_id", commonId);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(phone)) {
|
|
|
+ wrapper.eq("phone", phone);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(gmtCreate)) {
|
|
|
+ wrapper.eq("gmt_create", gmtCreate);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(gmtUpdate)) {
|
|
|
+ wrapper.eq("gmt_update", gmtUpdate);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(deleteFlag)) {
|
|
|
+ wrapper.eq("delete_flag", deleteFlag);
|
|
|
+ }
|
|
|
+ List<PhoneRecordInfo> list = phoneRecordInfoMapper.selectList(wrapper);
|
|
|
+ ExcelUtil<PhoneRecordInfo> util = new ExcelUtil<PhoneRecordInfo>(PhoneRecordInfo.class);
|
|
|
+ return util.exportExcel(list, "操作日志");
|
|
|
+ }
|
|
|
+}
|