您的位置:首页 > 其它

提交订单系统自动发邮件到收件人邮箱

2017-06-02 11:59 483 查看
Model 模型层逻辑处理

$spolNote = $this->_condition['spol_note'];

//是否存在增值服务项

if (!empty($spolNote)) {

     $qcoRes = Product_Service_QualityControlOrder::getQcoCode($this->_condition['qcCode']);

     $refId = Product_Service_Receiving::getByReceivingCode($qcoRes['qco_ref_code']);

     //是否为 CSP 的订单

     if ($refId['plat_form'] == "CSP") {

          //获取邮箱以及切割处理

          $configAttribute = Common_Service_Config::getByAttribute('CSP_EXCEPTION_LIST_EMAIL');

          if ($configAttribute) {

               $mailUser = explode(';', $configAttribute['config_value']);

          } else {

               $dbAdapter->rollback();

               $this->_error['msg'] = '请添加邮箱地址';

               return false;

          }

          $content = "ASN单号,采购单号,QC单号,CSP,增值服务项,原因,操作员,日期\n";

          //编列邮件内容

          $Is_show = $refId['plat_form'] == "CSP" ? '是' : '否';

          foreach ($spolNote as $k => $v) {

               $res = Special_Service_SpecialProjectOptions::getById($k);

               $content .= $qcoRes['qco_ref_code'] . ','

                       . $refId['ref_id'] . ','

                       . $qcoRes['qco_code'] . ','

                       . $Is_show . ','

                       . $res['spop_value_cn'] . ','

                       . $v . ','

                       . $qcoRes['user_id'] . ','

                       . date("Y-m-d H:i:s") . "\n";

          }

          //发送邮箱对应处理

          $content = iconv("UTF-8", "GBK", $content);

          $mail_subject = "CSP 订单报表";

          $mail = Cff::setupMail();

          $mail->setBodyHtml('CSP 订单,请跟进!');

          $mail->addTo($mailUser, $mail_subject);

          $mail->setSubject($mail_subject);

          $at = $mail->createAttachment($content);

          $at->type = 'application/vnd.ms-excel';

          $at->disposition = Zend_Mime::DISPOSITION_INLINE;

          $at->encoding = Zend_Mime::ENCODING_8BIT;

          $at->filename = iconv("UTF-8", "GB2312", $mail_subject . date('Y-m-d') . '.csv');

          $mail->send();

     }

     //记录来货异常订单添加增值服务项信息

     $Journal = array(

             'spo_code' => $spRes['spo_code'],

             'user_id' => $this->_userId,

             'customer_id' => $this->_receivingInfo['customer_id'],

             'spol_note' => implode(";", $spolNote),

             'spol_ip' => Common_Service_Common::getIP(),

             'spol_create_date' => date('Y-m-d H:i:s'),

             'spol_msg_type' => $this->_condition['spol_msg_type'],

             'warehouse_id' => $this->_receivingInfo['warehouse_id'],

     );

     //写入数据库

     $JournalObj = new Special_Model_SpecialProjectOrderLog();

     $addJournal = $JournalObj->create($Journal);

     if (empty($addJournal)) {

          $dbAdapter->rollback();

          $this->_error['msg'] = '写日志失败';

          return false;

     }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐