You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

57 lines
1.9 KiB

<?php
namespace App\Service;
use Hyperf\Di\Annotation\Inject;
use Hyperf\DbConnection\Db;
use App\Model\Goods;
use App\Model\Combination;
use App\Model\ShopCar;
use App\Constants\LogLabel;
use App\Commons\Log;
use Hyperf\Utils\ApplicationContext;
use App\TaskWorker\SSDBTask;
use App\Constants\SsdbKeysPrefix;
class PurchaseLimitService implements PurchaseLimitServiceInterface
{
public function getStoreIdByMarketId($params)
{
$res = [
'id' => 7,
'item' => 1,
'item_text' => 'page',
'logo' => 'http://lanzutest.lanzulive.com/attachment/images/2/2020/08/PY55Y3Mz17yJo17rv1Z7vImX1V5159.jpg',
'redirect_url' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid=123',
'src' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid=123',
'src2' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid=123',
];
return $res;
}
public function ssdbPurchaseRecord($data,$user_id,$global_order_id)
{
foreach ($data as $k => $v){
if($v['money'] == 0.01){
//添加特价商品购买记录到ssdb
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
$ssdb->exec('set', SsdbKeysPrefix::PURCHASE_RECORD. date('Ymd') .'_'.$user_id.'_'.$v['good_id'], $global_order_id);
$end_timestamp = strtotime(date('Y-m-d').'23:59:59');
$end_time = $end_timestamp - time();
$ssdb->exec('expire', SsdbKeysPrefix::PURCHASE_RECORD. date('Ymd') .'_'.$user_id.'_'.$v['good_id'],$end_time);
}
}
return true;
}
public function test($params)
{
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
//添加领取记录到ssdb
$data = [
'620',1561,
];
$test = $ssdb->exec('multi_hset', SsdbKeysPrefix::PURCHASE_RECORD. date('Ymd') .'_620', $data);
return $test;
}
}