|
@@ -119,12 +119,13 @@ public class OrderCloseEventHandler implements AwoaraEventHandler<OrderInfoObjec
|
|
|
* @param washOrder
|
|
* @param washOrder
|
|
|
*/
|
|
*/
|
|
|
private void doLocalSplit(WashOrder washOrder) {
|
|
private void doLocalSplit(WashOrder washOrder) {
|
|
|
- // 平台手续费10%
|
|
|
|
|
|
|
+ log.info("订单:{},执行(本店)分账", washOrder.getOrderId());
|
|
|
|
|
+ // 平台技术服务费10%
|
|
|
var platformAmount = (int) (washOrder.getAmount() * 0.1);
|
|
var platformAmount = (int) (washOrder.getAmount() * 0.1);
|
|
|
// 解冻金额
|
|
// 解冻金额
|
|
|
- var amount = (int) (washOrder.getAmount() * 0.3);
|
|
|
|
|
|
|
+ var unfreezeAmount = (int) (washOrder.getAmount() * 0.3);
|
|
|
stationAccountService.lambdaUpdate()
|
|
stationAccountService.lambdaUpdate()
|
|
|
- .setSql("balance = balance + {0}, frozen_amount = frozen_amount - {1}", amount - platformAmount, amount)
|
|
|
|
|
|
|
+ .setSql("balance = balance + {0}, frozen_amount = frozen_amount - {1}", unfreezeAmount - platformAmount, unfreezeAmount)
|
|
|
.eq(StationAccount::getStationId, washOrder.getStationId())
|
|
.eq(StationAccount::getStationId, washOrder.getStationId())
|
|
|
.update();
|
|
.update();
|
|
|
|
|
|
|
@@ -148,7 +149,7 @@ public class OrderCloseEventHandler implements AwoaraEventHandler<OrderInfoObjec
|
|
|
.setFromStationId(washOrder.getStationId())
|
|
.setFromStationId(washOrder.getStationId())
|
|
|
.setToStationId(washOrder.getStationId())
|
|
.setToStationId(washOrder.getStationId())
|
|
|
.setTradeNo(washOrder.getOrderId())
|
|
.setTradeNo(washOrder.getOrderId())
|
|
|
- .setAmount(amount)
|
|
|
|
|
|
|
+ .setAmount(unfreezeAmount)
|
|
|
.setType(SplitRecord.TYPE_UNFREEZE);
|
|
.setType(SplitRecord.TYPE_UNFREEZE);
|
|
|
|
|
|
|
|
// 基本户入账
|
|
// 基本户入账
|
|
@@ -156,7 +157,7 @@ public class OrderCloseEventHandler implements AwoaraEventHandler<OrderInfoObjec
|
|
|
.setFromStationId(washOrder.getStationId())
|
|
.setFromStationId(washOrder.getStationId())
|
|
|
.setToStationId(washOrder.getStationId())
|
|
.setToStationId(washOrder.getStationId())
|
|
|
.setTradeNo(washOrder.getOrderId())
|
|
.setTradeNo(washOrder.getOrderId())
|
|
|
- .setAmount(amount)
|
|
|
|
|
|
|
+ .setAmount(unfreezeAmount)
|
|
|
.setType(SplitRecord.TYPE_CONSUME);
|
|
.setType(SplitRecord.TYPE_CONSUME);
|
|
|
|
|
|
|
|
splitRecordService.saveBatch(List.of(splitRecord0, splitRecord1, splitRecord2));
|
|
splitRecordService.saveBatch(List.of(splitRecord0, splitRecord1, splitRecord2));
|
|
@@ -170,41 +171,45 @@ public class OrderCloseEventHandler implements AwoaraEventHandler<OrderInfoObjec
|
|
|
* @param stationId 用户归属的站点Id
|
|
* @param stationId 用户归属的站点Id
|
|
|
*/
|
|
*/
|
|
|
private void doCrossSplit(WashOrder washOrder, String stationId) {
|
|
private void doCrossSplit(WashOrder washOrder, String stationId) {
|
|
|
- var stationAccount = stationAccountService.getStationAccount(washOrder.getStationId());
|
|
|
|
|
- var splitAmount = (int) (washOrder.getAmount() * (0.3 - 0.1));
|
|
|
|
|
|
|
+ log.info("订单:{},执行(跨店)分账", washOrder.getOrderId());
|
|
|
|
|
+
|
|
|
|
|
+ // 平台技术服务费10%
|
|
|
|
|
+ var platformAmount = (int) (washOrder.getAmount() * 0.1);
|
|
|
|
|
+ // 解冻金额
|
|
|
|
|
+ var unfreezeAmount = (int) (washOrder.getAmount() * 0.3);
|
|
|
|
|
+
|
|
|
|
|
+ // 扣除平台技术服务费后总共用于分账的金额
|
|
|
|
|
+ var splitAmount = unfreezeAmount - platformAmount;
|
|
|
|
|
+
|
|
|
|
|
+ // 用户归属站点分账收入
|
|
|
var localAmount = (int) (splitAmount * 0.7);
|
|
var localAmount = (int) (splitAmount * 0.7);
|
|
|
|
|
+ // 当前消费站点分账收入
|
|
|
var crossAmount = splitAmount - localAmount;
|
|
var crossAmount = splitAmount - localAmount;
|
|
|
|
|
|
|
|
// 当前消费站点收入(跨店消费,原充值站点要分订单的70%)
|
|
// 当前消费站点收入(跨店消费,原充值站点要分订单的70%)
|
|
|
stationAccountService.lambdaUpdate()
|
|
stationAccountService.lambdaUpdate()
|
|
|
.setSql("balance = balance + {0}", crossAmount)
|
|
.setSql("balance = balance + {0}", crossAmount)
|
|
|
- .eq(StationAccount::getId, stationAccount.getId())
|
|
|
|
|
|
|
+ .eq(StationAccount::getStationId, washOrder.getStationId())
|
|
|
.update();
|
|
.update();
|
|
|
|
|
|
|
|
-// // 充值站点收入
|
|
|
|
|
-// stationAccountService.lambdaUpdate()
|
|
|
|
|
-// .setSql("balance = balance + {0}, frozen_amount = frozen_amount - {1}", localAmount, splitAmount)
|
|
|
|
|
-// .eq(InvestorAccount::getId, stationAccount.getId())
|
|
|
|
|
-// .update();
|
|
|
|
|
-//
|
|
|
|
|
-// // 充值站点支出
|
|
|
|
|
-// stationAccountService.lambdaUpdate()
|
|
|
|
|
-// .setSql("balance = balance - {0}", crossAmount)
|
|
|
|
|
-// .eq(InvestorAccount::getId, stationAccount.getId())
|
|
|
|
|
-// .update();
|
|
|
|
|
-
|
|
|
|
|
- // 以上充值站点的两次操作进行合并
|
|
|
|
|
- // 充值站点收入
|
|
|
|
|
|
|
+ // 用户归属站点收入
|
|
|
stationAccountService.lambdaUpdate()
|
|
stationAccountService.lambdaUpdate()
|
|
|
- .setSql("balance = balance + {0}, frozen_amount = frozen_amount - {1}", localAmount - crossAmount, splitAmount)
|
|
|
|
|
- .eq(StationAccount::getId, stationAccount.getId())
|
|
|
|
|
|
|
+ .setSql("balance = balance + {0}, frozen_amount = frozen_amount - {1}", localAmount, unfreezeAmount)
|
|
|
|
|
+ .eq(StationAccount::getStationId, stationId)
|
|
|
.update();
|
|
.update();
|
|
|
|
|
|
|
|
|
|
|
|
|
- // t_split_record 1.消费站点收入 2.归属站点收入 3.充值站点支出
|
|
|
|
|
|
|
+ // t_split_record 0.平台服务费收入 1.消费站点收入 2.归属站点收入 3.归属站点解冻
|
|
|
|
|
+ var splitRecord0 = new SplitRecord()
|
|
|
|
|
+ .setFromStationId(stationId)
|
|
|
|
|
+ .setToStationId(StationAccount.PLATFORM_STATION_ID)
|
|
|
|
|
+ .setTradeNo(washOrder.getOrderId())
|
|
|
|
|
+ .setAmount(platformAmount)
|
|
|
|
|
+ .setType(SplitRecord.TYPE_PLATFORM);
|
|
|
|
|
+
|
|
|
var splitRecord1 = new SplitRecord()
|
|
var splitRecord1 = new SplitRecord()
|
|
|
.setFromStationId(stationId)
|
|
.setFromStationId(stationId)
|
|
|
- .setToStationId(stationAccount.getStationId())
|
|
|
|
|
|
|
+ .setToStationId(washOrder.getStationId())
|
|
|
.setTradeNo(washOrder.getOrderId())
|
|
.setTradeNo(washOrder.getOrderId())
|
|
|
.setAmount(crossAmount)
|
|
.setAmount(crossAmount)
|
|
|
.setType(SplitRecord.TYPE_CONSUME);
|
|
.setType(SplitRecord.TYPE_CONSUME);
|
|
@@ -217,13 +222,13 @@ public class OrderCloseEventHandler implements AwoaraEventHandler<OrderInfoObjec
|
|
|
.setType(SplitRecord.TYPE_CONSUME);
|
|
.setType(SplitRecord.TYPE_CONSUME);
|
|
|
|
|
|
|
|
var splitRecord3 = new SplitRecord()
|
|
var splitRecord3 = new SplitRecord()
|
|
|
- .setFromStationId(stationAccount.getStationId())
|
|
|
|
|
- .setToStationId(stationAccount.getStationId())
|
|
|
|
|
|
|
+ .setFromStationId(stationId)
|
|
|
|
|
+ .setToStationId(washOrder.getStationId())
|
|
|
.setTradeNo(washOrder.getOrderId())
|
|
.setTradeNo(washOrder.getOrderId())
|
|
|
- .setAmount(splitAmount)
|
|
|
|
|
|
|
+ .setAmount(unfreezeAmount)
|
|
|
.setType(SplitRecord.TYPE_UNFREEZE);
|
|
.setType(SplitRecord.TYPE_UNFREEZE);
|
|
|
|
|
|
|
|
- splitRecordService.saveBatch(List.of(splitRecord1, splitRecord2, splitRecord3));
|
|
|
|
|
|
|
+ splitRecordService.saveBatch(List.of(splitRecord0, splitRecord1, splitRecord2, splitRecord3));
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|