MerchantCodeAudit.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace app\models\merchant;
  3. use crmeb\basic\BaseModel;
  4. use crmeb\traits\ModelTrait;
  5. class MerchantCodeAudit extends BaseModel
  6. {
  7. /**
  8. * 数据表主键
  9. * @var string
  10. */
  11. protected $pk = 'id';
  12. /**
  13. * 模型名称
  14. * @var string
  15. */
  16. protected $name = 'merchant_code_audit';
  17. use ModelTrait;
  18. public static function getList($where = null)
  19. {
  20. $data = ($data = self::setWhere($where)->page($where['page'] ?? 1, $where['limit'] ?? 10)->select()) && count($data) ? $data->toArray() : [];
  21. foreach ($data as &$item) {
  22. $item['mer_name'] = (Merchant::where('id', $item['mer_id'])->find())['name'] ?: '';
  23. switch ($item['status']) {
  24. case 0:
  25. $item['state'] = '审核成功';
  26. break;
  27. case 1:
  28. $item['state'] = '审核被拒绝';
  29. break;
  30. case 2:
  31. $item['state'] = '审核中';
  32. break;
  33. case 3:
  34. $item['state'] = '已撤回';
  35. break;
  36. case 4:
  37. $item['state'] = '审核延后';
  38. break;
  39. }
  40. }
  41. $count = self::setWhere($where)->count();
  42. return ['count' => $count, 'list' => $data];
  43. }
  44. public static function setWhere($where)
  45. {
  46. $model = (new self);
  47. if ($where['mer_id']) {
  48. $model = $model->where('mer_id', $where['mer_id']);
  49. }
  50. if ($where['auditid']) {
  51. $model = $model->where('auditid', $where['auditid']);
  52. }
  53. if ($where['status']) {
  54. $model = $model->where('status', $where['status']);
  55. }
  56. return $model;
  57. }
  58. }