TableDataLogic.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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\external\ExternalPlatform;
  20. use app\common\model\jobs_rules\JobsRules;
  21. use app\common\model\labels\Labels;
  22. use app\common\model\property\PropertyHead;
  23. use app\common\model\recharge\RechargeOrder;
  24. use app\common\model\refund\RefundLog;
  25. use app\common\model\refund\RefundRecord;
  26. use app\common\model\sale\Sale;
  27. use app\common\model\sale\SaleGroup;
  28. use app\common\model\setting\PostageRegion;
  29. use app\common\model\tenant\Tenant;
  30. use app\common\model\shops\ShopGoods;
  31. use app\common\model\training\TrainingCourse;
  32. use app\common\model\training\TrainingQuestions;
  33. use app\common\model\training\TrainingTask;
  34. use app\common\service\pay\AliPayService;
  35. use app\common\service\pay\WeChatPayService;
  36. /**
  37. * 查询选项类数据
  38. * Class TableDataLogic
  39. * @package app\common\logic
  40. */
  41. class TableDataLogic extends BaseLogic
  42. {
  43. /**
  44. * @notes 商品标签列表
  45. */
  46. public static function labels()
  47. {
  48. 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();
  49. }
  50. public static function allLabels()
  51. {
  52. return Labels::where('id','>',0)->field('id,label_name as name,id as value,"data_table_allLabels" as type_value')->select()->toArray();
  53. }
  54. /**
  55. * @notes 销售列表
  56. */
  57. public static function sale()
  58. {
  59. return Sale::where('id','>',0)->field('id,sale_name as name,id as value,"data_table_sale" as type_value')->select()->toArray();
  60. }
  61. /**
  62. * @notes 销售组列表
  63. */
  64. public static function saleGroup()
  65. {
  66. return SaleGroup::where('id','>',0)->field('id,sale_name as name,id as value,"data_table_saleGroup" as type_value')->select()->toArray();
  67. }
  68. public static function propertyHead()
  69. {
  70. return PropertyHead::where('id','>',0)->field('id,village_name as name,id as value,"data_table_propertyHead" as type_value')->select()->toArray();
  71. }
  72. /**
  73. * @notes 工程师标签列表
  74. */
  75. public static function masterWorkerLabels()
  76. {
  77. // 缓存优化
  78. $data = cache('labelMasterWorkerLabels');
  79. if(empty($data)){
  80. $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();
  81. $data = linear_to_tree($lists, 'children', 'id', 'pid');
  82. cache('labelMasterWorkerLabels',$data,3600);
  83. }
  84. return $data;
  85. }
  86. /**
  87. * @notes 优惠券标签列表
  88. */
  89. public static function couponLabels()
  90. {
  91. 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();
  92. }
  93. /**
  94. * @notes 权益卡列表
  95. */
  96. public static function equityConfig()
  97. {
  98. return EquityConfig::where('id','>',0)->field('id,equity_name as name,id as value,"data_table_equityConfig" as type_value')->select()->toArray();
  99. }
  100. public static function postageRegion(): array
  101. {
  102. // 缓存优化
  103. $data = cache('labelPostageRegion');
  104. if(empty($data)){
  105. $lists = PostageRegion::field('id,pid,name as label,id as value,"data_table_postageRegion" as type_value')->select()->toArray();
  106. $data = linear_to_tree($lists, 'children', 'id', 'pid');
  107. cache('labelPostageRegion',$data);
  108. }
  109. return $data;
  110. }
  111. public static function postageRegionCity(): array
  112. {
  113. // 缓存优化
  114. $data = cache('labelPostageRegionCity');
  115. if(empty($data)){
  116. $lists = PostageRegion::whereIn('level',[1,2])->field('id,pid,name as label,id as value,"data_table_postageRegionCity" as type_value')->select()->toArray();
  117. $data = linear_to_tree($lists, 'children', 'id', 'pid');
  118. cache('labelPostageRegionCity',$data);
  119. }
  120. return $data;
  121. }
  122. public static function jobsRules(): array
  123. {
  124. return JobsRules::field(['id', 'rule_name as label','id as value','"data_table_jobsRules" as type_value'])->select()->toArray();
  125. }
  126. public static function provinces()
  127. {
  128. return PostageRegion::where('pid','=',0)->field('id,merge_name as name,id as value,"data_table_provinces" as type_value')->select()->toArray();
  129. }
  130. public static function citys($province_ids = [])
  131. {
  132. if(!empty($province_ids)){
  133. 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();
  134. }
  135. return PostageRegion::where('level','=',2)->field('id,merge_name as name,id as value,"data_table_citys" as type_value')->select()->toArray();
  136. }
  137. public static function admins()
  138. {
  139. return Admin::where('disable','=',0)->field('id,name,id as value,"data_table_admins" as type_value')->select()->toArray();
  140. }
  141. public static function tenant()
  142. {
  143. return Tenant::where('disable','=',0)->field('id,name,id as value,"data_table_tenant" as type_value')->select()->toArray();
  144. }
  145. public static function trainingQuestions()
  146. {
  147. return TrainingQuestions::field('id,title as name,id as value,question_type,"data_table_trainingQuestions" as type_value')->select()->toArray();
  148. }
  149. public static function trainingCourse()
  150. {
  151. return TrainingCourse::field('id,course_name as name,id as value,"data_table_trainingCourse" as type_value')->select()->toArray();
  152. }
  153. public static function trainingTask()
  154. {
  155. return TrainingTask::field('id,task_name as name,id as value,"data_table_trainingTask" as type_value')->select()->toArray();
  156. }
  157. public static function shopGoods()
  158. {
  159. return ShopGoods::field('id,goods_name as name,id as value,"data_table_shopGoods" as type_value')->select()->toArray();
  160. }
  161. public static function externalPlatform()
  162. {
  163. return ExternalPlatform::field('id,name,CONVERT(id, CHAR) as value,"data_table_externalPlatform" as type_value')->select()->toArray();
  164. }
  165. }