基于javaweb的SpringBoot在线蛋糕销售商城(java+springboot+maven+mysql+thymeleaf+html)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

310023072402

320023072402

330023072402

340023072402

350023072402

基于javaweb的SpringBoot在线蛋糕销售商城(java+springboot+maven+mysql+thymeleaf+html)

一、项目简述

功能: 主页显示商品; 所有蛋糕商品展示,可进行商品搜索; 点击商品进入商品详情页,具有立即购买功能,可增减购买商品数量亦可手动输入,热销商品展示。 立即购买进入确认订单页面,可选择已经添加的地址,亦可新增地址。 可选择购买哪些商品,可删除不需要的商品。 点击结算进入确认订单页面,确认后提交订单。后台管理:(修改密码等),商品管理(商品批量添加、上下架等),订单管理。

二、项目运行

环境配置:

Jdk1.8 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:

JSP +Springboot+ SpringMVC + MyBatis + ThymeLeaf + FTP+ JavaScript + JQuery + Ajax + maven等等  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
            CustomerEntity customerEntity = customerService.selectById(articleEntity.getCustomerId());
if(customerEntity!=null){
articleEntity.setCustomerName(customerEntity.getName());
}
ChildTypeEntity childTypeEntity = childTypeService.selectById(articleEntity.getChildType());
if(childTypeEntity!=null){
articleEntity.setChildName(childTypeEntity.getName());
}
}
}
PageVo<ArticleEntity> pageVo = new PageVo<>();
pageVo.setCode(0);
pageVo.setCount(paged.getTotal());
pageVo.setData(list);
pageVo.setPageNum(limit);
pageVo.setPageSize(page);
return pageVo;

}

/**
* 界面
* @return
* @throws Exception
*/
@GetMapping("add.htm")
public String add(Model model)throws Exception{
List<ShopEntity> shopEntities = shopService.selectList(new EntityWrapper<>());
model.addAttribute("shopEntities",shopEntities);
return "article/add";
}


/**
* 保存数据
* @return
* @throws Exception
*/
@RequestMapping("addData.htm")
@ResponseBody
public Result addDatax(ArticleEntity articleEntity, HttpSession session)throws Exception{
articleEntity.setId(IdWorkerUtil.getId());
articleEntity.setTime(new Date());
articleEntity.setStatus(1);
articleEntity.setCustomerId("-1");
articleService.insert(articleEntity);
return Result.success("保存成功");
}


/**
* 根据文章ID推荐商品
* @param id
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
@GetMapping("list.htm")
public String list(Model model)throws Exception{
List<RoleEntity> list = roleService.selectList(new EntityWrapper<>());
model.addAttribute("list",list);
return "role/list";
}

/**
* 保存
* @param id
* @param name
* @return
* @throws Exception
*/
@PostMapping("save.htm")
@ResponseBody
@ImLog(type = "角色",mark = "保存角色 {id} {name} {status}")
public Result save(String id,String name,Boolean status)throws Exception{
RoleEntity roleEntity = new RoleEntity();
roleEntity.setName(name);
roleEntity.setStatus(status);
if(StringUtils.isEmpty(id)){
roleEntity.setId(IdWorker.get32UUID());
roleEntity.setTime(new Date());
roleService.insert(roleEntity);
}else{
roleEntity.setId(id);
roleService.updateById(roleEntity);
}
return Result.success("保存成功");
}


/**
* 删除
* @param id
* @return
* @throws Exception
*/
@PostMapping("del.htm")
@ResponseBody
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
        }
//验证库存是否足够
for (int i = 0; i < ids.length; i++) {
ShoppingGatEntity shoppingGatEntity = shoppingGatService.selectById(ids[i]);
ShopEntity shopEntity = shopService.selectById(shoppingGatEntity.getShopId());
if (shopEntity.getStock() == null || shopEntity.getStock() < shoppingGatEntity.getNum()) {
return Result.error(shopEntity.getName() + "库存不足");
}
}

orderEntity.setAddress(customerAddressEntity.getAddress());
orderEntity.setName(customerAddressEntity.getName());
orderEntity.setPhone(customerAddressEntity.getPhone());
orderService.insert(orderEntity);
String name = StrUtil.EMPTY;
for (int i = 0; i < ids.length; i++) {
ShoppingGatEntity shoppingGatEntity = shoppingGatService.selectById(ids[i]);
ShopEntity shopEntity = shopService.selectById(shoppingGatEntity.getShopId());
OrderShopEntity orderShopEntity = new OrderShopEntity();
orderShopEntity.setId(IdWorkerUtil.getId());
orderShopEntity.setPrice(new BigDecimal(prices[i]));
orderShopEntity.setNum(nums[i]);
orderShopEntity.setOrderId(orderEntity.getId());
orderShopEntity.setName(shopEntity.getName());
name = name.concat(shopEntity.getName() + "+");
orderShopEntity.setCover(shopEntity.getCover());
orderShopEntity.setShopId(shopEntity.getId());
orderShopEntity.setCustomerId(userEntity.getId());
orderShopService.insert(orderShopEntity);
shopEntity.setStock(shopEntity.getStock() - nums[i]);
shopService.updateById(shopEntity);
if (!StringUtils.isEmpty(shoppingGatEntity.getCid())) {
RoyaltyEntity royaltyEntity = new RoyaltyEntity();
royaltyEntity.setId(IdWorkerUtil.getId());
royaltyEntity.setCustomer(shoppingGatEntity.getCid());
royaltyEntity.setMark("订单下单抽取提成");
royaltyEntity.setTime(new Date());
royaltyEntity.setMoney(shopEntity.getRoyalty().multiply(new BigDecimal(shoppingGatEntity.getNum())));
royaltyService.insert(royaltyEntity);
}
}
jedis.set("WSY-SHOPID", name);
return Result.success("订单结算成功");
}

}
package com.wsy.controller.common;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
private ShopService service;

@Autowired
private ShopTypeService shopTypeService;


/**
* 界面
* @param model
* @return
*/
@RequestMapping("list.htm")
public String list(Model model){
List<ShopEntity> list = service.selectList(new EntityWrapper<>());
model.addAttribute("list",list);
return "shop/list";
}


/**
* 保存界面
* @param model
* @param id
* @return
* @throws Exception
*/
@RequestMapping("save.htm")
public String save(Model model,String id)throws Exception{
ShopEntity entity = new ShopEntity();
entity.setStatus(true);
entity.setHot(false);
if(!StringUtils.isEmpty(id)){
entity = service.selectById(id);
}
model.addAttribute("entity",entity);

List<ShopTypeEntity> types = shopTypeService.selectList(new EntityWrapper<>());
model.addAttribute("types",types);
return "shop/save";
}

/**
* 保存
* @param model
* @return
* @throws Exception
*/
@RequestMapping("saveData.htm")
@ResponseBody
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
        }
return Result.success("保存成功");
}

/**
* 保存
* @param model
* @return
* @throws Exception
*/
@RequestMapping("del.htm")
@ResponseBody
@ImLog(type = "用户",mark = "删除用户 {id}")
public Result del(Model model, String id )throws Exception{
userService.deleteById(id);
return Result.success("保存成功");
}



}
package com.wsy.controller.mobile;



@Controller
@RequestMapping("customerAddress")
public class CustomerAddressController {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
public String list(Model model)throws Exception{
CustomerEntity userEntity = Contants.getCustomer();
EntityWrapper entityWrapper = new EntityWrapper();
entityWrapper.eq(ShoppingGatTable.CUSTOMER_ID,userEntity.getId());
List<ShoppingGatEntity> gats = shoppingGatService.selectList(entityWrapper);
if(gats!=null ){
for (ShoppingGatEntity gat : gats) {
ShopEntity shopEntity = shopService.selectById(gat.getShopId());
gat.setShopEntity(shopEntity);
}
}
model.addAttribute("gats",gats);
CustomerEntity customerEntity = customerService.selectById(userEntity.getId());
model.addAttribute("integral",customerEntity.getIntegral());
List<CustomerAddressEntity> customerAddressEntities = customerAddressService.selectList(entityWrapper);
model.addAttribute("customerAddressEntities",customerAddressEntities);
return "mobile/gat";
}


/**
* 删除
* @param id
* @return
* @throws Exception
*/
@RequestMapping("delete.do")
@ResponseBody
public Result delete(String id)throws Exception{
CustomerEntity userEntity = Contants.getCustomer();
if(StringUtils.isEmpty(id)){
EntityWrapper entityWrapper = new EntityWrapper();
entityWrapper.eq(ShoppingGatTable.CUSTOMER_ID,userEntity.getId());
shoppingGatService.delete(entityWrapper);
}else{
shoppingGatService.deleteById(id);
}
return Result.success("成功");
}

/**
* 添加到购物车


项目链接:
https://javayms.github.io?id=121422282105200cm
https://javayms.pages.dev?id=121422282105200cm