当前位置: 首页>>代码示例>>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;未经允许,请勿转载。