add($partnerInfo); }else{ //编辑 M('partner', 'tab_')->save($partnerInfo); } $this->saveRelation($relation, $partnerInfo); M('partner_verify', 'tab_')->save($application); addOperationLog(['op_type' => 1, 'key'=>$application['partner_id'], "op_name"=>"管理员审核", 'url'=>U('index')]); } protected function saveRelation($relation, $company) { $selfCompany = M('company_info', 'tab_')->where(['id' => $relation['self_company_id']])->find(); $where = '(first_company_type=1 and first_company_id=' . $company['id'] . ') or (second_company_type=1 and second_company_id=' . $company['id'] . ')'; $oldRelation = M('company_relation', 'tab_')->where($where)->find(); $data = []; if ($relation['collaborate_way'] == 1) { $data['first_company_id'] = $company['id']; $data['first_company_name'] = $company['partner']; $data['first_company_type'] = 1; $data['second_company_id'] = $selfCompany['id']; $data['second_company_name'] = $selfCompany['partner']; $data['second_company_type'] = 0; } else { $data['first_company_id'] = $selfCompany['id']; $data['first_company_name'] = $selfCompany['partner']; $data['first_company_type'] = 0; $data['second_company_id'] = $company['id']; $data['second_company_name'] = $company['partner']; $data['second_company_type'] = 1; } $data['settlement_type'] = $relation['settlement_type']; $data['invoice_type'] = $relation['invoice_type']; $data['collection'] = $relation['collection']; $data['is_payment'] = $relation['is_payment']; $data['invoice_content'] = $relation['invoice_content']; if ($oldRelation) { M('company_relation', 'tab_')->where(['id' => $oldRelation['id']])->save($data); } else { M('company_relation', 'tab_')->add($data); } } }