|
|
@@ -5219,21 +5219,26 @@ class Index extends Frontend
|
|
|
$this->view->assign('defaultCclbmmc', $defaultDept);
|
|
|
$this->view->assign('adminNickname', trim((string)($profile['contact_name'] ?? '')) ?: '业务员');
|
|
|
$this->view->assign('rfqDeptOptions', $this->mprocLoadRfqDeptNameOptions());
|
|
|
- $this->view->assign('rows', $this->mprocLoadRfqAddRows($user, ''));
|
|
|
+ $this->view->assign('rfqStatusTab', 'pending');
|
|
|
+ $this->view->assign('rows', $this->mprocLoadRfqAddRows($user, '', 'pending'));
|
|
|
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 业务员询价列表 JSON(本人发起或被通知)
|
|
|
- * GET:q
|
|
|
+ * GET:q、status=pending|quoted
|
|
|
*/
|
|
|
public function rfqaddlist()
|
|
|
{
|
|
|
$user = $this->mprocRequireRfqUser();
|
|
|
$q = trim((string)$this->request->get('q', ''));
|
|
|
- $rows = $this->mprocLoadRfqAddRows($user, $q);
|
|
|
- $this->success('ok', null, ['rows' => $rows, 'total' => count($rows)]);
|
|
|
+ $status = trim((string)$this->request->get('status', 'pending'));
|
|
|
+ if ($status !== 'quoted') {
|
|
|
+ $status = 'pending';
|
|
|
+ }
|
|
|
+ $rows = $this->mprocLoadRfqAddRows($user, $q, $status);
|
|
|
+ $this->success('ok', null, ['rows' => $rows, 'total' => count($rows), 'status' => $status]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -5540,9 +5545,10 @@ class Index extends Frontend
|
|
|
* 手机端业务员询价列表(本人发起 / 被通知)
|
|
|
*
|
|
|
* @param array<string, mixed> $user
|
|
|
+ * @param string $status pending|quoted|''(空=全部)
|
|
|
* @return array<int, array<string, mixed>>
|
|
|
*/
|
|
|
- protected function mprocLoadRfqAddRows(array $user, string $q): array
|
|
|
+ protected function mprocLoadRfqAddRows(array $user, string $q, string $status = ''): array
|
|
|
{
|
|
|
$profile = $this->mprocProfileForUser($user);
|
|
|
$adminName = trim((string)($profile['contact_name'] ?? ''));
|
|
|
@@ -5595,10 +5601,33 @@ class Index extends Frontend
|
|
|
$rows = [];
|
|
|
}
|
|
|
$out = [];
|
|
|
+ $sids = [];
|
|
|
+ foreach ($rows as $r) {
|
|
|
+ if (!is_array($r)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $sid = (int)($r['scydgy_id'] ?? 0);
|
|
|
+ if ($sid < 0) {
|
|
|
+ $sids[$sid] = $sid;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $quotedMap = $this->mprocLoadRfqQuotedSidMap(array_values($sids));
|
|
|
+ $status = trim($status);
|
|
|
+ if ($status !== 'pending' && $status !== 'quoted') {
|
|
|
+ $status = '';
|
|
|
+ }
|
|
|
foreach ($rows as $r) {
|
|
|
if (!is_array($r)) {
|
|
|
continue;
|
|
|
}
|
|
|
+ $sid = (int)($r['scydgy_id'] ?? 0);
|
|
|
+ $isQuoted = !empty($quotedMap[$sid]);
|
|
|
+ if ($status === 'pending' && $isQuoted) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if ($status === 'quoted' && !$isQuoted) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
$created = trim((string)($r['createtime'] ?? ''));
|
|
|
if ($created === '' || stripos($created, '0000-00-00') === 0) {
|
|
|
$created = trim((string)($r['dStamp'] ?? ''));
|
|
|
@@ -5606,9 +5635,12 @@ class Index extends Frontend
|
|
|
if (preg_match('/^\d{10,}$/', $created)) {
|
|
|
$created = date('Y-m-d H:i:s', (int)$created);
|
|
|
}
|
|
|
+ if ($created !== '' && stripos($created, '0000-00-00') === 0) {
|
|
|
+ $created = '';
|
|
|
+ }
|
|
|
$out[] = [
|
|
|
'id' => (int)($r['id'] ?? 0),
|
|
|
- 'scydgy_id' => (int)($r['scydgy_id'] ?? 0),
|
|
|
+ 'scydgy_id' => $sid,
|
|
|
'CCYDH' => trim((string)($r['CCYDH'] ?? '')),
|
|
|
'CYJMC' => trim((string)($r['CYJMC'] ?? '')),
|
|
|
'CCLBMMC' => trim((string)($r['CCLBMMC'] ?? '')),
|
|
|
@@ -5619,7 +5651,7 @@ class Index extends Frontend
|
|
|
'ceilingPrice' => trim((string)($r['ceilingPrice'] ?? '')),
|
|
|
'cywyxm' => trim((string)($r['cywyxm'] ?? '')),
|
|
|
'MBZ' => trim((string)($r['MBZ'] ?? '')),
|
|
|
- 'progress_text' => $this->mprocFormatRfqProgressText($r),
|
|
|
+ 'progress_text' => $isQuoted ? '已报价' : '待询价',
|
|
|
'createtime' => $created,
|
|
|
];
|
|
|
}
|
|
|
@@ -5628,28 +5660,75 @@ class Index extends Frontend
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param array<string, mixed> $row
|
|
|
+ * 哪些手工询价单已有有效报价(amount 非空且非 0)
|
|
|
+ *
|
|
|
+ * @param array<int, int> $sids
|
|
|
+ * @return array<int, bool>
|
|
|
*/
|
|
|
- protected function mprocFormatRfqProgressText(array $row): string
|
|
|
+ protected function mprocLoadRfqQuotedSidMap(array $sids): array
|
|
|
{
|
|
|
- if (ProcuremenStatus::isPoCompleted($row['status'] ?? '')) {
|
|
|
- return ProcuremenStatus::PO_COMPLETED;
|
|
|
- }
|
|
|
- if ((int)($row['rfq_salesman_notified'] ?? 0) === 1) {
|
|
|
- return '已通知业务员';
|
|
|
+ $out = [];
|
|
|
+ $sids = array_values(array_unique(array_filter(array_map('intval', $sids), static function ($v) {
|
|
|
+ return $v < 0;
|
|
|
+ })));
|
|
|
+ if ($sids === []) {
|
|
|
+ return $out;
|
|
|
}
|
|
|
- $wflow = ProcuremenStatus::normalizeWflowStatus($row['wflow_status'] ?? '');
|
|
|
- if ($wflow !== ProcuremenStatus::WFLOW_PENDING_ISSUE) {
|
|
|
- return '待报价';
|
|
|
+ foreach (array_chunk($sids, 200) as $chunk) {
|
|
|
+ try {
|
|
|
+ $rows = Db::table('purchase_order_detail')
|
|
|
+ ->where('scydgy_id', 'in', $chunk)
|
|
|
+ ->whereRaw(ProcuremenStatus::sqlPodNotVoid('status'))
|
|
|
+ ->whereRaw('(status_name IS NULL OR TRIM(status_name) = \'\' OR status_name <> \'' . ProcuremenStatus::POD_VOID . '\')')
|
|
|
+ ->where('amount', '<>', '')
|
|
|
+ ->whereNotNull('amount')
|
|
|
+ ->where('amount', '<>', '0')
|
|
|
+ ->where('amount', '<>', '0.00')
|
|
|
+ ->field('scydgy_id')
|
|
|
+ ->group('scydgy_id')
|
|
|
+ ->select();
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ try {
|
|
|
+ $rows = Db::table('purchase_order_detail')
|
|
|
+ ->where('scydgy_id', 'in', $chunk)
|
|
|
+ ->where('amount', '<>', '')
|
|
|
+ ->whereNotNull('amount')
|
|
|
+ ->where('amount', '<>', '0')
|
|
|
+ ->where('amount', '<>', '0.00')
|
|
|
+ ->field('scydgy_id')
|
|
|
+ ->group('scydgy_id')
|
|
|
+ ->select();
|
|
|
+ } catch (\Throwable $e2) {
|
|
|
+ $rows = [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!is_array($rows)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ foreach ($rows as $r) {
|
|
|
+ if (!is_array($r)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $sid = (int)($r['scydgy_id'] ?? 0);
|
|
|
+ if ($sid < 0) {
|
|
|
+ $out[$sid] = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ return $out;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param array<string, mixed> $row
|
|
|
+ */
|
|
|
+ protected function mprocFormatRfqProgressText(array $row): string
|
|
|
+ {
|
|
|
$sid = (int)($row['scydgy_id'] ?? 0);
|
|
|
if ($sid < 0) {
|
|
|
- try {
|
|
|
- $cnt = (int)Db::table('purchase_order_detail')->where('scydgy_id', $sid)->count();
|
|
|
- if ($cnt > 0) {
|
|
|
- return '待报价';
|
|
|
- }
|
|
|
- } catch (\Throwable $e) {
|
|
|
+ $map = $this->mprocLoadRfqQuotedSidMap([$sid]);
|
|
|
+ if (!empty($map[$sid])) {
|
|
|
+ return '已报价';
|
|
|
}
|
|
|
}
|
|
|
|