ShopAccountLogService.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\service\admin\shop\site;
  12. use app\model\shop\ShopAccountLog;
  13. use core\base\BaseAdminService;
  14. /**
  15. * 店铺账单记录服务层
  16. * Class ShopService
  17. * @package app\service\admin\shop\site
  18. */
  19. class ShopAccountLogService extends BaseAdminService
  20. {
  21. public function __construct()
  22. {
  23. parent::__construct();
  24. $this->model = new ShopAccountLog();
  25. }
  26. /**
  27. * 获取账户收支记录
  28. */
  29. public function getPage(array $where = []):array
  30. {
  31. $field = 'id, related_id, from_type, money, create_time, memo';
  32. $order = 'create_time desc';
  33. $search_model = $this->model
  34. ->withSearch(['from_type', 'related_id', 'create_time'], $where)
  35. ->where([['site_id', '=', $this->site_id]])->append([ 'from_type_name' ])->field($field)->order($order);
  36. $list = $this->pageQuery($search_model);
  37. return $list;
  38. }
  39. /**
  40. * 添加账户收支记录
  41. * @param array $data
  42. * @return mixed
  43. */
  44. public function add(array $data)
  45. {
  46. $data[ 'create_time' ] = time();
  47. $res = $this->model->create($data);
  48. return $res->id;
  49. }
  50. }