ip phone日志6

unit test
增加一个测试包CuTest :类似JNuit工具,但没有界面. http://cutest.sourceforge.net
写makefile测试内存函数时, 有点问题:
要引用其他文件夹的.o文件.
需以下申明:
 VPATH = ../api:../test
VPATH时makefile的环境变量,后面表示引用两个同级目录.
#***********************************

cc = gcc
#BUILD = ../build

VPATH = ../api:api
#vpath  %.h api:../api 直接指定所有.h文件查询路径
#vpath  %.c api:../api
#vpath %.o ../api
#api_dir = ../api

object = AllTest.o CuTest.o StrUtil.o memorymanagement.o

alltest:$(object)
 $(cc) -o alltest $(object)

$(object):CuTest.h ../api/memorymanagement.h

clean:
 -rm *.o

#***********************************
另有个include不知怎么用,info帮助也没例子

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
优化以下代码public function convertedAndSameActiveClue(&$postData, $clueState, $handleSource = Constant::REGISTER) { $result = $this->result; $recentCluePhones = DistributeCommon::getRecentIpClue($postData['phone'], $postData['active_ip']); $specified_channel = TSalesConf::getValue('filter_specified_channel_categories'); foreach ($recentCluePhones as $recentCluePhone) { //过滤指定渠道大类 if ($specified_channel) { $specified_channel = json_decode($specified_channel, true); if (in_array($postData['channel_big_type'], $specified_channel, true)) { event(new SaveOperateLogEvent(OperateLog::OPERATING_CLUE, $postData['phone'] . '已转化线索同IP不下发,过滤指定渠道大类' . json_encode($postData))); break; } } $stateInfo = app(Clue::class)->getClue($recentCluePhone, '+86');//查找当前线索的状态 //排除代理商线索 if ($stateInfo['transform'] && $stateInfo['info']['base_id'] != self::AGENT_BASE_ID) { $result[self::IS_NEXT_CLUE] = true; $result[self::IS_TRIGGER_RULE] = true; $result[self::IS_DISTRIBUTE] = false; $result[self::BASE_ID] = self::WAIT_ACTIVE_BASE_ID; $result[self::POOL_ID] = self::WAIT_ACTIVE_POOL_ID; event(new SaveOperateLogEvent(OperateLog::OPERATING_CLUE, $postData['phone'].' 已转化线索同IP不下发, 与'.$recentCluePhone.'同一IP')); return $result; } } if (!empty($recentCluePhones)) { Log::channel('distribute')->info($postData['phone'] . ' 存在同一IP ' . json_encode($recentCluePhones) . ', 但该线索未转化或不存在与新系统中,或是代理商线索,或过滤指定渠道大类'); event(new SaveOperateLogEvent(OperateLog::OPERATING_CLUE, $postData['phone'] . ' 存在同一IP ' . json_encode($recentCluePhones) . ', 但该线索未转化或不存在与新系统中,或是代理商线索,或过滤指定渠道大类')); } return $result; }
06-10
这段代码的作用是将传入的线索信息转化并检查是否存在同IP的线索,若存在则判断是否为代理商线索或指定渠道大类的线索,如果不是则返回一个标记为待激活的线索结果。 以下是一些可以优化的地方: 1. 可以将 `$specified_channel` 的解析和判断移到函数外,避免每次循环时都进行解析和判断。 2. 可以将 `$result` 的初始值移动到函数内部,避免全局变量的使用。 3. 可以考虑使用 `continue` 替代 `break`,这样可以遍历完所有同IP线索并记录日志。 4. 可以将函数名改为更加具体的名称,提高代码的可读性。 下面是优化后的代码示例: ``` public function checkConvertedClueAndSameIP(&$postData, $clueState, $handleSource = Constant::REGISTER) { $result = [ self::IS_NEXT_CLUE => false, self::IS_TRIGGER_RULE => false, self::IS_DISTRIBUTE => true, self::BASE_ID => self::WAIT_ACTIVE_BASE_ID, self::POOL_ID => self::WAIT_ACTIVE_POOL_ID, ]; $recentCluePhones = DistributeCommon::getRecentIpClue($postData['phone'], $postData['active_ip']); $specifiedChannel = json_decode(TSalesConf::getValue('filter_specified_channel_categories'), true) ?? []; foreach ($recentCluePhones as $recentCluePhone) { if (in_array($postData['channel_big_type'], $specifiedChannel, true)) { event(new SaveOperateLogEvent(OperateLog::OPERATING_CLUE, $postData['phone'] . '已转化线索同IP不下发,过滤指定渠道大类' . json_encode($postData))); continue; } $stateInfo = app(Clue::class)->getClue($recentCluePhone, '+86'); if ($stateInfo['transform'] && $stateInfo['info']['base_id'] != self::AGENT_BASE_ID) { $result[self::IS_NEXT_CLUE] = true; $result[self::IS_TRIGGER_RULE] = true; $result[self::IS_DISTRIBUTE] = false; event(new SaveOperateLogEvent(OperateLog::OPERATING_CLUE, $postData['phone'].' 已转化线索同IP不下发, 与'.$recentCluePhone.'同一IP')); } } if (!empty($recentCluePhones)) { Log::channel('distribute')->info($postData['phone'] . ' 存在同一IP ' . json_encode($recentCluePhones) . ', 但该线索未转化或不存在与新系统中,或是代理商线索,或过滤指定渠道大类'); event(new SaveOperateLogEvent(OperateLog::OPERATING_CLUE, $postData['phone'] . ' 存在同一IP ' . json_encode($recentCluePhones) . ', 但该线索未转化或不存在与新系统中,或是代理商线索,或过滤指定渠道大类')); } return $result; } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值