Authored by unknown

ufo列表加销量排序

  1 +package com.yoho.search.dal;
  2 +
  3 +import com.yoho.search.dal.model.UfoBrand;
  4 +import com.yoho.search.dal.model.UfoBuyerOrderGoods;
  5 +
  6 +import java.util.List;
  7 +
  8 +public interface UfoBuyerOrderGoodsMapper {
  9 + int deleteByPrimaryKey(Integer id);
  10 +
  11 + int insert(UfoBuyerOrderGoods record);
  12 +
  13 + int insertSelective(UfoBuyerOrderGoods record);
  14 +
  15 + UfoBuyerOrderGoods selectByPrimaryKey(Integer id);
  16 +
  17 + int updateByPrimaryKeySelective(UfoBuyerOrderGoods record);
  18 +
  19 + int updateByPrimaryKey(UfoBuyerOrderGoods record);
  20 +
  21 + List<UfoBuyerOrderGoods> selectBySkupList(List<Integer> skupList);
  22 +}
  1 +package com.yoho.search.dal;
  2 +
  3 +import com.yoho.search.dal.model.UfoBuyerOrder;
  4 +import com.yoho.search.dal.model.UfoBuyerOrderGoods;
  5 +
  6 +import java.util.List;
  7 +
  8 +public interface UfoBuyerOrderMapper {
  9 + int deleteByPrimaryKey(Integer id);
  10 +
  11 + int insert(UfoBuyerOrder record);
  12 +
  13 + int insertSelective(UfoBuyerOrder record);
  14 +
  15 + UfoBuyerOrder selectByPrimaryKey(Integer id);
  16 +
  17 + int updateByPrimaryKeySelective(UfoBuyerOrder record);
  18 +
  19 + int updateByPrimaryKey(UfoBuyerOrder record);
  20 +
  21 + List<UfoBuyerOrder> selectByOrderCodeList(List<Long> orderCodeList);
  22 +}
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3 +<mapper namespace="com.yoho.search.dal.UfoBuyerOrderGoodsMapper" >
  4 + <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.UfoBuyerOrderGoods" >
  5 + <id column="id" property="id" jdbcType="INTEGER" />
  6 + <result column="order_code" property="orderCode" jdbcType="BIGINT" />
  7 + <result column="skup" property="skup" jdbcType="INTEGER" />
  8 + <result column="goods_price" property="goodsPrice" jdbcType="DECIMAL" />
  9 + <result column="goods_amount" property="goodsAmount" jdbcType="DECIMAL" />
  10 + <result column="uid" property="uid" jdbcType="INTEGER" />
  11 + <result column="coupon_cut_amount" property="couponCutAmount" jdbcType="DECIMAL" />
  12 + </resultMap>
  13 + <sql id="Base_Column_List" >
  14 + id, order_code, skup, goods_price, goods_amount, uid, coupon_cut_amount
  15 + </sql>
  16 + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  17 + select
  18 + <include refid="Base_Column_List" />
  19 + from ufo_buyer_order_goods
  20 + where id = #{id,jdbcType=INTEGER}
  21 + </select>
  22 + <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  23 + delete from ufo_buyer_order_goods
  24 + where id = #{id,jdbcType=INTEGER}
  25 + </delete>
  26 + <insert id="insert" parameterType="com.yoho.search.dal.model.UfoBuyerOrderGoods" >
  27 + insert into ufo_buyer_order_goods (id, order_code, skup,
  28 + goods_price, goods_amount, uid,
  29 + coupon_cut_amount)
  30 + values (#{id,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT}, #{skup,jdbcType=INTEGER},
  31 + #{goodsPrice,jdbcType=DECIMAL}, #{goodsAmount,jdbcType=DECIMAL}, #{uid,jdbcType=INTEGER},
  32 + #{couponCutAmount,jdbcType=DECIMAL})
  33 + </insert>
  34 + <insert id="insertSelective" parameterType="com.yoho.search.dal.model.UfoBuyerOrderGoods" >
  35 + insert into ufo_buyer_order_goods
  36 + <trim prefix="(" suffix=")" suffixOverrides="," >
  37 + <if test="id != null" >
  38 + id,
  39 + </if>
  40 + <if test="orderCode != null" >
  41 + order_code,
  42 + </if>
  43 + <if test="skup != null" >
  44 + skup,
  45 + </if>
  46 + <if test="goodsPrice != null" >
  47 + goods_price,
  48 + </if>
  49 + <if test="goodsAmount != null" >
  50 + goods_amount,
  51 + </if>
  52 + <if test="uid != null" >
  53 + uid,
  54 + </if>
  55 + <if test="couponCutAmount != null" >
  56 + coupon_cut_amount,
  57 + </if>
  58 + </trim>
  59 + <trim prefix="values (" suffix=")" suffixOverrides="," >
  60 + <if test="id != null" >
  61 + #{id,jdbcType=INTEGER},
  62 + </if>
  63 + <if test="orderCode != null" >
  64 + #{orderCode,jdbcType=BIGINT},
  65 + </if>
  66 + <if test="skup != null" >
  67 + #{skup,jdbcType=INTEGER},
  68 + </if>
  69 + <if test="goodsPrice != null" >
  70 + #{goodsPrice,jdbcType=DECIMAL},
  71 + </if>
  72 + <if test="goodsAmount != null" >
  73 + #{goodsAmount,jdbcType=DECIMAL},
  74 + </if>
  75 + <if test="uid != null" >
  76 + #{uid,jdbcType=INTEGER},
  77 + </if>
  78 + <if test="couponCutAmount != null" >
  79 + #{couponCutAmount,jdbcType=DECIMAL},
  80 + </if>
  81 + </trim>
  82 + </insert>
  83 + <update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.UfoBuyerOrderGoods" >
  84 + update ufo_buyer_order_goods
  85 + <set >
  86 + <if test="orderCode != null" >
  87 + order_code = #{orderCode,jdbcType=BIGINT},
  88 + </if>
  89 + <if test="skup != null" >
  90 + skup = #{skup,jdbcType=INTEGER},
  91 + </if>
  92 + <if test="goodsPrice != null" >
  93 + goods_price = #{goodsPrice,jdbcType=DECIMAL},
  94 + </if>
  95 + <if test="goodsAmount != null" >
  96 + goods_amount = #{goodsAmount,jdbcType=DECIMAL},
  97 + </if>
  98 + <if test="uid != null" >
  99 + uid = #{uid,jdbcType=INTEGER},
  100 + </if>
  101 + <if test="couponCutAmount != null" >
  102 + coupon_cut_amount = #{couponCutAmount,jdbcType=DECIMAL},
  103 + </if>
  104 + </set>
  105 + where id = #{id,jdbcType=INTEGER}
  106 + </update>
  107 + <update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.UfoBuyerOrderGoods" >
  108 + update ufo_buyer_order_goods
  109 + set order_code = #{orderCode,jdbcType=BIGINT},
  110 + skup = #{skup,jdbcType=INTEGER},
  111 + goods_price = #{goodsPrice,jdbcType=DECIMAL},
  112 + goods_amount = #{goodsAmount,jdbcType=DECIMAL},
  113 + uid = #{uid,jdbcType=INTEGER},
  114 + coupon_cut_amount = #{couponCutAmount,jdbcType=DECIMAL}
  115 + where id = #{id,jdbcType=INTEGER}
  116 + </update>
  117 +
  118 + <select id="selectBySkupList" resultMap="BaseResultMap" timeout="20000">
  119 + select
  120 + <include refid="Base_Column_List"/>
  121 + from ufo_buyer_order_goods
  122 + WHERE
  123 + skup in
  124 + <foreach item="item" index="index" collection="list"
  125 + open="(" separator="," close=")">
  126 + #{item}
  127 + </foreach>
  128 + </select>
  129 +</mapper>
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3 +<mapper namespace="com.yoho.search.dal.UfoBuyerOrderMapper" >
  4 + <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.UfoBuyerOrder" >
  5 + <id column="id" property="id" jdbcType="INTEGER" />
  6 + <result column="uid" property="uid" jdbcType="INTEGER" />
  7 + <result column="order_code" property="orderCode" jdbcType="BIGINT" />
  8 + <result column="seller_uid" property="sellerUid" jdbcType="INTEGER" />
  9 + <result column="client_type" property="clientType" jdbcType="TINYINT" />
  10 + <result column="payment" property="payment" jdbcType="TINYINT" />
  11 + <result column="payment_type" property="paymentType" jdbcType="TINYINT" />
  12 + <result column="is_cancel" property="isCancel" jdbcType="TINYINT" />
  13 + <result column="amount" property="amount" jdbcType="DECIMAL" />
  14 + <result column="ship_fee" property="shipFee" jdbcType="DECIMAL" />
  15 + <result column="status" property="status" jdbcType="TINYINT" />
  16 + <result column="create_time" property="createTime" jdbcType="INTEGER" />
  17 + <result column="update_time" property="updateTime" jdbcType="INTEGER" />
  18 + <result column="seller_order_status" property="sellerOrderStatus" jdbcType="TINYINT" />
  19 + <result column="buyer_order_status" property="buyerOrderStatus" jdbcType="TINYINT" />
  20 + <result column="channel_no" property="channelNo" jdbcType="VARCHAR" />
  21 + </resultMap>
  22 + <sql id="Base_Column_List" >
  23 + id, uid, order_code, seller_uid, client_type, payment, payment_type, is_cancel, amount,
  24 + ship_fee, status, create_time, update_time, seller_order_status, buyer_order_status,
  25 + channel_no
  26 + </sql>
  27 + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  28 + select
  29 + <include refid="Base_Column_List" />
  30 + from ufo_buyer_order
  31 + where id = #{id,jdbcType=INTEGER}
  32 + </select>
  33 + <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  34 + delete from ufo_buyer_order
  35 + where id = #{id,jdbcType=INTEGER}
  36 + </delete>
  37 + <insert id="insert" parameterType="com.yoho.search.dal.model.UfoBuyerOrder" >
  38 + insert into ufo_buyer_order (id, uid, order_code,
  39 + seller_uid, client_type, payment,
  40 + payment_type, is_cancel, amount,
  41 + ship_fee, status, create_time,
  42 + update_time, seller_order_status, buyer_order_status,
  43 + channel_no)
  44 + values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT},
  45 + #{sellerUid,jdbcType=INTEGER}, #{clientType,jdbcType=TINYINT}, #{payment,jdbcType=TINYINT},
  46 + #{paymentType,jdbcType=TINYINT}, #{isCancel,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL},
  47 + #{shipFee,jdbcType=DECIMAL}, #{status,jdbcType=TINYINT}, #{createTime,jdbcType=INTEGER},
  48 + #{updateTime,jdbcType=INTEGER}, #{sellerOrderStatus,jdbcType=TINYINT}, #{buyerOrderStatus,jdbcType=TINYINT},
  49 + #{channelNo,jdbcType=VARCHAR})
  50 + </insert>
  51 + <insert id="insertSelective" parameterType="com.yoho.search.dal.model.UfoBuyerOrder" >
  52 + insert into ufo_buyer_order
  53 + <trim prefix="(" suffix=")" suffixOverrides="," >
  54 + <if test="id != null" >
  55 + id,
  56 + </if>
  57 + <if test="uid != null" >
  58 + uid,
  59 + </if>
  60 + <if test="orderCode != null" >
  61 + order_code,
  62 + </if>
  63 + <if test="sellerUid != null" >
  64 + seller_uid,
  65 + </if>
  66 + <if test="clientType != null" >
  67 + client_type,
  68 + </if>
  69 + <if test="payment != null" >
  70 + payment,
  71 + </if>
  72 + <if test="paymentType != null" >
  73 + payment_type,
  74 + </if>
  75 + <if test="isCancel != null" >
  76 + is_cancel,
  77 + </if>
  78 + <if test="amount != null" >
  79 + amount,
  80 + </if>
  81 + <if test="shipFee != null" >
  82 + ship_fee,
  83 + </if>
  84 + <if test="status != null" >
  85 + status,
  86 + </if>
  87 + <if test="createTime != null" >
  88 + create_time,
  89 + </if>
  90 + <if test="updateTime != null" >
  91 + update_time,
  92 + </if>
  93 + <if test="sellerOrderStatus != null" >
  94 + seller_order_status,
  95 + </if>
  96 + <if test="buyerOrderStatus != null" >
  97 + buyer_order_status,
  98 + </if>
  99 + <if test="channelNo != null" >
  100 + channel_no,
  101 + </if>
  102 + </trim>
  103 + <trim prefix="values (" suffix=")" suffixOverrides="," >
  104 + <if test="id != null" >
  105 + #{id,jdbcType=INTEGER},
  106 + </if>
  107 + <if test="uid != null" >
  108 + #{uid,jdbcType=INTEGER},
  109 + </if>
  110 + <if test="orderCode != null" >
  111 + #{orderCode,jdbcType=BIGINT},
  112 + </if>
  113 + <if test="sellerUid != null" >
  114 + #{sellerUid,jdbcType=INTEGER},
  115 + </if>
  116 + <if test="clientType != null" >
  117 + #{clientType,jdbcType=TINYINT},
  118 + </if>
  119 + <if test="payment != null" >
  120 + #{payment,jdbcType=TINYINT},
  121 + </if>
  122 + <if test="paymentType != null" >
  123 + #{paymentType,jdbcType=TINYINT},
  124 + </if>
  125 + <if test="isCancel != null" >
  126 + #{isCancel,jdbcType=TINYINT},
  127 + </if>
  128 + <if test="amount != null" >
  129 + #{amount,jdbcType=DECIMAL},
  130 + </if>
  131 + <if test="shipFee != null" >
  132 + #{shipFee,jdbcType=DECIMAL},
  133 + </if>
  134 + <if test="status != null" >
  135 + #{status,jdbcType=TINYINT},
  136 + </if>
  137 + <if test="createTime != null" >
  138 + #{createTime,jdbcType=INTEGER},
  139 + </if>
  140 + <if test="updateTime != null" >
  141 + #{updateTime,jdbcType=INTEGER},
  142 + </if>
  143 + <if test="sellerOrderStatus != null" >
  144 + #{sellerOrderStatus,jdbcType=TINYINT},
  145 + </if>
  146 + <if test="buyerOrderStatus != null" >
  147 + #{buyerOrderStatus,jdbcType=TINYINT},
  148 + </if>
  149 + <if test="channelNo != null" >
  150 + #{channelNo,jdbcType=VARCHAR},
  151 + </if>
  152 + </trim>
  153 + </insert>
  154 + <update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.UfoBuyerOrder" >
  155 + update ufo_buyer_order
  156 + <set >
  157 + <if test="uid != null" >
  158 + uid = #{uid,jdbcType=INTEGER},
  159 + </if>
  160 + <if test="orderCode != null" >
  161 + order_code = #{orderCode,jdbcType=BIGINT},
  162 + </if>
  163 + <if test="sellerUid != null" >
  164 + seller_uid = #{sellerUid,jdbcType=INTEGER},
  165 + </if>
  166 + <if test="clientType != null" >
  167 + client_type = #{clientType,jdbcType=TINYINT},
  168 + </if>
  169 + <if test="payment != null" >
  170 + payment = #{payment,jdbcType=TINYINT},
  171 + </if>
  172 + <if test="paymentType != null" >
  173 + payment_type = #{paymentType,jdbcType=TINYINT},
  174 + </if>
  175 + <if test="isCancel != null" >
  176 + is_cancel = #{isCancel,jdbcType=TINYINT},
  177 + </if>
  178 + <if test="amount != null" >
  179 + amount = #{amount,jdbcType=DECIMAL},
  180 + </if>
  181 + <if test="shipFee != null" >
  182 + ship_fee = #{shipFee,jdbcType=DECIMAL},
  183 + </if>
  184 + <if test="status != null" >
  185 + status = #{status,jdbcType=TINYINT},
  186 + </if>
  187 + <if test="createTime != null" >
  188 + create_time = #{createTime,jdbcType=INTEGER},
  189 + </if>
  190 + <if test="updateTime != null" >
  191 + update_time = #{updateTime,jdbcType=INTEGER},
  192 + </if>
  193 + <if test="sellerOrderStatus != null" >
  194 + seller_order_status = #{sellerOrderStatus,jdbcType=TINYINT},
  195 + </if>
  196 + <if test="buyerOrderStatus != null" >
  197 + buyer_order_status = #{buyerOrderStatus,jdbcType=TINYINT},
  198 + </if>
  199 + <if test="channelNo != null" >
  200 + channel_no = #{channelNo,jdbcType=VARCHAR},
  201 + </if>
  202 + </set>
  203 + where id = #{id,jdbcType=INTEGER}
  204 + </update>
  205 + <update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.UfoBuyerOrder" >
  206 + update ufo_buyer_order
  207 + set uid = #{uid,jdbcType=INTEGER},
  208 + order_code = #{orderCode,jdbcType=BIGINT},
  209 + seller_uid = #{sellerUid,jdbcType=INTEGER},
  210 + client_type = #{clientType,jdbcType=TINYINT},
  211 + payment = #{payment,jdbcType=TINYINT},
  212 + payment_type = #{paymentType,jdbcType=TINYINT},
  213 + is_cancel = #{isCancel,jdbcType=TINYINT},
  214 + amount = #{amount,jdbcType=DECIMAL},
  215 + ship_fee = #{shipFee,jdbcType=DECIMAL},
  216 + status = #{status,jdbcType=TINYINT},
  217 + create_time = #{createTime,jdbcType=INTEGER},
  218 + update_time = #{updateTime,jdbcType=INTEGER},
  219 + seller_order_status = #{sellerOrderStatus,jdbcType=TINYINT},
  220 + buyer_order_status = #{buyerOrderStatus,jdbcType=TINYINT},
  221 + channel_no = #{channelNo,jdbcType=VARCHAR}
  222 + where id = #{id,jdbcType=INTEGER}
  223 + </update>
  224 + <select id="selectByOrderCodeList" resultMap="BaseResultMap" timeout="20000">
  225 + select
  226 + <include refid="Base_Column_List"/>
  227 + from ufo_buyer_order
  228 + WHERE
  229 + order_code in
  230 + <foreach item="item" index="index" collection="list"
  231 + open="(" separator="," close=")">
  232 + #{item}
  233 + </foreach>
  234 + </select>
  235 +</mapper>
  1 +package com.yoho.search.consumer.index.increment.ufo;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.yoho.search.base.utils.ConvertUtils;
  5 +import com.yoho.search.base.utils.EventReportEnum;
  6 +import com.yoho.search.consumer.index.increment.AbstractMqListener;
  7 +import com.yoho.search.consumer.service.daoService.ufo.UfoBuyerOrderGoodsService;
  8 +import com.yoho.search.consumer.service.daoService.ufo.UfoGoodsImagesService;
  9 +import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
  10 +import com.yoho.search.dal.model.UfoBuyerOrderGoods;
  11 +import com.yoho.search.dal.model.UfoGoodsImages;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.stereotype.Component;
  14 +
  15 +/**
  16 + * Created by aaron.wang on 2018/12/5.
  17 + */
  18 +@Component
  19 +@SearchMqConsumerListerner(tableName = "ufo_buyer_order_goods")
  20 +public class UfoBuyerOrderGoodsMqListener extends AbstractMqListener {
  21 +
  22 + @Autowired
  23 + private UfoBuyerOrderGoodsService ufoBuyerOrderGoodsService;
  24 +
  25 + @Override
  26 + protected EventReportEnum getEventReportEnum() {
  27 + return EventReportEnum.UFOBUYERORDERGOODSMQLISTENER_ONMESSAGE;
  28 + }
  29 +
  30 + @Override
  31 + protected void deleteData(String id) throws Exception {
  32 + ufoBuyerOrderGoodsService.delete(Integer.valueOf(id));
  33 + }
  34 +
  35 + @Override
  36 + protected void updateData(JSONObject data) throws Exception {
  37 + UfoBuyerOrderGoods ufoBuyerOrderGoods = ConvertUtils.toJavaObject(UfoBuyerOrderGoods.class, data);
  38 + if (ufoBuyerOrderGoods == null || ufoBuyerOrderGoods.getId() == null) {
  39 + return;
  40 + }
  41 + ufoBuyerOrderGoodsService.saveOrUpdate(ufoBuyerOrderGoods);
  42 + }
  43 +}
  1 +package com.yoho.search.consumer.index.increment.ufo;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.yoho.search.base.utils.ConvertUtils;
  5 +import com.yoho.search.base.utils.EventReportEnum;
  6 +import com.yoho.search.consumer.index.increment.AbstractMqListener;
  7 +import com.yoho.search.consumer.service.daoService.ufo.UfoBuyerOrderService;
  8 +import com.yoho.search.consumer.service.daoService.ufo.UfoGoodsImagesService;
  9 +import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
  10 +import com.yoho.search.dal.model.UfoBuyerOrder;
  11 +import com.yoho.search.dal.model.UfoGoodsImages;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.stereotype.Component;
  14 +
  15 +/**
  16 + * Created by aaron.wang on 2018/12/5.
  17 + */
  18 +@Component
  19 +@SearchMqConsumerListerner(tableName = "ufo_buyer_order")
  20 +public class UfoBuyerOrderMqListener extends AbstractMqListener {
  21 + @Autowired
  22 + private UfoBuyerOrderService ufoBuyerOrderService;
  23 +
  24 + @Override
  25 + protected EventReportEnum getEventReportEnum() {
  26 + return EventReportEnum.UFOBUYERORDERMQLISTENER_ONMESSAGE;
  27 + }
  28 +
  29 + @Override
  30 + protected void deleteData(String id) throws Exception {
  31 + ufoBuyerOrderService.delete(Integer.valueOf(id));
  32 + }
  33 +
  34 + @Override
  35 + protected void updateData(JSONObject data) throws Exception {
  36 + UfoBuyerOrder ufoBuyerOrder = ConvertUtils.toJavaObject(UfoBuyerOrder.class, data);
  37 + if (ufoBuyerOrder == null || ufoBuyerOrder.getId() == null) {
  38 + return;
  39 + }
  40 + ufoBuyerOrderService.saveOrUpdate(ufoBuyerOrder);
  41 + }
  42 +}
@@ -201,6 +201,9 @@ @@ -201,6 +201,9 @@
201 }, 201 },
202 "orderBy": { 202 "orderBy": {
203 "type": "integer" 203 "type": "integer"
  204 + },
  205 + "salesNum": {
  206 + "type": "integer"
204 } 207 }
205 } 208 }
206 } 209 }
@@ -52,6 +52,15 @@ public class UfoProductIndexBO { @@ -52,6 +52,15 @@ public class UfoProductIndexBO {
52 private Double price; 52 private Double price;
53 //other 53 //other
54 private String idString; 54 private String idString;
  55 + private Integer salesNum;
  56 +
  57 + public Integer getSalesNum() {
  58 + return salesNum;
  59 + }
  60 +
  61 + public void setSalesNum(Integer salesNum) {
  62 + this.salesNum = salesNum;
  63 + }
55 64
56 public Integer getId() { 65 public Integer getId() {
57 return id; 66 return id;
  1 +package com.yoho.search.consumer.service.daoService.ufo;
  2 +
  3 +import com.yoho.search.dal.UfoBuyerOrderGoodsMapper;
  4 +import com.yoho.search.dal.UfoBuyerOrderMapper;
  5 +import com.yoho.search.dal.model.UfoBuyerOrder;
  6 +import com.yoho.search.dal.model.UfoBuyerOrderGoods;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Component;
  9 +
  10 +/**
  11 + * Created by aaron.wang on 2018/12/5.
  12 + */
  13 +@Component
  14 +public class UfoBuyerOrderGoodsService{
  15 + @Autowired
  16 + private UfoBuyerOrderGoodsMapper ufoBuyerOrderGoodsMapper;
  17 +
  18 + public UfoBuyerOrderGoods getById(Integer id) {
  19 + return ufoBuyerOrderGoodsMapper.selectByPrimaryKey(id);
  20 + }
  21 +
  22 + public int insert(UfoBuyerOrderGoods ufoBuyerOrderGoods) {
  23 + return ufoBuyerOrderGoodsMapper.insertSelective(ufoBuyerOrderGoods);
  24 + }
  25 +
  26 + public int update(UfoBuyerOrderGoods ufoBuyerOrderGoods) {
  27 + return ufoBuyerOrderGoodsMapper.updateByPrimaryKeySelective(ufoBuyerOrderGoods);
  28 + }
  29 +
  30 + public int saveOrUpdate(UfoBuyerOrderGoods ufoBuyerOrderGoods) {
  31 + if (ufoBuyerOrderGoods.getId() == null || ufoBuyerOrderGoodsMapper.selectByPrimaryKey(ufoBuyerOrderGoods.getId()) == null) {
  32 + return ufoBuyerOrderGoodsMapper.insertSelective(ufoBuyerOrderGoods);
  33 + } else {
  34 + return ufoBuyerOrderGoodsMapper.updateByPrimaryKeySelective(ufoBuyerOrderGoods);
  35 + }
  36 + }
  37 +
  38 + public int delete(Integer id) {
  39 + return ufoBuyerOrderGoodsMapper.deleteByPrimaryKey(id);
  40 + }
  41 +}
  1 +package com.yoho.search.consumer.service.daoService.ufo;
  2 +
  3 +import com.yoho.search.dal.UfoBrandMapper;
  4 +import com.yoho.search.dal.UfoBuyerOrderMapper;
  5 +import com.yoho.search.dal.model.UfoBrand;
  6 +import com.yoho.search.dal.model.UfoBuyerOrder;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Component;
  9 +
  10 +/**
  11 + * Created by aaron.wang on 2018/12/5.
  12 + */
  13 +@Component
  14 +public class UfoBuyerOrderService {
  15 + @Autowired
  16 + private UfoBuyerOrderMapper ufoBuyerOrderMapper;
  17 +
  18 + public UfoBuyerOrder getById(Integer id) {
  19 + return ufoBuyerOrderMapper.selectByPrimaryKey(id);
  20 + }
  21 +
  22 + public int insert(UfoBuyerOrder ufoBuyerOrder) {
  23 + return ufoBuyerOrderMapper.insertSelective(ufoBuyerOrder);
  24 + }
  25 +
  26 + public int update(UfoBuyerOrder ufoBuyerOrder) {
  27 + return ufoBuyerOrderMapper.updateByPrimaryKeySelective(ufoBuyerOrder);
  28 + }
  29 +
  30 + public int saveOrUpdate(UfoBuyerOrder ufoBuyerOrder) {
  31 + if (ufoBuyerOrder.getId() == null || ufoBuyerOrderMapper.selectByPrimaryKey(ufoBuyerOrder.getId()) == null) {
  32 + return ufoBuyerOrderMapper.insertSelective(ufoBuyerOrder);
  33 + } else {
  34 + return ufoBuyerOrderMapper.updateByPrimaryKeySelective(ufoBuyerOrder);
  35 + }
  36 + }
  37 +
  38 + public int delete(Integer id) {
  39 + return ufoBuyerOrderMapper.deleteByPrimaryKey(id);
  40 + }
  41 +}
  1 +package com.yoho.search.consumer.service.logicService.ufo;
  2 +
  3 +import com.yoho.search.consumer.service.bo.UfoProductIndexBO;
  4 +import com.yoho.search.dal.UfoBuyerOrderGoodsMapper;
  5 +import com.yoho.search.dal.UfoBuyerOrderMapper;
  6 +import com.yoho.search.dal.UfoStorageMapper;
  7 +import com.yoho.search.dal.UfoStoragePriceMapper;
  8 +import com.yoho.search.dal.model.UfoBuyerOrder;
  9 +import com.yoho.search.dal.model.UfoBuyerOrderGoods;
  10 +import com.yoho.search.dal.model.UfoStoragePrice;
  11 +import org.apache.commons.collections.CollectionUtils;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.stereotype.Component;
  14 +
  15 +import java.math.BigDecimal;
  16 +import java.util.HashMap;
  17 +import java.util.List;
  18 +import java.util.Map;
  19 +import java.util.stream.Collectors;
  20 +
  21 +/**
  22 + * Created by aaron.wang on 2018/12/5.
  23 + */
  24 +@Component
  25 +public class UfoSalesNumFieldBuilder implements UfoIndexFieldBuilder {
  26 +
  27 + @Autowired
  28 + private UfoStoragePriceMapper ufoStoragePriceMapper;
  29 + @Autowired
  30 + private UfoBuyerOrderMapper ufoBuyerOrderMapper;
  31 + @Autowired
  32 + private UfoBuyerOrderGoodsMapper ufoBuyerOrderGoodsMapper;
  33 +
  34 + @Override
  35 + public void build(List<UfoProductIndexBO> ufoProductIndexBOList, List<Integer> idList) {
  36 + List<UfoStoragePrice> ufoStoragePriceList = ufoStoragePriceMapper.selectByProductIdList(idList);
  37 + Map<Integer, List<UfoStoragePrice>> ufoStoragePriceMap = new HashMap<>();
  38 + if (CollectionUtils.isNotEmpty(ufoStoragePriceList)) {
  39 + ufoStoragePriceMap = ufoStoragePriceList.stream().collect(Collectors.groupingBy(UfoStoragePrice::getProductId));
  40 + }
  41 + for (UfoProductIndexBO ufoProductIndexBO : ufoProductIndexBOList) {
  42 + ufoProductIndexBO.setSalesNum(0);
  43 + List<UfoStoragePrice> storagePriceList = ufoStoragePriceMap.get(ufoProductIndexBO.getId());
  44 + if (CollectionUtils.isEmpty(storagePriceList)) {
  45 + continue;
  46 + }
  47 + List<Integer> skupList = storagePriceList.stream().map(UfoStoragePrice::getSkup).collect(Collectors.toList());
  48 + if (CollectionUtils.isEmpty(storagePriceList)) {
  49 + continue;
  50 + }
  51 + List<UfoBuyerOrderGoods> ufoBuyerOrderGoodsList = ufoBuyerOrderGoodsMapper.selectBySkupList(skupList);
  52 + if (CollectionUtils.isEmpty(ufoBuyerOrderGoodsList)) {
  53 + continue;
  54 + }
  55 + List<Long> orderCodeList = ufoBuyerOrderGoodsList.stream().map(UfoBuyerOrderGoods::getOrderCode).collect(Collectors.toList());
  56 + if (CollectionUtils.isEmpty(orderCodeList)) {
  57 + continue;
  58 + }
  59 + List<UfoBuyerOrder> ufoBuyerOrderList = ufoBuyerOrderMapper.selectByOrderCodeList(orderCodeList);
  60 + if (CollectionUtils.isEmpty(ufoBuyerOrderList)) {
  61 + continue;
  62 + }
  63 + Integer saleNum = 0;
  64 + for(UfoBuyerOrder ufoBuyerOrder:ufoBuyerOrderList){
  65 + if(ufoBuyerOrder.getStatus()==1||ufoBuyerOrder.getStatus()==2||ufoBuyerOrder.getStatus()==3||ufoBuyerOrder.getStatus()==4||ufoBuyerOrder.getStatus()==5){
  66 + saleNum++;
  67 + }
  68 + }
  69 + ufoProductIndexBO.setSalesNum(saleNum);
  70 + }
  71 + }
  72 +}