🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### 更新积分日志 **位置:** Common\Lib\PointsLogLib.class.php **参数:** @param $log_id Integer 日志ID 必填 @param $api_step String 当前步骤是否成功,成功1,失败0 必填 @param $detail_json String 当前步骤的步骤详情 必填 @param $step_num Int 当前步骤是第几步 必填 **调用:** * 组件文件外调用 ~~~ $ptl = new PointsLogLib(); $log_id = 223; // 日志ID $api_step = 1; // 当前步骤是否成功,成功1,失败0 必填 $detail_json'= "crm_up:{}"; // 当前步骤详情 $step_num = 2; // 当前步骤是第几步 $res = $ptl->pointsUp($log_id, $api_step, $detail_json, $step_num); ~~~ **返回:** 成功时返回日志ID 失败时候返回对应的错误数组 **完整代码:** ~~~ /** * 更新积分日志 * @param $log_id Integer 日志ID 必填 * @param $api_step String API的进行步骤 必填 * @param $detail_json String 当前步骤的步骤详情 必填 * @param $step_num Int 当前步骤是第几步 必填 * @return array|Integer * 失败返回 错误 * 成功返回 日志ID */ public function pointsUp($log_id, $api_step, $detail_json, $step_num) { if (empty($log_id)) { return array('success' => false, 'code' => -1, 'msg'=> 'LOGID不能为空!'); } // 日志更新 $where['id'] = array('eq', $log_id); // 查询已经存在的日志 $log_item = M('points_log')->where($where)->find(); // 替换数据库已经存在的步骤字符串中的序号为 2*$step_num - 2的字符,作为新的步骤API字段内容 $points_up_log['api_step'] = substr_replace($log_item['api_step'], $api_step, 2*$step_num - 2, 1); // 当前步骤的详情拼接原有的日志步骤详情 $points_up_log['detail_json'] = $log_item['detail_json'].$detail_json; $res_log = M('points_log')->where($where)->save($points_up_log); if ($res_log === false) { return array('success' => false, 'code' => -200, 'msg'=> '更新积分日志写入失败!'); } else { return $log_id; } } ~~~