123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- <?php
- /**
- * 配送方式设置
- * Created by PhpStorm.
- * User: XiaoMing
- * Date: 2019/10/31
- * Time: 15:46
- */
- namespace JinDouYun\Controller\System;
- use Mall\Framework\Core\ErrorCode;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\System\MDeliverySetting;
- class DeliverySetting extends BaseController
- {
- private $objMDeliverySetting;
- /**
- * DeliverySetting constructor.
- * @param bool $isCheckAcl
- * @param bool $isMustLogin
- * @throws \Exception
- */
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMDeliverySetting = new MDeliverySetting($this->onlineUserId, $this->onlineEnterpriseId);
- }
- /**
- * 添加,编辑配送方式公共数据
- * @return array
- */
- public function commonFieldFilter()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $data = [
- 'title' => isset($params['title']) ? $params['title'] : '',
- 'defaultStatus' => isset($params['defaultStatus']) ? $params['defaultStatus'] : '',
- 'enableStatus' => isset($params['enableStatus']) ? $params['enableStatus'] : '',
- ];
- foreach ($data as $key => $value) {
- if (empty($value) && $value !== 0) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- $data['shopId'] = $this->shopId;
- $data['enterpriseId'] = $this->onlineEnterpriseId;
- $data['setData'] = getArrayItem( $params,'setData','');
- return $data;
- }
- /**
- * Doc: (des="配置运费模版")
- * User: XMing
- * Date: 2020/9/7
- * Time: 10:49 上午
- */
- public function setData()
- {
- //$id = $this->request->param('request_id');
- $params = $this->request->getRawJson();
- if (empty($params)) {
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- if (!isset($params['shopId'])){
- $params['shopId'] = is_null($this->shopId) ? 0 : $this->shopId;
- }
- $result = $this->objMDeliverySetting->setData($params);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * Doc: (des="设置自提点")
- * User: XMing
- * Date: 2020/9/9
- * Time: 10:28 上午
- */
- public function setSelfData()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- parent::sendOutput('参数为空', ErrorCode::$paramError);
- }
- if (!isset($params['shopId'])){
- $params['shopId'] = is_null($this->shopId) ? 0 : $this->shopId;
- }
- $result = $this->objMDeliverySetting->setSelfData($params);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * Doc: (des="删除运费模版规则")
- * User: XMing
- * Date: 2020/9/7
- * Time: 4:56 下午
- */
- public function delDeliveryRule()
- {
- $id = $this->request->param('request_id');
- $result = $this->objMDeliverySetting->delDeliveryRule($id);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * Doc: (des="删除自提点")
- * User: XMing
- * Date: 2020/9/9
- * Time: 10:55 上午
- */
- public function delDeliverySelfRule()
- {
- $id = $this->request->param('request_id');
- $result = $this->objMDeliverySetting->delDeliverySelfRule($id);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * 获取配送方式列表
- * @throws \Exception
- */
- public function getAllDelivery()
- {
- $page = $this->request->param('page') ?: 1;
- $pageSize = $this->request->param('pageSize') ?: 10;
- $offset = ($page - 1) * $pageSize;
- $selectParams = [
- 'limit' => $pageSize,
- 'offset' => $offset,
- ];
- $selectParams['shopId'] = $this->shopId;
- $orderData = $this->objMDeliverySetting->getAllDelivery($selectParams);
- if ($orderData->isSuccess()) {
- $returnData = $orderData->getData();
- $pageData = [
- 'pageIndex' => $page,
- 'pageSize' => $pageSize,
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- }
- parent::sendOutput($orderData->getData(), ErrorCode::$dberror);
- }
- /**
- * 更新配送方式,启用/禁用
- * @throws \Exception
- */
- public function updateEnableStatus()
- {
- $params['id'] = $this->request->param('request_id');
- $params['enableStatus'] = $this->request->param('enableStatus');
- foreach ($params as $key => $value) {
- if (empty($value)) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- $result = $this->objMDeliverySetting->updateEnableStatus($params);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * 更新配送方式的默认状态
- * @throws \Exception
- */
- public function updateDefaultStatus()
- {
- $params['id'] = $this->request->param('request_id');
- $params['defaultStatus'] = $this->request->param('defaultStatus');
- foreach ($params as $key => $value) {
- if (empty($value)) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- $params['shopId'] = is_null($this->shopId) ? 0 : $this->shopId;
- $result = $this->objMDeliverySetting->updateDefaultStatus($params);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * Doc: (des="获取配送方式详情")
- * User: XMing
- * Date: 2020/9/7
- * Time: 12:29 下午
- */
- public function getInfo()
- {
- $id = $this->request->param('request_id');
- $shopId = is_null($this->shopId) ? 0 : $this->shopId;
- $result = $this->objMDeliverySetting->getInfo($id,$shopId);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * 用于获取配送方式(设置->配送方式列表不要使用此接口)
- */
- public function allDelivery()
- {
- $dbResult = $this->objMDeliverySetting->allDelivery();
- if ($dbResult->isSuccess()) {
- $returnData = $dbResult->getData();
- parent::sendOutput($returnData['data'], 0);
- }
- parent::sendOutput($dbResult->getData(), ErrorCode::$dberror);
- }
- /**
- * Doc: (des="设置默认运费模版")
- * User: XMing
- * Date: 2020/9/10
- * Time: 2:07 下午
- */
- public function setDefaultRule()
- {
- $id = $this->request->param('request_id');
- $shopId = is_null($this->shopId) ? 0 : $this->shopId;
- $result = $this->objMDeliverySetting->setDefaultRule($id,$shopId);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * Doc: (des="获取运费模版详情")
- * User: XMing
- * Date: 2020/9/8
- * Time: 6:22 下午
- */
- public function getRuleInfo()
- {
- $id = $this->request->param('request_id');
- $result = $this->objMDeliverySetting->getRuleInfo($id);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * Doc: (des="获取自提点详情")
- * User: XMing
- * Date: 2020/9/9
- * Time: 10:48 上午
- */
- public function getSelfRuleInfo()
- {
- $id = $this->request->param('request_id');
- $result = $this->objMDeliverySetting->getSelfRuleInfo($id);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * Doc: (des="获取运费模版")
- * User: XMing
- * Date: 2020/9/7
- * Time: 6:26 下午
- */
- public function getAllExpressRule()
- {
- $page = $this->request->param('page') ?: 1;
- $pageSize = $this->request->param('pageSize') ?: 10;
- $offset = ($page - 1) * $pageSize;
- $orderData = $this->objMDeliverySetting->getAllExpressRule();
- if ($orderData->isSuccess()) {
- $returnData = $orderData->getData();
- $pageData = [
- 'pageIndex' => $page,
- 'pageSize' => $pageSize,
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- }
- parent::sendOutput($orderData->getData(), ErrorCode::$dberror);
- }
- /**
- * Doc: (des="获取快递公司")
- * User: XMing
- * Date: 2020/9/8
- * Time: 6:53 下午
- */
- public function getAllExpress()
- {
- $page = $this->request->param('page') ?: 1;
- $pageSize = $this->request->param('pageSize') ?: 10;
- $offset = ($page - 1) * $pageSize;
- $orderData = $this->objMDeliverySetting->getAllExpress();
- if ($orderData->isSuccess()) {
- $returnData = $orderData->getData();
- $pageData = [
- 'pageIndex' => $page,
- 'pageSize' => $pageSize,
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- }
- parent::sendOutput($orderData->getData(), ErrorCode::$dberror);
- }
- /**
- * Doc: (des="后台-获取自提点")
- * User: XMing
- * Date: 2020/11/4
- * Time: 3:30 下午
- */
- public function getAllSelfExpressRule()
- {
- $result = $this->objMDeliverySetting->getAllSelfExpressRule();
- if ($result->isSuccess()) {
- $pageData = [
- 'pageIndex' => 1,
- 'pageSize' => 999,
- 'pageTotal' => 999,
- ];
- parent::sendOutput($result->getData(),0,$pageData);
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
-
- /**
- * 物流提醒
- */
- public function updateLogisticsReminder()
- {
- $params = $this->request->getRawJson();
- if( empty($params) ){
- $this->sendOutput('参数为空', ErrorCode::$paramError );
- }
- $reminderData = [
- 'id' => getArrayItem( $params,'id'),
- 'reminder' => getArrayItem( $params,'reminder','')
- ];
- foreach ($reminderData as $key => $value) {
- if (empty($value)) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- $result = $this->objMDeliverySetting->updateLogisticsReminder($reminderData);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
-
- }
|