TraceUpQyList.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\bonus\CalcCache;
  5. use common\helpers\Cache;
  6. use common\helpers\Tool;
  7. use common\helpers\user\Info;
  8. use common\libs\dataList\column\Price;
  9. use common\libs\dataList\column\YesNo;
  10. use common\libs\dataList\DataListInterface;
  11. use common\models\CalcBonus;
  12. use common\models\PerfOrder;
  13. use common\models\PerfPeriod;
  14. use common\models\Period;
  15. use common\models\Region;
  16. use common\models\UserBind;
  17. use common\models\UserBonus;
  18. use common\models\UserInfo;
  19. use common\libs\dataList\column\DateTime;
  20. use common\models\UserNetwork;
  21. use common\models\UserSystem;
  22. use common\models\Withdraw;
  23. use Yii;
  24. class TraceUpQyList extends \common\libs\dataList\DataList implements DataListInterface
  25. {
  26. /**
  27. * 列表名称
  28. * @return string
  29. */
  30. public function getListName(){
  31. return '团队奖向上追溯';
  32. }
  33. /**
  34. * 列表筛选到的数据
  35. * @throws \yii\base\Exception
  36. */
  37. public function dataHandle()
  38. {
  39. $userId = $this->others['userId'];
  40. $periodNum = $this->others['periodNum'];
  41. $data = UserNetwork::getAllParentFromPeriodWithPage($userId, $periodNum);
  42. if ($data['list']) {
  43. $decTotal = CalcCache::nowPeriodPerf($userId, $periodNum);
  44. foreach ($data['list'] as $key => $value) {
  45. $perfPeriod = PerfPeriod::findOneAsArray('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$value['USER_ID'],':PERIOD_NUM'=>$periodNum]);
  46. $data['list'][$key]['PERIOD_NUM'] = $perfPeriod['PERIOD_NUM'];
  47. $data['list'][$key]['DEC_TOTAL'] = $decTotal['PV_PCS_ZC'] + $decTotal['PV_PCS_ZG'] +$decTotal['PV_LS_TOUCH'];
  48. $data['list'][$key]['USER_NAME'] = Info::getUserNameByUserId($value['USER_ID']);
  49. $data['list'][$key]['REAL_NAME'] = Info::getUserRealNameByUserId($value['USER_ID']);
  50. $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$perfPeriod['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
  51. $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$perfPeriod['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
  52. $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$perfPeriod['LAST_STATUS']]['label'] ?? '';
  53. $data['list'][$key]['PV_1L_TOUCH'] = $perfPeriod['PV_1L_TOUCH'];
  54. $data['list'][$key]['PV_2L_TOUCH'] = $perfPeriod['PV_2L_TOUCH'];
  55. $data['list'][$key]['PV_3L_TOUCH'] = $perfPeriod['PV_3L_TOUCH'];
  56. $data['list'][$key]['PV_4L_TOUCH'] = $perfPeriod['PV_4L_TOUCH'];
  57. $data['list'][$key]['PV_5L_TOUCH'] = $perfPeriod['PV_5L_TOUCH'];
  58. $data['list'][$key]['SURPLUS_1L'] = $perfPeriod['SURPLUS_1L'];
  59. $data['list'][$key]['SURPLUS_2L'] = $perfPeriod['SURPLUS_2L'];
  60. $data['list'][$key]['SURPLUS_3L'] = $perfPeriod['SURPLUS_3L'];
  61. $data['list'][$key]['SURPLUS_4L'] = $perfPeriod['SURPLUS_4L'];
  62. $data['list'][$key]['SURPLUS_5L'] = $perfPeriod['SURPLUS_5L'];
  63. $data['list'][$key]['CALC_MONTH'] = $perfPeriod['CALC_MONTH'];
  64. //区域业绩
  65. $pervSurplusPerf = CalcCache::surplusPerf($value['USER_ID'], $periodNum);
  66. $data['list'][$key]['QY_1L'] = $data['list'][$key]['PV_1L_TOUCH'] + $pervSurplusPerf['SURPLUS_1L'];
  67. $data['list'][$key]['QY_2L'] = $data['list'][$key]['PV_2L_TOUCH'] + $pervSurplusPerf['SURPLUS_2L'];
  68. $data['list'][$key]['QY_3L'] = $data['list'][$key]['PV_3L_TOUCH'] + $pervSurplusPerf['SURPLUS_3L'];
  69. $data['list'][$key]['QY_4L'] = $data['list'][$key]['PV_4L_TOUCH'] + $pervSurplusPerf['SURPLUS_4L'];
  70. $data['list'][$key]['QY_5L'] = $data['list'][$key]['PV_5L_TOUCH'] + $pervSurplusPerf['SURPLUS_5L'];
  71. unset($bonus,$bigLocation);
  72. }
  73. }
  74. $this->listData = $data;
  75. }
  76. /**
  77. * 要展示和导出的所有字段
  78. * @return array
  79. */
  80. public function getColumn(){
  81. if(!$this->columns){
  82. $this->columns = [
  83. 'PERIOD_NUM' => [
  84. 'header' => '期数',
  85. 'headerOther' => [
  86. 'width' => '150',
  87. ],
  88. ],
  89. 'USER_NAME' => [
  90. 'header' => '上级编号',
  91. 'headerOther' => [
  92. 'width' => '150',
  93. ],
  94. 'valueOther' => [
  95. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
  96. ],
  97. ],
  98. 'REAL_NAME' => [
  99. 'header' => '上级姓名',
  100. 'headerOther' => [
  101. 'width' => '120',
  102. ],
  103. 'valueOther' => [
  104. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  105. ],
  106. ],
  107. 'LOCATION' => [
  108. 'header' => '市场',
  109. 'headerOther' => [
  110. 'width' => '100',
  111. ],
  112. ],
  113. 'LAST_STATUS_NAME' => [
  114. 'header' => '结算时状态',
  115. 'headerOther' => [
  116. 'width' => '110',
  117. ],
  118. ],
  119. 'LAST_DEC_LV_NAME' => [
  120. 'header' => '结算时会员级别',
  121. 'headerOther' => [
  122. 'width' => '120',
  123. ],
  124. ],
  125. 'LAST_EMP_LV_NAME' => [
  126. 'header' => '结算时会员聘级',
  127. 'headerOther' => [
  128. 'width' => '140',
  129. ],
  130. ],
  131. 'DEC_TOTAL' => [
  132. 'header' => '报单总积分',
  133. 'headerOther' => [
  134. 'width' => '110',
  135. ],
  136. 'value' => function($row) {
  137. return (new Price([
  138. 'value' => $row['DEC_TOTAL'],
  139. ]))->result();
  140. },
  141. ],
  142. 'PV_1L_TOUCH' => [
  143. 'header' => '一市场新增业绩',
  144. 'headerOther' => [
  145. 'width' => '150',
  146. ],
  147. 'value' => function($row) {
  148. return (new Price([
  149. 'value' => $row['PV_1L_TOUCH'],
  150. ]))->result();
  151. },
  152. 'valueOther' => [
  153. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  154. ]
  155. ],
  156. 'QY_1L' => [
  157. 'header' => '一市场区域业绩',
  158. 'headerOther' => [
  159. 'width' => '150',
  160. ],
  161. 'value' => function($row) {
  162. return (new Price([
  163. 'value' => $row['QY_1L'],
  164. ]))->result();
  165. },
  166. 'valueOther' => [
  167. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  168. ]
  169. ],
  170. 'SURPLUS_1L' => [
  171. 'header' => '一市场结余业绩',
  172. 'headerOther' => [
  173. 'width' => '150',
  174. ],
  175. 'value' => function($row) {
  176. return (new Price([
  177. 'value' => $row['SURPLUS_1L'],
  178. ]))->result();
  179. },
  180. 'valueOther' => [
  181. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  182. ]
  183. ],
  184. 'PV_2L_TOUCH' => [
  185. 'header' => '二市场新增业绩',
  186. 'headerOther' => [
  187. 'width' => '150',
  188. ],
  189. 'value' => function($row) {
  190. return (new Price([
  191. 'value' => $row['PV_2L_TOUCH'],
  192. ]))->result();
  193. },
  194. 'valueOther' => [
  195. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  196. ]
  197. ],
  198. 'QY_2L' => [
  199. 'header' => '二市场区域业绩',
  200. 'headerOther' => [
  201. 'width' => '150',
  202. ],
  203. 'value' => function($row) {
  204. return (new Price([
  205. 'value' => $row['QY_2L'],
  206. ]))->result();
  207. },
  208. 'valueOther' => [
  209. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  210. ]
  211. ],
  212. 'SURPLUS_2L' => [
  213. 'header' => '二市场结余业绩',
  214. 'headerOther' => [
  215. 'width' => '150',
  216. ],
  217. 'value' => function($row) {
  218. return (new Price([
  219. 'value' => $row['SURPLUS_2L'],
  220. ]))->result();
  221. },
  222. 'valueOther' => [
  223. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  224. ]
  225. ],
  226. 'PV_3L_TOUCH' => [
  227. 'header' => '三市场新增业绩',
  228. 'headerOther' => [
  229. 'width' => '150',
  230. ],
  231. 'value' => function($row) {
  232. return (new Price([
  233. 'value' => $row['PV_3L_TOUCH'],
  234. ]))->result();
  235. },
  236. 'valueOther' => [
  237. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  238. ]
  239. ],
  240. 'QY_3L' => [
  241. 'header' => '三市场区域业绩',
  242. 'headerOther' => [
  243. 'width' => '150',
  244. ],
  245. 'value' => function($row) {
  246. return (new Price([
  247. 'value' => $row['QY_3L'],
  248. ]))->result();
  249. },
  250. 'valueOther' => [
  251. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  252. ]
  253. ],
  254. 'SURPLUS_3L' => [
  255. 'header' => '三市场结余业绩',
  256. 'headerOther' => [
  257. 'width' => '150',
  258. ],
  259. 'value' => function($row) {
  260. return (new Price([
  261. 'value' => $row['SURPLUS_3L'],
  262. ]))->result();
  263. },
  264. 'valueOther' => [
  265. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
  266. ]
  267. ],
  268. 'CALC_MONTH' => [
  269. 'header' => '结算月',
  270. 'headerOther' => [
  271. 'width' => '110',
  272. ],
  273. ],
  274. ];
  275. }
  276. return $this->columns;
  277. }
  278. /**
  279. * 前台用于筛选的类型集合
  280. * @return mixed
  281. */
  282. public function getFilterTypes()
  283. {
  284. if(!$this->filterTypes){
  285. $this->filterTypes = [];
  286. }
  287. return $this->filterTypes;
  288. }
  289. /**
  290. * 校验大区
  291. * @param $big
  292. * @param $loc
  293. * @param $num
  294. * @return bool
  295. */
  296. private function _chkBig($big, $loc, $num){
  297. return $loc == $num && $big != $loc;
  298. }
  299. }