Commit a6e13935 by kk

统计sku

parent 338bafcd
...@@ -19,4 +19,10 @@ import java.util.List; ...@@ -19,4 +19,10 @@ import java.util.List;
public interface SyncProductPublishMapper extends BaseMapper<SyncProductPublish> { public interface SyncProductPublishMapper extends BaseMapper<SyncProductPublish> {
List<SyncProductPublish> selectMotherSku(); List<SyncProductPublish> selectMotherSku();
List<SyncProductPublish> selectChildSku();
List<SyncProductPublish> selectMotherSku_2();
List<SyncProductPublish> selectChildSku_2();
} }
...@@ -54,7 +54,7 @@ spring: ...@@ -54,7 +54,7 @@ spring:
mybatis-plus: mybatis-plus:
mapper-locations: com/yswg/visual/mapper/**/*.xml mapper-locations: classpath:mapper/*.xml
global-config: global-config:
db-config: db-config:
id-type: auto id-type: auto
\ No newline at end of file
...@@ -12,13 +12,14 @@ ...@@ -12,13 +12,14 @@
select spp.sku, select spp.sku,
spp.relation_key, spp.relation_key,
spp.parent_asin,
spp.lowest_price, spp.lowest_price,
spp.thirty_day_sales spp.thirty_day_sales
from sync_product_publish spp from sync_product_publish spp
LEFT JOIN photo_progress pp on pp.sku = spp.sku LEFT JOIN photo_progress pp on pp.sku = spp.sku
LEFT JOIN shortVideo on shortVideo.sku = spp.sku LEFT JOIN shortVideo on shortVideo.sku = spp.sku
where spp.open_date BETWEEN 1 AND 1732291200 where spp.open_date BETWEEN 1 AND 1732550400
and spp.sale_status IN ('正常销售') and spp.sale_status IN ('正常销售')
and spp.site = 'Amazon.com' and spp.site = 'Amazon.com'
and spp.is_delete = 0 and spp.is_delete = 0
...@@ -30,4 +31,96 @@ ...@@ -30,4 +31,96 @@
and spp.thirty_day_sales > 0 and spp.thirty_day_sales > 0
</select> </select>
<select id="selectChildSku" resultType="cn.kk.spring_simple_operation.entity.SyncProductPublish">
with shortVideo as (select vp.sku
from video_product vp
INNER JOIN visual_video_plan vvp on vvp.id = vp.video_plan_id
where vp.is_delete = 0
and vvp.is_delete = 0
and vp.site = 'Amazon.com')
SELECT
spp.sku,
spp.relation_key,
spp.parent_asin,
spp.lowest_price,
spp.thirty_day_sales
FROM
sync_product_publish spp
LEFT JOIN photo_progress pp ON pp.sku = spp.sku
LEFT JOIN shortVideo ON shortVideo.sku = spp.sku
WHERE
spp.open_date BETWEEN 1
AND 1732550400
AND spp.sale_status IN ( '正常销售' )
AND spp.site = 'Amazon.com'
AND spp.is_delete = 0
AND spp.solar_term = 1
AND shortVideo.sku IS NULL
AND pp.id IS NULL
AND spp.lowest_price > 0
AND spp.thirty_day_sales > 0
</select>
<select id="selectMotherSku_2" resultType="cn.kk.spring_simple_operation.entity.SyncProductPublish">
with shortVideo as (select vp.sku
from video_product vp
INNER JOIN visual_video_plan vvp on vvp.id = vp.video_plan_id
where vp.is_delete = 0
and vvp.is_delete = 0
and vp.site = 'Amazon.com')
select spp.sku,
spp.relation_key,
spp.parent_asin,
spp.lowest_price,
spp.thirty_day_sales
from sync_product_publish spp
LEFT JOIN photo_progress pp on pp.sku = spp.sku
LEFT JOIN shortVideo on shortVideo.sku = spp.sku
LEFT JOIN sync_solar_term_info ti ON ti.solar_term_id = spp.solar_term
where spp.open_date BETWEEN 1 AND 1732550400
and spp.sale_status IN ('正常销售', '保留页面')
and spp.site = 'Amazon.com'
and spp.is_delete = 0
and spp.parent_asin = ''
AND ti.`month` BETWEEN 1 AND 6
and shortVideo.sku is null
and pp.id is null
and spp.lowest_price > 0
and spp.thirty_day_sales > 0
</select>
<select id="selectChildSku_2" resultType="cn.kk.spring_simple_operation.entity.SyncProductPublish">
with shortVideo as (select vp.sku
from video_product vp
INNER JOIN visual_video_plan vvp on vvp.id = vp.video_plan_id
where vp.is_delete = 0
and vvp.is_delete = 0
and vp.site = 'Amazon.com')
SELECT
spp.sku,
spp.relation_key,
spp.parent_asin,
spp.lowest_price,
spp.thirty_day_sales
FROM
sync_product_publish spp
LEFT JOIN photo_progress pp ON pp.sku = spp.sku
LEFT JOIN shortVideo ON shortVideo.sku = spp.sku
LEFT JOIN sync_solar_term_info ti ON ti.solar_term_id = spp.solar_term
WHERE
spp.open_date BETWEEN 1
AND 1732550400
AND spp.sale_status IN ( '正常销售', '保留页面' )
AND spp.site = 'Amazon.com'
AND spp.is_delete = 0
AND ti.`month` BETWEEN 1 AND 6
AND shortVideo.sku IS NULL
AND pp.id IS NULL
AND spp.lowest_price > 0
AND spp.thirty_day_sales > 0
</select>
</mapper> </mapper>
...@@ -6,6 +6,7 @@ import cn.kk.spring_simple_operation.mapper.VideoProductMapper; ...@@ -6,6 +6,7 @@ import cn.kk.spring_simple_operation.mapper.VideoProductMapper;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.compress.utils.Lists;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -31,12 +32,22 @@ class SpringSimpleOperationApplicationTests { ...@@ -31,12 +32,22 @@ class SpringSimpleOperationApplicationTests {
void contextLoads() { void contextLoads() {
} }
/**
* 1.已开售时间大于1个月 常规产品 无简易和精细化视频产品(正常销售)
* ① 单价<20美金,SKU或变体总月销100+
* ② 单价在20~40美金,SKU或变体总月销80+
* ③单价>40美金,SKU或变体总月销50+
* 2.已开售时间大于1个月 节气产品热卖期在1-6月 无简易和精细化视频产品(正常销售+保留页面)
* ① 单价<20美金,SKU或变体总月销100+
* ② 单价在20~40美金,SKU或变体总月销80+
* ③单价>40美金,SKU或变体总月销50+
*/
@Test @Test
void testSyncProductPublish() { void testSyncProductPublish() {
//List<String> shortUrlSkuList = videoProductMapper.selectHaveTask(); //List<String> shortUrlSkuList = videoProductMapper.selectHaveTask();
Map<String, Integer> salesMap = new HashMap<>(); Map<String, Integer> salesMap = new HashMap<>();
salesMap.put("<20", 0); salesMap.put("0~20", 0);
salesMap.put("20~40", 0); salesMap.put("20~40", 0);
salesMap.put(">40", 0); salesMap.put(">40", 0);
...@@ -44,6 +55,7 @@ class SpringSimpleOperationApplicationTests { ...@@ -44,6 +55,7 @@ class SpringSimpleOperationApplicationTests {
// 母体sku // 母体sku
List<SyncProductPublish> syncProductPublishes = syncProductPublishMapper.selectMotherSku(); List<SyncProductPublish> syncProductPublishes = syncProductPublishMapper.selectMotherSku();
List<SyncProductPublish> syncProductPublishes_2 = new LinkedList<>();
syncProductPublishes.forEach(item -> { syncProductPublishes.forEach(item -> {
List<SyncProductPublish> subList = syncProductPublishMapper.selectList(Wrappers.<SyncProductPublish>lambdaQuery().eq(SyncProductPublish::getParentAsin, item.getRelationKey()).select(SyncProductPublish::getSku, SyncProductPublish::getThirtyDaySales)); List<SyncProductPublish> subList = syncProductPublishMapper.selectList(Wrappers.<SyncProductPublish>lambdaQuery().eq(SyncProductPublish::getParentAsin, item.getRelationKey()).select(SyncProductPublish::getSku, SyncProductPublish::getThirtyDaySales));
...@@ -55,11 +67,42 @@ class SpringSimpleOperationApplicationTests { ...@@ -55,11 +67,42 @@ class SpringSimpleOperationApplicationTests {
} }
salesMap.put(s, salesMap.get(s) + 1); salesMap.put(s, salesMap.get(s) + 1);
haveSkuSet.addAll(subList.stream().map(SyncProductPublish::getSku).collect(Collectors.toList())); haveSkuSet.addAll(subList.stream().map(SyncProductPublish::getSku).collect(Collectors.toList()));
syncProductPublishes_2.addAll(subList);
}); });
System.out.println(JSONObject.toJSONString(salesMap)); //System.out.println(JSONObject.toJSONString(salesMap));
printSkuList(syncProductPublishes_2);
printMap(salesMap);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Map<String, Integer> salesMap_2 = new HashMap<>();
salesMap_2.put("0~20", 0);
salesMap_2.put("20~40", 0);
salesMap_2.put(">40", 0);
List<SyncProductPublish> publishList = syncProductPublishMapper.selectChildSku();
List<SyncProductPublish> publishList_2 = new LinkedList<>();
publishList.forEach(item -> {
if (haveSkuSet.contains(item.getSku())) {
return;
}
ArrayList<SyncProductPublish> list = new ArrayList<>();
list.add(item);
String s = checkPriceAndSales(list, item.getLowestPrice());
if (StringUtils.isBlank(s)) {
return;
}
salesMap_2.put(s, salesMap_2.get(s) + 1);
publishList_2.add(item);
});
//System.out.println(JSONObject.toJSONString(salesMap_2));
printSkuList(publishList_2);
printMap(salesMap_2);
} }
private String checkPriceAndSales(List<SyncProductPublish> subList, BigDecimal lowestPrice) { private String checkPriceAndSales(List<SyncProductPublish> subList, BigDecimal lowestPrice) {
...@@ -68,7 +111,7 @@ class SpringSimpleOperationApplicationTests { ...@@ -68,7 +111,7 @@ class SpringSimpleOperationApplicationTests {
} }
int sum = subList.stream().map(SyncProductPublish::getThirtyDaySales).reduce(Integer::sum).get(); int sum = subList.stream().map(SyncProductPublish::getThirtyDaySales).reduce(Integer::sum).get();
if (lowestPrice.compareTo(TWENTY) <= 0 && sum >= 100) { if (lowestPrice.compareTo(TWENTY) <= 0 && sum >= 100) {
return "<20"; return "0~20";
} }
else if (lowestPrice.compareTo(TWENTY) > 0 && lowestPrice.compareTo(FORTY) <= 0 && sum >= 80) { else if (lowestPrice.compareTo(TWENTY) > 0 && lowestPrice.compareTo(FORTY) <= 0 && sum >= 80) {
return "20~40"; return "20~40";
...@@ -79,4 +122,80 @@ class SpringSimpleOperationApplicationTests { ...@@ -79,4 +122,80 @@ class SpringSimpleOperationApplicationTests {
return null; return null;
} }
private void printSkuList(List<SyncProductPublish> list) {
list.forEach(item -> {
String content = String.format("sku: %s, 30天销量: %d, price: %s, relationKey: %s, parentAsin: %s", item.getSku(), item.getThirtyDaySales(), item.getLowestPrice(), item.getRelationKey(), item.getParentAsin());
System.out.println(content);
});
}
private void printMap(Map<String, Integer> salesMap) {
System.out.println("0~20: " + salesMap.get("0~20"));
System.out.println("20~40: " + salesMap.get("20~40"));
System.out.println(">40: " + salesMap.get(">40"));
}
@Test
void testSyncProductPublish_2() {
//List<String> shortUrlSkuList = videoProductMapper.selectHaveTask();
Map<String, Integer> salesMap = new HashMap<>();
salesMap.put("0~20", 0);
salesMap.put("20~40", 0);
salesMap.put(">40", 0);
Set<String> haveSkuSet = new HashSet<>();
// 母体sku
List<SyncProductPublish> syncProductPublishes = syncProductPublishMapper.selectMotherSku_2();
List<SyncProductPublish> syncProductPublishes_2 = new LinkedList<>();
syncProductPublishes.forEach(item -> {
List<SyncProductPublish> subList = syncProductPublishMapper.selectList(Wrappers.<SyncProductPublish>lambdaQuery().eq(SyncProductPublish::getParentAsin, item.getRelationKey()).select(SyncProductPublish::getSku, SyncProductPublish::getThirtyDaySales));
subList.add(item);
String s = checkPriceAndSales(subList, item.getLowestPrice());
if (StringUtils.isBlank(s)) {
return;
}
salesMap.put(s, salesMap.get(s) + 1);
haveSkuSet.addAll(subList.stream().map(SyncProductPublish::getSku).collect(Collectors.toList()));
syncProductPublishes_2.addAll(subList);
});
//System.out.println(JSONObject.toJSONString(salesMap));
printSkuList(syncProductPublishes_2);
printMap(salesMap);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Map<String, Integer> salesMap_2 = new HashMap<>();
salesMap_2.put("0~20", 0);
salesMap_2.put("20~40", 0);
salesMap_2.put(">40", 0);
List<SyncProductPublish> publishList = syncProductPublishMapper.selectChildSku_2();
List<SyncProductPublish> publishList_2 = new LinkedList<>();
publishList.forEach(item -> {
if (haveSkuSet.contains(item.getSku())) {
return;
}
ArrayList<SyncProductPublish> list = new ArrayList<>();
list.add(item);
String s = checkPriceAndSales(list, item.getLowestPrice());
if (StringUtils.isBlank(s)) {
return;
}
salesMap_2.put(s, salesMap_2.get(s) + 1);
publishList_2.add(item);
});
//System.out.println(JSONObject.toJSONString(salesMap_2));
printSkuList(publishList_2);
printMap(salesMap_2);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment