Authored by csgyoho

cps订单管理功能

... ... @@ -19,10 +19,16 @@ public interface UnionShareOrdersMapper {
UnionShareOrders selectByCode(String orderCode);
int selectCountByUids(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("uids") List<Integer> uids);
int selectCountByUids(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("uids") List<Integer> uids,@Param("orderCode")String orderCode);
@MapKey("orderCode")
Map<String,UnionShareOrders> selectListByUids(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("uids") List<Integer> uids,@Param("startIndex") int startIndex, @Param("pageSize") int pageSize);
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);
@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);
int selectCountByCondition(@Param("promoteUid")int promoteUid, @Param("status")String status);
... ...
package com.yoho.unions.dal.model;
/**
* Created by shengguo.cai on 2018/5/15.
*/
public class ShareUserOrderDatailBO {
}
... ...
... ... @@ -53,6 +53,15 @@
where promote_uid = #{promoteUid,jdbcType=INTEGER} and status = #{status,jdbcType=VARCHAR}
limit #{offset}, #{rows}
</select>
<select id="selectListByIds" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from union_share_orders
where id in
<foreach collection="list" open="(" close=")" item="id" separator=",">
#{id}
</foreach>
</select>
<select id="selectOrderCodesByCondition" resultType="java.lang.String" >
select order_code from union_share_orders
where settlement_code = #{settlementCode,jdbcType=VARCHAR}
... ... @@ -189,6 +198,9 @@
#{uid}
</foreach>
</if>
<if test="orderCode != null" >
and order_code = #{orderCode}
</if>
<if test="beginTime != 0" >
and create_time &gt; #{beginTime}
</if>
... ... @@ -196,6 +208,25 @@
and create_time &lt;#{endTime}
</if>
</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>
<if test="orderCode != null" >
and order_code = #{orderCode}
</if>
<if test="beginTime != 0" >
and create_time &gt; #{beginTime}
</if>
<if test="endTime != 0" >
and create_time &lt;#{endTime}
</if>
order BY create_time desc
</select>
<select id="selectListByUids" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from union_share_orders where 1=1
<if test="uids!=null and uids.size()>0">
... ... @@ -204,6 +235,9 @@
#{uid}
</foreach>
</if>
<if test="orderCode != null" >
and order_code = #{orderCode}
</if>
<if test="beginTime != 0" >
and create_time &gt; #{beginTime}
</if>
... ...
... ... @@ -41,7 +41,7 @@
<include refid="Base_Column_List" />
from union_share_user
where uid in
<foreach collection="uids" open="(" close=")" item="uid" separator=",">
<foreach collection="list" open="(" close=")" item="uid" separator=",">
#{uid}
</foreach>
</select>
... ... @@ -91,9 +91,9 @@
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectUids" parameterType="Long">
<select id="selectUids" parameterType="Long" resultType="Integer">
select uid from union_share_user where union_type in
<foreach collection="unionTypes" open="(" close=")" item="unionType" separator=",">
<foreach collection="list" open="(" close=")" item="unionType" separator=",">
#{unionType}
</foreach>
</select>
... ...
package com.yoho.unions.server.service.impl;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.config.ConfigReader;
import com.yoho.core.rabbitmq.YhProducer;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.union.bo.ShareOrderBo;
import com.yoho.service.model.union.bo.ShareSettlementBo;
import com.yoho.service.model.union.bo.ShareUserSettlementInfoBo;
import com.yoho.service.model.union.bo.UnionShareOrderSearchBo;
import com.yoho.service.model.union.request.UnionOrderReqBO;
import com.yoho.service.model.union.request.UnionShareOrderReqBO;
import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO;
import com.yoho.service.model.union.response.PageUnionShareOrderRspBO;
import com.yoho.service.model.union.response.UnionShareOrderRspBO;
... ... @@ -13,6 +19,7 @@ import com.yoho.unions.common.enums.ShareOrdersKeyEnum;
import com.yoho.unions.common.enums.ShareOrdersStatusEnum;
import com.yoho.unions.common.redis.RedisHashCache;
import com.yoho.unions.common.redis.RedisValueCache;
import com.yoho.unions.common.service.IBusinessExportService;
import com.yoho.unions.common.utils.DateUtil;
import com.yoho.unions.common.utils.RandomUtil;
import com.yoho.unions.dal.*;
... ... @@ -37,8 +44,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* Created by mingdan.ge on 2018/5/10.
*/
@Service
public class UnionShareServiceImpl implements IUnionShareService {
public class UnionShareServiceImpl implements IUnionShareService,IBusinessExportService {
private Logger logger = LoggerFactory.getLogger(UnionShareServiceImpl.class);
@Autowired
... ... @@ -95,35 +101,22 @@ public class UnionShareServiceImpl implements IUnionShareService {
@Override
public PageUnionShareOrderRspBO queryUnionShareOrders(UnionShareOrderSearchReqBO reqBO){
logger.info("queryUnionShareOrders param is {}", reqBO);
int beginTime = StringUtils.isBlank(reqBO.getBeginTime()) ? 0 : Integer.parseInt(reqBO.getBeginTime());
int endTime = StringUtils.isBlank(reqBO.getEndTime()) ? 0 : Integer.parseInt(reqBO.getEndTime());
long orderCode = StringUtils.isBlank(reqBO.getOrderCode()) ? 0 : Long.parseLong(reqBO.getOrderCode());
Long unionType = StringUtils.isBlank(reqBO.getUnionId()) ? null :Long.valueOf( reqBO.getUnionId());
String unionName = StringUtils.isBlank(reqBO.getUnionType()) ? null : reqBO.getUnionType();
String channelType=reqBO.getChannelType();
List<String> idList = reqBO.getIdsList();
List<Long> unionTypes=null;
if(unionType!=null || unionName!=null || channelType!=null){
unionTypes=mktMarketingUrlDAO.selectUnionTypes(unionType, unionName, channelType);
if(unionTypes.isEmpty()){
UnionShareOrderSearchBo bo=initUnionShareOrderSearchBo(reqBO);
List<Integer> uids=null;
if(bo.getUnionType()!=null || bo.getUnionName()!=null || bo.getChannelType()!=null){
uids=queryUids(bo);
if(null==uids){
return null;
}
}
List<Integer> uids=unionTypes==null?null:this.unionShareUserMapper.selectUids(unionTypes);
//查询总数
int count = unionShareOrdersMapper.selectCountByUids(beginTime, endTime, uids);
logger.info("userOrdersDAO.selectCount: size is {}", count);
int count = unionShareOrdersMapper.selectCountByUids(bo.getBeginTime(), bo.getEndTime(), uids,bo.getOrderCode());
logger.info("unionShareOrdersMapper.selectCountByUids: size is {}", count);
if (count < 1) {
return null;
}
Map<String,UnionShareOrders> ordersDOMap=this.unionShareOrdersMapper.selectListByUids(beginTime, endTime, uids, reqBO.getStart(), reqBO.getSize());
Map<Long, UserOrderDatailBO> userOrderDatailBOMap = initUserShareOrderDatails(ordersDOMap);
List<UnionShareOrderRspBO> unionOrderRspBOList = new ArrayList<>(ordersDOMap.size());
for (UnionShareOrders orders : ordersDOMap.values()) {
UnionShareOrderRspBO bo=initShareUnionOrderRspBO(orders,userOrderDatailBOMap);
bo.setChannelType(Integer.valueOf(channelType));
unionOrderRspBOList.add(bo);
}
Map<String,UnionShareOrders> ordersDOMap=this.unionShareOrdersMapper.selectListByUids(bo.getBeginTime(), bo.getEndTime(), uids,bo.getOrderCode(), reqBO.getStart(), reqBO.getSize());
List<UnionShareOrderRspBO> unionOrderRspBOList = queryUnionShareOrderRsp(ordersDOMap);
PageUnionShareOrderRspBO pageUnionOrderRspBO = new PageUnionShareOrderRspBO();
pageUnionOrderRspBO.setList(unionOrderRspBOList);
pageUnionOrderRspBO.setTotal(count);
... ... @@ -131,19 +124,55 @@ public class UnionShareServiceImpl implements IUnionShareService {
pageUnionOrderRspBO.setPage(reqBO.getPage());
return pageUnionOrderRspBO;
}
private UnionShareOrderRspBO initShareUnionOrderRspBO(UnionShareOrders orders,Map<Long, UserOrderDatailBO> userOrderDatailBOMap){
private List<Integer> queryUids(UnionShareOrderSearchBo bo){
List<Integer> uids=null;
List<Long> unionTypes=mktMarketingUrlDAO.selectUnionTypes(bo.getUnionType(), bo.getUnionName(), bo.getChannelType());
if(unionTypes.isEmpty()){
return null;
}
uids=this.unionShareUserMapper.selectUids(unionTypes);
if(uids.isEmpty()){
return null;
}
return uids;
}
private UnionShareOrderSearchBo initUnionShareOrderSearchBo(UnionShareOrderSearchReqBO reqBO){
UnionShareOrderSearchBo bo=new UnionShareOrderSearchBo();
bo.setBeginTime(StringUtils.isBlank(reqBO.getBeginTime()) ? 0 : Integer.parseInt(reqBO.getBeginTime()));
bo.setEndTime(StringUtils.isBlank(reqBO.getEndTime()) ? 0 : Integer.parseInt(reqBO.getEndTime()));
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;
}
private List<UnionShareOrderRspBO> queryUnionShareOrderRsp(Map<String,UnionShareOrders> ordersDOMap){
List<UnionShareOrderRspBO> unionOrderRspBOList = new ArrayList<>(ordersDOMap.size());
Map<String, ShareUserOrderDatailBO> userOrderDatailBOMap = initUserShareOrderDatails(ordersDOMap);
for (UnionShareOrders orders : ordersDOMap.values()) {
UnionShareOrderRspBO bo=initShareUnionOrderRspBO(orders,userOrderDatailBOMap);
unionOrderRspBOList.add(bo);
}
return unionOrderRspBOList;
}
private UnionShareOrderRspBO initShareUnionOrderRspBO(UnionShareOrders orders,Map<String, ShareUserOrderDatailBO> userOrderDatailBOMap){
UnionShareOrderRspBO orderRspBO=new UnionShareOrderRspBO();
orderRspBO.setOrderAmount(orders.getAmount());
orderRspBO.setOrderStatus(OrderStatusEnum.getNameByCode(orders.getStatus()));
Byte isNew=orders.getIsNew();
orderRspBO.setIsNew(isNew==null||isNew.equals(2)?"N":"Y");
orderRspBO.setUid(orders.getPromoteUid());
orderRspBO.setOrderCode(Long.parseLong(orders.getOrderCode()));
orderRspBO.setOrderCode(orders.getOrderCode());
orderRspBO.setId(orders.getId());
orderRspBO.setOrderTime(DateUtil.long2DateStr(Long.valueOf(orders.getCreateTime()) * Long.valueOf(1000), "yyyy-MM-dd HH:mm:ss"));
UserOrderDatailBO userOrderDatailBO = userOrderDatailBOMap.get(orders.getOrderCode());
orderRspBO.setUnionId(userOrderDatailBO.getUnionId());
ShareUserOrderDatailBO userOrderDatailBO = userOrderDatailBOMap.get(orders.getOrderCode());
orderRspBO.setUnionId(userOrderDatailBO.getUnionType());
orderRspBO.setUnionType(userOrderDatailBO.getUnionName());
orderRspBO.setChannelType(userOrderDatailBO.getChannelType());
return orderRspBO;
}
... ... @@ -154,13 +183,13 @@ public class UnionShareServiceImpl implements IUnionShareService {
}
return uids;
}
private Map<Long, UserOrderDatailBO> initUserShareOrderDatails( Map<String,UnionShareOrders> ordersDOMap){
Map<Long, UserOrderDatailBO> userOrderDatailBOMap = new HashMap<>(ordersDOMap.size());
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));
for (UnionShareOrders userOrders : ordersDOMap.values()) {
String unionType=userMap.get(userOrders.getPromoteUid()).getUnionType();
UserOrderDatailBO userOrderDatailBO = new UserOrderDatailBO();
userOrderDatailBO.setUnionId(unionType);
ShareUserOrderDatailBO userOrderDatailBO = new ShareUserOrderDatailBO();
userOrderDatailBO.setUnionType(unionType);
MktMarketingUrl mktMarketingUrl = redisValueCache.get("yh:union:uniontype:" + unionType, MktMarketingUrl.class);
if (mktMarketingUrl == null) {
mktMarketingUrl = mktMarketingUrlDAO.selectByPrimaryKey(Long.valueOf(unionType));
... ... @@ -168,8 +197,9 @@ public class UnionShareServiceImpl implements IUnionShareService {
}
if (mktMarketingUrl != null) {
userOrderDatailBO.setUnionName(mktMarketingUrl.getName());
userOrderDatailBO.setChannelType(mktMarketingUrl.getChannelType());
}
userOrderDatailBO.setOrderCode(Long.valueOf(userOrders.getOrderCode()));
userOrderDatailBO.setOrderCode(userOrders.getOrderCode());
userOrderDatailBOMap.put(userOrderDatailBO.getOrderCode(),userOrderDatailBO);
}
return userOrderDatailBOMap;
... ... @@ -517,4 +547,43 @@ public class UnionShareServiceImpl implements IUnionShareService {
redisHashCache.delete(ShareOrdersKeyEnum.USER_SETTLEMENT.getPreKey(),uid);
}
@Override
public Class getDataClass() {
return UnionShareOrderRspBO.class;
}
@Override
public List<? extends Object> batchExport(String confStr) {
try {
UnionShareOrderSearchReqBO request = JSONObject.parseObject(confStr, UnionShareOrderSearchReqBO.class);
List<UnionShareOrderRspBO> unionOrderRspBOList = queryUnionShareOrderRspBOForExport(request);
if (CollectionUtils.isEmpty(unionOrderRspBOList)) {
throw new ServiceException(400, "没有要导出的数据");
}
return unionOrderRspBOList;
} catch (JSONException e) {
logger.warn("parse confStr error: confStr {}, e {}", confStr, e);
throw new ServiceException(400, "传入数据格式错误");
} catch (com.yoho.error.exception.ServiceException e) {
logger.warn("make url error params is confStr {}, e {}", confStr, e);
throw new ServiceException(e.getCode(), e.getErrorMessage());
}
}
private List<UnionShareOrderRspBO> queryUnionShareOrderRspBOForExport(UnionShareOrderSearchReqBO reqBO){
UnionShareOrderSearchBo bo=initUnionShareOrderSearchBo(reqBO);
Map<String,UnionShareOrders> ordersDOMap=null;
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){
return null;
}
}
ordersDOMap=this.unionShareOrdersMapper.selectAllListByUids(bo.getBeginTime(), bo.getEndTime(), uids, bo.getOrderCode());
}
return ordersDOMap.isEmpty()?null:queryUnionShareOrderRsp(ordersDOMap);
}
}
... ...
... ... @@ -118,6 +118,9 @@ public class UserOrdersServiceImpl implements IUserOrdersService,IBusinessExport
return null;
}
List<UserOrders> userOrdersList = userOrdersDAO.selectUserOrderList(beginTime, endTime, String.valueOf(orderCode), null==unionType?null:unionType.toString(), idList, reqBO.getStart(), reqBO.getSize());
if(userOrdersList.isEmpty()){
return null;
}
List<UserOrderDatailBO> userOrderDatailBOList = initUserOrderDatails(userOrdersList);
Map<Long, UserOrderDatailBO> userOrderDatailBOMap = Maps.uniqueIndex(userOrderDatailBOList, new Function<UserOrderDatailBO, Long>() {
@Override
... ...
... ... @@ -118,8 +118,8 @@
value-type="com.yoho.unions.common.service.IBusinessExportService">
<entry key="channelUserServiceImpl" value-ref="channelUserServiceImpl"/>
<entry key="userOrdersServiceImpl" value-ref="userOrdersServiceImpl"/>
<entry key="unionShareServiceImpl" value-ref="unionShareServiceImpl"/>
<entry key="userRegisterBuyInfoserviceImpl" value-ref="userRegisterBuyInfoserviceImpl"/>
</util:map>
</beans>
... ...
... ... @@ -9,7 +9,7 @@
<body class="easyui-layout" fit="true">
<div region="north" style="padding-bottom: 35px; height: auto;">
<script>
document.write(addHead('市场报表管理', '联盟订单管理'));
document.write(addHead('市场报表管理', 'CPS订单管理'));
</script>
<form id="searchForm" method="post" accept-charset="utf-8">
<div style="margin-left: 10px;margin-top: 10px">
... ... @@ -73,86 +73,53 @@
title: "ID",
field: "id",
idField:"id",
width: 170,
width: 200,
align: "center",
checkbox: true
}, {
title: "联盟用户ID",
field: "unionId",
width: 170,
width: 200,
align: "center"
}, {
title: "下单时间",
field: "orderTime",
width: 170,
width: 200,
align: "center"
}, {
title: "订单号",
field: "orderCode",
width: 170,
width: 200,
align: "center"
}, {
title: "订单用户ID",
field: "uid",
width: 170,
width: 200,
align: "center"
}, {
title: "订单金额",
field: "orderAmount",
width: 170,
align: "center"
}, {
title: "优惠券金额",
field: "couponAmount",
width: 170,
align: "center"
}, {
title: "YOHO币",
field: "yohoCoinNum",
width: 170,
align: "center"
}, {
title: "运费",
field: "shipmentAmount",
width: 90,
align: "center"
}, {
title: "实付金额",
field: "realPayAmount",
width: 170,
width: 200,
align: "center"
}, {
title: "订单状态",
field: "orderStatus",
width: 170,
width: 200,
align: "center"
}, {
title: "渠道",
field: "unionType",
width: 170,
width: 200,
align: "center"
}, {
title: "渠道号类型",
field: "channelType",
width: 120,
align: "center",
formatter: function (value, rowData, rowIndex) {
return value==null?"":value==0?"机构":"个人";
}
}, {
title: "附加信息",
field: "exetInfmoation",
width: 140,
align: "center"
}, {
title: "支付方式",
field: "payChannel",
width: 170,
width: 200,
align: "center"
}, {
title: "是否新客",
field: "isNew",
width: 170,
width: 200,
align: "center"
}
]],
... ... @@ -164,13 +131,7 @@
singleSelect: false,
checkOnSelect: false,
onLoadSuccess: function (data) {
$(this).myDatagrid("getPanel").find("a[role='delete']").linkbutton({
iconCls: "icon-more",
onClick: function () {
deleteBlack($(this).attr("dataId"));
}
});
resetSelectedCheckBox(data);
}
});
$("#channelType").combobox({
... ... @@ -180,6 +141,17 @@
});
$("#channelType").combobox("clear");
function resetSelectedCheckBox(data){
$("input[type='checkbox'][name='id']").each(function () {
var cb=$(this);
$.each(checkedItems,function(index,value){
if(value==cb.val()){
cb.attr("checked",true);
return false;
}
});
});
}
function getParam(table) {
var paramsArray = $("#"+table+"").serializeArray();
var params = {};
... ... @@ -192,6 +164,7 @@
$("#searchBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
checkedItems=[];
var param = {};
if ($("#beginTime").datetimebox('getValue')!='')
{
... ... @@ -265,13 +238,13 @@
return;
}
var params = {"ids": checkedItems.toString() };
window.open(contextPath + "/batch/export.do?type=userOrdersServiceImpl&queryConf=" + JSON.stringify(params));
window.open(contextPath + "/batch/export.do?type=unionShareServiceImpl&queryConf=" + JSON.stringify(params));
}
});
$("#exportAllButton").linkbutton({
onClick : function() {
window.open(contextPath + "/batch/export.do?type=userOrdersServiceImpl&queryConf=" + JSON.stringify(getParams()));
window.open(contextPath + "/batch/export.do?type=unionShareServiceImpl&queryConf=" + JSON.stringify(getParams()));
}
});
... ...