Holders.Class.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?php
  2. namespace JinDouYun\Controller\Holders;
  3. use JinDouYun\Controller\BaseController;
  4. use JinDouYun\Model\Customer\MCustomer;
  5. use JinDouYun\Model\Department\MStaff;
  6. use JinDouYun\Model\Holders\Holders as MHolders;
  7. use Mall\Framework\Core\ErrorCode;
  8. use Mall\Framework\Core\StatusCode;
  9. //股东管理
  10. class Holders extends BaseController
  11. {
  12. private $objMHolders;
  13. public function __construct($isCheckAcl = true, $isMustLogin = true)
  14. {
  15. parent::__construct($isCheckAcl, $isMustLogin);
  16. $this->objMHolders = new MHolders($this->onlineEnterpriseId);
  17. }
  18. // 添加股东
  19. public function add()
  20. {
  21. $name = $this->request->param('name');
  22. $number = $this->request->param('number');
  23. $address = $this->request->param('address');
  24. $remk = $this->request->param('remk');
  25. $id = $this->request->param('id');
  26. if ($name == '' || $number == '' || $address == '') $this->sendOutput('参数错误', ErrorCode::$paramError);
  27. $data = [
  28. 'name' => $name,
  29. 'number' => $number,
  30. 'address' => $address,
  31. 'remk' => $remk,
  32. 'updateTime' => Date('Y-m-d H:i:s', time()),
  33. 'id' => $id
  34. ];
  35. //添加股东
  36. if(empty($data["id"])){
  37. //初始化股东信息
  38. $data["shares"]=0;
  39. $data["dends"]=0;
  40. $data["createTime"]=Date('Y-m-d H:i:s', time());
  41. $data["en_id"]=$this->onlineEnterpriseId;
  42. $staff = new MCustomer($this->onlineEnterpriseId, $this->onlineUserId);
  43. $param = [
  44. 'mobile' => $number,
  45. 'name' => $name,
  46. 'type' => 1,
  47. 'enableStatus' => 5,
  48. 'contact' => array
  49. (
  50. 'area' => '',
  51. 'name' => '',
  52. 'mobile' => $number,
  53. 'provinceCode' => '',
  54. 'cityCode' => '',
  55. 'districtCode' => '',
  56. 'address' => '',
  57. ),
  58. 'is_shareholder'=> 1,
  59. 'provinceCode' => '',
  60. 'cityCode' => '',
  61. 'districtCode' => '',
  62. 'shopId' => '',
  63. 'longitude' => '',
  64. 'latitude' => '',
  65. 'password' => '',
  66. 'address' => '',
  67. 'managerMobile' => $number,
  68. 'avatar' => '',
  69. 'departmentId' => '',
  70. 'salesManId' => '',
  71. 'salesManCode' => '',
  72. 'salesManName' => '',
  73. 'birthday' => 0,
  74. 'remark' => '',
  75. 'deleteStatus' => 5,
  76. 'status' => '',
  77. 'reservoirId' => '',
  78. 'extend' => json_encode(['license' => '']),
  79. 'memberBalance' => '',
  80. 'recommenderType' => 3,
  81. 'recommenderId' => '',
  82. 'createTime' => time(),
  83. 'updateTime' => time(),
  84. ];
  85. $res1 = $staff->addCustomer($param)->getData();
  86. $data['us_id'] = $res1;
  87. }
  88. $res = $this->objMHolders->add($data);
  89. if ($res) {
  90. parent::sendOutput('添加成功');
  91. } else {
  92. parent::sendOutput('添加失败', ErrorCode::$paramError);
  93. }
  94. }
  95. // 获取股东信息
  96. public function Getinfo()
  97. {
  98. $id = $this->request->param('id');
  99. if (empty($id)) {
  100. $this->sendOutput('参数为空', ErrorCode::$paramError);
  101. }
  102. $params['id'] = intval($id);
  103. $params['en_id'] = $this->onlineEnterpriseId;
  104. $result = $this->objMHolders->getinfo($params);
  105. if ($result->isSuccess()) {
  106. parent::sendOutput($result->getData());
  107. } else {
  108. parent::sendOutput($result->getData(), $result->getErrorCode());
  109. }
  110. }
  111. // 获取股东列表
  112. public function Lst()
  113. {
  114. $params = $this->request->getRawJson();
  115. if (empty($params)) {
  116. parent::sendOutput('参数为空', ErrorCode::$paramError);
  117. }
  118. $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
  119. $selectParams['limit'] = $pageParams['limit'];
  120. if (isset($params['createTime']) && !empty($params['createTime'])) {
  121. $selectParams['createTime'] = $params['createTime'];
  122. }
  123. if (!empty($this->onlineEnterpriseId)) {
  124. $selectParams['en_id'] = $this->onlineEnterpriseId;
  125. }
  126. $result = $this->objMHolders->lst($selectParams);
  127. if ($result->isSuccess()) {
  128. $returnData = $result->getData();
  129. $pageData = [
  130. 'pageIndex' => $params['page'],
  131. 'pageSize' => $params['pageSize'],
  132. 'pageTotal' => $returnData['total'],
  133. ];
  134. parent::sendOutput($returnData['data'], 0, $pageData);
  135. } else {
  136. parent::sendOutput($result->getData(), ErrorCode::$dberror);
  137. }
  138. }
  139. /**
  140. * 增加减少股份
  141. * @return void
  142. */
  143. public function edit_shares()
  144. {
  145. $param = $this->request->getRawJson();
  146. if (empty($param['type'])) parent::sendOutput('选择类型', ErrorCode::$dberror);
  147. if (empty($param['number'])) parent::sendOutput('填写修改数量', ErrorCode::$dberror);
  148. if (empty($param['pm'])) parent::sendOutput('选择增减', ErrorCode::$dberror);
  149. if (empty($param['id'])) parent::sendOutput('参数为空', ErrorCode::$dberror);
  150. $res = $this->objMHolders->edit_shares($param);
  151. if ($res) {
  152. parent::sendOutput('修改成功');
  153. }
  154. parent::sendOutput('修改失败', ErrorCode::$dberror);
  155. }
  156. /**
  157. * 详情
  158. * @return void
  159. */
  160. public function details()
  161. {
  162. $where = [];
  163. $id = $this->request->param('id');
  164. if(!empty($id)){
  165. $where['id'] = $id;
  166. }
  167. $result = $this->objMHolders->details($where);
  168. if ($result->isSuccess()) {
  169. parent::sendOutput($result->getData());
  170. } else {
  171. parent::sendOutput($result->getData(), $result->getErrorCode());
  172. }
  173. }
  174. public function delete()
  175. {
  176. $id['id'] = $this->request->param('id');
  177. if (empty($id['id'])) {
  178. $this->sendOutput('参数为空', ErrorCode::$paramError);
  179. }
  180. $result = $this->objMHolders->delete($id);
  181. if ($result->isSuccess()) {
  182. parent::sendOutput($result->getData());
  183. } else {
  184. parent::sendOutput($result->getData(), $result->getErrorCode());
  185. }
  186. }
  187. }