78 lines
2.1 KiB
PHP
78 lines
2.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\api\controller;
|
||
|
|
|
||
|
|
use app\common\controller\Api;
|
||
|
|
use app\common\model\Gifts as GiftsModel;
|
||
|
|
use app\common\model\GiftsOrder as GiftsOrderModel;
|
||
|
|
use app\common\model\JinbiOrder as JinbiOrderModel;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 邮箱验证码接口
|
||
|
|
*/
|
||
|
|
class Gifts extends Api
|
||
|
|
{
|
||
|
|
protected $noNeedLogin = '*';
|
||
|
|
protected $noNeedRight = '*';
|
||
|
|
|
||
|
|
public function lists()
|
||
|
|
{
|
||
|
|
$lists = GiftsModel::getList(['status'=>"1"]);
|
||
|
|
return $this->success('成功', $lists);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/*
|
||
|
|
* 赠送礼物
|
||
|
|
*/
|
||
|
|
public function give(){
|
||
|
|
$gifts_id = $this->request->post('gifts_id');
|
||
|
|
$nums = $this->request->post('nums',"1");
|
||
|
|
$to_user_id = $this->request->post('to_user_id');
|
||
|
|
$from_user_id = $this->auth->id;
|
||
|
|
|
||
|
|
if($from_user_id == $to_user_id){
|
||
|
|
$this->error('不能给自己赠送礼物');
|
||
|
|
}
|
||
|
|
|
||
|
|
$result = GiftsModel::giveGift($gifts_id, $from_user_id, $to_user_id, $nums);
|
||
|
|
if ($result['code'] <= 0){
|
||
|
|
$this->error($result['masg']);
|
||
|
|
}
|
||
|
|
return $this->success('成功');
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/*
|
||
|
|
* 创建购买礼物订单
|
||
|
|
*/
|
||
|
|
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 = JinbiOrderModel::giftsCreateOrder($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);
|
||
|
|
}
|
||
|
|
|
||
|
|
/*
|
||
|
|
* 重置订单流水号,二次支付时需要
|
||
|
|
*/
|
||
|
|
public function resetordersn(){
|
||
|
|
$order_id = $this->request->post('order_id');
|
||
|
|
$user_id = $this->auth->id;
|
||
|
|
$result = JinbiOrderModel::resetOrderSn($order_id,$user_id);
|
||
|
|
if ($result['code'] <= 0){
|
||
|
|
$this->error($result['msg']);
|
||
|
|
}else{
|
||
|
|
return $this->success('成功', $result['data']);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|