123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <?php
- namespace app\common\model;
- use think\facade\Db;
- /**
- * ============================================================================
- *
- * ============================================================================
- * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
- * 网站地址: https://www.valimart.net/
- * ----------------------------------------------------------------------------
- *
- * ============================================================================
- * 数据层模型
- */
- class Spec extends BaseModel {
- public $page_info;
- /**
- * 规格列表
- * @access public
- * @author csdeshang
- * @param type $condition 条件
- * @param type $pagesize 分页
- * @param type $order 排序
- * @return type
- */
- public function getSpecList($condition, $pagesize = '', $order = 'sp_id desc') {
- if($pagesize){
- $result= Db::name('spec')->where($condition)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
- $this->page_info=$result;
- return $result->items();
- }else{
- return Db::name('spec')->where($condition)->order($order)->select()->toArray();
- }
- }
- /**
- * 单条规格信息
- * @access public
- * @author csdeshang
- * @param type $sp_id 规格ID
- * @param type $field 字段
- * @return type
- */
- public function getSpecInfo($sp_id, $field = '*') {
- return Db::name('spec')->where('sp_id',$sp_id)->field($field)->find();
- }
- /**
- * 规格值列表
- * @access public
- * @author csdeshang
- * @param type $where 条件
- * @param type $field 字段
- * @param type $order 排序
- * @return type
- */
- public function getSpecvalueList($where, $field = '*', $order = 'spvalue_sort asc,spvalue_id asc') {
- $result = Db::name('specvalue')->field($field)->where($where)->order($order)->select()->toArray();
- return empty($result) ? array() : $result;
- }
- /**
- * 更新规格值
- * @access public
- * @author csdeshang
- * @param array $update 更新数据
- * @param array $where 条件
- * @return boolean
- */
- public function editSpecvalue($update, $where) {
- $result = Db::name('specvalue')->where($where)->update($update);
- return $result;
- }
- /**
- * 增加规格值
- * @access public
- * @author csdeshang
- * @param array $data 数据
- * @return boolean
- */
- public function addSpecvalue($data) {
- $result = Db::name('specvalue')->insertGetId($data);
- return $result;
- }
- /**
- * 添加规格 多条
- * @access public
- * @author csdeshang
- * @param array $data 数据
- * @return boolean
- */
- public function addSpecvalueALL($data) {
- $result = Db::name('specvalue')->insertAll($data);
- return $result;
- }
- /**
- * 删除规格值
- * @access public
- * @author csdeshang
- * @param array $where 条件
- * @return boolean
- */
- public function delSpecvalue($where) {
- $result = Db::name('specvalue')->where($where)->delete();
- return $result;
- }
- /**
- * 更新规格信息
- * @access public
- * @author csdeshang
- * @param type $update 更新数据
- * @param type $condition 条件
- * @return boolean
- */
- public function editSpec($update, $condition) {
- if (empty($update)) {
- return false;
- }
- return Db::name('spec')->where($condition)->update($update);
- }
- /**
- * 添加规格信息
- * @access public
- * @author csdeshang
- * @param type $data 数据
- * @return type
- */
- public function addSpec($data) {
- // 规格表插入数据
- $result = Db::name('spec')->insertGetId($data);
- return $result;
- }
-
- /**
- * 删除规格
- * @access public
- * @author csdeshang
- * @param type $condition 条件
- * @return type
- */
- public function delSpec($condition) {
- return Db::name('spec')->where($condition)->delete();
- }
- }
- ?>
|