Authored by mingdan.ge

cps三期后台管理功能

package com.yoho.unions.common.enums;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import java.util.Map;
/**
* Created by mingdan.ge on 2018/6/21.
*/
public enum SocialMediaSectionEnum {
one(1,1,10000),
two(2,10001,20000),
three(3,20001,30000);
private int no;
private int start;
private int end;
SocialMediaSectionEnum(int no, int start, int end) {
this.no = no;
this.start = start;
this.end = end;
}
public static Map<Integer, String> getAllSection(String separator) {
Map<Integer, String> map = new HashMap<>();
for (SocialMediaSectionEnum e : values()) {
map.put(e.getNo(), e.getStart() + separator + e.getEnd());
}
return map;
}
public static JSONArray getAllSectionArray(String separator) {
JSONArray jsonArray = new JSONArray();
for (SocialMediaSectionEnum e : values()) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("no",e.getNo());
jsonObject.put("desc", e.getStart() + separator + e.getEnd());
jsonArray.add(jsonObject);
}
return jsonArray;
}
public static String getSectionByNo(int no,String separator) {
for (SocialMediaSectionEnum e : values()) {
if (e.getNo() == no) {
return e.getStart() + separator + e.getEnd();
}
}
return null;
}
public static SocialMediaSectionEnum getEnumByNo(int no) {
for (SocialMediaSectionEnum e : values()) {
if (e.getNo() == no) {
return e;
}
}
return null;
}
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public int getStart() {
return start;
}
public void setStart(int start) {
this.start = start;
}
public int getEnd() {
return end;
}
public void setEnd(int end) {
this.end = end;
}
}
... ... @@ -16,11 +16,11 @@ public interface UnionShareUserApplyMapper {
int insertSelective(UnionShareUserApply record);
UnionShareUserApply selectByPrimaryKey(Integer id);
List<UnionShareUserApply> selectByIds(List<Integer> id);
List<UnionShareUserApply> selectByIds(@Param("ids")Set<Integer> ids);
int updateByPrimaryKeySelective(UnionShareUserApply record);
int updateStatus(@Param("ids")List<Integer> ids,@Param("oldState")Integer oldState,@Param("newState")Integer newState,@Param("time")Integer time);
int updateStatus(@Param("ids")Set<Integer> ids,@Param("oldState")Integer oldState,@Param("newState")Integer newState,@Param("time")Integer time);
int updateByPrimaryKey(UnionShareUserApply record);
... ...
... ... @@ -24,6 +24,15 @@
from union_share_user_apply
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByIds" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from union_share_user_apply
where id in
<foreach collection="ids" open="(" close=")" item="id" separator=",">
#{id}
</foreach>
</select>
<select id="selectByCondition"
resultType="com.yoho.service.model.union.response.UnionShareUserApplyListBo"
parameterType="com.yoho.service.model.union.request.UnionShareUserApplyListReqBo">
... ... @@ -52,8 +61,16 @@
<if test="status != null">
and status = #{status}
</if>
<if test="endTime != null">
and create_time &lt;= #{endTime}
</if>
<if test="beginTime != null">
and create_time &gt;= #{beginTime}
</if>
order by id desc
<if test="!queryAll">
limit #{start},#{size}
</if>
</select>
<select id="selectTotalByCondition" resultType="java.lang.Integer"
parameterType="com.yoho.service.model.union.request.UnionShareUserApplyListReqBo">
... ... @@ -81,6 +98,12 @@
<if test="status != null">
and status = #{status}
</if>
<if test="endTime != null">
and create_time &lt;= #{endTime}
</if>
<if test="beginTime != null">
and create_time &gt;= #{beginTime}
</if>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_user_apply
... ... @@ -205,6 +228,18 @@
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateStatus" parameterType="com.yoho.unions.dal.model.UnionShareUserApply" >
update union_share_user_apply
<set >
status = #{newState,jdbcType=TINYINT},
check_time = #{time,jdbcType=INTEGER},
</set>
where id in
<foreach collection="ids" open="(" close=")" item="id" separator=",">
#{id}
</foreach>
and status = #{oldState,jdbcType=TINYINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionShareUserApply" >
update union_share_user_apply
set uid = #{uid,jdbcType=INTEGER},
... ...
package com.yoho.unions.server.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yoho.service.model.union.request.UnionShareUserApplyListReqBo;
import com.yoho.service.model.union.response.UnionShareUserApplyListBo;
import com.yoho.unions.common.enums.SocialMediaTypeEnum;
import com.yoho.unions.common.service.IBusinessExportService;
import com.yoho.unions.dal.UnionShareUserApplyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* CPS联盟用户申请导出
* Created by mingdan.ge on 2018/6/27.
* http://localhost/union//html/unionshare/unionShareUserApplys.html
*/
@Service
public class UnionShareApplyExportImpl implements IBusinessExportService {
@Autowired
UnionShareUserApplyMapper unionShareUserApplyMapper;
@Override
public Class getDataClass() {
return UnionShareUserApplyListBo.class;
}
@Override
public List<? extends Object> batchExport(String confStr){
UnionShareUserApplyListReqBo req = JSONObject.parseObject(confStr, UnionShareUserApplyListReqBo.class);
req.setQueryAll(true);
List<UnionShareUserApplyListBo> applys=this.unionShareUserApplyMapper.selectByCondition(req);
for(UnionShareUserApplyListBo bo:applys){
bo.setSocialMediaType(null==bo.getSocialMediaType()?null: SocialMediaTypeEnum.getNameByType(Integer.parseInt(bo.getSocialMediaType())));
}
return applys;
}
}
... ...
... ... @@ -26,6 +26,7 @@ import com.yoho.unions.server.service.IUnionShareService;
import com.yoho.unions.utils.DateUtils;
import com.yoho.unions.utils.ImagesHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -40,6 +41,7 @@ import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
... ... @@ -289,7 +291,6 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
List<UnionShareUserApplyListBo> applys=this.unionShareUserApplyMapper.selectByCondition(parm);
for(UnionShareUserApplyListBo bo:applys){
bo.setSocialMediaType(null==bo.getSocialMediaType()?null:SocialMediaTypeEnum.getNameByType(Integer.parseInt(bo.getSocialMediaType())));
bo.setSocialMediaFans(null==bo.getSocialMediaFans()?null: SocialMediaSectionEnum.getSectionByNo(Integer.parseInt(bo.getSocialMediaFans()),"-"));
}
PageResponseBO<UnionShareUserApplyListBo> result=new PageResponseBO<>();
result.setList(applys);
... ... @@ -305,8 +306,6 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
*/
@Override
public int refuseApply(IdOrIdsBo req){
if (req.getId() != null) {
//单个操作
UnionShareUserApply unionShareUserApply = unionShareUserApplyMapper.selectByPrimaryKey(req.getId());
if (unionShareUserApply == null || unionShareUserApply.getStatus() > 1) {
return 0;
... ... @@ -318,22 +317,6 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
int result=unionShareUserApplyMapper.updateByPrimaryKeySelective(updateReq);
redisHashCache.delete(ShareOrdersKeyEnum.UNION_TYPE.getPreKey(),unionShareUserApply.getUid());
return result;
} else {
//批量操作
List<UnionShareUserApply> unionShareUserApplies = unionShareUserApplyMapper.selectByIds(Arrays.asList(req.getIdArray()));
if (CollectionUtils.isEmpty(unionShareUserApplies)) {
return 0;
}
List<Integer> ids = new ArrayList<>();
unionShareUserApplies.forEach(u->{
ids.add(u.getId());
});
int result=unionShareUserApplyMapper.updateStatus(ids,1,3,DateUtil.getCurrentTimeSecond());
unionShareUserApplies.forEach(u->{
redisHashCache.delete(ShareOrdersKeyEnum.UNION_TYPE.getPreKey(),u.getUid());
});
return result;
}
}
/**
... ... @@ -356,23 +339,35 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
updateReq.setCheckTime(DateUtil.getCurrentTimeSecond());
int result=unionShareUserApplyMapper.updateByPrimaryKeySelective(updateReq);
if (result > 0) {
//todo 绑定unionType
// 绑定unionType
relateUnionType(unionShareUserApply.getUid());
}
redisHashCache.delete(ShareOrdersKeyEnum.UNION_TYPE.getPreKey(),unionShareUserApply.getUid());
return result;
} else {
//批量操作
List<UnionShareUserApply> unionShareUserApplies = unionShareUserApplyMapper.selectByIds(Arrays.asList(req.getIdArray()));
Set<Integer> idSet = Arrays.stream(req.getIds().split(",")).map(s->{
Integer skn = null;
try {
skn = Integer.valueOf(s);
} catch (NumberFormatException e) {
}
return skn;
}).collect(Collectors.toSet());
int currentTimeSecond = DateUtil.getCurrentTimeSecond();
int result=unionShareUserApplyMapper.updateStatus(idSet,1,2, currentTimeSecond);
if (result == 0) {
return 0;
}
List<UnionShareUserApply> unionShareUserApplies = unionShareUserApplyMapper.selectByIds(idSet);
if (CollectionUtils.isEmpty(unionShareUserApplies)) {
return 0;
}
List<Integer> ids = new ArrayList<>();
unionShareUserApplies.forEach(u->{
ids.add(u.getId());
});
int result=unionShareUserApplyMapper.updateStatus(ids,1,2,DateUtil.getCurrentTimeSecond());
unionShareUserApplies.forEach(u->{
if (u.getCheckTime() != currentTimeSecond) {
return;
}
relateUnionType(u.getUid());
redisHashCache.delete(ShareOrdersKeyEnum.UNION_TYPE.getPreKey(),u.getUid());
});
... ... @@ -485,7 +480,6 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
public Map<String,JSONArray> getSocialMediaBasicParams(){
logger.info("getBankList");
Map<String, JSONArray> result = new HashMap<>();
result.put("section", SocialMediaSectionEnum.getAllSectionArray("-"));
result.put("mediaType", SocialMediaTypeEnum.getAllTypeArray());
return result;
}
... ...
... ... @@ -119,6 +119,7 @@
<entry key="channelUserServiceImpl" value-ref="channelUserServiceImpl"/>
<entry key="userOrdersServiceImpl" value-ref="userOrdersServiceImpl"/>
<entry key="unionShareServiceImpl" value-ref="unionShareServiceImpl"/>
<entry key="unionShareApplyExportImpl" value-ref="unionShareApplyExportImpl"/>
<entry key="userRegisterBuyInfoserviceImpl" value-ref="userRegisterBuyInfoserviceImpl"/>
</util:map>
... ...
... ... @@ -25,9 +25,6 @@
<label>社交媒体账号:</label>
<input class="easyui-textbox" id="socialMediaAccount" name="socialMediaAccount">
</input>
<label>社交媒体粉丝数:</label>
<input class="easyui-combobox" id="socialMediaFans" name="socialMediaFans">
</input>
<label>状态:</label>
<input class="easyui-combobox" id="status" name="status"
data-options="valueField: 'value',
... ... @@ -43,7 +40,18 @@
value: '3'
}]">
</input>
</div>
<div style="margin-left: 10px;margin-top: 10px">
<label>开始时间:</label>
<input class="easyui-datetimebox" id="beginTime" name="beginTime">
</input>
<label>结束时间:</label>
<input class="easyui-datetimebox" id="endTime" name="endTime">
</input>
<a id="searchBtn" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">查询</a>
<a id="passButton" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">批量通过</a>
<a id="exportButton" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">导出</a>
</div>
</form>
</div>
... ... @@ -57,7 +65,6 @@
$(function () {
var _socialMediaTypeSelector = $("#socialMediaType");
var _socialMediaFansSelector = $("#socialMediaFans");
$.ajax({
type: 'POST',
url: contextPath + "/UnionShareRest/getSocialMediaBasicParams",
... ... @@ -72,9 +79,6 @@
_socialMediaTypeSelector.combobox({valueField: 'type',
textField: 'name',
data:res.data.mediaType});
_socialMediaFansSelector.combobox({valueField: 'no',
textField: 'desc',
data:res.data.section});
}
} else {
$.messager.alert("失败", res.message, "error");
... ... @@ -143,19 +147,9 @@
align: "center"
}, {
title: "状态",
field: "status",
field: "statusStr",
width: 200,
align: "center",
formatter: function (value, rowData, rowIndex) {
//状态:1-申请中,2-通过,3-拒绝
if(rowData.status == 1) {
return "申请中";
}else if(rowData.status == 2) {
return "通过";
}else if(rowData.status == 3) {
return "拒绝";
}
}
align: "center"
}, {
title: "申请时间",
field: "createTime",
... ... @@ -213,7 +207,7 @@
function pass(id) {
var paramObj={};
if(id==null) {
paramObj.idArray = checkedItems;
paramObj.ids = checkedItems.toString();
}else {
paramObj.id = id;
}
... ... @@ -279,15 +273,7 @@
iconCls : "icon-search",
onClick : function() {
checkedItems=[];
var param = {
uid:$("#uid").val(),
name:$("#name").val(),
socialMediaType:$("#socialMediaType").combobox('getValue'),
socialMediaAccount:$("#socialMediaAccount").val(),
socialMediaFans:$("#socialMediaFans").combobox('getValue'),
status:$("#status").combobox('getValue'),
mobile:$("#mobile").val()
};
var param = getParams();
$("#userApplyTable").myDatagrid("load", param);
}
});
... ... @@ -300,8 +286,41 @@
}
});
}
$("#passButton").linkbutton({
onClick : function() {
if (checkedItems.length == 0) {
$.messager.alert('提示','请选择要审核通过的数据');
return;
}
pass(null);
}
});
$("#exportButton").linkbutton({
onClick : function() {
window.open(contextPath + "/batch/export.do?type=unionShareApplyExportImpl&queryConf=" + escape(JSON.stringify(getParams())));
// window.open(contextPath + "/batch/export.do?type=unionShareApplyExportImpl&queryConf=" + getParams());
}
});
var fileview = $.extend({}, $.fn.datagrid.defaults.view, { onAfterRender: function (target) { isCheckItem(); } });
function getParams() {
var param = {
uid:$("#uid").val(),
name:$("#name").val(),
socialMediaType:$("#socialMediaType").combobox('getValue'),
socialMediaAccount:$("#socialMediaAccount").val(),
status:$("#status").combobox('getValue'),
mobile:$("#mobile").val()
};
if ($("#beginTime").datetimebox('getValue')!='')
{
param.beginTime = parseInt(new Date($("#beginTime").datetimebox('getValue')).getTime() / 1000)
}
if ($("#endTime").datetimebox('getValue') != ''){
param.endTime = parseInt(new Date($("#endTime").datetimebox('getValue')).getTime() / 1000)
}
return param;
}
function isCheckItem() {
for (var i = 0; i < checkedItems.length; i++) {
... ...