UserController.php 93 KB

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