Building A Drupal 8 Website With A Lottery Purchase System

Team AdWeb has worked for a distinctive list of industries counting from hospitability to technology and retailers to an online lottery purchase system based website. Yes, we recently collaborated with a Japan-based company to build their website with lottery purchase system, using Drupal 8. We’ve been Drupal-ing even before our inception and have been an active member of the Drupal community, globally. Our association and experience of Drupal were the base of the client’s immense faith in us and we knew that we’re going to stand true to that.

About the Project
The project requirement of the client was to build a website for them in Drupal 8. The website is basically an online lottery purchase system. Due to confidential reasons, we can not share the name of the company/client but would like to share that the experience of working on this project was new and enriching.

Major Features/Functionalities
We personally love experimenting and implementing innovative features to enhance the client’s website. Plus, we get a little more excited when its a Drupal 8 website. We integrated a host of futuristic features to this very website too. But since, it’s an online lottery purchase system we knew that the integration of the Payment Gateway is going to be one of an integral part. Hence, we created three types of Payment Gateway, as follows:\

  • GMO Payment

  • Coins Payment

  • WebMoney Payment

The user is an integral part of this entire online lottery system and hence several functionalities are crafted around them. Like, a user can purchase coins by WebMoney Payment method and can also buy lottery from choosing any product bundle. A user also has an option to select the quantity of the product or go for the complete set. The payment for either of it can be done by the coins, GMO credit card or points.

Draw system is used for the selection of the lottery winner. Other than the lottery prize, the user also stands a chance to win the Kiriban Product as a prize. The Kiriban Product is based on the product bundle configuration, which is an additional product that a user gets as defined by an admin user.

The Problem
Any e-commerce website will definitely have multiple users buying for the same product. In this situation, the backend technicalities should be as such that it updates the quantity left of the product after the last purchase is made. Issues occur when two or more users place the order at the same time. This is an issue that is involved in concurrent shopping. In this case, the lottery opened for some specific time. Hence, the issue occurred in showcasing the updated quantity. This problem came to our notice when the site went live and around 7-8 users made the transaction at one specific time. We immediately started working on the issue.

Challenges Faced:
We quickly picked up the problem and started searching for the resolution. We have had several times, prior to this, created an e-commerce website. Hence, we used multiple methods to resolve the issues, mentioned below, but none of them worked in this particular case.

  • Initially, we tried using a Drupal lock to resolve the issue, but in vain.

  • We, later on, used the MySQL lock but this too didn’t work, due to the involvement of multiple quantities inside for loop.

  • The usage of sleep time with random sleep time also did not work, because it created the nearby value and not the exact one.

 

Though the method of random sleep time did not work in this case, it gave birth to the final resolution that worked. And hence, we did a minor modification to the same and divided the sleep time in a range of 3. Also, to avoid the possibility of any further clash, we adopted a table of 100.

The Final Resolution:
After trying out a handful of methods, we finally came up with a method that did work out in our favor. Let us share what steps did finally help us in addressing the problem of concurrent shopping that we faced:

  • A table consisting of 1 to 100 numbers was taken, with the sleep time by a range of 3.

  • Later, a random number was picked and a flag value for the same was set

  • Then, a greater number from those numbers with the range of 3 was picked

 

Below is the table that was created to bring out the final solution:

Lottery Purchase System
  • ‘Flag’ was used to 0 by default, which will be automatically set to 1 every time the number is in use

How it works:At the beginning of the transaction, the max sleep_time will be checked where flag=1

  • The sleep_time for the first user will be 0

  • After this, a random number from max sleep_time is selected with a range of 3

  • The first user’s range is 1-3

  • In the case of the second user, one number will be skipped after the max time and will be started after that number

  • In case a user gets the max sleep_time in 3 then the range for the random number will be 5-7

  • If the second user gets the random number as 6 then the random number range for the third user will be 8-10

  • The flag value will be updated as 1 for this random number

  • In the end, the flag value of the transaction will be updated with 0

The Final Say:
“All is well, that ends well.” And that’s exactly we have to say for this particular project. Yes, though we had coded and created many e-commerce websites before, this was the first time that we picked up a project to create a Drupal 8 website with an online lottery system. And believe us, it was a monumental success for us and satisfying project for the client.

Original Source: AddWeb Solutions

Advertisements

Drupal Europe, 2018 – A Community That Codes Together, Organize The Event Together, Grows Together!

A Drupal event is one such destination that I long to visit, each year. Plus, this one happening in Germany was a special one. Yes, you got it right, I’m talking about the Drupal Europe that took place last month at the Darmstadt, Germany. And to answer what apparently made this one a special Drupal event for me is that it was a community-driven event, the scale of which matches with that of a DrupalCon. Such enthusiasm and such efforts! Applauds and appreciation to the entire Drupal community of Europe and worldwide for having shown such a withstanding support for Drupal and making #DrupalEU such a massively successful event.

We Volunteer! 
Yes, did volunteer and contribute in order to do our share in supporting this massive and enthusiastic community-driven event called the Drupal Europe 2018. Isn’t that what is expected out of a hardcore Drupaler like us, who’s been a working aggressively for the community ever since 2012. We’re involved with the website part of the event and came up with a few bug fixes too. We intended to contribute on a way larger scale, but alas the time constraint and the work commitment. While not trying to redeem ourselves, but isn’t working on a Drupal project for a client is too a form of contribution done for the community?! Did just heard a yes from you!

Continue reading “Drupal Europe, 2018 – A Community That Codes Together, Organize The Event Together, Grows Together!”

‘Promote Drupal Initiative’ – Drupal 8 Will Go Places!

Drupal, the most favoured open source platform, took a huge leap with the launch of its latest version – Drupal 8. Today, it is not a mere open source platform; rather an enterprise level web content management that is pledged to provide an ambitious digital experience. Despite being the best on the technical front, Drupal 8 is facing issues in terms of visibility on a larger level. Today, the digital world is not just reigned by the technical people. A whole lot of non-technical and new decision makers has arrived, which affects and influences the market. This is where Drupal 8 was lagging behind and was missed from the eyes of these key influencers. And hence, arose the need of promoting it globally. Hence, ‘Promote Drupal Initiative’ came into the picture. Continue reading “‘Promote Drupal Initiative’ – Drupal 8 Will Go Places!”

Essential Reasons, Why You Should Upgrade To Drupal 8 – Now!

‘Think of the technologically best content-management framework, think of Drupal!’

The statement stands true and its adaptation by the big-shots of every industry possible acts as a strong confirmation for it. Drupal has anyway been the most favoured platform by experts of the community. And the release of Drupal 8 has just been accelerated this demand. The rich and robust open-source community of Drupal has always been a reason to choose Drupal over any other framework. But now with the length of futuristic and competent upgradations that Drupal 8 has come with, the popularity has taken an unbelievable rise and extended reach. In fact, now, even the non-technical decision makers around the world have been citing the strength of Drupal 8. Continue reading “Essential Reasons, Why You Should Upgrade To Drupal 8 – Now!”

Let’s Decode The ‘Decoupled Drupal’ Together!

‘Coexistence is the key to our survival’, they say about humanity. The same law applies to and therefore is adapted by the technological world too. ‘Decoupled Drupal’ is the outcome of the same law, coming from the field of web architecture. After years of following the traditional web architecture, Drupal came up with something that was not ‘monolithic’ – something that we call as ‘Decoupled Drupal’ today. Let us explore and decode in detail the web architecture that ‘Decoupled Drupal’ is! Continue reading “Let’s Decode The ‘Decoupled Drupal’ Together!”

ReactJS And Drupal – The Competent Combo!

What is ReactJS?

Created to enhance speed, simplicity, and scalability, ReactJS has been doing wonders ever since its initial release in 2013. It was basically created by Jordan Walke, a software engineer at Facebook. And its first deployment on Facebook’s newsfeed turned out to be so successful that it was later on adopted by Instagram too. Amongst all the open-source platforms used today for front-end web-application development, ReactJS is the library which is reaching heights these days. And there are multiple reasons for such a booming popularity in such a short period of time. Each adding to the enhancement of current front-end UI scenario. No wonder it looks like, ReactJS is here to stay!

Continue reading “ReactJS And Drupal – The Competent Combo!”

Drupal 8, Driesnote And A Lot More From Our Recent Visit To DrupalCon, Nashville 2018

“When the bond is strong, relationships lasts long!” said no one in specific because some facts are too true to be cited in words. But why are we talking about this in here and not Drupal? Well, because it is about Drupal; to be precise, our relationship with Drupal!

We realised this quite recently while on the way to our 10th Drupal event, ever since our inception in the year 2012. In these 5 years, we’ve attended 9 Drupal events, sponsored 5 of them and volunteered in 8 of them. Then how could we miss this one in Nashville?! And here we’re, back from the DrupalCon, Nashville 2018, with a bagful of memories and experiences to share. So, if you weren’t there, read on to discover all that was there! Continue reading “Drupal 8, Driesnote And A Lot More From Our Recent Visit To DrupalCon, Nashville 2018”