BonusController.php 101 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702
  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\models\Admin;
  10. use backendApi\modules\v1\models\exportForms\BonusExportForm;
  11. use backendApi\modules\v1\models\lists\bonus\BalanceList;
  12. use backendApi\modules\v1\models\lists\bonus\FlowBalanceList;
  13. use backendApi\modules\v1\models\lists\bonus\FlowBonusList;
  14. use backendApi\modules\v1\models\lists\bonus\FlowReconsumePointsList;
  15. use backendApi\modules\v1\models\lists\bonus\FlowWalletList;
  16. use backendApi\modules\v1\models\lists\bonus\PerfMonthList;
  17. use backendApi\modules\v1\models\lists\bonus\PerfOrderList;
  18. use backendApi\modules\v1\models\lists\bonus\PerfPeriodList;
  19. use backendApi\modules\v1\models\lists\bonus\PerfStandardList;
  20. use backendApi\modules\v1\models\lists\bonus\PeriodBonusList;
  21. use backendApi\modules\v1\models\lists\bonus\ScoreMonthList;
  22. use backendApi\modules\v1\models\lists\bonus\TraceDownBdList;
  23. use backendApi\modules\v1\models\lists\bonus\TraceDownGlList;
  24. use backendApi\modules\v1\models\lists\bonus\TraceDownGxList;
  25. use backendApi\modules\v1\models\lists\bonus\TraceDownQyList;
  26. use backendApi\modules\v1\models\lists\bonus\TraceDownTgList;
  27. use backendApi\modules\v1\models\lists\bonus\TraceDownXfList;
  28. use backendApi\modules\v1\models\lists\bonus\TraceDownYcList;
  29. use backendApi\modules\v1\models\lists\bonus\TraceDownYjList;
  30. use backendApi\modules\v1\models\lists\bonus\TraceUpBdList;
  31. use backendApi\modules\v1\models\lists\bonus\TraceUpGlList;
  32. use backendApi\modules\v1\models\lists\bonus\TraceUpGxList;
  33. use backendApi\modules\v1\models\lists\bonus\TraceUpQyList;
  34. use backendApi\modules\v1\models\lists\bonus\TraceUpTgList;
  35. use backendApi\modules\v1\models\lists\bonus\TraceUpXfList;
  36. use backendApi\modules\v1\models\lists\bonus\TraceUpYcList;
  37. use backendApi\modules\v1\models\lists\bonus\TraceUpYjList;
  38. use backendApi\modules\v1\models\lists\bonus\UserPerfList;
  39. use common\helpers\Cache;
  40. use common\helpers\Date;
  41. use common\helpers\Tool;
  42. use common\helpers\user\Info;
  43. use common\helpers\user\Perf;
  44. use common\models\CalcBonus;
  45. use common\models\CFLXAudit;
  46. use common\models\forms\ResendQYForm;
  47. use common\models\forms\SendCFAndLXForm;
  48. use common\models\PerfMonth;
  49. use common\models\PerfOrder;
  50. use common\models\PerfPeriod;
  51. use common\models\ResendQYAudit;
  52. use common\models\User;
  53. use common\models\UserInfo;
  54. use common\models\UserNetwork;
  55. use Yii;
  56. use common\helpers\Form;
  57. use common\models\FlowBonus;
  58. use common\models\forms\PeriodForm;
  59. use common\models\Period;
  60. class BonusController extends BaseController {
  61. public $modelClass = FlowBonus::class;
  62. public function behaviors() {
  63. $behaviors = parent::behaviors();
  64. //$behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_JSON;
  65. return $behaviors;
  66. }
  67. /**
  68. * 期数列表
  69. * @return mixed
  70. * @throws \yii\base\InvalidConfigException
  71. * @throws \yii\httpclient\Exception
  72. * @throws \yii\web\HttpException
  73. */
  74. public function actionPeriod() {
  75. $filter = $this->filterCondition([
  76. 'periodNum' => 'PERIOD_NUM',
  77. 'year' => 'CALC_YEAR',
  78. 'month' => 'CALC_MONTH',
  79. 'startTime' => 'START_TIME',
  80. 'endTime' => 'END_TIME',
  81. 'closedAt' => 'CLOSED_AT',
  82. 'perfStartedAt' => 'PERF_STARTED_AT',
  83. 'perfedAt' => 'PERFED_AT',
  84. 'calStartedAt' => 'CALCULATE_STARTED_AT',
  85. 'calculatedAt' => 'CALCULATED_AT',
  86. 'sendStartedAt' => 'SEND_STARTED_AT',
  87. 'sentAt' => 'SENT_AT',
  88. ]);
  89. $condition = $filter['condition'];
  90. $params = $filter['params'];
  91. $periodObj = Period::instance();
  92. $nowPeriodNum = $periodObj->getNowPeriodNum();
  93. $condition .= ' AND PERIOD_NUM<=:PERIOD_NUM';
  94. $params[':PERIOD_NUM'] = $nowPeriodNum;
  95. $data = Period::lists($condition, $params, ['orderBy' => 'PERIOD_NUM DESC']);
  96. foreach ($data['list'] as $key => $value) {
  97. // 是否可封期
  98. $data['list'][$key]['IS_CAN_CLOSE'] = $periodObj->isCanClose($value['PERIOD_NUM']);
  99. // 是否可生成业绩单
  100. $data['list'][$key]['IS_CAN_PERF'] = $periodObj->isCanPerf($value['PERIOD_NUM']);
  101. // 是否可结算
  102. $data['list'][$key]['IS_CAN_CALC'] = $periodObj->isCanCalc($value['PERIOD_NUM']);
  103. // 是否可挂网
  104. $data['list'][$key]['IS_CAN_SENT'] = $periodObj->isCanSend($value['PERIOD_NUM']);
  105. // 操作数据按钮是否可用
  106. $data['list'][$key]['BUTTON_IS_CAN'] = $periodObj->isCanClose($value['PERIOD_NUM']) || $periodObj->isCanPerf($value['PERIOD_NUM']) || $periodObj->isCanCalc($value['PERIOD_NUM']) || $periodObj->isCanSend($value['PERIOD_NUM']);
  107. }
  108. return static::notice($data);
  109. }
  110. /**
  111. * 封期
  112. * @return mixed
  113. * @throws \yii\db\Exception
  114. * @throws \yii\web\HttpException
  115. */
  116. public function actionClosePeriod() {
  117. $periodNum = \Yii::$app->request->get('periodNum');
  118. if (!$periodNum) {
  119. return static::notice('期数不存在', 400);
  120. }
  121. $formModel = new PeriodForm();
  122. if ($formModel->load(Yii::$app->request->get(), '') && $formModel->closePeriod()) {
  123. // Log::adminHandle('第' . $periodNum . '期封期成功');
  124. return static::notice('封期成功');
  125. } else {
  126. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  127. }
  128. }
  129. /**
  130. * 计算业绩并生成业绩单
  131. * @return mixed
  132. * @throws \yii\web\HttpException
  133. */
  134. public function actionPerfPeriod() {
  135. $periodNum = \Yii::$app->request->get('periodNum');
  136. if (!$periodNum) {
  137. return static::notice('期数不存在', 400);
  138. }
  139. $formModel = new PeriodForm();
  140. $formModel->scenario = 'perf';
  141. if ($formModel->load(Yii::$app->request->get(), '') && $formModel->perfWebToAsync()) {
  142. // Log::adminHandle('第' . $periodNum . '期封生成业绩单');
  143. return static::notice('生成业绩单已开始处理,请等待');
  144. } else {
  145. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  146. }
  147. }
  148. /**
  149. * 结算封期
  150. * @return mixed
  151. * @throws \yii\web\HttpException
  152. */
  153. public function actionCalcPeriod() {
  154. $periodNum = \Yii::$app->request->get('periodNum');
  155. if (!$periodNum) {
  156. return static::notice('期数不存在', 400);
  157. }
  158. $formModel = new PeriodForm();
  159. $formModel->scenario = 'calc';
  160. if ($formModel->load(Yii::$app->request->get(), '') && $formModel->calcWebToAsync()) {
  161. // Log::adminHandle('第' . $periodNum . '期结算');
  162. return static::notice('结算已开始处理,请等待');
  163. } else {
  164. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  165. }
  166. }
  167. /**
  168. * 挂网
  169. * @return mixed
  170. * @throws \yii\web\HttpException
  171. */
  172. public function actionSendPeriod() {
  173. $periodNum = \Yii::$app->request->get('periodNum');
  174. if (!$periodNum) {
  175. return static::notice('期数不存在', 400);
  176. }
  177. $formModel = new PeriodForm();
  178. $formModel->scenario = 'send';
  179. if ($formModel->load(Yii::$app->request->get(), '') && $formModel->sendWebToAsync()) {
  180. // Log::adminHandle('第' . $periodNum . '期挂网');
  181. return static::notice('挂网已开始处理,请等待');
  182. } else {
  183. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  184. }
  185. }
  186. /**
  187. * 查看业绩
  188. * @return mixed
  189. * @throws \yii\web\HttpException
  190. */
  191. public function actionPerf() {
  192. // 获取当前年月
  193. $period = Period::instance();
  194. $yearMonth = $period->getNowYearMonth();
  195. $yearMonth = Yii::$app->request->get('yearMonth', $yearMonth);
  196. //$filter = $this->filterCondition(Perf::tableName(), ['periodNum'=>'P.PERIOD_NUM', 'userName'=>'UI.USER_NAME']);
  197. $condition = '';
  198. $params = [];
  199. $data = PerfPeriod::lists($condition, $params, [
  200. 'select' => 'P.*, UI.USER_NAME',
  201. 'yearMonth' => $yearMonth,
  202. 'from' => PerfPeriod::tableName() . ' AS P',
  203. 'join' => [
  204. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'P.USER_ID=UI.USER_ID']
  205. ],
  206. 'orderBy' => 'P.PERIOD_NUM DESC',
  207. ]);
  208. $data['request'] = [];
  209. $data['request']['yearMonth'] = $yearMonth;
  210. return static::notice($data);
  211. }
  212. /**
  213. * 奖金流水
  214. * @return mixed
  215. * @throws \yii\base\Exception
  216. * @throws \yii\web\HttpException
  217. */
  218. public function actionFlowBonus() {
  219. $filter = $this->filterCondition([
  220. 'USER_NAME' => 'U.USER_NAME',
  221. 'REAL_NAME' => 'U.REAL_NAME',
  222. 'IS_DEC' => 'U.IS_DEC',
  223. 'userIds' => 'USER_ID',
  224. 'CREATED_AT' => 'FB.CREATED_AT',
  225. 'PERIOD_NUM' => 'PERIOD_NUM',
  226. 'CALC_MONTH' => 'CALC_MONTH',
  227. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  228. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  229. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  230. // 'LAST_STATUS_NAME' => 'LAST_STATUS',
  231. 'AMOUNT' => 'AMOUNT',
  232. 'TOTAL' => 'TOTAL',
  233. 'ADMIN_NAME' => 'ADMIN_NAME',
  234. 'REMARK' => 'REMARK',
  235. 'TRANSFER_SN' => 'TRANSFER_SN',
  236. ]);
  237. $condition = $filter['condition'];
  238. $params = $filter['params'];
  239. $listObj = new FlowBonusList();
  240. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  241. return static::notice($data);
  242. }
  243. /**
  244. * 奖金流水
  245. * @return mixed
  246. * @throws \yii\db\Exception
  247. * @throws \yii\web\HttpException
  248. */
  249. public function actionFlowBonusExport() {
  250. $filter = $this->filterCondition([
  251. 'USER_NAME' => 'U.USER_NAME',
  252. 'REAL_NAME' => 'U.REAL_NAME',
  253. 'IS_DEC' => 'U.IS_DEC',
  254. 'userIds' => 'USER_ID',
  255. 'CREATED_AT' => 'FB.CREATED_AT',
  256. 'PERIOD_NUM' => 'PERIOD_NUM',
  257. 'CALC_MONTH' => 'CALC_MONTH',
  258. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  259. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  260. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  261. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  262. 'AMOUNT' => 'AMOUNT',
  263. 'TOTAL' => 'TOTAL',
  264. 'ADMIN_NAME' => 'ADMIN_NAME',
  265. 'REMARK' => 'REMARK',
  266. 'TRANSFER_SN' => 'TRANSFER_SN',
  267. ]);
  268. $form = new BonusExportForm();
  269. $result = $form->run($filter, '奖金流水');
  270. if (!$result) {
  271. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  272. }
  273. return static::notice('导出开始,请到文件管理-导出文件查看');
  274. }
  275. /**
  276. * 复消积分流水
  277. * @return mixed
  278. * @throws \yii\base\Exception
  279. * @throws \yii\web\HttpException
  280. */
  281. public function actionFlowRp() {
  282. $filter = $this->filterCondition([
  283. 'userIds' => 'USER_ID',
  284. 'CREATED_AT' => 'CREATED_AT',
  285. 'PERIOD_NUM' => 'PERIOD_NUM',
  286. 'CALC_MONTH' => 'CALC_MONTH',
  287. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  288. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  289. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  290. 'AMOUNT' => 'AMOUNT',
  291. 'TOTAL' => 'TOTAL',
  292. 'ADMIN_NAME' => 'ADMIN_NAME',
  293. 'REMARK' => 'REMARK',
  294. ]);
  295. $condition = $filter['condition'];
  296. $params = $filter['params'];
  297. $listObj = new FlowReconsumePointsList();
  298. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  299. return static::notice($data);
  300. }
  301. /**
  302. * 复消积分流水导出
  303. * @return mixed
  304. * @throws \yii\db\Exception
  305. * @throws \yii\web\HttpException
  306. */
  307. public function actionFlowRpExport() {
  308. $filter = $this->filterCondition([
  309. 'userIds' => 'USER_ID',
  310. 'CREATED_AT' => 'CREATED_AT',
  311. 'PERIOD_NUM' => 'PERIOD_NUM',
  312. 'CALC_MONTH' => 'CALC_MONTH',
  313. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  314. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  315. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  316. 'AMOUNT' => 'AMOUNT',
  317. 'TOTAL' => 'TOTAL',
  318. 'ADMIN_NAME' => 'ADMIN_NAME',
  319. 'REMARK' => 'REMARK',
  320. ]);
  321. $form = new BonusExportForm();
  322. $result = $form->run($filter, '复消积分流水');
  323. if (!$result) {
  324. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  325. }
  326. return static::notice('导出开始,请到文件管理-导出文件查看');
  327. }
  328. /**
  329. * 会员余额流水
  330. * @return mixed
  331. * @throws \yii\base\Exception
  332. * @throws \yii\web\HttpException
  333. */
  334. public function actionFlowBalance() {
  335. $filter = $this->filterCondition([
  336. 'USER_NAME' => 'USER_NAME',
  337. 'REAL_NAME' => 'REAL_NAME',
  338. 'CALC_MONTH' => 'CALC_MONTH',
  339. 'PERIOD_NUM' => 'PERIOD_NUM',
  340. 'TRANSFER_SN' => 'TRANSFER_SN',
  341. 'CREATED_AT' => 'FW.CREATED_AT',
  342. 'AMOUNT' => 'AMOUNT',
  343. 'TOTAL' => 'TOTAL',
  344. 'REMARK' => 'REMARK',
  345. ]);
  346. $condition = $filter['condition'];
  347. $params = $filter['params'];
  348. $listObj = new FlowBalanceList();
  349. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  350. return static::notice($data);
  351. }
  352. /**
  353. * 会员余额流水导出
  354. * @return mixed
  355. * @throws \yii\db\Exception
  356. * @throws \yii\web\HttpException
  357. */
  358. public function actionFlowBalanceExport() {
  359. $filter = $this->filterCondition([
  360. 'USER_NAME' => 'USER_NAME',
  361. 'REAL_NAME' => 'REAL_NAME',
  362. 'CALC_MONTH' => 'CALC_MONTH',
  363. 'PERIOD_NUM' => 'PERIOD_NUM',
  364. 'TRANSFER_SN' => 'TRANSFER_SN',
  365. 'CREATED_AT' => 'FW.CREATED_AT',
  366. 'AMOUNT' => 'AMOUNT',
  367. 'TOTAL' => 'TOTAL',
  368. 'REMARK' => 'REMARK',
  369. ]);
  370. $form = new BonusExportForm();
  371. $result = $form->run($filter, '会员余额流水');
  372. if (!$result) {
  373. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  374. }
  375. return static::notice('导出开始,请到文件管理-导出文件查看');
  376. }
  377. /**
  378. * 现金钱包流水
  379. * @return mixed
  380. * @throws \yii\base\Exception
  381. * @throws \yii\web\HttpException
  382. */
  383. public function actionFlowWallet() {
  384. $filter = $this->filterCondition([
  385. 'USER_NAME' => 'U.USER_NAME',
  386. 'REAL_NAME' => 'U.REAL_NAME',
  387. 'IS_DEC' => 'U.IS_DEC',
  388. 'userIds' => 'USER_ID',
  389. 'CREATED_AT' => 'CREATED_AT',
  390. 'PERIOD_NUM' => 'PERIOD_NUM',
  391. 'CALC_MONTH' => 'CALC_MONTH',
  392. 'AMOUNT' => 'AMOUNT',
  393. 'TOTAL' => 'TOTAL',
  394. 'ADMIN_NAME' => 'ADMIN_NAME',
  395. 'REMARK' => 'REMARK',
  396. ]);
  397. $condition = $filter['condition'];
  398. $params = $filter['params'];
  399. $listObj = new FlowWalletList();
  400. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  401. return static::notice($data);
  402. }
  403. /**
  404. * 现金钱包流水导出
  405. * @return mixed
  406. * @throws \yii\db\Exception
  407. * @throws \yii\web\HttpException
  408. */
  409. public function actionFlowWalletExport() {
  410. $filter = $this->filterCondition([
  411. 'USER_NAME' => 'U.USER_NAME',
  412. 'REAL_NAME' => 'U.REAL_NAME',
  413. 'IS_DEC' => 'U.IS_DEC',
  414. 'userIds' => 'USER_ID',
  415. 'CREATED_AT' => 'CREATED_AT',
  416. 'PERIOD_NUM' => 'PERIOD_NUM',
  417. 'CALC_MONTH' => 'CALC_MONTH',
  418. 'AMOUNT' => 'AMOUNT',
  419. 'TOTAL' => 'TOTAL',
  420. 'ADMIN_NAME' => 'ADMIN_NAME',
  421. 'REMARK' => 'REMARK',
  422. ]);
  423. $form = new BonusExportForm();
  424. $result = $form->run($filter, '现金钱包流水');
  425. if (!$result) {
  426. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  427. }
  428. return static::notice('导出开始,请到文件管理-导出文件查看');
  429. }
  430. /**
  431. * 车房流水
  432. * @return mixed
  433. * @throws \yii\base\Exception
  434. * @throws \yii\web\HttpException
  435. */
  436. public function actionFlowCf() {
  437. $filter = $this->filterCondition([
  438. 'userIds' => 'USER_ID',
  439. 'CREATED_AT' => 'CREATED_AT',
  440. 'PERIOD_NUM' => 'PERIOD_NUM',
  441. 'CALC_MONTH' => 'CALC_MONTH',
  442. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  443. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  444. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  445. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  446. 'AMOUNT' => 'AMOUNT',
  447. 'TOTAL' => 'TOTAL',
  448. 'ADMIN_NAME' => 'ADMIN_NAME',
  449. 'REMARK' => 'REMARK',
  450. ]);
  451. $condition = $filter['condition'];
  452. $params = $filter['params'];
  453. $listObj = new FlowCfList();
  454. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  455. return static::notice($data);
  456. }
  457. /**
  458. * 车房养老奖流水导出
  459. * @return mixed
  460. * @throws \yii\db\Exception
  461. * @throws \yii\web\HttpException
  462. */
  463. public function actionFlowCfExport() {
  464. $filter = $this->filterCondition([
  465. 'userIds' => 'USER_ID',
  466. 'CREATED_AT' => 'CREATED_AT',
  467. 'PERIOD_NUM' => 'PERIOD_NUM',
  468. 'CALC_MONTH' => 'CALC_MONTH',
  469. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  470. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  471. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  472. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  473. 'AMOUNT' => 'AMOUNT',
  474. 'TOTAL' => 'TOTAL',
  475. 'ADMIN_NAME' => 'ADMIN_NAME',
  476. 'REMARK' => 'REMARK',
  477. ]);
  478. $form = new BonusExportForm();
  479. $result = $form->run($filter, '车房养老奖流水');
  480. if (!$result) {
  481. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  482. }
  483. return static::notice('导出开始,请到文件管理-导出文件查看');
  484. }
  485. /**
  486. * 领袖分红流水
  487. * @return mixed
  488. * @throws \yii\base\Exception
  489. * @throws \yii\web\HttpException
  490. */
  491. public function actionFlowLx() {
  492. $filter = $this->filterCondition([
  493. 'userIds' => 'USER_ID',
  494. 'CREATED_AT' => 'CREATED_AT',
  495. 'PERIOD_NUM' => 'PERIOD_NUM',
  496. 'CALC_MONTH' => 'CALC_MONTH',
  497. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  498. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  499. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  500. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  501. 'AMOUNT' => 'AMOUNT',
  502. 'TOTAL' => 'TOTAL',
  503. 'ADMIN_NAME' => 'ADMIN_NAME',
  504. 'REMARK' => 'REMARK',
  505. ]);
  506. $condition = $filter['condition'];
  507. $params = $filter['params'];
  508. $listObj = new FlowLxList();
  509. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  510. return static::notice($data);
  511. }
  512. /**
  513. * 导出
  514. * @return mixed
  515. * @throws \yii\db\Exception
  516. * @throws \yii\web\HttpException
  517. */
  518. public function actionFlowLxExport() {
  519. $filter = $this->filterCondition([
  520. 'userIds' => 'USER_ID',
  521. 'CREATED_AT' => 'CREATED_AT',
  522. 'PERIOD_NUM' => 'PERIOD_NUM',
  523. 'CALC_MONTH' => 'CALC_MONTH',
  524. 'DEAL_TYPE_NAME' => 'DEAL_TYPE_ID',
  525. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  526. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  527. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  528. 'AMOUNT' => 'AMOUNT',
  529. 'TOTAL' => 'TOTAL',
  530. 'ADMIN_NAME' => 'ADMIN_NAME',
  531. 'REMARK' => 'REMARK',
  532. ]);
  533. $form = new BonusExportForm();
  534. $result = $form->run($filter, '领袖分红奖流水');
  535. if (!$result) {
  536. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  537. }
  538. return static::notice('导出开始,请到文件管理-导出文件查看');
  539. }
  540. /**
  541. * 车房养老奖和领袖分红年度发放审核列表
  542. * @return mixed
  543. * @throws \yii\base\Exception
  544. * @throws \yii\web\HttpException
  545. */
  546. public function actionCfLxAuditList() {
  547. $filter = $this->filterCondition([
  548. 'userIds' => 'CFLXA.USER_ID',
  549. 'CF' => 'CFLXA.CF',
  550. 'LX' => 'CFLXA.LX',
  551. 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
  552. 'CREATED_AT' => 'CFLXA.CREATED_AT',
  553. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  554. 'AUDITED_AT' => 'CFLXA.AUDITED_AT',
  555. 'CREATE_REMARK' => 'CFLXA.CREATE_REMARK',
  556. 'filterStatus' => 'CFLXA.AUDIT_STATUS',
  557. ]);
  558. $condition = $filter['condition'];
  559. $params = $filter['params'];
  560. $listObj = new CfLxAuditList();
  561. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  562. return static::notice($data);
  563. }
  564. /**
  565. * 车房养老奖和领袖分红年度发放审核导出
  566. * @return mixed
  567. * @throws \yii\db\Exception
  568. * @throws \yii\web\HttpException
  569. */
  570. public function actionCfLxAuditExport() {
  571. $filter = $this->filterCondition([
  572. 'userIds' => 'CFLXA.USER_ID',
  573. 'CF' => 'CFLXA.CF',
  574. 'LX' => 'CFLXA.LX',
  575. 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
  576. 'CREATED_AT' => 'CFLXA.CREATED_AT',
  577. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  578. 'AUDITED_AT' => 'CFLXA.AUDITED_AT',
  579. 'CREATE_REMARK' => 'CFLXA.CREATE_REMARK',
  580. 'filterStatus' => 'CFLXA.AUDIT_STATUS',
  581. ]);
  582. $form = new BonusExportForm();
  583. $result = $form->run($filter, '年度奖金发放审核');
  584. if (!$result) {
  585. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  586. }
  587. return static::notice('导出开始,请到文件管理-导出文件查看');
  588. }
  589. /**
  590. * 申请发放车房养老奖和领袖分红
  591. * @return mixed
  592. * @throws \yii\db\Exception
  593. * @throws \yii\web\HttpException
  594. */
  595. public function actionCfLxApply() {
  596. if (Yii::$app->request->isPost) {
  597. $formModel = new SendCFAndLXForm();
  598. $formModel->scenario = 'apply';
  599. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->apply()) {
  600. if(!empty($result['logs'])){
  601. return static::notice('申请成功,请在年度奖管理中审核');
  602. }else{
  603. return static::notice('申请失败,无符合发放条件会员',400);
  604. }
  605. } else {
  606. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  607. }
  608. }
  609. return static::notice('非法请求', 400);
  610. }
  611. /**
  612. * 审核车房养老奖和领袖分红
  613. * @return mixed
  614. * @throws \yii\db\Exception
  615. * @throws \yii\web\HttpException
  616. */
  617. public function actionCfLxAudit() {
  618. $formModel = new SendCFAndLXForm();
  619. $formModel->scenario = 'audit';
  620. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
  621. return static::notice('审核年度奖申请完成');
  622. }
  623. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  624. }
  625. /**
  626. * 删除车房领袖审核信息
  627. * @return mixed
  628. * @throws \yii\db\Exception
  629. * @throws \yii\web\HttpException
  630. */
  631. public function actionCfLxAuditDelete() {
  632. $sendCFAndLXForm = new SendCFAndLXForm();
  633. $result = static::delete(CFLXAudit::class, function ($selected) use ($sendCFAndLXForm) {
  634. $sendCFAndLXForm->beforeDelete($selected);
  635. // Log::adminHandle('删除审核会员余额信息');
  636. }, function ($selected) use ($sendCFAndLXForm) {
  637. $sendCFAndLXForm->delete($selected);
  638. // Log::adminHandle('删除审核会员余额信息');
  639. }, true);
  640. return $result;
  641. }
  642. /**
  643. * 查看所传期数的各项奖金
  644. * @return mixed
  645. * @throws \yii\db\Exception
  646. * @throws \yii\web\HttpException
  647. */
  648. public function actionPeriodDetail() {
  649. $periodNum = \Yii::$app->request->get('periodNum');
  650. $period = Period::instance();
  651. $periodInfo = $period->setPeriodNum($periodNum);
  652. $yearMonth = $period->getYearMonth($periodNum);
  653. // $filter = $this->filterCondition('UT', [
  654. // 'userName' => 'UI.USER_NAME',
  655. // ]);
  656. $condition = '';
  657. $params = [];
  658. $condition .= ' AND C.PERIOD_NUM=:PERIOD_NUM';
  659. $params[':PERIOD_NUM'] = $periodNum;
  660. if (!$period->isClosed($periodNum)) {
  661. return static::notice('该期不能查看');
  662. }
  663. $data = CalcBonus::lists($condition, $params, [
  664. 'yearMonth' => $yearMonth,
  665. 'select' => 'C.*,UI.USER_NAME',
  666. 'from' => CalcBonus::tableName() . ' AS C',
  667. 'join' => [
  668. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'C.USER_ID=UI.USER_ID'],
  669. ],
  670. 'orderBy' => 'C.CREATED_AT DESC',
  671. ]);
  672. $data['periodInfo'] = $periodInfo;
  673. return static::notice($data);
  674. }
  675. /**
  676. * 获取最新一期结算的奖金
  677. * @return mixed
  678. * @throws \yii\base\Exception
  679. * @throws \yii\db\Exception
  680. * @throws \yii\web\HttpException
  681. */
  682. public function actionNewPeriodBonus() {
  683. $periodNum = Period::calculatedMaxPeriodNum();
  684. $data = $this->_periodBonus($periodNum);
  685. return static::notice($data);
  686. }
  687. /**
  688. * 最新一期奖金导出
  689. * @return mixed
  690. * @throws \yii\db\Exception
  691. * @throws \yii\web\HttpException
  692. */
  693. public function actionNewPeriodBonusExport() {
  694. $filter = $this->filterCondition([
  695. 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
  696. 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
  697. 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
  698. 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
  699. 'LAST_MOBILE' => 'CB.LAST_MOBILE',
  700. 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
  701. 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
  702. 'LAST_REC_USER_NAME' => 'CB.LAST_REC_USER_NAME',
  703. 'LAST_REC_REAL_NAME' => 'CB.LAST_REC_REAL_NAME',
  704. 'LAST_CON_USER_NAME' => 'CB.LAST_CON_USER_NAME',
  705. 'LAST_CON_REAL_NAME' => 'CB.LAST_CON_REAL_NAME',
  706. 'BONUS_BD' => 'CB.BONUS_BD',
  707. 'BONUS_TG' => 'CB.BONUS_TG',
  708. 'BONUS_YJ' => 'CB.BONUS_YJ',
  709. 'BONUS_GX' => 'CB.BONUS_GX',
  710. 'BONUS_GL' => 'CB.BONUS_GL',
  711. 'BONUS_QY' => 'CB.BONUS_QY',
  712. 'BONUS_YC' => 'CB.BONUS_YC',
  713. 'PV_1L' => 'CB.PV_1L',
  714. 'SURPLUS_1L' => 'CB.SURPLUS_1L',
  715. 'PV_2L' => 'CB.PV_2L',
  716. 'SURPLUS_2L' => 'CB.SURPLUS_2L',
  717. 'PV_3L' => 'CB.PV_3L',
  718. 'SURPLUS_3L' => 'CB.SURPLUS_3L',
  719. 'CALCULATED_AT' => 'CB.CALCULATED_AT',
  720. 'CALC_MONTH' => 'CB.CALC_MONTH',
  721. 'BONUS_QY_MONTH' => 'CB.BONUS_QY_MONTH',
  722. ]);
  723. $periodNum = Period::calculatedMaxPeriodNum();
  724. $period = Period::instance();
  725. $yearMonth = $period->getYearMonth($periodNum);
  726. $filter['condition'] .= ' AND PERIOD_NUM=:PERIOD_NUM';
  727. $filter['params'][':PERIOD_NUM'] = $periodNum;
  728. $form = new BonusExportForm();
  729. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth]]), '最新奖金');
  730. if (!$result) {
  731. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  732. }
  733. return static::notice('导出开始,请到文件管理-导出文件查看');
  734. }
  735. /**
  736. * 获取往期已结算的奖金
  737. * @return mixed
  738. * @throws \yii\db\Exception
  739. * @throws \yii\web\HttpException
  740. */
  741. public function actionOtherPeriodBonus() {
  742. $periodNumRequest = \Yii::$app->request->get('periodNum');
  743. if(!$periodNumRequest){
  744. $periodNum = Period::calculatedMaxPeriodNum();
  745. //return static::notice('请填写期数',400);
  746. }else{
  747. $periodNum = explode(",", $periodNumRequest)[1];
  748. }
  749. $data = $this->_periodBonus($periodNum,false);
  750. if( isset($data['filterTypes']) && is_array($data['filterTypes']) ) {
  751. $data['filterTypes'] = array_merge(['periodNum'=>['isUserTable'=> false, 'name'=> '结算期数']], $data['filterTypes']);
  752. }
  753. return static::notice($data);
  754. }
  755. /**
  756. * 往期奖金导出
  757. * @return mixed
  758. * @throws \yii\db\Exception
  759. * @throws \yii\web\HttpException
  760. */
  761. public function actionOtherPeriodBonusExport() {
  762. $filter = $this->filterCondition([
  763. 'periodNum' => 'CB.PERIOD_NUM',
  764. 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
  765. 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
  766. 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
  767. 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
  768. 'LAST_MOBILE' => 'CB.LAST_MOBILE',
  769. 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
  770. 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
  771. 'LAST_REC_USER_NAME' => 'CB.LAST_REC_USER_NAME',
  772. 'LAST_REC_REAL_NAME' => 'CB.LAST_REC_REAL_NAME',
  773. 'LAST_CON_USER_NAME' => 'CB.LAST_CON_USER_NAME',
  774. 'LAST_CON_REAL_NAME' => 'CB.LAST_CON_REAL_NAME',
  775. 'BONUS_BD' => 'CB.BONUS_BD',
  776. 'BONUS_TG' => 'CB.BONUS_TG',
  777. 'BONUS_YJ' => 'CB.BONUS_YJ',
  778. 'BONUS_GX' => 'CB.BONUS_GX',
  779. 'BONUS_GL' => 'CB.BONUS_GL',
  780. 'BONUS_QY' => 'CB.BONUS_QY',
  781. 'BONUS_YC' => 'CB.BONUS_YC',
  782. 'PV_1L' => 'CB.PV_1L',
  783. 'SURPLUS_1L' => 'CB.SURPLUS_1L',
  784. 'PV_2L' => 'CB.PV_2L',
  785. 'SURPLUS_2L' => 'CB.SURPLUS_2L',
  786. 'PV_3L' => 'CB.PV_3L',
  787. 'SURPLUS_3L' => 'CB.SURPLUS_3L',
  788. 'CALCULATED_AT' => 'CB.CALCULATED_AT',
  789. 'CALC_MONTH' => 'CB.CALC_MONTH',
  790. 'BONUS_QY_MONTH' => 'CB.BONUS_QY_MONTH',
  791. ]);
  792. $periodNumRequest = \Yii::$app->request->get('periodNum');
  793. if(!$periodNumRequest){
  794. $periodNum = Period::calculatedMaxPeriodNum();
  795. }else{
  796. $periodNum = explode(",", $periodNumRequest)[1];
  797. }
  798. // if(!isset($filter['params'][':PERIODNUM'])){
  799. // return static::notice('请填写期数',400);
  800. // }
  801. // $periodNum = $filter['params'][':PERIODNUM'];
  802. $period = Period::instance();
  803. $yearMonth = $period->getYearMonth($periodNum);
  804. // $filter['condition'] .= ' AND CB.PERIOD_NUM=:PERIOD_NUM';
  805. // $filter['params'][':PERIOD_NUM'] = $periodNum;
  806. $form = new BonusExportForm();
  807. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth]]), '往期奖金');
  808. if (!$result) {
  809. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  810. }
  811. return static::notice('导出开始,请到文件管理-导出文件查看');
  812. }
  813. /**
  814. * 获取筛选类型
  815. * @return mixed
  816. * @throws \yii\web\HttpException
  817. */
  818. public function actionOtherPeriodBonusFilterTypes(){
  819. $listObj = new PeriodBonusList();
  820. $filterTypes = $listObj->getFilterTypes();
  821. $filterTypes = array_merge(['periodNum'=>['isUserTable'=> false, 'name'=> '结算期数']], $filterTypes);
  822. return static::notice($filterTypes);
  823. }
  824. /**
  825. * 期数对应的奖金
  826. * @param $periodNum
  827. * @param $periodFilter
  828. * @return array
  829. * @throws \yii\base\Exception
  830. * @throws \yii\db\Exception
  831. */
  832. private function _periodBonus($periodNum,$periodFilter = true) {
  833. $filter = $this->filterCondition([
  834. 'periodNum' => 'CB.PERIOD_NUM',
  835. 'LAST_USER_NAME' => 'CB.LAST_USER_NAME',
  836. 'LAST_REAL_NAME' => 'CB.LAST_REAL_NAME',
  837. 'LAST_DEC_LV_NAME' => 'CB.LAST_DEC_LV',
  838. 'LAST_EMP_LV_NAME' => 'CB.LAST_EMP_LV',
  839. 'LAST_MOBILE' => 'CB.LAST_MOBILE',
  840. 'LAST_PERIOD_AT' => 'CB.LAST_PERIOD_AT',
  841. 'LAST_CREATED_AT' => 'CB.LAST_CREATED_AT',
  842. 'LAST_REC_USER_NAME' => 'CB.LAST_REC_USER_NAME',
  843. 'LAST_REC_REAL_NAME' => 'CB.LAST_REC_REAL_NAME',
  844. 'LAST_CON_USER_NAME' => 'CB.LAST_CON_USER_NAME',
  845. 'LAST_CON_REAL_NAME' => 'CB.LAST_CON_REAL_NAME',
  846. 'BONUS_BD' => 'CB.BONUS_BD',
  847. 'BONUS_TG' => 'CB.BONUS_TG',
  848. 'BONUS_XF' => 'CB.BONUS_XF',
  849. 'BONUS_YJ' => 'CB.BONUS_YJ',
  850. 'BONUS_GX' => 'CB.BONUS_GX',
  851. 'BONUS_GL' => 'CB.BONUS_GL',
  852. 'BONUS_QY' => 'CB.BONUS_QY',
  853. 'BONUS_YC' => 'CB.BONUS_YC',
  854. 'ORI_BONUS_STANDARD' => 'CB.ORI_BONUS_STANDARD',
  855. 'PV_1L' => 'CB.PV_1L',
  856. 'SURPLUS_1L' => 'CB.SURPLUS_1L',
  857. 'PV_2L' => 'CB.PV_2L',
  858. 'SURPLUS_2L' => 'CB.SURPLUS_2L',
  859. 'PV_3L' => 'CB.PV_3L',
  860. 'SURPLUS_3L' => 'CB.SURPLUS_3L',
  861. 'CALCULATED_AT' => 'CB.CALCULATED_AT',
  862. 'CALC_MONTH' => 'CB.CALC_MONTH',
  863. 'BONUS_QY_MONTH' => 'CB.BONUS_QY_MONTH',
  864. ]);
  865. $period = Period::instance();
  866. $yearMonth = $period->getYearMonth($periodNum);
  867. $condition = $filter['condition'];
  868. $params = $filter['params'];
  869. if($periodFilter){
  870. $condition .= ' AND CB.PERIOD_NUM=:PERIOD_NUM';
  871. $params[':PERIOD_NUM'] = $periodNum;
  872. }
  873. $listObj = new PeriodBonusList();
  874. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth]]);
  875. return $data;
  876. }
  877. /**
  878. * 团队奖奖金向下追溯
  879. * @return mixed
  880. * @throws \yii\base\Exception
  881. * @throws \yii\db\Exception
  882. * @throws \yii\web\HttpException
  883. */
  884. public function actionTraceDownQy() {
  885. $periodNum = Yii::$app->request->get('periodNum');
  886. if (!$periodNum) return static::notice('请填写期数', 400);
  887. $userName = Yii::$app->request->get('userName');
  888. if (!$userName) return static::notice('请填写会员编号', 400);
  889. $period = Period::instance();
  890. if (!$period->isCalculated($periodNum)) {
  891. return static::notice([]);
  892. }
  893. $yearMonth = $period->getYearMonth($periodNum);
  894. $filter = $this->filterCondition([
  895. 'decType' => 'PO.DEC_TYPE',
  896. 'periodNum' => 'PO.PERIOD_NUM',
  897. ]);
  898. $qyFilter = $this->_qyFilterCondition($filter['request']);
  899. $filter = array_merge($filter, $qyFilter);
  900. $condition = $filter['condition'];
  901. $params = $filter['params'];
  902. $listObj = new TraceDownQyList();
  903. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  904. return static::notice($data);
  905. }
  906. /**
  907. * 获取
  908. * @param $request
  909. * @return array|string[]
  910. */
  911. private function _qyFilterCondition($request) {
  912. //根据USER_NAME获取USER_ID
  913. $user = User::find()->select('ID')->where('USER_NAME=:USER_NAME', ['USER_NAME'=>$request['userName']])->asArray()->one();
  914. if( !$user ) return [];
  915. //找到这个会员的LOCATION_TAG
  916. $userNetwork = UserNetwork::find()->select(['LOCATION_TAG'])->where('USER_ID=:USER_ID', ['USER_ID'=>$user['ID']])->asArray()->one();
  917. $searchLocationTag = $userNetwork['LOCATION_TAG'];
  918. if( isset($request['location']) && $request['location'] ) {
  919. $searchLocationTag .= $request['location'];
  920. }
  921. return [
  922. 'LOCATION_TAG' => 'LIKE ' . $searchLocationTag . '%'
  923. ];
  924. }
  925. /**
  926. * 团队奖向下追溯导出
  927. * @return mixed
  928. * @throws \yii\db\Exception
  929. * @throws \yii\web\HttpException
  930. */
  931. public function actionTraceDownQyExport() {
  932. $periodNum = Yii::$app->request->get('periodNum');
  933. if (!$periodNum) return static::notice('请填写期数', 400);
  934. $userName = Yii::$app->request->get('userName');
  935. if (!$userName) return static::notice('请填写会员编号', 400);
  936. $period = Period::instance();
  937. if (!$period->isCalculated($periodNum)) {
  938. return static::notice([]);
  939. }
  940. $yearMonth = $period->getYearMonth($periodNum);
  941. $filter = $this->filterCondition([
  942. 'decType' => 'PO.DEC_TYPE',
  943. 'periodNum' => 'PO.PERIOD_NUM',
  944. ]);
  945. $qyFilter = $this->_qyFilterCondition($filter['request']);
  946. $filter = array_merge($filter, $qyFilter);
  947. $form = new BonusExportForm();
  948. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '团队奖向下追溯');
  949. if (!$result) {
  950. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  951. }
  952. return static::notice('导出开始,请到文件管理-导出文件查看');
  953. }
  954. /**
  955. * 团队奖向上追溯
  956. * @return mixed
  957. * @throws \yii\base\Exception
  958. * @throws \yii\web\HttpException
  959. */
  960. public function actionTraceUpQy() {
  961. $periodNum = Yii::$app->request->get('periodNum');
  962. if (!$periodNum) return static::notice('请填写期数', 400);
  963. if (!$userName = Yii::$app->request->get('userName')) return static::notice('请填写会员编号', 400);
  964. if(!$userId = Info::getUserIdByUserName($userName)) return static::notice('会员不存在', 400);
  965. //会员是否有业绩单
  966. if(!PerfOrder::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$userId,':PERIOD_NUM'=>$periodNum])->exists()){
  967. return static::notice('该会员本期没有业绩单', 400);
  968. }
  969. $listObj = new TraceUpQyList();
  970. $data = $listObj->getList(['condition'=>'', 'params'=>[], 'others'=>['userId'=>$userId, 'periodNum'=>$periodNum]]);
  971. return static::notice($data);
  972. }
  973. /**
  974. * 团队奖向上追溯导出
  975. * @return mixed
  976. * @throws \yii\db\Exception
  977. * @throws \yii\web\HttpException
  978. */
  979. public function actionTraceUpQyExport() {
  980. $periodNum = Yii::$app->request->get('periodNum');
  981. if (!$periodNum) return static::notice('请填写期数', 400);
  982. if (!$userName = Yii::$app->request->get('userName')) return static::notice('请填写会员编号', 400);
  983. if(!$userId = Info::getUserIdByUserName($userName)) return static::notice('会员不存在', 400);
  984. //会员是否有业绩单
  985. if(!PerfOrder::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$userId,':PERIOD_NUM'=>$periodNum])->exists()){
  986. return static::notice('该会员本期没有业绩单', 400);
  987. }
  988. $form = new BonusExportForm();
  989. $result = $form->run(array_merge(['condition'=>'', 'params'=>[]], ['others'=>['userId'=>$userId, 'periodNum'=>$periodNum]]), '团队奖向上追溯');
  990. if (!$result) {
  991. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  992. }
  993. return static::notice('导出开始,请到文件管理-导出文件查看');
  994. }
  995. /**
  996. * 荣衔奖向下追溯
  997. * @return mixed
  998. * @throws \yii\base\Exception
  999. * @throws \yii\db\Exception
  1000. * @throws \yii\web\HttpException
  1001. */
  1002. public function actionTraceDownYc() {
  1003. $periodNum = Yii::$app->request->get('periodNum');
  1004. if (!$periodNum) return static::notice([]);
  1005. $period = Period::instance();
  1006. $yearMonth = $period->getYearMonth($periodNum);
  1007. $filter = $this->filterCondition([
  1008. 'userName' => 'UI.USER_NAME',
  1009. 'periodNum' => 'CBY.PERIOD_NUM',
  1010. ]);
  1011. $condition = $filter['condition'];
  1012. $params = $filter['params'];
  1013. $listObj = new TraceDownYcList();
  1014. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1015. return static::notice($data);
  1016. }
  1017. /**
  1018. * 荣衔奖向下追溯导出
  1019. * @return mixed
  1020. * @throws \yii\db\Exception
  1021. * @throws \yii\web\HttpException
  1022. */
  1023. public function actionTraceDownYcExport() {
  1024. $periodNum = Yii::$app->request->get('periodNum');
  1025. if (!$periodNum) return static::notice([]);
  1026. $period = Period::instance();
  1027. $yearMonth = $period->getYearMonth($periodNum);
  1028. $filter = $this->filterCondition([
  1029. 'userName' => 'UI.USER_NAME',
  1030. 'periodNum' => 'CBY.PERIOD_NUM',
  1031. ]);
  1032. $form = new BonusExportForm();
  1033. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向下追溯');
  1034. if (!$result) {
  1035. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1036. }
  1037. return static::notice('导出开始,请到文件管理-导出文件查看');
  1038. }
  1039. /**
  1040. * 服务奖向下追溯
  1041. * @return mixed
  1042. * @throws \yii\base\Exception
  1043. * @throws \yii\db\Exception
  1044. * @throws \yii\web\HttpException
  1045. */
  1046. public function actionTraceDownBd() {
  1047. $periodNum = Yii::$app->request->get('periodNum');
  1048. if (!$periodNum) return static::notice([]);
  1049. $period = Period::instance();
  1050. $yearMonth = $period->getYearMonth($periodNum);
  1051. $filter = $this->filterCondition([
  1052. 'userName' => 'UI.USER_NAME',
  1053. 'periodNum' => 'CBB.PERIOD_NUM',
  1054. ]);
  1055. $condition = $filter['condition'];
  1056. $params = $filter['params'];
  1057. $listObj = new TraceDownBdList();
  1058. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1059. return static::notice($data);
  1060. }
  1061. /**
  1062. * 服务奖向下追溯导出
  1063. * @return mixed
  1064. * @throws \yii\db\Exception
  1065. * @throws \yii\web\HttpException
  1066. */
  1067. public function actionTraceDownBdExport() {
  1068. $periodNum = Yii::$app->request->get('periodNum');
  1069. if (!$periodNum) return static::notice([]);
  1070. $period = Period::instance();
  1071. $yearMonth = $period->getYearMonth($periodNum);
  1072. $filter = $this->filterCondition([
  1073. 'userName' => 'UI.USER_NAME',
  1074. 'periodNum' => 'CBB.PERIOD_NUM',
  1075. ]);
  1076. $form = new BonusExportForm();
  1077. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '服务奖向下追溯');
  1078. if (!$result) {
  1079. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1080. }
  1081. return static::notice('导出开始,请到文件管理-导出文件查看');
  1082. }
  1083. /**
  1084. * 推广奖向下追溯
  1085. * @return mixed
  1086. * @throws \yii\base\Exception
  1087. * @throws \yii\db\Exception
  1088. * @throws \yii\web\HttpException
  1089. */
  1090. public function actionTraceDownTg() {
  1091. $periodNum = Yii::$app->request->get('periodNum');
  1092. if (!$periodNum) return static::notice([]);
  1093. $period = Period::instance();
  1094. $yearMonth = $period->getYearMonth($periodNum);
  1095. $filter = $this->filterCondition([
  1096. 'userName' => 'UI.USER_NAME',
  1097. 'periodNum' => 'CTG.PERIOD_NUM',
  1098. ]);
  1099. $condition = $filter['condition'];
  1100. $params = $filter['params'];
  1101. $listObj = new TraceDownTgList();
  1102. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1103. return static::notice($data);
  1104. }
  1105. /**
  1106. * 推广奖向下追溯导出
  1107. * @return mixed
  1108. * @throws \yii\db\Exception
  1109. * @throws \yii\web\HttpException
  1110. */
  1111. public function actionTraceDownTgExport() {
  1112. $periodNum = Yii::$app->request->get('periodNum');
  1113. if (!$periodNum) return static::notice([]);
  1114. $period = Period::instance();
  1115. $yearMonth = $period->getYearMonth($periodNum);
  1116. $filter = $this->filterCondition([
  1117. 'userName' => 'UI.USER_NAME',
  1118. 'periodNum' => 'CTG.PERIOD_NUM',
  1119. ]);
  1120. $form = new BonusExportForm();
  1121. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '推广奖向下追溯');
  1122. if (!$result) {
  1123. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1124. }
  1125. return static::notice('导出开始,请到文件管理-导出文件查看');
  1126. }
  1127. /**
  1128. * 消费奖向下追溯
  1129. * @return mixed
  1130. * @throws \yii\base\Exception
  1131. * @throws \yii\db\Exception
  1132. * @throws \yii\web\HttpException
  1133. */
  1134. public function actionTraceDownXf() {
  1135. $periodNum = Yii::$app->request->get('periodNum');
  1136. if (!$periodNum) return static::notice([]);
  1137. $period = Period::instance();
  1138. $yearMonth = $period->getYearMonth($periodNum);
  1139. $filter = $this->filterCondition([
  1140. 'userName' => 'UI.USER_NAME',
  1141. 'periodNum' => 'CXF.PERIOD_NUM',
  1142. ]);
  1143. $condition = $filter['condition'];
  1144. $params = $filter['params'];
  1145. $listObj = new TraceDownXfList();
  1146. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1147. return static::notice($data);
  1148. }
  1149. /**
  1150. * 消费奖向下追溯导出
  1151. * @return mixed
  1152. * @throws \yii\db\Exception
  1153. * @throws \yii\web\HttpException
  1154. */
  1155. public function actionTraceDownXfExport() {
  1156. $periodNum = Yii::$app->request->get('periodNum');
  1157. if (!$periodNum) return static::notice([]);
  1158. $period = Period::instance();
  1159. $yearMonth = $period->getYearMonth($periodNum);
  1160. $filter = $this->filterCondition([
  1161. 'userName' => 'UI.USER_NAME',
  1162. 'periodNum' => 'CXF.PERIOD_NUM',
  1163. ]);
  1164. $form = new BonusExportForm();
  1165. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '推广奖向下追溯');
  1166. if (!$result) {
  1167. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1168. }
  1169. return static::notice('导出开始,请到文件管理-导出文件查看');
  1170. }
  1171. /**
  1172. * 业绩奖向下追溯
  1173. * @return mixed
  1174. * @throws \yii\base\Exception
  1175. * @throws \yii\db\Exception
  1176. * @throws \yii\web\HttpException
  1177. */
  1178. public function actionTraceDownYj() {
  1179. $periodNum = Yii::$app->request->get('periodNum');
  1180. if (!$periodNum) return static::notice([]);
  1181. $period = Period::instance();
  1182. $yearMonth = $period->getYearMonth($periodNum);
  1183. $filter = $this->filterCondition([
  1184. 'userName' => 'UI.USER_NAME',
  1185. 'periodNum' => 'CYJ.PERIOD_NUM',
  1186. ]);
  1187. $condition = $filter['condition'];
  1188. $params = $filter['params'];
  1189. $listObj = new TraceDownYjList();
  1190. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1191. return static::notice($data);
  1192. }
  1193. /**
  1194. * 业绩奖向下追溯导出
  1195. * @return mixed
  1196. * @throws \yii\db\Exception
  1197. * @throws \yii\web\HttpException
  1198. */
  1199. public function actionTraceDownYjExport() {
  1200. $periodNum = Yii::$app->request->get('periodNum');
  1201. if (!$periodNum) return static::notice([]);
  1202. $period = Period::instance();
  1203. $yearMonth = $period->getYearMonth($periodNum);
  1204. $filter = $this->filterCondition([
  1205. 'userName' => 'UI.USER_NAME',
  1206. 'periodNum' => 'CYJ.PERIOD_NUM',
  1207. ]);
  1208. $form = new BonusExportForm();
  1209. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '业绩奖向下追溯');
  1210. if (!$result) {
  1211. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1212. }
  1213. return static::notice('导出开始,请到文件管理-导出文件查看');
  1214. }
  1215. /**
  1216. * 共享奖向下追溯
  1217. * @return mixed
  1218. * @throws \yii\base\Exception
  1219. * @throws \yii\db\Exception
  1220. * @throws \yii\web\HttpException
  1221. */
  1222. public function actionTraceDownGx() {
  1223. $periodNum = Yii::$app->request->get('periodNum');
  1224. if (!$periodNum) return static::notice([]);
  1225. $period = Period::instance();
  1226. $yearMonth = $period->getYearMonth($periodNum);
  1227. $filter = $this->filterCondition([
  1228. 'userName' => 'UI.USER_NAME',
  1229. 'periodNum' => 'CGX.PERIOD_NUM',
  1230. ]);
  1231. $condition = $filter['condition'];
  1232. $params = $filter['params'];
  1233. $listObj = new TraceDownGxList();
  1234. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1235. return static::notice($data);
  1236. }
  1237. /**
  1238. * 共享奖向下追溯导出
  1239. * @return mixed
  1240. * @throws \yii\db\Exception
  1241. * @throws \yii\web\HttpException
  1242. */
  1243. public function actionTraceDownGxExport() {
  1244. $periodNum = Yii::$app->request->get('periodNum');
  1245. if (!$periodNum) return static::notice([]);
  1246. $period = Period::instance();
  1247. $yearMonth = $period->getYearMonth($periodNum);
  1248. $filter = $this->filterCondition([
  1249. 'userName' => 'UI.USER_NAME',
  1250. 'periodNum' => 'CGX.PERIOD_NUM',
  1251. ]);
  1252. $form = new BonusExportForm();
  1253. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '共享奖向下追溯');
  1254. if (!$result) {
  1255. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1256. }
  1257. return static::notice('导出开始,请到文件管理-导出文件查看');
  1258. }
  1259. /**
  1260. * 管理奖向下追溯
  1261. * @return mixed
  1262. * @throws \yii\base\Exception
  1263. * @throws \yii\db\Exception
  1264. * @throws \yii\web\HttpException
  1265. */
  1266. public function actionTraceDownGl() {
  1267. $periodNum = Yii::$app->request->get('periodNum');
  1268. if (!$periodNum) return static::notice([]);
  1269. $period = Period::instance();
  1270. $yearMonth = $period->getYearMonth($periodNum);
  1271. $filter = $this->filterCondition([
  1272. 'userName' => 'UI.USER_NAME',
  1273. 'periodNum' => 'CGL.PERIOD_NUM',
  1274. ]);
  1275. $condition = $filter['condition'];
  1276. $params = $filter['params'];
  1277. $listObj = new TraceDownGlList();
  1278. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1279. return static::notice($data);
  1280. }
  1281. /**
  1282. * 管理奖向下追溯导出
  1283. * @return mixed
  1284. * @throws \yii\db\Exception
  1285. * @throws \yii\web\HttpException
  1286. */
  1287. public function actionTraceDownGlExport() {
  1288. $periodNum = Yii::$app->request->get('periodNum');
  1289. if (!$periodNum) return static::notice([]);
  1290. $period = Period::instance();
  1291. $yearMonth = $period->getYearMonth($periodNum);
  1292. $filter = $this->filterCondition([
  1293. 'userName' => 'UI.USER_NAME',
  1294. 'periodNum' => 'CGL.PERIOD_NUM',
  1295. ]);
  1296. $form = new BonusExportForm();
  1297. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '管理奖向下追溯');
  1298. if (!$result) {
  1299. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1300. }
  1301. return static::notice('导出开始,请到文件管理-导出文件查看');
  1302. }
  1303. /**
  1304. * 荣衔奖向上追溯
  1305. * @return mixed
  1306. * @throws \yii\base\Exception
  1307. * @throws \yii\db\Exception
  1308. * @throws \yii\web\HttpException
  1309. */
  1310. public function actionTraceUpYc() {
  1311. $periodNum = Yii::$app->request->get('periodNum');
  1312. if (!$periodNum) return static::notice([]);
  1313. $period = Period::instance();
  1314. $yearMonth = $period->getYearMonth($periodNum);
  1315. $filter = $this->filterCondition([
  1316. 'userName' => 'UI.USER_NAME',
  1317. 'periodNum' => 'CBY.PERIOD_NUM',
  1318. ]);
  1319. $condition = $filter['condition'];
  1320. $params = $filter['params'];
  1321. $listObj = new TraceUpYcList();
  1322. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1323. return static::notice($data);
  1324. }
  1325. /**
  1326. * 荣衔奖向上追溯导出
  1327. * @return mixed
  1328. * @throws \yii\db\Exception
  1329. * @throws \yii\web\HttpException
  1330. */
  1331. public function actionTraceUpYcExport() {
  1332. $periodNum = Yii::$app->request->get('periodNum');
  1333. if (!$periodNum) return static::notice([]);
  1334. $period = Period::instance();
  1335. $yearMonth = $period->getYearMonth($periodNum);
  1336. $filter = $this->filterCondition([
  1337. 'userName' => 'UI.USER_NAME',
  1338. 'periodNum' => 'CBY.PERIOD_NUM',
  1339. ]);
  1340. $form = new BonusExportForm();
  1341. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1342. if (!$result) {
  1343. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1344. }
  1345. return static::notice('导出开始,请到文件管理-导出文件查看');
  1346. }
  1347. /**
  1348. * 服务奖向上追溯
  1349. * @return mixed
  1350. * @throws \yii\base\Exception
  1351. * @throws \yii\db\Exception
  1352. * @throws \yii\web\HttpException
  1353. */
  1354. public function actionTraceUpBd() {
  1355. $periodNum = Yii::$app->request->get('periodNum');
  1356. if (!$periodNum) return static::notice([]);
  1357. $period = Period::instance();
  1358. $yearMonth = $period->getYearMonth($periodNum);
  1359. $filter = $this->filterCondition([
  1360. 'userName' => 'UI.USER_NAME',
  1361. 'periodNum' => 'CBB.PERIOD_NUM',
  1362. ]);
  1363. $condition = $filter['condition'];
  1364. $params = $filter['params'];
  1365. $listObj = new TraceUpBdList();
  1366. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1367. return static::notice($data);
  1368. }
  1369. /**
  1370. * 服务奖向上追溯导出
  1371. * @return mixed
  1372. * @throws \yii\db\Exception
  1373. * @throws \yii\web\HttpException
  1374. */
  1375. public function actionTraceUpBdExport() {
  1376. $periodNum = Yii::$app->request->get('periodNum');
  1377. if (!$periodNum) return static::notice([]);
  1378. $period = Period::instance();
  1379. $yearMonth = $period->getYearMonth($periodNum);
  1380. $filter = $this->filterCondition([
  1381. 'userName' => 'UI.USER_NAME',
  1382. 'periodNum' => 'CBY.PERIOD_NUM',
  1383. ]);
  1384. $form = new BonusExportForm();
  1385. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1386. if (!$result) {
  1387. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1388. }
  1389. return static::notice('导出开始,请到文件管理-导出文件查看');
  1390. }
  1391. /**
  1392. * 推广奖向上追溯
  1393. * @return mixed
  1394. * @throws \yii\base\Exception
  1395. * @throws \yii\db\Exception
  1396. * @throws \yii\web\HttpException
  1397. */
  1398. public function actionTraceUpTg() {
  1399. $periodNum = Yii::$app->request->get('periodNum');
  1400. if (!$periodNum) return static::notice([]);
  1401. $period = Period::instance();
  1402. $yearMonth = $period->getYearMonth($periodNum);
  1403. $filter = $this->filterCondition([
  1404. 'userName' => 'UI.USER_NAME',
  1405. 'periodNum' => 'CTG.PERIOD_NUM',
  1406. ]);
  1407. $condition = $filter['condition'];
  1408. $params = $filter['params'];
  1409. $listObj = new TraceUpTgList();
  1410. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1411. return static::notice($data);
  1412. }
  1413. /**
  1414. * 推广奖向上追溯导出
  1415. * @return mixed
  1416. * @throws \yii\db\Exception
  1417. * @throws \yii\web\HttpException
  1418. */
  1419. public function actionTraceUpTgExport() {
  1420. $periodNum = Yii::$app->request->get('periodNum');
  1421. if (!$periodNum) return static::notice([]);
  1422. $period = Period::instance();
  1423. $yearMonth = $period->getYearMonth($periodNum);
  1424. $filter = $this->filterCondition([
  1425. 'userName' => 'UI.USER_NAME',
  1426. 'periodNum' => 'CTG.PERIOD_NUM',
  1427. ]);
  1428. $form = new BonusExportForm();
  1429. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1430. if (!$result) {
  1431. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1432. }
  1433. return static::notice('导出开始,请到文件管理-导出文件查看');
  1434. }
  1435. /**
  1436. * 消费奖向上追溯
  1437. * @return mixed
  1438. * @throws \yii\base\Exception
  1439. * @throws \yii\db\Exception
  1440. * @throws \yii\web\HttpException
  1441. */
  1442. public function actionTraceUpXf() {
  1443. $periodNum = Yii::$app->request->get('periodNum');
  1444. if (!$periodNum) return static::notice([]);
  1445. $period = Period::instance();
  1446. $yearMonth = $period->getYearMonth($periodNum);
  1447. $filter = $this->filterCondition([
  1448. 'userName' => 'UI.USER_NAME',
  1449. 'periodNum' => 'CXF.PERIOD_NUM',
  1450. ]);
  1451. $condition = $filter['condition'];
  1452. $params = $filter['params'];
  1453. $listObj = new TraceUpXfList();
  1454. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1455. return static::notice($data);
  1456. }
  1457. /**
  1458. * 推广奖向上追溯导出
  1459. * @return mixed
  1460. * @throws \yii\db\Exception
  1461. * @throws \yii\web\HttpException
  1462. */
  1463. public function actionTraceUpXfExport() {
  1464. $periodNum = Yii::$app->request->get('periodNum');
  1465. if (!$periodNum) return static::notice([]);
  1466. $period = Period::instance();
  1467. $yearMonth = $period->getYearMonth($periodNum);
  1468. $filter = $this->filterCondition([
  1469. 'userName' => 'UI.USER_NAME',
  1470. 'periodNum' => 'CXF.PERIOD_NUM',
  1471. ]);
  1472. $form = new BonusExportForm();
  1473. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1474. if (!$result) {
  1475. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1476. }
  1477. return static::notice('导出开始,请到文件管理-导出文件查看');
  1478. }
  1479. /**
  1480. * 业绩奖向上追溯
  1481. * @return mixed
  1482. * @throws \yii\base\Exception
  1483. * @throws \yii\db\Exception
  1484. * @throws \yii\web\HttpException
  1485. */
  1486. public function actionTraceUpYj() {
  1487. $periodNum = Yii::$app->request->get('periodNum');
  1488. if (!$periodNum) return static::notice([]);
  1489. $period = Period::instance();
  1490. $yearMonth = $period->getYearMonth($periodNum);
  1491. $filter = $this->filterCondition([
  1492. 'userName' => 'UI.USER_NAME',
  1493. 'periodNum' => 'CYJ.PERIOD_NUM',
  1494. ]);
  1495. $condition = $filter['condition'];
  1496. $params = $filter['params'];
  1497. $listObj = new TraceUpYjList();
  1498. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1499. return static::notice($data);
  1500. }
  1501. /**
  1502. * 业绩奖向上追溯导出
  1503. * @return mixed
  1504. * @throws \yii\db\Exception
  1505. * @throws \yii\web\HttpException
  1506. */
  1507. public function actionTraceUpYjExport() {
  1508. $periodNum = Yii::$app->request->get('periodNum');
  1509. if (!$periodNum) return static::notice([]);
  1510. $period = Period::instance();
  1511. $yearMonth = $period->getYearMonth($periodNum);
  1512. $filter = $this->filterCondition([
  1513. 'userName' => 'UI.USER_NAME',
  1514. 'periodNum' => 'CYJ.PERIOD_NUM',
  1515. ]);
  1516. $form = new BonusExportForm();
  1517. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1518. if (!$result) {
  1519. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1520. }
  1521. return static::notice('导出开始,请到文件管理-导出文件查看');
  1522. }
  1523. /**
  1524. * 共享奖向上追溯
  1525. * @return mixed
  1526. * @throws \yii\base\Exception
  1527. * @throws \yii\db\Exception
  1528. * @throws \yii\web\HttpException
  1529. */
  1530. public function actionTraceUpGx() {
  1531. $periodNum = Yii::$app->request->get('periodNum');
  1532. if (!$periodNum) return static::notice([]);
  1533. $period = Period::instance();
  1534. $yearMonth = $period->getYearMonth($periodNum);
  1535. $filter = $this->filterCondition([
  1536. 'userName' => 'UI.USER_NAME',
  1537. 'periodNum' => 'CGX.PERIOD_NUM',
  1538. ]);
  1539. $condition = $filter['condition'];
  1540. $params = $filter['params'];
  1541. $listObj = new TraceUpGxList();
  1542. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1543. return static::notice($data);
  1544. }
  1545. /**
  1546. * 共享奖向上追溯导出
  1547. * @return mixed
  1548. * @throws \yii\db\Exception
  1549. * @throws \yii\web\HttpException
  1550. */
  1551. public function actionTraceUpGxExport() {
  1552. $periodNum = Yii::$app->request->get('periodNum');
  1553. if (!$periodNum) return static::notice([]);
  1554. $period = Period::instance();
  1555. $yearMonth = $period->getYearMonth($periodNum);
  1556. $filter = $this->filterCondition([
  1557. 'userName' => 'UI.USER_NAME',
  1558. 'periodNum' => 'CGX.PERIOD_NUM',
  1559. ]);
  1560. $form = new BonusExportForm();
  1561. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1562. if (!$result) {
  1563. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1564. }
  1565. return static::notice('导出开始,请到文件管理-导出文件查看');
  1566. }
  1567. /**
  1568. * 管理奖向上追溯
  1569. * @return mixed
  1570. * @throws \yii\base\Exception
  1571. * @throws \yii\db\Exception
  1572. * @throws \yii\web\HttpException
  1573. */
  1574. public function actionTraceUpGl() {
  1575. $periodNum = Yii::$app->request->get('periodNum');
  1576. if (!$periodNum) return static::notice([]);
  1577. $period = Period::instance();
  1578. $yearMonth = $period->getYearMonth($periodNum);
  1579. $filter = $this->filterCondition([
  1580. 'userName' => 'UI.USER_NAME',
  1581. 'periodNum' => 'CGL.PERIOD_NUM',
  1582. ]);
  1583. $condition = $filter['condition'];
  1584. $params = $filter['params'];
  1585. $listObj = new TraceUpGlList();
  1586. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1587. return static::notice($data);
  1588. }
  1589. /**
  1590. * 管理奖向上追溯导出
  1591. * @return mixed
  1592. * @throws \yii\db\Exception
  1593. * @throws \yii\web\HttpException
  1594. */
  1595. public function actionTraceUpGlExport() {
  1596. $periodNum = Yii::$app->request->get('periodNum');
  1597. if (!$periodNum) return static::notice([]);
  1598. $period = Period::instance();
  1599. $yearMonth = $period->getYearMonth($periodNum);
  1600. $filter = $this->filterCondition([
  1601. 'userName' => 'UI.USER_NAME',
  1602. 'periodNum' => 'CGL.PERIOD_NUM',
  1603. ]);
  1604. $form = new BonusExportForm();
  1605. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '荣衔奖向上追溯');
  1606. if (!$result) {
  1607. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1608. }
  1609. return static::notice('导出开始,请到文件管理-导出文件查看');
  1610. }
  1611. /**
  1612. * 复销奖向下追溯
  1613. * @return mixed
  1614. * @throws \yii\base\Exception
  1615. * @throws \yii\db\Exception
  1616. * @throws \yii\web\HttpException
  1617. */
  1618. public function actionTraceDownFx() {
  1619. $periodNum = Yii::$app->request->get('periodNum');
  1620. if (!$periodNum) return static::notice([]);
  1621. $period = Period::instance();
  1622. $yearMonth = $period->getYearMonth($periodNum);
  1623. $filter = $this->filterCondition([
  1624. 'userName' => 'UI.USER_NAME',
  1625. 'periodNum' => 'CBF.PERIOD_NUM',
  1626. ]);
  1627. $condition = $filter['condition'];
  1628. $params = $filter['params'];
  1629. $listObj = new TraceDownFxList();
  1630. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1631. return static::notice($data);
  1632. }
  1633. /**
  1634. * 复销奖向下追溯导出
  1635. * @return mixed
  1636. * @throws \yii\db\Exception
  1637. * @throws \yii\web\HttpException
  1638. */
  1639. public function actionTraceDownFxExport() {
  1640. $periodNum = Yii::$app->request->get('periodNum');
  1641. if (!$periodNum) return static::notice([]);
  1642. $period = Period::instance();
  1643. $yearMonth = $period->getYearMonth($periodNum);
  1644. $filter = $this->filterCondition([
  1645. 'userName' => 'UI.USER_NAME',
  1646. 'periodNum' => 'CBF.PERIOD_NUM',
  1647. ]);
  1648. $form = new BonusExportForm();
  1649. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '复销奖向下追溯');
  1650. if (!$result) {
  1651. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1652. }
  1653. return static::notice('导出开始,请到文件管理-导出文件查看');
  1654. }
  1655. /**
  1656. * 复销奖向上追溯
  1657. * @return mixed
  1658. * @throws \yii\base\Exception
  1659. * @throws \yii\db\Exception
  1660. * @throws \yii\web\HttpException
  1661. */
  1662. public function actionTraceUpFx() {
  1663. $periodNum = Yii::$app->request->get('periodNum');
  1664. if (!$periodNum) return static::notice([]);
  1665. $period = Period::instance();
  1666. $yearMonth = $period->getYearMonth($periodNum);
  1667. $filter = $this->filterCondition([
  1668. 'userName' => 'UI.USER_NAME',
  1669. 'periodNum' => 'CBF.PERIOD_NUM',
  1670. ]);
  1671. $condition = $filter['condition'];
  1672. $params = $filter['params'];
  1673. $listObj = new TraceUpFxList();
  1674. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]);
  1675. return static::notice($data);
  1676. }
  1677. /**
  1678. * 复销奖向上追溯导出
  1679. * @return mixed
  1680. * @throws \yii\db\Exception
  1681. * @throws \yii\web\HttpException
  1682. */
  1683. public function actionTraceUpFxExport() {
  1684. $periodNum = Yii::$app->request->get('periodNum');
  1685. if (!$periodNum) return static::notice([]);
  1686. $period = Period::instance();
  1687. $yearMonth = $period->getYearMonth($periodNum);
  1688. $filter = $this->filterCondition([
  1689. 'userName' => 'UI.USER_NAME',
  1690. 'periodNum' => 'CBF.PERIOD_NUM',
  1691. ]);
  1692. $form = new BonusExportForm();
  1693. $result = $form->run(array_merge($filter, ['others'=>['yearMonth'=>$yearMonth, 'periodNum'=>$periodNum]]), '复销奖向上追溯');
  1694. if (!$result) {
  1695. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1696. }
  1697. return static::notice('导出开始,请到文件管理-导出文件查看');
  1698. }
  1699. /**
  1700. * 核算会员区域津贴
  1701. * @return mixed
  1702. * @throws \yii\db\Exception
  1703. * @throws \yii\web\HttpException
  1704. */
  1705. public function actionCalcQy() {
  1706. $periodNum = Yii::$app->request->get('periodNum');
  1707. $userName = Yii::$app->request->get('userName');
  1708. $period = Period::instance();
  1709. $yearMonth = $period->getYearMonth($periodNum);
  1710. if (!$userId = Info::getUserIdByUserName($userName)) {
  1711. return static::notice('会员不存在', 400);
  1712. }
  1713. $data = CalcBonus::findUseSlaves()->yearMonth($yearMonth)->where('PERIOD_NUM=:PERIOD_NUM AND USER_ID=:USER_ID', [':PERIOD_NUM' => $periodNum, ':USER_ID' => $userId])->asArray()->one();
  1714. if ($data) {
  1715. $data['REAL_NAME'] = Info::getUserRealNameByUserId($userId);
  1716. $data['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$data['LAST_DEC_LV']]['LEVEL_NAME']??'';
  1717. $data['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$data['LAST_EMP_LV']]['LEVEL_NAME']??'';
  1718. $data['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$data['LAST_STATUS']]['label']??'';
  1719. $data['AUDIT_STATUS'] = false;
  1720. if ($resendQy = ResendQYAudit::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM AND (AUDIT_STATUS=:AUDIT_STATUS_UN OR AUDIT_STATUS=:AUDIT_STATUS_TRUE)', [':USER_ID' => $userId, ':PERIOD_NUM' => $periodNum, ':AUDIT_STATUS_UN' => \Yii::$app->params['auditStatus']['un']['value'], ':AUDIT_STATUS_TRUE' => \Yii::$app->params['auditStatus']['true']['value']])->asArray()->one()) {
  1721. $data['AUDIT_STATUS'] = $resendQy['AUDIT_STATUS'];
  1722. }
  1723. }
  1724. return static::notice($data);
  1725. }
  1726. /**
  1727. * 补发区域津贴列表
  1728. * @return mixed
  1729. * @throws \yii\base\Exception
  1730. * @throws \yii\web\HttpException
  1731. */
  1732. public function actionResendQyList() {
  1733. $filter = $this->filterCondition([
  1734. 'userIds' => 'USER_ID',
  1735. 'filterStatus' => 'RESEND_STATUS',
  1736. 'PERIOD_NUM' => 'PERIOD_NUM',
  1737. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  1738. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  1739. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  1740. 'LAST_SUB_COM_NAME' => 'LAST_SUB_COM_ID',
  1741. 'LAST_AREA_NAME' => [
  1742. 'FIELD' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1743. 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1744. ],
  1745. 'LAST_SYSTEM_NAME' => 'LAST_SYSTEM_ID',
  1746. 'BONUS_QY' => 'BONUS_QY',
  1747. 'SHOULD_QY' => 'SHOULD_QY',
  1748. 'QY_1L' => 'QY_1L',
  1749. 'SURPLUS_1L' => 'SURPLUS_1L',
  1750. 'QY_2L' => 'QY_2L',
  1751. 'SURPLUS_2L' => 'SURPLUS_2L',
  1752. 'QY_3L' => 'QY_3L',
  1753. 'SURPLUS_3L' => 'SURPLUS_3L',
  1754. 'QY_4L' => 'QY_4L',
  1755. 'SURPLUS_4L' => 'SURPLUS_4L',
  1756. 'QY_5L' => 'QY_5L',
  1757. 'SURPLUS_5L' => 'SURPLUS_5L',
  1758. 'SURPLUS_LS' => 'SURPLUS_LS',
  1759. 'QY_LS' => 'QY_LS',
  1760. ]);
  1761. $condition = $filter['condition'];
  1762. $params = $filter['params'];
  1763. $listObj = new ResendQyList();
  1764. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  1765. return static::notice($data);
  1766. }
  1767. /**
  1768. * 区域津贴补发列表导出
  1769. * @return mixed
  1770. * @throws \yii\db\Exception
  1771. * @throws \yii\web\HttpException
  1772. */
  1773. public function actionResendQyListExport() {
  1774. $filter = $this->filterCondition([
  1775. 'userIds' => 'USER_ID',
  1776. 'filterStatus' => 'RESEND_STATUS',
  1777. 'PERIOD_NUM' => 'PERIOD_NUM',
  1778. 'LAST_DEC_LV_NAME' => 'LAST_DEC_LV',
  1779. 'LAST_EMP_LV_NAME' => 'LAST_EMP_LV',
  1780. 'LAST_STATUS_NAME' => 'LAST_STATUS',
  1781. 'LAST_SUB_COM_NAME' => 'LAST_SUB_COM_ID',
  1782. 'LAST_AREA_NAME' => [
  1783. 'FIELD' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1784. 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  1785. ],
  1786. 'LAST_SYSTEM_NAME' => 'LAST_SYSTEM_ID',
  1787. 'BONUS_QY' => 'BONUS_QY',
  1788. 'SHOULD_QY' => 'SHOULD_QY',
  1789. 'QY_1L' => 'QY_1L',
  1790. 'SURPLUS_1L' => 'SURPLUS_1L',
  1791. 'QY_2L' => 'QY_2L',
  1792. 'SURPLUS_2L' => 'SURPLUS_2L',
  1793. 'QY_3L' => 'QY_3L',
  1794. 'SURPLUS_3L' => 'SURPLUS_3L',
  1795. 'QY_4L' => 'QY_4L',
  1796. 'SURPLUS_4L' => 'SURPLUS_4L',
  1797. 'QY_5L' => 'QY_5L',
  1798. 'SURPLUS_5L' => 'SURPLUS_5L',
  1799. 'SURPLUS_LS' => 'SURPLUS_LS',
  1800. 'QY_LS' => 'QY_LS',
  1801. ]);
  1802. $form = new BonusExportForm();
  1803. $result = $form->run($filter, '区域津贴补发列表');
  1804. if (!$result) {
  1805. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1806. }
  1807. return static::notice('导出开始,请到文件管理-导出文件查看');
  1808. }
  1809. /**
  1810. * 补发区域津贴
  1811. * @return mixed
  1812. * @throws \yii\db\Exception
  1813. * @throws \yii\web\HttpException
  1814. */
  1815. public function actionResendQy() {
  1816. if (Yii::$app->request->isPost) {
  1817. $formModel = new ResendQYForm();
  1818. $formModel->scenario = 'apply';
  1819. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->apply()) {
  1820. if($result['logs']){
  1821. /*foreach ($result['logs'] as $k => $value) {
  1822. $userName = Info::getUserNameByUserId($value);
  1823. // Log::adminHandle('申请为会员' . $userName . '发放补发区域津贴', 0, $value, $userName);
  1824. }*/
  1825. return static::notice('申请成功,请在补发区域津贴审核管理中审核');
  1826. }else{
  1827. return static::notice('没有符合补发条件的记录',400);
  1828. }
  1829. } else {
  1830. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1831. }
  1832. }
  1833. return static::notice('非法请求', 400);
  1834. }
  1835. /**
  1836. * 补发审核表
  1837. * @return mixed
  1838. * @throws \yii\base\Exception
  1839. * @throws \yii\web\HttpException
  1840. */
  1841. public function actionResendQyAuditList() {
  1842. $filter = $this->filterCondition([
  1843. 'userIds' => 'RQYA.USER_ID',
  1844. 'filterStatus' => 'RQYA.AUDIT_STATUS',
  1845. 'SHOULD_BONUS' => 'RQYA.SHOULD_BONUS',
  1846. 'PERIOD_NUM' => 'RQYA.PERIOD_NUM',
  1847. 'CREATED_AT' => 'RQYA.CREATED_AT',
  1848. 'AUDITED_AT' => 'RQYA.AUDITED_AT',
  1849. 'RESEND_REMARK' => 'RQYA.RESEND_REMARK',
  1850. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  1851. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1852. ]);
  1853. $condition = $filter['condition'];
  1854. $params = $filter['params'];
  1855. $listObj = new ResendQyAuditList();
  1856. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  1857. return static::notice($data);
  1858. }
  1859. /**
  1860. * 补发审核表导出
  1861. * @return mixed
  1862. * @throws \yii\db\Exception
  1863. * @throws \yii\web\HttpException
  1864. */
  1865. public function actionResendQyAuditListExport() {
  1866. $filter = $this->filterCondition([
  1867. 'userIds' => 'RQYA.USER_ID',
  1868. 'filterStatus' => 'RQYA.AUDIT_STATUS',
  1869. 'SHOULD_BONUS' => 'RQYA.SHOULD_BONUS',
  1870. 'PERIOD_NUM' => 'RQYA.PERIOD_NUM',
  1871. 'CREATED_AT' => 'RQYA.CREATED_AT',
  1872. 'AUDITED_AT' => 'RQYA.AUDITED_AT',
  1873. 'RESEND_REMARK' => 'RQYA.RESEND_REMARK',
  1874. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  1875. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1876. ]);
  1877. $form = new BonusExportForm();
  1878. $result = $form->run($filter, '补发区域津贴审核列表');
  1879. if (!$result) {
  1880. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1881. }
  1882. return static::notice('导出开始,请到文件管理-导出文件查看');
  1883. }
  1884. /**
  1885. * 审核补发区域津贴
  1886. * @return mixed
  1887. * @throws \yii\db\Exception
  1888. * @throws \yii\web\HttpException
  1889. */
  1890. public function actionResendQyAudit() {
  1891. $formModel = new ResendQYForm();
  1892. $formModel->scenario = 'audit';
  1893. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
  1894. /*foreach ($result['logs'] as $k => $value) {
  1895. $userName = Info::getUserNameByUserId($value);
  1896. // Log::adminHandle('审核为会员' . $userName . '补发区域津贴', 1, $value, $userName);
  1897. }*/
  1898. return static::notice('审核补发区域津贴成功');
  1899. }
  1900. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1901. }
  1902. /**
  1903. * 删除补发区域津贴审核信息
  1904. * @return mixed
  1905. * @throws \yii\db\Exception
  1906. * @throws \yii\web\HttpException
  1907. */
  1908. public function actionResendQyAuditDelete() {
  1909. $resendQYForm = new ResendQYForm();
  1910. $result = static::delete(ResendQYAudit::class, function ($selected) use ($resendQYForm) {
  1911. $resendQYForm->beforeDelete($selected);
  1912. // Log::adminHandle('删除审核会员余额信息');
  1913. }, function ($selected) use ($resendQYForm) {
  1914. $resendQYForm->delete($selected);
  1915. // Log::adminHandle('删除审核会员余额信息');
  1916. }, true);
  1917. return $result;
  1918. }
  1919. /**
  1920. * 余额列表
  1921. * @return mixed
  1922. * @throws \yii\base\Exception
  1923. * @throws \yii\web\HttpException
  1924. */
  1925. public function actionBalanceList() {
  1926. $filter = $this->filterCondition([
  1927. 'USER_NAME' => 'UI.USER_NAME',
  1928. 'REAL_NAME' => 'UI.REAL_NAME',
  1929. 'userIds' => 'UB.USER_ID',
  1930. 'BONUS' => 'BONUS',
  1931. 'RECONSUME_POINTS' => 'RECONSUME_POINTS',
  1932. 'CASH' => 'CASH',
  1933. 'IS_DEC' => 'UI.IS_DEC',
  1934. 'PERIOD_AT' => 'UI.PERIOD_AT',
  1935. 'MOBILE' => 'UI.MOBILE',
  1936. 'TEL' => 'UI.TEL',
  1937. // 'CF' => 'CF',
  1938. // 'LX' => 'LX',
  1939. // 'HIGHEST_EMP_LV_NAME' => 'UI.HIGHEST_EMP_LV',
  1940. // 'SYSTEM_NAME' => 'UI.SYSTEM_ID',
  1941. ]);
  1942. $condition = $filter['condition'];
  1943. $params = $filter['params'];
  1944. $listObj = new BalanceList();
  1945. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  1946. return static::notice($data);
  1947. }
  1948. /**
  1949. * 会员奖金余额导出
  1950. * @return mixed
  1951. * @throws \yii\db\Exception
  1952. * @throws \yii\web\HttpException
  1953. */
  1954. public function actionBalanceExport() {
  1955. $filter = $this->filterCondition([
  1956. 'USER_NAME' => 'UI.USER_NAME',
  1957. 'REAL_NAME' => 'UI.REAL_NAME',
  1958. 'userIds' => 'UB.USER_ID',
  1959. 'BONUS' => 'BONUS',
  1960. 'IS_DEC' => 'UI.IS_DEC',
  1961. 'PERIOD_AT' => 'UI.PERIOD_AT',
  1962. 'MOBILE' => 'UI.MOBILE',
  1963. 'TEL' => 'UI.TEL',
  1964. // 'CF' => 'CF',
  1965. // 'LX' => 'LX',
  1966. ]);
  1967. $form = new BonusExportForm();
  1968. $result = $form->run($filter, '会员奖金余额');
  1969. if (!$result) {
  1970. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1971. }
  1972. return static::notice('导出开始,请到文件管理-导出文件查看');
  1973. }
  1974. /**
  1975. * 报单中心店补/补贴追溯
  1976. * @return mixed
  1977. * @throws \yii\base\Exception
  1978. * @throws \yii\web\HttpException
  1979. */
  1980. public function actionTraceBt() {
  1981. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  1982. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  1983. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  1984. $filterStatus = Yii::$app->request->get('filterStatus');
  1985. $filter = $this->filterCondition([
  1986. 'userName' => 'UI.USER_NAME',
  1987. ]);
  1988. $condition = $filter['condition'];
  1989. $params = $filter['params'];
  1990. if ($startPeriodNum) {
  1991. $condition .= ' AND CBT.PERIOD_NUM>=:START_PERIOD_NUM';
  1992. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  1993. }
  1994. if ($endPeriodNum) {
  1995. $condition .= ' AND CBT.PERIOD_NUM<=:END_PERIOD_NUM';
  1996. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  1997. }
  1998. if ($filterStatus) {
  1999. $condition .= ' AND CBT.BT_TYPE=:BT_TYPE';
  2000. $params[':BT_TYPE'] = $filterStatus;
  2001. }
  2002. $listObj = new TraceBtList();
  2003. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2004. return static::notice($data);
  2005. }
  2006. /**
  2007. * 报单中心补贴追溯导出
  2008. * @return mixed
  2009. * @throws \yii\db\Exception
  2010. * @throws \yii\web\HttpException
  2011. */
  2012. public function actionTraceBtExport() {
  2013. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2014. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2015. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2016. $filterStatus = Yii::$app->request->get('filterStatus');
  2017. $filter = $this->filterCondition([
  2018. 'userName' => 'UI.USER_NAME',
  2019. ]);
  2020. $condition = $filter['condition'];
  2021. $params = $filter['params'];
  2022. if ($startPeriodNum) {
  2023. $condition .= ' AND CBT.PERIOD_NUM>=:START_PERIOD_NUM';
  2024. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2025. }
  2026. if ($endPeriodNum) {
  2027. $condition .= ' AND CBT.PERIOD_NUM<=:END_PERIOD_NUM';
  2028. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2029. }
  2030. if ($filterStatus) {
  2031. $condition .= ' AND CBT.BT_TYPE=:BT_TYPE';
  2032. $params[':BT_TYPE'] = $filterStatus;
  2033. }
  2034. $form = new BonusExportForm();
  2035. $result = $form->run(['condition'=>$condition, 'params'=>$params], '报单中心补贴追溯');
  2036. if (!$result) {
  2037. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2038. }
  2039. return static::notice('导出开始,请到文件管理-导出文件查看');
  2040. }
  2041. /**
  2042. * 报单中心货补追溯
  2043. * @return mixed
  2044. * @throws \yii\base\Exception
  2045. * @throws \yii\web\HttpException
  2046. */
  2047. public function actionTraceFl() {
  2048. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2049. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2050. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2051. $filter = $this->filterCondition([
  2052. 'userName' => 'UI.USER_NAME',
  2053. ]);
  2054. $condition = $filter['condition'];
  2055. $params = $filter['params'];
  2056. if ($startPeriodNum) {
  2057. $condition .= ' AND CFL.PERIOD_NUM>=:START_PERIOD_NUM';
  2058. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2059. }
  2060. if ($endPeriodNum) {
  2061. $condition .= ' AND CFL.PERIOD_NUM<=:END_PERIOD_NUM';
  2062. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2063. }
  2064. $listObj = new TraceFlList();
  2065. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2066. return static::notice($data);
  2067. }
  2068. /**
  2069. * 报单中心货补追溯导出
  2070. * @return mixed
  2071. * @throws \yii\db\Exception
  2072. * @throws \yii\web\HttpException
  2073. */
  2074. public function actionTraceFlExport() {
  2075. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2076. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2077. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2078. $filter = $this->filterCondition([
  2079. 'userName' => 'UI.USER_NAME',
  2080. ]);
  2081. $condition = $filter['condition'];
  2082. $params = $filter['params'];
  2083. if ($startPeriodNum) {
  2084. $condition .= ' AND CFL.PERIOD_NUM>=:START_PERIOD_NUM';
  2085. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2086. }
  2087. if ($endPeriodNum) {
  2088. $condition .= ' AND CFL.PERIOD_NUM<=:END_PERIOD_NUM';
  2089. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2090. }
  2091. $form = new BonusExportForm();
  2092. $result = $form->run(['condition'=>$condition, 'params'=>$params], '报单中心货补追溯');
  2093. if (!$result) {
  2094. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2095. }
  2096. return static::notice('导出开始,请到文件管理-导出文件查看');
  2097. }
  2098. /**
  2099. * 区域业绩提成追溯
  2100. * @return mixed
  2101. * @throws \yii\base\Exception
  2102. * @throws \yii\web\HttpException
  2103. */
  2104. public function actionTraceFw() {
  2105. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2106. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2107. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2108. $filter = $this->filterCondition([
  2109. 'userName' => 'UI.USER_NAME',
  2110. ]);
  2111. $condition = $filter['condition'];
  2112. $params = $filter['params'];
  2113. if ($startPeriodNum) {
  2114. $condition .= ' AND CFW.PERIOD_NUM>=:START_PERIOD_NUM';
  2115. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2116. }
  2117. if ($endPeriodNum) {
  2118. $condition .= ' AND CFW.PERIOD_NUM<=:END_PERIOD_NUM';
  2119. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2120. }
  2121. $listObj = new TraceFwList();
  2122. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2123. return static::notice($data);
  2124. }
  2125. /**
  2126. * 区域业绩提成导出
  2127. * @return mixed
  2128. * @throws \yii\db\Exception
  2129. * @throws \yii\web\HttpException
  2130. */
  2131. public function actionTraceFwExport() {
  2132. $startPeriodNum = Yii::$app->request->get('startPeriodNum');
  2133. $endPeriodNum = Yii::$app->request->get('endPeriodNum');
  2134. if (!$startPeriodNum || !$endPeriodNum) return static::notice([]);
  2135. $filter = $this->filterCondition([
  2136. 'userName' => 'UI.USER_NAME',
  2137. ]);
  2138. $condition = $filter['condition'];
  2139. $params = $filter['params'];
  2140. if ($startPeriodNum) {
  2141. $condition .= ' AND CFW.PERIOD_NUM>=:START_PERIOD_NUM';
  2142. $params[':START_PERIOD_NUM'] = $startPeriodNum;
  2143. }
  2144. if ($endPeriodNum) {
  2145. $condition .= ' AND CFW.PERIOD_NUM<=:END_PERIOD_NUM';
  2146. $params[':END_PERIOD_NUM'] = $endPeriodNum;
  2147. }
  2148. $form = new BonusExportForm();
  2149. $result = $form->run(['condition'=>$condition, 'params'=>$params], '区域业绩提成追溯');
  2150. if (!$result) {
  2151. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2152. }
  2153. return static::notice('导出开始,请到文件管理-导出文件查看');
  2154. }
  2155. /**
  2156. * 业绩单
  2157. * @return mixed
  2158. * @throws \yii\base\Exception
  2159. * @throws \yii\web\HttpException
  2160. */
  2161. public function actionPerfOrder(){
  2162. $filter = $this->filterCondition([
  2163. 'PERIOD_NUM' => 'PO.PERIOD_NUM',
  2164. 'SN' => 'PO.SN',
  2165. 'DEC_STATUS_NAME' => 'PO.DEC_STATUS',
  2166. 'USER_NAME' => 'U.USER_NAME',
  2167. 'REAL_NAME' => 'U.REAL_NAME',
  2168. 'userIds' => 'PO.USER_ID',
  2169. 'filterType' => 'PO.DEC_TYPE',
  2170. 'LAST_REC_USER_NAME' => 'PO.LAST_REC_USER_NAME',
  2171. 'LAST_REC_REAL_NAME' => 'PO.LAST_REC_REAL_NAME',
  2172. 'PV' => 'PO.PV',
  2173. 'DEC_AMOUNT' => 'PO.DEC_AMOUNT',
  2174. 'DEC_SN' => 'PO.DEC_SN',
  2175. 'CREATED_AT' => 'PO.CREATED_AT',
  2176. ]);
  2177. $condition = $filter['condition'];
  2178. $params = $filter['params'];
  2179. $listObj = new PerfOrderList();
  2180. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2181. return static::notice($data);
  2182. }
  2183. /**
  2184. * 业绩单导出
  2185. * @return mixed
  2186. * @throws \yii\db\Exception
  2187. * @throws \yii\web\HttpException
  2188. */
  2189. public function actionPerfOrderExport() {
  2190. $filter = $this->filterCondition([
  2191. 'PERIOD_NUM' => 'PO.PERIOD_NUM',
  2192. 'SN' => 'PO.SN',
  2193. 'DEC_STATUS_NAME' => 'PO.DEC_STATUS',
  2194. 'userIds' => 'PO.USER_ID',
  2195. 'filterType' => 'PO.DEC_TYPE',
  2196. 'LAST_REC_USER_NAME' => 'PO.LAST_REC_USER_NAME',
  2197. 'LAST_REC_REAL_NAME' => 'PO.LAST_REC_REAL_NAME',
  2198. 'PV' => 'PO.PV',
  2199. 'DEC_AMOUNT' => 'PO.DEC_AMOUNT',
  2200. 'DEC_SN' => 'PO.DEC_SN',
  2201. 'LAST_SUB_COM_NAME' => 'PO.LAST_SUB_COM_ID',
  2202. 'LAST_SYSTEM_NAME' => 'PO.LAST_SYSTEM_ID',
  2203. 'LAST_AREA' => [
  2204. 'FIELD' => ['PO.LAST_PROVINCE', 'PO.LAST_CITY', 'PO.LAST_COUNTY'],
  2205. 'BIND' => ['LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY'],
  2206. ],
  2207. 'DEC_USER_NAME' => 'DUI.USER_NAME',
  2208. 'LAST_DEC_DEC_LV_NAME' => 'PO.LAST_DEC_DEC_LV',
  2209. 'LAST_DEC_SUB_COM_NAME' => 'PO.LAST_DEC_SUB_COM_ID',
  2210. 'LAST_DEC_AREA' => [
  2211. 'FIELD' => ['PO.LAST_DEC_PROVINCE', 'PO.LAST_DEC_CITY', 'PO.LAST_DEC_COUNTY'],
  2212. 'BIND' => ['LAST_DEC_PROVINCE', 'LAST_DEC_CITY', 'LAST_DEC_COUNTY'],
  2213. ],
  2214. 'CREATED_AT' => 'PO.CREATED_AT',
  2215. 'CLOSED_AT' => 'PO.CLOSED_AT',
  2216. ]);
  2217. $condition = $filter['condition'];
  2218. $params = $filter['params'];
  2219. $form = new BonusExportForm();
  2220. $result = $form->run(['condition'=>$condition, 'params'=>$params], '业绩单');
  2221. if (!$result) {
  2222. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2223. }
  2224. return static::notice('导出开始,请到文件管理-导出文件查看');
  2225. }
  2226. /**
  2227. * 月积分
  2228. * @return mixed
  2229. * @throws \yii\base\Exception
  2230. * @throws \yii\web\HttpException
  2231. */
  2232. public function actionScoreMonth(){
  2233. $filter = $this->filterCondition([
  2234. 'USER_NAME' => 'U.USER_NAME',
  2235. 'userIds' => 'SM.USER_ID',
  2236. 'CALC_MONTH' => 'SM.CALC_MONTH',
  2237. 'CREATED_AT' => 'SM.CREATED_AT',
  2238. ]);
  2239. $condition = $filter['condition'];
  2240. $params = $filter['params'];
  2241. $listObj = new ScoreMonthList();
  2242. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2243. return static::notice($data);
  2244. }
  2245. /**
  2246. * 月积分导出
  2247. * @return mixed
  2248. * @throws \yii\db\Exception
  2249. * @throws \yii\web\HttpException
  2250. */
  2251. public function actionScoreMonthExport() {
  2252. $filter = $this->filterCondition([
  2253. 'USER_NAME' => 'U.USER_NAME',
  2254. 'userIds' => 'SM.USER_ID',
  2255. 'CALC_MONTH' => 'SM.CALC_MONTH',
  2256. 'CREATED_AT' => 'SM.CREATED_AT',
  2257. ]);
  2258. $condition = $filter['condition'];
  2259. $params = $filter['params'];
  2260. $form = new BonusExportForm();
  2261. $result = $form->run(['condition'=>$condition, 'params'=>$params], '月积分');
  2262. if (!$result) {
  2263. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2264. }
  2265. return static::notice('导出开始,请到文件管理-导出文件查看');
  2266. }
  2267. /**
  2268. * 月业绩
  2269. * @return mixed
  2270. * @throws \yii\base\Exception
  2271. * @throws \yii\web\HttpException
  2272. */
  2273. public function actionPerfMonth(){
  2274. $filter = $this->filterCondition([
  2275. 'USER_NAME' => 'U.USER_NAME',
  2276. 'REC_USER_NAME' => 'RU.USER_NAME',
  2277. 'userIds' => 'PM.USER_ID',
  2278. 'CALC_MONTH' => 'PM.CALC_MONTH',
  2279. 'CREATED_AT' => 'PM.CREATED_AT',
  2280. ]);
  2281. $condition = $filter['condition'];
  2282. $params = $filter['params'];
  2283. $listObj = new PerfMonthList();
  2284. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2285. return static::notice($data);
  2286. }
  2287. /**
  2288. * 月业绩导出
  2289. * @return mixed
  2290. * @throws \yii\db\Exception
  2291. * @throws \yii\web\HttpException
  2292. */
  2293. public function actionPerfMonthExport() {
  2294. $filter = $this->filterCondition([
  2295. 'USER_NAME' => 'U.USER_NAME',
  2296. 'REC_USER_NAME' => 'RU.USER_NAME',
  2297. 'userIds' => 'PM.USER_ID',
  2298. 'CALC_MONTH' => 'PM.CALC_MONTH',
  2299. 'CREATED_AT' => 'PM.CREATED_AT',
  2300. ]);
  2301. $condition = $filter['condition'];
  2302. $params = $filter['params'];
  2303. $form = new BonusExportForm();
  2304. $result = $form->run(['condition'=>$condition, 'params'=>$params], '月业绩');
  2305. if (!$result) {
  2306. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2307. }
  2308. return static::notice('导出开始,请到文件管理-导出文件查看');
  2309. }
  2310. /**
  2311. * 期业绩
  2312. * @return mixed
  2313. * @throws \yii\base\Exception
  2314. * @throws \yii\web\HttpException
  2315. */
  2316. public function actionPerfPeriodList(){
  2317. $filter = $this->filterCondition([
  2318. 'USER_NAME' => 'U.USER_NAME',
  2319. 'userIds' => 'PP.USER_ID',
  2320. 'PERIOD_NUM' => 'PP.PERIOD_NUM',
  2321. 'CREATED_AT' => 'PP.CREATED_AT',
  2322. ]);
  2323. $condition = $filter['condition'];
  2324. $params = $filter['params'];
  2325. $listObj = new PerfPeriodList();
  2326. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2327. return static::notice($data);
  2328. }
  2329. /**
  2330. * 期业绩导出
  2331. * @return mixed
  2332. * @throws \yii\db\Exception
  2333. * @throws \yii\web\HttpException
  2334. */
  2335. public function actionPerfPeriodListExport() {
  2336. $filter = $this->filterCondition([
  2337. 'USER_NAME' => 'U.USER_NAME',
  2338. 'userIds' => 'PP.USER_ID',
  2339. 'PERIOD_NUM' => 'PP.PERIOD_NUM',
  2340. 'CREATED_AT' => 'PP.CREATED_AT',
  2341. ]);
  2342. $condition = $filter['condition'];
  2343. $params = $filter['params'];
  2344. $form = new BonusExportForm();
  2345. $result = $form->run(['condition'=>$condition, 'params'=>$params], '期业绩');
  2346. if (!$result) {
  2347. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2348. }
  2349. return static::notice('导出开始,请到文件管理-导出文件查看');
  2350. }
  2351. /**
  2352. * 达标业绩
  2353. * @return mixed
  2354. * @throws \yii\base\Exception
  2355. * @throws \yii\web\HttpException
  2356. */
  2357. public function actionPerfStandard(){
  2358. $filter = $this->filterCondition([
  2359. 'USER_NAME' => 'U.USER_NAME',
  2360. 'REC_USER_NAME' => 'RU.USER_NAME',
  2361. 'userIds' => 'PS.USER_ID',
  2362. 'CALC_MONTH' => 'PS.CALC_MONTH',
  2363. 'CREATED_AT' => 'PS.CREATED_AT',
  2364. ]);
  2365. $condition = $filter['condition'];
  2366. $params = $filter['params'];
  2367. $listObj = new PerfStandardList();
  2368. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2369. return static::notice($data);
  2370. }
  2371. /**
  2372. * 达标业绩导出
  2373. * @return mixed
  2374. * @throws \yii\db\Exception
  2375. * @throws \yii\web\HttpException
  2376. */
  2377. public function actionPerfStandardExport() {
  2378. $filter = $this->filterCondition([
  2379. 'USER_NAME' => 'U.USER_NAME',
  2380. 'REC_USER_NAME' => 'RU.USER_NAME',
  2381. 'userIds' => 'PS.USER_ID',
  2382. 'CALC_MONTH' => 'PS.CALC_MONTH',
  2383. 'CREATED_AT' => 'PS.CREATED_AT',
  2384. ]);
  2385. $condition = $filter['condition'];
  2386. $params = $filter['params'];
  2387. $form = new BonusExportForm();
  2388. $result = $form->run(['condition'=>$condition, 'params'=>$params], '达标业绩');
  2389. if (!$result) {
  2390. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2391. }
  2392. return static::notice('导出开始,请到文件管理-导出文件查看');
  2393. }
  2394. /**
  2395. * 会员实时业绩
  2396. * @return mixed
  2397. * @throws \yii\web\HttpException
  2398. */
  2399. public function actionRealTimePerf() {
  2400. $userName = Yii::$app->request->get('userName');
  2401. if (!$userId = Info::getUserIdByUserName($userName)) {
  2402. return static::notice('会员不存在', 400);
  2403. }
  2404. $period = Period::instance();
  2405. $newPerf = Perf::getPeriodNewPerf($userId);
  2406. $weekData = [['PV_1L' => $newPerf['PV_1L'], 'PV_2L' => $newPerf['PV_2L'], 'PV_3L' => $newPerf['PV_3L'], 'PV_4L' => $newPerf['PV_4L'], 'PV_5L' => $newPerf['PV_5L'], 'PV_PCS'=>Tool::formatPrice($newPerf['PV_PCS']), 'PV_PSS'=>Tool::formatPrice($newPerf['PV_PSS'])]];
  2407. $monthPerf = Perf::getMonthPerf($userId);
  2408. $monthData = [['PV_1L' => Tool::formatPrice($monthPerf['PV_1L']), 'PV_2L' => Tool::formatPrice($monthPerf['PV_2L']), 'PV_3L' => Tool::formatPrice($monthPerf['PV_3L']), 'PV_4L' => Tool::formatPrice($monthPerf['PV_4L']), 'PV_5L' => Tool::formatPrice($monthPerf['PV_5L']), 'PV_PCS'=>Tool::formatPrice($monthPerf['PV_PCS']), 'PV_PSS'=>Tool::formatPrice($monthPerf['PV_PSS'])]];
  2409. $lastMonth = PerfMonth::getMonthPerf($period->getLastMonth()['yearMonth'], $userId);
  2410. $lastData = [['PV_1L' => Tool::formatPrice($lastMonth['PV_1L_TOTAL']), 'PV_2L' => Tool::formatPrice($lastMonth['PV_2L_TOTAL']), 'PV_3L' => Tool::formatPrice($lastMonth['PV_3L_TOTAL']), 'PV_4L' => Tool::formatPrice($lastMonth['PV_4L_TOTAL']), 'PV_5L' => Tool::formatPrice($lastMonth['PV_5L_TOTAL']), 'PV_PCS'=>Tool::formatPrice($lastMonth['PV_PCS']), 'PV_PSS'=>Tool::formatPrice($lastMonth['PV_PSS']), 'PV_PSS_TOTAL'=>Tool::formatPrice($lastMonth['PV_PSS_TOTAL'])]];
  2411. //是否合格
  2412. // $lastChkStatus = '';
  2413. // $lastMonthPerfChk = Cache::getSystemConfig()['lastMonthPerfChk']['VALUE'];
  2414. // $lastArr = [$lastMonth['PV_1L_TOTAL'], $lastMonth['PV_2L_TOTAL'], $lastMonth['PV_3L_TOTAL'], $lastMonth['PV_4L_TOTAL'], $lastMonth['PV_5L_TOTAL']];
  2415. // if (array_sum($lastArr) >= $lastMonthPerfChk) {
  2416. // $lastChkStatus = '已合格';
  2417. // }
  2418. //判断大区
  2419. // $bigLocation = array_search(max($lastArr), $lastArr) + 1;
  2420. return static::notice(['weekData' => $weekData, 'monthData' => $monthData, 'lastData' => $lastData]);
  2421. }
  2422. /**
  2423. * 荣衔业绩
  2424. * @return mixed
  2425. * @throws \yii\web\HttpException
  2426. */
  2427. public function actionYcPerf() {
  2428. $userName = Yii::$app->request->get('userName');
  2429. if (!$userId = Info::getUserIdByUserName($userName)) {
  2430. return static::notice('会员不存在', 400);
  2431. }
  2432. $userPerfData = Perf::getUserPerf($userId);
  2433. $ycPerfList = [];
  2434. //查找推荐的子会员
  2435. $childrenList = UserInfo::findUseDbCalc()->select('USER_ID')->where('REC_UID=:REC_UID', [
  2436. 'REC_UID' => $userId
  2437. ])->asArray()->all();
  2438. $maxPvPss = 0;
  2439. $childSumPerf = 0;
  2440. foreach ($childrenList as $child) {
  2441. $childBaseUser = Info::getBaseUserById($child['USER_ID']);
  2442. if( !$childBaseUser ) continue;
  2443. $childPerfData = Perf::getUserPerf($child['USER_ID']);
  2444. if( !$childPerfData ) continue;
  2445. $childPvPcs = $childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'];
  2446. $childPvPssTotal = $childPvPcs + $childPerfData['PV_PSS'];
  2447. $childSumPerf += $childPvPssTotal;
  2448. if( $childPvPssTotal >= $maxPvPss ) {
  2449. $maxPvPss = $childPvPssTotal;
  2450. }
  2451. $ycPerfList[] = [
  2452. 'USER_NAME'=>$childBaseUser['USER_NAME'],
  2453. 'REAL_NAME'=>$childBaseUser['REAL_NAME'],
  2454. 'PV_PCS' => $childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'],
  2455. 'PV_PSS_TOTAL' => $childPerfData['PV_PSS_TOTAL'],
  2456. 'MAX_DEPART_PERF' => '-',
  2457. 'OTHER_DEPART_PERF' => '-',
  2458. 'PV_PSS_SUM_TOTAL' => round($childPerfData['PV_PCS_ZC'] + $childPerfData['PV_PCS_FX'] + $childPerfData['PV_PSS_TOTAL'],2),
  2459. ];
  2460. }
  2461. if( $userPerfData ) {
  2462. $baseUser = Info::getBaseUserById($userId);
  2463. $ycPerfData = [
  2464. 'USER_NAME'=>$baseUser['USER_NAME'],
  2465. 'REAL_NAME'=>$baseUser['REAL_NAME'],
  2466. 'PV_PCS' => $userPerfData['PV_PCS_ZC'] + $userPerfData['PV_PCS_FX'],
  2467. 'PV_PSS_TOTAL' => $userPerfData['PV_PSS_TOTAL'],
  2468. 'MAX_DEPART_PERF' => round($maxPvPss, 2),
  2469. 'OTHER_DEPART_PERF' => round($childSumPerf-$maxPvPss, 2),
  2470. 'PV_PSS_SUM_TOTAL' => round($userPerfData['PV_PCS_ZC'] + $userPerfData['PV_PCS_FX'] + $userPerfData['PV_PSS_TOTAL'],2),
  2471. ];
  2472. array_unshift($ycPerfList, $ycPerfData);
  2473. }
  2474. return static::notice(['ycPerfList' => $ycPerfList]);
  2475. }
  2476. /**
  2477. * 用户业绩
  2478. * @return mixed
  2479. * @throws \yii\web\HttpException
  2480. */
  2481. public function actionUserPerf() {
  2482. $filter = $this->filterCondition([
  2483. 'USER_NAME' => 'U.USER_NAME',
  2484. ]);
  2485. $condition = $filter['condition'];
  2486. $params = $filter['params'];
  2487. $listObj = new UserPerfList();
  2488. $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
  2489. return static::notice($data);
  2490. }
  2491. /**
  2492. * 月业绩导出
  2493. * @return mixed
  2494. * @throws \yii\db\Exception
  2495. * @throws \yii\web\HttpException
  2496. */
  2497. public function actionUserPerfExport() {
  2498. $filter = $this->filterCondition([
  2499. 'USER_NAME' => 'U.USER_NAME',
  2500. ]);
  2501. $condition = $filter['condition'];
  2502. $params = $filter['params'];
  2503. $form = new BonusExportForm();
  2504. $result = $form->run(['condition'=>$condition, 'params'=>$params], '用户业绩');
  2505. if (!$result) {
  2506. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2507. }
  2508. return static::notice('导出开始,请到文件管理-导出文件查看');
  2509. }
  2510. }