小票机打印

main
yangsai 3 months ago
parent 476a99ad8d
commit 7950bada64
  1. 53
      app/controller/admin/v1/statistic/ProductStatistic.php
  2. 24
      app/services/order/StoreOrderServices.php
  3. 11
      app/services/statistic/ProductStatisticServices.php
  4. 8
      crmeb/services/printer/storage/FeiEYun.php
  5. 7
      crmeb/services/printer/storage/YiLianYun.php
  6. 2
      route/admin.php
  7. BIN
      收银台/cashier/node_modules/.cache/eslint-loader/6b0c76aeae368d3e4782113252e9023cc445a1b6.json.gz
  8. BIN
      收银台/cashier/node_modules/.cache/eslint-loader/b020942471700b0b67da160b1024685e5001c4fb.json.gz
  9. 2
      收银台/cashier/node_modules/.cache/vue-loader/714acc3736d3a1a5d7469062569fb609.json
  10. 2
      收银台/cashier/node_modules/.cache/vue-loader/b9a863e967d933d64a86130167576886.json

@ -15,6 +15,10 @@ namespace app\controller\admin\v1\statistic;
use app\controller\admin\AuthController;
use app\services\product\category\StoreProductCategoryServices;
use app\services\statistic\ProductStatisticServices;
use app\services\order\StoreOrderServices;
use app\services\store\SystemStoreServices;
use app\services\product\product\StoreProductServices;
use app\services\order\StoreOrderCartInfoServices;
use think\facade\App;
/**
@ -81,7 +85,56 @@ class ProductStatistic extends AuthController
$where['time'] = $this->getDay($where['time']);
return $this->success($this->services->getProductRanking($where));
}
public function getProductcount(StoreProductCategoryServices $storeProductCategoryServices)
{
$where = $this->request->getMore([
['cate_id', ''],
['data', '', '', 'time'],
['sort', '']
]);
//查询所有已支付的订单
/** @var StoreOrderServices $StoreOrderServices */
$StoreOrderServices = app()->make(StoreOrderServices::class);
//商品服务层
/** @var StoreProductServices $StoreProductServices */
$StoreProductServices = app()->make(StoreProductServices::class);
//门店服务层
/** @var SystemStoreServices $SystemStoreServices */
$SystemStoreServices = app()->make(SystemStoreServices::class);
$payOrder = $StoreOrderServices->getOrderList(['paid'=>1]);
$products = [];
foreach($payOrder['data'] as $key => $val){
$val['pink_name'] = !empty($val['other_order'])?'[会员礼包]':$val['pink_name'];
//获取门店名称
$val['storename'] = empty($val['store_id'])?'平台':$SystemStoreServices->getFieldValue($val['store_id'],'id', 'name');
foreach($val['_info'] as $k => $v){
$v['cart_info']['productInfo']['pnum'] = empty($v['cart_info']['productInfo']['pnum'])?$v['cart_info']['cart_num']:$v['cart_info']['productInfo']['pnum'];
$v['cart_info']['productInfo']['pink_name'] = $val['pink_name'];
$v['cart_info']['productInfo']['order_no'] = $val['order_id'];
$v['cart_info']['productInfo']['sum_true_price'] = empty($v['cart_info']['sum_true_price'])?'0.00':$v['cart_info']['sum_true_price'];
$v['cart_info']['productInfo']['sum_price'] = $v['cart_info']['productInfo']['pnum']*$v['cart_info']['productInfo']['attrInfo']['price'];
$v['cart_info']['productInfo']['youhui'] = $v['cart_info']['productInfo']['sum_price']-$v['cart_info']['productInfo']['sum_true_price'];
$v['cart_info']['productInfo']['cost'] = $v['cart_info']['productInfo']['pnum']*$v['cart_info']['productInfo']['attrInfo']['cost'];
$v['cart_info']['productInfo']['code'] = $v['cart_info']['productInfo']['attrInfo']['code'];
$v['cart_info']['productInfo']['cate_name'] = $storeProductCategoryServices->getColumn(['id' => $v['cart_info']['productInfo']['cate_id']], 'cate_name')[0];
$v['cart_info']['productInfo']['storename'] = $val['storename'];
// print_r($v['cart_info']['sum_true_price']);die;
//获取商品单位
if(empty($v['cart_info']['productInfo']['unit_name'])) $v['cart_info']['productInfo']['unit_name'] = $StoreProductServices->getColumn(['id'=>$v['cart_info']['productInfo']['product_id']], 'unit_name')[0];
$products[] = $v['cart_info']['productInfo'];
}
}
$cateId = $where['cate_id'];
if ($cateId) {
$cateId = is_string($cateId) ? [$cateId] : $cateId;
$cateId = array_merge($cateId, $storeProductCategoryServices->getColumn(['pid' => $cateId], 'id'));
$cateId = array_unique(array_diff($cateId, [0]));
}
$where['cate_id'] = $cateId;
$where['time'] = $this->getDay($where['time']);
return $this->success($products);
}
/**
* 导出
* @return mixed

@ -47,6 +47,7 @@ use crmeb\traits\ServicesTrait;
use crmeb\utils\Arr;
use think\exception\ValidateException;
use think\facade\Log;
use app\services\activity\collage\UserCollageCodeServices;
/**
* Class StoreOrderServices
@ -176,7 +177,9 @@ class StoreOrderServices extends BaseServices
//查询otherorder订单是否存在订单号
$oodao = new OtherOrderDao;
$other_order = $oodao->getOne(['libao_id' => $item['order_id']]);
$item['other_order']=[];
if ($other_order) {
$item['other_order']=$other_order->toArray();
$item['order_id'] = $other_order['order_id'];
}
foreach ($item['_info'] as &$items) {
@ -1680,6 +1683,14 @@ HTML;
$relation_id = $supplier_id;
}
}
$table = [];
if($order['type']==10){
/** @var UserCollageCodeServices $UserCollageCodeServices */
$UserCollageCodeServices = app()->make(UserCollageCodeServices::class);
//查询订单所在的桌码
$qrcode_id = $UserCollageCodeServices->getFieldValue($order['id'],'oid', 'id');
$table = $UserCollageCodeServices->get($qrcode_id);
}
/** @var ConfigServices $configServices */
$configServices = app()->make(ConfigServices::class);
if ($type == 1) {//门店 可以配置多个打印机
@ -1695,19 +1706,26 @@ HTML;
throw new ValidateException('请先配置小票打印开发者');
}
}
foreach ($product as $pkey => $item) {
$newproduct = $product;
foreach ($newproduct as $pkey => $item) {
$printset = !empty($item['printset'])?explode(',', $item['printset']):'';
if($printset && !in_array($print['id'], $printset)) unset($product[$pkey]);
if($printset && !in_array($print['id'], $printset)) unset($newproduct[$pkey]);
}
$configData['print_num'] = $print['print_num'];
$printer = new Printer($name, $configData);
if(!empty($newproduct)){
$printer->setPrinterContent([
'name' => sys_config('site_name'),
'orderInfo' => is_object($order) ? $order->toArray() : $order,
'product' => $product
'tableInfo' => is_object($table) ? $table->toArray() : $table,
'product' => $newproduct
])->startPrinter();
}
}
}
} else {
[$switch, $name, $configData] = $configServices->getPrintingConfig($type, $relation_id);

@ -248,4 +248,15 @@ class ProductStatisticServices extends BaseServices
$productLog = app()->make(StoreProductLogServices::class);
return $productLog->getRanking($where);
}
/**
* 商品排行
* @param $where
* @return mixed
*/
public function getProductcount($where)
{
/** @var StoreProductLogServices $productLog */
$productLog = app()->make(StoreProductLogServices::class);
return $productLog->getRanking($where);
}
}

@ -57,8 +57,16 @@ class FeiEYun extends BasePrinter
$product = $config['product'];
$orderInfo = $config['orderInfo'];
$orderTime = date('Y-m-d H:i:s', $orderInfo['pay_time']);
$tableInfo = $config['tableInfo'];
$name = $config['name'];
/** @var TableQrcodeServices $qrcodeService */
$qrcodeService = app()->make(TableQrcodeServices::class);
$Info = $qrcodeService->getQrcodeyInfo((int)$tableInfo['qrcode_id'], ['category']);
$this->printerContent = '<CB>**' . $config['name'] . '**</CB><BR>';
$this->printerContent .= '--------------------------------<BR>';
$this->printerContent .= '桌码流水:' . $tableInfo['serial_number']??'' . '<BR>';
$this->printerContent .= '桌码分类: ' . $Info['category']['name']??'' . '<BR>';
$this->printerContent .= '桌码编号: ' . $Info['table_number']??'' . '<BR>';
$this->printerContent .= '订单编号:' . $orderInfo['order_id'] . '<BR>';
$this->printerContent .= '打印时间: ' . $printTime . '<BR>';
$this->printerContent .= '付款时间: ' . $orderTime . '<BR>';

@ -99,13 +99,20 @@ class YiLianYun extends BasePrinter
}
$goodsStr .= '</table>';
$orderInfo = $config['orderInfo'];
$tableInfo = $config['tableInfo'];
$name = $config['name'];
/** @var TableQrcodeServices $qrcodeService */
$qrcodeService = app()->make(TableQrcodeServices::class);
$Info = $qrcodeService->getQrcodeyInfo((int)$tableInfo['qrcode_id'], ['category']);
$discountPrice = (float)bcsub((string)bcadd((string)$orderInfo['total_price'], $orderInfo['pay_postage'], 2), (string)bcadd((string)$orderInfo['deduction_price'], $orderInfo['pay_price'], 2), 2);
$this->printerContent = <<<CONTENT
<MN>{$this->accessToken->times}</MN>
<FB><center> ** {$name} **</center></FB>
<FH2><FW2>----------------</FW2></FH2>
订单编号:{$orderInfo['order_id']}\r
桌码流水:{$tableInfo['serial_number']}\r
桌码分类: {$Info['category']['name']} \r
桌码编号: {$Info['table_number']} \r
日 期: {$timeYmd} \r
时 间: {$timeHis}\r
姓 名: {$orderInfo['real_name']}\r

@ -2015,6 +2015,8 @@ Route::group('adminapi', function () {
Route::get('product/get_trend', 'v1.statistic.ProductStatistic/getTrend')->option(['real_name' => '商品趋势']);
//商品排行
Route::get('product/get_product_ranking', 'v1.statistic.ProductStatistic/getProductRanking')->option(['real_name' => '商品排行']);
//商品排行
Route::get('product/get_product_count', 'v1.statistic.ProductStatistic/getProductcount')->option(['real_name' => '商品统计报表']);
//商品数据导出
Route::get('product/get_excel', 'v1.statistic.ProductStatistic/getExcel')->option(['real_name' => '商品数据导出']);
/** 交易统计 */

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save