當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OmAvailableModel::getMaxSpu方法代碼示例

本文整理匯總了PHP中OmAvailableModel::getMaxSpu方法的典型用法代碼示例。如果您正苦於以下問題:PHP OmAvailableModel::getMaxSpu方法的具體用法?PHP OmAvailableModel::getMaxSpu怎麽用?PHP OmAvailableModel::getMaxSpu使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OmAvailableModel的用法示例。


在下文中一共展示了OmAvailableModel::getMaxSpu方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: act_autoCreateSpu

 function act_autoCreateSpu()
 {
     $data = array();
     $prefix = trim($_POST['prefix']);
     if (!preg_match("/^[A-Z]{2}\$/", $prefix)) {
         self::$errCode = 11;
         self::$errMsg = 'error';
         return false;
     }
     $prefixList = OmAvailableModel::getTNameList('pc_auto_create_spu_prefix', 'isSingSpu', "WHERE prefix='{$prefix}'");
     $isSingSpu = $prefixList[0]['isSingSpu'];
     //該prefix下試單還是虛擬料號
     $autoSpuList = OmAvailableModel::getTNameList('pc_auto_create_spu', 'sort', "WHERE spu REGEXP '^{$prefix}[0-9]{6}\$' order by sort desc limit 1");
     $maxNumberAuto = $autoSpuList[0]['sort'];
     //auto表中最大的max
     $maxNumberTrue = OmAvailableModel::getMaxSpu($prefix, $isSingSpu);
     //對應goods表或combine表中最大的max
     $maxNumber = $maxNumberTrue > $maxNumberAuto ? $maxNumberTrue : $maxNumberAuto;
     //return $maxNumberTrue;
     //$maxNumber = OmAvailableModel::getMaxSpu($prefix, $isSingSpu);
     $spu = $prefix . str_pad($maxNumber + 1, 6, '0', STR_PAD_LEFT);
     $data = array('spu' => $spu, 'sort' => $maxNumber + 1, 'prefix' => $prefix, 'isSingSpu' => $isSingSpu);
     if (!empty($data)) {
         return $data;
     } else {
         self::$errCode = 1;
         self::$errMsg = 'error';
         return false;
     }
 }
開發者ID:ohjack,項目名稱:newErp,代碼行數:30,代碼來源:spu.action.php

示例2: act_searchOrAddCombineInfo

 function act_searchOrAddCombineInfo()
 {
     $spu = isset($_GET['goods_sn']) ? post_check(trim($_GET['goods_sn'])) : '';
     $amount = isset($_GET['amount']) ? $_GET['amount'] : '';
     $amount = intval($amount);
     $combineUserId = isset($_GET['truename']) ? $_GET['truename'] : '';
     $combineUserId = intval($combineUserId);
     $now = time();
     if (!preg_match("/^[A-Z0-9]+\$/", $spu)) {
         //sku不合規範
         self::$errCode = '101';
         self::$errMsg = 'SPU不合法';
         return false;
     }
     if ($amount <= 0) {
         //不是正數
         self::$errCode = '102';
         self::$errMsg = '數量不合法';
         return false;
     }
     if ($combineUserId <= 0) {
         //不是正數
         self::$errCode = '103';
         self::$errMsg = '組合人id不合法';
         return false;
     }
     $tName = 'pc_goods';
     $select = 'spu,sku';
     $where = "WHERE spu='{$spu}' and is_delete=0";
     $pcGoodsList = OmAvailableModel::getTNameList($tName, $select, $where);
     if (empty($pcGoodsList)) {
         //如果spu找不到
         $select = 'spu,sku';
         $where = "WHERE sku='{$spu}' and is_delete=0";
         $pcGoodsList = OmAvailableModel::getTNameList($tName, $select, $where);
         if (empty($pcGoodsList)) {
             //spu找不到去sku找
             self::$errCode = '104';
             self::$errMsg = "SPU {$spu} 不存在";
             return false;
         }
     }
     $tName = 'pc_sku_combine_relation';
     $select = '*';
     $where = "WHERE sku REGEXP '^{$spu}(_[A-Z0-9]+)*\$' and count={$amount} and combineSku REGEXP '^CB[0-9]{6}(_[A-Z0-9]+)*\$'";
     //符合條件
     $pcCombineRelList = OmAvailableModel::getTNameList($tName, $select, $where);
     if (!empty($pcCombineRelList)) {
         //如果真實料號對應的虛擬料號存在,則直接返回
         $arr = array();
         $arrDetail = array();
         foreach ($pcCombineRelList as $value) {
             $arrTmp = array();
             $arrTmp['CBSku'] = $value['combineSku'];
             $arrTmp['bindSku'] = $value['sku'] . '*' . $amount;
             $arrDetail[] = $arrTmp;
         }
         $arr['spu'] = substr($pcCombineRelList[0]['combineSku'], 0, 8);
         //spu
         $arr['detail'] = $arrDetail;
         self::$errCode = '200';
         self::$errMsg = "信息存在,查詢返回成功";
         return json_encode($arr);
     } else {
         //如果不存在的話,則插入數據,然後再返回,此時要現在autoCreateSpu表中和combine表中,選出最大的CB為前綴的數字
         $numberCombine = OmAvailableModel::getMaxSpu('CB', 2);
         //取得pc_goods_combine表中以CB為前綴的最大的數字
         $tName = 'pc_auto_create_spu';
         $select = 'spu';
         $where = "WHERE prefix='CB' order by sort desc limit 1";
         $autoCreSpuList = OmAvailableModel::getTNameList($tName, $select, $where);
         $numberAutoCreSpu = intval(substr($autoCreSpuList[0]['spu'], 2, 6));
         $maxNumber = $numberCombine > $numberAutoCreSpu ? $numberCombine : $numberAutoCreSpu;
         $maxNumber = $maxNumber + 1;
         //要生成CB為前綴的最大數字
         try {
             BaseModel::begin();
             $arr = array();
             //返回數組
             $arrDetail = array();
             //要同步到深圳ERP組合料號的數據變量
             $insertIdCom = 1;
             //添加組合料號的insert_id
             $dataRelation = array();
             //關聯真實料號的數組
             $dataRelationMem = array();
             //關聯真實料號的mem
             $ebayProductsCombineArr = array();
             if (count($pcGoodsList) == 1) {
                 //如果真實SPU料號隻有一條記錄的話,表示該SPU下沒有分料號
                 $tmpSpu = 'CB' . str_pad($maxNumber, 6, '0', STR_PAD_LEFT);
                 $tName = 'pc_auto_create_spu';
                 $set = "SET spu='{$tmpSpu}',purchaseId='{$combineUserId}',createdTime='{$now}',sort='{$maxNumber}',status=2,prefix='CB',isSingSpu=2";
                 OmAvailableModel::addTNameRow($tName, $set);
                 //add by zqt ,20140403 添加關聯銷售記錄
                 //addSalerInfoForAny($tmpSpu, 2, $combineUserId, $combineUserId);//改變邏輯
                 $tName = 'pc_goods_combine';
                 $set = "SET combineSpu='{$tmpSpu}',combineSku='{$tmpSpu}',combineUserId={$combineUserId},addTime='{$now}'";
                 $insertIdCom = OmAvailableModel::addTNameRow($tName, $set);
                 $tName = 'pc_sku_combine_relation';
//.........這裏部分代碼省略.........
開發者ID:ohjack,項目名稱:newErp,代碼行數:101,代碼來源:omAvailableApi.action.php


注:本文中的OmAvailableModel::getMaxSpu方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。