123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?php
- /**
- * 客户余额明细管理模块
- * Created by PhpStorm.
- * User: tpl
- * Date: 2019/10/30
- * Time: 13:54
- */
- namespace JinDouYun\Controller\Finance;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\StatusCode;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\Finance\MCustomerBalanceDetail;
- class CustomerBalanceDetail extends BaseController
- {
- private $objMCustomerBalanceDetail;
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMCustomerBalanceDetail = new MCustomerBalanceDetail($this->onlineEnterpriseId, $this->onlineUserId);
- }
- /**
- * 添加和编辑客户余额明细管理公共字段处理方法
- *
- * @return array
- */
- public function commonFieldFilter()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $customerBalanceDetailData = [
- 'name' => isset($params['name']) ? $params['name'] : '',
- 'enableStatus' => isset($params['enableStatus']) ? $params['enableStatus'] : '',
- 'images' => isset($params['images']) ? $params['images'] : '',
- 'images' => isset($params['images']) ? $params['images'] : '',
- 'images' => isset($params['images']) ? $params['images'] : '',
- ];
- foreach ($customerBalanceDetailData as $key => $value) {
- if (empty($value) && $value !== 0) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- $customerBalanceDetailData['deleteStatus'] = StatusCode::$standard;
- $customerBalanceDetailData['createTime'] = time();
- $customerBalanceDetailData['updateTime'] = time();
- return $customerBalanceDetailData;
- }
- /**
- * 添加客户余额明细
- */
- public function addCustomerBalanceDetail()
- {
- $customerBalanceDetailData = $this->commonFieldFilter();
- $result = $this->objMCustomerBalanceDetail->addCustomerBalanceDetail($customerBalanceDetailData);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 获取指定客户余额明细信息
- */
- public function getCustomerBalanceDetailInfo()
- {
- $customerBalanceDetailId = $this->request->param('request_id');
- if (!$customerBalanceDetailId) {
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $result = $this->objMCustomerBalanceDetail->getCustomerBalanceDetailInfo($customerBalanceDetailId);
- if ($result->isSuccess()) {
- $this->sendOutput($result->getData());
- } else {
- $this->sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 后台所有客户余额明细列表
- */
- public function getAllCustomerBalanceDetail()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $selectParams = [
- 'customerId' => isset($params['customerId']) ? $params['customerId'] : '',
- ];
- foreach ($selectParams as $key => $value) {
- if (empty($value) && $value !== 0) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- $selectParams['start'] = !empty($params['start']) ? $params['start'] : 0;
- $selectParams['end'] = !empty($params['end']) ? strtotime(date('Y-m-d', $params['end']).'23:59:59') : time();
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- $export = isset($params['export']) ? $params['export'] : 0;
- $result = $this->objMCustomerBalanceDetail->getAllCustomerBalanceDetail($selectParams,$export);
- if ($result->isSuccess()) {
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- 'openingBalance' => $returnData['openingBalance'],
- 'endingBalance' => $returnData['endingBalance'],
- 'shouldReceiveTotal' => $returnData['shouldReceiveTotal'],
- 'actualReceiveTotal' => $returnData['actualReceiveTotal'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- }
|