Authored by zhaoqing

Merge branch 'dev_180508_联盟红人推广' of http://git.yoho.cn/yoho30/yohobuy-union into dev_180508_联盟红人推广

Conflicts:
	server/src/main/java/com/yoho/unions/server/service/impl/UnionShareServiceImpl.java
Showing 24 changed files with 759 additions and 165 deletions
... ... @@ -13,5 +13,7 @@ public interface IMktMarketingUrlDAO {
MktMarketingUrl selectByName(String name);
List<Long> listUnionTypes(@Param("unionType")String unionType,@Param("name")String name,@Param("channelType")String channelType);
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);
}
\ No newline at end of file
... ...
... ... @@ -13,7 +13,7 @@ public interface IOrdersMapper {
List<Orders> selectByOrderCode(@Param("orderCode") long orderCode);
List<Orders> selectByOrderCodeList(@Param("list") List<Long> list);
List<Orders> selectByOrderCodeList(@Param("list") Long[] list);
/**
* 查询某用户一段时间以来的已交寄订单
... ...
... ... @@ -35,7 +35,7 @@ public interface IUserOrdersDAO {
*/
List<UserOrders> getExistOrderCodes(@Param("list") Set<String> list);
int selectCount(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("orderCode") String orderCode,@Param("unionIds") List<Long> unionIds,@Param("idList") List<String> idList);
int selectCount(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("orderCode") String orderCode,@Param("unionId") String unionId,@Param("idList") List<String> idList);
List<UserOrders> selectUserOrderList(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("orderCode") String orderCode,@Param("unionIds") List<Long> unionIds,@Param("idList") List<String> idList,@Param("startIndex") int startIndex, @Param("pageSize") int pageSize);
List<UserOrders> selectUserOrderList(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("orderCode") String orderCode,@Param("unionId") String unionId,@Param("idList") List<String> idList,@Param("startIndex") int startIndex, @Param("pageSize") int pageSize);
}
\ No newline at end of file
... ...
... ... @@ -5,11 +5,10 @@ import com.yoho.unions.dal.model.OrdersAccessOry;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
public interface OrdersAccessOryMapper {
OrdersAccessOry selectByPrimaryKey(Long orderCode);
List<OrdersAccessOry> selectByOrderCodeList(@Param("list") List<Long> orderCode);
List<OrdersAccessOry> selectByOrderCodeList(@Param("list") Long[] orderCode);
}
\ No newline at end of file
... ...
... ... @@ -5,12 +5,11 @@ import com.yoho.unions.dal.model.OrdersCoupons;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
public interface OrdersCouponsMapper {
OrdersCoupons selectByOrderCode(Long orderCode);
List<OrdersCoupons> selectByOrderCodeList(@Param("list") List<Long> orderCode);
List<OrdersCoupons> selectByOrderCodeList(@Param("list") Long[] orderCode);
}
\ No newline at end of file
... ...
... ... @@ -2,10 +2,12 @@ package com.yoho.unions.dal;
import com.yoho.service.model.union.request.UnionShareOrderReqBO;
import com.yoho.unions.dal.model.UnionShareOrders;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
public interface UnionShareOrdersMapper {
int deleteByPrimaryKey(Integer id);
... ... @@ -18,6 +20,17 @@ 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);
@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);
@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);
BigDecimal selectAmountByStatus(@Param("promoteUid")int promoteUid, @Param("statusList")List<String> statusList);
... ...
package com.yoho.unions.dal;
import com.yoho.unions.dal.model.UnionShareUser;
import org.apache.ibatis.annotations.MapKey;
import java.util.List;
import java.util.Map;
public interface UnionShareUserMapper {
int deleteByPrimaryKey(Integer id);
... ... @@ -18,4 +22,9 @@ public interface UnionShareUserMapper {
int updateByPrimaryKeySelective(UnionShareUser record);
int updateByPrimaryKey(UnionShareUser record);
List<Integer> selectUids(List<Long> unionTypes);
@MapKey("uid")
Map<Integer,UnionShareUser> selectByUids(List<Integer> uids);
}
\ No newline at end of file
... ...
package com.yoho.unions.dal.model;
/**
* Created by shengguo.cai on 2018/5/15.
*/
public class ShareUserOrderDatailBO{
private Integer channelType;
private String unionType;
private String unionName;
private String orderCode;
public Integer getChannelType() {
return channelType;
}
public void setChannelType(Integer channelType) {
this.channelType = channelType;
}
public String getUnionType() {
return unionType;
}
public void setUnionType(String unionType) {
this.unionType = unionType;
}
public String getUnionName() {
return unionName;
}
public void setUnionName(String unionName) {
this.unionName = unionName;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
}
... ...
... ... @@ -13,16 +13,6 @@ public class UserOrderDatailBO extends BaseBO {
private String unionName;
private Integer channelType;
public Integer getChannelType() {
return channelType;
}
public void setChannelType(Integer channelType) {
this.channelType = channelType;
}
public Long getOrderCode() {
return orderCode;
}
... ...
... ... @@ -38,7 +38,7 @@
delete from mkt_marketing_url
where union_type = #{unionType,jdbcType=BIGINT}
</delete>
<select id="listUnionTypes" resultType="long">
<select id="selectUnionTypes" resultType="long">
select union_type from mkt_marketing_url where
1=1
<if test="unionType!=null">
... ... @@ -51,4 +51,14 @@
and channel_type=#{channelType}
</if>
</select>
<select id="selectByNameAndUnionType" resultType="Long">
select union_type from mkt_marketing_url where 1=1
<if test="unionType!=null">
and union_type=#{unionType}
</if>
<if test="name!=null">
and name=#{name}
</if>
limit 1
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -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}
... ... @@ -181,6 +190,63 @@
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCountByUids" 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>
<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>
</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">
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
limit #{startIndex},#{pageSize}
</select>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
update union_share_orders
set order_code = #{orderCode,jdbcType=VARCHAR},
... ...
... ... @@ -352,11 +352,8 @@
<if test="orderCode != 0" >
and order_code = #{orderCode}
</if>
<if test="unionIds != null and unionIds.size>0" >
and uid in
<foreach item="item" index="index" collection="unionIds" open="(" separator="," close=")">
#{item}
</foreach>
<if test="unionId != null" >
and uid = #{unionId}
</if>
<if test="beginTime != 0" >
and create_time &gt; #{beginTime}
... ... @@ -380,11 +377,8 @@
<if test="orderCode != 0" >
and order_code = #{orderCode}
</if>
<if test="unionIds != null and unionIds.size>0" >
and uid in
<foreach item="item" index="index" collection="unionIds" open="(" separator="," close=")">
#{item}
</foreach>
<if test="unionId != null" >
and uid = #{unionId}
</if>
<if test="beginTime != 0" >
and create_time &gt; #{beginTime}
... ...
... ... @@ -36,6 +36,15 @@
values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}, #{unionType,jdbcType=VARCHAR},
#{updateTime,jdbcType=INTEGER})
</insert>
<select id="selectByUids" parameterType="Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from union_share_user
where uid in
<foreach collection="list" open="(" close=")" item="uid" separator=",">
#{uid}
</foreach>
</select>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareUser" >
insert into union_share_user
<trim prefix="(" suffix=")" suffixOverrides="," >
... ... @@ -82,6 +91,12 @@
</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>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionShareUser" >
update union_share_user
set uid = #{uid,jdbcType=INTEGER},
... ...
... ... @@ -5,7 +5,7 @@
<parent>
<groupId>com.yoho</groupId>
<artifactId>parent</artifactId>
<version>1.3.8-SNAPSHOT</version>
<version>1.3.9-SNAPSHOT</version>
</parent>
<groupId>com.yoho.dsf</groupId>
<artifactId>yoho-unions</artifactId>
... ...
... ... @@ -31,9 +31,13 @@ public class UnionSettleUpdateConsumer implements YhConsumer {
}
List<Object> list = JsonUtil.jsonToObject(o.toString(), List.class);
list.forEach(l->{
try {
ShareSettlementBo bo = JsonUtil.jsonToObject(l.toString(), ShareSettlementBo.class);
//TODO 提现结算单状态变更
unionShareService.updateSettlementStatus(bo);
} catch (Exception e) {
logger.warn("UnionSettleUpdateConsumer,handleMessage fail! obj is {}, e {}",l,e.getMessage());
}
});
} catch (Exception e) {
... ...
... ... @@ -32,9 +32,13 @@ public class UnionShareOrderConsumer implements YhConsumer {
List<Object> list = JsonUtil.jsonToObject(o.toString(), List.class);
list.forEach(l->{
try {
ShareOrderBo bo = JsonUtil.jsonToObject(l.toString(), ShareOrderBo.class);
//TODO 订单插入或更新
unionShareService.saveOrUpdateOrder(bo);
} catch (Exception e) {
logger.warn("UnionShareOrderConsumer,handleMessage fail! bo is {}, e {}",l,e.getMessage());
}
});
} catch (Exception e) {
logger.warn("UnionShareOrderConsumer,handleMessage fail! obj is {}, e {}",o,e.getMessage());
... ...
package com.yoho.unions.server.restapi;
import com.alibaba.fastjson.JSONObject;
import com.yoho.service.model.union.request.ActiveUnionRequestBO;
import com.yoho.service.model.union.request.AddUnionRequestBO;
import com.yoho.service.model.union.request.ClickUnionRequestBO;
import com.yoho.service.model.union.request.UnionOrderReqBO;
import com.yoho.service.model.union.response.ActiveUnionResponseBO;
import com.yoho.service.model.union.response.PageUnionOrderRspBO;
import com.yoho.service.model.union.response.UnionResponse;
import com.yoho.service.model.union.response.UnionResponseBO;
... ... @@ -128,4 +124,5 @@ public class UnionRest {
return new ApiResponse.ApiResponseBuilder().code(500).message("失败").build();
}
}
}
... ...
... ... @@ -3,7 +3,10 @@ package com.yoho.unions.server.restapi;
import com.yoho.service.model.union.bo.ShareOrderBo;
import com.yoho.service.model.union.bo.ShareUserSettlementInfoBo;
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.UnionResponse;
import com.yoho.unions.common.ApiResponse;
import com.yoho.unions.dal.model.UnionShareOrders;
import com.yoho.unions.dal.model.UnionShareSettlement;
import com.yoho.unions.dal.model.UnionShareUser;
... ... @@ -48,6 +51,22 @@ public class UnionShareRest {
return new UnionResponse(200, "addSettlement success", result);
}
@RequestMapping("/queryUnionShareOrders")
@ResponseBody
public ApiResponse queryUnionShareOrders(UnionShareOrderSearchReqBO reqBO) {
log.info("enter queryUnionShareOrders. param UnionShareOrderReqBO={}", reqBO);
if (reqBO == null) {
return new ApiResponse.ApiResponseBuilder().code(500).message("缺少参数").build();
}
try {
PageUnionShareOrderRspBO unionOrderRspBO = unionShareService.queryUnionShareOrders(reqBO);
return new ApiResponse.ApiResponseBuilder().code(200).message("查询共享联盟订单").data(unionOrderRspBO).build();
} catch (Exception e) {
log.warn("queryUnionShareOrders error exception is {}", e);
return new ApiResponse.ApiResponseBuilder().code(500).message("失败").build();
}
}
/**
* 用户登录时获取对应的渠道号
* Created by qing.zhao on 2018/5/15
... ... @@ -134,7 +153,7 @@ public class UnionShareRest {
* 订单列表
* //tab1表示1、全部订单;2、有效订单;3、无效订单 tab2表示1、已付款;2、待结算;3、结算中
* Created by qing.zhao on 2018/5/15
* @param unionShareOrderReqBO
* @param unionShareOrderReqBO csg
* @return
*/
@RequestMapping("/queryOrderList")
... ...
... ... @@ -4,13 +4,14 @@ 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.request.UnionShareOrderReqBO;
import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO;
import com.yoho.service.model.union.response.PageUnionShareOrderRspBO;
import com.yoho.unions.dal.model.UnionShareOrders;
import com.yoho.unions.dal.model.UnionShareSettlement;
import com.yoho.unions.dal.model.UnionShareUser;
import java.util.List;
import java.math.BigDecimal;
import java.util.List;
/**
* 联盟红人推广返利
... ... @@ -23,6 +24,7 @@ public interface IUnionShareService {
*/
void saveOrUpdateOrder(ShareOrderBo bo);
PageUnionShareOrderRspBO queryUnionShareOrders(UnionShareOrderSearchReqBO reqBO);
/**
* 提现结算单状态变更
* */
... ...
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.*;
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;
import com.yoho.unions.common.enums.OrderStatusEnum;
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.convert.BeanConvert;
import com.yoho.unions.convert.Convert;
import com.yoho.unions.dal.UnionShareOrdersMapper;
import com.yoho.unions.dal.UnionShareOrdersProductMapper;
import com.yoho.unions.dal.UnionShareSettlementMapper;
import com.yoho.unions.dal.UnionShareUserMapper;
import com.yoho.unions.dal.*;
import com.yoho.unions.dal.model.*;
import com.yoho.unions.server.service.IUnionShareService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -30,13 +38,13 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
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
... ... @@ -47,10 +55,12 @@ public class UnionShareServiceImpl implements IUnionShareService {
private UnionShareSettlementMapper unionShareSettlementMapper;
@Autowired
private UnionShareUserMapper unionShareUserMapper;
@Autowired
IMktMarketingUrlDAO mktMarketingUrlDAO;
@Resource
RedisValueCache redisValueCache;
@Resource( name = "yhProducer")
private YhProducer yhProducer;
@Resource(name = "core-config-reader")
private ConfigReader configReader;
... ... @@ -88,10 +98,116 @@ public class UnionShareServiceImpl implements IUnionShareService {
result.setCanSettlement(canSettlement);
result.setHistorySettlementAmount(historySettlementAmount);
result.setSettlementAmount(settlementAmount);
logger.info("getUserSettleMentInfo enter,uid is {},result is {}",uid,result);
logger.info("getUserSettleMentInfo end,uid is {},result is {}",uid,result);
return result;
}
@Override
public PageUnionShareOrderRspBO queryUnionShareOrders(UnionShareOrderSearchReqBO reqBO){
logger.info("queryUnionShareOrders param is {}", reqBO);
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;
}
}
//查询总数
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(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);
pageUnionOrderRspBO.setSize(reqBO.getSize());
pageUnionOrderRspBO.setPage(reqBO.getPage());
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()){
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(orders.getOrderCode());
orderRspBO.setId(orders.getId());
orderRspBO.setOrderTime(DateUtil.long2DateStr(Long.valueOf(orders.getCreateTime()) * Long.valueOf(1000), "yyyy-MM-dd HH:mm:ss"));
ShareUserOrderDatailBO userOrderDatailBO = userOrderDatailBOMap.get(orders.getOrderCode());
orderRspBO.setUnionId(userOrderDatailBO.getUnionType());
orderRspBO.setUnionType(userOrderDatailBO.getUnionName());
orderRspBO.setChannelType(userOrderDatailBO.getChannelType());
return orderRspBO;
}
private List<Integer> getUids(Map<String,UnionShareOrders> ordersDOMap){
List<Integer> uids=new ArrayList<>(ordersDOMap.size());
for(UnionShareOrders order:ordersDOMap.values()){
uids.add(order.getPromoteUid());
}
return uids;
}
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();
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));
redisValueCache.set("yh:union:uniontype:" + unionType, mktMarketingUrl, 1, TimeUnit.HOURS);
}
if (mktMarketingUrl != null) {
userOrderDatailBO.setUnionName(mktMarketingUrl.getName());
userOrderDatailBO.setChannelType(mktMarketingUrl.getChannelType());
}
userOrderDatailBO.setOrderCode(userOrders.getOrderCode());
userOrderDatailBOMap.put(userOrderDatailBO.getOrderCode(),userOrderDatailBO);
}
return userOrderDatailBOMap;
}
/**
* 用户登录时获取对应的渠道号
* @param uid
... ... @@ -113,7 +229,7 @@ public class UnionShareServiceImpl implements IUnionShareService {
unionShareUser.setShareId(configReader.getString(UNION_SHAREID, ""));
unionShareUser.setUrl(configReader.getString(UNION_URL, ""));
//设置缓存
addToRedis(ShareOrdersKeyEnum.UNION_TYPE,uid,unionShareUser,key);
addToRedis(ShareOrdersKeyEnum.UNION_TYPE, uid, unionShareUser, key);
return unionShareUser;
}
... ... @@ -212,18 +328,22 @@ public class UnionShareServiceImpl implements IUnionShareService {
//判断是否可以进行状态变更
if (!checkOrderStatusChangePass(unionShareOrders.getStatus(), bo.getStatus())) {
//订单状态不可变更
logger.info("saveOrUpdateOrder end,status can not be change,oldStatus is {} ,req is {}",unionShareOrders.getStatus(),bo);
return;
}
int result = unionShareOrdersMapper.updateStatusById(unionShareOrders.getId(), unionShareOrders.getStatus(), bo.getStatus(), DateUtil.getCurrentTimeSecond());
if (result == 0) {
logger.info("saveOrUpdateOrder enter,update nothing,req is {}",bo);
//没有更新到数据,应该有并发更新事件,查询新的再试一下
UnionShareOrders unionShareOrdersNew = unionShareOrdersMapper.selectByCode(bo.getOrderCode());
if (unionShareOrdersNew == null) {
logger.info("saveOrUpdateOrder end,can not find the orderCode,req is {}",bo);
//查不到数据,不该出现的情况,目前没有硬删数据的途径
return;
}
if (!checkOrderStatusChangePass(unionShareOrdersNew.getStatus(), bo.getStatus())) {
//订单状态不可变更
logger.info("saveOrUpdateOrder end,Second try,status can not be change,oldStatus is {} ,req is {}",unionShareOrdersNew.getStatus(),bo);
return;
}
unionShareOrdersMapper.updateStatusById(unionShareOrdersNew.getId(), unionShareOrdersNew.getStatus(), bo.getStatus(), DateUtil.getCurrentTimeSecond());
... ... @@ -239,13 +359,15 @@ public class UnionShareServiceImpl implements IUnionShareService {
logger.info("insertOrder,req is {}",bo);
//检查参数
if (!checkParam(bo)) {
//缺少参数 todo logger
//缺少参数
logger.warn("insertOrder end,param is invaild,req is {}",bo);
return;
}
//检查状态
if (!canInsertStatus(bo.getStatus())) {
//该状态数据不可插入 todo logger
//该状态数据不可插入
logger.warn("insertOrder end,status can not be change,req is {}",bo);
return;
}
//新增订单信息
... ... @@ -271,10 +393,14 @@ public class UnionShareServiceImpl implements IUnionShareService {
unionShareOrdersMapper.insertSelective(insertReq);
//新增订单商品信息
bo.getProductList().forEach(p->{
try {
UnionShareOrdersProduct insertPro = new UnionShareOrdersProduct();
BeanUtils.copyProperties(p, insertPro);
insertPro.setOrderCode(bo.getOrderCode());
unionShareOrdersProductMapper.insertSelective(insertPro);
} catch (BeansException e) {
logger.info("insertOrder product error,orderCode is {},product is {}",bo.getOrderCode(), p);
}
});
logger.info("insertOrder end,req is {}",bo);
}
... ... @@ -325,11 +451,13 @@ public class UnionShareServiceImpl implements IUnionShareService {
int count = unionShareUserMapper.selectCountByUid(uid);
if (count == 0) {
//不是特邀用户
logger.info("addSettlement end,can not find unionType,uid is {}",uid);
return null;
}
//查询是否有处理中的提现
if (hasSettlement(uid)) {
//有处理中的提现单,不可提现
logger.info("addSettlement end,hasSettlement,uid is {}",uid);
return null;
}
... ... @@ -337,10 +465,12 @@ public class UnionShareServiceImpl implements IUnionShareService {
int orderCount = unionShareOrdersMapper.selectCountByCondition(uid,ShareOrdersStatusEnum.CAN_SETTLE.getCode());
if (orderCount == 0 ) {
//没有可以提现的订单
logger.info("addSettlement end,has not remaining settlement,uid is {}",uid);
return null;
}
//todo 生成取现单,绑定订单,考虑是否异步操作
BigDecimal amount = relateSettlementAndOrder(uid);
logger.info("addSettlement end,remaining settlement is {},uid is {}",amount,uid);
return amount;
}
... ... @@ -392,7 +522,7 @@ public class UnionShareServiceImpl implements IUnionShareService {
return cacheResult;
}
int count = unionShareSettlementMapper.selectCountByUid(uid,(byte) 1);//是否打款成功:1-处理中,2-已打款
logger.info("hasSettlement ,uid is {},result is {},count is {}",uid,count);
logger.info("hasSettlement ,uid is {},count is {}",uid,count);
if (count > 0) {
addToRedis(ShareOrdersKeyEnum.USER_SETTLEMENT,uid,true,type);
return true;
... ... @@ -429,17 +559,22 @@ public class UnionShareServiceImpl implements IUnionShareService {
* */
public BigDecimal relateSettlementAndOrder(int uid) {
logger.info("relateSettlementAndOrder enter,uid is {}",uid);
//生成提现编号
String settlementCode = createSettlementCode();
logger.info("relateSettlementAndOrder,uid is {},settlementCode is {}",uid,settlementCode);
//更新订单状态,由可结算变为打款中
int updateTime = DateUtil.getCurrentTimeSecond();
int count=unionShareOrdersMapper.updateStatusByUid(uid,settlementCode, ShareOrdersStatusEnum.CAN_SETTLE.getCode(), ShareOrdersStatusEnum.SETTLE.getCode(), updateTime);
if (count == 0) {
logger.info("relateSettlementAndOrder end,uid is {},settlementCode is {},There are no available orders.",uid,settlementCode);
return null;
}
//计算提现金额
BigDecimal totalAmount=unionShareOrdersMapper.selectAmountBySettleCode(uid, settlementCode);
logger.info("relateSettlementAndOrder,uid is {},settlementCode is {},totalAmount is {}",uid,settlementCode,totalAmount);
//生成提现单
UnionShareSettlement insertReq = new UnionShareSettlement();
... ... @@ -451,7 +586,8 @@ public class UnionShareServiceImpl implements IUnionShareService {
insertReq.setStatus((byte)1);//是否打款成功:1-处理中,2-已打款
int num=unionShareSettlementMapper.insertSelective(insertReq);
if (num < 1) {
//todo 插入失败
//插入失败
logger.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},insert nothing.",uid,settlementCode,totalAmount);
}
Set<String> orderCodes = new HashSet<>();
... ... @@ -466,6 +602,8 @@ public class UnionShareServiceImpl implements IUnionShareService {
orderCodes.addAll(periodOrders);
}
if (orderCodes.size() == 0) {
//不该查不到订单
logger.warn("relateSettlementAndOrder end,uid is {},settlementCode is {},totalAmount is {},can not find orders.",uid,settlementCode,totalAmount);
return null;
}
... ... @@ -477,6 +615,7 @@ public class UnionShareServiceImpl implements IUnionShareService {
ShareSettlementBo bo = new ShareSettlementBo();
BeanUtils.copyProperties(insertReq,bo);
bo.setOrderCodes(orderCodes);
logger.info("relateSettlementAndOrder,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
yhProducer.send(SETTLEMENT_TOPIC, bo);
return totalAmount;
}
... ... @@ -532,4 +671,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);
}
}
... ...
... ... @@ -26,7 +26,10 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
... ... @@ -55,41 +58,8 @@ public class UserOrdersServiceImpl implements IUserOrdersService,IBusinessExport
@Resource
RedisValueCache redisValueCache;
public PageUnionOrderRspBO queryUnionOrders(UnionOrderReqBO reqBO) {
logger.info("queryUnionOrders param is {}", reqBO);
int beginTime = StringUtils.isBlank(reqBO.getBeginTime()) ? 0 : Integer.valueOf(reqBO.getBeginTime());
int endTime = StringUtils.isBlank(reqBO.getEndTime()) ? 0 : Integer.valueOf(reqBO.getEndTime());
long orderCode = StringUtils.isBlank(reqBO.getOrderCode()) ? 0 : Long.valueOf(reqBO.getOrderCode());
String unionId = StringUtils.isBlank(reqBO.getUnionId()) ? null : reqBO.getUnionId();
String unionType = StringUtils.isBlank(reqBO.getUnionType()) ? null : reqBO.getUnionType();
String channelType=StringUtils.isBlank(reqBO.getChannelType()) ? null : reqBO.getChannelType();
List<String> idList = new ArrayList<>();
if (StringUtils.isNotBlank(reqBO.getIds())) {
String[] ids = StringUtils.isBlank(reqBO.getIds()) ? null : reqBO.getIds().split(",");
idList = Arrays.asList(ids);
}
List<Long> unionTypes=null;
if(unionId!=null||unionType!=null||channelType!=null){
unionTypes=this.mktMarketingUrlDAO.listUnionTypes(unionId,unionType,channelType);
if (unionTypes.isEmpty()) {
return null;
}
}
//查询总数
int count = userOrdersDAO.selectCount(beginTime, endTime, String.valueOf(orderCode), unionTypes, idList);
logger.info("userOrdersDAO.selectCount: size is {}", count);
List<UserOrders> userOrdersList = new ArrayList<>();
List<UnionOrderRspBO> unionOrderRspBOList = new ArrayList<>();
if (count < 1) {
return null;
}
if (count > 0) {
userOrdersList = userOrdersDAO.selectUserOrderList(beginTime, endTime, String.valueOf(orderCode), unionTypes, idList, reqBO.getStart(), reqBO.getSize());
}
List<OrdersDetailBO> ordersDetailBOList = new ArrayList<>();
List<Long> orderCodeList = new ArrayList<>();
List<UserOrderDatailBO> userOrderDatailBOList = new ArrayList<>();
private List<UserOrderDatailBO> initUserOrderDatails(List<UserOrders> userOrdersList){
List<UserOrderDatailBO> userOrderDatailBOList = new ArrayList<>(userOrdersList.size());
for (UserOrders userOrders : userOrdersList) {
//根据查询出来的uid,ordercode,查询ERP_ORDERS.Orders
UserOrderDatailBO userOrderDatailBO = new UserOrderDatailBO();
... ... @@ -101,45 +71,16 @@ public class UserOrdersServiceImpl implements IUserOrdersService,IBusinessExport
}
if (mktMarketingUrl != null) {
userOrderDatailBO.setUnionName(mktMarketingUrl.getName());
userOrderDatailBO.setChannelType(mktMarketingUrl.getChannelType());
}
userOrderDatailBO.setOrderCode(Long.valueOf(userOrders.getOrderCode()));
userOrderDatailBOList.add(userOrderDatailBO);
orderCodeList.add(Long.valueOf(userOrders.getOrderCode()));
}
Map<Long, UserOrderDatailBO> userOrderDatailBOMap = Maps.uniqueIndex(userOrderDatailBOList, new Function<UserOrderDatailBO, Long>() {
@Override
public Long apply(UserOrderDatailBO userOrderDatailBO) {
return userOrderDatailBO.getOrderCode();
}
});
//批量查询erp_orders.orders表
List<Orders> ordersList = ordersMapper.selectByOrderCodeList(orderCodeList);
Map<Long, Orders> ordersMap = Maps.uniqueIndex(ordersList, new Function<Orders, Long>() {
@Override
public Long apply(Orders orders) {
return orders.getOrderCode();
}
});
List<Long> subOrderCodeList = new ArrayList<>();
for (Map.Entry<Long, Orders> map : ordersMap.entrySet()) {
OrdersDetailBO ordersDetailBO = new OrdersDetailBO();
Orders orders = map.getValue();
ordersDetailBO.setOrders(orders);
subOrderCodeList.add(map.getKey());
ordersDetailBOList.add(ordersDetailBO);
return userOrderDatailBOList;
}
//批量查询优惠券金额
List<OrdersCoupons> ordersCouponsList = ordersCouponsMapper.selectByOrderCodeList(subOrderCodeList);
/*Map<Long, OrdersCoupons> couponsMap = Maps.uniqueIndex(ordersCouponsList, new Function<OrdersCoupons, Long>() {
@Override
public Long apply(OrdersCoupons ordersCoupons) {
return ordersCoupons.getOrderCode();
}
});*/
Map<Long, OrdersCoupons> couponsMap = new HashMap<Long, OrdersCoupons>();
private Map<Long, OrdersCoupons> initOrdersCoupons(Long[] subOrderCodeArr){
List<OrdersCoupons> ordersCouponsList = ordersCouponsMapper.selectByOrderCodeList(subOrderCodeArr);
Map<Long, OrdersCoupons> couponsMap = new HashMap<Long, OrdersCoupons>(ordersCouponsList.size());
for (OrdersCoupons coupon : ordersCouponsList) {
try {
OrdersCoupons c = couponsMap.get(coupon.getOrderCode());
... ... @@ -152,6 +93,53 @@ public class UserOrdersServiceImpl implements IUserOrdersService,IBusinessExport
logger.error("set OrdersCoupons error :", e);
}
}
return couponsMap;
}
public PageUnionOrderRspBO queryUnionOrders(UnionOrderReqBO reqBO) {
logger.info("queryUnionOrders 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();
List<String> idList = reqBO.getIdsList();
if(unionType!=null || unionName!=null){
unionType=mktMarketingUrlDAO.selectByNameAndUnionType(unionName,unionType);
if(unionType==null){
return null;
}
}
//查询总数
int count = userOrdersDAO.selectCount(beginTime, endTime, String.valueOf(orderCode),null==unionType?null:unionType.toString(), idList);
logger.info("userOrdersDAO.selectCount: size is {}", count);
if (count < 1) {
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
public Long apply(UserOrderDatailBO userOrderDatailBO) {
return userOrderDatailBO.getOrderCode();
}
});
//批量查询erp_orders.orders表
Long[] orderCodes=userOrderDatailBOMap.keySet().toArray(new Long[0]);
List<Orders> ordersList = ordersMapper.selectByOrderCodeList(orderCodes);
Map<Long, Orders> ordersMap = Maps.uniqueIndex(ordersList, new Function<Orders, Long>() {
@Override
public Long apply(Orders orders) {
return orders.getOrderCode();
}
});
Long[] subOrderCodeList=ordersMap.keySet().toArray(new Long[0]);
//批量查询优惠券金额
Map<Long, OrdersCoupons> couponsMap = initOrdersCoupons(subOrderCodeList);
//批量查询是否新客
List<OrdersAccessOry> ordersAccessOryList = ordersAccessOryMapper.selectByOrderCodeList(subOrderCodeList);
Map<Long, OrdersAccessOry> ordersAccessOryMap = Maps.uniqueIndex(ordersAccessOryList, new Function<OrdersAccessOry, Long>() {
... ... @@ -160,26 +148,28 @@ public class UserOrdersServiceImpl implements IUserOrdersService,IBusinessExport
return ordersAccessOry.getOrderCode();
}
});
List<UnionOrderRspBO> unionOrderRspBOList = new ArrayList<>(ordersMap.size());
for (Orders orders : ordersMap.values()) {
unionOrderRspBOList.add(initUnionOrderRspBO(orders, couponsMap, ordersAccessOryMap, userOrderDatailBOMap));
}
PageUnionOrderRspBO pageUnionOrderRspBO = new PageUnionOrderRspBO();
pageUnionOrderRspBO.setList(unionOrderRspBOList);
pageUnionOrderRspBO.setTotal(count);
pageUnionOrderRspBO.setSize(reqBO.getSize());
pageUnionOrderRspBO.setPage(reqBO.getPage());
return pageUnionOrderRspBO;
}
for (OrdersDetailBO ordersDetailBO : ordersDetailBOList) {
Orders orders = ordersDetailBO.getOrders();
UnionOrderRspBO orderRspBO = new UnionOrderRspBO();
private UnionOrderRspBO initUnionOrderRspBO(Orders orders,Map<Long, OrdersCoupons> couponsMap,Map<Long, OrdersAccessOry> ordersAccessOryMap,Map<Long, UserOrderDatailBO> userOrderDatailBOMap){
UnionOrderRspBO orderRspBO=new UnionOrderRspBO();
//优惠券金额
OrdersCoupons ordersCoupons = couponsMap.get(orders.getOrderCode());
if (null != ordersCoupons) {
orderRspBO.setCouponAmount(ordersCoupons.getCouponAmount());
} else {
orderRspBO.setCouponAmount(new BigDecimal(0));
}
orderRspBO.setCouponAmount(null != ordersCoupons?ordersCoupons.getCouponAmount():new BigDecimal(0));
//防止订单数据没有在ERP中
//订单金额
orderRspBO.setOrderAmount(orders.getOrderAmount());
orderRspBO.setYohoCoinNum(orders.getYohoCoinNum());
orderRspBO.setOrderAmount(orders.getAmount());
//礼品卡抵运费--数据较少,暂时就用单个查询把
BigDecimal pay_shipping_amount = ordersGiftCardMapper.selectPayShippingAmount(Long.valueOf(orders.getOrderCode()));
// 免邮券--数据较少,暂时就用单个查询把
BigDecimal coupon_amount = ordersFreightCouponsMapper.selectCouponAmount(Long.valueOf(orders.getOrderCode()));
//运费
... ... @@ -204,19 +194,10 @@ public class UserOrdersServiceImpl implements IUserOrdersService,IBusinessExport
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.getParentOrderCode());
orderRspBO.setUnionId(userOrderDatailBO.getUnionId());
orderRspBO.setUnionType(userOrderDatailBO.getUnionName());
orderRspBO.setChannelType(userOrderDatailBO.getChannelType());
unionOrderRspBOList.add(orderRspBO);
}
PageUnionOrderRspBO pageUnionOrderRspBO = new PageUnionOrderRspBO();
pageUnionOrderRspBO.setList(unionOrderRspBOList);
pageUnionOrderRspBO.setTotal(count);
pageUnionOrderRspBO.setSize(reqBO.getSize());
pageUnionOrderRspBO.setPage(reqBO.getPage());
return pageUnionOrderRspBO;
return orderRspBO;
}
@Override
... ... @@ -243,4 +224,9 @@ public class UserOrdersServiceImpl implements IUserOrdersService,IBusinessExport
throw new ServiceException(e.getCode(), e.getErrorMessage());
}
}
}
... ...
... ... @@ -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>
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Yoho!Buy运营平台</title>
<script src="/union/js/include.js"></script>
<script src="/union/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="padding-bottom: 35px; height: auto;">
<script>
document.write(addHead('市场报表管理', 'CPS订单管理'));
</script>
<form id="searchForm" method="post" accept-charset="utf-8">
<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>
<label>订单号:</label>
<input class="easyui-textbox" id="orderCode" name="orderCode">
</input>
<label>联盟用户ID:</label>
<input class="easyui-textbox" id="unionId" name="unionId">
</input>
<label>渠道:</label>
<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>
<a id="exportAllButton" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">全部导出</a>
</div>
</form>
</div>
<div region="center">
<div style="margin-left: 30px;margin-top: 20px; height: 500px;">
<table id="userOrdersTable"></table>
</div>
</div>
<script type="text/javascript">
var checkedItems = [];
$(function () {
$("#userOrdersTable").myDatagrid({
fit: true,
fitColumns: true,
<!-- idField: "id",-->
view: fileview,
nowrap: false,
onCheckAll: addcheckItem,
onCheck: addcheckItem,
onUncheckAll: removeAllItem,
onUncheck: removeSingleItem,
url: contextPath + "/UnionShareRest/queryUnionShareOrders",
method: 'POST',
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "ID",
field: "id",
idField:"id",
width: 200,
align: "center",
checkbox: true
}, {
title: "联盟用户ID",
field: "unionId",
width: 200,
align: "center"
}, {
title: "下单时间",
field: "orderTime",
width: 200,
align: "center"
}, {
title: "订单号",
field: "orderCode",
width: 200,
align: "center"
}, {
title: "订单用户ID",
field: "uid",
width: 200,
align: "center"
}, {
title: "订单金额",
field: "orderAmount",
width: 200,
align: "center"
}, {
title: "订单状态",
field: "orderStatus",
width: 200,
align: "center"
}, {
title: "渠道",
field: "unionType",
width: 200,
align: "center"
}, {
title: "渠道号类型",
field: "channelType",
width: 200,
align: "center"
}, {
title: "是否新客",
field: "isNew",
width: 200,
align: "center"
}
]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: false,
checkOnSelect: false,
onLoadSuccess: function (data) {
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 () {
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 = {};
for (var i = 0; i < paramsArray.length; i++) {
params[paramsArray[i].name] = paramsArray[i].value;
}
return params;
}
$("#searchBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
checkedItems=[];
var param = {};
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)
}
param.orderCode = $("#orderCode").val(),
param.unionId = $("#unionId").val(),
param.unionType=$("#unionType").val(),
param.channelType=$("#channelType").combobox("getValue"),
$("#userOrdersTable").myDatagrid("load", param);
}
});
function addcheckItem() {
$("input[type='checkbox'][name='id']:checked").each(function () {
var k = findCheckedItem($(this).val());
if (k == -1) {
checkedItems.push($(this).val());
}
});
}
var fileview = $.extend({}, $.fn.datagrid.defaults.view, { onAfterRender: function (target) { isCheckItem(); } });
function isCheckItem() {
for (var i = 0; i < checkedItems.length; i++) {
$("input[type='checkbox'][name='id'][value='"+checkedItems[i]+"']").attr("checked", "checked");
}
}
function findCheckedItem(ID) {
for (var i = 0; i < checkedItems.length; i++) {
if (checkedItems[i] == ID) return i;
}
return -1;
}
function findCheckedItem(ID) {
for (var i = 0; i < checkedItems.length; i++) {
if (checkedItems[i] == ID) return i;
}
return -1;
}
function removeAllItem(rows) {
$("input[type='checkbox'][name='id']").each(function () {
if (!this.checked) {
var k = findCheckedItem($(this).val());
if (k != -1) {
checkedItems.splice(k, 1);
}
}
});
}
function removeSingleItem(rowIndex, rowData) {
var k = findCheckedItem(rowData.id);
if (k != -1) {
checkedItems.splice(k, 1);
}
}
$("#exportButton").linkbutton({
onClick : function() {
if (checkedItems.length == 0) {
$.messager.alert('提示','请选择要导出的数据');
return;
}
var params = {"ids": checkedItems.toString() };
window.open(contextPath + "/batch/export.do?type=unionShareServiceImpl&queryConf=" + JSON.stringify(params));
}
});
$("#exportAllButton").linkbutton({
onClick : function() {
window.open(contextPath + "/batch/export.do?type=unionShareServiceImpl&queryConf=" + JSON.stringify(getParams()));
}
});
function getParams() {
var paramsArray = $("#searchForm").serializeArray();
var params = {};
var orderCode = "";
var beginTime="";
var endTime="";
for (var i = 0; i < paramsArray.length; i++ ) {
if (paramsArray[i].name == "orderCode") {
orderCode += paramsArray[i].value + ",";
}else if(paramsArray[i].name=="beginTime"){
beginTime += paramsArray[i].value + ",";
}else if(paramsArray[i].name=="endTime"){
endTime +=paramsArray[i].value+",";
} else {
params[paramsArray[i].name] = paramsArray[i].value;
}
}
if (orderCode.length != 0) {
params["orderCode"] = orderCode.substring(0, orderCode.length -1);
}
if(beginTime.length !=0){
params["beginTime"]= parseInt(new Date($("#beginTime").datetimebox('getValue')).getTime() / 1000)
}
if(endTime.length !=0){
params["endTime"]= parseInt(new Date($("#endTime").datetimebox('getValue')).getTime() / 1000)
}
return params;
}
});
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -34,10 +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>
<a id="exportAllButton" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">全部导出</a>
... ... @@ -114,7 +110,7 @@
}, {
title: "运费",
field: "shipmentAmount",
width: 90,
width: 170,
align: "center"
}, {
title: "实付金额",
... ... @@ -132,17 +128,9 @@
width: 170,
align: "center"
}, {
title: "渠道号类型",
field: "channelType",
width: 120,
align: "center",
formatter: function (value, rowData, rowIndex) {
return value==null?"":value==0?"机构":"个人";
}
}, {
title: "附加信息",
field: "exetInfmoation",
width: 140,
width: 170,
align: "center"
}, {
title: "支付方式",
... ... @@ -173,12 +161,6 @@
});
}
});
$("#channelType").combobox({
valueField : "channelType",
textField : "channelTypeDesc",
data:[{channelTypeDesc:"个人",channelType:"1"},{channelTypeDesc:"机构",channelType:"0"}]
});
$("#channelType").combobox("clear");
function getParam(table) {
var paramsArray = $("#"+table+"").serializeArray();
... ... @@ -204,7 +186,6 @@
param.orderCode = $("#orderCode").val(),
param.unionId = $("#unionId").val(),
param.unionType=$("#unionType").val(),
param.channelType=$("#channelType").combobox("getValue"),
$("#userOrdersTable").myDatagrid("load", param);
}
});
... ...