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.

56 lines
1.9 KiB

6 years ago
6 years ago
6 years ago
6 years ago
  1. <?php
  2. namespace App\Service;
  3. use Hyperf\Di\Annotation\Inject;
  4. use Hyperf\DbConnection\Db;
  5. use App\Model\Goods;
  6. use App\Model\Combination;
  7. use App\Model\ShopCar;
  8. use App\Constants\LogLabel;
  9. use App\Commons\Log;
  10. use Hyperf\Utils\ApplicationContext;
  11. use App\TaskWorker\SSDBTask;
  12. use App\Constants\SsdbKeysPrefix;
  13. class PurchaseLimitService implements PurchaseLimitServiceInterface
  14. {
  15. public function getStoreIdByMarketId($params)
  16. {
  17. $res = [
  18. 'id' => 7,
  19. 'item' => 1,
  20. 'item_text' => 'page',
  21. 'logo' => 'http://lanzutest.lanzulive.com/attachment/images/2/2020/08/PY55Y3Mz17yJo17rv1Z7vImX1V5159.jpg',
  22. 'redirect_url' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid=123',
  23. 'src' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid=123',
  24. 'src2' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid=123',
  25. ];
  26. return $res;
  27. }
  28. public function ssdbPurchaseRecord($data,$user_id,$global_order_id)
  29. {
  30. foreach ($data as $k => $v){
  31. if($v['money'] == 0.01){
  32. //添加特价商品购买记录到ssdb
  33. $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
  34. $ssdb->exec('set', SsdbKeysPrefix::PURCHASE_RECORD. date('Ymd') .'_'.$user_id.'_'.$v['good_id'], $global_order_id);
  35. $end_timestamp = strtotime(date('Y-m-d').'23:59:59');
  36. $end_time = $end_timestamp - time();
  37. $ssdb->exec('expire', SsdbKeysPrefix::PURCHASE_RECORD. date('Ymd') .'_'.$user_id.'_'.$v['good_id'],$end_time);
  38. }
  39. }
  40. return true;
  41. }
  42. public function test($params)
  43. {
  44. $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
  45. //添加领取记录到ssdb
  46. $data = [
  47. '620',1561,
  48. ];
  49. $test = $ssdb->exec('multi_hset', SsdbKeysPrefix::PURCHASE_RECORD. date('Ymd') .'_620', $data);
  50. return $test;
  51. }
  52. }