Authored by mingdan.ge

Merge branch 'dev_180508_联盟红人推广' into test6.6.1

... ... @@ -7,12 +7,12 @@ import org.slf4j.helpers.MessageFormatter;
*/
public enum ShareOrdersKeyEnum {
ORDER_LIST("yh:unions:share:orderList:","type:{}:status:{}:page:{}:limit:{}",600,"订单列表"),
ORDER_INFO("yh:unions:share:orderInfo:","key:{}:orderCode:{}",600,"订单详情"),
USER_SETTLEMENT("yh:unions:share:userSettlement:","type:{}",600,"用户提现未提现总计"),
SETTLEMENT_LIST("yh:unions:share:settlementList:","key:{}:page:{}:limit:{}",600,"提现列表"),
UNION_TYPE("yh:unions:share:unionType:","key:{}",600,"用户登录时获取对应的渠道号"),
RECENTLY_ORDER_LIMIT_TEN("yh:unions:share:recentlyOrderLimitTen:","key:{}",600,"用户前台获取个人推广近期订单(10个)");
ORDER_LIST("yh:union:share:orderList:","type:{}:status:{}:page:{}:limit:{}",600,"订单列表"),
ORDER_INFO("yh:union:share:orderInfo:","key:{}:orderCode:{}",600,"订单详情"),
USER_SETTLEMENT("yh:union:share:userSettlement:","type:{}",600,"用户提现未提现总计"),
SETTLEMENT_LIST("yh:union:share:settlementList:","key:{}:page:{}:limit:{}",600,"提现列表"),
UNION_TYPE("yh:union:share:unionType:","key:{}",600,"用户登录时获取对应的渠道号"),
RECENTLY_ORDER_LIMIT_TEN("yh:union:share:recentlyOrderLimitTen:","key:{}",600,"用户前台获取个人推广近期订单(10个)");
private String preKey;
... ...
... ... @@ -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
... ...
... ... @@ -35,8 +35,6 @@ public class UnionShareRest {
private static Logger log = LoggerFactory.getLogger(UnionShareRest.class);
private static Logger mqlog = LoggerFactory.getLogger("cps_mq");
@Autowired
IUnionShareService unionShareService;
... ... @@ -151,7 +149,7 @@ public class UnionShareRest {
@RequestMapping("/mqUnionShareOrder")
@ResponseBody
public UnionResponse mqUnionShareOrder(@RequestBody List<ShareOrderBo> list){
mqlog.info("UnionShareRest.mqUnionShareOrder req is {}", JsonUtil.objectToJSON(list));
log.info("UnionShareRest.mqUnionShareOrder req is {}", JsonUtil.objectToJSON(list));
try {
if (null == list) {
return new UnionResponse(500, "mqUnionShareOrder error,req is null");
... ... @@ -162,11 +160,11 @@ public class UnionShareRest {
//订单插入或更新
unionShareService.saveOrUpdateOrder(l);
} catch (Exception e) {
mqlog.info("UnionShareRest.mqUnionShareOrder fail! bo is {}, e {}", l,e.getMessage());
log.info("UnionShareRest.mqUnionShareOrder fail! bo is {}, e {}", l,e.getMessage());
}
});
} catch (Exception e) {
mqlog.warn("UnionShareRest.mqUnionShareOrder fail! str is {}, e {}",JsonUtil.objectToJSON(list),e.getMessage());
log.warn("UnionShareRest.mqUnionShareOrder fail! str is {}, e {}",JsonUtil.objectToJSON(list),e.getMessage());
}
return new UnionResponse(200, "mqUnionShareOrder success");
}
... ... @@ -174,7 +172,7 @@ public class UnionShareRest {
@RequestMapping("/mqUnionSettleUpdate")
@ResponseBody
public UnionResponse mqUnionSettleUpdate(@RequestBody ShareSettlementBo bo){
mqlog.info("UnionShareRest.mqUnionSettleUpdate req is {}", bo);
log.info("UnionShareRest.mqUnionSettleUpdate req is {}", bo);
try {
if (null == bo) {
return new UnionResponse(500, "mqUnionSettleUpdate error,req is null");
... ... @@ -183,7 +181,7 @@ public class UnionShareRest {
unionShareService.updateSettlementStatus(bo);
} catch (Exception e) {
mqlog.warn("UnionShareRest.mqUnionSettleUpdate fail! req is {}, e {}", bo,e.getMessage());
log.warn("UnionShareRest.mqUnionSettleUpdate fail! req is {}, e {}", bo,e.getMessage());
}
return new UnionResponse(200, "mqUnionSettleUpdate success");
}
... ...
... ... @@ -113,27 +113,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);
... ... @@ -143,17 +137,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();
... ... @@ -162,7 +153,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;
}
... ... @@ -204,14 +194,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());
... ... @@ -223,6 +216,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 {
... ... @@ -816,14 +820,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);
}
});
... ...