|
|
@@ -2470,45 +2470,11 @@ class OrderController extends BaseController
|
|
|
$order->save();
|
|
|
$cg->payTime = $new;
|
|
|
$cg->save();
|
|
|
- //有修改账单日期需要更新到欠款变动明细,财务好对账,多个地方要同步修改,关键词to_change_custom_debt_pay_time
|
|
|
+ //有修改账单日期需要更新到欠款变动明细,财务好对账,多个地方要同步修改,关键词 to_change_custom_debt_pay_time
|
|
|
CustomDebtChangeClass::updateByCondition(['capitalType' => 10, 'relateId' => $id], ['payTime' => $new]);
|
|
|
|
|
|
//找到当前订单客户的账单日期为 $date 的所有订单,然后更新同天内的所有订单的 sameTimeIds(加此次要改变的订单的订单号$id)
|
|
|
- $customId = $order->customId;
|
|
|
- $startTime = $date . ' 00:00:00';
|
|
|
- $endTime = $date . ' 23:59:59';
|
|
|
- $dayOrders = OrderClass::getAllByCondition([
|
|
|
- 'customId' => $customId,
|
|
|
- 'payTime' => ['between', [$startTime, $endTime]]
|
|
|
- ], 'id ASC', 'id, sameTimeIds');
|
|
|
-
|
|
|
- $ids = [];
|
|
|
- if (!empty($dayOrders)) {
|
|
|
- $ids = array_column($dayOrders, 'id');
|
|
|
- }
|
|
|
- // 确保当前订单ID在列表中
|
|
|
- if (!in_array($id, $ids)) {
|
|
|
- $ids[] = $id;
|
|
|
- }
|
|
|
- // 排序并去重
|
|
|
- sort($ids);
|
|
|
- $ids = array_unique($ids);
|
|
|
- $sameTimeIdsStr = implode(',', $ids);
|
|
|
- // 更新所有相关订单
|
|
|
- if (!empty($ids)) {
|
|
|
- OrderClass::updateByIds($ids, ['sameTimeIds' => $sameTimeIdsStr]);
|
|
|
- }
|
|
|
-
|
|
|
- //从原先同天内的订单中删除此次要改变的订单的订单号$id
|
|
|
- $oldSameTimeIds = $order->sameTimeIds;
|
|
|
- $oldSameTimeIdsArr = explode(',', $oldSameTimeIds);
|
|
|
- if (in_array($id, $oldSameTimeIdsArr)) {
|
|
|
- $oldSameTimeIdsArr = array_diff($oldSameTimeIdsArr, [$id]);
|
|
|
- $oldSameTimeIdsStr = implode(',', $oldSameTimeIdsArr);
|
|
|
- if (!empty($oldSameTimeIdsArr)) {
|
|
|
- OrderClass::updateByIds($oldSameTimeIdsArr, ['sameTimeIds' => $oldSameTimeIdsStr]);
|
|
|
- }
|
|
|
- }
|
|
|
+ OrderClass::updateSameTimeIds($id, $order->customId, $date, $order->sameTimeIds);
|
|
|
|
|
|
$transaction->commit();
|
|
|
util::complete('修改成功');
|