From a634aa152c9f2bbbe841e835c473c20677fd2fd6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 14 Sep 2023 13:48:51 +0800 Subject: [PATCH] 1 --- webapp/controller/MailController.class.php | 74 +++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/webapp/controller/MailController.class.php b/webapp/controller/MailController.class.php index a8e1e01d..aea043de 100644 --- a/webapp/controller/MailController.class.php +++ b/webapp/controller/MailController.class.php @@ -1,7 +1,19 @@ propertyChgService = new services\PropertyChgService(); + $this->awardService = new services\AwardService(); + } + public function getAttachment() { $mailIds = getReqVal('mail_ids', ''); @@ -29,13 +41,73 @@ class MailController extends BaseAuthedController { $rspObj = json_decode($response, true); if ($rspObj && $rspObj['errcode'] == 0) { $this->procAttachments($rspObj['attachments']); + $rspObj['award'] = $this->awardService->toDto(); + $rspObj['property_chg'] = $this->propertyChgService->toDto(); } - echo $response; + echo json_encode($rspObj); } private function procAttachments($attachments) { + $mailHash = array(); + { + foreach ($attachments as $item) { + if (!array_key_exists($item['mailid'], $mailHash)) { + $mailHash[$item['mailid']] = array(); + } + array_push($mailHash[$item['mailid']], $item); + } + } + foreach ($mailHash as $key => $val) { + $mailId = $key; + $items = arary(); + foreach ($val as $item) { + array_push($items, array( + 'item_id' => $item['itemid'], + 'item_num' => $item['itemnum'], + )); + } + $row = SqlHelper::ormSelect( + myself()->_getSelfMysql(), + 't_mail', + array( + 'account_id' => myself()->_getAccountId(), + 'mailid' => $mailId + ) + ); + if (!$row) { + SqlHelper::upsert( + myself()->_getSelfMysql(), + 't_mail', + array( + 'account_id' => myself()->_getAccountId(), + 'mailid' => $mailId + ), + array( + ), + array( + 'account_id' => myself()->_getAccountId(), + 'mailid' => $mailId, + 'attachments' => json_encode($items), + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + $this->_addItems($items, $this->awardService, $this->propertyChgService); + SqlHelper::update( + myself()->_getSelfMysql(), + 't_mail', + array( + 'account_id' => myself()->_getAccountId(), + 'mailid' => $mailId + ), + array( + 'confirmed' => 1 + ) + ); + } + } } private static function getMailServerUrl()