|
|
@@ -2974,6 +2974,55 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改订单发货日期:同时写 xhGhsOrder.sendTimeWant 与 xhCg.sendTimeWant。
|
|
|
+ * ghsApp 订单详情「发货时间-修改」调用;允许补录过去日期。关键词 sync_send_time_want
|
|
|
+ */
|
|
|
+ public function actionModifySendTimeWant()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $id = $get['id'] ?? 0;
|
|
|
+ $date = $get['date'] ?? '';
|
|
|
+ $date = str_replace('/', '-', trim($date));
|
|
|
+ if (empty($date) || !preg_match('/^\d{4}-\d{2}-\d{2}$/', $date)) {
|
|
|
+ util::fail('请选择日期');
|
|
|
+ }
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $order = OrderClass::getById($id, true);
|
|
|
+ if (empty($order)) {
|
|
|
+ util::fail('没有找到订单');
|
|
|
+ }
|
|
|
+ if ($order->mainId != $this->mainId) {
|
|
|
+ util::fail('不是你的订单');
|
|
|
+ }
|
|
|
+ $oldDate = substr((string)$order->sendTimeWant, 0, 10);
|
|
|
+ if ($oldDate === $date) {
|
|
|
+ util::fail('日期没变');
|
|
|
+ }
|
|
|
+ $cgId = $order->purchaseId ?? 0;
|
|
|
+ $cg = PurchaseClass::getById($cgId, true);
|
|
|
+ if (empty($cg)) {
|
|
|
+ util::fail('没有找到订单信息');
|
|
|
+ }
|
|
|
+ // 销售单、采购单发货日期必须一致,否则花店侧看到的要求发货日会对不上
|
|
|
+ $order->sendTimeWant = $date;
|
|
|
+ if (!$order->save()) {
|
|
|
+ util::fail('修改失败');
|
|
|
+ }
|
|
|
+ $cg->sendTimeWant = $date;
|
|
|
+ if (!$cg->save()) {
|
|
|
+ util::fail('修改失败');
|
|
|
+ }
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete('修改成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ util::fail('修改失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 应收统计:按支付日汇总。
|
|
|
* originAmount=未扣隔天;nextDayAmount=跨天售后;amount=已扣隔天(净额)。
|