())."/".date("m-d",time());
            $filepath= __ROOT__."/public". $upfile;
            $newfilename=date("YmdHis",time()).rand(10000,99999).$ext;
            if(is_dir($filepath)==false)
            {
                mkdir($filepath,0777,true);
            }
            $file_tmp_name= $_FILES['image']['tmp_name'];//上传文件路径
            $upfile=$upfile."/".$newfilename;
            move_uploaded_file($file_tmp_name,$filepath."/".$newfilename);//把图片移到服务器目录
        }

        $arr=[];
        if(empty($result['refundsn']))
        {
            $arr['refundremark']=$content;//退款原因
            $arr['refundpic']=$upfile;//退款上传图片
        }else
        {
            $arr['refundmsg2']=$content;//退款原因
            $arr['refundpic2']=$upfile;//退款上传图片
        }
        $arr['dtrefundtime']=date("Y-m-d H:i:s");
        $arr['state']=5;
        $arr['intflag']=6;


        if(db("order")->where(array('id'=>$orderid,'idsite'=>$idsite))->update($arr))
        {
            //替换信息
            $replace = [];
            //给客户和商务发短信通知    类型：3--申请退款
            sysSendMsg($idsite, 3, array_merge($datainfo, $arr), $replace);
            template_tg($orderid);
            exit(json_encode(array('state'=>1,'msg'=>'退款申请已提交成功')));
        }else
        {
            exit(json_encode(array('state'=>0,'msg'=>'退款申请已提交失改')));
        }
    }

    /**
     * 修改订单金额
     * @return   [type]                   [description]
     */
    public function ajax_update_order_price()
    {
        if(Request::instance()->isPost()==false)
        {
            exit(json_encode(array('state'=>0,'msg'=>'非法操作')));
        }

        $request = Request::instance()->param();
        $sitecode=$request['sitecode'];
        $config=$this->wxConfig;
        $idsite=$config['id'];
        $orderid=$request["order_id"];
        $user_info = $this->userinfo;
        //查询订单的信息
        $datainfo=db("order")->where(array('id'=>$orderid,'idsite'=>$idsite,'state'=>12))->find();
        if(empty($datainfo))
        {
            exit(json_encode(array('state'=>0,'msg'=>'待支付订单不存在！')));
        }
        //修改订单表中的金额，并且将该订单的是否更改过订单金额的字段改为是
        $update_bool = db("order")->where(array('id'=>$orderid,'idsite'=>$idsite,'state'=>12))->update(['is_change_price'=>1,'price'=>$request['new_price']]);
        if($update_bool)
        {
            $add_data = ['user_id'=>$user_info['idmember'],'order_id'=>$orderid,'name'=>$user_info['nickname'],
                'old_price'=>$datainfo['price'],'new_price'=>$request['new_price'],'remark'=>$request['remark'],'site_id'=>$idsite];
            //执行插入修改订单金额记录
            db('update_order_price')->insert($add_data);
            exit(json_encode(array('state'=>1,'msg'=>'修改成功！')));
        }else
        {
            exit(json_encode(array('state'=>0,'msg'=>'修改订单表数据失败！')));
        }
    }


    public function orderdetail()
    {

        $request = Request::instance()->param();
        $id=$request['id'];
        $sitecode=$request['sitecode'];
        $config=$this->wxConfig;
        $idsite=$config['id'];

        $row = db('order')->where(array('id'=>$id))->find();

        if($row && $row['group_buy_order_id'])
        {
            $package = db('package')->find($row['package_id']);
            $row['payname'] = $package['keyword1'].''. $package['keyword2'].'拼团价'. $row['price'] / $row['paynum'].'(原价 '. $package['member_price']. ')';

            $groupBuyInfo=db('group_buy_order')->where(['group_buy_order_id'=>$row['group_buy_order_id']])->find();
            $map = [
                0 => '开启拼团未支付',
                1 => '拼团中',
                2 => '拼团成功',
                3 => '拼团到期',
                4 => '拼团取消'
            ];
            $groupBuyInfo['state']=$map[$groupBuyInfo['state']];
            $this->assign('groupBuyInfo',$groupBuyInfo);

        }

        $frmdata=[];

        if($row &&!empty($row['txtdata']))
        {

            $row2= explode("☆", $row['txtfield']);
            $row1= explode("☆", $row['txtdata']);
            foreach($row1 as $k=>$vo) {
                $arr = explode("∫", $row2[$k]);
                $datatype = 1;
                $datafield = $arr[0];
                if (count($arr) > 1) {
                    $datatype = $arr[1];
                }
                if($datatype==7)
                {
                    $frmdata[$datafield]='<img src="'.$vo.'" style="border: 0px;height: 50px;padding: 1px;"  />';
                }
                else
                {
                    $frmdata[$datafield]=$vo;
                }

            }
        }

        $frmdatasub=[];

        if($row &&!empty($row['txtdata1']))
        {

            $row2= explode("☆", $row['txtfield1']);

            $frmdatasubRow=explode("§", $row['txtdata1']);

            foreach ($frmdatasubRow as $k1=>$vo)
            {
                $row1= explode("☆", $vo);
                $frmdata1=[];
                foreach($row1 as $k=>$vo) {
                    $arr = explode("∫", $row2[$k]);
                    $datatype = 1;
                    $datafield = $arr[0];
                    if (count($arr) > 1) {
                        $datatype = $arr[1];
                    }
                    if($datatype==7)
                    {
                        $frmdata1[$datafield]='<img src="'.$vo.'" style="border: 0px;height: 50px;padding: 1px;"  />';
                    }
                    else
                    {
                        $frmdata1[$datafield]=$vo;
                    }
                }
                $frmdatasub[]=$frmdata1;

            }

        }

        $roottpl = 'template/modules/';
        //获得栏目列表模版路径
        $url =$roottpl.'/mine/order_detail.html';

        $this->assign('roottpl','/'.$roottpl);
        $this->assign('sitecode',$sitecode);
        $this->assign('orderinfo',$row);
        $this->assign('frmdatasub',$frmdatasub);
        $this->assign('frmdata',$frmdata