Commit cfff1274 by huluobin

头程费用计算

亚马逊广告
parent 56e48859
......@@ -46,10 +46,10 @@ public class AmazonAdGenerateReportIdJob implements SimpleJob {
dcBaseCompanyAccountList.forEach(dcBaseCompanyAccount -> {
try {
//
LocalDateTime reportDate = LocalDateTime.now().minusDays(1).minusHours(12);
// LocalDateTime reportDate = LocalDateTime.now().minusDays(1).minusHours(12);
LocalDateTime reportDate =LocalDateTime.of(2020,8,21,0,0);
// LocalDateTime reportDate = LocalDateTime.of(2020, 8, 22, 0, 0);
JSONObject jsonObject = new JSONObject();
jsonObject.put("reportDate", reportDate.format(DateTimeFormatter.ofPattern("yyyyMMdd")));
jsonObject.put("metrics", propertiesUtil.getPropertyAsString("METRICS"));
......
import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.job.CompanyAccountSyncJob;
import com.bailuntec.job.CompanyInfoSyncJob;
import com.bailuntec.job.CompanyStaffSyncJob;
import org.junit.jupiter.api.Test;
import java.time.LocalDateTime;
public class CompanyTest {
@Test
public void test() {
CompanyInfoSyncJob skuSyncJob = new CompanyInfoSyncJob();
skuSyncJob.executeJob(null, new JobPointLog("", 0, 100, 1, 1, LocalDateTime.now().minusMonths(1), LocalDateTime.now().minusDays(29)));
}
@Test
public void test2() {
CompanyStaffSyncJob skuSyncJob = new CompanyStaffSyncJob();
skuSyncJob.executeJob(null, new JobPointLog("", 0, 100, 1, 1, LocalDateTime.now().minusMonths(1), LocalDateTime.now().minusDays(29)));
}
@Test
public void test3() {
CompanyAccountSyncJob skuSyncJob = new CompanyAccountSyncJob();
skuSyncJob.execute(null);
}
}
......@@ -139,5 +139,5 @@ public interface DcBaseCostFirstMapper {
* @param pageOffset 分页参数
* @return 未计算的基础头程费用
*/
List<DcBaseCostFirst> listUnCalc(@Param("pageStart") Integer pageStart, @Param("pageOffset") Integer pageOffset);
List<DcBaseCostFirst> dcBaseCostGroupList(@Param("pageStart") Integer pageStart, @Param("pageOffset") Integer pageOffset);
}
......@@ -834,7 +834,7 @@
# and has_calculation = 0
GROUP BY channel_order_id, transfer_order_id, box_id, warehouse_code) tb;
</select>
<select id="listUnCalc" resultType="com.bailuntec.domain.entity.DcBaseCostFirst">
<select id="dcBaseCostGroupList" resultType="com.bailuntec.domain.entity.DcBaseCostFirst">
SELECT t2.*
from (
SELECT channel_order_id, transfer_order_id, box_id, warehouse_code
......@@ -857,7 +857,6 @@
and transfer_order_id = #{transferOrderId}
and box_id = #{boxId}
and warehouse_code = #{warehouseCode}
# and has_calculation = 0
</update>
......
......@@ -121,4 +121,12 @@ public interface DcMidCostFirstMapper {
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int upsertSelective(DcMidCostFirst record);
/**
* 批量插入更细
*
* @param dcMidCostFirstList
*/
void upsertBatch(@Param("lists") List<DcMidCostFirst> dcMidCostFirstList);
}
......@@ -6,14 +6,14 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="cost_first" jdbcType="DECIMAL" property="costFirst" />
<result column="bailun_sku" jdbcType="VARCHAR" property="bailunSku" />
<result column="warehouse_code" jdbcType="VARCHAR" property="warehouseCode" />
<result column="company_id" jdbcType="INTEGER" property="companyId" />
<result column="has_calculation" jdbcType="BIT" property="hasCalculation" />
<result column="cost_count" jdbcType="INTEGER" property="costCount" />
<result column="has_config" jdbcType="BIT" property="hasConfig" />
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="cost_first" jdbcType="DECIMAL" property="costFirst"/>
<result column="bailun_sku" jdbcType="VARCHAR" property="bailunSku"/>
<result column="warehouse_code" jdbcType="VARCHAR" property="warehouseCode"/>
<result column="company_id" jdbcType="INTEGER" property="companyId"/>
<result column="has_calculation" jdbcType="BIT" property="hasCalculation"/>
<result column="cost_count" jdbcType="INTEGER" property="costCount"/>
<result column="has_config" jdbcType="BIT" property="hasConfig"/>
</resultMap>
<sql id="Example_Where_Clause">
<!--
......@@ -37,7 +37,8 @@
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
......@@ -70,7 +71,8 @@
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
......@@ -89,7 +91,8 @@
id, cost_first, bailun_sku, warehouse_code, company_id, has_calculation, cost_count,
has_config
</sql>
<select id="selectByExample" parameterType="com.bailuntec.domain.example.DcMidCostFirstExample" resultMap="BaseResultMap">
<select id="selectByExample" parameterType="com.bailuntec.domain.example.DcMidCostFirstExample"
resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
......@@ -98,10 +101,10 @@
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
from dc_mid_cost_first
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
......@@ -121,7 +124,7 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
from dc_mid_cost_first
where id = #{id,jdbcType=INTEGER}
</select>
......@@ -140,7 +143,7 @@
-->
delete from dc_mid_cost_first
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
</delete>
<insert id="insert" parameterType="com.bailuntec.domain.entity.DcMidCostFirst">
......@@ -214,14 +217,15 @@
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.bailuntec.domain.example.DcMidCostFirstExample" resultType="java.lang.Long">
<select id="countByExample" parameterType="com.bailuntec.domain.example.DcMidCostFirstExample"
resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from dc_mid_cost_first
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
......@@ -257,7 +261,7 @@
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExample" parameterType="map">
......@@ -275,7 +279,7 @@
cost_count = #{record.costCount,jdbcType=INTEGER},
has_config = #{record.hasConfig,jdbcType=BIT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.DcMidCostFirst">
......@@ -324,6 +328,39 @@
has_config = #{hasConfig,jdbcType=BIT}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="upsertBatch">
insert into dc_mid_cost_first
(
cost_first,
bailun_sku,
warehouse_code,
company_id,
has_calculation,
cost_count,
has_config)
values
<foreach collection="lists" item="item" index="index" separator=",">
(
#{item.costFirst,jdbcType=DECIMAL},
#{item.bailunSku,jdbcType=VARCHAR},
#{item.warehouseCode,jdbcType=VARCHAR},
#{item.companyId,jdbcType=INTEGER},
#{item.hasCalculation,jdbcType=BIT},
#{item.costCount,jdbcType=INTEGER},
#{item.hasConfig,jdbcType=BIT}
)
</foreach>
on duplicate key update
cost_first = values(cost_first),
bailun_sku = values(bailun_sku),
warehouse_code = values(warehouse_code),
company_id = values(company_id),
has_calculation = values(has_calculation),
cost_count = values(cost_count),
has_config = values(has_config)
</update>
<insert id="upsertSelective" parameterType="com.bailuntec.domain.entity.DcMidCostFirst">
<!--
WARNING - @mbg.generated
......@@ -435,17 +472,18 @@
cost_count = #{costCount,jdbcType=INTEGER},
has_config = #{hasConfig,jdbcType=BIT}
</insert>
<select id="selectOneByExample" parameterType="com.bailuntec.domain.example.DcMidCostFirstExample" resultMap="BaseResultMap">
<select id="selectOneByExample" parameterType="com.bailuntec.domain.example.DcMidCostFirstExample"
resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
from dc_mid_cost_first
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
......
......@@ -129,6 +129,5 @@ public interface DcMidCostFirstOrderMapper {
List<MidCostFirst> listSkuWarehouse(@Param("v1") int v1, @Param("v2") int v2);
int updateHasCalculation(MidCostFirst midCostFirst);
}
......@@ -577,28 +577,26 @@
limit 1
</select>
<!---->
<select id="countSkuWarehouse" resultType="int">
select count(*)
from (SELECT * FROM dc_mid_cost_first_order where has_calculation = 0 GROUP BY bailun_sku, warehouse_code) tb;
from (SELECT *
FROM dc_mid_cost_first_order
GROUP BY bailun_sku, warehouse_code) tb;
</select>
<!---->
<select id="listSkuWarehouse" resultType="com.bailuntec.domain.pojo.MidCostFirst">
SELECT bailun_sku,
warehouse_code,
sum(cost_first) as total_cost_first,
sum(quantity) as total_count
FROM dc_mid_cost_first_order
where has_calculation = 0
GROUP BY bailun_sku, warehouse_code
order by id asc
order by id
limit #{v1}, #{v2}
</select>
<update id="updateHasCalculation">
update dc_mid_cost_first_order
set has_calculation = 1
where bailun_sku = #{bailunSku}
and warehouse_code = #{warehouseCode}
</update>
</mapper>
......@@ -2,7 +2,6 @@ import com.bailuntec.domain.constant.Constant;
import com.bailuntec.domain.entity.DcBaseSku;
import com.bailuntec.domain.entity.DcMidCostFirst;
import com.bailuntec.domain.entity.DcMidCostFirstConfig;
import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.domain.example.DcBaseSkuExample;
import com.bailuntec.domain.example.DcMidCostFirstExample;
import com.bailuntec.domain.pojo.MidCostFirst;
......@@ -37,7 +36,7 @@ public class CostFirstTest {
@Test
public void test() {
CalculateCostFirstJob costFirstJob = new CalculateCostFirstJob();
costFirstJob.executeJob(null, new JobPointLog("dc-mid-calculate-cost-first", 1, 100, null, null, null, null));
costFirstJob.execute(null);
}
@Test
......
......@@ -20,6 +20,6 @@ class CalculateCostFirstJobTest {
JobPointLog jobPointLog = new JobPointLog();
jobPointLog.setPageSize(1000);
jobPointLog.setPageIndex(1);
calculateCostFirstJob.executeJob(null, jobPointLog);
calculateCostFirstJob.execute(null);
}
}
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