MemberBalanceDetail.Class.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Gss
  5. * Date: 2021/3/26 0026
  6. * Time: 10:50
  7. */
  8. namespace JinDouYun\Controller\Customer;
  9. use Mall\Framework\Core\ErrorCode;
  10. use Mall\Framework\Core\StatusCode;
  11. use JinDouYun\Dao\BaseDao;
  12. use JinDouYun\Model\Customer\MMemberBalanceDetail;
  13. use JinDouYun\Controller\BaseController;
  14. class MemberBalanceDetail extends BaseController
  15. {
  16. private $objMMemberBalanceDetail;
  17. public function __construct($isCheckAcl = true, $isMustLogin = true)
  18. {
  19. parent::__construct($isCheckAcl, $isMustLogin);
  20. $this->objMMemberBalanceDetail = new MMemberBalanceDetail($this->onlineEnterpriseId, $this->onlineUserId);
  21. }
  22. /**
  23. * 添加和编辑会员明细公共字段处理方法
  24. *
  25. * @return array
  26. */
  27. public function commonFieldFilter()
  28. {
  29. $params = $this->request->getRawJson();
  30. if (empty($params)) {
  31. $this->sendOutput('参数为空', ErrorCode::$paramError);
  32. }
  33. $memberBalanceDetailData = [
  34. 'customerId' =>getArrayItem($params,'customerId',''),//int(10) DEFAULT NULL COMMENT '客户id',
  35. 'type' =>getArrayItem($params,'type',''),//int(1) NOT NULL COMMENT '金额类型 5收入/4支出',
  36. 'purpose' =>getArrayItem($params,'purpose',''),//varchar(255) NOT NULL COMMENT '用途',
  37. 'money' =>getArrayItem($params,'money',''),//decimal(15,4) NOT NULL COMMENT '变动金额',
  38. 'orderIds' =>getArrayItem($params,'orderIds',''),
  39. ];
  40. foreach ($memberBalanceDetailData as $key => $value) {
  41. if (empty($value) && $value !== 0) {
  42. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  43. }
  44. }
  45. $memberBalanceDetailData['remark'] = getArrayItem($params,'remark','');
  46. $memberBalanceDetailData['createTime'] = time();
  47. $memberBalanceDetailData['updateTime'] = time();
  48. return $memberBalanceDetailData;
  49. }
  50. /**
  51. * 新增会员明细
  52. */
  53. public function addMemberBalanceDetail()
  54. {
  55. $memberBalanceDetailData = $this->commonFieldFilter();
  56. $result = $this->objMMemberBalanceDetail->addMemberBalanceDetail($memberBalanceDetailData);
  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 getAllMemberBalanceDetail()
  67. {
  68. $params = $this->request->getRawJson();
  69. if (empty($params)) {
  70. $this->sendOutput('参数为空', ErrorCode::$paramError);
  71. }
  72. $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
  73. $params['limit'] = $pageParams['limit'];
  74. $params['offset'] = $pageParams['offset'];
  75. $params['start'] = getArrayItem($params,'start',"");
  76. $params['end'] = getArrayItem($params,'end',"");
  77. $returnData = $this->objMMemberBalanceDetail->getAllMemberBalanceDetail($params);
  78. if ($returnData->isSuccess()) {
  79. $returnData = $returnData->getData();
  80. $pageData = [
  81. 'pageIndex' => $params['page'],
  82. 'pageSize' => $params['pageSize'],
  83. 'pageTotal' => $returnData['total'],
  84. ];
  85. parent::sendOutput($returnData['data'], 0, $pageData);
  86. } else {
  87. parent::sendOutput($returnData->getData(), ErrorCode::$dberror);
  88. }
  89. }
  90. }