├── .gitignore ├── README.md ├── img ├── Redis分布式算法1.png ├── Redis分布式算法2.png ├── Redis分布式算法3.png ├── Redis分布式算法4.png ├── Redis分布式算法5.png ├── Session过期.png ├── bad.jpg ├── buy.gif ├── cj.jpg ├── code1.jpg ├── corn1.jpg ├── corn2.jpg ├── error1.jpg ├── good.jpg ├── hash1.jpg ├── hash2.jpg ├── hash3.jpg ├── hash4.jpg ├── hash5.jpg ├── jiagou.png ├── pay.gif ├── payprocess.png ├── payprocess2.jpg ├── redis4.jpg ├── redis5.jpg ├── redis分布式锁1.jpg ├── redis分布式锁2.png ├── redis分布式锁3.jpg ├── simditor.jpg ├── xl.jpg ├── 传统分布式算法.jpg ├── 全局异常.jpg ├── 全局异常例子.png ├── 单点登录1.png ├── 单点登录2.png ├── 拦截器.jpg ├── 接口清单.png ├── 无全局异常.jpg ├── 无锁.jpg ├── 行锁.jpg ├── 表锁1.jpg ├── 表锁2.jpg ├── 表锁3.jpg └── 非全局异常例子.png ├── pom.xml └── src └── main ├── java └── com │ ├── alipay │ └── demo │ │ └── trade │ │ ├── DemoHbRunner.java │ │ └── Main.java │ └── mmall │ ├── common │ ├── Const.java │ ├── ResponseCode.java │ ├── ServerResponse.java │ └── TokenCache.java │ ├── controller │ ├── backend │ │ ├── CategoryManageController.java │ │ ├── OrderManageController.java │ │ ├── ProductManageController.java │ │ └── UserManageController.java │ └── portal │ │ ├── CartController.java │ │ ├── OrderController.java │ │ ├── ProductController.java │ │ ├── ShippingController.java │ │ └── UserController.java │ ├── dao │ ├── CartMapper.java │ ├── CategoryMapper.java │ ├── OrderItemMapper.java │ ├── OrderMapper.java │ ├── PayInfoMapper.java │ ├── ProductMapper.java │ ├── ShippingMapper.java │ └── UserMapper.java │ ├── pojo │ ├── Cart.java │ ├── Category.java │ ├── Order.java │ ├── OrderItem.java │ ├── PayInfo.java │ ├── Product.java │ ├── Shipping.java │ └── User.java │ ├── service │ ├── ICartService.java │ ├── ICategoryService.java │ ├── IFileService.java │ ├── IOrderService.java │ ├── IProductService.java │ ├── IShippingService.java │ ├── IUserService.java │ └── impl │ │ ├── CartServiceImpl.java │ │ ├── CategoryServiceImpl.java │ │ ├── FileServiceImpl.java │ │ ├── OrderServiceImpl.java │ │ ├── ProductServiceImpl.java │ │ ├── ShippingServiceImpl.java │ │ └── UserServiceImpl.java │ ├── test │ ├── BaseTest.java │ ├── BigDecimalTest.java │ └── ResponseCodeTest.java │ ├── util │ ├── BigDecimalUtil.java │ ├── DataTimeUtil.java │ ├── FTPUtil.java │ ├── MD5Util.java │ └── PropertiesUtil.java │ └── vo │ ├── CartProductVo.java │ ├── CartVo.java │ ├── OrderItemVo.java │ ├── OrderProductVo.java │ ├── OrderVo.java │ ├── ProductDetailVo.java │ ├── ProductListVo.java │ └── ShippingVo.java ├── resources ├── applicationContext-datasource.xml ├── applicationContext.xml ├── datasource.properties ├── generatorConfig.xml ├── logback.xml ├── mappers │ ├── CartMapper.xml │ ├── CategoryMapper.xml │ ├── OrderItemMapper.xml │ ├── OrderMapper.xml │ ├── PayInfoMapper.xml │ ├── ProductMapper.xml │ ├── ShippingMapper.xml │ └── UserMapper.xml ├── mmall.properties └── zfbinfo.properties └── webapp ├── WEB-INF ├── dispatcher-servlet.xml ├── lib │ ├── alipay-sdk-java-3.3.0-source.jar │ ├── alipay-sdk-java-3.3.0.jar │ ├── alipay-trade-sdk-20161215-source.jar │ └── alipay-trade-sdk-20161215.jar └── web.xml └── index.jsp /.gitignore: -------------------------------------------------------------------------------- 1 | # 配置的文件将无法上穿到github仓库上 2 | *.class 3 | # package ignore 4 | *.war 5 | *.ear 6 | 7 | # kdiff3 ignore 8 | *.orig 9 | 10 | # maven ignore 11 | target/ 12 | 13 | # eclipse ignore 14 | .settings/ 15 | .project 16 | .classpath 17 | 18 | # idea ignore 19 | .idea/ 20 | /idea/ 21 | *.ipr 22 | *.iml 23 | *.iws 24 | 25 | # temp file 26 | *.log 27 | *.cache 28 | *.diff 29 | *.patch 30 | *.tmp 31 | 32 | # system ignore 33 | .DS_Store 34 | Thumbs.db -------------------------------------------------------------------------------- /img/Redis分布式算法1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/Redis分布式算法1.png -------------------------------------------------------------------------------- /img/Redis分布式算法2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/Redis分布式算法2.png -------------------------------------------------------------------------------- /img/Redis分布式算法3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/Redis分布式算法3.png -------------------------------------------------------------------------------- /img/Redis分布式算法4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/Redis分布式算法4.png -------------------------------------------------------------------------------- /img/Redis分布式算法5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/Redis分布式算法5.png -------------------------------------------------------------------------------- /img/Session过期.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/Session过期.png -------------------------------------------------------------------------------- /img/bad.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/bad.jpg -------------------------------------------------------------------------------- /img/buy.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/buy.gif -------------------------------------------------------------------------------- /img/cj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/cj.jpg -------------------------------------------------------------------------------- /img/code1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/code1.jpg -------------------------------------------------------------------------------- /img/corn1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/corn1.jpg -------------------------------------------------------------------------------- /img/corn2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/corn2.jpg -------------------------------------------------------------------------------- /img/error1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/error1.jpg -------------------------------------------------------------------------------- /img/good.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/good.jpg -------------------------------------------------------------------------------- /img/hash1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/hash1.jpg -------------------------------------------------------------------------------- /img/hash2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/hash2.jpg -------------------------------------------------------------------------------- /img/hash3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/hash3.jpg -------------------------------------------------------------------------------- /img/hash4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/hash4.jpg -------------------------------------------------------------------------------- /img/hash5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/hash5.jpg -------------------------------------------------------------------------------- /img/jiagou.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/jiagou.png -------------------------------------------------------------------------------- /img/pay.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/pay.gif -------------------------------------------------------------------------------- /img/payprocess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/payprocess.png -------------------------------------------------------------------------------- /img/payprocess2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/payprocess2.jpg -------------------------------------------------------------------------------- /img/redis4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/redis4.jpg -------------------------------------------------------------------------------- /img/redis5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/redis5.jpg -------------------------------------------------------------------------------- /img/redis分布式锁1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/redis分布式锁1.jpg -------------------------------------------------------------------------------- /img/redis分布式锁2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/redis分布式锁2.png -------------------------------------------------------------------------------- /img/redis分布式锁3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/redis分布式锁3.jpg -------------------------------------------------------------------------------- /img/simditor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/simditor.jpg -------------------------------------------------------------------------------- /img/xl.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/xl.jpg -------------------------------------------------------------------------------- /img/传统分布式算法.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/传统分布式算法.jpg -------------------------------------------------------------------------------- /img/全局异常.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/全局异常.jpg -------------------------------------------------------------------------------- /img/全局异常例子.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/全局异常例子.png -------------------------------------------------------------------------------- /img/单点登录1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/单点登录1.png -------------------------------------------------------------------------------- /img/单点登录2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/单点登录2.png -------------------------------------------------------------------------------- /img/拦截器.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/拦截器.jpg -------------------------------------------------------------------------------- /img/接口清单.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/接口清单.png -------------------------------------------------------------------------------- /img/无全局异常.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/无全局异常.jpg -------------------------------------------------------------------------------- /img/无锁.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/无锁.jpg -------------------------------------------------------------------------------- /img/行锁.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/行锁.jpg -------------------------------------------------------------------------------- /img/表锁1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/表锁1.jpg -------------------------------------------------------------------------------- /img/表锁2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/表锁2.jpg -------------------------------------------------------------------------------- /img/表锁3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/表锁3.jpg -------------------------------------------------------------------------------- /img/非全局异常例子.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/img/非全局异常例子.png -------------------------------------------------------------------------------- /src/main/java/com/alipay/demo/trade/DemoHbRunner.java: -------------------------------------------------------------------------------- 1 | package com.alipay.demo.trade; 2 | 3 | import com.alipay.demo.trade.model.builder.AlipayHeartbeatSynRequestBuilder; 4 | import com.alipay.demo.trade.model.hb.*; 5 | import com.alipay.demo.trade.service.AlipayMonitorService; 6 | import com.alipay.demo.trade.service.impl.hb.AbsHbRunner; 7 | import com.alipay.demo.trade.service.impl.hb.HbQueue; 8 | import com.alipay.demo.trade.utils.Utils; 9 | 10 | import java.util.ArrayList; 11 | import java.util.Date; 12 | import java.util.List; 13 | 14 | /** 15 | * Created by liuyangkly on 15/10/23. 16 | 执行调度,主要任务由两个线程完成,交 易线程(调用当面付2.0接口)和交易保障线程(轮询),具体需要做的事情 17 | 1.当面付程序每执行完一笔交易后将交易结果保存在临时队列 18 | 2.轮询线程读取临时队列,获取基础采集信息和最多30条trade_info信息,调用支付宝monitor.heartbeat.syn接口 19 | 示例代码仅封装了如何调用该接口api,采集数据,比如采集网络信息、交易耗时、异常信息等,需要系统商开发者自行完成。 20 | */ 21 | public class DemoHbRunner extends AbsHbRunner { 22 | 23 | public DemoHbRunner(AlipayMonitorService monitorService) { 24 | super(monitorService); 25 | } 26 | 27 | @Override 28 | public String getAppAuthToken() { 29 | // 对于系统商,如果是为了商户开发监控保障接口,则需要传此值,否则如果为系统商自己做交易保障接口开发,则可不传。 30 | return null; 31 | } 32 | 33 | @Override 34 | public AlipayHeartbeatSynRequestBuilder getBuilder() { 35 | // 系统商使用的交易信息格式,json字符串类型,从交易队列中获取 36 | List sysTradeInfoList = HbQueue.poll(); 37 | 38 | // 异常信息的采集,系统商自行完成 39 | List exceptionInfoList = new ArrayList(); 40 | // exceptionInfoList.add(ExceptionInfo.HE_SCANER); 41 | // exceptionInfoList.add(ExceptionInfo.HE_PRINTER); 42 | // exceptionInfoList.add(ExceptionInfo.HE_OTHER); 43 | 44 | AlipayHeartbeatSynRequestBuilder builder = new AlipayHeartbeatSynRequestBuilder() 45 | .setProduct(Product.FP).setType(Type.CR).setEquipmentId("cr1000001") 46 | .setEquipmentStatus(EquipStatus.NORMAL).setTime(Utils.toDate(new Date())) 47 | .setStoreId("store10001").setMac("0a:00:27:00:00:00").setNetworkType("LAN") 48 | .setProviderId("2088911212323549") // 设置系统商pid 49 | .setSysTradeInfoList(sysTradeInfoList) // 系统商同步trade_info信息 50 | .setExceptionInfoList(exceptionInfoList) // 填写异常信息,如果有的话 51 | ; 52 | return builder; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/common/Const.java: -------------------------------------------------------------------------------- 1 | package com.mmall.common; 2 | 3 | import com.google.common.collect.Sets; 4 | 5 | import java.util.Set; 6 | 7 | /** 8 | * @ClassName:Const 9 | * @Description 常量类 10 | * @Author oyj 11 | * @Date 2018/11/24 16:10 12 | * @Version 1.0 13 | **/ 14 | public class Const { 15 | public static final String CURRENT_USER = "currentUser"; 16 | public static final String EMAIL = "email"; 17 | public static final String USERNAME = "username"; 18 | 19 | public interface ProductListOrderBy{ 20 | Set PRICE_ASC_DESC = Sets.newHashSet("price_desc","price_asc"); 21 | } 22 | public interface Cart{ 23 | int CHECKED = 1;//购物车选中状态 24 | int UN_CHECKED = 0;//购物车未选中状态 25 | 26 | String LIMIT_NUM_FAIL = "LIMIT_NUM_FAIL"; 27 | String LIMIT_NUM_SUCCESS = "LIMIT_NUM_SUCCESS"; 28 | } 29 | 30 | public interface Role{ 31 | int ROLE_CUSTOMER = 0;//普通用户 32 | int ROLE_ADMIN = 1; //管理员 33 | } 34 | public enum ProductStatusEnum{ 35 | ON_SALE(1,"在线"); 36 | private String value; 37 | private int code; 38 | ProductStatusEnum(int code,String value){ 39 | this.code = code; 40 | this.value = value; 41 | } 42 | 43 | public String getValue() { 44 | return value; 45 | } 46 | 47 | public void setValue(String value) { 48 | this.value = value; 49 | } 50 | 51 | public int getCode() { 52 | return code; 53 | } 54 | 55 | public void setCode(int code) { 56 | this.code = code; 57 | } 58 | } 59 | 60 | //订单状态 61 | public enum OrderStatusEnum{ 62 | 63 | CANCELED(0,"已取消"), 64 | NO_PAY(10,"未支付"), 65 | PAID(20,"已付款"), 66 | SHIPPED(40,"已发货"), 67 | ORDER_SUCCESS(50,"订单完成"), 68 | ORDER_CLOSE(60,"订单关闭"); 69 | 70 | private int code; 71 | private String value; 72 | 73 | OrderStatusEnum(int code, String value) { 74 | this.code = code; 75 | this.value = value; 76 | } 77 | 78 | public int getCode() { 79 | return code; 80 | } 81 | public String getValue() { 82 | return value; 83 | } 84 | public static OrderStatusEnum codeOf(int code){ 85 | for(OrderStatusEnum orderStatusEnum : values()){ 86 | if(orderStatusEnum.getCode() == code){ 87 | return orderStatusEnum; 88 | } 89 | } 90 | throw new RuntimeException("么有找到对应的枚举"); 91 | } 92 | } 93 | 94 | 95 | public interface AlipayCallback{ 96 | //交易创建 97 | String TRADE_STATUS_WAIT_BUYER_PAY = "WAIT_BUYER_PAY"; 98 | //支付成功 99 | String TRADE_STATUS_TRADE_SUCCESS = "TRADE_SUCCESS"; 100 | 101 | String RESPONSE_SUCCESS = "success"; 102 | String RESPONSE_FAILED = "failed"; 103 | } 104 | 105 | //支付类型 106 | public enum PayPlatformEnum{ 107 | ALIPAY(1,"支付宝"); 108 | 109 | PayPlatformEnum(int code,String value){ 110 | this.code = code; 111 | this.value = value; 112 | } 113 | private String value; 114 | private int code; 115 | 116 | public String getValue() { 117 | return value; 118 | } 119 | 120 | public int getCode() { 121 | return code; 122 | } 123 | } 124 | 125 | public enum PaymentTypeEnum{ 126 | ONLINE_PAY(1,"在线支付"); 127 | 128 | PaymentTypeEnum(int code,String value){ 129 | this.code = code; 130 | this.value = value; 131 | } 132 | private String value; 133 | private int code; 134 | 135 | public String getValue() { 136 | return value; 137 | } 138 | 139 | public int getCode() { 140 | return code; 141 | } 142 | 143 | 144 | public static PaymentTypeEnum codeOf(int code){ 145 | for(PaymentTypeEnum paymentTypeEnum : values()){ 146 | if(paymentTypeEnum.getCode() == code){ 147 | return paymentTypeEnum; 148 | } 149 | } 150 | throw new RuntimeException("没有找到对应的枚举"); 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/common/ResponseCode.java: -------------------------------------------------------------------------------- 1 | package com.mmall.common; 2 | 3 | public enum ResponseCode { 4 | SUCCESS(0,"SUCCESS"), 5 | ERROR(1,"ERROR"), 6 | NEED_LOGIN(10,"NEED_LOGIN"), 7 | ILLEGAL_ARGUMENT(2,"ILLEGAL_ARGUMENT"); 8 | 9 | private int code; 10 | private String desc; 11 | ResponseCode(int code,String desc){ 12 | this.code = code; 13 | this.desc = desc; 14 | } 15 | public int getCode(){ 16 | return code; 17 | } 18 | public String getDesc(){ 19 | return desc; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/common/ServerResponse.java: -------------------------------------------------------------------------------- 1 | package com.mmall.common; 2 | 3 | import org.codehaus.jackson.annotate.JsonIgnore; 4 | import org.codehaus.jackson.map.annotate.JsonSerialize; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @ClassName:ServerResponse 10 | * @Description 状态记录类 11 | * @Author oyj 12 | * @Date 2018/11/23 16:48 13 | * @Version 1.0 14 | **/ 15 | @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) 16 | //保证json序列化的时候,如果此时有null的对象,key也会消失 17 | public class ServerResponse implements Serializable { 18 | private int status; 19 | private String msg;//消息 20 | private T data;//返回的数据 21 | private ServerResponse(int status){ 22 | this.status = status; 23 | } 24 | public ServerResponse(int status,String msg){ 25 | this.status = status; 26 | this.msg = msg; 27 | } 28 | public ServerResponse(int status,T data){ 29 | this.status = status; 30 | this.data = data; 31 | } 32 | private ServerResponse(int status,String msg,T data){ 33 | this.status = status; 34 | this.msg = msg; 35 | this.data = data; 36 | } 37 | //使之不在json序列化中 38 | @JsonIgnore 39 | public boolean isSuccess(){ 40 | return this.status == ResponseCode.SUCCESS.getCode(); 41 | } 42 | public int getStatus(){ 43 | return status; 44 | } 45 | public String getMsg(){ 46 | return msg; 47 | } 48 | public T getData(){ 49 | return data; 50 | } 51 | //创建一个成功的服务器响应 52 | public static ServerResponse createBySuccess(){ 53 | return new ServerResponse(ResponseCode.SUCCESS.getCode()); 54 | } 55 | //创建一个成功的服务器响应,并且把msg填充进去 56 | public static ServerResponse createBySuccessMessage(String msg){ 57 | return new ServerResponse(ResponseCode.SUCCESS.getCode(),msg); 58 | } 59 | //创建一个成功的服务器响应,并且把data填充进去 60 | public static ServerResponse createBySuccess(T data){ 61 | return new ServerResponse(ResponseCode.SUCCESS.getCode(),data); 62 | } 63 | //创建一个成功的服务器响应,并且把msg和data填充进去 64 | public static ServerResponse createBySuccess(String msg,T data){ 65 | return new ServerResponse(ResponseCode.SUCCESS.getCode(),msg,data); 66 | } 67 | //error 68 | public static ServerResponse createByError(){ 69 | return new ServerResponse(ResponseCode.ERROR.getCode(),ResponseCode.ERROR.getDesc()); 70 | } 71 | public static ServerResponse createByErrorMessage(String errorMessage){ 72 | return new ServerResponse(ResponseCode.ERROR.getCode(),errorMessage); 73 | } 74 | public static ServerResponse createByErrorCodeMessage(int errorCode,String errorMessage){ 75 | return new ServerResponse(errorCode,errorMessage); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/common/TokenCache.java: -------------------------------------------------------------------------------- 1 | package com.mmall.common; 2 | 3 | import com.google.common.cache.CacheBuilder; 4 | import com.google.common.cache.CacheLoader; 5 | import com.google.common.cache.LoadingCache; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.util.concurrent.TimeUnit; 10 | 11 | /** 12 | * @Classname TokenCache 13 | * @Description TODO 14 | * @Date 2019/1/26 21:29 15 | * @Created by oyj 16 | */ 17 | public class TokenCache { 18 | private static Logger logger = LoggerFactory.getLogger(TokenCache.class); 19 | public static final String TOKEN_PREFIX = "token_"; 20 | //LRU算法(Least Recently Used,即最近最少使用,常用于页面置换算法) 21 | private static LoadingCache localCache = CacheBuilder.newBuilder().initialCapacity(1000).maximumSize(10000).expireAfterAccess(12, TimeUnit.HOURS).build(new CacheLoader() { 22 | //默认的数据加载实现,当调用get取值的时候,如果key没有对应的值,就调用这个方法进行加载 23 | @Override 24 | public String load(String s) throws Exception { 25 | return "null"; 26 | } 27 | }); 28 | public static void setKey(String key,String value){ 29 | localCache.put(key,value); 30 | } 31 | public static String getKey(String key){ 32 | String value = null; 33 | try{ 34 | value = localCache.get(key); 35 | if("null".equals(value)){ 36 | return null; 37 | } 38 | return value; 39 | }catch(Exception e){ 40 | logger.error("localCache get error",e); 41 | } 42 | return null; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/controller/backend/CategoryManageController.java: -------------------------------------------------------------------------------- 1 | package com.mmall.controller.backend; 2 | 3 | import com.mmall.common.Const; 4 | import com.mmall.common.ResponseCode; 5 | import com.mmall.common.ServerResponse; 6 | import com.mmall.pojo.User; 7 | import com.mmall.service.ICategoryService; 8 | import com.mmall.service.IUserService; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestParam; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import javax.servlet.http.HttpSession; 15 | 16 | /** 17 | * @Classname CategoryManageController 18 | * @Description 商品的类型管理 19 | * @Date 2019/2/16 15:32 20 | * @Created by oyj 21 | */ 22 | @RestController 23 | @RequestMapping("/manage/category") 24 | public class CategoryManageController { 25 | @Autowired 26 | private IUserService iUserService; 27 | @Autowired 28 | private ICategoryService iCategoryService; 29 | //添加商品分类 30 | @RequestMapping("add_category.do") 31 | public ServerResponse addCategory(HttpSession session,String categoryName,@RequestParam(value = "parentid",defaultValue = "0") int parentId){ 32 | User user = (User)session.getAttribute(Const.CURRENT_USER); 33 | if(user==null){ 34 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户还未登陆,需要先登陆"); 35 | } 36 | //用户已登录,则判断是否是管理员 37 | if(iUserService.checkAdminRole(user).isSuccess()){ 38 | //是管理员,进行添加商品分类的操作 39 | return iCategoryService.addCategory(categoryName, parentId); 40 | } 41 | return ServerResponse.createByErrorMessage("用户的操作权限不够,需要管理员权限"); 42 | } 43 | 44 | //更新商品类名 45 | @RequestMapping("set_category_name") 46 | public ServerResponse setCategoryName(HttpSession session,Integer categoryId,String categotyName){ 47 | User user = (User)session.getAttribute(Const.CURRENT_USER); 48 | if(user==null){ 49 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户还未登陆,需要先登陆"); 50 | } 51 | //用户已登录,则判断是否是管理员 52 | if(iUserService.checkAdminRole(user).isSuccess()){ 53 | //是管理员 54 | return iCategoryService.updateCategoryName(categoryId,categotyName); 55 | } 56 | return ServerResponse.createByErrorMessage("用户的操作权限不够,需要管理员权限"); 57 | } 58 | //根据传入的categoryId,获取该类别下平级的子节点信息,不进行递归 59 | @RequestMapping("get_category") 60 | public ServerResponse getChildrenParallelCategory(HttpSession session,@RequestParam(value = "categoryId",defaultValue = "0") Integer categoryId){ 61 | User user = (User)session.getAttribute(Const.CURRENT_USER); 62 | if(user==null){ 63 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户还未登陆,需要先登陆"); 64 | } 65 | //用户已登录,则判断是否是管理员 66 | if(iUserService.checkAdminRole(user).isSuccess()){ 67 | //是管理员 68 | return iCategoryService.getChildrenCategoryByParentId(categoryId); 69 | } 70 | return ServerResponse.createByErrorMessage("用户的操作权限不够,需要管理员权限"); 71 | } 72 | 73 | //根据传入的categoryId,获取该类别下平级的子节点信息,进行递归 74 | @RequestMapping("get_deep_category") 75 | public ServerResponse getChildrenDeepCategory(HttpSession session,@RequestParam(value = "categoryId",defaultValue = "0") Integer categoryId){ 76 | User user = (User)session.getAttribute(Const.CURRENT_USER); 77 | if(user==null){ 78 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户还未登陆,需要先登陆"); 79 | } 80 | //用户已登录,则判断是否是管理员 81 | if(iUserService.checkAdminRole(user).isSuccess()){ 82 | //进行递归查询 83 | return iCategoryService.selectCategoryAndChildById(categoryId); 84 | } 85 | return ServerResponse.createByErrorMessage("用户的操作权限不够,需要管理员权限"); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/controller/backend/OrderManageController.java: -------------------------------------------------------------------------------- 1 | package com.mmall.controller.backend; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.mmall.common.Const; 5 | import com.mmall.common.ResponseCode; 6 | import com.mmall.common.ServerResponse; 7 | import com.mmall.pojo.User; 8 | import com.mmall.service.IOrderService; 9 | import com.mmall.service.IUserService; 10 | import com.mmall.vo.OrderVo; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestParam; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | 17 | import javax.servlet.http.HttpSession; 18 | 19 | /** 20 | * Created by oyj 21 | */ 22 | 23 | @Controller 24 | @RequestMapping("/manage/order") 25 | public class OrderManageController { 26 | 27 | @Autowired 28 | private IUserService iUserService; 29 | @Autowired 30 | private IOrderService iOrderService; 31 | 32 | 33 | //查看所有的订单 34 | @RequestMapping("list.do") 35 | @ResponseBody 36 | public ServerResponse orderList(HttpSession session, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum, 37 | @RequestParam(value = "pageSize",defaultValue = "10")int pageSize){ 38 | 39 | User user = (User)session.getAttribute(Const.CURRENT_USER); 40 | if(user == null){ 41 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录,请登录管理员"); 42 | } 43 | if(iUserService.checkAdminRole(user).isSuccess()){ 44 | //填充我们增加产品的业务逻辑 45 | return iOrderService.manageList(pageNum,pageSize); 46 | }else{ 47 | return ServerResponse.createByErrorMessage("无权限操作"); 48 | } 49 | } 50 | 51 | //查看某一订单的细节 52 | @RequestMapping("detail.do") 53 | @ResponseBody 54 | public ServerResponse orderDetail(HttpSession session, Long orderNo){ 55 | 56 | User user = (User)session.getAttribute(Const.CURRENT_USER); 57 | if(user == null){ 58 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录,请登录管理员"); 59 | 60 | } 61 | if(iUserService.checkAdminRole(user).isSuccess()){ 62 | //填充我们增加产品的业务逻辑 63 | return iOrderService.manageDetail(orderNo); 64 | }else{ 65 | return ServerResponse.createByErrorMessage("无权限操作"); 66 | } 67 | } 68 | 69 | 70 | 71 | //按订单号搜索 72 | @RequestMapping("search.do") 73 | @ResponseBody 74 | public ServerResponse orderSearch(HttpSession session, Long orderNo, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum, 75 | @RequestParam(value = "pageSize",defaultValue = "10")int pageSize){ 76 | User user = (User)session.getAttribute(Const.CURRENT_USER); 77 | if(user == null){ 78 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录,请登录管理员"); 79 | 80 | } 81 | if(iUserService.checkAdminRole(user).isSuccess()){ 82 | //填充我们增加产品的业务逻辑 83 | return iOrderService.manageSearch(orderNo,pageNum,pageSize); 84 | }else{ 85 | return ServerResponse.createByErrorMessage("无权限操作"); 86 | } 87 | } 88 | 89 | 90 | 91 | //发货 92 | @RequestMapping("send_goods.do") 93 | @ResponseBody 94 | public ServerResponse orderSendGoods(HttpSession session, Long orderNo){ 95 | 96 | User user = (User)session.getAttribute(Const.CURRENT_USER); 97 | if(user == null){ 98 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录,请登录管理员"); 99 | } 100 | if(iUserService.checkAdminRole(user).isSuccess()){ 101 | //填充我们增加产品的业务逻辑 102 | return iOrderService.manageSendGoods(orderNo); 103 | }else{ 104 | return ServerResponse.createByErrorMessage("无权限操作"); 105 | } 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/controller/backend/ProductManageController.java: -------------------------------------------------------------------------------- 1 | package com.mmall.controller.backend; 2 | 3 | import com.google.common.collect.Maps; 4 | import com.mmall.common.Const; 5 | import com.mmall.common.ResponseCode; 6 | import com.mmall.common.ServerResponse; 7 | import com.mmall.pojo.Product; 8 | import com.mmall.pojo.User; 9 | import com.mmall.service.IFileService; 10 | import com.mmall.service.IProductService; 11 | import com.mmall.service.IUserService; 12 | import com.mmall.util.PropertiesUtil; 13 | import org.apache.commons.lang3.StringUtils; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RequestMethod; 17 | import org.springframework.web.bind.annotation.RequestParam; 18 | import org.springframework.web.bind.annotation.RestController; 19 | import org.springframework.web.multipart.MultipartFile; 20 | 21 | import javax.servlet.http.HttpServletRequest; 22 | import javax.servlet.http.HttpServletResponse; 23 | import javax.servlet.http.HttpSession; 24 | import java.util.Map; 25 | 26 | /** 27 | * @Classname ProductManageController 28 | * @Description 产品后台管理 29 | * @Date 2019/2/26 14:12 30 | * @Created by oyj 31 | */ 32 | @RestController 33 | //商品模块的管理 34 | @RequestMapping("/manage/product") 35 | public class ProductManageController { 36 | @Autowired 37 | private IUserService iUserService; 38 | @Autowired 39 | private IProductService iProductService; 40 | @Autowired 41 | private IFileService iFileService; 42 | 43 | //保存商品 44 | @RequestMapping("save_product.do") 45 | public ServerResponse saveProduct(HttpSession session,Product product){ 46 | User user = (User)session.getAttribute(Const.CURRENT_USER); 47 | if(user == null) { 48 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), "用户还未登陆"); 49 | } 50 | if(iUserService.checkAdminRole(user).isSuccess()){ 51 | //是管理员,进行保存商品操作 52 | return iProductService.saveOrUpdateProduct(product); 53 | } 54 | return ServerResponse.createByErrorMessage("操作权限不够"); 55 | } 56 | 57 | //设置商品的状态 58 | @RequestMapping(value = "set_sale_status.do",method = RequestMethod.POST) 59 | public ServerResponse setSaleStatus(HttpSession session,Integer productId,Integer status){ 60 | User user = (User)session.getAttribute(Const.CURRENT_USER); 61 | if(user == null) { 62 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), "用户还未登陆"); 63 | } 64 | if(iUserService.checkAdminRole(user).isSuccess()){ 65 | //是管理员,进行保存商品操作 66 | return iProductService.setSaleStatus(productId,status); 67 | } 68 | return ServerResponse.createByErrorMessage("操作权限不够"); 69 | } 70 | 71 | //获取商品的信息 72 | @RequestMapping(value = "detail.do") 73 | public ServerResponse getDetail(HttpSession session,Integer productId){ 74 | User user = (User)session.getAttribute(Const.CURRENT_USER); 75 | if(user == null) { 76 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), "用户还未登陆"); 77 | } 78 | if(iUserService.checkAdminRole(user).isSuccess()){ 79 | //填充业务代码 80 | return iProductService.manageProductDetail(productId); 81 | 82 | } 83 | return ServerResponse.createByErrorMessage("操作权限不够"); 84 | } 85 | 86 | //获取商品的列表 87 | @RequestMapping(value = "list.do",method = RequestMethod.POST) 88 | public ServerResponse getList(HttpSession session, @RequestParam(value="pageNum",defaultValue = "1") int pageNum, @RequestParam(value="pageSize",defaultValue = "10")int pageSize){ 89 | User user = (User)session.getAttribute(Const.CURRENT_USER); 90 | if(user == null) { 91 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), "用户还未登陆"); 92 | } 93 | if(iUserService.checkAdminRole(user).isSuccess()){ 94 | //填充业务代码 95 | return iProductService.getProductList(pageNum,pageSize); 96 | } 97 | return ServerResponse.createByErrorMessage("操作权限不够"); 98 | } 99 | //查询商品 100 | @RequestMapping(value = "search.do",method = RequestMethod.POST) 101 | public ServerResponse productSearch(HttpSession session,String productName,Integer productId,@RequestParam(value="pageNum",defaultValue = "1") int pageNum, @RequestParam(value="pageSize",defaultValue = "10")int pageSize){ 102 | User user = (User)session.getAttribute(Const.CURRENT_USER); 103 | if(user == null) { 104 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), "用户还未登陆"); 105 | } 106 | if(iUserService.checkAdminRole(user).isSuccess()){ 107 | //填充业务代码 108 | return iProductService.searchProduct(productName,productId,pageNum,pageSize); 109 | } 110 | return ServerResponse.createByErrorMessage("操作权限不够"); 111 | } 112 | 113 | //文件上传 114 | @RequestMapping("upload.do") 115 | public ServerResponse upload(HttpSession session,@RequestParam(value="upload_file",required = false) MultipartFile file, HttpServletRequest request){ 116 | User user = (User)session.getAttribute(Const.CURRENT_USER); 117 | if(user == null) { 118 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), "用户还未登陆"); 119 | } 120 | if(iUserService.checkAdminRole(user).isSuccess()){ 121 | String path = request.getSession().getServletContext().getRealPath("upload"); 122 | String targetFileName = iFileService.upload(file,path); 123 | String url = PropertiesUtil.getProperty("ftp.server.http.prefix")+targetFileName; 124 | 125 | Map fileMap = Maps.newHashMap(); 126 | //URI是统一资源标识符,而URL是统一资源定位符 127 | fileMap.put("uri",targetFileName); 128 | fileMap.put("url",url); 129 | return ServerResponse.createBySuccess(fileMap); 130 | } 131 | return ServerResponse.createByErrorMessage("操作权限不够"); 132 | } 133 | //富文本上传 134 | @RequestMapping("richtext_img_upload.do") 135 | public Map RichtextImgUpload(HttpSession session, @RequestParam(value="upload_file",required = false) MultipartFile file, HttpServletRequest request, HttpServletResponse response){ 136 | Map resultMap = Maps.newHashMap(); 137 | User user = (User)session.getAttribute(Const.CURRENT_USER); 138 | if(user == null) { 139 | resultMap.put("success",false); 140 | resultMap.put("msg","请登陆管理员"); 141 | return resultMap; 142 | } 143 | //富文本对于返回值有自己的要求,我们使用的是simditor,所以按照simditor的要求进行返回 144 | // { 145 | // "success": true/false, 146 | // "msg": "error message", # optional 147 | // "file_path": "[real file path]" 148 | // } 149 | if(iUserService.checkAdminRole(user).isSuccess()){ 150 | String path = request.getSession().getServletContext().getRealPath("upload"); 151 | String targetFileName = iFileService.upload(file,path); 152 | if(StringUtils.isBlank(targetFileName)){ 153 | resultMap.put("success",false); 154 | resultMap.put("msg","上传失败"); 155 | return resultMap; 156 | } 157 | String url = PropertiesUtil.getProperty("ftp.server.http.prefix")+targetFileName; 158 | resultMap.put("success",true); 159 | resultMap.put("msg","上传成功"); 160 | resultMap.put("file_path",url); 161 | response.addHeader("Access-Control-Allow-Headers","X-File-Name"); 162 | return resultMap; 163 | }else{ 164 | resultMap.put("success",false); 165 | resultMap.put("msg","用户权限不够"); 166 | return resultMap; 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/controller/backend/UserManageController.java: -------------------------------------------------------------------------------- 1 | package com.mmall.controller.backend; 2 | 3 | import com.mmall.common.Const; 4 | import com.mmall.common.ServerResponse; 5 | import com.mmall.pojo.User; 6 | import com.mmall.service.IUserService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | import javax.servlet.http.HttpSession; 13 | 14 | /** 15 | * @Classname UserManageController 16 | * @Description TODO 17 | * @Date 2019/1/27 17:28 18 | * @Created by oyj 19 | */ 20 | 21 | @RestController 22 | @RequestMapping("/manage/user") 23 | public class UserManageController { 24 | @Autowired 25 | private IUserService iUserService; 26 | 27 | //后台管理员登陆 28 | @RequestMapping(value="login.do",method = RequestMethod.POST) 29 | public ServerResponse login(String username, String password, HttpSession session) { 30 | ServerResponse response = iUserService.login(username, password); 31 | //登陆成功,将用户信息存储在session中 32 | if(response.isSuccess()) { 33 | User user = response.getData(); 34 | if(user.getRole() == Const.Role.ROLE_ADMIN){ 35 | //说明登陆的是管理员 36 | session.setAttribute(Const.CURRENT_USER,user); 37 | return response; 38 | }else{ 39 | return ServerResponse.createByErrorMessage("不是管理员,无法登陆"); 40 | } 41 | } 42 | //不能存在该用户,登陆失败 43 | return response; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/controller/portal/CartController.java: -------------------------------------------------------------------------------- 1 | package com.mmall.controller.portal; 2 | 3 | import com.mmall.common.Const; 4 | import com.mmall.common.ResponseCode; 5 | import com.mmall.common.ServerResponse; 6 | import com.mmall.pojo.User; 7 | import com.mmall.service.ICartService; 8 | import com.mmall.vo.CartVo; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import javax.servlet.http.HttpSession; 14 | 15 | /** 16 | * @Classname CartController 17 | * @Description 购物车模块 18 | * @Date 2019/3/23 19:41 19 | * @Created by oyj 20 | */ 21 | @RestController 22 | @RequestMapping("/cart/") 23 | public class CartController { 24 | @Autowired 25 | private ICartService iCartService; 26 | 27 | @RequestMapping("add.do") 28 | public ServerResponse add(HttpSession session, Integer count, Integer productId){ 29 | User user = (User)session.getAttribute(Const.CURRENT_USER); 30 | if(user == null ){ 31 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 32 | } 33 | return iCartService.add(user.getId(),productId,count); 34 | } 35 | @RequestMapping("update.do") 36 | public ServerResponse update(HttpSession session, Integer count, Integer productId){ 37 | User user = (User)session.getAttribute(Const.CURRENT_USER); 38 | if(user == null ){ 39 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 40 | } 41 | return iCartService.update(user.getId(),productId,count); 42 | } 43 | 44 | @RequestMapping("delete_product.do") 45 | //删除购物车商品,与前端的的约定,用字符串保存多个productId,且使用逗号隔离 46 | public ServerResponse deleteProduct(HttpSession session, String productIds){ 47 | User user = (User)session.getAttribute(Const.CURRENT_USER); 48 | if(user == null ){ 49 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 50 | } 51 | return iCartService.deleteProduct(user.getId(),productIds); 52 | } 53 | 54 | 55 | @RequestMapping("list.do") 56 | public ServerResponse list(HttpSession session){ 57 | User user = (User)session.getAttribute(Const.CURRENT_USER); 58 | if(user == null ){ 59 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 60 | } 61 | return iCartService.list(user.getId()); 62 | } 63 | 64 | //全选 65 | @RequestMapping("select_all.do") 66 | public ServerResponse selectAll(HttpSession session){ 67 | User user = (User)session.getAttribute(Const.CURRENT_USER); 68 | if(user == null){ 69 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 70 | } 71 | return iCartService.selectOrUnSelect(user.getId(),null,Const.Cart.CHECKED); 72 | } 73 | 74 | //全反选 75 | @RequestMapping("un_select_all.do") 76 | public ServerResponse UnSelectAll(HttpSession session){ 77 | User user = (User)session.getAttribute(Const.CURRENT_USER); 78 | if(user == null){ 79 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 80 | } 81 | return iCartService.selectOrUnSelect(user.getId(),null,Const.Cart.UN_CHECKED); 82 | } 83 | 84 | //单独选 85 | @RequestMapping("select.do") 86 | public ServerResponse select(HttpSession session,Integer productId){ 87 | User user = (User)session.getAttribute(Const.CURRENT_USER); 88 | if(user == null){ 89 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 90 | } 91 | return iCartService.selectOrUnSelect(user.getId(),productId,Const.Cart.CHECKED); 92 | } 93 | 94 | //单独反选,计算除了productId之外的购物车商品 95 | @RequestMapping("un_select.do") 96 | public ServerResponse UnSelect(HttpSession session,Integer productId){ 97 | User user = (User)session.getAttribute(Const.CURRENT_USER); 98 | if(user == null){ 99 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 100 | } 101 | return iCartService.selectOrUnSelect(user.getId(),productId,Const.Cart.UN_CHECKED); 102 | } 103 | //查询当前用户的购物车里面的产品数量,如果一个产品有10个,数量就是10 104 | @RequestMapping("get_cart_product_count.do") 105 | public ServerResponse getCartProductCount(HttpSession session){ 106 | User user = (User)session.getAttribute(Const.CURRENT_USER); 107 | if(user == null){ 108 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 109 | } 110 | return iCartService.getCartProductCount(user.getId()); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/controller/portal/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.mmall.controller.portal; 2 | 3 | import com.alipay.api.AlipayApiException; 4 | import com.alipay.api.internal.util.AlipaySignature; 5 | import com.alipay.demo.trade.config.Configs; 6 | import com.google.common.collect.Maps; 7 | import com.mmall.common.Const; 8 | import com.mmall.common.ResponseCode; 9 | import com.mmall.common.ServerResponse; 10 | import com.mmall.pojo.Order; 11 | import com.mmall.pojo.OrderItem; 12 | import com.mmall.pojo.User; 13 | import com.mmall.service.IOrderService; 14 | import com.mmall.vo.OrderVo; 15 | import org.slf4j.Logger; 16 | import org.slf4j.LoggerFactory; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.stereotype.Controller; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.bind.annotation.RequestParam; 21 | import org.springframework.web.bind.annotation.ResponseBody; 22 | 23 | import javax.servlet.http.HttpServletRequest; 24 | import javax.servlet.http.HttpSession; 25 | import java.util.Iterator; 26 | import java.util.List; 27 | import java.util.Map; 28 | 29 | /** 30 | * Created by oyj 31 | */ 32 | 33 | @Controller 34 | @RequestMapping("/order/") 35 | public class OrderController { 36 | 37 | private static final Logger logger = LoggerFactory.getLogger(OrderController.class); 38 | 39 | @Autowired 40 | private IOrderService iOrderService; 41 | 42 | //创建订单 43 | @RequestMapping("create.do") 44 | @ResponseBody 45 | public ServerResponse create(HttpSession session, Integer shippingId){ 46 | User user = (User)session.getAttribute(Const.CURRENT_USER); 47 | if(user ==null){ 48 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 49 | } 50 | return iOrderService.createOrder(user.getId(),shippingId); 51 | } 52 | //取消订单 53 | @RequestMapping("cancel.do") 54 | @ResponseBody 55 | public ServerResponse cancel(HttpSession session, Long orderNo){ 56 | User user = (User)session.getAttribute(Const.CURRENT_USER); 57 | if(user ==null){ 58 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 59 | } 60 | return iOrderService.cancel(user.getId(),orderNo); 61 | } 62 | 63 | 64 | //获取购物车中选中的商品详情 65 | @RequestMapping("get_order_cart_product.do") 66 | @ResponseBody 67 | public ServerResponse getOrderCartProduct(HttpSession session){ 68 | User user = (User)session.getAttribute(Const.CURRENT_USER); 69 | if(user ==null){ 70 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 71 | } 72 | return iOrderService.getOrderCartProduct(user.getId()); 73 | } 74 | 75 | //查看订单详情 76 | @RequestMapping("detail.do") 77 | @ResponseBody 78 | public ServerResponse detail(HttpSession session,Long orderNo){ 79 | User user = (User)session.getAttribute(Const.CURRENT_USER); 80 | if(user ==null){ 81 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 82 | } 83 | return iOrderService.getOrderDetail(user.getId(),orderNo); 84 | } 85 | 86 | //查看订单列表 87 | @RequestMapping("list.do") 88 | @ResponseBody 89 | public ServerResponse list(HttpSession session, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum, @RequestParam(value = "pageSize",defaultValue = "10") int pageSize){ 90 | User user = (User)session.getAttribute(Const.CURRENT_USER); 91 | if(user ==null){ 92 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 93 | } 94 | return iOrderService.getOrderList(user.getId(),pageNum,pageSize); 95 | } 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | //前台调用支付的接口,返回支付二维码的ftp服务器地址,前台进行显示 111 | @RequestMapping("pay.do") 112 | @ResponseBody 113 | public ServerResponse pay(HttpSession session, Long orderNo, HttpServletRequest request) { 114 | User user = (User) session.getAttribute(Const.CURRENT_USER); 115 | if (user == null) { 116 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), ResponseCode.NEED_LOGIN.getDesc()); 117 | } 118 | String path = request.getSession().getServletContext().getRealPath("upload"); 119 | return iOrderService.pay(orderNo, user.getId(), path); 120 | } 121 | 122 | //支付宝异步回调的系统接口(异步调用即不管前台有没有扫码支付,支付宝都会调用这个回调接口,不会等着用户扫码之后才调用) 123 | //支付宝回调的信息都在request域当中 124 | @RequestMapping("alipay_callback.do") 125 | @ResponseBody 126 | public Object alipayCallback(HttpServletRequest request){ 127 | Map params = Maps.newHashMap(); 128 | 129 | Map requestParams = request.getParameterMap(); 130 | for(Iterator iter = requestParams.keySet().iterator();iter.hasNext();){ 131 | String name = (String)iter.next(); 132 | String[] values = (String[]) requestParams.get(name); 133 | String valueStr = ""; 134 | for(int i = 0 ; i queryOrderPayStatus(HttpSession session, Long orderNo){ 170 | User user = (User)session.getAttribute(Const.CURRENT_USER); 171 | if(user ==null){ 172 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),ResponseCode.NEED_LOGIN.getDesc()); 173 | } 174 | 175 | ServerResponse serverResponse = iOrderService.queryOrderPayStatus(user.getId(),orderNo); 176 | if(serverResponse.isSuccess()){ 177 | return ServerResponse.createBySuccess(true); 178 | } 179 | return ServerResponse.createBySuccess(false); 180 | } 181 | 182 | 183 | 184 | 185 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/controller/portal/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.mmall.controller.portal; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.mmall.common.ServerResponse; 5 | import com.mmall.service.IProductService; 6 | import com.mmall.vo.ProductDetailVo; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | /** 13 | * @Classname ProductController 14 | * @Description TODO 15 | * @Date 2019/3/21 22:54 16 | * @Created by oyj 17 | */ 18 | @RestController 19 | @RequestMapping("/product") 20 | public class ProductController { 21 | @Autowired 22 | private IProductService iProductService; 23 | 24 | @RequestMapping("detail.do") 25 | public ServerResponse detail(Integer productId){ 26 | return iProductService.getProductDetail(productId); 27 | } 28 | 29 | @RequestMapping("list.do") 30 | public ServerResponse list(@RequestParam(value="keyword",required = false)String keyword, 31 | @RequestParam(value="categoryId",required = false)Integer categoryId, 32 | @RequestParam(value="pageNum",defaultValue = "1") int pageNum, 33 | @RequestParam(value="pageSize",defaultValue = "10")int pageSize, 34 | @RequestParam(value="orderBy",defaultValue = "")String orderBy 35 | ){ 36 | return iProductService.getProductByKeyWordCategory(keyword,categoryId,pageNum,pageSize,orderBy); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/controller/portal/ShippingController.java: -------------------------------------------------------------------------------- 1 | package com.mmall.controller.portal; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.mmall.common.Const; 5 | import com.mmall.common.ResponseCode; 6 | import com.mmall.common.ServerResponse; 7 | import com.mmall.pojo.Shipping; 8 | import com.mmall.pojo.User; 9 | import com.mmall.service.IShippingService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestParam; 14 | import org.springframework.web.bind.annotation.ResponseBody; 15 | 16 | import javax.servlet.http.HttpSession; 17 | 18 | /** 19 | * Created by oyj 20 | */ 21 | 22 | @Controller 23 | @RequestMapping("/shipping/") 24 | public class ShippingController { 25 | @Autowired 26 | private IShippingService iShippingService; 27 | 28 | @RequestMapping("add.do") 29 | @ResponseBody 30 | public ServerResponse add(HttpSession session, Shipping shipping){ 31 | User user = (User)session.getAttribute(Const.CURRENT_USER); 32 | if(user ==null){ 33 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), ResponseCode.NEED_LOGIN.getDesc()); 34 | } 35 | return iShippingService.add(user.getId(),shipping); 36 | } 37 | 38 | 39 | @RequestMapping("del.do") 40 | @ResponseBody 41 | public ServerResponse del(HttpSession session, Integer shippingId){ 42 | User user = (User)session.getAttribute(Const.CURRENT_USER); 43 | if(user ==null){ 44 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), ResponseCode.NEED_LOGIN.getDesc()); 45 | } 46 | return iShippingService.del(user.getId(),shippingId); 47 | } 48 | 49 | @RequestMapping("update.do") 50 | @ResponseBody 51 | public ServerResponse update(HttpSession session, Shipping shipping){ 52 | User user = (User)session.getAttribute(Const.CURRENT_USER); 53 | if(user ==null){ 54 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), ResponseCode.NEED_LOGIN.getDesc()); 55 | } 56 | return iShippingService.update(user.getId(),shipping); 57 | } 58 | 59 | 60 | @RequestMapping("select.do") 61 | @ResponseBody 62 | public ServerResponse select(HttpSession session, Integer shippingId){ 63 | User user = (User)session.getAttribute(Const.CURRENT_USER); 64 | if(user ==null){ 65 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), ResponseCode.NEED_LOGIN.getDesc()); 66 | } 67 | return iShippingService.select(user.getId(),shippingId); 68 | } 69 | 70 | 71 | @RequestMapping("list.do") 72 | @ResponseBody 73 | public ServerResponse list(@RequestParam(value = "pageNum",defaultValue = "1") int pageNum, 74 | @RequestParam(value = "pageSize",defaultValue = "10")int pageSize, 75 | HttpSession session){ 76 | User user = (User)session.getAttribute(Const.CURRENT_USER); 77 | if(user ==null){ 78 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), ResponseCode.NEED_LOGIN.getDesc()); 79 | } 80 | return iShippingService.list(user.getId(),pageNum,pageSize); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/controller/portal/UserController.java: -------------------------------------------------------------------------------- 1 | package com.mmall.controller.portal; 2 | 3 | import com.mmall.common.Const; 4 | import com.mmall.common.ResponseCode; 5 | import com.mmall.common.ServerResponse; 6 | import com.mmall.pojo.User; 7 | import com.mmall.service.IUserService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | import javax.servlet.http.HttpSession; 15 | 16 | /** 17 | * @ClassName:UserController 18 | * @Description 前台用户接口 19 | * @Author oyj 20 | * @Date 2018/11/23 16:08 21 | * @Version 1.0 22 | **/ 23 | @Controller 24 | @RequestMapping("/user") 25 | public class UserController { 26 | @Autowired 27 | private IUserService iUserService; 28 | 29 | /** 30 | * 用户登陆方法 31 | * 32 | * @param username 33 | * @param password 34 | * @param session 35 | * @return 36 | */ 37 | @RequestMapping(value = "login.do", method = RequestMethod.POST) 38 | @ResponseBody 39 | //登陆接口 40 | public ServerResponse login(String username, String password, HttpSession session) { 41 | ServerResponse response = iUserService.login(username, password); 42 | //登陆成功,将用户信息存储在session中 43 | if (response.isSuccess()) { 44 | session.setAttribute(Const.CURRENT_USER, response.getData()); 45 | } 46 | return response; 47 | } 48 | //注销接口 49 | @RequestMapping(value = "logout.do", method = RequestMethod.POST) 50 | @ResponseBody 51 | public ServerResponse logout(HttpSession session) { 52 | session.removeAttribute(Const.CURRENT_USER); 53 | return ServerResponse.createBySuccess("退出登陆成功!"); 54 | } 55 | //注册接口 56 | @RequestMapping(value = "register.do", method = RequestMethod.POST) 57 | @ResponseBody 58 | public ServerResponse register(User user) { 59 | return iUserService.register(user); 60 | } 61 | 62 | //校验接口,根据type传入的类型进行不同的校验 63 | @RequestMapping(value = "checkValid.do", method = RequestMethod.POST) 64 | @ResponseBody 65 | public ServerResponse checkValid(String str, String type) { 66 | return iUserService.checkValid(str, type); 67 | } 68 | //获取用户的接口 69 | @RequestMapping(value="get_user_info.do",method = RequestMethod.POST) 70 | @ResponseBody 71 | public ServerResponse getUserInfo(HttpSession session){ 72 | User user = (User)session.getAttribute(Const.CURRENT_USER); 73 | if(user!=null){ 74 | return ServerResponse.createBySuccess(user); 75 | }else{ 76 | return ServerResponse.createByErrorMessage("用户未登录,无法获取当前用户的信息"); 77 | } 78 | } 79 | 80 | //找回密保问题接口 81 | @RequestMapping(value="forget_get_question.do",method=RequestMethod.POST) 82 | @ResponseBody 83 | public ServerResponse forgetGetQuestion(String username){ 84 | return iUserService.selectQuestion(username); 85 | } 86 | 87 | 88 | 89 | //验证用户输入的问题答案是否正确 90 | @RequestMapping(value="forget_check_answer.do",method=RequestMethod.POST) 91 | @ResponseBody 92 | public ServerResponse forgetCheckAnswer(String username,String question,String answer){ 93 | return iUserService.checkAnswer(username,question,answer); 94 | } 95 | 96 | 97 | 98 | //未登录情况下,忘记了密码。依据密保问题获取的token,重置密码 99 | @RequestMapping(value="forget_reset_password.do",method=RequestMethod.POST) 100 | @ResponseBody 101 | public ServerResponse forgetRestPassword(String username,String passwoedNew,String forgetToken){ 102 | return iUserService.forgetRestPassword(username,passwoedNew,forgetToken); 103 | } 104 | 105 | //已经登陆系统情况下,重置密码 106 | @RequestMapping(value="reset_password.do",method=RequestMethod.POST) 107 | @ResponseBody 108 | public ServerResponse resetPassword(HttpSession session,String passwordOld,String passwordNew){ 109 | User user = (User)session.getAttribute(Const.CURRENT_USER); 110 | if(user == null){ 111 | return ServerResponse.createByErrorMessage("用户未登录"); 112 | } 113 | return iUserService.resetPassword(passwordOld,passwordNew,user); 114 | } 115 | 116 | 117 | //登陆状态,更新个人用户信息接口 118 | @RequestMapping(value="update_information.do",method=RequestMethod.POST) 119 | @ResponseBody 120 | public ServerResponse update_information(HttpSession session,User user){ 121 | User currentUser = (User)session.getAttribute(Const.CURRENT_USER); 122 | if(currentUser == null){ 123 | return ServerResponse.createByErrorMessage("用户未登录"); 124 | } 125 | //只有在登陆状态下才能更新该用户信息 126 | user.setId(currentUser.getId()); 127 | user.setUsername(currentUser.getUsername()); 128 | ServerResponse response = iUserService.updateInformation(user); 129 | if(response.isSuccess()){ 130 | session.setAttribute(Const.CURRENT_USER,response.getData()); 131 | } 132 | return response; 133 | } 134 | 135 | //查询个人用户信息 136 | @RequestMapping(value="get_information.do",method=RequestMethod.POST) 137 | @ResponseBody 138 | public ServerResponse get_information(HttpSession session){ 139 | User currentUser = (User)session.getAttribute(Const.CURRENT_USER); 140 | if(currentUser == null){ 141 | return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"未登录,需要强制登录status=10"); 142 | } 143 | return iUserService.getInformation(currentUser.getId()); 144 | } 145 | 146 | } 147 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/CartMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.Cart; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.List; 7 | 8 | public interface CartMapper { 9 | int deleteByPrimaryKey(Integer id); 10 | 11 | int insert(Cart record); 12 | 13 | int insertSelective(Cart record); 14 | 15 | Cart selectByPrimaryKey(Integer id); 16 | 17 | int updateByPrimaryKeySelective(Cart record); 18 | 19 | int updateByPrimaryKey(Cart record); 20 | 21 | Cart selectCartByUserIdProductId(@Param("userId") Integer userId,@Param("productId") Integer productId); 22 | 23 | List selectCartByUserId(Integer userId); 24 | 25 | int selectCartProductCheckedStatusByUserId(Integer userId); 26 | 27 | int deleteByUserIdProductIds(@Param("userId")Integer userId,@Param("productListId") List productListId); 28 | 29 | int checkedOrUncheckedProduct(@Param("userId")Integer userId,@Param("productId") Integer productId,@Param("checked")Integer checked); 30 | 31 | int selectCartProductCount(@Param("userId")Integer userId); 32 | 33 | List selectCheckedCartByUserId(Integer userId); 34 | 35 | 36 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/CategoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.Category; 4 | 5 | import java.util.List; 6 | 7 | public interface CategoryMapper { 8 | int deleteByPrimaryKey(Integer id); 9 | 10 | int insert(Category record); 11 | 12 | int insertSelective(Category record); 13 | 14 | Category selectByPrimaryKey(Integer id); 15 | 16 | int updateByPrimaryKeySelective(Category record); 17 | 18 | int updateByPrimaryKey(Category record); 19 | 20 | List getChildrenCategoryByParentId(Integer parent_id); 21 | 22 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/OrderItemMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.OrderItem; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.List; 7 | 8 | public interface OrderItemMapper { 9 | int deleteByPrimaryKey(Integer id); 10 | 11 | int insert(OrderItem record); 12 | 13 | int insertSelective(OrderItem record); 14 | 15 | OrderItem selectByPrimaryKey(Integer id); 16 | 17 | int updateByPrimaryKeySelective(OrderItem record); 18 | 19 | int updateByPrimaryKey(OrderItem record); 20 | 21 | 22 | //查询某用户对应的某一个订单下面的商品明细 23 | List getByOrderNoUserId(@Param("orderNo")Long orderNo, @Param("userId")Integer userId); 24 | 25 | //批量插入doing的那详情 26 | void batchInsert(@Param("orderItemList") List orderItemList); 27 | List getByOrderNo(@Param("orderNo")Long orderNo); 28 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/OrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.Order; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.List; 7 | 8 | public interface OrderMapper { 9 | int deleteByPrimaryKey(Integer id); 10 | 11 | int insert(Order record); 12 | 13 | int insertSelective(Order record); 14 | 15 | Order selectByPrimaryKey(Integer id); 16 | 17 | int updateByPrimaryKeySelective(Order record); 18 | 19 | int updateByPrimaryKey(Order record); 20 | 21 | Order selectByUserIdAndOrderNo(@Param("userId")Integer userId, @Param("orderNo")Long orderNo); 22 | 23 | Order selectByOrderNo(Long orderNo); 24 | 25 | List selectByUserId(Integer userId); 26 | 27 | 28 | List selectAllOrder(); 29 | 30 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/PayInfoMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.PayInfo; 4 | 5 | public interface PayInfoMapper { 6 | int deleteByPrimaryKey(Integer id); 7 | 8 | int insert(PayInfo record); 9 | 10 | int insertSelective(PayInfo record); 11 | 12 | PayInfo selectByPrimaryKey(Integer id); 13 | 14 | int updateByPrimaryKeySelective(PayInfo record); 15 | 16 | int updateByPrimaryKey(PayInfo record); 17 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/ProductMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.Product; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.springframework.web.bind.annotation.RequestParam; 6 | 7 | import java.util.List; 8 | 9 | public interface ProductMapper { 10 | int deleteByPrimaryKey(Integer id); 11 | 12 | int insert(Product record); 13 | 14 | int insertSelective(Product record); 15 | 16 | Product selectByPrimaryKey(Integer id); 17 | 18 | int updateByPrimaryKeySelective(Product record); 19 | 20 | int updateByPrimaryKey(Product record); 21 | 22 | List selectList(); 23 | 24 | List selectByNameAndProductId(@Param("productName")String productName,@Param("productId") Integer productId ); 25 | 26 | //根据商品名,类型查询所有的商品信息 27 | List selectByNameAndCategoryIds(@Param("productName")String productName,@Param("categoryIdList") List categoryIdList); 28 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/ShippingMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.Shipping; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.List; 7 | 8 | public interface ShippingMapper { 9 | int deleteByPrimaryKey(Integer id); 10 | 11 | int insert(Shipping record); 12 | 13 | int insertSelective(Shipping record); 14 | 15 | Shipping selectByPrimaryKey(Integer id); 16 | 17 | int updateByPrimaryKeySelective(Shipping record); 18 | 19 | int updateByPrimaryKey(Shipping record); 20 | 21 | int deleteByShippingIdUserId(@Param("userId") Integer userId, @Param("shippingId") Integer shippingId); 22 | 23 | int updateByShipping(Shipping record); 24 | 25 | Shipping selectByShippingIdUserId(@Param("userId") Integer userId, @Param("shippingId") Integer shippingId); 26 | 27 | List selectByUserId(@Param("userId") Integer userId); 28 | 29 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.mmall.dao; 2 | 3 | import com.mmall.pojo.User; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | public interface UserMapper { 7 | int deleteByPrimaryKey(Integer id); 8 | 9 | int insert(User record); 10 | 11 | int insertSelective(User record); 12 | 13 | User selectByPrimaryKey(Integer id); 14 | 15 | int updateByPrimaryKeySelective(User record); 16 | 17 | int updateByPrimaryKey(User record); 18 | 19 | //检查用户名是否存在 20 | int checkUsername(String username); 21 | //进行登陆 22 | User selectLogin(@Param("username") String username, @Param("password") String password); 23 | //检查邮箱是否存在 24 | int checkEmail(String email); 25 | //返回用户的问题 26 | String selectQuestionByUsername(String username); 27 | 28 | int checkAnswer(@Param("username") String username,@Param("question")String question,@Param("answer")String answer); 29 | 30 | int updatePasswordByUsername(@Param("username") String username,@Param("passwordNew")String passwordNew); 31 | 32 | int checkPassword(@Param("password")String password,@Param("userId")Integer userId); 33 | 34 | //检查邮箱是否被使用 35 | int checkEmailByUserId(@Param("email") String email,@Param("userId") int userId); 36 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/Cart.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.util.Date; 4 | 5 | public class Cart { 6 | private Integer id; 7 | 8 | private Integer userId; 9 | 10 | private Integer productId; 11 | 12 | private Integer quantity; 13 | 14 | private Integer checked; 15 | 16 | private Date createTime; 17 | 18 | private Date updateTime; 19 | 20 | public Cart(Integer id, Integer userId, Integer productId, Integer quantity, Integer checked, Date createTime, Date updateTime) { 21 | this.id = id; 22 | this.userId = userId; 23 | this.productId = productId; 24 | this.quantity = quantity; 25 | this.checked = checked; 26 | this.createTime = createTime; 27 | this.updateTime = updateTime; 28 | } 29 | 30 | public Cart() { 31 | super(); 32 | } 33 | 34 | public Integer getId() { 35 | return id; 36 | } 37 | 38 | public void setId(Integer id) { 39 | this.id = id; 40 | } 41 | 42 | public Integer getUserId() { 43 | return userId; 44 | } 45 | 46 | public void setUserId(Integer userId) { 47 | this.userId = userId; 48 | } 49 | 50 | public Integer getProductId() { 51 | return productId; 52 | } 53 | 54 | public void setProductId(Integer productId) { 55 | this.productId = productId; 56 | } 57 | 58 | public Integer getQuantity() { 59 | return quantity; 60 | } 61 | 62 | public void setQuantity(Integer quantity) { 63 | this.quantity = quantity; 64 | } 65 | 66 | public Integer getChecked() { 67 | return checked; 68 | } 69 | 70 | public void setChecked(Integer checked) { 71 | this.checked = checked; 72 | } 73 | 74 | public Date getCreateTime() { 75 | return createTime; 76 | } 77 | 78 | public void setCreateTime(Date createTime) { 79 | this.createTime = createTime; 80 | } 81 | 82 | public Date getUpdateTime() { 83 | return updateTime; 84 | } 85 | 86 | public void setUpdateTime(Date updateTime) { 87 | this.updateTime = updateTime; 88 | } 89 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/Category.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.util.Date; 4 | import java.util.Objects; 5 | 6 | public class Category { 7 | private Integer id; 8 | 9 | private Integer parentId; 10 | 11 | private String name; 12 | 13 | private Boolean status; 14 | 15 | private Integer sortOrder; 16 | 17 | private Date createTime; 18 | 19 | private Date updateTime; 20 | 21 | public Category(Integer id, Integer parentId, String name, Boolean status, Integer sortOrder, Date createTime, Date updateTime) { 22 | this.id = id; 23 | this.parentId = parentId; 24 | this.name = name; 25 | this.status = status; 26 | this.sortOrder = sortOrder; 27 | this.createTime = createTime; 28 | this.updateTime = updateTime; 29 | } 30 | 31 | public Category() { 32 | super(); 33 | } 34 | 35 | public Integer getId() { 36 | return id; 37 | } 38 | 39 | public void setId(Integer id) { 40 | this.id = id; 41 | } 42 | 43 | public Integer getParentId() { 44 | return parentId; 45 | } 46 | 47 | public void setParentId(Integer parentId) { 48 | this.parentId = parentId; 49 | } 50 | 51 | public String getName() { 52 | return name; 53 | } 54 | 55 | public void setName(String name) { 56 | this.name = name == null ? null : name.trim(); 57 | } 58 | 59 | public Boolean getStatus() { 60 | return status; 61 | } 62 | 63 | public void setStatus(Boolean status) { 64 | this.status = status; 65 | } 66 | 67 | public Integer getSortOrder() { 68 | return sortOrder; 69 | } 70 | 71 | public void setSortOrder(Integer sortOrder) { 72 | this.sortOrder = sortOrder; 73 | } 74 | 75 | public Date getCreateTime() { 76 | return createTime; 77 | } 78 | 79 | public void setCreateTime(Date createTime) { 80 | this.createTime = createTime; 81 | } 82 | 83 | public Date getUpdateTime() { 84 | return updateTime; 85 | } 86 | 87 | public void setUpdateTime(Date updateTime) { 88 | this.updateTime = updateTime; 89 | } 90 | //alt + inset 91 | 92 | @Override 93 | public boolean equals(Object o) { 94 | if (this == o) return true; 95 | if (o == null || getClass() != o.getClass()) return false; 96 | Category category = (Category) o; 97 | return id.equals(category.id); 98 | } 99 | 100 | @Override 101 | public int hashCode() { 102 | return Objects.hash(id); 103 | } 104 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/Order.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | 6 | public class Order { 7 | private Integer id; 8 | 9 | private Long orderNo; 10 | 11 | private Integer userId; 12 | 13 | private Integer shippingId; 14 | 15 | private BigDecimal payment; 16 | 17 | private Integer paymentType; 18 | 19 | private Integer postage; 20 | 21 | private Integer status; 22 | 23 | private Date paymentTime; 24 | 25 | private Date sendTime; 26 | 27 | private Date endTime; 28 | 29 | private Date closeTime; 30 | 31 | private Date createTime; 32 | 33 | private Date updateTime; 34 | 35 | public Order(Integer id, Long orderNo, Integer userId, Integer shippingId, BigDecimal payment, Integer paymentType, Integer postage, Integer status, Date paymentTime, Date sendTime, Date endTime, Date closeTime, Date createTime, Date updateTime) { 36 | this.id = id; 37 | this.orderNo = orderNo; 38 | this.userId = userId; 39 | this.shippingId = shippingId; 40 | this.payment = payment; 41 | this.paymentType = paymentType; 42 | this.postage = postage; 43 | this.status = status; 44 | this.paymentTime = paymentTime; 45 | this.sendTime = sendTime; 46 | this.endTime = endTime; 47 | this.closeTime = closeTime; 48 | this.createTime = createTime; 49 | this.updateTime = updateTime; 50 | } 51 | 52 | public Order() { 53 | super(); 54 | } 55 | 56 | public Integer getId() { 57 | return id; 58 | } 59 | 60 | public void setId(Integer id) { 61 | this.id = id; 62 | } 63 | 64 | public Long getOrderNo() { 65 | return orderNo; 66 | } 67 | 68 | public void setOrderNo(Long orderNo) { 69 | this.orderNo = orderNo; 70 | } 71 | 72 | public Integer getUserId() { 73 | return userId; 74 | } 75 | 76 | public void setUserId(Integer userId) { 77 | this.userId = userId; 78 | } 79 | 80 | public Integer getShippingId() { 81 | return shippingId; 82 | } 83 | 84 | public void setShippingId(Integer shippingId) { 85 | this.shippingId = shippingId; 86 | } 87 | 88 | public BigDecimal getPayment() { 89 | return payment; 90 | } 91 | 92 | public void setPayment(BigDecimal payment) { 93 | this.payment = payment; 94 | } 95 | 96 | public Integer getPaymentType() { 97 | return paymentType; 98 | } 99 | 100 | public void setPaymentType(Integer paymentType) { 101 | this.paymentType = paymentType; 102 | } 103 | 104 | public Integer getPostage() { 105 | return postage; 106 | } 107 | 108 | public void setPostage(Integer postage) { 109 | this.postage = postage; 110 | } 111 | 112 | public Integer getStatus() { 113 | return status; 114 | } 115 | 116 | public void setStatus(Integer status) { 117 | this.status = status; 118 | } 119 | 120 | public Date getPaymentTime() { 121 | return paymentTime; 122 | } 123 | 124 | public void setPaymentTime(Date paymentTime) { 125 | this.paymentTime = paymentTime; 126 | } 127 | 128 | public Date getSendTime() { 129 | return sendTime; 130 | } 131 | 132 | public void setSendTime(Date sendTime) { 133 | this.sendTime = sendTime; 134 | } 135 | 136 | public Date getEndTime() { 137 | return endTime; 138 | } 139 | 140 | public void setEndTime(Date endTime) { 141 | this.endTime = endTime; 142 | } 143 | 144 | public Date getCloseTime() { 145 | return closeTime; 146 | } 147 | 148 | public void setCloseTime(Date closeTime) { 149 | this.closeTime = closeTime; 150 | } 151 | 152 | public Date getCreateTime() { 153 | return createTime; 154 | } 155 | 156 | public void setCreateTime(Date createTime) { 157 | this.createTime = createTime; 158 | } 159 | 160 | public Date getUpdateTime() { 161 | return updateTime; 162 | } 163 | 164 | public void setUpdateTime(Date updateTime) { 165 | this.updateTime = updateTime; 166 | } 167 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/OrderItem.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | 6 | public class OrderItem { 7 | private Integer id; 8 | 9 | private Integer userId; 10 | 11 | private Long orderNo; 12 | 13 | private Integer productId; 14 | 15 | private String productName; 16 | 17 | private String productImage; 18 | 19 | private BigDecimal currentUnitPrice; 20 | 21 | private Integer quantity; 22 | 23 | private BigDecimal totalPrice; 24 | 25 | private Date createTime; 26 | 27 | private Date updateTime; 28 | 29 | public OrderItem(Integer id, Integer userId, Long orderNo, Integer productId, String productName, String productImage, BigDecimal currentUnitPrice, Integer quantity, BigDecimal totalPrice, Date createTime, Date updateTime) { 30 | this.id = id; 31 | this.userId = userId; 32 | this.orderNo = orderNo; 33 | this.productId = productId; 34 | this.productName = productName; 35 | this.productImage = productImage; 36 | this.currentUnitPrice = currentUnitPrice; 37 | this.quantity = quantity; 38 | this.totalPrice = totalPrice; 39 | this.createTime = createTime; 40 | this.updateTime = updateTime; 41 | } 42 | 43 | public OrderItem() { 44 | super(); 45 | } 46 | 47 | public Integer getId() { 48 | return id; 49 | } 50 | 51 | public void setId(Integer id) { 52 | this.id = id; 53 | } 54 | 55 | public Integer getUserId() { 56 | return userId; 57 | } 58 | 59 | public void setUserId(Integer userId) { 60 | this.userId = userId; 61 | } 62 | 63 | public Long getOrderNo() { 64 | return orderNo; 65 | } 66 | 67 | public void setOrderNo(Long orderNo) { 68 | this.orderNo = orderNo; 69 | } 70 | 71 | public Integer getProductId() { 72 | return productId; 73 | } 74 | 75 | public void setProductId(Integer productId) { 76 | this.productId = productId; 77 | } 78 | 79 | public String getProductName() { 80 | return productName; 81 | } 82 | 83 | public void setProductName(String productName) { 84 | this.productName = productName == null ? null : productName.trim(); 85 | } 86 | 87 | public String getProductImage() { 88 | return productImage; 89 | } 90 | 91 | public void setProductImage(String productImage) { 92 | this.productImage = productImage == null ? null : productImage.trim(); 93 | } 94 | 95 | public BigDecimal getCurrentUnitPrice() { 96 | return currentUnitPrice; 97 | } 98 | 99 | public void setCurrentUnitPrice(BigDecimal currentUnitPrice) { 100 | this.currentUnitPrice = currentUnitPrice; 101 | } 102 | 103 | public Integer getQuantity() { 104 | return quantity; 105 | } 106 | 107 | public void setQuantity(Integer quantity) { 108 | this.quantity = quantity; 109 | } 110 | 111 | public BigDecimal getTotalPrice() { 112 | return totalPrice; 113 | } 114 | 115 | public void setTotalPrice(BigDecimal totalPrice) { 116 | this.totalPrice = totalPrice; 117 | } 118 | 119 | public Date getCreateTime() { 120 | return createTime; 121 | } 122 | 123 | public void setCreateTime(Date createTime) { 124 | this.createTime = createTime; 125 | } 126 | 127 | public Date getUpdateTime() { 128 | return updateTime; 129 | } 130 | 131 | public void setUpdateTime(Date updateTime) { 132 | this.updateTime = updateTime; 133 | } 134 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/PayInfo.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.util.Date; 4 | 5 | public class PayInfo { 6 | private Integer id; 7 | 8 | private Integer userId; 9 | 10 | private Long orderNo; 11 | 12 | private Integer payPlatform; 13 | 14 | private String platformNumber; 15 | 16 | private String platformStatus; 17 | 18 | private Date createTime; 19 | 20 | private Date updateTime; 21 | 22 | public PayInfo(Integer id, Integer userId, Long orderNo, Integer payPlatform, String platformNumber, String platformStatus, Date createTime, Date updateTime) { 23 | this.id = id; 24 | this.userId = userId; 25 | this.orderNo = orderNo; 26 | this.payPlatform = payPlatform; 27 | this.platformNumber = platformNumber; 28 | this.platformStatus = platformStatus; 29 | this.createTime = createTime; 30 | this.updateTime = updateTime; 31 | } 32 | 33 | public PayInfo() { 34 | super(); 35 | } 36 | 37 | public Integer getId() { 38 | return id; 39 | } 40 | 41 | public void setId(Integer id) { 42 | this.id = id; 43 | } 44 | 45 | public Integer getUserId() { 46 | return userId; 47 | } 48 | 49 | public void setUserId(Integer userId) { 50 | this.userId = userId; 51 | } 52 | 53 | public Long getOrderNo() { 54 | return orderNo; 55 | } 56 | 57 | public void setOrderNo(Long orderNo) { 58 | this.orderNo = orderNo; 59 | } 60 | 61 | public Integer getPayPlatform() { 62 | return payPlatform; 63 | } 64 | 65 | public void setPayPlatform(Integer payPlatform) { 66 | this.payPlatform = payPlatform; 67 | } 68 | 69 | public String getPlatformNumber() { 70 | return platformNumber; 71 | } 72 | 73 | public void setPlatformNumber(String platformNumber) { 74 | this.platformNumber = platformNumber == null ? null : platformNumber.trim(); 75 | } 76 | 77 | public String getPlatformStatus() { 78 | return platformStatus; 79 | } 80 | 81 | public void setPlatformStatus(String platformStatus) { 82 | this.platformStatus = platformStatus == null ? null : platformStatus.trim(); 83 | } 84 | 85 | public Date getCreateTime() { 86 | return createTime; 87 | } 88 | 89 | public void setCreateTime(Date createTime) { 90 | this.createTime = createTime; 91 | } 92 | 93 | public Date getUpdateTime() { 94 | return updateTime; 95 | } 96 | 97 | public void setUpdateTime(Date updateTime) { 98 | this.updateTime = updateTime; 99 | } 100 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/Product.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | 6 | public class Product { 7 | private Integer id; 8 | 9 | private Integer categoryId; 10 | 11 | private String name; 12 | 13 | private String subtitle; 14 | 15 | private String mainImage; 16 | 17 | private String subImages; 18 | 19 | private String detail; 20 | 21 | private BigDecimal price; 22 | 23 | private Integer stock; 24 | 25 | private Integer status; 26 | 27 | private Date createTime; 28 | 29 | private Date updateTime; 30 | 31 | public Product(Integer id, Integer categoryId, String name, String subtitle, String mainImage, String subImages, String detail, BigDecimal price, Integer stock, Integer status, Date createTime, Date updateTime) { 32 | this.id = id; 33 | this.categoryId = categoryId; 34 | this.name = name; 35 | this.subtitle = subtitle; 36 | this.mainImage = mainImage; 37 | this.subImages = subImages; 38 | this.detail = detail; 39 | this.price = price; 40 | this.stock = stock; 41 | this.status = status; 42 | this.createTime = createTime; 43 | this.updateTime = updateTime; 44 | } 45 | 46 | public Product() { 47 | super(); 48 | } 49 | 50 | public Integer getId() { 51 | return id; 52 | } 53 | 54 | public void setId(Integer id) { 55 | this.id = id; 56 | } 57 | 58 | public Integer getCategoryId() { 59 | return categoryId; 60 | } 61 | 62 | public void setCategoryId(Integer categoryId) { 63 | this.categoryId = categoryId; 64 | } 65 | 66 | public String getName() { 67 | return name; 68 | } 69 | 70 | public void setName(String name) { 71 | this.name = name == null ? null : name.trim(); 72 | } 73 | 74 | public String getSubtitle() { 75 | return subtitle; 76 | } 77 | 78 | public void setSubtitle(String subtitle) { 79 | this.subtitle = subtitle == null ? null : subtitle.trim(); 80 | } 81 | 82 | public String getMainImage() { 83 | return mainImage; 84 | } 85 | 86 | public void setMainImage(String mainImage) { 87 | this.mainImage = mainImage == null ? null : mainImage.trim(); 88 | } 89 | 90 | public String getSubImages() { 91 | return subImages; 92 | } 93 | 94 | public void setSubImages(String subImages) { 95 | this.subImages = subImages == null ? null : subImages.trim(); 96 | } 97 | 98 | public String getDetail() { 99 | return detail; 100 | } 101 | 102 | public void setDetail(String detail) { 103 | this.detail = detail == null ? null : detail.trim(); 104 | } 105 | 106 | public BigDecimal getPrice() { 107 | return price; 108 | } 109 | 110 | public void setPrice(BigDecimal price) { 111 | this.price = price; 112 | } 113 | 114 | public Integer getStock() { 115 | return stock; 116 | } 117 | 118 | public void setStock(Integer stock) { 119 | this.stock = stock; 120 | } 121 | 122 | public Integer getStatus() { 123 | return status; 124 | } 125 | 126 | public void setStatus(Integer status) { 127 | this.status = status; 128 | } 129 | 130 | public Date getCreateTime() { 131 | return createTime; 132 | } 133 | 134 | public void setCreateTime(Date createTime) { 135 | this.createTime = createTime; 136 | } 137 | 138 | public Date getUpdateTime() { 139 | return updateTime; 140 | } 141 | 142 | public void setUpdateTime(Date updateTime) { 143 | this.updateTime = updateTime; 144 | } 145 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/Shipping.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.util.Date; 4 | 5 | public class Shipping { 6 | private Integer id; 7 | 8 | private Integer userId; 9 | 10 | private String receiverName; 11 | 12 | private String receiverPhone; 13 | 14 | private String receiverMobile; 15 | 16 | private String receiverProvince; 17 | 18 | private String receiverCity; 19 | 20 | private String receiverDistrict; 21 | 22 | private String receiverAddress; 23 | 24 | private String receiverZip; 25 | 26 | private Date createTime; 27 | 28 | private Date updateTime; 29 | 30 | public Shipping(Integer id, Integer userId, String receiverName, String receiverPhone, String receiverMobile, String receiverProvince, String receiverCity, String receiverDistrict, String receiverAddress, String receiverZip, Date createTime, Date updateTime) { 31 | this.id = id; 32 | this.userId = userId; 33 | this.receiverName = receiverName; 34 | this.receiverPhone = receiverPhone; 35 | this.receiverMobile = receiverMobile; 36 | this.receiverProvince = receiverProvince; 37 | this.receiverCity = receiverCity; 38 | this.receiverDistrict = receiverDistrict; 39 | this.receiverAddress = receiverAddress; 40 | this.receiverZip = receiverZip; 41 | this.createTime = createTime; 42 | this.updateTime = updateTime; 43 | } 44 | 45 | public Shipping() { 46 | super(); 47 | } 48 | 49 | public Integer getId() { 50 | return id; 51 | } 52 | 53 | public void setId(Integer id) { 54 | this.id = id; 55 | } 56 | 57 | public Integer getUserId() { 58 | return userId; 59 | } 60 | 61 | public void setUserId(Integer userId) { 62 | this.userId = userId; 63 | } 64 | 65 | public String getReceiverName() { 66 | return receiverName; 67 | } 68 | 69 | public void setReceiverName(String receiverName) { 70 | this.receiverName = receiverName == null ? null : receiverName.trim(); 71 | } 72 | 73 | public String getReceiverPhone() { 74 | return receiverPhone; 75 | } 76 | 77 | public void setReceiverPhone(String receiverPhone) { 78 | this.receiverPhone = receiverPhone == null ? null : receiverPhone.trim(); 79 | } 80 | 81 | public String getReceiverMobile() { 82 | return receiverMobile; 83 | } 84 | 85 | public void setReceiverMobile(String receiverMobile) { 86 | this.receiverMobile = receiverMobile == null ? null : receiverMobile.trim(); 87 | } 88 | 89 | public String getReceiverProvince() { 90 | return receiverProvince; 91 | } 92 | 93 | public void setReceiverProvince(String receiverProvince) { 94 | this.receiverProvince = receiverProvince == null ? null : receiverProvince.trim(); 95 | } 96 | 97 | public String getReceiverCity() { 98 | return receiverCity; 99 | } 100 | 101 | public void setReceiverCity(String receiverCity) { 102 | this.receiverCity = receiverCity == null ? null : receiverCity.trim(); 103 | } 104 | 105 | public String getReceiverDistrict() { 106 | return receiverDistrict; 107 | } 108 | 109 | public void setReceiverDistrict(String receiverDistrict) { 110 | this.receiverDistrict = receiverDistrict == null ? null : receiverDistrict.trim(); 111 | } 112 | 113 | public String getReceiverAddress() { 114 | return receiverAddress; 115 | } 116 | 117 | public void setReceiverAddress(String receiverAddress) { 118 | this.receiverAddress = receiverAddress == null ? null : receiverAddress.trim(); 119 | } 120 | 121 | public String getReceiverZip() { 122 | return receiverZip; 123 | } 124 | 125 | public void setReceiverZip(String receiverZip) { 126 | this.receiverZip = receiverZip == null ? null : receiverZip.trim(); 127 | } 128 | 129 | public Date getCreateTime() { 130 | return createTime; 131 | } 132 | 133 | public void setCreateTime(Date createTime) { 134 | this.createTime = createTime; 135 | } 136 | 137 | public Date getUpdateTime() { 138 | return updateTime; 139 | } 140 | 141 | public void setUpdateTime(Date updateTime) { 142 | this.updateTime = updateTime; 143 | } 144 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/pojo/User.java: -------------------------------------------------------------------------------- 1 | package com.mmall.pojo; 2 | 3 | import java.util.Date; 4 | 5 | public class User { 6 | private Integer id; 7 | 8 | private String username; 9 | 10 | private String password; 11 | 12 | private String email; 13 | 14 | private String phone; 15 | 16 | private String question; 17 | 18 | private String answer; 19 | 20 | private Integer role; 21 | 22 | private Date createTime; 23 | 24 | private Date updateTime; 25 | 26 | public User(Integer id, String username, String password, String email, String phone, String question, String answer, Integer role, Date createTime, Date updateTime) { 27 | this.id = id; 28 | this.username = username; 29 | this.password = password; 30 | this.email = email; 31 | this.phone = phone; 32 | this.question = question; 33 | this.answer = answer; 34 | this.role = role; 35 | this.createTime = createTime; 36 | this.updateTime = updateTime; 37 | } 38 | 39 | public User() { 40 | super(); 41 | } 42 | 43 | public Integer getId() { 44 | return id; 45 | } 46 | 47 | public void setId(Integer id) { 48 | this.id = id; 49 | } 50 | 51 | public String getUsername() { 52 | return username; 53 | } 54 | 55 | public void setUsername(String username) { 56 | this.username = username == null ? null : username.trim(); 57 | } 58 | 59 | public String getPassword() { 60 | return password; 61 | } 62 | 63 | public void setPassword(String password) { 64 | this.password = password == null ? null : password.trim(); 65 | } 66 | 67 | public String getEmail() { 68 | return email; 69 | } 70 | 71 | public void setEmail(String email) { 72 | this.email = email == null ? null : email.trim(); 73 | } 74 | 75 | public String getPhone() { 76 | return phone; 77 | } 78 | 79 | public void setPhone(String phone) { 80 | this.phone = phone == null ? null : phone.trim(); 81 | } 82 | 83 | public String getQuestion() { 84 | return question; 85 | } 86 | 87 | public void setQuestion(String question) { 88 | this.question = question == null ? null : question.trim(); 89 | } 90 | 91 | public String getAnswer() { 92 | return answer; 93 | } 94 | 95 | public void setAnswer(String answer) { 96 | this.answer = answer == null ? null : answer.trim(); 97 | } 98 | 99 | public Integer getRole() { 100 | return role; 101 | } 102 | 103 | public void setRole(Integer role) { 104 | this.role = role; 105 | } 106 | 107 | public Date getCreateTime() { 108 | return createTime; 109 | } 110 | 111 | public void setCreateTime(Date createTime) { 112 | this.createTime = createTime; 113 | } 114 | 115 | public Date getUpdateTime() { 116 | return updateTime; 117 | } 118 | 119 | public void setUpdateTime(Date updateTime) { 120 | this.updateTime = updateTime; 121 | } 122 | } -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/ICartService.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service; 2 | 3 | import com.mmall.common.ServerResponse; 4 | import com.mmall.vo.CartVo; 5 | 6 | /** 7 | * @Classname ICartService 8 | * @Description TODO 9 | * @Date 2019/3/23 19:47 10 | * @Created by oyj 11 | */ 12 | public interface ICartService { 13 | ServerResponse add(Integer userId,Integer productId,Integer count); 14 | ServerResponse update(Integer userId,Integer productId,Integer count); 15 | ServerResponse deleteProduct(Integer userId,String productIds); 16 | ServerResponse list(Integer userId); 17 | ServerResponse selectOrUnSelect(Integer userId,Integer productId,Integer checked); 18 | ServerResponse getCartProductCount(Integer userId); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/ICategoryService.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service; 2 | 3 | import com.mmall.common.ServerResponse; 4 | import com.mmall.pojo.Category; 5 | import java.util.List; 6 | 7 | /** 8 | * @Classname ICategoryService 9 | * @Description TODO 10 | * @Date 2019/2/16 16:07 11 | * @Created by oyj 12 | */ 13 | public interface ICategoryService { 14 | 15 | //添加品类 16 | public ServerResponse addCategory(String categoryName, Integer parentId); 17 | //修改品类名 18 | public ServerResponse updateCategoryName(Integer categoryId,String categoryName); 19 | 20 | //根据类型id查询第一层子类商品类型 21 | public ServerResponse> getChildrenCategoryByParentId(Integer categoryId); 22 | 23 | //根据父节点的categoryId,递归查询本节点以及所有子节点的id信息 24 | public ServerResponse> selectCategoryAndChildById(Integer categoryId); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/IFileService.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service; 2 | 3 | import org.springframework.web.multipart.MultipartFile; 4 | 5 | /** 6 | * @Classname IFileService 7 | * @Description 处理文件 8 | * @Date 2019/3/18 14:57 9 | * @Created by oyj 10 | */ 11 | public interface IFileService { 12 | String upload(MultipartFile file, String path); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/IOrderService.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.mmall.common.ServerResponse; 5 | import com.mmall.vo.OrderVo; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * Created by oyj 11 | */ 12 | public interface IOrderService { 13 | ServerResponse pay(Long orderNo, Integer userId, String path); 14 | public ServerResponse aliCallback(Map params); 15 | public ServerResponse queryOrderPayStatus(Integer userId,Long orderNo); 16 | 17 | public ServerResponse createOrder(Integer userId,Integer shippingId); 18 | public ServerResponse cancel(Integer userId,Long orderNo); 19 | public ServerResponse getOrderCartProduct(Integer userId); 20 | public ServerResponse getOrderDetail(Integer userId, Long orderNo); 21 | public ServerResponse getOrderList(Integer userId,int pageNum,int pageSize); 22 | 23 | 24 | 25 | public ServerResponse manageList(int pageNum,int pageSize); 26 | public ServerResponse manageDetail(Long orderNo); 27 | public ServerResponse manageSearch(Long orderNo,int pageNum,int pageSize); 28 | public ServerResponse manageSendGoods(Long orderNo); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/IProductService.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.mmall.common.ServerResponse; 5 | import com.mmall.pojo.Product; 6 | import com.mmall.vo.ProductDetailVo; 7 | 8 | /** 9 | * @Classname IProductService 10 | * @Description TODO 11 | * @Date 2019/2/26 14:31 12 | * @Created by oyj 13 | */ 14 | public interface IProductService { 15 | ServerResponse saveOrUpdateProduct(Product product); 16 | ServerResponse setSaleStatus(Integer productId,Integer status); 17 | ServerResponse manageProductDetail(Integer productId); 18 | ServerResponse getProductList(int pageNum,int pageSize); 19 | ServerResponse searchProduct(String productName, Integer productId, int pageNum, int pageSize); 20 | ServerResponse getProductDetail(Integer productId); 21 | ServerResponse getProductByKeyWordCategory(String keyword,Integer categoryId,int pageNum,int pageSize,String orderBy); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/IShippingService.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.mmall.common.ServerResponse; 5 | import com.mmall.pojo.Shipping; 6 | 7 | /** 8 | * Created by oyj 9 | */ 10 | public interface IShippingService { 11 | 12 | //添加地址 13 | ServerResponse add(Integer userId, Shipping shipping); 14 | //删除地址 15 | ServerResponse del(Integer userId, Integer shippingId); 16 | //更新地址 17 | ServerResponse update(Integer userId, Shipping shipping); 18 | //查询用户地址 19 | ServerResponse select(Integer userId, Integer shippingId); 20 | //如果用户有多个地址,查询所有的用户地址列表进行分页输出 21 | ServerResponse list(Integer userId, int pageNum, int pageSize); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/IUserService.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service; 2 | 3 | import com.mmall.common.ServerResponse; 4 | import com.mmall.pojo.User; 5 | 6 | /** 7 | * @InterfaceName:IUserService 8 | * @Description 前台用户service接口 9 | * @Author oyj 10 | * @Date 2018/11/23 16:21 11 | * @Version 1.0 12 | **/ 13 | public interface IUserService { 14 | ServerResponse login(String username, String password); 15 | ServerResponse register(User user); 16 | ServerResponse checkValid(String str,String type); 17 | ServerResponse selectQuestion(String username); 18 | ServerResponse checkAnswer (String username,String question,String answer); 19 | ServerResponse forgetRestPassword(String username,String passwoedNew,String forgetToken); 20 | ServerResponse resetPassword(String passwordOld,String passwordNew,User user); 21 | ServerResponse updateInformation(User user); 22 | ServerResponse getInformation(int userId); 23 | //判断是否为管理员 24 | ServerResponse checkAdminRole(User user); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/impl/CartServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service.impl; 2 | 3 | import com.google.common.base.Splitter; 4 | import com.google.common.collect.Lists; 5 | import com.mmall.common.Const; 6 | import com.mmall.common.ResponseCode; 7 | import com.mmall.common.ServerResponse; 8 | import com.mmall.dao.CartMapper; 9 | import com.mmall.dao.ProductMapper; 10 | import com.mmall.pojo.Cart; 11 | import com.mmall.pojo.Product; 12 | import com.mmall.service.ICartService; 13 | import com.mmall.util.BigDecimalUtil; 14 | import com.mmall.util.PropertiesUtil; 15 | import com.mmall.vo.CartProductVo; 16 | import com.mmall.vo.CartVo; 17 | import org.apache.commons.collections.CollectionUtils; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.stereotype.Service; 20 | 21 | import java.math.BigDecimal; 22 | import java.util.List; 23 | 24 | /** 25 | * @Classname CartServiceImpl 26 | * @Description TODO 27 | * @Date 2019/3/23 19:47 28 | * @Created by oyj 29 | */ 30 | @Service("iCartService") 31 | public class CartServiceImpl implements ICartService { 32 | @Autowired 33 | private CartMapper cartMapper; 34 | @Autowired 35 | private ProductMapper productMapper; 36 | 37 | public ServerResponse add(Integer userId,Integer productId,Integer count){ 38 | if(productId == null || count == null){ 39 | return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(),ResponseCode.ILLEGAL_ARGUMENT.getDesc()); 40 | } 41 | Cart cart = cartMapper.selectCartByUserIdProductId(userId, productId); 42 | if(cart == null){ 43 | //这个产品不在购物车中,需要新增一个这个产品的记录 44 | Cart cartItem = new Cart(); 45 | cartItem.setQuantity(count); 46 | cartItem.setChecked(Const.Cart.CHECKED); 47 | cartItem.setProductId(productId); 48 | cartItem.setUserId(userId); 49 | cartMapper.insert(cartItem); 50 | }else{ 51 | //这个产品已经在购物车里 52 | //如果商品已经存在,则数量进行相加 53 | count = cart.getQuantity() + count; 54 | cart.setQuantity(count); 55 | cartMapper.updateByPrimaryKeySelective(cart); 56 | } 57 | return this.list(userId); 58 | } 59 | 60 | public ServerResponse update(Integer userId,Integer productId,Integer count){ 61 | if(productId == null || count == null){ 62 | return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(),ResponseCode.ILLEGAL_ARGUMENT.getDesc()); 63 | } 64 | Cart cart = cartMapper.selectCartByUserIdProductId(userId, productId); 65 | if(cart != null){ 66 | cart.setQuantity(count); 67 | } 68 | cartMapper.updateByPrimaryKeySelective(cart); 69 | return this.list(userId); 70 | } 71 | 72 | 73 | 74 | public ServerResponse deleteProduct(Integer userId,String productIds){ 75 | List productIdList = Splitter.on(",").splitToList(productIds); 76 | if(CollectionUtils.isEmpty(productIdList)){ 77 | return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(),ResponseCode.ILLEGAL_ARGUMENT.getDesc()); 78 | } 79 | cartMapper.deleteByUserIdProductIds(userId,productIdList); 80 | return this.list(userId); 81 | } 82 | 83 | public ServerResponse list(Integer userId){ 84 | CartVo cartVo = this.getCartVoLimit(userId); 85 | return ServerResponse.createBySuccess(cartVo); 86 | } 87 | 88 | public ServerResponse selectOrUnSelect(Integer userId,Integer productId,Integer checked){ 89 | cartMapper.checkedOrUncheckedProduct(userId,productId,checked); 90 | return this.list(userId); 91 | } 92 | 93 | public ServerResponse getCartProductCount(Integer userId){ 94 | if(userId == null){ 95 | return ServerResponse.createBySuccess(0); 96 | } 97 | return ServerResponse.createBySuccess(cartMapper.selectCartProductCount(userId)); 98 | } 99 | 100 | 101 | 102 | 103 | //购物车核心方法 104 | private CartVo getCartVoLimit(Integer userId){ 105 | CartVo cartVo = new CartVo(); 106 | List cartProductVoList = Lists.newArrayList(); 107 | BigDecimal cartTotalPrice = new BigDecimal("0"); 108 | 109 | //1. Cart与product结合存在cartProductVoList的集合元素中 110 | List cartList = cartMapper.selectCartByUserId(userId); 111 | if(CollectionUtils.isNotEmpty(cartList)){ 112 | for(Cart cartItem : cartList){ 113 | CartProductVo cartProductVo = new CartProductVo(); 114 | cartProductVo.setId(cartItem.getId()); 115 | cartProductVo.setUserId(userId); 116 | cartProductVo.setProductId(cartItem.getProductId()); 117 | 118 | Product product = productMapper.selectByPrimaryKey(cartItem.getProductId()); 119 | if(product != null){ 120 | cartProductVo.setProductMainImage(product.getMainImage()); 121 | cartProductVo.setProductName(product.getName()); 122 | cartProductVo.setProductSubtitle(product.getSubtitle()); 123 | cartProductVo.setProductStatus(product.getStatus()); 124 | cartProductVo.setProductPrice(product.getPrice()); 125 | cartProductVo.setProductStock(product.getStock()); 126 | 127 | //判断库存 128 | int buyLimitCount = 0; 129 | if(product.getStock() >= cartItem.getQuantity()){ 130 | //库存充足 131 | buyLimitCount = cartItem.getQuantity(); 132 | cartProductVo.setLimitQuantity(Const.Cart.LIMIT_NUM_SUCCESS); 133 | }else{ 134 | //库存不充足 135 | buyLimitCount = product.getStock(); 136 | cartProductVo.setLimitQuantity(Const.Cart.LIMIT_NUM_FAIL); 137 | //购物车中更新有效的库存 138 | Cart cartForQuantity = new Cart(); 139 | cartForQuantity.setId(cartItem.getId()); 140 | cartForQuantity.setQuantity(buyLimitCount); 141 | cartMapper.updateByPrimaryKeySelective(cartForQuantity); 142 | } 143 | cartProductVo.setQuantity(buyLimitCount); 144 | //计算每一个产品的总价 145 | cartProductVo.setProductTotalPrice(BigDecimalUtil.mul(product.getPrice().doubleValue(),cartProductVo.getQuantity().doubleValue())); 146 | cartProductVo.setProductChecked(cartItem.getChecked()); 147 | } 148 | 149 | if(cartItem.getChecked() == Const.Cart.CHECKED){ 150 | //如果已经勾选,增加到整个的购物车总价中 151 | cartTotalPrice = BigDecimalUtil.add(cartTotalPrice.doubleValue(),cartProductVo.getProductTotalPrice().doubleValue()); 152 | } 153 | cartProductVoList.add(cartProductVo); 154 | }//for 155 | } 156 | 157 | //2. 将cartProductVoList、cartTotalPrice 存放在cartVo对象中 158 | cartVo.setCartProductVoList(cartProductVoList); 159 | cartVo.setCartTotalPrice(cartTotalPrice); 160 | cartVo.setAllChecked(this.getAllCheckedStatus(userId)); 161 | cartVo.setImageHost(PropertiesUtil.getProperty("ftp.server.http.prefix")); 162 | return cartVo; 163 | } 164 | private boolean getAllCheckedStatus(Integer userId){ 165 | if(userId == null){ 166 | return false; 167 | } 168 | return cartMapper.selectCartProductCheckedStatusByUserId(userId) == 0; 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/impl/CategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service.impl; 2 | 3 | /** 4 | * @Classname CategoryServiceImpl 5 | * @Description TODO 6 | * @Date 2019/2/16 16:25 7 | * @Created by oyj 8 | */ 9 | 10 | import com.google.common.collect.Lists; 11 | import com.google.common.collect.Sets; 12 | import com.mmall.common.ServerResponse; 13 | import com.mmall.dao.CategoryMapper; 14 | import com.mmall.pojo.Category; 15 | import com.mmall.service.ICategoryService; 16 | import org.apache.commons.collections.CollectionUtils; 17 | import org.apache.commons.lang3.StringUtils; 18 | import org.slf4j.Logger; 19 | import org.slf4j.LoggerFactory; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.stereotype.Service; 22 | 23 | import java.util.List; 24 | import java.util.Set; 25 | 26 | /** 27 | * @Classname CategoryService 28 | * @Description TODO 29 | * @Date 2019/2/16 16:07 30 | * @Created by oyj 31 | */ 32 | @Service("iCategoryService") 33 | public class CategoryServiceImpl implements ICategoryService { 34 | private Logger logger = LoggerFactory.getLogger(CategoryServiceImpl.class); 35 | @Autowired 36 | private CategoryMapper categoryMapper; 37 | public ServerResponse addCategory(String categoryName, Integer parentId){ 38 | if(parentId==null || StringUtils.isBlank(categoryName)){ 39 | ServerResponse.createByErrorMessage("商品类型参数错误"); 40 | } 41 | //添加商品类型 42 | Category category = new Category(); 43 | category.setName(categoryName); 44 | category.setParentId(parentId); 45 | category.setStatus(true); 46 | int rowCount = categoryMapper.insert(category); 47 | if(rowCount>0) { 48 | return ServerResponse.createBySuccessMessage("添加品类成功"); 49 | } 50 | return ServerResponse.createByErrorMessage("添加品类失败"); 51 | } 52 | 53 | //修改品类名 54 | public ServerResponse updateCategoryName(Integer categoryId,String categoryName){ 55 | if(categoryId==null || StringUtils.isBlank(categoryName)){ 56 | ServerResponse.createByErrorMessage("更新品类参数错误"); 57 | } 58 | //更新品类参数 59 | Category category = new Category(); 60 | category.setId(categoryId); 61 | category.setName(categoryName); 62 | int rowCount = categoryMapper.updateByPrimaryKeySelective(category); 63 | if(rowCount>0){ 64 | return ServerResponse.createBySuccessMessage("品类名更新成功"); 65 | } 66 | return ServerResponse.createBySuccessMessage("品类名更新失败"); 67 | } 68 | //根据父节点的categoryId,非递归查询所有子节点的信息 69 | public ServerResponse> getChildrenCategoryByParentId(Integer categoryId){ 70 | List categoryList = categoryMapper.getChildrenCategoryByParentId(categoryId); 71 | if(CollectionUtils.isEmpty(categoryList)){ 72 | logger.info("未找到当前分类的子分类"); 73 | } 74 | return ServerResponse.createBySuccess(categoryList); 75 | } 76 | //根据父节点的categoryId,递归查询本节点以及所有子节点的id信息 77 | public ServerResponse> selectCategoryAndChildById(Integer categoryId){ 78 | Set categorySet = Sets.newHashSet(); 79 | findChidrenCategory(categorySet,categoryId); 80 | List categoryIdList = Lists.newArrayList(); 81 | if(categoryId != null){ 82 | for(Category category : categorySet){ 83 | categoryIdList.add(category.getId()); 84 | } 85 | } 86 | return ServerResponse.createBySuccess(categoryIdList); 87 | } 88 | 89 | //递归查询孩子分类节点 90 | private Set findChidrenCategory(Set categorySet,Integer categoryId){ 91 | // 0->10000->1233 92 | Category category = categoryMapper.selectByPrimaryKey(categoryId); 93 | //如果当前节点不为空,这添加到Set集合 94 | if(category != null){ 95 | categorySet.add(category); 96 | } 97 | List childrenList = categoryMapper.getChildrenCategoryByParentId(categoryId); 98 | for(Category childCategory : childrenList){ 99 | //获取孩子节点,递归调用findChidrenCategory方法 100 | findChidrenCategory(categorySet,childCategory.getId()); 101 | } 102 | return categorySet; 103 | } 104 | } 105 | 106 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/impl/FileServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service.impl; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.mmall.service.IFileService; 5 | import com.mmall.util.FTPUtil; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.web.multipart.MultipartFile; 10 | 11 | import java.io.File; 12 | import java.io.IOException; 13 | import java.util.UUID; 14 | 15 | /** 16 | * @Classname FileServiceImpl 17 | * @Description TODO 18 | * @Date 2019/3/18 14:58 19 | * @Created by oyj 20 | */ 21 | @Service("iFileService") 22 | public class FileServiceImpl implements IFileService { 23 | private Logger logger = LoggerFactory.getLogger(FileServiceImpl.class); 24 | public String upload(MultipartFile file,String path){ 25 | String fileName = file.getOriginalFilename(); 26 | //获取上传的文件扩展名 27 | String fileExtensionName = fileName.substring(fileName.lastIndexOf(".")+1); 28 | String uploadFileName = UUID.randomUUID().toString()+"."+fileExtensionName; 29 | logger.info("开始上传文件,上传文件的文件名:{},上传的路径:{},新文件名:{}",fileName,path,uploadFileName); 30 | 31 | File fileDir = new File(path); 32 | if(!fileDir.exists()){ 33 | //对应的文件目录不存在,则创建该路径目录 34 | fileDir.setWritable(true); 35 | fileDir.mkdirs(); 36 | } 37 | //包括完整的路径名+文件名 38 | File targetFile = new File(path,uploadFileName); 39 | try { 40 | file.transferTo(targetFile); 41 | 42 | //将targetFile上传到我们的FTP服务器上 43 | FTPUtil.uploadFile(Lists.newArrayList(targetFile)); 44 | 45 | //上传完之后,删除upload下面的文件 46 | targetFile.delete(); 47 | } catch (IOException e) { 48 | logger.error("上传文件异常",e); 49 | return null; 50 | } 51 | return targetFile.getName(); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/service/impl/ShippingServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.mmall.service.impl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.google.common.collect.Maps; 6 | import com.mmall.common.ServerResponse; 7 | import com.mmall.dao.ShippingMapper; 8 | import com.mmall.pojo.Shipping; 9 | import com.mmall.service.IShippingService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | /** 17 | * Created by oyj 18 | */ 19 | @Service("iShippingService") 20 | public class ShippingServiceImpl implements IShippingService { 21 | 22 | 23 | @Autowired 24 | private ShippingMapper shippingMapper; 25 | 26 | public ServerResponse add(Integer userId, Shipping shipping){ 27 | shipping.setUserId(userId); 28 | int rowCount = shippingMapper.insert(shipping); 29 | if(rowCount > 0){ 30 | Map result = Maps.newHashMap(); 31 | result.put("shippingId",shipping.getId()); 32 | return ServerResponse.createBySuccess("新建地址成功",result); 33 | } 34 | return ServerResponse.createByErrorMessage("新建地址失败"); 35 | } 36 | 37 | public ServerResponse del(Integer userId, Integer shippingId){ 38 | int resultCount = shippingMapper.deleteByShippingIdUserId(userId,shippingId); 39 | if(resultCount > 0){ 40 | return ServerResponse.createBySuccess("删除地址成功"); 41 | } 42 | return ServerResponse.createByErrorMessage("删除地址失败"); 43 | } 44 | 45 | 46 | public ServerResponse update(Integer userId, Shipping shipping){ 47 | shipping.setUserId(userId); 48 | int rowCount = shippingMapper.updateByShipping(shipping); 49 | if(rowCount > 0){ 50 | return ServerResponse.createBySuccess("更新地址成功"); 51 | } 52 | return ServerResponse.createByErrorMessage("更新地址失败"); 53 | } 54 | 55 | public ServerResponse select(Integer userId, Integer shippingId){ 56 | Shipping shipping = shippingMapper.selectByShippingIdUserId(userId,shippingId); 57 | if(shipping == null){ 58 | return ServerResponse.createByErrorMessage("无法查询到该地址"); 59 | } 60 | return ServerResponse.createBySuccess("更新地址成功",shipping); 61 | } 62 | 63 | 64 | public ServerResponse list(Integer userId, int pageNum, int pageSize){ 65 | PageHelper.startPage(pageNum,pageSize); 66 | List shippingList = shippingMapper.selectByUserId(userId); 67 | PageInfo pageInfo = new PageInfo(shippingList); 68 | return ServerResponse.createBySuccess(pageInfo); 69 | } 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/test/BaseTest.java: -------------------------------------------------------------------------------- 1 | package com.mmall.test; 2 | import org.junit.runner.RunWith; 3 | import org.springframework.test.context.ContextConfiguration; 4 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 5 | /** 6 | * @ClassName:BaseTest 7 | * @Description TODO 8 | * @Author oyj 9 | * @Date 2018/11/24 10:40 10 | * @Version 1.0 11 | **/ 12 | @RunWith(SpringJUnit4ClassRunner.class) 13 | //告诉junit spring配置文件 14 | @ContextConfiguration("classpath:applicationContext.xml") 15 | public class BaseTest { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/test/BigDecimalTest.java: -------------------------------------------------------------------------------- 1 | package com.mmall.test; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * @Classname BigDecimalTest 7 | * @Description 浮点型商业运算中丢失精度的问题 8 | * @Date 2019/3/23 19:10 9 | * @Created by oyj 10 | */ 11 | public class BigDecimalTest { 12 | @Test 13 | public void test1(){ 14 | System.out.println(0.05+0.01); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/test/ResponseCodeTest.java: -------------------------------------------------------------------------------- 1 | package com.mmall.test; 2 | 3 | import com.mmall.common.ResponseCode; 4 | import org.junit.Test; 5 | 6 | /** 7 | * @ClassName:ResponseCodeTest 8 | * @Description 测试枚举类 9 | * @Author oyj 10 | * @Date 2018/11/24 10:42 11 | * @Version 1.0 12 | **/ 13 | public class ResponseCodeTest extends BaseTest { 14 | @Test 15 | public void test1() { 16 | ResponseCode rs1 = ResponseCode.SUCCESS; 17 | System.out.println("状态码"+rs1.getCode()); 18 | System.out.println("装态描述"+rs1.getDesc()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/util/BigDecimalUtil.java: -------------------------------------------------------------------------------- 1 | package com.mmall.util; 2 | 3 | import java.math.BigDecimal; 4 | 5 | /** 6 | * @Classname BigDecimalUtil 7 | * @Description 处理浮点型精度丢失的问题,在商业中采用BigDecimal的字符型构造器 8 | * @Date 2019/3/23 22:17 9 | * @Created by oyj 10 | */ 11 | public class BigDecimalUtil { 12 | private BigDecimalUtil(){ 13 | 14 | } 15 | public static BigDecimal add(double v1,double v2){ 16 | BigDecimal b1 = new BigDecimal(Double.toString(v1)); 17 | BigDecimal b2 = new BigDecimal(Double.toString(v2)); 18 | return b1.add(b2); 19 | } 20 | public static BigDecimal sub(double v1,double v2){ 21 | BigDecimal b1 = new BigDecimal(Double.toString(v1)); 22 | BigDecimal b2 = new BigDecimal(Double.toString(v2)); 23 | return b1.subtract(b2); 24 | } 25 | public static BigDecimal mul(double v1,double v2){ 26 | BigDecimal b1 = new BigDecimal(Double.toString(v1)); 27 | BigDecimal b2 = new BigDecimal(Double.toString(v2)); 28 | return b1.multiply(b2); 29 | } 30 | public static BigDecimal div(double v1,double v2){ 31 | BigDecimal b1 = new BigDecimal(Double.toString(v1)); 32 | BigDecimal b2 = new BigDecimal(Double.toString(v2)); 33 | return b1.divide(b2,2,BigDecimal.ROUND_HALF_UP);//四舍五入,保留两位小数,处理除不尽的情况 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/util/DataTimeUtil.java: -------------------------------------------------------------------------------- 1 | package com.mmall.util; 2 | 3 | import org.apache.commons.lang.StringUtils; 4 | import org.joda.time.DateTime; 5 | import org.joda.time.format.DateTimeFormat; 6 | import org.joda.time.format.DateTimeFormatter; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * @Classname DataTimeUtil 12 | * @Description 日期转化类 13 | * @Date 2019/3/14 16:55 14 | * @Created by oyj 15 | */ 16 | public class DataTimeUtil { 17 | 18 | //joda-time 19 | //str->Date 20 | //Date->str 21 | 22 | public static final String STANDARD_FORMAT = "yyyy-MM-dd HH:mm:ss"; 23 | 24 | 25 | public static Date strToDate(String dateTimeStr, String formatStr){ 26 | DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(formatStr); 27 | DateTime dateTime = dateTimeFormatter.parseDateTime(dateTimeStr); 28 | return dateTime.toDate(); 29 | } 30 | public static String dateToStr(Date date,String formatStr){ 31 | if(date == null){ 32 | return StringUtils.EMPTY; 33 | } 34 | DateTime dateTime = new DateTime(date); 35 | return dateTime.toString(formatStr); 36 | } 37 | 38 | public static Date strToDate(String dateTimeStr){ 39 | DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(STANDARD_FORMAT); 40 | DateTime dateTime = dateTimeFormatter.parseDateTime(dateTimeStr); 41 | return dateTime.toDate(); 42 | } 43 | public static String dateToStr(Date date){ 44 | if(date == null){ 45 | return org.apache.commons.lang3.StringUtils.EMPTY; 46 | } 47 | DateTime dateTime = new DateTime(date); 48 | return dateTime.toString(STANDARD_FORMAT); 49 | } 50 | 51 | 52 | public static void main(String[] args) { 53 | System.out.println(DataTimeUtil.dateToStr(new Date(),"yyyy-MM-dd")); 54 | System.out.println(DataTimeUtil.strToDate("2018-01-01","yyyy-MM-dd")); 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/util/FTPUtil.java: -------------------------------------------------------------------------------- 1 | package com.mmall.util; 2 | 3 | import org.apache.commons.net.ftp.FTPClient; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.io.File; 8 | import java.io.FileInputStream; 9 | import java.io.IOException; 10 | import java.util.List; 11 | 12 | /** 13 | * @Classname FTPUtil 14 | * @Description TODO 15 | * @Date 2019/3/18 15:56 16 | * @Created by oyj 17 | */ 18 | public class FTPUtil { 19 | private static final Logger logger = LoggerFactory.getLogger(FTPUtil.class); 20 | 21 | private static String ftpIp = PropertiesUtil.getProperty("ftp.server.ip"); 22 | private static String ftpUser = PropertiesUtil.getProperty("ftp.user"); 23 | private static String ftpPass = PropertiesUtil.getProperty("ftp.pass"); 24 | 25 | public FTPUtil(String ip, int port, String user, String pwd) { 26 | this.ip = ip; 27 | this.port = port; 28 | this.user = user; 29 | this.pwd = pwd; 30 | } 31 | public static boolean uploadFile(List fileList) throws IOException { 32 | FTPUtil ftpUtil = new FTPUtil(ftpIp,21,ftpUser,ftpPass); 33 | logger.info("开始连接ftp服务器"); 34 | boolean result = ftpUtil.uploadFile("img", fileList); 35 | logger.info("开始连接ftp服务器,结束上传,上传结果:{}",result); 36 | return result; 37 | } 38 | 39 | //指定的路径上传文件到FTP服务器 40 | private boolean uploadFile(String remotePath,List fileList) throws IOException{ 41 | boolean uploaded = true; 42 | FileInputStream fis = null; 43 | //连接FTP服务器 44 | if(connectServer(this.ip,this.port,this.user,this.pwd)){ 45 | try { 46 | ftpClient.changeWorkingDirectory(remotePath); 47 | ftpClient.setBufferSize(1024); 48 | ftpClient.setControlEncoding("UTF-8"); 49 | ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); 50 | ftpClient.enterLocalPassiveMode(); 51 | for(File fileItem : fileList){ 52 | fis = new FileInputStream(fileItem); 53 | ftpClient.storeFile(fileItem.getName(),fis); 54 | } 55 | } catch (IOException e) { 56 | logger.error("文件上传异常"); 57 | uploaded = false; 58 | e.printStackTrace(); 59 | }finally{ 60 | fis.close(); 61 | ftpClient.disconnect(); 62 | } 63 | } 64 | return uploaded; 65 | } 66 | 67 | //连接FTP服务器 68 | private boolean connectServer(String ip,int port,String user,String pwd){ 69 | boolean isSuccess = false; 70 | ftpClient = new FTPClient(); 71 | try { 72 | ftpClient.connect(ip); 73 | isSuccess = ftpClient.login(user,pwd); 74 | }catch (IOException e){ 75 | logger.error("连接FTP服务器异常"); 76 | } 77 | return isSuccess; 78 | } 79 | 80 | private String ip; 81 | private int port; 82 | private String user; 83 | private String pwd; 84 | private FTPClient ftpClient; 85 | 86 | public String getIp() { 87 | return ip; 88 | } 89 | 90 | public void setIp(String ip) { 91 | this.ip = ip; 92 | } 93 | 94 | public int getPort() { 95 | return port; 96 | } 97 | 98 | public void setPort(int port) { 99 | this.port = port; 100 | } 101 | 102 | public String getUser() { 103 | return user; 104 | } 105 | 106 | public void setUser(String user) { 107 | this.user = user; 108 | } 109 | 110 | public String getPwd() { 111 | return pwd; 112 | } 113 | 114 | public void setPwd(String pwd) { 115 | this.pwd = pwd; 116 | } 117 | 118 | public FTPClient getFtpClient() { 119 | return ftpClient; 120 | } 121 | 122 | public void setFtpClient(FTPClient ftpClient) { 123 | this.ftpClient = ftpClient; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/util/MD5Util.java: -------------------------------------------------------------------------------- 1 | package com.mmall.util; 2 | import java.security.MessageDigest; 3 | 4 | /** 5 | * Created by geely 6 | */ 7 | public class MD5Util { 8 | 9 | private static String byteArrayToHexString(byte b[]) { 10 | StringBuffer resultSb = new StringBuffer(); 11 | for (int i = 0; i < b.length; i++) 12 | resultSb.append(byteToHexString(b[i])); 13 | 14 | return resultSb.toString(); 15 | } 16 | 17 | private static String byteToHexString(byte b) { 18 | int n = b; 19 | if (n < 0) 20 | n += 256; 21 | int d1 = n / 16; 22 | int d2 = n % 16; 23 | return hexDigits[d1] + hexDigits[d2]; 24 | } 25 | 26 | /** 27 | * 返回大写MD5 28 | * 29 | * @param origin 30 | * @param charsetname 31 | * @return 32 | */ 33 | private static String MD5Encode(String origin, String charsetname) { 34 | String resultString = null; 35 | try { 36 | resultString = new String(origin); 37 | MessageDigest md = MessageDigest.getInstance("MD5"); 38 | if (charsetname == null || "".equals(charsetname)) 39 | resultString = byteArrayToHexString(md.digest(resultString.getBytes())); 40 | else 41 | resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname))); 42 | } catch (Exception exception) { 43 | } 44 | return resultString.toUpperCase(); 45 | } 46 | 47 | public static String MD5EncodeUtf8(String origin) { 48 | origin = origin + PropertiesUtil.getProperty("password.salt", "oyj"); 49 | return MD5Encode(origin, "utf-8"); 50 | } 51 | 52 | 53 | private static final String hexDigits[] = {"0", "1", "2", "3", "4", "5", 54 | "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"}; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/util/PropertiesUtil.java: -------------------------------------------------------------------------------- 1 | package com.mmall.util; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.io.IOException; 8 | import java.io.InputStreamReader; 9 | import java.util.Properties; 10 | 11 | /** 12 | * create by oyj 13 | * */ 14 | public class PropertiesUtil { 15 | 16 | private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class); 17 | 18 | private static Properties props; 19 | 20 | //静态代码块,用于配置的初始化 21 | static { 22 | String fileName = "mmall.properties"; 23 | props = new Properties(); 24 | try { 25 | props.load(new InputStreamReader(PropertiesUtil.class.getClassLoader().getResourceAsStream(fileName),"UTF-8")); 26 | } catch (IOException e) { 27 | logger.error("配置文件读取异常",e); 28 | } 29 | } 30 | 31 | public static String getProperty(String key){ 32 | String value = props.getProperty(key.trim()); 33 | if(StringUtils.isBlank(value)){ 34 | return null; 35 | } 36 | return value.trim(); 37 | } 38 | 39 | public static String getProperty(String key,String defaultValue){ 40 | String value = props.getProperty(key.trim()); 41 | if(StringUtils.isBlank(value)){ 42 | value = defaultValue; 43 | } 44 | return value.trim(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/vo/CartProductVo.java: -------------------------------------------------------------------------------- 1 | package com.mmall.vo; 2 | 3 | import java.math.BigDecimal; 4 | 5 | /** 6 | * @Classname CartProductVo 7 | * @Description 这是结合了产品和购物车的一个抽象对象 8 | * @Date 2019/3/23 21:35 9 | * @Created by oyj 10 | */ 11 | public class CartProductVo { 12 | private Integer id; 13 | private Integer userId; 14 | private Integer productId; 15 | private Integer quantity;//购物车中此商品的数量 16 | private String productName; 17 | private String productSubtitle; 18 | private String productMainImage; 19 | private BigDecimal productPrice; 20 | private Integer productStatus; 21 | private BigDecimal productTotalPrice; 22 | private Integer productStock; 23 | private Integer productChecked;//此商品是否勾选 24 | 25 | private String limitQuantity;//限制数量的一个返回结果 26 | 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Integer id) { 32 | this.id = id; 33 | } 34 | 35 | public Integer getUserId() { 36 | return userId; 37 | } 38 | 39 | public void setUserId(Integer userId) { 40 | this.userId = userId; 41 | } 42 | 43 | public Integer getProductId() { 44 | return productId; 45 | } 46 | 47 | public void setProductId(Integer productId) { 48 | this.productId = productId; 49 | } 50 | 51 | public Integer getQuantity() { 52 | return quantity; 53 | } 54 | 55 | public void setQuantity(Integer quantity) { 56 | this.quantity = quantity; 57 | } 58 | 59 | public String getProductName() { 60 | return productName; 61 | } 62 | 63 | public void setProductName(String productName) { 64 | this.productName = productName; 65 | } 66 | 67 | public String getProductSubtitle() { 68 | return productSubtitle; 69 | } 70 | 71 | public void setProductSubtitle(String productSubtitle) { 72 | this.productSubtitle = productSubtitle; 73 | } 74 | 75 | public String getProductMainImage() { 76 | return productMainImage; 77 | } 78 | 79 | public void setProductMainImage(String productMainImage) { 80 | this.productMainImage = productMainImage; 81 | } 82 | 83 | public BigDecimal getProductPrice() { 84 | return productPrice; 85 | } 86 | 87 | public void setProductPrice(BigDecimal productPrice) { 88 | this.productPrice = productPrice; 89 | } 90 | 91 | public Integer getProductStatus() { 92 | return productStatus; 93 | } 94 | 95 | public void setProductStatus(Integer productStatus) { 96 | this.productStatus = productStatus; 97 | } 98 | 99 | public BigDecimal getProductTotalPrice() { 100 | return productTotalPrice; 101 | } 102 | 103 | public void setProductTotalPrice(BigDecimal productTotalPrice) { 104 | this.productTotalPrice = productTotalPrice; 105 | } 106 | 107 | public Integer getProductStock() { 108 | return productStock; 109 | } 110 | 111 | public void setProductStock(Integer productStock) { 112 | this.productStock = productStock; 113 | } 114 | 115 | public Integer getProductChecked() { 116 | return productChecked; 117 | } 118 | 119 | public void setProductChecked(Integer productChecked) { 120 | this.productChecked = productChecked; 121 | } 122 | 123 | public String getLimitQuantity() { 124 | return limitQuantity; 125 | } 126 | 127 | public void setLimitQuantity(String limitQuantity) { 128 | this.limitQuantity = limitQuantity; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/vo/CartVo.java: -------------------------------------------------------------------------------- 1 | package com.mmall.vo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.List; 5 | 6 | /** 7 | * @Classname CartVo 8 | * @Description 整个购物车抽象对象 9 | * @Date 2019/3/23 21:48 10 | * @Created by oyj 11 | */ 12 | public class CartVo { 13 | List cartProductVoList; 14 | private BigDecimal cartTotalPrice; 15 | private Boolean allChecked; //是否已经都勾选 16 | private String imageHost; 17 | 18 | public List getCartProductVoList() { 19 | return cartProductVoList; 20 | } 21 | 22 | public void setCartProductVoList(List cartProductVoList) { 23 | this.cartProductVoList = cartProductVoList; 24 | } 25 | 26 | public BigDecimal getCartTotalPrice() { 27 | return cartTotalPrice; 28 | } 29 | 30 | public void setCartTotalPrice(BigDecimal cartTotalPrice) { 31 | this.cartTotalPrice = cartTotalPrice; 32 | } 33 | 34 | public Boolean getAllChecked() { 35 | return allChecked; 36 | } 37 | 38 | public void setAllChecked(Boolean allChecked) { 39 | this.allChecked = allChecked; 40 | } 41 | 42 | public String getImageHost() { 43 | return imageHost; 44 | } 45 | 46 | public void setImageHost(String imageHost) { 47 | this.imageHost = imageHost; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/vo/OrderItemVo.java: -------------------------------------------------------------------------------- 1 | package com.mmall.vo; 2 | 3 | import java.math.BigDecimal; 4 | 5 | /** 6 | * Created by oyj 7 | */ 8 | public class OrderItemVo { 9 | 10 | private Long orderNo; 11 | 12 | private Integer productId; 13 | 14 | private String productName; 15 | private String productImage; 16 | 17 | private BigDecimal currentUnitPrice; 18 | 19 | private Integer quantity; 20 | 21 | private BigDecimal totalPrice; 22 | 23 | private String createTime; 24 | 25 | public Long getOrderNo() { 26 | return orderNo; 27 | } 28 | 29 | public void setOrderNo(Long orderNo) { 30 | this.orderNo = orderNo; 31 | } 32 | 33 | public Integer getProductId() { 34 | return productId; 35 | } 36 | 37 | public void setProductId(Integer productId) { 38 | this.productId = productId; 39 | } 40 | 41 | public String getProductName() { 42 | return productName; 43 | } 44 | 45 | public void setProductName(String productName) { 46 | this.productName = productName; 47 | } 48 | 49 | public String getProductImage() { 50 | return productImage; 51 | } 52 | 53 | public void setProductImage(String productImage) { 54 | this.productImage = productImage; 55 | } 56 | 57 | public BigDecimal getCurrentUnitPrice() { 58 | return currentUnitPrice; 59 | } 60 | 61 | public void setCurrentUnitPrice(BigDecimal currentUnitPrice) { 62 | this.currentUnitPrice = currentUnitPrice; 63 | } 64 | 65 | public Integer getQuantity() { 66 | return quantity; 67 | } 68 | 69 | public void setQuantity(Integer quantity) { 70 | this.quantity = quantity; 71 | } 72 | 73 | public BigDecimal getTotalPrice() { 74 | return totalPrice; 75 | } 76 | 77 | public void setTotalPrice(BigDecimal totalPrice) { 78 | this.totalPrice = totalPrice; 79 | } 80 | 81 | public String getCreateTime() { 82 | return createTime; 83 | } 84 | 85 | public void setCreateTime(String createTime) { 86 | this.createTime = createTime; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/vo/OrderProductVo.java: -------------------------------------------------------------------------------- 1 | package com.mmall.vo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by geely 8 | */ 9 | public class OrderProductVo { 10 | private List orderItemVoList; 11 | private BigDecimal productTotalPrice; 12 | private String imageHost; 13 | 14 | public List getOrderItemVoList() { 15 | return orderItemVoList; 16 | } 17 | 18 | public void setOrderItemVoList(List orderItemVoList) { 19 | this.orderItemVoList = orderItemVoList; 20 | } 21 | 22 | public BigDecimal getProductTotalPrice() { 23 | return productTotalPrice; 24 | } 25 | 26 | public void setProductTotalPrice(BigDecimal productTotalPrice) { 27 | this.productTotalPrice = productTotalPrice; 28 | } 29 | 30 | public String getImageHost() { 31 | return imageHost; 32 | } 33 | 34 | public void setImageHost(String imageHost) { 35 | this.imageHost = imageHost; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/vo/OrderVo.java: -------------------------------------------------------------------------------- 1 | package com.mmall.vo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.List; 5 | 6 | /** 7 | * Created by geely 8 | */ 9 | public class OrderVo { 10 | 11 | private Long orderNo; 12 | 13 | private BigDecimal payment; 14 | 15 | private Integer paymentType; 16 | 17 | private String paymentTypeDesc; 18 | private Integer postage; 19 | 20 | private Integer status; 21 | 22 | 23 | private String statusDesc; 24 | 25 | private String paymentTime; 26 | 27 | private String sendTime; 28 | 29 | private String endTime; 30 | 31 | private String closeTime; 32 | 33 | private String createTime; 34 | 35 | //订单的明细 36 | private List orderItemVoList; 37 | 38 | private String imageHost; 39 | private Integer shippingId; 40 | private String receiverName; 41 | 42 | private ShippingVo shippingVo; 43 | 44 | public Long getOrderNo() { 45 | return orderNo; 46 | } 47 | 48 | public void setOrderNo(Long orderNo) { 49 | this.orderNo = orderNo; 50 | } 51 | 52 | public BigDecimal getPayment() { 53 | return payment; 54 | } 55 | 56 | public void setPayment(BigDecimal payment) { 57 | this.payment = payment; 58 | } 59 | 60 | public Integer getPaymentType() { 61 | return paymentType; 62 | } 63 | 64 | public void setPaymentType(Integer paymentType) { 65 | this.paymentType = paymentType; 66 | } 67 | 68 | public String getPaymentTypeDesc() { 69 | return paymentTypeDesc; 70 | } 71 | 72 | public void setPaymentTypeDesc(String paymentTypeDesc) { 73 | this.paymentTypeDesc = paymentTypeDesc; 74 | } 75 | 76 | public Integer getPostage() { 77 | return postage; 78 | } 79 | 80 | public void setPostage(Integer postage) { 81 | this.postage = postage; 82 | } 83 | 84 | public Integer getStatus() { 85 | return status; 86 | } 87 | 88 | public void setStatus(Integer status) { 89 | this.status = status; 90 | } 91 | 92 | public String getStatusDesc() { 93 | return statusDesc; 94 | } 95 | 96 | public void setStatusDesc(String statusDesc) { 97 | this.statusDesc = statusDesc; 98 | } 99 | 100 | public String getPaymentTime() { 101 | return paymentTime; 102 | } 103 | 104 | public void setPaymentTime(String paymentTime) { 105 | this.paymentTime = paymentTime; 106 | } 107 | 108 | public String getSendTime() { 109 | return sendTime; 110 | } 111 | 112 | public void setSendTime(String sendTime) { 113 | this.sendTime = sendTime; 114 | } 115 | 116 | public String getEndTime() { 117 | return endTime; 118 | } 119 | 120 | public void setEndTime(String endTime) { 121 | this.endTime = endTime; 122 | } 123 | 124 | public String getCloseTime() { 125 | return closeTime; 126 | } 127 | 128 | public void setCloseTime(String closeTime) { 129 | this.closeTime = closeTime; 130 | } 131 | 132 | public String getCreateTime() { 133 | return createTime; 134 | } 135 | 136 | public void setCreateTime(String createTime) { 137 | this.createTime = createTime; 138 | } 139 | 140 | public List getOrderItemVoList() { 141 | return orderItemVoList; 142 | } 143 | 144 | public void setOrderItemVoList(List orderItemVoList) { 145 | this.orderItemVoList = orderItemVoList; 146 | } 147 | 148 | public String getImageHost() { 149 | return imageHost; 150 | } 151 | 152 | public void setImageHost(String imageHost) { 153 | this.imageHost = imageHost; 154 | } 155 | 156 | public Integer getShippingId() { 157 | return shippingId; 158 | } 159 | 160 | public void setShippingId(Integer shippingId) { 161 | this.shippingId = shippingId; 162 | } 163 | 164 | public String getReceiverName() { 165 | return receiverName; 166 | } 167 | 168 | public void setReceiverName(String receiverName) { 169 | this.receiverName = receiverName; 170 | } 171 | 172 | public ShippingVo getShippingVo() { 173 | return shippingVo; 174 | } 175 | 176 | public void setShippingVo(ShippingVo shippingVo) { 177 | this.shippingVo = shippingVo; 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/vo/ProductDetailVo.java: -------------------------------------------------------------------------------- 1 | package com.mmall.vo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | 6 | /** 7 | * @Classname ProductDetailVo 8 | * @Description TODO 9 | * @Date 2019/3/14 15:23 10 | * @Created by oyj 11 | */ 12 | public class ProductDetailVo { 13 | private Integer id; 14 | 15 | private Integer categoryId; 16 | 17 | private String name; 18 | 19 | private String subtitle; 20 | 21 | private String mainImage; 22 | 23 | private String subImages; 24 | 25 | private String detail; 26 | 27 | //价格计算时,避免丢失精度 28 | private BigDecimal price; 29 | 30 | private Integer stock; 31 | 32 | private Integer status; 33 | 34 | private String createTime; 35 | 36 | private String updateTime; 37 | 38 | //图片服务器的地址 39 | private String imageHost; 40 | //商品父类型编号 41 | private Integer parentCategoryId; 42 | 43 | public Integer getId() { 44 | return id; 45 | } 46 | 47 | public void setId(Integer id) { 48 | this.id = id; 49 | } 50 | 51 | public Integer getCategoryId() { 52 | return categoryId; 53 | } 54 | 55 | public void setCategoryId(Integer categoryId) { 56 | this.categoryId = categoryId; 57 | } 58 | 59 | public String getName() { 60 | return name; 61 | } 62 | 63 | public void setName(String name) { 64 | this.name = name; 65 | } 66 | 67 | public String getSubtitle() { 68 | return subtitle; 69 | } 70 | 71 | public void setSubtitle(String subtitle) { 72 | this.subtitle = subtitle; 73 | } 74 | 75 | public String getMainImage() { 76 | return mainImage; 77 | } 78 | 79 | public void setMainImage(String mainImage) { 80 | this.mainImage = mainImage; 81 | } 82 | 83 | public String getSubImages() { 84 | return subImages; 85 | } 86 | 87 | public void setSubImages(String subImages) { 88 | this.subImages = subImages; 89 | } 90 | 91 | public String getDetail() { 92 | return detail; 93 | } 94 | 95 | public void setDetail(String detail) { 96 | this.detail = detail; 97 | } 98 | 99 | public BigDecimal getPrice() { 100 | return price; 101 | } 102 | 103 | public void setPrice(BigDecimal price) { 104 | this.price = price; 105 | } 106 | 107 | public Integer getStock() { 108 | return stock; 109 | } 110 | 111 | public void setStock(Integer stock) { 112 | this.stock = stock; 113 | } 114 | 115 | public Integer getStatus() { 116 | return status; 117 | } 118 | 119 | public void setStatus(Integer status) { 120 | this.status = status; 121 | } 122 | 123 | public String getCreateTime() { 124 | return createTime; 125 | } 126 | 127 | public void setCreateTime(String createTime) { 128 | this.createTime = createTime; 129 | } 130 | 131 | public String getUpdateTime() { 132 | return updateTime; 133 | } 134 | 135 | public void setUpdateTime(String updateTime) { 136 | this.updateTime = updateTime; 137 | } 138 | 139 | public String getImageHost() { 140 | return imageHost; 141 | } 142 | 143 | public void setImageHost(String imageHost) { 144 | this.imageHost = imageHost; 145 | } 146 | 147 | public Integer getParentCategoryId() { 148 | return parentCategoryId; 149 | } 150 | 151 | public void setParentCategoryId(Integer parentCategoryId) { 152 | this.parentCategoryId = parentCategoryId; 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/vo/ProductListVo.java: -------------------------------------------------------------------------------- 1 | package com.mmall.vo; 2 | 3 | import java.math.BigDecimal; 4 | 5 | /** 6 | * @Classname ProductListVo 7 | * @Description TODO 8 | * @Date 2019/3/17 21:54 9 | * @Created by oyj 10 | */ 11 | public class ProductListVo { 12 | private Integer id; 13 | 14 | private Integer categoryId; 15 | 16 | private String name; 17 | 18 | private String subtitle; 19 | 20 | private String mainImage; 21 | 22 | private BigDecimal price; 23 | 24 | private Integer status; 25 | 26 | private String imageHost; 27 | 28 | public Integer getId() { 29 | return id; 30 | } 31 | 32 | public void setId(Integer id) { 33 | this.id = id; 34 | } 35 | 36 | public Integer getCategoryId() { 37 | return categoryId; 38 | } 39 | 40 | public void setCategoryId(Integer categoryId) { 41 | this.categoryId = categoryId; 42 | } 43 | 44 | public String getName() { 45 | return name; 46 | } 47 | 48 | public void setName(String name) { 49 | this.name = name; 50 | } 51 | 52 | public String getSubtitle() { 53 | return subtitle; 54 | } 55 | 56 | public void setSubtitle(String subtitle) { 57 | this.subtitle = subtitle; 58 | } 59 | 60 | public String getMainImage() { 61 | return mainImage; 62 | } 63 | 64 | public void setMainImage(String mainImage) { 65 | this.mainImage = mainImage; 66 | } 67 | 68 | public BigDecimal getPrice() { 69 | return price; 70 | } 71 | 72 | public void setPrice(BigDecimal price) { 73 | this.price = price; 74 | } 75 | 76 | public Integer getStatus() { 77 | return status; 78 | } 79 | 80 | public void setStatus(Integer status) { 81 | this.status = status; 82 | } 83 | 84 | public String getImageHost() { 85 | return imageHost; 86 | } 87 | 88 | public void setImageHost(String imageHost) { 89 | this.imageHost = imageHost; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/com/mmall/vo/ShippingVo.java: -------------------------------------------------------------------------------- 1 | package com.mmall.vo; 2 | 3 | /** 4 | * Created by oyj 5 | */ 6 | public class ShippingVo { 7 | private String receiverName; 8 | 9 | private String receiverPhone; 10 | 11 | private String receiverMobile; 12 | 13 | private String receiverProvince; 14 | 15 | private String receiverCity; 16 | 17 | private String receiverDistrict; 18 | 19 | private String receiverAddress; 20 | 21 | private String receiverZip; 22 | 23 | public String getReceiverName() { 24 | return receiverName; 25 | } 26 | 27 | public void setReceiverName(String receiverName) { 28 | this.receiverName = receiverName; 29 | } 30 | 31 | public String getReceiverPhone() { 32 | return receiverPhone; 33 | } 34 | 35 | public void setReceiverPhone(String receiverPhone) { 36 | this.receiverPhone = receiverPhone; 37 | } 38 | 39 | public String getReceiverMobile() { 40 | return receiverMobile; 41 | } 42 | 43 | public void setReceiverMobile(String receiverMobile) { 44 | this.receiverMobile = receiverMobile; 45 | } 46 | 47 | public String getReceiverProvince() { 48 | return receiverProvince; 49 | } 50 | 51 | public void setReceiverProvince(String receiverProvince) { 52 | this.receiverProvince = receiverProvince; 53 | } 54 | 55 | public String getReceiverCity() { 56 | return receiverCity; 57 | } 58 | 59 | public void setReceiverCity(String receiverCity) { 60 | this.receiverCity = receiverCity; 61 | } 62 | 63 | public String getReceiverDistrict() { 64 | return receiverDistrict; 65 | } 66 | 67 | public void setReceiverDistrict(String receiverDistrict) { 68 | this.receiverDistrict = receiverDistrict; 69 | } 70 | 71 | public String getReceiverAddress() { 72 | return receiverAddress; 73 | } 74 | 75 | public void setReceiverAddress(String receiverAddress) { 76 | this.receiverAddress = receiverAddress; 77 | } 78 | 79 | public String getReceiverZip() { 80 | return receiverZip; 81 | } 82 | 83 | public void setReceiverZip(String receiverZip) { 84 | this.receiverZip = receiverZip; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/resources/applicationContext-datasource.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | classpath:datasource.properties 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 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | dialect=mysql 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/datasource.properties: -------------------------------------------------------------------------------- 1 | db.driverLocation=D:/dev/repository/mysql/mysql-connector-java/8.0.11/mysql-connector-java-8.0.11.jar 2 | db.driverClassName=com.mysql.cj.jdbc.Driver 3 | 4 | db.url=jdbc:mysql://127.0.0.1:3306/mmall_learning?characterEncoding=utf8&useSSL=false&serverTimezone=UTC 5 | db.username=root 6 | db.password=root 7 | 8 | 9 | db.initialSize = 20 10 | db.maxActive = 50 11 | db.maxIdle = 20 12 | db.minIdle = 10 13 | db.maxWait = 10 14 | db.defaultAutoCommit = true 15 | db.minEvictableIdleTimeMillis = 3600000 16 | -------------------------------------------------------------------------------- /src/main/resources/generatorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | 80 | 81 | 82 |
83 |
84 | 85 | 86 | 87 |
88 |
-------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | UTF-8 5 | 6 | [%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n 7 | 8 | 9 | DEBUG 10 | 11 | 12 | 13 | 14 | E:/oyj/malllog/mmall.log 15 | 16 | E:/oyj/malllog/mmall.log.%d{yyyy-MM-dd}.gz 17 | true 18 | 10 19 | 20 | 21 | [%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n 22 | 23 | 24 | 25 | 26 | 27 | E:/oyj/malllog/error.log 28 | 29 | E:/oyj/malllog/error.log.%d{yyyy-MM-dd}.gz 30 | true 31 | 10 32 | 33 | 34 | [%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n 35 | 36 | 37 | ERROR 38 | ACCEPT 39 | DENY 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/main/resources/mappers/CartMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id, user_id, product_id, quantity, checked, create_time, update_time 17 | 18 | 24 | 25 | delete from mmall_cart 26 | where id = #{id,jdbcType=INTEGER} 27 | 28 | 29 | insert into mmall_cart (id, user_id, product_id, 30 | quantity, checked, create_time, 31 | update_time) 32 | values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, 33 | #{quantity,jdbcType=INTEGER}, #{checked,jdbcType=INTEGER}, now(), 34 | now()) 35 | 36 | 37 | insert into mmall_cart 38 | 39 | 40 | id, 41 | 42 | 43 | user_id, 44 | 45 | 46 | product_id, 47 | 48 | 49 | quantity, 50 | 51 | 52 | checked, 53 | 54 | 55 | create_time, 56 | 57 | 58 | update_time, 59 | 60 | 61 | 62 | 63 | #{id,jdbcType=INTEGER}, 64 | 65 | 66 | #{userId,jdbcType=INTEGER}, 67 | 68 | 69 | #{productId,jdbcType=INTEGER}, 70 | 71 | 72 | #{quantity,jdbcType=INTEGER}, 73 | 74 | 75 | #{checked,jdbcType=INTEGER}, 76 | 77 | 78 | now(), 79 | 80 | 81 | now(), 82 | 83 | 84 | 85 | 86 | update mmall_cart 87 | 88 | 89 | user_id = #{userId,jdbcType=INTEGER}, 90 | 91 | 92 | product_id = #{productId,jdbcType=INTEGER}, 93 | 94 | 95 | quantity = #{quantity,jdbcType=INTEGER}, 96 | 97 | 98 | checked = #{checked,jdbcType=INTEGER}, 99 | 100 | 101 | create_time = #{createTime,jdbcType=TIMESTAMP}, 102 | 103 | 104 | update_time = now(), 105 | 106 | 107 | where id = #{id,jdbcType=INTEGER} 108 | 109 | 110 | update mmall_cart 111 | set user_id = #{userId,jdbcType=INTEGER}, 112 | product_id = #{productId,jdbcType=INTEGER}, 113 | quantity = #{quantity,jdbcType=INTEGER}, 114 | checked = #{checked,jdbcType=INTEGER}, 115 | create_time = #{createTime,jdbcType=TIMESTAMP}, 116 | update_time = now() 117 | where id = #{id,jdbcType=INTEGER} 118 | 119 | 120 | 121 | 128 | 129 | 130 | 136 | 137 | 141 | 142 | 143 | delete from mmall_cart 144 | where user_id = #{userId} 145 | 146 | and product_id in 147 | 148 | #{item} 149 | 150 | 151 | 152 | 153 | 154 | UPDATE mmall_cart 155 | set checked = #{checked},update_time = now() 156 | where user_id = #{userId} 157 | 158 | and product_id = #{productId} 159 | 160 | 161 | 162 | 165 | 166 | 173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /src/main/resources/mappers/CategoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id, parent_id, name, status, sort_order, create_time, update_time 17 | 18 | 24 | 25 | delete from mmall_category 26 | where id = #{id,jdbcType=INTEGER} 27 | 28 | 29 | insert into mmall_category (id, parent_id, name, 30 | status, sort_order, create_time, 31 | update_time) 32 | values (#{id,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 33 | #{status,jdbcType=BIT}, #{sortOrder,jdbcType=INTEGER}, now(), 34 | now()) 35 | 36 | 37 | insert into mmall_category 38 | 39 | 40 | id, 41 | 42 | 43 | parent_id, 44 | 45 | 46 | name, 47 | 48 | 49 | status, 50 | 51 | 52 | sort_order, 53 | 54 | 55 | create_time, 56 | 57 | 58 | update_time, 59 | 60 | 61 | 62 | 63 | #{id,jdbcType=INTEGER}, 64 | 65 | 66 | #{parentId,jdbcType=INTEGER}, 67 | 68 | 69 | #{name,jdbcType=VARCHAR}, 70 | 71 | 72 | #{status,jdbcType=BIT}, 73 | 74 | 75 | #{sortOrder,jdbcType=INTEGER}, 76 | 77 | 78 | now(), 79 | 80 | 81 | now(), 82 | 83 | 84 | 85 | 86 | update mmall_category 87 | 88 | 89 | parent_id = #{parentId,jdbcType=INTEGER}, 90 | 91 | 92 | name = #{name,jdbcType=VARCHAR}, 93 | 94 | 95 | status = #{status,jdbcType=BIT}, 96 | 97 | 98 | sort_order = #{sortOrder,jdbcType=INTEGER}, 99 | 100 | 101 | create_time = #{createTime,jdbcType=TIMESTAMP}, 102 | 103 | 104 | update_time = now(), 105 | 106 | 107 | where id = #{id,jdbcType=INTEGER} 108 | 109 | 110 | update mmall_category 111 | set parent_id = #{parentId,jdbcType=INTEGER}, 112 | name = #{name,jdbcType=VARCHAR}, 113 | status = #{status,jdbcType=BIT}, 114 | sort_order = #{sortOrder,jdbcType=INTEGER}, 115 | create_time = #{createTime,jdbcType=TIMESTAMP}, 116 | update_time = now() 117 | where id = #{id,jdbcType=INTEGER} 118 | 119 | 120 | 126 | -------------------------------------------------------------------------------- /src/main/resources/mappers/OrderItemMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | id, user_id, order_no, product_id, product_name, product_image, current_unit_price, 21 | quantity, total_price, create_time, update_time 22 | 23 | 29 | 30 | delete from mmall_order_item 31 | where id = #{id,jdbcType=INTEGER} 32 | 33 | 34 | insert into mmall_order_item (id, user_id, order_no, 35 | product_id, product_name, product_image, 36 | current_unit_price, quantity, total_price, 37 | create_time, update_time) 38 | values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{orderNo,jdbcType=BIGINT}, 39 | #{productId,jdbcType=INTEGER}, #{productName,jdbcType=VARCHAR}, #{productImage,jdbcType=VARCHAR}, 40 | #{currentUnitPrice,jdbcType=DECIMAL}, #{quantity,jdbcType=INTEGER}, #{totalPrice,jdbcType=DECIMAL}, 41 | now(), now()) 42 | 43 | 44 | insert into mmall_order_item 45 | 46 | 47 | id, 48 | 49 | 50 | user_id, 51 | 52 | 53 | order_no, 54 | 55 | 56 | product_id, 57 | 58 | 59 | product_name, 60 | 61 | 62 | product_image, 63 | 64 | 65 | current_unit_price, 66 | 67 | 68 | quantity, 69 | 70 | 71 | total_price, 72 | 73 | 74 | create_time, 75 | 76 | 77 | update_time, 78 | 79 | 80 | 81 | 82 | #{id,jdbcType=INTEGER}, 83 | 84 | 85 | #{userId,jdbcType=INTEGER}, 86 | 87 | 88 | #{orderNo,jdbcType=BIGINT}, 89 | 90 | 91 | #{productId,jdbcType=INTEGER}, 92 | 93 | 94 | #{productName,jdbcType=VARCHAR}, 95 | 96 | 97 | #{productImage,jdbcType=VARCHAR}, 98 | 99 | 100 | #{currentUnitPrice,jdbcType=DECIMAL}, 101 | 102 | 103 | #{quantity,jdbcType=INTEGER}, 104 | 105 | 106 | #{totalPrice,jdbcType=DECIMAL}, 107 | 108 | 109 | now(), 110 | 111 | 112 | now(), 113 | 114 | 115 | 116 | 117 | update mmall_order_item 118 | 119 | 120 | user_id = #{userId,jdbcType=INTEGER}, 121 | 122 | 123 | order_no = #{orderNo,jdbcType=BIGINT}, 124 | 125 | 126 | product_id = #{productId,jdbcType=INTEGER}, 127 | 128 | 129 | product_name = #{productName,jdbcType=VARCHAR}, 130 | 131 | 132 | product_image = #{productImage,jdbcType=VARCHAR}, 133 | 134 | 135 | current_unit_price = #{currentUnitPrice,jdbcType=DECIMAL}, 136 | 137 | 138 | quantity = #{quantity,jdbcType=INTEGER}, 139 | 140 | 141 | total_price = #{totalPrice,jdbcType=DECIMAL}, 142 | 143 | 144 | create_time = #{createTime,jdbcType=TIMESTAMP}, 145 | 146 | 147 | update_time = now(), 148 | 149 | 150 | where id = #{id,jdbcType=INTEGER} 151 | 152 | 153 | update mmall_order_item 154 | set user_id = #{userId,jdbcType=INTEGER}, 155 | order_no = #{orderNo,jdbcType=BIGINT}, 156 | product_id = #{productId,jdbcType=INTEGER}, 157 | product_name = #{productName,jdbcType=VARCHAR}, 158 | product_image = #{productImage,jdbcType=VARCHAR}, 159 | current_unit_price = #{currentUnitPrice,jdbcType=DECIMAL}, 160 | quantity = #{quantity,jdbcType=INTEGER}, 161 | total_price = #{totalPrice,jdbcType=DECIMAL}, 162 | create_time = #{createTime,jdbcType=TIMESTAMP}, 163 | update_time = now() 164 | where id = #{id,jdbcType=INTEGER} 165 | 166 | 167 | 168 | 169 | 176 | 177 | 178 | insert into mmall_order_item (id, order_no,user_id, product_id, 179 | product_name, product_image, current_unit_price, 180 | quantity, total_price, create_time, 181 | update_time) 182 | values 183 | 184 | 185 | #{item.id},#{item.orderNo},#{item.userId},#{item.productId},#{item.productName},#{item.productImage},#{item.currentUnitPrice},#{item.quantity},#{item.totalPrice},now(),now() 186 | 187 | 188 | 189 | 190 | 196 | -------------------------------------------------------------------------------- /src/main/resources/mappers/PayInfoMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | id, user_id, order_no, pay_platform, platform_number, platform_status, create_time, 18 | update_time 19 | 20 | 26 | 27 | delete from mmall_pay_info 28 | where id = #{id,jdbcType=INTEGER} 29 | 30 | 31 | insert into mmall_pay_info (id, user_id, order_no, 32 | pay_platform, platform_number, platform_status, 33 | create_time, update_time) 34 | values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{orderNo,jdbcType=BIGINT}, 35 | #{payPlatform,jdbcType=INTEGER}, #{platformNumber,jdbcType=VARCHAR}, #{platformStatus,jdbcType=VARCHAR}, 36 | now(), now()) 37 | 38 | 39 | insert into mmall_pay_info 40 | 41 | 42 | id, 43 | 44 | 45 | user_id, 46 | 47 | 48 | order_no, 49 | 50 | 51 | pay_platform, 52 | 53 | 54 | platform_number, 55 | 56 | 57 | platform_status, 58 | 59 | 60 | create_time, 61 | 62 | 63 | update_time, 64 | 65 | 66 | 67 | 68 | #{id,jdbcType=INTEGER}, 69 | 70 | 71 | #{userId,jdbcType=INTEGER}, 72 | 73 | 74 | #{orderNo,jdbcType=BIGINT}, 75 | 76 | 77 | #{payPlatform,jdbcType=INTEGER}, 78 | 79 | 80 | #{platformNumber,jdbcType=VARCHAR}, 81 | 82 | 83 | #{platformStatus,jdbcType=VARCHAR}, 84 | 85 | 86 | now(), 87 | 88 | 89 | now(), 90 | 91 | 92 | 93 | 94 | update mmall_pay_info 95 | 96 | 97 | user_id = #{userId,jdbcType=INTEGER}, 98 | 99 | 100 | order_no = #{orderNo,jdbcType=BIGINT}, 101 | 102 | 103 | pay_platform = #{payPlatform,jdbcType=INTEGER}, 104 | 105 | 106 | platform_number = #{platformNumber,jdbcType=VARCHAR}, 107 | 108 | 109 | platform_status = #{platformStatus,jdbcType=VARCHAR}, 110 | 111 | 112 | create_time = #{createTime,jdbcType=TIMESTAMP}, 113 | 114 | 115 | update_time =now(), 116 | 117 | 118 | where id = #{id,jdbcType=INTEGER} 119 | 120 | 121 | update mmall_pay_info 122 | set user_id = #{userId,jdbcType=INTEGER}, 123 | order_no = #{orderNo,jdbcType=BIGINT}, 124 | pay_platform = #{payPlatform,jdbcType=INTEGER}, 125 | platform_number = #{platformNumber,jdbcType=VARCHAR}, 126 | platform_status = #{platformStatus,jdbcType=VARCHAR}, 127 | create_time = #{createTime,jdbcType=TIMESTAMP}, 128 | update_time = now() 129 | where id = #{id,jdbcType=INTEGER} 130 | 131 | -------------------------------------------------------------------------------- /src/main/resources/mappers/ProductMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | id, category_id, name, subtitle, main_image, sub_images, detail, price, stock, status, 22 | create_time, update_time 23 | 24 | 30 | 31 | delete from mmall_product 32 | where id = #{id,jdbcType=INTEGER} 33 | 34 | 35 | insert into mmall_product (id, category_id, name, 36 | subtitle, main_image, sub_images, 37 | detail, price, stock, 38 | status, create_time, update_time 39 | ) 40 | values (#{id,jdbcType=INTEGER}, #{categoryId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 41 | #{subtitle,jdbcType=VARCHAR}, #{mainImage,jdbcType=VARCHAR}, #{subImages,jdbcType=VARCHAR}, 42 | #{detail,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{stock,jdbcType=INTEGER}, 43 | #{status,jdbcType=INTEGER}, now(), now() 44 | ) 45 | 46 | 47 | insert into mmall_product 48 | 49 | 50 | id, 51 | 52 | 53 | category_id, 54 | 55 | 56 | name, 57 | 58 | 59 | subtitle, 60 | 61 | 62 | main_image, 63 | 64 | 65 | sub_images, 66 | 67 | 68 | detail, 69 | 70 | 71 | price, 72 | 73 | 74 | stock, 75 | 76 | 77 | status, 78 | 79 | 80 | create_time, 81 | 82 | 83 | update_time, 84 | 85 | 86 | 87 | 88 | #{id,jdbcType=INTEGER}, 89 | 90 | 91 | #{categoryId,jdbcType=INTEGER}, 92 | 93 | 94 | #{name,jdbcType=VARCHAR}, 95 | 96 | 97 | #{subtitle,jdbcType=VARCHAR}, 98 | 99 | 100 | #{mainImage,jdbcType=VARCHAR}, 101 | 102 | 103 | #{subImages,jdbcType=VARCHAR}, 104 | 105 | 106 | #{detail,jdbcType=VARCHAR}, 107 | 108 | 109 | #{price,jdbcType=DECIMAL}, 110 | 111 | 112 | #{stock,jdbcType=INTEGER}, 113 | 114 | 115 | #{status,jdbcType=INTEGER}, 116 | 117 | 118 | now(), 119 | 120 | 121 | now(), 122 | 123 | 124 | 125 | 126 | update mmall_product 127 | 128 | 129 | category_id = #{categoryId,jdbcType=INTEGER}, 130 | 131 | 132 | name = #{name,jdbcType=VARCHAR}, 133 | 134 | 135 | subtitle = #{subtitle,jdbcType=VARCHAR}, 136 | 137 | 138 | main_image = #{mainImage,jdbcType=VARCHAR}, 139 | 140 | 141 | sub_images = #{subImages,jdbcType=VARCHAR}, 142 | 143 | 144 | detail = #{detail,jdbcType=VARCHAR}, 145 | 146 | 147 | price = #{price,jdbcType=DECIMAL}, 148 | 149 | 150 | stock = #{stock,jdbcType=INTEGER}, 151 | 152 | 153 | status = #{status,jdbcType=INTEGER}, 154 | 155 | 156 | create_time = #{createTime,jdbcType=TIMESTAMP}, 157 | 158 | 159 | update_time = now(), 160 | 161 | 162 | where id = #{id,jdbcType=INTEGER} 163 | 164 | 165 | update mmall_product 166 | set category_id = #{categoryId,jdbcType=INTEGER}, 167 | name = #{name,jdbcType=VARCHAR}, 168 | subtitle = #{subtitle,jdbcType=VARCHAR}, 169 | main_image = #{mainImage,jdbcType=VARCHAR}, 170 | sub_images = #{subImages,jdbcType=VARCHAR}, 171 | detail = #{detail,jdbcType=VARCHAR}, 172 | price = #{price,jdbcType=DECIMAL}, 173 | stock = #{stock,jdbcType=INTEGER}, 174 | status = #{status,jdbcType=INTEGER}, 175 | create_time = #{createTime,jdbcType=TIMESTAMP}, 176 | update_time = now() 177 | where id = #{id,jdbcType=INTEGER} 178 | 179 | 180 | 186 | 187 | 188 | 201 | 202 | 217 | -------------------------------------------------------------------------------- /src/main/resources/mappers/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | id, username, password, email, phone, question, answer, role, create_time, update_time 20 | 21 | 27 | 28 | delete from mmall_user 29 | where id = #{id,jdbcType=INTEGER} 30 | 31 | 32 | insert into mmall_user (id, username, password, 33 | email, phone, question, 34 | answer, role, create_time, 35 | update_time) 36 | values (#{id,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, 37 | #{email,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{question,jdbcType=VARCHAR}, 38 | #{answer,jdbcType=VARCHAR}, #{role,jdbcType=INTEGER}, now(), 39 | now()) 40 | 41 | 42 | insert into mmall_user 43 | 44 | 45 | id, 46 | 47 | 48 | username, 49 | 50 | 51 | password, 52 | 53 | 54 | email, 55 | 56 | 57 | phone, 58 | 59 | 60 | question, 61 | 62 | 63 | answer, 64 | 65 | 66 | role, 67 | 68 | 69 | create_time, 70 | 71 | 72 | update_time, 73 | 74 | 75 | 76 | 77 | #{id,jdbcType=INTEGER}, 78 | 79 | 80 | #{username,jdbcType=VARCHAR}, 81 | 82 | 83 | #{password,jdbcType=VARCHAR}, 84 | 85 | 86 | #{email,jdbcType=VARCHAR}, 87 | 88 | 89 | #{phone,jdbcType=VARCHAR}, 90 | 91 | 92 | #{question,jdbcType=VARCHAR}, 93 | 94 | 95 | #{answer,jdbcType=VARCHAR}, 96 | 97 | 98 | #{role,jdbcType=INTEGER}, 99 | 100 | 101 | now(), 102 | 103 | 104 | now(), 105 | 106 | 107 | 108 | 109 | update mmall_user 110 | 111 | 112 | username = #{username,jdbcType=VARCHAR}, 113 | 114 | 115 | password = #{password,jdbcType=VARCHAR}, 116 | 117 | 118 | email = #{email,jdbcType=VARCHAR}, 119 | 120 | 121 | phone = #{phone,jdbcType=VARCHAR}, 122 | 123 | 124 | question = #{question,jdbcType=VARCHAR}, 125 | 126 | 127 | answer = #{answer,jdbcType=VARCHAR}, 128 | 129 | 130 | role = #{role,jdbcType=INTEGER}, 131 | 132 | 133 | create_time = #{createTime,jdbcType=TIMESTAMP}, 134 | 135 | 136 | update_time = now(), 137 | 138 | 139 | where id = #{id,jdbcType=INTEGER} 140 | 141 | 142 | update mmall_user 143 | set username = #{username,jdbcType=VARCHAR}, 144 | password = #{password,jdbcType=VARCHAR}, 145 | email = #{email,jdbcType=VARCHAR}, 146 | phone = #{phone,jdbcType=VARCHAR}, 147 | question = #{question,jdbcType=VARCHAR}, 148 | answer = #{answer,jdbcType=VARCHAR}, 149 | role = #{role,jdbcType=INTEGER}, 150 | create_time = #{createTime,jdbcType=TIMESTAMP}, 151 | update_time = now() 152 | where id = #{id,jdbcType=INTEGER} 153 | 154 | 155 | 158 | 159 | 165 | 166 | 169 | 170 | 173 | 180 | 181 | 182 | update mmall_user 183 | set password = #{passwordNew},update_time = now() where username = #{username} 184 | 185 | 191 | 192 | 197 | 198 | -------------------------------------------------------------------------------- /src/main/resources/mmall.properties: -------------------------------------------------------------------------------- 1 | ftp.server.ip=127.0.0.1 2 | ftp.user=oyj 3 | ftp.pass=1996 4 | ftp.server.http.prefix=http://image.imooc.com:81/ 5 | 6 | alipay.callback.url=http://pj2y89.natappfree.cc/mmall/order/alipay_callback.do 7 | 8 | password.salt = geelysdafaqj23ou89ZXcj@#$@#$#@KJdjklj;D../dSF., 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/resources/zfbinfo.properties: -------------------------------------------------------------------------------- 1 | 2 | # 支付宝网关名、partnerId和appId 3 | open_api_domain = https://openapi.alipaydev.com/gateway.do 4 | mcloud_api_domain = http://mcloudmonitor.com/gateway.do 5 | pid = 2088102177845238 6 | appid = 2016092900625941 7 | 8 | # RSA私钥、公钥和支付宝公钥 9 | private_key = MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCGgXlnauh921ITKPrlQrk7QL/WBdiw8elM8GiuRGeeDx3cVguMSb3jmatloVvg8TvNqVZTZ0/AJOljskL6vW5R6B+cNQM2t3Uu7hIaCvC90zbdB3EK8zyT/V1KwRNgbxcScpcPCjX+MxwfylpcQR44Bb2tRL0KF2smPexbI8+jlyxltQCQzh4YSlvhqZMyuYvzkRftlbsNRsPcnHENTqz/SjwIiqvTJORTvfS1zCyvilj8fOoUGO3wnElV8Z2wZp1TpDh26T4Dn0dwD+w8CIqhp5C8v5IYipzAE+oJGXDEpB2m+a+pvEZtqyD7kl/2NZGSujoyT/H+J6sBlwjaCM6rAgMBAAECggEARaz6U804pEGhkZVP6sUWqRAQj/C1YGvgO9/piiSbPHB+Om5ESybD/AvVkq70pmCwZwgKVOgWkuVMFT35nmPUqw9AmK2JfaWpSWc/70etj9fC+tpo/5Ai2FKOKjQ8Ml85p2++uqbCc2zMa9dp2ZJN8h1fNUt/VaPt+IBpWIkDfa0DIrTM/JoqHQuubN70kcN/dUSGIscXY+LSAC70RZXZFI7hHkZDSFprIyG1gqc9COYpAXl4R2R/IauxJSscO52nC6mFJNYGfJHMKa5Up1mtD/5EbIJL1gsxe0x51g7XttFV3QzHQDv4UjoK9xtDFVcrAfCYaUsBDjEF6bVzogVswQKBgQDrygAJ9ky7xEThKvuoSgPPlVIDnn/R+OoOA4UqwdpCeI/EMcwSIUjrcZ7i55K9bmJS4SGmPbF292O92Y1wT1TUYxQAAK9sssZEbyhIYZ11r+jMwZyI0aKLgzyKfT5rX5oLTOvQBCBYKhN/vd5Q5H6SbRqgVX3LS/KaaWtXUzZ4YQKBgQCSCPrgKraKcXodnoQZ2iX0hpMG87hxIxCiAiKqScehaYImHm5qaOev0SvFVRWkIQgJbXLiZ6XQpYM8s5R3C+ulgON2zFy8fcu6HH4c1sYMy5gb0Sjme0Th008oFnqlEnIHzpN+MrOv9gpvl38fHm01RBNsg3XP+ALbn3PHuwKyiwKBgQDiIQQQicnlecGlQJfBOdqVxlq1ZdioAtRVREL+UpODlCQswKU57foE8x6x9ezhB2/8lDS1Pg1oTrG1bWMcBrkQR0TzC7UxxfInx4MWh6d/KolVdYkuHf6JVf9Fwf+O8kzF8atl/88VPqUcqXcAlWJeA4y5n8PYqKmuNNPhF8jxgQKBgQCAAYsWj5ouREXMTLRyjLuUWZnrEBtuYFQmDkUgi0eHfxpsG2ShtY7QmEML2Ab+NU38JYn8VuoLt+kPfkH3D+XgzteTvJLVTlcTrgIFeWVktdmBGJgHX6oDYNwTwZCDvWVi3np+tia3aK3BH0R4nI0RkbiM97Z/M2Ad7ujn/E7i/QKBgQCVJB5pp6WbVS7UzEYG3wv9/vML+c8FV/5/ATKrrFisiW6owTu3HcrODpzwwJAMBCUfTsDfdAK+NQozjBk1AKOibgQ7LfvynzXne9qHpmEIDW+FJgbkL0PvxcyyRo29b0ziZ46//NYYdheUk+HvCCUbpMO5Q4VuGNSxG3ocQgMZjg== 10 | public_key = MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhoF5Z2rofdtSEyj65UK5O0C/1gXYsPHpTPBorkRnng8d3FYLjEm945mrZaFb4PE7zalWU2dPwCTpY7JC+r1uUegfnDUDNrd1Lu4SGgrwvdM23QdxCvM8k/1dSsETYG8XEnKXDwo1/jMcH8paXEEeOAW9rUS9ChdrJj3sWyPPo5csZbUAkM4eGEpb4amTMrmL85EX7ZW7DUbD3JxxDU6s/0o8CIqr0yTkU730tcwsr4pY/HzqFBjt8JxJVfGdsGadU6Q4duk+A59HcA/sPAiKoaeQvL+SGIqcwBPqCRlwxKQdpvmvqbxGbasg+5Jf9jWRkro6Mk/x/ierAZcI2gjOqwIDAQAB 11 | 12 | #SHA1withRsa对应支付宝公钥 13 | #alipay_public_key = MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDI6d306Q8fIfCOaTXyiUeJHkrIvYISRcc73s3vF1ZT7XN8RNPwJxo8pWaJMmvyTn9N4HQ632qJBVHf8sxHi/fEsraprwCtzvzQETrNRwVxLO5jVmRGi60j8Ue1efIlzPXV9je9mkjzOmdssymZkh2QhUrCmZYI/FCEa3/cNMW0QIDAQAB 14 | 15 | #SHA256withRsa对应支付宝公钥 16 | alipay_public_key = MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAikft4CHkhiqXu2k5GkInYgyhV90cXgziUIcWrUavoOYNB70JnaaKy9nynUZRpfnlN/jH10kedN9PI3MXIxzAaNGx4XsiAf8/rbyj6SuLt3wiWmweBb0lMYsWSBbVEVzJkywuXoSW56ZxfmAJJQxRWJpzPZRi0ChW1SCQC1VMdDuLk4ahGgLbPfT+Je+YCV6xH15mYkWRIJwtZTKmD1RDKj6Z9tOTxw9jJZO4CxnIU16miSABlAS+ZaHCv92vyMHIzZouL/DWOCDoFVo8HuJqF20R2+2xF/w1KmDsYCDqWalKfNBQrSInXpfT963NByWb/0LgyFagr1YgCB25bmu72wIDAQAB 17 | 18 | # 签名类型: RSA->SHA1withRsa,RSA2->SHA256withRsa 19 | sign_type = RSA2 20 | # 当面付最大查询次数和查询间隔(毫秒) 21 | max_query_retry = 5 22 | query_duration = 5000 23 | 24 | # 当面付最大撤销次数和撤销间隔(毫秒) 25 | max_cancel_retry = 3 26 | cancel_duration = 2000 27 | 28 | # 交易保障线程第一次调度延迟和调度间隔(秒) 29 | heartbeat_delay = 5 30 | heartbeat_duration = 900 31 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/dispatcher-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | text/plain;charset=UTF-8 19 | text/html;charset=UTF-8 20 | 21 | 22 | 23 | 24 | 25 | 26 | application/json;charset=UTF-8 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/alipay-sdk-java-3.3.0-source.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/src/main/webapp/WEB-INF/lib/alipay-sdk-java-3.3.0-source.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/alipay-sdk-java-3.3.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/src/main/webapp/WEB-INF/lib/alipay-sdk-java-3.3.0.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/alipay-trade-sdk-20161215-source.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/src/main/webapp/WEB-INF/lib/alipay-trade-sdk-20161215-source.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/lib/alipay-trade-sdk-20161215.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyjcodes/mmall/01fb4ce48fc2863e2a1d63630898dc090828c7c2/src/main/webapp/WEB-INF/lib/alipay-trade-sdk-20161215.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | Archetype Created Web Application 8 | 9 | 10 | characterEncodingFilter 11 | org.springframework.web.filter.CharacterEncodingFilter 12 | 13 | encoding 14 | UTF-8 15 | 16 | 17 | forceEncoding 18 | true 19 | 20 | 21 | 22 | characterEncodingFilter 23 | /* 24 | 25 | 26 | 27 | 28 | org.springframework.web.context.request.RequestContextListener 29 | 30 | 31 | 32 | org.springframework.web.context.ContextLoaderListener 33 | 34 | 35 | contextConfigLocation 36 | 37 | classpath:applicationContext.xml 38 | 39 | 40 | 41 | 42 | dispatcher 43 | org.springframework.web.servlet.DispatcherServlet 44 | 1 45 | 46 | 47 | 48 | 49 | 50 | dispatcher 51 | *.do 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 |

Hello World!

5 |

springmvc上传文件

6 |
7 | 8 | 9 |
10 | 11 | 12 |

富文本图片上传文件

13 |
14 | 15 | 16 |
17 | 18 | 19 | --------------------------------------------------------------------------------