UserController.php 91 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: leo
  5. * Date: 2018/2/24
  6. * Time: 下午12:48
  7. */
  8. namespace backendApi\modules\v1\controllers;
  9. use backendApi\modules\v1\components\UserAuth;
  10. use backendApi\modules\v1\models\Admin;
  11. use backendApi\modules\v1\models\exportForms\BaUserExportForm;
  12. use backendApi\modules\v1\models\exportForms\UserExportForm;
  13. use backendApi\modules\v1\models\lists\shop\BaUserList;
  14. use backendApi\modules\v1\models\lists\user\BindList;
  15. use backendApi\modules\v1\models\lists\user\ChangeHighestEmpLevelList;
  16. use backendApi\modules\v1\models\lists\user\DecLevelList;
  17. use backendApi\modules\v1\models\lists\user\GroupList;
  18. use backendApi\modules\v1\models\lists\user\IndexList;
  19. use backendApi\modules\v1\models\lists\user\MoveList;
  20. use backendApi\modules\v1\models\lists\user\StatusAuditList;
  21. use backendApi\modules\v1\models\lists\user\SystemList;
  22. use backendApi\modules\v1\models\lists\user\TeamworkList;
  23. use backendApi\modules\v1\models\lists\user\YearHighestEmpLvList;
  24. use common\helpers\Date;
  25. use common\helpers\Form;
  26. use common\helpers\http\BackendToFrontendApi;
  27. use common\helpers\Log;
  28. use common\helpers\NetPoint;
  29. use common\helpers\Tool;
  30. use common\helpers\user\Balance;
  31. use common\helpers\user\Cash;
  32. use common\helpers\user\Info;
  33. use common\helpers\user\Status;
  34. use common\models\BaUser;
  35. use common\models\CompanyBank;
  36. use common\models\FlowBonus;
  37. use common\models\forms\AdminAddUserForm;
  38. use common\models\forms\BaUserBasicForm;
  39. use common\models\forms\ChangeShowEmpLvForm;
  40. use common\models\forms\CloseDecForm;
  41. use common\models\forms\CloseLoginForm;
  42. use common\models\forms\DecLevelLogForm;
  43. use common\models\forms\DecRoleLogForm;
  44. use common\models\forms\HighestEmpLevelLogForm;
  45. use common\models\forms\NetMoveForm;
  46. use common\models\forms\RechargeForm;
  47. use common\models\forms\ReconsumeForm;
  48. use common\models\forms\RegInfoAuditForm;
  49. use common\models\forms\UploadForm;
  50. use common\models\forms\UserBasicForm;
  51. use common\models\forms\UserBindForm;
  52. use common\models\forms\UserCloseForm;
  53. use common\models\forms\UserDecForm;
  54. use common\models\forms\UserForm;
  55. use common\models\forms\UserGroupForm;
  56. use common\models\forms\UserStatusForm;
  57. use common\models\forms\UserSystemForm;
  58. use common\models\forms\UserTeamworkForm;
  59. use common\models\forms\UserTransferPropForm;
  60. use common\models\Period;
  61. use common\models\ReconsumeAudit;
  62. use common\models\ReconsumePool;
  63. use common\models\RegInfoAudit;
  64. use common\models\RegType;
  65. use common\models\DecOrder;
  66. use common\models\DecRole;
  67. use common\models\EmployLevel;
  68. use common\models\OpenBank;
  69. use common\models\UserBind;
  70. use common\models\UserClose;
  71. use common\models\UserMove;
  72. use common\models\UserNetwork;
  73. use common\models\UserRelation;
  74. use common\models\UserStatusAudit;
  75. use common\models\UserSystem;
  76. use common\models\YearHighestEmpLv;
  77. use SebastianBergmann\CodeCoverage\Report\PHP;
  78. use sunmoon\phpspreadsheet\Excel;
  79. use Yii;
  80. use common\helpers\Cache;
  81. use common\models\User;
  82. use common\models\UserInfo;
  83. use common\models\UserTeamwork;
  84. use yii\base\Exception;
  85. use yii\web\HttpException;
  86. use yii\web\UploadedFile;
  87. class UserController extends BaseController
  88. {
  89. public $modelClass = User::class;
  90. public function behaviors()
  91. {
  92. $behaviors = parent::behaviors();
  93. //$behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_JSON;
  94. return $behaviors;
  95. }
  96. /**
  97. * 会员列表
  98. * @return mixed
  99. * @throws Exception
  100. * @throws HttpException
  101. */
  102. public function actionIndex()
  103. {
  104. $filter = $this->filterCondition([
  105. 'USER_NAME' => 'U.USER_NAME',
  106. 'REAL_NAME' => 'U.REAL_NAME',
  107. 'STATUS' => 'U.STATUS',
  108. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  109. 'CREATED_AT' => 'U.CREATED_AT',
  110. 'PERIOD_AT' => 'U.PERIOD_AT',
  111. 'DEC_LV_NAME' => 'U.DEC_LV',
  112. 'DEC_LV_UPDATED_AT' => 'U.DEC_LV_UPDATED_AT',
  113. 'LAST_DEC_LV_NAME' => 'U.LAST_DEC_LV',
  114. 'EMP_LV_NAME' => 'U.EMP_LV',
  115. 'LAST_EMP_LV_NAME' => 'U.LAST_EMP_LV',
  116. 'CROWN_LV_NAME' => 'U.CROWN_LV',
  117. 'LAST_CROWN_LV_NAME' => 'U.LAST_CROWN_LV',
  118. 'REC_USER_NAME' => 'RU.USER_NAME',
  119. 'CON_USER_NAME' => 'CU.USER_NAME',
  120. 'ID_CARD' => 'U.ID_CARD',
  121. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  122. 'SPOUSE_IDCARD' => 'U.SPOUSE_IDCARD',
  123. 'SYSTEM_NAME' => 'U.SYSTEM_ID',
  124. 'MOBILE' => 'U.MOBILE',
  125. 'TEL' => 'U.TEL',
  126. 'DEC_USER_NAME' => 'DU.USER_NAME',
  127. 'IS_DEC' => 'U.IS_DEC',
  128. 'IS_STUDIO' => 'U.IS_STUDIO',
  129. 'DEC_ROLE_NAME' => 'U.DEC_ROLE_ID',
  130. 'OPEN_BANK_NAME' => 'U.OPEN_BANK',
  131. 'BANK_AREA' => [
  132. 'FIELD' => ['U.BANK_PROVINCE', 'U.BANK_CITY', 'U.BANK_COUNTY'],
  133. 'BIND' => ['BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY'],
  134. ],
  135. 'BANK_ADDRESS' => 'U.BANK_ADDRESS',
  136. 'BANK_NO' => 'U.BANK_NO',
  137. 'SEX' => 'U.SEX',
  138. 'NATION_NAME' => 'U.NATION',
  139. 'AREA' => [
  140. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  141. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  142. ],
  143. 'ADDRESS' => 'U.ADDRESS',
  144. // 'IS_AUTO_WITHDRAW' => 'UI.IS_AUTO_WITHDRAW',
  145. 'VERIFIED' => 'U.VERIFIED',
  146. 'VERIFIED_AT' => 'U.VERIFIED_AT',
  147. // 'IS_DIRECT_SELLER' => 'U.IS_DIRECT_SELLER',
  148. // 'IS_SYSTEM_LEADER' => 'UI.IS_SYSTEM_LEADER',
  149. // 'IS_GROUP_LEADER' => 'UI.IS_GROUP_LEADER',
  150. 'ALLOW_TRANSFER' => 'UI.ALLOW_TRANSFER',
  151. ]);
  152. $condition = $filter['condition'];
  153. $params = $filter['params'];
  154. $condition .= ' AND UI.DELETED=0 ';
  155. $listObj = new IndexList();
  156. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  157. return static::notice($data);
  158. }
  159. /**
  160. * 导出会员列表
  161. * @return mixed
  162. * @throws \yii\db\Exception
  163. * @throws HttpException
  164. */
  165. public function actionIndexExport()
  166. {
  167. $filter = $this->filterCondition([
  168. 'USER_NAME' => 'U.USER_NAME',
  169. 'REAL_NAME' => 'U.REAL_NAME',
  170. 'STATUS' => 'U.STATUS',
  171. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  172. 'CREATED_AT' => 'U.CREATED_AT',
  173. 'PERIOD_AT' => 'U.PERIOD_AT',
  174. 'DEC_LV_NAME' => 'U.DEC_LV',
  175. 'DEC_LV_UPDATED_AT' => 'U.DEC_LV_UPDATED_AT',
  176. 'LAST_DEC_LV_NAME' => 'U.LAST_DEC_LV',
  177. 'EMP_LV_NAME' => 'U.EMP_LV',
  178. 'REC_USER_NAME' => 'RU.USER_NAME',
  179. 'CON_USER_NAME' => 'CU.USER_NAME',
  180. 'ID_CARD' => 'U.ID_CARD',
  181. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  182. 'SPOUSE_IDCARD' => 'U.SPOUSE_IDCARD',
  183. 'SYSTEM_NAME' => 'U.SYSTEM_ID',
  184. 'MOBILE' => 'U.MOBILE',
  185. 'TEL' => 'U.TEL',
  186. 'DEC_USER_NAME' => 'DU.USER_NAME',
  187. 'IS_DEC' => 'U.IS_DEC',
  188. 'IS_STUDIO' => 'U.IS_STUDIO',
  189. 'DEC_ROLE_NAME' => 'U.DEC_ROLE_ID',
  190. 'OPEN_BANK_NAME' => 'U.OPEN_BANK',
  191. 'BANK_AREA' => [
  192. 'FIELD' => ['U.BANK_PROVINCE', 'U.BANK_CITY', 'U.BANK_COUNTY'],
  193. 'BIND' => ['BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY'],
  194. ],
  195. 'BANK_ADDRESS' => 'U.BANK_ADDRESS',
  196. 'BANK_NO' => 'U.BANK_NO',
  197. 'SEX' => 'U.SEX',
  198. 'NATION_NAME' => 'U.NATION',
  199. 'AREA' => [
  200. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  201. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  202. ],
  203. 'ADDRESS' => 'U.ADDRESS',
  204. 'VERIFIED' => 'U.VERIFIED',
  205. 'VERIFIED_AT' => 'U.VERIFIED_AT',
  206. 'ALLOW_TRANSFER' => 'UI.ALLOW_TRANSFER',
  207. ]);
  208. $form = new UserExportForm();
  209. $result = $form->run($filter, 'Member_List');
  210. if (!$result) {
  211. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  212. }
  213. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  214. }
  215. /**
  216. * 空单会员列表
  217. * @return mixed
  218. * @throws Exception
  219. * @throws HttpException
  220. */
  221. public function actionEmptyList()
  222. {
  223. $filter = $this->filterCondition([
  224. 'USER_NAME' => 'U.USER_NAME',
  225. 'REAL_NAME' => 'U.REAL_NAME',
  226. 'STATUS' => 'U.STATUS',
  227. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  228. 'CREATED_AT' => 'U.CREATED_AT',
  229. 'PERIOD_AT' => 'U.PERIOD_AT',
  230. 'DEC_LV_NAME' => 'U.DEC_LV',
  231. 'DEC_LV_UPDATED_AT' => 'U.DEC_LV_UPDATED_AT',
  232. 'LAST_DEC_LV_NAME' => 'U.LAST_DEC_LV',
  233. 'EMP_LV_NAME' => 'U.EMP_LV',
  234. // 'HIGHEST_EMP_LV_NAME' => 'UI.HIGHEST_EMP_LV',
  235. // 'HIGHEST_EMP_LV_PERIOD' => 'UI.HIGHEST_EMP_LV_PERIOD',
  236. 'REC_USER_NAME' => 'RU.USER_NAME',
  237. 'CON_USER_NAME' => 'CU.USER_NAME',
  238. 'ID_CARD' => 'U.ID_CARD',
  239. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  240. 'SPOUSE_IDCARD' => 'U.SPOUSE_IDCARD',
  241. 'SYSTEM_NAME' => 'U.SYSTEM_ID',
  242. 'MOBILE' => 'U.MOBILE',
  243. 'TEL' => 'U.TEL',
  244. 'DEC_USER_NAME' => 'DU.USER_NAME',
  245. 'IS_DEC' => 'U.IS_DEC',
  246. 'DEC_ROLE_NAME' => 'U.DEC_ROLE_ID',
  247. 'OPEN_BANK_NAME' => 'U.OPEN_BANK',
  248. 'BANK_AREA' => [
  249. 'FIELD' => ['U.BANK_PROVINCE', 'U.BANK_CITY', 'U.BANK_COUNTY'],
  250. 'BIND' => ['BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY'],
  251. ],
  252. 'BANK_ADDRESS' => 'U.BANK_ADDRESS',
  253. 'BANK_NO' => 'U.BANK_NO',
  254. 'SEX' => 'U.SEX',
  255. 'NATION_NAME' => 'U.NATION',
  256. 'AREA' => [
  257. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  258. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  259. ],
  260. 'ADDRESS' => 'U.ADDRESS',
  261. // 'IS_AUTO_WITHDRAW' => 'UI.IS_AUTO_WITHDRAW',
  262. 'VERIFIED' => 'U.VERIFIED',
  263. 'VERIFIED_AT' => 'U.VERIFIED_AT',
  264. // 'IS_DIRECT_SELLER' => 'U.IS_DIRECT_SELLER',
  265. // 'IS_SYSTEM_LEADER' => 'UI.IS_SYSTEM_LEADER',
  266. // 'IS_GROUP_LEADER' => 'UI.IS_GROUP_LEADER',
  267. 'ALLOW_TRANSFER' => 'UI.ALLOW_TRANSFER',
  268. ]);
  269. $condition = $filter['condition'];
  270. $params = $filter['params'];
  271. $condition .= ' AND UI.DELETED=0 AND U.REG_FROM=0';
  272. $listObj = new IndexList();
  273. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  274. return static::notice($data);
  275. }
  276. /**
  277. * 点位绑定
  278. * @return mixed
  279. * @throws Exception
  280. * @throws HttpException
  281. */
  282. public function actionBind()
  283. {
  284. $filter = $this->filterCondition([
  285. 'userIds' => 'UI.USER_ID',
  286. 'MAIN_USER_NAME' => 'MUI.USER_NAME',
  287. 'HIGHEST_EMP_LV' => 'UI.HIGHEST_EMP_LV',
  288. 'CREATED_AT' => 'UB.CREATED_AT',
  289. 'UPDATED_AT' => 'UB.UPDATED_AT',
  290. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  291. 'UPDATE_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  292. ]);
  293. $condition = $filter['condition'];
  294. $params = $filter['params'];
  295. $condition .= ' AND UB.IS_DEL=0';
  296. $listObj = new BindList();
  297. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  298. return static::notice($data);
  299. }
  300. /**
  301. * 点位绑定导出
  302. * @return mixed
  303. * @throws \yii\db\Exception
  304. * @throws HttpException
  305. */
  306. public function actionBindExport()
  307. {
  308. $filter = $this->filterCondition([
  309. 'userIds' => 'UI.USER_ID',
  310. 'MAIN_USER_NAME' => 'MUI.USER_NAME',
  311. 'HIGHEST_EMP_LV' => 'UI.HIGHEST_EMP_LV',
  312. 'CREATED_AT' => 'UB.CREATED_AT',
  313. 'UPDATED_AT' => 'UB.UPDATED_AT',
  314. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  315. 'UPDATE_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  316. ]);
  317. $filter['condition'] .= ' AND UB.IS_DEL=0';
  318. $form = new UserExportForm();
  319. $result = $form->run($filter, '点位绑定');
  320. if (!$result) {
  321. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  322. }
  323. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  324. }
  325. /**
  326. * 添加点位绑定
  327. * @return mixed
  328. * @throws HttpException
  329. */
  330. public function actionBindAdd()
  331. {
  332. if (Yii::$app->request->isPost) {
  333. return parent::edit(UserBindForm::class, Yii::t('ctx', 'successfully'), 'add', ['add'], null, function ($form, $result) {
  334. // Log::adminHandle('为' . $form->userName . '添加点位绑定,主点位:' . $form->mainUserName);
  335. });
  336. }
  337. }
  338. /**
  339. * 编辑点位绑定
  340. * @return mixed
  341. * @throws Exception
  342. * @throws HttpException
  343. */
  344. public function actionBindEdit()
  345. {
  346. $id = Yii::$app->request->get('id');
  347. if (Yii::$app->request->isPost) {
  348. return parent::edit(UserBindForm::class, Yii::t('ctx', 'successfully'), 'edit', ['edit'], null, function ($form, $result) {
  349. //$userBaseInfo = Info::baseInfo($result->USER_ID);
  350. // Log::adminHandle('为' . $userBaseInfo['USER_NAME'] . '更改点位绑定关系');
  351. });
  352. }
  353. // 获得当前会员的用户名等信息
  354. $userBind = UserBind::findOneAsArray('ID=:ID AND IS_DEL=0', [':ID' => $id]);
  355. $userBinds = UserBind::findAllAsArray('MAIN_UID=:MAIN_UID AND IS_DEL=0', [':MAIN_UID' => $userBind['MAIN_UID']]);
  356. foreach ($userBinds as $key => $value) {
  357. $userBinds[$key]['BASE_INFO'] = Info::baseInfoZh($value['USER_ID']);
  358. }
  359. return static::notice(['userBinds' => $userBinds, 'mainUid' => $userBind['MAIN_UID']]);
  360. }
  361. /**
  362. * 删除点位绑定
  363. * @return mixed
  364. * @throws \yii\db\Exception
  365. * @throws HttpException
  366. */
  367. public function actionBindDelete()
  368. {
  369. $userBindForm = new UserBindForm();
  370. $result = static::delete(UserBind::class, function ($selected) use ($userBindForm) {
  371. $userBindForm->beforeDelete($selected);
  372. }, function ($selected) use ($userBindForm) {
  373. $userBindForm->delete($selected);
  374. }, false);
  375. return self::notice(Yii::t('ctx', 'successfully'));
  376. }
  377. /**
  378. * 生成点位合作的用户名
  379. * @return mixed
  380. * @throws \yii\base\InvalidConfigException
  381. * @throws HttpException
  382. */
  383. public function actionGenerateUserName()
  384. {
  385. // 获取用户名
  386. if (!$userName = Info::generateUserName('hz')) {
  387. return static::notice(Yii::t('ctx', 'failed'), 400);
  388. }
  389. return static::notice(['userName' => $userName]);
  390. }
  391. /**
  392. * 点位合作
  393. * @return mixed
  394. * @throws Exception
  395. * @throws HttpException
  396. */
  397. public function actionTeamwork()
  398. {
  399. $filter = $this->filterCondition([
  400. 'userIds' => 'UI.USER_ID',
  401. 'MAIN_USER_NAME' => 'MUI.USER_NAME',
  402. 'DIVIDE_PERCENT' => 'UT.DIVIDE_PERCENT',
  403. 'CREATE_REMARK' => 'UT.CREATE_REMARK',
  404. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  405. 'CREATED_AT' => 'UT.CREATED_AT',
  406. 'PERIOD_NUM' => 'UT.PERIOD_NUM',
  407. 'UPDATE_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  408. 'UPDATED_AT' => 'UT.UPDATED_AT',
  409. 'UPDATED_PERIOD' => 'UT.PERIOD_NUM',
  410. ]);
  411. $condition = $filter['condition'];
  412. $params = $filter['params'];
  413. $condition .= ' AND UT.IS_DEL=0';
  414. $listObj = new TeamworkList();
  415. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  416. return static::notice($data);
  417. }
  418. /**
  419. * 点位合作导出
  420. * @return mixed
  421. * @throws \yii\db\Exception
  422. * @throws HttpException
  423. */
  424. public function actionTeamworkExport()
  425. {
  426. $filter = $this->filterCondition([
  427. 'userIds' => 'UI.USER_ID',
  428. 'MAIN_USER_NAME' => 'MUI.USER_NAME',
  429. 'DIVIDE_PERCENT' => 'UT.DIVIDE_PERCENT',
  430. 'CREATE_REMARK' => 'UT.CREATE_REMARK',
  431. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  432. 'CREATED_AT' => 'UT.CREATED_AT',
  433. 'PERIOD_NUM' => 'UT.PERIOD_NUM',
  434. 'UPDATE_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  435. 'UPDATED_AT' => 'UT.UPDATED_AT',
  436. 'UPDATED_PERIOD' => 'UT.PERIOD_NUM',
  437. ]);
  438. $filter['condition'] .= ' AND UT.IS_DEL=0';
  439. $form = new UserExportForm();
  440. $result = $form->run($filter, '点位合作');
  441. if (!$result) {
  442. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  443. }
  444. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  445. }
  446. /**
  447. * 添加点位合作
  448. * @return mixed
  449. * @throws HttpException
  450. */
  451. public function actionTeamworkAdd()
  452. {
  453. if (Yii::$app->request->isPost) {
  454. return parent::edit(UserTeamworkForm::class, Yii::t('ctx', 'successfully'), 'add', ['add'], null, function ($form, $result) {
  455. // Log::adminHandle('为' . $form->mainUserName . '添加合作点位,姓名:' . $form->userName, 0, $result->USER_ID, $form->userName);
  456. });
  457. }
  458. // 所有民族
  459. $allNation = Yii::$app->params['nation'];
  460. // 所有开户行
  461. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  462. return static::notice(['allNation' => $allNation, 'allOpenBank' => $allOpenBank]);
  463. }
  464. /**
  465. * 编辑点位合作
  466. * @return mixed
  467. * @throws Exception
  468. * @throws HttpException
  469. */
  470. public function actionTeamworkEdit()
  471. {
  472. $id = Yii::$app->request->get('id');
  473. if (Yii::$app->request->isPost) {
  474. return parent::edit(UserTeamworkForm::class, Yii::t('ctx', 'successfully'), 'changeDivide', ['changeDivide'], null, function ($form, $result) {
  475. foreach ($result['logs'] as $k => $value) {
  476. $userName = Info::getUserNameByUserId($k);
  477. // Log::adminHandle('为' . $userName . '编辑合作点位分成比例为' . $value , 1, $k, $userName);
  478. }
  479. });
  480. }
  481. // 获得当前会员的用户名等信息
  482. if (!$userTeamwork = UserTeamwork::findOneAsArray('ID=:ID AND IS_DEL=0', [':ID' => $id], 'MAIN_UID')) {
  483. return static::notice('点位合作不存在', 404);
  484. }
  485. $teamwork = UserTeamwork::findAllAsArray('MAIN_UID=:MAIN_UID AND IS_DEL=0', [':MAIN_UID' => $userTeamwork['MAIN_UID']], 'ID,USER_ID,MAIN_UID,DIVIDE_PERCENT');
  486. foreach ($teamwork as $key => $value) {
  487. $userInfo = Info::baseInfo($value['USER_ID']);
  488. $teamwork[$key]['USER_NAME'] = $userInfo['USER_NAME'];
  489. $teamwork[$key]['REAL_NAME'] = $userInfo['REAL_NAME'];
  490. }
  491. unset($userInfo);
  492. return static::notice($teamwork);
  493. }
  494. /**
  495. * 删除方法
  496. * @return mixed
  497. * @throws \yii\db\Exception
  498. * @throws HttpException
  499. */
  500. public function actionTeamworkDelete()
  501. {
  502. return static::notice('无法删除', 400);
  503. $result = static::delete(UserTeamwork::class, null, function ($selected) {
  504. UserTeamworkForm::delete($selected);
  505. // Log::adminHandle('删除合作点位');
  506. }, false);
  507. return $result;
  508. }
  509. /**
  510. * 会员体系
  511. * @return mixed
  512. * @throws Exception
  513. * @throws HttpException
  514. */
  515. public function actionSystem()
  516. {
  517. $filter = $this->filterCondition([
  518. 'userIds' => 'US.LEADER_UID',
  519. 'SYSTEM_NAME' => 'US.SYSTEM_NAME',
  520. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  521. 'PERIOD_NUM' => 'US.PERIOD_NUM',
  522. 'CREATED_AT' => 'US.CREATED_AT',
  523. 'UPDATE_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  524. 'UPDATE_PERIOD_NUM' => 'US.UPDATE_PERIOD_NUM',
  525. 'UPDATED_AT' => 'US.UPDATED_AT',
  526. 'IS_DEL' => 'US.IS_DEL',
  527. 'CREATE_REMARK' => 'US.CREATE_REMARK',
  528. ]);
  529. $condition = $filter['condition'];
  530. $params = $filter['params'];
  531. $listObj = new SystemList();
  532. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  533. return static::notice($data);
  534. }
  535. /**
  536. * 体系管理导出
  537. * @return mixed
  538. * @throws \yii\db\Exception
  539. * @throws HttpException
  540. */
  541. public function actionSystemExport()
  542. {
  543. $filter = $this->filterCondition([
  544. 'userIds' => 'US.LEADER_UID',
  545. 'SYSTEM_NAME' => 'US.SYSTEM_NAME',
  546. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  547. 'PERIOD_NUM' => 'US.PERIOD_NUM',
  548. 'CREATED_AT' => 'US.CREATED_AT',
  549. 'UPDATE_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  550. 'UPDATE_PERIOD_NUM' => 'US.UPDATE_PERIOD_NUM',
  551. 'UPDATED_AT' => 'US.UPDATED_AT',
  552. 'IS_DEL' => 'US.IS_DEL',
  553. 'CREATE_REMARK' => 'US.CREATE_REMARK',
  554. ]);
  555. $form = new UserExportForm();
  556. $result = $form->run($filter, '体系管理');
  557. if (!$result) {
  558. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  559. }
  560. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  561. }
  562. /**
  563. * 添加体系
  564. * @return mixed
  565. * @throws \yii\base\InvalidConfigException
  566. * @throws \yii\db\Exception
  567. * @throws \yii\httpclient\Exception
  568. * @throws HttpException
  569. */
  570. public function actionSystemAdd()
  571. {
  572. if (Yii::$app->request->post()) {
  573. $formModel = new UserSystemForm();
  574. $formModel->scenario = 'add';
  575. if ($formModel->load(Yii::$app->request->post(), '') && $formModel->edit()) {
  576. // Log::adminHandle('添加体系' . Yii::$app->request->post('systemName'));
  577. return static::notice(Yii::t('ctx', 'successfully'));
  578. } else {
  579. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  580. }
  581. }
  582. }
  583. /**
  584. * 编辑体系
  585. * @return mixed
  586. * @throws \yii\base\InvalidConfigException
  587. * @throws \yii\httpclient\Exception
  588. * @throws HttpException
  589. */
  590. public function actionSystemEdit()
  591. {
  592. $id = Yii::$app->request->get('id');
  593. if (Yii::$app->request->isPost) {
  594. return parent::edit(UserSystemForm::class, Yii::t('ctx', 'successfully'), 'edit', ['edit'], null, function ($form, $result) {
  595. // Log::adminHandle('编辑体系' . $result['SYSTEM_NAME']);
  596. });
  597. }
  598. if (!$oneData = UserSystem::find()->select('US.*, UI.USER_NAME AS LEADER_NAME')->where('US.ID=:ID AND US.IS_DEL=0', [':ID' => $id])->from(UserSystem::tableName() . ' AS US')->join('LEFT JOIN', UserInfo::tableName() . ' AS UI', 'US.LEADER_UID=UI.USER_ID')->asArray()->one()) {
  599. return static::notice('体系已撤销或不存在', 400);
  600. }
  601. return static::notice(['oneData' => $oneData]);
  602. }
  603. /**
  604. * 恢复体系
  605. * @return mixed
  606. * @throws HttpException
  607. */
  608. public function actionSystemRenew()
  609. {
  610. return parent::edit(UserSystemForm::class, Yii::t('ctx', 'successfully'), 'renewSystem', [
  611. 'renewSystem',
  612. ], null, function ($form, $result) {
  613. // Log::adminHandle('编辑体系' . $result['SYSTEM_NAME']);
  614. });
  615. }
  616. /**
  617. * 删除方法
  618. * @return mixed
  619. * @throws \yii\db\Exception
  620. * @throws HttpException
  621. */
  622. public function actionSystemDelete()
  623. {
  624. $userSystemForm = new UserSystemForm();
  625. $result = static::delete(UserSystem::class, function ($selected) use ($userSystemForm) {
  626. $userSystemForm->beforeDelete($selected);
  627. }, function ($selected) use ($userSystemForm) {
  628. $userSystemForm->delete($selected);
  629. }, false);
  630. return self::notice(Yii::t('ctx', 'successfully'));
  631. }
  632. /**
  633. * 团队领导人列表
  634. * @return mixed
  635. * @throws Exception
  636. * @throws HttpException
  637. */
  638. public function actionGroup()
  639. {
  640. $filter = $this->filterCondition([
  641. 'userName' => 'UI.USER_NAME',
  642. ]);
  643. $condition = $filter['condition'];
  644. $params = $filter['params'];
  645. $condition .= ' AND PUI.IS_GROUP_LEADER=1';
  646. $listObj = new GroupList();
  647. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  648. return static::notice($data);
  649. }
  650. /**
  651. * 团队领导人列表导出
  652. * @return mixed
  653. * @throws \yii\db\Exception
  654. * @throws HttpException
  655. */
  656. public function actionGroupExport()
  657. {
  658. $filter = $this->filterCondition([
  659. 'userName' => 'UI.USER_NAME',
  660. ]);
  661. $filter['condition'] .= ' AND PUI.IS_GROUP_LEADER=1';
  662. $form = new UserExportForm();
  663. $result = $form->run($filter, '团队领导人列表');
  664. if (!$result) {
  665. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  666. }
  667. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  668. }
  669. /**
  670. * 会员移网记录
  671. * @return mixed
  672. * @throws Exception
  673. * @throws HttpException
  674. */
  675. public function actionMove()
  676. {
  677. $filter = $this->filterCondition([
  678. // 'userIds' => 'UM.USER_ID',
  679. 'filterStatus' => 'UM.AUDIT_STATUS',
  680. 'MOVE_USER_NAME' => 'CU.USER_NAME',
  681. 'MOVE_REAL_NAME' => 'CU.REAL_NAME',
  682. // 'moveType' => 'UM.TYPE',
  683. // 'FROM_USER_NAME' => 'FUI.USER_NAME',
  684. // 'TO_USER_NAME' => 'TUI.USER_NAME',
  685. 'MOVE_PERCENT_SHOW' => 'UM.MOVE_PERCENT',
  686. // 'STARTED_AT' => 'UM.STARTED_AT',
  687. // 'ENDED_AT' => 'UM.ENDED_AT',
  688. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  689. 'PERIOD_NUM' => 'UM.PERIOD_NUM',
  690. // 'CREATED_AT' => 'UM.CREATED_AT',
  691. 'AUDIT_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  692. 'MOVE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  693. // 'AUDIT_PERIOD_NUM' => 'UM.AUDIT_PERIOD_NUM',
  694. 'AUDITED_AT' => 'UM.AUDITED_AT',
  695. // 'CREATE_REMARK' => 'UM.CREATE_REMARK',
  696. ]);
  697. $condition = $filter['condition'];
  698. $params = $filter['params'];
  699. $listObj = new MoveList();
  700. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  701. return static::notice($data);
  702. }
  703. /**
  704. * 移网管理导出
  705. * @return mixed
  706. * @throws \yii\db\Exception
  707. * @throws HttpException
  708. */
  709. public function actionMoveExport()
  710. {
  711. $filter = $this->filterCondition([
  712. //'userIds' => 'UM.USER_ID',
  713. 'filterStatus' => 'UM.AUDIT_STATUS',
  714. 'moveType' => 'UM.TYPE',
  715. 'FROM_USER_NAME' => 'FUI.USER_NAME',
  716. 'TO_USER_NAME' => 'TUI.USER_NAME',
  717. //'MOVE_PERCENT_SHOW' => 'UM.MOVE_PERCENT',
  718. //'STARTED_AT' => 'UM.STARTED_AT',
  719. //'ENDED_AT' => 'UM.ENDED_AT',
  720. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  721. 'PERIOD_NUM' => 'UM.PERIOD_NUM',
  722. 'CREATED_AT' => 'UM.CREATED_AT',
  723. 'AUDIT_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  724. //'AUDIT_PERIOD_NUM' => 'UM.AUDIT_PERIOD_NUM',
  725. 'AUDITED_AT' => 'UM.AUDITED_AT',
  726. //'CREATE_REMARK' => 'UM.CREATE_REMARK',
  727. ]);
  728. $form = new UserExportForm();
  729. $result = $form->run($filter, 'Move_Network'); // 移网管理
  730. if (!$result) {
  731. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  732. }
  733. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  734. }
  735. /**
  736. * 申请移网
  737. * @return mixed
  738. * @throws \yii\base\InvalidConfigException
  739. * @throws \yii\httpclient\Exception
  740. * @throws HttpException
  741. */
  742. public function actionMoveAdd()
  743. {
  744. if (Yii::$app->request->isPost) {
  745. return parent::edit(NetMoveForm::class, Yii::t('ctx', 'successfully'), 'add', ['add'], null, function ($form, $result) { // 移网申请成功
  746. // $user = User::getBaseInfoFromRedis($result['USER_ID']);
  747. // Log::adminHandle('申请为' . $user['USER_NAME'] . '移网', 1, $result['USER_ID'], $user['USER_NAME']);
  748. });
  749. }
  750. }
  751. /**
  752. * 获取全部移网类型
  753. * @return mixed
  754. * @throws HttpException
  755. */
  756. public function actionMoveNetType()
  757. {
  758. return static::notice(['netType' => UserMove::getNetWork()]);
  759. }
  760. /**
  761. * 获取移网数据
  762. * @return mixed
  763. * @throws Exception
  764. * @throws HttpException
  765. */
  766. public function actionMoveGet()
  767. {
  768. $id = Yii::$app->request->get('id');
  769. $userMove = UserMove::find()->where('ID=:ID', [':ID' => $id])->asArray()->one();
  770. if (!$userMove) {
  771. return static::notice('Data not exists', 400);
  772. }
  773. $userMove['BASE_INFO'] = Info::baseInfoWithNet($userMove['USER_ID']);
  774. $toUserInfo = Info::baseInfoZh($userMove['TO_UID']);
  775. return static::notice(['moveId' => $userMove['ID'], 'moveUserName' => $userMove['BASE_INFO']['USER_NAME'], 'baseInfo' => $userMove['BASE_INFO'], 'type' => $userMove['TYPE'], 'toConUserName' => $toUserInfo['USER_NAME'], 'toConRealName' => $toUserInfo['REAL_NAME'], 'location' => $userMove['LOCATION'], 'remark' => $userMove['CREATE_REMARK']]);
  776. }
  777. /**
  778. * 修改移网数据
  779. * @return mixed
  780. * @throws \yii\db\Exception
  781. * @throws HttpException
  782. */
  783. public function actionMoveEdit()
  784. {
  785. $formModel = new NetMoveForm();
  786. $formModel->scenario = 'edit';
  787. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->edit()) {
  788. $user = Info::baseInfoZh($result['USER_ID']);
  789. // Log::adminHandle('修改' . $user['USER_NAME'] . '移网录入数据', 1, $result['USER_ID'], $user['USER_NAME']);
  790. return static::notice(Yii::t('ctx', 'successfully')); // 修改移网录入数据完成
  791. }
  792. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  793. }
  794. /**
  795. * 审核通过移网数据(实际的移网动作在这里,异步操作)
  796. * @return mixed
  797. * @throws \yii\db\Exception
  798. * @throws HttpException
  799. */
  800. public function actionMovePass()
  801. {
  802. $formModel = new NetMoveForm();
  803. $formModel->scenario = 'pass';
  804. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->pass()) {
  805. $user = Info::baseInfoZh($result['USER_ID']);
  806. // Log::adminHandle('审核通过移网数据', 1, $result['USER_ID'], $user['USER_NAME']);
  807. return static::notice("It's on the move. Please wait"); // 正在移动中,请稍候
  808. }
  809. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  810. }
  811. /**
  812. * 审核移网数据
  813. * @return mixed
  814. * @throws \yii\base\InvalidConfigException
  815. * @throws \yii\db\Exception
  816. * @throws \yii\httpclient\Exception
  817. * @throws HttpException
  818. */
  819. public function actionMoveAudit()
  820. {
  821. $formModel = new NetMoveForm();
  822. $formModel->scenario = 'changeAudit';
  823. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->changeAudit()) {
  824. // Log::adminHandle('审核移网数据');
  825. return static::notice(Yii::t('ctx', 'successfully')); // 审核移网数据完成
  826. }
  827. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  828. }
  829. /**
  830. * 删除移网数据
  831. * @return mixed
  832. * @throws \yii\db\Exception
  833. * @throws HttpException
  834. */
  835. public function actionMoveDelete()
  836. {
  837. $netMoveForm = new NetMoveForm();
  838. $result = static::delete(UserMove::class, function ($selected) use ($netMoveForm) {
  839. $netMoveForm->beforeDelete($selected);
  840. }, function ($selected) use ($netMoveForm) {
  841. $netMoveForm->delete($selected);
  842. }, true);
  843. return $result;
  844. }
  845. /**
  846. * 会员的基础用户信息
  847. * @return mixed
  848. * @throws HttpException
  849. */
  850. public function actionFullInfo()
  851. {
  852. $userName = Yii::$app->request->get('userName');
  853. $userInfo = Info::getBaseUserByUserName($userName);
  854. if($userInfo){
  855. $decLevelConfig = Cache::getDecLevelConfig();
  856. $userInfo['LEVEL_NAME'] = isset($decLevelConfig[$userInfo['DEC_LV']])?$decLevelConfig[$userInfo['DEC_LV']]['LEVEL_NAME'] : '';
  857. $userInfo['BONUS'] = Balance::getAvailableBalance($userInfo['ID']);
  858. $userInfo['CASH'] = Cash::getAvailableBalance($userInfo['ID']);
  859. $userInfo['RECONSUME_POINTS'] = Balance::getBalanceReconsumePoints($userInfo['ID']);
  860. $userInfo['EXCHANGE_POINTS'] = Balance::getBalanceExchangePoints($userInfo['ID']);
  861. $userInfo['TOURISM_POINTS'] = Balance::getAccountBalance($userInfo['ID'], 'tourism_points');
  862. $userInfo['GARAGE_POINTS'] = Balance::getAccountBalance($userInfo['ID'], 'garage_points');
  863. $userInfo['VILLA_POINTS'] = Balance::getAccountBalance($userInfo['ID'], 'villa_points');
  864. return static::notice($userInfo);
  865. }else{
  866. return static::notice('Member number does not exist', 400);//会员编号不存在
  867. }
  868. }
  869. /**
  870. * 会员的基本信息编号名称
  871. * @return mixed
  872. * @throws HttpException
  873. */
  874. public function actionBaseInfo()
  875. {
  876. $userName = Yii::$app->request->get('userName');
  877. $baseUser = Info::getBaseUserByUserName($userName);
  878. return static::notice($baseUser);
  879. }
  880. /**
  881. * 点位合作主点位分成比例
  882. * @return mixed
  883. * @throws HttpException
  884. */
  885. public function actionMainDivide()
  886. {
  887. $userId = Yii::$app->request->get('userId');
  888. $divide = 100;
  889. if ($teamwork = UserTeamwork::findOneAsArray('USER_ID=:USER_ID AND MAIN_UID=:USER_ID AND IS_DEL=0', [':USER_ID' => $userId], 'DIVIDE_PERCENT')) {
  890. $divide = $teamwork['DIVIDE_PERCENT'];
  891. }
  892. return static::notice($divide);
  893. }
  894. /**
  895. * 获取子公司
  896. * @return mixed
  897. * @throws HttpException
  898. */
  899. public function actionGetSubCom()
  900. {
  901. $areaSelected = Yii::$app->request->get('areaSelected');
  902. $location = [];
  903. return static::notice($location);
  904. }
  905. /**
  906. * 判断是否在同一推荐网络
  907. * @return mixed
  908. * @throws HttpException
  909. */
  910. public function actionChkRelation()
  911. {
  912. $userName = Yii::$app->request->get('userName');
  913. $toUserName = Yii::$app->request->get('toUserName');
  914. $userId = Info::getUserIdByUserName($userName);
  915. $toUserId = Info::getUserIdByUserName($toUserName);
  916. $is = 0;
  917. if (UserRelation::isParentUser($userId, $toUserId)) {
  918. $is = 1;
  919. }
  920. $toUser = Info::baseInfoWithNetAndBalance($toUserId);
  921. $real_name = $toUser ? $toUser['REAL_NAME'] : '';
  922. return static::notice(['is' => $is, 'real_name' => $real_name]);
  923. }
  924. /**
  925. * 获取当前期数
  926. * @return mixed
  927. * @throws HttpException
  928. */
  929. public function actionGetPeriodNum()
  930. {
  931. $period = Period::instance();
  932. $periodNum = $period->getNowPeriodNum();
  933. //上期是否挂网
  934. $lastPeriodNum = $periodNum - 1;
  935. $periodArr = [$periodNum];
  936. if ($period->isSent($lastPeriodNum)) {
  937. $periodArr[] = $periodNum + 1;
  938. } else {
  939. $periodArr[] = $lastPeriodNum;
  940. }
  941. return static::notice($periodArr);
  942. }
  943. /**
  944. * 关停列表
  945. * @return mixed
  946. * @throws HttpException
  947. */
  948. // public function actionClose()
  949. // {
  950. // $filter = $this->filterCondition([
  951. // 'userIds' => 'UC.USER_ID',
  952. // 'filterStatus' => 'UC.AUDIT_STATUS',
  953. // ]);
  954. // $condition = $filter['condition'];
  955. // $params = $filter['params'];
  956. // $data = UserClose::lists($condition, $params, [
  957. // 'from' => UserClose::tableName() . ' AS UC',
  958. // 'orderBy' => 'UC.CREATED_AT DESC',
  959. // ]);
  960. // // 获取全部移网类型
  961. // $data['type'] = [
  962. // UserClose::TYPE_GT => '关停',
  963. // UserClose::TYPE_TF => '停发',
  964. // ];
  965. // $auditStatus = array_column(\Yii::$app->params['auditStatus'], null, 'value');
  966. // foreach ($data['list'] as $key => $value) {
  967. // $data['list'][$key]['BASE_INFO'] = Info::baseInfoZh($value['USER_ID']);
  968. // $data['list'][$key]['CREATE_ADMIN_NAME'] = Admin::getAdminNameById($value['ADMIN_ID']);
  969. // $data['list'][$key]['AUDIT_ADMIN_NAME'] = Admin::getAdminNameById($value['AUDIT_ADMIN_ID']);
  970. // $data['list'][$key]['STATUS_NAME'] = $auditStatus[$value['AUDIT_STATUS']]['label'];
  971. // }
  972. // return static::notice($data);
  973. //
  974. // }
  975. /**
  976. * 申请关停或停发
  977. * @return mixed
  978. * @throws HttpException
  979. */
  980. // public function actionCloseAdd()
  981. // {
  982. // if (Yii::$app->request->isPost) {
  983. // return parent::edit(UserCloseForm::class, '申请成功', null, null, null, function ($form, $result) {
  984. // $user = User::getBaseInfoFromRedis($result['USER_ID']);
  985. // $type = '';
  986. // switch ($result['TYPE']) {
  987. // case UserClose::TYPE_GT:
  988. // $type = '关停';
  989. // break;
  990. // case UserClose::TYPE_TF:
  991. // $type = '停发';
  992. // break;
  993. // }
  994. // // Log::adminHandle('申请' . $user['USER_NAME'] . $type, 1, $result['USER_ID'], $user['USER_NAME']);
  995. // });
  996. // }
  997. // // 获取全部移网类型
  998. // $type = [
  999. // UserClose::TYPE_GT => '关停',
  1000. // UserClose::TYPE_TF => '停发',
  1001. // ];
  1002. // return static::notice(['type' => $type]);
  1003. // }
  1004. /**
  1005. * 审核关停或停发
  1006. * @return mixed
  1007. * @throws \yii\db\Exception
  1008. * @throws HttpException
  1009. */
  1010. // public function actionCloseAudit()
  1011. // {
  1012. // $formModel = new UserCloseForm();
  1013. // $formModel->scenario = 'audit';
  1014. // if ($formModel->load(Yii::$app->request->get(), '') && $result = $formModel->audit()) {
  1015. // $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1016. // $type = '';
  1017. // switch ($result['TYPE']) {
  1018. // case UserClose::TYPE_GT:
  1019. // $type = '关停';
  1020. // break;
  1021. // case UserClose::TYPE_TF:
  1022. // $type = '停发';
  1023. // break;
  1024. // }
  1025. // // Log::adminHandle('审核' . $user['USER_NAME'] . $type, 1, $result['USER_ID'], $user['USER_NAME']);
  1026. // return static::notice('操作成功');
  1027. // }
  1028. // return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1029. // }
  1030. /**
  1031. * 添加会员
  1032. * @return mixed
  1033. * @throws HttpException
  1034. */
  1035. public function actionUserAdd()
  1036. {
  1037. if (Yii::$app->request->isPost) {
  1038. return parent::edit(AdminAddUserForm::class, Yii::t('ctx', 'successfully'), null, null, null, function ($form, $result) {//添加成功
  1039. // Log::adminHandle('后台添加会员:' . $result['USER_NAME'], 1, $result['ID'], $result['USER_NAME']);
  1040. });
  1041. }
  1042. // 获取所有报单中心级别
  1043. $allDecRole = DecRole::getAllData();
  1044. // 所有民族
  1045. $allNation = Yii::$app->params['nation'];
  1046. // 所有开户行
  1047. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  1048. if (!$userName = Info::generateUserName('NG')) {
  1049. return static::notice('Failed to generate member number', 400);//会员编号生成失败
  1050. }
  1051. return static::notice(['allDecRole' => $allDecRole, 'allNation' => $allNation, 'allOpenBank' => $allOpenBank, 'userName' => $userName]);
  1052. }
  1053. /**
  1054. * 分页导入excel文件到待导入数据的表中
  1055. * @return mixed
  1056. * @throws HttpException
  1057. */
  1058. public function actionImportUsersToExcelTable()
  1059. {
  1060. // 先上传到服务器文件
  1061. if (\Yii::$app->request->isPost) {
  1062. $excelImportId = Yii::$app->request->post('excelImportId');
  1063. $rowCount = Yii::$app->request->post('rowCount');
  1064. $startRow = Yii::$app->request->post('startRow');
  1065. $limit = Yii::$app->request->post('limit', 1000);
  1066. $errorMsg = '';
  1067. try {
  1068. $excel = new \common\helpers\Excel();
  1069. $result = $excel->pageImportDataFromExcel('addUser', $excelImportId, $rowCount, $startRow, $limit);
  1070. } catch (Exception $e) {
  1071. $result = false;
  1072. $errorMsg = $e->getMessage();
  1073. }
  1074. // 还有数据
  1075. if ($result === 1) {
  1076. return static::notice(['finish' => false]);
  1077. } elseif ($result === 0) {
  1078. return static::notice(['finish' => true]);
  1079. } else {
  1080. return static::notice('An error occurred:' . $errorMsg, 400);//发生错误
  1081. }
  1082. }
  1083. }
  1084. public function actionModifyPassword() {
  1085. $form = new UserBasicForm();
  1086. $form->scenario = 'modifyPassword';
  1087. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->edit()){
  1088. return static::notice(Yii::t('ctx', 'successfully')); // 密码修改成功
  1089. } else {
  1090. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1091. }
  1092. }
  1093. /**
  1094. * 个人资料获取
  1095. * @return mixed
  1096. * @throws HttpException
  1097. */
  1098. public function actionProfileGet() {
  1099. $id = Yii::$app->request->get('id');
  1100. $userInfo = User::findOneAsArray('ID=:ID', [':ID' => $id]);
  1101. if (!$userInfo) {
  1102. return static::notice('Data does not exist', 400);//数据不存在
  1103. }
  1104. $allNation = \Yii::$app->params['nation'];
  1105. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  1106. $data['allNation'] = $allNation;
  1107. $data['allOpenBank'] = $allOpenBank;
  1108. $data['userInfo'] = [
  1109. 'userId' => $userInfo['ID'],
  1110. 'nation' => \Yii::$app->params['nation'][$userInfo['NATION']]['name']??'',
  1111. 'realName' => $userInfo['REAL_NAME'],
  1112. 'idCard' => $userInfo['ID_CARD'],
  1113. 'mobile' => $userInfo['MOBILE'],
  1114. 'openBank' => $userInfo['OPEN_BANK'],
  1115. 'bankAddress' => $userInfo['BANK_ADDRESS'],
  1116. 'bankNo' => $userInfo['BANK_NO'],
  1117. ];
  1118. return static::notice($data);
  1119. }
  1120. public function actionModifyProfile() {
  1121. $form = new UserBasicForm();
  1122. $form->scenario = 'modifyProfile';
  1123. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->modifyProfile()){
  1124. return static::notice(Yii::t('ctx', 'successfully'));//个人资料修改成功
  1125. } else {
  1126. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1127. }
  1128. }
  1129. public function actionModifyStatus() {
  1130. $form = new UserBasicForm();
  1131. $form->scenario = 'modifyStatus';
  1132. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->modifyStatus()){
  1133. return static::notice(Yii::t('ctx', 'successfully'));//会员状态修改成功
  1134. } else {
  1135. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1136. }
  1137. }
  1138. /**
  1139. * @return mixed
  1140. * @throws \yii\db\Exception
  1141. * @throws HttpException
  1142. */
  1143. public function actionIsModifyPasswordStatus() {
  1144. $form = new UserBasicForm();
  1145. $form->scenario = 'isModifyPasswordStatus';
  1146. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->isModifyPasswordStatus()){
  1147. return static::notice(Yii::t('ctx', 'successfully'));//状态修改成功
  1148. } else {
  1149. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1150. }
  1151. }
  1152. /**
  1153. * 分页把待导入表中的数据导入到真正的数据中
  1154. * @return mixed
  1155. * @throws HttpException
  1156. */
  1157. public function actionImportUsersAdd()
  1158. {
  1159. if (\Yii::$app->request->isPost) {
  1160. $excelImportId = Yii::$app->request->post('excelImportId');
  1161. $offset = Yii::$app->request->post('offset');
  1162. $limit = Yii::$app->request->post('limit', 1000);
  1163. $errorMsg = '';
  1164. try {
  1165. $excel = new \common\helpers\Excel();
  1166. $result = $excel->pageImportDataFromExcelTable('addUser', $excelImportId, $offset, $limit);
  1167. } catch (Exception $e) {
  1168. $result = false;
  1169. $errorMsg = $e->getMessage();
  1170. }
  1171. // 还有数据
  1172. if ($result === 1) {
  1173. return static::notice(['finish' => false]);
  1174. } elseif ($result === 0) {
  1175. return static::notice(['finish' => true]);
  1176. } else {
  1177. return static::notice('An error occurred:' . $errorMsg, 400);//发生错误
  1178. }
  1179. }
  1180. }
  1181. /**
  1182. * 判断是否满足删除条件
  1183. * @return mixed
  1184. * @throws HttpException
  1185. */
  1186. public function actionChkDelUser()
  1187. {
  1188. $userName = Yii::$app->request->get('userName');
  1189. if (!$uid = Info::getUserIdByUserName($userName)) {
  1190. return static::notice('user does not exist' . $userName, 400);//用户不存在
  1191. }
  1192. if (UserInfo::findOneAsArray('REC_UID=:REC_UID AND DELETED=0', [':REC_UID' => $uid], 'USER_ID')) {
  1193. return static::notice('This member has developed other members and cannot be deleted', 400);//此会员已开拓其它会员不可以删除
  1194. }
  1195. if (UserInfo::findOneAsArray('CON_UID=:CON_UID AND DELETED=0', [':CON_UID' => $uid], 'USER_ID')) {
  1196. return static::notice('This member has been placed with other members and cannot be deleted', 400);//此会员已安置其它会员不可以删除
  1197. }
  1198. if (User::findOneAsArray('DEC_ID=:DEC_ID AND DELETED=0', [':DEC_ID' => $uid], 'ID')) {
  1199. return static::notice('This member has submitted a bill and other members cannot delete it', 400);//此会员已报单其它会员不可以删除
  1200. }
  1201. if (DecOrder::findOneAsArray('USER_ID=:TO_USER_ID OR TO_USER_ID=:TO_USER_ID', [':TO_USER_ID' => $uid], 'ID')) {
  1202. return static::notice('This member has submitted a bill and cannot be deleted', 400);//此会员已报单不可以删除
  1203. }
  1204. $info = Info::baseInfoWithNet($uid);
  1205. if ($info['REG_FROM'] == 1) {
  1206. return static::notice('This member is not empty and cannot be deleted', 400);//此会员不是空单无法删除
  1207. }
  1208. $sentMaxPeriodNum = Period::sentMaxPeriodNum();
  1209. if ($info['PERIOD_AT'] <= $sentMaxPeriodNum) {
  1210. return static::notice('The number of enrollment periods of this member is less than or equal to the number of online periods', 400);//此会员加入期数小于等于已挂网期数
  1211. }
  1212. if (User::find()->where('ID=:ID AND VERIFIED=1', [':ID' => $uid])->exists()) {
  1213. return static::notice('This member has been authenticated by real name and cannot be deleted', 400);//此会员已实名认证无法删除
  1214. }
  1215. if (User::find()->where('ID=:ID AND SUB_COM_LEADER=1', [':ID' => $uid])->exists()) {
  1216. return static::notice('This member is a branch leader and cannot be deleted', 400);//此会员是分公司领导人无法删除
  1217. }
  1218. if (UserInfo::find()->where('USER_ID=:USER_ID AND (IS_GROUP_LEADER=1 OR IS_SYSTEM_LEADER=1 OR IS_BIND=1 OR IS_TEAM=1)', [':USER_ID' => $uid])->exists()) {
  1219. return static::notice('This member cannot be deleted due to the following conditions: Team Leader / system leader / point binding / point cooperation', 400);//此会员存在以下情况无法删除,团队领导人/体系领导人/点位绑定/点位合作
  1220. }
  1221. if (FlowBonus::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $uid], 'ID')) {
  1222. return static::notice('This member has generated a balance flow, which cannot be deleted', 400);//该会员产生过余额流水无法删除
  1223. }
  1224. if (UserMove::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $uid], 'ID')) {
  1225. return static::notice('The member cannot be deleted due to network migration', 400);//该会员发生过移网无法删除
  1226. }
  1227. return static::notice($info);
  1228. }
  1229. /**
  1230. * 删除空单会员
  1231. * @return mixed
  1232. * @throws Exception
  1233. * @throws HttpException
  1234. */
  1235. public function actionUserDel()
  1236. {
  1237. $formModel = new AdminAddUserForm();
  1238. $formModel->scenario = 'userDel';
  1239. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->userDel()) {
  1240. $user = User::getBaseInfoFromRedis($result);
  1241. //// Log::adminHandle('删除空单会员' . $user['USER_NAME'], 1, $result, $user['USER_NAME']);
  1242. // Log::adminHandle('删除空单会员' . $user['USER_NAME'], 1);
  1243. return static::notice(Yii::t('ctx', 'successfully'));//删除空单会员完成
  1244. }
  1245. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1246. }
  1247. /**
  1248. * 复销列表
  1249. * @return mixed
  1250. * @throws HttpException
  1251. */
  1252. public function actionReConsumeList()
  1253. {
  1254. // $filter = $this->filterCondition(ReconsumePool::tableName(), [
  1255. // 'userName' => ['UI.USER_NAME', '='],
  1256. // ]);
  1257. $condition = '';
  1258. $params = [];
  1259. $data = ReconsumePool::lists($condition, $params, [
  1260. 'select' => 'RP.USER_ID,RP.UNUSED_PV,RP.UNUSED_MONTH',
  1261. 'from' => ReconsumePool::tableName() . ' AS RP',
  1262. 'join' => [
  1263. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'UI.USER_ID=RP.USER_ID']
  1264. ],
  1265. 'orderBy' => 'RP.USER_ID ASC'
  1266. ]);
  1267. foreach ($data['list'] as $key => $value) {
  1268. $userBaseInfo = Cache::getUserBaseInfo($value['USER_ID']);
  1269. $data['list'][$key]['USER_NAME'] = $userBaseInfo['USER_NAME'];
  1270. $data['list'][$key]['REAL_NAME'] = $userBaseInfo['REAL_NAME'];
  1271. $data['list'][$key]['DEC_LV'] = Info::getDecLv($value['USER_ID']);
  1272. $data['list'][$key]['EMP_LV'] = Info::getEmpLv($value['USER_ID']);
  1273. }
  1274. return static::notice($data);
  1275. }
  1276. /**
  1277. * 筛选用户
  1278. * 前端传过来的get参数类似于
  1279. * [
  1280. * 'USER_NAME' => 'like,test',
  1281. * 'CREATED_AT' => '>=,2018-11-10,date'
  1282. * ]
  1283. * @return mixed
  1284. * @throws HttpException
  1285. */
  1286. public function actionFilterUser()
  1287. {
  1288. $filter = $this->filterCondition([
  1289. 'USER_NAME' => 'U.USER_NAME',
  1290. 'REAL_NAME' => 'U.REAL_NAME',
  1291. 'STATUS' => 'U.STATUS',
  1292. 'STATUS_AT' => 'U.STATUS_AT',
  1293. 'STATUS_NAME' => 'U.STATUS',
  1294. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  1295. 'CREATED_AT' => 'U.CREATED_AT',
  1296. 'USER_CREATED_AT' => 'U.CREATED_AT',
  1297. 'PERIOD_AT' => 'U.PERIOD_AT',
  1298. 'DEC_LV' => 'U.DEC_LV',
  1299. 'DEC_LV_NAME' => 'U.DEC_LV',
  1300. 'DEC_LV_UPDATED_AT' => 'U.DEC_LV_UPDATED_AT',
  1301. 'LAST_DEC_LV' => 'U.LAST_DEC_LV',
  1302. 'LAST_DEC_LV_NAME' => 'U.LAST_DEC_LV',
  1303. 'EMP_LV' => 'U.EMP_LV',
  1304. 'EMP_LV_NAME' => 'U.EMP_LV',
  1305. //'ID_TYPE' => 'U.ID_TYPE',
  1306. 'ID_CARD' => 'U.ID_CARD',
  1307. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  1308. 'SPOUSE_IDCARD' => 'U.SPOUSE_IDCARD',
  1309. 'SUB_COM_ID' => 'U.SUB_COM_ID',
  1310. 'SUB_COM_NAME' => 'U.SUB_COM_ID',
  1311. 'MOBILE' => 'U.MOBILE',
  1312. 'TEL' => 'U.TEL',
  1313. 'DEC_DEC_ROLE_ID' => 'UD.DEC_ROLE_ID',
  1314. 'DEC_DEC_ROLE_NAME' => 'UD.DEC_ROLE_ID',
  1315. 'DEC_USER_NAME' => 'UD.USER_NAME',
  1316. 'IS_DEC' => 'U.IS_DEC',
  1317. 'DEC_ROLE_ID' => 'U.DEC_ROLE_ID',
  1318. 'DEC_ROLE_NAME' => 'U.DEC_ROLE_ID',
  1319. 'OPEN_BANK' => 'U.OPEN_BANK',
  1320. 'OPEN_BANK_NAME' => 'U.OPEN_BANK',
  1321. 'BANK_AREA' => [
  1322. 'FIELD' => ['U.BANK_PROVINCE', 'U.BANK_CITY', 'U.BANK_COUNTY'],
  1323. 'BIND' => ['BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY'],
  1324. ],
  1325. 'BANK_ADDRESS' => 'U.BANK_ADDRESS',
  1326. 'BANK_NO' => 'U.BANK_NO',
  1327. 'SEX' => 'U.SEX',
  1328. 'NATION' => 'U.NATION',
  1329. 'NATION_NAME' => 'U.NATION',
  1330. 'AREA' => [
  1331. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  1332. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  1333. ],
  1334. 'ADDRESS' => 'U.ADDRESS',
  1335. 'VERIFIED' => 'U.VERIFIED',
  1336. 'VERIFIED_AT' => 'U.VERIFIED_AT',
  1337. 'IS_DIRECT_SELLER' => 'U.IS_DIRECT_SELLER',
  1338. 'PART_FUNC_CLOSED' => 'U.PART_FUNC_CLOSED',
  1339. //'BIRTHDAY' => 'U.BIRTHDAY',
  1340. 'DEC_CLOSED' => 'U.DEC_CLOSED',
  1341. 'NOT_OPERATING' => 'U.NOT_OPERATING',
  1342. ]);
  1343. $condition = $filter['condition'];
  1344. $params = $filter['params'];
  1345. $data = User::lists($condition, $params, [
  1346. 'select' => 'U.*, UD.USER_NAME AS UD_USER_NAME',
  1347. 'from' => User::tableName() . ' AS U',
  1348. 'join' => [
  1349. ['LEFT JOIN', User::tableName() . ' AS UD', 'U.DEC_ID=UD.ID'],
  1350. ],
  1351. 'orderBy' => 'U.CREATED_AT DESC',
  1352. ]);
  1353. return static::notice($data);
  1354. }
  1355. /**
  1356. * 会员级别变动记录
  1357. * @return mixed
  1358. * @throws \yii\base\Exception
  1359. * @throws HttpException
  1360. */
  1361. public function actionDecLevelList()
  1362. {
  1363. $filter = $this->filterCondition([
  1364. 'USER_NAME' => 'CU.USER_NAME',
  1365. 'CREATED_AT' => 'LL.CREATED_AT',
  1366. 'ADMIN_NAME' => 'ADM.ADMIN_NAME',
  1367. ]);
  1368. $condition = $filter['condition'];
  1369. $params = $filter['params'];
  1370. $listObj = new DecLevelList();
  1371. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  1372. return static::notice($data);
  1373. }
  1374. /**
  1375. * 调整会员级别报单级别
  1376. * @return mixed
  1377. * @throws HttpException
  1378. */
  1379. public function actionChangeUserDecLevel()
  1380. {
  1381. if (Yii::$app->request->isPost) {
  1382. return parent::edit(DecLevelLogForm::class, Yii::t('ctx', 'successfully'), 'adminChange', [ // 修改会员级别成功
  1383. 'adminChange',
  1384. ], null, function ($form, $result) {
  1385. //$userName = Info::getUserNameByUserId($result['ID']);
  1386. // Log::adminHandle('后台调整会员级别级别:'.$userName, 1, $result['ID'], $userName);
  1387. });
  1388. }
  1389. }
  1390. /**
  1391. * 调整会员级别报单级别
  1392. * @return mixed
  1393. * @throws HttpException
  1394. */
  1395. public function actionChangeUserDecRole()
  1396. {
  1397. if (Yii::$app->request->isPost) {
  1398. return parent::edit(DecRoleLogForm::class, Yii::t('ctx', 'successfully'), 'adminChange', [//修改报单中心级别成功
  1399. 'adminChange',
  1400. ], null, function ($form, $result) {
  1401. //$userName = Info::getUserNameByUserId($result['ID']);
  1402. // Log::adminHandle('后台调整会员级别级别:'.$userName, 1, $result['ID'], $userName);
  1403. });
  1404. }
  1405. }
  1406. /**
  1407. * 修改会员前台显示聘级
  1408. * @return mixed
  1409. * @throws HttpException
  1410. */
  1411. public function actionChangeShowEmpLevel()
  1412. {
  1413. if (Yii::$app->request->isPost) {
  1414. return parent::edit(ChangeShowEmpLvForm::class, Yii::t('ctx', 'successfully'), 'adminChange', [//修改会员前台显示聘级成功
  1415. 'adminChange',
  1416. ], null, function ($form, $result) {
  1417. //$userName = Info::getUserNameByUserId($result['ID']);
  1418. // Log::adminHandle('后台调整会员级别级别:'.$userName, 1, $result['ID'], $userName);
  1419. });
  1420. }
  1421. }
  1422. /**
  1423. * 注册信息管理
  1424. * @return mixed
  1425. * @throws Exception
  1426. * @throws HttpException
  1427. */
  1428. public function actionRegInfo()
  1429. {
  1430. $filter = $this->filterCondition([
  1431. 'userIds' => 'UI.USER_ID',
  1432. 'regType' => 'UI.REG_TYPE',
  1433. ]);
  1434. $condition = $filter['condition'];
  1435. $params = $filter['params'];
  1436. $condition .= ' AND UI.DELETED=0';
  1437. $data = UserInfo::lists($condition, $params, [
  1438. 'orderBy' => 'UI.CREATED_AT DESC',
  1439. 'from' => UserInfo::tableName() . ' AS UI',
  1440. ]);
  1441. foreach ($data['list'] as $key => $value) {
  1442. $data['list'][$key]['BASE_INFO'] = Info::baseInfoZh($value['USER_ID']);
  1443. $data['list'][$key]['AUDIT_INFO'] = RegInfoAudit::find()->from(RegInfoAudit::tableName() . ' AS RIA')->select('RIA.*,ADM.ADMIN_NAME CREATE_ADMIN_NAME,ADMA.ADMIN_NAME AUDIT_ADMIN_NAME')->where('USER_ID=:USER_ID AND AUDIT_STATUS=:AUDIT_STATUS', [':USER_ID' => $value['USER_ID'], ':AUDIT_STATUS' => \Yii::$app->params['auditStatus']['true']['value']])->join('LEFT JOIN', Admin::tableName() . ' AS ADM', 'ADM.ID=RIA.CREATE_ADMIN')->join('LEFT JOIN', Admin::tableName() . ' AS ADMA', 'ADMA.ID=RIA.AUDIT_ADMIN')->orderBy('AUDITED_AT DESC')->asArray()->one();
  1444. }
  1445. return static::notice($data);
  1446. }
  1447. /**
  1448. * 注册信息管理中提交修改注册信息
  1449. * @return mixed
  1450. * @throws HttpException
  1451. */
  1452. public function actionRegInfoEdit()
  1453. {
  1454. if (Yii::$app->request->isPost) {
  1455. return parent::edit(RegInfoAuditForm::class, 'The registration information modification has been submitted successfully and will take effect after approval', 'editRegInfo', ['editRegInfo'], null, function ($form, $result) {//注册信息修改提交成功,审核后生效
  1456. $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1457. // Log::adminHandle('申请为' . $user['USER_NAME'] . '注册信息修改', 1, $result['USER_ID'], $user['USER_NAME']);
  1458. });
  1459. }
  1460. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  1461. return static::notice(['allOpenBank' => $allOpenBank]);
  1462. }
  1463. /**
  1464. * 会员注册信息审核
  1465. * @return mixed
  1466. * @throws Exception
  1467. * @throws HttpException
  1468. */
  1469. public function actionRegInfoAudit()
  1470. {
  1471. $filter = $this->filterCondition([
  1472. 'userIds' => 'UI.USER_ID',
  1473. 'createdAt' => 'RIA.CREATED_AT',
  1474. 'regType' => 'RIA.REG_TYPE',
  1475. 'filterStatus' => 'RIA.AUDIT_STATUS',
  1476. ]);
  1477. $condition = $filter['condition'];
  1478. $params = $filter['params'];
  1479. $data = RegInfoAudit::lists($condition, $params, [
  1480. 'orderBy' => 'RIA.CREATED_AT DESC',
  1481. 'from' => RegInfoAudit::tableName() . ' AS RIA',
  1482. 'join' => [
  1483. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'RIA.USER_ID=UI.USER_ID'],
  1484. ],
  1485. ]);
  1486. $auditStatus = array_column(\Yii::$app->params['auditStatus'], null, 'value');
  1487. foreach ($data['list'] as $key => $value) {
  1488. $data['list'][$key]['BASE_INFO'] = Info::baseInfoZh($value['USER_ID']);
  1489. $data['list'][$key]['CREATE_ADMIN_NAME'] = Admin::getAdminNameById($value['CREATE_ADMIN']);
  1490. $data['list'][$key]['AUDIT_ADMIN_NAME'] = Admin::getAdminNameById($value['AUDIT_ADMIN']);
  1491. $data['list'][$key]['STATUS_NAME'] = $auditStatus[$value['AUDIT_STATUS']]['label'];
  1492. }
  1493. return static::notice($data);
  1494. }
  1495. /**
  1496. * 会员注册信息添加
  1497. * @return mixed
  1498. * @throws HttpException
  1499. */
  1500. public function actionRegInfoAuditAdd()
  1501. {
  1502. if (Yii::$app->request->isPost) {
  1503. return parent::edit(RegInfoAuditForm::class, Yii::t('ctx', 'successfully'), 'add', ['add'], null, function ($form, $result) {//注册信息录入成功
  1504. $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1505. // Log::adminHandle('申请为' . $user['USER_NAME'] . '注册信息录入', 1, $result['USER_ID'], $user['USER_NAME']);
  1506. });
  1507. }
  1508. }
  1509. /**
  1510. * 会员注册信息添加获取
  1511. * @return mixed
  1512. * @throws HttpException
  1513. */
  1514. public function actionRegInfoAuditAddOpt()
  1515. {
  1516. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  1517. return static::notice(['allOpenBank' => $allOpenBank]);
  1518. }
  1519. /**
  1520. * 会员注册信息获取
  1521. * @return mixed
  1522. * @throws Exception
  1523. * @throws HttpException
  1524. */
  1525. public function actionRegInfoAuditGet()
  1526. {
  1527. $id = Yii::$app->request->get('id');
  1528. $regInfo = RegInfoAudit::findOneAsArray('ID=:ID', [':ID' => $id]);
  1529. if (!$regInfo) {
  1530. return static::notice('Data does not exist', 400);//数据不存在
  1531. }
  1532. $regInfo['BASE_INFO'] = Info::baseInfoZh($regInfo['USER_ID']);
  1533. $regInfo['REG_EXPIRES'] = Date::convert($regInfo['REG_EXPIRES']);
  1534. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  1535. $companyBank = CompanyBank::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $regInfo['USER_ID']]);
  1536. $bank = ['openBank' => null, 'bankAreaSelected' => [], 'bankAddress' => null, 'openName' => null, 'bankNo' => null];
  1537. if ($companyBank) $bank = ['openBank' => $companyBank['OPEN_BANK'], 'bankAreaSelected' => [$companyBank['BANK_PROVINCE'], $companyBank['BANK_CITY'], $companyBank['BANK_COUNTY']], 'bankAddress' => $companyBank['BANK_ADDRESS'], 'openName' => $companyBank['OPEN_NAME'], 'bankNo' => $companyBank['BANK_NO']];
  1538. return static::notice(['form' => ['id' => $regInfo['ID'], 'userId' => $regInfo['USER_ID'], 'baseInfo' => $regInfo['BASE_INFO'], 'type' => $regInfo['REG_TYPE'], 'regName' => $regInfo['REG_NAME'], 'creditCode' => $regInfo['CREDIT_CODE'], 'premises' => $regInfo['PREMISES'], 'legalPerson' => $regInfo['LEGAL_PERSON'], 'regExpires' => $regInfo['REG_EXPIRES'], 'createRemark' => $regInfo['CREATE_REMARK'], 'companyBank' => $bank], 'allOpenBank' => $allOpenBank]);
  1539. }
  1540. /**
  1541. * 会员注册信息修改
  1542. * @return mixed
  1543. * @throws \yii\db\Exception
  1544. * @throws HttpException
  1545. */
  1546. public function actionRegInfoAuditEdit()
  1547. {
  1548. $formModel = new RegInfoAuditForm();
  1549. $formModel->scenario = 'edit';
  1550. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->edit()) {
  1551. $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1552. // Log::adminHandle('修改' . $user['USER_NAME'] . '注册信息录入数据', 1, $result['USER_ID'], $user['USER_NAME']);
  1553. return static::notice(Yii::t('ctx', 'successfully'));//修改注册信息录入数据完成
  1554. }
  1555. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1556. }
  1557. /**
  1558. * 会员注册信息审核
  1559. * @return mixed
  1560. * @throws \yii\db\Exception
  1561. * @throws HttpException
  1562. */
  1563. public function actionRegInfoAuditAudit()
  1564. {
  1565. $formModel = new RegInfoAuditForm();
  1566. $formModel->scenario = 'audit';
  1567. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
  1568. $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1569. // Log::adminHandle('审核' . $user['USER_NAME'] . '注册信息', 1, $result['USER_ID'], $user['USER_NAME']);
  1570. return static::notice(Yii::t('ctx', 'successfully'));//审核注册信息完成
  1571. }
  1572. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1573. }
  1574. /**
  1575. * 分页导入excel文件到待导入数据的表中
  1576. * @return mixed
  1577. * @throws HttpException
  1578. */
  1579. public function actionImportRegInfoToExcelTable()
  1580. {
  1581. // 先上传到服务器文件
  1582. if (\Yii::$app->request->isPost) {
  1583. $excelImportId = Yii::$app->request->post('excelImportId');
  1584. $rowCount = Yii::$app->request->post('rowCount');
  1585. $startRow = Yii::$app->request->post('startRow');
  1586. $limit = Yii::$app->request->post('limit', 1000);
  1587. $errorMsg = '';
  1588. try {
  1589. $excel = new \common\helpers\Excel();
  1590. $result = $excel->pageImportDataFromExcel('regInfo', $excelImportId, $rowCount, $startRow, $limit);
  1591. } catch (Exception $e) {
  1592. $result = false;
  1593. $errorMsg = $e->getMessage();
  1594. }
  1595. // 还有数据
  1596. if ($result === 1) {
  1597. return static::notice(['finish' => false]);
  1598. } elseif ($result === 0) {
  1599. return static::notice(['finish' => true]);
  1600. } else {
  1601. return static::notice('发生错误:' . $errorMsg, 400);
  1602. }
  1603. }
  1604. }
  1605. /**
  1606. * 分页把待导入表中的数据导入到真正的数据中
  1607. * @return mixed
  1608. * @throws Exception
  1609. * @throws HttpException
  1610. */
  1611. public function actionImportRegInfo()
  1612. {
  1613. if (\Yii::$app->request->isPost) {
  1614. $excelImportId = Yii::$app->request->post('excelImportId');
  1615. $offset = Yii::$app->request->post('offset');
  1616. $limit = Yii::$app->request->post('limit', 1000);
  1617. $errorMsg = '';
  1618. $excel = new \common\helpers\Excel();
  1619. $result = $excel->pageImportDataFromExcelTable('regInfo', $excelImportId, $offset, $limit);
  1620. // 还有数据
  1621. if ($result === 1) {
  1622. return static::notice(['finish' => false]);
  1623. } elseif ($result === 0) {
  1624. return static::notice(['finish' => true]);
  1625. } else {
  1626. return static::notice('发生错误:' . $errorMsg, 400);
  1627. }
  1628. }
  1629. }
  1630. /**
  1631. * 会员注册信息删除
  1632. * @return mixed
  1633. * @throws \yii\db\Exception
  1634. * @throws HttpException
  1635. */
  1636. public function actionRegInfoAuditDelete()
  1637. {
  1638. $result = static::delete(RegInfoAudit::class, null, function ($selected) {
  1639. RegInfoAuditForm::delete($selected);
  1640. // Log::adminHandle('删除注册信息');
  1641. }, true);
  1642. return $result;
  1643. }
  1644. /**
  1645. * 禁止登录
  1646. * @return mixed
  1647. * @throws HttpException
  1648. */
  1649. public function actionCloseLogin()
  1650. {
  1651. if (Yii::$app->request->isPost) {
  1652. return parent::edit(CloseLoginForm::class, Yii::t('ctx', 'successfully'), 'single', ['single'], null, function ($form, $result) {
  1653. // $appStr = CloseLoginForm::$apps[$form->shopOrBonus];
  1654. // $closeStr = CloseLoginForm::$closeSwitch[$form->isClose];
  1655. // $typeStr = CloseLoginForm::$types[$form->type];
  1656. // $remark = $form->remark;
  1657. // Log::adminHandle('为会员' . $form->userName . $typeStr . $closeStr . $appStr, 1, $result, $form->userName, $remark);
  1658. });
  1659. }
  1660. }
  1661. /**
  1662. * 禁止登陆类型获取
  1663. * @return mixed
  1664. * @throws HttpException
  1665. */
  1666. public function actionCloseLoginGet()
  1667. {
  1668. return static::notice(['types' => CloseLoginForm::$types, 'closeSwitch' => CloseLoginForm::$closeSwitch]);
  1669. }
  1670. /**
  1671. * 关闭地区登录
  1672. * @return mixed
  1673. * @throws HttpException
  1674. */
  1675. public function actionCloseAreaLogin()
  1676. {
  1677. if (Yii::$app->request->isPost) {
  1678. return parent::edit(CloseLoginForm::class, Yii::t('ctx', 'successfully'), 'area', ['area'], null, function ($form, $result) {
  1679. // $appStr = CloseLoginForm::$apps[$form->shopOrBonus];
  1680. // $closeStr = CloseLoginForm::$closeSwitch[$form->isClose];
  1681. // $province = $form->areaSelected[0] ?? '';
  1682. // $city = $form->areaSelected[1] ?? '';
  1683. // $county = $form->areaSelected[2] ?? '';
  1684. // $remark = $form->remark;
  1685. // Log::adminHandle('区域'.$appStr.$closeStr.':' . $province . $city . $county, 1, null, null, $remark);
  1686. });
  1687. }
  1688. return static::notice(['types' => CloseLoginForm::$types, 'closeSwitch' => CloseLoginForm::$closeSwitch]);
  1689. }
  1690. /**
  1691. * 批量登录管理
  1692. * @return mixed
  1693. * @throws HttpException
  1694. */
  1695. public function actionBatchCloseLogin()
  1696. {
  1697. if (Yii::$app->request->isPost) {
  1698. return parent::edit(CloseLoginForm::class, Yii::t('ctx', 'successfully'), 'batch', ['batch'], null, function ($form, $result) {
  1699. /*$appStr = CloseLoginForm::$apps[$form->shopOrBonus];
  1700. $closeStr = CloseLoginForm::$closeSwitch[$form->isClose];
  1701. $remark = $form->remark;
  1702. if (is_array($result)) {
  1703. foreach ($result as $value) {
  1704. // 获取其中一个人的会员编号
  1705. $userName = Info::getUserNameByUserId($value);
  1706. // Log::adminHandle('为会员' . $userName . $closeStr . $appStr, 1, $value, $userName, $remark);
  1707. }
  1708. }*/
  1709. });
  1710. }
  1711. return static::notice(['types' => CloseLoginForm::$types, 'closeSwitch' => CloseLoginForm::$closeSwitch]);
  1712. }
  1713. /**
  1714. * 关闭报单信息获取
  1715. * @return mixed
  1716. * @throws HttpException
  1717. */
  1718. public function actionCloseDecGet()
  1719. {
  1720. return static::notice(['types' => CloseDecForm::$types, 'closeSwitch' => CloseDecForm::$closeSwitch]);
  1721. }
  1722. /**
  1723. * 关闭报单
  1724. * @return mixed
  1725. * @throws HttpException
  1726. */
  1727. public function actionCloseDec()
  1728. {
  1729. if (Yii::$app->request->isPost) {
  1730. return parent::edit(CloseDecForm::class, Yii::t('ctx', 'successfully'), 'single', ['single'], null, function ($form, $result) {
  1731. // $closeStr = CloseDecForm::$closeSwitch[$form->isClose];
  1732. // $typeStr = CloseDecForm::$types[$form->type];
  1733. // $remark = $form->remark;
  1734. // Log::adminHandle('为会员' . $form->userName . $typeStr . $closeStr, 1, $result, $form->userName, $remark);
  1735. });
  1736. }
  1737. }
  1738. /**
  1739. * 批量关闭报单
  1740. * @return mixed
  1741. * @throws HttpException
  1742. */
  1743. public function actionBatchCloseDec()
  1744. {
  1745. if (Yii::$app->request->isPost) {
  1746. return parent::edit(CloseDecForm::class, Yii::t('ctx', 'successfully'), 'batch', ['batch'], null, function ($form, $result) {
  1747. /*$closeStr = CloseDecForm::$closeSwitch[$form->isClose];
  1748. $remark = $form->remark;
  1749. if (is_array($result)) {
  1750. foreach ($result as $value) {
  1751. // 获取其中一个人的会员编号
  1752. $userName = Info::getUserNameByUserId($value);
  1753. // Log::adminHandle('为会员' . $userName . $closeStr, 1, $value, $userName, $remark);
  1754. }
  1755. }*/
  1756. });
  1757. }
  1758. return static::notice(['types' => CloseDecForm::$types, 'closeSwitch' => CloseDecForm::$closeSwitch]);
  1759. }
  1760. /**
  1761. * 按地区关闭报单
  1762. * @return mixed
  1763. * @throws HttpException
  1764. */
  1765. public function actionCloseAreaDec()
  1766. {
  1767. if (Yii::$app->request->isPost) {
  1768. return parent::edit(CloseDecForm::class, Yii::t('ctx', 'successfully'), 'area', ['area'], null, function ($form, $result) {
  1769. // $closeStr = CloseDecForm::$closeSwitch[$form->isClose];
  1770. // $province = $form->areaSelected[0] ?? '';
  1771. // $city = $form->areaSelected[1] ?? '';
  1772. // $county = $form->areaSelected[2] ?? '';
  1773. // $remark = $form->remark;
  1774. // Log::adminHandle('区域'.$closeStr.':' . $province . $city . $county, 1, null, null, $remark);
  1775. });
  1776. }
  1777. return static::notice(['types' => CloseDecForm::$types, 'closeSwitch' => CloseDecForm::$closeSwitch]);
  1778. }
  1779. /**
  1780. * 会员状态管理
  1781. * @return mixed
  1782. * @throws Exception
  1783. * @throws HttpException
  1784. */
  1785. // public function actionStatusAuditList()
  1786. // {
  1787. // $filter = $this->filterCondition([
  1788. // 'userIds' => 'UI.USER_ID',
  1789. // 'filterStatus' => 'USA.AUDIT_STATUS',
  1790. // 'SYSTEM_NAME' => 'UI.SYSTEM_ID',
  1791. // 'ORI_STATUS_NAME' => 'USA.ORI_VALUE',
  1792. // 'STATUS_NAME' => 'USA.STATUS_VALUE',
  1793. // 'PERIOD_NUM' => 'USA.PERIOD_NUM',
  1794. // 'CREATE_REMARK' => 'USA.CREATE_REMARK',
  1795. // 'IS_PERIOD_ADD_T' => 'USA.IS_PERIOD_ADD_T',
  1796. // 'ADD_T_PERIOD_NUM' => 'USA.ADD_T_PERIOD_NUM',
  1797. // 'IS_PERIOD_OPEN' => 'USA.IS_PERIOD_OPEN',
  1798. // 'OPEN_PERIOD_NUM' => 'USA.OPEN_PERIOD_NUM',
  1799. // 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
  1800. // 'CREATED_AT' => 'ADM.CREATED_AT',
  1801. // 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1802. // 'AUDITED_AT' => 'ADM.AUDITED_AT',
  1803. // ]);
  1804. // $condition = $filter['condition'];
  1805. // $params = $filter['params'];
  1806. // $listObj = new StatusAuditList();
  1807. // $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  1808. // return static::notice($data);
  1809. // }
  1810. /**
  1811. * 会员状态管理导出
  1812. * @return mixed
  1813. * @throws \yii\db\Exception
  1814. * @throws HttpException
  1815. */
  1816. public function actionStatusAuditExport()
  1817. {
  1818. $filter = $this->filterCondition([
  1819. 'userIds' => 'UI.USER_ID',
  1820. 'filterStatus' => 'USA.AUDIT_STATUS',
  1821. 'SYSTEM_NAME' => 'UI.SYSTEM_ID',
  1822. 'ORI_STATUS_NAME' => 'USA.ORI_VALUE',
  1823. 'STATUS_NAME' => 'USA.STATUS_VALUE',
  1824. 'PERIOD_NUM' => 'USA.PERIOD_NUM',
  1825. 'CREATE_REMARK' => 'USA.CREATE_REMARK',
  1826. 'IS_PERIOD_ADD_T' => 'USA.IS_PERIOD_ADD_T',
  1827. 'ADD_T_PERIOD_NUM' => 'USA.ADD_T_PERIOD_NUM',
  1828. 'IS_PERIOD_OPEN' => 'USA.IS_PERIOD_OPEN',
  1829. 'OPEN_PERIOD_NUM' => 'USA.OPEN_PERIOD_NUM',
  1830. 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
  1831. 'CREATED_AT' => 'ADM.CREATED_AT',
  1832. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1833. 'AUDITED_AT' => 'ADM.AUDITED_AT',
  1834. ]);
  1835. $form = new UserExportForm();
  1836. $result = $form->run($filter, '会员状态管理');
  1837. if (!$result) {
  1838. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1839. }
  1840. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1841. }
  1842. /**
  1843. * 申请修改会员状态
  1844. * @return mixed
  1845. * @throws HttpException
  1846. */
  1847. public function actionStatusAuditAdd()
  1848. {
  1849. if (Yii::$app->request->isPost) {
  1850. return parent::edit(UserStatusForm::class, Yii::t('ctx', 'successfully'), 'add', ['add'], null, function ($form, $result) {
  1851. $userInfo = Info::baseInfo($result->USER_ID);
  1852. // Log::adminHandle('申请修改' . $userInfo['USER_NAME'] . '状态为' . Yii::$app->params['userStatus'][$result->STATUS_VALUE]['label'], 1, $result->USER_ID, $userInfo['USER_NAME']);
  1853. });
  1854. }
  1855. }
  1856. /**
  1857. * 获取全部移网类型
  1858. * @return mixed
  1859. * @throws HttpException
  1860. */
  1861. public function actionStatusAuditGetStatuses()
  1862. {
  1863. $statuses = Tool::paramConvert(Yii::$app->params['userStatus']);
  1864. return static::notice(['statuses' => $statuses]);
  1865. }
  1866. /**
  1867. * 获取会员状态数据
  1868. * @return mixed
  1869. * @throws Exception
  1870. * @throws HttpException
  1871. */
  1872. public function actionStatusAuditGet()
  1873. {
  1874. $id = Yii::$app->request->get('id');
  1875. $userStatusAudit = UserStatusAudit::findOneAsArray('ID=:ID', [':ID' => $id]);
  1876. if (!$userStatusAudit) {
  1877. return static::notice('The data does not exist', 400); // 数据不存在
  1878. }
  1879. $userStatusAudit['BASE_INFO'] = Info::baseInfoZh($userStatusAudit['USER_ID']);
  1880. $statuses = Tool::paramConvert(Yii::$app->params['userStatus']);
  1881. return static::notice([
  1882. 'id' => $userStatusAudit['ID'],
  1883. 'baseInfo' => $userStatusAudit['BASE_INFO'],
  1884. 'statusValue' => $userStatusAudit['STATUS_VALUE'],
  1885. 'isPeriodAddT' => $userStatusAudit['IS_PERIOD_ADD_T'] ? true : false,
  1886. 'addTPeriodNum' => $userStatusAudit['ADD_T_PERIOD_NUM'],
  1887. 'isPeriodOpen' => $userStatusAudit['IS_PERIOD_OPEN'] ? true : false,
  1888. 'openPeriodNum' => $userStatusAudit['OPEN_PERIOD_NUM'],
  1889. 'remark' => $userStatusAudit['CREATE_REMARK'],
  1890. ]);
  1891. }
  1892. /**
  1893. * 审核修改会员状态
  1894. * @return mixed
  1895. * @throws Exception
  1896. * @throws \yii\db\Exception
  1897. * @throws HttpException
  1898. */
  1899. public function actionStatusAudit()
  1900. {
  1901. $formModel = new UserStatusForm();
  1902. $formModel->scenario = 'audit';
  1903. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
  1904. $userInfo = Info::baseInfo($result->USER_ID);
  1905. // Log::adminHandle('审核修改' . $userInfo['USER_NAME'] . '状态为' . Yii::$app->params['userStatus'][$result->STATUS_VALUE]['label'], 1, $result->USER_ID, $userInfo['USER_NAME']);
  1906. return static::notice(Yii::t('ctx', 'successfully'));
  1907. }
  1908. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1909. }
  1910. /**
  1911. * 删除审核修改会员状态
  1912. * @return mixed
  1913. * @throws \yii\db\Exception
  1914. * @throws HttpException
  1915. */
  1916. public function actionStatusAuditDelete()
  1917. {
  1918. $userStatusForm = new UserStatusForm();
  1919. $result = static::delete(UserStatusAudit::class, function ($selected) use ($userStatusForm) {
  1920. $userStatusForm->beforeDelete($selected);
  1921. // Log::adminHandle('删除审核修改会员状态信息');
  1922. }, function ($selected) use ($userStatusForm) {
  1923. $userStatusForm->delete($selected);
  1924. // Log::adminHandle('删除审核修改会员状态信息');
  1925. }, true);
  1926. return $result;
  1927. }
  1928. /**
  1929. * 设置是否运作
  1930. * @return mixed
  1931. * @throws HttpException
  1932. */
  1933. public function actionIsOperating()
  1934. {
  1935. if (Yii::$app->request->isPost) {
  1936. return parent::edit(UserStatusForm::class, Yii::t('ctx', 'successfully'), 'operating', ['operating'], null, function ($form, $result) {
  1937. /*$isOperating = $form->isOperating ? '运作' : '不运作';
  1938. if(is_array($result)){
  1939. foreach ($result as $value){
  1940. // 获取其中一个人的会员编号
  1941. $userName = Info::getUserNameByUserId($value);
  1942. // Log::adminHandle('为会员' . $userName . '会员设置为' . $isOperating, 1, $value, $userName);
  1943. }
  1944. }*/
  1945. });
  1946. }
  1947. }
  1948. /**
  1949. * 团队领导人
  1950. * @return mixed
  1951. * @throws HttpException
  1952. */
  1953. public function actionIsGroup()
  1954. {
  1955. if (Yii::$app->request->isPost) {
  1956. return parent::edit(UserGroupForm::class, Yii::t('ctx', 'successfully'), 'group', ['group'], null, function ($form, $result) {
  1957. $isGroup = $form->isGroup ? '设为团队领导人' : '取消团队领导人';
  1958. if (is_array($result)) {
  1959. foreach ($result as $value) {
  1960. // 获取其中一个人的会员编号
  1961. $userName = Info::getUserNameByUserId($value);
  1962. // Log::adminHandle('为会员' . $userName . $isGroup, 1, $value, $userName);
  1963. }
  1964. }
  1965. });
  1966. }
  1967. }
  1968. /**
  1969. * 报单中心
  1970. * @return mixed
  1971. * @throws HttpException
  1972. */
  1973. public function actionIsDec()
  1974. {
  1975. if (Yii::$app->request->isPost) {
  1976. return parent::edit(UserDecForm::class, Yii::t('ctx', 'successfully'), 'isDec', ['isDec'], null, null);
  1977. }
  1978. }
  1979. /**
  1980. * 工作室
  1981. * @return mixed
  1982. * @throws HttpException
  1983. */
  1984. public function actionIsStudio()
  1985. {
  1986. if (Yii::$app->request->isPost) {
  1987. return parent::edit(UserDecForm::class, Yii::t('ctx', 'successfully'), 'isStudio', ['isStudio'], null, null);
  1988. }
  1989. }
  1990. /**
  1991. * 网络图谱
  1992. * @return mixed
  1993. * @throws HttpException
  1994. */
  1995. public function actionIsAtlas()
  1996. {
  1997. if (Yii::$app->request->isPost) {
  1998. return parent::edit(UserDecForm::class, Yii::t('ctx', 'successfully'), 'isAtlas', ['isAtlas'], null, null);
  1999. }
  2000. }
  2001. /**
  2002. * 会员充值管理显隐设置
  2003. * @return mixed
  2004. * @throws HttpException
  2005. */
  2006. public function actionIsRecharge()
  2007. {
  2008. if (Yii::$app->request->isPost) {
  2009. return parent::edit(UserDecForm::class, Yii::t('ctx', 'successfully'), 'isRecharge', ['isRecharge'], null, null);
  2010. }
  2011. }
  2012. /**
  2013. * 获取企业银行信息
  2014. * @return mixed
  2015. * @throws HttpException
  2016. */
  2017. public function actionCompanyBankGet()
  2018. {
  2019. $id = Yii::$app->request->get('id');
  2020. $userName = Yii::$app->request->get('userName');
  2021. $companyBank = [];
  2022. if ($id) {
  2023. $companyBank = CompanyBank::findOneAsArray('ID=:ID', [':ID' => $id]);
  2024. }
  2025. if ($userName) {
  2026. $userId = Info::getUserIdByUserName($userName);
  2027. if ($userId) $companyBank = CompanyBank::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $userId]);
  2028. }
  2029. if ($companyBank) return static::notice(['openBank' => $companyBank['OPEN_BANK'], 'bankAreaSelected' => [$companyBank['BANK_PROVINCE'], $companyBank['BANK_CITY'], $companyBank['BANK_COUNTY']], 'bankAddress' => $companyBank['BANK_ADDRESS'], 'openName' => $companyBank['OPEN_NAME'], 'bankNo' => $companyBank['BANK_NO']]);
  2030. return static::notice(['openBank' => null, 'bankAreaSelected' => [], 'bankAddress' => null, 'openName' => null, 'bankNo' => null]);
  2031. }
  2032. /**
  2033. * 调整会员转账/提现比例
  2034. * @return mixed
  2035. * @throws HttpException
  2036. */
  2037. public function actionChangeTransferProp()
  2038. {
  2039. if (Yii::$app->request->isPost) {
  2040. return parent::edit(UserTransferPropForm::class, Yii::t('ctx', 'successfully'), 'change', ['change'], null, function ($form, $result) {
  2041. /*$remark = $form->remark;
  2042. if (is_array($result)) {
  2043. foreach ($result as $value) {
  2044. // 获取其中一个人的会员编号
  2045. $userName = Info::getUserNameByUserId($value);
  2046. // Log::adminHandle('调整会员'.$userName.'转账/提现比例成功', 1, $value, $userName, $remark);
  2047. }
  2048. }*/
  2049. });
  2050. }
  2051. }
  2052. public function actionStatusCloseGet()
  2053. {
  2054. $users = Status::getCloseUser();
  2055. return $users;
  2056. }
  2057. /**
  2058. * 清空关停会员钱包
  2059. * @return mixed
  2060. * @throws Exception
  2061. * @throws \yii\db\Exception
  2062. * @throws HttpException
  2063. */
  2064. public function actionClearWallet()
  2065. {
  2066. $formModel = new UserStatusForm();
  2067. $formModel->scenario = 'clearWallet';
  2068. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->clearWallet()) {
  2069. /*if (is_array($result)) {
  2070. foreach ($result as $value) {
  2071. // 获取其中一个人的会员编号
  2072. $userName = Info::getUserNameByUserId($value);
  2073. Log::adminHandle('清空关停会员' . $userName . '钱包', 1, $value, $userName);
  2074. }
  2075. }*/
  2076. return static::notice('清空关停会员钱包,影响会员【' . count($result) . '】人');
  2077. }
  2078. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  2079. }
  2080. /**
  2081. * 会员历史年度最高聘级表
  2082. * @return mixed
  2083. * @throws Exception
  2084. * @throws HttpException
  2085. */
  2086. public function actionYearHighestEmpLv()
  2087. {
  2088. $filter = $this->filterCondition([
  2089. 'userIds' => 'UI.USER_ID',
  2090. 'YEAR' => 'YHEL.YEAR',
  2091. 'HIGHEST_EMP_LV_NAME' => 'YHEL.HIGHEST_EMP_LV',
  2092. 'HIGHEST_EMP_LV_PERIOD' => 'YHEL.HIGHEST_EMP_LV_PERIOD',
  2093. ]);
  2094. $condition = $filter['condition'];
  2095. $params = $filter['params'];
  2096. $listObj = new YearHighestEmpLvList();
  2097. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  2098. return static::notice($data);
  2099. }
  2100. /**
  2101. * 会员历史年度最高聘级表导出
  2102. * @return mixed
  2103. * @throws \yii\db\Exception
  2104. * @throws HttpException
  2105. */
  2106. public function actionYearHighestEmpLvExport()
  2107. {
  2108. $filter = $this->filterCondition([
  2109. 'userIds' => 'UI.USER_ID',
  2110. 'YEAR' => 'YHEL.YEAR',
  2111. 'HIGHEST_EMP_LV_NAME' => 'YHEL.HIGHEST_EMP_LV',
  2112. 'HIGHEST_EMP_LV_PERIOD' => 'YHEL.HIGHEST_EMP_LV_PERIOD',
  2113. ]);
  2114. $form = new UserExportForm();
  2115. $result = $form->run($filter, '会员历史年度最高聘级表');
  2116. if (!$result) {
  2117. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2118. }
  2119. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2120. }
  2121. /**
  2122. * 会员现金充值
  2123. * @return mixed
  2124. * @throws \yii\db\Exception
  2125. * @throws HttpException
  2126. */
  2127. public function actionRechargeToUser()
  2128. {
  2129. $formModel = new RechargeForm();
  2130. $formModel->scenario = 'addByAdmin';
  2131. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->recharge()) {
  2132. return static::notice(Yii::t('ctx', 'successfully'));
  2133. }
  2134. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  2135. }
  2136. /**
  2137. * 会员修改密码
  2138. * @return mixed
  2139. * @throws HttpException
  2140. */
  2141. public function actionBaModifyPassword()
  2142. {
  2143. $form = new BaUserBasicForm();
  2144. $form->scenario = 'modifyPassword';
  2145. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->edit()){
  2146. return static::notice(Yii::t('ctx', 'successfully')); // 密码修改成功
  2147. } else {
  2148. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2149. }
  2150. }
  2151. /**
  2152. * 个人资料获取
  2153. * @return mixed
  2154. * @throws HttpException
  2155. */
  2156. public function actionBaProfileGet() {
  2157. $id = Yii::$app->request->get('id');
  2158. $userInfo = BaUser::findOneAsArray('ID=:ID', [':ID' => $id]);
  2159. if (!$userInfo) {
  2160. return static::notice('Data does not exist', 400);//数据不存在
  2161. }
  2162. $data['userInfo'] = [
  2163. 'userId' => $userInfo['ID'],
  2164. 'realName' => $userInfo['REAL_NAME'],
  2165. 'mobile' => $userInfo['MOBILE'],
  2166. ];
  2167. return static::notice($data);
  2168. }
  2169. public function actionBaModifyProfile() {
  2170. $form = new BaUserBasicForm();
  2171. $form->scenario = 'modifyProfile';
  2172. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->modifyProfile()){
  2173. return static::notice(Yii::t('ctx', 'successfully'));//个人资料修改成功
  2174. } else {
  2175. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2176. }
  2177. }
  2178. public function actionBaModifyStatus() {
  2179. $form = new BaUserBasicForm();
  2180. $form->scenario = 'modifyStatus';
  2181. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->modifyStatus()){
  2182. return static::notice(Yii::t('ctx', 'successfully'));//会员状态修改成功
  2183. } else {
  2184. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2185. }
  2186. }
  2187. /**
  2188. * @return mixed
  2189. * @throws \yii\db\Exception
  2190. * @throws HttpException
  2191. */
  2192. public function actionBaIsModifyPasswordStatus() {
  2193. $form = new BaUserBasicForm();
  2194. $form->scenario = 'isModifyPasswordStatus';
  2195. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->isModifyPasswordStatus()){
  2196. return static::notice(Yii::t('ctx', 'successfully'));//状态修改成功
  2197. } else {
  2198. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2199. }
  2200. }
  2201. /**
  2202. * BA会员列表
  2203. * @return mixed
  2204. * @throws Exception
  2205. * @throws \yii\web\HttpException
  2206. */
  2207. public function actionBaUserList() {
  2208. $filter = $this->filterCondition([
  2209. 'USER_NAME' => 'U.USER_NAME',
  2210. 'REAL_NAME' => 'U.REAL_NAME',
  2211. 'STATUS' => 'U.STATUS',
  2212. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  2213. 'CREATED_AT' => 'U.CREATED_AT',
  2214. 'PERIOD_AT' => 'U.PERIOD_AT',
  2215. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  2216. 'MOBILE' => 'U.MOBILE',
  2217. 'TEL' => 'U.TEL',
  2218. 'SEX' => 'U.SEX',
  2219. 'AREA' => [
  2220. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  2221. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  2222. ],
  2223. 'ADDRESS' => 'U.ADDRESS',
  2224. 'ALLOW_TRANSFER' => 'UI.ALLOW_TRANSFER',
  2225. ]);
  2226. $condition = $filter['condition'];
  2227. $params = $filter['params'];
  2228. $condition .= ' AND UI.DELETED=0 ';
  2229. $listObj = new BaUserList();
  2230. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  2231. return static::notice($data);
  2232. }
  2233. /**
  2234. * @throws \yii\db\Exception
  2235. * @throws HttpException
  2236. */
  2237. public function actionBaUserListExport() {
  2238. $filter = $this->filterCondition([
  2239. 'USER_NAME' => 'U.USER_NAME',
  2240. 'REAL_NAME' => 'U.REAL_NAME',
  2241. 'STATUS' => 'U.STATUS',
  2242. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  2243. 'CREATED_AT' => 'U.CREATED_AT',
  2244. 'PERIOD_AT' => 'U.PERIOD_AT',
  2245. 'REC_USER_NAME' => 'RU.USER_NAME',
  2246. 'CON_USER_NAME' => 'CU.USER_NAME',
  2247. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  2248. 'SYSTEM_NAME' => 'U.SYSTEM_ID',
  2249. 'MOBILE' => 'U.MOBILE',
  2250. 'TEL' => 'U.TEL',
  2251. 'SEX' => 'U.SEX',
  2252. 'AREA' => [
  2253. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  2254. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  2255. ],
  2256. 'ADDRESS' => 'U.ADDRESS',
  2257. 'ALLOW_TRANSFER' => 'UI.ALLOW_TRANSFER',
  2258. ]);
  2259. $form = new BaUserExportForm();
  2260. $result = $form->run($filter, 'Brand_Ambassador_List');
  2261. if (!$result) {
  2262. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2263. }
  2264. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2265. }
  2266. /**
  2267. * 会员最高聘级变动记录.
  2268. * @return mixed
  2269. * @throws \yii\base\Exception
  2270. * @throws \yii\web\HttpException
  2271. */
  2272. public function actionChangeHighestEmpLevelList()
  2273. {
  2274. $filter = $this->filterCondition([
  2275. 'USER_NAME' => 'CU.USER_NAME',
  2276. 'CREATED_AT' => 'LL.CREATED_AT',
  2277. 'ADMIN_NAME' => 'ADM.ADMIN_NAME',
  2278. ]);
  2279. $condition = $filter['condition'];
  2280. $params = $filter['params'];
  2281. $listObj = new ChangeHighestEmpLevelList();
  2282. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  2283. return static::notice($data);
  2284. }
  2285. /**
  2286. * 调整会员最高聘级.
  2287. * @return mixed
  2288. * @throws \yii\web\HttpException
  2289. */
  2290. public function actionChangeHighestEmpLevel()
  2291. {
  2292. if (Yii::$app->request->isPost) {
  2293. return parent::edit(HighestEmpLevelLogForm::class, Yii::t('ctx', 'successfully'), 'adminChange', ['adminChange',], null, function ($form, $result) {
  2294. });
  2295. }
  2296. return static::notice('无效请求', 400);
  2297. }
  2298. }