123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <?php
- /**
- * 积分商品Controller
- * Created by PhpStorm.
- * User: haoren
- * Date: 2021/03/25
- * Time: 16:00
- */
- namespace JinDouYun\Controller\Integral;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\StatusCode;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\Integral\MIntegralGoods;
- class ApiIntegralGoods extends BaseController
- {
- private $objMIntegralGoods;
- public function __construct($isCheckAcl = false, $isMustLogin = true, $checkToken=true)
- {
- parent::__construct($isCheckAcl, $isMustLogin, $checkToken);
- $this->objMIntegralGoods = new MIntegralGoods($this->onlineEnterpriseId, $this->onlineUserId);
- }
- /**
- * 积分商品兑换添加
- */
- public function addIntegralGoodsExchange()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- $data = [
- 'goodsId' => isset($params['goodsId']) ? $params['goodsId'] : '',
- 'num' => isset($params['num']) ? $params['num'] : [],
- 'address' => isset($params['address']) ? json_encode($params['address']) : [],
- ];
- foreach($data as $key => $value){
- if(empty($value)){
- parent::sendOutput($key.'参数错误', ErrorCode::$paramError);
- }
- }
- $data['shopId'] = $this->shopId ? $this->shopId : 0;
- $data['userCenterId'] = isset($params['userCenterId']) ? $params['userCenterId'] : '';
- if(empty($data['userCenterId'])){
- $data['userCenterId'] = $this->onlineUserId;
- }
- $data['remark'] = isset($params['remark']) ? $params['remark'] : '';
- $result = $this->objMIntegralGoods->addIntegralGoodsExchange($data);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 积分商品列表
- */
- public function getAllIntegralGoods()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- if(isset($params['search']) && !empty($params['search'])){
- $selectParams['search'] = $params['search'];
- }
- if(!empty($this->shopId)){
- $selectParams['shopId'] = $this->shopId;
- }
- $result = $this->objMIntegralGoods->getAllIntegralGoods($selectParams);
- if ($result->isSuccess()) {
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- } else {
- parent::sendOutput($result->getData(), ErrorCode::$dberror);
- }
- }
- /**
- * 积分商品详情
- */
- public function getIntegralGoodsInfo()
- {
- $params['id'] = $this->request->param('request_id');
- if (empty($params['id'])) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $result = $this->objMIntegralGoods->getIntegralGoodsInfo($params);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 积分商品兑换列表
- */
- public function getAllIntegralGoodsExchange()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- if(isset($params['search']) && !empty($params['search'])){
- $selectParams['search'] = $params['search'];
- }
- if(isset($params['status']) && !empty($params['status'])){
- $selectParams['status'] = $params['status'];
- }
- if(!empty($this->shopId)){
- $selectParams['shopId'] = $this->shopId;
- }
- $selectParams['userCenterId'] = $this->onlineUserId;
- $result = $this->objMIntegralGoods->getAllIntegralGoodsExchange($selectParams);
- if ($result->isSuccess()) {
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- } else {
- parent::sendOutput($result->getData(), ErrorCode::$dberror);
- }
- }
- /**
- * 积分商品兑换详情
- */
- public function getIntegralGoodsExchangeInfo()
- {
- $params['id'] = $this->request->param('request_id');
- if (empty($params['id'])) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $result = $this->objMIntegralGoods->getIntegralGoodsExchangeInfo($params);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- }
|