Authored by csgyoho

CPS订单查询取消渠道号类型条件

... ... @@ -2,18 +2,23 @@ package com.yoho.unions.dal;
import com.yoho.unions.dal.model.MktMarketingUrl;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface IMktMarketingUrlDAO {
int deleteByPrimaryKey(Long unionType);
MktMarketingUrl selectByPrimaryKey(Long unionType);
@MapKey("unionType")
Map<Long,MktMarketingUrl> selectByUnionTypes(List<String> unionTypes);
MktMarketingUrl selectByName(String name);
List<Long> selectUnionTypes(@Param("unionType") Long unionType, @Param("name") String name, @Param("channelType") String channelType);
Long selectByNameAndUnionType(@Param("name")String name,@Param("unionType")Long unionType);
Long selectUnionTypeByNameAndUnionType(@Param("name")String name, @Param("unionType")Long unionType);
}
\ No newline at end of file
... ...
... ... @@ -20,16 +20,16 @@ public interface UnionShareOrdersMapper {
UnionShareOrders selectByCode(String orderCode);
int selectCountByUids(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("uids") List<Integer> uids,@Param("orderCode")String orderCode);
int selectCountBySearchCodition(@Param("beginTime") int beginTime, @Param("endTime") int endTime, @Param("uid") Integer uid, @Param("orderCode")String orderCode);
@MapKey("orderCode")
Map<String,UnionShareOrders> selectListByUids(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("uids") List<Integer> uids,@Param("orderCode") String orderCode,@Param("startIndex") int startIndex, @Param("pageSize") int pageSize);
Map<String,UnionShareOrders> selectListBySearchCodition(@Param("beginTime") int beginTime, @Param("endTime") int endTime, @Param("uid") Integer uid, @Param("orderCode") String orderCode, @Param("startIndex") int startIndex, @Param("pageSize") int pageSize);
@MapKey("orderCode")
Map<String,UnionShareOrders> selectListByIds(List<String> ids);
@MapKey("orderCode")
Map<String,UnionShareOrders> selectAllListByUids(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("uids") List<Integer> uids,@Param("orderCode") String orderCode);
Map<String,UnionShareOrders> selectAllListByUids(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("uid") Integer uid,@Param("orderCode") String orderCode);
int selectCountByCondition(@Param("promoteUid")int promoteUid, @Param("status")String status);
... ...
... ... @@ -23,7 +23,7 @@ public interface UnionShareUserMapper {
int updateByPrimaryKey(UnionShareUser record);
List<Integer> selectUids(List<Long> unionTypes);
Integer selectUidByUnionType(Long unionType);
@MapKey("uid")
Map<Integer,UnionShareUser> selectByUids(List<Integer> uids);
... ...
... ... @@ -51,7 +51,7 @@
and channel_type=#{channelType}
</if>
</select>
<select id="selectByNameAndUnionType" resultType="java.lang.Long">
<select id="selectUnionTypeByNameAndUnionType" resultType="java.lang.Long">
select union_type from mkt_marketing_url where 1=1
<if test="unionType!=null">
and union_type=#{unionType}
... ... @@ -61,4 +61,13 @@
</if>
limit 1
</select>
<select id="selectByUnionTypes" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List" />
from mkt_marketing_url
where union_type in
<foreach collection="list" open="(" close=")" item="unionType" separator=",">
#{unionType}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -190,13 +190,10 @@
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCountByUids" resultType="int">
<select id="selectCountBySearchCodition" resultType="int">
select count(*) from union_share_orders where 1=1
<if test="uids!=null and uids.size()>0">
and promote_uid in
<foreach collection="uids" open="(" close=")" item="uid" separator=",">
#{uid}
</foreach>
<if test="uid!=null">
and promote_uid = #{uid}
</if>
<if test="orderCode != null" >
and order_code = #{orderCode}
... ... @@ -210,11 +207,8 @@
</select>
<select id="selectAllListByUids" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from union_share_orders where 1=1
<if test="uids!=null and uids.size()>0">
and promote_uid in
<foreach collection="uids" open="(" close=")" item="uid" separator=",">
#{uid}
</foreach>
<if test="uid!=null">
and promote_uid = #{uid}
</if>
<if test="orderCode != null" >
and order_code = #{orderCode}
... ... @@ -227,13 +221,10 @@
</if>
order BY create_time desc
</select>
<select id="selectListByUids" resultMap="BaseResultMap">
<select id="selectListBySearchCodition" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from union_share_orders where 1=1
<if test="uids!=null and uids.size()>0">
and promote_uid in
<foreach collection="uids" open="(" close=")" item="uid" separator=",">
#{uid}
</foreach>
<if test="uid!=null">
and promote_uid =#{uid}
</if>
<if test="orderCode != null" >
and order_code = #{orderCode}
... ...
... ... @@ -91,11 +91,8 @@
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectUids" parameterType="Long" resultType="Integer">
select uid from union_share_user where union_type in
<foreach collection="list" open="(" close=")" item="unionType" separator=",">
#{unionType}
</foreach>
<select id="selectUidByUnionType" parameterType="java.lang.Long" resultType="java.lang.Integer">
select uid from union_share_user where union_type =#{unionType} limit 1
</select>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionShareUser" >
update union_share_user
... ...
... ... @@ -108,27 +108,21 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
@Override
public PageUnionShareOrderRspBO queryUnionShareOrders(UnionShareOrderSearchReqBO reqBO){
logger.info("queryUnionShareOrders param is {}", reqBO);
/*
* 由于不能连表查所以解决方案有二:
* 1.牺牲内存,临时数据先查出存到内存中(比如这里 uids),缺点是数据太多的话内存放不下
* 2.数据库添加冗余外表字段(比如A表连接B表查,可把B表中用的字段在A表也添加上去,缺点是业务复杂度提高)
*
*/
UnionShareOrderSearchBo bo=initUnionShareOrderSearchBo(reqBO);
List<Integer> uids=null;
if(bo.getUnionType()!=null || bo.getUnionName()!=null || bo.getChannelType()!=null){
uids=queryUids(bo);
if(null==uids){
Integer uid=null;
if(bo.getUnionType()!=null || bo.getUnionName()!=null ){
uid=queryUid(bo);
if(null==uid){
return null;
}
}
//查询总数
int count = unionShareOrdersMapper.selectCountByUids(bo.getBeginTime(), bo.getEndTime(), uids,bo.getOrderCode());
logger.info("unionShareOrdersMapper.selectCountByUids: size is {}", count);
int count = unionShareOrdersMapper.selectCountBySearchCodition(bo.getBeginTime(), bo.getEndTime(), uid,bo.getOrderCode());
logger.info("unionShareOrdersMapper.selectCountByBySearchCodition: size is {}", count);
if (count < 1) {
return null;
}
Map<String,UnionShareOrders> ordersDOMap=this.unionShareOrdersMapper.selectListByUids(bo.getBeginTime(), bo.getEndTime(), uids,bo.getOrderCode(), reqBO.getStart(), reqBO.getSize());
Map<String,UnionShareOrders> ordersDOMap=this.unionShareOrdersMapper.selectListBySearchCodition(bo.getBeginTime(), bo.getEndTime(), uid,bo.getOrderCode(), reqBO.getStart(), reqBO.getSize());
List<UnionShareOrderRspBO> unionOrderRspBOList = queryUnionShareOrderRsp(ordersDOMap);
PageUnionShareOrderRspBO pageUnionOrderRspBO = new PageUnionShareOrderRspBO();
pageUnionOrderRspBO.setList(unionOrderRspBOList);
... ... @@ -138,17 +132,14 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return pageUnionOrderRspBO;
}
private List<Integer> queryUids(UnionShareOrderSearchBo bo){
List<Integer> uids=null;
List<Long> unionTypes=mktMarketingUrlDAO.selectUnionTypes(bo.getUnionType(), bo.getUnionName(), bo.getChannelType());
if(unionTypes.isEmpty()){
private Integer queryUid(UnionShareOrderSearchBo bo){
Integer uid=null;
Long unionType=mktMarketingUrlDAO.selectUnionTypeByNameAndUnionType(bo.getUnionName(),bo.getUnionType());
if(null==unionType){
return null;
}
uids=this.unionShareUserMapper.selectUids(unionTypes);
if(uids.isEmpty()){
return null;
}
return uids;
uid=this.unionShareUserMapper.selectUidByUnionType(unionType);
return uid;
}
private UnionShareOrderSearchBo initUnionShareOrderSearchBo(UnionShareOrderSearchReqBO reqBO){
UnionShareOrderSearchBo bo=new UnionShareOrderSearchBo();
... ... @@ -157,7 +148,6 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
bo.setOrderCode(StringUtils.isBlank(reqBO.getOrderCode()) ? null : reqBO.getOrderCode());
bo.setUnionType(StringUtils.isBlank(reqBO.getUnionId()) ? null :Long.valueOf( reqBO.getUnionId()));
bo.setUnionName(StringUtils.isBlank(reqBO.getUnionType()) ? null : reqBO.getUnionType());
bo.setChannelType(StringUtils.isBlank(reqBO.getChannelType())?null:reqBO.getChannelType());
bo.setIdList(reqBO.getIdsList());
return bo;
}
... ... @@ -199,14 +189,17 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
private Map<String, ShareUserOrderDatailBO> initUserShareOrderDatails( Map<String,UnionShareOrders> ordersDOMap){
Map<String, ShareUserOrderDatailBO> userOrderDatailBOMap = new HashMap<>(ordersDOMap.size());
Map<Integer,UnionShareUser> userMap=unionShareUserMapper.selectByUids(getUids(ordersDOMap));
Map<Long,MktMarketingUrl> mktMarketMap=listMktMarketingUrls(ordersDOMap,userMap);
for (UnionShareOrders userOrders : ordersDOMap.values()) {
String unionType=userMap.get(userOrders.getPromoteUid()).getUnionType();
ShareUserOrderDatailBO userOrderDatailBO = new ShareUserOrderDatailBO();
userOrderDatailBO.setUnionType(unionType);
MktMarketingUrl mktMarketingUrl = redisValueCache.get("yh:union:uniontype:" + unionType, MktMarketingUrl.class);
if (mktMarketingUrl == null &&isLong(unionType)) {
mktMarketingUrl = mktMarketingUrlDAO.selectByPrimaryKey(Long.valueOf(unionType));
redisValueCache.set("yh:union:uniontype:" + unionType, mktMarketingUrl, 1, TimeUnit.HOURS);
if (mktMarketingUrl == null && isLong(unionType)) {
mktMarketingUrl = mktMarketMap.get(Long.valueOf(unionType));
if(null!=mktMarketingUrl){
redisValueCache.set("yh:union:uniontype:" + unionType, mktMarketingUrl, 1, TimeUnit.HOURS);
}
}
if (mktMarketingUrl != null) {
userOrderDatailBO.setUnionName(mktMarketingUrl.getName());
... ... @@ -218,6 +211,17 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return userOrderDatailBOMap;
}
private Map<Long,MktMarketingUrl> listMktMarketingUrls(Map<String,UnionShareOrders> ordersDOMap, Map<Integer,UnionShareUser> userMap){
List<String> unionTypes=new ArrayList<>();
for (UnionShareOrders userOrders : ordersDOMap.values()) {
String unionType=userMap.get(userOrders.getPromoteUid()).getUnionType();
if(StringUtils.isNotBlank(unionType)){
unionTypes.add(unionType);
}
}
return unionTypes.isEmpty()?new HashMap<>():this.mktMarketingUrlDAO.selectByUnionTypes(unionTypes);
}
private boolean isLong(String value){
boolean flag=true;
try {
... ... @@ -773,14 +777,14 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
if(bo.getIdList()!=null&&!bo.getIdList().isEmpty()){
ordersDOMap= this.unionShareOrdersMapper.selectListByIds(bo.getIdList());
}else{
List<Integer> uids=null;
if(bo.getUnionType()!=null || bo.getUnionName()!=null || bo.getChannelType()!=null){
uids=queryUids(bo);
if(null==uids){
Integer uid=null;
if(bo.getUnionType()!=null || bo.getUnionName()!=null){
uid=queryUid(bo);
if(null==uid){
return null;
}
}
ordersDOMap=this.unionShareOrdersMapper.selectAllListByUids(bo.getBeginTime(), bo.getEndTime(), uids, bo.getOrderCode());
ordersDOMap=this.unionShareOrdersMapper.selectAllListByUids(bo.getBeginTime(), bo.getEndTime(), uid, bo.getOrderCode());
}
return ordersDOMap.isEmpty()?null:queryUnionShareOrderRsp(ordersDOMap);
}
... ...
... ... @@ -106,7 +106,7 @@ public class UserOrdersServiceImpl implements IUserOrdersService,IBusinessExport
List<String> idList = reqBO.getIdsList();
if(unionType!=null || unionName!=null){
unionType=mktMarketingUrlDAO.selectByNameAndUnionType(unionName,unionType);
unionType=mktMarketingUrlDAO.selectUnionTypeByNameAndUnionType(unionName,unionType);
if(unionType==null){
return null;
}
... ...
... ... @@ -34,9 +34,6 @@
<input class="easyui-textbox" id="unionType" name="unionType">
</input>
<label>渠道号类型:</label>
<input class="easyui-combobox" id="channelType" name="channelType">
</input>
<a id="searchBtn" 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>
... ... @@ -134,12 +131,6 @@
resetSelectedCheckBox(data);
}
});
$("#channelType").combobox({
valueField : "channelType",
textField : "channelTypeDesc",
data:[{channelTypeDesc:"个人",channelType:"1"},{channelTypeDesc:"机构",channelType:"0"}]
});
$("#channelType").combobox("clear");
function resetSelectedCheckBox(data){
$("input[type='checkbox'][name='id']").each(function () {
... ... @@ -177,7 +168,6 @@
param.orderCode = $("#orderCode").val(),
param.unionId = $("#unionId").val(),
param.unionType=$("#unionType").val(),
param.channelType=$("#channelType").combobox("getValue"),
$("#userOrdersTable").myDatagrid("load", param);
}
});
... ...