Browse Source

记录当天订单数

master
Lemon 5 years ago
parent
commit
00afcdcfe2
  1. 5
      app/Constants/v3/SsdbKeys.php
  2. 10
      app/Controller/v3/NotifyController.php
  3. 10
      app/Service/v3/Implementations/FeiePrintService.php
  4. 18
      app/Service/v3/Implementations/OrderStatisticsService.php
  5. 2
      app/Service/v3/Interfaces/OrderStatisticsServiceInterface.php

5
app/Constants/v3/SsdbKeys.php

@ -85,4 +85,9 @@ class SsdbKeys extends AbstractConstants
*/
const HORSEMAN_COORDINATE = 'horseman_coordinate_';
/**
* @Message("市场当日线上订单数量统计")
*/
const TODAY_SALES_FOR_MARKET = 'today_sales_for_market_';
}

10
app/Controller/v3/NotifyController.php

@ -23,6 +23,7 @@ use App\Service\v3\Interfaces\MiniprogramServiceInterface;
use App\Service\v3\Interfaces\MqttServiceInterface;
use App\Service\v3\Interfaces\OrderOfflineServiceInterface;
use App\Service\v3\Interfaces\OrderOnlineServiceInterface;
use App\Service\v3\Interfaces\OrderStatisticsServiceInterface;
use App\Service\v3\Interfaces\SeparateAccountsServiceInterface;
use EasyWeChat\Factory;
use Hyperf\DbConnection\Db;
@ -107,6 +108,12 @@ class NotifyController extends BaseController
*/
protected $goodsActivityService;
/**
* @Inject
* @var OrderStatisticsServiceInterface
*/
protected $orderStatisticsService;
public function wxminiOnline()
{
@ -163,6 +170,9 @@ class NotifyController extends BaseController
Db::commit();
//记录当前市场的当天外卖订单数
$this->orderStatisticsService->setForMarket($orderMain->market_id);
// 优惠券返券
$this->couponRebateService->couponRebateInTask($orderMain->global_order_id);

10
app/Service/v3/Implementations/FeiePrintService.php

@ -9,6 +9,7 @@ use App\Model\v3\Feprint;
use App\Model\v3\OrderMain;
use App\Service\v3\Interfaces\FeiePrintServiceInterface;
use App\Service\v3\Interfaces\HelperServiceInterface;
use App\Service\v3\Interfaces\OrderStatisticsServiceInterface;
use Hyperf\DbConnection\Db;
use Hyperf\Di\Annotation\Inject;
@ -27,6 +28,12 @@ class FeiePrintService implements FeiePrintServiceInterface
*/
protected $helperService;
/**
* @Inject
* @var OrderStatisticsServiceInterface
*/
protected $orderStatistics;
// *必填*:飞鹅云后台注册账号
const USER = '13161443713@163.com';
// *必填*: 飞鹅云后台注册账号后生成的UKEY 【备注:这不是填打印机的KEY】
@ -218,6 +225,9 @@ class FeiePrintService implements FeiePrintServiceInterface
}else{
$orderInfo .= '自提时间:' . $arr->delivery_time_note . '<BR>';
}
$orderStatistics = $this->orderStatistics->getForMarket($arr->market_id);
$str = sprintf ("%05d", $orderStatistics); // 生成5位数,不足前面补0
$orderInfo .= $arr->global_order_id.$str;
//$orderInfo .= '<QR>http://www.feieyun.com</QR>';//把解析后的二维码生成的字符串用标签套上即可自动生成二维码
return $orderInfo;
}

18
app/Service/v3/Implementations/OrderStatisticsService.php

@ -4,10 +4,12 @@
namespace App\Service\v3\Implementations;
use App\Constants\v3\OrderState;
use App\Constants\v3\OrderType;
use App\Constants\v3\SsdbKeys;
use App\Model\v3\Order;
use App\Model\v3\OrderGoods;
use App\Model\v3\OrderMain;
use \App\Service\v3\Interfaces\OrderStatisticsServiceInterface;
use App\TaskWorker\SSDBTask;
use Hyperf\Utils\ApplicationContext;
class OrderStatisticsService implements OrderStatisticsServiceInterface
@ -73,4 +75,20 @@ class OrderStatisticsService implements OrderStatisticsServiceInterface
// ->count();
// return $count;
}
public function setForMarket($marketId)
{
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
$incr = $ssdb->exec('incr', SsdbKeys::TODAY_SALES_FOR_MARKET.$marketId);
$expire = strtotime('23:59:59') - time();
$expire = $ssdb->exec('expire', SsdbKeys::TODAY_SALES_FOR_MARKET.$marketId,$expire);
return $incr && $expire;
}
public function getForMarket($marketId)
{
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
$count = $ssdb->exec('get', SsdbKeys::TODAY_SALES_FOR_MARKET.$marketId);
return $count;
}
}

2
app/Service/v3/Interfaces/OrderStatisticsServiceInterface.php

@ -10,4 +10,6 @@ interface OrderStatisticsServiceInterface
public function check();
public function undo();
public function countOrder($storeId,$type,$startTime = '',$endTime = '');
public function getForMarket($marketId);
public function setForMarket($marketId);
}
Loading…
Cancel
Save