|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Created by PhpStorm.
|
|
|
|
|
* User: xmy 280564871@qq.com
|
|
|
|
|
* Date: 2017/4/6
|
|
|
|
|
* Time: 11:06
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Sdk\Controller;
|
|
|
|
|
|
|
|
|
|
use App\Model\PointShopModel;
|
|
|
|
|
use App\Model\PointShopRecordModel;
|
|
|
|
|
|
|
|
|
|
class PointShopController extends BaseController{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 积分兑换平台币
|
|
|
|
|
* @param $token
|
|
|
|
|
* @param $num
|
|
|
|
|
* author: yyh 2018 10 26
|
|
|
|
|
*/
|
|
|
|
|
public function point_convert_coin(){
|
|
|
|
|
$request = json_decode(base64_decode(file_get_contents("php://input")), true);
|
|
|
|
|
$user_id = $request['user_id'];
|
|
|
|
|
$num = $request['num'];//兑换数量
|
|
|
|
|
if($num<1){
|
|
|
|
|
$this->new_set_message(0, "兑换数量不正确", []);
|
|
|
|
|
}
|
|
|
|
|
$model = new PointShopRecordModel();
|
|
|
|
|
$result = $model->PointConvertCoin($user_id,$num);
|
|
|
|
|
if($result){
|
|
|
|
|
$this->new_set_message(200,"兑换成功",[]);
|
|
|
|
|
}else{
|
|
|
|
|
$this->new_set_message(1063,"兑换失败:".$model->getError());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 获取用户兑换记录
|
|
|
|
|
* @param $token
|
|
|
|
|
* @param int $p
|
|
|
|
|
* @param int $type 1:全部 2:商品 3:平台币
|
|
|
|
|
* author: yyh 2018 10 26
|
|
|
|
|
*/
|
|
|
|
|
public function get_user_buy_record(){
|
|
|
|
|
$request = json_decode(base64_decode(file_get_contents("php://input")), true);
|
|
|
|
|
$user_id = $request['user_id'];
|
|
|
|
|
$page = intval($request['p']);
|
|
|
|
|
$row = intval($request['row']);
|
|
|
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
|
|
|
$type = $request['type'];
|
|
|
|
|
$row = $row ? $row : 20;
|
|
|
|
|
$model = new PointShopRecordModel();
|
|
|
|
|
$map['user_id'] = $user_id;
|
|
|
|
|
if ($type == 3){
|
|
|
|
|
$map['good_type'] = 3;//平台币
|
|
|
|
|
}else{
|
|
|
|
|
$this->new_set_message(0, "type参数不正确", []);
|
|
|
|
|
}
|
|
|
|
|
// elseif ($type == 3) {
|
|
|
|
|
// $map['good_type'] = ['in',[1,2]];//商品
|
|
|
|
|
// }
|
|
|
|
|
$result = $model->getLists($map,"create_time desc",$page,$row);
|
|
|
|
|
// $total = $model->getUserSpendPoint2($user_id,$map);
|
|
|
|
|
if(empty($result)){
|
|
|
|
|
$this->new_set_message(1062,"数据不存在");
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
$this->new_set_message(200,"成功",$result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|