Authored by mali

Merge branch 'test6.8.2' of http://git.yoho.cn/ufo/ufo-platform into test6.8.2

1 package com.yoho.order.dal; 1 package com.yoho.order.dal;
2 2
  3 +import java.util.List;
  4 +
3 import org.apache.ibatis.annotations.Param; 5 import org.apache.ibatis.annotations.Param;
4 6
  7 +import com.yoho.order.model.SellerWalletDetail;
  8 +
5 public interface SellerWalletDetailMapper { 9 public interface SellerWalletDetailMapper {
6 10
7 //查询用户违约的次数 11 //查询用户违约的次数
8 int selectUserBreakRulesCount(@Param("uid") Integer uid); 12 int selectUserBreakRulesCount(@Param("uid") Integer uid);
9 13
  14 + List<SellerWalletDetail> selectMerchantInfo(@Param("uid") Integer uid,
  15 + @Param("startTime") Integer stratTime,
  16 + @Param("endTime") Integer endTime,
  17 + @Param("stateList") List<Integer> stateList,
  18 + @Param("start") int start,
  19 + @Param("rows") Integer rows);
  20 +
  21 + int selectMerchantInfoCount(@Param("uid") Integer uid,
  22 + @Param("startTime") Integer stratTime,
  23 + @Param("endTime") Integer endTime,
  24 + @Param("stateList") List<Integer> stateList);
  25 +
  26 + SellerWalletDetail selectById(Integer id);
10 } 27 }
  1 +package com.yoho.order.model;
  2 +
  3 +import java.util.List;
  4 +
  5 +import com.yoho.ufo.service.model.PageRequestBO;
  6 +
  7 +import lombok.Data;
  8 +import lombok.EqualsAndHashCode;
  9 +import lombok.ToString;
  10 +
  11 +@Data
  12 +@ToString
  13 +@EqualsAndHashCode(callSuper=false)
  14 +public class MerchantReq extends PageRequestBO {
  15 +
  16 + private static final long serialVersionUID = 1620427808531296022L;
  17 +
  18 + private Integer id;
  19 +
  20 + private Integer uid;
  21 +
  22 + private String startTime;
  23 +
  24 + private String endTime;
  25 +
  26 + private List<Integer> stateList;
  27 +
  28 +}
@@ -28,4 +28,35 @@ @@ -28,4 +28,35 @@
28 where uid = #{uid,jdbcType=INTEGER} and is_batch = 0 and type in (32,33) 28 where uid = #{uid,jdbcType=INTEGER} and is_batch = 0 and type in (32,33)
29 </select> 29 </select>
30 30
  31 +
  32 + <select id="selectMerchantInfoCount" resultType="java.lang.Integer" >
  33 + select count(*) from seller_wallet_detail
  34 + where is_batch = 0 <include refid="condi" />
  35 + </select>
  36 +
  37 + <select id="selectMerchantInfo" resultMap="BaseResultMap">
  38 + select * from seller_wallet_detail
  39 + where is_batch = 0 <include refid="condi" /> order by id desc limit #{start},#{rows}
  40 + </select>
  41 + <select id="selectById" resultMap="BaseResultMap">
  42 + select * from seller_wallet_detail
  43 + where id = #{id,jdbcType=INTEGER}
  44 + </select>
  45 + <sql id="condi">
  46 + <if test="uid != null and uid > 0">
  47 + and uid = #{uid,jdbcType=INTEGER}
  48 + </if>
  49 + <if test="startTime != null and startTime > 0">
  50 + and create_time &gt;= #{startTime,jdbcType=INTEGER}
  51 + </if>
  52 + <if test="endTime != null and endTime > 0">
  53 + and create_time &lt;= #{endTime,jdbcType=INTEGER}
  54 + </if>
  55 + <if test="stateList != null and stateList.size()>0">
  56 + and type in
  57 + <foreach collection="stateList" item="item" open="(" close=")" separator=",">
  58 + #{item}
  59 + </foreach>
  60 + </if>
  61 + </sql>
31 </mapper> 62 </mapper>
  1 +package com.yoho.ufo.order.controller;
  2 +
  3 +import org.slf4j.Logger;
  4 +import org.slf4j.LoggerFactory;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RestController;
  8 +
  9 +import com.yoho.order.model.MerchantReq;
  10 +import com.yoho.ufo.order.service.impl.MerchantServiceImpl;
  11 +import com.yoho.ufo.service.model.ApiResponse;
  12 +import com.yoho.ufo.service.model.PageResponseBO;
  13 +import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
  14 +
  15 +@RestController
  16 +@RequestMapping(value = "/merchant")
  17 +public class MerchantController {
  18 +
  19 + private static final Logger LOGGER = LoggerFactory.getLogger(MerchantController.class);
  20 +
  21 + @Autowired
  22 + private MerchantServiceImpl service;
  23 +
  24 + @RequestMapping(value = "/earnestList")
  25 + public ApiResponse earnestList(MerchantReq req) {
  26 + LOGGER.info("earnestList in. req is {}", req);
  27 + PageResponseBO<MerchantOrderAttachInfo> result = service.earnestList(req);
  28 + return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
  29 + }
  30 +
  31 + @RequestMapping(value = "/earnestDetail")
  32 + public ApiResponse earnestDetail(MerchantReq req) {
  33 + if(req.getId()==null) {
  34 + return new ApiResponse(400, "参数有误", null);
  35 + }
  36 + MerchantOrderAttachInfo info = service.earnestDetail(req);
  37 + return new ApiResponse.ApiResponseBuilder().code(200).message("获取信息成功").data(info).build();
  38 + }
  39 +}
  1 +package com.yoho.ufo.order.service.impl;
  2 +
  3 +import java.text.ParseException;
  4 +import java.text.SimpleDateFormat;
  5 +import java.util.ArrayList;
  6 +import java.util.Date;
  7 +import java.util.List;
  8 +
  9 +import org.apache.commons.collections.CollectionUtils;
  10 +import org.apache.commons.lang3.StringUtils;
  11 +import org.slf4j.Logger;
  12 +import org.slf4j.LoggerFactory;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.stereotype.Service;
  15 +
  16 +import com.alibaba.fastjson.JSON;
  17 +import com.yoho.order.dal.SellerWalletDetailMapper;
  18 +import com.yoho.order.model.MerchantReq;
  19 +import com.yoho.order.model.SellerWalletDetail;
  20 +import com.yoho.ufo.service.model.PageResponseBO;
  21 +import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
  22 +
  23 +@Service
  24 +public class MerchantServiceImpl {
  25 +
  26 + private static final Logger LOGGER = LoggerFactory.getLogger(MerchantServiceImpl.class);
  27 +
  28 + private ThreadLocal<SimpleDateFormat> sdf = ThreadLocal.withInitial(()-> new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"));
  29 +
  30 + @Autowired
  31 + private SellerWalletDetailMapper mapper;
  32 +
  33 +
  34 + public MerchantOrderAttachInfo earnestDetail(MerchantReq req) {
  35 + return exchange(mapper.selectById(req.getId()));
  36 + }
  37 +
  38 +
  39 + public PageResponseBO<MerchantOrderAttachInfo> earnestList(MerchantReq req) {
  40 +
  41 + Integer stratTime = parse(req.getStartTime());
  42 + Integer endTime = parse(req.getEndTime());
  43 +
  44 + int total = mapper.selectMerchantInfoCount(req.getUid(), stratTime, endTime, req.getStateList());
  45 + if(total == 0) {
  46 + return new PageResponseBO<>();
  47 + }
  48 +
  49 + List<SellerWalletDetail> beanList = mapper.selectMerchantInfo(req.getUid(), stratTime, endTime, req.getStateList(), req.getStart(), req.getRows());
  50 + List<MerchantOrderAttachInfo> boList = new ArrayList<>();
  51 + for(SellerWalletDetail detail : beanList) {
  52 + boList.add(exchange(detail));
  53 + }
  54 +
  55 + PageResponseBO<MerchantOrderAttachInfo> result=new PageResponseBO<>();
  56 + result.setList(boList);
  57 + result.setPage(req.getPage());
  58 + result.setSize(req.getSize());
  59 + result.setTotal(total);
  60 +
  61 + return result;
  62 + }
  63 +
  64 +
  65 + private MerchantOrderAttachInfo exchange(SellerWalletDetail detail) {
  66 + MerchantOrderAttachInfo info = new MerchantOrderAttachInfo();
  67 + if(StringUtils.isNotBlank(detail.getAttachValue())) {
  68 + info = JSON.parseObject(detail.getAttachValue(), MerchantOrderAttachInfo.class);
  69 + }
  70 + info.setId(detail.getId());
  71 + info.setUid(detail.getUid());
  72 + info.setType(detail.getType());
  73 + info.setUserName("");
  74 + info.setTime(sdf.get().format(new Date(detail.getCreateTime() * 1000L)));
  75 + if (info.getType() / 10 == 3 || info.getType()==61) {
  76 + info.setAccountAmount(detail.getAmount().toString());
  77 + info.setLockEarnestMoney(detail.getAmount().toString());
  78 + info.setAvailEarnestMoney("/");
  79 + } else {
  80 + info.setAccountAmount("/");
  81 + info.setLockEarnestMoney("/");
  82 + info.setAvailEarnestMoney(detail.getAmount().toString());
  83 + }
  84 + info.setAccountAllAmount(detail.getAvailAmount().add(detail.getLockAmount()).toString());
  85 + info.setLockAllEarnestMoney(detail.getLockAmount().toString());
  86 + info.setAvailAllEarnestMoney(detail.getAvailAmount().toString());
  87 + return info;
  88 + }
  89 +
  90 +
  91 + private Integer parse(String startTime) {
  92 + if(StringUtils.isBlank(startTime)) {
  93 + return null;
  94 + }
  95 + try {
  96 + return (int) (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(startTime).getTime()/1000);
  97 + } catch (ParseException e) {
  98 + return null;
  99 + }
  100 + }
  101 +
  102 +}
@@ -19,7 +19,7 @@ import com.yoho.ufo.service.IChannelSkuCompareService; @@ -19,7 +19,7 @@ import com.yoho.ufo.service.IChannelSkuCompareService;
19 * 19 *
20 */ 20 */
21 @Service(value="scheduledUpdateSuggestPrice") 21 @Service(value="scheduledUpdateSuggestPrice")
22 -@YhJobDef(desc = "定时变参考价", jobName = "scheduledUpdateSuggestPrice", cron = "00 00 12 * * ?", misfiredPolicy = MisfiredPolicy.CRON_DO_NOTHING, 22 +@YhJobDef(desc = "定时变参考价", jobName = "scheduledUpdateSuggestPrice", cron = "00 00 5 * * ?", misfiredPolicy = MisfiredPolicy.CRON_DO_NOTHING,
23 jobType = JobType.CRON, jobGroup = "ufoPlatform") 23 jobType = JobType.CRON, jobGroup = "ufoPlatform")
24 public class ScheduledUpdateSuggestPrice implements YhJob{ 24 public class ScheduledUpdateSuggestPrice implements YhJob{
25 private static final Logger LOGGER = LoggerFactory.getLogger("scheduledLog"); 25 private static final Logger LOGGER = LoggerFactory.getLogger("scheduledLog");