You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jy-sdk/Application/Sdk/Controller/PointShopController.class.php

73 lines
2.1 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?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);
}
}
}