Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e8b2113
create qrWizard page & test page
toluene5019 Mar 2, 2021
46a353a
change pictures when changing steps
toluene5019 Mar 2, 2021
67f0a2d
improve qrWizard page, delete unusable code
toluene5019 Mar 4, 2021
a743c00
wip qrWizard page
toluene5019 Mar 10, 2021
a70e570
wip qrWizard page
toluene5019 Mar 15, 2021
24ec261
wip quantity
toluene5019 Mar 24, 2021
4954195
wip quantity, add translations
ReverieSylve Mar 24, 2021
e24c4d5
added product quantity to productDTO
top802 Mar 26, 2021
090a44f
shows the quantity of goods on the pages of goods, store, category
top802 Mar 26, 2021
97fc50e
save quantity value in edit product
toluene5019 Mar 29, 2021
a89cf20
wip quantity ui
toluene5019 Mar 30, 2021
78b3060
wip quantity view in shop/category pages
toluene5019 Apr 4, 2021
ccf98da
wip quantity: added functionality to quantity
top802 Apr 26, 2021
a073c95
wip quantity: hidden quantity container if it equals 0
top802 Apr 26, 2021
a3905e2
wip quantity: show message
top802 Apr 26, 2021
060d7e7
wip quantity: added visibility for quantity on product page
top802 Apr 27, 2021
eb78b40
wip quantity: fixed visibility
top802 Apr 27, 2021
4dc474c
wip quantity: added quantity visibility on create product page
top802 Apr 27, 2021
5a1be03
wip quantity: reduce product quantity after sell this product
top802 Apr 27, 2021
09274c9
wip qr wizard 0.0.1
top802 May 19, 2021
81284cb
wip qr wizard 0.0.2
top802 May 21, 2021
9975ee7
fix
ReverieSylve May 22, 2021
174208d
wip form registration - display current form
top802 May 24, 2021
bfaa23b
wip form registration - 0.0.2
top802 May 24, 2021
7f88364
wip form registration - 0.0.3
top802 May 25, 2021
48dd6ef
wip form registration - 0.0.4
top802 May 26, 2021
e0673e0
wip form registration - 0.0.5
top802 May 26, 2021
78eb8e0
wip form registration - 0.0.6
top802 May 26, 2021
26903fa
wip form registration - 0.0.7
top802 May 26, 2021
10e11ea
wip form registration - 0.0.8
top802 May 27, 2021
b156daf
wip form registration - 0.0.9
top802 May 27, 2021
3015369
wip form registration - 0.1.0
top802 May 28, 2021
e5c4d9e
wip form registration - 0.1.1
top802 May 28, 2021
e90e0f6
wip form registration - 0.1.2
top802 Jun 2, 2021
6520bc8
wip form registration - 0.1.3
top802 Jun 2, 2021
b763cbb
wip form registration - 0.1.4
top802 Jun 2, 2021
28a3fe1
wip form registration - 0.1.5
top802 Jun 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/controllers/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public static void product(String client, String uuid, String language){
defaultAdditions = DataBaseQueries.checkIsAdditionDefaultToProduct(product);
product.defaultAdditions = defaultAdditions;
}
System.out.println("request.params qr_uuid.isEmpty() in Product => " + qr_uuid);
System.out.println("request.params qr_uuid.isEmpty() in Product => " + product.isQuantityVisible);

Translation.setTranslationForProduct(language, product);
Translation.setTranslationForShop(language, shop);
Expand Down Expand Up @@ -842,4 +842,10 @@ public static void shopLanding(){
public static void qrCode(String client){
renderTemplate("Application/qrCode.html");
}
public static void qrWizard(String client){
renderTemplate("Application/qrWizard.html");
}
public static void testPage(String client){
renderTemplate("Application/testPage.html");
}
}
11 changes: 11 additions & 0 deletions app/controllers/OrderAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ public static void create(String client, String chosenLanguage) throws Exception
OrderItemListResult orderItemListResult = _parseOrderItemsList(shoppingCart.items, order);
order.items = orderItemListResult.orderItemList;

order.items.stream()
.forEach(orderItemDTO -> reduceProductQuantity(orderItemDTO));

DeliveryDTO delivery = shop.delivery;
System.out.println("deliveryType in order creating => " + shoppingCart.deliveryType);
if(shoppingCart.deliveryType != null){
Expand Down Expand Up @@ -298,6 +301,14 @@ public static void create(String client, String chosenLanguage) throws Exception
}
}

private static void reduceProductQuantity(OrderItemDTO orderItemDTO) {
ProductDTO product = ProductDTO.findById(orderItemDTO.productUuid);
if (product.quantity > 0) {
product.quantity = product.quantity - orderItemDTO.quantity;
product.save();
}
}

private static void validationShoppingCart(String jsonCart, ShoppingCartDTO shoppingCart) throws ParseException {
if (jsonCart.isEmpty() || shoppingCart == null) {
return;
Expand Down
15 changes: 9 additions & 6 deletions app/controllers/ProductAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ProductAPI extends AuthController {


public static void create(String client, String name, String description,
Double price, File fake, Integer mainPhotoIndex,
Double price, Integer quantity, Boolean isQuantityVisible, File fake, Integer mainPhotoIndex,
String category,
Integer sortOrder, Boolean isActive, Double oldPrice, Integer wholesaleCount, Double wholesalePrice,
String nameUk, String descriptionUk, String nameEn, String descriptionEn) throws Exception {
Expand All @@ -45,17 +45,18 @@ public static void create(String client, String name, String description,
images.add(productImage);
}

CategoryDTO cat = CategoryDTO.findById(category);
ProductDTO product = new ProductDTO(name, description, price, images, shop, cat, wholesaleCount, wholesalePrice);
CategoryDTO categoryDTO = CategoryDTO.findById(category);
ProductDTO product = new ProductDTO(name, description, price, images, shop, categoryDTO, wholesaleCount, wholesalePrice);
product.mainImage = images.get(mainPhotoIndex);
product.isActive = isActive;
product.sortOrder = sortOrder;
product.oldPrice = oldPrice;
product.wholesaleCount = wholesaleCount;
product.wholesalePrice = wholesalePrice;
product.quantity = quantity == null ? 0 : quantity;
product.isQuantityVisible = isQuantityVisible;
product = product.save();


List<ProductPropertyDTO> properties = ProductPropertyDTO.find("byCategoryUuidAndProductUuidIsNull", product.categoryUuid).fetch();
for(ProductPropertyDTO property : properties) {
ProductPropertyDTO propertyNew = new ProductPropertyDTO();
Expand Down Expand Up @@ -157,8 +158,8 @@ public static void list(String client, int page) throws Exception {
renderJSON(json);
}

public static void update(String client, String uuid, String name, String description, Double price, Upload photo,
Integer sortOrder, Boolean isActive, Double oldPrice, String properties, Integer wholesaleCount, Double wholesalePrice) throws Exception {
public static void update(String client, String uuid, String name, String description, Double price, Integer quantity, Boolean isQuantityVisible,
Upload photo, Integer sortOrder, Boolean isActive, Double oldPrice, String properties, Integer wholesaleCount, Double wholesalePrice) throws Exception {
ShopDTO shop = ShopDTO.find("byDomain", client).first();
if (shop == null) {
shop = ShopDTO.find("byDomain", "localhost").first();
Expand Down Expand Up @@ -211,6 +212,8 @@ public static void update(String client, String uuid, String name, String descri

product.wholesaleCount = wholesaleCount;
product.wholesalePrice = wholesalePrice;
product.quantity = quantity;
product.isQuantityVisible = isQuantityVisible;

product.save();

Expand Down
1 change: 0 additions & 1 deletion app/controllers/UserAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public static void register(String email, String password, String passwordConfir
forbidden(reason);
}


if (user != null && user.isGoogleSignIn) {
UserDTO userWithGivenPhone = UserDTO.find("byPhone", phone).first();
if(userWithGivenPhone != null) {
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/UserDashBoardAPI.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package controllers;

import jobs.AdditionalSettingForShop;
import models.*;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
Expand Down Expand Up @@ -78,6 +79,9 @@ public static void createShop() throws Exception{
shop.googleMapsApiKey = "AIzaSyAuKg9jszEEgoGfUlIqmd4n9czbQsgcYRM";
visualSettings.shop = shop;

AdditionalSettingForShop additionalSettingForShop = new AdditionalSettingForShop();
additionalSettingForShop.setWorkingTime(shop);

_appendDomainToList(user.wizard.shopDomain);
shop.save();
renderJSON(json(shop));
Expand Down
68 changes: 47 additions & 21 deletions app/controllers/WizardAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ public static void upDateWizardDetails() throws Exception{
}

public static void checkDomainNameAvailability() throws Exception{
String domain = request.params.get("shopDomain").toLowerCase();



JSONParser parser = new JSONParser();
JSONObject jsonBody = (JSONObject) parser.parse(params.get("body"));
System.out.println(" checkDomainNameAvailability => " + jsonBody);

String domain = (String) jsonBody.get("domain");
System.out.println("checkDomainNameAvailability => " + domain);
String domainPath;
if (Application.isDevEnv) {
domainPath = ".localhost";
Expand All @@ -82,24 +85,34 @@ public static void checkDomainNameAvailability() throws Exception{
}

if(isDomainNameInvalid(domain)){
JsonResponse jsonResponse = new JsonResponse(420, "назва не повинна містити: !, _");
JsonResponse jsonResponse = new JsonResponse(421, "Назва не повинна містити: !, _");
renderJSON(jsonResponse);
}

String authorizationHeader = request.headers.get("authorization").value();
String userId = getUserIdFromAuthorization(authorizationHeader);
System.out.println("String userId " + userId);
UserDTO user = UserDTO.find("byUuid", userId).first();
String shopName = (String) jsonBody.get("shopName");
System.out.println("shopName => " + shopName);
ShopDTO shop = ShopDTO.find("byDomain", domain).first();
if (shop == null){
String reason = "адреса доступна";
JsonResponse jsonResponse = new JsonResponse(421, reason);
UserDTO user = UserDTO.find("byUuid", userId).first();
String reason = "Адреса доступна";
JsonResponse jsonResponse = new JsonResponse(420, reason);
if (user.wizard == null){
WizardDTO wizardDTO = new WizardDTO();
wizardDTO.user = user;
user.wizard = wizardDTO;
wizardDTO.save();
}
user.wizard.shopDomain = domain;
user.wizard.shopName = shopName;

user.wizard.save();
renderJSON(jsonResponse);
}
String reason = "адреса недоступна";
JsonResponse jsonResponse = new JsonResponse(420, reason);
JsonResponse jsonResponse = new JsonResponse(421, reason);
renderJSON(jsonResponse);

}
Expand All @@ -112,9 +125,20 @@ private static boolean isDomainNameInvalid(String domainName) {
}

public static void setShopContactInfo() throws Exception{
String cityName = request.params.get("cityName");
String streetName = request.params.get("streetName");
String buildingNumber = request.params.get("buildingNumber");
String cityName, streetName, buildingNumber;
cityName = request.params.get("cityName");
streetName = request.params.get("streetName");
buildingNumber = request.params.get("buildingNumber");

JSONParser parser = new JSONParser();
JSONObject jsonBody = (JSONObject) parser.parse(params.get("body"));
System.out.println("setShopContactInfo jsonBody\n" + jsonBody);

if (jsonBody != null){
cityName = (String) jsonBody.get("city");
streetName = (String) jsonBody.get("street");
buildingNumber = (String) jsonBody.get("house");
}

System.out.println("setShopContactInfo\n" + cityName + "\n" + streetName + "\n" + buildingNumber);

Expand All @@ -125,34 +149,36 @@ public static void setShopContactInfo() throws Exception{
UserDTO user = UserDTO.find("byUuid", userId).first();
System.out.println("setShopContactInfo get userDTO\n" + userId);

if(cityName != null){
if(cityName != null && !cityName.isEmpty()){
user.wizard.cityName = cityName;
}
if(streetName != null){
if(streetName != null && !streetName.isEmpty()){
user.wizard.streetName = streetName;
}
if(buildingNumber != null){
if(buildingNumber != null && !buildingNumber.isEmpty()){
user.wizard.buildingNumber =buildingNumber;
}

user.wizard.save();
renderJSON(json(user.wizard));
renderJSON(json(new JsonResponse(103, "save")));
}

public static void setVariantsOfDeliveryAndPaymentTypes() throws Exception{
String authorizationHeader = request.headers.get("authorization").value();
String userId = getUserIdFromAuthorization(authorizationHeader);
UserDTO user = UserDTO.find("byUuid", userId).first();

JSONParser parser = new JSONParser();
JSONObject jsonBody = (JSONObject) parser.parse(params.get("body"));
boolean courierDelivery = (boolean) jsonBody.get("courierDelivery");
boolean postDepartment = (boolean) jsonBody.get("postDepartment");
boolean selfTake = (boolean) jsonBody.get("selfTake");
boolean payCash = true;
boolean payOnline = false;

String authorizationHeader = request.headers.get("authorization").value();
String userId = getUserIdFromAuthorization(authorizationHeader);
UserDTO user = UserDTO.find("byUuid", userId).first();
System.out.println("setVariantsOfDeliveryAndPaymentTypes\n" + user.givenName);
boolean payCash = false, payOnline = false;
if (jsonBody.get("payCash") != null) payCash = (boolean) jsonBody.get("payCash");
if (jsonBody.get("payOnline") != null) payOnline = (boolean) jsonBody.get("payOnline");

System.out.println("setVariantsOfDeliveryAndPaymentTypes\n" + jsonBody + user.givenName);

user.wizard.courierDelivery = courierDelivery;
user.wizard.postDepartment = postDepartment;
Expand Down Expand Up @@ -206,7 +232,7 @@ public static void signUp() throws Exception {
if (user != null) {
System.out.println("user.with.email.already.exist");
String reason = Messages.get("user.with.email.already.exist");
JsonResponse jsonResponse = new JsonResponse(420, reason);
JsonResponse jsonResponse = new JsonResponse(421, reason);
renderJSON(jsonResponse);
}

Expand Down
30 changes: 15 additions & 15 deletions app/jobs/AdditionalSettingForShop.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,38 @@ public AdditionalSettingForShop(){

}

public void setWorkkingTime(ShopDTO shop){
public void setWorkingTime(ShopDTO shop){

if(shop.monStartTime == null) {
shop.monStartTime = "1970-01-01T05:00:00.000Z";
shop.monEndTime = "1970-01-01T15:00:00.000Z";
shop.monStartTime = "04:20";
shop.monEndTime = "16:20";
}

if(shop.tueStartTime == null) {
shop.tueStartTime = "1970-01-01T05:00:00.000Z";
shop.tueEndTime = "1970-01-01T15:00:00.000Z";
shop.tueStartTime = "04:20";
shop.tueEndTime = "16:20";
}

if(shop.wedStartTime == null) {
shop.wedStartTime = "1970-01-01T05:00:00.000Z";
shop.wedEndTime = "1970-01-01T15:00:00.000Z";
shop.wedStartTime = "04:20";
shop.wedEndTime = "16:20";
}

if(shop.thuStartTime == null) {
shop.thuStartTime = "1970-01-01T05:00:00.000Z";
shop.thuEndTime = "1970-01-01T15:00:00.000Z";
shop.thuStartTime = "04:20";
shop.thuEndTime = "16:20";
}
if(shop.friStartTime == null) {
shop.friStartTime = "1970-01-01T05:00:00.000Z";
shop.friEndTime = "1970-01-01T15:00:00.000Z";
shop.friStartTime = "04:20";
shop.friEndTime = "16:20";
}
if(shop.satStartTime == null) {
shop.satStartTime = "1970-01-01T05:00:00.000Z";
shop.satEndTime = "1970-01-01T15:00:00.000Z";
shop.satStartTime = "04:20";
shop.satEndTime = "16:20";
}
if(shop.sunStartTime == null) {
shop.sunStartTime = "1970-01-01T05:00:00.000Z";
shop.sunEndTime = "1970-01-01T15:00:00.000Z";
shop.sunStartTime = "04:20";
shop.sunEndTime = "16:20";
}
}

Expand Down
3 changes: 1 addition & 2 deletions app/jobs/WisehandsSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ public void doJob() throws Exception {
boolean hasPages = listsPage.size() != 0;

AdditionalSettingForShop additionalSettingForShop = new AdditionalSettingForShop();
additionalSettingForShop.setWorkkingTime(shop);
additionalSettingForShop.setWorkingTime(shop);
shop = shop.save();
if (!hasPages){
additionalSettingForShop.setPageListForFooter(shop);
}
}

}

private void createShop(String shopName, String domain) {
Expand Down
30 changes: 28 additions & 2 deletions app/models/ProductDTO.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package models;

import com.google.gson.annotations.Expose;
import json.shoppingcart.LineItem;
import org.hibernate.annotations.GenericGenerator;
import play.db.jpa.GenericModel;
import util.ShoppingCartUtil;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;


@Entity
public class ProductDTO extends GenericModel {
Expand Down Expand Up @@ -59,6 +63,12 @@ public class ProductDTO extends GenericModel {
@Expose
public Double wholesalePrice;

@Expose
public int quantity;

@Expose
public Boolean isQuantityVisible = false;

@Expose
@OneToOne
public ProductImage mainImage;
Expand Down Expand Up @@ -138,12 +148,28 @@ public String formatDecimalOldPrice() {
if (number != null) {
float epsilon = 0.004f; // 4 tenths of a cent
if (Math.abs(Math.round(number) - number) < epsilon) {
return String.format("%10.0f", number) + " " + "uah"; // sdb
return String.format("%10.0f", number) + " " + "&#8372;"; // sdb
} else {
return String.format("%10.2f", number) + " " + "uah"; // dj_segfault
return String.format("%10.2f", number) + " " + "&#8372;"; // dj_segfault
}
}
return "";
}

public int getProductQuantity() {
List<ShoppingCartDTO> cart = ShoppingCartDTO.findAll();
List<LineItem> lineItems = cart.get(cart.size() - 1).items;

LineItem _lineItem = lineItems.stream()
.filter(lineItem -> this.uuid.equals(lineItem.productId))
.findAny()
.orElse(null);
if (_lineItem != null) {
return this.quantity - _lineItem.quantity;
} else {
return this.quantity;
}

}

}
1 change: 1 addition & 0 deletions app/models/UserDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public UserDTO(String givenName, String familyName, String phone, String email,
this.phone = phone;
this.email = email;
this.password = password;
this.token = UUID.randomUUID().toString();
}

}
Loading