//检测前端是否有对应的方式处理对应的文件类型 //html if ($this->frontHandler === 'pagelets') { $this->infoList['200'][$this->frontHandler] = $content; //静态资源 } else { $this->infoList['200']['resource_map'][$this->frontHandler] = $content; } echo json_encode($this->infoList['200']); exit; } private function merge_data() { $arrays = func_get_args(); $base = array_shift($arrays); foreach ($arrays as $array) { reset($base); //important while (list($key, $value) = @each($array)) { if (is_array($value) && @is_array($base[$key])) { $base[$key] = $this->merge_data($base[$key], $value); } else { $base[$key] = $value; } } } return $base; } } $sidebar = new OpenApi(); $sidebar->index();
public function act_sentEmail($contentArr, $spu, $sku, $deal_order, $availableStock, $outOfStockDays, $availableInventoryDays, $originalSku, $toEmail) { /* //关于分销商超卖SPU及SKU只针对推送给分销商的类别(发邮件) 引处暂时注释 $spuCategory = OpenApi::getSpuCategory($spu); global $distributorsCategory; foreach($distributorsCategory as $k=>$v) { //echo '<pre>'.$spuCategory;print_r($v); //判断该spu是否属于对应分销商类别的 if($v['categorys'] == 'ALL' || (is_array($v['categorys']) && in_array($spuCategory, $v['categorys']))) { foreach($v['email'] as $email) { $toEmail[] = $email; } } } */ //$toEmail[] = '*****@*****.**'; //edit by zxh 2014/5/8 林正祥通知暂时去掉 //$toEmail[] = '*****@*****.**'; $toEmail = array('0' => array('email' => '*****@*****.**', 'userName' => '肖金华'), '1' => array('email' => '*****@*****.**', 'userName' => '钟衍台'), '2' => array('email' => '*****@*****.**', 'userName' => '周聪'), '3' => array('email' => '*****@*****.**', 'userName' => '陈小霞'), '4' => array('email' => '*****@*****.**', 'userName' => '林正祥'), '5' => array('email' => '*****@*****.**', 'userName' => '席惠超'), '6' => array('email' => '*****@*****.**', 'userName' => '陈燕去'), '7' => array('email' => '*****@*****.**', 'userName' => '陈月葵'), '8' => array('email' => '*****@*****.**', 'userName' => '郑凤娇'), '9' => array('email' => '*****@*****.**', 'userName' => '潘旭东'), '10' => array('email' => '*****@*****.**', 'userName' => '李美琴'), '11' => array('email' => '*****@*****.**', 'userName' => '曾祥红')); $content = C("EMAILCONTENTS"); $sellerTd = $sellerFields = $values = ''; $location = isset($_REQUEST['location']) ? $_REQUEST['location'] : ''; //仓位 foreach ($spu as $k => $v) { //通过spu获取对应销售和采购的统一用户编号 $pcGetSpuSalerIdsBySpu = OpenApi::pcGetSpuSalerIdsBySpu($v['conbineSpu']); //$spu if (!empty($pcGetSpuSalerIdsBySpu['purchaseId'])) { $purchaseEmail = OpenApi::getUserEmail($pcGetSpuSalerIdsBySpu['purchaseId']); $toEmail[] = array('email' => $purchaseEmail['email'], 'userName' => $purchaseEmail['userName']); } else { Log::write($v['conbineSpu'] . ": 没有采购负责人", 'NOTIC'); } //同一个平台,同一个sku对应一个采购,但是对应多个销售 if (!empty($pcGetSpuSalerIdsBySpu['salerArr'])) { $i = 1; foreach ($pcGetSpuSalerIdsBySpu['salerArr'] as $platformId => $salerId) { //通采购的统一用户编号获取其邮箱 $salerEmail = OpenApi::getUserEmail($salerId); $toEmail[] = array('email' => $salerEmail['email'], 'userName' => $salerEmail['userName']); $sellerFields .= "<td>销售" . $i . "<input type='hidden' value='" . $salerId . "' /></td>"; $sellerTd .= "<td>" . $salerEmail['userName'] . "</td>"; $i++; } } else { Log::write($v['conbineSpu'] . ": 没有销售负责人", 'NOTIC'); } $content = str_replace('{sellerFields}', $sellerFields, $content); if ($deal_order == 1) { //下架产品 $content = str_replace('{availableInventoryDaysFields}', '', $content); $values .= "<tr>\n\t\t\t\t\t\t\t\t<td>下架</td>\n\t\t\t\t\t\t\t\t<td>" . $v['conbineSpu'] . "</td>\n\t\t\t\t\t\t\t\t<td>" . $v['conbineSku'] . "</td>\n\t\t\t\t\t\t\t\t<td>" . $originalSku . "</td>\n\t\t\t\t\t\t\t\t<td>" . $purchaseEmail['userName'] . "</td>\n\t\t\t\t\t\t\t\t<td>" . $availableStock . "</td>\n\t\t\t\t\t\t\t\t<td>" . $outOfStockDays . "</td>\n\t\t\t\t\t\t\t\t" . $sellerTd . "\n\t\t\t\t\t\t\t\t<td>" . $location . "</td>\n\t\t\t\t\t\t\t</tr>"; } else { if ($deal_order == 2) { //上架产品 $content = str_replace('{availableInventoryDaysFields}', '<td>可用库存天数</td>', $content); $values .= "<tr>\n\t\t\t\t\t\t\t\t<td>上架</td>\n\t\t\t\t\t\t\t\t<td>" . $v['conbineSpu'] . "</td>\n\t\t\t\t\t\t\t\t<td>" . $v['conbineSku'] . "</td>\n\t\t\t\t\t\t\t\t<td>" . $originalSku . "</td>\n\t\t\t\t\t\t\t\t<td>" . $purchaseEmail['userName'] . "</td>\n\t\t\t\t\t\t\t\t<td>" . $availableStock . "</td>\n\t\t\t\t\t\t\t\t<td>" . $availableInventoryDays . "</td>\n\t\t\t\t\t\t\t\t<td>" . $outOfStockDays . "</td>\n\t\t\t\t\t\t\t\t" . $sellerTd . "\n\t\t\t\t\t\t\t\t<td>" . $location . "</td>\n\t\t\t\t\t\t\t</tr>"; } } } $content = str_replace('{values}', $values, $content); //+++++++++++++++end 同一个平台,同一个sku对应一个采购,但是对应多个销售, 有时候可能会没有销售人员的数据 if (empty($toEmail)) { Log::write($originalSku . ": 没有找到销售及采购负责人", 'NOTIC'); self::$errCode = '500'; self::$errMsg = '未找到此SKU的销售人员和采购人员记录'; return false; } if ($deal_order == 1) { //下架产品 /*switch($platform) //勿删 edited by zxh 2014/5/12 { case 'ebay平台': $content = ' 很遗憾的告诉你,由于sku为 '.$sku.' 库存不足,请把 '.$platform.' 上的'; break; case 'aliexpress': //速卖通平台 $content = ' 很遗憾的告诉你,由于sku为 '.$sku.' 库存不足,请把 '.$platform.' 上的'; break; default: echo '平台错误'; break; }*/ $title = '华成平台 超卖系统 重要通知:子料号 ' . $originalSku . ' 缺货天数为 ' . $outOfStockDays . ',请下架该商品 '; /*$content = ' 很遗憾的告诉你,由于SPU为 '.$spu.' 中子料号sku为 '.$sku.' //暂时保留,勿删 edited by zxh 2014/5/12 可用库存只有 '.$availableStock.' ,缺货天数为 '.$outOfStockDays.' ,请下架该商品。'; //",可用库存天数 '.$availableInventoryDays.'" //东哥说需要去掉 edited by zxh 2014/5/6 15:49*/ } else { if ($deal_order == 2) { //上架产品 /*switch($platform) //勿删 edited by zxh 2014/5/12 { //case 'ebay平台': $content = ' 很高兴的告诉你,由于sku为 '.$sku.' 已经到货,请为 '.$platform.' 上的'; break; case 'aliexpress': //速卖通平台 $content = ' 很高兴的告诉你,由于sku为 '.$sku.' 已经到货,请为 '.$platform.' 上的'; break; default: echo '平台错误'; break; }*/ $title = '华成平台 超卖系统 重要通知:子料号 ' . $originalSku . ' 缺货天数为 ' . $outOfStockDays . ' ,可上架该商品'; /*$content = ' 很高兴的告诉你,由于SPU为 '.$spu.' 中子料号sku为 '.$sku.' //暂时保留,勿删 edited by zxh 2014/5/12 可用库存有 '.$availableStock.' ,缺货天数为 '.$outOfStockDays.' ,可用库存天数 '.$availableInventoryDays.',可上架该商品。';*/ } else { return false; } } $emailStyle = file_get_contents(WEB_PATH . "html/template/emailStyle.html"); $emailStyle = preg_replace('/{time}/i', date("Y-m-d H:i:s", time()), $emailStyle); $emailStyle = preg_replace('/{{content}}/i', $content, $emailStyle); $sendmail = sendEmail($toEmail, $title, $emailStyle); if (strlen($sendmail) > 1) { //如果邮件发送失败,则将错误信息返回到$sendmail变量内, Log::write(json_encode($_REQUEST), 'DEBUG'); //邮件发送失败记入日志 self::$errCode = '1101'; self::$errMsg = $sendmail; return false; } return true; }