Commit 00a9e7e1 by wutong

修改同步物流头程费, 对数据不做处理.

parent 7bd825c2
......@@ -14,9 +14,25 @@ public class CostFirstData {
private Integer channelId;
@JSONField(name = "boxCode")
private String boxId;
@JSONField(name = "moneyRMB")
private BigDecimal costFirst;
@JSONField(name = "wareCode")
private String warehouseCode;
private List<CostFirstSku> skus;
//燃油附加费
@JSONField(name = "fuelFee")
private BigDecimal costFuel;
//原始重量邮费
@JSONField(name = "weightFee")
private BigDecimal costWeight;
//清关费
@JSONField(name = "customsClearanceFee")
private BigDecimal costCustomsClearance;
//关税预付
@JSONField(name = "dutyFee")
private BigDecimal costDuty;
//报关费
@JSONField(name = "clearanceGoodsFee")
private BigDecimal costGoodsClearance;
//总费用
@JSONField(name = "totalPrices")
private BigDecimal costFirst;
}
......@@ -2,15 +2,12 @@ package com.bailuntec.job;
import com.alibaba.fastjson.JSON;
import com.bailuntec.domain.entity.DcBaseCostFirst;
import com.bailuntec.domain.entity.DcBaseSku;
import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.domain.example.DcBaseCostFirstExample;
import com.bailuntec.domain.example.DcBaseSkuExample;
import com.bailuntec.domain.pojo.CostFirstData;
import com.bailuntec.domain.pojo.CostFirstResult;
import com.bailuntec.domain.pojo.CostFirstSku;
import com.bailuntec.mapper.DcBaseCostFirstMapper;
import com.bailuntec.mapper.DcBaseSkuMapper;
import com.bailuntec.mapper.JobPointLogMapper;
import com.bailuntec.support.PointJob;
import com.bailuntec.utils.OkHttpUtil;
......@@ -20,10 +17,10 @@ import com.dangdang.ddframe.job.api.ShardingContext;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
......@@ -37,13 +34,13 @@ public class SyncCostFirstJob extends PointJob {
public void executeJob(ShardingContext shardingContext, JobPointLog jobPointLog) {
OkHttpClient client = OkHttpUtil.getInstance();
HashMap<String, String> map = new HashMap<>();
map.put("startTime",jobPointLog.getStartTime().minusMinutes(3).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
map.put("endTime",jobPointLog.getEndTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
map.put("startTime", jobPointLog.getStartTime().minusMinutes(3).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
map.put("endTime", jobPointLog.getEndTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
Integer totalPage = 0;
do {
map.put("currentPage",jobPointLog.getPageIndex().toString());
map.put("currentPage", jobPointLog.getPageIndex().toString());
Request request = new Request.Builder()
.url(OkHttpUtil.attachHttpGetParams(propertiesUtil.getPropertyAsString("COST_FIRST_URL"),map))
.url(OkHttpUtil.attachHttpGetParams(propertiesUtil.getPropertyAsString("COST_FIRST_URL"), map))
.get()
.addHeader("Content-Type", "application/json")
.addHeader("cache-control", "no-cache")
......@@ -64,7 +61,7 @@ public class SyncCostFirstJob extends PointJob {
if (StringUtils.isNotBlank(result)) {
CostFirstResult costFirstResult = JSON.parseObject(result, CostFirstResult.class);
totalPage = costFirstResult.getPageCount();
if (costFirstResult.getData() !=null && costFirstResult.getData().size() > 0) {
if (costFirstResult.getData() != null && costFirstResult.getData().size() > 0) {
handleCostFirstData(costFirstResult.getData());
}
} else {
......@@ -82,64 +79,37 @@ public class SyncCostFirstJob extends PointJob {
}
private void handleCostFirstData(List<CostFirstData> costFirstDataList) {
try {
DcBaseCostFirstMapper baseCostFirstMapper = SessionUtil.getSession().getMapper(DcBaseCostFirstMapper.class);
for (CostFirstData costFirstData : costFirstDataList) {
costFirstData.setCostDuty(costFirstData.getCostDuty().setScale(3, RoundingMode.HALF_EVEN));
costFirstData.setCostCustomsClearance(costFirstData.getCostCustomsClearance().setScale(3, RoundingMode.HALF_EVEN));
costFirstData.setCostGoodsClearance(costFirstData.getCostGoodsClearance().setScale(3, RoundingMode.HALF_EVEN));
costFirstData.setCostWeight(costFirstData.getCostWeight().setScale(3, RoundingMode.HALF_EVEN));
costFirstData.setCostFuel(costFirstData.getCostFuel().setScale(3, RoundingMode.HALF_EVEN));
costFirstData.setCostFirst(costFirstData.getCostFirst().setScale(3, RoundingMode.HALF_EVEN));
DcBaseCostFirst dcBaseCostFirst = new DcBaseCostFirst();
dcBaseCostFirst.setBoxId(costFirstData.getBoxId());
dcBaseCostFirst.setChannelId(costFirstData.getChannelId());
dcBaseCostFirst.setChannelOrderId(costFirstData.getChannelOrderId());
dcBaseCostFirst.setWarehouseCode(costFirstData.getWarehouseCode());
if (costFirstData.getSkus() != null && costFirstData.getSkus().size() > 0) {
HashMap<String, BigDecimal> map = new HashMap<>();
/*
* 先算出总重量, 再按重量占总重量平摊
*/
BigDecimal totalWeight = null;
List<CostFirstSku> skus = costFirstData.getSkus();
if (skus != null && skus.size() > 0) {
for (CostFirstSku costFirstSku : skus) {
dcBaseCostFirst.setBailunSku(costFirstSku.getBailunSku());
dcBaseCostFirst.setQuantity(costFirstSku.getQuantity());
try {
DcBaseSkuMapper dcBaseSkuMapper = SessionUtil.getSession().getMapper(DcBaseSkuMapper.class);
totalWeight = BigDecimal.ZERO;
for (CostFirstSku sku : costFirstData.getSkus()) {
DcBaseSku dcBaseSku = dcBaseSkuMapper.selectOneByExample(DcBaseSkuExample.newAndCreateCriteria().andBailunSkuEqualTo(sku.getBailunSku()).example());
BigDecimal weight = dcBaseSku.getWeight().multiply(BigDecimal.valueOf(sku.getQuantity()));
map.put(sku.getBailunSku(), weight);
totalWeight = totalWeight.add(weight);
}
BeanUtils.copyProperties(dcBaseCostFirst, costFirstData);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("MYBATIS操作DB查询SKU信息失败");
} finally {
SessionUtil.closeSession();
}
BigDecimal totalRatioCostFrist = BigDecimal.ZERO;
try {
DcBaseCostFirstMapper baseCostFirstMapper = SessionUtil.getSession().getMapper(DcBaseCostFirstMapper.class);
for (int i = 0; i < costFirstData.getSkus().size(); i++) {
dcBaseCostFirst.setBailunSku(costFirstData.getSkus().get(i).getBailunSku());
dcBaseCostFirst.setQuantity(costFirstData.getSkus().get(i).getQuantity());
BigDecimal weight = map.get(costFirstData.getSkus().get(i).getBailunSku());
if (totalWeight.compareTo(BigDecimal.ZERO) == 1) {
BigDecimal weightRatio = weight.divide(totalWeight, 4, RoundingMode.HALF_EVEN);
dcBaseCostFirst.setRatioWeight(weightRatio);
BigDecimal skuCostFirst = costFirstData.getCostFirst().multiply(weightRatio).setScale(3, RoundingMode.HALF_EVEN);
dcBaseCostFirst.setCostFirst(skuCostFirst);
if (i == costFirstData.getSkus().size() - 1) {
dcBaseCostFirst.setCostFirst(costFirstData.getCostFirst().subtract(totalRatioCostFrist));
throw new RuntimeException("BeanUtils.copyProperties失败, ChannelId是" + costFirstData.getChannelId());
}
totalRatioCostFrist = totalRatioCostFrist.add(skuCostFirst);
int i1 = baseCostFirstMapper.updateByExampleSelective(dcBaseCostFirst, DcBaseCostFirstExample.newAndCreateCriteria().andBailunSkuEqualTo(dcBaseCostFirst.getBailunSku()).andChannelIdEqualTo(dcBaseCostFirst.getChannelId()).example());
if (i1 == 0) {
int i = baseCostFirstMapper.updateByExampleSelective(dcBaseCostFirst, DcBaseCostFirstExample.newAndCreateCriteria().andBailunSkuEqualTo(dcBaseCostFirst.getBailunSku()).andChannelIdEqualTo(dcBaseCostFirst.getChannelId()).example());
if (i == 0) {
baseCostFirstMapper.insertSelective(dcBaseCostFirst);
}
} else {
throw new RuntimeException("算头程费占比时SKU总重量为0, ChannelId是" + costFirstData.getChannelId());
}
}
}
} catch (RuntimeException e) {
throw new RuntimeException("MYBATIS操作DB更新插入数据失败, ChannelId是" + costFirstData.getChannelId(),e);
throw new RuntimeException("MYBATIS操作DB更新插入数据失败",e);
} finally {
SessionUtil.closeSession();
}
}
}
}
}
......@@ -54,11 +54,47 @@ public class DcBaseCostFirst {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_cost_first.bailun_sku
* This field corresponds to the database column dc_base_cost_first.cost_goods_clearance
*
* @mbg.generated
*/
private String bailunSku;
private BigDecimal costGoodsClearance;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_cost_first.cost_duty
*
* @mbg.generated
*/
private BigDecimal costDuty;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_cost_first.cost_customs_clearance
*
* @mbg.generated
*/
private BigDecimal costCustomsClearance;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_cost_first.cost_weight
*
* @mbg.generated
*/
private BigDecimal costWeight;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_cost_first.cost_fuel
*
* @mbg.generated
*/
private BigDecimal costFuel;
/**
*
......@@ -72,6 +108,15 @@ public class DcBaseCostFirst {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_cost_first.bailun_sku
*
* @mbg.generated
*/
private String bailunSku;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_cost_first.quantity
*
* @mbg.generated
......@@ -81,11 +126,11 @@ public class DcBaseCostFirst {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_cost_first.ratio_weight
* This field corresponds to the database column dc_base_cost_first.sku_weight
*
* @mbg.generated
*/
private BigDecimal ratioWeight;
private BigDecimal skuWeight;
/**
* This method was generated by MyBatis Generator.
......@@ -104,10 +149,15 @@ public class DcBaseCostFirst {
sb.append(", channelId=").append(channelId);
sb.append(", boxId=").append(boxId);
sb.append(", costFirst=").append(costFirst);
sb.append(", bailunSku=").append(bailunSku);
sb.append(", costGoodsClearance=").append(costGoodsClearance);
sb.append(", costDuty=").append(costDuty);
sb.append(", costCustomsClearance=").append(costCustomsClearance);
sb.append(", costWeight=").append(costWeight);
sb.append(", costFuel=").append(costFuel);
sb.append(", warehouseCode=").append(warehouseCode);
sb.append(", bailunSku=").append(bailunSku);
sb.append(", quantity=").append(quantity);
sb.append(", ratioWeight=").append(ratioWeight);
sb.append(", skuWeight=").append(skuWeight);
sb.append("]");
return sb.toString();
}
......@@ -135,10 +185,15 @@ public class DcBaseCostFirst {
&& (this.getChannelId() == null ? other.getChannelId() == null : this.getChannelId().equals(other.getChannelId()))
&& (this.getBoxId() == null ? other.getBoxId() == null : this.getBoxId().equals(other.getBoxId()))
&& (this.getCostFirst() == null ? other.getCostFirst() == null : this.getCostFirst().equals(other.getCostFirst()))
&& (this.getBailunSku() == null ? other.getBailunSku() == null : this.getBailunSku().equals(other.getBailunSku()))
&& (this.getCostGoodsClearance() == null ? other.getCostGoodsClearance() == null : this.getCostGoodsClearance().equals(other.getCostGoodsClearance()))
&& (this.getCostDuty() == null ? other.getCostDuty() == null : this.getCostDuty().equals(other.getCostDuty()))
&& (this.getCostCustomsClearance() == null ? other.getCostCustomsClearance() == null : this.getCostCustomsClearance().equals(other.getCostCustomsClearance()))
&& (this.getCostWeight() == null ? other.getCostWeight() == null : this.getCostWeight().equals(other.getCostWeight()))
&& (this.getCostFuel() == null ? other.getCostFuel() == null : this.getCostFuel().equals(other.getCostFuel()))
&& (this.getWarehouseCode() == null ? other.getWarehouseCode() == null : this.getWarehouseCode().equals(other.getWarehouseCode()))
&& (this.getBailunSku() == null ? other.getBailunSku() == null : this.getBailunSku().equals(other.getBailunSku()))
&& (this.getQuantity() == null ? other.getQuantity() == null : this.getQuantity().equals(other.getQuantity()))
&& (this.getRatioWeight() == null ? other.getRatioWeight() == null : this.getRatioWeight().equals(other.getRatioWeight()));
&& (this.getSkuWeight() == null ? other.getSkuWeight() == null : this.getSkuWeight().equals(other.getSkuWeight()));
}
/**
......@@ -156,10 +211,15 @@ public class DcBaseCostFirst {
result = prime * result + ((getChannelId() == null) ? 0 : getChannelId().hashCode());
result = prime * result + ((getBoxId() == null) ? 0 : getBoxId().hashCode());
result = prime * result + ((getCostFirst() == null) ? 0 : getCostFirst().hashCode());
result = prime * result + ((getBailunSku() == null) ? 0 : getBailunSku().hashCode());
result = prime * result + ((getCostGoodsClearance() == null) ? 0 : getCostGoodsClearance().hashCode());
result = prime * result + ((getCostDuty() == null) ? 0 : getCostDuty().hashCode());
result = prime * result + ((getCostCustomsClearance() == null) ? 0 : getCostCustomsClearance().hashCode());
result = prime * result + ((getCostWeight() == null) ? 0 : getCostWeight().hashCode());
result = prime * result + ((getCostFuel() == null) ? 0 : getCostFuel().hashCode());
result = prime * result + ((getWarehouseCode() == null) ? 0 : getWarehouseCode().hashCode());
result = prime * result + ((getBailunSku() == null) ? 0 : getBailunSku().hashCode());
result = prime * result + ((getQuantity() == null) ? 0 : getQuantity().hashCode());
result = prime * result + ((getRatioWeight() == null) ? 0 : getRatioWeight().hashCode());
result = prime * result + ((getSkuWeight() == null) ? 0 : getSkuWeight().hashCode());
return result;
}
}
\ No newline at end of file
......@@ -161,6 +161,15 @@ public class DcBaseCrmRefund {
private BigDecimal amountRefundRmb;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_crm_refund.crm_id
*
* @mbg.generated
*/
private Integer crmId;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_crm_refund
*
......@@ -189,6 +198,7 @@ public class DcBaseCrmRefund {
sb.append(", gmtModified=").append(gmtModified);
sb.append(", linked=").append(linked);
sb.append(", amountRefundRmb=").append(amountRefundRmb);
sb.append(", crmId=").append(crmId);
sb.append("]");
return sb.toString();
}
......@@ -227,7 +237,8 @@ public class DcBaseCrmRefund {
&& (this.getGmtCreate() == null ? other.getGmtCreate() == null : this.getGmtCreate().equals(other.getGmtCreate()))
&& (this.getGmtModified() == null ? other.getGmtModified() == null : this.getGmtModified().equals(other.getGmtModified()))
&& (this.getLinked() == null ? other.getLinked() == null : this.getLinked().equals(other.getLinked()))
&& (this.getAmountRefundRmb() == null ? other.getAmountRefundRmb() == null : this.getAmountRefundRmb().equals(other.getAmountRefundRmb()));
&& (this.getAmountRefundRmb() == null ? other.getAmountRefundRmb() == null : this.getAmountRefundRmb().equals(other.getAmountRefundRmb()))
&& (this.getCrmId() == null ? other.getCrmId() == null : this.getCrmId().equals(other.getCrmId()));
}
/**
......@@ -257,6 +268,7 @@ public class DcBaseCrmRefund {
result = prime * result + ((getGmtModified() == null) ? 0 : getGmtModified().hashCode());
result = prime * result + ((getLinked() == null) ? 0 : getLinked().hashCode());
result = prime * result + ((getAmountRefundRmb() == null) ? 0 : getAmountRefundRmb().hashCode());
result = prime * result + ((getCrmId() == null) ? 0 : getCrmId().hashCode());
return result;
}
}
\ No newline at end of file
......@@ -1460,6 +1460,66 @@ public class DcBaseCrmRefundExample {
addCriterion("amount_refund_rmb not between", value1, value2, "amountRefundRmb");
return (Criteria) this;
}
public Criteria andCrmIdIsNull() {
addCriterion("crm_id is null");
return (Criteria) this;
}
public Criteria andCrmIdIsNotNull() {
addCriterion("crm_id is not null");
return (Criteria) this;
}
public Criteria andCrmIdEqualTo(Integer value) {
addCriterion("crm_id =", value, "crmId");
return (Criteria) this;
}
public Criteria andCrmIdNotEqualTo(Integer value) {
addCriterion("crm_id <>", value, "crmId");
return (Criteria) this;
}
public Criteria andCrmIdGreaterThan(Integer value) {
addCriterion("crm_id >", value, "crmId");
return (Criteria) this;
}
public Criteria andCrmIdGreaterThanOrEqualTo(Integer value) {
addCriterion("crm_id >=", value, "crmId");
return (Criteria) this;
}
public Criteria andCrmIdLessThan(Integer value) {
addCriterion("crm_id <", value, "crmId");
return (Criteria) this;
}
public Criteria andCrmIdLessThanOrEqualTo(Integer value) {
addCriterion("crm_id <=", value, "crmId");
return (Criteria) this;
}
public Criteria andCrmIdIn(List<Integer> values) {
addCriterion("crm_id in", values, "crmId");
return (Criteria) this;
}
public Criteria andCrmIdNotIn(List<Integer> values) {
addCriterion("crm_id not in", values, "crmId");
return (Criteria) this;
}
public Criteria andCrmIdBetween(Integer value1, Integer value2) {
addCriterion("crm_id between", value1, value2, "crmId");
return (Criteria) this;
}
public Criteria andCrmIdNotBetween(Integer value1, Integer value2) {
addCriterion("crm_id not between", value1, value2, "crmId");
return (Criteria) this;
}
}
/**
......
......@@ -87,6 +87,6 @@ public class CommonSkuCondition {
/// </summary>
private Integer isResultWare;
//是否上传
public Integer IsUpApi;
}
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