56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\api\controller;
|
||
|
|
|
||
|
|
use app\common\controller\Api;
|
||
|
|
use think\Config;
|
||
|
|
use think\Db;
|
||
|
|
use app\common\model\Gifts as GiftsModel;
|
||
|
|
use app\common\model\GiftsOrder as GiftsOrderModel;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 女友相关接口
|
||
|
|
*/
|
||
|
|
class Girlfriend extends Api
|
||
|
|
{
|
||
|
|
protected $noNeedLogin = [];
|
||
|
|
protected $noNeedRight = '*';
|
||
|
|
|
||
|
|
public function _initialize()
|
||
|
|
{
|
||
|
|
parent::_initialize();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 赠送礼物
|
||
|
|
*/
|
||
|
|
public function gifts_give(){
|
||
|
|
$gifts_id = $this->request->post('gifts_id');
|
||
|
|
$nums = $this->request->post('nums',"1");
|
||
|
|
$from_user_id = $this->auth->id;
|
||
|
|
|
||
|
|
$result = GiftsModel::giveGiftGirlfriend($gifts_id, $from_user_id, $nums);
|
||
|
|
return $this->success('成功', $result);
|
||
|
|
}
|
||
|
|
|
||
|
|
/*
|
||
|
|
* 创建购买礼物订单
|
||
|
|
*/
|
||
|
|
public function createOrder(){
|
||
|
|
$gifts_id = $this->request->post('gifts_id');
|
||
|
|
$nums = $this->request->post('nums',"1");
|
||
|
|
$pay_type = $this->request->post('pay_type');
|
||
|
|
$from_user_id = $this->auth->id;
|
||
|
|
$result = GiftsOrderModel::createOrder($gifts_id, $from_user_id, $pay_type, $nums);
|
||
|
|
if ($result['code'] <= 0){
|
||
|
|
$this->error($result['msg']);
|
||
|
|
}else{
|
||
|
|
return $this->success('成功', $result['data']);
|
||
|
|
}
|
||
|
|
return $this->success('成功', $result);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
}
|