feat : check
This commit is contained in:
@@ -25,9 +25,13 @@ class PickupCode extends Model
|
|||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*/
|
*/
|
||||||
protected array $fillable = [];
|
protected array $fillable = [];
|
||||||
|
protected array $guarded = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that should be cast to native types.
|
* The attributes that should be cast to native types.
|
||||||
*/
|
*/
|
||||||
protected array $casts = ['id' => 'integer', 'order_id' => 'integer', 'copies' => 'integer'];
|
protected array $casts = ['id' => 'integer', 'order_id' => 'integer', 'copies' => 'integer'];
|
||||||
|
|
||||||
|
const string CREATED_AT = 'create_time';
|
||||||
|
const null UPDATED_AT = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ class CateringService extends CateringBaseService
|
|||||||
if (empty($this->orderList)) throw new ErrException('无数据打印');
|
if (empty($this->orderList)) throw new ErrException('无数据打印');
|
||||||
|
|
||||||
// 打印或者喷码
|
// 打印或者喷码
|
||||||
$res = match ($this->request->input('type')) {
|
$res = match ((int)$this->request->input('type')) {
|
||||||
CateringCode::OPTION_PRINT_YLY => $this->printOrderByYly(),
|
CateringCode::OPTION_PRINT_YLY => $this->printOrderByYly(),
|
||||||
CateringCode::OPTION_PRINT_CODING => $this->printOrderByCoding(),
|
CateringCode::OPTION_PRINT_CODING => $this->printOrderByCoding(),
|
||||||
};
|
};
|
||||||
@@ -199,7 +199,7 @@ class CateringService extends CateringBaseService
|
|||||||
$currentCode++;
|
$currentCode++;
|
||||||
$paddedCode = str_pad((string)$currentCode, 3, '0', STR_PAD_LEFT);
|
$paddedCode = str_pad((string)$currentCode, 3, '0', STR_PAD_LEFT);
|
||||||
$fullCode = "$prefix-$paddedCode";
|
$fullCode = "$prefix-$paddedCode";
|
||||||
$copiesItem['take_food_code'] = $fullCode;
|
$copiesItem['pickup_code'] = $fullCode;
|
||||||
$copiesItem['heapsort'] = $codeRanges[$currentCode] ?? '';
|
$copiesItem['heapsort'] = $codeRanges[$currentCode] ?? '';
|
||||||
$takeFoodCodes[] = [
|
$takeFoodCodes[] = [
|
||||||
'order_id' => $order['id'],
|
'order_id' => $order['id'],
|
||||||
@@ -231,7 +231,7 @@ class CateringService extends CateringBaseService
|
|||||||
{
|
{
|
||||||
$pickupCodeList = $this->pickupCodeModel
|
$pickupCodeList = $this->pickupCodeModel
|
||||||
->whereIn('order_id',$this->orderIds)
|
->whereIn('order_id',$this->orderIds)
|
||||||
->get(['take_food_code', 'order_id', 'box_num', 'heapsort', 'id'])
|
->get(['pickup_code', 'order_id', 'copies', 'heapsort', 'id'])
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
if (empty($pickupCodeList)) {
|
if (empty($pickupCodeList)) {
|
||||||
@@ -243,8 +243,9 @@ class CateringService extends CateringBaseService
|
|||||||
|
|
||||||
foreach ($this->orderList as &$order) {
|
foreach ($this->orderList as &$order) {
|
||||||
foreach ($order['copies_list'] as &$copiesItem) {
|
foreach ($order['copies_list'] as &$copiesItem) {
|
||||||
$copiesItem['take_food_code'] = $pickupCodeArrList[$copiesItem['id']][$copiesItem]['take_food_code'];
|
|
||||||
$copiesItem['heapsort'] = $pickupCodeArrList[$copiesItem['id']][$copiesItem]['heapsort'];
|
$copiesItem['pickup_code'] = $pickupCodeArrList[$order['id']][$copiesItem['copies']]['pickup_code'];
|
||||||
|
$copiesItem['heapsort'] = $pickupCodeArrList[$order['id']][$copiesItem['copies']]['heapsort'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($pickupCodeArrList);
|
unset($pickupCodeArrList);
|
||||||
@@ -262,11 +263,11 @@ class CateringService extends CateringBaseService
|
|||||||
try {
|
try {
|
||||||
Db::beginTransaction();
|
Db::beginTransaction();
|
||||||
|
|
||||||
$delRes = $this->pickupCodeModel->whereIn('order_id',$this->orderIds)->delete();
|
$this->pickupCodeModel->whereIn('order_id',$this->orderIds)->delete();
|
||||||
$insertModel = new PickupCode();
|
$insertModel = new PickupCode();
|
||||||
$insertRes = $insertModel->insert($codeRanges);
|
$insertRes = $insertModel->insert($codeRanges);
|
||||||
|
|
||||||
if (!$insertRes || !$delRes) throw new Exception('取餐码生成失败');
|
if (!$insertRes) throw new Exception('取餐码生成失败');
|
||||||
|
|
||||||
$this->buildPickupCodeCache();
|
$this->buildPickupCodeCache();
|
||||||
|
|
||||||
@@ -358,6 +359,8 @@ class CateringService extends CateringBaseService
|
|||||||
// $adminInfo = $this->adminUserModel->find($this->siteInfo->delivered_id);
|
// $adminInfo = $this->adminUserModel->find($this->siteInfo->delivered_id);
|
||||||
$driverInfo = $this->driverSequenceModel->where('driver_id',$this->siteInfo->delivered_id)->first();
|
$driverInfo = $this->driverSequenceModel->where('driver_id',$this->siteInfo->delivered_id)->first();
|
||||||
if (empty($driverInfo)) throw new ErrException('配送员信息丢失,请联系管理员');
|
if (empty($driverInfo)) throw new ErrException('配送员信息丢失,请联系管理员');
|
||||||
|
if ($driverInfo->driver_num <= 0) throw new ErrException('配送员编号丢失,请联系管理员');
|
||||||
|
if (empty($driverInfo->driver_name)) throw new ErrException('配送员姓名丢失,请联系管理员');
|
||||||
|
|
||||||
foreach ($orderList as &$one) {
|
foreach ($orderList as &$one) {
|
||||||
$one['dates'] = date('Y-m-d');
|
$one['dates'] = date('Y-m-d');
|
||||||
@@ -435,13 +438,11 @@ class CateringService extends CateringBaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($result[$orderId][$copies])) {
|
if (!isset($result[$orderId][$copies])) {
|
||||||
$result[$orderId][$copies] = [];
|
$result[$orderId][$copies] = [
|
||||||
|
'pickup_code' => $pickupCode,
|
||||||
|
'heapsort' => $heapsort,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$result[$orderId][$copies][] = [
|
|
||||||
'pickup_code' => $pickupCode,
|
|
||||||
'heapsort' => $heapsort,
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -477,6 +478,8 @@ class CateringService extends CateringBaseService
|
|||||||
if (empty($this->logInfo)) throw new ErrException('配餐数据不存在');
|
if (empty($this->logInfo)) throw new ErrException('配餐数据不存在');
|
||||||
|
|
||||||
if ($this->logInfo->quantity <= 0) throw new ErrException('该配餐数量为0,不可配餐');
|
if ($this->logInfo->quantity <= 0) throw new ErrException('该配餐数量为0,不可配餐');
|
||||||
|
|
||||||
|
if ($this->siteInfo->sequence <= 0) throw new ErrException('请先配置点位顺序');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -492,7 +495,7 @@ class CateringService extends CateringBaseService
|
|||||||
*/
|
*/
|
||||||
private function printOrderByYly(): true
|
private function printOrderByYly(): true
|
||||||
{
|
{
|
||||||
$service = $this->printOrderFactory->handle($this->request->input('type'));
|
$service = $this->printOrderFactory->handle((int)$this->request->input('type'));
|
||||||
$service->printId = (int)$this->request->input('print_id');
|
$service->printId = (int)$this->request->input('print_id');
|
||||||
$service->handle();
|
$service->handle();
|
||||||
|
|
||||||
@@ -506,13 +509,13 @@ class CateringService extends CateringBaseService
|
|||||||
//todo 数据加载做一下
|
//todo 数据加载做一下
|
||||||
$service->data = [
|
$service->data = [
|
||||||
'pickup_code' => $copiesItem['pickup_code'],
|
'pickup_code' => $copiesItem['pickup_code'],
|
||||||
'driver_num' => '',
|
'driver_num' => $one['driver_num'],
|
||||||
'site_order' => '',
|
'site_order' => $one['site_order'],
|
||||||
'site_text' => '',
|
'site_text' => $one['site_text'],
|
||||||
'order_sno' => '',
|
'order_sno' => $one['order_sno'],
|
||||||
'username' => '',
|
'username' => $one['nickname'],
|
||||||
'date' => '',
|
'date' => $one['dates'],
|
||||||
'mobile' => '',
|
'mobile' => $one['mobile'],
|
||||||
'heapsort' => $copiesItem['heapsort'],
|
'heapsort' => $copiesItem['heapsort'],
|
||||||
'sku' => $copiesItem['sku'],
|
'sku' => $copiesItem['sku'],
|
||||||
];
|
];
|
||||||
@@ -530,10 +533,10 @@ class CateringService extends CateringBaseService
|
|||||||
if ($printBoxNum != 0) continue;
|
if ($printBoxNum != 0) continue;
|
||||||
|
|
||||||
$service->data = [
|
$service->data = [
|
||||||
'driver_num' => '',
|
'driver_num' => $one['driver_num'],
|
||||||
'site_order' => '',
|
'site_order' => $one['site_order'],
|
||||||
'site_text' => '',
|
'site_text' => $one['site_text'],
|
||||||
'driver_name' => '',
|
'driver_name' => $one['real_name'],
|
||||||
'current_num' => $printCurrentNum,
|
'current_num' => $printCurrentNum,
|
||||||
'date_text' => date('Y-m-d'),
|
'date_text' => date('Y-m-d'),
|
||||||
'copies_num' => $this->copiesCount,
|
'copies_num' => $this->copiesCount,
|
||||||
@@ -554,7 +557,7 @@ class CateringService extends CateringBaseService
|
|||||||
*/
|
*/
|
||||||
private function printOrderByCoding(): array
|
private function printOrderByCoding(): array
|
||||||
{
|
{
|
||||||
$service = $this->printOrderFactory->handle($this->request->input('type'));
|
$service = $this->printOrderFactory->handle((int)$this->request->input('type'));
|
||||||
|
|
||||||
$printBoxNum = 0;
|
$printBoxNum = 0;
|
||||||
$printCurrentNum = 0;
|
$printCurrentNum = 0;
|
||||||
@@ -565,13 +568,13 @@ class CateringService extends CateringBaseService
|
|||||||
foreach ($one['copies_list'] as $copiesItem) {
|
foreach ($one['copies_list'] as $copiesItem) {
|
||||||
$service->data = [
|
$service->data = [
|
||||||
'pickup_code' => $copiesItem['pickup_code'],
|
'pickup_code' => $copiesItem['pickup_code'],
|
||||||
'driver_num' => '',
|
'driver_num' => $one['driver_num'],
|
||||||
'site_order' => '',
|
'site_order' => $one['site_order'],
|
||||||
'site_text' => '',
|
'site_text' => $one['site_text'],
|
||||||
'order_sno' => '',
|
'order_sno' => $one['order_sno'],
|
||||||
'username' => '',
|
'username' => $one['nickname'],
|
||||||
'date' => '',
|
'date' => $one['dates'],
|
||||||
'mobile' => '',
|
'mobile' => $one['mobile'],
|
||||||
'heapsort' => $copiesItem['heapsort'],
|
'heapsort' => $copiesItem['heapsort'],
|
||||||
'sku' => $copiesItem['sku'],
|
'sku' => $copiesItem['sku'],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -99,12 +99,16 @@ class CompletePrintService extends CateringBaseService
|
|||||||
|
|
||||||
|
|
||||||
$siteInfo = $this->siteModel->find($orderInfo->site_id);
|
$siteInfo = $this->siteModel->find($orderInfo->site_id);
|
||||||
|
if ($siteInfo->sequence <= 0) throw new ErrException('请先配置点位顺序');
|
||||||
|
|
||||||
$userInfo = $this->userModel->find($orderInfo->user_id);
|
$userInfo = $this->userModel->find($orderInfo->user_id);
|
||||||
|
|
||||||
$driverInfo = $this->driverSequenceModel->find($siteInfo->delivered_id);
|
$driverInfo = $this->driverSequenceModel->find($siteInfo->delivered_id);
|
||||||
|
if (empty($driverInfo)) throw new ErrException('配送员信息丢失,请联系管理员');
|
||||||
|
if ($driverInfo->driver_num <= 0) throw new ErrException('配送员编号丢失,请联系管理员');
|
||||||
|
if (empty($driverInfo->driver_name)) throw new ErrException('配送员姓名丢失,请联系管理员');
|
||||||
|
|
||||||
$this->printService = $this->printOrderFactory->handle($this->request->input('type'));
|
$this->printService = $this->printOrderFactory->handle((int)$this->request->input('type'));
|
||||||
// 打印或者喷码
|
// 打印或者喷码
|
||||||
match ($this->request->input('type')) {
|
match ($this->request->input('type')) {
|
||||||
CateringCode::OPTION_PRINT_YLY => $this->printOrderByYly(),
|
CateringCode::OPTION_PRINT_YLY => $this->printOrderByYly(),
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ class YlyPrintService implements PrintOrderInterface
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
empty($this->data['pickup_code']) ||
|
empty($this->data['pickup_code']) ||
|
||||||
empty($this->data['driver_num']) ||
|
// empty($this->data['driver_num']) ||
|
||||||
empty($this->data['site_order']) ||
|
// empty($this->data['site_order']) ||
|
||||||
empty($this->data['site_text']) ||
|
empty($this->data['site_text']) ||
|
||||||
empty($this->data['sku']) ||
|
empty($this->data['sku']) ||
|
||||||
empty($this->data['order_sno']) ||
|
empty($this->data['order_sno']) ||
|
||||||
@@ -278,7 +278,7 @@ class YlyPrintService implements PrintOrderInterface
|
|||||||
$this->content .= "\n";
|
$this->content .= "\n";
|
||||||
|
|
||||||
// 箱数
|
// 箱数
|
||||||
$currentNum = str_pad($this->data['current_num'], 2, '0', STR_PAD_LEFT);
|
$currentNum = str_pad((string)$this->data['current_num'], 2, '0', STR_PAD_LEFT);
|
||||||
$this->content .= "<FS2><CA>箱数:$currentNum</CA></FS2>\n";
|
$this->content .= "<FS2><CA>箱数:$currentNum</CA></FS2>\n";
|
||||||
$this->content .= "\n";
|
$this->content .= "\n";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user