123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\model\Category;
- use app\common\model\project\ProjectDonation;
- use app\common\model\project\ProjectDonationOrder;
- use app\common\model\project\ProjectDonationRocord;
- use app\common\model\project\ProjectDonationUser;
- use think\Request;
- use liuniu\UtilService;
- class Project extends Api
- {
- protected $noNeedRight = ['*'];
- /**
- * 获取捐赠列表
- * @param Request $request
- */
- public function lst(Request $request)
- {
- $where = UtilService::getMore([
- ['status',-2],
- ['page',1],
- ['limit',10],
- ['cid',$this->cid],
- ],$request);
- $this->success('获取成功',ProjectDonation::lst($where));
- }
- /**
- * 获取捐赠详情
- * @param Request $request
- */
- public function info(Request $request)
- {
- $id = input('id',0);
- $info = ProjectDonation::info($id)->toArray();
- if(!$info) return $this->error('此捐赠不存在!');
- $this->success('获取成功',$info);
- }
- /**
- * 获取我的捐赠
- * @param $where
- */
- public function myorder(Request $request)
- {
- $where = UtilService::postMore([
- ['status',-2],
- ['page',1],
- ['limit',10],
- ['all',0],
- ],$request);
- $where['uid'] = $this->auth->getUserinfo()['id'];
- $this->success('获取成功',ProjectDonationOrder::lst($where));
- }
- /**
- * 获取所有状态
- * @param Request $request
- */
- public function bill(Request $request)
- {
- list($project_id,$page,$limit,$type) = UtilService::postMore([
- ['project_id',0],
- ['page',1],
- ['limit',10],
- ['type',''],
- ],$request,true);
- $this->success('获取成功',ProjectDonationRocord::getbill($project_id,$type,$page,$limit));
- }
- /**
- * 活动捐赠
- * @param Request $request
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function all_order(Request $request)
- {
- $where = UtilService::postMore([
- ['status',-2],
- ['page',1],
- ['limit',10],
- ['all',1],
- ['project_id',0],
- ],$request);
- //$where['uid'] = $this->auth->getUserinfo()['id'];
- $where['cid'] = $this->cid;
- $this->success('获取成功',ProjectDonationOrder::lst($where));
- }
- /**
- * 创建捐赠
- * @param Request $request
- */
- public function order_create(Request $request)
- {
- $where = UtilService::postMore([
- ['name',''],
- ['project_id',0],
- ['project_user_id',0],
- ['matter',''],
- ['qc',''],
- ['worth',''],
- ['item',[]],
- ['logistics',''],
- ],$request);
- if(empty($where['name'])) $this->error('名称不能为空!');
- if($where['project_user_id']<1) $this->error('用户不能为空!');
- if(sizeof($where['item'])==0) $this->error('捐赠物资不能为空!');
- $where['uid'] = $this->auth->getUserinfo()['id'];
- $where['cid'] = $this->cid;
- $order = ProjectDonationOrder::create_order($where);
- if ($order === false) return $this->error(ProjectDonationOrder::getErrorInfo('订单生成失败'));
- $this->success('创建成功',$order);
- }
- /**
- * 获取订单详情
- * @param Request $request
- */
- public function order_info(Request $request)
- {
- $id = input('id',0);
- $this->success('获取成功',ProjectDonationOrder::info($id));
- }
- /**
- * 创建用户
- * @param Request $request
- */
- public function create_user(Request $request)
- {
- $where = UtilService::postMore([
- ['name',''],
- ['card_id',''],
- ['phone',''],
- ['tel',''],
- ['contacts',''],
- ['anonymous',0],
- ['invoice',0],
- ['user_type',0],
- ['logistics',''],
- ['cid',$this->cid],
- ],$request);
- $where['uid'] = $this->auth->getUserinfo()['id'];
- $id = input('id',0);
- if($where['user_type']==0)
- {
- if(empty($where['name'])) $this->error('姓名不能为空!');
- if(empty($where['phone'])) $this->error('联系方式不能为空!');
- }
- else
- {
- if(empty($where['name'])) $this->error('单位不能为空!');
- if(empty($where['contacts'])) $this->error('联系人不能为空!');
- if(empty($where['tel'])) $this->error('单位电话不能为空!');
- }
- if(empty($where['logistics'])) $this->error('物流类型不能为空!');
- if($id==0)
- {
- $rs = ProjectDonationUser::create($where);
- }
- else
- {
- $rs = ProjectDonationUser::where('id')->update($where);
- }
- $this->success('获取成功',$rs);
- }
- /**
- * 获取用户列表
- * @param Request $request
- */
- public function user_list(Request $request)
- {
- $where['uid'] = $this->auth->getUserinfo()['id'];
- return $this->success('获取成功',ProjectDonationUser::where($where)->order("id DESC")->select());
- }
- public function Donation_info()
- {
- $this->success('获取成功',Category::getCategoryArray('project'));
- }
- }
|