1
This commit is contained in:
parent
ef699fe8cd
commit
a634aa152c
@ -1,7 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
class MailController extends BaseAuthedController {
|
class MailController extends BaseAuthedController {
|
||||||
|
|
||||||
|
private $propertyChgService = null;
|
||||||
|
private $awardService = null;
|
||||||
|
|
||||||
|
public function _handlePre()
|
||||||
|
{
|
||||||
|
parent::_handlePre();
|
||||||
|
$this->propertyChgService = new services\PropertyChgService();
|
||||||
|
$this->awardService = new services\AwardService();
|
||||||
|
}
|
||||||
|
|
||||||
public function getAttachment()
|
public function getAttachment()
|
||||||
{
|
{
|
||||||
$mailIds = getReqVal('mail_ids', '');
|
$mailIds = getReqVal('mail_ids', '');
|
||||||
@ -29,13 +41,73 @@ class MailController extends BaseAuthedController {
|
|||||||
$rspObj = json_decode($response, true);
|
$rspObj = json_decode($response, true);
|
||||||
if ($rspObj && $rspObj['errcode'] == 0) {
|
if ($rspObj && $rspObj['errcode'] == 0) {
|
||||||
$this->procAttachments($rspObj['attachments']);
|
$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)
|
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()
|
private static function getMailServerUrl()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user