├── README.md ├── wechat_order_h ├── .gitignore ├── Read.md ├── doc │ ├── API.md │ └── sql ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── hhh │ │ │ └── wechat_order │ │ │ ├── VO │ │ │ ├── ProductInfoVo.java │ │ │ ├── ProductVo.java │ │ │ └── ResultVo.java │ │ │ ├── WechatOrderApplication.java │ │ │ ├── aspect │ │ │ └── SellerAuthorizeAspect.java │ │ │ ├── config │ │ │ ├── ProjectUrlConfig.java │ │ │ ├── WebSocketConfig.java │ │ │ ├── WechatAccountConfig.java │ │ │ ├── WechatMpConfig.java │ │ │ ├── WechatOpenConfig.java │ │ │ └── WechatPayConfig.java │ │ │ ├── constant │ │ │ ├── CookieConstant.java │ │ │ └── RedisConstant.java │ │ │ ├── controller │ │ │ ├── AdminUserController.java │ │ │ ├── BuyerOrderController.java │ │ │ ├── BuyerProductController.java │ │ │ ├── CommentController.java │ │ │ ├── PayController.java │ │ │ ├── PictureController.java │ │ │ ├── SellerCategoryController.java │ │ │ ├── SellerOrderController.java │ │ │ ├── SellerProductController.java │ │ │ └── UserController.java │ │ │ ├── converter │ │ │ ├── OrderForm2OrderDTOConverter.java │ │ │ └── OrderMaster2OrderDTOConverter.java │ │ │ ├── dto │ │ │ ├── CartDTO.java │ │ │ └── OrderDTO.java │ │ │ ├── entity │ │ │ ├── Comment.java │ │ │ ├── OrderDetail.java │ │ │ ├── OrderMaster.java │ │ │ ├── Picture.java │ │ │ ├── ProductCategory.java │ │ │ ├── ProductInfo.java │ │ │ ├── SellerInfo.java │ │ │ └── User.java │ │ │ ├── enums │ │ │ ├── CodeEnum.java │ │ │ ├── OrderStatusEnum.java │ │ │ ├── PayStatusEnum.java │ │ │ ├── ProductStatusEnum.java │ │ │ └── ResultEnum.java │ │ │ ├── exception │ │ │ ├── SellException.java │ │ │ └── SellerAuthorizeException.java │ │ │ ├── form │ │ │ ├── CategoryForm.java │ │ │ ├── OrderForm.java │ │ │ ├── PictureForm.java │ │ │ ├── ProductForm.java │ │ │ ├── SellerForm.java │ │ │ └── UserForm.java │ │ │ ├── handler │ │ │ └── SellerExceptionHandler.java │ │ │ ├── repository │ │ │ ├── CommentRepository.java │ │ │ ├── OrderDetailRepository.java │ │ │ ├── OrderMasterRepository.java │ │ │ ├── PictureRepository.java │ │ │ ├── ProductCategoryRepository.java │ │ │ ├── ProductInfoRepository.java │ │ │ ├── SellerInfoRepository.java │ │ │ └── UserRepository.java │ │ │ ├── service │ │ │ ├── BuyerService.java │ │ │ ├── CategoryService.java │ │ │ ├── OrderService.java │ │ │ ├── ProductService.java │ │ │ ├── SellerService.java │ │ │ ├── UserService.java │ │ │ ├── WebSocket.java │ │ │ └── impl │ │ │ │ ├── BuyerServiceImpl.java │ │ │ │ ├── CategoryServiceImpl.java │ │ │ │ ├── OrderServiceImpl.java │ │ │ │ ├── PayService.java │ │ │ │ ├── ProductServiceImpl.java │ │ │ │ ├── SellerServiceImpl.java │ │ │ │ └── UserServiceImpl.java │ │ │ └── utils │ │ │ ├── CookieUtil.java │ │ │ ├── EnumUtil.java │ │ │ ├── JsonUtil.java │ │ │ ├── KeyUtil.java │ │ │ ├── MathUtil.java │ │ │ ├── ResultVOUtil.java │ │ │ └── serializer │ │ │ ├── Date2LongSerializer.java │ │ │ └── Date2StringSerializer.java │ └── resources │ │ ├── application.yml │ │ ├── static │ │ ├── api │ │ │ ├── ratings.json │ │ │ └── seller.json │ │ ├── css │ │ │ └── style.css │ │ ├── js │ │ │ └── login.js │ │ └── mp3 │ │ │ └── song.mp3 │ │ └── templates │ │ ├── admin │ │ ├── index.ftl │ │ └── list.ftl │ │ ├── category │ │ ├── index.ftl │ │ └── list.ftl │ │ ├── common │ │ ├── error.ftl │ │ ├── header.ftl │ │ ├── loginView.ftl │ │ ├── nav.ftl │ │ └── success.ftl │ │ ├── order │ │ ├── detail.ftl │ │ ├── list.ftl │ │ └── list1.ftl │ │ ├── pay │ │ ├── create.ftl │ │ └── success.ftl │ │ ├── picture │ │ ├── index.ftl │ │ └── list.ftl │ │ └── product │ │ ├── index.ftl │ │ └── list.ftl │ └── test │ └── java │ └── com │ └── hhh │ └── wechat_order │ ├── WechatOrderApplicationTests.java │ ├── repository │ ├── OrderDetailRepositoryTest.java │ ├── OrderMasterRepositoryTest.java │ ├── ProductCategoryRepositoryTest.java │ └── ProductInfoRepositoryTest.java │ └── service │ └── impl │ ├── CategoryServiceImplTest.java │ ├── OrderServiceImplTest.java │ ├── PayServiceImplTest.java │ └── ProductServiceImplTest.java └── wechat_order_q ├── app.js ├── app.json ├── app.wxss ├── functions └── getOpenid │ ├── index.js │ └── package.json ├── image ├── 1.jpg ├── 2.jpg ├── 3.jpg ├── 4.jpg ├── 5.jpg ├── ask_no.png ├── ask_yes.png ├── cart.png ├── header.png ├── home_no.png ├── home_yes.png ├── kf.png ├── logo.jpg ├── logo1.png ├── logo2.jpg ├── logo60.png ├── mall.png ├── me_no.png ├── me_yes.png ├── news.png ├── noP.gif ├── scan.png ├── shopCart.png ├── shopart.png └── sopCart.png ├── pages ├── buy │ ├── buy.js │ ├── buy.json │ ├── buy.wxml │ └── buy.wxss ├── change │ ├── change.js │ ├── change.json │ ├── change.wxml │ └── change.wxss ├── confirmOrder │ ├── confirmOrder.js │ ├── confirmOrder.json │ ├── confirmOrder.wxml │ └── confirmOrder.wxss ├── index │ ├── index.js │ ├── index.json │ ├── index.wxml │ └── index.wxss ├── me │ ├── me.js │ ├── me.json │ ├── me.wxml │ └── me.wxss ├── myOrder │ ├── myOrder.js │ ├── myOrder.json │ ├── myOrder.wxml │ └── myOrder.wxss └── mycomment │ ├── mycomment.js │ ├── mycomment.json │ ├── mycomment.wxml │ └── mycomment.wxss ├── project.config.json ├── sitemap.json └── wxss ├── common.wxss └── weui.wxss /README.md: -------------------------------------------------------------------------------- 1 | # SpringBootAndOrder 2 | 基于SpringBoot前后端分离的点餐系统 3 | 4 | 开发环境:主要采用Spring boot框架和小程序开发 5 | 项目简介:点餐系统,分成卖家端和买家端。买家端使用微信小程序开发,实现扫码点餐、浏览菜单、下单、评论的功能。而卖家端则是使用Web网站开发,主要实现商品类目的管理、商品的管理、前端页面的轮播图替换、订单的取消、完结功能、卖家的登录功能等。 6 | 7 | 后端主要用到的技术: 8 | JDK8、MySql、SpringBoot、Spring—data-jpa、Lombok、Freemarker、Bootstrap、WebSocket 9 | 前端主要用到的技术: 10 | 微信小程序开发 11 | 12 | 由于本人没有商家号,微信支付功能并没有完善。 13 | 14 | 此点餐系统还在不断的完善中... 15 | 16 | 此点餐系统的详细讲解在:https://www.cnblogs.com/HHHY/p/11787174.html 17 | 18 | 19 | -------------------------------------------------------------------------------- /wechat_order_h/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /wechat_order_h/Read.md: -------------------------------------------------------------------------------- 1 | **点餐系统** 2 | 3 | -------------------------------------------------------------------------------- /wechat_order_h/doc/API.md: -------------------------------------------------------------------------------- 1 | # API 2 | 3 | ###商品列表 4 | 5 | ``` 6 | GET /sell/buyer/product/list 7 | ``` 8 | 9 | 参数 10 | 11 | ``` 12 | 无 13 | ``` 14 | 15 | 返回 16 | 17 | ``` 18 | { 19 | "code": 0, 20 | "msg": "成功", 21 | "data": [ 22 | { 23 | "name": "热榜", 24 | "type": 1, 25 | "foods": [ 26 | { 27 | "id": "123456", 28 | "name": "皮蛋粥", 29 | "price": 1.2, 30 | "description": "好吃的皮蛋粥", 31 | "icon": "http://xxx.com", 32 | } 33 | ] 34 | }, 35 | { 36 | "name": "好吃的", 37 | "type": 2, 38 | "foods": [ 39 | { 40 | "id": "123457", 41 | "name": "慕斯蛋糕", 42 | "price": 10.9, 43 | "description": "美味爽口", 44 | "icon": "http://xxx.com", 45 | } 46 | ] 47 | } 48 | ] 49 | } 50 | ``` 51 | 52 | 53 | ###创建订单 54 | 55 | ``` 56 | POST /sell/buyer/order/create 57 | ``` 58 | 59 | 参数 60 | 61 | ``` 62 | name: "张三" 63 | phone: "18868822111" 64 | address: "慕课网总部" 65 | openid: "ew3euwhd7sjw9diwkq" //用户的微信openid 66 | items: [{ 67 | productId: "1423113435324", 68 | productQuantity: 2 //购买数量 69 | }] 70 | 71 | ``` 72 | 73 | 返回 74 | 75 | ``` 76 | { 77 | "code": 0, 78 | "msg": "成功", 79 | "data": { 80 | "orderId": "147283992738221" 81 | } 82 | } 83 | ``` 84 | 85 | ###订单列表 86 | 87 | ``` 88 | GET /sell/buyer/order/list 89 | ``` 90 | 91 | 参数 92 | 93 | ``` 94 | openid: 18eu2jwk2kse3r42e2e 95 | page: 0 //从第0页开始 96 | size: 10 97 | ``` 98 | 99 | 返回 100 | 101 | ``` 102 | { 103 | "code": 0, 104 | "msg": "成功", 105 | "data": [ 106 | { 107 | "orderId": "161873371171128075", 108 | "buyerName": "张三", 109 | "buyerPhone": "18868877111", 110 | "buyerAddress": "慕课网总部", 111 | "buyerOpenid": "18eu2jwk2kse3r42e2e", 112 | "orderAmount": 0, 113 | "orderStatus": 0, 114 | "payStatus": 0, 115 | "createTime": 1490171219, 116 | "updateTime": 1490171219, 117 | "orderDetailList": null 118 | }, 119 | { 120 | "orderId": "161873371171128076", 121 | "buyerName": "张三", 122 | "buyerPhone": "18868877111", 123 | "buyerAddress": "慕课网总部", 124 | "buyerOpenid": "18eu2jwk2kse3r42e2e", 125 | "orderAmount": 0, 126 | "orderStatus": 0, 127 | "payStatus": 0, 128 | "createTime": 1490171219, 129 | "updateTime": 1490171219, 130 | "orderDetailList": null 131 | }] 132 | } 133 | ``` 134 | 135 | ###查询订单详情 136 | 137 | ``` 138 | GET /sell/buyer/order/detail 139 | ``` 140 | 141 | 参数 142 | 143 | ``` 144 | openid: 18eu2jwk2kse3r42e2e 145 | orderId: 161899085773669363 146 | ``` 147 | 148 | 返回 149 | 150 | ``` 151 | { 152 | "code": 0, 153 | "msg": "成功", 154 | "data": { 155 | "orderId": "161899085773669363", 156 | "buyerName": "李四", 157 | "buyerPhone": "18868877111", 158 | "buyerAddress": "慕课网总部", 159 | "buyerOpenid": "18eu2jwk2kse3r42e2e", 160 | "orderAmount": 18, 161 | "orderStatus": 0, 162 | "payStatus": 0, 163 | "createTime": 1490177352, 164 | "updateTime": 1490177352, 165 | "orderDetailList": [ 166 | { 167 | "detailId": "161899085974995851", 168 | "orderId": "161899085773669363", 169 | "productId": "157875196362360019", 170 | "productName": "招牌奶茶", 171 | "productPrice": 9, 172 | "productQuantity": 2, 173 | "productIcon": "http://xxx.com", 174 | "productImage": "http://xxx.com" 175 | } 176 | ] 177 | } 178 | } 179 | ``` 180 | 181 | ###取消订单 182 | 183 | ``` 184 | POST /sell/buyer/order/cancel 185 | ``` 186 | 187 | 参数 188 | 189 | ``` 190 | openid: 18eu2jwk2kse3r42e2e 191 | orderId: 161899085773669363 192 | ``` 193 | 194 | 返回 195 | 196 | ``` 197 | { 198 | "code": 0, 199 | "msg": "成功", 200 | "data": null 201 | } 202 | ``` 203 | 204 | ###获取openid 205 | 206 | ``` 207 | 重定向到 /sell/wechat/authorize 208 | ``` 209 | 210 | 参数 211 | 212 | ``` 213 | returnUrl: http://xxx.com/abc //【必填】 214 | ``` 215 | 216 | 返回 217 | 218 | ``` 219 | http://xxx.com/abc?openid=oZxSYw5ldcxv6H0EU67GgSXOUrVg 220 | ``` 221 | 222 | 223 | -------------------------------------------------------------------------------- /wechat_order_h/doc/sql: -------------------------------------------------------------------------------- 1 | drop database if exists wechat_order; 2 | create database wechat_order default character set utf8 collate utf8_general_ci; 3 | use wechat_order; 4 | 5 | /*类目表*/ 6 | create table product_category( 7 | category_id int not null auto_increment comment '类目id' , 8 | category_name varchar(64) not null comment '类目名称' , 9 | category_type int not null comment '类目编号' , 10 | create_time timestamp not null default current_timestamp comment '创建时间' , 11 | update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间' , 12 | primary key(category_id), 13 | unique key uqe_category_type (category_type) 14 | ) comment '类目表' ; 15 | 16 | 17 | /*商品表*/ 18 | create table product_info( 19 | product_id varchar(32) not null comment '商品id' , 20 | product_name varchar(64) not null comment '商品名称' , 21 | product_price decimal(8,2) not null comment '商品单价' , 22 | product_stock int not null comment '库存' , 23 | product_icon varchar(512) comment '商品图片' , 24 | product_description varchar(64) comment '商品描述' , 25 | product_status tinyint(3) default '0' comment '商品状态 , 0正常 , 1下架' , 26 | category_type int not null comment '类目编号' , 27 | create_time timestamp not null default current_timestamp comment '创建时间' , 28 | update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间' , 29 | primary key (product_id) 30 | /*foreign key(category_type) references product_category(category_type)*/ 31 | ) comment '商品表' ; 32 | 33 | 34 | 35 | /*订单表*/ 36 | create table order_master( 37 | order_id varchar(32) not null comment '订单id' , 38 | buyer_name varchar(32) not null comment '买家名称' , 39 | buyer_phone varchar(32) not null comment '买家电话' , 40 | buyer_address varchar(128) not null comment '买家地址' , 41 | buyer_openid varchar(64) not null comment '买家微信的openid' , 42 | order_amount decimal(8,2) not null comment '订单总金额' , 43 | order_status tinyint(3) not null default '0' comment '订单状态 , 默认0为新订单' , 44 | pay_status tinyint(3) not null default '0' comment '支付状态 , 默认0为未支付' , 45 | create_time timestamp not null default current_timestamp comment '创建时间' , 46 | update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间' , 47 | primary key (order_id) , 48 | key idx_buyer_openid (buyer_openid) 49 | ) comment '订单表' ; 50 | 51 | /*订单详情表*/ 52 | create table order_detail( 53 | detail_id varchar(32) not null comment '订单详情表的id' , 54 | order_id varchar(32) not null comment '订单id' , 55 | product_id varchar(32) not null comment '商品id' , 56 | product_name varchar(64) not null comment '商品名称' , 57 | product_price decimal(8,2) not null comment '商品价格' , 58 | product_quantity int not null comment '商品数量' , 59 | product_icon varchar(512) not null comment '商品图片' , 60 | create_time timestamp not null default current_timestamp comment '创建时间' , 61 | update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间' , 62 | primary key (detail_id) , 63 | key idx_order_id (order_id) 64 | ) comment '订单详情表' ; 65 | 66 | 67 | /*商家信息表*/ 68 | create table seller_info( 69 | seller_id int not null auto_increment comment '商家信息表id' , 70 | username varchar(32) not null comment '商家名称' , 71 | password varchar(332) not null comment '商家密码' , 72 | phone varchar(64) not null comment '用户手机号' , 73 | create_time timestamp not null default current_timestamp comment '创建时间' , 74 | update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间' , 75 | primary key (seller_id) 76 | ) comment '商家信息表' ; 77 | 78 | /* 评论信息表 */ 79 | create table comment( 80 | comment_id int not null auto_increment comment '评论信息的id' , 81 | comment_name varchar(64) not null comment '评论者姓名' , 82 | openid varchar(64) not null comment '评论者的openid' , 83 | comment_content text not null comment '评论内容' , 84 | create_time timestamp not null default current_timestamp comment '评论时间' , 85 | primary key (comment_id) 86 | )comment '评论信息表' ; 87 | 88 | /* 用户信息表 */ 89 | create table user( 90 | user_id int not null auto_increment comment '用户id' , 91 | user_name varchar(32) not null comment '用户名' , 92 | user_phone varchar(32) not null comment '用户手机号' , 93 | openid varchar(64) not null comment '用户微信openid' , 94 | user_table varchar(64) comment '桌号' , 95 | user_number varchar(64) comment '就餐人数' , 96 | create_time timestamp not null default current_timestamp comment '创建时间' , 97 | update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间' , 98 | primary key (user_id) 99 | )comment '用户就餐信息表' ; 100 | 101 | /* 轮播图片 */ 102 | create table picture( 103 | pic_id int not null auto_increment comment '图片id' , 104 | pic_url varchar(256) not null comment '图片路径' , 105 | pic_message varchar(64) not null comment '图片信息' , 106 | create_time timestamp not null default current_timestamp comment '创建时间' , 107 | primary key (pic_id) 108 | ) comment '轮播图表' ; 109 | 110 | 111 | -------------------------------------------------------------------------------- /wechat_order_h/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.8.RELEASE 9 | 10 | 11 | com.hhh 12 | wechat_order 13 | 0.0.1-SNAPSHOT 14 | wechat_order 15 | Demo project for Spring Boot 16 | 17 | 18 | UTF-8 19 | UTF-8 20 | 1.8 21 | 22 | 23 | 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-test 35 | test 36 | 37 | 38 | 39 | 40 | org.projectlombok 41 | lombok 42 | 43 | 44 | 45 | 46 | mysql 47 | mysql-connector-java 48 | runtime 49 | 5.1.46 50 | 51 | 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-starter-data-jpa 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | com.google.code.gson 67 | gson 68 | 69 | 70 | 71 | 72 | com.github.binarywang 73 | weixin-java-miniapp 74 | 3.5.0 75 | 76 | 77 | 78 | 79 | com.github.binarywang 80 | weixin-java-mp 81 | 3.5.0 82 | 83 | 84 | 85 | 86 | cn.springboot 87 | best-pay-sdk 88 | 1.1.0 89 | 90 | 91 | 92 | com.github.binarywang 93 | weixin-java-pay 94 | 3.5.0 95 | 96 | 97 | 98 | 99 | org.springframework.boot 100 | spring-boot-starter-freemarker 101 | 102 | 103 | 104 | 105 | org.springframework.boot 106 | spring-boot-starter-data-redis 107 | 108 | 109 | 110 | 111 | org.springframework.boot 112 | spring-boot-starter-websocket 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | org.springframework.boot 121 | spring-boot-maven-plugin 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/VO/ProductInfoVo.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.VO; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import lombok.Data; 5 | import java.math.BigDecimal; 6 | 7 | /** 8 | * 商品详情 9 | */ 10 | @Data 11 | public class ProductInfoVo { 12 | 13 | @JsonProperty("id") 14 | private String productId; 15 | 16 | @JsonProperty("name") 17 | private String productName; 18 | 19 | @JsonProperty("price") 20 | private BigDecimal productPrice; 21 | 22 | @JsonProperty("description") 23 | private String productDescription; 24 | 25 | @JsonProperty("icon") 26 | private String productIcon; 27 | 28 | @JsonProperty("stock") 29 | private Integer productStock; 30 | } 31 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/VO/ProductVo.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.VO; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 商品(包含类目) 10 | */ 11 | @Data 12 | public class ProductVo { 13 | 14 | @JsonProperty("name") 15 | private String categoryName; 16 | 17 | @JsonProperty("type") 18 | private Integer categoryType; 19 | 20 | @JsonProperty("foods") 21 | private List productInfoVoList; 22 | } 23 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/VO/ResultVo.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.VO; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * http请求返回的最外层对象 7 | */ 8 | @Data 9 | public class ResultVo { 10 | 11 | //错误码 12 | private Integer code; 13 | 14 | //提示信息 15 | private String msg; 16 | 17 | //返回的具体对象 18 | private T data; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/WechatOrderApplication.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class WechatOrderApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(WechatOrderApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/aspect/SellerAuthorizeAspect.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.aspect; 2 | 3 | import com.hhh.wechat_order.constant.CookieConstant; 4 | import com.hhh.wechat_order.constant.RedisConstant; 5 | import com.hhh.wechat_order.exception.SellerAuthorizeException; 6 | import com.hhh.wechat_order.utils.CookieUtil; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.aspectj.lang.annotation.Aspect; 9 | import org.aspectj.lang.annotation.Before; 10 | import org.aspectj.lang.annotation.Pointcut; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.data.redis.core.StringRedisTemplate; 13 | import org.springframework.stereotype.Component; 14 | import org.springframework.util.StringUtils; 15 | import org.springframework.web.context.request.RequestAttributes; 16 | import org.springframework.web.context.request.RequestContextHolder; 17 | import org.springframework.web.context.request.ServletRequestAttributes; 18 | 19 | import javax.servlet.http.Cookie; 20 | import javax.servlet.http.HttpServletRequest; 21 | 22 | /** 23 | * 卖家登录的AOP 24 | */ 25 | @Aspect 26 | @Component 27 | @Slf4j 28 | public class SellerAuthorizeAspect { 29 | 30 | @Autowired 31 | private StringRedisTemplate redisTemplate; 32 | 33 | @Pointcut("execution(public * com.hhh.wechat_order.controller.Seller*.*(..))") 34 | public void verify(){} 35 | 36 | @Before("verify()") 37 | public void doVerify(){ 38 | ServletRequestAttributes attributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes(); 39 | HttpServletRequest request = attributes.getRequest(); 40 | //查询cookie 41 | Cookie cookie = CookieUtil.get(request , CookieConstant.TOKEN); 42 | if(cookie == null){ 43 | log.warn("【登录校验】 Cookie中查询不到token"); 44 | throw new SellerAuthorizeException(); 45 | } 46 | 47 | //去redis查询 48 | // String tokenValue = redisTemplate.opsForValue().get(String.format(RedisConstant.TOKEN_PREFIX , cookie.getValue())); 49 | // if(StringUtils.isEmpty(tokenValue)){ 50 | // log.warn("【登录校验】 Redis中查询不到token"); 51 | // throw new SellerAuthorizeException(); 52 | // } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/config/ProjectUrlConfig.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * 项目中的Url 9 | */ 10 | @Data 11 | @ConfigurationProperties(prefix = "projecturl") 12 | @Component 13 | public class ProjectUrlConfig { 14 | 15 | //微信公众平台授权url 16 | private String wechatMpAuthorize; 17 | 18 | //微信开放平台授权的url 19 | private String wechatOpenAuthorize; 20 | 21 | //项目的url 22 | private String sell; 23 | } 24 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.socket.server.standard.ServerEndpointExporter; 6 | 7 | /** 8 | * websocket配置 9 | */ 10 | @Component 11 | public class WebSocketConfig { 12 | 13 | @Bean 14 | public ServerEndpointExporter serverEndpointExporter(){ 15 | return new ServerEndpointExporter(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/config/WechatAccountConfig.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * 微信账号配置 11 | */ 12 | @Data 13 | @Component 14 | @ConfigurationProperties(prefix = "wechat") 15 | public class WechatAccountConfig { 16 | 17 | //公众平台id 18 | private String mpAppId; 19 | 20 | //微信开发平台的id 21 | private String openAppId; 22 | 23 | //公众平台密钥 24 | private String mpAppSecret; 25 | 26 | //微信开放平台的密钥 27 | private String openAppSecret; 28 | 29 | //商户号 30 | private String mchId; 31 | 32 | //商户密钥 33 | private String mchKey; 34 | 35 | //商户证书路径 36 | private String keyPath; 37 | 38 | //微信支付异步通知地址 39 | private String notifyUrl; 40 | 41 | //消息推送模板Id 42 | private Map templateId; 43 | } 44 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/config/WechatMpConfig.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.config; 2 | 3 | import me.chanjar.weixin.mp.api.WxMpService; 4 | import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; 5 | import me.chanjar.weixin.mp.config.WxMpConfigStorage; 6 | import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.stereotype.Component; 10 | 11 | /** 12 | * 公众账号配置 13 | */ 14 | @Component 15 | public class WechatMpConfig { 16 | 17 | @Autowired 18 | private WechatAccountConfig accountConfig; 19 | 20 | @Bean 21 | public WxMpService wxMpService(){ 22 | WxMpService wxMpService = new WxMpServiceImpl(); 23 | wxMpService.setWxMpConfigStorage(wxMpConfigStorage()); 24 | return wxMpService; 25 | } 26 | 27 | @Bean 28 | public WxMpConfigStorage wxMpConfigStorage(){ 29 | WxMpDefaultConfigImpl wxMpConfigStorage = new WxMpDefaultConfigImpl(); 30 | wxMpConfigStorage.setAppId(accountConfig.getMpAppId()); 31 | wxMpConfigStorage.setSecret(accountConfig.getMpAppSecret()); 32 | return wxMpConfigStorage; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/config/WechatOpenConfig.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.config; 2 | 3 | import me.chanjar.weixin.mp.api.WxMpService; 4 | import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; 5 | import me.chanjar.weixin.mp.config.WxMpConfigStorage; 6 | import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.stereotype.Component; 10 | 11 | /** 12 | * 微信开放平台的配置 13 | */ 14 | @Component 15 | public class WechatOpenConfig { 16 | 17 | @Autowired 18 | private WechatAccountConfig accountConfig; 19 | 20 | @Bean 21 | public WxMpService wxOpenService(){ 22 | WxMpService wxOpenService = new WxMpServiceImpl(); 23 | wxOpenService.setWxMpConfigStorage(wxOpenConfigStorage()); 24 | return wxOpenService; 25 | } 26 | 27 | @Bean 28 | public WxMpConfigStorage wxOpenConfigStorage(){ 29 | WxMpDefaultConfigImpl wxMpConfigStorage = new WxMpDefaultConfigImpl(); 30 | wxMpConfigStorage.setAppId(accountConfig.getOpenAppId()); 31 | wxMpConfigStorage.setSecret(accountConfig.getOpenAppSecret()); 32 | return wxMpConfigStorage; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/config/WechatPayConfig.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.config; 2 | 3 | import com.lly835.bestpay.config.WxPayH5Config; 4 | import com.lly835.bestpay.service.impl.BestPayServiceImpl; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.stereotype.Component; 8 | 9 | /** 10 | * 微信支付的配置 11 | */ 12 | @Component 13 | public class WechatPayConfig { 14 | 15 | @Autowired 16 | private WechatAccountConfig accountConfig; 17 | 18 | @Bean 19 | public BestPayServiceImpl bestPayService(){ 20 | BestPayServiceImpl bestPayService = new BestPayServiceImpl(); 21 | bestPayService.setWxPayH5Config(wxPayH5Config()); 22 | return bestPayService; 23 | } 24 | 25 | @Bean 26 | public WxPayH5Config wxPayH5Config(){ 27 | WxPayH5Config wxPayH5Config = new WxPayH5Config(); 28 | wxPayH5Config.setAppId(accountConfig.getMpAppId()); 29 | wxPayH5Config.setAppSecret(accountConfig.getMpAppSecret()); 30 | wxPayH5Config.setMchId(accountConfig.getMchId()); 31 | wxPayH5Config.setMchKey(accountConfig.getMchKey()); 32 | wxPayH5Config.setKeyPath(accountConfig.getKeyPath()); 33 | wxPayH5Config.setNotifyUrl(accountConfig.getNotifyUrl()); 34 | 35 | return wxPayH5Config; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/constant/CookieConstant.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.constant; 2 | 3 | /** 4 | * cookie 的常量 5 | */ 6 | public interface CookieConstant { 7 | 8 | String TOKEN = "token"; 9 | 10 | Integer EXPIRE = 7200; 11 | } 12 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/constant/RedisConstant.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.constant; 2 | 3 | /** 4 | * redis 的常量 5 | */ 6 | public interface RedisConstant { 7 | 8 | //redis的前缀 9 | String TOKEN_PREFIX = "token_%s"; 10 | 11 | //redis的过期时间 12 | Integer EXPIRE = 7200; 13 | } 14 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/controller/AdminUserController.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.controller; 2 | 3 | import com.hhh.wechat_order.constant.CookieConstant; 4 | import com.hhh.wechat_order.constant.RedisConstant; 5 | import com.hhh.wechat_order.entity.SellerInfo; 6 | import com.hhh.wechat_order.enums.ResultEnum; 7 | import com.hhh.wechat_order.exception.SellException; 8 | import com.hhh.wechat_order.form.SellerForm; 9 | import com.hhh.wechat_order.repository.SellerInfoRepository; 10 | import com.hhh.wechat_order.utils.CookieUtil; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.springframework.beans.BeanUtils; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Controller; 15 | import org.springframework.util.StringUtils; 16 | import org.springframework.validation.BindingResult; 17 | import org.springframework.web.bind.annotation.*; 18 | import org.springframework.web.servlet.ModelAndView; 19 | 20 | import javax.servlet.http.Cookie; 21 | import javax.servlet.http.HttpServletRequest; 22 | import javax.servlet.http.HttpServletResponse; 23 | import javax.validation.Valid; 24 | import java.util.List; 25 | import java.util.Map; 26 | import java.util.UUID; 27 | 28 | /** 29 | * 商家操作的Controller层 30 | * @author HHH 31 | * @version 1.0 2019/10/17 32 | */ 33 | @RestController 34 | @RequestMapping("/admin") 35 | @Slf4j 36 | public class AdminUserController { 37 | 38 | @Autowired 39 | private SellerInfoRepository sellerInfoRepository; 40 | 41 | @GetMapping("/loginAdmin") 42 | public String loginAdmin(@RequestParam("phone") String phone , 43 | @RequestParam("password") String password , 44 | HttpServletResponse response){ 45 | SellerInfo sellerInfo = sellerInfoRepository.findByPhone(phone); 46 | log.info("【商家登录】 商家信息={}" , sellerInfo); 47 | if(sellerInfo != null && sellerInfo.getPassword().equals(password)){ 48 | String token = UUID.randomUUID().toString(); 49 | log.info("【商家登录】 登录成功的token = {}" , token); 50 | Integer expire = RedisConstant.EXPIRE; 51 | //设置token至cookie 52 | CookieUtil.set(response , CookieConstant.TOKEN , token , expire); 53 | return "登录成功"; 54 | }else{ 55 | throw new SellException(ResultEnum.LOGIN_FAIL); 56 | } 57 | } 58 | 59 | @GetMapping("/logout") 60 | public ModelAndView logout(HttpServletRequest request , 61 | HttpServletResponse response , 62 | Map map){ 63 | //从cookie里查询 64 | Cookie cookie = CookieUtil.get(request , CookieConstant.TOKEN); 65 | if(cookie != null){ 66 | //清除cookie 67 | CookieUtil.set(response , CookieConstant.TOKEN , null , 0); 68 | } 69 | map.put("msg" , ResultEnum.LOGOUT_SUCCESS.getMessage()); 70 | map.put("url" , "/sell/seller/order/list"); 71 | return new ModelAndView("common/success" , map); 72 | } 73 | 74 | @GetMapping("/list") 75 | public ModelAndView list(Map map){ 76 | List sellerInfoList = sellerInfoRepository.findAll(); 77 | map.put("sellerInfoList" , sellerInfoList); 78 | return new ModelAndView("admin/list" , map); 79 | } 80 | 81 | @GetMapping("/index") 82 | public ModelAndView index(@RequestParam(value = "sellerId" , required = false) Integer sellerId , 83 | Map map){ 84 | if(!StringUtils.isEmpty(sellerId)){ 85 | SellerInfo sellerInfo = sellerInfoRepository.findBySellerId(sellerId); 86 | map.put("sellerInfo" , sellerInfo); 87 | } 88 | return new ModelAndView("admin/index" , map); 89 | } 90 | 91 | @PostMapping("/save") 92 | public ModelAndView save(@Valid SellerForm form , 93 | BindingResult bindingResult , 94 | Map map){ 95 | if(bindingResult.hasErrors()){ 96 | map.put("msg" , bindingResult.getFieldError().getDefaultMessage()); 97 | map.put("url", "/sell/admin/index"); 98 | return new ModelAndView("common/error" , map); 99 | } 100 | SellerInfo sellerInfo = new SellerInfo(); 101 | try{ 102 | if(form.getSellerId() != null){ 103 | sellerInfo = sellerInfoRepository.findBySellerId(form.getSellerId()); 104 | } 105 | BeanUtils.copyProperties(form , sellerInfo); 106 | sellerInfoRepository.save(sellerInfo); 107 | }catch (SellException e){ 108 | map.put("msg", e.getMessage()); 109 | map.put("url", "/sell/admin/index"); 110 | return new ModelAndView("common/error", map); 111 | } 112 | map.put("msg" , "操作成功!"); 113 | map.put("url" , "/sell/admin/list"); 114 | return new ModelAndView("common/success" , map); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/controller/BuyerOrderController.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.controller; 2 | 3 | import com.hhh.wechat_order.VO.ResultVo; 4 | import com.hhh.wechat_order.converter.OrderForm2OrderDTOConverter; 5 | import com.hhh.wechat_order.dto.OrderDTO; 6 | import com.hhh.wechat_order.enums.ResultEnum; 7 | import com.hhh.wechat_order.exception.SellException; 8 | import com.hhh.wechat_order.form.OrderForm; 9 | import com.hhh.wechat_order.service.BuyerService; 10 | import com.hhh.wechat_order.service.OrderService; 11 | import com.hhh.wechat_order.utils.ResultVOUtil; 12 | import lombok.extern.slf4j.Slf4j; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.data.domain.Page; 15 | import org.springframework.data.domain.PageRequest; 16 | import org.springframework.util.CollectionUtils; 17 | import org.springframework.util.StringUtils; 18 | import org.springframework.validation.BindingResult; 19 | import org.springframework.web.bind.annotation.*; 20 | 21 | import javax.validation.Valid; 22 | import java.util.HashMap; 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | /** 27 | * 买家订单的Controller层 28 | */ 29 | @RestController 30 | @RequestMapping("/buyer/order") 31 | @Slf4j 32 | public class BuyerOrderController { 33 | 34 | @Autowired 35 | private OrderService orderService; 36 | @Autowired 37 | private BuyerService buyerService; 38 | 39 | //创建订单 40 | @PostMapping("/create") 41 | public ResultVo> create(@Valid OrderForm orderForm , BindingResult bindingResult){ 42 | 43 | //判断表单校验有无错误 44 | if(bindingResult.hasErrors()){ 45 | log.error("【创建订单】 参数不正确 , orderForm={}" , orderForm); 46 | throw new SellException(ResultEnum.PARAM_ERROR.getCode() , 47 | bindingResult.getFieldError().getDefaultMessage()); 48 | } 49 | 50 | OrderDTO orderDTO = OrderForm2OrderDTOConverter.conver(orderForm); 51 | if(CollectionUtils.isEmpty(orderDTO.getOrderDetailList())){ 52 | log.error("【创建订单】 购物车不能为空"); 53 | throw new SellException(ResultEnum.CART_EMPTY); 54 | } 55 | OrderDTO createResult = orderService.create(orderDTO); 56 | Map map = new HashMap<>(); 57 | map.put("orderId" , createResult.getOrderId()); 58 | return ResultVOUtil.success(map); 59 | } 60 | 61 | //订单列表 62 | @GetMapping("/list") 63 | public ResultVo list(@RequestParam("openid") String openid , 64 | @RequestParam(value = "page" , defaultValue = "0") Integer page , 65 | @RequestParam(value = "size" , defaultValue = "5") Integer size){ 66 | if(StringUtils.isEmpty(openid)){ 67 | log.error("【查询订单列表】 openid为空"); 68 | throw new SellException(ResultEnum.PARAM_ERROR); 69 | } 70 | PageRequest request = new PageRequest(page , size); 71 | Page orderDTOPage = orderService.findList(openid, request); 72 | return ResultVOUtil.success(orderDTOPage.getContent()); 73 | } 74 | 75 | @GetMapping("/listByStatus") 76 | public ResultVo> listByStatus(@RequestParam("openid") String openid , 77 | @RequestParam(value="orderStatus" , defaultValue = "0") Integer orderStatus){ 78 | if(StringUtils.isEmpty(openid)){ 79 | log.error("【查询订单列表】openid为空"); 80 | throw new SellException(ResultEnum.PARAM_ERROR); 81 | } 82 | List orderList = buyerService.findOrderList(openid , orderStatus); 83 | return ResultVOUtil.success(orderList); 84 | } 85 | 86 | //订单详情 87 | @GetMapping("/detail") 88 | public ResultVo detail(@RequestParam("openid") String openid , 89 | @RequestParam("orderId") String orderId){ 90 | OrderDTO orderDTO = buyerService.findOrderOne(openid, orderId); 91 | return ResultVOUtil.success(orderDTO); 92 | } 93 | 94 | //确认收货 95 | //TODO 96 | // @PostMapping("/sure") 97 | // public ResultVo sure(@RequestParam("openid") String openid , 98 | // @RequestParam("orderId") String orderId){ 99 | // buyerService.cancelOrder(openid , orderId); 100 | // return ResultVOUtil.success(); 101 | // } 102 | 103 | //取消订单 104 | @PostMapping("/cancel") 105 | public ResultVo cancel(@RequestParam("openid") String openid , 106 | @RequestParam("orderId") String orderId){ 107 | buyerService.cancelOrder(openid , orderId); 108 | return ResultVOUtil.success(); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/controller/BuyerProductController.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.controller; 2 | 3 | import com.hhh.wechat_order.VO.ProductInfoVo; 4 | import com.hhh.wechat_order.VO.ProductVo; 5 | import com.hhh.wechat_order.VO.ResultVo; 6 | import com.hhh.wechat_order.entity.ProductCategory; 7 | import com.hhh.wechat_order.entity.ProductInfo; 8 | import com.hhh.wechat_order.service.CategoryService; 9 | import com.hhh.wechat_order.service.ProductService; 10 | import com.hhh.wechat_order.utils.ResultVOUtil; 11 | import org.springframework.beans.BeanUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.web.bind.annotation.GetMapping; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RestController; 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | import java.util.stream.Collectors; 19 | 20 | /** 21 | * 买家商品 22 | */ 23 | @RestController 24 | @RequestMapping("/buyer/product") 25 | public class BuyerProductController { 26 | 27 | @Autowired 28 | private ProductService productService; 29 | 30 | @Autowired 31 | private CategoryService categoryService; 32 | 33 | @GetMapping("/list") 34 | public ResultVo list(){ 35 | 36 | //查询所有上架的商品 37 | List productInfoList = productService.findUpAll(); 38 | 39 | //查询类目 40 | //java8的lambda方法 41 | List categoryTypeList = productInfoList.stream().map(e -> e.getCategoryType()).collect(Collectors.toList()); 42 | List productCategoryList = categoryService.findByCategoryTypeIn(categoryTypeList); 43 | 44 | //数据拼装 45 | List productVoList = new ArrayList<>(); 46 | for (ProductCategory productCategory : productCategoryList){ 47 | ProductVo productVo = new ProductVo(); 48 | productVo.setCategoryType(productCategory.getCategoryType()); 49 | productVo.setCategoryName(productCategory.getCategoryName()); 50 | 51 | List productInfoVoList = new ArrayList<>(); 52 | for (ProductInfo productInfo : productInfoList){ 53 | if(productInfo.getCategoryType().equals(productCategory.getCategoryType())){ 54 | ProductInfoVo productInfoVo = new ProductInfoVo(); 55 | BeanUtils.copyProperties(productInfo , productInfoVo); 56 | productInfoVoList.add(productInfoVo); 57 | } 58 | } 59 | productVo.setProductInfoVoList(productInfoVoList); 60 | productVoList.add(productVo); 61 | } 62 | return ResultVOUtil.success(productVoList); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/controller/CommentController.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.controller; 2 | 3 | import com.hhh.wechat_order.VO.ResultVo; 4 | import com.hhh.wechat_order.dto.OrderDTO; 5 | import com.hhh.wechat_order.entity.Comment; 6 | import com.hhh.wechat_order.entity.OrderMaster; 7 | import com.hhh.wechat_order.enums.OrderStatusEnum; 8 | import com.hhh.wechat_order.enums.ResultEnum; 9 | import com.hhh.wechat_order.exception.SellException; 10 | import com.hhh.wechat_order.repository.CommentRepository; 11 | import com.hhh.wechat_order.repository.OrderMasterRepository; 12 | import com.hhh.wechat_order.service.OrderService; 13 | import com.hhh.wechat_order.utils.ResultVOUtil; 14 | import org.springframework.beans.BeanUtils; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.util.StringUtils; 17 | import org.springframework.web.bind.annotation.GetMapping; 18 | import org.springframework.web.bind.annotation.PostMapping; 19 | import org.springframework.web.bind.annotation.RequestParam; 20 | import org.springframework.web.bind.annotation.RestController; 21 | 22 | import java.util.List; 23 | 24 | /** 25 | * 评论的Controller层 26 | * @author HHH 27 | * @version 1.0 2019/10/17 28 | */ 29 | @RestController 30 | public class CommentController { 31 | 32 | @Autowired 33 | private CommentRepository commentRepository; 34 | @Autowired 35 | private OrderService orderService; 36 | @Autowired 37 | private OrderMasterRepository masterRepository; 38 | 39 | //订单详情 40 | @PostMapping("/comment") 41 | public ResultVo detail(@RequestParam("openid") String openid , 42 | @RequestParam("orderId") String orderId , 43 | @RequestParam("username") String username , 44 | @RequestParam("avatarUrl") String avatarUrl , 45 | @RequestParam("content") String content){ 46 | if(StringUtils.isEmpty(openid) || StringUtils.isEmpty(orderId)){ 47 | throw new SellException(ResultEnum.PARAM_ERROR); 48 | } 49 | 50 | //提交评论 51 | Comment comment = new Comment(); 52 | comment.setCommentName(username); 53 | comment.setAvatarUrl(avatarUrl); 54 | comment.setOpenid(openid); 55 | comment.setCommentContent(content); 56 | Comment save = commentRepository.save(comment); 57 | 58 | //修改订单状态 59 | OrderDTO orderDTO = orderService.findOne(orderId); 60 | orderDTO.setOrderStatus(OrderStatusEnum.COMMENT.getCode()); 61 | OrderMaster orderMaster = new OrderMaster(); 62 | BeanUtils.copyProperties(orderDTO , orderMaster); 63 | OrderMaster updateResult = masterRepository.save(orderMaster); 64 | return ResultVOUtil.success(save); 65 | } 66 | 67 | //所有评论 68 | @GetMapping("/commentList") 69 | public ResultVo> commentList(){ 70 | List all = commentRepository.findAll(); 71 | return ResultVOUtil.success(all); 72 | } 73 | 74 | //单个用户的所有评论 75 | @GetMapping("/userCommentList") 76 | public ResultVo> userCommentList(@RequestParam("openid") String openid){ 77 | List all =commentRepository.findAllByOpenid(openid); 78 | return ResultVOUtil.success(all); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/controller/PayController.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.controller; 2 | 3 | import com.hhh.wechat_order.VO.ResultVo; 4 | import com.hhh.wechat_order.dto.OrderDTO; 5 | import com.hhh.wechat_order.enums.OrderStatusEnum; 6 | import com.hhh.wechat_order.enums.ResultEnum; 7 | import com.hhh.wechat_order.exception.SellException; 8 | import com.hhh.wechat_order.service.OrderService; 9 | import com.hhh.wechat_order.service.impl.PayService; 10 | import com.hhh.wechat_order.utils.ResultVOUtil; 11 | import com.lly835.bestpay.model.PayResponse; 12 | import lombok.extern.slf4j.Slf4j; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Controller; 15 | import org.springframework.web.bind.annotation.*; 16 | import org.springframework.web.servlet.ModelAndView; 17 | 18 | import java.util.Map; 19 | 20 | /** 21 | * 支付 22 | */ 23 | @RestController 24 | @RequestMapping("/pay") 25 | @Slf4j 26 | public class PayController { 27 | 28 | @Autowired 29 | private OrderService orderService; 30 | @Autowired 31 | private PayService payService; 32 | 33 | @GetMapping("/goPay") 34 | public ResultVo goPay(@RequestParam("orderId") String orderId){ 35 | //查询订单 36 | OrderDTO orderDTO = orderService.findOne(orderId); 37 | if(orderDTO == null){ 38 | throw new SellException(ResultEnum.ORDER_NOT_EXIST); 39 | } 40 | 41 | //发起支付 42 | OrderDTO orderDTO1 = payService.goPay(orderDTO); 43 | if(!orderDTO.getOrderStatus().equals(OrderStatusEnum.NEW_PAYED.getCode())){ 44 | log.error("【支付订单】订单状态不正确, orderStatus={}", orderDTO1.getOrderStatus()); 45 | throw new SellException(ResultEnum.ORDER_STATUS_ERROR); 46 | } 47 | return ResultVOUtil.success(true); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/controller/PictureController.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.controller; 2 | 3 | import com.hhh.wechat_order.VO.ResultVo; 4 | import com.hhh.wechat_order.entity.Picture; 5 | import com.hhh.wechat_order.exception.SellException; 6 | import com.hhh.wechat_order.form.PictureForm; 7 | import com.hhh.wechat_order.repository.PictureRepository; 8 | import com.hhh.wechat_order.utils.ResultVOUtil; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.springframework.beans.BeanUtils; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.validation.BindingResult; 14 | import org.springframework.web.bind.annotation.*; 15 | import org.springframework.web.servlet.ModelAndView; 16 | 17 | import javax.validation.Valid; 18 | import java.util.List; 19 | import java.util.Map; 20 | 21 | /** 22 | * 微信用户端的图片相关操作的Controller 23 | * @author HHH 24 | * @version 1.0 2019/10/17 25 | */ 26 | @RestController 27 | @RequestMapping("/picture") 28 | @Slf4j 29 | public class PictureController { 30 | 31 | @Autowired 32 | private PictureRepository pictureRepository; 33 | 34 | @GetMapping("/getAll") 35 | public ResultVo getUserInfo(){ 36 | List pictures = pictureRepository.findAll(); 37 | return ResultVOUtil.success(pictures); 38 | } 39 | 40 | //页面相关 41 | //TODO 42 | @GetMapping("/list") 43 | public ModelAndView list(Map map){ 44 | List pictures = pictureRepository.findAll(); 45 | map.put("pictures" , pictures); 46 | return new ModelAndView("picture/list" , map); 47 | } 48 | 49 | @GetMapping("/index") 50 | public ModelAndView index(@RequestParam(value = "picId" , required = false) Integer picId , 51 | Map map){ 52 | if(picId != null){ 53 | Picture picture = pictureRepository.findByPicId(picId); 54 | map.put("picture" , picture); 55 | } 56 | return new ModelAndView("picture/index" , map); 57 | } 58 | 59 | @PostMapping("/save") 60 | public ModelAndView save(@Valid PictureForm form , 61 | BindingResult bindingResult , 62 | Map map){ 63 | if(bindingResult.hasErrors()){ 64 | map.put("msg" , bindingResult.getFieldError().getDefaultMessage()); 65 | map.put("url" , "/sell/picture/index"); 66 | return new ModelAndView("common/error" , map); 67 | } 68 | Picture picture = new Picture(); 69 | try{ 70 | if(form.getPicId() != null){ 71 | picture = pictureRepository.findByPicId(form.getPicId()); 72 | } 73 | BeanUtils.copyProperties(form , picture); 74 | pictureRepository.save(picture); 75 | }catch (SellException e){ 76 | map.put("msg" , e.getMessage()); 77 | map.put("url" , "/sell/picture/index"); 78 | return new ModelAndView("common/error" , map); 79 | } 80 | map.put("msg" , "操作成功!"); 81 | map.put("url", "/sell/picture/list"); 82 | return new ModelAndView("common/success", map); 83 | } 84 | 85 | @GetMapping("/delete") 86 | public ModelAndView delete(@RequestParam("picId") Integer picId , Map map){ 87 | Picture picture = pictureRepository.findByPicId(picId); 88 | pictureRepository.delete(picture); 89 | map.put("msg" , "图片删除成功!"); 90 | map.put("url" , "/sell/picture/list"); 91 | return new ModelAndView("common/success" , map); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/controller/SellerCategoryController.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.controller; 2 | 3 | import com.hhh.wechat_order.entity.ProductCategory; 4 | import com.hhh.wechat_order.entity.ProductInfo; 5 | import com.hhh.wechat_order.exception.SellException; 6 | import com.hhh.wechat_order.form.CategoryForm; 7 | import com.hhh.wechat_order.service.CategoryService; 8 | import com.hhh.wechat_order.service.ProductService; 9 | import org.springframework.beans.BeanUtils; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.util.StringUtils; 13 | import org.springframework.validation.BindingResult; 14 | import org.springframework.web.bind.annotation.GetMapping; 15 | import org.springframework.web.bind.annotation.PostMapping; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RequestParam; 18 | import org.springframework.web.servlet.ModelAndView; 19 | 20 | import javax.validation.Valid; 21 | import java.util.List; 22 | import java.util.Map; 23 | import java.util.Optional; 24 | 25 | /** 26 | * 卖家类目Controller层 27 | */ 28 | @Controller 29 | @RequestMapping("/seller/category") 30 | public class SellerCategoryController { 31 | 32 | @Autowired 33 | private CategoryService categoryService; 34 | @Autowired 35 | private ProductService productService; 36 | 37 | /** 38 | * 类目列表 39 | * @param map 40 | * @return 41 | */ 42 | @GetMapping("/list") 43 | public ModelAndView list(Map map){ 44 | List productCategoryList = categoryService.findAll(); 45 | map.put("productCategoryList" , productCategoryList); 46 | return new ModelAndView("category/list" , map); 47 | } 48 | 49 | /** 50 | * 修改 / 新增页面 51 | * @param categoryId 52 | * @param map 53 | * @return 54 | */ 55 | @GetMapping("/index") 56 | public ModelAndView index(@RequestParam(value = "categoryId" , required = false) Integer categoryId , 57 | Map map){ 58 | if(categoryId != null){ 59 | Optional productCategory = categoryService.findById(categoryId); 60 | map.put("productCategory" , productCategory.get()); 61 | } 62 | return new ModelAndView("category/index" , map); 63 | } 64 | 65 | /** 66 | * 新增 / 修改后 , 保存类目 67 | * @param categoryForm 68 | * @param bindingResult 69 | * @param map 70 | * @return 71 | */ 72 | @PostMapping("/save") 73 | public ModelAndView save(@Valid CategoryForm categoryForm , 74 | BindingResult bindingResult , 75 | Map map){ 76 | if(bindingResult.hasErrors()){ 77 | map.put("msg" , bindingResult.getFieldError().getDefaultMessage()); 78 | map.put("url" , "/sell/seller/category/index"); 79 | return new ModelAndView("common/error" , map); 80 | } 81 | try { 82 | if(categoryForm.getCategoryId() != null){ 83 | Optional productCategory = categoryService.findById(categoryForm.getCategoryId()); 84 | List productInfoList = productService.findByCategoryType(productCategory.get().getCategoryType()); 85 | BeanUtils.copyProperties(categoryForm , productCategory.get()); 86 | categoryService.save(productCategory.get()); 87 | for(ProductInfo productInfo : productInfoList){ 88 | productInfo.setCategoryType(productCategory.get().getCategoryType()); 89 | productService.save(productInfo); 90 | } 91 | }else{ 92 | ProductCategory productCategory = new ProductCategory(); 93 | BeanUtils.copyProperties(categoryForm , productCategory); 94 | categoryService.save(productCategory); 95 | } 96 | }catch (SellException e){ 97 | map.put("msg" , e.getMessage()); 98 | map.put("url" , "/sell/seller/category/index"); 99 | return new ModelAndView("common/error" , map); 100 | } 101 | map.put("msg" , "类目操作成功!"); 102 | map.put("url" , "/sell/seller/category/list"); 103 | return new ModelAndView("common/success" , map); 104 | } 105 | 106 | //删除类目 107 | @GetMapping("/delete") 108 | public ModelAndView delete(@RequestParam("categoryId") Integer categoryId , 109 | Map map){ 110 | try { 111 | categoryService.delete(categoryId); 112 | }catch (SellException e){ 113 | map.put("msg" , "还有商品属于该类目 , 不能删除该类目!"); 114 | map.put("url" , "/sell/seller/category/list"); 115 | return new ModelAndView("common/error" , map); 116 | } 117 | map.put("msg" , "类目删除成功!"); 118 | map.put("url" , "/sell/seller/category/list"); 119 | return new ModelAndView("common/success" , map); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/controller/SellerOrderController.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.controller; 2 | 3 | import com.hhh.wechat_order.dto.OrderDTO; 4 | import com.hhh.wechat_order.enums.ResultEnum; 5 | import com.hhh.wechat_order.exception.SellException; 6 | import com.hhh.wechat_order.service.OrderService; 7 | import jodd.util.StringUtil; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.data.domain.Page; 11 | import org.springframework.data.domain.PageRequest; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.GetMapping; 14 | import org.springframework.web.bind.annotation.PostMapping; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RequestParam; 17 | import org.springframework.web.servlet.ModelAndView; 18 | 19 | import javax.servlet.http.HttpServletRequest; 20 | import javax.servlet.http.HttpServletResponse; 21 | import java.io.IOException; 22 | import java.util.Map; 23 | 24 | /** 25 | *卖家端的订单 Controller 层 26 | */ 27 | @Controller 28 | @RequestMapping("/seller/order") 29 | @Slf4j 30 | public class SellerOrderController { 31 | 32 | @Autowired 33 | private OrderService orderService; 34 | 35 | /** 36 | * 卖家的订单列表 37 | * @param page 第几页,从第一页开始 38 | * @param size 一页有多少条数据 39 | * @return 40 | */ 41 | @GetMapping("/list") 42 | public ModelAndView list(@RequestParam(value = "page" , defaultValue = "1") Integer page , 43 | @RequestParam(value = "size" , defaultValue = "10") Integer size , 44 | Map map){ 45 | PageRequest pageRequest = new PageRequest(page - 1 , size); 46 | // Page orderDTOPage = orderService.findList(pageRequest); 47 | Page orderDTOPage = orderService.findOrderMastersByCreateTimeDesc(pageRequest); 48 | map.put("orderDTOPage" , orderDTOPage); 49 | map.put("currentPage" , page); 50 | map.put("size" , size); 51 | return new ModelAndView("order/list" , map); 52 | } 53 | 54 | @PostMapping("/search") 55 | public ModelAndView search(HttpServletRequest request , 56 | HttpServletResponse response , 57 | Map map) throws IOException { 58 | String orderId = request.getParameter("search"); 59 | if (orderId == null || orderId == ""){ 60 | // map.put("msg", ResultEnum.ORDER_NOT_EXIST.getMessage()); 61 | // map.put("url", "/sell/seller/order/list"); 62 | // return new ModelAndView("common/error", map); 63 | response.sendRedirect(request.getContextPath() + "/seller/order/list"); 64 | return null; 65 | } 66 | OrderDTO orderDTO = orderService.findOne(orderId); 67 | map.put("orderDTO" , orderDTO); 68 | return new ModelAndView("order/list1" , map); 69 | } 70 | 71 | /** 72 | * 取消订单 73 | * @param orderId 订单的ID 74 | * @return 75 | */ 76 | @GetMapping("/cancel") 77 | public ModelAndView cancel(@RequestParam("orderId") String orderId , 78 | Map map){ 79 | try{ 80 | OrderDTO orderDTO = orderService.findOne(orderId); 81 | orderService.cancel(orderDTO); 82 | }catch (SellException e){ 83 | log.error("【卖家端取消订单】 发生异常{}" , e); 84 | map.put("msg" , ResultEnum.ORDER_NOT_EXIST.getMessage()); 85 | map.put("url" , "/sell/seller/order/list"); 86 | return new ModelAndView("common/error" , map); 87 | } 88 | map.put("msg" , ResultEnum.ORDER_CANCEL_SUCCESS.getMessage()); 89 | map.put("url" , "/sell/seller/order/list"); 90 | return new ModelAndView("common/success" , map); 91 | } 92 | 93 | /** 94 | * 订单详情 95 | * @param orderId 96 | * @return 97 | */ 98 | @GetMapping("/detail") 99 | public ModelAndView detail(@RequestParam("orderId") String orderId , 100 | Map map) { 101 | OrderDTO orderDTO = new OrderDTO(); 102 | try { 103 | orderDTO = orderService.findOne(orderId); 104 | } catch (SellException e) { 105 | log.error("【卖家端查询订单详情】 发生异常{}", e); 106 | map.put("msg", ResultEnum.ORDER_NOT_EXIST.getMessage()); 107 | map.put("url", "/sell/seller/order/list"); 108 | return new ModelAndView("common/error", map); 109 | } 110 | map.put("orderDTO" , orderDTO); 111 | return new ModelAndView("order/detail", map); 112 | } 113 | 114 | /** 115 | * 订单完结 116 | * @param orderId 117 | * @param map 118 | * @return 119 | */ 120 | @GetMapping("/finish") 121 | public ModelAndView finish(@RequestParam("orderId") String orderId , 122 | Map map){ 123 | try { 124 | OrderDTO orderDTO = orderService.findOne(orderId); 125 | orderService.finish(orderDTO); 126 | }catch (SellException e){ 127 | log.error("【卖家端完结订单】 发生异常{}", e); 128 | map.put("msg" , ResultEnum.ORDER_NOT_EXIST.getMessage()); 129 | map.put("url" , "/sell/seller/order/list"); 130 | return new ModelAndView("common/error" , map); 131 | } 132 | map.put("msg" , ResultEnum.ORDER_FINISH_SUCCESS.getMessage()); 133 | map.put("url" , "/sell/seller/order/list"); 134 | return new ModelAndView("common/success" , map); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.controller; 2 | 3 | import com.hhh.wechat_order.VO.ResultVo; 4 | import com.hhh.wechat_order.entity.User; 5 | import com.hhh.wechat_order.enums.ResultEnum; 6 | import com.hhh.wechat_order.exception.SellException; 7 | import com.hhh.wechat_order.form.UserForm; 8 | import com.hhh.wechat_order.service.UserService; 9 | import com.hhh.wechat_order.utils.ResultVOUtil; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.validation.BindingResult; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | import javax.validation.Valid; 16 | 17 | /** 18 | * 用户相关 19 | * @author HHH 20 | * @version 1.0 2019/10/18 21 | */ 22 | @RestController 23 | @RequestMapping("/user") 24 | @Slf4j 25 | public class UserController { 26 | 27 | @Autowired 28 | private UserService userService; 29 | 30 | @PostMapping("/save") 31 | public ResultVo create(@Valid UserForm form , 32 | BindingResult bindingResult){ 33 | if(bindingResult.hasErrors()){ 34 | log.error("参数不正确, userForm={}", form); 35 | throw new SellException(ResultEnum.PARAM_ERROR.getCode(), 36 | bindingResult.getFieldError().getDefaultMessage()); 37 | } 38 | User userOld = userService.findByOpenid(form.getOpenid()); 39 | User user = new User(); 40 | if(userOld != null){ 41 | user.setUserId(userOld.getUserId()); 42 | } 43 | user.setUserName(form.getUsername()); 44 | user.setOpenid(form.getOpenid()); 45 | user.setUserPhone(form.getPhone()); 46 | user.setUserTable(form.getUsertable()); 47 | user.setUserNumber(form.getUsernumber()); 48 | userService.save(user); 49 | 50 | return ResultVOUtil.success(user); 51 | } 52 | 53 | @GetMapping("/getUserInfo") 54 | public ResultVo getUserInfo(@RequestParam("openid") String openid){ 55 | User user = userService.findByOpenid(openid); 56 | return ResultVOUtil.success(user); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/converter/OrderForm2OrderDTOConverter.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.converter; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.reflect.TypeToken; 5 | import com.hhh.wechat_order.dto.OrderDTO; 6 | import com.hhh.wechat_order.entity.OrderDetail; 7 | import com.hhh.wechat_order.enums.ResultEnum; 8 | import com.hhh.wechat_order.exception.SellException; 9 | import com.hhh.wechat_order.form.OrderForm; 10 | import lombok.extern.slf4j.Slf4j; 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * OrderForm 对象转换成 OrderDTO 对象 16 | */ 17 | @Slf4j 18 | public class OrderForm2OrderDTOConverter { 19 | 20 | public static OrderDTO conver(OrderForm orderForm){ 21 | Gson gson = new Gson(); 22 | OrderDTO orderDTO = new OrderDTO(); 23 | 24 | orderDTO.setBuyerName(orderForm.getName()); 25 | orderDTO.setBuyerPhone(orderForm.getPhone()); 26 | orderDTO.setBuyerAddress(orderForm.getAddress()); 27 | orderDTO.setBuyerOpenid(orderForm.getOpenid()); 28 | 29 | List orderDetailList = new ArrayList<>(); 30 | try { 31 | orderDetailList = gson.fromJson(orderForm.getItems() , 32 | new TypeToken>(){}.getType()); 33 | }catch (Exception e){ 34 | log.error("【对象转换】 错误 , string={}" , orderForm.getItems()); 35 | throw new SellException(ResultEnum.PARAM_ERROR); 36 | } 37 | orderDTO.setOrderDetailList(orderDetailList); 38 | return orderDTO; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/converter/OrderMaster2OrderDTOConverter.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.converter; 2 | 3 | import com.hhh.wechat_order.dto.OrderDTO; 4 | import com.hhh.wechat_order.entity.OrderMaster; 5 | import org.springframework.beans.BeanUtils; 6 | import java.util.List; 7 | import java.util.stream.Collectors; 8 | 9 | /** 10 | * 将OrderMaster对象转换成OrderDTO对象 11 | */ 12 | public class OrderMaster2OrderDTOConverter { 13 | 14 | public static OrderDTO convert(OrderMaster orderMaster){ 15 | OrderDTO orderDTO = new OrderDTO(); 16 | BeanUtils.copyProperties(orderMaster , orderDTO); 17 | return orderDTO; 18 | } 19 | 20 | public static List convert(List orderMasterList){ 21 | return orderMasterList.stream().map(e -> convert(e)).collect(Collectors.toList()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/dto/CartDTO.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.dto; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 购物车 7 | */ 8 | @Data 9 | public class CartDTO { 10 | 11 | //商品id 12 | private String productId; 13 | 14 | //数量 15 | private Integer productQuantity; 16 | 17 | public CartDTO(String productId, Integer productQuantity) { 18 | this.productId = productId; 19 | this.productQuantity = productQuantity; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/dto/OrderDTO.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 6 | import com.hhh.wechat_order.entity.OrderDetail; 7 | import com.hhh.wechat_order.enums.OrderStatusEnum; 8 | import com.hhh.wechat_order.enums.PayStatusEnum; 9 | import com.hhh.wechat_order.utils.EnumUtil; 10 | import com.hhh.wechat_order.utils.serializer.Date2LongSerializer; 11 | import lombok.Data; 12 | import java.math.BigDecimal; 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | /** 17 | * 订单传输对象类 18 | */ 19 | @Data 20 | public class OrderDTO { 21 | 22 | //订单的id 23 | private String orderId; 24 | 25 | //买家名字 26 | private String buyerName; 27 | 28 | //买家的电话 29 | private String buyerPhone; 30 | 31 | //买家的地址 32 | private String buyerAddress; 33 | 34 | //买家微信Openid 35 | private String buyerOpenid; 36 | 37 | //订单总金额 38 | private BigDecimal orderAmount; 39 | 40 | //订单状态,默认为新下单 41 | private Integer orderStatus; 42 | 43 | //支付状态,默认为0,未支付 44 | private Integer payStatus; 45 | 46 | private String orderStatusStr; 47 | 48 | //创建时间 49 | @JsonSerialize(using = Date2LongSerializer.class) 50 | private Date createTime; 51 | 52 | //修改时间 53 | @JsonSerialize(using = Date2LongSerializer.class) 54 | private Date updateTime; 55 | 56 | //订单详情列表 57 | List orderDetailList; 58 | 59 | /** 60 | * 获取订单状态的枚举类 61 | * @return 62 | */ 63 | @JsonIgnore 64 | public OrderStatusEnum getOrderStatusEnum(){ 65 | return EnumUtil.getByCode(orderStatus , OrderStatusEnum.class); 66 | } 67 | 68 | /** 69 | * 获取支付状态的枚举类 70 | * @return 71 | */ 72 | @JsonIgnore 73 | public PayStatusEnum getPayStatusEnum(){ 74 | return EnumUtil.getByCode(payStatus , PayStatusEnum.class); 75 | } 76 | 77 | @JsonIgnore 78 | public String getOrderStatusStr(Integer orderStatus2) { 79 | return EnumUtil.getByCode(orderStatus2, OrderStatusEnum.class).getMessage(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/entity/Comment.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.DynamicInsert; 5 | import org.hibernate.annotations.DynamicUpdate; 6 | 7 | import javax.persistence.Entity; 8 | import javax.persistence.GeneratedValue; 9 | import javax.persistence.Id; 10 | import java.util.Date; 11 | 12 | /** 13 | * 评论表 14 | * @author HHH 15 | * @version 1.0 2019/10/16 16 | */ 17 | @Data 18 | @Entity 19 | @DynamicUpdate 20 | @DynamicInsert 21 | public class Comment { 22 | 23 | //评论表id 24 | @Id 25 | @GeneratedValue 26 | private Integer commentId; 27 | 28 | //评论者的名字 29 | private String commentName; 30 | 31 | //评论者的openid 32 | private String openid; 33 | 34 | //评论内容 35 | private String commentContent; 36 | 37 | //评论者的头像 38 | private String avatarUrl; 39 | 40 | //创建时间 41 | private Date createTime; 42 | } 43 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/entity/OrderDetail.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.entity; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.Id; 7 | import java.math.BigDecimal; 8 | 9 | /** 10 | * 订单详情表 11 | */ 12 | @Entity 13 | @Data 14 | public class OrderDetail { 15 | 16 | //订单详情表id 17 | @Id 18 | private String detailId; 19 | 20 | //订单id 21 | private String orderId; 22 | 23 | //商品id 24 | private String productId; 25 | 26 | //商品名称 27 | private String productName; 28 | 29 | //商品单价 30 | private BigDecimal productPrice; 31 | 32 | //商品数量 33 | private Integer productQuantity; 34 | 35 | //商品图片 36 | private String productIcon; 37 | } 38 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/entity/OrderMaster.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.entity; 2 | 3 | import com.hhh.wechat_order.enums.OrderStatusEnum; 4 | import com.hhh.wechat_order.enums.PayStatusEnum; 5 | import lombok.Data; 6 | import org.hibernate.annotations.DynamicInsert; 7 | import org.hibernate.annotations.DynamicUpdate; 8 | import javax.persistence.Entity; 9 | import javax.persistence.Id; 10 | import javax.persistence.Transient; 11 | import java.math.BigDecimal; 12 | import java.util.Date; 13 | import java.util.List; 14 | 15 | /** 16 | * 订单的主表 17 | */ 18 | @Entity 19 | @Data 20 | @DynamicUpdate 21 | @DynamicInsert 22 | public class OrderMaster { 23 | 24 | //订单的id 25 | @Id 26 | private String orderId; 27 | 28 | //买家名字 29 | private String buyerName; 30 | 31 | //买家的电话 32 | private String buyerPhone; 33 | 34 | //买家的地址 35 | private String buyerAddress; 36 | 37 | //买家微信Openid 38 | private String buyerOpenid; 39 | 40 | //订单总金额 41 | private BigDecimal orderAmount; 42 | 43 | //订单状态,默认为新下单 44 | private Integer orderStatus = OrderStatusEnum.NEW.getCode(); 45 | 46 | //支付状态,默认为0,未支付 47 | //TODO 48 | private Integer payStatus = PayStatusEnum.WAIT.getCode(); 49 | 50 | //创建时间 51 | private Date createTime; 52 | 53 | //修改时间 54 | private Date updateTime; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/entity/Picture.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.DynamicInsert; 5 | import org.hibernate.annotations.DynamicUpdate; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.Id; 9 | import java.util.Date; 10 | 11 | /** 12 | * 轮播图 13 | * @author HHH 14 | * @version 1.0 2019/10/16 15 | */ 16 | @Data 17 | @Entity 18 | @DynamicInsert 19 | @DynamicUpdate 20 | public class Picture { 21 | 22 | //图片id 23 | @Id 24 | @GeneratedValue 25 | private Integer picId; 26 | 27 | //图片地址 28 | private String picUrl; 29 | 30 | //图片信息 31 | private String picMessage; 32 | 33 | //创建时间 34 | private Date createTime; 35 | } 36 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/entity/ProductCategory.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.DynamicInsert; 5 | import org.hibernate.annotations.DynamicUpdate; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import java.util.Date; 11 | 12 | /** 13 | * 商品类目表 14 | */ 15 | @Entity 16 | @DynamicUpdate 17 | @DynamicInsert 18 | @Data 19 | public class ProductCategory { 20 | 21 | //类目id 22 | @Id 23 | @GeneratedValue(strategy = GenerationType.IDENTITY) 24 | private Integer categoryId; 25 | 26 | //类目名称 27 | private String categoryName; 28 | 29 | //类目编号 30 | private Integer categoryType; 31 | 32 | //创建时间 33 | private Date createTime; 34 | 35 | //修改时间 36 | private Date updateTime; 37 | 38 | public ProductCategory() { } 39 | 40 | public ProductCategory(String categoryName, Integer categoryType) { 41 | this.categoryName = categoryName; 42 | this.categoryType = categoryType; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/entity/ProductInfo.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.hhh.wechat_order.enums.ProductStatusEnum; 5 | import com.hhh.wechat_order.utils.EnumUtil; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import org.hibernate.annotations.DynamicInsert; 9 | import org.hibernate.annotations.DynamicUpdate; 10 | 11 | import javax.persistence.Entity; 12 | import javax.persistence.Id; 13 | import java.math.BigDecimal; 14 | import java.util.Date; 15 | 16 | /** 17 | * 商品表 18 | */ 19 | @Entity 20 | @Data 21 | @AllArgsConstructor 22 | @DynamicUpdate 23 | @DynamicInsert 24 | public class ProductInfo { 25 | 26 | //商品id 27 | @Id 28 | private String productId; 29 | 30 | //商品名称 31 | private String productName; 32 | 33 | //商品价格 34 | private BigDecimal productPrice; 35 | 36 | //商品库存 37 | private Integer productStock; 38 | 39 | //商品图片 40 | private String productIcon; 41 | 42 | //商品描述 43 | private String productDescription; 44 | 45 | //商品状态( 0正常 , 1下架 ) 46 | private Integer productStatus = ProductStatusEnum.UP.getCode(); 47 | 48 | //类目编号 49 | private Integer categoryType; 50 | 51 | //创建时间 52 | private Date createTime; 53 | 54 | //修改时间 55 | private Date updateTime; 56 | 57 | public ProductInfo() { } 58 | 59 | @JsonIgnore 60 | public ProductStatusEnum getProductStatusEnum(){ 61 | return EnumUtil.getByCode(productStatus , ProductStatusEnum.class); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/entity/SellerInfo.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.DynamicInsert; 5 | import org.hibernate.annotations.DynamicUpdate; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.Id; 9 | import java.util.Date; 10 | 11 | /** 12 | * 商家信息表 13 | * @author HHH 14 | * @version 1.0 2019/10/16 15 | */ 16 | @Data 17 | @Entity 18 | @DynamicInsert 19 | @DynamicUpdate 20 | public class SellerInfo { 21 | 22 | //商家用户id 23 | @Id 24 | @GeneratedValue 25 | private Integer sellerId; 26 | 27 | //商家用户名称 28 | private String username; 29 | 30 | //商家登录密码 31 | private String password; 32 | 33 | //商家手机 34 | private String phone; 35 | 36 | //创建时间 37 | private Date createTime; 38 | 39 | //修改时间 40 | private Date updateTime; 41 | } 42 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.entity; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.DynamicInsert; 5 | import org.hibernate.annotations.DynamicUpdate; 6 | 7 | import javax.persistence.Entity; 8 | import javax.persistence.GeneratedValue; 9 | import javax.persistence.Id; 10 | import java.util.Date; 11 | 12 | /** 13 | * 就餐用户信息 14 | * @author HHH 15 | * @version 1.0 2019/10/16 16 | */ 17 | @Data 18 | @Entity 19 | @DynamicUpdate 20 | @DynamicInsert 21 | public class User { 22 | 23 | //用户id 24 | @Id 25 | @GeneratedValue 26 | private Integer userId; 27 | 28 | //用户名称 29 | private String userName; 30 | 31 | //用户手机号 32 | private String userPhone; 33 | 34 | //用户openid 35 | private String openid; 36 | 37 | //用户就餐的桌号 38 | private String userTable; 39 | 40 | //用户就餐人数 41 | private String userNumber; 42 | 43 | //创建时间 44 | private Date createTime; 45 | 46 | //修改时间 47 | private Date updateTime; 48 | } 49 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/enums/CodeEnum.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.enums; 2 | 3 | public interface CodeEnum { 4 | 5 | T getCode(); 6 | } 7 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/enums/OrderStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * 订单状态 7 | */ 8 | @Getter 9 | public enum OrderStatusEnum implements CodeEnum { 10 | NEW(0,"新订单未支付") , 11 | NEW_PAYED(1 , "新订单已支付" ) , 12 | CANCEL(2,"订单取消") , 13 | FINSHED(3,"订单完成"), 14 | COMMENT(4 , "已评价") , 15 | ; 16 | 17 | private Integer code; 18 | 19 | private String message; 20 | 21 | OrderStatusEnum(Integer code, String message) { 22 | this.code = code; 23 | this.message = message; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/enums/PayStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.enums; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public enum PayStatusEnum implements CodeEnum { 7 | 8 | WAIT(0,"等待支付"), 9 | SUCCESS(1,"支付成功") , 10 | REBACK_MONEY(2 , "已退款") 11 | ; 12 | 13 | private Integer code; 14 | 15 | private String message; 16 | 17 | PayStatusEnum(Integer code, String message) { 18 | this.code = code; 19 | this.message = message; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/enums/ProductStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * 商品状态的枚举类 7 | */ 8 | @Getter 9 | public enum ProductStatusEnum implements CodeEnum { 10 | UP(0 , "在售") , 11 | DOWN(1 , "下架") 12 | ; 13 | 14 | private Integer code; 15 | 16 | private String message; 17 | 18 | ProductStatusEnum(Integer code, String message) { 19 | this.code = code; 20 | this.message = message; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/enums/ResultEnum.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * 错误信息的枚举类 7 | */ 8 | @Getter 9 | public enum ResultEnum { 10 | 11 | SUCCESS(0,"成功"), 12 | 13 | PARAM_ERROR(1,"参数不正确"), 14 | 15 | PRODUCT_NOT_EXIST(10,"商品不存在"), 16 | 17 | PRODUCT_STOCK_ERROR(11 , "商品库存不足"), 18 | 19 | ORDER_NOT_EXIST(12 , "订单不存在"), 20 | 21 | ORDERDETAIL_NOT_EXIST(13 , "订单详情不存在"), 22 | 23 | ORDER_STATUS_ERROR(14 , "订单状态不正确"), 24 | 25 | ORDER_UPDATE_FAIL(15 , "订单更新失败"), 26 | 27 | ORDER_DETAIL_EMPTY(16 , "订单详情为空"), 28 | 29 | ORDER_PAY_STATUS_ERROR(17 , "订单支付状态不正确"), 30 | 31 | CART_EMPTY(18,"购物车为空"), 32 | 33 | ORDER_OWNER_ERROR(19,"该订单不属于当前用户"), 34 | 35 | ORDER_NO_PAY(20 , "用户还没有支付,提示用户支付"), 36 | 37 | WXPAY_NOTIFY_MONEY_VERIFY_ERROR(21 , "微信支付异步通知金额校验不正确"), 38 | 39 | ORDER_CANCEL_SUCCESS(22,"订单取消成功"), 40 | 41 | ORDER_FINISH_SUCCESS(23,"订单完结成功"), 42 | 43 | PRODUCT_STATUS_ERROR(24,"商品状态不正确"), 44 | 45 | LOGIN_FAIL(25 , "登录失败 , 登录信息不正确"), 46 | 47 | LOGOUT_SUCCESS(26 , "登出成功") , 48 | 49 | PRODUCT_IN_CATEGORY_ERROR(27 , "类目中还有商品") , 50 | ; 51 | 52 | private Integer code; 53 | 54 | private String message; 55 | 56 | ResultEnum(Integer code, String message) { 57 | this.code = code; 58 | this.message = message; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/exception/SellException.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.exception; 2 | 3 | import com.hhh.wechat_order.enums.ResultEnum; 4 | 5 | /** 6 | * 异常错误 7 | */ 8 | public class SellException extends RuntimeException { 9 | 10 | private Integer code; 11 | 12 | public SellException(ResultEnum resultEnum) { 13 | super(resultEnum.getMessage()); 14 | this.code = resultEnum.getCode(); 15 | } 16 | 17 | public SellException(Integer code , String message) { 18 | super(message); 19 | this.code = code; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/exception/SellerAuthorizeException.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.exception; 2 | 3 | public class SellerAuthorizeException extends RuntimeException { 4 | } 5 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/form/CategoryForm.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.form; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | 9 | /** 10 | * 类目表单对象 11 | */ 12 | @Data 13 | public class CategoryForm { 14 | 15 | //类目id 16 | private Integer categoryId; 17 | 18 | //类目名称 19 | private String categoryName; 20 | 21 | //类目编号 22 | private Integer categoryType; 23 | } 24 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/form/OrderForm.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.form; 2 | 3 | import lombok.Data; 4 | 5 | import javax.validation.constraints.NotEmpty; 6 | 7 | /** 8 | * 订单表单验证 9 | */ 10 | @Data 11 | public class OrderForm { 12 | 13 | //买家姓名 14 | @NotEmpty(message = "姓名必填") 15 | private String name; 16 | 17 | //买家电话 18 | @NotEmpty(message = "手机号必填") 19 | private String phone; 20 | 21 | //买家地址 22 | @NotEmpty(message = "地址必填") 23 | private String address; 24 | 25 | //买家微信openid 26 | @NotEmpty(message = "openid必填") 27 | private String openid; 28 | 29 | //购物车 30 | @NotEmpty(message = "购物车不能为空") 31 | private String items; 32 | } 33 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/form/PictureForm.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.form; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 图片表单 7 | * @author HHH 8 | * @version 1.0 2019/10/17 9 | */ 10 | @Data 11 | public class PictureForm { 12 | 13 | private Integer picId; 14 | private String picUrl; 15 | private String picMessage; 16 | // private Data createTime; 17 | } 18 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/form/ProductForm.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.form; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Id; 6 | import java.math.BigDecimal; 7 | 8 | /** 9 | * 表单提交的字段 10 | */ 11 | @Data 12 | public class ProductForm { 13 | 14 | //商品id 15 | private String productId; 16 | 17 | //商品名称 18 | private String productName; 19 | 20 | //商品价格 21 | private BigDecimal productPrice; 22 | 23 | //商品库存 24 | private Integer productStock; 25 | 26 | //商品图片 27 | private String productIcon; 28 | 29 | //商品描述 30 | private String productDescription; 31 | 32 | //类目编号 33 | private Integer categoryType; 34 | } 35 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/form/SellerForm.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.form; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 商家表单 7 | * @author HHH 8 | * @version 1.0 2019/10/17 9 | */ 10 | @Data 11 | public class SellerForm { 12 | 13 | private String username; 14 | private String password; 15 | private String phone; 16 | private Integer sellerId; 17 | } 18 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/form/UserForm.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.form; 2 | 3 | import lombok.Data; 4 | 5 | import javax.validation.constraints.NotEmpty; 6 | 7 | /** 8 | * 买家表单 9 | * @author HHH 10 | * @version 1.0 2019/10/17 11 | */ 12 | @Data 13 | public class UserForm { 14 | 15 | //买家姓名 16 | @NotEmpty(message = "姓名必填") 17 | private String username; 18 | 19 | //买家手机号 20 | @NotEmpty(message = "手机号必填") 21 | private String phone; 22 | 23 | //买家openid 24 | @NotEmpty(message = "openid必填") 25 | private String openid; 26 | 27 | private String usertable; 28 | 29 | private String usernumber; 30 | } 31 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/handler/SellerExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.handler; 2 | 3 | import com.hhh.wechat_order.VO.ResultVo; 4 | import com.hhh.wechat_order.config.ProjectUrlConfig; 5 | import com.hhh.wechat_order.exception.SellException; 6 | import com.hhh.wechat_order.exception.SellerAuthorizeException; 7 | import com.hhh.wechat_order.utils.ResultVOUtil; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.ControllerAdvice; 10 | import org.springframework.web.bind.annotation.ExceptionHandler; 11 | import org.springframework.web.bind.annotation.ResponseBody; 12 | import org.springframework.web.bind.annotation.RestController; 13 | import org.springframework.web.servlet.ModelAndView; 14 | 15 | /** 16 | * 处理登录异常 17 | */ 18 | @ControllerAdvice 19 | public class SellerExceptionHandler { 20 | 21 | @Autowired 22 | private ProjectUrlConfig projectUrlConfig; 23 | 24 | //拦截登录异常 25 | @ExceptionHandler(value = SellerAuthorizeException.class) 26 | public ModelAndView handlerAuthorizeException(){ 27 | // return new ModelAndView("redirect:" 28 | // .concat(projectUrlConfig.getWechatOpenAuthorize()) 29 | // .concat("/sell/wechat/qrAuthorize") 30 | // .concat("?returnUrl=") 31 | // .concat(projectUrlConfig.getSell()) 32 | // .concat("/sell/seller/login")); 33 | return new ModelAndView("common/loginView"); 34 | } 35 | 36 | // @ExceptionHandler(value = SellException.class) 37 | // @ResponseBody 38 | // public ResultVo handlerSellerException(SellException e){ 39 | // return ResultVOUtil.error(e.getCode() , e.getMessage()); 40 | // } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/repository/CommentRepository.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.repository; 2 | 3 | import com.hhh.wechat_order.entity.Comment; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import java.util.List; 6 | 7 | /** 8 | * 评论的Dao接口 9 | * @author HHH 10 | * @version 1.0 2019/10/17 11 | */ 12 | public interface CommentRepository extends JpaRepository { 13 | 14 | /** 15 | * 通过openid查询所有的评论 16 | * @param openid 17 | * @return 18 | */ 19 | List findAllByOpenid(String openid); 20 | } 21 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/repository/OrderDetailRepository.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.repository; 2 | 3 | import com.hhh.wechat_order.entity.OrderDetail; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.List; 7 | 8 | public interface OrderDetailRepository extends JpaRepository { 9 | 10 | /** 11 | * 通过 orderId 查询所有的订单详情 12 | * @param orderId 13 | * @return 14 | */ 15 | List findByOrderId(String orderId); 16 | } 17 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/repository/OrderMasterRepository.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.repository; 2 | 3 | import com.hhh.wechat_order.entity.OrderMaster; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.Pageable; 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.data.jpa.repository.Query; 8 | 9 | import java.util.List; 10 | 11 | public interface OrderMasterRepository extends JpaRepository { 12 | 13 | /** 14 | * 通过 openid 查询所有的订单 15 | * @param buyerOpenid 16 | * @param pageable 17 | * @return 分页对象 18 | */ 19 | Page findByBuyerOpenid(String buyerOpenid , Pageable pageable); 20 | 21 | /** 22 | * 通过openid 和 orderStatus 查询订单 23 | * @param buyerOpenid 24 | * @param orderStatus 25 | * @return 26 | */ 27 | List findByBuyerOpenidAndOrderStatus(String buyerOpenid , Integer orderStatus); 28 | 29 | @Query("select o from OrderMaster o ORDER BY o.createTime DESC ") 30 | Page findOrderMastersByCreateTimeDesc(Pageable pageable); 31 | } 32 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/repository/PictureRepository.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.repository; 2 | 3 | import com.hhh.wechat_order.entity.Picture; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | /** 7 | * 图片的 DAO 接口 8 | * @author HHH 9 | * @version 1.0 2019/10/17 10 | */ 11 | public interface PictureRepository extends JpaRepository { 12 | 13 | /** 14 | * 通过 picId 查询该图片 15 | * @param picId 16 | * @return Picture 对象 17 | */ 18 | Picture findByPicId(Integer picId); 19 | } 20 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/repository/ProductCategoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.repository; 2 | 3 | import com.hhh.wechat_order.entity.ProductCategory; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import java.util.List; 6 | 7 | /** 8 | * 商品类目的Dao层 9 | */ 10 | public interface ProductCategoryRepository extends JpaRepository { 11 | 12 | /** 13 | *通过 类目编号 查询类目 14 | * @param categoryTypeList 类目编号的列表 15 | * @return 16 | */ 17 | List findByCategoryTypeIn(List categoryTypeList); 18 | } 19 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/repository/ProductInfoRepository.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.repository; 2 | 3 | import com.hhh.wechat_order.entity.ProductInfo; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import java.util.List; 6 | 7 | public interface ProductInfoRepository extends JpaRepository { 8 | 9 | /** 10 | * 通过 productStatus 查询所有的商品信息 11 | * @param productStatus 12 | * @return 13 | */ 14 | List findByProductStatus(Integer productStatus); 15 | 16 | /** 17 | * 通过 productCategory 查询所有的商品信息 18 | * @param productCategory 19 | * @return 20 | */ 21 | List findByCategoryType(Integer productCategory); 22 | } 23 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/repository/SellerInfoRepository.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.repository; 2 | 3 | import com.hhh.wechat_order.entity.SellerInfo; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | /** 7 | * 商家信息Dao接口 8 | */ 9 | public interface SellerInfoRepository extends JpaRepository { 10 | 11 | /** 12 | * 通过 phone 查询商家信息 13 | * @param phone 14 | * @return 15 | */ 16 | SellerInfo findByPhone(String phone); 17 | 18 | /** 19 | * 通过 id 查询商家信息 20 | * @param sellerId 21 | * @return 22 | */ 23 | SellerInfo findBySellerId(Integer sellerId); 24 | } 25 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.repository; 2 | 3 | import com.hhh.wechat_order.entity.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | /** 7 | * 用户信息Dao接口 8 | * @author HHH 9 | * @version 1.0 2019/10/17 10 | */ 11 | public interface UserRepository extends JpaRepository { 12 | 13 | /** 14 | * 通过 openid 查询用户信息 15 | * @param openid 16 | * @return 17 | */ 18 | User findByOpenid(String openid); 19 | } 20 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/service/BuyerService.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service; 2 | 3 | import com.hhh.wechat_order.dto.OrderDTO; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 买家Service层接口 9 | */ 10 | public interface BuyerService { 11 | 12 | //查询一个订单 13 | OrderDTO findOrderOne(String openid , String orderId); 14 | 15 | //查询某个用户的所有订单 16 | List findOrderList(String openid , Integer status); 17 | 18 | //取消订单 19 | OrderDTO cancelOrder(String openid , String orderId); 20 | } 21 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/service/CategoryService.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service; 2 | 3 | import com.hhh.wechat_order.entity.ProductCategory; 4 | 5 | import java.util.List; 6 | import java.util.Optional; 7 | 8 | /** 9 | * 商品类目的Service层接口 10 | */ 11 | 12 | public interface CategoryService { 13 | 14 | //根据类目的id查找类目的信息 15 | Optional findById(Integer categoryId); 16 | 17 | //查找所有的类目信息 18 | List findAll(); 19 | 20 | //根据类目编号列表的值,查找出类目信息(多条) 21 | List findByCategoryTypeIn(List categoryTypeList); 22 | 23 | //保存类目信息 24 | ProductCategory save(ProductCategory productCategory); 25 | 26 | //删除类目 27 | void delete(Integer categoryId); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service; 2 | 3 | import com.hhh.wechat_order.dto.OrderDTO; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.Pageable; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 订单的Service层 11 | */ 12 | public interface OrderService { 13 | 14 | //创建订单 15 | OrderDTO create(OrderDTO orderDTO); 16 | 17 | //查询单个订单 18 | OrderDTO findOne(String orderId); 19 | 20 | //查询订单列表(指定买家的订单) 21 | Page findList(String buyerOpenid , Pageable pageable); 22 | 23 | //查询订单列表(所有买家的订单) 24 | Page findList(Pageable pageable); 25 | 26 | //查询订单列表(所有买家的订单)根据创建时间排序(降序) 27 | Page findOrderMastersByCreateTimeDesc(Pageable pageable); 28 | 29 | //查询不同状态的订单列表 30 | List findListStats(String buyerOpenid , Integer orderStatus); 31 | 32 | //取消订单 33 | OrderDTO cancel(OrderDTO orderDTO); 34 | 35 | //完结订单 36 | OrderDTO finish(OrderDTO orderDTO); 37 | 38 | //支付订单 39 | OrderDTO paid(OrderDTO orderDTO); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service; 2 | 3 | import com.hhh.wechat_order.dto.CartDTO; 4 | import com.hhh.wechat_order.entity.ProductInfo; 5 | import org.springframework.data.domain.Page; 6 | import org.springframework.data.domain.Pageable; 7 | 8 | import java.util.List; 9 | import java.util.Optional; 10 | 11 | /** 12 | *商品Service层的接口 13 | */ 14 | public interface ProductService { 15 | 16 | //通过商品id查询商品 17 | Optional findById(String productId); 18 | 19 | //查询所有在架商品列表 20 | List findUpAll(); 21 | 22 | //查询所有商品(分页) 23 | Page findAll(Pageable pageable); 24 | 25 | //通过类目编号查询商品列表 26 | List findByCategoryType(Integer categoryType); 27 | 28 | //保存商品 29 | ProductInfo save(ProductInfo productInfo); 30 | 31 | //加库存 32 | void increaseStock(List cartDTOList); 33 | 34 | //减库存 35 | void decreaseStock(List cartDTOList); 36 | 37 | //上架商品 38 | ProductInfo onSale(String productId); 39 | 40 | //下架商品 41 | ProductInfo offSale(String productId); 42 | 43 | //删除商品 44 | void delete(String productId); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/service/SellerService.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service; 2 | 3 | import com.hhh.wechat_order.entity.SellerInfo; 4 | 5 | public interface SellerService { 6 | 7 | //通过phone 查询卖家端信息 8 | SellerInfo findSellerInfoByPhone(String phone); 9 | } 10 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service; 2 | 3 | import com.hhh.wechat_order.entity.User; 4 | 5 | /** 6 | * 用户端 7 | * @author HHH 8 | * @version 1.0 2019/10/17 9 | */ 10 | public interface UserService { 11 | 12 | //通过 openid 查询用户信息 13 | User findByOpenid(String openid); 14 | 15 | //保存 16 | void save(User user); 17 | } 18 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/service/WebSocket.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Component; 5 | import javax.websocket.OnClose; 6 | import javax.websocket.OnMessage; 7 | import javax.websocket.OnOpen; 8 | import javax.websocket.Session; 9 | import javax.websocket.server.ServerEndpoint; 10 | import java.util.concurrent.CopyOnWriteArraySet; 11 | 12 | /** 13 | * websocket操作 14 | */ 15 | @Component 16 | @ServerEndpoint("/webSocket") 17 | @Slf4j 18 | public class WebSocket { 19 | 20 | private Session session; 21 | 22 | private static CopyOnWriteArraySet webSocketSet = new CopyOnWriteArraySet<>(); 23 | 24 | @OnOpen 25 | public void onOpen(Session session){ 26 | this.session = session; 27 | webSocketSet.add(this); 28 | log.info("【websocket 消息】有新的连接 , 总数:{}" , webSocketSet.size()); 29 | } 30 | 31 | @OnClose 32 | public void onClose(){ 33 | webSocketSet.remove(this); 34 | log.info("【websocket消息】连接断开 , 总数:{}" , webSocketSet.size()); 35 | } 36 | 37 | @OnMessage 38 | public void onMessage(String message){ 39 | log.info("【websocket消息】收到客户端发来的消息:{} " , message); 40 | } 41 | 42 | public void sendMessage(String message){ 43 | for(WebSocket webSocket : webSocketSet){ 44 | log.info("【websocket消息】广播消息 , message={}" , message); 45 | try { 46 | webSocket.session.getBasicRemote().sendText(message); 47 | }catch (Exception e){ 48 | e.printStackTrace(); 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/service/impl/BuyerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service.impl; 2 | 3 | import com.hhh.wechat_order.dto.OrderDTO; 4 | import com.hhh.wechat_order.enums.ResultEnum; 5 | import com.hhh.wechat_order.exception.SellException; 6 | import com.hhh.wechat_order.service.BuyerService; 7 | import com.hhh.wechat_order.service.OrderService; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | @Service 16 | @Slf4j 17 | public class BuyerServiceImpl implements BuyerService { 18 | 19 | @Autowired 20 | private OrderService orderService; 21 | 22 | //判断是否属于自己的订单方法 23 | private OrderDTO checkOrderOwner(String openid , String orderId){ 24 | OrderDTO orderDTO = orderService.findOne(orderId); 25 | //判断订单是否为空 26 | if(orderDTO == null){ 27 | return null; 28 | } 29 | //判断是否属于自己的订单 30 | if( !orderDTO.getBuyerOpenid().equalsIgnoreCase(openid)){ 31 | log.error("【查询订单】订单的openid不一致 , openid={} , orderDTO={}" ,openid , orderDTO); 32 | throw new SellException(ResultEnum.ORDER_OWNER_ERROR); 33 | } 34 | return orderDTO; 35 | } 36 | 37 | @Override 38 | public OrderDTO findOrderOne(String openid, String orderId) { 39 | return checkOrderOwner(openid , orderId); 40 | } 41 | 42 | @Override 43 | public List findOrderList(String openid, Integer status) { 44 | List list = new ArrayList<>(); 45 | list.clear(); 46 | 47 | List listStats = orderService.findListStats(openid , status); 48 | listStats.forEach((orderDTO) -> { 49 | String orderId = orderDTO.getOrderId(); 50 | OrderDTO one = orderService.findOne(orderId); 51 | list.add(one); 52 | }); 53 | return list; 54 | } 55 | 56 | @Override 57 | public OrderDTO cancelOrder(String openid, String orderId) { 58 | OrderDTO orderDTO = checkOrderOwner(openid, orderId); 59 | if(orderDTO == null){ 60 | log.error("【取消订单】查不到改订单 , orderId={}" , orderId); 61 | throw new SellException(ResultEnum.ORDER_NOT_EXIST); 62 | } 63 | return orderService.cancel(orderDTO); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/service/impl/CategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service.impl; 2 | 3 | import com.hhh.wechat_order.entity.ProductCategory; 4 | import com.hhh.wechat_order.entity.ProductInfo; 5 | import com.hhh.wechat_order.enums.ResultEnum; 6 | import com.hhh.wechat_order.exception.SellException; 7 | import com.hhh.wechat_order.repository.ProductCategoryRepository; 8 | import com.hhh.wechat_order.repository.ProductInfoRepository; 9 | import com.hhh.wechat_order.service.CategoryService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | import java.util.List; 13 | import java.util.Optional; 14 | 15 | /** 16 | * 商品类目的Service层实现类 17 | */ 18 | 19 | @Service 20 | public class CategoryServiceImpl implements CategoryService { 21 | 22 | @Autowired 23 | private ProductCategoryRepository repository; 24 | @Autowired 25 | private ProductInfoRepository productInfoRepository; 26 | 27 | //根据类目的id查找类目的信息 28 | @Override 29 | public Optional findById(Integer categoryId) { 30 | return repository.findById(categoryId); 31 | } 32 | 33 | //查找所有的类目信息 34 | @Override 35 | public List findAll() { 36 | return repository.findAll(); 37 | } 38 | 39 | //根据类目编号列表的值,查找出类目信息(多条) 40 | @Override 41 | public List findByCategoryTypeIn(List categoryTypeList) { 42 | return repository.findByCategoryTypeIn(categoryTypeList); 43 | } 44 | 45 | //保存类目信息 46 | @Override 47 | public ProductCategory save(ProductCategory productCategory) { 48 | return repository.save(productCategory); 49 | } 50 | 51 | //删除类目 52 | @Override 53 | public void delete(Integer categoryId) { 54 | Optional category = repository.findById(categoryId); 55 | List productInfoList = productInfoRepository.findByCategoryType(category.get().getCategoryType()); 56 | if( !productInfoList.isEmpty()){ 57 | throw new SellException(ResultEnum.PRODUCT_IN_CATEGORY_ERROR); 58 | } 59 | repository.delete(category.get()); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/service/impl/PayService.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service.impl; 2 | 3 | import com.hhh.wechat_order.dto.OrderDTO; 4 | import com.hhh.wechat_order.entity.OrderMaster; 5 | import com.hhh.wechat_order.enums.OrderStatusEnum; 6 | import com.hhh.wechat_order.enums.PayStatusEnum; 7 | import com.hhh.wechat_order.enums.ResultEnum; 8 | import com.hhh.wechat_order.exception.SellException; 9 | import com.hhh.wechat_order.repository.OrderMasterRepository; 10 | import com.hhh.wechat_order.service.OrderService; 11 | import com.hhh.wechat_order.utils.JsonUtil; 12 | import com.hhh.wechat_order.utils.MathUtil; 13 | import com.lly835.bestpay.enums.BestPayTypeEnum; 14 | import com.lly835.bestpay.model.PayRequest; 15 | import com.lly835.bestpay.model.PayResponse; 16 | import com.lly835.bestpay.model.RefundRequest; 17 | import com.lly835.bestpay.model.RefundResponse; 18 | import com.lly835.bestpay.service.impl.BestPayServiceImpl; 19 | import lombok.extern.slf4j.Slf4j; 20 | import org.springframework.beans.BeanUtils; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.stereotype.Service; 23 | 24 | import java.util.Optional; 25 | 26 | /** 27 | * 支付 28 | */ 29 | @Service 30 | @Slf4j 31 | public class PayService { 32 | 33 | @Autowired 34 | private OrderMasterRepository orderMasterRepository; 35 | 36 | public OrderDTO goPay(OrderDTO orderDTO){ 37 | //判断订单状态 38 | if(!orderDTO.getOrderStatus().equals(OrderStatusEnum.NEW.getCode())){ 39 | log.error("【支付订单】订单状态不正确, orderId={}, orderStatus={}", orderDTO.getOrderId(), 40 | orderDTO.getOrderStatus()); 41 | throw new SellException(ResultEnum.ORDER_STATUS_ERROR); 42 | } 43 | //修改订单状态 44 | OrderMaster orderMaster = new OrderMaster(); 45 | orderDTO.setOrderStatus(OrderStatusEnum.NEW_PAYED.getCode()); 46 | //TODO 47 | orderDTO.setPayStatus(PayStatusEnum.SUCCESS.getCode()); 48 | BeanUtils.copyProperties(orderDTO , orderMaster); 49 | OrderMaster updateResult = orderMasterRepository.save(orderMaster); 50 | if(updateResult == null){ 51 | log.error("【支付订单】更新失败, orderMaster={}", orderMaster); 52 | throw new SellException(ResultEnum.ORDER_UPDATE_FAIL); 53 | } 54 | return orderDTO; 55 | } 56 | 57 | //退款 58 | public RefundResponse refund(OrderDTO orderDTO){ 59 | return null; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/service/impl/ProductServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service.impl; 2 | 3 | import com.hhh.wechat_order.dto.CartDTO; 4 | import com.hhh.wechat_order.entity.ProductCategory; 5 | import com.hhh.wechat_order.entity.ProductInfo; 6 | import com.hhh.wechat_order.enums.ProductStatusEnum; 7 | import com.hhh.wechat_order.enums.ResultEnum; 8 | import com.hhh.wechat_order.exception.SellException; 9 | import com.hhh.wechat_order.repository.ProductInfoRepository; 10 | import com.hhh.wechat_order.service.ProductService; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.data.domain.Page; 13 | import org.springframework.data.domain.Pageable; 14 | import org.springframework.stereotype.Service; 15 | import org.springframework.transaction.annotation.Transactional; 16 | 17 | import java.util.List; 18 | import java.util.Optional; 19 | 20 | @Service 21 | public class ProductServiceImpl implements ProductService { 22 | 23 | @Autowired 24 | private ProductInfoRepository repository; 25 | 26 | //根据商品id,查找商品信息 27 | @Override 28 | public Optional findById(String productId) { 29 | return repository.findById(productId); 30 | } 31 | 32 | //查找所有上架的商品信息 33 | @Override 34 | public List findUpAll() { 35 | return repository.findByProductStatus(ProductStatusEnum.UP.getCode()); 36 | } 37 | 38 | //查找所有商品信息,返回分页对象 39 | @Override 40 | public Page findAll(Pageable pageable) { 41 | return repository.findAll(pageable); 42 | } 43 | 44 | @Override 45 | public List findByCategoryType(Integer categoryType) { 46 | //TODO 47 | return repository.findByCategoryType(categoryType); 48 | } 49 | 50 | //保存商品信息 51 | @Override 52 | public ProductInfo save(ProductInfo productInfo) { 53 | return repository.save(productInfo); 54 | } 55 | 56 | //增加商品库存 57 | @Override 58 | @Transactional 59 | public void increaseStock(List cartDTOList) { 60 | for(CartDTO cartDTO : cartDTOList){ 61 | Optional productInfo = repository.findById(cartDTO.getProductId()); 62 | if( !productInfo.isPresent()){ 63 | throw new SellException(ResultEnum.PRODUCT_NOT_EXIST); 64 | } 65 | Integer result = productInfo.get().getProductStock() + cartDTO.getProductQuantity(); 66 | productInfo.get().setProductStock(result); 67 | repository.save(productInfo.get()); 68 | } 69 | } 70 | 71 | //减少商品库存 72 | @Override 73 | @Transactional 74 | public void decreaseStock(List cartDTOList) { 75 | for (CartDTO cartDTO : cartDTOList){ 76 | Optional productInfo = repository.findById(cartDTO.getProductId()); 77 | if( !productInfo.isPresent()){ 78 | throw new SellException(ResultEnum.PRODUCT_NOT_EXIST); 79 | } 80 | Integer result = productInfo.get().getProductStock() - cartDTO.getProductQuantity(); 81 | if(result < 0){ 82 | throw new SellException(ResultEnum.PRODUCT_STOCK_ERROR); 83 | } 84 | productInfo.get().setProductStock(result); 85 | repository.save(productInfo.get()); 86 | } 87 | } 88 | 89 | @Override 90 | public ProductInfo onSale(String productId) { 91 | Optional productInfo = repository.findById(productId); 92 | if(!productInfo.isPresent()){ 93 | throw new SellException(ResultEnum.PRODUCT_NOT_EXIST); 94 | } 95 | if(productInfo.get().getProductStatusEnum() == ProductStatusEnum.UP){ 96 | throw new SellException(ResultEnum.PRODUCT_STATUS_ERROR); 97 | } 98 | productInfo.get().setProductStatus(ProductStatusEnum.UP.getCode()); 99 | return repository.save(productInfo.get()); 100 | } 101 | 102 | @Override 103 | public ProductInfo offSale(String productId) { 104 | Optional productInfo = repository.findById(productId); 105 | if(!productInfo.isPresent()){ 106 | throw new SellException(ResultEnum.PRODUCT_NOT_EXIST); 107 | } 108 | if(productInfo.get().getProductStatusEnum() == ProductStatusEnum.DOWN){ 109 | throw new SellException(ResultEnum.PRODUCT_STATUS_ERROR); 110 | } 111 | productInfo.get().setProductStatus(ProductStatusEnum.DOWN.getCode()); 112 | return repository.save(productInfo.get()); 113 | } 114 | 115 | @Override 116 | public void delete(String productId) { 117 | Optional productInfo = repository.findById(productId); 118 | if(productInfo.get().getProductStatusEnum().getMessage() == "在售"){ 119 | throw new SellException(ResultEnum.PRODUCT_STATUS_ERROR); 120 | } 121 | repository.delete(productInfo.get()); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/service/impl/SellerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service.impl; 2 | 3 | import com.hhh.wechat_order.entity.SellerInfo; 4 | import com.hhh.wechat_order.repository.SellerInfoRepository; 5 | import com.hhh.wechat_order.service.SellerService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class SellerServiceImpl implements SellerService { 11 | 12 | @Autowired 13 | private SellerInfoRepository repository; 14 | 15 | @Override 16 | public SellerInfo findSellerInfoByPhone(String phone) { 17 | return repository.findByPhone(phone); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service.impl; 2 | 3 | import com.hhh.wechat_order.entity.User; 4 | import com.hhh.wechat_order.repository.UserRepository; 5 | import com.hhh.wechat_order.service.UserService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author HHH 11 | * @version 1.0 2019/10/17 12 | */ 13 | @Service 14 | public class UserServiceImpl implements UserService { 15 | 16 | @Autowired 17 | private UserRepository repository; 18 | 19 | @Override 20 | public User findByOpenid(String openid) { 21 | return repository.findByOpenid(openid); 22 | } 23 | 24 | @Override 25 | public void save(User user) { 26 | repository.save(user); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/utils/CookieUtil.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.utils; 2 | 3 | import javax.servlet.http.Cookie; 4 | import javax.servlet.http.HttpServletRequest; 5 | import javax.servlet.http.HttpServletResponse; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | /** 10 | * CookieUtil工具类 11 | */ 12 | public class CookieUtil { 13 | 14 | /** 15 | * 设置 16 | * @param response 17 | * @param name 18 | * @param value 19 | * @param maxAge 20 | */ 21 | public static void set(HttpServletResponse response , 22 | String name , String value , int maxAge){ 23 | Cookie cookie = new Cookie(name , value); 24 | cookie.setPath("/"); 25 | cookie.setMaxAge(maxAge); 26 | response.addCookie(cookie); 27 | } 28 | 29 | /** 30 | * 获取cookie 31 | * @param request 32 | * @param name 33 | * @return 34 | */ 35 | public static Cookie get(HttpServletRequest request , 36 | String name){ 37 | Map cookieMap = readCookieMap(request); 38 | if(cookieMap.containsKey(name)){ 39 | return cookieMap.get(name); 40 | }else { 41 | return null; 42 | } 43 | } 44 | 45 | /** 46 | * 将cookie封装成Map 47 | * @param request 48 | * @return 49 | */ 50 | private static Map readCookieMap(HttpServletRequest request){ 51 | Map cookieMap = new HashMap<>(); 52 | Cookie[] cookies = request.getCookies(); 53 | if (cookies != null){ 54 | for(Cookie cookie : cookies){ 55 | cookieMap.put(cookie.getName() , cookie); 56 | } 57 | } 58 | return cookieMap; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/utils/EnumUtil.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.utils; 2 | 3 | import com.hhh.wechat_order.enums.CodeEnum; 4 | 5 | public class EnumUtil { 6 | 7 | public static T getByCode(Integer code , Class enumClass){ 8 | for(T each : enumClass.getEnumConstants()){ 9 | if(code.equals(each.getCode())){ 10 | return each; 11 | } 12 | } 13 | return null; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/utils/JsonUtil.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.utils; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | 6 | /** 7 | * json 格式化工具 8 | */ 9 | public class JsonUtil { 10 | 11 | public static String toJson(Object object){ 12 | GsonBuilder gsonBuilder = new GsonBuilder(); 13 | gsonBuilder.setPrettyPrinting(); 14 | Gson gson = gsonBuilder.create(); 15 | return gson.toJson(object); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/utils/KeyUtil.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.utils; 2 | 3 | import java.util.Random; 4 | 5 | /** 6 | * 主键随机数生成 7 | */ 8 | public class KeyUtil { 9 | 10 | /** 11 | * 生成唯一的主键 12 | * 格式:时间 + 随机数 13 | * @return 14 | */ 15 | public static synchronized String genUniqueKey(){ 16 | Random random = new Random(); 17 | 18 | Integer number = random.nextInt(900000) + 100000; 19 | 20 | return System.currentTimeMillis() + String.valueOf(number) ; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/utils/MathUtil.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.utils; 2 | 3 | /** 4 | * 校验 5 | */ 6 | public class MathUtil { 7 | 8 | //最小范围常量 9 | private static final Double MONEY_RANGE = 0.01; 10 | 11 | /** 12 | * 比较2个金额是否相等 13 | * @param d1 14 | * @param d2 15 | * @return 16 | */ 17 | public static Boolean equals(Double d1 , Double d2){ 18 | Double result = Math.abs(d1 - d2); 19 | if(result < MONEY_RANGE){ 20 | return true; 21 | }else { 22 | return false; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/utils/ResultVOUtil.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.utils; 2 | 3 | import com.hhh.wechat_order.VO.ResultVo; 4 | 5 | public class ResultVOUtil { 6 | 7 | public static ResultVo success(Object obj){ 8 | ResultVo resultVo = new ResultVo(); 9 | resultVo.setCode(0); 10 | resultVo.setMsg("成功"); 11 | resultVo.setData(obj); 12 | return resultVo; 13 | } 14 | 15 | public static ResultVo success(){ 16 | return success(null); 17 | } 18 | 19 | public static ResultVo error(Integer code , String msg){ 20 | ResultVo resultVo = new ResultVo(); 21 | resultVo.setCode(code); 22 | resultVo.setMsg(msg); 23 | return resultVo; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/utils/serializer/Date2LongSerializer.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.utils.serializer; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import java.io.IOException; 7 | import java.util.Date; 8 | 9 | /** 10 | * 日期类型对象转换为 Long对象类型 11 | */ 12 | public class Date2LongSerializer extends JsonSerializer { 13 | @Override 14 | public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { 15 | jsonGenerator.writeNumber(date.getTime() / 1000); ; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/java/com/hhh/wechat_order/utils/serializer/Date2StringSerializer.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.utils.serializer; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | import com.google.gson.JsonElement; 7 | import com.google.gson.JsonSerializationContext; 8 | 9 | import java.io.IOException; 10 | import java.lang.reflect.Type; 11 | import java.text.SimpleDateFormat; 12 | import java.util.Date; 13 | 14 | /** 15 | * 把date类型的时间戳转换为long类型,因为date返回的时间戳比正常的要大1000倍 16 | * @author HHH 17 | * @version 1.0 2019/10/17 18 | */ 19 | public class Date2StringSerializer extends JsonSerializer { 20 | 21 | @Override 22 | public void serialize(Date value, JsonGenerator gen, SerializerProvider serializers) throws IOException { 23 | Date sqlDate = new java.sql.Date(value.getTime()); 24 | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 25 | String dateString = formatter.format(sqlDate); 26 | gen.writeString(dateString); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | driver-class-name: com.mysql.jdbc.Driver 4 | username: root 5 | password: 852013 6 | url: jdbc:mysql://localhost/wechat_order 7 | jpa: 8 | show-sql: true 9 | hibernate: 10 | ddl-auto: update 11 | properties: 12 | hibernate: 13 | format_sql: true 14 | 15 | jackson: 16 | default-property-inclusion: non_null 17 | 18 | # redis: 19 | # host: 192.168.131.134 20 | # port: 6379 21 | 22 | server: 23 | servlet: 24 | context-path: /sell 25 | port: 8080 26 | 27 | #定义网址 28 | projecturl: 29 | sell: localhost:8080 30 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/static/api/seller.json: -------------------------------------------------------------------------------- 1 | { 2 | "errno": 0, 3 | "data": { 4 | "name": "粥品香坊(回龙观)", 5 | "description": "蜂鸟专送", 6 | "deliveryTime": 38, 7 | "score": 4.2, 8 | "serviceScore": 4.1, 9 | "foodScore": 4.3, 10 | "rankRate": 69.2, 11 | "minPrice": 0, 12 | "deliveryPrice": 0, 13 | "ratingCount": 24, 14 | "sellCount": 90, 15 | "bulletin": "粥品香坊其烹饪粥料的秘方源于中国千年古法,在融和现代制作工艺,由世界烹饪大师屈浩先生领衔研发。坚守纯天然、0添加的良心品质深得消费者青睐,发展至今成为粥类的引领品牌。是2008年奥运会和2013年园博会指定餐饮服务商。", 16 | "supports": [ 17 | { 18 | "type": 0, 19 | "description": "在线支付满28减5" 20 | }, 21 | { 22 | "type": 1, 23 | "description": "VC无限橙果汁全场8折" 24 | }, 25 | { 26 | "type": 2, 27 | "description": "单人精彩套餐" 28 | }, 29 | { 30 | "type": 3, 31 | "description": "该商家支持发票,请下单写好发票抬头" 32 | }, 33 | { 34 | "type": 4, 35 | "description": "已加入“外卖保”计划,食品安全保障" 36 | } 37 | ], 38 | "avatar": "http://static.galileo.xiaojukeji.com/static/tms/seller_avatar_256px.jpg", 39 | "pics": [ 40 | "http://fuss10.elemecdn.com/8/71/c5cf5715740998d5040dda6e66abfjpeg.jpeg?imageView2/1/w/180/h/180", 41 | "http://fuss10.elemecdn.com/b/6c/75bd250e5ba69868f3b1178afbda3jpeg.jpeg?imageView2/1/w/180/h/180", 42 | "http://fuss10.elemecdn.com/f/96/3d608c5811bc2d902fc9ab9a5baa7jpeg.jpeg?imageView2/1/w/180/h/180", 43 | "http://fuss10.elemecdn.com/6/ad/779f8620ff49f701cd4c58f6448b6jpeg.jpeg?imageView2/1/w/180/h/180" 44 | ], 45 | "infos": [ 46 | "该商家支持发票,请下单写好发票抬头", 47 | "品类:其他菜系,包子粥店", 48 | "北京市昌平区回龙观西大街龙观置业大厦底商B座102单元1340", 49 | "营业时间:10:00-20:30" 50 | ] 51 | } 52 | } -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/static/js/login.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * qcl 3 | */ 4 | "use strict"; 5 | //# sourceURL=main.js 6 | // DOM 加载完再执行 7 | $(function () { 8 | //点击登录按钮 9 | $("#loginBtn").click(function () { 10 | login(); 11 | console.log("点击了登录") 12 | }); 13 | 14 | //管理登录 15 | function login() { 16 | let phone = $(" input[ name='username' ] ").val(); 17 | let psw = $(" input[ name='password' ] ").val(); 18 | if (phone == undefined || phone == "") { 19 | alert("请输入手机号"); 20 | return; 21 | } 22 | if (psw == undefined || psw == "") { 23 | alert("请输入密码"); 24 | return; 25 | } 26 | $.ajax({ 27 | url: "/sell/admin/loginAdmin", 28 | data: { 29 | "phone": phone, 30 | "password": psw 31 | }, 32 | success: function (data) { 33 | $("#mainContainer").html(data); 34 | console.log("登录成功", data); 35 | window.location.href = "/sell/seller/order/list"; 36 | }, 37 | error: function (err) { 38 | console.log("登录失败,用户名或者密码不正确", err); 39 | alert("登录失败,手机号或者密码不正确"); 40 | toastr.error("error!"); 41 | } 42 | }); 43 | } 44 | 45 | // 分页 46 | // $.tbpage("#mainContainer", function (pageIndex, pageSize) { 47 | // getUersByName(pageIndex, pageSize); 48 | // _pageSize = pageSize; 49 | // }); 50 | 51 | 52 | // 获取添加用户的界面 53 | // $("#addUser").click(function () { 54 | // $.ajax({ 55 | // url: "/users/add", 56 | // success: function (data) { 57 | // $("#userFormContainer").html(data); 58 | // }, 59 | // error: function (data) { 60 | // toastr.error("error!"); 61 | // } 62 | // }); 63 | // }); 64 | 65 | // 获取编辑用户的界面 66 | // $("#rightContainer").on("click", ".blog-edit-user", function () { 67 | // $.ajax({ 68 | // url: "/users/edit/" + $(this).attr("userId"), 69 | // success: function (data) { 70 | // $("#userFormContainer").html(data); 71 | // }, 72 | // error: function () { 73 | // toastr.error("error!"); 74 | // } 75 | // }); 76 | // }); 77 | 78 | // 提交变更后,清空表单 79 | // $("#submitEdit").click(function () { 80 | // $.ajax({ 81 | // url: "/users", 82 | // type: 'POST', 83 | // data: $('#userForm').serialize(), 84 | // success: function (data) { 85 | // $('#userForm')[0].reset(); 86 | // 87 | // if (data.success) { 88 | // // 从新刷新主界面 89 | // getUersByName(0, _pageSize); 90 | // } else { 91 | // toastr.error(data.message); 92 | // } 93 | // 94 | // }, 95 | // error: function () { 96 | // toastr.error("error!"); 97 | // } 98 | // }); 99 | // }); 100 | 101 | // 删除用户 102 | // $("#rightContainer").on("click", ".blog-delete-user", function () { 103 | // // 获取 CSRF Token 104 | // var csrfToken = $("meta[name='_csrf']").attr("content"); 105 | // var csrfHeader = $("meta[name='_csrf_header']").attr("content"); 106 | // $.ajax({ 107 | // url: "/users/" + $(this).attr("userId"), 108 | // type: 'DELETE', 109 | // beforeSend: function (request) { 110 | // request.setRequestHeader(csrfHeader, csrfToken); // 添加 CSRF Token 111 | // }, 112 | // success: function (data) { 113 | // if (data.success) { 114 | // // 从新刷新主界面 115 | // getUersByName(0, _pageSize); 116 | // } else { 117 | // toastr.error(data.message); 118 | // } 119 | // }, 120 | // error: function () { 121 | // toastr.error("error!"); 122 | // } 123 | // }); 124 | // }); 125 | }); -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/static/mp3/song.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_h/src/main/resources/static/mp3/song.mp3 -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/admin/index.ftl: -------------------------------------------------------------------------------- 1 | 2 | <#include "../common/header.ftl"> 3 | 4 |
5 | 6 | <#include "../common/nav.ftl"> 7 | 8 | 9 |
10 |
11 |
12 |
13 |
14 |
15 | 16 | 17 |
18 |
19 | 20 | 21 |
22 |
23 | 24 | 25 |
26 | 27 | 28 |
29 |
30 |
31 |
32 |
33 |
34 | 35 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/admin/list.ftl: -------------------------------------------------------------------------------- 1 | 2 | <#include "../common/header.ftl"> 3 | 4 | 5 |
6 | 7 | <#--边栏sidebar--> 8 | <#include "../common/nav.ftl"> 9 | 10 | <#--主要内容content--> 11 |
12 |
13 |
14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | <#list sellerInfoList as sellerInfo> 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
用户id名字密码手机号创建时间修改时间操作
${sellerInfo.sellerId}${sellerInfo.username}${sellerInfo.password}${sellerInfo.phone}${sellerInfo.createTime}${sellerInfo.updateTime}修改
42 |
43 |
44 |
45 |
46 | 47 |
48 | 49 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/category/index.ftl: -------------------------------------------------------------------------------- 1 | 2 | <#include "../common/header.ftl"> 3 | 4 |
5 | 6 | <#include "../common/nav.ftl"> 7 | 8 | 9 |
10 |
11 |
12 |
13 |
14 |
15 | 16 | 17 |
18 |
19 | 20 | 21 |
22 | 23 | 24 |
25 |
26 |
27 |
28 |
29 |
30 | 31 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/category/list.ftl: -------------------------------------------------------------------------------- 1 | 2 | <#include "../common/header.ftl"> 3 | 4 |
5 | 6 | <#include "../common/nav.ftl"> 7 | 8 | 9 |
10 |
11 |
12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | <#list productCategoryList as category> 26 | 27 | 28 | 29 | 30 | 31 | 32 | 35 | 38 | 39 | 40 | 41 |
类目id类目名称type创建时间修改时间操作
${category.categoryId}${category.categoryName}${category.categoryType}${category.createTime}${category.updateTime} 33 | 修改 34 | 36 | 删除 37 |
42 |
43 |
44 |
45 |
46 |
47 | 48 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/common/error.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 错误提示 5 | 6 | 7 | 8 |
9 |
10 |
11 |
12 | 13 |

14 | 错误! 15 |

${msg} 3s后自动跳转 16 |
17 |
18 |
19 |
20 | 21 | 22 | 25 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/common/header.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 卖家后端管理系统 4 | 5 | 6 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/common/loginView.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 卖家管理系统后台 5 | 6 | 7 | 8 | 9 | 10 | 11 | 44 | 45 | 46 | 47 | 48 | 49 | <#--自动机定义的本地js请求--> 50 | 51 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/common/nav.ftl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/common/success.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 成功提示 5 | 6 | 7 | 8 |
9 |
10 |
11 |
12 | 13 |

14 | 操作成功! 15 |

${msg!""} 3s后自动跳转 16 |
17 |
18 |
19 |
20 | 21 | 22 | 25 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/order/detail.ftl: -------------------------------------------------------------------------------- 1 | 2 | <#include "../common/header.ftl"> 3 | 4 |
5 | 6 | <#include "../common/nav.ftl"> 7 | 8 | 9 |
10 |
11 |
12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
订单id订单总金额
${orderDTO.orderId}${orderDTO.orderAmount}
27 |
28 | 29 | 30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | <#list orderDTO.orderDetailList as orderDetail> 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
商品id商品名称价格数量总额
${orderDetail.productId}${orderDetail.productName}${orderDetail.productPrice}${orderDetail.productQuantity}${orderDetail.productQuantity * orderDetail.productPrice}
53 |
54 | 55 | 56 |
57 | <#if orderDTO.getOrderStatusEnum().message == "新订单已支付"> 58 | 完结订单 59 | 取消订单 60 | 61 |
62 |
63 |
64 |
65 | 66 |
67 | 68 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/pay/create.ftl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/pay/success.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/picture/index.ftl: -------------------------------------------------------------------------------- 1 | 2 | <#include "../common/header.ftl"> 3 | 4 | 5 |
6 | 7 | <#--边栏sidebar--> 8 | <#include "../common/nav.ftl"> 9 | 10 | <#--主要内容content--> 11 |
12 |
13 |
14 |
15 |
16 |
17 | 18 | 20 |
21 |
22 | 23 | 25 |
26 | 28 | 29 |
30 |
31 |
32 |
33 |
34 | 35 |
36 | 37 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/picture/list.ftl: -------------------------------------------------------------------------------- 1 | 2 | <#include "../common/header.ftl"> 3 | 4 | 5 |
6 | 7 | <#--边栏sidebar--> 8 | <#include "../common/nav.ftl"> 9 | 10 | <#--主要内容content--> 11 |
12 |
13 |
14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | <#list pictures as picture> 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
图片id图片描述图片url创建时间操作
${picture.picId}${picture.picMessage}${picture.picUrl}${picture.createTime}修改删除
39 |
40 |
41 |
42 |
43 | 44 |
45 | 46 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/product/index.ftl: -------------------------------------------------------------------------------- 1 | 2 | <#include "../common/header.ftl"> 3 | 4 |
5 | 6 | <#include "../common/nav.ftl"> 7 | 8 | 9 |
10 |
11 |
12 |
13 |
14 |
15 | 16 | 17 |
18 |
19 | 20 | 21 |
22 |
23 | 24 | 25 |
26 |
27 | 28 | 29 |
30 |
31 | 32 | 33 | 34 |
35 |
36 | 37 | 45 |
46 | 47 | 48 |
49 |
50 |
51 |
52 |
53 |
54 | 55 | -------------------------------------------------------------------------------- /wechat_order_h/src/main/resources/templates/product/list.ftl: -------------------------------------------------------------------------------- 1 | 2 | <#include "../common/header.ftl"> 3 | 4 |
5 | 6 | <#include "../common/nav.ftl"> 7 | 8 | 9 |
10 |
11 |
12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | <#list productInfoPage.content as productInfo> 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 46 | 53 | 54 | 55 | 56 |
商品id名称图片单价库存描述类目创建时间修改时间操作
${productInfo.productId}${productInfo.productName}${productInfo.productPrice}${productInfo.productStock}${productInfo.productDescription}${productInfo.categoryType}${productInfo.createTime}${productInfo.updateTime} 41 | 修改 42 | 44 | 删除 45 | 47 | <#if productInfo.getProductStatusEnum().message == "在售"> 48 | 下架 49 | <#else> 50 | 上架 51 | 52 |
57 |
58 | 59 | 60 |
61 |
    62 | <#if currentPage lte 1> 63 |
  • 上一页
  • 64 | <#else> 65 |
  • 上一页
  • 66 | 67 | 68 | <#list 1..productInfoPage.getTotalPages() as index> 69 | <#if currentPage == index> 70 |
  • ${index}
  • 71 | <#else> 72 |
  • ${index}
  • 73 | 74 | 75 | 76 | <#if currentPage gte productInfoPage.getTotalPages()> 77 |
  • 下一页
  • 78 | <#else> 79 |
  • 下一页
  • 80 | 81 |
82 |
83 |
84 |
85 |
86 |
87 | 88 | -------------------------------------------------------------------------------- /wechat_order_h/src/test/java/com/hhh/wechat_order/WechatOrderApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class WechatOrderApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /wechat_order_h/src/test/java/com/hhh/wechat_order/repository/OrderDetailRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.repository; 2 | 3 | import com.hhh.wechat_order.entity.OrderDetail; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import java.math.BigDecimal; 12 | import java.util.List; 13 | 14 | import static org.junit.Assert.*; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | public class OrderDetailRepositoryTest { 19 | 20 | @Autowired 21 | private OrderDetailRepository repository; 22 | 23 | @Test 24 | public void saveTest(){ 25 | OrderDetail orderDetail = new OrderDetail(); 26 | orderDetail.setDetailId("12345678910"); 27 | orderDetail.setOrderId("123456"); 28 | orderDetail.setProductIcon("http://xxxx.jpg"); 29 | orderDetail.setProductId("12145"); 30 | orderDetail.setProductName("白粥"); 31 | orderDetail.setProductPrice(new BigDecimal(1.2)); 32 | orderDetail.setProductQuantity(1); 33 | 34 | OrderDetail result = repository.save(orderDetail); 35 | Assert.assertNotNull(result); 36 | } 37 | 38 | @Test 39 | public void findByOrderId() { 40 | List byOrderId = repository.findByOrderId("123456"); 41 | Assert.assertNotEquals(0 , byOrderId.size()); 42 | } 43 | } -------------------------------------------------------------------------------- /wechat_order_h/src/test/java/com/hhh/wechat_order/repository/OrderMasterRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.repository; 2 | 3 | import com.hhh.wechat_order.entity.OrderMaster; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.data.domain.Page; 10 | import org.springframework.data.domain.PageRequest; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | import java.math.BigDecimal; 14 | 15 | import static org.junit.Assert.*; 16 | 17 | @RunWith(SpringRunner.class) 18 | @SpringBootTest 19 | public class OrderMasterRepositoryTest { 20 | 21 | @Autowired 22 | private OrderMasterRepository repository; 23 | 24 | @Test 25 | public void saveTest(){ 26 | OrderMaster orderMaster = new OrderMaster(); 27 | orderMaster.setOrderId("1234567"); 28 | orderMaster.setBuyerName("HHH"); 29 | orderMaster.setBuyerPhone("17875303280"); 30 | orderMaster.setBuyerAddress("嘉应学院"); 31 | orderMaster.setBuyerOpenid("abc23"); 32 | orderMaster.setOrderAmount(new BigDecimal(25.7)); 33 | 34 | OrderMaster result = repository.save(orderMaster); 35 | Assert.assertNotNull(result); 36 | } 37 | 38 | @Test 39 | public void findByBuyerOpenid() { 40 | PageRequest pageRequest = new PageRequest(0,1); 41 | Page pageOrder = repository.findByBuyerOpenid("abc123", pageRequest); 42 | System.out.println(pageOrder.getTotalElements());//获取总的条数 43 | Assert.assertNotEquals(0 , pageOrder.getTotalElements()); 44 | } 45 | } -------------------------------------------------------------------------------- /wechat_order_h/src/test/java/com/hhh/wechat_order/repository/ProductCategoryRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.repository; 2 | 3 | import com.hhh.wechat_order.entity.ProductCategory; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import java.util.Arrays; 12 | import java.util.List; 13 | import java.util.Optional; 14 | 15 | @RunWith(SpringRunner.class) 16 | @SpringBootTest 17 | public class ProductCategoryRepositoryTest { 18 | 19 | @Autowired 20 | private ProductCategoryRepository productCategoryRepository; 21 | 22 | @Test 23 | public void findByIdTest(){ 24 | Optional productCategory = productCategoryRepository.findById(1); 25 | System.out.println(productCategory); 26 | } 27 | 28 | @Test 29 | public void saveTest(){ 30 | ProductCategory productCategory = new ProductCategory(); 31 | productCategory.setCategoryName("女生最爱"); 32 | productCategory.setCategoryType(2); 33 | productCategoryRepository.save(productCategory); 34 | } 35 | 36 | @Test 37 | public void updateTest(){ 38 | ProductCategory productCategory = new ProductCategory(); 39 | productCategory.setCategoryId(1); 40 | productCategory.setCategoryName("热销榜"); 41 | productCategory.setCategoryType(1); 42 | productCategoryRepository.save(productCategory); 43 | } 44 | 45 | @Test 46 | public void findByCategoryTypeInTest(){ 47 | List list = Arrays.asList(1,2,3); 48 | List result = productCategoryRepository.findByCategoryTypeIn(list); 49 | Assert.assertNotEquals(0,result.size()); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /wechat_order_h/src/test/java/com/hhh/wechat_order/repository/ProductInfoRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.repository; 2 | 3 | import com.hhh.wechat_order.entity.ProductInfo; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import java.math.BigDecimal; 13 | import java.util.List; 14 | 15 | import static org.junit.Assert.*; 16 | 17 | @RunWith(SpringRunner.class) 18 | @SpringBootTest 19 | public class ProductInfoRepositoryTest { 20 | 21 | @Autowired 22 | private ProductInfoRepository repository; 23 | 24 | @Test 25 | public void saveTest(){ 26 | ProductInfo productInfo = new ProductInfo(); 27 | productInfo.setProductId("123456"); 28 | productInfo.setProductName("皮蛋粥"); 29 | productInfo.setProductPrice(new BigDecimal(5.0)); 30 | productInfo.setProductStock(100); 31 | productInfo.setProductDescription("好多皮蛋"); 32 | productInfo.setProductIcon("http://ssssss.jpg"); 33 | productInfo.setProductStatus(0); 34 | productInfo.setCategoryType(1); 35 | repository.save(productInfo); 36 | } 37 | 38 | @Test 39 | public void findByProductStatus() { 40 | List productInfoList = repository.findByProductStatus(0); 41 | Assert.assertNotEquals(0 , productInfoList.size()); 42 | } 43 | } -------------------------------------------------------------------------------- /wechat_order_h/src/test/java/com/hhh/wechat_order/service/impl/CategoryServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service.impl; 2 | 3 | import com.hhh.wechat_order.entity.ProductCategory; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import java.util.Arrays; 13 | import java.util.List; 14 | import java.util.Optional; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | public class CategoryServiceImplTest { 19 | 20 | @Autowired 21 | private CategoryServiceImpl categoryService; 22 | 23 | @Test 24 | public void findById() { 25 | Optional productCategory = categoryService.findById(1); 26 | System.out.println(productCategory); 27 | } 28 | 29 | @Test 30 | public void findAll() { 31 | List productCategoryList = categoryService.findAll(); 32 | Assert.assertNotEquals(0 , productCategoryList.size()); 33 | } 34 | 35 | @Test 36 | public void findByCategoryTypeIn() { 37 | List productCategoryList = categoryService.findByCategoryTypeIn(Arrays.asList(1,2,3)); 38 | Assert.assertNotEquals(0,productCategoryList.size()); 39 | } 40 | 41 | @Test 42 | @Transactional 43 | public void save() { 44 | ProductCategory productCategory = new ProductCategory("男生专享" , 3); 45 | ProductCategory result = categoryService.save(productCategory); 46 | Assert.assertNotNull(result); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /wechat_order_h/src/test/java/com/hhh/wechat_order/service/impl/OrderServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service.impl; 2 | 3 | import com.hhh.wechat_order.dto.OrderDTO; 4 | import com.hhh.wechat_order.entity.OrderDetail; 5 | import com.hhh.wechat_order.enums.OrderStatusEnum; 6 | import com.hhh.wechat_order.enums.PayStatusEnum; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import org.springframework.data.domain.Page; 14 | import org.springframework.data.domain.PageRequest; 15 | import org.springframework.test.context.junit4.SpringRunner; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import static org.junit.Assert.*; 21 | 22 | @RunWith(SpringRunner.class) 23 | @SpringBootTest 24 | @Slf4j 25 | public class OrderServiceImplTest { 26 | 27 | @Autowired 28 | private OrderServiceImpl orderService; 29 | 30 | private final String BUYER_OPENID = "abc123"; 31 | private final String ORDER_ID = "1569052543479819643"; 32 | 33 | @Test 34 | public void create() { 35 | OrderDTO orderDTO = new OrderDTO(); 36 | orderDTO.setBuyerName("小芳"); 37 | orderDTO.setBuyerAddress("嘉应学院"); 38 | orderDTO.setBuyerPhone("12345678910"); 39 | orderDTO.setBuyerOpenid(BUYER_OPENID); 40 | //购物车 41 | List orderDetailList = new ArrayList<>(); 42 | OrderDetail o1 = new OrderDetail(); 43 | o1.setProductId("123456"); 44 | o1.setProductQuantity(1); 45 | orderDetailList.add(o1); 46 | 47 | OrderDetail o2 = new OrderDetail(); 48 | o2.setProductId("111"); 49 | o2.setProductQuantity(1); 50 | orderDetailList.add(o2); 51 | 52 | //错误测试,商品不存在的测试 53 | // OrderDetail o1 = new OrderDetail(); 54 | // o1.setProductId("123"); 55 | // o1.setProductQuantity(2); 56 | // orderDetailList.add(o1); 57 | 58 | orderDTO.setOrderDetailList(orderDetailList); 59 | OrderDTO result = orderService.create(orderDTO); 60 | log.info("【创建订单】 result={}",result); 61 | Assert.assertNotNull(result); 62 | } 63 | 64 | @Test 65 | public void findOne() { 66 | OrderDTO result = orderService.findOne(ORDER_ID); 67 | log.info("【查询单个订单】 result={}" , result); 68 | Assert.assertEquals(ORDER_ID , result.getOrderId()); 69 | } 70 | 71 | @Test 72 | public void findList() { 73 | PageRequest request = new PageRequest(0 , 2); 74 | Page orderDTOPage = orderService.findList(BUYER_OPENID, request); 75 | Assert.assertNotEquals(0 , orderDTOPage.getTotalElements()); 76 | } 77 | 78 | @Test 79 | public void findListAll() { 80 | PageRequest request = new PageRequest(0 , 2); 81 | Page orderDTOPage = orderService.findList(request); 82 | Assert.assertNotEquals(0 , orderDTOPage.getTotalElements()); 83 | } 84 | 85 | @Test 86 | public void cancel() { 87 | OrderDTO orderDTO = orderService.findOne(ORDER_ID); 88 | OrderDTO result = orderService.cancel(orderDTO); 89 | Assert.assertEquals(OrderStatusEnum.CANCEL.getCode() , result.getOrderStatus()); 90 | } 91 | 92 | @Test 93 | public void finish() { 94 | OrderDTO orderDTO = orderService.findOne(ORDER_ID); 95 | OrderDTO result = orderService.finish(orderDTO); 96 | Assert.assertEquals(OrderStatusEnum.FINSHED.getCode() , result.getOrderStatus()); 97 | } 98 | 99 | @Test 100 | public void paid() { 101 | OrderDTO orderDTO = orderService.findOne(ORDER_ID); 102 | OrderDTO result = orderService.paid(orderDTO); 103 | Assert.assertEquals(PayStatusEnum.SUCCESS.getCode(), result.getPayStatus()); 104 | } 105 | } -------------------------------------------------------------------------------- /wechat_order_h/src/test/java/com/hhh/wechat_order/service/impl/PayServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service.impl; 2 | 3 | import com.hhh.wechat_order.dto.OrderDTO; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | @RunWith(SpringRunner.class) 12 | @SpringBootTest 13 | @Slf4j 14 | public class PayServiceImplTest { 15 | 16 | @Autowired 17 | private PayService payService; 18 | 19 | // @Test 20 | // public void create() { 21 | // OrderDTO orderDTO = new OrderDTO(); 22 | // payService.create(orderDTO); 23 | // } 24 | } -------------------------------------------------------------------------------- /wechat_order_h/src/test/java/com/hhh/wechat_order/service/impl/ProductServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package com.hhh.wechat_order.service.impl; 2 | 3 | import com.hhh.wechat_order.entity.ProductInfo; 4 | import com.hhh.wechat_order.enums.ProductStatusEnum; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.data.domain.Page; 11 | import org.springframework.data.domain.PageRequest; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | 14 | import java.math.BigDecimal; 15 | import java.util.List; 16 | import java.util.Optional; 17 | 18 | import static org.junit.Assert.*; 19 | 20 | @RunWith(SpringRunner.class) 21 | @SpringBootTest 22 | public class ProductServiceImplTest { 23 | 24 | @Autowired 25 | private ProductServiceImpl productService; 26 | 27 | @Test 28 | public void findById() { 29 | Optional productInfo = productService.findById("123456"); 30 | System.out.println(productInfo); 31 | } 32 | 33 | @Test 34 | public void findUpAll() { 35 | List productInfoList = productService.findUpAll(); 36 | Assert.assertNotEquals(0 , productInfoList.size()); 37 | } 38 | 39 | @Test 40 | public void findAll() { 41 | PageRequest request = new PageRequest(0 , 2); 42 | Page productInfoPage = productService.findAll(request); 43 | System.out.println(productInfoPage.getTotalElements()); 44 | } 45 | 46 | @Test 47 | public void save() { 48 | ProductInfo productInfo = new ProductInfo(); 49 | productInfo.setProductId("456789"); 50 | productInfo.setProductName("白粥"); 51 | productInfo.setProductPrice(new BigDecimal(1.2)); 52 | productInfo.setCategoryType(1); 53 | productInfo.setProductStatus(ProductStatusEnum.UP.getCode()); 54 | productInfo.setProductIcon("http://oooo.jpg"); 55 | productInfo.setProductDescription("白粥很绵"); 56 | productInfo.setProductStock(50); 57 | productService.save(productInfo); 58 | } 59 | 60 | @Test 61 | public void onSaleTest(){ 62 | ProductInfo result = productService.onSale("111"); 63 | Assert.assertEquals(ProductStatusEnum.UP , result.getProductStatusEnum()); 64 | } 65 | 66 | @Test 67 | public void offSaleTest(){ 68 | ProductInfo result = productService.offSale("111"); 69 | Assert.assertEquals(ProductStatusEnum.DOWN , result.getProductStatusEnum()); 70 | } 71 | 72 | @Test 73 | public void findByCategory(){ 74 | List productInfoList = productService.findByCategoryType(1); 75 | Assert.assertNotEquals(0 , productInfoList); 76 | 77 | } 78 | } -------------------------------------------------------------------------------- /wechat_order_q/app.js: -------------------------------------------------------------------------------- 1 | //app.js 2 | App({ 3 | 4 | //创建towxml对象,供小程序页面使用 5 | globalData:{ 6 | userInfo: null, 7 | openid: null, 8 | baseUrl: 'http://localhost:8080/sell' 9 | }, 10 | 11 | onLaunch:function(){ 12 | //云开发初始化 13 | wx.cloud.init({ 14 | // env: 'hhh-rgvp9', 15 | traceUser: true 16 | }) 17 | //云数据库初始化 18 | this.db = wx.cloud.database(); 19 | this.getOpenid(); 20 | }, 21 | 22 | //获取用户的openid 23 | getOpenid: function(){ 24 | var app = this; 25 | var openidStor = wx.getStorageSync('openid'); 26 | if(openidStor){ 27 | console.log('本地获取openid:' + openidStor); 28 | app.globalData.openid = openidStor; 29 | app._getUserInfo(); 30 | } else{ 31 | wx.cloud.callFunction({ 32 | name: 'getOpenid' , 33 | success(res){ 34 | console.log('云函数获取成功' , res); 35 | var openid = res.result.openid; 36 | wx.setStorageSync('openid', openid); 37 | app.globalData.openid = openid; 38 | app._getUserInfo(); 39 | }, 40 | fail(res){ 41 | console.log('云函数获取失败' , res); 42 | } 43 | }) 44 | } 45 | }, 46 | 47 | //获取用户信息,如果用户没有授权,就获取不到 48 | _getUserInfo: function(){ 49 | var app = this; 50 | //从网络获取最新用户信息 51 | wx.getUserInfo({ 52 | success: function(res){ 53 | var user = res.userInfo; 54 | user.openid = app.globalData.openid; 55 | app.globalData.userInfo = user; 56 | console.log('请求获取user成功'); 57 | console.log(user); 58 | app._saveUserInfo(user); 59 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 60 | // 所以此处加入 callback 以防止这种情况 61 | if(app.userInfoReadyCallback){ 62 | app.userInfoReadyCallback(res); 63 | } 64 | }, 65 | //请求网络失败时,再读本地数据 66 | fail: function(res){ 67 | console.log('请求获取user失败'); 68 | var userStor = wx.getStorageSync('user'); 69 | if(userStor){ 70 | console.log('本地获取user'); 71 | app.globalData.userInfo = userStor; 72 | } 73 | } 74 | }) 75 | }, 76 | 77 | //检测是否获取了openid 78 | _checkOpenid(){ 79 | let openid = this.globalData.openid; 80 | if(!openid){ 81 | app.getOpenid(); 82 | wx.showLoading({ 83 | title: 'openid不能为空,请重新登录', 84 | }) 85 | return null; 86 | }else{ 87 | return openid; 88 | } 89 | }, 90 | 91 | //保存userinfo 92 | _saveUserInfo: function(user){ 93 | this.globalData.userInfo = user; 94 | this._getMyUserInfo(); 95 | }, 96 | 97 | //获取自己后台的user信息 98 | _getMyUserInfo(user){ 99 | let app = this; 100 | let userInfo = app.globalData.userInfo; 101 | wx.request({ 102 | url: app.globalData.baseUrl + '/user/getUserInfo', 103 | data:{ 104 | openid: app.globalData.openid 105 | }, 106 | success:function(res){ 107 | if(res && res.data && res.data.data){ 108 | userInfo.realname = res.data.data.userName; 109 | userInfo.realphone = res.data.data.userPhone; 110 | userInfo.realzhuohao = res.data.data.userTable; 111 | userInfo.realrenshu = res.data.data.userNumber; 112 | app.globalData.userInfo = userInfo; 113 | } 114 | } 115 | }) 116 | console.log('我的后台:' , userInfo); 117 | //缓存到sd卡里 118 | wx.setStorageSync('user', userInfo); 119 | }, 120 | 121 | //获取今天是本月第几周 122 | _getWeek:function(){ 123 | //将字符串转为标准时间格式 124 | let date = new Date(); 125 | let month = date.getMonth() + 1; 126 | let week = this.getWeekFromDate(date); 127 | //第0周归于上月的最后一周 128 | if(week === 0){ 129 | month = date.getMonth(); 130 | let dateLast = new Date(); 131 | let dayLast = new Date(dateLast.getFullYear() , dateLast.getMonth() , 0).getDate(); 132 | let timestamp = new Date(new Date().getFullYear() , new Date().getMonth - 1 ,dayLast); 133 | week = this.getWeekFromDate(new Date(timestamp)); 134 | } 135 | let time = month + '月第' + week + '周'; 136 | return time; 137 | }, 138 | 139 | getWeekFromDate:function(date){ 140 | // 将字符串转为标准时间格式 141 | let w = date.getDay(); 142 | if(w === 0){ 143 | w = 7; 144 | } 145 | let week = Math.ceil((date.getDate() + 6 - w) / 7) - 1; 146 | return week; 147 | }, 148 | 149 | //获取当前时间 150 | _getCurrentTime(){ 151 | var d = new Date(); 152 | var month = d.getMonth() + 1; 153 | var date = d.getDate(); 154 | var day = d.getDay(); 155 | var hours = d.getHours(); 156 | var minutes = d.getMinutes(); 157 | var seconds = d.getSeconds(); 158 | var ms = d.getMilliseconds(); 159 | 160 | var curDateTime = d.getFullYear() + '年'; 161 | if(month>9){ 162 | curDateTime += month + '月'; 163 | }else{ 164 | curDateTime += month + '月'; 165 | } 166 | if (date > 9) 167 | curDateTime = curDateTime + date + "日"; 168 | else 169 | curDateTime = curDateTime + date + "日"; 170 | if (hours > 9) 171 | curDateTime = curDateTime + hours + "时"; 172 | else 173 | curDateTime = curDateTime + hours + "时"; 174 | if (minutes > 9) 175 | curDateTime = curDateTime + minutes + "分"; 176 | else 177 | curDateTime = curDateTime + minutes + "分"; 178 | return curDateTime; 179 | } 180 | }) 181 | -------------------------------------------------------------------------------- /wechat_order_q/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/index/index", 4 | "pages/me/me", 5 | "pages/mycomment/mycomment", 6 | "pages/myOrder/myOrder", 7 | "pages/buy/buy", 8 | "pages/change/change", 9 | "pages/confirmOrder/confirmOrder" 10 | ], 11 | "window": { 12 | "backgroundTextStyle": "light", 13 | "navigationBarBackgroundColor": "#fff", 14 | "navigationBarTitleText": "四季等你", 15 | "navigationBarTextStyle": "black" 16 | }, 17 | "tabBar": { 18 | "color": "#a9b7b7", 19 | "selectedColor": "#11cd6e", 20 | "borderStyle": "white", 21 | "list": [ 22 | { 23 | "selectedIconPath": "image/home_yes.png", 24 | "iconPath": "image/home_no.png", 25 | "pagePath": "pages/index/index", 26 | "text": "首页" 27 | }, 28 | { 29 | "selectedIconPath": "image/me_yes.png", 30 | "iconPath": "image/me_no.png", 31 | "pagePath": "pages/me/me", 32 | "text": "我的" 33 | } 34 | ] 35 | }, 36 | "sitemapLocation": "sitemap.json" 37 | } -------------------------------------------------------------------------------- /wechat_order_q/app.wxss: -------------------------------------------------------------------------------- 1 | /**app.wxss**/ 2 | /* .container { 3 | height: 100%; 4 | display: flex; 5 | flex-direction: column; 6 | align-items: center; 7 | justify-content: space-between; 8 | padding: 200rpx 0; 9 | box-sizing: border-box; 10 | } */ 11 | .container { 12 | display: flex; 13 | flex-direction: column; 14 | min-height: 100%; 15 | } 16 | /*个人中心的条目布局,全局统一布局 */ 17 | .my_item { 18 | width: 100%; 19 | display: flex; 20 | flex-direction: row; 21 | align-items: center; 22 | padding: 17px; 23 | background: white; 24 | border-bottom: 1px solid gainsboro; 25 | } 26 | .line_5px { 27 | height: 15px; 28 | } 29 | .line_8pt { 30 | height: 8pt; 31 | } 32 | .line_1px { 33 | height: 1px; 34 | background: gainsboro 35 | } 36 | .right_arrow { 37 | border: solid black; 38 | border-width: 0 3px 3px 0; 39 | padding: 3px; 40 | position: absolute; 41 | right: 15px; 42 | /* margin-left: 66%; */ 43 | transform: rotate(-45deg); 44 | -webkit-transform: rotate(-45deg); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /wechat_order_q/functions/getOpenid/index.js: -------------------------------------------------------------------------------- 1 | // 云函数入口文件 2 | const cloud = require('wx-server-sdk') 3 | 4 | cloud.init() 5 | 6 | // 云函数入口函数 7 | exports.main = async (event, context) => { 8 | const wxContext = cloud.getWXContext() 9 | 10 | return { 11 | openid: wxContext.OPENID 12 | } 13 | } -------------------------------------------------------------------------------- /wechat_order_q/functions/getOpenid/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "getOpenid", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "wx-server-sdk": "latest" 13 | } 14 | } -------------------------------------------------------------------------------- /wechat_order_q/image/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/1.jpg -------------------------------------------------------------------------------- /wechat_order_q/image/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/2.jpg -------------------------------------------------------------------------------- /wechat_order_q/image/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/3.jpg -------------------------------------------------------------------------------- /wechat_order_q/image/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/4.jpg -------------------------------------------------------------------------------- /wechat_order_q/image/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/5.jpg -------------------------------------------------------------------------------- /wechat_order_q/image/ask_no.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/ask_no.png -------------------------------------------------------------------------------- /wechat_order_q/image/ask_yes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/ask_yes.png -------------------------------------------------------------------------------- /wechat_order_q/image/cart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/cart.png -------------------------------------------------------------------------------- /wechat_order_q/image/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/header.png -------------------------------------------------------------------------------- /wechat_order_q/image/home_no.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/home_no.png -------------------------------------------------------------------------------- /wechat_order_q/image/home_yes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/home_yes.png -------------------------------------------------------------------------------- /wechat_order_q/image/kf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/kf.png -------------------------------------------------------------------------------- /wechat_order_q/image/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/logo.jpg -------------------------------------------------------------------------------- /wechat_order_q/image/logo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/logo1.png -------------------------------------------------------------------------------- /wechat_order_q/image/logo2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/logo2.jpg -------------------------------------------------------------------------------- /wechat_order_q/image/logo60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/logo60.png -------------------------------------------------------------------------------- /wechat_order_q/image/mall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/mall.png -------------------------------------------------------------------------------- /wechat_order_q/image/me_no.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/me_no.png -------------------------------------------------------------------------------- /wechat_order_q/image/me_yes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/me_yes.png -------------------------------------------------------------------------------- /wechat_order_q/image/news.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/news.png -------------------------------------------------------------------------------- /wechat_order_q/image/noP.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/noP.gif -------------------------------------------------------------------------------- /wechat_order_q/image/scan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/scan.png -------------------------------------------------------------------------------- /wechat_order_q/image/shopCart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/shopCart.png -------------------------------------------------------------------------------- /wechat_order_q/image/shopart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/shopart.png -------------------------------------------------------------------------------- /wechat_order_q/image/sopCart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HCychao/SpringBootAndOrder/883941f9cc800156aca9e93a16e5c423332380bd/wechat_order_q/image/sopCart.png -------------------------------------------------------------------------------- /wechat_order_q/pages/buy/buy.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /wechat_order_q/pages/change/change.js: -------------------------------------------------------------------------------- 1 | // change.js 2 | 3 | const app = getApp(); 4 | 5 | Page({ 6 | 7 | /** 8 | * 页面的初始数据 9 | */ 10 | data: { 11 | username: '', 12 | phone: '', 13 | tablenumber: '', 14 | number: '' 15 | }, 16 | 17 | bindinputusername: function(e) { 18 | this.setData({ 19 | username: e.detail.value 20 | }) 21 | }, 22 | 23 | bindinputphone: function(e) { 24 | this.setData({ 25 | phone: e.detail.value 26 | }) 27 | }, 28 | 29 | bindinputtablenumber: function(e) { 30 | this.setData({ 31 | tablenumber: e.detail.value 32 | }) 33 | }, 34 | 35 | bindinputrenshu: function(e) { 36 | this.setData({ 37 | number: e.detail.value 38 | }) 39 | }, 40 | 41 | /** 42 | * 修改个人信息 43 | */ 44 | formSubmit: function() { 45 | var that = this; 46 | //如果 openid 不存在 ,就重新请求接口获取openid 47 | var openid = app.globalData.openid; 48 | if (openid === null || openid === undefined) { 49 | app.getOpenid(); 50 | //这里提示失败原因 51 | wx.showToast({ 52 | title: '您还没有登陆!', 53 | duration: 1500 54 | }) 55 | return; 56 | } 57 | 58 | let username = that.data.username; 59 | let phone = that.data.phone; 60 | let tablenumber = that.data.tablenumber; 61 | console.log(tablenumber); 62 | let number = that.data.number; 63 | console.log(number); 64 | 65 | if (username === '') { 66 | wx.showToast({ 67 | title: '用户名不能为空', 68 | icon: 'none' 69 | }) 70 | return; 71 | } 72 | if (phone === '') { 73 | wx.showToast({ 74 | title: '手机号不能为空', 75 | icon: 'none' 76 | }) 77 | return; 78 | } 79 | 80 | wx.request({ 81 | url: app.globalData.baseUrl + '/user/save', 82 | method: "POST", 83 | header: { 84 | "Content-Type": "application/x-www-form-urlencoded" 85 | }, 86 | data: { 87 | openid: openid, 88 | username: username, 89 | phone: phone, 90 | usertable: tablenumber, 91 | usernumber: number 92 | }, 93 | success: function(res) { 94 | wx.showToast({ 95 | title: '修改成功', 96 | }) 97 | app._getMyUserInfo(); 98 | wx.switchTab({ 99 | url: '../index/index', 100 | }) 101 | } 102 | }) 103 | }, 104 | 105 | /** 106 | * 生命周期函数--监听页面加载 107 | */ 108 | onLoad: function(options) { 109 | let that = this; 110 | var openid = app.globalData.openid; 111 | if (openid === null || openid === undefined) { 112 | app.getOpenid(); 113 | wx.showToast({ 114 | title: '您还没有登陆!', 115 | duration: 1500 116 | }) 117 | return; 118 | } 119 | if (app.globalData.userInfo) { 120 | console.log(app.globalData.userInfo); 121 | that.setData({ 122 | username: app.globalData.userInfo.realname, 123 | phone: app.globalData.userInfo.realphone, 124 | tablenumber: app.globalData.userInfo.realzhuohao, 125 | number: app.globalData.userInfo.realrenshu 126 | }) 127 | } 128 | }, 129 | 130 | }) -------------------------------------------------------------------------------- /wechat_order_q/pages/change/change.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "个人信息修改" 3 | } -------------------------------------------------------------------------------- /wechat_order_q/pages/change/change.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 姓名: 8 | 9 | 10 | 11 | 12 | 13 | 14 | 电话: 15 | 16 | 17 | 18 | 19 | 20 | 21 | 桌号: 22 | 23 | 24 | 25 | 26 | 27 | 28 | 就餐人数: 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /wechat_order_q/pages/change/change.wxss: -------------------------------------------------------------------------------- 1 | /* change.wxss */ 2 | 3 | page{ 4 | background: #69e6db; 5 | } 6 | 7 | .container{ 8 | width: 90%; 9 | margin: 4%; 10 | background: white 11 | } 12 | 13 | .item_root{ 14 | background: white; 15 | padding: 8px 10px; 16 | } 17 | 18 | .textarea80px{ 19 | width: 100%; 20 | height: 80px; 21 | border: 1px solid gainsboro; 22 | } 23 | 24 | .textarea25px { 25 | width: 100%; 26 | height: 25px; 27 | border: 1px solid gainsboro; 28 | } 29 | 30 | .my_item_small { 31 | /* 带选择箭头 */ 32 | width: 90%; 33 | display: flex; 34 | flex-direction: row; 35 | align-items: center; 36 | padding: 8px 10px; 37 | background: white; 38 | /* border-bottom: 1px solid gainsboro; */ 39 | } 40 | 41 | /* 发布按钮 */ 42 | .btn_fabu { 43 | width: 80%; 44 | height: 40px; 45 | margin-top: 30px; 46 | align-items: center; 47 | } -------------------------------------------------------------------------------- /wechat_order_q/pages/confirmOrder/confirmOrder.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /wechat_order_q/pages/index/index.js: -------------------------------------------------------------------------------- 1 | //index.js 2 | const app = getApp() 3 | 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | //轮播图图片的路径 11 | banner:[ 12 | '/image/2.jpg', 13 | '/image/3.jpg', 14 | '/image/4.jpg', 15 | '/image/5.jpg', 16 | // '/image/1.jpg' 17 | ], 18 | // banner:[] 19 | }, 20 | 21 | //扫码点餐 22 | btnclick1: function(){ 23 | let that = this; 24 | // that.goToBuy("1号桌"); 25 | 26 | //允许从相机和相册扫码 27 | wx.scanCode({ 28 | success:(res) => { 29 | console.log(res.result); 30 | if(res.result){ 31 | let str = res.result; 32 | //识别的二维码里包好30paotui.com就弹出红包领取页 33 | if(str.search("111") != -1){ 34 | console.log("1号桌"); 35 | that.goToBuy("1号桌"); 36 | } else if(str.search("222") != -1){ 37 | console.log("2号桌"); 38 | that.goToBuy("2号桌"); 39 | } else if(str.search("333") != -1){ 40 | console.log("3号桌"); 41 | that.goToBuy("3号桌"); 42 | } else if (str.search("444") != -1) { 43 | console.log("4号桌"); 44 | that.goToBuy("4号桌"); 45 | } else if (str.search("555") != -1) { 46 | console.log("5号桌"); 47 | that.goToBuy("5号桌"); 48 | } 49 | } 50 | } 51 | }) 52 | }, 53 | //去点餐页 54 | goToBuy(tableNum){ 55 | wx.navigateTo({ 56 | url: '../buy/buy?tableNum=' + tableNum 57 | }) 58 | }, 59 | 60 | //菜品浏览 61 | btnclick2:function() { 62 | wx.navigateTo({ 63 | url: '../buy/buy' 64 | }) 65 | }, 66 | 67 | //店铺电话 68 | btnclick3:function(){ 69 | wx.makePhoneCall({ 70 | phoneNumber: '17875303280' 71 | }) 72 | }, 73 | 74 | //加载顶部的图片 75 | // onLoad(){ 76 | // this.getTopBanner(); 77 | // }, 78 | // getTopBanner(){ 79 | // let that = this; 80 | // wx.request({ 81 | // url: app.globalData.baseUrl + '/picture/getAll', 82 | // success:function(res){ 83 | // if(res && res.data && res.data.data && res.data.data.length > 0){ 84 | // let dataList = res.data.data; 85 | // console.log(dataList); 86 | // that.setData({ 87 | // banner : dataList 88 | // }) 89 | // } else{ 90 | // that.setData({ 91 | // list:[] 92 | // }) 93 | // } 94 | // } 95 | // }) 96 | // } 97 | 98 | }) -------------------------------------------------------------------------------- /wechat_order_q/pages/index/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "4-seasons for you" 3 | } -------------------------------------------------------------------------------- /wechat_order_q/pages/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 四季等你:天河区北大光明街43号 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 扫码点餐 23 | 24 | 25 | 26 | 27 | 菜单浏览 28 | 29 | 30 | 31 | 32 | 33 | 34 | 饭店电话 35 | 36 | 37 | 38 | 41 | 在线客服 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /wechat_order_q/pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | /**index.wxss**/ 2 | 3 | /* .canel{ 4 | background: #d7f9f6; 5 | } */ 6 | 7 | .category-panel1 { 8 | height: 300px; 9 | width: 100%; 10 | display: flex; 11 | color: #666; 12 | flex-direction: column; 13 | font-size: 11px; 14 | justify-content: space-around; 15 | } 16 | 17 | .category-panel2 { 18 | height: 100px; 19 | width: 100%; 20 | display: flex; 21 | color: #666; 22 | flex-direction: row; 23 | font-size: 11px; 24 | justify-content: space-around; 25 | } 26 | 27 | .category-item { 28 | display: flex; 29 | width: 60px; 30 | text-align: center; 31 | flex-direction: column; 32 | } 33 | 34 | .category-item-image { 35 | width: 50px; 36 | height: 50px; 37 | overflow: unset; 38 | padding: 15px 12px 0 6px; 39 | } 40 | 41 | .category-item-image1 { 42 | width: 50px; 43 | height: 45px; 44 | overflow: unset; 45 | padding: 15px 12px 0 6px; 46 | } 47 | 48 | .kf_button { 49 | background-color: rgba(255, 255, 255, 0); 50 | padding: 0px 0px 0px 0px; 51 | border: 0px; 52 | } 53 | 54 | .kf_button::after { 55 | border: 0px; 56 | } 57 | 58 | .category-item-text { 59 | margin-top: 11px; 60 | } 61 | 62 | .category-item-text1 { 63 | margin-top: 0px; 64 | } 65 | 66 | /* 下面是领取红包的弹窗样式 */ 67 | 68 | /* 遮罩层 */ 69 | 70 | .mask { 71 | width: 100%; 72 | height: 100%; 73 | position: fixed; 74 | top: 0; 75 | left: 0; 76 | background: #000; 77 | z-index: 9000; 78 | opacity: 0.5; 79 | } 80 | 81 | /* 弹出层 */ 82 | 83 | .modalDlg { 84 | width: 70%; 85 | position: fixed; 86 | top: 200px; 87 | left: 0; 88 | right: 0; 89 | z-index: 9999; 90 | margin: 0 auto; 91 | background-color: #fff; 92 | border-radius: 5px; 93 | display: flex; 94 | flex-direction: column; 95 | align-items: center; 96 | } 97 | 98 | /* 弹出层里面的图片 */ 99 | 100 | .modalDlg image { 101 | width: 120px; 102 | height: 120px; 103 | margin-top: 30px; 104 | } 105 | 106 | /* 弹出层里面的按钮 */ 107 | 108 | .ok { 109 | width: 80px; 110 | height: 35px; 111 | background: #44b549; 112 | line-height: 35px; 113 | text-align: center; 114 | color: #fff; 115 | font-size: 15px; 116 | margin: 20px auto; 117 | border-radius: 100px; 118 | } 119 | 120 | /* 弹出层里面的文字 */ 121 | 122 | .dialog-text { 123 | text-align:center; 124 | font-size: 14px; 125 | color: #666; 126 | width: 180px; 127 | margin-top: 10px; 128 | } 129 | -------------------------------------------------------------------------------- /wechat_order_q/pages/me/me.js: -------------------------------------------------------------------------------- 1 | // pages/me/me.js 2 | 3 | const app = getApp(); 4 | 5 | Page({ 6 | 7 | //页面初始数据 8 | data: { 9 | isShowUserName: false, 10 | userInfo: null 11 | }, 12 | 13 | //button按钮事件 -> 获取用户信息 14 | onGotUserInfo: function(e) { 15 | if (e.detail.userInfo) { 16 | var user = e.detail.userInfo; 17 | this.setData({ 18 | isShowUserName: true, 19 | userInfo: e.detail.userInfo, 20 | }) 21 | user.openid = app.globalData.openid; 22 | app._saveUserInfo(user); 23 | } else{ 24 | app._showSettingToast('登录需要允许授权'); 25 | } 26 | }, 27 | 28 | //跳转页面(我的订单页) 29 | goToMyOrder: function(){ 30 | wx.navigateTo({ 31 | url: '../myOrder/myOrder', 32 | }) 33 | }, 34 | 35 | //跳转页面(我的评论页) 36 | goToMyComment: function(){ 37 | wx.navigateTo({ 38 | url: '../mycomment/mycomment?type=1', 39 | }) 40 | }, 41 | 42 | //个人信息页 43 | change(){ 44 | wx.navigateTo({ 45 | url: '../change/change', 46 | }) 47 | }, 48 | 49 | //显示函数(页面显示) 50 | onShow(options){ 51 | console.log("个人show",options); 52 | var user = app.globalData.userInfo; 53 | if(user){ 54 | this.setData({ 55 | isShowUserName: true, 56 | userInfo: user, 57 | }) 58 | } 59 | }, 60 | 61 | //生命周期函数 -> 页面加载 62 | onLoad: function(options){ 63 | console.log("个人onLoad"); 64 | var that = this; 65 | var user = app.globalData.userInfo; 66 | if(user){ 67 | // that.setData({ 68 | // isShowUserName: true, 69 | // userInfo: user, 70 | // }) 71 | } else{ 72 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 73 | // 所以此处加入 callback 以防止这种情况 74 | app.userInfoReadyCallback = res => { 75 | that.setData({ 76 | userInfo: res.userInfo, 77 | isShowUserName: true 78 | }) 79 | } 80 | } 81 | } 82 | 83 | }) -------------------------------------------------------------------------------- /wechat_order_q/pages/me/me.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /wechat_order_q/pages/me/me.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{userInfo.realname?userInfo.realname:userInfo.nickName}} 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 我的订单 19 | 20 | 21 | 22 | 23 | 我的评价 24 | 25 | -------------------------------------------------------------------------------- /wechat_order_q/pages/me/me.wxss: -------------------------------------------------------------------------------- 1 | /* me.wxss */ 2 | 3 | page{ 4 | background: gainsboro; 5 | } 6 | 7 | .header{ 8 | width: 100%; 9 | display: flex; 10 | flex-direction: column; 11 | padding-bottom: 20px; 12 | align-items: center; 13 | background: white; 14 | } 15 | 16 | .btn-login{ 17 | padding: 10%; 18 | background: white; 19 | } 20 | 21 | .userinfo-avatar{ 22 | border-radius: 128rpx; 23 | width: 128rpx; 24 | height: 128rpx; 25 | } 26 | 27 | .userinfo-nickname{ 28 | margin-top: 20rpx; 29 | font-size: 38rpx; 30 | } 31 | 32 | .runner_desc{ 33 | font-size: 10pt; 34 | color: red; 35 | } -------------------------------------------------------------------------------- /wechat_order_q/pages/myOrder/myOrder.js: -------------------------------------------------------------------------------- 1 | //JS 2 | var app = getApp() 3 | //0"新订单,未支付;1"新订单,已支付";2, "已取消";3"待评价";4“已完成” 4 | let orderStatus = 1; 5 | 6 | Page({ 7 | data: { 8 | // 顶部菜单切换 9 | navbar: ["待上餐", "已取消", "待评价", "已完成"], 10 | // 默认选中菜单 11 | currentTab: 0, 12 | //是否显示评论框 13 | isShowComment: false, 14 | list: [] 15 | }, 16 | 17 | 18 | //顶部tab切换 19 | navbarTap: function(e) { 20 | let index = e.currentTarget.dataset.idx; 21 | this.setData({ 22 | currentTab: index 23 | }) 24 | 25 | //1"新订单,已支付";2, "已取消";3"待评价";4“已完成” 26 | if (index == 1) { 27 | orderStatus = 2; 28 | } else if (index == 2) { 29 | orderStatus = 3; 30 | } else if (index == 3) { 31 | orderStatus = 4; 32 | } else { 33 | orderStatus = 1; 34 | } 35 | this.getMyOrderList(); 36 | }, 37 | 38 | onShow: function() { 39 | this.getMyOrderList(); 40 | }, 41 | 42 | 43 | getMyOrderList() { 44 | let that = this; 45 | let openid = app._checkOpenid(); 46 | if (!openid) { 47 | return; 48 | } 49 | //请求自己后台获取用户openid 50 | wx.request({ 51 | url: app.globalData.baseUrl + '/buyer/order/listByStatus', 52 | data: { 53 | openid: openid, 54 | orderStatus: orderStatus 55 | }, 56 | success: function(res) { 57 | console.log(res); 58 | if (res && res.data && res.data.data && res.data.data.length > 0) { 59 | let dataList = res.data.data; 60 | console.log(dataList) 61 | that.setData({ 62 | list: dataList 63 | }) 64 | } else { 65 | that.setData({ 66 | list: [] 67 | }) 68 | } 69 | } 70 | }) 71 | }, 72 | 73 | 74 | //去评论页面 75 | goCommentPage() { 76 | wx.navigateTo({ 77 | url: '../mycomment/mycomment?type=' + 1, 78 | }) 79 | }, 80 | 81 | 82 | //弹起评论框 83 | goComment(event) { 84 | let orderId = event.currentTarget.dataset.orderid; 85 | this.setData({ 86 | isShowComment: true, 87 | orderId: orderId 88 | }) 89 | }, 90 | 91 | 92 | //隐藏评论框 93 | cancelComment() { 94 | this.setData({ 95 | isShowComment: false 96 | }) 97 | }, 98 | 99 | 100 | //获取评论内容 101 | setValue(input) { 102 | this.setData({ 103 | comment: input.detail.value 104 | }) 105 | }, 106 | 107 | 108 | //提交评论 109 | submitComment() { 110 | let that = this; 111 | that.cancelComment(); 112 | let content = that.data.comment; 113 | let orderId = that.data.orderId; 114 | if (!content) { 115 | wx.showToast({ 116 | title: '评论内容为空', 117 | }) 118 | return; 119 | } 120 | let openid = app._checkOpenid(); 121 | if (!openid) { 122 | return; 123 | } 124 | 125 | wx.request({ 126 | url: app.globalData.baseUrl + '/comment', 127 | method: "POST", 128 | header: { 129 | "Content-Type": "application/x-www-form-urlencoded" 130 | }, 131 | data: { 132 | orderId: orderId, 133 | openid: openid, 134 | username: app.globalData.userInfo.nickName, 135 | avatarUrl: app.globalData.userInfo.avatarUrl, 136 | content: content 137 | }, 138 | success: function(res) { 139 | that.getMyOrderList(); 140 | wx.showToast({ 141 | title: '评论成功', 142 | }) 143 | } 144 | }) 145 | }, 146 | 147 | 148 | //催单 149 | clickSure(event) { 150 | let that = this; 151 | let orderId = event.currentTarget.dataset.orderid; 152 | wx.showToast({ 153 | title: '催单成功', 154 | }) 155 | }, 156 | 157 | //点击去支付页面 158 | clickGoPay(event) { 159 | let that = this; 160 | let orderId = event.currentTarget.dataset.orderid; 161 | wx.showModal({ 162 | title: '模拟支付', 163 | content: '确定去支付吗?', 164 | success(res) { 165 | if (res.confirm) { 166 | that.goPay(orderId) 167 | } else if (res.cancel) { 168 | console.log('用户点击取消') 169 | } 170 | } 171 | }) 172 | }, 173 | 174 | 175 | //去支付 176 | goPay(orderId) { 177 | let that = this; 178 | let openid = app._checkOpenid(); 179 | if (!openid) { 180 | return; 181 | } 182 | 183 | //请求自己后台获取用户openid 184 | wx.request({ 185 | url: app.globalData.baseUrl + '/pay/goPay', 186 | data: { 187 | orderId: orderId 188 | }, 189 | success: function(res) { 190 | console.log(res); 191 | if (res && res.data && res.data.data) { 192 | let dataList = res.data.data; 193 | that.getMyOrderList(); 194 | wx.showToast({ 195 | title: '支付成功', 196 | }) 197 | } else { 198 | wx.showToast({ 199 | title: '支付失败', 200 | }) 201 | } 202 | } 203 | }) 204 | }, 205 | 206 | 207 | //取消订单 208 | cancleOrder(event) { 209 | let that = this; 210 | let openid = app._checkOpenid(); 211 | if (!openid) { 212 | return; 213 | } 214 | 215 | let orderId = event.currentTarget.dataset.orderid; 216 | wx.request({ 217 | url: app.globalData.baseUrl + '/buyer/order/cancel', 218 | method: "POST", 219 | header: { 220 | "Content-Type": "application/x-www-form-urlencoded" 221 | }, 222 | data: { 223 | openid: "" + openid, 224 | orderId: orderId 225 | }, 226 | success: function(res) { 227 | console.log({ 228 | res 229 | }); 230 | that.getMyOrderList(); 231 | } 232 | }) 233 | } 234 | 235 | }) -------------------------------------------------------------------------------- /wechat_order_q/pages/myOrder/myOrder.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /wechat_order_q/pages/myOrder/myOrder.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{item}} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 合计:¥{{item.orderAmount}} 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /wechat_order_q/pages/mycomment/mycomment.js: -------------------------------------------------------------------------------- 1 | //JS 2 | var app = getApp() 3 | 4 | Page({ 5 | data: { 6 | // 顶部菜单切换 7 | navbar: ['全部评价', "我的评价"], 8 | // 默认选中菜单 9 | currentTab: 0, 10 | list: [] 11 | }, 12 | //顶部tab切换 13 | navbarTap: function(e) { 14 | let index = e.currentTarget.dataset.idx; 15 | this.setData({ 16 | currentTab: index 17 | }) 18 | if (index == 1) { 19 | this.getMyCommentList(); 20 | } else { 21 | this.getCommentList(); 22 | } 23 | 24 | }, 25 | onLoad(options) { 26 | let type = options.type; 27 | if (type == 1) { 28 | this.getMyCommentList(); 29 | this.setData({ 30 | currentTab: 1 31 | }) 32 | } else { 33 | this.getCommentList(); 34 | 35 | } 36 | }, 37 | //获取所有评论列表 38 | getCommentList() { 39 | let that = this; 40 | //请求自己后台获取用户openid 41 | wx.request({ 42 | url: app.globalData.baseUrl + '/commentList', 43 | success: function(res) { 44 | if (res && res.data && res.data.data && res.data.data.length > 0) { 45 | let dataList = res.data.data; 46 | console.log(dataList) 47 | that.setData({ 48 | list: dataList 49 | }) 50 | } else { 51 | that.setData({ 52 | list: [] 53 | }) 54 | } 55 | } 56 | }) 57 | }, 58 | 59 | //获取我的所有评论列表 60 | getMyCommentList() { 61 | let that = this; 62 | let openid = app._checkOpenid(); 63 | if (!openid) { 64 | return; 65 | } 66 | //请求自己后台获取用户openid 67 | wx.request({ 68 | url: app.globalData.baseUrl + '/userCommentList', 69 | data: { 70 | openid: openid 71 | }, 72 | success: function(res) { 73 | if (res && res.data && res.data.data && res.data.data.length > 0) { 74 | let dataList = res.data.data; 75 | console.log(dataList) 76 | that.setData({ 77 | list: dataList 78 | }) 79 | } else { 80 | that.setData({ 81 | list: [] 82 | }) 83 | } 84 | } 85 | }) 86 | }, 87 | }) -------------------------------------------------------------------------------- /wechat_order_q/pages/mycomment/mycomment.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /wechat_order_q/pages/mycomment/mycomment.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | {{item.commentName}}评论: 17 | 18 | {{item.commentContent}} 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /wechat_order_q/pages/mycomment/mycomment.wxss: -------------------------------------------------------------------------------- 1 | /* 顶部菜单切换 */ 2 | 3 | .navbar { 4 | display: flex; 5 | background: #fff; 6 | } 7 | 8 | .none_tab { 9 | position: relative; 10 | top: 20rpx; 11 | color: #999; 12 | font-size: 32rpx; 13 | } 14 | 15 | /* 默认选中菜单 */ 16 | 17 | .navbar .item { 18 | position: relative; 19 | flex: auto; 20 | font-size: 27rpx; 21 | width: 100rpx; 22 | text-align: center; 23 | line-height: 80rpx; 24 | color: #333; 25 | border-bottom: 6rpx solid #ddd; 26 | } 27 | 28 | /* 选中菜单样式 */ 29 | 30 | .navbar .item.active { 31 | color: #333; 32 | border-bottom: 6rpx solid #d66058; 33 | } 34 | 35 | /* 字体 */ 36 | 37 | .navbar .item.active:after { 38 | content: ""; 39 | display: block; 40 | position: absolute; 41 | bottom: 0; 42 | left: 0; 43 | right: 0; 44 | height: 4rpx; 45 | } 46 | 47 | /* 列表样式 */ 48 | 49 | .singleTrade { 50 | background: #fff; 51 | padding: 20rpx; 52 | display: flex; 53 | border-bottom: 20rpx solid #fafafa; 54 | } 55 | 56 | .name_root { 57 | display: flex; 58 | flex-direction: column; 59 | width: 100%; 60 | } 61 | 62 | .img { 63 | width: 100rpx; 64 | height: 100rpx; 65 | border-radius: 100rpx; 66 | } 67 | 68 | .name { 69 | font-size: 27rpx; 70 | color: black; 71 | } 72 | 73 | .content { 74 | flex: 1; 75 | margin: 0rpx 15rpx; 76 | display: flex; 77 | flex-direction: column; 78 | justify-content: space-around; 79 | font-size: 25rpx; 80 | line-height: 50rpx; 81 | display: -webkit-box; 82 | word-break: break-all; 83 | text-overflow: ellipsis; 84 | overflow: hidden; 85 | -webkit-box-orient: vertical; 86 | } 87 | -------------------------------------------------------------------------------- /wechat_order_q/project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件", 3 | "packOptions": { 4 | "ignore": [] 5 | }, 6 | "setting": { 7 | "urlCheck": false, 8 | "es6": true, 9 | "postcss": true, 10 | "minified": true, 11 | "newFeature": true, 12 | "coverView": true, 13 | "autoAudits": false, 14 | "checkInvalidKey": true, 15 | "checkSiteMap": true, 16 | "uploadWithSourceMap": true, 17 | "babelSetting": { 18 | "ignore": [], 19 | "disablePlugins": [], 20 | "outputPath": "" 21 | } 22 | }, 23 | "compileType": "miniprogram", 24 | "libVersion": "2.8.3", 25 | "cloudfunctionRoot": "functions/", 26 | "appid": "wx2e9e8949f0cab7cf", 27 | "projectname": "wechat_order", 28 | "debugOptions": { 29 | "hidedInDevtools": [] 30 | }, 31 | "scripts": {}, 32 | "simulatorType": "wechat", 33 | "simulatorPluginLibVersion": {}, 34 | "condition": { 35 | "search": { 36 | "current": -1, 37 | "list": [] 38 | }, 39 | "conversation": { 40 | "current": -1, 41 | "list": [] 42 | }, 43 | "plugin": { 44 | "current": -1, 45 | "list": [] 46 | }, 47 | "game": { 48 | "list": [] 49 | }, 50 | "gamePlugin": { 51 | "current": -1, 52 | "list": [] 53 | }, 54 | "miniprogram": { 55 | "current": 1, 56 | "list": [ 57 | { 58 | "id": -1, 59 | "name": "me", 60 | "pathName": "pages/me/me", 61 | "query": "", 62 | "scene": null 63 | }, 64 | { 65 | "id": -1, 66 | "name": "change", 67 | "pathName": "pages/change/change", 68 | "query": "", 69 | "scene": null 70 | }, 71 | { 72 | "id": -1, 73 | "name": "mycomment", 74 | "pathName": "pages/mycomment/mycomment", 75 | "query": "", 76 | "scene": null 77 | }, 78 | { 79 | "id": -1, 80 | "name": "buy", 81 | "pathName": "pages/buy/buy", 82 | "query": "", 83 | "scene": null 84 | }, 85 | { 86 | "id": -1, 87 | "name": "confirmOrder", 88 | "pathName": "pages/confirmOrder/confirmOrder", 89 | "query": "", 90 | "scene": null 91 | }, 92 | { 93 | "id": -1, 94 | "name": "myOrder", 95 | "pathName": "pages/myOrder/myOrder", 96 | "scene": null 97 | } 98 | ] 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /wechat_order_q/sitemap.json: -------------------------------------------------------------------------------- 1 | { 2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", 3 | "rules": [{ 4 | "action": "allow", 5 | "page": "*" 6 | }] 7 | } -------------------------------------------------------------------------------- /wechat_order_q/wxss/common.wxss: -------------------------------------------------------------------------------- 1 | /*icon图标 */ 2 | 3 | @font-face { 4 | font-family: 'iconfont'; 5 | src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAXcAA0AAAAACFgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAFwAAAABoAAAAcf7+j60dERUYAAAWkAAAAHAAAAB4AJwAMT1MvMgAAAaAAAABCAAAAVlbmSABjbWFwAAAB/AAAAE4AAAFKy8chmmdhc3AAAAWcAAAACAAAAAj//wADZ2x5ZgAAAlwAAAHLAAACLGyxjtFoZWFkAAABMAAAADAAAAA2DrhOw2hoZWEAAAFgAAAAHQAAACQH0gOGaG10eAAAAeQAAAAWAAAAFg1MADZsb2NhAAACTAAAAA4AAAAOAYwAvm1heHAAAAGAAAAAHwAAACABFQBdbmFtZQAABCgAAAFJAAACiCnmEVVwb3N0AAAFdAAAACgAAAA7ElgeUHicY2BkYGAA4jNbVWvj+W2+MnCzMIDA1bOtSXCa638P8xfmMiCXg4EJJAoATAQL9XicY2BkYGBu+N/AEMPCAALMXxgYGVABKwBZEwNhAAAAeJxjYGRgYGBjCGRgZQABJiDmAkIGhv9gPgMAEUgBcwB4nGNgZP7BOIGBlYGBqZPpDAMDQz+EZnzNYMTIARRlYGVmwAoC0lxTGBwYKp6JMTf8b2CIYW5gaAAKM4LkACKWDHoAAAQAAAAAAAAAAVUAAAPpACwEAAAKAA4AAHicY2BgYGaAYBkGRgYQcAHyGMF8FgYNIM0GpBkZmBgqnon9/w/kVzwT/f//f7fke6h6IGBkY4BzGJmABBMDKmBkoBlgpp3RJAEAQpQKSAAAAAAAAAAAAAAAdgC+ARYAAHicfZC/btNQFMbPuTfXsXMdp7Hj/00Tx9QGtUQiccNQtR1g4c9QiYmRBwCkDu3C0AWJoUN5BYTEA2TtlOQNnEgMLAiidmRgtG64JsDI1dHV90m/o/OdAwx2V1/pFfXAgttwDx7CMQAqO9gzSBujNOuTHbQjZrstg6ZxGlXjXp8eoNtTWs5glCWuUlUaaOAWDqPBKO2TFPeyQ7KPA6eN6IfBM3N706SXWPPSrbfiMfmAdifebBzeFY92j1qDrqWe6abpm+aFqjCmElJpGPjSdTSm1RTxkTUC+6pzh3RQ99Pg6fN6NzRfvMtetbddDfH8HK2wa3w6agZNWW8CxzL96kZd9YJ6fKuFZ9+5Z+nt5BvIR6G2uqA/6SlwcCEu94SqA+4I7idAE0ilkFYBKyq3K/fJElzNxVJRMJwvMGRMLBdTUTCGlekMK9IXTLxWdV3F9/KnpyWwEEsJhAvZUDyQ5OwPOZuJAr9wk8ta5zFWl/QHPfmdZ/ifPPFelvSUNsZlrn20y9Mf4HCdLxc3Mp+Xz9GTU27mEyHkeDKZIpFeVMa8ycca59pfQU+YuM5zcS0xP8/RL56U/GTNT2Q/fh6rnKtjfUP/J+AXSs57JgB4nH2QPU4DMRCFn/MHJBJCIKhdUQDa/JQpEyn0CKWjSDbekGjXXnmdSDkBLRUHoOUYHIAbINFyCl6WSZMia+3o85uZ57EBnOMbCv/fJe6EFY7xKFzBETLhKvUX4Rr5XbiOFj6FG9R/hJu4VQPhFi7UGx1U7YS7m9JtywpnGAhXcIon4Sr1lXCN/CpcxxU+hBvUv4SbGONXuIVrZakM4WEwQWCcQWOKDeMCMRwskjIG1qE59GYSzExPN3oRO5s4GyjvV2KXAx5oOeeAKe09t2a+Sif+YMuB1JhuHgVLtimNLiJ0KBtfLJzV3ahzsP2e7ba02L9rgTXH7FENbNT8Pdsz0khsDK+QkjXyMrekElOPaGus8btnKdbzXgiJTrzL9IjHmjR1OvduaeLA4ufyjBx9tLmSPfeoHD5jWQh5v91OxCCKXYY/k9hxGQAAAHicY2BigAAuBuyADYgZGZgYohmZGJnZcjPzSouNWAtySosNASgNBNYAAAAB//8AAnicY2BkYGDgAWIxIGZiYARCViBmAfMYAAPVADR4nGNgYGBkAIIrKjPVQPTVs61JMBoAQ08GywAA) format('woff'), 6 | url('iconfont.ttf') format('truetype'); 7 | font-weight: normal; 8 | font-style: normal; 9 | } 10 | 11 | .iconfont { 12 | font-family: "iconfont" !important; 13 | font-size: 16px; 14 | font-style: normal; 15 | -webkit-font-smoothing: antialiased; 16 | -moz-osx-font-smoothing: grayscale; 17 | } 18 | 19 | .icon-minus2:before { 20 | content: "\e615"; 21 | } 22 | 23 | .icon-plus1:before { 24 | content: "\e616"; 25 | } 26 | 27 | /*公共头部 */ 28 | 29 | .posi_fiexd { 30 | position: fixed; 31 | top: 0; 32 | left: 0; 33 | width: 100%; 34 | z-index: 100; 35 | } 36 | 37 | /*店铺图片圆角 */ 38 | 39 | .bd_radius { 40 | border-radius: 50%; 41 | } 42 | --------------------------------------------------------------------------------