ChainGoods.php 2.3 KB

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