MerchantContributeRepository.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\common\repositories\merchant\apply;
  3. use app\common\dao\merchant\apply\MerchantContributeDao;
  4. use app\common\repositories\BaseRepository;
  5. use think\facade\Db;
  6. /**
  7. * Class MerchantContributeRepository
  8. * @package app\common\repositories\merchant\apply
  9. * @author php迷途小书童
  10. * @created 2021/1/30 17:42
  11. */
  12. class MerchantContributeRepository extends BaseRepository
  13. {
  14. /**
  15. * MerchantRepository constructor.
  16. * @param MerchantContributeDao $dao
  17. */
  18. public function __construct(MerchantContributeDao $dao)
  19. {
  20. $this->dao = $dao;
  21. }
  22. /**
  23. * 获取单条信息
  24. * @return array|\think\Model|null
  25. * @author php迷途小书童
  26. * @created 2021/1/16 10:45
  27. */
  28. public function getOne($where)
  29. {
  30. return ($this->dao->getWhere($where));
  31. }
  32. /**
  33. * 查询列表
  34. *
  35. */
  36. public function queryList()
  37. {
  38. return Db::name('merchant_contribute')
  39. ->field("id,contribute_name,ratio_start,ratio_end,jing_dou,contribute_value")
  40. ->where('del_yn', 0)
  41. ->order('id', 'ASC')
  42. ->select();
  43. }
  44. public function deleteById($id)
  45. {
  46. return Db::name('merchant_contribute')
  47. ->where('id', $id)
  48. ->update(['del_yn'=>1]);
  49. }
  50. public function updateById($data, $id)
  51. {
  52. return Db::name('merchant_contribute')
  53. ->where('id', $id)
  54. ->update($data);
  55. }
  56. public function add($data)
  57. {
  58. return Db::name('merchant_contribute')
  59. ->insert($data);
  60. }
  61. }