ChainGoods.php 2.2 KB

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