123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- <?php
- /**
- *
- * User: anyluck
- * Date: 2020/6/3
- * Time: 10:22
- */
- namespace app\web\controller;
- use app\common\controller\Orde;
- use app\common\model\Banner;
- use app\common\model\Message;
- use app\common\model\Mining;
- use app\common\model\Notice;
- use app\common\model\Order;
- use app\common\model\State;
- use app\common\model\User;
- use app\web\model\Back;
- use app\web\model\Msg;
- use app\web\model\Orders;
- class Index extends Base
- {
- // todo 首页
- // 首页
- public function index()
- {
- $data=[];
- $message_count=Message::where(["status"=>0,"user_id"=>$this->user_id])->count();
- $data["message_count"]=$message_count;// 未读消息
- $banner=Banner::where(["status"=>0])->field("id,image")->select();
- $data["banner"]=$banner;// 轮播图
- // 公告
- $notice=Notice::where(["status"=>0])->field("id,name")->select();
- $data["notice"]=$notice;
- // 交易区块
- $back=Back::back();
- $data["back"]=$back;
- json_result(200,"",$data);
- }
- // 轮播图详情
- public function banner_show()
- {
- $id=input("id");
- $where["id"]=$id;
- $data=Banner::where($where)->find();
- json_result(200,"",$data);
- }
- // 获取交易区块
- public function back()
- {
- $back=Back::back();
- json_result(200,"",$back);
- }
- // 根据个人信息查询交易区块
- public function persion_back()
- {
- $back=Back::persion_back($this->user_id);
- json_result(200,"",$back);
- }
- // 交易数据列表
- public function order_list()
- {
- $page=input("page")?:1;
- $limit=input("limit")?:10;
- $type=input("type")?:0;// 0是查看交易中心求购数据 1我的购买数据 2我的卖出数据
- $status=input("status");//0 不根据状态查询 1 查找进行中的 2 已完成的 配合上面的type 一起使用
- $num=input("num")?:0;// 查看交易中心是传的区块数量 0 是全部
- $user_id=$this->user_id;
- $res=Orders::order_list($type,$user_id,$status,$page,$limit,$num);
- json_result(200,"",$res);
- }
- // 买入和卖出
- public function order_buy()
- {
- $type=input("type")?:0;
- $mining_id=input("mining_id")?:0;
- $order_id=input("order_id");
- Orders::push_order($this->user,$this->user_id,$type,$order_id,$mining_id);
- }
- // 订单详情
- public function order_show()
- {
- $id=input("id");if (!$id)json_result(400,"请上传订单id");
- $order=Order::where(["id"=>$id])->find();
- if (!$order){
- json_result(400,"订单不存在");
- }
- if ($order->buy_user&&$order->push_user){
- Orders::order_show($order,$this->user_id);
- }else{
- json_result(400,"当前订单未卖出无法查询卖出人信息");
- }
- }
- //上传凭证
- public function order_voucher()
- {
- $id=input("id");if (!$id)json_result(400,"订单id 没有上传");
- $image=input("image");if ($image)json_result(400,"请上传凭证");
- $where["id"]=$id;
- $order=Order::where($where)->find();
- if (!$order){
- json_result(400,"订单id错误");
- }
- if ($order->status!=1){
- json_result(400,"当前状态无法上传凭证");
- }
- // 给用户短信或者邮件通知
- $where_user["id"]=$order->push_user;
- $user=User::where($where_user)->find();
- $content="您的订单买家已经打款请前去查看";
- \app\common\controller\Message::add_message($order->push_user,2,"买家已付款","您在".$order->number."区的订单,编号【".$order->order."】,买家已付款,请审核");
- //dump($user);die();
- Order::update(["image"=>$image,"status"=>2],$where);
- if ($user->phone){
- Msg::phone($content,$user->phone);
- }else{
- Msg::mail($content,$user->mail);
- }
- json_result(200,"操作成功");
- }
- // 审核成功
- public function order_success()
- {
- $id=input("id");
- $where["id"]=$id;
- $order=Order::where($where)->find();
- if (!$order){
- json_result(400,"订单id错误");
- }
- if ($order->status==3){
- json_result(400,"订单已经完成");
- }
- if ($order->status!=2){
- json_result(400,"还没有上传证明");
- }
- Orde::order_success($order);
- json_result(200,"处理成功");
- }
-
- // 审核失败
- public function order_fail()
- {
- $id=input("id");if (!$id)json_result(400,"请上传订单id");
- $msg=input("msg");if (!$msg)json_result(400,"请添加失败原因");
- Orders::order_fail($msg,$id);
- }
- // 取消交易
- public function Order_Cancel ()
- {
- $id=input("id");
- $where["id"]=$id;
- $order=Order::where(["id"=>$id])->find();
- if ($order->status==0){
- // 修改订单状态
- $update["status"]=4;
- Order::update($update,["id"=>$id]);
- json_result(200,"取消成功");
- }else{
- json_result(400,"不能取消");
- }
-
- }
- // 申述
- public function state()
- {
- $order_id=input("order_id");
- $content=input("content");if (!$content)json_result(400,"请填写申述内容");
- $image=input("image");
- $add["add_time"]=time();
- $add["user_id"]=$this->user_id;
- $add["order"]=$order_id;
- $add["content"]=$content;
- $add["image"]=$image;
- State::create($add);
- json_result(200,"申述提交成功");
- }
- }
|