Authored by unknown

批量查询/导出手机号对应的用户

package com.yoho.unions.bo;
/**
* Created by jianhui.wang on 2017/7/25.
*/
public class UserRegisterBuyBO {
//是否注册
private Boolean register;
//注册时间
private Integer registerTime;
private Integer uid;
//是否购买
private Boolean Buy;
public Boolean getRegister() {
return register;
}
public void setRegister(Boolean register) {
this.register = register;
}
public Integer getRegisterTime() {
return registerTime;
}
public void setRegisterTime(Integer registerTime) {
this.registerTime = registerTime;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public Boolean getBuy() {
return Buy;
}
public void setBuy(Boolean buy) {
Buy = buy;
}
}
... ...
package com.yoho.unions.vo;
import lombok.Data;
/**
* Created by jianhui.wang on 2017/7/25.
*/
@Data
public class UserPhoneNumberVO {
private String mobile;
private String area;
}
... ...
package com.yoho.unions.dal;
import com.yoho.unions.dal.model.UserProfile;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface IUserProfileDAO {
int deleteByPrimaryKey(Integer uid);
int insert(UserProfile record);
int insertSelective(UserProfile record);
UserProfile selectByPrimaryKey(Integer uid);
UserProfile selectProfileByEmail(String email);
UserProfile selectProfileByMobile(String mobile);
UserProfile selectProfileByMobileForForeign(@Param("mobile1") String mobile1, @Param("mobile2") String mobile2);
int updateByPrimaryKeySelective(UserProfile record);
int updateByPrimaryKey(UserProfile record);
List<UserProfile> selectProfileByUIds(List<Integer> uids);
int selectCountByUidOrMobileOrEmail(@Param("list") List<Integer> uidsList, @Param("mobile") String mobile,
@Param("email") String email, @Param("startTime") Integer startTime,
@Param("endTime") Integer endTime);
}
\ No newline at end of file
... ...
package com.yoho.unions.dal.model;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import java.io.Serializable;
public class BaseModel implements Serializable {
/**
*
*/
private static final long serialVersionUID = 3879004768382010547L;
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this);
}
}
... ...
package com.yoho.unions.dal.model;
public class UserProfile extends BaseModel {
/**
*
*/
private static final long serialVersionUID = -772087989417656344L;
private Integer uid;
private String email;
private String mobile;
private String password;
private Byte userSource;
private Integer createTime;
private Short userChannel;
private Byte status;
private String ssoPassword;
public UserProfile() {
}
public UserProfile(String email, String mobile, String password,
Byte userSource, Integer createTime, Short userChannel, Byte status) {
super();
this.email = email;
this.mobile = mobile;
this.password = password;
this.userSource = userSource;
this.createTime = createTime;
this.userChannel = userChannel;
this.status = status;
}
public UserProfile(Integer uid, String email, String mobile,
String password, Byte userSource, Integer createTime,
Short userChannel, Byte status) {
this.uid = uid;
this.email = email;
this.mobile = mobile;
this.password = password;
this.userSource = userSource;
this.createTime = createTime;
this.userChannel = userChannel;
this.status = status;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email == null ? null : email.trim();
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile == null ? null : mobile.trim();
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password == null ? null : password.trim();
}
public Byte getUserSource() {
return userSource;
}
public void setUserSource(Byte userSource) {
this.userSource = userSource;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
public Short getUserChannel() {
return userChannel;
}
public void setUserChannel(Short userChannel) {
this.userChannel = userChannel;
}
public Byte getStatus() {
return status;
}
public void setStatus(Byte status) {
this.status = status;
}
public String getSsoPassword() {
return ssoPassword;
}
public void setSsoPassword(String ssoPassword) {
this.ssoPassword = ssoPassword;
}
}
\ No newline at end of file
... ...
... ... @@ -19,6 +19,8 @@
<result column="remark" property="remark" jdbcType="VARCHAR" />
<result column="order_status" property="orderStatus" jdbcType="INTEGER" />
<result column="new_user_orders" property="newUserOrders" jdbcType="CHAR" />
<result column="create_time" property="createTime" jdbcType="CHAR" />
</resultMap>
<sql id="Base_Column_List">
... ... @@ -26,29 +28,14 @@
last_order_amount, express_number,order_type,
yoho_coin_num, payment_status, payment_type,
payment, shipping_cost, remark,
order_status,new_user_orders
order_status,new_user_orders,create_time
</sql>
<select id="selectByUidAndOrderCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from orders
where order_code = #{orderCode,jdbcType=BIGINT} and uid = #{uid,jdbcType=INTEGER}
</select>
<select id="selectByOrderCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from orders
where order_code = #{orderCode,jdbcType=BIGINT}
</select>
<select id="selectCountShipStatusOrderSince" resultType="java.lang.Integer">
select count(1)
from orders
where uid = #{uid,jdbcType=INTEGER}
and status >= 4
and order_status >= 4
and create_time > #{createTime,jdbcType=INTEGER}
</select>
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.unions.dal.IUserProfileDAO">
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UserProfile">
<id column="uid" property="uid" jdbcType="INTEGER" />
<result column="email" property="email" jdbcType="VARCHAR" />
<result column="mobile" property="mobile" jdbcType="VARCHAR" />
<result column="password" property="password" jdbcType="VARCHAR" />
<result column="user_source" property="userSource" jdbcType="TINYINT" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="user_channel" property="userChannel" jdbcType="SMALLINT" />
<result column="status" property="status" jdbcType="TINYINT" />
<result column="sso_password" property="ssoPassword" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
uid, email, mobile, password, user_source, create_time, user_channel,
status, sso_password
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from user_profile
where uid = #{uid,jdbcType=INTEGER}
</select>
<select id="selectProfileByEmail" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List" />
from user_profile
where email=#{email} and status=1 limit 1
</select>
<select id="selectProfileByMobile" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List" />
from user_profile
where mobile=#{mobile} and status=1 limit 1
</select>
<select id="selectProfileByMobileForForeign" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from user_profile
where mobile=#{mobile1} or mobile=#{mobile2} and status=1 limit 1
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="uid" parameterType="com.yoho.unions.dal.model.UserProfile">
insert into user_profile (email, mobile,
password, user_source, create_time,
user_channel, status)
values
(#{email,jdbcType=VARCHAR},
#{mobile,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR}, #{userSource,jdbcType=TINYINT}, #{createTime,jdbcType=INTEGER},
#{userChannel,jdbcType=SMALLINT},
#{status,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" useGeneratedKeys="true" keyProperty="uid" parameterType="com.yoho.unions.dal.model.UserProfile">
insert into user_profile
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="uid != null">
uid,
</if>
<if test="email != null">
email,
</if>
<if test="mobile != null">
mobile,
</if>
<if test="password != null">
password,
</if>
<if test="userSource != null">
user_source,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="userChannel != null">
user_channel,
</if>
<if test="status != null">
status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="uid != null">
#{uid,jdbcType=INTEGER},
</if>
<if test="email != null">
#{email,jdbcType=VARCHAR},
</if>
<if test="mobile != null">
#{mobile,jdbcType=VARCHAR},
</if>
<if test="password != null">
#{password,jdbcType=VARCHAR},
</if>
<if test="userSource != null">
#{userSource,jdbcType=TINYINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=INTEGER},
</if>
<if test="userChannel != null">
#{userChannel,jdbcType=SMALLINT},
</if>
<if test="status != null">
#{status,jdbcType=TINYINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UserProfile">
update user_profile
<set>
<if test="email != null">
email = #{email,jdbcType=VARCHAR},
</if>
<if test="mobile != null">
mobile = #{mobile,jdbcType=VARCHAR},
</if>
<if test="password != null">
password = #{password,jdbcType=VARCHAR},
</if>
<if test="userSource != null">
user_source = #{userSource,jdbcType=TINYINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="userChannel != null">
user_channel = #{userChannel,jdbcType=SMALLINT},
</if>
<if test="status != null">
status = #{status,jdbcType=TINYINT},
</if>
<if test="ssoPassword != null">
sso_password = #{ssoPassword,jdbcType=VARCHAR},
</if>
</set>
where uid = #{uid,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UserProfile">
update user_profile
set email = #{email,jdbcType=VARCHAR},
mobile = #{mobile,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
user_source =
#{userSource,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=INTEGER},
user_channel = #{userChannel,jdbcType=SMALLINT},
status = #{status,jdbcType=TINYINT}
where uid = #{uid,jdbcType=INTEGER}
</update>
<select id="selectProfileByUIds" resultMap="BaseResultMap" parameterType="java.util.List">
select
<include refid="Base_Column_List" />
from user_profile where uid in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<select id="selectCountByUidOrMobileOrEmail" resultType="java.lang.Integer">
SELECT COUNT(1) from
user_profile
where 1=1
<if test="list!=null and list.size !=0">
AND uid in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="mobile !=null">
and mobile = #{mobile}
</if>
<if test="email !=null">
and email = #{email}
</if>
<if test = "startTime !=null and startTime != 0">
and create_time &lt;#{startTime}
</if>
<if test="endTime !=null and endTime !=0">
and create_time &gt;#{endTime}
</if>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -5,7 +5,7 @@
<parent>
<groupId>com.yoho</groupId>
<artifactId>parent</artifactId>
<version>1.2.5-SNAPSHOT</version>
<version>1.2.6-SNAPSHOT</version>
</parent>
<groupId>com.yoho.dsf</groupId>
<artifactId>yoho-unions</artifactId>
... ...
... ... @@ -61,6 +61,11 @@
<groupId>com.yoho.service.model</groupId>
<artifactId>union-service-model</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.service.model</groupId>
<artifactId>union-service-model</artifactId>
<version>1.2.6-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
... ...
package com.yoho.unions.server.restapi;
import com.yoho.tools.common.beans.ApiResponse;
import com.yoho.unions.bo.UserRegisterBuyBO;
import com.yoho.unions.server.service.IUserRegisterBuyInfoService;
import com.yoho.unions.vo.UserPhoneNumberVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* Created by jianhui.wang on 2017/7/25.
* 批量查询/导出手机号对应的用户情况
* 功能:是否注册,uid(如果注册提供uid),是否购买,注册时间。
*/
@Controller
@RequestMapping("/UserRegisterBuy")
public class UserRegisterBuyInfoRest {
@Resource
IUserRegisterBuyInfoService userRegisterBuyInfoService;
@RequestMapping("/InfoBatchQuery")
public ApiResponse<?> activeUnion(HttpServletRequest request,UserPhoneNumberVO userPhoneNumberVO) {
List<UserRegisterBuyBO> UserRegisterBuyList = userRegisterBuyInfoService.UserRegisterBuyInfo(userPhoneNumberVO);
return new ApiResponse<>();
}
}
... ...
package com.yoho.unions.server.service;
import com.yoho.unions.bo.UserRegisterBuyBO;
import com.yoho.unions.vo.UserPhoneNumberVO;
import java.util.List;
/**
* Created by jianhui.wang on 2017/7/25.
*/
public interface IUserRegisterBuyInfoService {
public List<UserRegisterBuyBO> UserRegisterBuyInfo(UserPhoneNumberVO userPhoneNumberVO);
}
... ...
package com.yoho.unions.server.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.unions.bo.UserRegisterBuyBO;
import com.yoho.unions.common.utils.PhoneUtil;
import com.yoho.unions.dal.IOrdersMapper;
import com.yoho.unions.dal.IUserProfileDAO;
import com.yoho.unions.dal.model.UserProfile;
import com.yoho.unions.server.service.IUserRegisterBuyInfoService;
import com.yoho.unions.vo.UserPhoneNumberVO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* Created by jianhui.wang on 2017/7/25.
*/
@Service
public class UserRegisterBuyInfoserviceImpl implements IUserRegisterBuyInfoService {
static Logger logger = LoggerFactory.getLogger("UserRegisterBuyInfoserviceImpl");
@Autowired
IUserProfileDAO userProfileDAO;
@Autowired
IOrdersMapper ordersMapper;
@Override
public List<UserRegisterBuyBO> UserRegisterBuyInfo(UserPhoneNumberVO userPhoneNumberVO) {
logger.info("enter UserRegisterBuyInfo with mobile={}", userPhoneNumberVO.getMobile());
if (userPhoneNumberVO == null || StringUtils.isEmpty(userPhoneNumberVO.getMobile())) {
logger.warn("UserRegisterBuyInfo: request param is null");
throw new ServiceException(ServiceError.REQUEST_PARAM_INVALID);
}
boolean isMobile = PhoneUtil.areaMobileVerify(userPhoneNumberVO.getArea(), userPhoneNumberVO.getMobile());
if (!isMobile) {
// 402, '手机号码格式错误'
logger.warn("checkBindParam error because MOBILE_IS_ERROR mobile={}", userPhoneNumberVO.getMobile());
throw new ServiceException(ServiceError.MOBILE_IS_ERROR);
}
UserProfile userProfile = userProfileDAO.selectProfileByMobile(userPhoneNumberVO.getMobile());
if (userProfile == null) {
logger.warn("UserRegisterBuyInfo:uid is {},mobile is {},userSource is {}", userProfile.getUid(), userProfile.getMobile(), userProfile.getUserSource());
throw new ServiceException(ServiceError.USER_NOT_EXIST);
}
UserRegisterBuyBO userRegisterBuyBO = new UserRegisterBuyBO();
userRegisterBuyBO.setRegister(true);
userRegisterBuyBO.setUid(userProfile.getUid());
userRegisterBuyBO.setRegisterTime(userProfile.getCreateTime());
int flag = ordersMapper.selectCountShipStatusOrderSince(userProfile.getUid(), userProfile.getCreateTime());
if (flag > 0) {
userRegisterBuyBO.setBuy(true);
}
List<UserRegisterBuyBO> UserRegisterBuyList = new ArrayList<>();
UserRegisterBuyList.add(userRegisterBuyBO);
return UserRegisterBuyList;
}
}
... ...
No preview for this file type
<!DOCTYPE html>
<table style="width: 100%;padding: 30px 30px 0px 30px">
<tbody>
<tr>
<td style="font-size: large">上传EXCEL:</td>
<td>
<div id="batchImportDiv"></div>
</td>
</tr>
<tr>
<td style="font-size: large">批量导入:</td>
<td style="font-size: large">
1、上传文件必须是<span style="color: red">.xlsx</span>文件<br>
2、Excel表头为:<span style="color: greenyellow">手机号、uid</span><br>
3、第一行为表头内容,第二行开始为正式内容<br>
4、每个文件控制在***行以内<br>
5、<a id="importA" style="margin-left: 30px" href="">下载样例.xlsx</a><br>
</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
$(function () {
$("#importA").attr("href", contextPath + "/common/userinfo.xlsx");
$("#batchImportDiv").fileUpload({
text: "请选择文件", //按钮文字
uploadInputName: "file", //上传文件的控件名称
url: contextPath + "/batch/import", //提交到后端的url
queryParams: {
type: "productBuyLimitImport", //spring-web-context.xml 文件配置实现类 <entry key="productBuyLimitImport" value-ref="productBuyLimitServiceImpl"/>
args: "import"
}, //提交到后端额外参数
showFileName: false, //上传成功后,是否显示文件名
onLoadSuccess: function (fileName, data) {
$("#productBuyLimitListTable").myDatagrid("reload");
$("#batchProgramDialogDiv").dialog("close");
$.messager.show({
title: "提示",
msg: data.data,
height: 250
});
}
});
});
</script>
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/union/js/include.js"></script>
<script src="/union/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div id="search" region="north" style="height: 170px;" class="xsdvideogl">
<script>
document.write(addHead('运营管理', '用户信息列表'));
</script>
<div style="margin-left: 30px;margin-top: 20px;">
<a id="batchProgram" class="easyui-linkbutton btn-primary" style="margin-left: 30px"></a>
<a id="exportButton" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">批量导出</a>
</div>
</div>
<div region="center" id="productBuyLimitListDiv">
<table id="productBuyLimitListTable" style="widght: 600px;"></table>
</div>
<script type="text/javascript">
$(function () {
$("#batchProgram").linkbutton({
text: "批量导入",
iconCls: "icon-add",
onClick: function () {
batchProgramDialog();
}
});
$("#productBuyLimitListTable").myDatagrid({
fit: true,
fitColumns: true,
nowrap: false,
url: contextPath + "/operations/buylimit/getList",
method: 'POST',
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "手机号",
field: "productSkn",
width: 65,
align: "center"
}, {
title: "uid",
field: "level0Limit",
width: 65,
align: "center"
}, {
title: "是否注册",
field: "level1Limit",
width: 30,
align: "center"
}, {
title: "注册时间",
field: "level2Limit",
width: 80,
align: "center"
}, {
title: "是否购买",
field: "level2Limit",
width: 30,
align: "center"
}]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "productSkn",
singleSelect: true,
checkOnSelect: false,
onLoadSuccess: function () {
}
});
});
function batchProgramDialog() {
var div = $("<div id='batchProgramDialogDiv'>").appendTo($(document.body));
$(div).myDialog({
width: "80px",
height: "60%",
title: "批量功能",
href: contextPath + "/html/getUserInfo/userinfoBatch.html",
modal: true,
collapsible: true,
cache: false
});
$("#exportButton").linkbutton({
onClick : function() {
if (checkedItems.length == 0) {
$.messager.alert('提示','请选择要导出的数据');
return;
}
var params = {"ids": checkedItems.toString() };
window.open(contextPath + "/batch/export.do?type=userOrdersServiceImpl&queryConf=" + JSON.stringify(params));
}
});
}
</script>
</body>
</html>
\ No newline at end of file
... ...