UserController.php 91 KB

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