fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserMoneyControllerV2.java
@@ -114,7 +114,7 @@ return new JsonPrimitive(""); } else { // 保留2位小数 value = value.setScale(2); value = value.setScale(2, BigDecimal.ROUND_DOWN); return new JsonPrimitive(value.toString()); } } @@ -484,7 +484,9 @@ object.put("list", gson.toJson(list)); out.print(JsonUtil.loadTrueResult(object)); } catch (ParseException e) { out.print(JsonUtil.loadFalseResult(1, "查询失败")); e.printStackTrace(); LogHelper.errorDetailInfo(e); } } @@ -736,8 +738,9 @@ object.put("list", gson.toJson(list)); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(object)); } catch (ParseException e) { e.printStackTrace(); JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("统计失败")); e.printStackTrace(); LogHelper.errorDetailInfo(e); } } @@ -790,10 +793,10 @@ @Override public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) { if (value == null) { return new JsonPrimitive("0.000"); return new JsonPrimitive("0.00"); } else { // 保留2位小数 value = value.setScale(3); value = value.setScale(2); return new JsonPrimitive(value.toString()); } } @@ -818,8 +821,9 @@ object.put("list", gson.toJson(list)); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(object)); } catch (Exception e) { e.printStackTrace(); JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); e.printStackTrace(); LogHelper.errorDetailInfo(e); } } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java
@@ -7,10 +7,8 @@ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import javax.annotation.Resource; @@ -40,8 +38,6 @@ import com.yeshi.fanli.entity.order.ESOrder; import com.yeshi.fanli.entity.order.HongBaoOrder; import com.yeshi.fanli.entity.order.UserOrderWeiQuanRecord; import com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrder; import com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrderUserMap; import com.yeshi.fanli.entity.system.ConfigKeyEnum; import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum; import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder; @@ -501,7 +497,7 @@ BigDecimal shareMoney = null; BigDecimal teamMoney = null; // VIP预览信息 if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { if (VersionUtil.greaterThan_2_1_1(acceptData.getPlatform(), acceptData.getVersion())) { String redisContent = previewInfoService.getRedisContent(uid, PreviewEnum.mineInfo); if (!StringUtil.isNullOrEmpty(redisContent)) { MineInfoVO vo = new Gson().fromJson(redisContent, MineInfoVO.class); @@ -807,7 +803,7 @@ * @param out */ @RequestMapping(value = "teamOrderSearch") public void teamOrderSearch(String callback, AcceptData acceptData, Long uid, String key, PrintWriter out) { public void teamOrderSearch(String callback, AcceptData acceptData, Long uid, Integer page, String key, PrintWriter out) { if (uid == null) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录")); return; @@ -816,127 +812,88 @@ List<TeamOrderVO> resultList = new ArrayList<>(); if (StringUtil.isNullOrEmpty(key)) { JSONObject data = new JSONObject(); data.put("count", 0); data.put("list", resultList); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); return; } try { // 查询此单是否存在分红 List<TeamOrderVO> tempList = new ArrayList<>(); List<TeamDividentsSourceOrder> listSourceOrder = teamDividentsSourceOrderService.listByOrderNo(key); if (listSourceOrder != null && listSourceOrder.size() > 0) { for (TeamDividentsSourceOrder sourceOrder: listSourceOrder) { List<TeamDividentsSourceOrderUserMap> listDividents = teamDividentsSourceOrderUserMapService.listBySourceOrderIdAndTargetUid(sourceOrder.getId(), uid); if (listDividents != null && listDividents.size() > 0) { Integer state = null; Date sendTime = null; BigDecimal money = BigDecimal.ZERO; for (TeamDividentsSourceOrderUserMap teamDividents: listDividents) { money = money.add(teamDividents.getMoney()); state = teamDividents.getState(); sendTime = teamDividents.getSendTime(); } TeamOrderVO teamOrderVO = new TeamOrderVO(); teamOrderVO.setSourceType(sourceOrder.getSourceType()); teamOrderVO.setOrderNo(sourceOrder.getOrderNo()); teamOrderVO.setDivMoney(money); teamOrderVO.setDivState(state); if (sendTime != null) teamOrderVO.setAccountTime(TimeUtil.formatDate(sendTime)); tempList.add(teamOrderVO); } } if (page == null) page = 1; List<TeamOrderVO> list = teamDividentsSourceOrderUserMapService.searchByOrderNoOrSourceUid((page-1)*20, 20, uid, key); if (list == null) { list = new ArrayList<>(); } if (tempList.size() > 0) { List<CommonOrder> listOrder = commonOrderService.listByOrderNo(key); if(listOrder != null && listOrder.size() > 0) { Map<String, TeamOrderVO> map = new HashMap<String, TeamOrderVO>(); for (CommonOrder order: listOrder) { Integer sourceType = order.getSourceType(); String orderNo = order.getOrderNo(); String mapKey = orderNo + "##" + sourceType; TeamOrderVO teamVO = map.get(mapKey); if (teamVO != null) { teamVO.setPayment(teamVO.getPayment().add(order.getPayment())); } else { Long orderUid = order.getUserInfo().getId(); teamVO = new TeamOrderVO(); teamVO.setUid(orderUid); teamVO.setOrderNo(orderNo); teamVO.setSourceType(sourceType); if (list.size() > 0) { for (int i = 0; i < list.size(); i ++) { TeamOrderVO teamVO = list.get(i); // 粉丝代数 ThreeSaleDetail threeDetail = threeSaleDetailService.getByBossUidAndWorkerUid(uid, teamVO.getUid()); if (threeDetail == null) { list.remove(i); i--; continue; } teamVO.setTeamGrade(threeDetail.getLevel()); // 粉丝基本信息 UserInfo userInfo = userInfoService.getUserByIdWithMybatis(teamVO.getUid()); if (userInfo == null) { list.remove(i); i--; continue; } teamVO.setNickName(userInfo.getNickName()); teamVO.setPortrait(userInfo.getPortrait()); BigDecimal payment = BigDecimal.ZERO; List<CommonOrder> listOrder = commonOrderService.listBySourceTypeAndOrderId(teamVO.getSourceType(), teamVO.getOrderNo()); if (listOrder != null && listOrder.size() > 0) { for (CommonOrder order: listOrder) { payment = payment.add(order.getPayment()); teamVO.setSourceName(order.getChildSourceType()); teamVO.setPayment(order.getPayment()); teamVO.setDownTime(TimeUtil.formatDate(order.getThirdCreateTime())); // 下单时等级 UserLevelEnum userLevel = UserLevelUtil.getByOrderRank(order.getUrank()); if (userLevel == null) userLevel = UserLevelEnum.daRen; teamVO.setUserRank(UserLevelUtil.getShowLevel(userLevel).name()); // 粉丝基本信息 UserInfo userInfo = userInfoService.getUserByIdWithMybatis(orderUid); if (userInfo == null) { continue; } teamVO.setUid(orderUid); teamVO.setNickName(userInfo.getNickName()); teamVO.setPortrait(userInfo.getPortrait()); // 结算时间 Date settleTime = order.getSettleTime(); if (settleTime != null) teamVO.setSettleTime(TimeUtil.formatDate(settleTime)); // 粉丝代数 ThreeSaleDetail threeDetail = threeSaleDetailService.getByBossUidAndWorkerUid(uid, orderUid); if (threeDetail == null) { continue; } teamVO.setTeamGrade(threeDetail.getLevel()); } // 结算时间 Date settleTime = order.getSettleTime(); if (settleTime != null) teamVO.setSettleTime(TimeUtil.formatDate(settleTime)); // 分红信息 for (TeamOrderVO teamOrderVO: tempList) { if (teamOrderVO.getSourceType() == sourceType) { teamVO.setDivMoney(teamOrderVO.getDivMoney()); teamVO.setDivState(teamOrderVO.getDivState()); teamVO.setAccountTime(teamOrderVO.getAccountTime()); break; } } // 维权信息 Integer orderState = order.getState(); if (!StringUtil.isNullOrEmpty(teamVO.getServiceTime()) && CommonOrder.STATE_WQ == orderState) { if (sourceType == Constant.SOURCE_TYPE_TAOBAO) { UserOrderWeiQuanRecord record = userOrderWeiQuanRecordService.selectByOrderInfoAndUid(uid, order.getTradeId(), sourceType); if (record != null) { teamVO.setServiceTime(TimeUtil.formatDate(record.getCreateTime())); // 维权信息 Integer orderState = order.getState(); if (!StringUtil.isNullOrEmpty(teamVO.getServiceTime()) && CommonOrder.STATE_WQ == orderState) { if (order.getSourceType() == Constant.SOURCE_TYPE_TAOBAO) { UserOrderWeiQuanRecord record = userOrderWeiQuanRecordService.selectByOrderInfoAndUid(uid, order.getTradeId(), order.getSourceType()); if (record != null) { teamVO.setServiceTime(TimeUtil.formatDate(record.getCreateTime())); } } } } String orderTime = "下单" + teamVO.getDownTime() ; if (!StringUtil.isNullOrEmpty(teamVO.getSettleTime())) { orderTime += "\n收货" + teamVO.getSettleTime(); } if (!StringUtil.isNullOrEmpty(teamVO.getServiceTime())) { orderTime += "\n售后" + teamVO.getServiceTime(); } teamVO.setOrderTime(orderTime); map.put(mapKey, teamVO); } teamVO.setPayment(payment); // 遍历放入数组 Iterator<Entry<String, TeamOrderVO>> entries = map.entrySet().iterator(); while(entries.hasNext()){ Entry<String, TeamOrderVO> entry = entries.next(); resultList.add(entry.getValue()); // 订单时间信息 String orderTime = "下单" + teamVO.getDownTime() ; if (!StringUtil.isNullOrEmpty(teamVO.getSettleTime())) { orderTime += "\n收货" + teamVO.getSettleTime(); } if (!StringUtil.isNullOrEmpty(teamVO.getServiceTime())) { orderTime += "\n售后" + teamVO.getServiceTime(); } teamVO.setOrderTime(orderTime); } } @@ -949,14 +906,15 @@ return new JsonPrimitive(""); } else { // 保留2位小数 return new JsonPrimitive(MoneyBigDecimalUtil.getWithNoZera(value) + ""); value = value.setScale(2, BigDecimal.ROUND_DOWN); return new JsonPrimitive(value.toString()); } } }); Gson gson = gsonBuilder.create(); JSONObject data = new JSONObject(); data.put("list", gson.toJson(resultList)); data.put("count", teamDividentsSourceOrderUserMapService.countSearchByOrderNoOrSourceUid(uid, key)); data.put("list", gson.toJson(list)); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); } catch (Exception e) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在")); fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/dividents/TeamDividentsSourceOrderUserMapMapper.java
@@ -8,6 +8,7 @@ import com.yeshi.fanli.dao.BaseMapper; import com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrderUserMap; import com.yeshi.fanli.vo.order.TeamDividentsVO; import com.yeshi.fanli.vo.order.TeamOrderVO; public interface TeamDividentsSourceOrderUserMapMapper extends BaseMapper<TeamDividentsSourceOrderUserMap> { @@ -102,4 +103,8 @@ @Param("maxTime") Date maxTime , @Param("key")String key); List<TeamOrderVO> searchByOrderNoOrSourceUid(@Param("start") long start, @Param("count") int count, @Param("targetUid") Long targetUid , @Param("key")String key); Long countSearchByOrderNoOrSourceUid(@Param("targetUid") Long targetUid , @Param("key")String key); } fanli/src/main/java/com/yeshi/fanli/mapping/order/dividents/TeamDividentsSourceOrderUserMapMapper.xml
@@ -34,6 +34,17 @@ <result column="subsidy" property="subsidy" jdbcType="DECIMAL" /> </resultMap> <resultMap id="TeamOrderVOMap" type="com.yeshi.fanli.vo.order.TeamOrderVO"> <result column="sou_state" property="divState" jdbcType="INTEGER" /> <result column="totalMoney" property="divMoney" jdbcType="DECIMAL" /> <result column="tdo_source_type" property="sourceType" jdbcType="INTEGER" /> <result column="tdo_order_no" property="orderNo" jdbcType="VARCHAR" /> <result column="sou_send_time" property="sendTime" jdbcType="TIMESTAMP" /> <result column="sou_source_uid" property="uid" jdbcType="BIGINT" /> </resultMap> <sql id="Base_Column_List">sou_id,sou_source_order_id,sou_source_uid,sou_target_uid,sou_state,sou_type,sou_rate,sou_money,sou_pre_send_time,sou_create_time,sou_update_time,sou_beizhu,sou_send_time </sql> <select id="selectByPrimaryKey" resultMap="BaseResultMap" @@ -200,8 +211,8 @@ SELECT t.`tdo_order_no`,t.`tdo_source_type`, SUM(IF(d.`sou_type` = 1, d.`sou_money`,0)) AS subsidy, SUM(IF(d.`sou_type` = 2, d.`sou_money`,0)) AS dividents FROM yeshi_ec_team_dividents_source_order_user d LEFT JOIN yeshi_ec_team_dividents_source_order t ON d.`sou_source_order_id` = t.`tdo_id` WHERE d.`sou_target_uid` = #{targetUid} AND t.`tdo_create_time` >= #{minTime} AND t.`tdo_create_time` <![CDATA[<=]]>#{maxTime} WHERE d.`sou_target_uid` = #{targetUid} AND d.`sou_state` <![CDATA[<>]]>4 AND t.`tdo_create_time` >= #{minTime} AND t.`tdo_create_time` <![CDATA[<=]]>#{maxTime} <if test = "key != null and key != ''"> AND (t.`tdo_order_no` = #{key} OR d.`sou_source_uid` = #{key}) </if> @@ -214,8 +225,8 @@ <select id="countByDateAndTargetUid" resultType="Long"> SELECT COUNT(A.sou_id) FROM (SELECT d.`sou_id` FROM yeshi_ec_team_dividents_source_order_user d LEFT JOIN yeshi_ec_team_dividents_source_order t ON d.`sou_source_order_id` = t.`tdo_id` WHERE d.`sou_target_uid` = #{targetUid} AND t.`tdo_create_time` >= #{minTime} AND t.`tdo_create_time` <![CDATA[<=]]>#{maxTime} WHERE d.`sou_target_uid` = #{targetUid} AND d.`sou_state` <![CDATA[<>]]>4 AND t.`tdo_create_time` >= #{minTime} AND t.`tdo_create_time` <![CDATA[<=]]>#{maxTime} <if test = "key != null and key != ''"> AND (t.`tdo_order_no` = #{key} OR d.`sou_source_uid` = #{key}) </if> @@ -225,10 +236,27 @@ <select id="sumByDateAndTargetUid" resultMap="TeamDividentsVOMap"> SELECT SUM(IF(d.`sou_type` = 1, d.`sou_money`,0)) AS subsidy, SUM(IF(d.`sou_type` = 2, d.`sou_money`,0)) AS dividents FROM yeshi_ec_team_dividents_source_order_user d LEFT JOIN yeshi_ec_team_dividents_source_order t ON d.`sou_source_order_id` = t.`tdo_id` WHERE d.`sou_target_uid` = #{targetUid} AND t.`tdo_create_time` >= #{minTime} AND t.`tdo_create_time` <![CDATA[<=]]>#{maxTime} WHERE d.`sou_target_uid` = #{targetUid} AND d.`sou_state` <![CDATA[<>]]>4 AND t.`tdo_create_time` >= #{minTime} AND t.`tdo_create_time` <![CDATA[<=]]>#{maxTime} <if test = "key != null and key != ''"> AND (t.`tdo_order_no` = #{key} OR d.`sou_source_uid` = #{key}) </if> </select> <select id="searchByOrderNoOrSourceUid" resultMap="TeamOrderVOMap"> SELECT d.*,t.*, SUM(d.`sou_money`) AS totalMoney FROM yeshi_ec_team_dividents_source_order_user d LEFT JOIN yeshi_ec_team_dividents_source_order t ON d.`sou_source_order_id` = t.`tdo_id` WHERE d.`sou_target_uid` = #{targetUid} AND (t.`tdo_order_no` = #{key} OR d.`sou_source_uid` = #{key}) GROUP BY t.`tdo_order_no`,t.`tdo_source_type` ORDER BY t.`tdo_create_time` DESC LIMIT #{start},#{count} </select> <select id="countSearchByOrderNoOrSourceUid" resultType="Long"> SELECT COUNT(A.sou_id) FROM (SELECT d.`sou_id` FROM yeshi_ec_team_dividents_source_order_user d LEFT JOIN yeshi_ec_team_dividents_source_order t ON d.`sou_source_order_id` = t.`tdo_id` WHERE d.`sou_target_uid` = #{targetUid} AND (t.`tdo_order_no` = #{key} OR d.`sou_source_uid` = #{key}) GROUP BY t.`tdo_order_no`,t.`tdo_source_type`)A </select> </mapper> fanli/src/main/java/com/yeshi/fanli/service/impl/order/dividents/TeamDividentsSourceOrderUserMapServiceImpl.java
@@ -7,6 +7,7 @@ import javax.annotation.Resource; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -16,6 +17,7 @@ import com.yeshi.fanli.service.inter.order.dividents.TeamDividentsSourceOrderUserMapService; import com.yeshi.fanli.util.MoneyBigDecimalUtil; import com.yeshi.fanli.vo.order.TeamDividentsVO; import com.yeshi.fanli.vo.order.TeamOrderVO; @Service public class TeamDividentsSourceOrderUserMapServiceImpl implements TeamDividentsSourceOrderUserMapService { @@ -187,4 +189,17 @@ return teamDividentsSourceOrderUserMapMapper.sumByDateAndTargetUid(targetUid, minTime, maxTime, key); } @Override public List<TeamOrderVO> searchByOrderNoOrSourceUid(long start, int count, Long targetUid ,String key) { return teamDividentsSourceOrderUserMapMapper.searchByOrderNoOrSourceUid(start, count, targetUid, key); } @Override public long countSearchByOrderNoOrSourceUid(Long targetUid ,String key) { Long count = teamDividentsSourceOrderUserMapMapper.countSearchByOrderNoOrSourceUid(targetUid, key); if (count == null) count = 0L; return count; } } fanli/src/main/java/com/yeshi/fanli/service/impl/user/PreviewInfoServiceImpl.java
@@ -119,9 +119,9 @@ if (StringUtil.isNullOrEmpty(time)) throw new PreviewInfoException(1, "提现时间不能为空"); Date parse = TimeUtil.parseDotCommon2(time); if (parse == null) throw new PreviewInfoException(1, "请输入正确的时间格式,如:2020.01.01 01:01"); Date receiveTime = TimeUtil.parseYYYYMMDD_HHMM(time); if (receiveTime == null) throw new PreviewInfoException(1, "请输入正确的时间格式"); Gson gson = new Gson(); @@ -131,7 +131,7 @@ extract.setName(alipay.getName()); extract.setAccount(alipay.getAccount()); extract.setMoney(money); extract.setReceiveTime(TimeUtil.parseDotCommon2(time)); extract.setReceiveTime(receiveTime); extract.setId(java.lang.System.currentTimeMillis()); String id = StringUtil.Md5(uid + "#" + PreviewEnum.extractRecord.name()); @@ -256,12 +256,9 @@ throw new PreviewInfoException(1, "请输入订单号"); if(StringUtil.isNullOrEmpty(time)) throw new PreviewInfoException(1, "请输入创建时间"); Date date = TimeUtil.parseDotCommon2(time); Date date = TimeUtil.parseYYYYMMDD_HHMM(time); if (date == null) throw new PreviewInfoException(1, "请输入正确的时间格式,如:2020.01.01 01:01"); // 转换格式 time = TimeUtil.formatYMDHHMM(date); throw new PreviewInfoException(1, "请输入正确的时间格式"); InputStream drawStream = null; if ("ios".equalsIgnoreCase(platform)) { fanli/src/main/java/com/yeshi/fanli/service/inter/order/dividents/TeamDividentsSourceOrderUserMapService.java
@@ -7,6 +7,7 @@ import com.yeshi.fanli.entity.order.dividents.TeamDividentsSourceOrderUserMap; import com.yeshi.fanli.exception.ParamsException; import com.yeshi.fanli.vo.order.TeamDividentsVO; import com.yeshi.fanli.vo.order.TeamOrderVO; /** * 分红源订单与参与分红用户的对应关系 @@ -176,4 +177,17 @@ public TeamDividentsVO sumByDateAndTargetUid(Long targetUid, Date minTime, Date maxTime, String key); /** * 根据uid 和订单号搜索 * @param start * @param count * @param sourceUid * @param targetUid * @param key * @return */ public List<TeamOrderVO> searchByOrderNoOrSourceUid(long start, int count, Long targetUid, String key); public long countSearchByOrderNoOrSourceUid(Long targetUid, String key); } fanli/src/main/java/com/yeshi/fanli/util/TimeUtil.java
@@ -111,6 +111,17 @@ } } public static Date parseYYYYMMDD_HHMM(String st) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); try { return sdf.parse(st); } catch (Exception e) { e.printStackTrace(); return null; } } public static Date parseYYYYMMDD(String st) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { fanli/src/main/java/com/yeshi/fanli/vo/order/TeamOrderVO.java
@@ -2,6 +2,7 @@ import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; import com.google.gson.annotations.Expose; @@ -47,6 +48,9 @@ private Integer divState; // 分红状态 @Expose private String accountTime; // 到账时间 @Expose private Date sendTime; public Long getUid() { return uid; @@ -175,6 +179,14 @@ public void setOrderTime(String orderTime) { this.orderTime = orderTime; } public Date getSendTime() { return sendTime; } public void setSendTime(Date sendTime) { this.sendTime = sendTime; } }