门店号推广

master
LegnaYet 6 years ago
parent a4292628bd
commit 9c80065385

@ -3,7 +3,10 @@ package com.kiisoo.ic.common.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.kiisoo.ic.common.utils.httpClientUtil.HttpClientUtil;
import com.kiisoo.ic.config.WxCpConfiguration;
import com.kiisoo.ic.wx.entity.ContactWayDTO;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -16,6 +19,8 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import static com.kiisoo.ic.config.WxCpConfiguration.APPLICATIONID;
/**
* @author dexiang.jiang
* @data 2017/03/11
@ -37,27 +42,27 @@ public class WeixinApi {
/**
* ID
*/
public static final String CORPID = "wwc8b3e81998fe5394";
public static final String CORPID = "ww6f6138e7d7cac0f4";
/**
*
*/
public static final String CORPSECRET = "scb9m8DEtSwJpB_ZFXg4J9WE91yH-WNBBQ4Vxv1NYy4";
public static final String CORPSECRET = "Iw1OhiRnASC63B6c9yplOLril87YHPchR-eetvvBSnE";
public static final String TOKEN = "Dlmf92";
public static final String ENCODING_AES_KEY = "dzHDDrTV1ArmrRSVMf3Ex1RcU7hHNXeS0zpV86D3qTD";
public static final String TOKEN = "xX8XSN4MY5bGWdxrbDTVrtB";
public static final String ENCODING_AES_KEY = "RwYBA8OPZxx5UwEJzJdltZbamKdWfNjqu3lYcozJBYs";
/**
*
*/
public static final String CONTACT_TOKEN = "mx3hi3yH1LkkHDgvs70u";
public static final String CONTACT_ENCODING_AES_KEY = "9Dsf9pubOb2tMWtrueZsxC9jsYKX1Id7tTgeg2hou1w";
public static final String CONTACT_TOKEN = "xX8XSN4MY5bGWdxrbDTVrtB";
public static final String CONTACT_ENCODING_AES_KEY = "RwYBA8OPZxx5UwEJzJdltZbamKdWfNjqu3lYcozJBYs";
/**
*
*/
public static final String CUSTOMER_TOKEN = "Em5S2o";
public static final String CUSTOMER_ENCODING_AES_KEY = "fSPMWJe2ODX41q0ul8hmdp2y7CEep2PDGeQG5dOJDz7";
public static final String CUSTOMER_TOKEN = "xX8XSN4MY5bGWdxrbDTVrtB";
public static final String CUSTOMER_ENCODING_AES_KEY = "RwYBA8OPZxx5UwEJzJdltZbamKdWfNjqu3lYcozJBYs";
public static String getToken() throws IOException {
@ -309,8 +314,9 @@ public class WeixinApi {
* @return userid?
* @throws IOException IO
*/
public static String getExternalContactInfo(String externalUserId) throws IOException {
String token = readToken();
public static String getExternalContactInfo(String externalUserId) throws IOException, WxErrorException {
WxCpService cpService = WxCpConfiguration.getCpService(APPLICATIONID);
String token = cpService.getAccessToken();
JSONObject jsonObject2 = null;
jsonObject2 = JSON.parseObject(HttpClientUtil.httpGet("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=" + token + "&external_userid=" + externalUserId).getMessage());
if (null != jsonObject2) {

@ -57,6 +57,7 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/user/qrCode", "anon");
filterChainDefinitionMap.put("/user/sync", "anon");
filterChainDefinitionMap.put("/store/emp/download/store/code", "anon");
filterChainDefinitionMap.put("/qy/customer/handle", "anon");
filterChainDefinitionMap.put("/store/emp/download/store/seller/code", "anon");
filterChainDefinitionMap.put("/department/sync", "anon");
filterChainDefinitionMap.put("/store/promotion/data/**", "anon");

@ -32,6 +32,8 @@ public class WxCpConfiguration {
private static Map<Integer, WxCpService> cpServices = Maps.newHashMap();
public static Integer APPLICATIONID = 1000004;
@Autowired
private BasicConfigDOMapper basicConfigDOMapper;
@ -42,12 +44,12 @@ public class WxCpConfiguration {
@PostConstruct
public void initServices() {
QueryWrapper<BasicConfigDO> baseParams = new QueryWrapper<>();
baseParams.eq("code","CP_CORPID");
baseParams.eq("code","HT_CP_CORPID");
BasicConfigDO basicConfigDO = basicConfigDOMapper.selectOne(baseParams);
QueryWrapper<BasicConfigDO> confParams = new QueryWrapper<>();
confParams.likeRight("code","CP_");
confParams.ne("code","CP_CORPID");
confParams.likeRight("code","HT_CP_");
confParams.ne("code","HT_CP_CORPID");
List<BasicConfigDO> confConfigDO = basicConfigDOMapper.selectList(confParams);
Map<String,Map<String,String>> confMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(confConfigDO)){

@ -138,8 +138,11 @@ public class CustomerService {
* @param staffCode Code
*/
private void sellerCustomerRelation(OpCustomer opCustomer,String staffCode,long shopId,long sellerId){
QueryWrapper<PoiStoreStaff> staf = new QueryWrapper<PoiStoreStaff>();
staf.eq("staff_code",staffCode);
PoiStoreStaff poiStoreStaff = poiStoreStaffDOMapper.selectOne(staf);
QueryWrapper<OpSellerCustomerRelation> wrapper1 = new QueryWrapper<>();
wrapper1.eq("customer_id",opCustomer.getId()).eq("staff_code",staffCode).eq("store_id",shopId).last("limit 1");
wrapper1.eq("customer_id",opCustomer.getId()).eq("user_id",poiStoreStaff.getUserId()).eq("store_id",shopId).last("limit 1");
OpSellerCustomerRelation opSellerCustomerRelation = opSellerCustomerRelationDOMapper.selectOne(wrapper1);
if(null == opSellerCustomerRelation){
//不存在就添加

@ -27,6 +27,7 @@ import java.util.Date;
@Service
public class CustomerEnterpriseService {
@Autowired
private OpCustomerEnterpriseWechatDOMapper opCustomerDOMapper;
/**

@ -17,4 +17,6 @@ import java.util.List;
@Repository
public interface PrivilageCpUserStoreDOMapper extends BaseMapper<PrivilageCpUserStoreDO> {
List<StoreUserDTO> selectCpUserByShops (@Param("shopIds") List<Long> shops);
Long selectOneByCpUserId(String cpuserId);
}

@ -60,7 +60,7 @@ public class WxAccessController extends BaseController {
private QrCodeService qrCodeService;
private String loginPageUrl = "http://localhost:8311/kiisoo-ic-ui";
private String baseUrl = "http://jdxdev.vipgz4.idcfengye.com/kiisoo-ic";
private String baseUrl = "http://jdxdev.vipgz4.idcfengye.com/ic";
/**
*
@ -255,6 +255,40 @@ public class WxAccessController extends BaseController {
}
/**
* (controller)
*
* @param sVerifyMsgSig msg_signature
* @param sVerifyTimeStamp timestamp
* @param sVerifyNonce nonce
* @param sVerifyEchoStr echostr
* @return urlticket
* @author dexiang.jiang
* @date 2020/03/11 15:44
*/
// @RequestMapping(value = "/customer/handle", method = RequestMethod.GET)
// @ResponseBody
// public String verify(@RequestParam("msg_signature") String sVerifyMsgSig,
// @RequestParam("timestamp") String sVerifyTimeStamp,
// @RequestParam("nonce") String sVerifyNonce,
// @RequestParam("echostr") String sVerifyEchoStr) {
//
// try {
// String sEchoStr = wxResponseService.VerifyURL(sVerifyMsgSig, sVerifyTimeStamp,
// sVerifyNonce, sVerifyEchoStr);
// // 验证URL成功将sEchoStr返回
// System.out.println(sEchoStr);
// return sEchoStr;
// } catch (Exception e) {
// //验证URL失败错误原因请查看异常
// e.printStackTrace();
// }
// return null;
// }
/**
* -
*

@ -3,23 +3,25 @@ package com.kiisoo.ic.wx.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.kiisoo.ic.common.utils.WeixinApi;
import com.kiisoo.ic.config.WxCpConfiguration;
import com.kiisoo.ic.customer.CustomerService;
import com.kiisoo.ic.customer.bean.CustomerDTO;
import com.kiisoo.ic.customer.bean.CustomerModifyDTO;
import com.kiisoo.ic.customer.entity.OpCustomerEnterpriseWechat;
import com.kiisoo.ic.customer.mapper.OpCustomerEnterpriseWechatDOMapper;
import com.kiisoo.ic.customer.service.CustomerEnterpriseService;
import com.kiisoo.ic.employee.entity.QrCodeVO;
import com.kiisoo.ic.store.entity.PoiStore;
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper;
import com.kiisoo.ic.wx.aes.AesException;
import com.kiisoo.ic.wx.aes.WXBizMsgCrypt;
import com.kiisoo.ic.wx.entity.FollowUserDTO;
import com.kiisoo.ic.wx.entity.FollowUserTag;
import com.sun.org.apache.regexp.internal.RE;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.w3c.dom.Document;
@ -33,10 +35,11 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.io.StringReader;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import static com.kiisoo.ic.config.WxCpConfiguration.APPLICATIONID;
/**
* @author yechenhao
* @date 2020/03/16 16:45
@ -54,6 +57,15 @@ public class WxResponseService {
@Autowired
private QWMailListManageService qwMailListManageService;
@Autowired
private PrivilageCpUserStoreDOMapper privilageCpUserStoreDOMapper;
@Autowired
private PoiStoreDOMapper poiStoreDOMapper;
@Autowired
private PoiStoreStaffDOMapper poiStoreStaffDOMapper;
/**
* (使)
*
@ -276,7 +288,8 @@ public class WxResponseService {
* @throws Exception
*/
public String customerParse(String sVerifyMsgSig, String sVerifyTimeStamp, String sVerifyNonce, String data) throws AesException, ParserConfigurationException, IOException, SAXException, WxErrorException {
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WeixinApi.CUSTOMER_TOKEN, WeixinApi.CUSTOMER_ENCODING_AES_KEY, WeixinApi.CORPID);
WxCpService cpService = WxCpConfiguration.getCpService(APPLICATIONID);
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(cpService.getWxCpConfigStorage().getToken(), cpService.getWxCpConfigStorage().getAesKey(), cpService.getWxCpConfigStorage().getCorpId());
String sMsg = wxcpt.DecryptMsg(sVerifyMsgSig, sVerifyTimeStamp, sVerifyNonce, data);
log.info(sMsg);
//解析xml
@ -349,10 +362,10 @@ public class WxResponseService {
//添加客户并添加店铺企业微信信息
addExternalContact(res);
welcomeCodeNode = root.getElementsByTagName("WelcomeCode");
welcomeCode = welcomeCodeNode.item(0).getTextContent();
sendWelcomeMsg(welcomeCode);
// welcomeCodeNode = root.getElementsByTagName("WelcomeCode");
// welcomeCode = welcomeCodeNode.item(0).getTextContent();
//
// sendWelcomeMsg(welcomeCode);
break;
case "add_half_external_contact":
@ -404,7 +417,7 @@ public class WxResponseService {
* @param
* @return
*/
public OpCustomerEnterpriseWechat analyticCustomerEnterprise(String res){
public OpCustomerEnterpriseWechat analyticCustomerEnterprise(String res){
JSONObject parseObject = JSON.parseObject(res);
//解析企业微信信息
OpCustomerEnterpriseWechat ocew = JSONObject.parseObject(parseObject.getString("external_contact"), OpCustomerEnterpriseWechat.class);
@ -442,7 +455,14 @@ public class WxResponseService {
String[] split = ocew.getState().split("-");
customerDTO.setShopCode(split[0]);
customerDTO.setStaffCode(split[1]);
};
}else{
String cpuserId = ocew.getUserid();
Long storeId = privilageCpUserStoreDOMapper.selectOneByCpUserId(cpuserId);
PoiStore poiStore = poiStoreDOMapper.selectById(storeId);
customerDTO.setShopCode(poiStore.getCode());
String staffCode = poiStoreStaffDOMapper.selectShopManagerByShop(storeId);
customerDTO.setStaffCode(staffCode);
}
//调添加客户接口
Long customerId = customerService.customerRelation(customerDTO);
if (null != customerId){

@ -19,4 +19,11 @@
order by pcu.id desc
</select>
<select id="selectOneByCpUserId" resultType="java.lang.Long">
select pcus.store_id
from privilage_cp_user_store pcus ,privilage_cp_user pcu where pcus.cp_user_id = pcu.id and pcu.status in (1,4)
and pcu.cp_user_id = #{cpuserId}
limit 1
</select>
</mapper>

Loading…
Cancel
Save