Exemple #1
0
 public function actionDel()
 {
     $result = 0;
     if ($_POST['BrandIDs']) {
         $str = ',' . $_POST['BrandIDs'] . ',';
     }
     $app = MakePromitBrand::model()->find('BrandName like "%' . $str . '%"');
     if ($app) {
         $errorMsg = '该品牌已授权删除失败';
         echo json_encode(array('success' => false, 'errorMsg' => $errorMsg));
         exit;
     } else {
         $result = MakeGoodsBrand::model()->deleteByPk($_POST['BrandIDs']);
         if ($result > 0) {
             $errorMsg = '删除成功';
         } else {
             $errorMsg = '删除失败';
         }
     }
     echo json_encode(array('success' => $result > 0 ? true : false, 'errorMsg' => $errorMsg));
 }
Exemple #2
0
 /**
  * 商品编号接口
  */
 public static function GetGoodsByGoodsNo($goodsno, $manufacturer_ID)
 {
     try {
         //$userID=Yii::app()->user->id;
         //$dealerID=Dealer::model()->find('userID=:userID',array(':userID'=>$userID));
         //$grade=MakeEmpowerDealer::model()->find('up_userID=:up_userID and dealer_id=:dealer_id',array(':up_userID'=>$manufacturer_ID,':dealer_id'=>$dealerID->id));
         //	  $sql=" select distinct a.id as goodsID,a.oe as OE, a.brand as brand ,a.NewVersion as verion_name,b.goodsno as goodsno,b.name as goodsname,b.price as makretprice,"
         //		."b.price".$grade->grade." as goodsprice,"
         //		." (select f.code  from tbl_parts_level f where b.parts_level=f.id) as parts_level,"
         //		." (select e.cp_name from tbl_goods_standard e where e.id=d.standard_id) as cp_name,"
         //		." (select c.name from tbl_goods_category c where c.id=a.category_id and a.manufacturer_id=c.manufacturer_id) as category"
         //		//." (select n.car from tbl_goods_vehicle m,tbl_vehicle n where m.Goods_ID='$goodsID' and n.VehicleID in (m.VehicleID)) as car"
         //		."  from tbl_goods a ,tbl_goods_version b,tbl_goods_template d,tbl_vehicle n"
         //		.'  where a.id=b.goods_id and a.NewVersion=b.version_name'
         //		."  and b.templet_id=d.id"
         //		."  and a.manufacturer_id=b.manufacturer_id"
         //		."  and a.ISdelete='N' and a.IsSale='Y'  "
         //		."  and a.manufacturer_id=$manufacturer_ID "
         //		."  and a.id=$goodsID"
         //		."  group by a.id order by a.id desc";
         //$sql=" select distinct a.id as goodsID ,a.oe as OE,a.brand as brand,a.NewVersion as verion_name,b.goodsno as goodsno,b.name as goodsname,b.price as marketprice,"
         //		."b.price".$grade->grade." as goodsprice,"
         //		." (select distinct f.code  from tbl_parts_level f where b.parts_level=f.id) as parts_level,"
         //		." (select distinct e.cp_name from tbl_goods_standard e where e.id=d.standard_id) as cp_name,"
         //		." (select distinct c.name from tbl_goods_category c where c.id=a.category_id and a.manufacturer_id=c.manufacturer_id) as category"
         //		."  from tbl_goods a ,tbl_goods_version b,tbl_goods_category c,tbl_goods_template d,tbl_goods_standard e,tbl_parts_level f,tbl_goods_values g"
         //		.'  where a.id=b.goods_id and a.NewVersion=b.version_name'
         //		."  and b.parts_level=f.id"
         //		."  and b.templet_id=d.id"
         //		."  and e.id=d.standard_id"
         //		."  and a.category_id=c.id"
         //		."  and b.values_id = g.id"
         //		."  and a.manufacturer_id=b.manufacturer_id"
         //		."  and a.ISdelete='N' and a.IsSale='Y'"
         //		."  and a.manufacturer_id='$manufacturer_ID' ";
         //		$sql.="  and b.goodsno='{$goodsno}'";
         //		$sql.="  group by a.id order by a.id desc";
         //授权品牌
         $organID = Commonmodel::getOrganID();
         $brands = MakePromitBrand::model()->find('DealerID=' . $organID . ' and OrganID=' . $manufacturer_ID);
         $sql2 = "select distinct a.id as goodsID ,b.goods_category as category_id,b.goods_oe as OE,b.goods_brand as brand,b.organID,\n                \t\t \t    a.NewVersion as verion_name,b.goods_no as goodsno,b.goods_name as goodsname,\n                                b.benchmarking_brand,b.benchmarking_sn,a.create_time,d.Price," . " b.inventory as inventory,b.senddays,b.description,a.IsSale,b.standard_id" . " from  tbl_make_goods a ,tbl_make_goods_version b ,tbl_make_goods_vehicle c,tbl_make_price_relation d" . '  where a.id=b.goods_id and a.NewVersion=b.version_name' . "  and a.ISdelete='0' and b.ISdelete=0" . "  and a.organID='{$manufacturer_ID}' and b.goods_no='{$goodsno}'";
         $identity = Commonmodel::getIdentity(Yii::app()->user->id);
         if ($identity['identity'] == 2 && $brands['CustomerType']) {
             $sql2 .= " and d.TypeID= {$brands['CustomerType']} and d.GoodsID=a.id and d.Price is not null and a.IsSale=0";
         }
         $result = Yii::app()->db->createCommand($sql2)->queryRow();
         if ($result) {
             //查询品牌名称
             $brandmodel = MakeGoodsBrand::model()->findByPK($result['brand']);
             $result['brand'] = $brandmodel['BrandName'];
             //商品销售价
             if ($result['Price']) {
                 $result['goodsprice'] = $result['Price'];
             }
             //$result['goodsprice']=sprintf("%.2f", $result['salesprice'] * $ratio / 100);
         }
         return $result;
     } catch (CDbException $e) {
         throw CDbException($e);
     }
 }
Exemple #3
0
 public function actionDelpromit()
 {
     $OrganID = Commonmodel::getOrganID();
     if (!empty($_POST['ids'])) {
         $ids = explode(',', $_POST['ids']);
         $ids = array_filter($ids);
         $count = count($ids);
         $i = 0;
         if (is_array($ids)) {
             foreach ($ids as $v) {
                 $PromitBrand = MakePromitBrand::model()->findByPk($v);
                 $result = MakePromitBrand::model()->deleteByPK($v);
                 if ($PromitBrand['CustomerType']) {
                     $oldType = MakeType::model()->find(array("condition" => "OrganID = {$OrganID} AND ID = {$PromitBrand['CustomerType']}"));
                     $oldCount = $oldType['TypeQuantity'];
                     MakeType::model()->updateAll(array("TypeQuantity" => $oldCount - 1, "UpdateTime" => time()), array("condition" => "OrganID = {$OrganID} AND ID = {$PromitBrand['CustomerType']}"));
                 }
                 if ($result) {
                     $i = $i + $result;
                 }
             }
         }
         $messager = '';
         //   if ($count == $i) {
         if ($i) {
             $messager = '删除成功';
         } else {
             $messager = '删除失败';
         }
         echo json_encode($messager);
     }
 }