Authored by mingdan.ge

cps订单管理后台修改

... ... @@ -2,6 +2,7 @@ package com.yoho.unions.dal;
import com.yoho.service.model.union.bo.UnionShareOrdersUidBo;
import com.yoho.service.model.union.request.UnionShareOrderReqBO;
import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO;
import com.yoho.unions.dal.model.UnionShareOrders;
import com.yoho.unions.dal.model.UnionShareOrdersMonth;
import org.apache.ibatis.annotations.Param;
... ... @@ -20,9 +21,9 @@ public interface UnionShareOrdersMapper {
UnionShareOrders selectByCode(String orderCode);
int selectCountBySearchCodition(@Param("beginTime") int beginTime, @Param("endTime") int endTime, @Param("uid") Integer uid, @Param("orderCode")String orderCode);
int selectCountBySearchCodition(UnionShareOrderSearchReqBO req);
List<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);
List<UnionShareOrders> selectListBySearchCodition(UnionShareOrderSearchReqBO req);
List<UnionShareOrders> selectListByIds(@Param("ids") List<String> ids);
List<UnionShareOrders> selectListByOrderCodesForActivity(@Param("orderCodes") List<String> orderCodes);
... ...
... ... @@ -26,7 +26,7 @@ public interface UnionShareUserMapper {
int updateByPrimaryKey(UnionShareUser record);
Integer selectUidByUnionType(Long unionType);
Integer selectUidByUnionType(String unionType);
@MapKey("uid")
Map<Integer,UnionShareUser> selectByUids(@Param("uids") Set<Integer> uids);
... ...
... ... @@ -303,18 +303,21 @@
order_amount = #{orderAmount,jdbcType=DECIMAL}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCountBySearchCodition" resultType="int">
select count(*) from union_share_orders where order_code is not null
<if test="uid!=null">
and promote_uid = #{uid}
<select id="selectCountBySearchCodition" resultType="java.lang.Integer" parameterType="com.yoho.service.model.union.request.UnionShareOrderSearchReqBO">
select count(1) from union_share_orders where order_code is not null
<if test="promoteUid!=null">
and promote_uid = #{promoteUid}
</if>
<if test="orderUid!=null">
and order_uid = #{orderUid}
</if>
<if test="orderCode != null" >
and order_code = #{orderCode}
</if>
<if test="beginTime != 0" >
<if test="beginTime != null" >
and order_time &gt; #{beginTime}
</if>
<if test="endTime != 0" >
<if test="endTime != null" >
and order_time &lt;#{endTime}
</if>
</select>
... ... @@ -372,22 +375,27 @@
where order_uid = #{orderUid} and promote_uid = #{promoteUid} and activity_id = #{activityId}
limit 1
</select>
<select id="selectListBySearchCodition" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from union_share_orders where order_code is not null
<if test="uid!=null">
and promote_uid =#{uid}
<select id="selectListBySearchCodition" resultMap="BaseResultMap" parameterType="com.yoho.service.model.union.request.UnionShareOrderSearchReqBO">
select <include refid="Base_Column_List" />
from union_share_orders
where order_code is not null
<if test="promoteUid!=null">
and promote_uid = #{promoteUid}
</if>
<if test="orderUid!=null">
and order_uid = #{orderUid}
</if>
<if test="orderCode != null" >
and order_code = #{orderCode}
</if>
<if test="beginTime != 0" >
<if test="beginTime != null" >
and order_time &gt; #{beginTime}
</if>
<if test="endTime != 0" >
<if test="endTime != null" >
and order_time &lt;#{endTime}
</if>
order BY order_time desc
limit #{startIndex},#{pageSize}
order by order_time desc
limit #{start},#{size}
</select>
<update id="updateStatusById" >
update union_share_orders
... ...
... ... @@ -142,7 +142,7 @@
</set>
where uid = #{uid,jdbcType=INTEGER}
</update>
<select id="selectUidByUnionType" parameterType="java.lang.Long" resultType="java.lang.Integer">
<select id="selectUidByUnionType" parameterType="java.lang.String" 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" >
... ...
... ... @@ -251,22 +251,23 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
@Override
public PageUnionShareOrderRspBO queryUnionShareOrders(UnionShareOrderSearchReqBO reqBO){
logger.info("queryUnionShareOrders param is {}", reqBO);
UnionShareOrderSearchBo bo=initUnionShareOrderSearchBo(reqBO);
Integer uid=null;
if(bo.getUnionType()!=null || bo.getUnionName()!=null ){
uid=queryUid(bo);
if(null==uid){
if(StringUtils.isNotBlank(reqBO.getUnionType())){
setUid(reqBO);
if (reqBO.getPromoteUid() ==null) {
return null;
}
}
if (StringUtils.isBlank(reqBO.getOrderCode())) {
reqBO.setOrderCode(null);
}
//查询总数
int count = unionShareOrdersMapper.selectCountBySearchCodition(bo.getBeginTime(), bo.getEndTime(), uid,bo.getOrderCode());
int count = unionShareOrdersMapper.selectCountBySearchCodition(reqBO);
logger.info("unionShareOrdersMapper.selectCountByBySearchCodition: size is {}", count);
if (count < 1) {
return null;
}
List<UnionShareOrders> ordersDOList=this.unionShareOrdersMapper.selectListBySearchCodition(bo.getBeginTime(), bo.getEndTime(), uid,bo.getOrderCode(), reqBO.getStart(), reqBO.getSize());
List<UnionShareOrderRspBO> unionOrderRspBOList = queryUnionShareOrderRspBO(ordersDOList);
List<UnionShareOrders> ordersDOList=this.unionShareOrdersMapper.selectListBySearchCodition(reqBO);
List<UnionShareOrderRspBO> unionOrderRspBOList = getUnionShareOrderRspList(ordersDOList,reqBO);
PageUnionShareOrderRspBO pageUnionOrderRspBO = new PageUnionShareOrderRspBO();
pageUnionOrderRspBO.setList(unionOrderRspBOList);
pageUnionOrderRspBO.setTotal(count);
... ... @@ -275,43 +276,47 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return pageUnionOrderRspBO;
}
private Integer queryUid(UnionShareOrderSearchBo bo){
Long unionType=null==bo.getUnionName()?bo.getUnionType():mktMarketingUrlDAO.selectUnionTypeByNameAndUnionType(bo.getUnionName(),bo.getUnionType());
if(null==unionType){
return null;
private List<UnionShareOrderRspBO> getUnionShareOrderRspList(List<UnionShareOrders> ordersDOList,UnionShareOrderSearchReqBO reqBO) {
List<UnionShareOrderRspBO> rsplist = new ArrayList<>();
if (CollectionUtils.isEmpty(ordersDOList)) {
return rsplist;
}
return this.unionShareUserMapper.selectUidByUnionType(unionType);
}
private UnionShareOrderSearchBo initUnionShareOrderSearchBo(UnionShareOrderSearchReqBO reqBO){
UnionShareOrderSearchBo bo=new UnionShareOrderSearchBo();
bo.setBeginTime(StringUtils.isNumeric(reqBO.getBeginTime()) ? Integer.parseInt(reqBO.getBeginTime()):0);
bo.setEndTime(StringUtils.isNumeric(reqBO.getEndTime()) ? Integer.parseInt(reqBO.getEndTime()):0);
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.setIdList(reqBO.getIdsList());
return bo;
Set<Integer> uidSet;
if (reqBO.getPromoteUid() == null) {
uidSet = ordersDOList.stream().map(o -> o.getPromoteUid()).collect(Collectors.toSet());
} else {
uidSet = new HashSet<Integer>(){{add(reqBO.getPromoteUid());}};
}
Map<Integer, UnionShareUser> userMap = unionShareUserMapper.selectByUids(uidSet);
ordersDOList.forEach(o->{
UnionShareOrderRspBO rspBO = new UnionShareOrderRspBO();
BeanUtils.copyProperties(o,rspBO);
rspBO.setAmount(o.getOrderAmount());
rspBO.setOrderAmount(o.getLastOrderAmount());
rspBO.setOrderStatus(ShareOrdersStatusEnum.getDescByCode(o.getStatus()));
rspBO.setOrderTime(DateUtil.long2DateStr(Long.valueOf(o.getOrderTime()) * Long.valueOf(1000), "yyyy-MM-dd HH:mm:ss"));
if (userMap.containsKey(o.getPromoteUid())) {
rspBO.setUnionType(userMap.get(o.getPromoteUid()).getUnionType());
}
rsplist.add(rspBO);
});
return rsplist;
}
private UnionShareOrderRspBO initShareUnionOrderRspBO(String unionType,MktMarketingUrl mktMarketingUrl,UnionShareOrders orders){
UnionShareOrderRspBO orderRspBO=new UnionShareOrderRspBO();
orderRspBO.setOrderAmount(orders.getLastOrderAmount());
orderRspBO.setAmount(orders.getAmount());
orderRspBO.setOrderStatus(ShareOrdersStatusEnum.getDescByCode(orders.getStatus()));
orderRspBO.setIsNew(orders.getIsNew());
orderRspBO.setUid(orders.getPromoteUid());
orderRspBO.setOrderUid(orders.getOrderUid());
orderRspBO.setOrderCode(orders.getOrderCode());
orderRspBO.setId(orders.getId());
orderRspBO.setOrderTime(DateUtil.long2DateStr(Long.valueOf(orders.getOrderTime()) * Long.valueOf(1000), "yyyy-MM-dd HH:mm:ss"));
orderRspBO.setUnionId(unionType);
if(null!=mktMarketingUrl){
orderRspBO.setUnionType(mktMarketingUrl.getName());
orderRspBO.setChannelType(mktMarketingUrl.getChannelType());
private void setUid(UnionShareOrderSearchReqBO reqBO){
Integer uid=this.unionShareUserMapper.selectUidByUnionType(reqBO.getUnionType());
if (uid == null) {
reqBO.setPromoteUid(null);
return;
}
if (reqBO.getPromoteUid() != null && reqBO.getPromoteUid() != uid.intValue()) {
reqBO.setPromoteUid(null);
return;
}
return orderRspBO;
reqBO.setPromoteUid(uid);
}
private Set<Integer> getUids(List<UnionShareOrders> ordersDOList){
Set<Integer> uids=new HashSet<>(ordersDOList.size());
for(UnionShareOrders order:ordersDOList){
... ... @@ -320,23 +325,6 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return uids;
}
private List<UnionShareOrderRspBO> queryUnionShareOrderRspBO(List<UnionShareOrders> ordersDOList){
List<UnionShareOrderRspBO> unionOrderRspBOList = new ArrayList<>(ordersDOList.size());
Map<Integer,UnionShareUser> userMap=unionShareUserMapper.selectByUids(getUids(ordersDOList));
Map<Long,MktMarketingUrl> mktMarketMap=listMktMarketingUrls(ordersDOList,userMap);
for (UnionShareOrders userOrders : ordersDOList) {
UnionShareUser unionShareUser = userMap.get(userOrders.getPromoteUid());
if (unionShareUser == null) {
continue;
}
String unionType= unionShareUser.getUnionType();
MktMarketingUrl mktMarketingUrl = isLong(unionType)?mktMarketMap.get(Long.valueOf(unionType)):null;
UnionShareOrderRspBO bo=initShareUnionOrderRspBO(unionType,mktMarketingUrl,userOrders);
unionOrderRspBOList.add(bo);
}
return unionOrderRspBOList;
}
private Map<Long,MktMarketingUrl> listMktMarketingUrls(List<UnionShareOrders> ordersDOList, Map<Integer,UnionShareUser> userMap){
List<String> unionTypes=new ArrayList<>();
for (UnionShareOrders userOrders : ordersDOList) {
... ... @@ -2218,7 +2206,18 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
public List<? extends Object> batchExport(String confStr) {
try {
UnionShareOrderSearchReqBO request = JSONObject.parseObject(confStr, UnionShareOrderSearchReqBO.class);
List<UnionShareOrderRspBO> unionOrderRspBOList = queryUnionShareOrderRspBOForExport(request);
request.setSize(1000);
List<UnionShareOrders> ordersDOList;
if (request.getIds() != null) {
List<String> ids = Arrays.asList(request.getIds().split(","));
logger.info("batchExport.ids is {},req is {}",ids,request);
ordersDOList = unionShareOrdersMapper.selectListByIds(ids);
} else {
logger.info("batchExport.req is {}",request);
ordersDOList = this.unionShareOrdersMapper.selectListBySearchCodition(request);
}
List<UnionShareOrderRspBO> unionOrderRspBOList = getUnionShareOrderRspList(ordersDOList,request);
if (CollectionUtils.isEmpty(unionOrderRspBOList)) {
throw new ServiceException(400, "没有要导出的数据");
}
... ... @@ -2231,24 +2230,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
throw new ServiceException(e.getCode(), e.getErrorMessage());
}
}
private List<UnionShareOrderRspBO> queryUnionShareOrderRspBOForExport(UnionShareOrderSearchReqBO reqBO){
UnionShareOrderSearchBo bo=initUnionShareOrderSearchBo(reqBO);
List<UnionShareOrders> ordersDOList=null;
if(bo.getIdList()!=null&&!bo.getIdList().isEmpty()){
ordersDOList= this.unionShareOrdersMapper.selectListByIds(bo.getIdList());
}else{
Integer uid=null;
if(bo.getUnionType()!=null || bo.getUnionName()!=null){
uid=queryUid(bo);
if(null==uid){
return null;
}
}
ordersDOList=this.unionShareOrdersMapper.selectAllListByUids(bo.getBeginTime(), bo.getEndTime(), uid, bo.getOrderCode());
}
return ordersDOList.isEmpty()?null: queryUnionShareOrderRspBO(ordersDOList);
}
@Override
public UnionShareStatisticsRspBO getStatisticsInfo(UnionShareOrderReqBO bo) {
logger.info("getStatisticsInfo enter,req is {}",bo);
... ...
... ... @@ -26,12 +26,16 @@
<input class="easyui-textbox" id="orderCode" name="orderCode">
</input>
<label>联盟渠道号:</label>
<input class="easyui-textbox" id="unionId" name="unionId">
<label>渠道号:</label>
<input class="easyui-textbox" id="unionType" name="unionType">
</input>
<label>渠道:</label>
<input class="easyui-textbox" id="unionType" name="unionType">
<label>分享人uid:</label>
<input class="easyui-textbox" id="promoteUid" name="promoteUid">
</input>
<label>下单人uid:</label>
<input class="easyui-textbox" id="orderUid" name="orderUid">
</input>
... ... @@ -75,22 +79,12 @@
checkbox: true
}, {
title: "联盟渠道号",
field: "unionId",
width: 200,
align: "center"
}, {
title: "下单时间",
field: "orderTime",
width: 200,
align: "center"
}, {
title: "订单号",
field: "orderCode",
field: "unionType",
width: 200,
align: "center"
}, {
title: "分享用户ID",
field: "uid",
field: "promoteUid",
width: 200,
align: "center"
}, {
... ... @@ -99,6 +93,11 @@
width: 200,
align: "center"
}, {
title: "订单号",
field: "orderCode",
width: 200,
align: "center"
}, {
title: "订单金额",
field: "orderAmount",
width: 200,
... ... @@ -114,18 +113,13 @@
width: 200,
align: "center"
}, {
title: "渠道名称",
field: "unionType",
width: 200,
align: "center"
}, {
title: "渠道号类型",
field: "channelType",
title: "是否新客",
field: "isNew",
width: 200,
align: "center"
}, {
title: "是否新客",
field: "isNew",
title: "下单时间",
field: "orderTime",
width: 200,
align: "center"
}
... ... @@ -176,9 +170,10 @@
}
param.orderCode = $("#orderCode").val(),
param.unionId = $("#unionId").val(),
param.unionType=$("#unionType").val(),
$("#userOrdersTable").myDatagrid("load", param);
param.promoteUid = $("#promoteUid").val(),
param.orderUid = $("#orderUid").val(),
param.unionType=$("#unionType").val(),
$("#userOrdersTable").myDatagrid("load", param);
}
});
... ...