PeriodBonusList.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\Cache;
  5. use common\helpers\Tool;
  6. use common\helpers\user\Info;
  7. use common\libs\dataList\column\Price;
  8. use common\libs\dataList\column\YesNo;
  9. use common\libs\dataList\DataListInterface;
  10. use common\models\CalcBonus;
  11. use common\models\PerfOrder;
  12. use common\models\Period;
  13. use common\models\Region;
  14. use common\models\User as modelUser;
  15. use common\models\UserBind;
  16. use common\models\UserBonus;
  17. use common\models\UserInfo;
  18. use common\libs\dataList\column\DateTime;
  19. use common\models\UserPerf;
  20. use common\models\UserSystem;
  21. use common\models\Withdraw;
  22. use Yii;
  23. class PeriodBonusList extends \common\libs\dataList\DataList implements DataListInterface
  24. {
  25. /**
  26. * 列表名称
  27. * @return string
  28. */
  29. public function getListName(){
  30. return '奖金列表';
  31. }
  32. /**
  33. * 列表筛选到的数据
  34. * @throws \yii\base\Exception
  35. */
  36. public function dataHandle()
  37. {
  38. $yearMonth = $this->others['yearMonth'];
  39. $this->listData = CalcBonus::lists($this->condition, $this->params, [
  40. 'select'=>'CB.*,UI.CON_UID,UI.REC_UID',
  41. 'from' => CalcBonus::tableName().' AS CB',
  42. 'join' => [
  43. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CB.USER_ID=UI.USER_ID'],
  44. ],
  45. 'yearMonth' => $yearMonth,
  46. 'orderBy' => 'CB.CREATED_AT DESC, CB.ID DESC',
  47. 'page' => $this->page,
  48. 'pageSize' => $this->pageSize,
  49. ]);
  50. unset($yearMonth);
  51. if ($this->listData['list']) {
  52. foreach ($this->listData['list'] as $key => $value) {
  53. $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'];
  54. $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'];
  55. $this->listData['list'][$key]['LAST_STATUS_NAME'] = Tool::paramConvert(Yii::$app->params['userStatus'])[$value['LAST_STATUS']]['label'];
  56. $this->listData['list'][$key]['LAST_REC_USER_NAME'] = Info::getUserNameByUserId($value['REC_UID']);
  57. $this->listData['list'][$key]['LAST_REC_REAL_NAME'] = Info::getUserRealNameByUserId($value['REC_UID']);
  58. $this->listData['list'][$key]['LAST_CON_USER_NAME'] = Info::getUserNameByUserId($value['CON_UID']);
  59. $this->listData['list'][$key]['LAST_CON_REAL_NAME'] = Info::getUserRealNameByUserId($value['CON_UID']);
  60. }
  61. }
  62. }
  63. /**
  64. * 要展示和导出的所有字段
  65. * @return array
  66. */
  67. public function getColumn(){
  68. if(!$this->columns){
  69. $this->columns = [
  70. 'ID' => null,
  71. 'PERIOD_NUM' => [
  72. 'header' => \Yii::t('ctx', 'payCycle'), // 结算期数
  73. 'headerOther' => [
  74. 'width' => '150',
  75. ],
  76. 'valueOther' => [
  77. 'tag'=>['type'=>'', 'size' => 'small', 'class'=>'no-border'],
  78. ],
  79. ],
  80. 'CALCULATED_AT' => [
  81. 'header' => \Yii::t('ctx', 'bonusDate'), // 结算时间
  82. 'value' => function($row) {
  83. return (new DateTime([
  84. 'value' => $row['CALCULATED_AT'],
  85. ]))->result();
  86. },
  87. 'headerOther' => ['width' => '170'],
  88. ],
  89. 'LAST_USER_NAME' => [
  90. 'header' => \Yii::t('ctx', 'memberCode'), // 会员编号
  91. 'headerOther' => [
  92. 'width' => '150',
  93. ],
  94. 'valueOther' => [
  95. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
  96. ],
  97. ],
  98. 'LAST_REAL_NAME' => [
  99. 'header' => \Yii::t('ctx', 'memberName'), // 会员姓名
  100. 'headerOther' => [
  101. 'width' => '120',
  102. ],
  103. 'valueOther' => [
  104. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  105. ],
  106. ],
  107. 'LAST_DEC_LV_NAME' => [
  108. 'header' => \Yii::t('ctx', 'PCMemberLevel'), // 结算时会员级别
  109. 'headerOther' => [
  110. 'width' => '140',
  111. ],
  112. ],
  113. 'LAST_EMP_LV_NAME' => [
  114. 'header' => \Yii::t('ctx', 'latestDirector'), // 结算时会员最新管理星级
  115. 'headerOther' => [
  116. 'width' => '140',
  117. ],
  118. ],
  119. 'LAST_MOBILE' => [
  120. 'header' => \Yii::t('ctx', 'phoneNumber'),//手机号码
  121. 'headerOther' => [
  122. 'width' => '120',
  123. ],
  124. ],
  125. 'LAST_PERIOD_AT' => [
  126. 'header' => Yii::t('ctx', 'joiningPeriod'), // 加入期数
  127. 'headerOther' => [
  128. 'width' => '110',
  129. ],
  130. ],
  131. 'LAST_CREATED_AT' => [
  132. 'header' => Yii::t('ctx', 'joiningDate'), // 加入时间
  133. 'value' => function($row) {
  134. return (new DateTime([
  135. 'value' => $row['LAST_CREATED_AT'],
  136. ]))->result();
  137. },
  138. 'headerOther' => ['width' => '170'],
  139. ],
  140. 'LAST_REC_USER_NAME' => [
  141. 'header' => Yii::t('ctx', 'sponsorNo'), // 开拓者编号
  142. 'headerOther' => [
  143. 'width' => '150',
  144. ],
  145. ],
  146. 'LAST_REC_REAL_NAME' => [
  147. 'header' => Yii::t('ctx', 'sponsorName'), // 开拓者姓名
  148. 'headerOther' => [
  149. 'width' => '120',
  150. ],
  151. ],
  152. // 'LAST_CON_USER_NAME' => [
  153. // 'header' => Yii::t('ctx', 'superiorCode'), // 上级编号
  154. // 'headerOther' => [
  155. // 'width' => '150',
  156. // ],
  157. // ],
  158. // 'LAST_CON_REAL_NAME' => [
  159. // 'header' => Yii::t('ctx', 'superiorName'), // 上级姓名
  160. // 'headerOther' => [
  161. // 'width' => '120',
  162. // ],
  163. // ],
  164. 'BONUS_TG' => [
  165. 'header' => Yii::t('ctx', 'welcomeBonus'), // 销售奖金
  166. 'value' => function($row) {
  167. return (new Price([
  168. 'value' => $row['BONUS_TG'],
  169. ]))->result();
  170. },
  171. 'headerOther' => [
  172. 'width' => '130',
  173. 'prop'=>'BONUS_TG',
  174. ],
  175. ],
  176. 'BONUS_QY' => [
  177. 'header' => Yii::t('ctx', 'teamBonus'), // 绩效奖金
  178. 'value' => function($row) {
  179. return (new Price([
  180. 'value' => $row['BONUS_QY'],
  181. ]))->result();
  182. },
  183. 'headerOther' => [
  184. 'width' => '120',
  185. 'prop'=>'BONUS_QY',
  186. ],
  187. ],
  188. 'ORI_CAPPED_BONUS_QY' => [
  189. 'header' => Yii::t('ctx', 'uncappedTeamBonus'), // 绩效奖未封顶金额
  190. 'value' => function($row) {
  191. return (new Price([
  192. 'value' => $row['ORI_CAPPED_BONUS_QY'],
  193. ]))->result();
  194. },
  195. 'headerOther' => [
  196. 'width' => '170',
  197. 'prop'=>'ORI_CAPPED_BONUS_QY',
  198. ],
  199. ],
  200. 'BONUS_BS' => [
  201. 'header' => Yii::t('ctx', 'directorBonus'),// 管理奖/蓝星奖
  202. 'value' => function($row) {
  203. return (new Price([
  204. 'value' => $row['BONUS_BS'],
  205. ]))->result();
  206. },
  207. 'headerOther' => [
  208. 'width' => '120',
  209. 'prop'=>'BONUS_BS',
  210. ],
  211. ],
  212. 'BONUS_BD' => [
  213. 'header' => Yii::t('ctx', 'stockistCommission'), // 服务奖
  214. 'value' => function($row) {
  215. return (new Price([
  216. 'value' => $row['BONUS_BD'],
  217. ]))->result();
  218. },
  219. 'headerOther' => [
  220. 'width' => '150',
  221. 'prop'=>'BONUS_BD',
  222. ],
  223. ],
  224. 'BONUS_QUARTER' => [
  225. 'header' => Yii::t('ctx', 'quarterlyBonus'), // 季度分红
  226. 'value' => function($row) {
  227. return (new Price([
  228. 'value' => $row['BONUS_QUARTER'],
  229. ]))->result();
  230. },
  231. 'headerOther' => [
  232. 'width' => '130',
  233. 'prop'=>'BONUS_QUARTER',
  234. ],
  235. ],
  236. 'BONUS_REAL' => [
  237. 'header' => Yii::t('ctx', 'actualBonus'), // 实发奖金
  238. 'value' => function($row) {
  239. return (new Price([
  240. 'value' => $row['BONUS_REAL'],
  241. ]))->result();
  242. },
  243. 'headerOther' => [
  244. 'width' => '120',
  245. 'prop'=>'BONUS_REAL',
  246. ],
  247. ],
  248. 'BONUS_TOTAL' => [
  249. 'header' => Yii::t('ctx', 'totalBonus'), // 总奖金
  250. 'value' => function($row) {
  251. return (new Price([
  252. 'value' => $row['BONUS_TOTAL'],
  253. ]))->result();
  254. },
  255. 'headerOther' => [
  256. 'width' => '120',
  257. 'prop'=>'BONUS_TOTAL',
  258. ],
  259. ],
  260. 'BONUS_INCOME' => [
  261. 'header' => Yii::t('ctx', 'totalRevenue'), // 总收入
  262. 'value' => function($row) {
  263. return (new Price([
  264. 'value' => $row['BONUS_INCOME'],
  265. ]))->result();
  266. },
  267. 'headerOther' => [
  268. 'width' => '120',
  269. 'prop'=>'BONUS_INCOME',
  270. ],
  271. ],
  272. 'CALC_MONTH' => [
  273. 'header' => Yii::t('ctx', 'bonusMonth'), // 结算月
  274. 'headerOther' => [
  275. 'width' => '110',
  276. ],
  277. ],
  278. ];
  279. }
  280. return $this->columns;
  281. }
  282. /**
  283. * 前台用于筛选的类型集合
  284. * @return mixed
  285. */
  286. public function getFilterTypes()
  287. {
  288. if(!$this->filterTypes){
  289. $this->filterTypes = [
  290. 'LAST_USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberCode')], // 会员编号
  291. 'LAST_REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberName')], // 会员姓名
  292. 'LAST_DEC_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'PCMemberLevel'), 'other'=> 'decLevel'], // 结算时会员级别
  293. 'LAST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'latestDirector'), 'other'=> 'empLevel'], // 结算时会员管理星级
  294. 'LAST_MOBILE'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'phoneNumber')], // 手机号
  295. 'LAST_PERIOD_AT'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'joiningPeriod')], // 加入期数
  296. 'LAST_CREATED_AT'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'joiningDate'), 'other'=> 'date'], // 加入时间
  297. 'CALCULATED_AT'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'date'), 'other'=> 'date'], // 备份时间
  298. 'LAST_REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'sponsorNo')], // 开拓者编号
  299. 'LAST_REC_REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'sponsorName')], // 开拓者姓名
  300. 'LAST_CON_USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'superiorNumber')], // 上级编号
  301. 'LAST_CON_REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'superiorName')], // 上级姓名
  302. 'PV_1L'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'oneNewMarketPerformance')], // 一市场新增业绩
  303. 'SURPLUS_1L'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'oneMarketBalancePerformance')], // 一市场结余业绩
  304. 'PV_2L'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'twoNewMarketPerformance')], // 二市场新增业绩
  305. 'SURPLUS_2L'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'twoMarketBalancePerformance')], // 二市场结余业绩
  306. 'BONUS_BD'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'stockistCommission')], // 服务奖
  307. 'BONUS_GL'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'managementAward')], // 管理奖
  308. 'BONUS_QY'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'teamBonus')], // 团队奖
  309. 'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'bonusMonth')], // 结算月
  310. ];
  311. }
  312. return $this->filterTypes;
  313. }
  314. }