Commit 11b8d4bd by guojuxing

添加导购同步微盟队列任务

parent 5a663ad9
......@@ -181,4 +181,8 @@ public interface ClerkApiService {
* @throws
*/
ServiceResponse updateClerkLeader(Integer clerkId);
ServiceResponse<Void> syncClerkToWeimob(Integer wmMallStoreId, List<Integer> storeIdList, Integer enterpriseId);
ServiceResponse<Void> syncClerkToWeimobTask(String param);
}
......@@ -141,6 +141,11 @@
<artifactId>gic-marketing-process-api</artifactId>
<version>${gic-marketing-process-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-weimob-api</artifactId>
<version>${gic-weimob-api}</version>
</dependency>
</dependencies>
<build>
......
......@@ -5,10 +5,12 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.CollectionUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.enterprise.constants.Constants;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.response.EnterpriseServiceResponse;
import com.gic.enterprise.service.EnterpriseApiService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.store.constant.ClerkLogReasonEnum;
import com.gic.store.constant.ImportClerkBatchResultEnum;
import com.gic.store.constant.StoreLogTypeEnum;
......@@ -21,6 +23,8 @@ import com.gic.store.entity.TabClerk;
import com.gic.store.entity.TabStoreGroup;
import com.gic.store.entity.TabStoreRegion;
import com.gic.store.service.*;
import com.gic.weimob.api.dto.WeimobGuiderSynDTO;
import com.gic.weimob.api.service.WeimobStoreSiteService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
......@@ -56,6 +60,8 @@ public class ClerkApiServiceImpl implements ClerkApiService {
private StoreRegionService storeRegionService;
@Autowired
private EnterpriseApiService enterpriseApiService;
@Autowired
private WeimobStoreSiteService weimobStoreSiteService;
@Override
public ServiceResponse saveOrUpdate(ClerkDTO clerkDTO) {
......@@ -619,6 +625,68 @@ public class ClerkApiServiceImpl implements ClerkApiService {
return EnterpriseServiceResponse.success();
}
@Override
public ServiceResponse<Void> syncClerkToWeimob(Integer wmMallStoreId, List<Integer> storeIdList, Integer enterpriseId) {
ClerkSearchDTO searchDTO = new ClerkSearchDTO();
searchDTO.setEnterpriseId(enterpriseId);
StringBuilder sb = new StringBuilder();
storeIdList.forEach(e -> sb.append(e).append(","));
searchDTO.setStoreIds(sb.toString());
ServiceResponse<Page<ClerkStoreListDTO>> pageResult = listClerk(enterpriseId, searchDTO, 0, storeIdList.size());
if (pageResult.isSuccess()) {
Page<ClerkStoreListDTO> page = pageResult.getResult();
if (page != null) {
List<ClerkStoreListDTO> list = page.getResult();
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(e -> {
List<ClerkDTO> clerkList = e.getClerkList();
if (CollectionUtils.isNotEmpty(clerkList)) {
clerkList.forEach(clerk -> {
WeimobGuiderSynDTO weimobGuiderSynDTO = new WeimobGuiderSynDTO();
weimobGuiderSynDTO.setStoreNumber(e.getStoreCode());
weimobGuiderSynDTO.setClerkId(clerk.getClerkId());
weimobGuiderSynDTO.setGuiderName(clerk.getClerkName());
weimobGuiderSynDTO.setGuiderPhone(clerk.getPhoneNumber());
weimobGuiderSynDTO.setJobNumber(clerk.getClerkCode());
weimobGuiderSynDTO.setStoreInfoId(e.getStoreInfoId());
asynClerkInfoToWeimobMQ(wmMallStoreId, enterpriseId, weimobGuiderSynDTO);
});
}
});
}
}
}
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> syncClerkToWeimobTask(String param) {
JSONObject jsonObject = JSONObject.parseObject(param);
String enterpriseId = jsonObject.getString("enterpriseId");
String wmMallStoreId = jsonObject.getString("wmMallStoreId");
String wmGuiderDTOStr = (String) jsonObject.get("wmGuiderDTO");
WeimobGuiderSynDTO wmGuiderDTO = JSONObject.parseObject(wmGuiderDTOStr, WeimobGuiderSynDTO.class);
ServiceResponse<Void> result = weimobStoreSiteService.addWeimobGuider(Integer.parseInt(wmMallStoreId),
Integer.parseInt(enterpriseId), wmGuiderDTO);
logger.info("异步导购结果:code:{}, message:{}", result.getCode(), result.getMessage());
return ServiceResponse.success();
}
private void asynClerkInfoToWeimobMQ(Integer wmMallStoreId, Integer enterpriseId, WeimobGuiderSynDTO wmGuiderDTO) {
GicMQClient client = GICMQClientUtil.getClientInstance();
Map<String, Object> params = new HashMap<>(4);
params.put("enterpriseId", enterpriseId);
params.put("wmMallStoreId", wmMallStoreId);
params.put("wmGuiderDTO", JSONObject.toJSONString(wmGuiderDTO));
logger.info("异步导购微盟放入参数:{}", JSONObject.toJSONString(params));
try {
client.sendMessage("tmpClerkToWeimob", JSONObject.toJSONString(params));
} catch (Exception e) {
logger.warn("同步导购到微盟错误:{}", e.getMessage(), e);
}
}
private static ServiceResponse<String> responseErrorElement(ImportClerkBatchResultEnum error) {
logger.warn("批处理导购错误返回结果:{}", error.toString());
return ServiceResponse.failure(error.getCode(), error.toString());
......
......@@ -63,4 +63,6 @@
<dubbo:service interface="com.gic.store.service.StoreTagTmpApiService" ref="storeTagTmpApiService" timeout="6000" />
<dubbo:service interface="com.gic.store.service.StoreOpenApiService" ref="storeOpenApiService" timeout="6000" />
<dubbo:service interface="com.gic.store.service.DictApiService" ref="dictApiService" timeout="6000" />
<dubbo:reference interface="com.gic.weimob.api.service.WeimobStoreSiteService" id="weimobStoreSiteService" timeout="6000"/>
</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