コード例 #1
0
ファイル: month_contract.php プロジェクト: RenzcPHP/3dproduct
 public function template_use($userId, $templateId)
 {
     $agentDao = Myagent::instance();
     $agent = $agentDao->get_by_user_id($userId);
     if ($agent == null) {
         remind::set(Kohana::lang('o_agent.agent_not_exists'), request::referrer(), 'error');
     }
     $mtTemplateDao = MyMonth_contract_template::instance();
     $template = $mtTemplateDao->get_by_id($templateId);
     if ($template == null) {
         remind::set(Kohana::lang('o_contract.contract_not_exists'), request::referrer(), 'error');
     }
     $mtDtlTemplateDao = MyMonth_contract_detail_template::instance();
     $searchStruct = array();
     $searchStruct['where'] = array('contract_id' => $templateId);
     $dtlTemplateList = $mtDtlTemplateDao->lists($searchStruct);
     //		tool::filter_strip_tags($data);
     $mtContractDao = MyMonth_contract::instance();
     $mtContractDtlDao = MyMonth_contract_detail::instance();
     $contract = array();
     $contract['contract_type'] = 0;
     //普通代理返利
     $contract['relation_id'] = 0;
     $contract['agent_id'] = 0;
     $contract['user_id'] = $agent['user_id'];
     $contract['flag'] = 0;
     $contract['type'] = $template['type'];
     $contract['taxrate'] = 0;
     $contract['createtime'] = date("Y-m-d H:i:s", time());
     $contract['starttime'] = date("Y-m-d H:i:s", time());
     $contract['lastsettletime'] = date("Y-m-d H:i:s", time());
     $contract['note'] = null;
     if ($contractId = $mtContractDao->add($contract)) {
         foreach ($dtlTemplateList as $aDtlTemplate) {
             $contractDtl = array();
             $contractDtl['contract_id'] = $contractId;
             $contractDtl['grade'] = $aDtlTemplate['grade'];
             $contractDtl['minimum'] = $aDtlTemplate['minimum'];
             $contractDtl['maximum'] = $aDtlTemplate['maximum'];
             $contractDtl['rate'] = $aDtlTemplate['rate'];
             $contractDtl['createtime'] = date("Y-m-d H:i:s", time());
             $mtContractDtlDao->add($contractDtl);
         }
         remind::set(Kohana::lang('o_global.add_success'), 'distribution/month_contract/index/' . $userId, 'success');
     } else {
         remind::set(Kohana::lang('o_global.add_error'), request::referrer(), 'error');
     }
 }
コード例 #2
0
ファイル: agent.php プロジェクト: RenzcPHP/3dproduct
 public function open($agentId)
 {
     //权限验证
     role::check('distribution_system_manage');
     if (!$agentId) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
     }
     $aAgent = $this->agentDao->get_by_id($agentId);
     if ($aAgent == null) {
         remind::set(Kohana::lang('o_agent.agent_not_exists'), request::referrer(), 'error');
     }
     $realCttDao = MyRealtime_contract::instance();
     $searchStruct = array();
     //检查实时合约 (普通)
     $searchStruct['where'] = array('user_id' => $aAgent['user_id'], 'type' => 0, 'flag' => 2);
     $realCttList = $realCttDao->lists($searchStruct);
     if (count($realCttList) == 0) {
         remind::set(Kohana::lang('o_contract.normal_realtime_contract_missing'), request::referrer(), 'error');
     }
     if (count($realCttList) > 1) {
         remind::set(Kohana::lang('o_contract.too_many_normal_realtime_contract'), request::referrer(), 'error');
     }
     //检查实时合约 (北单)
     $searchStruct['where'] = array('user_id' => $aAgent['user_id'], 'type' => 7, 'flag' => 2);
     $realCttList = $realCttDao->lists($searchStruct);
     if (count($realCttList) == 0) {
         remind::set(Kohana::lang('o_contract.BEIDAN_realtime_contract_missing'), request::referrer(), 'error');
     }
     if (count($realCttList) > 1) {
         remind::set(Kohana::lang('o_contract.too_many_BEIDAN_realtime_contract'), request::referrer(), 'error');
     }
     $monthCttDao = MyMonth_contract::instance();
     //检查月结合约 (普通)
     $searchStruct['where'] = array('user_id' => $aAgent['user_id'], 'type' => 0, 'flag' => 2);
     $monthCttList = $monthCttDao->lists($searchStruct);
     if (count($monthCttList) == 0) {
         remind::set(Kohana::lang('o_contract.normal_month_contract_missing'), request::referrer(), 'error');
     }
     if (count($monthCttList) > 1) {
         remind::set(Kohana::lang('o_contract.too_many_normal_month_contract'), request::referrer(), 'error');
     }
     //检查月结合约 (北单)
     $searchStruct['where'] = array('user_id' => $aAgent['user_id'], 'type' => 7, 'flag' => 2);
     $realCttList = $monthCttDao->lists($searchStruct);
     if (count($realCttList) == 0) {
         remind::set(Kohana::lang('o_contract.BEIDAN_month_contract_missing'), request::referrer(), 'error');
     }
     if (count($realCttList) > 1) {
         remind::set(Kohana::lang('o_contract.too_many_BEIDAN_month_contract'), request::referrer(), 'error');
     }
     //通过有效性检查,开启代理用户
     $aAgent['flag'] = 2;
     if ($this->agentDao->edit($aAgent)) {
         remind::set(Kohana::lang('o_global.update_success'), request::referrer(), 'success');
     } else {
         remind::set(Kohana::lang('o_global.update_fail'), request::referrer(), 'error');
     }
 }