UserController.php 93 KB

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