<?php
 namespace Payment\Common\Cmb\Data; use Payment\Common\BaseData; use Payment\Common\PayException; use Payment\Utils\ArrayUtil; abstract class CmbBaseData extends BaseData { protected function makeSign($signStr) { switch ($this->signType) { case 'SHA-256': $sign = hash('sha256', "$signStr&{$this->merKey}"); break; default: $sign = ''; } return $sign; } protected function buildData() { $signData = [ 'version' => $this->version, 'charset' => $this->charset, 'signType' => $this->signType, 'reqData' => $this->getReqData(), ]; $this->retData = ArrayUtil::paraFilter($signData); } protected function checkDataParam() { $branchNo = $this->branchNo; $merchantNo = $this->merchantNo; if (empty($branchNo) || mb_strlen($branchNo) !== 4) { throw new PayException('商户分行号，4位数字'); } if (empty($merchantNo) || mb_strlen($merchantNo) !== 6) { throw new PayException('商户号，6位数字'); } } abstract protected function getReqData(); } 