Files
ntonpower/app/api/controller/v1/GoodsCoupon.php
2026-10-14 14:00:29 +08:00

67 lines
1.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\api\controller\v1;
use app\api\model\GoodsCoupon as GoodsCouponModel;
use app\api\validate\GoodsCoupon as GoodsCouponValidate;
/**
* 优惠券口令类
* Class GoodsCoupon
* @package app\api\controller
*/
class GoodsCoupon extends Base
{
public function initialize()
{
parent::initialize(); // TODO: Change the autogenerated stub
$this->model = new GoodsCouponModel();
$this->validate = new GoodsCouponValidate();
}
/**
* 列表
* @return \think\response\Json
*/
public function index()
{
$inputData = $this->request->param();
// //语言包
// if (isset($inputData['language_id']) && $inputData['language_id'] != '' && $inputData['language_id'] != 0) {
// $this->focus['language_id'] = $inputData['language_id'];
// } else {
// return $this->msg(504,'语言包ID不正确,请检查!');
// }
$data = [
// 'language_id'=>$inputData['language_id'],
'platform_id'=>$this->platformId
];
$result = $this->model->getLatest($data);
$result = ['old_code'=>$result['new_code']];
return $this->msg(200,'获取列表成功',$result);
}
/**
* 新增
* @return \think\response\Json
*/
public function create()
{
$inputData = $this->request->param();
$inputData['platform_id'] = $this->platformId;
$inputData['new_code'] = htmlspecialchars_decode($inputData['new_code']);
if (!$this->commonValidate(__FUNCTION__,$inputData)) {
return $this->msg(-1,$this->validate->getError());
}
$inputData['new_code'] = htmlspecialchars($inputData['new_code']);
$result = $this->model->addData($inputData);
if ($result) {
return $this->msg(200,'新增成功');
} else {
return $this->msg(504,'新增失败');
}
}
}