|
@@ -0,0 +1,165 @@
|
|
|
+package com.iotechn.unimall.admin.api.card.impl;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import com.iotechn.unimall.admin.api.card.ICardExchangeInfoService;
|
|
|
+import com.iotechn.unimall.data.domain.CardExchangeInfo;
|
|
|
+import com.iotechn.unimall.data.domain.CardHolderInfo;
|
|
|
+import com.iotechn.unimall.data.mapper.CardExchangeInfoMapper;
|
|
|
+import com.iotechn.unimall.data.mapper.CardHolderInfoMapper;
|
|
|
+import com.iotechn.unimall.data.model.Page;
|
|
|
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
+import com.baomidou.mybatisplus.mapper.Wrapper;
|
|
|
+import com.iotechn.unimall.data.util.ExcelUtil;
|
|
|
+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.iotechn.unimall.core.exception.ServiceException;
|
|
|
+import java.util.Date;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 名片交换Service业务层处理
|
|
|
+ *
|
|
|
+ * @author jlb
|
|
|
+ * @date 2023-04-12
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CardExchangeInfoServiceImpl implements ICardExchangeInfoService {
|
|
|
+ @Autowired
|
|
|
+ private CardExchangeInfoMapper cardExchangeInfoMapper;
|
|
|
+ @Autowired
|
|
|
+ private CardHolderInfoMapper cardHolderInfoMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean add(CardExchangeInfo cardExchangeInfo) throws ServiceException {
|
|
|
+ Date now = new Date();
|
|
|
+ cardExchangeInfo.setGmtCreate(now);
|
|
|
+ cardExchangeInfo.setGmtUpdate(now);
|
|
|
+ return cardExchangeInfoMapper.insert(cardExchangeInfo)>0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<CardExchangeInfo> list(Long sendId,Long receiveId,Long sendCardId,Long receiveCardId,String circleName,String status,Date gmtCreate,Date gmtUpdate,Long deleteFlag, Integer page, Integer limit)throws ServiceException {
|
|
|
+ Wrapper<CardExchangeInfo> wrapper = new EntityWrapper<CardExchangeInfo>();
|
|
|
+ if (!StringUtils.isEmpty(sendId)) {
|
|
|
+ wrapper.eq("send_id", sendId);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(receiveId)) {
|
|
|
+ wrapper.eq("receive_id", receiveId);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(sendCardId)) {
|
|
|
+ wrapper.eq("send_card_id", sendCardId);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(receiveCardId)) {
|
|
|
+ wrapper.eq("receive_card_id", receiveCardId);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(circleName)) {
|
|
|
+ wrapper.eq("circle_name", circleName);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(status)) {
|
|
|
+ wrapper.eq("status", status);
|
|
|
+ }
|
|
|
+ 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<CardExchangeInfo> list = cardExchangeInfoMapper.selectPage(new RowBounds((page - 1) * limit, limit), wrapper);
|
|
|
+ Integer count = cardExchangeInfoMapper.selectCount(wrapper);
|
|
|
+ return new Page<CardExchangeInfo>(list, page, limit, count);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean delete(String id) {
|
|
|
+ String[] ids = String.valueOf(id).split(",");
|
|
|
+ for (String tt:ids) {
|
|
|
+ CardExchangeInfo tmp = cardExchangeInfoMapper.selectById(Long.parseLong(tt));
|
|
|
+ if(tmp != null){
|
|
|
+ tmp.setDeleteFlag(1L);
|
|
|
+ cardExchangeInfoMapper.updateById(tmp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean update(CardExchangeInfo cardExchangeInfo,String updateFlag) throws ServiceException {
|
|
|
+ Date now = new Date();
|
|
|
+ cardExchangeInfo.setGmtUpdate(now);
|
|
|
+ //拉黑
|
|
|
+ if ("1".equals(updateFlag)){
|
|
|
+ }
|
|
|
+ //拒绝
|
|
|
+ else if ("2".equals(updateFlag)){
|
|
|
+ cardExchangeInfo.setStatus("3");
|
|
|
+ }
|
|
|
+ //接受
|
|
|
+ else{
|
|
|
+ cardExchangeInfo.setStatus("1");
|
|
|
+ //发起人名片夹添加数据
|
|
|
+ CardHolderInfo cardHolderInfo=new CardHolderInfo();
|
|
|
+ cardHolderInfo.setCardId(String.valueOf(cardExchangeInfo.getReceiveCardId()));
|
|
|
+ cardHolderInfo.setCommonId(cardExchangeInfo.getSendId());
|
|
|
+ cardHolderInfo.setGmtCreate(now);
|
|
|
+ cardHolderInfo.setGmtUpdate(now);
|
|
|
+ cardHolderInfoMapper.insert(cardHolderInfo);
|
|
|
+ //接收人名片夹添加数据
|
|
|
+ cardHolderInfo=new CardHolderInfo();
|
|
|
+ cardHolderInfo.setCardId(String.valueOf(cardExchangeInfo.getSendCardId()));
|
|
|
+ cardHolderInfo.setCommonId(cardExchangeInfo.getReceiveId());
|
|
|
+ cardHolderInfo.setGmtCreate(now);
|
|
|
+ cardHolderInfo.setGmtUpdate(now);
|
|
|
+ cardHolderInfoMapper.insert(cardHolderInfo);
|
|
|
+ }
|
|
|
+ return cardExchangeInfoMapper.updateById(cardExchangeInfo)>0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CardExchangeInfo get(Long id) throws ServiceException {
|
|
|
+ return cardExchangeInfoMapper.selectById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String export(Long sendId,Long receiveId,Long sendCardId,Long receiveCardId,String circleName,String status,Date gmtCreate,Date gmtUpdate,Long deleteFlag, Integer page, Integer limit)throws ServiceException {
|
|
|
+ Wrapper<CardExchangeInfo> wrapper = new EntityWrapper<CardExchangeInfo>();
|
|
|
+ if (!StringUtils.isEmpty(sendId)) {
|
|
|
+ wrapper.eq("send_id", sendId);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(receiveId)) {
|
|
|
+ wrapper.eq("receive_id", receiveId);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(sendCardId)) {
|
|
|
+ wrapper.eq("send_card_id", sendCardId);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(receiveCardId)) {
|
|
|
+ wrapper.eq("receive_card_id", receiveCardId);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(circleName)) {
|
|
|
+ wrapper.eq("circle_name", circleName);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(status)) {
|
|
|
+ wrapper.eq("status", status);
|
|
|
+ }
|
|
|
+ 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<CardExchangeInfo> list = cardExchangeInfoMapper.selectList(wrapper);
|
|
|
+ ExcelUtil<CardExchangeInfo> util = new ExcelUtil<CardExchangeInfo>(CardExchangeInfo.class);
|
|
|
+ return util.exportExcel(list, "操作日志");
|
|
|
+ }
|
|
|
+}
|