This commit is contained in:
van
2026-05-16 22:03:59 +08:00
parent 746be8c633
commit 17ec7fa131
4 changed files with 23 additions and 7 deletions

View File

@@ -173,6 +173,10 @@ public class JDOrder extends BaseEntity {
/** 利润是否手动锁定1 是:保存时不再自动重算) */
private Integer profitManual;
/** 额外成本(计入自动利润:从 netReceipt 成本中再减去此项,默认 0 */
@Excel(name = "额外成本")
private Double extraCost;
}

View File

@@ -46,7 +46,7 @@ public class JDOrderProfitServiceImpl implements IJDOrderProfitService {
if ("H-TF".equals(mark)) {
if (!profitLocked) {
// 与 F 单一致:利润 = 对客实收 (下单付款 后返)。列表未填售价时默认直款并从型号配置取价。
// 与 F 单一致:利润 = 对客实收 (下单付款 后返) 额外成本。列表未填售价时默认直款并从型号配置取价。
String type = order.getSellingPriceType();
if (type == null || type.isEmpty()) {
order.setSellingPriceType("direct");
@@ -61,7 +61,9 @@ public class JDOrderProfitServiceImpl implements IJDOrderProfitService {
} else {
String buyer = order.getBuyer();
boolean fan = buyer != null && buyer.trim().startsWith("凡-");
order.setProfit(fan ? 65.0 : 15.0);
double base = fan ? 65.0 : 15.0;
order.setProfit(BigDecimal.valueOf(base - extraCostOrZero(order))
.setScale(2, RoundingMode.HALF_UP).doubleValue());
}
}
return;
@@ -127,13 +129,19 @@ public class JDOrderProfitServiceImpl implements IJDOrderProfitService {
order.setProfit(null);
return;
}
// 成本 = 下单付款 - 后返金额;利润 = 对客实收(直款=售价,闲鱼=扣点后的到账)- 成本
// 成本 = 下单付款 - 后返金额;利润 = 对客实收 成本 额外成本
double cost = BigDecimal.valueOf(pay).subtract(BigDecimal.valueOf(rebate))
.setScale(2, RoundingMode.HALF_UP).doubleValue();
order.setProfit(BigDecimal.valueOf(netReceipt - cost)
double net = netReceipt - cost - extraCostOrZero(order);
order.setProfit(BigDecimal.valueOf(net)
.setScale(2, RoundingMode.HALF_UP).doubleValue());
}
private static double extraCostOrZero(JDOrder order) {
Double e = order == null ? null : order.getExtraCost();
return e != null ? e : 0.0;
}
@Override
public int syncAutoProfitIfChanged(List<Long> ids) {
if (ids == null || ids.isEmpty()) {

View File

@@ -42,6 +42,7 @@
<result property="profit" column="profit"/>
<result property="sellingPriceManual" column="selling_price_manual"/>
<result property="profitManual" column="profit_manual"/>
<result property="extraCost" column="extra_cost"/>
</resultMap>
<sql id="selectJDOrderBase">
@@ -50,7 +51,7 @@
is_refunded, refund_date, is_refund_received, refund_received_date, is_rebate_received, rebate_received_date,
is_price_protected, price_protected_date, is_invoice_opened, invoice_opened_date, is_review_posted, review_posted_date,
rebate_remark_json, rebate_remark_has_abnormal,
selling_price_type, selling_price, profit, selling_price_manual, profit_manual
selling_price_type, selling_price, profit, selling_price_manual, profit_manual, extra_cost
from jd_order
</sql>
@@ -174,7 +175,7 @@
order_id, buyer, order_time, create_time, update_time, status, is_count_enabled, third_party_order_no, jingfen_actual_price,
is_refunded, refund_date, is_refund_received, refund_received_date, is_rebate_received, rebate_received_date,
is_price_protected, price_protected_date, is_invoice_opened, invoice_opened_date, is_review_posted, review_posted_date,
selling_price_type, selling_price, profit, selling_price_manual, profit_manual
selling_price_type, selling_price, profit, selling_price_manual, profit_manual, extra_cost
) values (
#{remark}, #{distributionMark}, #{modelNumber}, #{link},
#{paymentAmount}, #{rebateAmount}, #{address}, #{logisticsLink},
@@ -182,7 +183,7 @@
#{orderId}, #{buyer}, #{orderTime}, now(), now(), #{status}, #{isCountEnabled}, #{thirdPartyOrderNo}, #{jingfenActualPrice},
#{isRefunded}, #{refundDate}, #{isRefundReceived}, #{refundReceivedDate}, #{isRebateReceived}, #{rebateReceivedDate},
#{isPriceProtected}, #{priceProtectedDate}, #{isInvoiceOpened}, #{invoiceOpenedDate}, #{isReviewPosted}, #{reviewPostedDate},
#{sellingPriceType}, #{sellingPrice}, #{profit}, #{sellingPriceManual}, #{profitManual}
#{sellingPriceType}, #{sellingPrice}, #{profit}, #{sellingPriceManual}, #{profitManual}, #{extraCost,jdbcType=DOUBLE}
)
</insert>
@@ -220,6 +221,7 @@
<if test="reviewPostedDate != null"> review_posted_date = #{reviewPostedDate},</if>
<if test="rebateRemarkJson != null"> rebate_remark_json = #{rebateRemarkJson},</if>
<if test="rebateRemarkHasAbnormal != null"> rebate_remark_has_abnormal = #{rebateRemarkHasAbnormal},</if>
<if test="extraCost != null"> extra_cost = #{extraCost},</if>
<if test="params != null and params.applyProfitFields != null and params.applyProfitFields == true">
selling_price_type = #{sellingPriceType,jdbcType=VARCHAR},
selling_price = #{sellingPrice,jdbcType=DOUBLE},