MerchantHaikeRefundRepository.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * @package merchant
  4. *
  5. * @author xaboy
  6. * @day 2020-04-16
  7. *
  8. *
  9. */
  10. namespace app\common\repositories\system\merchant;
  11. use app\common\dao\system\merchant\MerchantHaikeRefundDao;
  12. use app\common\model\system\merchant\MerchantHaikeRefund;
  13. use app\common\repositories\BaseRepository;
  14. use FormBuilder\Factory\Elm;
  15. use think\db\exception\DataNotFoundException;
  16. use think\db\exception\DbException;
  17. use think\db\exception\ModelNotFoundException;
  18. use think\facade\Route;
  19. /**
  20. * Class MerchantHaikeRefundRepository
  21. * @package app\common\repositories\system\merchant
  22. * @author php迷途小书童
  23. * @created 2021/3/17 9:27
  24. */
  25. class MerchantHaikeRefundRepository extends BaseRepository
  26. {
  27. /**
  28. * MerchantRepository constructor.
  29. * @param MerchantHaikeRefundDao $dao
  30. */
  31. public function __construct(MerchantHaikeRefundDao $dao)
  32. {
  33. $this->dao = $dao;
  34. }
  35. /**
  36. * @param array $where
  37. * @param $page
  38. * @param $limit
  39. * @return array
  40. * @throws DataNotFoundException
  41. * @throws DbException
  42. * @throws ModelNotFoundException
  43. * @author xaboy
  44. * @day 2020-04-16
  45. */
  46. public function getList(array $where, $page, $limit)
  47. {
  48. $query = $this->dao->search($where);
  49. $count = $query->count($this->dao->getPk());
  50. $list = $query->with(['merchant'])
  51. ->page($page, $limit)
  52. ->select();
  53. $query1 = $this->dao->search($where);
  54. $count1 = MerchantHaikeRefund::getInstance()->where('status', 0)->count();
  55. $count2 = MerchantHaikeRefund::getInstance()->where('status', 1)->count();
  56. $count3 = MerchantHaikeRefund::getInstance()->where('status', 2)->count();
  57. $merdata= [
  58. ['className'=> 'el-icon-s-order', 'count'=>$count1, 'field'=> '个', 'name'=> '待处理'],
  59. ['className'=> 'el-icon-s-order', 'count'=>$count2, 'field'=> '个', 'name'=> '已处理'],
  60. ['className'=> 'el-icon-s-order', 'count'=>$count3, 'field'=> '个', 'name'=> '已出款']
  61. ];
  62. return compact('count', 'list','merdata');
  63. }
  64. public function changeStatusForm(int $id)
  65. {
  66. $form = Elm::createForm(Route::buildUrl('systemMerchantHaikeRefundChangeStatus', ['id' => $id])->build());
  67. $form->setRule([
  68. Elm::radio('status', '修改状态', 1)
  69. ->setOptions([
  70. ['value' => 0, 'label' => '待处理'],
  71. ['value' => 1, 'label' => '已处理'],
  72. ['value' => 2, 'label' => '已出款'],
  73. ]),
  74. Elm::input('mark', '备注'),
  75. ]);
  76. return $form->setTitle('修改状态');
  77. }
  78. }