ExpressLogic.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\admin\logic;
  3. use app\model\AccountBatchLogModel;
  4. use app\model\ExpressModel;
  5. use app\model\CommonModel;
  6. use app\model\VideoModel;
  7. use think\Exception;
  8. use think\exception\ValidateException;
  9. use think\facade\Config;
  10. use think\facade\Db;
  11. use think\response\Json;
  12. class ExpressLogic extends BaseLogic
  13. {
  14. //列表
  15. public static function list(array $data = []): Json
  16. {
  17. $where = [];
  18. if ($data['express_code'] != '') $where[] = ['express_code', 'like', '%' . $data['express_code'] . '%'];
  19. if ($data['express_name'] != '') $where[] = ['express_name', 'like', '%' . $data['express_name'] . '%'];
  20. if ($data['mobile'] != '') $where[] = ['mobile', 'like', '%' . $data['mobile'] . '%'];
  21. if ($data['status'] != '') $where[] = ['status', '=', $data['status']];
  22. $count = ExpressModel::where($where)->count('id');
  23. $list = ExpressModel::where($where)
  24. ->field(true)
  25. ->order('id', 'desc')
  26. ->page($data['page'], $data['size'])
  27. ->select()
  28. ->toArray();
  29. return json_show(CommonModel::$success, '获取快递公司列表成功', ['count' => $count, 'list' => $list]);
  30. }
  31. //删除
  32. public static function status(array $data = []): Json
  33. {
  34. $rs = ExpressModel::where(['id' => $data['id']])
  35. ->where('status', '<>', $data['status'])
  36. ->save(['status' => $data['status']]);
  37. return $rs ? json_show(CommonModel::$success, '操作成功') : json_show(CommonModel::$error_param, '操作失败,该快递公司不存在或重复操作');
  38. }
  39. }