123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <?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\MReceive;
- class Receive extends BaseController
- {
- private $objMReceive;
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMReceive = new MReceive($this->onlineEnterpriseId, $this->onlineUserId);
- }
- /**
- * 添加和编辑应收单管理公共字段处理方法
- *
- * @return array
- */
- public function commonFieldFilter()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $receiveData = [
- 'customerId' => isset($params['customerId']) ? $params['customerId'] : '',//int(11) DEFAULT NULL COMMENT '客户Id',
- 'customerName' => isset($params['customerName']) ? $params['customerName'] : '',//varchar(50) DEFAULT NULL COMMENT '客户名称',
- 'orderId' => isset($params['orderId']) ? $params['orderId'] : '',//varchar(50) DEFAULT NULL COMMENT '单据编号',
- 'sourceNo' => isset($params['sourceNo']) ? $params['sourceNo'] : '',//varchar(50) DEFAULT NULL COMMENT '订单号',
- 'financeTypeId' => isset($params['financeTypeId']) ? $params['financeTypeId'] : '',//int(10) DEFAULT NULL COMMENT '财务类型id',
- 'financeType' => isset($params['financeType']) ? $params['financeType'] : '',
- 'discountMoney' => isset($params['discountMoney']) ? $params['discountMoney'] : '',//float(10,2) DEFAULT NULL COMMENT '优惠金额',
- 'receiveMoney' => isset($params['receiveMoney']) ? $params['receiveMoney'] : '',//float(10,2) DEFAULT NULL COMMENT '实际应收金额',
- 'shopId' => isset($params['shopId']) ? $params['shopId'] : '',//int(11) DEFAULT NULL COMMENT '商铺Id',
- 'shopName' => isset($params['shopName']) ? $params['shopName'] : '',//varchar(50) DEFAULT NULL COMMENT '商铺名称',
- 'receiptTypeId' => isset($params['receiptTypeId']) ? $params['receiptTypeId'] : '',//tinyint(2) DEFAULT NULL COMMENT '单据状态',
- 'auditStatus' => isset($params['auditStatus']) ? $params['auditStatus'] : '',//tinyint(2) DEFAULT NULL COMMENT '单据状态',
- 'offsetStatus' => getArrayItem($params, 'offsetStatus',4),
- ];
- foreach ($receiveData as $key => $value) {
- if (empty($value) && $value !== 0) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- $receiveData['deleteStatus'] = StatusCode::$standard;
- $receiveData['createTime'] = time();
- $receiveData['updateTime'] = time();
- return $receiveData;
- }
- /**
- * 添加应收单
- */
- public function addReceive()
- {
- $receiveData = $this->commonFieldFilter();
- $result = $this->objMReceive->addReceive($receiveData);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 获取指定应收单信息
- */
- public function getReceiveInfo()
- {
- $params = $this->request->getRawJson();
- if (empty($params['id']) || empty($params['createTime'])) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $result = $this->objMReceive->getReceiveInfo($params);
- if ($result->isSuccess()) {
- $this->sendOutput($result->getData());
- } else {
- $this->sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 应收单审核
- */
- public function updateReceiveStatus()
- {
- $params = $this->request->getRawJson();
- if (empty($params['id']) || empty($params['createTime'])) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $result = $this->objMReceive->updateReceiveStatus($params);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 后台所有应收单列表
- */
- public function getAllReceive()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $selectParams = [
- 'customerId' => getArrayItem($params, 'customerId', 0),
- 'auditStatus' => getArrayItem($params, 'auditStatus', 0),
- 'offsetStatus' => getArrayItem($params, 'offsetStatus', []),
- 'shopId' => getArrayItem($params, 'shopId', 0),
- 'receiveReceiptIds' => getArrayItem($params, 'receiveReceiptIds', []),
- 'start' => getArrayItem($params, 'start', 0),
- 'end' => getArrayItem($params, 'end', 0),
- ];
- $isExport = false;
- if(isset($params['isExport'])) {
- $isExport = $params['isExport'];
- }
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- $result = $this->objMReceive->getAllReceive($selectParams, $isExport);
- 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(), $result->getErrorCode());
- }
- }
- /**
- * 搜索
- */
- public function search()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $selectParams = [
- 'keyword' => isset($params['keyword']) ? $params['keyword'] : '',
- 'shopId' => isset($params['shopId']) ? $params['shopId'] : '',
- 'start' => isset($params['start']) ? $params['start'] : '',
- 'end' => isset($params['end']) ? $params['end'] : '',
- 'receiptTypeId' => isset($params['receiptTypeId']) ? $params['receiptTypeId'] : '',
- 'auditStatus' => isset($params['auditStatus']) ? $params['auditStatus'] : '',
- 'isExport' => isset($params['isExport']) ? $params['isExport'] : 0,
- ];
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- $result = $this->objMReceive->search($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(), $result->getErrorCode());
- }
- }
- }
|