order($order)->paginate($rows, false, ['query' => $param]); return $list; } /** * 添加数据 * @param $param */ public function addStoreProduct($param) { $insertId = 0; try { $param['create_time'] = date('Y-m-d H:i:s'); $param['status'] = 1; $insertId = self::strict(false)->field(true)->insertGetId($param); // 写入商品详情表 $data['product_id'] = $insertId; $data['content'] = $param['content']; Db::table('cms_store_product_content')->strict(false)->field(true)->insertGetId($data); add_log('add', $insertId, $param); } catch(\Exception $e) { return to_assign(1, '操作失败,原因:'.$e->getMessage()); } return to_assign(0,'操作成功',['aid'=>$insertId]); } /** * 编辑信息 * @param $param */ public function editStoreProduct($param) { try { // $param['update_time'] = time(); self::where('product_id', $param['product_id'])->strict(false)->field(true)->update($param); // 修改商品详情表 $data['content'] = $param['content']; Db::table('cms_store_product_content')->where('product_id', $param['product_id'])->strict(false)->field(true)->update($data); add_log('edit', $param['product_id'], $param); } catch(\Exception $e) { return to_assign(1, '操作失败,原因:'.$e->getMessage()); } return to_assign(); } /** * 根据id获取信息 * @param $id */ public function getStoreProductById($id) { $info = self::where('product_id', $id)->find(); return $info; } /** * 删除信息 * @param $id * @return array */ public function delStoreProductById($id,$type=0) { if($type==0){ //逻辑删除 try { $param['delete_time'] = time(); self::where('product_id', $id)->update(['delete_time'=>time()]); add_log('delete', $id); } catch(\Exception $e) { return to_assign(1, '操作失败,原因:'.$e->getMessage()); } } else{ //物理删除 try { self::where('product_id', $id)->delete(); add_log('delete', $id); } catch(\Exception $e) { return to_assign(1, '操作失败,原因:'.$e->getMessage()); } } return to_assign(); } }