123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <?php
- 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
- {
-
-
- 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;
- $status=input("status");
- $num=input("num")?: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="您的订单买家已经打款请前去查看";
- 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,"申述提交成功");
- }
- }
|