where($map)->find(); return $res; } public function addPlug($item) { $re = $this->add($item); return $re; } public function getSelect($map) { $res = $this->where($map)->select(); return $res; } public function delPlug($map) { $res = $this->where($map)->delete(); return $res; } /* * 修改一个新的板块 */ public function updatePlug($map, $item) { $res = $this->where($map)->save($item); return $res; } /* * 获取所有的插件信息 */ public function getAllPlug() { $info = $this->alias('p') ->join('ls_plug_class as c on p.class_id=c.id') ->field('p.*,c.class_name') ->select(); if (!empty($info)) { return $info; } else { return false; } } /** * 验证商户的红包插件是否可用 * $merhcantid 商户id */ public function getRewardAccess($merchantid) { $plug = M('plug')->where(array('plug_name' => '红包', 'status' => 1))->find(); if ($plug) { // 有该插件 $map['plug_id'] = $plug['id']; // $map['merchant_id'] = $merchantid; // 主店id $map['m_status'] = 1; $merchant_plug = M('plug_merchant')->where($map)->find(); if ($merchant_plug) { return $plug; } else { return false; } } else { return false; } } public function getActivityAccess($merchantid) { $map['pm.merchant_id'] = $merchantid; $map['pm.m_status'] = 1; $reward_plug = M('plug_merchant as pm')->join("ls_plug as p on p.id=pm.plug_id AND p.plug_name='红包'")->where($map)->find(); $reward = M('reward')->where(array('merchantid' => $merchantid, 'status' => 1, 'type' => 2))->find(); if (!empty($reward_plug) && !empty($reward)) { $reward['plug_name'] = '红包'; return $reward; } else { $turntable_plug = M('plug_merchant as pm')->join("ls_plug as p on p.id=pm.plug_id AND p.plug_name='大转盘'")->where($map)->find(); $turntable = M('turntable')->where(array('merchantid' => $merchantid, 'status' => 1, 'type' => 2))->find(); if (!empty($turntable_plug) && !empty($turntable)) { $turntable['plug_name'] = '大转盘'; return $turntable; } else { return false; } } } public function closeAgentPlug($id, $agent_id) { $map['plug_id'] = $id; $map['a_status'] = 1; $map['agent_id'] = $agent_id; $updatePartner = M('plug_agent')->where($map)->save(array('a_status' => 2)); $merchant_list = M('retail_merchant')->where(array('agentid' => $agent_id))->select(); if (!empty($merchant_list)) { $merchant_ids = ''; foreach ($merchant_list as $val) { if ($merchant_ids == '') { $merchant_ids = $val['id']; } else { $merchant_ids .= ',' . $val['id']; } } $map2['merchant_id'] = array('in', $merchant_ids); $map2['m_status'] = 1; $map2['plug_id'] = $id; $updateAgent = M('plug_merchant')->where($map2)->save(array('m_status' => 2)); } } }