<?php
namespace Application\Service\DB\Item;
use Interop\Container\ContainerInterface;

class MessageSendPatient extends \Application\Service\DB\AbstractDb
{
    public function __construct($dbAdapter, ContainerInterface $container)
    {
        $this->tableName = 'yikeen_item_message_send_patient';
        parent::__construct($dbAdapter, $container);
    }

    /**
     * Notes: 统计中心下的消息数据量
     * @param
     * @return
     * @author haojinhua
     * @date 2024-08-13
     */
    public function getSigcount($data = [])
    {
        $res = [];
        $where      = 'is_del = 0 and FROM_UNIXTIME(create_time ,"%Y-%m-%d")="'.date('Y-m-d').'"';
        $where_cound         = [
            'where'   => $where,
            'columns' => ['item_id','itemsig_id', 'is_write',],
            'order'   => ['is_write', 'is_complete'],
        ];
        $itemMessageSendData = $this->fetchAll($where_cound);
        if (!empty($itemMessageSendData)) {
            foreach ($itemMessageSendData as $itemMessageSend) {
                $res[$itemMessageSend['item_id']][$itemMessageSend['itemsig_id']]['allcount'] ++;
                if(!empty($itemMessageSend['is_write'])){
                    $res[$itemMessageSend['item_id']][$itemMessageSend['itemsig_id']]['write_count'] ++;
                }else{
                    $res[$itemMessageSend['item_id']][$itemMessageSend['itemsig_id']]['no_write_count'] ++;
                }
            }
        }

        return $res;

    }

}

