TableDataLogic.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\common\logic;
  15. use app\common\enum\PayEnum;
  16. use app\common\enum\RefundEnum;
  17. use app\common\model\auth\Admin;
  18. use app\common\model\equity\EquityConfig;
  19. use app\common\model\jobs_rules\JobsRules;
  20. use app\common\model\labels\Labels;
  21. use app\common\model\property\PropertyHead;
  22. use app\common\model\recharge\RechargeOrder;
  23. use app\common\model\refund\RefundLog;
  24. use app\common\model\refund\RefundRecord;
  25. use app\common\model\sale\Sale;
  26. use app\common\model\sale\SaleGroup;
  27. use app\common\model\setting\PostageRegion;
  28. use app\common\model\tenant\Tenant;
  29. use app\common\service\pay\AliPayService;
  30. use app\common\service\pay\WeChatPayService;
  31. /**
  32. * 查询选项类数据
  33. * Class TableDataLogic
  34. * @package app\common\logic
  35. */
  36. class TableDataLogic extends BaseLogic
  37. {
  38. /**
  39. * @notes 商品标签列表
  40. */
  41. public static function labels()
  42. {
  43. return Labels::where('id','>',0)->where('label_type',1)->field('id,label_name as name,id as value,"data_table_labels" as type_value')->select()->toArray();
  44. }
  45. public static function allLabels()
  46. {
  47. return Labels::where('id','>',0)->field('id,label_name as name,id as value,"data_table_allLabels" as type_value')->select()->toArray();
  48. }
  49. /**
  50. * @notes 销售列表
  51. */
  52. public static function sale()
  53. {
  54. return Sale::where('id','>',0)->field('id,sale_name as name,id as value,"data_table_sale" as type_value')->select()->toArray();
  55. }
  56. /**
  57. * @notes 销售组列表
  58. */
  59. public static function saleGroup()
  60. {
  61. return SaleGroup::where('id','>',0)->field('id,sale_name as name,id as value,"data_table_saleGroup" as type_value')->select()->toArray();
  62. }
  63. public static function propertyHead()
  64. {
  65. return PropertyHead::where('id','>',0)->field('id,village_name as name,id as value,"data_table_propertyHead" as type_value')->select()->toArray();
  66. }
  67. /**
  68. * @notes 工程师标签列表
  69. */
  70. public static function masterWorkerLabels()
  71. {
  72. // 缓存优化
  73. $data = cache('labelMasterWorkerLabels');
  74. if(empty($data)){
  75. $lists = Labels::where('id','>',0)->where('label_type',2)->field('id,pid,label_name as name,id as value,"data_table_masterWorkerLabels" as type_value')->select()->toArray();
  76. $data = linear_to_tree($lists, 'children', 'id', 'pid');
  77. cache('labelMasterWorkerLabels',$data,3600);
  78. }
  79. return $data;
  80. }
  81. /**
  82. * @notes 优惠券标签列表
  83. */
  84. public static function couponLabels()
  85. {
  86. return Labels::where('id','>',0)->where('label_type',3)->field('id,label_name as name,id as value,"data_table_couponLabels" as type_value')->select()->toArray();
  87. }
  88. /**
  89. * @notes 权益卡列表
  90. */
  91. public static function equityConfig()
  92. {
  93. return EquityConfig::where('id','>',0)->field('id,equity_name as name,id as value,"data_table_equityConfig" as type_value')->select()->toArray();
  94. }
  95. public static function postageRegion(): array
  96. {
  97. // 缓存优化
  98. $data = cache('labelPostageRegion');
  99. if(empty($data)){
  100. $lists = PostageRegion::field(['id', 'pid', 'name as label','id as value','"data_table_postageRegion" as type_value'])->select()->toArray();
  101. $data = linear_to_tree($lists, 'children', 'id', 'pid');
  102. cache('labelPostageRegion',$data);
  103. }
  104. return $data;
  105. }
  106. public static function jobsRules(): array
  107. {
  108. return JobsRules::field(['id', 'rule_name as label','id as value','"data_table_jobsRules" as type_value'])->select()->toArray();
  109. }
  110. public static function provinces()
  111. {
  112. return PostageRegion::where('pid','=',0)->field('id,merge_name as name,id as value,"data_table_provinces" as type_value')->select()->toArray();
  113. }
  114. public static function citys($province_ids = [])
  115. {
  116. if(!empty($province_ids)){
  117. return PostageRegion::where('pid','in',$province_ids)->where('level','=',2)->field('id,merge_name as name,id as value,"data_table_citys" as type_value')->select()->toArray();
  118. }
  119. return PostageRegion::where('level','=',2)->field('id,merge_name as name,id as value,"data_table_citys" as type_value')->select()->toArray();
  120. }
  121. public static function admins()
  122. {
  123. return Admin::where('disable','=',0)->field('id,name,id as value,"data_table_admins" as type_value')->select()->toArray();
  124. }
  125. public static function tenant()
  126. {
  127. return Tenant::where('disable','=',0)->field('id,name,id as value,"data_table_tenant" as type_value')->select()->toArray();
  128. }
  129. }