You've already forked qlg.tsgz.moe
							
							Init Repo
This commit is contained in:
		
							
								
								
									
										97
									
								
								hyhproject/home/validate/Goods.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										97
									
								
								hyhproject/home/validate/Goods.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,97 @@
 | 
			
		||||
<?php 
 | 
			
		||||
namespace wstmart\home\validate;
 | 
			
		||||
use think\Validate;
 | 
			
		||||
/**
 | 
			
		||||
 * ============================================================================
 | 
			
		||||
 * 商品验证器
 | 
			
		||||
 */
 | 
			
		||||
class Goods extends Validate{
 | 
			
		||||
	protected $rule = [
 | 
			
		||||
        ['goodsName'  ,'require|max:300','请输入商品名称|商品名称不能超过100个字符'],
 | 
			
		||||
        ['goodsImg'  ,'require','请上传商品图片'],
 | 
			
		||||
        ['goodsType'  ,'in:,0,1','无效的商品类型'],
 | 
			
		||||
        ['goodsSn'  ,'checkGoodsSn:1','请输入商品编号'],
 | 
			
		||||
        ['productNo'  ,'checkProductNo:1','请输入商品货号'],
 | 
			
		||||
        ['marketPrice'  ,'checkMarketPrice:1','请输入市场价格'],
 | 
			
		||||
        ['shopPrice'  ,'checkShopPrice:1','请输入店铺价格'],
 | 
			
		||||
        ['goodsUnit'  ,'require','请输入商品单位'],
 | 
			
		||||
        ['isSale'  ,'in:,0,1','无效的上架状态'],
 | 
			
		||||
        ['isRecom'  ,'in:,0,1','无效的推荐状态'],
 | 
			
		||||
        ['isBest'  ,'in:,0,1','无效的精品状态'],
 | 
			
		||||
        ['isNew'  ,'in:,0,1','无效的新品状态'],
 | 
			
		||||
        ['isHot'  ,'in:,0,1','无效的热销状态'],
 | 
			
		||||
        ['isFreeShipping','in:,0,1','无效的包邮状态'],
 | 
			
		||||
        ['goodsCatId'  ,'require','请选择完整商品分类'],
 | 
			
		||||
        ['goodsDesc','require','请输入商品描述'],
 | 
			
		||||
        ['specsIds','checkSpecsIds:1','请填写完整商品规格信息']
 | 
			
		||||
    ];
 | 
			
		||||
    /**
 | 
			
		||||
     * 检测商品编号
 | 
			
		||||
     */
 | 
			
		||||
    protected function checkGoodsSn($value){
 | 
			
		||||
    	$goodsId = Input('post.goodsId/d',0);
 | 
			
		||||
    	$key = Input('post.goodsSn');
 | 
			
		||||
    	if($key=='')return '请输入商品编号';
 | 
			
		||||
    	$isChk = model('Goods')->checkExistGoodsKey('goodsSn',$key,$goodsId);
 | 
			
		||||
    	if($isChk)return '对不起,该商品编号已存在';
 | 
			
		||||
    	return true;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 检测商品货号
 | 
			
		||||
     */
 | 
			
		||||
    protected function checkProductNo($value){
 | 
			
		||||
    	$goodsId = Input('post.goodsId/d',0);
 | 
			
		||||
    	$key = Input('post.productNo');
 | 
			
		||||
    	if($key=='')return '请输入商品货号';
 | 
			
		||||
    	$isChk = model('Goods')->checkExistGoodsKey('productNo',$key,$goodsId);
 | 
			
		||||
    	if($isChk)return '对不起,该商品货号已存在';
 | 
			
		||||
    	return true;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 检测价格
 | 
			
		||||
     */
 | 
			
		||||
    public function checkMarketPrice(){
 | 
			
		||||
        $marketPrice = floatval(input('post.marketPrice'));
 | 
			
		||||
        if($marketPrice<0.01)return '市场价格不能小于0.01';
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    public function checkShopPrice(){
 | 
			
		||||
        $shopPrice = floatval(input('post.shopPrice'));
 | 
			
		||||
        if($shopPrice<0.01)return '店铺价格不能小于0.01';
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 检测商品规格是否填写完整
 | 
			
		||||
     */
 | 
			
		||||
    public function checkSpecsIds(){
 | 
			
		||||
    	$specsIds = input('post.specsIds');
 | 
			
		||||
    	if($specsIds!=''){
 | 
			
		||||
	    	$str = explode(',',$specsIds);
 | 
			
		||||
	    	$specsIds = [];
 | 
			
		||||
	    	foreach ($str as $v){
 | 
			
		||||
	    		$vs = explode('-',$v);
 | 
			
		||||
	    		foreach ($vs as $vv){
 | 
			
		||||
	    		   if(!in_array($vv,$specsIds))$specsIds[] = $vv;
 | 
			
		||||
	    		}
 | 
			
		||||
	    	}
 | 
			
		||||
    		//检测规格名称是否填写完整
 | 
			
		||||
    		foreach ($specsIds as $v){
 | 
			
		||||
    			if(input('post.specName_'.$v)=='')return '请填写完整商品规格值';
 | 
			
		||||
    		}
 | 
			
		||||
    		//检测销售规格是否完整	
 | 
			
		||||
    		foreach ($str as $v){
 | 
			
		||||
    			if(input('post.productNo_'.$v)=='')return '请填写完整商品销售规格-货号';
 | 
			
		||||
                if(input('post.marketPrice_'.$v)=='')return '请填写完整商品销售规格-市场价';
 | 
			
		||||
                if(floatval(input('post.marketPrice_'.$v))<0.01)return '商品销售规格-市场价不能小于0.01';
 | 
			
		||||
                if(input('post.specPrice_'.$v)=='')return '请填写完整商品销售规格-本店价';
 | 
			
		||||
                if(floatval(input('post.specPrice_'.$v))<0.01)return '商品销售规格-本店价不能小于0.01';
 | 
			
		||||
                if(input('post.specStock_'.$v)=='')return '请填写完整商品销售规格-库存';
 | 
			
		||||
                if(intval(input('post.specStock_'.$v))<0)return '商品销售规格-库存不能小于0';
 | 
			
		||||
                if(input('post.warnStock_'.$v)=='')return '请填写完整商品销售规格-预警库存';
 | 
			
		||||
                if(intval(input('post.warnStock_'.$v))<0)return '商品销售规格-预警库存不能小于0';
 | 
			
		||||
    		}
 | 
			
		||||
    		if(input('post.defaultSpec')=='')return '请选择推荐规格';
 | 
			
		||||
    	}
 | 
			
		||||
    	return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										118
									
								
								hyhproject/home/validate/Shops.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										118
									
								
								hyhproject/home/validate/Shops.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,118 @@
 | 
			
		||||
<?php 
 | 
			
		||||
namespace wstmart\home\validate;
 | 
			
		||||
use think\Validate;
 | 
			
		||||
/**
 | 
			
		||||
 * ============================================================================
 | 
			
		||||
 * 店铺验证器
 | 
			
		||||
 */
 | 
			
		||||
class Shops extends Validate{
 | 
			
		||||
	protected $rule = [
 | 
			
		||||
        //入驻步骤1
 | 
			
		||||
        ['applyLinkMan','require','请输入联系人姓名'],
 | 
			
		||||
        ['applyLinkTel','require','请输入联系人手机'],
 | 
			
		||||
       // ['applyLinkEmail','require','请输入联系人邮箱'],
 | 
			
		||||
        ['isInvestment','in:0,1','无效的对接商城招商人参数'],
 | 
			
		||||
        ['investmentStaff','checkInvestment:1','请输入商城招商人员姓名'],
 | 
			
		||||
        //入驻步骤2
 | 
			
		||||
        ['businessLicenceType','require','请选择执照类型'],
 | 
			
		||||
        ['businessLicence','require','请输入营业执照注册号'],
 | 
			
		||||
        ['legalPersonName','require','请输入法定代表人姓名'],
 | 
			
		||||
        //['businessAreaPath0','require','请选择营业执照所在地'],
 | 
			
		||||
        //['licenseAddress','require','请输入营业执照详细地址'],
 | 
			
		||||
        //['establishmentDate','require','请选择成立日期'],
 | 
			
		||||
        //['businessStartDate','require','请输入营业期限开始日期'],
 | 
			
		||||
        //['businessEndDate','checkBusinessEndDate:1','请输入营业期限结束日期'],
 | 
			
		||||
        //['isLongbusinessDate','in:0,1','无效的营业期限参数'],
 | 
			
		||||
        //['registeredCapital','require','请输入注册资本'],
 | 
			
		||||
        //['empiricalRange','require','请输入经营范围'],
 | 
			
		||||
        ['areaIdPath0','require','请选择公司所在地'],
 | 
			
		||||
        ['shopCompany','require','请输入公司名称'],
 | 
			
		||||
        ['shopAddress','require','请输入公司详细地址'],
 | 
			
		||||
        ['shopTel','require','请输入公司电话'],
 | 
			
		||||
        // mark by cheng 添加开店必须输入旺旺和qq20130318
 | 
			
		||||
        //['shopWangWang','require','请输入店铺客服旺旺'],
 | 
			
		||||
        //['shopQQ','require','请输入店铺客服QQ'],
 | 
			
		||||
        ['shopkeeper','require','请输入公司紧急联系人'],
 | 
			
		||||
        ['telephone','require','请输入公司紧急联系人电话'],
 | 
			
		||||
        ['legalCertificateType','require','请选择法人代表证件类型'],
 | 
			
		||||
        ['legalCertificate','require','请输入法定代表人证件号'],
 | 
			
		||||
        //['legalCertificateStartDate','require','请选择法定代表人证件有效期开始日期'],
 | 
			
		||||
        //['legalCertificateEndDate','checkLegalCertificateEndDate:1','请选择法定代表人证件有效期结束日期'],
 | 
			
		||||
        //['isLonglegalCertificateDate','in:0,1','无效的代表人证件有效期参数'],
 | 
			
		||||
        ['legalCertificateImg','require','请上传法人证件电子版'],
 | 
			
		||||
        ['businessLicenceImg','require','请上传营业执照电子版'],
 | 
			
		||||
        ['bankAccountPermitImg','require','请上传银行开户许可证电子版'],
 | 
			
		||||
        // ['organizationCode','require','请输入组织机构代码'],
 | 
			
		||||
        // ['organizationCodeStartDate','require','请输入商标注册证有效期开始日期'],
 | 
			
		||||
        // ['organizationCodeEndDate','checkOrganizationCodeEndDate:1','请输入商标注册证有效期结束日期'],
 | 
			
		||||
        // ['isLongOrganizationCodeDate','in:0,1','无效的商标注册证有效期参数'],
 | 
			
		||||
        ['organizationCodeImg','require','请上传商标注册证电子版'],
 | 
			
		||||
        //入驻步骤3
 | 
			
		||||
        /*--------取消上传图片选项 mark hsf 20180104----------*/
 | 
			
		||||
        //['taxpayerType','require','请选择纳税人类型'],
 | 
			
		||||
        //['taxpayerNo','require','请输入纳税人识别号'],
 | 
			
		||||
        //['taxRegistrationCertificateImg','require','请上传税务登记证电子版'],
 | 
			
		||||
        //['taxpayerQualificationImg','require','请上传一般纳税人资格证电子版'],
 | 
			
		||||
        /*-------------------------end-------------------------*/
 | 
			
		||||
        ['bankUserName'  ,'require|max:100','请输入持卡人名称|持卡人名称长度不能能超过50个字符'],
 | 
			
		||||
        ['bankNo'  ,'require','请选择银行账号'],
 | 
			
		||||
        ['bankId'  ,'require','请选择结算银行'],
 | 
			
		||||
        //['bankAreaId'  ,'require','请选择开户所地区'],
 | 
			
		||||
        //入驻步骤4
 | 
			
		||||
        ['shopName'  ,'require','请输入店铺名称'],
 | 
			
		||||
        ['shopImg'  ,'require','请上传店铺图标'],
 | 
			
		||||
        ['goodsCatIds'  ,'require','请选择经营类目'],
 | 
			
		||||
        ['isInvoice'  ,'in:0,1','无效的发票类型'],
 | 
			
		||||
        ['invoiceRemarks','checkInvoiceRemark:1','请输入发票说明'],
 | 
			
		||||
        ['freight','integer','请输入运费'],
 | 
			
		||||
        ['serviceStartTime','require','请选择服务开始时间'],
 | 
			
		||||
        ['serviceEndTime','require','请选择服务结束时间']
 | 
			
		||||
    ];
 | 
			
		||||
/*
 | 
			
		||||
 public $scene = [
 | 
			
		||||
        'editInfo'  =>['shopImg','isInvoice','serviceStartTime','serviceEndTime','freight'],
 | 
			
		||||
        'editBank'  =>['bankId','bankAreaId','bankNo','bankUserName'],
 | 
			
		||||
        'applyStep1'=>['applyLinkMan','applyLinkTel','applyLinkEmail','isInvestment','investmentStaff'],
 | 
			
		||||
        'applyStep2'=>['businessLicenceType','businessLicence','legalPersonName','businessAreaPath0','licenseAddress','establishmentDate','businessStartDate','businessEndDate','isLongbusinessDate','registeredCapital','empiricalRange','areaIdPath0','shopCompany','shopAddress','shopTel','shopkeeper','telephone','shopEmergencyLinkMan','legalCertificateType','legalCertificate','legalCertificateStartDate','legalCertificateEndDate','isLonglegalCertificateDate','legalCertificateImg','businessLicenceImg','bankAccountPermitImg','organizationCode','organizationCodeStartDate','organizationCodeEndDate','organizationCodeImg'],
 | 
			
		||||
        'applyStep3'=>['taxpayerType','taxpayerNo','taxRegistrationCertificateImg','taxpayerQualificationImg','bankUserName','bankNo','bankId','bankAreaId'],
 | 
			
		||||
        'applyStep4'=>['shopName','shopImg','goodsCatIds','isInvoice','invoiceRemarks','freight','serviceStartTime','serviceEndTime']
 | 
			
		||||
    ]; 
 | 
			
		||||
    */
 | 
			
		||||
    //添加旺旺和qq非空验证 mark by cheng 20170318 
 | 
			
		||||
    public $scene = [
 | 
			
		||||
        'editInfo'  =>['shopImg','isInvoice','serviceStartTime','serviceEndTime','freight'],
 | 
			
		||||
        'editBank'  =>['bankId','bankAreaId','bankNo','bankUserName'],
 | 
			
		||||
        'applyStep1'=>['applyLinkMan','applyLinkTel','applyLinkEmail','isInvestment','investmentStaff'],
 | 
			
		||||
        'applyStep2'=>['businessLicenceType','businessLicence','legalPersonName','businessAreaPath0','licenseAddress','establishmentDate','businessStartDate','businessEndDate','isLongbusinessDate','registeredCapital','empiricalRange','areaIdPath0','shopCompany','shopAddress','shopTel','shopkeeper','telephone','shopEmergencyLinkMan','legalCertificateType','legalCertificate','legalCertificateStartDate','legalCertificateEndDate','isLonglegalCertificateDate','legalCertificateImg','businessLicenceImg','bankAccountPermitImg','organizationCode','organizationCodeStartDate','organizationCodeEndDate','organizationCodeImg'],
 | 
			
		||||
        'applyStep3'=>['taxpayerType','taxpayerNo','taxRegistrationCertificateImg','taxpayerQualificationImg','bankUserName','bankNo','bankId','bankAreaId'],
 | 
			
		||||
        'applyStep4'=>['shopName','shopImg','goodsCatIds','isInvoice','invoiceRemarks','freight','serviceStartTime','serviceEndTime']
 | 
			
		||||
    ]; 
 | 
			
		||||
    
 | 
			
		||||
    protected function checkInvoiceRemark($value){
 | 
			
		||||
    	$isInvoice = input('post.isInvoice/d',0);
 | 
			
		||||
    	$key = Input('post.invoiceRemarks');
 | 
			
		||||
    	return ($isInvoice==1 && $key=='')?'请输入发票说明':true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function checkInvestment($value){
 | 
			
		||||
        $isInvestment = input('post.isInvestment/d',0);
 | 
			
		||||
        $key = Input('post.investmentStaff');
 | 
			
		||||
        return ($isInvestment==1 && $key=='')?'请输入商城招商人员姓名':true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function checkBusinessEndDate($value){
 | 
			
		||||
        $isLongbusinessDate = input('post.isLongbusinessDate/d',0);
 | 
			
		||||
        $key = Input('post.businessEndDate');
 | 
			
		||||
        return ($isLongbusinessDate==0 && $key=='')?'请输入营业期限结束日期':true;
 | 
			
		||||
    }
 | 
			
		||||
    protected function checkLegalCertificateEndDate($value){
 | 
			
		||||
        $isLonglegalCertificateDate = input('post.isLonglegalCertificateDate/d',0);
 | 
			
		||||
        $key = Input('post.legalCertificateEndDate');
 | 
			
		||||
        return ($isLonglegalCertificateDate==0 && $key=='')?'请选择法定代表人证件有效期结束日期':true;
 | 
			
		||||
    }
 | 
			
		||||
    protected function checkOrganizationCodeEndDate($value){
 | 
			
		||||
        // $isLonglegalCertificateDate = input('post.isLongOrganizationCodeDate/d',0);
 | 
			
		||||
        // $key = Input('post.organizationCodeEndDate');
 | 
			
		||||
        // return ($isLonglegalCertificateDate==0 && $key=='')?'请输入商标注册证有效期结束日期':true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user