'CGRK', '10' => 'DBRK', '20' => 'QTRK', '30' => 'XNRK', '40' => 'QTRK', ]; /** * 选择物流公司 * @param string $province * @param string $weight * @return string */ public function chooseLogisticsCompany($province, $weight) { $expressChooseConf = require(dirname(dirname(__FILE__)) . '/config/express_choose.php'); if (in_array($province, $expressChooseConf['address_list'])) { if ($weight >= $expressChooseConf['jzh_express_weight']) { $logisticsCode = 'KYE'; } else { $logisticsCode = 'STO'; } } else { if ($weight >= $expressChooseConf['other_express_weight']) { $logisticsCode = 'KYE'; } else { $logisticsCode = 'STO'; } } return $logisticsCode; } function filterEmoji(string $str): string { if (!empty($str)) { $str = preg_replace_callback( '/./u', function (array $match) { return strlen($match[0]) >= 4 ? '' : $match[0]; }, $str ); } return $str; } /** * 金额转换分=》元 * * @param mixed $data * @param array $fields 一层数组字段转化 * @param array $multi 两层数组转化 * * @return float|array */ function cent2yuan($data, $fields = [], $multi = []) { if (is_array($data) && !empty($data)) { if (!empty($multi)) { foreach ($multi as $key => $val) { $data[$key] = $this->cent2yuan($data[$key], $val); } } if (!empty($fields)) { foreach ($fields as $key => &$val) { if (is_int($key) && isset($data[$val])) { $data[$val] = $this->formatMoneyDiv($data[$val], 100, 2); } if (!is_int($key) && isset($data[$key]) && is_array($val)) { foreach ($data[$key] as &$datum) { foreach ($val as $item) { $datum[$item] = $this->formatMoneyDiv( $datum[$item], 100, 2 ); } } } } return $data; } } if (is_numeric($data) || is_string($data)) { if ($data === 0 || $data === '0') { return '0.00'; } else { return $this->formatMoneyDiv($data, 100, 2); } } return $data; } /** 除法 */ function formatMoneyDiv($param1, $param2, $scale = 2) { return bcdiv($param1, $param2, $scale); } //格式化金额 function formatNumber($number, $decimals = 2) { return number_format($number, $decimals, ".", ""); } //商品入库采购单号 function goodsWarehouseCgrkNumber() { return "10" . $this->generate(); } function generate() { $time = date("YmdHis", time()); $no = $time . rand(1000, 9999); return substr($no, 2, strlen($no)); } }