基于javaweb的SpringBoot二手商品系统(java+springboot+vue+mybatis+maven+mysql)

运行环境

Java≥8、MySQL≥5.7、Node.js≥14

开发工具

后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可

❗没学过node.js的不要搞前后端分离项目

适用

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

功能说明

000923551103

540923541103

550923541103

560923541103

580923541103

590923541103

基于javaweb的SpringBoot二手商品系统(java+springboot+vue+mybatis+maven+mysql)

一、项目运行 环境配置:

Jdk1.8 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。

项目技术:

Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
前端启动命令:npm run serve

卖家用户
13599999999 123456

管理员
1234567890 123456

买家用户
13588888888 123456

购物流程:
[卖家用户]管理商品、订单发货等
[管理员]审核用户和商品
[买家用户]充值余额、个人信息、购买商品、收货评价等

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
//购买商品的数量
int commodityQuantity = Integer.parseInt(num);

//购买商品的总价钱
double totalPrice = 0.0;

//积分可以转换成的现金(100积分=1¥)
int transferToCash = (int) integral / 100;

//再进行一次判断
if (commodityQuantity <= saleCount) {
totalPrice = commodityQuantity * price - transferToCash;
saleCount = saleCount - commodityQuantity;
historicalSaleCount = historicalSaleCount + commodityQuantity;
tradingCount = tradingCount + commodityQuantity;
peopleBuy += 1;

balance = balance - totalPrice;
integral = integral - transferToCash * 100 + (int) totalPrice;

//更新商品信息
Commodity modifyCommodity = new Commodity();
modifyCommodity.setId(Integer.parseInt(id));
modifyCommodity.setSaleCount(saleCount);
modifyCommodity.setHistoricalSaleCount(historicalSaleCount);
modifyCommodity.setTradingCount(tradingCount);
modifyCommodity.setPeopleBuy(peopleBuy);
modifyCommodity.setAppraiseScore(appraiseScore);//不能删除
modifyCommodity.setPrice(price);//不能删除

//根据商品id改变商品信息:在售数量、历史销量、交易数量、购买人数
commodityService.updateCommodity(modifyCommodity);

//更新用户信息
User modifyUser = new User();
modifyUser.setId(Integer.parseInt(userId));
modifyUser.setBalance(balance);
modifyUser.setIntegral(integral);

//根据用户id改变用户信息:余额、积分
userService.updateUser(modifyUser);

//新增支付记录
double payment = totalPrice;
int isTopUp = 0;
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
@Autowired
private CommodityService commodityService;

@Autowired
private PurchaseService purchaseService;

@Autowired
private UserService userService;

/**
* 新增用户对于商品的评价信息
*
* @return 返回JSON字符串
*/
@PostMapping(value = "/user/information/insert", produces = "application/json;charset=utf-8")
public String insertInformationByUserAndCommodity(String appraiseInformation, String appraiseService, String price,
String appraiseScore, String userId, String commodityId) {
HashMap<String, Object> message = new HashMap<>();

Information information = new Information();
information.setAppraiseInformation(appraiseInformation);
information.setAppraiseService(Integer.parseInt(appraiseService));
information.setUserId(Integer.parseInt(userId));
information.setCommodityId(Integer.parseInt(commodityId));

if (informationService.total() == 0) {
information.setId(1);
}

Commodity commodity = commodityService.selectCommodityById(Integer.parseInt(commodityId));

int merchantId = commodity.getUserId();

information.setMerchantId(merchantId);
int i = informationService.insertInformationByUserAndCommodity(information);
message.put("message", i);

double score = commodity.getAppraiseScore();//针对商品评价的平均分数
Integer confirmPurchase = commodity.getConfirmPurchase();//商品收货人数
Integer goodComment = commodity.getGoodComment();//好评人数

double totalScore = (confirmPurchase - 1) * score;//总的评价分数
double presentScore = (Double.parseDouble(appraiseScore) + totalScore) / confirmPurchase;//现在的评价分数

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
 */

@RestController
public class CartController {

@Autowired
private PurchaseService purchaseService;

@Autowired
private CommodityService commodityService;

@Autowired
private UserService userService;

@Autowired
private WalletRecordService walletRecordService;

/**
* 将商品添加至购物车
*
* @param userId 购买商品的用户id
* @param commodityId 商品id
* @param num 添加至购物车中商品的数量
* @param isShopping 是否是购物(0:否;1:是)
* @return 返回JSON字符串
*/
@PostMapping(value = "/user/cart/add", produces = "application/json;charset=utf-8")
public String addToCart(String userId, String commodityId, String num, String isShopping) {
Map<String, Object> message = new HashMap<>();

Commodity commodity = commodityService.selectCommodityById(Integer.parseInt(commodityId));
int merchantId = commodity.getUserId();//获取该商品对应的商家用户id
double price = commodity.getPrice();

int purchaseCount = Integer.parseInt(num);//添加至购物车中商品的数量
double totalPrice = purchaseCount * price;//添加至购物车中商品的总价

Purchase purchase = new Purchase();
purchase.setPurchaseCount(purchaseCount);//加入购物车中商品的数量
purchase.setTotalPrice(totalPrice);
purchase.setIsShopping(Integer.parseInt(isShopping));
purchase.setUserId(Integer.parseInt(userId));
purchase.setMerchantId(merchantId);
purchase.setCommodityId(Integer.parseInt(commodityId));

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
 */
@PostMapping(value = "/administrator/commodity/text", produces = "application/json;charset=utf-8")
public String selectCommodityByText(String text, String currentPage, String pageSize){
Map<String, Object> message = new HashMap<>();

List<Commodity> commodities = commodityService.selectAllCommodityByText(text, Integer.parseInt(currentPage),
Integer.parseInt(pageSize));

List<Map<String, Object>> information = this.selectAllCommodityAndMerchant(commodities);
message.put("information", information);

Long total = commodityService.totalByText(text);
message.put("total", total);
return JSON.toJSONString(message);
}

/**
* 查询商品审核状态为已发布的商品
* @param currentPage 当前页码
* @param pageSize 页面尺寸
* @return 返回的JSON字符串
*/
@PostMapping(value = "/administrator/commodity/emit", produces = "application/json;charset=utf-8")
public String selectCommodityByAuditState(String currentPage, String pageSize){
Map<String, Object> message = new HashMap<>();

List<Commodity> commodities = commodityService.selectCommodityByAuditState(Integer.parseInt(currentPage),
Integer.parseInt(pageSize));

List<Map<String, Object>> information = this.selectAllCommodityAndMerchant(commodities);
message.put("information", information);

Long total = commodityService.totalAuditState();
message.put("total", total);
return JSON.toJSONString(message);
}

/**
* 根据商品名称查询audit_state=1的商品信息(实现分页)(模糊查询)
* @param text 商品名称
* @param currentPage 当前页码
* @param pageSize 页面尺寸
* @return 返回的JSON字符串
*/
@PostMapping(value = "/administrator/commodity/text/audit_state", produces = "application/json;charset=utf-8")
public String selectCommodityByTextAndAuditState(String text, String currentPage, String pageSize){
Map<String, Object> message = new HashMap<>();

List<Commodity> commodities = commodityService.selectAllCommodityByTextAndAuditState(text, Integer.parseInt(currentPage),
Integer.parseInt(pageSize));
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

/**
* @version 1.0
* @project Name: secondhand-trading-latform
* @file Name: UserController
* @desc 功能描述
* @time 17:07
* @by IDE: IntelliJ IDEA
*/

@RestController
public class UserController {

@Autowired
private UserService userService;

/**
* 获取全部用户(包括注册未审核、审核已通过审核未通过的全部用户)(未实现分页)
*
* @return JSON字符串
*/
@PostMapping(value = "/administrator/user/all", produces = "application/json;charset=utf-8")
public String allUser() {
Map<String, Object> message = new HashMap<>();
List<User> users = userService.selectAllUsers();

message.put("message", users);

return JSON.toJSONString(message);
}

/**
* 修改指定用户的信息
*
* @return JSON字符串
*/
@PostMapping(value = "/administrator/user/update", produces = "application/json;charset=utf-8")
public String updateDefinedUser(String id, String enableState, String auditRegistryState, String currentPage, String pageSize) {
Map<String, Object> message = new HashMap<>();
User user = new User();
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


/**
* @version 1.0
* @project Name: secondhand-trading-latform
* @file Name: CommentOfCommodityController
* @desc 功能描述
* @time 18:12
* @by IDE: IntelliJ IDEA
*/

@RestController
public class CommentOfCommodityController {

@Autowired
private CommodityService commodityService;

@Autowired
private InformationService informationService;

@Autowired
private UserService userService;

/**
* 查询当前商家用户的所有已发布的商品信息
*
* @param merchantId 商家用户id
* @param currentPage 当前页码
* @param pageSize 每页显示条数
* @return 返回的JSON字符串
*/
@PostMapping(value = "/merchant/commodity/issued/all", produces = "application/json;charset=utf-8")
public String selectCommodityByCurrentMerchantAndAuditState(String merchantId, String currentPage, String pageSize) {
Map<String, Object> message = new HashMap<>();

List<Commodity> commodities = commodityService.selectCommodityByCurrentMerchant(Integer.parseInt(merchantId),
Integer.parseInt(currentPage), Integer.parseInt(pageSize));
message.put("commodities", commodities);

Long total = commodityService.totalCommodityByCurrentMerchant(Integer.parseInt(merchantId));
message.put("total", total);


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