123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Gss
- * Date: 2021/4/7 0007
- * Time: 15:23
- */
- namespace JinDouYun\Controller\Merchant;
- use Mall\Framework\Core\ErrorCode;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\Merchant\MMerchantDetail;
- class MerchantDetail extends BaseController
- {
- private $objMMerchantDetail;
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMMerchantDetail = new MMerchantDetail($this->onlineEnterpriseId, $this->onlineUserId);
- }
- /**
- * 添加和编辑收支记录公共字段处理方法
- *
- * @return array
- */
- public function commonFieldFilter()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $ReceiptRequisitionData = [
- 'merchantId' => getArrayItem($params,'merchantId',''),
- 'merchantName' => getArrayItem($params, 'merchantName',''),
- 'money' => isset($params['money']) ? $params['money'] : 0.00,
- 'type' => isset($params['type']) ? $params['type'] : '',
- 'settlementId' => getArrayItem($params,'settlementId',''),
- ];
- foreach ($ReceiptRequisitionData as $key => $value) {
- if (empty($value) && $value !== 0) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- $ReceiptRequisitionData['createTime'] = time();
- $ReceiptRequisitionData['updateTime'] = time();
- return $ReceiptRequisitionData;
- }
- /*
- * 新增收支记录
- * */
- public function addMerchantDetail()
- {
- $merchantDetailData = $this->commonFieldFilter();
- $result = $this->objMMerchantDetail->addMerchantDetail($merchantDetailData);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /*
- * 所有收支记录
- * */
- public function getAllMerchantDetail()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $params['limit'] = $pageParams['limit'];
- $params['offset'] = $pageParams['offset'];
- $params['merchantId'] = getArrayItem($params,'merchantId','');
- $params['type'] = getArrayItem($params,'type','');
- $params['start'] = getArrayItem($params,'start','');
- $params['end'] = getArrayItem($params,'end','');
- $returnData = $this->objMMerchantDetail->getAllMerchantDetail($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);
- }
- }
- }
|