|
|
@@ -2446,50 +2446,60 @@ class OrderController extends BaseController
|
|
|
if (empty($date)) {
|
|
|
util::fail('请选择日期');
|
|
|
}
|
|
|
- $order = OrderClass::getById($id, true);
|
|
|
- if (empty($order)) {
|
|
|
- util::fail('没有找到订单');
|
|
|
- }
|
|
|
- if ($order->mainId != $this->mainId) {
|
|
|
- util::fail('不是你的订单');
|
|
|
- }
|
|
|
- if ($order->payStatus == 0) {
|
|
|
- util::fail('没有确认的订单');
|
|
|
- }
|
|
|
- $mainId = $this->mainId;
|
|
|
- //超管或者约定的人可以修改日期
|
|
|
- if (getenv('YII_ENV') == 'production') {
|
|
|
- if (in_array($mainId, [23390])) {
|
|
|
- if (!in_array($this->adminId, [24586, 23960, 24043])) {
|
|
|
- util::fail('你不能修改哦');
|
|
|
- }
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();//开启事务
|
|
|
+ try {
|
|
|
+ $order = OrderClass::getById($id, true);
|
|
|
+ if (empty($order)) {
|
|
|
+ util::fail('没有找到订单');
|
|
|
}
|
|
|
- } else {
|
|
|
- if (in_array($mainId, [644])) {
|
|
|
- if (!in_array($this->adminId, [919])) {
|
|
|
+ if ($order->mainId != $this->mainId) {
|
|
|
+ util::fail('不是你的订单');
|
|
|
+ }
|
|
|
+ if ($order->payStatus == 0) {
|
|
|
+ util::fail('没有确认的订单');
|
|
|
+ }
|
|
|
+ $mainId = $this->mainId;
|
|
|
+ //超管或者约定的人可以修改日期
|
|
|
+ if (getenv('YII_ENV') == 'production') {
|
|
|
+ if (in_array($mainId, [23390])) {
|
|
|
+ if (!in_array($this->adminId, [24586, 23960, 24043])) {
|
|
|
+ util::fail('你不能修改哦');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- $payTime = $order->payTime;
|
|
|
- $time = strtotime($payTime);
|
|
|
- $after = date("H:i:s", $time);
|
|
|
- $new = $date . ' ' . $after;
|
|
|
- $cgId = $order->purchaseId ?? 0;
|
|
|
- $cg = PurchaseClass::getById($cgId, true);
|
|
|
- if (empty($cg)) {
|
|
|
- util::fail('没有找到订单信息');
|
|
|
- }
|
|
|
- if (strtotime($new) > time()) {
|
|
|
- util::fail('不能修改成未来时间');
|
|
|
+ $payTime = $order->payTime;
|
|
|
+ $timeArr = explode(' ', $payTime);
|
|
|
+ $dateStr = $timeArr[0];
|
|
|
+ if ($dateStr == $date) {
|
|
|
+ util::fail('日期没变');
|
|
|
+ }
|
|
|
+
|
|
|
+ $after = $timeArr[1];
|
|
|
+ $new = $date . ' ' . $after;
|
|
|
+ $cgId = $order->purchaseId ?? 0;
|
|
|
+ $cg = PurchaseClass::getById($cgId, true);
|
|
|
+ if (empty($cg)) {
|
|
|
+ util::fail('没有找到订单信息');
|
|
|
+ }
|
|
|
+ $order->payTime = $new;
|
|
|
+ $order->save();
|
|
|
+ $cg->payTime = $new;
|
|
|
+ $cg->save();
|
|
|
+ //有修改账单日期需要更新到欠款变动明细,财务好对账,多个地方要同步修改,关键词 to_change_custom_debt_pay_time
|
|
|
+ CustomDebtChangeClass::updateByCondition(['capitalType' => 10, 'relateId' => $id], ['payTime' => $new]);
|
|
|
+
|
|
|
+ //找到当前订单客户的账单日期为 $date 的所有订单,然后更新同天内的所有订单的 sameTimeIds(加此次要改变的订单的订单号$id),有多处调用,关键词 update_same_ids
|
|
|
+ OrderClass::updateSameTimeIds($order, $date);
|
|
|
+
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete('修改成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ util::fail('修改失败');
|
|
|
}
|
|
|
- $order->payTime = $new;
|
|
|
- $order->save();
|
|
|
- $cg->payTime = $new;
|
|
|
- $cg->save();
|
|
|
- //有修改账单日期需要更新到欠款变动明细,财务好对账,多个地方要同步修改,关键词to_change_custom_debt_pay_time
|
|
|
- CustomDebtChangeClass::updateByCondition(['capitalType' => 10, 'relateId' => $id], ['payTime' => $new]);
|
|
|
- util::complete('修改成功');
|
|
|
}
|
|
|
|
|
|
//应收款统计 ssh 20240528
|