ChainGoods.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class ChainGoods extends BaseModel
  12. {
  13. public $page_info;
  14. /**
  15. * 插入数据
  16. * @access public
  17. * @author csdeshang
  18. * @param array $data 数据
  19. * @return boolean
  20. */
  21. public function addChainGoods($data)
  22. {
  23. return Db::name('chain_goods')->insertGetId($data);
  24. }
  25. /**
  26. * 查询门店列表
  27. * @access public
  28. * @author csdeshang
  29. * @param array $condition 检索条件
  30. * @param int $pagesize 分页信息
  31. * @param string $order 排序
  32. * @return array
  33. */
  34. public function getChainGoodsList($condition, $pagesize = 0, $order = 'chain_goods_id desc')
  35. {
  36. if ($pagesize) {
  37. $res = Db::name('chain_goods')->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  38. $this->page_info = $res;
  39. return $res->items();
  40. } else {
  41. return Db::name('chain_goods')->where($condition)->order($order)->select()->toArray();
  42. }
  43. }
  44. /**
  45. * 取得门店详细信息
  46. * @access public
  47. * @author csdeshang
  48. * @param array $condition 检索条件
  49. * @param string $field 字段
  50. * @return array
  51. */
  52. public function getChainGoodsInfo($condition, $field = '*')
  53. {
  54. return Db::name('chain_goods')->where($condition)->field($field)->find();
  55. }
  56. /**
  57. * 门店信息
  58. * @access public
  59. * @author csdeshang
  60. * @param array $update 更新数据
  61. * @param array $condition 条件
  62. * @return bool
  63. */
  64. public function editChainGoods($update, $condition)
  65. {
  66. return Db::name('chain_goods')->where($condition)->update($update);
  67. }
  68. }