123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <?php
- /**
- * Created by PhpStorm.
- * User: kang
- * Date: 2021/3/27
- * Time: 12:09
- */
- namespace JinDouYun\Controller\Goods;
- use Mall\Framework\Core\ErrorCode;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\Goods\MGoodsSupport;
- class GoodsSupport extends BaseController
- {
- private $objMGoodsSupport;
-
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMGoodsSupport = new MGoodsSupport($this->onlineEnterpriseId, $this->onlineUserId);
- }
-
- /**
- * 添加和编辑商品服务公共字段处理方法
- *
- * @return array
- */
- public function commonFieldFilter(){
-
- $params = $this->request->getRawJson();
- if( empty($params) ){
- $this->sendOutput('参数为空', ErrorCode::$paramError );
- }
- $goodsData = [
- 'enterprise' => $this->onlineEnterpriseId,
- 'servicesName' => getArrayItem($params,'servicesName'),
- ];
- foreach($goodsData as $key => $value){
- if(empty($value) && $value !== 0){
- $this->sendOutput($key.'参数错误', ErrorCode::$paramError );
- }
- }
- $goodsData['describe'] = getArrayItem($params,'describe','');
- $goodsData['Icon'] = getArrayItem($params,'Icon','');
- $goodsData['createTime'] = time();
- return $goodsData;
- }
-
- /**
- * 添加商品服务
- */
- public function addGoodsSupport()
- {
- $addGoodsSupportData = $this->commonFieldFilter();
- $result = $this->objMGoodsSupport ->addGoodsSupport($addGoodsSupportData);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
-
- }
- /**
- * 获取指定商品服务
- */
- public function getGoodsSupportInfo()
- {
- $GoodsSupportId = $this->request->param('request_id');
- if ( !$GoodsSupportId ) {
- $this->sendOutput('参数错误', ErrorCode::$paramError );
- }
- $result = $this->objMGoodsSupport->getGoodsSupportInfo($GoodsSupportId);
- if($result->isSuccess()){
- $this->sendOutput($result->getData());
- }else{
- $this->sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 编辑商品服务
- */
- public function editGoodsSupport()
- {
- $params = $this->request->getRawJson();
- if(empty($params)){
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $result = $this->objMGoodsSupport->editGoodsSupport($params);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
-
- }
-
- /**
- * 删除商品服务
- */
- public function delGoodsSupport()
- {
- $GoodsSupportId = $this->request->param('request_id');
- if ( !$GoodsSupportId ) {
- $this->sendOutput('参数错误', ErrorCode::$paramError );
- }
- $result = $this->objMGoodsSupport->delGoodsSupport($GoodsSupportId);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
-
- /**
- * 后台所有商品服务
- */
- public function getAllGoodsSupport()
- {
- $params = $this->request->getRawJson();
- if(empty($params)){
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $params['servicesName'] = getArrayItem($params,'servicesName','');
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $params['limit'] = $pageParams['limit'];
- $params['offset'] = $pageParams['offset'];
-
- $returnData = $this->objMGoodsSupport->getAllGoodsSupport($params);
- if ($returnData->isSuccess()) {
- $returnData = $returnData->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- } else {
- parent::sendOutput($returnData->getData(), ErrorCode::$dberror);
- }
- }
-
- }
|