生成导购二维码添加店铺人员事件
parent
c7ea9d04f7
commit
cd1e0baa2d
@ -1,16 +0,0 @@
|
|||||||
//package com.kiisoo.ic.employee.mapper;
|
|
||||||
//
|
|
||||||
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
//import com.kiisoo.ic.employee.entity.PoiStoreStaffDO;
|
|
||||||
//import org.springframework.stereotype.Repository;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * @Description 店铺人员表mapper
|
|
||||||
// * @Author yinliujing
|
|
||||||
// * @Version V1.0.0
|
|
||||||
// * @Date 2020/4/7
|
|
||||||
// */
|
|
||||||
//@Repository
|
|
||||||
//public interface PoiStoreStaffDOMapper extends BaseMapper<PoiStoreStaffDO> {
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
@ -1,87 +1,108 @@
|
|||||||
//package com.kiisoo.ic.employee.service;
|
package com.kiisoo.ic.employee.service;
|
||||||
//
|
|
||||||
//import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
//import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
//import com.kiisoo.ic.config.WxCpConfiguration;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
//import com.kiisoo.ic.employee.entity.PoiStoreStaffDO;
|
import com.kiisoo.ic.config.WxCpConfiguration;
|
||||||
//import com.kiisoo.ic.employee.entity.QrCodeDO;
|
import com.kiisoo.ic.employee.entity.QrCodeDO;
|
||||||
//import com.kiisoo.ic.employee.entity.QrCodeVO;
|
import com.kiisoo.ic.employee.entity.QrCodeVO;
|
||||||
////import com.kiisoo.ic.employee.mapper.PoiStoreStaffDOMapper;
|
import com.kiisoo.ic.store.entity.PoiStoreStaff;
|
||||||
//import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
|
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
|
||||||
//import me.chanjar.weixin.common.error.WxErrorException;
|
import me.chanjar.weixin.common.error.WxErrorException;
|
||||||
//import me.chanjar.weixin.cp.api.WxCpService;
|
import me.chanjar.weixin.cp.api.WxCpService;
|
||||||
//import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
//import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
//import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
//
|
|
||||||
//import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
//import java.util.Map;
|
import java.util.Map;
|
||||||
//
|
|
||||||
///**
|
/**
|
||||||
// * @Description: 推广码业务
|
* @Description: 推广码业务
|
||||||
// * @Auther: yinliujing
|
* @Auther: yinliujing
|
||||||
// * @Date: 2020/4/7 0002 14:06
|
* @Date: 2020/4/7 0002 14:06
|
||||||
// * @Version: v1
|
* @Version: v1
|
||||||
// */
|
*/
|
||||||
//@Service
|
@Service
|
||||||
//public class QrCodeService {
|
public class QrCodeService {
|
||||||
// WxCpService mainService = WxCpConfiguration.getCpService(1000037);
|
WxCpService mainService = WxCpConfiguration.getCpService(1000037);
|
||||||
// @Autowired
|
@Autowired
|
||||||
// private PoiStoreStaffDOMapper poiStoreStaffDOMapper;
|
private PoiStoreStaffDOMapper poiStoreStaffDOMapper;
|
||||||
//
|
|
||||||
// public QrCodeVO getQrCode(QrCodeDO qrCodeDO) throws Exception {
|
public QrCodeVO getQrCode(QrCodeDO qrCodeDO) throws Exception {
|
||||||
// //获取token
|
//获取token
|
||||||
// String token = mainService.getAccessToken();
|
String token = mainService.getAccessToken();
|
||||||
// qrCodeDO.setAccess_token(token);
|
qrCodeDO.setAccess_token(token);
|
||||||
// //获取configId
|
//获取configId
|
||||||
// String configId = getConfigId(qrCodeDO);
|
String configId = getConfigId(qrCodeDO);
|
||||||
// //获取配置实体
|
//获取配置实体
|
||||||
// QrCodeVO qrCodeVO = getContactWay(token, configId);
|
QrCodeVO qrCodeVO = getContactWay(token, configId);
|
||||||
// return qrCodeVO;
|
//添加店铺人员
|
||||||
// }
|
saveStoreStaff( parseStoreStaff(qrCodeDO,qrCodeVO));
|
||||||
//
|
return qrCodeVO;
|
||||||
// /**
|
}
|
||||||
// * 配置客户联系「联系我」方式
|
|
||||||
// *
|
/**
|
||||||
// * @param qrCodeDO
|
* 配置客户联系「联系我」方式
|
||||||
// * @return
|
*
|
||||||
// * @throws WxErrorException
|
* @param qrCodeDO
|
||||||
// */
|
* @return
|
||||||
// public String getConfigId(QrCodeDO qrCodeDO) throws WxErrorException {
|
* @throws WxErrorException
|
||||||
// String url = mainService.getWxCpConfigStorage().getApiUrl("/cgi-bin/externalcontact/add_contact_way");
|
*/
|
||||||
// String result = mainService.post(url, qrCodeDO.toJson());
|
public String getConfigId(QrCodeDO qrCodeDO) throws WxErrorException {
|
||||||
// JSONObject parseObject = JSON.parseObject(result);
|
String url = mainService.getWxCpConfigStorage().getApiUrl("/cgi-bin/externalcontact/add_contact_way");
|
||||||
// String configId = parseObject.getString("config_id");
|
String result = mainService.post(url, qrCodeDO.toJson());
|
||||||
// return configId;
|
JSONObject parseObject = JSON.parseObject(result);
|
||||||
// }
|
String configId = parseObject.getString("config_id");
|
||||||
//
|
return configId;
|
||||||
// /**
|
}
|
||||||
// * 获取企业已配置的「联系我」方式
|
|
||||||
// *
|
/**
|
||||||
// * @param token
|
* 获取企业已配置的「联系我」方式
|
||||||
// * @param configId
|
*
|
||||||
// * @return
|
* @param token
|
||||||
// * @throws WxErrorException
|
* @param configId
|
||||||
// */
|
* @return
|
||||||
// public QrCodeVO getContactWay(String token, String configId) throws WxErrorException {
|
* @throws WxErrorException
|
||||||
// String url = mainService.getWxCpConfigStorage().getApiUrl("/cgi-bin/externalcontact/get_contact_way");
|
*/
|
||||||
// Map<String, Object> map = new HashMap<>();
|
public QrCodeVO getContactWay(String token, String configId) throws WxErrorException {
|
||||||
// map.put("config_id", configId);
|
String url = mainService.getWxCpConfigStorage().getApiUrl("/cgi-bin/externalcontact/get_contact_way");
|
||||||
// map.put("access_token", token);
|
Map<String, Object> map = new HashMap<>();
|
||||||
// String result = mainService.post(url, JSON.toJSONString(map));
|
map.put("config_id", configId);
|
||||||
// JSONObject parseObject = JSON.parseObject(result);
|
map.put("access_token", token);
|
||||||
// QrCodeVO qrCodeVO = JSONObject.parseObject(parseObject.getString("contact_way"), QrCodeVO.class);
|
String result = mainService.post(url, JSON.toJSONString(map));
|
||||||
// return qrCodeVO;
|
JSONObject parseObject = JSON.parseObject(result);
|
||||||
// }
|
QrCodeVO qrCodeVO = JSONObject.parseObject(parseObject.getString("contact_way"), QrCodeVO.class);
|
||||||
//
|
return qrCodeVO;
|
||||||
// /**
|
}
|
||||||
// * 添加店铺人员表
|
|
||||||
// * @return
|
|
||||||
// * @throws WxErrorException
|
/***
|
||||||
// */
|
*封装需要添加的店铺人员实体
|
||||||
// @Transactional(rollbackFor = Exception.class)
|
* 前台传的实体参数
|
||||||
// public int saveStoreStaff(PoiStoreStaffDO poiStoreStaffDO) throws Exception {
|
* 企业微信返回的实体
|
||||||
// return poiStoreStaffDOMapper.insert(poiStoreStaffDO);
|
*/
|
||||||
// }
|
public PoiStoreStaff parseStoreStaff(QrCodeDO qrCodeDO,QrCodeVO qrCodeVO) throws Exception {
|
||||||
//}
|
PoiStoreStaff poiStoreStaff = new PoiStoreStaff();
|
||||||
|
BeanUtils.copyProperties(qrCodeDO,poiStoreStaff);
|
||||||
|
poiStoreStaff.setType(qrCodeDO.getRole());
|
||||||
|
poiStoreStaff.setEpWechatQrCode(qrCodeVO.getQr_code());
|
||||||
|
poiStoreStaff.setEpWechatConfigId(qrCodeVO.getConfig_id());
|
||||||
|
return poiStoreStaff;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 添加店铺人员表
|
||||||
|
* @return
|
||||||
|
* @throws WxErrorException
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void saveStoreStaff(PoiStoreStaff poiStoreStaffDO) throws Exception {
|
||||||
|
QueryWrapper<PoiStoreStaff> storeStaff = new QueryWrapper<>();
|
||||||
|
storeStaff.eq("user_id",poiStoreStaffDO.getUserId()).eq("store_id",poiStoreStaffDO.getStoreId()).last("limit 1");
|
||||||
|
PoiStoreStaff poiStoreStaff = poiStoreStaffDOMapper.selectOne(storeStaff);
|
||||||
|
if (null == poiStoreStaff){
|
||||||
|
poiStoreStaffDOMapper.insert(poiStoreStaffDO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue