调整转结,在转结时使用最新的单价转结
parent
0935c05b84
commit
4788a2fae0
|
|
@ -154,7 +154,7 @@ public class CheckUndonOrderclusterJob implements Job {
|
|||
}
|
||||
}
|
||||
|
||||
log.debug("自动转结完成, %s");
|
||||
log.debug("自动转结完成");
|
||||
} else {
|
||||
log.debug("无未完成的订单");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -723,26 +723,10 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
BigDecimal ofsset_weight = model.getTotalWeight().subtract(oldobj.getTotalWeight()); // 本次修改增加的重量
|
||||
BigDecimal offset_total_price = ofsset_weight.multiply(oldobj.getUnitPrice()); // 本次修改增加的价格
|
||||
plan_total_price = offset_total_price.add(undo_price); // 剩余未完成金额加上本次增加的金额
|
||||
|
||||
// 线上调试
|
||||
log.debug("已完成:%s", overweight);
|
||||
log.debug("旧配额:%s", oldobj.getTotalWeight());
|
||||
log.debug("本调整:%s", ofsset_weight);
|
||||
log.debug("本调整总价:%s", offset_total_price);
|
||||
log.debug("客户未完总价:%s", undo_price);
|
||||
log.debug("调整后总价:%s", plan_total_price);
|
||||
} else { // 修改后比原来的小
|
||||
BigDecimal ofsset_weight = oldobj.getTotalWeight().subtract(model.getTotalWeight()); // 本次修改增加的重量
|
||||
BigDecimal offset_total_price = ofsset_weight.multiply(oldobj.getUnitPrice()); // 本次修改增加的价格
|
||||
plan_total_price = undo_price.subtract(offset_total_price); // 剩余未完成金额加上本次增加的金额
|
||||
|
||||
// 线上调试
|
||||
log.debug("已完成:%s", overweight);
|
||||
log.debug("旧配额:%s", oldobj.getTotalWeight());
|
||||
log.debug("本调整:%s", ofsset_weight);
|
||||
log.debug("本调整总价:%s", offset_total_price);
|
||||
log.debug("客户未完总价:%s", undo_price);
|
||||
log.debug("调整后总价:%s", plan_total_price);
|
||||
}
|
||||
|
||||
if (plan_total_price.compareTo(prepayCustomer.getSurplus()) > 0) {
|
||||
|
|
@ -951,6 +935,12 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
return Result.failed("不是预付费用户");
|
||||
}
|
||||
|
||||
// 当前配额指定的客户、超市、品类对应的单价
|
||||
BigDecimal unitprice = CustomerSupermarketProductService.me.getUnitPrice(oldobj.getCustomerId(), oldobj.getSupermarketId(), oldobj.getProductId());
|
||||
if (unitprice == null) {
|
||||
return Result.failed("未配置商品单价");
|
||||
}
|
||||
|
||||
// 按客户统计已完成量
|
||||
BigDecimal over_weight = OrderclusterService.me.getOverWeight(oldobj.getId()); // 按客户找集团订单已完成量
|
||||
BigDecimal surplus_weight = oldobj.getTotalWeight().subtract(over_weight); // 剩余未完成量
|
||||
|
|
@ -971,16 +961,18 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
BigDecimal plan_total_price;
|
||||
if (total_weight.compareTo(surplus_weight) > 0) { // 修改后,比原来的大
|
||||
BigDecimal surplus_weight_1 = total_weight.subtract(surplus_weight); // 本次修改增加的重量
|
||||
BigDecimal offset_total_price = surplus_weight_1.multiply(oldobj.getUnitPrice()); // 本次修改增加的价格
|
||||
BigDecimal offset_total_price = surplus_weight_1.multiply(unitprice); // 本次修改增加的价格
|
||||
plan_total_price = offset_total_price.add(undo_price); // 剩余未完成金额加上本次增加的金额
|
||||
} else { // 修改后比原来的小
|
||||
BigDecimal surplus_weight_1 = surplus_weight.subtract(total_weight); // 本次修改增加的重量
|
||||
BigDecimal offset_total_price = surplus_weight_1.multiply(oldobj.getUnitPrice()); // 本次修改增加的价格
|
||||
BigDecimal offset_total_price = surplus_weight_1.multiply(unitprice); // 本次修改增加的价格
|
||||
plan_total_price = undo_price.subtract(offset_total_price); // 剩余未完成金额加上本次增加的金额
|
||||
}
|
||||
|
||||
if (plan_total_price.compareTo(prepayCustomer.getSurplus()) > 0) {
|
||||
return Result.failedstr("共计总配额达 %.2f元,客户余额(%.2f元)不足", plan_total_price, prepayCustomer.getSurplus());
|
||||
BigDecimal availableBalance = RefundDetailService.me.getAvailableBalance(prepayCustomer.getCustomerId(), prepayCustomer.getSurplus());
|
||||
|
||||
if (plan_total_price.compareTo(availableBalance) > 0) {
|
||||
return Result.failedstr("共计总配额达 %.2f元,客户可用余额(%.2f元)不足", plan_total_price, availableBalance);
|
||||
}
|
||||
|
||||
List<OrderclusterTruck> octs = OrderclusterTruck.dao.find("select * from ordercluster_truck t where t.ordercluster_id = ?", ordercluster_id);
|
||||
|
|
@ -1053,6 +1045,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
forwardoldobj[0] = oldobj.clone();
|
||||
forwardoldobj[0].setId(null); // 等待数据库自增长
|
||||
forwardoldobj[0].setUuid(StrKit.getRandomUUID());
|
||||
forwardoldobj[0].setUnitPrice(unitprice); // 用最新的单价更新
|
||||
forwardoldobj[0].setTotalWeight(total_weight);
|
||||
forwardoldobj[0].setCutoffTime(cutoff_time);
|
||||
forwardoldobj[0].setCreateTime(now); // 当前系统时间
|
||||
|
|
@ -1065,6 +1058,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
} else {
|
||||
// 已有的,直接更新重量
|
||||
forwardoldobj[0].setTotalWeight(forwardoldobj[0].getTotalWeight().add(total_weight));
|
||||
forwardoldobj[0].setUnitPrice(unitprice); // 用最新的单价更新
|
||||
|
||||
ret = forwardoldobj[0].update();
|
||||
synctask.addUpdateData(forwardoldobj[0]);
|
||||
|
|
@ -1143,6 +1137,12 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
return Result.failed("已经完结或者取消的,不能再修改");
|
||||
}
|
||||
|
||||
// 当前配额指定的客户、超市、品类对应的单价
|
||||
BigDecimal unitprice = CustomerSupermarketProductService.me.getUnitPrice(oldobj.getCustomerId(), oldobj.getSupermarketId(), oldobj.getProductId());
|
||||
if (unitprice == null) {
|
||||
return Result.failed("未配置商品单价");
|
||||
}
|
||||
|
||||
// 按客户统计已完成量
|
||||
BigDecimal over_weight = OrderclusterService.me.getOverWeight(oldobj.getId()); // 按客户找集团订单已完成量
|
||||
BigDecimal surplus_weight = oldobj.getTotalWeight().subtract(over_weight); // 剩余未完成量
|
||||
|
|
@ -1247,6 +1247,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
forwardoldobj = oldobj.clone();
|
||||
forwardoldobj.setId(null); // 等待数据库自增长
|
||||
forwardoldobj.setUuid(StrKit.getRandomUUID());
|
||||
forwardoldobj.setUnitPrice(unitprice);
|
||||
forwardoldobj.setTotalWeight(total_weight);
|
||||
forwardoldobj.setCutoffTime(cutoff_time);
|
||||
forwardoldobj.setCreateTime(now); // 当前系统时间
|
||||
|
|
@ -1259,6 +1260,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
} else {
|
||||
// 已有的,直接更新重量
|
||||
forwardoldobj.setTotalWeight(forwardoldobj.getTotalWeight().add(total_weight));
|
||||
forwardoldobj.setUnitPrice(unitprice);
|
||||
|
||||
ret = forwardoldobj.update();
|
||||
synctask.addUpdateData(forwardoldobj);
|
||||
|
|
|
|||
Loading…
Reference in New Issue