|
|
@@ -285,10 +285,12 @@ class Procuremen extends Backend
|
|
|
/**
|
|
|
* 手机端协助明细首页直达链接(登录后打开对应明细,免搜索)
|
|
|
* 配置 application/extra/mproc.php:mobile_base_url、mobile_index_path
|
|
|
+ * 列表 Tab 写入 hash(mproc_tab),避免邮件客户端拆坏多 query 参数;浏览器端再补全 tab=
|
|
|
*
|
|
|
- * @param int $purchaseOrderDetailId purchase_order_detail 主键
|
|
|
+ * @param int $purchaseOrderDetailId purchase_order_detail 主键
|
|
|
+ * @param string $listTab rfq|draft|submitted|done|rfq_submitted,空则仅靠服务端按状态推断
|
|
|
*/
|
|
|
- protected function buildMprocMobileOrderUrl($purchaseOrderDetailId)
|
|
|
+ protected function buildMprocMobileOrderUrl($purchaseOrderDetailId, $listTab = '')
|
|
|
{
|
|
|
static $mprocCfgLoaded = false;
|
|
|
if (!$mprocCfgLoaded) {
|
|
|
@@ -308,12 +310,62 @@ class Procuremen extends Backend
|
|
|
} else {
|
|
|
$path = '/' . ltrim($path, '/');
|
|
|
}
|
|
|
- // 邮件 HTML 中多参数链接常被邮箱客户端错误解析(& 后参数丢失),仅保留 focus_eid 单参数 + hash 备份
|
|
|
+ $tab = trim((string)$listTab);
|
|
|
+ if (!in_array($tab, ['rfq', 'rfq_submitted', 'draft', 'submitted', 'done'], true)) {
|
|
|
+ $tab = '';
|
|
|
+ }
|
|
|
+ // 邮件 HTML 中多参数链接常被邮箱客户端错误解析(& 后参数丢失),仅保留 focus_eid 单参数 + hash 备份 Tab
|
|
|
if ($eid > 0) {
|
|
|
- return $base . $path . '?focus_eid=' . $eid . '#mproc_fe=' . $eid;
|
|
|
+ $hash = 'mproc_fe=' . $eid;
|
|
|
+ if ($tab !== '') {
|
|
|
+ $hash .= '&mproc_tab=' . $tab;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $base . $path . '?focus_eid=' . $eid . '#' . $hash;
|
|
|
}
|
|
|
|
|
|
- return $base . $path . '?main_tab=orders';
|
|
|
+ return $base . $path . '?main_tab=orders' . ($tab !== '' ? ('&tab=' . $tab) : '');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 业务员手机端「订单询价」直达链接(默认待询价)
|
|
|
+ *
|
|
|
+ * @param int $scydgyId 手工询价 scydgy_id(负数)
|
|
|
+ * @param string $status pending|quoted
|
|
|
+ */
|
|
|
+ protected function buildMprocMobileRfqAddUrl($scydgyId = 0, $status = 'pending')
|
|
|
+ {
|
|
|
+ static $mprocCfgLoaded = false;
|
|
|
+ if (!$mprocCfgLoaded) {
|
|
|
+ $mprocCfgLoaded = true;
|
|
|
+ if (is_file(APP_PATH . 'extra/mproc.php')) {
|
|
|
+ Config::load(APP_PATH . 'extra/mproc.php', 'mproc');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $base = $this->resolveMprocMobilePublicBaseUrl();
|
|
|
+ if ($base === '') {
|
|
|
+ throw new \Exception('无法生成手机端链接,请检查站点访问地址或 application/extra/mproc.php 中的 mobile_base_url');
|
|
|
+ }
|
|
|
+ $indexPath = trim((string)Config::get('mproc.mobile_index_path'));
|
|
|
+ if ($indexPath === '') {
|
|
|
+ $indexPath = '/index.php/index/index/index';
|
|
|
+ } else {
|
|
|
+ $indexPath = '/' . ltrim($indexPath, '/');
|
|
|
+ }
|
|
|
+ $path = preg_replace('#/index$#', '/rfqadd', rtrim($indexPath, '/'));
|
|
|
+ if ($path === null || $path === '' || substr($path, -6) === '/index') {
|
|
|
+ $path = '/index.php/index/index/rfqadd';
|
|
|
+ }
|
|
|
+ $status = trim((string)$status) === 'quoted' ? 'quoted' : 'pending';
|
|
|
+ $sid = (int)$scydgyId;
|
|
|
+ $q = 'status=' . $status;
|
|
|
+ $hash = '';
|
|
|
+ if ($sid < 0) {
|
|
|
+ $q .= '&focus_sid=' . $sid;
|
|
|
+ $hash = '#mproc_fs=' . $sid;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $base . $path . '?' . $q . $hash;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -8022,7 +8074,9 @@ class Procuremen extends Backend
|
|
|
}
|
|
|
$mprocUrl = '';
|
|
|
if ($buildMobileLinks && $detailId > 0) {
|
|
|
- $mprocUrl = $this->buildMprocMobileOrderUrl($detailId);
|
|
|
+ // 手工询价 → 待报价;协助下发 → 未提交
|
|
|
+ $listTab = ($sid < 0) ? 'rfq' : 'draft';
|
|
|
+ $mprocUrl = $this->buildMprocMobileOrderUrl($detailId, $listTab);
|
|
|
}
|
|
|
$detailLinks[] = [
|
|
|
'detail_id' => $detailId,
|
|
|
@@ -8112,6 +8166,9 @@ class Procuremen extends Backend
|
|
|
throw new \Exception($companyName . ' 未填写手机号,无法发送短信');
|
|
|
}
|
|
|
|
|
|
+ $emailTplScene = trim($emailTplScene) !== '' ? trim($emailTplScene) : 'review_email';
|
|
|
+ $linkListTab = (strpos($emailTplScene, 'rfq_') === 0) ? 'rfq' : 'draft';
|
|
|
+
|
|
|
$sids = [];
|
|
|
foreach ($mergeRows as $mr) {
|
|
|
if (!is_array($mr)) {
|
|
|
@@ -8181,14 +8238,17 @@ class Procuremen extends Backend
|
|
|
$detailLinks[] = [
|
|
|
'detail_id' => $detailId,
|
|
|
'cgymc' => $gymc,
|
|
|
- 'url' => $this->buildMprocMobileOrderUrl($detailId),
|
|
|
+ // 询价邮件 → 待报价;下发报价 → 未提交
|
|
|
+ 'url' => $this->buildMprocMobileOrderUrl(
|
|
|
+ $detailId,
|
|
|
+ ($linkListTab === 'rfq' || $sid < 0) ? 'rfq' : 'draft'
|
|
|
+ ),
|
|
|
];
|
|
|
}
|
|
|
if ($detailLinks === []) {
|
|
|
throw new \Exception('未找到有效的手机端链接,无法发送通知');
|
|
|
}
|
|
|
|
|
|
- $emailTplScene = trim($emailTplScene) !== '' ? trim($emailTplScene) : 'review_email';
|
|
|
$ctx = $this->buildIssueNotifyContext($mergeRows, $sysRqNotify);
|
|
|
$orderTypeCtx = $this->resolveIssueNotifyOrderTypeFromBundle($bundle);
|
|
|
$ctx['order_type'] = (string)($orderTypeCtx['order_type'] ?? '');
|
|
|
@@ -8966,6 +9026,7 @@ class Procuremen extends Backend
|
|
|
. "工序名称:{cgymc}\n"
|
|
|
. "本次数量:{this_quantity}\n"
|
|
|
. "供应商报价:\n{supplier_quotes}\n"
|
|
|
+ . "平台链接:{platform_url}\n"
|
|
|
. "需求发起人:{cywyxm}\n";
|
|
|
try {
|
|
|
$row = Db::table('purchase_sms_template')
|
|
|
@@ -8977,9 +9038,14 @@ class Procuremen extends Backend
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
if (is_array($row) && $row !== []) {
|
|
|
$old = (string)($row['content'] ?? '');
|
|
|
- // 仍用旧的「供应商:{supplier_name}」或没有报价占位符时,补上单价表格
|
|
|
+ // 无报价表格 / 无平台链接 / 链接不在「需求发起人」上方时,同步默认文案
|
|
|
+ $urlPos = strpos($old, '{platform_url}');
|
|
|
+ $cywyPos = strpos($old, '需求发起人');
|
|
|
+ $linkNotAboveStarter = ($urlPos === false)
|
|
|
+ || ($cywyPos !== false && $urlPos > $cywyPos);
|
|
|
$needMigrate = (strpos($old, '{supplier_quotes}') === false)
|
|
|
- || (strpos($old, '供应商:{supplier_name}') !== false);
|
|
|
+ || (strpos($old, '供应商:{supplier_name}') !== false)
|
|
|
+ || $linkNotAboveStarter;
|
|
|
if ($needMigrate) {
|
|
|
$data = ['content' => $content];
|
|
|
if (trim((string)($row['title'] ?? '')) === '' || trim((string)($row['title'] ?? '')) === '询价通知') {
|
|
|
@@ -9970,6 +10036,11 @@ class Procuremen extends Backend
|
|
|
$supplier = trim((string)($po['pick_company_name'] ?? ''));
|
|
|
}
|
|
|
$supplierQuotesHtml = $this->buildRfqSalesmanSupplierQuotesHtml($sid, $supplier);
|
|
|
+ try {
|
|
|
+ $platformUrl = $this->buildMprocMobileRfqAddUrl($sid, 'pending');
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ $platformUrl = '';
|
|
|
+ }
|
|
|
try {
|
|
|
$mailSubjectTpl = $this->resolveProcuremenEmailSubject('rfq_salesman_email');
|
|
|
} catch (\Throwable $e) {
|
|
|
@@ -9996,6 +10067,7 @@ class Procuremen extends Backend
|
|
|
// 占位符,转 HTML 后再替换成表格,避免被 htmlspecialchars 转义
|
|
|
'supplier_quotes' => '__RFQ_SUPPLIER_QUOTES_TABLE__',
|
|
|
'cywyxm' => $cywyxm,
|
|
|
+ 'platform_url' => $platformUrl,
|
|
|
];
|
|
|
try {
|
|
|
$mailPlain = $this->renderNotifyTemplate('rfq_salesman_email', $notifyVars);
|