Commit b837e5a5 by qwmqiuwenmin

Merge branch 'developer' into 'master'

Developer

See merge request !75
parents 3a9b40bb 277bdc61
......@@ -38,46 +38,46 @@ public class GlobalExceptionHandler extends WebBaseController {
}
@ResponseBody
@ExceptionHandler(RuntimeException.class)
public HaobanResponse ControllerException(HttpServletResponse response, RuntimeException ex) {
HaobanResponse res = new HaobanResponse();
res.setErrorCode(HaoBanErrCode.ERR_3.getCode());
String message = ex.getMessage();
if (message != null && message.indexOf(ShowFrontMessageException.class.getName()) > -1) {
Matcher matcher = pattern.matcher(message);
while (matcher.find()) {
message = (matcher.group(2));
}
} else {
message = HaoBanErrCode.ERR_3.getMsg();
}
res.setMessage(message);
return res;
}
// @ResponseBody
// @ExceptionHandler(RuntimeException.class)
// public HaobanResponse ControllerException(HttpServletResponse response, RuntimeException ex) {
// HaobanResponse res = new HaobanResponse();
// res.setErrorCode(HaoBanErrCode.ERR_3.getCode());
// String message = ex.getMessage();
// if (message != null && message.indexOf(ShowFrontMessageException.class.getName()) > -1) {
// Matcher matcher = pattern.matcher(message);
// while (matcher.find()) {
// message = (matcher.group(2));
// }
// } else {
// message = HaoBanErrCode.ERR_3.getMsg();
// }
// res.setMessage(message);
// return res;
// }
@ResponseBody
@ExceptionHandler(Exception.class)
public HaobanResponse ControllerException(HttpServletResponse response, Exception ex) {
logger.error("err");
ex.printStackTrace();
HaoBanErrCode errCode = HaoBanErrCode.ERR_3;
StringBuilder sb = new StringBuilder();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (PrintWriter printWriter = new PrintWriter(baos)) {
ex.printStackTrace(printWriter);
}
try {
sb.append(baos.toString());
} catch (Exception ignored) {
}
if (sb.length() == 0) {
sb.append(ex.getMessage());
}
// 输出详细错误信息,便于调试
return resultResponse(errCode, null, sb.toString());
}
// @ResponseBody
// @ExceptionHandler(Exception.class)
// public HaobanResponse ControllerException(HttpServletResponse response, Exception ex) {
// logger.error("err");
// ex.printStackTrace();
// HaoBanErrCode errCode = HaoBanErrCode.ERR_3;
// StringBuilder sb = new StringBuilder();
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// try (PrintWriter printWriter = new PrintWriter(baos)) {
// ex.printStackTrace(printWriter);
// }
// try {
// sb.append(baos.toString());
// } catch (Exception ignored) {
// }
// if (sb.length() == 0) {
// sb.append(ex.getMessage());
// }
//
// // 输出详细错误信息,便于调试
// return resultResponse(errCode, null, sb.toString());
// }
@ResponseBody
......
package com.gic.haoban.manage.service.service;
import com.gic.haoban.manage.service.entity.Test;
/**
* Created by tgs on 2020/2/9.
*/
public interface TestService {
public void save(Test test);
}
package com.gic.haoban.manage.service.service.impl;
import com.gic.haoban.manage.service.dao.mapper.TestMapper;
import com.gic.haoban.manage.service.entity.Test;
import com.gic.haoban.manage.service.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by tgs on 2020/2/9.
*/
public class TestApiServiceImpl {
@Service
public class TestApiServiceImpl implements TestService {
@Autowired
private TestMapper testMapper;
@Override
public void save(Test test) {
testMapper.insert(test);
}
}
......@@ -33,6 +33,7 @@ import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.Page;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.clerk.api.service.PowerService;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.MD5Utils;
......@@ -125,6 +126,8 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
private StaffClerkRelationService staffClerkRelationService;
@Autowired
private ExternalClerkRelatedService externalClerkRelatedService;
@Autowired
private PowerService powerService;
@Override
public List<MemberStoreDTO> listByExTernalUseridAndWxUserId(String externalUserid, String wxUserId) {
......@@ -293,9 +296,19 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
String clerkCode = staffClerkRelationDTO.getClerkCode();
ClerkDTO clerk = clerkService.getClerkByClerkCode(staffClerkRelationDTO.getEnterpriseId(), clerkCode);
log.info("【新增外部联系人】clerkCode={},unionid:{}",clerkCode,unionId);
if(clerk != null && StringUtils.isNotBlank(clerk.getQrcodeParam())&&StringUtils.isNotBlank(unionId)){
log.info("【新增外部联系人会员】enterpriseId={},unionId={},name={},avatar={},QrcodeParam={}",staffClerkRelationDTO.getEnterpriseId(),unionId,name,avatar,clerk.getQrcodeParam());
member = memberOpenCardBusinessService.getMemberByQywxChannelParam(staffClerkRelationDTO.getEnterpriseId(),unionId,"",name,avatar,clerk.getQrcodeParam());
if(clerk == null){
log.info("【新增外币联系人】导购为空");
return;
}
String qrcodeParam = clerk.getQrcodeParam();
if(StringUtils.isBlank(qrcodeParam)){
powerService.saveClerkQrCode(clerk.getClerkId());
clerk = clerkService.getClerkByClerkCode(staffClerkRelationDTO.getEnterpriseId(), clerkCode);
qrcodeParam = clerk.getQrcodeParam();
}
if(clerk != null && StringUtils.isNotBlank(qrcodeParam)&&StringUtils.isNotBlank(unionId)){
log.info("【新增外部联系人会员】enterpriseId={},unionId={},name={},avatar={},QrcodeParam={}",staffClerkRelationDTO.getEnterpriseId(),unionId,name,avatar,qrcodeParam);
member = memberOpenCardBusinessService.getMemberByQywxChannelParam(staffClerkRelationDTO.getEnterpriseId(),unionId,"",name,avatar,qrcodeParam);
}
TabHaobanExternalClerkRelated exsitDTO = externalClerkRelatedService.getByParams(wxUserId, wxEnterpriseId,name,createTime);
......
......@@ -74,5 +74,7 @@
<dubbo:reference id="enterpriseService" interface="com.gic.enterprise.api.service.EnterpriseService" timeout="10000" retries="0" check="false" />
<dubbo:reference interface="com.gic.haoban.communicate.api.service.SyncHaobanToGicServiceApi" id="syncHaobanToGicServiceApi"/>
<dubbo:reference interface="com.gic.clerk.api.service.PowerService" id="powerService"/>
</beans>
\ No newline at end of file
......@@ -8,7 +8,10 @@
<sql id="Base_Column_List">
id, name
</sql>
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.Test" >
insert into test (id,name)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR})
</insert>
<select id="queryList" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
......
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.JSONResponse;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.SyncSingleDealDTO;
import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.wechat.api.dto.qywx.DepartmentDTO;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.gic.haoban.manage.service.service.TestService;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.QywxExternalcontactDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.redisson.api.RLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class DealSyncTest {
private static Logger logger= LoggerFactory.getLogger(DealSyncTest.class);
@Autowired
private DealSyncOperationApiService dealSyncOperationApiService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private StaffService staffService;
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private TestService testService;
@Test
public void test() {
List<SyncSingleDealDTO> add = new ArrayList<>();
......@@ -64,11 +75,104 @@ public class DealSyncTest {
@Test
public void test2() {
dealSyncOperationApiService.cleanDiffrence("ca66a01b79474c40b3e7c7f93daf1a3b", "73387b7d355c416f93242f3d71a487a8");
int i =1;
while (true) {
i++;
if (i==5){
System.out.println("close");
RedisUtil.close();
}
if (i==10||i==25){
System.out.println("creConnect");
RedisUtil.reConnect();
}
try {
RedisUtil.setCache("1", "2");
Object cache = RedisUtil.getCache("1");
System.out.println("======={}"+i+":"+cache);
Thread.sleep(2000);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Test
public void test3() {
staffApiService.getWxSaveNew("3e7a7c09097a40b18aef1478b04688fe", "ca66a01b79474c40b3e7c7f93daf1a3b");
}
@Test
public void test5() {
String key="test2";
RedisUtil.lock(key,100L, TimeUnit.SECONDS,0L);
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// if(RedisUtil.isLocked(key)){
// RedisUtil.unlock(key);
// }
}
@Test
public void test6() {
String key="test2";
// RedisUtil.lock(key,100L, TimeUnit.SECONDS,0L);
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
RLock lock = RedisUtil.getRedisClient().getLock(key);
try {
if (lock.tryLock(0, 10, TimeUnit.MINUTES)) {
try {
Thread.sleep(1000L);
} finally {
lock.unlock();
}
}
} catch (InterruptedException e) {
e.printStackTrace();
}
// if(RedisUtil.isLocked(key)){
// RedisUtil.unlock(key);
// }
// RedisUtil.unlock();
// RedisUtil.setCache("test5511","111",2592030L);
}
@Test
public void test4() {
List<StaffDTO> retList = staffService.listByUserIdsAndWxEnterpriseId(null, "ca66a01b79474c40b3e7c7f93daf1a3b");
System.out.println(retList.size());
if (CollectionUtils.isEmpty(retList)) {
return;
}
List<StaffDTO> staffDTOS = retList.subList(2, retList.size()-1);
staffDTOS.forEach(staffDTO -> {
if (StringUtils.isNotBlank(staffDTO.getWxUserId())) {
logger.info(staffDTO.getWxUserId());
QywxExternalcontactDTO send = new QywxExternalcontactDTO();
send.setType(1);
send.setScene(1);
send.setRemark("tesst_" + staffDTO.getPhoneNumber());
List<String> userIds = new ArrayList<>();
userIds.add(staffDTO.getWxUserId());
send.setUser(userIds);
String configId = qywxUserApiService.getExternalcontactByUserId("ww9ede832a84b7ae5f", "65zze159pYb4ofbFsIREZ5X7d7iaZ-bWsVIQk2y5kTU", send);
if (StringUtils.isNotBlank(configId)) {
logger.info("staff:{}", configId, JSONObject.toJSONString(staffDTO));
com.gic.haoban.manage.service.entity.Test test = new com.gic.haoban.manage.service.entity.Test();
test.setId(configId);
test.setName(staffDTO.getWxUserId());
testService.save(test);
}
}
});
}
}
......@@ -224,6 +224,16 @@
<artifactId>gic-quartz-api</artifactId>
<version>${gic-quartz-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-cloud-data-api</artifactId>
<version>${gic-cloud-data-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-cloud-web-service-api</artifactId>
<version>${gic-cloud-web-service-api}</version>
</dependency>
</dependencies>
<build>
......
......@@ -19,6 +19,7 @@ import com.gic.haoban.manage.web.anno.HttpLimit;
import com.gic.haoban.manage.web.auth.AuthRequestUtil;
import com.gic.haoban.manage.web.vo.BatchApproveVO;
import com.gic.haoban.manage.web.vo.LoginVO;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -28,6 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.redis.data.util.RedisUtil;
@RestController
@RequestMapping("/audit")
......@@ -205,9 +207,16 @@ public class AuditController extends WebBaseController{
public HaobanResponse audit(String auditId,String auditName ) {
LoginVO login = (LoginVO) AuthRequestUtil.getLoginUser();
StaffDTO loginStaffDTO = login.getStaffDTO();
if (null == login) {
if (null == loginStaffDTO) {
return resultResponse(HaoBanErrCode.ERR_4);
}
Object o = RedisUtil.getCache("audit-"+auditId);
if(o != null){
log.info("请不要过于频繁点击");
return resultResponse(HaoBanErrCode.ERR_10008);
}
//设置缓存10秒
RedisUtil.setCache("audit-"+auditId, "1",10L);
String staffId = login.getStaffDTO().getStaffId();
String staffName = login.getStaffDTO().getStaffName();
if(StringUtils.isAnyBlank(auditId)){
......
......@@ -38,13 +38,14 @@ public class StoreController extends WebBaseController{
private StoreService storeService;
//门店列表
@RequestMapping("/find-simple-page")
public HaobanResponse storeList(String enterpriseId,BasePageInfo basePageInfo) {
public HaobanResponse storeList(Integer storeType,String enterpriseId,BasePageInfo basePageInfo) {
Page page = new Page<>();
page.setCurrentPage(basePageInfo.getPageNum());
page.setPageSize(basePageInfo.getPageSize());
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setEnterpriseId(enterpriseId);
storeSearchDTO.setStatus("2");
storeSearchDTO.setStoreType(storeType);
Page<StoreDTO> resultPage = storeService.storeListPage(page, storeSearchDTO);
List<StoreDTO> resultList = resultPage.getResult();
PageResult<StoreDTO> pageVo = new PageResult<>();
......
......@@ -114,4 +114,16 @@ public class TestController extends WebBaseController {
RedisUtil.delCache(key);
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("/lock")
public HaobanResponse lock(String name,Long time,int ty) {
RedisUtil.lock(name, time, TimeUnit.SECONDS, 0L);
if (ty==0) {
if(RedisUtil.isLocked(name)){
RedisUtil.unlock(name);
}
}
return resultResponse(HaoBanErrCode.ERR_1);
}
}
......@@ -68,4 +68,7 @@
<dubbo:reference id="applicationTemplateApiService" interface="com.gic.haoban.manage.api.service.ApplicationTemplateApiService" timeout="10000"/>
<dubbo:reference interface="com.gic.cloud.web.service.api.service.CloudStoreGroupService" id="cloudStoreGroupService" timeout="10000" retries="0" />
<dubbo:reference id="maidianDataService" interface="com.gic.cloud.data.api.service.MaidianDataService" timeout="10000" retries="0" check="false"/>
</beans>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment