public function sendRedGiftForCustomer($newOpenid, $oldOpenid) { //取出配置信息 $SetRedpacketModel = new SetRedpacketModel(); $config = $SetRedpacketModel->init(); //老用户发红包 if ($config['old_state'] == true && $oldOpenid != '') { $WechatRedpacketModel = new WechatRedpacketModel(); $count = $WechatRedpacketModel->getCountsByOpenid($oldOpenid); if ($count <= $config['old_max_num']) { $this->send($config['send_name'], $config['send_name'], $oldOpenid, $config['old_min_value'], $config['old_max_value'], trim($config['wishing']), $config['act_name'], $config['remark']); } } //新用户发红包 if ($config['new_state'] == true) { //判断是否直接关注 if ($oldOpenid == '') { if ($config['attention_give'] == false) { return; } } //按规则发放红包 $this->send($config['send_name'], $config['send_name'], $newOpenid, $config['new_min_value'], $config['new_max_value'], trim($config['wishing']), $config['act_name'], $config['remark']); } }
public function updateAction() { $setPacketM = new SetRedpacketModel(); $data = $setPacketM->create(); $data['id'] = I('post.id'); $data['old_state'] = I('post.old_state', 0); $data['new_state'] = I('post.new_state', 0); $data['old_min_value'] = huansuan(I('post.old_min_value')); $data['old_max_value'] = huansuan(I('post.old_max_value')); $data['new_min_value'] = huansuan(I('post.new_min_value')); $data['new_max_value'] = huansuan(I('post.new_max_value')); $data['old_max_num'] = I('post.old_max_num'); $data['attention_give'] = I('post.attention_give', 0); $data['wishing'] = trim(I('post.wishing')); $data['share_url'] = trim(I('post.share_url')); $setPacketM->save($data); $urlIndex = U('Active/SendRedGift/index'); redirect_url($urlIndex); }