diff --git a/app/Commons/TencentMap.php b/app/Commons/TencentMap.php
new file mode 100644
index 0000000..13b78c1
--- /dev/null
+++ b/app/Commons/TencentMap.php
@@ -0,0 +1,76 @@
+clientFactory = $clientFactory;
+ }
+
+ public function getClient()
+ {
+ // $options 等同于 GuzzleHttp\Client 构造函数的 $config 参数
+ $options = [
+ 'timeout' => 2.0,
+ ];
+ // $client 为协程化的 GuzzleHttp\Client 对象
+ $client = $this->clientFactory->create($options);
+
+ return $client;
+ }
+
+ public function event($labels=null,$datas){
+
+ co(function () use ($labels,$datas){
+
+ $client = $this->getClient();
+ $kv = [];
+ foreach ($datas as $key => $value) {
+ $kv[] = $key."=".$value;
+ }
+ $pushLabels = [];
+
+ $event_name = 'event_'.env('APP_ENV');
+ if(!empty($labels)) $pushLabels[$event_name] = $labels;
+
+ /*
+ * data format:
+ curl -v -H "Content-Type: application/json" -XPOST -s "http://39.96.12.39:3100/loki/api/v1/push" --data-raw \
+ '{"streams": [{ "stream": { "foo": "bar2" }, "values": [ [ "1596274538882028800", "fizzbuzz" ] ] }]}'
+ */
+ $ts = $this->getMsecTime() . '000000';
+ $datas = implode("&",$kv);
+ $values = [[$ts,$datas]];
+ $app_name = env('APP_NAME').'_'.env('APP_ENV');
+
+ $pushLabels['app']= $app_name;
+ $pushDatas = [
+ 'streams'=>[
+ [
+ 'stream'=>$pushLabels,
+ 'values'=>$values,
+ ]
+ ]
+ ];
+ $client->post(
+ env('LOG_HOST','http://39.96.12.39:3100').'/loki/api/v1/push',
+ [
+ 'headers'=>[
+ 'Content-Type'=>'application/json'
+ ],
+ 'body' => json_encode($pushDatas)
+ ]
+ );
+ //var_dump(json_encode($pushDatas) );
+ });
+ }
+
+}
diff --git a/app/Constants/v3/ErrorCode.php b/app/Constants/v3/ErrorCode.php
index a7beedb..6af0f88 100644
--- a/app/Constants/v3/ErrorCode.php
+++ b/app/Constants/v3/ErrorCode.php
@@ -156,6 +156,12 @@ class ErrorCode extends AbstractConstants
*/
const STORE_REST = 709;
+ /**
+ * 商户已休息
+ * @Message("服务站已休息")
+ */
+ const MARKET_REST = 710;
+
/************************************/
/* 定位相关 751-800 */
/************************************/
diff --git a/app/Model/v3/OrderGoods.php b/app/Model/v3/OrderGoods.php
index b8290d0..b31f698 100644
--- a/app/Model/v3/OrderGoods.php
+++ b/app/Model/v3/OrderGoods.php
@@ -14,7 +14,8 @@ class OrderGoods extends Model
];
protected $appends = [
- 'tags'
+ 'tags',
+ 'name_unit'
];
protected $fillable = [
@@ -52,4 +53,9 @@ class OrderGoods extends Model
{
return Goods::query()->where(['id' => $this->attributes['goods_id']])->value('tags');
}
+
+ public function getNameUnitAttribute()
+ {
+ return $this->attributes['name'] . ' ' . $this->attributes['goods_unit'];
+ }
}
\ No newline at end of file
diff --git a/app/Service/v3/Implementations/AppointmentTimeService.php b/app/Service/v3/Implementations/AppointmentTimeService.php
index d8a7d17..5c18d2b 100644
--- a/app/Service/v3/Implementations/AppointmentTimeService.php
+++ b/app/Service/v3/Implementations/AppointmentTimeService.php
@@ -43,13 +43,18 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface
$time4Arr = [];
$nowTime = time();
//服务站最晚营业时间
- $closedTime = strtotime('19:30');
+ if (env('APP_ENV') === 'prod') {
+ $closedTime = strtotime('19:30');
+ if($nowTime > $closedTime){
+ throw new ErrorCodeException(ErrorCode::MARKET_REST);
+ }
+ }
//取得所有店铺营业时间交集
foreach($stores as $store){
//获取店铺开始营业时间
$time1 = strtotime(($store['time1']));
//店铺是否在营业时间 店铺手动点击休息 || 小于店铺开始营业时间 || 当前时间大于服务站休业时间
- if($store['is_rest'] == 1 || $nowTime < $time1 || $nowTime > $closedTime){
+ if($store['is_rest'] == 1 || $nowTime < $time1){
throw new ErrorCodeException(ErrorCode::STORE_REST);
}
diff --git a/app/Service/v3/Implementations/FeiePrintService.php b/app/Service/v3/Implementations/FeiePrintService.php
index 1c261fb..91ef906 100644
--- a/app/Service/v3/Implementations/FeiePrintService.php
+++ b/app/Service/v3/Implementations/FeiePrintService.php
@@ -67,7 +67,7 @@ class FeiePrintService implements FeiePrintServiceInterface
$content = $this->printFormat($data, 4, 14, 7, 7);
- //$res = $this->printMsg('920527381', $content, 1);
+ $res = $this->printMsg('920527381', $content, 1);
return $content;
}
@@ -105,15 +105,22 @@ class FeiePrintService implements FeiePrintServiceInterface
$orderInfo = '懒族生活
';
$orderInfo .= '数量 名称 单价 金额
';
$orderInfo .= '--------------------------------
';
+ //$shopnum 当前为第几个店铺
$shopnum = 0;
+ //循环处理子订单
foreach ($arr->orders as $k5 => $order) {
$orderInfo .= '
';
$shopnum++;
$orderInfo .= "(" . $shopnum . ")" .$order->store->name . '
';
+ $subNum = 0;
+ //循环处理子订单下商品
foreach ($order['orderGoods'] as $goods){
+ //店铺商品数量小计
+ $subNum += $goods->number;
$orderInfo .= str_pad($goods->number,$A,' ',STR_PAD_RIGHT);
- $nameLength = mb_strwidth($goods->name);
- $nameArr = mb_str_split($goods->name);
+ //商品名处理
+ $nameLength = mb_strwidth($goods->name_unit);
+ $nameArr = mb_str_split($goods->name_unit);
$length = $A;
foreach ($nameArr as $name){
$len = mb_strwidth($name);
@@ -124,15 +131,23 @@ class FeiePrintService implements FeiePrintServiceInterface
}
$orderInfo .= $name;
}
+ //商品名长度是否超过一行
if($nameLength > ($B+$C+$D)){
$orderInfo .= '
';
$orderInfo .= str_pad($goods->price,$A+$B+$C,' ',STR_PAD_LEFT);
- $orderInfo .= str_pad(bcmul($goods->number,$goods->price,2),$D,' ',STR_PAD_LEFT);
}else{
$orderInfo .= str_pad($goods->price,$C+$B+$A-$length,' ',STR_PAD_LEFT);
- $orderInfo .= str_pad(bcmul($goods->number,$goods->price,2),$D,' ',STR_PAD_LEFT);
}
+ $orderInfo .= str_pad(bcmul($goods->number,$goods->price,2),$D,' ',STR_PAD_LEFT);
}
+ /**
+ * 订单商品处理结束
+ */
+
+ //处理订单备注
+ $orderInfo .= '--------------------------------
';
+ //订单小计
+ $orderInfo .= $this->space($subNum,$order->money);
if(!empty($order->note)){
$orderInfo .='
';
$orderInfo .='
';
@@ -157,9 +172,10 @@ class FeiePrintService implements FeiePrintServiceInterface
}
$userLength = preg_replace('/[^\x{4e00}-\x{9fa5}]/u', '', $userName);
$totalLength = preg_replace('/[^\x{4e00}-\x{9fa5}]/u', '', $total);
- var_dump($userLength,$totalLength);
+ $userLength = mb_strlen($userLength);
+ $totalLength = mb_strlen($totalLength);
$orderInfo .= str_pad($userName,$A+$B+$userLength,' ',STR_PAD_RIGHT);
- $orderInfo .= str_pad($total,$C+$D+$totalLength,' ',STR_PAD_LEFT);
+ $orderInfo .= str_pad($total,$C+$D+$totalLength+1,' ',STR_PAD_LEFT);
$orderInfo .= '
';
$orderInfo .= '送货地点:' . $arr->address . '
';
$tel = substr_replace( $arr->tel, '****', 3, 4);
diff --git a/composer.lock b/composer.lock
index e88de0d..06537cf 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "71c3d5cf05fbd7b480f24350362675e4",
+ "content-hash": "9f238a6a5e556f4061e56600f28bacfd",
"packages": [
{
"name": "adbario/php-dot-notation",
@@ -2145,16 +2145,16 @@
},
{
"name": "hyperf/guzzle",
- "version": "v2.0.2",
+ "version": "v2.0.11",
"source": {
"type": "git",
"url": "https://github.com/hyperf/guzzle.git",
- "reference": "34eca5665aa49a534bacf89d6b84c454ab622ebc"
+ "reference": "d0a5d72e93f4c6fa90c3e25a0eb192e1445cc1e0"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/hyperf/guzzle/zipball/34eca5665aa49a534bacf89d6b84c454ab622ebc",
- "reference": "34eca5665aa49a534bacf89d6b84c454ab622ebc",
+ "url": "https://api.github.com/repos/hyperf/guzzle/zipball/d0a5d72e93f4c6fa90c3e25a0eb192e1445cc1e0",
+ "reference": "d0a5d72e93f4c6fa90c3e25a0eb192e1445cc1e0",
"shasum": "",
"mirrors": [
{
@@ -2200,7 +2200,7 @@
"php",
"swoole"
],
- "time": "2020-07-07T07:50:52+00:00"
+ "time": "2020-09-07T10:26:15+00:00"
},
{
"name": "hyperf/http-message",