| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <?php
- namespace App\Http\Controllers\Api\v1;
- use App\Http\Controllers\Api\webApp;
- use App\Services\Common\MemberService;
- use App\Services\Common\TradeService;
- /**
- * 交易
- * Class TradeController
- * @package App\Http\Controllers\Api
- */
- class TradeController extends webApp
- {
- public function index()
- {
- $params = request()->all();
- $pageSize = isset($params['pageSize'])? $params['pageSize'] : 18;
- $type = isset($params['type'])? $params['type'] : 1;
- $status = isset($params['status'])? $params['status'] : 0;
- // 我的订单
- if($type == 1){
- $params['user_id'] = $this->userId;
- $params['sell_uid'] = $this->userId;
- }
- // 推广订单
- else if($type == 2){
- $params['parent_id'] = $this->userId;
- }
- // 店铺订单
- else if($type == 3){
- $params['shop_id'] = $this->shopId;
- }
- $params['time'] = strtotime(date('Y-m-d'))-86400*7;
- $datas = TradeService::make()->getDataList($params, $pageSize);
- return message(1010, true, $datas);
- }
- /**
- * 详情
- * @return array|mixed
- */
- public function info()
- {
- $id = request()->post('id', 0);
- $info = TradeService::make()->getInfo($id);
- return message(1010, true, $info);
- }
- /**
- * 统计
- * @return array
- */
- public function counts()
- {
- $params = request()->all();
- $type = isset($params['type'])? $params['type'] : 1;
- $status = isset($params['status'])? $params['status'] : 0;
- // 我的订单
- if($type == 1){
- if($status==2){
- $params['sell_uid'] = $this->userId;
- }else{
- $params['user_id'] = $this->userId;
- }
- }
- // 推广订单
- else if($type == 2){
- $params['parent_id'] = $this->userId;
- }
- // 店铺订单
- else if($type == 3){
- $params['shop_id'] = $this->shopId;
- }
- $params['time'] = strtotime(date('Y-m-d'))-86400*7;
- $counts = TradeService::make()->getCounts($params);
- return message(1010, true, $counts);
- }
- /**
- * 抢拍
- * @return array
- */
- public function buy()
- {
- if(TradeService::make()->buy(request()->all(), $this->userId, $this->shopId)){
- return message(TradeService::make()->getError(), true);
- }else{
- return message(TradeService::make()->getError(), false);
- }
- }
- /**
- * 付款
- * @return array
- */
- public function pay()
- {
- if(TradeService::make()->pay(request()->all(), $this->userId, $this->shopId)){
- return message(TradeService::make()->getError(), true);
- }else{
- return message(TradeService::make()->getError(), false);
- }
- }
- /**
- * 确认收款
- * @return array
- */
- public function confirm()
- {
- if(TradeService::make()->confirm(request()->all(), $this->userId)){
- return message(TradeService::make()->getError(), true);
- }else{
- return message(TradeService::make()->getError(), false);
- }
- }
- /**
- * 上架
- * @return array
- */
- public function sell()
- {
- if(TradeService::make()->sell(request()->all(), $this->userId)){
- return message(TradeService::make()->getError(), true);
- }else{
- return message(TradeService::make()->getError(), false);
- }
- }
- /**
- * 上架审核
- * @return array
- */
- public function sellConfirm()
- {
- if(TradeService::make()->sellConfirm(request()->all())){
- return message(TradeService::make()->getError(), true);
- }else{
- return message(TradeService::make()->getError(), false);
- }
- }
- /**
- * 修改订单
- * @return array
- */
- public function modify()
- {
- if(TradeService::make()->modify(request()->all())){
- return message(TradeService::make()->getError(), true);
- }else{
- return message(TradeService::make()->getError(), false);
- }
- }
- /**
- * 取消订单
- * @return array
- */
- public function cancel()
- {
- if(TradeService::make()->cancel(request()->all())){
- return message(TradeService::make()->getError(), true);
- }else{
- return message(TradeService::make()->getError(), false);
- }
- }
- }
|