public function __construct() { parent::__construct(); $di = \Phalcon\DI::getDefault(); $di->setShared('txyredispro', function () use($di) { $redis = new Redis(); $redis->connect($di['config']->txyredispro->host, intval($di['config']->txyredispro->port), 3); if (APP_ENV == 'product') { $redis->auth($di['config']->txyredispro->instanceid . ":" . $di['config']->txyredispro->auth); } return $redis; }); $di->setShared('rocksdbcomwrite', function () use($di) { $redis = new Redis(); $redis->connect($di['config']->rocksdbcomwrite->host, intval($di['config']->rocksdbcomwrite->port), 3); $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE); return $redis; }); //注册队列 $di->setShared('rabbitmq', function () use($di) { $cfg = $di['config']->rabbitmq_write->toArray(); \Xz\Lib\RabbitMQ::addConfigration('gstask', $cfg); $rabbit = \Xz\Lib\RabbitMQ::getInstance("gstask"); return $rabbit; }); }
/** * 设置审核信息 * @author 彭东江 * @param int $id 主键id * @return array 审核信息 */ public function audit($id, $state, $comname, $checkdesc = '', $mname = '') { if (empty($id) || empty($state) || empty($comname) || empty($mname)) { return $this->outputData('', '600', '参数错误'); } $certify = MGccertify::findFirst(array('id = ?1', 'bind' => array(1 => $id), 'order' => 'id DESC')); $certify->state = $state; $certify->checkdesc = $checkdesc; $certify->checktime = time(); $certify->name = $mname; if ($certify->save()) { $com = Gccompany::findFirst(array('supid = ?1', 'bind' => array(1 => $certify->supid))); $com->is_gccertify = $certify->state; if ($com->save() && $com->is_gccertify == 1) { $gc_gccertify = new GcGccertify(); $gc_gccertify->supid = $certify->supid; $gc_gccertify->state = 1; $gc_gccertify->comname = $comname; $gc_gccertify->addtime = time(); $result = $gc_gccertify->save(); } } $msg['supid'] = $certify->supid; if ($state == 1) { //工厂认证 添加基础评分 $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray()); $queueData = json_encode(array('cid' => $com->cid, 'supid' => $certify->supid, 'scoretype' => 4)); $rabbit->set('v3work', 'sup', $queueData, 'score'); //工厂认证统计 $array = array('supid' => $certify->supid, 'province' => $com->province, 'city' => $com->city, 'cate1' => $com->cate1, 'cate2' => $com->cate2, 'busmode' => $com->busmode, 'auth' => 1); Statistic::report(Statistic::SUP_PERSONAL_AUTH, $array); //站内信 $msg['subject'] = "工厂认证审核通过"; $msg['message'] = '您提交的工厂认证申请已经审核通过,拥有发布10条普通特权产品的权限,可以更好的提升营销效果。如需发布更多特权产品,您可以开通营销4.0服务!【<a href="' . $this->di['config']->base->sup . '/product/special/index/">发布特权产品</a>】【<a href="' . $this->di['config']->base->sup . '/cost/" target="_blank">开通营销4.0</a>】'; } else { //站内信 $msg['subject'] = "工厂认证被拒审"; $msg['message'] = '您提交的工厂认证申请已经被拒审,拘审原因是:(' . $checkdesc . ')!【<a href="' . $this->di['config']->base->sup . '/company/gongchang/">重新认证</a>】'; } \Gcsupplier\Services\MsgService::getInstance()->addMsg($msg); return $this->outputData($certify); }
/** * 操作单个产品上下架 * @param int $pid 产品id * @param int $cid 供应商cid * @param int online 0是下架 1是上架 */ public function operaGoods($pid, $cid, $online = 1) { $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray()); $di = \Phalcon\Di::getDefault(); $cid = intval($cid); $pid = intval($pid); if (empty($pid) or empty($cid)) { return $this->outputData(false, 600, '参数有误'); } $info = \Gcproinfo\Models\Pdinfo::findFirst(array('pid = :pid: and cid = :cid:', 'bind' => array('pid' => $pid, 'cid' => $cid))); if ($info) { $rs = $di->getShared('gcproinfo')->update('pd_info', array('online'), array($online), 'pid = ' . $pid . ' and cid = ' . $cid); $infoMq = json_encode(array('pid' => $pid, 'cid' => $cid)); $rabbit->setBroadcast('v3product', 'product', $infoMq); if ($rs) { $di->getShared('gcproinfo')->update('pd_pidgid', array('online'), array($online), 'pid = ' . $pid . ' and cid = ' . $cid); if ($online) { $desc = $info->getDesc($info->pid); if (empty($desc)) { $desc = ''; } $comInfo = ComBaseService::getInstance()->getComInfo($info->supid, 'comname'); $comname = ''; if ($comInfo['code'] == 200 and is_array($comInfo['data'])) { $comname = $comInfo['data']['comname']; } $rabbit->setBroadcast('v3prodesc', 'prodesc', json_encode(array('pid' => $info->pid, 'cid' => $info->cid, 'cname' => $comname, 'prodesc' => $desc, 'cateid' => array($info->cate1, $info->cate2, $info->cate3, 0, 0), 'table' => 'product', 'op' => 'weijin'))); $mProduct = \Gcproinfo\Models\Mproduct::findFirst(array('pid = :pid:', 'bind' => array('pid' => $info->pid))); if ($mProduct) { if ($mProduct->state == -8) { $mProduct->state = -7; $mProduct->save(); } } } return $this->outputData(1); } } else { return $this->outputData(false, 600, '数据获取失败'); } }
public function afterSave() { $info = json_encode(array('pid' => $this->pid, 'cid' => $this->cid)); $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray()); $rabbit->setBroadcast('v3product', 'product', $info); }
/** * 营业执照审核 * @param id int 审核表主键 * @param int $opType 1通过 -1拒审 * @return boolean true/false * @author zhuyuping <[<email address>]> */ public function check($id = '', $opType = '', $checkdesc = '', $mname = '', $postData = array()) { $opType = intval($opType); if ($id <= 0 || empty($opType) || empty($mname)) { return $this->outputData('', '600', '参数错误'); } $mobj = MCompermit::findFirst(array('id = ?1', 'bind' => array(1 => $id))); if (!empty($mobj) && empty($mobj->state)) { $mArr = $mobj->toArray(); $cid = $mArr['cid']; $obj = Gccompermit::findFirst(array("cid = ?1", 'bind' => array(1 => $cid))); if (empty($obj) || !empty($obj->state)) { return $this->outputData(false, '600', '行业资格证信息不存在'); } } else { return $this->outputData(false, '600', '要审核行业资格证信息不存在'); } $this->di['gccominfo']->begin(); $comObj = \Gccominfo\Models\Gccompany::findFirst(array("cid = ?1", 'bind' => array(1 => $cid))); if (empty($comObj)) { return $this->outputData(false, '600', '企业不存在'); } $msg['supid'] = $mArr['supid']; $msg['addtime'] = time(); //审核通过 if ($opType == 1) { //执照通过否 $is_buslicense = 0; $buslicenseObj = Mbuslicense::findFirst(array("cid = ?1", 'bind' => array(1 => $cid), 'order' => 'id desc')); if (!empty($buslicenseObj) && $buslicenseObj->state == 1) { $is_buslicense = 1; } //发产品否 $is_pubpro = 0; $proObj = \Gcproinfo\Models\Pdinfo::findFirst(array('cid = :cid:', 'bind' => array('cid' => $cid))); if ($proObj) { $is_pubpro = 1; } //企业资料已完善 if ($is_buslicense == 1) { $comObj->is_complete = 1; } if ($is_buslicense == 1 && $is_pubpro == 1) { //已完善 + 已发 $comObj->state = 1; } elseif ($is_buslicense == 0 && $is_pubpro == 1) { //未完善 + 已发 $comObj->state = -4; } elseif ($is_buslicense == 1 && $is_pubpro == 0) { //已完善 + 未发 $comObj->state = -3; } else { $comObj->state = -2; } $comObj->save(); //更新资格证主表 客服修改的信息 if (isset($postData['permitno'])) { $obj->permitno = $postData['permitno']; } if (isset($postData['permittype'])) { $obj->permittype = $postData['permittype']; } if (isset($postData['endtime'])) { $obj->endtime = strtotime($postData['endtime']); } //更新审核表 $mobj->checktime = time(); $mobj->state = $opType; $mobj->name = $mname; //站内信 $msg['subject'] = "行业资格证审核通过"; $msg['message'] = '您提交的行业资格证已经审核通过,可以在工厂网经营该行业产品,快去发布产品吧!【<a href="' . $this->di['config']->base->sup . '/product/new/">立即发布</a>】'; } else { //拒审 //更新审核表 if (empty($checkdesc)) { return $this->outputData(false, '600', '拒审理由非空'); } $mobj->checkdesc = $checkdesc; $mobj->checktime = time(); $mobj->state = $opType; $mobj->name = $mname; //站内信 $msg['subject'] = "行业资证被拒审"; $msg['message'] = '您提交的行业资格证已经被拒审,原因是:(' . $checkdesc . ')!【<a href="' . $this->di['config']->base->sup . '/company/index/init2/">重新提交</a>】'; } //更新资格证主表 $obj->state = $opType; if ($obj->save() === false) { $this->di['gccominfo']->rollback(); return $this->outputData(false, '600', $obj->getMessages()); } //更新审核表 if ($mobj->save() === false) { $this->di['gccominfo']->rollback(); return $this->outputData(false, '600', $mobj->getMessages()); } $this->di['gccominfo']->commit(); if ($opType == 1 && $is_buslicense == 1 && $is_pubpro == 1) { $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray()); $queueData = json_encode(array('cid' => $cid, 'supid' => $comObj->supid)); $rabbit->set('v3work', 'open', $queueData, 'store'); } \Gcsupplier\Services\MsgService::getInstance()->addMsg($msg); return $this->outputData(true); }
public function beforeSave() { $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray()); $rabbit->set('v3com', 'com', $this->cid, 'ssdb'); }
public function afterSave() { $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray()); $rabbit->set('v3com', 'com', $this->cid, 'ssdb'); //更新二维码名片 $rabbit->set('v3work', 'qrcode', $this->supid, 'mysql'); }
public function sphinxNotice($id, $type) { $rabbit = new RabbitMQ($this->di['config']->rabbitmq_write->toArray()); if ($type == 1) { $obj = Pdspecialpro::findFirst(array('pid = :pid:', 'bind' => array('pid' => $id))); if ($obj == false) { return $this->outputData(1); } $sphinxInfo2 = array('id' => $obj->pid, 'supid' => $obj->supid, 'proname' => $obj->proname, 'cid' => $obj->cid, 'addtime' => $obj->addtime, 'uptime' => $obj->uptime, 'state' => $obj->state, 'online' => 1, 'groupid' => 0, 'cate1' => $obj->cate1, 'cate2' => $obj->cate2, 'cate3' => $obj->cate3, 'whichTable' => 2); $rabbit->set('v3search', 'prosearch', json_encode($sphinxInfo2), 'sphinxRT'); $sphinxInfo3 = array('id' => $obj->pid, 'cid' => $obj->cid, 'supid' => $obj->supid, 'proname' => $obj->proname, 'addtime' => $obj->addtime, 'uptime' => $obj->uptime, 'star' => $obj->star, 'cate3' => $obj->cate3, 'state' => $obj->state, 'is_op' => $obj->is_op, 'ratio' => $obj->ratio, 'whichTable' => 3); $rabbit->set('v3search', 'prosearch', json_encode($sphinxInfo3), 'sphinxRT'); } elseif ($type == 2) { $obj = Mspecialpro::findFirst(array('id = :id:', 'bind' => array('id' => $id))); if ($obj == false) { return $this->outputData(1); } $sphinxInfo4 = array('id' => $obj->id, 'cid' => $obj->cid, 'supid' => $obj->supid, 'proname' => $obj->proname, 'addtime' => $obj->addtime, 'uptime' => $obj->uptime, 'star' => $obj->star, 'cate3' => $obj->cate3, 'state' => $obj->state, 'is_op' => $obj->is_op, 'ratio' => $obj->ratio, 'whichTable' => 4); $rabbit->set('v3search', 'prosearch', json_encode($sphinxInfo4), 'sphinxRT'); } }