MerchantSettlement.Class.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Gss
  5. * Date: 2021/4/6 0006
  6. * Time: 12:21
  7. */
  8. namespace JinDouYun\Controller\Merchant;
  9. use JinDouYun\Controller\BaseController;
  10. use JinDouYun\Model\Merchant\MMerchantSettlement;
  11. use Mall\Framework\Core\ErrorCode;
  12. class MerchantSettlement extends BaseController
  13. {
  14. private $objMMerchantSettlement;
  15. public function __construct($isCheckAcl = true, $isMustLogin = true)
  16. {
  17. parent::__construct($isCheckAcl, $isMustLogin);
  18. $this->objMMerchantSettlement = new MMerchantSettlement($this->onlineEnterpriseId, $this->onlineUserId);
  19. }
  20. /**
  21. * 添加和编辑结算记录公共字段处理方法
  22. *
  23. * @return array
  24. */
  25. public function commonFieldFilter()
  26. {
  27. $params = $this->request->getRawJson();
  28. if (empty($params)) {
  29. $this->sendOutput('参数为空', ErrorCode::$paramError);
  30. }
  31. $merchantSettlementData = [
  32. 'orderId' => getArrayItem($params,'orderId',''),
  33. 'orderNo' => getArrayItem($params, 'orderNo',''),
  34. 'goodsId' => isset($params['goodsId']) ? $params['goodsId'] : '',
  35. 'goodsName' => isset($params['goodsName']) ? $params['goodsName'] : '',
  36. 'goodsPrice' => isset($params['goodsPrice']) ? $params['goodsPrice'] : '',
  37. 'goodsMoney' => getArrayItem($params,'goodsMoney',0.00),
  38. 'merchantId' => getArrayItem($params,'merchantId',''),
  39. 'merchantName' => getArrayItem($params,'merchantId','')
  40. ];
  41. foreach ($merchantSettlementData as $key => $value) {
  42. if (empty($value) && $value !== 0) {
  43. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  44. }
  45. }
  46. $merchantSettlementData['createTime'] = time();
  47. $merchantSettlementData['updateTime'] = time();
  48. return $merchantSettlementData;
  49. }
  50. /*
  51. * 新增结算记录
  52. * */
  53. public function addMerchantSettlement()
  54. {
  55. $merchantSettlementData = $this->commonFieldFilter();
  56. $result = $this->objMMerchantSettlement->addMerchantSettlement($merchantSettlementData);
  57. if ($result->isSuccess()) {
  58. parent::sendOutput($result->getData());
  59. } else {
  60. parent::sendOutput($result->getData(), $result->getErrorCode());
  61. }
  62. }
  63. /*
  64. * 结算记录状态
  65. * */
  66. public function updateMerchantSettlement()
  67. {
  68. $params = $this->request->getRawJson();
  69. if( empty($params['orderId'])){
  70. $this->sendOutput('参数为空', ErrorCode::$paramError );
  71. }
  72. $result = $this->objMMerchantSettlement->updateMerchantSettlement($params);
  73. if($result->isSuccess()){
  74. parent::sendOutput($result->getData());
  75. }else{
  76. parent::sendOutput($result->getData(), $result->getErrorCode());
  77. }
  78. }
  79. /*
  80. * 获取所有结算记录
  81. * */
  82. public function getAllMerchantSettlement()
  83. {
  84. $params = $this->request->getRawJson();
  85. if (empty($params)) {
  86. $this->sendOutput('参数为空', ErrorCode::$paramError);
  87. }
  88. $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
  89. $params['limit'] = $pageParams['limit'];
  90. $params['offset'] = $pageParams['offset'];
  91. // $params['operatorName'] = getArrayItem($params,'operatorName','');
  92. $params['MerchantId'] = getArrayItem($params,'MerchantId','');
  93. $params['goodName'] = getArrayItem($params,'goodName','');
  94. $params['settlementStatus'] = getArrayItem($params,'settlementStatus','');
  95. $params['start'] = getArrayItem($params,'start','');
  96. $params['end'] = getArrayItem($params,'end','');
  97. $returnData = $this->objMMerchantSettlement->getAllMerchantSettlement($params);
  98. if ($returnData->isSuccess()) {
  99. $returnData = $returnData->getData();
  100. $pageData = [
  101. 'pageIndex' => $params['page'],
  102. 'pageSize' => $params['pageSize'],
  103. 'pageTotal' => $returnData['total'],
  104. ];
  105. parent::sendOutput($returnData['data'], 0, $pageData);
  106. } else {
  107. parent::sendOutput($returnData->getData(), ErrorCode::$dberror);
  108. }
  109. }
  110. }