/** * 删除 do_delete * @return bool|int */ public function do_delete() { $result = 0; if (IS_POST && IS_AJAX) { $id = I('post.itemID'); /* 判断分类下是否有内容 */ $whereCount['group_id'] = array('EQ', $id); $count = M('AuthGroupAccess')->where($whereCount)->count(); if (empty($count)) { /* 捕获异常 */ try { $where['id'] = array('EQ', $id); $where['display'] = array('EQ', 1); $result = $this->where($where)->setField('display', 0); } catch (\Exception $e) { $remark = $e->getMessage(); /* 记录操作异常日志 */ logs_system_error($remark); } } else { $this->error = L('YZ_auth_group_exist_member'); } } return $result; }
public function do_recall() { $result = 0; if (IS_POST && IS_AJAX) { /* 捕获异常 */ try { if ($this->create()) { /* 定义变量 */ $id = I('post.itemID'); /* 数据操作 */ $this->startTrans(); //开启事务 $whereRecall['id'] = array('EQ', $id); $whereRecall['trade_state'] = array('EQ', 0); $whereRecall['display'] = array('EQ', 1); /* 获取优惠劵信息 */ $orderInfo = $this->field('user_id,shop_coupon_like_consume_count')->where($whereRecall)->find(); $user_id = $orderInfo['user_id']; $shop_coupon_like_consume_count = $orderInfo['shop_coupon_like_consume_count']; /* 改变优惠劵状态 */ $dataRecall['trade_state'] = 2; $dataRecall['update_time'] = NOW_TIME; $resultRecall = $this->where($whereRecall)->save($dataRecall); /* 更改用户积分 */ $whereUserCountLike['id'] = array('EQ', $user_id); $whereUserCountLike['status'] = array('EQ', 1); $whereUserCountLike['display'] = array('EQ', 1); $userData = M('User')->field('like_now_count,like_consume_count')->where($whereUserCountLike)->find(); /* 修改用户颜值 */ $dataUserCountLike['like_now_count'] = $userData['like_now_count'] + $shop_coupon_like_consume_count; $dataUserCountLike['like_consume_count'] = $userData['like_consume_count'] - $shop_coupon_like_consume_count; $resultUserCountLike = M('User')->where($whereUserCountLike)->save($dataUserCountLike); if ($resultRecall && $resultUserCountLike) { $this->commit(); //提交事务 return true; } else { $this->rollback(); //事务回滚 } } } catch (\Exception $e) { $remark = $e->getMessage(); /* 记录操作异常日志 */ logs_system_error($remark); } } return $result; }
public function do_update_password() { $result = 0; if (IS_POST && IS_AJAX) { /* 捕获异常 */ try { if ($this->create('', self::MODEL_UPDATE_PASSWORD)) { $where['id'] = session('user_id'); $result = $this->where($where)->setField('password', md5(I('post.password'))); } } catch (\Exception $e) { $remark = $e->getMessage(); /* 记录操作异常日志 */ logs_system_error($remark); } } return $result; }
public function do_update_head_auth() { $result = 0; if (IS_POST && IS_AJAX) { /* 捕获异常 */ try { if ($this->create('', self::MODEL_HEAD_AUTH)) { $where['id'] = array('EQ', I('post.id')); $where['upfile_head_auth_type'] = array('EQ', 2); $result = $this->where($where)->setField('upfile_head_auth_type', I('upfile_head_auth_type')); } } catch (\Exception $e) { $remark = $e->getMessage(); /* 记录操作异常日志 */ logs_system_error($remark); } } return $result; }
/** * 修改权限 do_accessUpdate */ public function do_memberUpdate($id = NULL) { $result = 0; if (IS_POST && IS_AJAX) { /* 捕获异常 */ try { /* 定义变量 */ $itemID = I('post.itemID'); $dataList = array(); /* 数据操作 */ $this->startTrans(); //开启事务 $where['group_id'] = array('EQ', $id); $resultDel = $this->where($where)->delete(); $itemIDArr = explode(',', $itemID); foreach ($itemIDArr as $v) { $dataList[] = array('user_id' => $v, 'group_id' => $id); } if ($dataList) { $resultAdd = $this->addall($dataList); } if ($resultDel !== false && $resultAdd) { $this->commit(); //提交事务 return true; } else { $this->rollback(); //事务回滚 } } catch (\Exception $e) { $remark = $e->getMessage(); /* 记录操作异常日志 */ logs_system_error($remark); } } return $result; }
/** * 设置置顶自动下架 do_autodown * @param array $condition * @param string $status * @return bool|int */ public function do_autodown($condition = array(), $statusUp) { $result = 0; $top_ = 1; if (IS_POST && IS_AJAX) { $id = I('post.itemID'); if ($id || $condition && in_array($this->getPk(), array_keys($condition))) { $where['id'] = array('IN', $id); //$where['top_'] = array('EQ', 0); $where['display'] = array('EQ', 1); if (!$statusUp) { $top_ = 0; //$where['top_'] = array('EQ', 1); $where['display'] = array('EQ', 1); } $where = array_merge($where, $condition); /* 捕获异常 */ try { $result = $this->where($where)->setField('autodown', $top_); logs_system_error(json_encode($where) . '|' . $top_ . '|' . $this->getLastSql()); //logs_system_error(); } catch (\Exception $e) { $remark = $e->getMessage(); /* 记录操作异常日志 */ logs_system_error($remark); } } } return $result; }
public function do_consume() { $result = 0; if (IS_POST && IS_AJAX) { /* 捕获异常 */ try { if ($this->create('', self::MODEL_CONSUME)) { $where['trade_no'] = array('EQ', I('post.verify')); $where['trade_state'] = array('EQ', 0); $where['shop_account_id'] = array('EQ', UID); $where['display'] = array('EQ', 1); /* 修改订单状态 */ $data['trade_state'] = 1; $data['update_time'] = NOW_TIME; $result = $this->where($where)->save($data); } } catch (\Exception $e) { $remark = $e->getMessage(); /* 记录操作异常日志 */ logs_system_error($remark); } } return $result; }
/** * 删除 doDelete * @param array $condition * @param bool $type * @return bool|int|mixed */ public function do_delete($condition = array(), $type = false) { $result = 0; if (IS_POST && IS_AJAX) { $id = I('post.itemID'); if ($id || $condition && in_array($this->getPk(), array_keys($condition))) { $where['id'] = array('IN', $id); if ($type) { /* 捕获异常 */ try { $result = $this->where($where)->delete(); } catch (\Exception $e) { $remark = $e->getMessage(); /* 记录错误日记 */ logs_system_error($remark); } } else { $where['display'] = array('EQ', 1); $where = array_merge($where, $condition); /* 捕获异常 */ try { $result = $this->where($where)->setField('display', 0); } catch (\Exception $e) { $remark = $e->getMessage(); /* 记录操作异常日志 */ logs_system_error($remark); } } } } return $result; }