售货机商品列表及购买功能

FangShiBa
fangzhe 2023-12-17 15:10:05 +08:00
parent 44df269604
commit 08420bb7e1
8 changed files with 310 additions and 0 deletions

View File

@ -4,7 +4,9 @@
<file url="file://$PROJECT_DIR$/bwie-auth/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-gateway/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-models/bwie-buy/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-models/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-models/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-mq/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@ -0,0 +1,33 @@
package com.bwie.common.pojo.DTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class DTOGoods {
private Integer goodsId; //商品设备中间id
private Integer shopId; //商品id
private Integer facilityId; //设备id
private Integer goodsNum; //库存
private Integer goodsIsDelete; //上下架(逻辑字段: 0上架, 1下架)
private String shopName; //商品名称
private Double shopPrice; //商品价格
private Integer typeId; //商品类型id
private String facilityType; //设备类型
private String facilitySite; //设备地址
private Integer replenishmentUserId; //补货员工
private Integer maintainUserId; //维修员工
private String facilityStatic; //设备状态
private Integer delId; //删除状态
}

View File

@ -0,0 +1,28 @@
package com.bwie.common.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Facility {
private Integer facilityId; //设备编号
private String facilityType; //设备类型
private String facilitySite; //设备地址
private Integer replenishmentUserId; //补货员工
private Integer maintainUserId; //维修员工
private String facilityStatic; //设备状态
private Integer delId; //删除状态
}

View File

@ -0,0 +1,23 @@
package com.bwie.common.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Goods {
private Integer goodsId; //商品设备中间id
private Integer shopId; //商品id
private Integer facilityId; //设备id
private Integer goodsNum; //库存
private Integer goodsIsDelete; //上下架(逻辑字段: 0上架, 1下架)
}

View File

@ -0,0 +1,23 @@
package com.bwie.common.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Shop {
private Integer shopId; //商品id
private String shopName; //商品名称
private Double shopPrice; //商品价格
private Integer typeId; //商品类型id
}

View File

@ -0,0 +1,27 @@
package com.bwie.common.pojo.VO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class VOGoods {
private Integer goodsId; //商品设备中间id
private Integer shopId; //商品id
private Integer facilityId; //设备id
private Integer goodsNum; //库存
private Integer goodsIsDelete; //上下架(逻辑字段: 0上架, 1下架)
private Double payForMoney; //支付金额
private Integer pageNum=1;
private Integer pageSize=3;
}

View File

@ -0,0 +1,50 @@
package com.bwie.buy.service.impl;
import com.bwie.buy.dao.BuyDao;
import com.bwie.buy.service.BuyService;
import com.bwie.common.pojo.DTO.DTOGoods;
import com.bwie.common.pojo.Shop;
import com.bwie.common.pojo.VO.VOGoods;
import com.bwie.common.result.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author FangShiBa
* @date 2023/12/17
* @apiNote
*/
@Service
public class BuyServiceImp implements BuyService {
@Autowired
private BuyDao dao;
@Override
public Result buyGood(VOGoods voGoods) {
if(null==voGoods.getFacilityId()||null==voGoods.getPayForMoney()){
return Result.error("输入的值有误或未输入");
}
Shop shop=dao.findById(voGoods.getShopId());
if(shop.getShopPrice()>voGoods.getPayForMoney()){
return Result.error("小老弟,钱不够");
}
//voGoods 参数有商品编号和售货机编号
dao.buyGood(voGoods);
return Result.success("购买成功");
}
@Override
public Result showGoodsList(VOGoods voGoods) {
PageHelper.startPage(voGoods.getPageNum(),voGoods.getPageSize());
List<DTOGoods> list=dao.showGoodsList(voGoods);
PageInfo<DTOGoods> info = new PageInfo<>(list);
return Result.success(info);
}
}