Demo entry 5950772

php

   

Submitted by anonymous on Sep 08, 2016 at 05:43
Language: PHP. Code size: 85.2 kB.

<?php
class b2b_businessControl extends SystemControl{

    public function __construct(){
        parent::__construct();
    }

    public function indexOp() {
        Tpl::setDirquna('supplier');
        Tpl::showpage('b2b_business.index');
    }

    public function get_xmlOp() {
        $model_business = Model('b2b_business');
        $condition  = array();
        if ($_POST['query'] != '') {
            $condition[$_POST['qtype']] = array('like', '%' . $_POST['query'] . '%');
        }
        
        $list = $model_business->getBusinessList($condition,'*','',$_POST['rp']);
        $data = array();
        $data['now_page'] = $model_business->shownowpage();
        $data['total_num'] = $model_business->gettotalnum();
        foreach ($list as $k => $info) {
            $list = array();$operation_detail = '';
//            $list['operation'] = "<a class='btn red' onclick=\"fg_delete({$info['business_id']})\"><i class='fa fa-trash-o'></i>删除</a>";
            $operation_detail .= "<li><a href=\"index.php?act=b2b_business&op=edit&business_id={$info['business_id']}\" style=\"text-align: left;\">编辑</a></li>";
            $operation_detail .= "<li><a href=\"index.php?act=b2b_business&op=add_business_area&business_id={$info['business_id']}\">业务-地区设置</a></li>";
//            $operation_detail .= "<li><a href=\"index.php?act=b2b_business&op=add_business_chain&business_id={$info['business_id']}\">业务-提货点设置</a></li>";
            
            $list['operation'] .= "<span class='btn'><em><i class='fa fa-cog'></i>设置 <i class='arrow'></i></em><ul>{$operation_detail}</ul>";
            $list['business_id'] = $info['business_id'];
            $list['business_name'] = $info['business_name'];
            $list['business_sort'] = $info['business_sort'];
            $list['state'] = Model('b2b_business')->getState($info['state']);
            $data['list'][$info['business_id']] = $list;
        }
        exit(Tpl::flexigridXML($data));
    }

    public function addOp() {
        $info = array();
        $model_business = Model('b2b_business');
        Tpl::setDirquna('supplier');
        Tpl::showpage('b2b_business.add');
    }

    public function saveOp() {
        if (!chksubmit()) return ;
        $model_business = Model('b2b_business');
        $data = array();
        $data['business_name'] = $_POST['business_name'];
        $data['business_sort'] = $_POST['business_sort'];
        
        
        if ($_GET['business_id']) {
            $data['state']=  intval($_POST['state']);
            $result = $model_business->editBusiness($data,array('business_id'=>intval($_GET['business_id'])));
        } else {
            $data['state'] = 1;
            $result = $model_business->addBusiness($data);
        }
        if ($result) {
            showMessage('操作成功',$_GET['business_id'] ? 'index.php?act=b2b_business' : '');
        } else {
            showMessage('操作失败','','html','error');
        }
    }

    public function editOp() {
        $business_id = intval($_GET['business_id']);
        if ($business_id <= 0) {
            showMessage('参数错误','','html','error');
        }

        $model_business = Model('b2b_business');
        $info = $model_business->getBusinessInfo(array('business_id'=>$business_id));
        if (!$info) {
            showMessage('该业务区不存在','','html','error');
        }

        Tpl::output('info',$info);
        Tpl::setDirquna('supplier');
        Tpl::showpage('b2b_business.edit');
    }

    public function delOp(){
        $model_business = Model('b2b_business');
        $condition = array();
        if (preg_match('/^[\d,]+$/', $_GET['business_id'])) {
            $business_ids = explode(',',trim($_GET['business_id'],','));
            foreach ($business_ids as $v) {
                $business_ids = array_merge($business_ids,$model_business->getChildrenIDs($v));
            }
            $condition['business_id'] = array('in',$business_ids);
        }else{
            $condition['business_id'] = intval($_GET['business_id']);
        }
        $result = $model_business->delArea($condition);
        if ($result) {
            $this->log('删除业务区',1);
            exit(json_encode(array('state'=>true,'msg'=>'删除成功')));
        }
        exit(json_encode(array('state'=>false,'msg'=>'删除失败')));
    }
    
    public function business_areaOp() {
        Tpl::setDirquna('supplier');
        Tpl::showpage('b2b_business_area.index');
    }
    
    public function get_xml_business_areaOp() {
        $model_business = Model('b2b_business');
       
        $condition  = array();
        if ($_POST['query'] != '') {
            $condition[$_POST['qtype']] = array('like', '%' . $_POST['query'] . '%');
        }
        //用于取名字
        $area_array        = $model_business->getAreaID_NAME();
        $business_array    = $model_business->getBusinessID_NAME();
        
        $list = $model_business->getBusinessAreaList($condition,'*','',$_POST['rp']);
        $data = array();
        $data['now_page'] = $model_business->shownowpage();
        $data['total_num'] = $model_business->gettotalnum();
        foreach ($list as $k => $info) {
            $list = array();$operation_detail = '';
//            $list['operation'] = "<a class='btn red' onclick=\"fg_delete({$info['business_id']})\"><i class='fa fa-trash-o'></i>删除</a>";
//            $operation_detail .= "<li><a href=\"index.php?act=b2b_business&op=edit&business_id={$info['business_id']}\">编辑</a></li>";
            
            
//            $list['operation'] .= "<span class='btn'><em><i class='fa fa-cog'></i>设置 <i class='arrow'></i></em><ul>{$operation_detail}</ul>";
            $list['area_id']       = $info['area_id'];
            $list['area_name']     = $area_array[$info['area_id']];
            $list['business_id']   = $info['business_id'];
            $list['business_name'] = $business_array[$info['business_id']];

            $data['list'][$info['area_id']] = $list;
        }
        exit(Tpl::flexigridXML($data));
    }
    
    
    public function add_business_areaOp() {
        $info = array();
        $model_business = Model('b2b_business');

        if (chksubmit()){
            
            $obj_validate = new Validate();
            $obj_validate->validateparam = array(
                array("input"=>$_POST["business_id"], "require"=>"true", "message"=>'id不能为空'),
                
            );
            $error = $obj_validate->validate();
            if ($error != ''){
                showMessage($error);
            }
            
            
            
            $business_id = trim($_POST['business_id']);
            $area_ids=explode(',',$_POST['area_ids']);
            
            $data_array = array();
            foreach ($area_ids as $value) {
                //判断该地区是否已经绑定
                $is_area=$model_business->getBusiness_AreaInfo(array('area_id'=>$value));
                if(!empty($is_area)&&$is_area['business_id']!=$business_id){
                    $areainfo=Model('area')->getAreaInfo(array('area_id'=>$value));
                    showMessage($areainfo['area_name'].'已经设置业务区'.$is_area['business_id'].'!');
                }else{
                    array_push($data_array, array('area_id'=>$value,'business_id'=>$business_id));
                }
            }
            
            //将之前的business_id删除后添加
            $model_business->delBusiness_Area(array('business_id'=>$business_id));
            
            $re = $model_business->addBusiness_Area($data_array);

            if(!$re){
                showMessage('设置业务区-地区失败!');
            }
            
            $url = array(
                array(
                    'url'=>'index.php?act=b2b_business&op=index',
                    'msg'=>'继续添加'
                ),
                array(
                    'url'=>'index.php?act=b2b_business&op=index',
                    'msg'=>'查看列表'
                )
            );
            $this->log(L('nc_add,b2b_business_area').'['.$_POST['business_id'].']',1);
            showMessage('添加成功',$url);
        }

        
        
        $areas=Model('area')->getAreas();

        $business_areas_set=$model_business->getBusinessAreaList(array('business_id'=>$_GET['business_id']));
        $area_ids_val=array();
        foreach ($business_areas_set as $value) {
            array_push($area_ids_val, $value['area_id']);
        }
        $area_ids_val_str=implode(",",$area_ids_val);
        
        Tpl::output('business_areas_set', $business_areas_set);
        Tpl::output('area_ids_val', $area_ids_val_str);

        Tpl::output('areas', $areas);
        Tpl::output('areas_province', $areas['children'][0]);
        
        
        
        
        Tpl::setDirquna('supplier');
        Tpl::showpage('b2b_business_area.add');
    }
    
    
    /**
     * 新增业务区与提货点关联
     */
    public function add_business_chainOp() {
        $info = array();
        $model_business = Model('b2b_business');

        if (chksubmit()){
            
            $obj_validate = new Validate();
            $obj_validate->validateparam = array(
                array("input"=>$_POST["business_id"], "require"=>"true", "message"=>'id不能为空'),
                
            );
            $error = $obj_validate->validate();
            if ($error != ''){
                showMessage($error);
            }
            
            
            
            $business_id = trim($_POST['business_id']);
            $area_ids=explode(',',$_POST['area_ids']);
            
            $data_array = array();
            foreach ($area_ids as $value) {
                //判断该地区是否已经绑定
                $is_area=$model_business->getBusiness_AreaInfo(array('area_id'=>$value));
                if(!empty($is_area)&&$is_area['business_id']!=$business_id){
                    $areainfo=Model('area')->getAreaInfo(array('area_id'=>$value));
                    showMessage($areainfo['area_name'].'已经设置业务区'.$is_area['business_id'].'!');
                }else{
                    array_push($data_array, array('area_id'=>$value,'business_id'=>$business_id));
                }
            }
            
            //将之前的business_id删除后添加
            $model_business->delBusiness_Area(array('business_id'=>$business_id));
            
            $re = $model_business->addBusiness_Area($data_array);

            if(!$re){
                showMessage('设置业务区-地区失败!');
            }
            
            $url = array(
                array(
                    'url'=>'index.php?act=b2b_business&op=index',
                    'msg'=>'继续添加'
                ),
                array(
                    'url'=>'index.php?act=b2b_business&op=index',
                    'msg'=>'查看列表'
                )
            );
            $this->log(L('nc_add,b2b_business_area').'['.$_POST['business_id'].']',1);
            showMessage('添加成功',$url);
        }

        
        
        $areas=Model('area')->getAreas();

        $business_areas_set=$model_business->getBusinessAreaList(array('business_id'=>$_GET['business_id']));
        $area_ids_val=array();
        foreach ($business_areas_set as $value) {
            array_push($area_ids_val, $value['area_id']);
        }
        $area_ids_val_str=implode(",",$area_ids_val);
        
        Tpl::output('business_areas_set', $business_areas_set);
        Tpl::output('area_ids_val', $area_ids_val_str);

        Tpl::output('areas', $areas);
        Tpl::output('areas_province', $areas['children'][0]);
        
        
        
        
        Tpl::setDirquna('supplier');
        Tpl::showpage('b2b_business_area.add');
    }

}

<?php

class b2b_jjw_refereeControl extends SystemControl{
    const EXPORT_SIZE = 1000;
    public function __construct(){
        parent::__construct();
        Language::read('b2b_jjw_referee');
    }

    public function indexOp() {
        $this->b2b_jjw_refereeOp();
    }

    /**
     * 推荐人管理
     */
    public function b2b_jjw_refereeOp(){
        Tpl::setDirquna('supplier'); 
        Tpl::showpage('b2b_jjw_referee.index');
    }

    /**
     * 推荐人修改
     */
    public function b2b_jjw_referee_editOp(){
        $lang   = Language::getLangContent();
        $model_jjw_referee = Model('b2b_jjw_referee');
        /**
         * 保存
         */
        if (chksubmit()){
            /**
             * 验证
             */
            $obj_validate = new Validate();
            $obj_validate->validateparam = array(
            array("input"=>$_POST["referee"], "require"=>"true",  "message"=>'名字不能为空'),
            );
            $error = $obj_validate->validate();
            if ($error != ''){
                showMessage($error);
            }else {
                $update_array = array();
                
                $update_array['referee_mobile'] = $_POST['referee_mobile'];
                $update_array['state']          = $_POST['state'];

                $result = $model_jjw_referee->editjjw_referee(array('referee_id'=>intval($_POST['referee_id'])),$update_array);
               
                if ($result){
                    $url = array(
                    array(
                    'url'=>'index.php?act=b2b_jjw_referee&op=index',
                    'msg'=>'返回列表',
                    ),
                    array(
                    'url'=>'index.php?act=b2b_jjw_referee&op=b2b_jjw_referee_edit&referee_id='.intval($_POST['referee_id']),
                    'msg'=>'再次修改',
                    ),
                    );
                    $this->log(L('nc_edit,referee_index_name').'[ID:'.$_POST['referee_id'].']',1);
                    showMessage('编辑成功!',$url);
                }else {
                    showMessage('编辑失败!');
                }
            }
        }
        $condition['referee_id'] = intval($_GET['referee_id']);
        $referee_array = $model_jjw_referee->getjjw_refereeInfo($condition);

        Tpl::output('referee_array',$referee_array);
        
        
       
        Tpl::setDirquna('supplier'); 
        Tpl::showpage('b2b_jjw_referee.edit');
    }

    /**
     * 新增推荐人
     */
    public function b2b_jjw_referee_addOp(){
        $lang   = Language::getLangContent();
        $model_jjw_referee = Model('b2b_jjw_referee');
        
        /**
         * 保存
         */
        if (chksubmit()){
            /**
             * 验证
             */
            $obj_validate = new Validate();
            $obj_validate->validateparam = array(
                array("input"=>$_POST["referee"], "require"=>"true", "message"=>'名字不能为空'),
            );
            $error = $obj_validate->validate();
            if ($error != ''){
                showMessage($error);
            }else {
                $insert_array = array();
                $insert_array['referee']     = trim($_POST['referee']);
                $insert_array['referee_mobile']   = trim($_POST['referee_mobile']);

                $result = $model_jjw_referee->addjjw_referee($insert_array);
                if ($result){
                    $url = array(
                    array(
                    'url'=>'index.php?act=b2b_jjw_referee&op=index',
                    'msg'=>'返回列表',
                    ),
                    array(
                    'url'=>'index.php?act=b2b_jjw_referee&op=jjw_referee_add',
                    'msg'=>'再次添加',
                    ),
                    );
                    $this->log(L('nc_add,referee_index_name').'[ '.$_POST['referee'].']',1);
                    showMessage('推荐人添加成功!',$url);
                }else {
                    showMessage('推荐人添加失败!');
                }
            }
        }
        
        
        
        
        
        Tpl::setDirquna('supplier'); 
        Tpl::showpage('b2b_jjw_referee.add');
    }

    /**
     * ajax操作
     */
    public function ajaxOp(){
        switch ($_GET['branch']){
                /**
             * 推荐人手机号码
             */
            case 'check_referee_mobile':
                $model_jjw_referee = Model('b2b_jjw_referee');
                $condition['referee_mobile'] = $_GET['referee_mobile'];
                $condition['referee_id'] = array('neq',intval($_GET['referee_id']));
                $list = $model_jjw_referee->getjjw_refereeInfo($condition);
                if (empty($list)){
                    echo 'true';exit;
                }else {
                    echo 'false';exit;
                }
                break;
        }
    }

    /**
     * 输出XML数据
     */
    public function get_xmlOp() {
        $model_jjw_referee = Model('b2b_jjw_referee');
       
        $condition = array();
        if ($_POST['query'] != '') {
            $condition[$_POST['qtype']] = array('like', '%' . $_POST['query'] . '%');
        }
        $order = '';
        $param = array('referee_id','referee','state');
        if (in_array($_POST['sortname'], $param) && in_array($_POST['sortorder'], array('asc', 'desc'))) {
            $order = $_POST['sortname'] . ' ' . $_POST['sortorder'];
        }
        $page = $_POST['rp'];
        $member_list = $model_jjw_referee->getjjw_refereeList($condition, '*', $page, $order);

        $sex_array = $this->get_sex();

        $data = array();
        $data['now_page'] = $model_jjw_referee->shownowpage();
        $data['total_num'] = $model_jjw_referee->gettotalnum();
        foreach ($member_list as $value) {
            $param = array();
            $param['operation'] = "<a class='btn blue' href='index.php?act=b2b_jjw_referee&op=b2b_jjw_referee_edit&referee_id=" . $value['referee_id'] . "'><i class='fa fa-pencil-square-o'></i>编辑</a>";
            $param['referee_id']     = $value['referee_id'];
            $param['referee']        = $value['referee'];
            $param['referee_mobile'] = $value['referee_mobile'];
            $param['state']          = $model_jjw_referee->getState($value['state']);

            $data['list'][$value['referee_id']] = $param;
        }
        echo Tpl::flexigridXML($data);exit();
    }

    /**
     * 性别
     * @return multitype:string
     */
    private function get_sex() {
        $array = array();
        $array[1] = '男';
        $array[2] = '女';
        $array[3] = '保密';
        return $array;
    }
    /**
     * csv导出
     */
    public function export_csvOp() {
        $model_jjw_referee = Model('b2b_jjw_referee');
        $condition = array();
        $limit = false;
        if ($_GET['id'] != '') {
            $id_array = explode(',', $_GET['id']);
            $condition['member_id'] = array('in', $id_array);
        }
        if ($_GET['query'] != '') {
            $condition[$_GET['qtype']] = array('like', '%' . $_GET['query'] . '%');
        }
        $order = '';
        $param = array('member_id','member_name','member_avatar','member_email','member_mobile','member_sex','member_truename','member_birthday'
                ,'member_time','member_login_time','member_login_ip','member_points','member_exppoints','member_grade','available_predeposit'
                ,'freeze_predeposit','available_rc_balance','freeze_rc_balance','inform_allow','is_buy','is_allowtalk','member_state'
        );
        if (in_array($_GET['sortname'], $param) && in_array($_GET['sortorder'], array('asc', 'desc'))) {
            $order = $_GET['sortname'] . ' ' . $_GET['sortorder'];
        }
        if (!is_numeric($_GET['curpage'])){
            $count = $model_jjw_referee->getMemberCount($condition);
            if ($count > self::EXPORT_SIZE ){   //显示下载链接
                $array = array();
                $page = ceil($count/self::EXPORT_SIZE);
                for ($i=1;$i<=$page;$i++){
                    $limit1 = ($i-1)*self::EXPORT_SIZE + 1;
                    $limit2 = $i*self::EXPORT_SIZE > $count ? $count : $i*self::EXPORT_SIZE;
                    $array[$i] = $limit1.' ~ '.$limit2 ;
                }
                Tpl::output('list',$array);
                Tpl::output('murl','index.php?act=b2b_jjw_referee&op=index');
                Tpl::setDirquna('supplier'); 
                Tpl::showpage('export.excel');
                exit();
            }
        } else {
            $limit1 = ($_GET['curpage']-1) * self::EXPORT_SIZE;
            $limit2 = self::EXPORT_SIZE;
            $limit = $limit1 .','. $limit2;
        }

        $member_list = $model_jjw_referee->getMemberList($condition, '*', null, $order, $limit);
        $this->createCsv($member_list);
    }
    /**
     * 生成csv文件
     */
    private function createCsv($member_list) {
        $model_jjw_referee = Model('b2b_jjw_referee');
        $member_grade = $model_jjw_referee->getMemberGradeArr();
        // 性别
        $sex_array = $this->get_sex();
        $data = array();
        foreach ($member_list as $value) {
            $param = array();
            $param['member_id'] = $value['member_id'];
            $param['member_name'] = $value['member_name'];
            $param['member_avatar'] = getMemberAvatarForID($value['member_id']);
            $param['member_email'] = $value['member_email'];
            $param['member_mobile'] = $value['member_mobile'];
            $param['member_sex'] = $sex_array[$value['member_sex']];
            $param['member_truename'] = $value['member_truename'];
            $param['member_birthday'] = $value['member_birthday'];
            $param['member_time'] = date('Y-m-d', $value['member_time']);
            $param['member_login_time'] = date('Y-m-d', $value['member_login_time']);
            $param['member_login_ip'] = $value['member_login_ip'];
            $param['member_points'] = $value['member_points'];
            $param['member_exppoints'] = $value['member_exppoints'];
            $param['member_grade'] = ($t = $model_jjw_referee->getOneMemberGrade($value['member_exppoints'], false, $member_grade))?$t['level_name']:'';
            $param['available_predeposit'] = ncPriceFormat($value['available_predeposit']);
            $param['freeze_predeposit'] = ncPriceFormat($value['freeze_predeposit']);
            $param['available_rc_balance'] = ncPriceFormat($value['available_rc_balance']);
            $param['freeze_rc_balance'] = ncPriceFormat($value['freeze_rc_balance']);
            $param['inform_allow'] = $value['inform_allow'] ==  '1' ? '是' : '否';
            $param['is_buy'] = $value['is_buy'] ==  '1' ? '是' : '否';
            $param['is_allowtalk'] = $value['is_allowtalk'] ==  '1' ? '是' : '否';
            $param['member_state'] = $value['member_state'] ==  '1' ? '是' : '否';
            $data[$value['member_id']] = $param;
        }

        $header = array(
                'member_id' => '会员ID',
                'member_name' => '会员名称',
                'member_avatar' => '会员头像',
                'member_email' => '会员邮箱',
                'member_mobile' => '会员手机',
                'member_sex' => '会员性别',
                'member_truename' => '真实姓名',
                'member_birthday' => '出生日期',
                'member_time' => '注册时间',
                'member_login_time' => '最后登录时间',
                'member_login_ip' => '最后登录IP',
                'member_points' => '会员积分',
                'member_exppoints' => '会员经验',
                'member_grade' => '会员等级',
                'available_predeposit' => '可用预存款(元)',
                'freeze_predeposit' => '冻结预存款(元)',
                'available_rc_balance' => '可用充值卡(元)',
                'freeze_rc_balance' => '冻结充值卡(元)',
                'inform_allow' => '允许举报',
                'is_buy' => '允许购买',
                'is_allowtalk' => '允许咨询',
                'member_state' => '允许登录'
        );
       array_unshift($data, $header);
        $csv = new Csv();
        $export_data = $csv->charset($data,CHARSET,'gbk');
        $csv->filename = $csv->charset('member_list',CHARSET).$_GET['curpage'] . '-'.date('Y-m-d');
        $csv->export($data);   
    }
    
    
}

<?php
class store_goods_priceControl extends BaseSellerControl {
    public function __construct() {
        parent::__construct ();
        Language::read ('member_store_goods_index');
    }
    public function indexOp() {
        $this->goods_listOp();
    }

    /**
     * 出售中的商品列表
     */
    public function goods_listOp() {
        $model_goods = Model('supplier_goods');
        $model_wgp = Model('b2b_wholesale_grade_price');

        $where = array();
        $where['store_id'] = $_SESSION['b2b_store_id'];
        if (intval($_GET['stc_id']) > 0) {
            $where['goods_stcids'] = array('like', '%,' . intval($_GET['stc_id']) . ',%');
        }
        if (trim($_GET['keyword']) != '') {
            switch ($_GET['search_type']) {
                case 0:
                    $where['goods_name'] = array('like', '%' . trim($_GET['keyword']) . '%');
                    break;
                case 1:
                    $where['goods_serial'] = array('like', '%' . trim($_GET['keyword']) . '%');
                    break;
                case 2:
                    $where['goods_commonid'] = intval($_GET['keyword']);
                    break;
            }
        }
        if (intval($_GET['sup_id']) > 0) {
            $where['sup_id']= intval($_GET['sup_id']);
        }

        //权限组对应分类权限判断
        if (!$_SESSION['b2b_seller_gc_limits'] && $_SESSION['b2b_seller_group_id']) {
            $gc_list = Model('supplier_seller_group_bclass')->getSellerGroupBclasList(array('group_id'=>$_SESSION['b2b_seller_group_id']),'','','gc_id','gc_id');
            $where['gc_id'] = array('in',array_keys($gc_list));
        }
        //导出时查询所有数据
        if($_GET['export']==1){
            $goods_list = $model_goods->getGoodsCommonOnlineList($where,'*',0,'goods_commonid asc');
        }else{
            $goods_list = $model_goods->getGoodsCommonOnlineList($where,'*',10,'goods_commonid asc');
        }
        
        
        foreach ($goods_list as $key=>$value) {
            //截取名字字符串
            $goods_list[$key]['goods_name_limit']=$this->substr_cut($value['goods_name'],6);
            
            //根据spu查询该spu的所有sku商品
            $goods_list_sku = $model_goods->getGoodsList(array('store_id' => $_SESSION['b2b_store_id'], 'goods_commonid' => $value['goods_commonid']), 'goods_id,goods_name,goods_spec,store_id,goods_price,goods_serial,goods_storage_alarm,goods_storage,invite_rate');
            
            if(!empty($goods_list_sku)){
                //获取规格名称
                $spec_name = array_values((array)unserialize($value['spec_name']));
                $goodskuids=array();
                foreach ($goods_list_sku as $k => $v) {
                    array_push($goodskuids, $v['goods_id']);
                }
                
                //获取所有sku的批发等级价格
                $condition_wgp=array();
                if(!empty($goodskuids)){
                    $condition_wgp['goods_id']=array('IN',$goodskuids);
                    $result_wgp=$model_wgp->getWGP($condition_wgp);
                }else{
                    $result_wgp=array();
                }
                $sku_goods_wgp=$model_wgp->format_goods_price($goodskuids,$result_wgp['wgplist']);
                
                foreach ($goods_list_sku as $kk => $val) {
                    $goods_specs = array_values((array)unserialize($val['goods_spec']));
                    $spec_str="";
                    foreach ($goods_specs as $k=>$v) {
                        if(strlen($spec_str)>0){
                            $spec_str.=','.$spec_name[$k].':'.$v;
                        }else{
                             $spec_str.=$spec_name[$k].':'.$v;
                        }
                    }
                    $goods_list_sku[$kk]['goods_spec']=$spec_str;
                    //截取字符串
                    $goods_list_sku[$kk]['goods_spec_limit']=$this->substr_cut($spec_str,6);
                    
                    //设置批发等级价格
                    $goods_list_sku[$kk]['wgp']=$sku_goods_wgp[$val['goods_id']];
                }
            } 
            
            //将sku传入spu中
            $goods_list[$key]['goods_sku_list']=$goods_list_sku;
        }
        
        
        Tpl::output('show_page', $model_goods->showpage());
        Tpl::output('goods_list', $goods_list);

        // 计算库存
        $storage_array = $model_goods->calculateStorage($goods_list);
        Tpl::output('storage_array', $storage_array);

        // 商品分类
        $store_goods_class = Model('supplier_store_goods_class')->getClassTree(array('store_id' => $_SESSION['b2b_store_id'], 'stc_state' => '1'));
        Tpl::output('store_goods_class', $store_goods_class);

        // 供货商
        $supplier_list = Model('supplier_store_supplier')->getStoreSupplierList(array('sup_store_id' => $_SESSION['b2b_store_id']));
        Tpl::output('supplier_list', $supplier_list);
        
        // 分销权限
        $store_info = $this->store_info; 
        $distribution_info = Model('supplier_store_distribution')->where(array('distri_store_id'=>$store_info['store_id']))->find();
        Tpl::output('distribution_info',$distribution_info);
        Tpl::output('store_info',$store_info);
                
                
                
        //批发等级
        $model_wholesalegrade = Model('b2b_wholesale_grade');
        $ValidWholesaleGrade=$model_wholesalegrade->getValidWholesaleGrade();
        Tpl::output('ValidWholesaleGrade',$ValidWholesaleGrade);
        
        //是否导出数据
        if($_GET['export']==1){
            $this->export_sku_price($goods_list);
            exit();
        }
                
        $this->profile_menu('goods_list', 'goods_list');
        Tpl::showpage('store_goods_price.list');
    }



    /**
     * ajax获取商品列表
     */
    public function get_goods_list_ajaxOp() {
        $common_id = $_GET['commonid'];
        if ($common_id <= 0) {
            echo 'false';exit();
        }
        $model_goods = Model('supplier_goods');
        $goodscommon_list = $model_goods->getGoodsCommonInfoByID($common_id, 'spec_name,store_id');
        if (empty($goodscommon_list) || $goodscommon_list['store_id'] != $_SESSION['b2b_store_id']) {
            echo 'false';exit();
        }
        $goods_list = $model_goods->getGoodsList(array('store_id' => $_SESSION['b2b_store_id'], 'goods_commonid' => $common_id), 'goods_id,goods_spec,store_id,goods_price,goods_serial,goods_storage_alarm,goods_storage,goods_image,invite_rate');
        if (empty($goods_list)) {
            echo 'false';exit();
        }
        // 分销权限
        $store_info = $this->store_info; 

        $spec_name = array_values((array)unserialize($goodscommon_list['spec_name']));
        foreach ($goods_list as $key => $val) {
            $goods_spec = array_values((array)unserialize($val['goods_spec']));
            $spec_array = array();
            foreach ($goods_spec as $k => $v) {
                $spec_array[] = '<div class="goods-spec">' . $spec_name[$k] . L('nc_colon') . '<em title="' . $v . '">' . $v .'</em>' . '</div>';
            }
            $goods_list[$key]['is_distribution']       = $store_info['is_distribution'];
            $goods_list[$key]['goods_id']       = $val['goods_id'];
            $goods_list[$key]['goods_serial']   = $val['goods_serial'];
            $goods_list[$key]['invite_rate']   = $val['invite_rate'];
            $goods_list[$key]['goods_image']    = b2b_thumb($val, '60');
            $goods_list[$key]['goods_spec']     = implode('', $spec_array);
            $goods_list[$key]['alarm']          = ($val['goods_storage_alarm'] != 0 && $val['goods_storage'] <= $val['goods_storage_alarm']) ? 'style="color:red;"' : '';
            $goods_list[$key]['url']            = urlSupplier('goods', 'index', array('goods_id' => $val['goods_id']));
        }

        /**
         * 转码
         */
        if (strtoupper(CHARSET) == 'GBK') {
            Language::getUTF8($goods_list);
        }
        echo json_encode($goods_list);
    }
    
    /**
     * 用户中心右边,小导航
     *
     * @param string $menu_type 导航类型
     * @param string $menu_key 当前导航的menu_key
     * @param boolean $allow_promotion
     * @return
     */
    private function profile_menu($menu_type,$menu_key, $allow_promotion = array()) {
        $menu_array = array();
        switch ($menu_type) {
            case 'goods_price_list':
                $menu_array = array(
                   array('menu_key' => 'goods_price_list',    'menu_name' => '修改价格', 'menu_url' => urlSupplier('store_goods_online', 'index'))
                );
                break;
            
        }
        Tpl::output ( 'member_menu', $menu_array );
        Tpl::output ( 'menu_key', $menu_key );
    }
    
    /*
     * 截取字符串
     * 
     */
    private function substr_cut($str_cut,$length){
        //截取字符串
        if(strlen($str_cut)>$length){
            while (ord($str_cut[$length])>128) {
                $length=$length+2;
            }
//            if(ord($str_cut[$length])>128){
//                
//            }
            $str_cut=substr($str_cut, 0,$length)."...";
        }else{
            return $str_cut;
        }
        
        return $str_cut;
    } 
    
    /*
     * 保存修改的价格
     * Array(
                [sku_price_data] => Array
                    (
                        [0] => Array
                            (
                                [0] => 1        //skuId
                                [1] => 111.00   //price
                                [2] => 19       //storage
                            )
                    )
                [sku_wgp_data] => Array
                    (
                        [0] => Array
                            (
                                [0] => 1       //skuId
                                [1] => 2       //wgpId
                                [2] => 111.00  //price
                            )
                    )

                [common_id] => 1
            )
     */
    public function sku_price_saveOp() {
        $sku_price_data = $_POST['sku_price_data'];
        $sku_wgp_data   = $_POST['sku_wgp_data'];
        $common_id      = $_POST['common_id'];
        $model_goods    = Model('supplier_goods');
        $model_wgp      = Model('b2b_wholesale_grade_price');

        if(empty($sku_price_data)||empty($common_id)){
           echo json_encode(array('state'=>0,'msg'=>'提交参数错误!'));
           exit();
       }
        
        try {
            $model_goods->beginTransaction();
            $get_min=array();
            $sum_storage=0;
            foreach ($sku_price_data as $value) {
                $goods_id=$value[0];
                $update=array();
                $update['goods_price']   = $value[1];
                $update['goods_storage'] = $value[2];
               

                $result_p=$model_goods->editGoodsById($update, $goods_id); 
                if(!$result_p){
                    throw new Exception('批发价更新失败');
                }
                array_push($get_min, $value[1]);
                $sum_storage= $sum_storage+$value[2];
            }
            
            
            foreach ($sku_wgp_data as $v){
                //先删除原批发等级价$v[0]--goods_id   $v[1]--wholesale_grade_id
                if(empty($v[0])||empty($v[1])){
                    continue;
                }
                
                $result_wgp1=$model_wgp->del_wholesale_grade_price(array('goods_id'=>$v[0],'wholesale_grade_id'=>$v[1]));
                //添加新的批发等级价
                $data_wgp=array();
                $data_wgp['goods_id']           = $v[0];
                $data_wgp['wholesale_grade_id'] = $v[1];
                $data_wgp['price']              = $v[2];
                $result_wgp2=$model_wgp->add_wholesale_grade_price($data_wgp);
                if(!$result_wgp1||!$result_wgp2){
                    throw new Exception('批发等级价格更新失败');
                }
            }
            
            
            //获取最小价
            $goods_list_sku = $model_goods->getGoodsList(array('goods_commonid' => $value['goods_commonid']), 'goods_id,goods_price');
            foreach($goods_list_sku as $value){
                array_push($get_min, $value['goods_price']);
            }
            $min_price=min($get_min);
//            $common_info=$model_goods->getGoodsCommonInfoByID($common_id);
//            if($min_price<$common_info['goods_price']){
                $update_common=array();
                $update_common['goods_price']=$min_price;
                $condition_common=array();
                $condition_common['goods_commonid']=$common_id;
                $result_common=$model_goods->editGoodsCommon($update_common,$condition_common);
                if(!$result_common){
                    throw new Exception('common批发价格更新失败');
                }
            QueueClient::b2b_push('updateGoodsPromotionPriceByGoodsCommonId', $common_id);
            $model_goods->commit();
            
        }catch (Exception $e){
            $model_goods->rollback();
            echo json_encode(array('state'=>0,'msg'=>$e->getMessage()));
            exit();
        }
        
        echo json_encode(array('state'=>1,'msg'=>'修改成功!','min_price'=>$min_price,'sum_storage'=>$sum_storage));
        exit();
    }
    
    
    /**
     * 导出sku价格明细CSV
     *
     */
    private function export_sku_price($goods_list){
        $export_data = array();
        $export_data[0] = array('spu','sku','商品名','规格','库存','批发价');
        
        //取批发等级
        $model_wholesalegrade = Model('b2b_wholesale_grade');
        $ValidWholesaleGrade=$model_wholesalegrade->getValidWholesaleGrade();
        
        foreach ($ValidWholesaleGrade as $value) {
            array_push($export_data[0], $value['grade_name']);
        }
        
        $k = 0;
        foreach ($goods_list as $value) {
            foreach ($value['goods_sku_list'] as $v) {

                $export_data[$k+1][] = $value['goods_commonid'];
                $export_data[$k+1][] = $v['goods_id'];
                $export_data[$k+1][] = $v['goods_name'];
                $export_data[$k+1][] = $v['goods_spec'];
                $export_data[$k+1][] = $v['goods_storage'];
                $export_data[$k+1][] = $v['goods_price'];
                //注意此顺序会影响到后续的导入数据,如果等级规则发生变动,请重新导出一份最新的批发等级规则
                foreach ($ValidWholesaleGrade as $vv) {
                    if(isset($v['wgp'][$vv['wholesale_grade_id']])){
                        $export_data[$k+1][]=$v['wgp'][$vv['wholesale_grade_id']];
                    }else{
                        $export_data[$k+1][]=0;
                    }
                }
                $k++;
            }
        }
        
        
        $csv = new Csv();
        $export_data = $csv->charset($export_data,CHARSET,'gbk');
        $csv->filename = 'sku_price_'.date('YmdHis');
        $csv->export($export_data);
    }
    
    /*
     * 导入csv
     */
    private function import_sku_price($goods_list){
        
    }
    
    
   
    public function import_csvOp(){
        if(chksubmit()){
            
            $file   = $_FILES['csv'];
            //上传文件存在判断
            if(empty($file['name'])){
                showMessage('请上传文件','','html','error');
            }
            //文件类型判断
            $file_name_array    = explode('.',$file['name']);
            if($file_name_array[count($file_name_array)-1] != 'csv'){
                    showMessage('文件类型必须为csv,您所上传的文件类型为:'.$file_name_array[count($file_name_array)-1],'','html','error');
            }
            $data_csv=array();
            
            $handle = fopen($file['tmp_name'], 'r');
            while(!feof($handle))
            {
                $result=fgetcsv($handle);
                $data_csv[]=$result;
            }
            fclose($handle);
            
            //去掉首行数据
            unset($data_csv[0]);
            
            //开始更新数据
            $model_goods    = Model('supplier_goods');
            $model_wgp      = Model('b2b_wholesale_grade_price');
            
            //取批发等级
            $model_wholesalegrade = Model('b2b_wholesale_grade');
            $ValidWholesaleGrade=$model_wholesalegrade->getValidWholesaleGrade();
            
            try {
                $model_goods->beginTransaction();
                
                $data_wgp_goodsids=array();
                $data_wgp_list=array();
                $get_min=array();
                foreach ($data_csv as $value) {
                    if(!is_array($value)){
                        continue;
                    }
                    
                    //更新批发价
                    $goods_id=$value[1];
                    $update=array();
                    $update['goods_price']   = $value[5];
                    $update['goods_storage'] = $value[4];

                    $result_p=$model_goods->editGoodsById($update, $goods_id); 
                    if(!$result_p){
                        throw new Exception('批发价更新失败');
                    }
                    
                    //组合公用参数
//                    if(is_array($get_min[$value[0]])){
//                        array_push($get_min[$value[0]], $value[5]);
//                    }else{
//                        $get_min[$value[0]]=array();
//                        array_push($get_min[$value[0]], $value[5]);
//                    }
                    $get_min[$value[0]][]+=$value[5];
                    
                    //获取导入的批发等级价的个数
                    $wgp_import_num=count($value)-6;
                    //系统的批发等级数量
                    $wgp_system_num=count($ValidWholesaleGrade);
                    
                    
                    if($wgp_import_num!=$wgp_system_num){
                        throw new Exception('等级价格数量匹配失败');
                    }
                    
                    //组合批发等级价数据
                    $data_wgp_goodsids[]=$value[1];
                    
                    for ($i=0;$i<$wgp_system_num;$i++) {
                        //添加新的批发等级价数据
                        $data_wgp_info=array();
                        $data_wgp_info['goods_id']           = $value[1];
                        $data_wgp_info['wholesale_grade_id'] = $ValidWholesaleGrade[$i]['wholesale_grade_id'];
                        $data_wgp_info['price']              = $value[$i + 6];
                        
                        if(empty($data_wgp_info['goods_id'])||empty($data_wgp_info['wholesale_grade_id'])){
                            throw new Exception('等级价格数据组成失败');
                        }

                        $data_wgp_list[]=$data_wgp_info;
                        
                        
                    }
                    
                    
                    
                    
                }
                //更新共用参数
                //获取最小价,修改共用参数的最小价
                foreach ($get_min as $key => $value) {
                    $min_price=min($value);
                    $update_common=array();
                    $update_common['goods_price']=$min_price;
                    $condition_common=array();
                    $condition_common['goods_commonid']=$key;
                    $result_common=$model_goods->editGoodsCommon($update_common,$condition_common);
                    if(!$result_common){
                        throw new Exception('common批发价格更新失败');
                    }
                    
//            if ($common_array['is_virtual'] == 1) {
                    // 如果是特殊商品清理促销活动,团购、限时折扣、组合销售
//                QueueClient::b2b_push('clearSpecialGoodsPromotion', array('goods_commonid' => $common_id, 'goodsid_array' => $goodsid_array));
//            } else {
                    // 更新商品促销价格
//                QueueClient::b2b_push('updateGoodsPromotionPriceByGoodsCommonId', $common_id);
//            }
                    //暂时不考虑特殊产品
                    // 更新商品促销价格
                    QueueClient::b2b_push('updateGoodsPromotionPriceByGoodsCommonId', $key);
                }
                


                
                //更新批发等级价
                if(!empty($data_wgp_goodsids)&&!empty($data_wgp_list)){
                    //先删除原所有的批发等级价
                    $result_wgp1=$model_wgp->del_wholesale_grade_price(array('goods_id'=>array('in',$data_wgp_goodsids)));
                    if(!$result_wgp1){
                        throw new Exception('批发等级价格批量修改失败');
                    }
                    //添加所有的批发等级价格
                    $result_wgp2=$model_wgp->addAll_wholesale_grade_price($data_wgp_list);
                    if(!$result_wgp2){
                        throw new Exception('批发等级价格批量更新失败');
                    }
                }
                
                
                
                
                $model_goods->commit();
                
            }catch (Exception $e){
                $model_goods->rollback();
                showMessage($e->getMessage(),'','html','error');
            }
            //更新数据结束    
            showMessage('批量更新完成','','html','succ');
            exit();
            
        }
        Tpl::showpage('store_goods_price.import');
    }

}


    /*
     * 导出execl文件
     */
    public function export_orderOp(){
        $objPHPExcel = new PHPExcel();
        
        //设置excel的属性
        $objPHPExcel->getProperties()->setCreator("机机网");
        $objPHPExcel->getProperties()->setLastModifiedBy("机机网");
        $objPHPExcel->getProperties()->setTitle("机机网");
        $objPHPExcel->getProperties()->setSubject("机机网");
        $objPHPExcel->getProperties()->setDescription("机机网");
        
        //设置当前的sheet
        $objPHPExcel->setActiveSheetIndex(0);
        //设置sheet的name
        $objPHPExcel->getActiveSheet()->setTitle($_SESSION['b2b_store_name'].'采购订单');
        //设置头部格式
//        $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
        $objPHPExcel->getActiveSheet()->getStyle('A1:O1')->getFont()->setBold(true);
        $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(17);
        
        $objPHPExcel->getActiveSheet()->SetCellValue('A1', '订单编号');
        
        $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(12);
        $objPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setWrapText(TRUE);
        $objPHPExcel->getActiveSheet()->SetCellValue('B1', '下单时间');
        $objPHPExcel->getActiveSheet()->SetCellValue('C1', 'sku');
        
        $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(12);
        $objPHPExcel->getActiveSheet()->getStyle('D')->getAlignment()->setWrapText(TRUE);
        $objPHPExcel->getActiveSheet()->SetCellValue('D1', '商品');
        
        $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(12);
        $objPHPExcel->getActiveSheet()->getStyle('E')->getAlignment()->setWrapText(TRUE);
        $objPHPExcel->getActiveSheet()->SetCellValue('E1', '规格');
        $objPHPExcel->getActiveSheet()->SetCellValue('F1', '价格');
        $objPHPExcel->getActiveSheet()->SetCellValue('G1', '数量');
        $objPHPExcel->getActiveSheet()->SetCellValue('H1', '商品总价');
        $objPHPExcel->getActiveSheet()->SetCellValue('I1', '订单总价');
        $objPHPExcel->getActiveSheet()->SetCellValue('J1', '付款方式');
        $objPHPExcel->getActiveSheet()->SetCellValue('K1', '付款时间');
        $objPHPExcel->getActiveSheet()->SetCellValue('L1', '是否配送');
        $objPHPExcel->getActiveSheet()->SetCellValue('M1', '购买人');
        
        $objPHPExcel->getActiveSheet()->getColumnDimension('N')->setWidth(17);
        $objPHPExcel->getActiveSheet()->getStyle('N')->getAlignment()->setWrapText(TRUE);
        $objPHPExcel->getActiveSheet()->SetCellValue('N1', '收货地址');
        
        $objPHPExcel->getActiveSheet()->getColumnDimension('O')->setWidth(17);
        $objPHPExcel->getActiveSheet()->getStyle('O')->getAlignment()->setWrapText(TRUE);
        $objPHPExcel->getActiveSheet()->SetCellValue('O1', '联系方式');
        $objPHPExcel->getActiveSheet()->SetCellValue('P1', '收货人');
        
        
        //获取 待发货的采购订单数据
        $model_order = Model('b2b_cg_order');
        $order_list = $model_order->getStoreOrderList($_SESSION['b2b_store_id'], '', '', 'state_pay', '', '', 1, '*', array('order_goods','order_common','member'));
        
        $order_list_num=count($order_list);
        //数据开始行数
        $row=2;
        $i=0;
        foreach ($order_list as $key => $value) {

            $setRow=$row+$i;//一个订单开始的行
            $objPHPExcel->getActiveSheet()->setCellValueExplicit('A'.($setRow),$order_list[$key]['order_sn'],PHPExcel_Cell_DataType::TYPE_STRING);//订单编号
            $objPHPExcel->getActiveSheet()->SetCellValue('B'.($setRow), date("Y-m-d H:i:s",$order_list[$key]['add_time']));//下单时间
            //循环商品明细
            $goods_num=count($order_list[$key]['extend_order_goods']);
            $goods_list=$order_list[$key]['extend_order_goods'];
            $setRow_sku=$setRow;
            for($j=0;$j<$goods_num;$j++){
                $setRow_sku=$setRow+$j;
                $objPHPExcel->getActiveSheet()->SetCellValue('C'.($setRow_sku), $goods_list[$j]['goods_id']);//sku
                $objPHPExcel->getActiveSheet()->SetCellValue('D'.($setRow_sku), $goods_list[$j]['goods_name']);//商品
                $objPHPExcel->getActiveSheet()->SetCellValue('E'.($setRow_sku), $goods_list[$j]['goods_spec']);//规格
                $objPHPExcel->getActiveSheet()->SetCellValue('F'.($setRow_sku), ncPriceFormat($goods_list[$j]['goods_price']));//价格
                $objPHPExcel->getActiveSheet()->SetCellValue('G'.($setRow_sku), $goods_list[$j]['goods_num']);//数量
                $objPHPExcel->getActiveSheet()->SetCellValue('H'.($setRow_sku), '=SUM(F'.$setRow_sku.'*G'.$setRow_sku.')');//商品总价
            }
            
            $objPHPExcel->getActiveSheet()->SetCellValue('I'.($setRow), ncPriceFormat($order_list[$key]['order_amount']));//订单总价
            $objPHPExcel->getActiveSheet()->SetCellValue('J'.($setRow), b2b_cg_orderPaymentName($order_list[$key]['payment_code']));//付款方式
            $objPHPExcel->getActiveSheet()->SetCellValue('K'.($setRow), ($order_list[$key]['payment_time']>0)?date("Y-m-d H:i:s",$order_list[$key]['payment_time']):0);//付款时间
            //收货信息
            $commoninfo=$order_list[$key]['extend_order_common'];
            $objPHPExcel->getActiveSheet()->SetCellValue('L'.($setRow), ($commoninfo['reciver_info']['is_send']==1)?'是':'否');//是否配送
            $objPHPExcel->getActiveSheet()->SetCellValue('M'.($setRow), $order_list[$key]['buyer_name']);//购买人
            $objPHPExcel->getActiveSheet()->SetCellValue('N'.($setRow), $commoninfo['reciver_info']['address']);//收货地址
            $objPHPExcel->getActiveSheet()->SetCellValue('O'.($setRow), $commoninfo['reciver_info']['mob_phone'].'/'.$commoninfo['reciver_info']['tel_phone']);//联系方式
            $objPHPExcel->getActiveSheet()->SetCellValue('P'.($setRow), $commoninfo['reciver_name']);//收货人
            
            //合并单元格
            $objPHPExcel->getActiveSheet()->mergeCells('A'.$setRow.':A'.$setRow_sku);
            
            //一个订单的最后的行数
            $i=$setRow_sku+1;
        }
        $objPHPExcel->getActiveSheet()->getStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
//        $objPHPExcel->getActiveSheet()->getStyle( 'C1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
//        $objPHPExcel->getActiveSheet()->getStyle( 'C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
        
        
        //输出下载
        $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
        header("Content-Type:application/force-download");
        header("Content-Type:application/vnd.ms-execl");
        header("Content-Type:application/octet-stream");
        header("Content-Type:application/download");;
        header('Content-Disposition:attachment;filename="'.$_SESSION['b2b_store_name'].'采购订单_'.date('YmdHis').'.xlsx"');
        header("Content-Transfer-Encoding:binary");
        $objWriter->save('php://output');

        
    }
/**
     * 选择合并发货地址
     * @return boolean
     */
    public function send_address_select_mergeOp() {
        Language::read('deliver');
        $address_list = Model('supplier_daddress')->getAddressList(array('store_id'=>$_SESSION['b2b_store_id']));
        Tpl::output('address_list',$address_list);
        Tpl::output('order_id_list', $_GET['order_id_list']);
        Tpl::output('first_id', $_GET['first_id']);
        Tpl::showpage('b2b_cg_store_deliver.daddress.select_merge','null_layout');
    }

    /**
     * 保存合并发货地址修改
     */
    public function send_address_save_mergeOp() {
        
        $result = $this->_edit_order_daddress_merge($_POST['daddress_id'], $_POST['order_id_list']);
        if($result) {
            echo 'true';
        } else {
            echo 'flase';
        }
    }
    
    
     /**
     * 修改合并发货地址
     */
    private function _edit_order_daddress_merge($daddress_id, $order_id_list) {
        $model_cg_order = Model('b2b_cg_order');
        $model_dh_order = Model('b2b_dh_order');
        $data = array();
        $data['daddress_id'] = intval($daddress_id);
        $order_id_list_arr = explode(",", $order_id_list);
        $condition = array();
        $condition['order_id'] = array('in',$order_id_list_arr);
        $condition['store_id'] = $_SESSION['b2b_store_id'];
        
        
        $cg_order_list = $model_cg_order->getOrderList1($condition);
        $dh_order_id_list = array();



        $res1 = $model_cg_order->editOrderCommon($data, $condition);
        
        //根据cg_order_id寻找dg_order_id
        foreach ($cg_order_list as $key => $order) {
            $dh_order_id_list[] = $order['dh_order_id'];
        }
     
        $condition['order_id'] = array('in',$dh_order_id_list);
        $res2 = $model_dh_order->editOrderCommon($data, $condition);
        if($res1&&$res2){
            return true;
        }else{
            return false;
        }
    }

  /**
     * 设置采购订单地址并生成采购订单
     */
    public function b2b_cg_orderCreateOp(){
        $order_id = intval($_GET['order_id']);
        $model_order    = Model('b2b_dh_order');
        $model_business = Model('b2b_business');
        $model_member   = Model('b2b_member');
        $model_cg_order = Model('b2b_cg_order');
        $model_store    = Model('supplier_store');
        $model_dsm      = Model('b2b_delivery_send_man');
        $model_dp       = Model('b2b_delivery_point');


        if (chksubmit()) {
            
            $order_id = intval($_POST['order_id']);
            if ($order_id <= 0) {
                    showDialog(L('nc_common_op_fail'), 'reload');
            }
            $pay_names=array('offline','banktransfer','dateaccount');
            if(!in_array($_POST['pay_name'],$pay_names)){
                showDialog('订单生成失败[支付方式选择错误]', '', 'error', '$("#flexigrid").flexReload();');
            }
            
            if($_POST['is_send']==1&&empty($_POST['send_dlyp_id'])){
                showDialog('订单生成失败[配送方式选择错误]', '', 'error', '$("#flexigrid").flexReload();');
            }
            
//            if($_POST['is_send']==1&&empty($_POST['send_man_id'])){
//                showDialog('订单生成失败[配送员选择错误]', '', 'error', '$("#flexigrid").flexReload();');
//            }
//            
//            if($_POST['is_send']==1&&!empty($_POST['send_man_id'])){
//                //判断配送员是否有效
//                $deliveryman_info=$model_dsm->getDeliveryManInfo(array('send_man_id'=>$_POST['send_man_id'],'state'=>1));
//                if(empty($deliveryman_info)){
//                    showDialog('订单生成失败[配送员无效]', '', 'error', '$("#flexigrid").flexReload();');
//                }
//            }
            
           
            //判断是否已经存在该order_id的未完成的采购订单,提示
            
            //获取自营店的用户id,以自营店的用户作为采购者
//            $ownids=$model_store->getOwnShopIds();
//            $ownstore=$model_store->getStoreInfo(array('store_id'=>$ownids[0]));
            //避免出现不能购买自己店铺的情况,用buyer_id
            $order_info2 = $model_order->getOrderInfo(array('order_id'=>$order_id));
            
            //生成采购订单
            $logic_buy=logic('b2b_cg_buy');
            
            $result = $logic_buy->create_cg_order($_POST,$order_info2['buyer_id']);
            
            if (!$result['state']) {
                $this->log('将订货订单生成采购订单失败,'.L('order_number').':'.$order_info2['order_sn'],1);
                showDialog('订单生成失败['.$result['msg'].']', '', 'error', '$("#flexigrid").flexReload();',8);
            }
            $this->log('将订货订单生成采购订单成功,'.L('order_number').':'.$order_info2['order_sn'],1);
            showDialog('订单生成成功', '', 'succ', '$("#flexigrid").flexReload();CUR_DIALOG.close();');
            //生成采购订单成功,跳转到付款信息页面 转向到支付页面
//            redirect('index.php?act=b2b_cg_order&op=change_state&state_type=receive_pay&order_id=1');
            exit();
        }
        //订单信息
        $order_info = $model_order->getOrderInfo(array('order_id'=>$order_id),array('order_common'));
        Tpl::output('order_info', $order_info);
        //输出收货信息
        
        Tpl::output('reciver_info', $order_info['extend_order_common']['reciver_info']);
        //配送地址信息
        if(!empty($order_info['extend_order_common']['reciver_info']['is_send'])&&$order_info['extend_order_common']['reciver_info']['is_send']==1&&!empty($order_info['extend_order_common']['reciver_info']['send_dlyp_id'])){
            $send_deliveryinfo=$model_dp->getDeliveryPointInfo(array('dlyp_id'=>$order_info['extend_order_common']['reciver_info']['send_dlyp_id']));
            Tpl::output('send_deliveryinfo', $send_deliveryinfo);
        }
        
        //送货方式(0.快递、1.客户自提、2.门店自提)
        
        $delivery_way=0;
        if(empty($order_info['chain_id'])){
            $order_common=$order_info['extend_order_common'];
            if($order_common['reciver_info']['dlyp']){
                $delivery_way=1;
            }else{
                $delivery_way=0; 
            }
        }else{
            //暂时不考虑
            $delivery_way=2;
        }
        Tpl::output('delivery_way', $delivery_way);
        
        //获取购买的用户的详细信息
        $member_info=$model_member->getMemberInfo($order_info['buyer_id']);
        Tpl::output('member_info',$member_info);
        
        
        
        //获取该客户关联的业务地区可用配送的自提点
        $DeliveryPoints=$model_business->getBusiness_Member_Delivery($order_info['buyer_id']);
        Tpl::output('DeliveryPoints', $DeliveryPoints);
        
        //获取该用户机机网扩展表的收货地址
        $jjw_common=$model_member->getMemberjjw_commonInfo(array('member_id'=>$order_info['buyer_id']));
        Tpl::output('jjw_common', $jjw_common);
        
        //获取有效的配送员
//        $delivery_send_man_list=$model_dsm->getDeliveryManList(array('state'=>1));
//        Tpl::output('delivery_send_man_list', $delivery_send_man_list);
                        //网 店 运 维shop wwi.com
        Tpl::setDirquna('supplier');
        Tpl::showpage('b2b_dh_order.cg.create', 'null_layout');
    }



/**
     * 审核详细页
     */
    public function b2b_member_review_detailOp(){
        $model_member_review = Model('b2b_member_jjw_verify');
        $review_detail = $model_member_review->getOne(array('member_id'=>$_GET['member_id']));

        $review_detail_title = '查看';
        if($review_detail['state'] == 0) {
            $review_detail_title = '审核';
        }
        if (!empty($joinin_detail['sg_info'])) {
            $store_grade_info = Model('supplier_store_grade')->getOneGrade($joinin_detail['sg_id']);
            $joinin_detail['sg_price'] = $store_grade_info['sg_price'];
        } else {
            $joinin_detail['sg_info'] = @unserialize($joinin_detail['sg_info']);
            if (is_array($joinin_detail['sg_info'])) {
                $joinin_detail['sg_price'] = $joinin_detail['sg_info']['sg_price'];
            }
        }
        
        //获取推荐人信息
        $referee_info=Model('b2b_jjw_referee')->getjjw_refereeInfo(array('referee_id'=>$review_detail['referee_id']));
         Tpl::output('referee_info', $referee_info);

        Tpl::output('review_detail_title', $review_detail_title);
        Tpl::output('review_detail', $review_detail);
        Tpl::setDirquna('supplier');/*网 店 运 维shop wwi.com*/
        Tpl::showpage('b2b_member_review.detail');
    }

    /**
     * 审核
     */
    public function b2b_member_review_verifyOp() {
        $model_member_review = Model('b2b_member_jjw_verify');
        $model_member = Model('b2b_member');
        
        $member_id = $_POST['member_id'];
        $condition = array();
        $data = array();
        $type = $_POST['type'];
                
                

                
        if($type=="suc"){
                        //修改审核表信息
                        $data['review_time'] = time();
            $data['states'] = 1;
            $data['review_opinion'] = $_POST['review_opinion']==""?"":$_POST['review_opinion'];
                        //修改会员登录状态
                        $data_status = array();
            $data_status['member_state'] = 1;
            $rese = $model_member->editMember(array('member_id'=>$member_id), $data_status);
                        
                        if(!$rese){
                            showMessage('修改会员登陆操作失败');
                        }
                        
                        //b2b_member_jjw_common 添加到扩展属性
                        $member_review_info=$model_member_review->getOne(array('member_id'=>$member_id));
                        $referee_info=Model('b2b_jjw_referee')->getjjw_refereeInfo(array('referee_id'=>$member_review_info['referee_id']));
                        
                        $jjw_commoninfo=$model_member->getMemberjjw_commonInfo(array('member_id'=>$member_id));
                        if(empty($jjw_commoninfo)){
                            $data_jjw_common                   = array();
                            $data_jjw_common['member_id']      = $member_id;
                            $data_jjw_common['jjw_mobile']     = $member_review_info['jjw_mobile'];
                            $data_jjw_common['jjw_referee_id'] = $member_review_info['referee_id'];
                            $data_jjw_common['jjw_referee']    = $referee_info['referee'];
                            $data_jjw_common['true_name']      = $member_review_info['true_name'];
                            $data_jjw_common['area_id']        = $member_review_info['area_id'];
                            $data_jjw_common['city_id']        = $member_review_info['city_id'];
                            $data_jjw_common['area_info']      = $member_review_info['area_info'];
                            $data_jjw_common['address']        = $member_review_info['address'];
                            $data_jjw_common['dlyp_id']        = $member_review_info['dlyp_id'];
                            $model_member->addMemberjjw_common($data_jjw_common);
                        }
                        //b2b_address 添加地址
                        
                        $data_a               = array();
                        $data_a['member_id']  = $member_id;
                        $data_a['true_name']  = $member_review_info['true_name'];
                        $data_a['area_id']    = $member_review_info['area_id'];
                        $data_a['city_id']    = $member_review_info['city_id'];
                        $data_a['area_info']  = $member_review_info['area_info'];
                        $data_a['address']    = $member_review_info['address'];
                        $data_a['mob_phone']  = $member_review_info['jjw_mobile'];
                        $data_a['is_default'] = 1;

                        Model('b2b_address')->addAddress($data_a);
                        
        }else{
            $data['review_time'] = time();
            $data['review_opinion'] = $_POST['review_opinion'];
        }
        $condition['member_id'] = $member_id;
        $result = $model_member_review->modify($data,$condition);
                
                
                


        if(!$result){
            //失败
            showMessage('操作失败');
        }else{
            //成功
            showMessage('操作成功');
        }
        
    }

<?php defined('ByShopWWI') or exit('Access Invalid!');?>

<div class="page">
  <div class="fixed-bar">
    <div class="item-title"><a class="back" href="index.php?act=b2b_business&op=index" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
      <div class="subject">
        <h3>业务区--地区设置 - 新增</h3>
        <h5>业务区--地区设置</h5>
      </div>
    </div>
  </div>
  <div class="explanation" id="explanation">
    <div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
      <h4 title="<?php echo $lang['nc_prompts_title'];?>"><?php echo $lang['nc_prompts'];?></h4>
      <span id="explanationZoom" title="<?php echo $lang['nc_prompts_span'];?>"></span> </div>
    <ul>
      <li>业务区--地区设置</li>
    </ul>
  </div>
  <form id="type_form" method="post">
    <input type="hidden" value="ok" name="form_submit">
    <input type="hidden" name="area_ids" id="area_ids" value="<?php echo $output['area_ids_val'];?>">
    <div class="ncap-form-default">
      <dl class="row">
        <dt class="tit">
          <label for="t_sort"><em>*</em>业务区id</label>
        </dt>
        <dd class="opt">
            <input type="text" class="input-txt" name="business_id" id="business_id" value="<?php echo $_GET['business_id'];?>" readonly="readonly" />
          <span class="err"></span>
          <p class="notic"><?php echo $lang['type_add_sort_desc'];?></p>
        </dd>
      </dl>
        </div>
       </form> 
      <dl class="row">
        <dt class="tit">
          <label>选择地区</label>
        </dt>
        <dd class="opt">
<!--          <div id="brandcategory">快捷定位
            <select class="class-select">
              <option value="0"><?php echo $lang['nc_please_choose'];?></option>
              <?php if(!empty($output['gc_list'])){ ?>
              <?php foreach($output['gc_list'] as $k => $v){ ?>
              <?php if ($v['gc_parent_id'] == 0) {?>
              <option value="<?php echo $v['gc_id'];?>"><?php echo $v['gc_name'];?></option>
              <?php } ?>
              <?php } ?>
              <?php } ?>
            </select>
            分类下对应的地区 <a class="ncap-btn" nctype="brand_hide" href="javascript:void(0);">隐藏未选</a></div>-->
<div id="area_div" class="scrollbar-box" style="max-height:500px;">
            <div class="ncap-type-spec-list">
              <?php if(is_array($output['areas_province']) && !empty($output['areas_province'])) {?>
              <?php foreach ($output['areas_province'] as $k=>$val){?>
              <dl>
                  <dt id="area_dt_<?php echo $k;?>" style="font-weight:normal;"><h3 style=" float: left; padding-right: 10px;">省/直辖市:<?php echo $output['areas']['name'][$val];?></h3></dt>
                
                <!--市-->
                 <?php if(is_array($output['areas']['children'][$val])&& !empty($output['areas']['children'][$val])) {?>
                <dd>
                    <!--<h3 style=" float: left; padding-right: 10px;">市:</h3>-->
                  <?php foreach ($output['areas']['children'][$val] as $cbval){?>
                    <!--<label></label>-->
                     <label style="width:100%"><?php echo $output['areas']['name'][$cbval]?>
                            <div style=" padding-left: 20px;"><li>
                                    
                            <dl>
                                <dt></dt>
                                <dd>
                                    <!--区/镇-->
                                <?php if(is_array($output['areas']['children'][$cbval])&& !empty($output['areas']['children'][$cbval])) { ?>
                                <?php foreach ($output['areas']['children'][$cbval] as  $tval) { ?>
                                <label>
                                    
                                    <input type="checkbox" onclick="checkall(this)" <?php if(!empty($output['business_areas_set'])){foreach ($output['business_areas_set'] as $val_set) {if($val_set['area_id']==$tval){echo "checked=\"checked\"";}}}?>  data-area-id="<?php echo $tval?>" id="area_<?php echo $tval;?>" /><?php echo $output['areas']['name'][$tval]?>
                                    <div style=" padding-left: 20px;"><li>
                                    <!--村-->
                                    <?php if(is_array($output['areas']['children'][$tval])&& !empty($output['areas']['children'][$tval])){ ?>
                                    <?php foreach ($output['areas']['children'][$tval] as $vval){ ?>
                                           <label><input type="checkbox" <?php if(!empty($output['business_areas_set'])){foreach ($output['business_areas_set'] as $val_set) {if($val_set['area_id']==$vval){echo "checked=\"checked\"";}}}?>  data-area-id="<?php echo $vval?>" id="area_<?php echo $vval;?>" /><?php echo $output['areas']['name'][$vval]?></label>
                                           
                                           
                                           
                                    <?php } ?>
                                    <?php } ?>
                                    <!--村 结束-->
                                                
                                    </li></div>

                                </label>
                                <?php }?>
                                <?php }?>
                                    <!--区/镇 结束-->
                                </dd>

                            </dl>
                                    
                            </li></div>
                  </label>
                    
                    
                  <?php }?>
                </dd>
                <!--市 结束-->
                
                <?php }?>
                
              </dl>
              <?php }?>
              <?php }else{?>
              <div><?php echo $lang['type_add_brand_null_one'];?><a href="JavaScript:void(0);" onclick="window.parent.openItem('shop|brand')"><?php echo $lang['nc_brand_manage'];?></a><?php echo $lang['type_add_brand_null_two']?></div>
              <?php }?>
            </div>
          </div>
        </dd>
      </dl>
        
        <div class="bot"><a id="submitBtn" class="ncap-btn-big ncap-btn-green" href="JavaScript:void(0);"><?php echo $lang['nc_submit'];?></a></div>
    
  
      
</div>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/common_select.js" charset="utf-8"></script> 
<script>
$(function(){
    //自动加载滚动条
    
    $('#area_div').perfectScrollbar();


    //表单验证
    $('#type_form').validate({
        errorPlacement: function(error, element){
            var error_td = element.parent('dd').children('span.err');
            error_td.append(error);
        },
        rules : {
            business_id: {
                required : true,
                
            },
            
        },
        messages : {
            business_id : {
                required : '<i class="fa fa-exclamation-circle"></i>不能为空',
            },
            
        }
    });

    //按钮先执行验证再提交表单
    $("#submitBtn").click(function(){
        
        if($("#type_form").valid()){
            $("#type_form").submit();
        }
    });
    
    $("input[type='checkbox']").live('click',function(){
        var checkeds=$("input[type='checkbox']:checked");
        var str="";
        for(i=0;i<checkeds.length;i++){
            if(str!=""){
                str+=','+checkeds[i].dataset.areaId;
            }else{
                str=checkeds[i].dataset.areaId;
            }
            
        }
        $('#area_ids').val(str);
    });

    
    // 品牌搜索
//    $("#brandcategory > select").live('change',function(){
//        brand_scroll($(this));
//    });
//
//    
//    // 品牌隐藏未选项
//    $('a[nctype="brand_hide"]').live('click',function(){
//        checked_hide('brand');
//    });
//    // 品牌全部显示
//    $('a[nctype="brand_show"]').live('click',function(){
//        checked_show('brand');
//    });
});


function checkall(o){
    var checks=$('#'+o.id).next('div').find('input');
    if($('#'+o.id)[0].checked){
        for(i=0;i<checks.length;i++){
            checks[i].checked=true;
        }
    }else{
        for(i=0;i<checks.length;i++){
            checks[i].checked=false;
        }
    }
    
}
//
//
//var brandScroll = 0;
//function brand_scroll(o){
//    var id = o.val();
//    if(!$('#brand_dt_'+id).is('dt')){
//        return false;
//    }
//    $('#brand_div').scrollTop(-brandScroll);
//    var sp_top = $('#brand_dt_'+id).offset().top;
//    var div_top = $('#brand_div').offset().top;
//    $('#brand_div').scrollTop(sp_top-div_top);
//    brandScroll = sp_top-div_top;
//}
//
//// 隐藏未选项
//function checked_show(str) {
//    $('#'+str+'_div').find('dt').show().end().find('label').show();
//    $('#'+str+'_div').find('dl').show();
//    $('a[nctype="'+str+'_show"]').attr('nctype',str+'_hide').html('<?php echo $lang['type_common_checked_hide'];?>');
//    $('#'+str+'_div').perfectScrollbar('destroy').perfectScrollbar();
//}
//
//// 显示全部选项
//function checked_hide(str) {
//    $('#'+str+'_div').find('dt').hide();
//    $('#'+str+'_div').find('input[type="checkbox"]').parents('label').hide();
//    $('#'+str+'_div').find('input[type="checkbox"]:checked').parents('label').show();
//    $('#'+str+'_div').find('dl').each(function(){
//        if ($(this).find('input[type="checkbox"]:checked').length == 0 ) $(this).hide();
//    });
//    $('a[nctype="'+str+'_hide"]').attr('nctype',str+'_show').html('<?php echo $lang['type_common_checked_show'];?>');
//    $('#'+str+'_div').perfectScrollbar('destroy').perfectScrollbar();
//}




</script> 
<?php //递归循环 
function getareaforb2b($areas,$namelist,$val){
    if(is_array($areas['children'][$val])&&!empty($areas['children'][$val])){
        echo '<dd>';
        foreach ($areas['children'][$val] as $key => $value) {
            echo '<label for="brand_'.$v.'">
    <input type="checkbox" name="brand_id[]" value="'.$value.'" id="brand_'.$value.'" />
    '.$namelist[$value].' </label>';
            getareaforb2b($areas,$namelist,$value);
            
            
        }
        echo '</dd>';
    }else{
        $childrens=$areas['children'][$areas['parent'][$val]];
        $is_key=array_search($val,$childrens);
        if($is_key==0){
            foreach ($childrens as $k => $v) {
                echo '<div class="ncap-type-spec-list"><dl><dt><dd><label for="brand_'.$v.'">
    <input type="checkbox" name="brand_id[]" value="'.$v.'" id="brand_'.$v.'" />
    '.$namelist[$v].' </label></dd></dt></dl></div>';
            }
        }


    }
}
?>

<?php defined('ByShopWWI') or exit('Access Invalid!');?>
<script src="<?php echo ADMIN_RESOURCE_URL?>/js/admin.js" type="text/javascript"></script>
<form method="post" name="form1" id="form1" style="max-height: 800px;" class="ncap-form-dialog" action="<?php echo urlAdminSupplier('b2b_dh_order', 'b2b_cg_orderCreate');?>">
  <input type="hidden" name="form_submit" value="ok" />
  <input type="hidden" value="<?php echo $output['order_info']['order_id'];?>" name="order_id">
  <div class="ncap-form-default">
    <dl class="row">
      <dt class="tit">订货单编号</dt><dd class="opt"><?php echo $output['order_info']['order_sn'];?></dd></dl>
    <dl class="row">
      <dt class="tit">买家姓名</dt><dd class="opt"><?php echo $output['order_info']['buyer_name'];?></dd></dl>
    <dl class="row">
      <dt class="tit">买家手机</dt><dd class="opt"><?php echo $output['order_info']['buyer_phone'];?></dd></dl>
    
      
      
      
    <dl class="row">
        <dt class="tit">
          <label> (订货单)是否自提</label>
        </dt>
        <dd class="opt">
          <label>
              <input type="radio" <?php if($output['delivery_way']=='1'){ echo "checked=\"checked\""; }?>value="1" name="delivery_way" disabled="disabled">
            客户自提</label>
          <label>
            <input type="radio" <?php if($output['delivery_way']=='0'){ echo "checked=\"checked\""; }?> value="0" name="delivery_way" disabled="disabled">
            快递</label>
            <label>
              <input type="radio" <?php if($output['delivery_way']=='2'){ echo "checked=\"checked\""; }?> value="2" name="delivery_way" disabled="disabled">
            门店自提</label>
          <span class="err"></span></dd>
      </dl>
      
      <dl class="row" >
        <dt class="tit">
          <label for="">(订货单)收货信息</label>
        </dt>
        <dd class="opt">
        
            <p id="_shouhuo_span" class="">地址:<?php echo $output['order_info']['extend_order_common']['reciver_info']['address'];?></p>
            <p id="_shouhuo_span2" class="">电话:<?php echo $output['order_info']['extend_order_common']['reciver_info']['phone'];?></p>
          <span class="err"></span>
               
          <p class="notic"></p>
        </dd>
      </dl>
     
      <!--是否配送-->
      <dl class="row">
        <dt class="tit">
          <label> (订货单)是否配送</label>
        </dt>
        <dd class="opt">
          <label>
              <input type="radio" value="1" name="is_send" disabled="disabled" <?php if(!empty($output['reciver_info']['is_send'])&&$output['reciver_info']['is_send']==1){ echo "checked=\"checked\"";}?> >
            是</label>
          <label>
              <input type="radio"  value="0" name="is_send" disabled="disabled" <?php if(!empty($output['reciver_info']['is_send'])&&$output['reciver_info']['is_send']==0){ echo "checked=\"checked\"";}?> >
            否</label>
            
          <span class="err"></span></dd>
      </dl>
      
      <!--配送的站点-->
      <dl class="row" id="show_send_deliveryinfo" <?php if(!empty($output['reciver_info']['is_send'])&&$output['reciver_info']['is_send']==0){ echo "style=\"display:none;\"";}?> >
        <dt class="tit">
          <label for="">(订货单)配送信息</label>
        </dt>
        <dd class="opt">
            
            <p id="_send_deliveryinfo_span1" class="">配送点:<?php echo $output['send_deliveryinfo']['dlyp_address_name'];?></p>
            <p id="_send_deliveryinfo_span2" class="">配送点地址:<?php echo $output['send_deliveryinfo']['dlyp_area_info'].'  '.$output['send_deliveryinfo']['dlyp_address'];?></p>
            <p id="_send_deliveryinfo_span3" class="">电话:<?php echo $output['send_deliveryinfo']['dlyp_telephony'];?>&nbsp;&nbsp;手机:<?php echo $output['send_deliveryinfo']['dlyp_mobile'];?></p>
            
          <span class="err"></span>
          <p class="notic"></p>
        </dd>
      </dl>
      
      
      
      <!--付款方式-->
      <dl class="row">
        <dt class="tit">
          <label>(采购单)付款方式</label>
        </dt>
        <dd class="opt">
          <label>
            <input type="radio" checked="checked" value="banktransfer" name="pay_name">
            银行转账</label>
          <label>
            <input type="radio" value="offline" name="pay_name">
            货到付款</label>
          <label>
            <input type="radio" value="dateaccount" name="pay_name">
            定期结算</label>
          <span class="err"></span></dd>
      </dl>
      
      <!--采购单收货信息-->
      <dl class="row" id="cg_address_info" >
        <dt class="tit">
          <label for=""><em></em>(采购单)收货地址</label>
        </dt>
        <dd class="opt"  >
            <div id="show_dh_address_info" <?php if(!(!empty($output['reciver_info']['is_send'])&&$output['reciver_info']['is_send']==0)){ echo "style=\"display:none;\"";}?>>
            <p  class="">地址:<?php echo $output['order_info']['extend_order_common']['reciver_info']['address'];?></p>
            <p  class="">电话:<?php echo $output['order_info']['extend_order_common']['reciver_info']['phone'];?></p>
            </div>
            
            <div id="show_cg_address_info" <?php if(!(!empty($output['reciver_info']['is_send'])&&$output['reciver_info']['is_send']==1)){ echo "style=\"display:none;\"";}?>>
            <?php if(!empty($output['send_deliveryinfo'])){?>
                
            <p id="_cg_address_info_span" class="cg_address_info_span_class">配送点:<?php echo $output['send_deliveryinfo']['dlyp_address_name'];?></p>
            <p id="_cg_address_info_span1" class="cg_address_info_span_class">地址:<?php echo $output['send_deliveryinfo']['dlyp_area_info'].'  '.$output['send_deliveryinfo']['dlyp_address'];?></p>
            <p id="_cg_address_info_span2" class="cg_address_info_span_class">电话:<?php echo $output['send_deliveryinfo']['dlyp_telephony'];?>&nbsp;&nbsp;手机:<?php echo $output['send_deliveryinfo']['dlyp_mobile'];?></p>
                
            <?php }?>
            </div>

          <span class="err"></span>
        </dd>
      </dl>
      

    
      
    
    <div class="bot"><a href="javascript:void(0);" class="ncap-btn-big ncap-btn-green" nctype="btn_submit"><?php echo $lang['nc_submit'];?></a></div>
  </div>
</form>
<script>
$(function(){
    //是否配送
//    $("input[name='is_send']").click(function(){
//        var checkval=$("input[name='is_send']:checked").val();
//        if(checkval==0){
//            $('#show_dh_address_info').show();
//            $('#show_cg_address_info').hide();
//            $('.cg_address_info_span_class').hide();
//            $('#select_send').attr("disabled", true);
//            $('#select_send').val(0);
//            
//        }else{
//            $('#show_dh_address_info').hide();
//            $('#show_cg_address_info').show();
//            $('#select_send').attr("disabled", false);
//            
//        }
//
//    });
    //是否配送--结束
    
    //选择配送地址
//    $("#select_send").change(function(){
//        var id=$("#select_send").val();
//        $('.cg_address_info_span_class').hide();
//        $('#_cg_address_info_span_'+id).show();
//        $('#_cg_address_info_span1_'+id).show();
//        $('#_cg_address_info_span2_'+id).show();
//    });
    //选择配送地址--结束
    
    
    $('a[nctype="btn_submit"]').click(function(){
//        if($("input[name='delivery_way']:checked").val()==1&&(!$('#show_chain').val()||$('#show_chain').val()==0)){
//            alert("提货点不能为空!");
//            return false;
//        }
        
//        if($("input[name='delivery_way']:checked").val()==0&&!$('#delivery_address').val()){
//            alert("地址不能为空!");
//            return false;
//        }
        
        var isok=false;
        //检查是否存在未完成的订单
        $.ajax({
        async:false,
        type: "GET",
        dataType: "json",
        url: "index.php?act=b2b_dh_order&op=ajax&branch=check_order_id",
        data: "dh_order_id="+<?php echo $output['order_info']['order_id'];?>,
        success: function(data){
//            debugger;
            if (data){
                var r=confirm("已存在未完成的订单,是否继续生成采购单?");
//                debugger;
                if (r!=true)
                {
                    isok=false;
                }else{
                    isok=true;
                }
            }else{
                isok=true;
            }
        }
    });
        
        if(isok){
            ajaxpost('form1', '', '', 'onerror');
        }else{
            return false;
        }
    
        
    });
    
});
</script>

This snippet took 0.07 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).