zxhxx 3 năm trước cách đây
mục cha
commit
7104201961

+ 30 - 0
application/admin/controller/article/Article.php

@@ -32,6 +32,36 @@ class Article extends Backend
     {
         parent::import();
     }
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                $data = $this->selectpage()->getData();
+                return $data;
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+            /**
+             * 获取企业信息
+             */
+            $where1  = is_sys_admin();
+            $list = $this->model
+                ->where($where)->where($where1)
+                ->order($sort, $order)
+                ->paginate($limit);
+            foreach ($list as $k => $v) {
+            }
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
 
     /**
      * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法

+ 56 - 0
application/admin/controller/help/HelpApply.php

@@ -0,0 +1,56 @@
+<?php
+
+namespace app\admin\controller\help;
+
+use app\common\controller\Backend;
+
+/**
+ * 帮扶人申请管理
+ *
+ * @icon fa fa-circle-o
+ */
+class HelpApply extends Backend
+{
+    
+    /**
+     * HelpApply模型对象
+     * @var \app\admin\model\help\HelpApply
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\help\HelpApply;
+        $this->view->assign("statusList", $this->model->getStatusList());
+    }
+
+    public function import()
+    {
+        parent::import();
+    }
+    public function edit($ids=null)
+    {
+        if($this->request->isPost()) {
+            $info = $this->model->where('id', $ids)->find();
+            if ($info['status']!='0') $this->error('已审核状态,不能修改');
+            if($this->model->where('help_id',$info['help_id'])->where('status','1')->find())
+            {
+                $this->error('该项目已有帮扶人,不能审核为通过');
+            }
+            $this->model->where('help_id',$info['help_id'])->where('id','<>',$ids)->update(['status'=>-1]);
+            \app\admin\model\help\Help::where('id',$info['help_id'])->update(['apply_user_id'=>$info['user_id']]);
+        }
+
+        return parent::edit($ids);
+
+    }
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+    
+
+}

+ 16 - 0
application/admin/lang/zh-cn/help/help_apply.php

@@ -0,0 +1,16 @@
+<?php
+
+return [
+    'Id'         => '编号',
+    'Cid'        => '企业编号',
+    'Help_id'    => '项目编号',
+    'User_id'    => '用户编号',
+    'Full_name'  => '姓名',
+    'Phone'      => '手机号',
+    'Createtime' => '申请时间',
+    'Updatetime' => '审核时间',
+    'Status'     => '状态',
+    'Status -1'  => '未通过',
+    'Status 0'   => '待审核',
+    'Status 1'   => '已通过'
+];

+ 49 - 0
application/admin/model/help/HelpApply.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace app\admin\model\help;
+
+use think\Model;
+
+
+class HelpApply extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'help_apply';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'status_text'
+    ];
+    
+
+    
+    public function getStatusList()
+    {
+        return ['-1' => __('Status -1'), '0' => __('Status 0'), '1' => __('Status 1')];
+    }
+
+
+    public function getStatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+        $list = $this->getStatusList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
+
+
+}

+ 27 - 0
application/admin/validate/help/HelpApply.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\admin\validate\help;
+
+use think\Validate;
+
+class HelpApply extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'add'  => [],
+        'edit' => [],
+    ];
+    
+}

+ 6 - 2
application/admin/view/article/article/add.html

@@ -1,11 +1,15 @@
 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
 
-   <div class="form-group">
+    {eq name="admin.cid" value="0"}
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Cid')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-cid" data-rule="required" data-source="Company" data-field="company_name" class="form-control selectpage" name="row[cid]" type="text" value="0">
+            <input id="c-cid" data-rule="required" data-source="Company" data-field="company_name" class="form-control selectpage" name="row[cid]" type="text" >
         </div>
     </div>
+    {else/}
+    <input id="c-cid"  name="row[cid]" type="hidden" value="{$admin.cid}">
+    {/eq}
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Article_category_id')}:</label>
         <div class="col-xs-12 col-sm-8">

+ 4 - 0
application/admin/view/article/article/edit.html

@@ -1,11 +1,15 @@
 <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
 
+    {eq name="admin.cid" value="0"}
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Cid')}:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-cid" data-rule="required" data-source="Company" data-field="company_name" class="form-control selectpage" name="row[cid]" type="text" value="{$row.cid}">
         </div>
     </div>
+    {else/}
+    <input id="c-cid"  name="row[cid]" type="hidden" value="{$admin.cid}">
+    {/eq}
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Article_category_id')}:</label>
         <div class="col-xs-12 col-sm-8">

+ 7 - 3
application/admin/view/article/article_category/add.html

@@ -1,12 +1,16 @@
 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
 
-   
-   <div class="form-group">
+
+    {eq name="admin.cid" value="0"}
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Cid')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-cid" data-rule="required" data-source="Company" data-field="company_name" class="form-control selectpage" name="row[cid]" type="text" value="0">
+            <input id="c-cid" data-rule="required" data-source="Company" data-field="company_name" class="form-control selectpage" name="row[cid]" type="text" >
         </div>
     </div>
+    {else/}
+    <input id="c-cid"  name="row[cid]" type="hidden" value="{$admin.cid}">
+    {/eq}
    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Pid')}:</label>
         <div class="col-xs-12 col-sm-8">

+ 6 - 2
application/admin/view/article/article_category/edit.html

@@ -1,12 +1,16 @@
 <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
 
-   
-   <div class="form-group">
+
+    {eq name="admin.cid" value="0"}
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Cid')}:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-cid" data-rule="required" data-source="Company" data-field="company_name" class="form-control selectpage" name="row[cid]" type="text" value="{$row.cid}">
         </div>
     </div>
+    {else/}
+    <input id="c-cid"  name="row[cid]" type="hidden" value="{$admin.cid}">
+    {/eq}
     <!--<div class="form-group">-->
     <!--    <label class="control-label col-xs-12 col-sm-2">{:__('Pid')}:</label>-->
     <!--    <div class="col-xs-12 col-sm-8">-->

+ 1 - 1
application/admin/view/donate/add.html

@@ -63,7 +63,7 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Category_id')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-category_id" data-rule="required" data-source="category/selectpage" data-params='{"custom[type]":"donate"}' class="form-control selectpage" name="row[category_id]" type="text" value="">
+            <input id="c-category_ids" data-rule="required" data-source="category/selectpage" data-params='{"custom[type]":"donate"}' class="form-control selectpage" name="row[category_ids]" type="text" value="">
         </div>
     </div>
     <div class="form-group">

+ 1 - 1
application/admin/view/donate/edit.html

@@ -63,7 +63,7 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Category_id')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-category_id" data-rule="required" data-source="category/selectpage" data-params='{"custom[type]":"donate"}' class="form-control selectpage" name="row[category_id]" type="text" value="{$row.category_id|htmlentities}">
+            <input id="c-category_ids" data-rule="required" data-source="category/selectpage" data-params='{"custom[type]":"donate"}' class="form-control selectpage" name="row[category_ids]" type="text" value="{$row.category_ids|htmlentities}">
         </div>
     </div>
     <div class="form-group">

+ 56 - 0
application/admin/view/help/help_apply/add.html

@@ -0,0 +1,56 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    {eq name="admin.cid" value="0"}
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Cid')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-cid" data-rule="required" data-source="Company" data-field="company_name" class="form-control selectpage" name="row[cid]" type="text" >
+        </div>
+    </div>
+    {else/}
+    <input id="c-cid"  name="row[cid]" type="hidden" value="{$admin.cid}">
+    {/eq}
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Help_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-help_id" data-rule="required" data-source="help/help" data-field="title"   class="form-control selectpage" name="row[help_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Full_name')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-full_name" class="form-control" name="row[full_name]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Phone')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-phone" class="form-control" name="row[phone]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            
+            <div class="radio">
+            {foreach name="statusList" item="vo"}
+            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="-1"}checked{/in} /> {$vo}</label> 
+            {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 56 - 0
application/admin/view/help/help_apply/edit.html

@@ -0,0 +1,56 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    {eq name="admin.cid" value="0"}
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Cid')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-cid" data-rule="required" data-source="Company" data-field="company_name" class="form-control selectpage" name="row[cid]" type="text" value="{$row.cid}">
+        </div>
+    </div>
+    {else/}
+    <input id="c-cid"  name="row[cid]" type="hidden" value="{$admin.cid}">
+    {/eq}
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Help_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-help_id" data-rule="required" data-source="help/help" data-field="title"  class="form-control selectpage" name="row[help_id]" type="text" value="{$row.help_id}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Full_name')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-full_name" class="form-control" name="row[full_name]" type="text" value="{$row.full_name|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Phone')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-phone" class="form-control" name="row[phone]" type="text" value="{$row.phone|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            
+            <div class="radio">
+            {foreach name="statusList" item="vo"}
+            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label> 
+            {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 45 - 0
application/admin/view/help/help_apply/index.html

@@ -0,0 +1,45 @@
+<div class="panel panel-default panel-intro">
+    
+    <div class="panel-heading">
+        {:build_heading(null,FALSE)}
+        <ul class="nav nav-tabs" data-field="status">
+            <li class="{:$Think.get.status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
+            {foreach name="statusList" item="vo"}
+            <li class="{:$Think.get.status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
+            {/foreach}
+        </ul>
+    </div>
+
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('help/help_apply/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('help/help_apply/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('help/help_apply/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('help/help_apply/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
+
+                        <div class="dropdown btn-group {:$auth->check('help/help_apply/multi')?'':'hide'}">
+                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
+                            <ul class="dropdown-menu text-left" role="menu">
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
+                            </ul>
+                        </div>
+
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-edit="{:$auth->check('help/help_apply/edit')}" 
+                           data-operate-del="{:$auth->check('help/help_apply/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 2 - 0
application/api/controller/Donate.php

@@ -25,6 +25,7 @@ class Donate extends Api
                 ['tel',''],
                 ['mobile',''],
                 ['executor',''],
+                ['executor_relation',''],
                 ['executor_id_card',''],
                 ['executor_tel',''],
                 ['executor_mobile',''],
@@ -34,6 +35,7 @@ class Donate extends Api
         if(IdentityCard::isValid($where['id_card']))$this->error('身份证号不正确!');
         if($where['vocation']=='')$this->error('职业不能为空');
         if($where['category_ids']=='')$this->error('捐献类型不能空');
+        if($where['executor_relation']=='')$this->error('执行人关系');
         if(!preg_match("/^1\d{10}$/", $where['mobile'])) $this->error('手机号不对');
         if(!preg_match("/^1\d{10}$/", $where['executor_mobile'])) $this->error('执行人移动电话不对');
         if(IdentityCard::isValid($where['executor_id_card']))$this->error('执行人身份证号不正确!');

+ 35 - 2
application/api/controller/Help.php

@@ -1,7 +1,7 @@
 <?php
 namespace app\api\controller;
 use app\common\controller\Api;
-use app\common\model\{Category,Help as HelpModel};
+use app\common\model\{Category, Help as HelpModel, HelpApply};
 use liuniu\UtilService;
 use think\Request;
 
@@ -17,7 +17,9 @@ class Help extends Api
                 ['category_id',0],
                 ['page',1],
                 ['limit',10],
+                ['status',-2],
                 ['isrec',-1],
+                ['user_id_1',$this->auth->getUserinfo()['id']],
             ]
         );
        return $this->success('获取成功',HelpModel::lst($where));
@@ -61,6 +63,37 @@ class Help extends Api
         if(!$rs) $this->error(HelpModel::getErrorInfo());
         $this->success('申请成功',$rs);
     }
+    public function help_user_apply(Request $request)
+    {
+        $where = UtilService::postMore(
+            [
+                ['help_id',0],
+                ['full_name',''],
+                ['phone',''],
+                ['user_id',$this->auth->getUserinfo()['id']],
+                ['cid',$this->cid],
+            ],$request
+        );
+        if($where['help_id']==0) $this->error('项目编号不能为0!');
+        if($where['full_name']=='') $this->error('姓名不能为空!');
+        if($where['phone']=='') $this->error('手机号不能为空!');
+       if(HelpApply::where('user_id',$this->auth->getUserinfo()['id'])->where('help_id',$where['help_id'])->find()) $this->error('项目不能重复申请!');
+        HelpApply::create($where);
+        $this->success('申请成功');
+
+    }
+    public function user_apply_lst(Request $request)
+    {
+        $where = UtilService::getMore(
+            [
+                ['status',-2],
+                ['page',''],
+                ['limit',''],
+                ['user_id',$this->auth->getUserinfo()['id']],
+            ],$request
+        );
+        $this->success('获取成功',HelpApply::lst($where));
+    }
     public function lst(Request $request)
     {
         $where = UtilService::getMore(
@@ -77,7 +110,7 @@ class Help extends Api
     {
         $id = input('id',0);
         if($id==0) $this->error('参数错误!');
-        $rs = HelpModel::info($id);
+        $rs = HelpModel::info($this->cid,$id,$this->auth->getUserinfo()['id']);
         if(!$rs)$this->error(HelpModel::getErrorInfo());
         return $this->success('获取成功',$rs);
     }

+ 3 - 3
application/api/controller/Lave.php

@@ -114,11 +114,11 @@ class Lave extends Api
             case '0':
                 try {
                     if ($from == 'routine') {
-                        $jsConfig = LaveRepository::jsPay($order); //订单列表发起支付
+                        $jsConfig = LaveRepository::jsPay($this->cid,$order); //订单列表发起支付
                     } else if ($from == 'weixinh5') {
-                        $jsConfig = LaveRepository::h5Pay($order);
+                        $jsConfig = LaveRepository::h5Pay($this->cid,$order);
                     } else {
-                        $jsConfig = LaveRepository::wxPay($order);
+                        $jsConfig = LaveRepository::wxPay($this->cid,$order);
                     }
                 } catch (\Exception $e) {
                     $this->error($e->getMessage());

+ 13 - 10
application/api/controller/Level.php

@@ -24,12 +24,15 @@ class Level extends Api
                 ['level_id',0],
                 ['body',''],
                 ['pay_type',0],
-                ['name',''],
                 ['pay_price',0],
                 ['from','weixin'],
             ],$request
         );
-        $order = OrderLevel::order_create($where);
+        $where1 = $where;
+        unset($where1['from']);
+        $where1['order_id'] = OrderLevel::getNewOrderId();
+        $where1['createtime'] = time();
+        $order = OrderLevel::order_create($where1);
         if(!$order) $this->error(OrderLevel::getErrorInfo());
         $orderId = $order['order_id'];
         $info = compact('orderId');
@@ -39,18 +42,18 @@ class Level extends Api
             if ($orderInfo['paid']) $this->error('支付已支付!');
             try {
                 if ($where['from'] == 'routine') {
-                    $jsConfig = LevelRepository::jsPay($orderId); //创建订单jspay
+                    $jsConfig = LevelRepository::jsPay($this->cid,$orderId); //创建订单jspay
                 } else if ($where['from'] == 'weixinh5') {
-                    $jsConfig = LevelRepository::h5Pay($orderId);
+                    $jsConfig = LevelRepository::h5Pay($this->cid,$orderId);
                 } else {
-                    $jsConfig = LevelRepository::wxPay($orderId);
+                    $jsConfig = LevelRepository::wxPay($this->cid,$orderId);
                 }
             } catch (\Exception $e) {
                 return $this->error( $e->getMessage());
             }
             $info['jsConfig'] = $jsConfig;
 
-            return $this->success('订单创建成功');
+            return $this->success('订单创建成功',$info);
 
         } else $this->error(OrderLevel::getErrorInfo());
     }
@@ -80,7 +83,7 @@ class Level extends Api
             ['from', 'weixin']
         ], $request, true);
         if (!$uni)  $this->error('参数错误!');
-        $order = OrderLevel::where('cid',$this->cid)->where('order_id',$uni)->find();
+        $order = LevelRepository::where('cid',$this->cid)->where('order_id',$uni)->find();
         if (!$order)
             $this->error('订单不存在!');
         if ($order['paid'])
@@ -90,11 +93,11 @@ class Level extends Api
             case '0':
                 try {
                     if ($from == 'routine') {
-                        $jsConfig = OrderLevel::jsPay($order); //订单列表发起支付
+                        $jsConfig = LevelRepository::jsPay($this->cid,$order); //订单列表发起支付
                     } else if ($from == 'weixinh5') {
-                        $jsConfig = OrderLevel::h5Pay($order);
+                        $jsConfig = LevelRepository::h5Pay($this->cid,$order);
                     } else {
-                        $jsConfig = OrderLevel::wxPay($order);
+                        $jsConfig = LevelRepository::wxPay($this->cid,$order);
                     }
                 } catch (\Exception $e) {
                     $this->error($e->getMessage());

+ 3 - 1
application/api/controller/Training.php

@@ -16,6 +16,7 @@ class Training extends Api
                 ['status',1],
                 ['page',1],
                 ['limit',10],
+                ['user_id',$this->auth->getUserinfo()['id']],
             ]
         );
         return $this->success('获取成功',TrainingModel::lst($where));
@@ -38,6 +39,7 @@ class Training extends Api
         if($where['num']==0) $this->error('人数不能为0');
         if(TrainingInfo::Where('training_id',$where['training_id'])->where('user_id',$where['user_id'])->find()) $this->error('已报名,不能重复报名!');
         $rs = TrainingInfo::create($where);
+        TrainingModel::where('id',$where['training_id'])->inc('number',$where['num'])->update();
         $this->success('创建成功',$rs);
     }
     public function mylst(Request $request)
@@ -56,7 +58,7 @@ class Training extends Api
     {
         $id = input('id',0);
         if($id==0) $this->error('参数错误!');
-        $rs = TrainingModel::info($id);
+        $rs = TrainingModel::info($this->cid,$id);
         if(!$rs)$this->error(TrainingModel::getErrorInfo());
         return $this->success('获取成功',$rs);
     }

+ 1 - 1
application/api/controller/User.php

@@ -397,7 +397,7 @@ class User extends Api
                 }
                 else
                 {
-                    $user_ext['key'] =$v;
+                    $user_ext[$key] =$v;
                 }
             }
         }

+ 20 - 2
application/common/model/Help.php

@@ -91,15 +91,33 @@ class Help extends BaseModel
         if(isset($where['status']) && $where['status']>-2) $model->where('status',$where['status']);
         if(isset($where['is_rec']) && $where['is_rec']==1) $model->where('is_rec',$where['is_rec']);
         $data = $model->order('id desc')->page($where['page'],$where['limit'])->select();
+        foreach ($data as &$v)
+        {
+            $v['is_apply'] = HelpApply::where('help_id',$v['id'])->where('user_id',$where['user_id_1'])->find();
+            $v['apply_sum'] = HelpApply::where('help_id',$v['id'])->value('count(id)')?:0;
+            $v['category'] = Category::where('id',$v['category_id'])->value('name');
+            if($v['apply_user_id']>0)
+            {
+                $v['apply_user'] = HelpApply::where('help_id',$v['id'])->where('user_id',$v['apply_user_id'])->find();
+            }
+            else
+            {
+                $v['apply_user'] = null;
+            }
+        }
         return $data;
     }
-    public static function info($cid,$id)
+    public static function info($cid,$id,$user_id=0)
     {
         $info = self::where('cid',$cid)->where('id',$id)->find();
         if(!$info)return self::setErrorInfo('非法数据');
         $info['ext'] = HelpExt::where('help_id',$info['id'])->find();
         $info['family'] = HelpFamily::where('help_id',$info['id'])->select();
-        $info['lave'] = Lave::lst(['cid'=>$cid,'paid'=>1,'help_id'=>$info['id']]);
+        $info['lave'] = Lave::lst(['cid'=>$cid,'paid'=>1,'help_id'=>$info['id'],'page'=>1,'limit'=>99999]);
+        $info['sum_lave'] = Lave::where(['cid'=>$cid,'paid'=>1,'help_id'=>$id])->sum('amount');
+        $info['is_apply'] = HelpApply::where('help_id',$info['id'])->where('user_id',$user_id)->find();
+        $info['apply_sum'] = HelpApply::where('help_id',$info['id'])->value('count(id)')?:0;
+        $info['category'] = Category::where('id',$info['category_id'])->value('name');
         return $info;
     }
 

+ 32 - 0
application/common/model/HelpApply.php

@@ -0,0 +1,32 @@
+<?php
+namespace app\common\model;
+use liuniu\BaseModel;
+
+class HelpApply extends BaseModel
+{
+    // 表名
+    protected $name = 'help_apply';
+
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = false;
+
+    public static function lst($where)
+    {
+        $model = new self;
+        if (isset($where['cid']) && $where['cid'] > 0) $model->where('cid', $where['cid']);
+        if (isset($where['user_id']) && $where['user_id'] > 0) $model->where('user_id', $where['user_id']);
+        if (isset($where['help_id']) && $where['help_id'] > 0) $model->where('help_id', $where['help_id']);
+        if (isset($where['status']) && $where['status'] > -2) $model->where('status', $where['status']);
+        $data = $model->order('id desc')->page($where['page'], $where['limit'])->select();
+        foreach ($data as &$v)
+        {
+            $v['info'] = Help::info($v['cid'],$v['id'],$v['user_id']);
+        }
+        return $data;
+    }
+}

+ 10 - 1
application/common/model/OrderLevel.php

@@ -18,7 +18,7 @@ class OrderLevel extends BaseModel
     protected $name = 'order_level';
 
     // 自动写入时间戳字段
-    protected $autoWriteTimestamp = false;
+    protected $autoWriteTimestamp = true;
 
     // 定义时间戳字段名
     protected $createTime = false;
@@ -54,6 +54,15 @@ class OrderLevel extends BaseModel
         User::setendtime($info['user_id'],$info['level_id']);
         return false !== $res;
     }
+    public static function getNewOrderId()
+    {
+        do {
+            list($msec, $sec) = explode(' ', microtime());
+            $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
+            $orderId = 'wx' . $msectime . mt_rand(10000, 99999);
+        } while (self::where(['order_id' => $orderId])->find());
+        return $orderId;
+    }
 
 
 

+ 4 - 0
application/common/model/training/Training.php

@@ -49,6 +49,10 @@ class Training extends Model
         if(isset($where['status']) && $where['status']>-2) $model->where('status',$where['status']);
         $model = $model->where('reg_start','<',date("Y-m-d H:i:s"))->where('reg_end','>',date("Y-m-d H:i:s"));
         $data = $model->order('id desc')->page($where['page'],$where['limit'])->field("id,title,image,info,reg_start,reg_end,max_number,number")->select();
+        foreach ($data as &$v)
+        {
+            $v['is_create'] = TrainingInfo::where('training_id',$v['id'])->where('user_id',$where['user_id'])->find();
+        }
         return $data;
     }
     public static function info($cid,$id)

+ 7 - 5
application/route.php

@@ -80,7 +80,8 @@ Route::group('api', function () {
         Route::post('apply', 'api/help/apply');
         Route::get('ify', 'api/help/ify');
         Route::get('applylst', 'api/help/lst');
-
+        Route::post("userapply",'api/help/help_user_apply'); //项目帮扶人申请
+        Route::get("userapplylst",'api/help/user_apply_lst'); //项目帮扶人申请
     });
     //物资
     Route::group('project', function () {
@@ -105,16 +106,17 @@ Route::group('api', function () {
     });
     //年费
     Route::group('level', function () {
-        Route::post('create', 'api/level/apply');
+        Route::post('create', 'api/level/create');
         Route::get('ify', 'api/level/ify');
         Route::get('lst', 'api/level/lst');
         Route::get('view', 'api/level/view');
     });
     //捐献
     Route::group('donate', function () {
-        Route::post('apply', 'api/help/apply');
-        Route::get('lst', 'api/help/lst');
-        Route::get('view', 'api/help/view');
+        Route::post('apply', 'api/donate/apply');
+        Route::get('lst', 'api/donate/lst');
+        Route::get('ify', 'api/donate/ify');
+        Route::get('view', 'api/donate/view');
     });
     //志愿者
     Route::group('volunteer', function () {

+ 5 - 5
extend/liuniu/repositories/LevelRepository.php

@@ -22,8 +22,8 @@ class LevelRepository
             $orderInfo = $orderId;
         if (!$orderInfo || !isset($orderInfo['paid'])) exception('支付订单不存在!');
         if ($orderInfo['paid']) exception('支付已支付!');
-        if ($orderInfo['amount'] <= 0) exception('该支付无需支付!');
-        $openid = UserRelation::userIdToOpenId($orderInfo['uid'],'routine_openid');
+        if ($orderInfo['pay_price'] <= 0) exception('该支付无需支付!');
+        $openid = UserRelation::userIdToOpenId($orderInfo['user_id']);
         $rs = WechatService::paymentOrder($openid, $orderInfo['order_id'], $orderInfo['pay_price'],"level", $orderInfo['body'],'', 'JSAPI', [],$cid);
         return WechatService::jspay($cid,$rs['prepay_id']);
     }
@@ -46,8 +46,8 @@ class LevelRepository
             $orderInfo = $orderId;
         if (!$orderInfo || !isset($orderInfo['paid'])) exception('支付订单不存在!');
         if ($orderInfo['paid']) exception('支付已支付!');
-        if ($orderInfo['amount'] <= 0) exception('该支付无需支付!');
-        $openid = UserRelation::userIdToOpenId($orderInfo['uid'],'routine_openid');
+        if ($orderInfo['pay_price'] <= 0) exception('该支付无需支付!');
+        $openid = UserRelation::userIdToOpenId($orderInfo['user_id'],'routine_openid');
         return MiniProgramService::paymentOrder($openid, $orderInfo['order_id'], $orderInfo['pay_price'], 'level', $orderInfo['body'],'','',[],$cid);
 
     }
@@ -66,7 +66,7 @@ class LevelRepository
             $orderInfo = $orderId;
         if (!$orderInfo || !isset($orderInfo['paid'])) exception('支付订单不存在!');
         if ($orderInfo['paid']) exception('支付已支付!');
-        if ($orderInfo['amount'] <= 0) exception('该支付无需支付!');
+        if ($orderInfo['pay_price'] <= 0) exception('该支付无需支付!');
         return WechatService::payment(false,$cid)->paymentOrder(null, $orderInfo['order_id'], $orderInfo['pay_price'],"level", $orderInfo['body'],'', 'MWEB', [],$cid);
     }
 }

+ 64 - 0
public/assets/js/backend/help/help_apply.js

@@ -0,0 +1,64 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'help/help_apply/index' + location.search,
+                    add_url: 'help/help_apply/add',
+                    edit_url: 'help/help_apply/edit',
+                    del_url: 'help/help_apply/del',
+                    multi_url: 'help/help_apply/multi',
+                    import_url: 'help/help_apply/import',
+                    table: 'help_apply',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'cid', title: __('Cid')},
+                        {field: 'help_id', title: __('Help_id')},
+                        {field: 'user_id', title: __('User_id')},
+                        {field: 'full_name', title: __('Full_name'), operate: 'LIKE'},
+                        {field: 'phone', title: __('Phone'), operate: 'LIKE'},
+                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'status', title: __('Status'), searchList: {"-1":__('Status -1'),"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            $("#c-help_id").data("params", function (obj) {
+                return {custom: {cid: $("#c-cid").val()}};
+            });
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            $("#c-help_id").data("params", function (obj) {
+                return {custom: {cid: $("#c-cid").val()}};
+            });
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});