Commit 5f5189a7 by XiaHou

增加万科 从微V导入 功能

parent 698273f2
......@@ -9,8 +9,10 @@ import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.UmsAdminDto;
import com.macro.mall.model.dto.quanxing.UmsMemberDto;
import com.macro.mall.model.dto.vanke.VankeImportMemberDto;
import com.macro.mall.model.dto.vanke.VankeVvUserImportVo;
import com.macro.mall.service.member.UmsMemberService;
import com.macro.mall.service.system.UmsAdminService;
import com.macro.mall.service.vanke.IVankeMemberLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -18,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Controller
@Api(tags = "万科后台_用户列表管理员相关接口", description = "用户列表控制器")
@RequestMapping("/umsMember")
......@@ -27,6 +31,8 @@ public class UmsMemberController {
private UmsMemberService umsMemberService;
@Autowired
private UmsAdminService umsAdminService;
@Autowired
private IVankeMemberLoginService vankeMemberLoginService;
@ApiOperation("万科后台_用户分页操作")
@RequestMapping(value = "/list", method = RequestMethod.GET)
......@@ -82,6 +88,14 @@ public class UmsMemberController {
}
@ApiOperation("分页获取万科企业所有组织人员")
@RequestMapping(value = "/getAllPersons", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<VankeVvUserImportVo>> getAllPersons(@ApiParam(value="起始数据下表") @RequestParam(value = "pageSize", required = true) Integer pageSize,
@ApiParam(value="结束数据下表") @RequestParam(value = "pageNum", required = true) Integer pageNum) {
return CommonResult.success(this.vankeMemberLoginService.getAllPersons(pageNum,pageSize));
}
@ApiOperation("根据会员id查询一条数据")
@RequestMapping(value = "/selectOneByMemberId", method = RequestMethod.GET)
@ResponseBody
......
......@@ -19,6 +19,12 @@
<dependencies>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
</dependency>
......
package com.macro.mall.common.utils;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
......@@ -168,4 +169,35 @@ public class HttpClientUtil {
return resultString;
}
/**
* 通过Post请求 x-www-form-urlencoded 此方式请求Url
* @param actionUrl
* @param data
* @return
* @throws IOException
* auth xh
*/
public static String formUrlencodedPost(String actionUrl, org.apache.commons.httpclient.NameValuePair[] data) throws IOException {
String result = "";
try {
String postURL = actionUrl;
PostMethod postMethod = null;
postMethod = new PostMethod(postURL);
postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
//参数设置,需要注意的就是里边不能传NULL,要传空字符串
postMethod.setRequestBody(data);
org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
int response = httpClient.executeMethod(postMethod); // 执行POST方法
result = postMethod.getResponseBodyAsString();
System.out.println(response);
System.out.println(result);
} catch (Exception e) {
// logger.info("请求异常"+e.getMessage(),e);
throw new RuntimeException(e.getMessage());
}
return result;
}
}
......@@ -20,6 +20,21 @@ public class VankeConfig implements Serializable {
@ApiModelProperty(value = "领取时间间隔")
private BigDecimal receiveInterval;
@ApiModelProperty(value = "轻应用id")
private String appid;
@ApiModelProperty(value = "轻应用secret,即appsecret")
private String secret;
@ApiModelProperty(value = "授权级别:例如app")
private String scope;
@ApiModelProperty(value = "企业id 例如:测试环境:eid:16216997 生产环境:eid:101")
private String eid;
@ApiModelProperty(value = "访问接口地址 测试环境:https://vvtest.vanke.com 生产环境:https://vv9.vanke.com")
private String host;
@ApiModelProperty(value = "创建人")
private Long createBy;
......@@ -60,6 +75,46 @@ public class VankeConfig implements Serializable {
this.receiveInterval = receiveInterval;
}
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getEid() {
return eid;
}
public void setEid(String eid) {
this.eid = eid;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public Long getCreateBy() {
return createBy;
}
......@@ -101,6 +156,11 @@ public class VankeConfig implements Serializable {
sb.append(", id=").append(id);
sb.append(", stockWarning=").append(stockWarning);
sb.append(", receiveInterval=").append(receiveInterval);
sb.append(", appid=").append(appid);
sb.append(", secret=").append(secret);
sb.append(", scope=").append(scope);
sb.append(", eid=").append(eid);
sb.append(", host=").append(host);
sb.append(", createBy=").append(createBy);
sb.append(", updateBy=").append(updateBy);
sb.append(", createtime=").append(createtime);
......
......@@ -19,6 +19,8 @@ public class VankeImportMemberDto {
private String username;
@ApiModelProperty("账号")
private String account;
@ApiModelProperty(value = "头像")
private String photourl;
@ApiModelProperty("数据传输 只供导入会员对象集合时候使用")
private List<VankeImportMemberDto> vimdList;
}
package com.macro.mall.model.dto.vanke;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class VankeVvUserImportVo implements Serializable {
@ApiModelProperty(value = "头像")
private String photoUrl;
@ApiModelProperty(value = "团队用户id")
private String openid;
@ApiModelProperty(value = "性别: 0未知 1女 2男")
private Integer gender;
@ApiModelProperty(value = "openId")
private String openId;
@ApiModelProperty(value = "员工编号")
private String jobNo;
@ApiModelProperty(value = "用户姓名")
private String name;
@ApiModelProperty(value = "部门名称")
private String department;
}
......@@ -5,6 +5,11 @@
<id column="id" jdbcType="BIGINT" property="id" />
<result column="stock_warning" jdbcType="INTEGER" property="stockWarning" />
<result column="receive_interval" jdbcType="DECIMAL" property="receiveInterval" />
<result column="appid" jdbcType="VARCHAR" property="appid" />
<result column="secret" jdbcType="VARCHAR" property="secret" />
<result column="scope" jdbcType="VARCHAR" property="scope" />
<result column="eid" jdbcType="VARCHAR" property="eid" />
<result column="host" jdbcType="VARCHAR" property="host" />
<result column="create_by" jdbcType="BIGINT" property="createBy" />
<result column="update_by" jdbcType="BIGINT" property="updateBy" />
<result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
......@@ -69,7 +74,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, stock_warning, receive_interval, create_by, update_by, createtime, updatetime
id, stock_warning, receive_interval, appid, secret, scope, eid, host, create_by,
update_by, createtime, updatetime
</sql>
<select id="selectByExample" parameterType="com.macro.mall.model.VankeConfigExample" resultMap="BaseResultMap">
select
......@@ -105,12 +111,14 @@
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into vanke_config (stock_warning, receive_interval, create_by,
update_by, createtime, updatetime
)
values (#{stockWarning,jdbcType=INTEGER}, #{receiveInterval,jdbcType=DECIMAL}, #{createBy,jdbcType=BIGINT},
#{updateBy,jdbcType=BIGINT}, #{createtime,jdbcType=TIMESTAMP}, #{updatetime,jdbcType=TIMESTAMP}
)
insert into vanke_config (stock_warning, receive_interval, appid,
secret, scope, eid,
host, create_by, update_by,
createtime, updatetime)
values (#{stockWarning,jdbcType=INTEGER}, #{receiveInterval,jdbcType=DECIMAL}, #{appid,jdbcType=VARCHAR},
#{secret,jdbcType=VARCHAR}, #{scope,jdbcType=VARCHAR}, #{eid,jdbcType=VARCHAR},
#{host,jdbcType=VARCHAR}, #{createBy,jdbcType=BIGINT}, #{updateBy,jdbcType=BIGINT},
#{createtime,jdbcType=TIMESTAMP}, #{updatetime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.macro.mall.model.VankeConfig">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
......@@ -124,6 +132,21 @@
<if test="receiveInterval != null">
receive_interval,
</if>
<if test="appid != null">
appid,
</if>
<if test="secret != null">
secret,
</if>
<if test="scope != null">
scope,
</if>
<if test="eid != null">
eid,
</if>
<if test="host != null">
host,
</if>
<if test="createBy != null">
create_by,
</if>
......@@ -144,6 +167,21 @@
<if test="receiveInterval != null">
#{receiveInterval,jdbcType=DECIMAL},
</if>
<if test="appid != null">
#{appid,jdbcType=VARCHAR},
</if>
<if test="secret != null">
#{secret,jdbcType=VARCHAR},
</if>
<if test="scope != null">
#{scope,jdbcType=VARCHAR},
</if>
<if test="eid != null">
#{eid,jdbcType=VARCHAR},
</if>
<if test="host != null">
#{host,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=BIGINT},
</if>
......@@ -176,6 +214,21 @@
<if test="record.receiveInterval != null">
receive_interval = #{record.receiveInterval,jdbcType=DECIMAL},
</if>
<if test="record.appid != null">
appid = #{record.appid,jdbcType=VARCHAR},
</if>
<if test="record.secret != null">
secret = #{record.secret,jdbcType=VARCHAR},
</if>
<if test="record.scope != null">
scope = #{record.scope,jdbcType=VARCHAR},
</if>
<if test="record.eid != null">
eid = #{record.eid,jdbcType=VARCHAR},
</if>
<if test="record.host != null">
host = #{record.host,jdbcType=VARCHAR},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=BIGINT},
</if>
......@@ -198,6 +251,11 @@
set id = #{record.id,jdbcType=BIGINT},
stock_warning = #{record.stockWarning,jdbcType=INTEGER},
receive_interval = #{record.receiveInterval,jdbcType=DECIMAL},
appid = #{record.appid,jdbcType=VARCHAR},
secret = #{record.secret,jdbcType=VARCHAR},
scope = #{record.scope,jdbcType=VARCHAR},
eid = #{record.eid,jdbcType=VARCHAR},
host = #{record.host,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=BIGINT},
update_by = #{record.updateBy,jdbcType=BIGINT},
createtime = #{record.createtime,jdbcType=TIMESTAMP},
......@@ -215,6 +273,21 @@
<if test="receiveInterval != null">
receive_interval = #{receiveInterval,jdbcType=DECIMAL},
</if>
<if test="appid != null">
appid = #{appid,jdbcType=VARCHAR},
</if>
<if test="secret != null">
secret = #{secret,jdbcType=VARCHAR},
</if>
<if test="scope != null">
scope = #{scope,jdbcType=VARCHAR},
</if>
<if test="eid != null">
eid = #{eid,jdbcType=VARCHAR},
</if>
<if test="host != null">
host = #{host,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=BIGINT},
</if>
......@@ -234,6 +307,11 @@
update vanke_config
set stock_warning = #{stockWarning,jdbcType=INTEGER},
receive_interval = #{receiveInterval,jdbcType=DECIMAL},
appid = #{appid,jdbcType=VARCHAR},
secret = #{secret,jdbcType=VARCHAR},
scope = #{scope,jdbcType=VARCHAR},
eid = #{eid,jdbcType=VARCHAR},
host = #{host,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=BIGINT},
update_by = #{updateBy,jdbcType=BIGINT},
createtime = #{createtime,jdbcType=TIMESTAMP},
......
package com.macro.mall.portal;
import com.macro.mall.common.baiduyun.HttpUtil;
import com.macro.mall.common.utils.MyJsonUtil;
import com.macro.mall.dao.order.PortalProductDao;
import com.macro.mall.domain.vo.order.PromotionProduct;
import com.macro.mall.service.vanke.IVankeMemberLoginService;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -10,7 +13,9 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by macro on 2018/8/27.
......@@ -19,16 +24,28 @@ import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
public class PortalProductDaoTests {
@Autowired
private PortalProductDao portalProductDao;
@Autowired
private IVankeMemberLoginService vankeMemberLoginService;
@Test
public void testGetPromotionProductList(){
List<Long> ids = new ArrayList<>();
ids.add(26L);
ids.add(27L);
ids.add(28L);
ids.add(29L);
List<PromotionProduct> promotionProductList = portalProductDao.getPromotionProductList(ids);
Assert.assertEquals(4,promotionProductList.size());
public void testGetVankeUserInfo(){//DX5KljWcPLnMkryBZtH2ct0OxcqXxzsE
String accessToken = this.vankeMemberLoginService.getVankeAccessToken();
//通过appId 和 ticket 以及 token发起获取用户身份信息请求
String params ="{\n" +
" \"begin\":0, \n" +
" \"count\":100 \n" +
"}}";
String res = null;
Map<String,Object> map = new HashMap<>();
try {
res = HttpUtil.postGeneralUrl("https://vvtest.vanke.com/gateway/openimport/open/person/getall?accessToken="+accessToken,"application/json",params,"UTF-8");
map = MyJsonUtil.getMapChangeJson(res);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(res);
}
}
......@@ -814,8 +814,12 @@ public class UmsMemberServiceImpl implements UmsMemberService {
return new ResultMsg(false,"传入会员集合为空 !");
}
for(VankeImportMemberDto vimd : vimdList){//遍历导入会员 插入万科会员表数据中
UmsMember umsMember = this.memberDao.selectUmsMemberByJobNo(vimd.getJobNo());
if(umsMember != null){ //如果存在 则跳出此次循环
continue;
}
//判断是否已存在 此手机号
UmsMember umsMember = this.memberDao.selectOntByPhone(vimd.getMobile());
umsMember = this.memberDao.selectOntByPhone(vimd.getMobile());
if(umsMember != null){
return new ResultMsg(false,"手机号:"+vimd.getMobile()+"已存在!!");
}
......@@ -877,4 +881,14 @@ public class UmsMemberServiceImpl implements UmsMemberService {
this.umsMemberMapper.updateByPrimaryKeySelective(umsMember);
return new ResultMsg(true,"操作成功");
}
@Test
public void test(){
VankeImportMemberDto vimd = new VankeImportMemberDto();
//将对象复制到vankevvuser里去 插入到表中
VankeVvUser vvu = new VankeVvUser();
//将属性赋值到另一个对象中去
BeanUtils.copyProperties(vimd,vvu);
}
}
......@@ -172,16 +172,16 @@ public class UmsAdminServiceImpl implements UmsAdminService {
return CommonResult.failed("输入验证码错误");
}
//如果是admin 登录 则默认为超管登录 判断账号密码即可 其他账号登录均为域登录
//if("admin".equals(username)){
if("admin".equals(username)){
if (!passwordEncoder.matches(password, userDetails.getPassword())) {
return CommonResult.failed("密码不正确");
}
/*}else{ //否则通过域登录判断
}else{ //否则通过域登录判断
ResultMsg res = this.aDService.loginAd(username,password);
if(!res.isFlag()){
return CommonResult.failed(res.getMsg());
}
}*/
}
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);
token = jwtTokenUtil.generateToken(userDetails);
......
......@@ -2,7 +2,9 @@ package com.macro.mall.service.vanke;
import com.macro.mall.model.UmsMember;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeVvUserImportVo;
import java.util.List;
import java.util.Map;
public interface IVankeMemberLoginService {
......@@ -33,4 +35,12 @@ public interface IVankeMemberLoginService {
* @return
*/
ResultMsg updateVankeVvUser(String ticket);
/**
* 通过 起始页 和 每页显示数量获取企业所有组织人员
* @param pageNum
* @param pageSize
* @return
*/
List<VankeVvUserImportVo> getAllPersons(Integer pageNum, Integer pageSize);
}
......@@ -4,7 +4,9 @@ import com.macro.mall.mapper.VankeConfigMapper;
import com.macro.mall.model.VankeConfig;
import com.macro.mall.model.VankeConfigExample;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.service.system.RedisService;
import com.macro.mall.service.vanke.IVankeConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -14,19 +16,22 @@ import java.util.List;
@Service
public class VankeConfigServiceImpl implements IVankeConfigService {
@Autowired
private RedisService redisService;
@Resource
private VankeConfigMapper vankeConfigMapper;
/**
* 得到config配置
*
* @return
*/
@Override
public VankeConfig getConfig(){
public VankeConfig getConfig() {
VankeConfigExample example = new VankeConfigExample();
VankeConfigExample.Criteria criteria = example.createCriteria();
List<VankeConfig> vcList = this.vankeConfigMapper.selectByExample(example);
if(vcList != null && vcList.size()>0 ){
if (vcList != null && vcList.size() > 0) {
return vcList.get(0);
}
return null;
......@@ -34,24 +39,40 @@ public class VankeConfigServiceImpl implements IVankeConfigService {
/**
* 根据id判断是修改还是新增
*
* @param vankeConfig
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ResultMsg insertAndUpdateConfig(VankeConfig vankeConfig){
if(vankeConfig.getStockWarning() == null){
return new ResultMsg(false,"库存预警传入为空");
public ResultMsg insertAndUpdateConfig(VankeConfig vankeConfig) {
if (vankeConfig.getStockWarning() == null) {
return new ResultMsg(false, "库存预警传入为空");
}
if(vankeConfig.getReceiveInterval() == null){
return new ResultMsg(false,"领取时间间隔为空");
if (vankeConfig.getReceiveInterval() == null) {
return new ResultMsg(false, "领取时间间隔为空");
}
if (vankeConfig.getId() != null) { //如果id不为空 说明是修改
if (!vankeConfig.getAppid().isEmpty()) { //如果参数不为空 则需要更新redis
redisService.set("vanke_appid", vankeConfig.getAppid());
}
if (!vankeConfig.getSecret().isEmpty()) { //如果参数不为空 则需要更新redis
redisService.set("vanke_secret", vankeConfig.getSecret());
}
if (!vankeConfig.getScope().isEmpty()) { //如果参数不为空 则需要更新redis
redisService.set("vanke_scope", vankeConfig.getScope());
}
if (!vankeConfig.getEid().isEmpty()) { //如果参数不为空 则需要更新redis
redisService.set("vanke_eid", vankeConfig.getEid());
}
if (!vankeConfig.getHost().isEmpty()) { //如果参数不为空 则需要更新redis
redisService.set("vanke_host", vankeConfig.getHost());
}
if(vankeConfig.getId() != null){ //如果id不为空 说明是修改
this.vankeConfigMapper.updateByPrimaryKeySelective(vankeConfig);
}else{ //否则新增操作
} else { //否则新增操作
this.vankeConfigMapper.insertSelective(vankeConfig);
}
return new ResultMsg(true,"操作成功");
return new ResultMsg(true, "操作成功");
}
}
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