|
@@ -341,6 +341,15 @@ class GluingReport extends Api
|
|
|
$this->error($validate->getError());
|
|
$this->error($validate->getError());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if ($this->isEmptyReportPrice($param['price'] ?? null)) {
|
|
|
|
|
+ $resolvedPrice = $this->resolveReportPrice($param);
|
|
|
|
|
+ if ($resolvedPrice !== null) {
|
|
|
|
|
+ $param['price'] = $resolvedPrice;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ unset($param['price']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 3. 事务处理(确保数据一致性)
|
|
// 3. 事务处理(确保数据一致性)
|
|
|
$currentTime = date('Y-m-d H:i:s');
|
|
$currentTime = date('Y-m-d H:i:s');
|
|
|
$tableClass = '糊盒报工班组';
|
|
$tableClass = '糊盒报工班组';
|
|
@@ -1058,8 +1067,227 @@ class GluingReport extends Api
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 判断报工单价是否为空
|
|
|
|
|
+ * @param mixed $price
|
|
|
|
|
+ * @return bool
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function isEmptyReportPrice($price)
|
|
|
|
|
+ {
|
|
|
|
|
+ return $price === null || $price === '';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 报工时自动解析单价
|
|
|
|
|
+ * @param array $param
|
|
|
|
|
+ * @return float|null
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function resolveReportPrice(array $param)
|
|
|
|
|
+ {
|
|
|
|
|
+ $machine = trim($param['sczl_jtbh']);
|
|
|
|
|
+ $gxmc = trim($param['sczl_gxmc']);
|
|
|
|
|
+ $count = $this->extractManualProcessCountSilent($param);
|
|
|
|
|
+
|
|
|
|
|
+ $machinePrices = $this->collectMachinePriceValues($machine);
|
|
|
|
|
+ if (!empty($machinePrices)) {
|
|
|
|
|
+ return (float)$machinePrices[0];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $manualPrice = $this->resolveManualProcessPriceSilent($gxmc, $count);
|
|
|
|
|
+ if ($manualPrice !== null) {
|
|
|
|
|
+ return $manualPrice;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $aiService = new Aicompute();
|
|
|
|
|
+ $rates = $aiService->fetchWorkshopRatesByMachine($machine);
|
|
|
|
|
+ if (empty($rates)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $productName = db('工单_基本资料')
|
|
|
|
|
+ ->where('Gd_gdbh', trim($param['sczl_gdbh']))
|
|
|
|
|
+ ->value('Gd_cpmc');
|
|
|
|
|
+ $productName = $productName ? trim($productName) : '';
|
|
|
|
|
+
|
|
|
|
|
+ if ($productName !== '') {
|
|
|
|
|
+ $matched = $aiService->matchWorkshopRateByProductName($rates, $productName);
|
|
|
|
|
+ if (!empty($matched)) {
|
|
|
|
|
+ return (float)$matched['piece_price'];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $aiPrice = $aiService->resolvePiecePriceByAi(trim($param['sczl_gdbh']), $machine);
|
|
|
|
|
+ if ($aiPrice !== null) {
|
|
|
|
|
+ return $aiPrice;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return (float)$rates[0]['piece_price'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 收集机台单价列表
|
|
|
|
|
+ * @param string $machine
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function collectMachinePriceValues($machine)
|
|
|
|
|
+ {
|
|
|
|
|
+ $list = db('machine_price')
|
|
|
|
|
+ ->where('machine_id', $machine)
|
|
|
|
|
+ ->field('price1,price2,price3,price4,price5,price6,price7,price8,price9,price10')
|
|
|
|
|
+ ->select();
|
|
|
|
|
+
|
|
|
|
|
+ $result = [];
|
|
|
|
|
+ foreach ($list as $item) {
|
|
|
|
|
+ foreach ($item as $value) {
|
|
|
|
|
+ if ($value !== '' && $value !== null) {
|
|
|
|
|
+ $result[] = $value;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 静默解析手工工序单价(报工场景,不中断请求)
|
|
|
|
|
+ * @param string $gxmc
|
|
|
|
|
+ * @param int|null $count
|
|
|
|
|
+ * @return float|null
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function resolveManualProcessPriceSilent($gxmc, $count)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (strpos($gxmc, '割围条') !== false) {
|
|
|
|
|
+ $row = db('machine_price')->where('machine_id', '手工割围条')->find();
|
|
|
|
|
+ return $row ? (float)$row['price1'] : null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (strpos($gxmc, '打孔') !== false) {
|
|
|
|
|
+ if ($count === null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->resolvePunchHolePrice($count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (strpos($gxmc, '拆片') !== false) {
|
|
|
|
|
+ $rows = db('machine_price')->where('machine_id', '手工拆片')->select();
|
|
|
|
|
+ if (empty($rows)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->resolveManualStripPriceSilent($rows, $gxmc, $count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $row = db('machine_price')
|
|
|
|
|
+ ->where('machine_id', $gxmc)
|
|
|
|
|
+ ->whereOr('machine_name', 'like', '%' . $gxmc . '%')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+
|
|
|
|
|
+ return $row ? (float)$row['price1'] : null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 静默提取孔数/拼数
|
|
|
|
|
+ * @param array $params
|
|
|
|
|
+ * @return int|null
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function extractManualProcessCountSilent(array $params)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!isset($params['count']) || $params['count'] === '') {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!is_numeric($params['count']) || (int)$params['count'] != $params['count'] || (int)$params['count'] <= 0) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return (int)$params['count'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 静默解析手工拆片单价
|
|
|
|
|
+ * @param array $rows
|
|
|
|
|
+ * @param string $gxmc
|
|
|
|
|
+ * @param int|null $count
|
|
|
|
|
+ * @return float|null
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function resolveManualStripPriceSilent(array $rows, $gxmc, $count)
|
|
|
|
|
+ {
|
|
|
|
|
+ $gxmc = trim($gxmc);
|
|
|
|
|
+
|
|
|
|
|
+ if ($gxmc === '手工拆片' || $gxmc === '拆片') {
|
|
|
|
|
+ if ($count === null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->resolveDefaultStripPriceByCount($count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($gxmc !== '') {
|
|
|
|
|
+ $row = $this->matchManualPriceRow($rows, $gxmc);
|
|
|
|
|
+ if (empty($row)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->calculateStripPriceByRowSilent($row, $count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($count === null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $this->resolveDefaultStripPriceByCount($count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 静默计算拆片规格单价
|
|
|
|
|
+ * @param array $row
|
|
|
|
|
+ * @param int|null $count
|
|
|
|
|
+ * @return float|null
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function calculateStripPriceByRowSilent(array $row, $count)
|
|
|
|
|
+ {
|
|
|
|
|
+ $name = $row['machine_name'];
|
|
|
|
|
+ $basePrice = (float)$row['price1'];
|
|
|
|
|
+
|
|
|
|
|
+ if (strpos($name, '1-4拼(特种纸') !== false) {
|
|
|
|
|
+ if ($count === null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($count <= 4) {
|
|
|
|
|
+ return $basePrice;
|
|
|
|
|
+ }
|
|
|
|
|
+ return floatval(number_format($basePrice + ($count - 4) * 0.001, 4, '.', ''));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (strpos($name, '1-4拼(小盒二次拆片') !== false) {
|
|
|
|
|
+ if ($count === null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($count === 8) {
|
|
|
|
|
+ return 0.01;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($count === 10) {
|
|
|
|
|
+ return 0.012;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $basePrice;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (strpos($name, '5-6拼(小盒二次拆片') !== false) {
|
|
|
|
|
+ return $basePrice;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (strpos($name, '6拼及以上') !== false) {
|
|
|
|
|
+ return $basePrice;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (preg_match('/^(\d+)拼/u', $name) && $count === null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $basePrice;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取机台报工单价数据
|
|
* 获取机台报工单价数据
|
|
|
|
|
+ * 参数:machine(机台编号)、gxmc(工序名称)、count(孔数/拼数,纯数字)
|
|
|
|
|
+ * 优先按机台编号查询;查不到则按手工工序(gxmc + count)匹配单价
|
|
|
* @return void
|
|
* @return void
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
@@ -1067,17 +1295,19 @@ class GluingReport extends Api
|
|
|
*/
|
|
*/
|
|
|
public function getMachinePriceData()
|
|
public function getMachinePriceData()
|
|
|
{
|
|
{
|
|
|
- if ($this->request->isGet() === false){
|
|
|
|
|
|
|
+ if ($this->request->isGet() === false) {
|
|
|
$this->error('请求错误');
|
|
$this->error('请求错误');
|
|
|
}
|
|
}
|
|
|
$params = $this->request->param();
|
|
$params = $this->request->param();
|
|
|
- if (!isset($params['machine']) || empty($params['machine'])){
|
|
|
|
|
|
|
+ if (!isset($params['machine']) || $params['machine'] === '') {
|
|
|
$this->error('参数错误');
|
|
$this->error('参数错误');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //查询机台的单价列表(仅返回有值的单价)
|
|
|
|
|
|
|
+ $machine = trim($params['machine']);
|
|
|
|
|
+
|
|
|
|
|
+ // 1. 优先按机台编号查询
|
|
|
$list = db('machine_price')
|
|
$list = db('machine_price')
|
|
|
- ->where('machine_id',$params['machine'])
|
|
|
|
|
|
|
+ ->where('machine_id', $machine)
|
|
|
->field('price1,price2,price3,price4,price5,price6,price7,price8,price9,price10')
|
|
->field('price1,price2,price3,price4,price5,price6,price7,price8,price9,price10')
|
|
|
->select();
|
|
->select();
|
|
|
|
|
|
|
@@ -1089,7 +1319,236 @@ class GluingReport extends Api
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- $this->success('获取成功',$result);
|
|
|
|
|
|
|
+ if (!empty($result)) {
|
|
|
|
|
+ $this->success('获取成功', $result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 机台编号查不到,按手工工序查询
|
|
|
|
|
+ $gxmc = trim((string)($params['gxmc'] ?? ''));
|
|
|
|
|
+ if ($gxmc === '') {
|
|
|
|
|
+ $this->error('未找到机台单价,请传入工序名称');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $price = $this->resolveManualProcessPriceByGxmc($gxmc, $params);
|
|
|
|
|
+ if ($price === null) {
|
|
|
|
|
+ $this->error('未找到匹配的单价');
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->success('获取成功', [$price]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按工序名称解析手工工序单价
|
|
|
|
|
+ * @param string $gxmc 工序名称
|
|
|
|
|
+ * @param array $params count=孔数/拼数(纯数字)
|
|
|
|
|
+ * @return float|null
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function resolveManualProcessPriceByGxmc($gxmc, array $params)
|
|
|
|
|
+ {
|
|
|
|
|
+ $count = $this->extractManualProcessCount($params);
|
|
|
|
|
+
|
|
|
|
|
+ if (strpos($gxmc, '割围条') !== false) {
|
|
|
|
|
+ $row = db('machine_price')->where('machine_id', '手工割围条')->find();
|
|
|
|
|
+ return $row ? (float)$row['price1'] : null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (strpos($gxmc, '打孔') !== false) {
|
|
|
|
|
+ if ($count === null) {
|
|
|
|
|
+ $this->error('请传入孔数(纯数字)');
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->resolvePunchHolePrice($count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (strpos($gxmc, '拆片') !== false) {
|
|
|
|
|
+ $rows = db('machine_price')->where('machine_id', '手工拆片')->select();
|
|
|
|
|
+ if (empty($rows)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->resolveManualStripPrice($rows, $gxmc, $count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 其他手工工序:按 machine_id 或 machine_name 匹配
|
|
|
|
|
+ $row = db('machine_price')
|
|
|
|
|
+ ->where('machine_id', $gxmc)
|
|
|
|
|
+ ->whereOr('machine_name', 'like', '%' . $gxmc . '%')
|
|
|
|
|
+ ->find();
|
|
|
|
|
+ return $row ? (float)$row['price1'] : null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 提取孔数/拼数(前端传入纯数字)
|
|
|
|
|
+ * @param array $params
|
|
|
|
|
+ * @return int|null
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function extractManualProcessCount(array $params)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!isset($params['count']) || $params['count'] === '') {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!is_numeric($params['count']) || (int)$params['count'] != $params['count'] || (int)$params['count'] <= 0) {
|
|
|
|
|
+ $this->error('孔数/拼数必须为大于0的整数');
|
|
|
|
|
+ }
|
|
|
|
|
+ return (int)$params['count'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 手工打孔单价(按孔数区间)
|
|
|
|
|
+ * @param int $holeCount
|
|
|
|
|
+ * @return float
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function resolvePunchHolePrice($holeCount)
|
|
|
|
|
+ {
|
|
|
|
|
+ $holeCount = (int)$holeCount;
|
|
|
|
|
+ if ($holeCount === 1) {
|
|
|
|
|
+ return 0.0055;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($holeCount >= 2 && $holeCount <= 4) {
|
|
|
|
|
+ return 0.007;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($holeCount >= 5 && $holeCount <= 8) {
|
|
|
|
|
+ return 0.012;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($holeCount >= 9 && $holeCount <= 12) {
|
|
|
|
|
+ return 0.016;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($holeCount >= 13 && $holeCount <= 18) {
|
|
|
|
|
+ return 0.025;
|
|
|
|
|
+ }
|
|
|
|
|
+ return floatval(number_format(0.025 + ($holeCount - 18) * 0.001, 4, '.', ''));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 手工拆片单价(按规格名称 + 拼数)
|
|
|
|
|
+ * @param array $rows
|
|
|
|
|
+ * @param string $gxmc 工序规格名称(文字)
|
|
|
|
|
+ * @param int|null $count 拼数(纯数字)
|
|
|
|
|
+ * @return float|null
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function resolveManualStripPrice(array $rows, $gxmc, $count)
|
|
|
|
|
+ {
|
|
|
|
|
+ $gxmc = trim($gxmc);
|
|
|
|
|
+
|
|
|
|
|
+ // 通用拆片工序,仅按拼数数字匹配默认单价
|
|
|
|
|
+ if ($gxmc === '手工拆片' || $gxmc === '拆片') {
|
|
|
|
|
+ if ($count === null) {
|
|
|
|
|
+ $this->error('请传入拼数(纯数字)');
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->resolveDefaultStripPriceByCount($count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($gxmc !== '') {
|
|
|
|
|
+ $row = $this->matchManualPriceRow($rows, $gxmc);
|
|
|
|
|
+ if (empty($row)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->calculateStripPriceByRow($row, $count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($count === null) {
|
|
|
|
|
+ $this->error('请传入拼数(纯数字)');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $this->resolveDefaultStripPriceByCount($count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 默认拆片单价(1.0厚以上灰白板,按拼数数字匹配)
|
|
|
|
|
+ * @param int $count
|
|
|
|
|
+ * @return float
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function resolveDefaultStripPriceByCount($count)
|
|
|
|
|
+ {
|
|
|
|
|
+ $prices = [
|
|
|
|
|
+ 1 => 0.008,
|
|
|
|
|
+ 2 => 0.01,
|
|
|
|
|
+ 3 => 0.013,
|
|
|
|
|
+ 4 => 0.017,
|
|
|
|
|
+ 5 => 0.022,
|
|
|
|
|
+ 6 => 0.028,
|
|
|
|
|
+ ];
|
|
|
|
|
+ $pieceCount = min((int)$count, 6);
|
|
|
|
|
+ return $prices[$pieceCount];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按 machine_name 匹配手工单价行
|
|
|
|
|
+ * @param array $rows
|
|
|
|
|
+ * @param string $gxmc
|
|
|
|
|
+ * @return array|null
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function matchManualPriceRow(array $rows, $gxmc)
|
|
|
|
|
+ {
|
|
|
|
|
+ $gxmc = trim($gxmc);
|
|
|
|
|
+ foreach ($rows as $row) {
|
|
|
|
|
+ if ($row['machine_name'] === $gxmc) {
|
|
|
|
|
+ return $row;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $best = null;
|
|
|
|
|
+ $bestLen = 0;
|
|
|
|
|
+ foreach ($rows as $row) {
|
|
|
|
|
+ $name = $row['machine_name'];
|
|
|
|
|
+ if (strpos($name, $gxmc) !== false || strpos($gxmc, $name) !== false) {
|
|
|
|
|
+ $len = mb_strlen($name);
|
|
|
|
|
+ if ($len > $bestLen) {
|
|
|
|
|
+ $best = $row;
|
|
|
|
|
+ $bestLen = $len;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $best;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据拆片规格行及拼数计算单价
|
|
|
|
|
+ * @param array $row
|
|
|
|
|
+ * @param int|null $count 拼数(纯数字)
|
|
|
|
|
+ * @return float|null
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function calculateStripPriceByRow(array $row, $count)
|
|
|
|
|
+ {
|
|
|
|
|
+ $name = $row['machine_name'];
|
|
|
|
|
+ $basePrice = (float)$row['price1'];
|
|
|
|
|
+
|
|
|
|
|
+ if (strpos($name, '1-4拼(特种纸') !== false) {
|
|
|
|
|
+ if ($count === null) {
|
|
|
|
|
+ $this->error('请传入拼数(纯数字)');
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($count <= 4) {
|
|
|
|
|
+ return $basePrice;
|
|
|
|
|
+ }
|
|
|
|
|
+ return floatval(number_format($basePrice + ($count - 4) * 0.001, 4, '.', ''));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (strpos($name, '1-4拼(小盒二次拆片') !== false) {
|
|
|
|
|
+ if ($count === null) {
|
|
|
|
|
+ $this->error('请传入拼数(纯数字)');
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($count === 8) {
|
|
|
|
|
+ return 0.01;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($count === 10) {
|
|
|
|
|
+ return 0.012;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $basePrice;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (strpos($name, '5-6拼(小盒二次拆片') !== false) {
|
|
|
|
|
+ return $basePrice;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (strpos($name, '6拼及以上') !== false) {
|
|
|
|
|
+ return $basePrice;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (preg_match('/^(\d+)拼/u', $name, $matches)) {
|
|
|
|
|
+ if ($count === null) {
|
|
|
|
|
+ $this->error('请传入拼数(纯数字)');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $basePrice;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|