UserController.php 93 KB

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