RecordLogic.php 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop开源商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | gitee下载:https://gitee.com/likeshop_gitee
  7. // | github下载:https://github.com/likeshop-github
  8. // | 访问官网:https://www.likeshop.cn
  9. // | 访问社区:https://home.likeshop.cn
  10. // | 访问手册:http://doc.likeshop.cn
  11. // | 微信公众号:likeshop技术社区
  12. // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
  13. // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
  14. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  15. // | likeshop团队版权所有并拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshop.cn.team
  18. // +----------------------------------------------------------------------
  19. namespace app\shop\logic\distribution;
  20. use app\common\basics\Logic;
  21. use app\common\model\distribution\DistributionOrderGoods;
  22. class RecordLogic extends Logic
  23. {
  24. public static function lists($get)
  25. {
  26. $where = [
  27. ['dog.shop_id', '=', $get['shop_id']]
  28. ];
  29. // 搜索
  30. if(!empty($get['keyword'])) {
  31. $fieldDesc = '';
  32. switch($get['keyword_type']) {
  33. case 'order_sn':
  34. $fieldDesc = 'o.order_sn';
  35. break;
  36. case 'user_nickname':
  37. $fieldDesc = 'u.nickname';
  38. break;
  39. case 'user_sn':
  40. $fieldDesc = 'u.sn';
  41. break;
  42. case 'user_mobile':
  43. $fieldDesc = 'u.mobile';
  44. break;
  45. }
  46. $where[] = [$fieldDesc, '=', trim($get['keyword'])];
  47. }
  48. // 佣金状态
  49. if(!empty($get['status'])) {
  50. $where[] = ['dog.status', '=', $get['status']];
  51. }
  52. // 记录时间
  53. if(!empty($get['start_time'])) {
  54. $where[] = ['dog.create_time', '>=', strtotime($get['start_time'])];
  55. }
  56. if(!empty($get['end_time'])) {
  57. $where[] = ['dog.create_time', '<=', strtotime($get['end_time'])];
  58. }
  59. $lists = DistributionOrderGoods::alias('dog')
  60. ->field('dog.money, dog.status as status_desc,dog.create_time as distribution_create_time,u.nickname as user_nickname,u.sn as user_sn,u.mobile as user_mobile,og.total_pay_price,o.order_sn')
  61. ->leftJoin('user u', 'u.id=dog.user_id')
  62. ->leftJoin('order_goods og', 'og.id=dog.order_goods_id')
  63. ->leftJoin('order o', 'o.id=og.order_id')
  64. ->where($where)
  65. ->order('dog.create_time', 'desc')
  66. ->page($get['page'], $get['limit'])
  67. ->select()
  68. ->toArray();
  69. $count = DistributionOrderGoods::alias('dog')
  70. ->field('dog.money, dog.status as status_desc,dog.create_time as distribution_create_time,u.nickname as user_nickname,u.sn as user_sn,u.mobile as user_mobile,og.total_pay_price,o.order_sn')
  71. ->leftJoin('user u', 'u.id=dog.user_id')
  72. ->leftJoin('order_goods og', 'og.id=dog.order_goods_id')
  73. ->leftJoin('order o', 'o.id=og.order_id')
  74. ->where($where)
  75. ->count();
  76. return [
  77. 'count' => $count,
  78. 'lists' => $lists
  79. ];
  80. }
  81. }