Example #1
0
 public function getGroupView($gid, $cid)
 {
     if (is_numeric($gid) and is_numeric($cid)) {
         $rs = Pdcustomgroup::findFirst(array("gid = :gid: and cid=:cid:", "bind" => array('gid' => $gid, 'cid' => $cid)));
         return $this->outputData($rs);
     } else {
         return $this->outputData(false, 600, '参数必须为数字!');
     }
 }
Example #2
0
 /**
  * 添加产品的单个分组
  * @param ing $gid   分组id
  * @param ing $pid   产品id
  * @param ing $supid 供应商id
  */
 public function addGoodsGroup($pidgid, $pid, $supid, $cid)
 {
     $pidgid = explode('-', $pidgid);
     $gid = isset($pidgid[0]) ? intval($pidgid[0]) : 0;
     $cgid = isset($pidgid[1]) ? intval($pidgid[1]) : 0;
     $state = $online = 1;
     if (!is_array($pid)) {
         $pid = array($pid);
     }
     if (is_array($pid)) {
         $this->di['gcproinfo']->begin();
         foreach ($pid as $v) {
             //判断是否超过3条的限制
             $count = \Gcproinfo\Models\PdPidgid::count(array('pid = :pid: and cid = :cid: and state in(0,1)', "bind" => array('pid' => $v, 'cid' => $cid)));
             if ($count >= 3) {
                 continue;
             } else {
                 //判断是否有重复的分组
                 $count = \Gcproinfo\Models\PdPidgid::count(array('pid = :pid: and gid=:gid: and cgid=:cgid: and state in (0,1)', "bind" => array('pid' => $v, 'gid' => $gid, 'cgid' => $cgid)));
                 if ($count > 0) {
                     continue;
                 } else {
                     $info = \Gcproinfo\Models\Pdinfo::findFirst(array('pid = :pid: and cid = :cid:', 'bind' => array('pid' => $v, 'cid' => $cid)));
                     if (isset($info->state)) {
                         $state = $info->state;
                     }
                     if (isset($info->online)) {
                         $online = $info->online;
                     }
                     $pidgidModel = new \Gcproinfo\Models\PdPidgid();
                     $pidgidModel->pid = $v;
                     $pidgidModel->gid = $gid;
                     $pidgidModel->cid = $cid;
                     $pidgidModel->supid = $supid;
                     $pidgidModel->cgid = $cgid;
                     $pidgidModel->state = $state;
                     $pidgidModel->online = $online;
                     $re = $pidgidModel->save();
                     if ($re == false) {
                         $this->di['gcproinfo']->rollback();
                         return $this->outputData(false, '600', '处理失败');
                         exit;
                     }
                 }
             }
         }
         if (empty($cgid)) {
             $groupobj = \Gcproinfo\Models\Pdcustomgroup::findFirst(array('cid=:cid: and gid = :gid: and parentgid=0', 'bind' => array('gid' => $gid, 'cid' => $cid)));
         } else {
             $groupobj = \Gcproinfo\Models\Pdcustomgroup::findFirst(array('cid=:cid: and gid = :cgid: and parentgid=:gid:', 'bind' => array('cgid' => $cgid, 'gid' => $gid, 'cid' => $cid)));
         }
         if (!empty($groupobj) && is_object($groupobj)) {
             if ($groupobj->pronum > 0) {
                 $groupobj->pronum = $groupobj->pronum + 1;
                 $re2 = $groupobj->save();
                 if ($re2 == false) {
                     $this->di['gcproinfo']->rollback();
                     return $this->outputData(false, '600', '处理失败');
                     exit;
                 }
             }
         }
         $this->di['gcproinfo']->commit();
         return $this->outputData(1);
         exit;
     }
     return $this->outputData(false, '600', '处理失败');
 }