Skip to content

Commit

Permalink
feat(shop): 阻止购买自动重置套餐的用户购买新的套餐
Browse files Browse the repository at this point in the history
  • Loading branch information
laurieryayoi committed Mar 8, 2020
1 parent a3119e3 commit 1e2b1d7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,22 @@ public function buy($request, $response, $args)

$shop = Shop::where('id', $shop)->where('status', 1)->first();

$orders = Bought::where('userid', $this->user->id)->get();
foreach ($orders as $order)
{
$shop_item = Shop::where('id',$order['shopid'])->first();
$shop_item = json_decode($shop_item['content']);
$shop_item->datetime = $order['datetime'];
if (array_key_exists('reset',$shop_item) || array_key_exists('reset_value',$shop_item) || array_key_exists('reset_exp',$shop_item))
{
if (time() < ($shop_item->datetime + $shop_item->reset_exp * 86400) ) {
$res['ret'] = 0;
$res['msg'] = '您购买的含有自动重置系统的套餐还未过期,无法购买新套餐';
return $response->getBody()->write(json_encode($res));
}
}
};

if ($shop == null) {
$res['ret'] = 0;
$res['msg'] = '非法请求';
Expand Down

0 comments on commit 1e2b1d7

Please sign in to comment.