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

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;
     }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值