123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Gss
- * Date: 2021/4/6 0006
- * Time: 12:21
- */
- namespace JinDouYun\Controller\Merchant;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\Merchant\MMerchantSettlement;
- use Mall\Framework\Core\ErrorCode;
- class MerchantSettlement extends BaseController
- {
- private $objMMerchantSettlement;
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMMerchantSettlement = new MMerchantSettlement($this->onlineEnterpriseId, $this->onlineUserId);
- }
- /**
- * 添加和编辑结算记录公共字段处理方法
- *
- * @return array
- */
- public function commonFieldFilter()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $merchantSettlementData = [
- 'orderId' => getArrayItem($params,'orderId',''),
- 'orderNo' => getArrayItem($params, 'orderNo',''),
- 'goodsId' => isset($params['goodsId']) ? $params['goodsId'] : '',
- 'goodsName' => isset($params['goodsName']) ? $params['goodsName'] : '',
- 'goodsPrice' => isset($params['goodsPrice']) ? $params['goodsPrice'] : '',
- 'goodsMoney' => getArrayItem($params,'goodsMoney',0.00),
- 'merchantId' => getArrayItem($params,'merchantId',''),
- 'merchantName' => getArrayItem($params,'merchantId','')
- ];
- foreach ($merchantSettlementData as $key => $value) {
- if (empty($value) && $value !== 0) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- $merchantSettlementData['createTime'] = time();
- $merchantSettlementData['updateTime'] = time();
- return $merchantSettlementData;
- }
- /*
- * 新增结算记录
- * */
- public function addMerchantSettlement()
- {
- $merchantSettlementData = $this->commonFieldFilter();
- $result = $this->objMMerchantSettlement->addMerchantSettlement($merchantSettlementData);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /*
- * 结算记录状态
- * */
- public function updateMerchantSettlement()
- {
- $params = $this->request->getRawJson();
- if( empty($params['orderId'])){
- $this->sendOutput('参数为空', ErrorCode::$paramError );
- }
- $result = $this->objMMerchantSettlement->updateMerchantSettlement($params);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /*
- * 获取所有结算记录
- * */
- public function getAllMerchantSettlement()
- {
- $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['operatorName'] = getArrayItem($params,'operatorName','');
- $params['MerchantId'] = getArrayItem($params,'MerchantId','');
- $params['goodName'] = getArrayItem($params,'goodName','');
- $params['settlementStatus'] = getArrayItem($params,'settlementStatus','');
- $params['start'] = getArrayItem($params,'start','');
- $params['end'] = getArrayItem($params,'end','');
- $returnData = $this->objMMerchantSettlement->getAllMerchantSettlement($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);
- }
- }
- }
|