├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── images └── user1.png ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── sell │ │ ├── SellApplication.java │ │ ├── Test.java │ │ ├── common │ │ ├── Const.java │ │ ├── Res.java │ │ ├── ResponseCode.java │ │ ├── cache │ │ │ ├── IBaseCache.java │ │ │ └── RedisCache.java │ │ └── utils │ │ │ ├── CheckUtil.java │ │ │ ├── DateTimeUtil.java │ │ │ ├── FTPUtil.java │ │ │ ├── FileUploadUtil.java │ │ │ ├── PropertiesUtil.java │ │ │ ├── QiniuFileUtils.java │ │ │ ├── RedisUtil.java │ │ │ └── UserUtils.java │ │ ├── config │ │ ├── CorsFilter.java │ │ ├── GlobalExceptionAdvice.java │ │ ├── MyRolesAuthorizationFilter.java │ │ ├── QiniuFileConfig.java │ │ ├── RedisConfig.java │ │ ├── ShiroConfig.java │ │ ├── SwaggerConfig.java │ │ ├── TransactionManagerConfig.java │ │ ├── WebConfig.java │ │ └── WebSocketConfig.java │ │ └── modules │ │ ├── store │ │ ├── controller │ │ │ ├── DeliveryAdminController.java │ │ │ ├── DeliveryController.java │ │ │ ├── OrderCommentController.java │ │ │ ├── OrderController.java │ │ │ ├── ProductCategoryController.java │ │ │ ├── ProductController.java │ │ │ ├── ShippingController.java │ │ │ ├── ShopAdminController.java │ │ │ ├── ShopCategoryController.java │ │ │ ├── ShopController.java │ │ │ └── UserAdminController.java │ │ ├── dao │ │ │ ├── DeliveryMapper.java │ │ │ ├── OrderCommentMapper.java │ │ │ ├── OrderItemMapper.java │ │ │ ├── OrderMapper.java │ │ │ ├── OrderStatusMapper.java │ │ │ ├── ProductCategoryMapper.java │ │ │ ├── ProductMapper.java │ │ │ ├── ShippingMapper.java │ │ │ ├── ShopCategoryMapper.java │ │ │ └── ShopMapper.java │ │ ├── dto │ │ │ ├── QueryCommentDTO.java │ │ │ ├── QueryDTO.java │ │ │ ├── QueryOrderDTO.java │ │ │ ├── QueryProductDTO.java │ │ │ └── ShopCountDTO.java │ │ ├── entity │ │ │ ├── Delivery.java │ │ │ ├── Feedback.java │ │ │ ├── Order.java │ │ │ ├── OrderComment.java │ │ │ ├── OrderItem.java │ │ │ ├── OrderStatus.java │ │ │ ├── Product.java │ │ │ ├── ProductCategory.java │ │ │ ├── Shipping.java │ │ │ ├── Shop.java │ │ │ └── ShopCategory.java │ │ ├── service │ │ │ ├── DeliveryService.java │ │ │ ├── FileService.java │ │ │ ├── OrderCommentService.java │ │ │ ├── OrderItemService.java │ │ │ ├── OrderService.java │ │ │ ├── OrderStatusService.java │ │ │ ├── ProductCategoryService.java │ │ │ ├── ProductService.java │ │ │ ├── RedisService.java │ │ │ ├── ShippingService.java │ │ │ ├── ShopCategoryService.java │ │ │ ├── ShopService.java │ │ │ └── impl │ │ │ │ ├── DeliveryServiceImpl.java │ │ │ │ ├── FileServiceImpl.java │ │ │ │ ├── OrderCommentServiceImpl.java │ │ │ │ ├── OrderItemServiceImpl.java │ │ │ │ ├── OrderServiceImpl.java │ │ │ │ ├── OrderStatusServiceImpl.java │ │ │ │ ├── ProductCategoryServiceImpl.java │ │ │ │ ├── ProductServiceImpl.java │ │ │ │ ├── RedisServiceImpl.java │ │ │ │ ├── ShippingServiceImpl.java │ │ │ │ ├── ShopCategoryServiceImpl.java │ │ │ │ └── ShopServiceImpl.java │ │ └── vo │ │ │ ├── Cart.java │ │ │ ├── DeliveryOrderVo.java │ │ │ ├── NewOrderVo.java │ │ │ ├── ProductVo.java │ │ │ ├── ShopVo.java │ │ │ └── UserOrderVo.java │ │ └── sys │ │ ├── controller │ │ ├── FileController.java │ │ ├── LocationController.java │ │ ├── LoginController.java │ │ ├── TestController.java │ │ └── UserController.java │ │ ├── dao │ │ ├── LocationMapper.java │ │ └── UserMapper.java │ │ ├── dto │ │ └── PasswordDTO.java │ │ ├── entity │ │ ├── Location.java │ │ ├── Permission.java │ │ ├── Role.java │ │ └── User.java │ │ ├── security │ │ ├── AuthRealm.java │ │ ├── CredentialMatcher.java │ │ ├── MySessionManager.java │ │ └── WebSocket.java │ │ └── service │ │ ├── LocationService.java │ │ ├── UserService.java │ │ └── impl │ │ ├── LocationServiceImpl.java │ │ └── UserServiceImpl.java └── resources │ ├── application-dev.yml │ ├── application-prod.yml │ ├── application.yml │ ├── banner.txt │ ├── generatorConfig.xml │ ├── init.sql │ ├── logback.xml │ ├── mappers │ ├── DeliveryMapper.xml │ ├── LocationMapper.xml │ ├── OrderCommentMapper.xml │ ├── OrderItemMapper.xml │ ├── OrderMapper.xml │ ├── OrderStatusMapper.xml │ ├── ProductCategoryMapper.xml │ ├── ProductMapper.xml │ ├── ShippingMapper.xml │ ├── ShopCategoryMapper.xml │ ├── ShopMapper.xml │ └── UserMapper.xml │ ├── sell.properties │ └── templates │ ├── first.html │ └── images │ ├── 22.png │ ├── 555.png │ ├── 商家端.png │ ├── 商家端2.jpg │ ├── 商家端3.png │ ├── 商家端5.png │ ├── 商家端6.png │ ├── 商家端7.png │ ├── 用户端.png │ ├── 用户端3.png │ ├── 用户端4.png │ └── 骑手端.png └── test └── java └── com └── sell └── DailyTest.java /.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 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | #FROM java:8 2 | #EXPOSE 8080 3 | # 4 | #VOLUME /tmp 5 | #ADD renren-fast.jar /app.jar 6 | #RUN bash -c 'touch /app.jar' 7 | #ENTRYPOINT ["java","-jar","/app.jar"] 8 | FROM java:8 9 | EXPOSE 8080 10 | VOLUME /slm 11 | ADD sell.jar boot-docker.jar 12 | RUN sh -c 'touch /boot-docker.jar' 13 | ENV JAVA_OPTS="" 14 | ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /boot-docker.jar" ] 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **系统一个共有三个端,分别是用户端、商家端和骑手端,麻烦各位同学们点点star!!** 2 | 3 | 项目的架构是SpringBoot和Vue的前后端分离,数据库为MySQL+Redis,MyBatis、Swagger接口文档、Shiro安全框架,3个客户端分别对应3个角色具有不同操作权限, 4 | 5 | 使用了主流的 **七牛云图片文件服务器** /本地存储两种文件上传访问方式,前后端采用Restful接口风格对接,采用Websocket通讯实时交互。 6 | 7 | :hand: 用户端和骑手端采用移动端UI框架Vant、商家端使用ElementUI 8 | 9 | 项目部署上采用Doker虚拟化技术部署在自己的阿里云上,整合合Nginx、Haproxy和keepalived,从数据库到后端、前端均采用多节点负载均衡策略部署。 10 | 11 | 整个项目用的都是目前主流的技术,覆盖前后端各个技术的基础,从数据库,到后端,再到前端,再部署上云,覆盖了前后端开发部署的全部流程及各种细节。 12 | 13 | ### 项目演示: 14 | :smile: :smile: :smile: :smile: :smile: :smile: 15 | 16 | :raised_hand:[移动用户端](http://43.139.228.129:8018/#/user)(电脑端打开请按F12进入开发模式,调成手机大小) 17 | 18 | :raised_hand:[商家PC端](http://43.139.228.129:8017/#/login) 19 | 20 | :raised_hand:[后端接口文档](http://43.139.228.129:8086/doc.html) 21 | 22 | **移动用户端主要界面:** 23 | ![输入图片说明](src/main/resources/templates/images/%E7%94%A8%E6%88%B7%E7%AB%AF.png) 24 | ### 项目说明: 25 | 本项目后端代码已全部开源,后端开发者可直接拉取下载代码,沟通联系开发者:qq 1058298031 26 | 如有疑问可沟通交流! 27 | ![输入图片说明](src/main/resources/templates/images/555.png) 28 | ![输入图片说明](src/main/resources/templates/images/%E7%94%A8%E6%88%B7%E7%AB%AF3.png) 29 | ![输入图片说明](src/main/resources/templates/images/%E7%94%A8%E6%88%B7%E7%AB%AF4.png) 30 | 31 | **移动骑手端主要界面:** 32 | ![输入图片说明](src/main/resources/templates/images/%E9%AA%91%E6%89%8B%E7%AB%AF.png) 33 | 34 | 35 | **pc商家管理端主要界面:** 36 | 37 | ![输入图片说明](src/main/resources/templates/images/%E5%95%86%E5%AE%B6%E7%AB%AF.png) 38 | ![输入图片说明](src/main/resources/templates/images/%E5%95%86%E5%AE%B6%E7%AB%AF2.jpg) 39 | ![输入图片说明](src/main/resources/templates/images/%E5%95%86%E5%AE%B6%E7%AB%AF3.png) 40 | ![输入图片说明](src/main/resources/templates/images/%E5%95%86%E5%AE%B6%E7%AB%AF7.png) 41 | ![输入图片说明](src/main/resources/templates/images/%E5%95%86%E5%AE%B6%E7%AB%AF5.png) 42 | ![输入图片说明](src/main/resources/templates/images/%E5%95%86%E5%AE%B6%E7%AB%AF6.png) 43 | -------------------------------------------------------------------------------- /images/user1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linycha/sell/62b387b488e7105c6afd90d041fac89592476f0f/images/user1.png -------------------------------------------------------------------------------- /src/main/java/com/sell/SellApplication.java: -------------------------------------------------------------------------------- 1 | package com.sell; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import springfox.documentation.oas.annotations.EnableOpenApi; 7 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 8 | 9 | /** 10 | * @author linyc 11 | * @date 2019/12/9 18:25 12 | */ 13 | @EnableOpenApi 14 | @SpringBootApplication 15 | @MapperScan(basePackages= {"com.sell.modules.store.dao", "com.sell.modules.sys.dao"}) 16 | public class SellApplication { 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(SellApplication.class, args); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/sell/Test.java: -------------------------------------------------------------------------------- 1 | package com.sell; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | import org.springframework.test.context.junit4.SpringRunner; 6 | 7 | /** 8 | * @author linyuc 9 | * @date 2019/12/12 12:52 10 | */ 11 | @RunWith(SpringRunner.class) 12 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 13 | public class Test { 14 | 15 | @org.junit.Test 16 | public void test(){ 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/sell/common/Const.java: -------------------------------------------------------------------------------- 1 | package com.sell.common; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.google.common.collect.Lists; 5 | import com.google.common.collect.Sets; 6 | 7 | import java.util.List; 8 | import java.util.Set; 9 | import java.util.regex.Matcher; 10 | import java.util.regex.Pattern; 11 | 12 | /** 13 | * 一些常量 14 | * @author linyuc 15 | * @date 2019/11/20 11:34 16 | */ 17 | public class Const { 18 | public static final String CURRENT_USER = "currentUser"; 19 | public static final String USERNAME = "username"; 20 | public static final String EMAIL = "email"; 21 | public static final String PHONE = "phone"; 22 | public static final String NOT_DELETE = "0"; 23 | public static final String DELETED = "1"; 24 | public static final String FTP_PATH_USER = "user"; 25 | public static final String FTP_PATH_SHOP = "shop"; 26 | public static final String FTP_PATH_PRODUCT = "product"; 27 | public static final String FTP_PATH_COMMENT = "comment"; 28 | public static final String FTP_PATH_TEST = "test"; 29 | public static final String FTP_PATH_DAILY = "daily"; 30 | public static final Integer PAGE_DEFAULT_NUM = 1; 31 | public static final Integer PAGE_DEFAULT_SIZE = 10; 32 | public static final Integer PAGE_DEFAULT_SIZE2 = 5; 33 | public static final Integer PAGE_DEFAULT_SIZE_TEN = 10; 34 | public static final Integer PAGE_DEFAULT_SIZE_FIVE = 5; 35 | public static final Integer CATEGORY_PARENT_ID = 0; 36 | public static final String UPLOADING_IMG_URL = ""; 37 | //评价等级 0:好评,1:一般,2:差评 38 | public static final Integer COMMENT_GOOD = 0; 39 | public static final Integer COMMENT_GENERAL = 1; 40 | public static final Integer COMMENT_BAD = 2; 41 | 42 | public static final String UPLOAD_CHECK = "980424"; 43 | 44 | public interface ShopList{ 45 | List ORDER_BY = Lists.newArrayList("monthly_sales desc","monthly_sales desc","score desc","delivery_time"); 46 | } 47 | 48 | /** 49 | * 订单状态:0:已提交,1:已支付 , 2:商家已接单 , 3: 骑手已接单, 4: 骑手已到店, 50 | * 5骑手已取货,6:订单已送达,70已退款(用户发起),71已退款(商家发起),8已评价 51 | */ 52 | 53 | public interface OrderStatus{ 54 | String PAID = "1"; 55 | String SHOP_ACCEPT = "2"; 56 | String DELIVERY_ACCEPT = "3"; 57 | String DELIVERY_ARRIVE = "4"; 58 | String DELIVERY_TAKE = "5"; 59 | String ACCOMPLISH = "6"; 60 | String REFUND_USER = "70"; 61 | String REFUND_SHOP = "71"; 62 | String HAVE_EVALUATION = "8"; 63 | 64 | } 65 | /** 66 | * 用户账号状态:0:禁用,1:正常 67 | */ 68 | public static final String USER_STATUS_ENABLE = "1"; 69 | public static final String USER_STATUS_DISABLE = "0"; 70 | 71 | /** 72 | * 角色信息 73 | * @return 74 | */ 75 | public static final String USER_ROLE_ADMIN = "admin"; 76 | public static final String USER_ROLE_CUSTOMER = "customer"; 77 | public static final String USER_ROLE_BUSINESS = "business"; 78 | public static final String USER_ROLE_DELIVERY = "delivery"; 79 | 80 | public static long generateOrderNo(){ 81 | long currentTime = System.currentTimeMillis(); 82 | return currentTime + currentTime%10; 83 | } 84 | 85 | /** 86 | * 初始化分页大小 87 | */ 88 | public static void initPage(int pageNum,int pageSize){ 89 | if(pageNum == 0 || pageSize == 0){ 90 | pageNum = Const.PAGE_DEFAULT_NUM; 91 | pageSize = Const.PAGE_DEFAULT_SIZE; 92 | } 93 | PageHelper.startPage(pageNum,pageSize); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/sell/common/Res.java: -------------------------------------------------------------------------------- 1 | package com.sell.common; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 高复用服务响应对象 10 | * JsonSerialize保证序列化Json的时候,如果是null的对象,可以也会消失, 11 | * code:状态码,msg信息,data数据 12 | * @author linyuc 13 | * @date 2019/12/18 10:11 14 | */ 15 | @JsonSerialize 16 | public class Res implements Serializable { 17 | private int code; 18 | private String msg; 19 | private T data; 20 | 21 | private Res(int code){ 22 | this.code =code; 23 | } 24 | private Res(int code, T data){ 25 | this.code = code; 26 | this.data = data; 27 | } 28 | private Res(int code,String msg){ 29 | this.code =code; 30 | this.msg = msg; 31 | } 32 | private Res(int code, String msg, T data){ 33 | this.code = code; 34 | this.msg = msg; 35 | this.data = data; 36 | } 37 | //使之不在json序列化结果当中 38 | @JsonIgnore 39 | public boolean isSuccess(){ 40 | return this.code == ResponseCode.SUCCESS.getCode(); 41 | } 42 | 43 | public int getCode() { 44 | return code; 45 | } 46 | public String getMsg() { 47 | return msg; 48 | } 49 | public T getData() { 50 | return data; 51 | } 52 | public static Res success(){ 53 | return new Res(ResponseCode.SUCCESS.getCode()); 54 | } 55 | public static Res successMsg(String msg){ 56 | return new Res(ResponseCode.SUCCESS.getCode(),msg); 57 | } 58 | public static Res success(T data){ 59 | return new Res(ResponseCode.SUCCESS.getCode(),data); 60 | } 61 | public static Res success(String msg,T data){ 62 | return new Res(ResponseCode.SUCCESS.getCode(),msg,data); 63 | } 64 | public static Res error(){ 65 | return new Res(ResponseCode.ERROR.getCode(),ResponseCode.ERROR.getDesc()); 66 | } 67 | public static Res errorMsg(String msg){ 68 | return new Res(ResponseCode.ERROR.getCode(),msg); 69 | } 70 | 71 | public static Res errorCodeMsg(int code,String msg){ 72 | return new Res(code,msg); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/sell/common/ResponseCode.java: -------------------------------------------------------------------------------- 1 | package com.sell.common; 2 | /** 3 | * 枚举类 4 | * @author linyuc 5 | * @date 2019/12/18 10:11 6 | */ 7 | public enum ResponseCode { 8 | /** 9 | * success 10 | * @Params 11 | */ 12 | SUCCESS(200,"SUCCESS"), 13 | ERROR(400,"ERROR"), 14 | NEED_LOGIN(10,"NEED_LOGIN"), 15 | Unauthorized(401,"Unauthorized"), 16 | Forbidden(403,"Forbidden"), 17 | BUSINESS_ERROR(500,"BUSINESS_ERROR"); 18 | 19 | private final int code; 20 | private final String desc; 21 | 22 | ResponseCode(int code, String desc){ 23 | this.code = code; 24 | this.desc = desc; 25 | } 26 | public int getCode(){ 27 | return code; 28 | } 29 | public String getDesc(){ 30 | return desc; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/sell/common/cache/IBaseCache.java: -------------------------------------------------------------------------------- 1 | package com.sell.common.cache; 2 | 3 | import com.sell.modules.store.entity.ShopCategory; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author linyuc 9 | * @date 2020/4/8 20:36 10 | */ 11 | public interface IBaseCache { 12 | List getShopTopCategoryList(Integer categoryId); 13 | List getShopSiblingCategoryList(Integer categoryId); 14 | void del(); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/sell/common/cache/RedisCache.java: -------------------------------------------------------------------------------- 1 | package com.sell.common.cache; 2 | 3 | import com.sell.common.utils.RedisUtil; 4 | import com.sell.modules.store.entity.ShopCategory; 5 | import com.sell.modules.store.service.ShopCategoryService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author linyuc 13 | * @date 2020/4/8 20:36 14 | */ 15 | @Component 16 | public class RedisCache implements IBaseCache { 17 | @Autowired 18 | private RedisUtil redisUtil; 19 | @Autowired 20 | private RedisUtil.redisList redisList; 21 | @Autowired 22 | private ShopCategoryService shopCategoryService; 23 | @Override 24 | public List getShopTopCategoryList(Integer categoryId) { 25 | if (redisUtil.hasKey("shopTopCategoryList")) { 26 | return redisList.get("shopTopCategoryList", 0, -1); 27 | }else{ 28 | List list2 = shopCategoryService.getSiblingCategory(categoryId); 29 | redisList.set("shopTopCategoryList", list2,1800); 30 | return list2; 31 | } 32 | } 33 | @Override 34 | public void del(){ 35 | redisUtil.del("shopTopCategoryList"); 36 | } 37 | @Override 38 | public List getShopSiblingCategoryList(Integer categoryId) { 39 | //List list = new ArrayList<>(); 40 | if (redisUtil.hasKey("shopSiblingCategoryList")) { 41 | List list = redisList.get("shopSiblingCategoryList", 0, 0); 42 | return list; 43 | }else{ 44 | List list2 = shopCategoryService.getSiblingCategory(categoryId); 45 | redisList.set("shopSiblingCategoryList", list2,5); 46 | return list2; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/sell/common/utils/CheckUtil.java: -------------------------------------------------------------------------------- 1 | package com.sell.common.utils; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | import java.util.regex.Matcher; 6 | import java.util.regex.Pattern; 7 | 8 | /** 9 | * 校验工具类 10 | * @author linyuc 11 | * @date 2020/4/20 13:04 12 | */ 13 | public class CheckUtil { 14 | 15 | /** 16 | * 校验是否是数字 17 | * @param num 18 | * @return 19 | */ 20 | public static boolean isNumber(String num){ 21 | String regex = "^\\d{5}[0-9]$"; 22 | Pattern pattern = Pattern.compile(regex); 23 | Matcher matcher=pattern.matcher(num); 24 | return matcher.matches(); 25 | } 26 | 27 | /** 28 | * 校验是否是手机号 29 | * @param mobile 30 | * @return 31 | */ 32 | public static boolean isMobile(String mobile) { 33 | if(StringUtils.isBlank(mobile)){ 34 | return false; 35 | } 36 | String regex = "1[536789]\\d{9}|15[1267089]\\d{8}"; 37 | //编译正则表达式 38 | Pattern pattern= Pattern.compile(regex); 39 | Matcher matcher=pattern.matcher(mobile); 40 | return matcher.matches(); 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/sell/common/utils/DateTimeUtil.java: -------------------------------------------------------------------------------- 1 | package com.sell.common.utils; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.joda.time.DateTime; 5 | import org.joda.time.format.DateTimeFormat; 6 | import org.joda.time.format.DateTimeFormatter; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * Created by geely 12 | */ 13 | public class DateTimeUtil { 14 | 15 | //joda-time 16 | 17 | //str->Date 18 | //Date->str 19 | public static final String STANDARD_FORMAT = "yyyy-MM-dd HH:mm:ss"; 20 | public static final String STANDARD_FORMAT_TIME = "HH:mm"; 21 | 22 | 23 | 24 | public static Date strToDate(String dateTimeStr,String formatStr){ 25 | DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(formatStr); 26 | DateTime dateTime = dateTimeFormatter.parseDateTime(dateTimeStr); 27 | return dateTime.toDate(); 28 | } 29 | 30 | public static String dateToStr(Date date,String formatStr){ 31 | if(date == null){ 32 | return StringUtils.EMPTY; 33 | } 34 | DateTime dateTime = new DateTime(date); 35 | return dateTime.toString(formatStr); 36 | } 37 | 38 | public static Date strToDate(String dateTimeStr){ 39 | DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(STANDARD_FORMAT); 40 | DateTime dateTime = dateTimeFormatter.parseDateTime(dateTimeStr); 41 | return dateTime.toDate(); 42 | } 43 | 44 | public static String dateToStr(Date date){ 45 | if(date == null){ 46 | return StringUtils.EMPTY; 47 | } 48 | DateTime dateTime = new DateTime(date); 49 | return dateTime.toString(STANDARD_FORMAT); 50 | } 51 | public static String dateToTimeStr(Date date){ 52 | if(date == null){ 53 | return StringUtils.EMPTY; 54 | } 55 | DateTime dateTime = new DateTime(date); 56 | return dateTime.toString(STANDARD_FORMAT_TIME); 57 | } 58 | 59 | 60 | 61 | public static void main(String[] args) { 62 | System.out.println(DateTimeUtil.dateToStr(new Date(),STANDARD_FORMAT)); 63 | System.out.println(DateTimeUtil.strToDate("2010-01-01 11:11:11","yyyy-MM-dd HH:mm:ss")); 64 | 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/sell/common/utils/FileUploadUtil.java: -------------------------------------------------------------------------------- 1 | package com.sell.common.utils; 2 | 3 | import cn.hutool.core.util.StrUtil; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.stereotype.Component; 7 | import org.springframework.web.multipart.MultipartFile; 8 | 9 | import javax.annotation.Resource; 10 | import java.io.File; 11 | import java.io.IOException; 12 | import java.util.UUID; 13 | 14 | /** 15 | * 统一文件上传工具类 16 | * @author linyuc 17 | * @Description TODO 18 | * @date 2022/3/9 17:06 19 | */ 20 | @Component 21 | @Slf4j 22 | public class FileUploadUtil { 23 | 24 | @Resource 25 | private QiniuFileUtils qiniuFileUtils; 26 | 27 | @Value("${uploadFileModel}") 28 | public String model; 29 | 30 | /** 31 | * 本地文件上传路径 32 | */ 33 | @Value("${myFile.path}") 34 | public String path; 35 | @Value("${myFile.url}") 36 | public String url; 37 | 38 | /** 39 | * 统一上传文件入口 40 | * @param file 41 | * @return 42 | * @throws IOException 43 | */ 44 | public String uploadFile(MultipartFile file) throws IOException { 45 | if(StrUtil.equals(model,"local")) { 46 | return uploadFileLocal(file); 47 | } else if(StrUtil.equals(model,"cloud")){ 48 | return qiniuFileUtils.uploadFile(file.getInputStream()); 49 | } 50 | return ""; 51 | } 52 | 53 | 54 | /** 55 | * 上传文件到指定本地磁盘 56 | * @param file 57 | * @return 58 | * @throws IOException 59 | */ 60 | public String uploadFileLocal(MultipartFile file) throws IOException { 61 | String fileName = file.getOriginalFilename(); 62 | //获取文件名后缀 63 | assert fileName != null; 64 | String fileExtensionName = fileName.substring(fileName.lastIndexOf(".")+1); 65 | String uploadFileName = UUID.randomUUID()+"."+fileExtensionName; 66 | File fileDir = new File(path); 67 | if(!fileDir.exists()){ 68 | //给权限 69 | fileDir.setWritable(true); 70 | fileDir.mkdirs(); 71 | } 72 | File targetFile = new File(path,uploadFileName); 73 | //保存 74 | file.transferTo(targetFile); 75 | return url+uploadFileName; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/sell/common/utils/PropertiesUtil.java: -------------------------------------------------------------------------------- 1 | package com.sell.common.utils; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.io.IOException; 8 | import java.io.InputStreamReader; 9 | import java.util.Properties; 10 | 11 | /** 12 | * 配置读取工具类 13 | * @author by 14 | */ 15 | public class PropertiesUtil { 16 | 17 | private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class); 18 | 19 | private static Properties props; 20 | 21 | static { 22 | String fileName = "sell.properties"; 23 | props = new Properties(); 24 | try { 25 | props.load(new InputStreamReader(PropertiesUtil.class.getClassLoader().getResourceAsStream(fileName),"UTF-8")); 26 | } catch (IOException e) { 27 | logger.error("配置文件读取异常",e); 28 | } 29 | } 30 | 31 | public static String getProperty(String key){ 32 | String value = props.getProperty(key.trim()); 33 | if(StringUtils.isBlank(value)){ 34 | return null; 35 | } 36 | return value.trim(); 37 | } 38 | 39 | public static String getProperty(String key,String defaultValue){ 40 | 41 | String value = props.getProperty(key.trim()); 42 | if(StringUtils.isBlank(value)){ 43 | value = defaultValue; 44 | } 45 | return value.trim(); 46 | } 47 | 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/sell/common/utils/QiniuFileUtils.java: -------------------------------------------------------------------------------- 1 | package com.sell.common.utils; 2 | 3 | import cn.hutool.core.util.IdUtil; 4 | import com.alibaba.fastjson.JSON; 5 | import com.qiniu.common.QiniuException; 6 | import com.qiniu.http.Response; 7 | import com.qiniu.storage.BucketManager; 8 | import com.qiniu.storage.UploadManager; 9 | import com.qiniu.storage.model.DefaultPutRet; 10 | import com.qiniu.util.Auth; 11 | import com.qiniu.util.StringMap; 12 | import lombok.extern.slf4j.Slf4j; 13 | import org.springframework.beans.factory.InitializingBean; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.beans.factory.annotation.Value; 16 | import org.springframework.stereotype.Component; 17 | 18 | import java.io.File; 19 | import java.io.InputStream; 20 | 21 | /** 22 | * 七牛云文件上传工具 23 | */ 24 | @Slf4j 25 | @Component 26 | public class QiniuFileUtils implements InitializingBean { 27 | 28 | @Value("${qiniu.bucket}") 29 | private String bucket; 30 | @Value("${qiniu.prefix}") 31 | private String prefix; 32 | @Value("${qiniu.visitUrl}") 33 | private String visitUrl; 34 | 35 | @Autowired 36 | private UploadManager uploadManager; 37 | @Autowired 38 | private BucketManager bucketManager; 39 | @Autowired 40 | private Auth auth; 41 | // 定义七牛云上传的相关策略 42 | private StringMap putPolicy; 43 | 44 | private static String directory = "sell/"; 45 | 46 | /** * 以文件的形式上传 * * @param file * @return * @throws QiniuException */ 47 | public String uploadFile(File file) throws QiniuException { 48 | Response response = this.uploadManager.put(file, null, getUploadToken()); 49 | int retry = 0; 50 | while (response.needRetry() && retry < 3) { 51 | response = this.uploadManager.put(file, null, getUploadToken()); 52 | retry++; 53 | } 54 | //解析结果 55 | DefaultPutRet putRet = JSON.parseObject(response.bodyString(), DefaultPutRet.class); 56 | String return_path = prefix + "/" + putRet.key; 57 | log.info("文件名称={}", return_path); 58 | return return_path; 59 | } 60 | 61 | /** * 以流的形式上传 * * @param inputStream * @return * @throws QiniuException */ 62 | public String uploadFile(InputStream inputStream) throws QiniuException { 63 | Response response = this.uploadManager.put(inputStream, null, getUploadToken(), null, null); 64 | int retry = 0; 65 | while (response.needRetry() && retry < 3) { 66 | response = this.uploadManager.put(inputStream, null, getUploadToken(), null, null); 67 | retry++; 68 | } 69 | //解析结果 70 | DefaultPutRet putRet = JSON.parseObject(response.bodyString(), DefaultPutRet.class); 71 | String returnPath = visitUrl + "/" + putRet.key; 72 | log.info("文件名称={}", returnPath); 73 | return returnPath; 74 | } 75 | 76 | /** * 删除七牛云上的相关文件 * * @param key * @return * @throws QiniuException */ 77 | public Response delete(String key) throws QiniuException { 78 | Response response = bucketManager.delete(bucket, key); 79 | int retry = 0; 80 | while (response.needRetry() && retry++ < 3) { 81 | response = bucketManager.delete(bucket, key); 82 | } 83 | return response; 84 | } 85 | 86 | @Override 87 | public void afterPropertiesSet() { 88 | this.putPolicy = new StringMap(); 89 | putPolicy.put("returnBody", "{\"key\":\"$(key)\",\"hash\":\"$(etag)\",\"bucket\":\"$(bucket)\",\"width\":$(imageInfo.width), \"height\":${imageInfo.height}}"); 90 | // 自定义文件名字 91 | putPolicy.put("saveKey", directory + IdUtil.nanoId()); 92 | } 93 | 94 | /** * 获取上传凭证 * * @return */ 95 | private String getUploadToken() { 96 | return this.auth.uploadToken(bucket, null, 3600, putPolicy); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/sell/common/utils/UserUtils.java: -------------------------------------------------------------------------------- 1 | package com.sell.common.utils; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.sell.modules.sys.entity.User; 5 | import org.apache.shiro.SecurityUtils; 6 | import org.apache.shiro.crypto.hash.SimpleHash; 7 | import org.springframework.beans.BeanUtils; 8 | 9 | /** 10 | * 获取当前登录用户信息工具类 11 | * @author linyuc 12 | * @date 2020/1/15 20:25 13 | */ 14 | public class UserUtils { 15 | /** 16 | * 获取当前登录用户信息 17 | * @return user 18 | */ 19 | public static User getUser() { 20 | Object o = SecurityUtils.getSubject().getPrincipal(); 21 | //解析user的json字符串 22 | return JSON.parseObject(o.toString(),User.class); 23 | } 24 | 25 | /** 26 | * 获取当前登录用户Id 27 | * @return userId 28 | */ 29 | public static Integer getUserId() { 30 | return getUser().getId(); 31 | } 32 | 33 | /** 34 | * 获取当前登录用户的商家Id 35 | * @return shopId 36 | */ 37 | public static Integer getShopId() { 38 | return getUser().getShopId(); 39 | } 40 | /** 41 | * 获取当前登录用户的骑手Id 42 | * @return shopId 43 | */ 44 | public static Integer getDeliveryId() { 45 | return getUser().getDeliveryId(); 46 | } 47 | 48 | /** 49 | * 获取当前登录用户首个角色,如 “admin” 50 | */ 51 | public static String getRole(){ 52 | return getUser().getRoles()[0]; 53 | } 54 | 55 | /** 56 | * 利用shiro的api加密密码 57 | * @param password 58 | * @return 59 | */ 60 | public static String hashTwo(String password){ 61 | Object md5Password = new SimpleHash("md5",password, null, 2); 62 | return md5Password.toString(); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/sell/config/CorsFilter.java: -------------------------------------------------------------------------------- 1 | package com.sell.config; 2 | 3 | /** 4 | * 跨域过滤器 5 | * @author linyuc 6 | * @date 2020/3/27 21:46 7 | */ 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.http.HttpStatus; 10 | 11 | import javax.servlet.*; 12 | import javax.servlet.annotation.WebFilter; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import java.io.IOException; 16 | 17 | @WebFilter(filterName = "CorsFilter ") 18 | @Configuration 19 | public class CorsFilter implements Filter { 20 | @Override 21 | public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { 22 | /*HttpServletResponse response = (HttpServletResponse) res; 23 | response.setHeader("Access-Control-Allow-Origin","*"); 24 | response.setHeader("Access-Control-Allow-Credentials", "true"); 25 | response.setHeader("Access-Control-Allow-Methods", "*"); 26 | response.setHeader("Access-Control-Max-Age", "3600"); 27 | response.setHeader("Access-Control-Allow-Headers", "*"); 28 | chain.doFilter(req, res);*/ 29 | HttpServletRequest request = (HttpServletRequest) req; 30 | HttpServletResponse response = (HttpServletResponse) res; 31 | String method = request.getMethod(); 32 | // this origin value could just as easily have come from a database 33 | response.setHeader("Access-Control-Allow-Origin", "*"); 34 | response.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, DELETE, OPTIONS"); 35 | response.setHeader("Access-Control-Max-Age", "3600"); 36 | response.setHeader("Access-Control-Allow-Credentials", "true"); 37 | response.setHeader("Access-Control-Allow-Headers", "Accept, Origin, X-Requested-With, Content-Type,Last-Modified,device,token"); 38 | if ("OPTIONS".equals(method)) {//检测是options方法则直接返回200 39 | response.setStatus(HttpStatus.OK.value()); 40 | } else { 41 | chain.doFilter(req, res); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/sell/config/GlobalExceptionAdvice.java: -------------------------------------------------------------------------------- 1 | package com.sell.config; 2 | 3 | import com.sell.common.Res; 4 | import com.sell.common.ResponseCode; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.web.bind.annotation.ExceptionHandler; 7 | import org.springframework.web.bind.annotation.RestControllerAdvice; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | 11 | /** 12 | * 统一异常处理 13 | */ 14 | @Slf4j 15 | @RestControllerAdvice 16 | public class GlobalExceptionAdvice { 17 | 18 | @ExceptionHandler(value = Exception.class) 19 | public Res handleHttpException(HttpServletRequest request, Exception e){ 20 | log.info("发生系统异常:"+e.getMessage()); 21 | return Res.errorCodeMsg(ResponseCode.BUSINESS_ERROR.getCode(),"发生系统业务异常,异常信息:"+e.getMessage()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/sell/config/MyRolesAuthorizationFilter.java: -------------------------------------------------------------------------------- 1 | package com.sell.config; 2 | 3 | import org.apache.shiro.subject.Subject; 4 | import org.apache.shiro.util.CollectionUtils; 5 | import org.apache.shiro.web.filter.authz.AuthorizationFilter; 6 | 7 | import javax.servlet.ServletRequest; 8 | import javax.servlet.ServletResponse; 9 | import java.util.Set; 10 | 11 | /** 12 | * 自定义角色过滤器,满足其中一个角色即可通过 13 | * @author linyuc 14 | * @date 2020/1/2 13:41 15 | */ 16 | public class MyRolesAuthorizationFilter extends AuthorizationFilter { 17 | 18 | @Override 19 | protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object o) throws Exception { 20 | Subject subject = this.getSubject(request, response); 21 | //获取当前访问路径所需要的角色集合 22 | String[] rolesArray = (String[]) o; 23 | //没有角色限制,可以直接访问 24 | if (rolesArray != null && rolesArray.length != 0) { 25 | return true; 26 | } 27 | Set roles = CollectionUtils.asSet(rolesArray); 28 | for(String role:roles){ 29 | if(subject.hasRole(role)){ 30 | return true; 31 | } 32 | } 33 | return false; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/sell/config/QiniuFileConfig.java: -------------------------------------------------------------------------------- 1 | package com.sell.config; 2 | import com.google.gson.Gson; 3 | import com.qiniu.storage.BucketManager; 4 | import com.qiniu.storage.Region; 5 | import com.qiniu.storage.UploadManager; 6 | import com.qiniu.util.Auth; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | @Configuration 12 | public class QiniuFileConfig { 13 | 14 | @Value("${qiniu.accessKey}") 15 | private String accessKey; 16 | @Value("${qiniu.secretKey}") 17 | private String secretKey; 18 | 19 | /** * 华东机房,配置自己空间所在的区域 */ 20 | @Bean 21 | public com.qiniu.storage.Configuration qiniuConfig() { 22 | return new com.qiniu.storage.Configuration(Region.huadong()); 23 | } 24 | /** * 构建一个七牛上传工具实例 */ 25 | @Bean 26 | public UploadManager uploadManager() { 27 | return new UploadManager(qiniuConfig()); 28 | } 29 | /** * 认证信息实例 * @return */ 30 | @Bean 31 | public Auth auth() { 32 | return Auth.create(accessKey, secretKey); 33 | } 34 | /** * 构建七牛空间管理实例 */ 35 | @Bean 36 | public BucketManager bucketManager() { 37 | return new BucketManager(auth(), qiniuConfig()); 38 | } 39 | @Bean 40 | public Gson gson() { 41 | return new Gson(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/sell/config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.sell.config; 2 | 3 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 4 | import com.fasterxml.jackson.annotation.PropertyAccessor; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.data.redis.connection.RedisConnectionFactory; 10 | import org.springframework.data.redis.core.*; 11 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; 12 | import org.springframework.data.redis.serializer.StringRedisSerializer; 13 | 14 | /** 15 | * @author linyuc 16 | * @date 2020/4/8 19:43 17 | */ 18 | @Configuration 19 | public class RedisConfig { 20 | @Autowired 21 | private RedisConnectionFactory factory; 22 | @Bean 23 | @SuppressWarnings("all") 24 | public RedisTemplate redisTemplate(RedisConnectionFactory factory) { 25 | 26 | RedisTemplate template = new RedisTemplate(); 27 | template.setConnectionFactory(factory); 28 | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); 29 | ObjectMapper om = new ObjectMapper(); 30 | om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); 31 | om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); 32 | jackson2JsonRedisSerializer.setObjectMapper(om); 33 | StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); 34 | //key采用String的序列化方式 35 | template.setKeySerializer(stringRedisSerializer); 36 | //hash的key也采用String的序列化方式 37 | template.setHashKeySerializer(stringRedisSerializer); 38 | //value序列化方式采用jackson 39 | template.setValueSerializer(jackson2JsonRedisSerializer); 40 | //hash的value序列化方式采用jackson 41 | template.setHashValueSerializer(jackson2JsonRedisSerializer); 42 | template.afterPropertiesSet(); 43 | return template; 44 | } 45 | // @Bean 46 | // public HashOperations hashOperations(RedisTemplate redisTemplate) { 47 | // return redisTemplate.opsForHash(); 48 | // } 49 | // 50 | // @Bean 51 | // public ValueOperations valueOperations(RedisTemplate redisTemplate) { 52 | // return redisTemplate.opsForValue(); 53 | // } 54 | // 55 | // @Bean 56 | // public ListOperations listOperations(RedisTemplate redisTemplate) { 57 | // return redisTemplate.opsForList(); 58 | // } 59 | // 60 | // @Bean 61 | // public SetOperations setOperations(RedisTemplate redisTemplate) { 62 | // return redisTemplate.opsForSet(); 63 | // } 64 | // 65 | // @Bean 66 | // public ZSetOperations zSetOperations(RedisTemplate redisTemplate) { 67 | // return redisTemplate.opsForZSet(); 68 | // } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/sell/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.sell.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.oas.annotations.EnableOpenApi; 9 | import springfox.documentation.service.ApiInfo; 10 | import springfox.documentation.service.Contact; 11 | import springfox.documentation.spi.DocumentationType; 12 | import springfox.documentation.spring.web.plugins.Docket; 13 | 14 | @Configuration 15 | @EnableOpenApi 16 | public class SwaggerConfig { 17 | 18 | Boolean swaggerEnabled=true; 19 | @Bean 20 | public Docket createRestApi() { 21 | return new Docket(DocumentationType.OAS_30).apiInfo(apiInfo()) 22 | // 是否开启 23 | .enable(swaggerEnabled).select() 24 | // 扫描的路径包 25 | .apis(RequestHandlerSelectors.basePackage("com.sell.modules")) 26 | // 指定路径处理PathSelectors.any()代表所有的路径 27 | .paths(PathSelectors.any()).build().pathMapping("/"); 28 | } 29 | 30 | private ApiInfo apiInfo() { 31 | return new ApiInfoBuilder() 32 | .title("Lin sell 接口文档") 33 | .description("前后端分离的网上外卖订餐系统") 34 | // 作者信息 35 | .contact(new Contact("linyuc", "个人主页url", "email")) 36 | .version("v1.0") 37 | .build(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sell/config/TransactionManagerConfig.java: -------------------------------------------------------------------------------- 1 | package com.sell.config; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.aspectj.lang.annotation.Aspect; 5 | import org.springframework.aop.Advisor; 6 | import org.springframework.aop.aspectj.AspectJExpressionPointcut; 7 | import org.springframework.aop.support.DefaultPointcutAdvisor; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | import org.springframework.stereotype.Component; 12 | import org.springframework.transaction.PlatformTransactionManager; 13 | import org.springframework.transaction.TransactionDefinition; 14 | import org.springframework.transaction.interceptor.*; 15 | 16 | import java.util.Collections; 17 | import java.util.HashMap; 18 | import java.util.Map; 19 | 20 | /** 21 | * 全局事务配置 22 | * @author linyuc 23 | * @date 2021/11/8 22:47 24 | */ 25 | @Slf4j 26 | @Aspect 27 | @Configuration 28 | public class TransactionManagerConfig { 29 | private static final int AOP_TIME_OUT = 50000; 30 | private static final String AOP_POINTCUT_EXPRESSION = "execution(* com.sell..*ServiceImpl.*(..)))"; 31 | 32 | @Autowired 33 | private PlatformTransactionManager transactionManager; 34 | 35 | @Bean 36 | public TransactionInterceptor txAdvice(){ 37 | NameMatchTransactionAttributeSource source = new NameMatchTransactionAttributeSource(); 38 | 39 | /** 只读事务,不做更新操作 */ 40 | RuleBasedTransactionAttribute readOnlyTx = new RuleBasedTransactionAttribute(); 41 | readOnlyTx.setReadOnly(true); 42 | readOnlyTx.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); 43 | 44 | /** 当前存在事务就使用当前事务,当前不存在事务就创建一个新的事务 */ 45 | RuleBasedTransactionAttribute requiredTx = new RuleBasedTransactionAttribute(); 46 | 47 | /** 什么异常需要回滚 */ 48 | requiredTx.setRollbackRules(Collections.singletonList(new RollbackRuleAttribute(Exception.class))); 49 | requiredTx.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); 50 | requiredTx.setTimeout(AOP_TIME_OUT); 51 | 52 | Map methodMap = new HashMap<>(); 53 | 54 | /** 可以提及事务或回滚事务的方法 */ 55 | methodMap.put("add*", requiredTx); 56 | methodMap.put("save*", requiredTx); 57 | methodMap.put("update*", requiredTx); 58 | methodMap.put("modify*", requiredTx); 59 | methodMap.put("edit*", requiredTx); 60 | methodMap.put("insert*", requiredTx); 61 | methodMap.put("delete*", requiredTx); 62 | methodMap.put("remove*", requiredTx); 63 | methodMap.put("repair*", requiredTx); 64 | methodMap.put("binding*", requiredTx); 65 | 66 | /** 其他方法无事务,只读 */ 67 | methodMap.put("*", readOnlyTx); 68 | source.setNameMap(methodMap); 69 | 70 | return new TransactionInterceptor(transactionManager, source); 71 | } 72 | 73 | @Bean(name = "txAdviceAdvisor") 74 | public Advisor txAdviceAdvisor() { 75 | log.info("===============================创建自定义txAdviceAdvisor==================================="); 76 | AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut(); 77 | pointcut.setExpression(AOP_POINTCUT_EXPRESSION); 78 | return new DefaultPointcutAdvisor(pointcut, txAdvice()); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/sell/config/WebConfig.java: -------------------------------------------------------------------------------- 1 | package com.sell.config; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.*; 6 | 7 | /** 8 | * 允许swagger路径访问 9 | * @author linyuc 10 | * @date 2020/1/9 17:49 11 | */ 12 | 13 | @Configuration 14 | public class WebConfig implements WebMvcConfigurer { 15 | /** 16 | * 文件上传路径 17 | */ 18 | @Value("${myFile.path}") 19 | public String path; 20 | 21 | @Override 22 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 23 | registry. 24 | addResourceHandler("/swagger-ui/**") 25 | .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/") 26 | .resourceChain(false); 27 | // 文件路径映射 28 | registry.addResourceHandler("/file/**").addResourceLocations("file:"+path); 29 | } 30 | 31 | @Override 32 | public void addViewControllers(ViewControllerRegistry registry) { 33 | registry.addViewController("/swagger-ui/") 34 | .setViewName("forward:/swagger-ui/index.html"); 35 | } 36 | // protected final static Logger logger = LoggerFactory.getLogger(WebConfig.class); 37 | // 38 | // @Override 39 | // public void addCorsMappings(CorsRegistry registry) { 40 | // registry.addMapping("/**") 41 | // .allowedOrigins("*") 42 | // .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") 43 | // .allowCredentials(true) 44 | // .allowedMethods("*") 45 | // .allowedHeaders("*") 46 | // .maxAge(36000).allowedHeaders("*"); 47 | // logger.info("*********************************跨域过滤器**************************"); 48 | // } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /src/main/java/com/sell/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package com.sell.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.socket.server.standard.ServerEndpointExporter; 6 | 7 | 8 | /** 9 | * @author linyuc 10 | * @date 2020/3/10 16:31 11 | */ 12 | @Configuration 13 | public class WebSocketConfig { 14 | @Bean 15 | public ServerEndpointExporter serverEndpointExporter() { 16 | return new ServerEndpointExporter(); 17 | } 18 | // /** 19 | // * 注册端点,发布或订阅消息的时候需要连接此端点 20 | // * setAllowedOrigins非必须,*表示允许其他域进行连接 21 | // * withSockJs 表示开启sockejs支持 22 | // */ 23 | // @Override 24 | // public void registerStompEndpoints(StompEndpointRegistry registry) { 25 | // registry.addEndpoint("/websocket").setAllowedOrigins("*").withSockJS(); 26 | // } 27 | // 28 | // /** 29 | // * 配置消息代理(中介) 30 | // * enableSimpleBroker 服务端推送给客户端的路径前缀 31 | // * setApplicationDestinationPrefixes 客户端发送数据给服务端的一个前缀 32 | // */ 33 | // @Override 34 | // public void configureMessageBroker(MessageBrokerRegistry registry) { 35 | // registry.enableSimpleBroker("/topic","/chat"); 36 | // registry.setApplicationDestinationPrefixes("/app"); 37 | // } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/controller/DeliveryAdminController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.controller; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Res; 5 | import com.sell.modules.store.dto.QueryDTO; 6 | import com.sell.modules.store.entity.Delivery; 7 | import com.sell.modules.store.service.DeliveryService; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.apache.commons.lang3.StringUtils; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | /** 14 | * 管理员端,骑手管理相关接口 15 | * @author linyuc 16 | * @Description TODO 17 | * @date 2022/2/28 23:02 18 | */ 19 | @RestController 20 | @RequestMapping("deliveryAdmin") 21 | public class DeliveryAdminController { 22 | 23 | @Autowired 24 | private DeliveryService deliveryService; 25 | 26 | @GetMapping("list") 27 | @ApiOperation("查找骑手列表") 28 | public Res> getUserList(QueryDTO dto){ 29 | return Res.success(deliveryService.getDeliveryList(dto)); 30 | } 31 | 32 | @PostMapping("saveOrUpdate") 33 | @ApiOperation("修改骑手信息") 34 | public Res saveOrUpdate(@RequestBody Delivery delivery){ 35 | if(delivery.getId() == null){ 36 | return deliveryService.save(delivery); 37 | } 38 | int result = deliveryService.update(delivery); 39 | if(result < 1){ 40 | return Res.errorMsg("修改用户失败"); 41 | } 42 | return Res.successMsg("修改用户成功"); 43 | } 44 | 45 | @DeleteMapping("delete") 46 | @ApiOperation("批量删除骑手") 47 | public Res deleteUser(String ids){ 48 | if(StringUtils.isBlank(ids)){ 49 | return Res.errorMsg("传递的id参数不能为空"); 50 | } 51 | int result = deliveryService.deleteBatch(ids); 52 | if(result == 0){ 53 | return Res.errorMsg("删除失败"); 54 | } 55 | return Res.successMsg("删除成功"); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/controller/OrderCommentController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.controller; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Const; 5 | import com.sell.common.Res; 6 | import com.sell.common.utils.FileUploadUtil; 7 | import com.sell.common.utils.UserUtils; 8 | import com.sell.modules.store.dto.QueryCommentDTO; 9 | import com.sell.modules.store.entity.OrderComment; 10 | import com.sell.modules.store.service.OrderCommentService; 11 | import com.sell.modules.store.service.OrderService; 12 | import com.sell.modules.store.service.OrderStatusService; 13 | import io.swagger.annotations.Api; 14 | import io.swagger.annotations.ApiOperation; 15 | import lombok.extern.slf4j.Slf4j; 16 | import org.apache.commons.lang3.StringUtils; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.web.bind.annotation.*; 19 | 20 | import java.io.IOException; 21 | import java.math.BigDecimal; 22 | 23 | /** 24 | * @author linyuc 25 | * @date 2020/3/31 23:24 26 | */ 27 | @Slf4j 28 | @RestController 29 | @RequestMapping("comment") 30 | @Api(tags = "订单评价相关接口") 31 | public class OrderCommentController { 32 | @Autowired 33 | private OrderCommentService orderCommentService; 34 | @Autowired 35 | private OrderStatusService orderStatusService; 36 | @Autowired 37 | private OrderService orderService; 38 | @Autowired 39 | private FileUploadUtil fileUploadUtil; 40 | 41 | @PostMapping("save") 42 | @ApiOperation("用户提交保存评价信息") 43 | public Res save(OrderComment orderComment){ 44 | orderComment.setUserId(UserUtils.getUserId()); 45 | if(orderComment.getFile() != null){ 46 | try { 47 | String newFileName = fileUploadUtil.uploadFile(orderComment.getFile()); 48 | orderComment.setImages(newFileName); 49 | } catch (IOException e) { 50 | e.printStackTrace(); 51 | return Res.errorMsg("上传文件失败"); 52 | } 53 | } 54 | BigDecimal score = new BigDecimal(orderComment.getScores()); 55 | orderComment.setScore(score); 56 | int result = orderCommentService.save(orderComment); 57 | if(result == 0){ 58 | return Res.errorMsg("评价失败"); 59 | } 60 | int r = orderService.updateStatusByOrderNo(orderComment.getOrderNo(), Const.OrderStatus.HAVE_EVALUATION); 61 | if(r == 0){ 62 | return Res.errorMsg("评价失败"); 63 | } 64 | boolean b2 = orderStatusService.saveStatus(orderComment.getOrderNo(),Const.OrderStatus.HAVE_EVALUATION); 65 | if(!b2){ 66 | return Res.errorMsg("评价失败"); 67 | } 68 | return Res.successMsg("评价成功"); 69 | } 70 | 71 | /** 72 | * 商家发起查询自己的订单评价列表 73 | */ 74 | @GetMapping("list") 75 | @ApiOperation("商家发起查询自己的订单评价列表") 76 | public Res> list(QueryCommentDTO dto){ 77 | if(dto.getShopId() == null) { 78 | dto.setShopId(UserUtils.getShopId()); 79 | } 80 | return Res.success(orderCommentService.list(dto)); 81 | } 82 | 83 | /** 84 | * 用户查询自己的订单评价列表 85 | */ 86 | @GetMapping("listUser") 87 | @ApiOperation("商家发起查询自己的订单评价列表") 88 | public Res> listUser(QueryCommentDTO dto){ 89 | dto.setUserId(UserUtils.getUserId()); 90 | return Res.success(orderCommentService.list(dto)); 91 | } 92 | 93 | @PostMapping("reply") 94 | @ApiOperation("商家回复订单评价") 95 | public Res reply(@RequestBody OrderComment comment){ 96 | if(StringUtils.isBlank(comment.getReply())){ 97 | return Res.errorMsg("回复内容为空"); 98 | } 99 | int result = orderCommentService.update(comment.getOrderNo(),comment.getReply()); 100 | if(result == 1){ 101 | return Res.successMsg("回复成功"); 102 | } 103 | return Res.errorMsg("回复失败"); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.controller; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Const; 5 | import com.sell.common.Res; 6 | import com.sell.common.utils.UserUtils; 7 | import com.sell.modules.store.entity.Order; 8 | import com.sell.modules.store.entity.OrderItem; 9 | import com.sell.modules.store.entity.OrderStatus; 10 | import com.sell.modules.store.entity.Shipping; 11 | import com.sell.modules.store.service.*; 12 | import com.sell.modules.store.vo.UserOrderVo; 13 | import com.sell.modules.sys.security.WebSocket; 14 | import io.swagger.annotations.Api; 15 | import io.swagger.annotations.ApiOperation; 16 | import org.apache.commons.lang3.StringUtils; 17 | import org.json.JSONArray; 18 | import org.json.JSONObject; 19 | import org.springframework.beans.factory.annotation.Autowired; 20 | import org.springframework.web.bind.annotation.*; 21 | 22 | import java.math.BigDecimal; 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | /** 27 | * @author linyuc 28 | * @date 2020/3/1 0:09 29 | */ 30 | @RestController 31 | @RequestMapping("/order") 32 | @Api(tags = "订单模块相关接口") 33 | public class OrderController { 34 | @Autowired 35 | private OrderService orderService; 36 | @Autowired 37 | private ProductService productService; 38 | @Autowired 39 | private OrderItemService orderItemService; 40 | @Autowired 41 | private OrderStatusService orderStatusService; 42 | @Autowired 43 | private ShippingService shippingService; 44 | @Autowired 45 | private WebSocket webSocket; 46 | @PostMapping("create") 47 | @ApiOperation("用户提交创建订单") 48 | public Res create(@RequestBody Order order) throws Exception{ 49 | //生成订单号 50 | Long orderNo = Const.generateOrderNo(); 51 | List orderItemList = new ArrayList<>(); 52 | JSONArray jsonArray = new JSONArray(order.getCartStr()); 53 | //获取前端传过来的商品信息 54 | for(int i = 0; i< jsonArray.length();i++){ 55 | JSONObject o= jsonArray.getJSONObject(i); 56 | OrderItem orderItem = new OrderItem(); 57 | orderItem.setProductName(o.getString("name")); 58 | orderItem.setProductId(o.getInt("productId")); 59 | //orderItem.setProductImg(o.getString("logoImg")); 60 | orderItem.setNumber(o.getInt("num")); 61 | orderItem.setSellPrice(new BigDecimal(o.getString("sellPrice"))); 62 | orderItem.setShopId(order.getShopId()); 63 | orderItem.setOrderNo(orderNo); 64 | orderItemList.add(orderItem); 65 | } 66 | //校验库存 67 | for(OrderItem item : orderItemList){ 68 | boolean b = productService.checkStock(item.getProductName(),item.getNumber()); 69 | if(!b){ 70 | return Res.errorMsg(item.getProductName()+"商品库存不足"); 71 | } 72 | int result = orderItemService.insert(item); 73 | //扣库存 74 | if(result == 0){ 75 | return Res.errorMsg("创建订单失败"); 76 | } 77 | } 78 | //创建订单 79 | order.setUserId(UserUtils.getUserId()); 80 | order.setOrderNo(orderNo); 81 | //order.setBoxCost(new BigDecimal(order.getBCost())); 82 | //order.setSendCost(new BigDecimal(order.getSCost())); 83 | order.setPayMoney(new BigDecimal(order.getMoney())); 84 | order.setStatus(Const.OrderStatus.PAID); 85 | boolean b1 = orderService.save(order); 86 | if(!b1){ 87 | return Res.errorMsg("创建订单失败"); 88 | } 89 | //记录订单状态 90 | boolean b2 = orderStatusService.saveStatus(order.getOrderNo(), Const.OrderStatus.PAID); 91 | if(!b2){ 92 | return Res.errorMsg("订单状态修改失败"); 93 | } 94 | //webSocket消息推送通知商家 95 | //webSocket.sendOneMessage(order.getShopId().toString(), "您有一条新的Lin sell订单了"); 96 | return Res.successMsg("订单创建成功"); 97 | } 98 | @GetMapping("list_user") 99 | public Res> listOfUser(String orderNo,String pageNum){ 100 | PageInfo orderList = orderService.getUserOrderList(UserUtils.getUserId(),null,orderNo,pageNum); 101 | return Res.success(orderList); 102 | } 103 | 104 | @GetMapping("listDelivery") 105 | @ApiOperation("获取骑手页面我的订单") 106 | public Res> listDelivery(String orderNo,String pageNum){ 107 | PageInfo orderList = orderService.getUserOrderList(null,UserUtils.getDeliveryId(),orderNo,pageNum); 108 | return Res.success(orderList); 109 | } 110 | @GetMapping("detail") 111 | @ApiOperation("用户获取订单详情") 112 | public Res detail(String orderNo){ 113 | if(StringUtils.isBlank(orderNo)){ 114 | return Res.errorMsg("订单号参数错误"); 115 | } 116 | Order order = orderService.getOrderDetail(orderNo); 117 | if(order == null){ 118 | return Res.errorMsg("该订单号不存在"); 119 | } 120 | List orderItemList = orderItemService.getList(orderNo); 121 | order.setOrderItemList(orderItemList); 122 | Shipping shipping = shippingService.getByOrderNo(orderNo); 123 | order.setShippingAddress(shipping.getAddressDetail()); 124 | order.setShippingName(shipping.getName()+shipping.getTel()); 125 | return Res.success(order); 126 | } 127 | @GetMapping("status") 128 | @ApiOperation("用户查看订单配送状态") 129 | public Res> statusList(String orderNo){ 130 | if(StringUtils.isBlank(orderNo)){ 131 | return Res.errorMsg("订单号参数错误"); 132 | } 133 | List orderStatusList = orderStatusService.getList(orderNo); 134 | return Res.success(orderStatusList); 135 | } 136 | /** 137 | * 获取骑手手机号 138 | */ 139 | @GetMapping("dmobile") 140 | @ApiOperation("用户获取骑手手机号") 141 | public Res deliveryMobile(Long orderNo){ 142 | String mobile = orderService.getDeliveryMobile(orderNo); 143 | if(StringUtils.isBlank(mobile)){ 144 | return Res.errorMsg("未找到该骑手电话"); 145 | } 146 | return Res.success(mobile); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/controller/ProductCategoryController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.controller; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Res; 5 | import com.sell.common.utils.UserUtils; 6 | import com.sell.modules.store.dto.QueryProductDTO; 7 | import com.sell.modules.store.entity.ProductCategory; 8 | import com.sell.modules.store.service.ProductCategoryService; 9 | import io.swagger.annotations.Api; 10 | import io.swagger.annotations.ApiOperation; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.apache.shiro.authz.annotation.RequiresRoles; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.web.bind.annotation.*; 15 | 16 | import java.util.List; 17 | 18 | /** 19 | * @author linyuc 20 | * @date 2020/1/16 18:51 21 | */ 22 | @RestController 23 | @RequestMapping("category") 24 | @Api(tags = "商品分类相关接口") 25 | public class ProductCategoryController { 26 | @Autowired 27 | private ProductCategoryService productCategoryService; 28 | 29 | /** 30 | * 查找某个商家的商品分类 31 | * @param shopId 32 | * @return 33 | */ 34 | @GetMapping("product") 35 | @ApiOperation("查找某个商家的商品分类") 36 | public Res> getCategory(Integer shopId){ 37 | if(shopId == null){ 38 | shopId = UserUtils.getShopId(); 39 | } 40 | List categoryList = productCategoryService.getProductCategory(shopId); 41 | return Res.success(categoryList); 42 | } 43 | /** 44 | * 商家查询自家店铺的商品分类 45 | * @param dto 46 | * @return 47 | */ 48 | @GetMapping("list") 49 | @RequiresRoles("business") 50 | @ApiOperation("查找某个商家的商品分类") 51 | public Res> getCategoryList(QueryProductDTO dto){ 52 | dto.setShopId(UserUtils.getShopId()); 53 | return Res.success(productCategoryService.getCategoryList(dto)); 54 | } 55 | @PostMapping("save") 56 | @RequiresRoles("business") 57 | @ApiOperation("添加商品分类") 58 | public Res saveCategory(@RequestBody ProductCategory category){ 59 | int result = productCategoryService.saveProductCategory(category.getName()); 60 | if(result > 0){ 61 | return Res.successMsg("添加商品分类成功"); 62 | } 63 | return Res.errorMsg("添加商品分类失败"); 64 | } 65 | @PutMapping("update") 66 | @RequiresRoles("business") 67 | @ApiOperation("修改商品分类") 68 | public Res updateCategory(@RequestBody ProductCategory category){ 69 | if(category.getId() == null && StringUtils.isBlank(category.getName())){ 70 | return Res.errorMsg("参数错误"); 71 | } 72 | int result = productCategoryService.updateProductCategory(category); 73 | if(result > 0){ 74 | return Res.successMsg("修改成功"); 75 | } 76 | return Res.errorMsg("修改失败"); 77 | } 78 | 79 | @DeleteMapping("delete") 80 | @RequiresRoles("business") 81 | @ApiOperation("删除商品分类") 82 | public Res deleteCategory(String ids){ 83 | if(StringUtils.isBlank(ids)){ 84 | return Res.errorMsg("传递的id参数失败"); 85 | } 86 | int result = productCategoryService.deleteBatch(ids); 87 | if(result == 0){ 88 | return Res.errorMsg("删除失败"); 89 | } 90 | return Res.successMsg("删除成功"); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.controller; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Res; 5 | import com.sell.common.utils.FileUploadUtil; 6 | import com.sell.modules.store.dto.QueryProductDTO; 7 | import com.sell.modules.store.entity.Product; 8 | import com.sell.modules.store.entity.ProductCategory; 9 | import com.sell.modules.store.service.ProductCategoryService; 10 | import com.sell.modules.store.service.ProductService; 11 | import com.sell.modules.store.vo.ProductVo; 12 | import io.swagger.annotations.Api; 13 | import io.swagger.annotations.ApiOperation; 14 | import lombok.extern.slf4j.Slf4j; 15 | import org.apache.commons.collections.CollectionUtils; 16 | import org.apache.commons.lang3.StringUtils; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.web.bind.annotation.*; 19 | import java.io.IOException; 20 | import java.math.BigDecimal; 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | /** 24 | * @author linyuc 25 | * @date 2020/1/20 16:34 26 | */ 27 | @Slf4j 28 | @RestController 29 | @RequestMapping("product") 30 | @Api(tags = "商品相关接口") 31 | public class ProductController { 32 | @Autowired 33 | private ProductService productService; 34 | @Autowired 35 | private ProductCategoryService productCategoryService; 36 | @Autowired 37 | private FileUploadUtil fileUploadUtil; 38 | 39 | @GetMapping("list") 40 | @ApiOperation("用户查询商品列表") 41 | public Res>> list(Integer shopId){ 42 | if(shopId == null){ 43 | return Res.errorMsg("该分类无商品信息"); 44 | } 45 | List categoryList = productCategoryService.getProductCategory(shopId); 46 | List productList = productService.getByCategory(shopId); 47 | List> productLists = new ArrayList<>(); 48 | categoryList.forEach(e->{ 49 | List list = new ArrayList<>(); 50 | for(ProductVo item : productList){ 51 | if(item.getCategoryId().equals(e.getId())){ 52 | item.setCategoryName(e.getName()); 53 | list.add(item); 54 | } 55 | } 56 | if(CollectionUtils.isNotEmpty(list)){ 57 | productLists.add(list); 58 | } 59 | }); 60 | if(productLists.size() == 0){ 61 | return Res.errorMsg("该分类无商品信息"); 62 | } 63 | return Res.success(productLists); 64 | } 65 | @GetMapping("shop_list") 66 | @ApiOperation("商家查询商品列表") 67 | public Res> getProductList(QueryProductDTO dto){ 68 | PageInfo productList = productService.getProductList(dto); 69 | return Res.success(productList); 70 | } 71 | @PostMapping("save") 72 | @ApiOperation("新增保存商品信息") 73 | public Res save(Product product){ 74 | if(!StringUtils.isBlank(product.getOrigin())){ 75 | product.setOriginPrice(new BigDecimal(product.getOrigin())); 76 | } 77 | if(!StringUtils.isBlank(product.getSell())){ 78 | product.setSellPrice(new BigDecimal(product.getSell())); 79 | } 80 | if(product.getFile() != null){ 81 | try { 82 | String newFileName = fileUploadUtil.uploadFile(product.getFile()); 83 | product.setLogoImg(newFileName); 84 | } catch (IOException e) { 85 | e.printStackTrace(); 86 | return Res.errorMsg("上传文件失败"); 87 | } 88 | } 89 | int result = productService.saveProduct(product); 90 | if(result == 0){ 91 | return Res.errorMsg("保存商品信息失败"); 92 | } 93 | return Res.successMsg("保存商品信息成功"); 94 | } 95 | 96 | @PutMapping("update") 97 | @ApiOperation("修改商品信息") 98 | public Res update(Product product){ 99 | if(!StringUtils.isBlank(product.getOrigin())){ 100 | product.setOriginPrice(new BigDecimal(product.getOrigin())); 101 | } 102 | if(!StringUtils.isBlank(product.getSell())){ 103 | product.setSellPrice(new BigDecimal(product.getSell())); 104 | } 105 | if(product.getFile() != null){ 106 | try { 107 | String newFileName = fileUploadUtil.uploadFile(product.getFile()); 108 | product.setLogoImg(newFileName); 109 | } catch (IOException e) { 110 | e.printStackTrace(); 111 | return Res.errorMsg("上传文件失败"); 112 | } 113 | } 114 | int result = productService.update(product); 115 | if(result == 0){ 116 | return Res.errorMsg("修改商品信息失败"); 117 | } 118 | return Res.successMsg("修改商品信息成功"); 119 | } 120 | 121 | @DeleteMapping("delete") 122 | @ApiOperation("删除商品信息") 123 | public Res delete(String ids){ 124 | if(StringUtils.isBlank(ids)){ 125 | return Res.errorMsg("传递的id参数失败"); 126 | } 127 | int result = productService.deleteBatch(ids); 128 | if(result == 0){ 129 | return Res.errorMsg("删除失败"); 130 | } 131 | return Res.successMsg("删除成功"); 132 | } 133 | 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/controller/ShippingController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.controller; 2 | 3 | import com.sell.common.Const; 4 | import com.sell.common.Res; 5 | import com.sell.common.utils.UserUtils; 6 | import com.sell.modules.store.entity.Shipping; 7 | import com.sell.modules.store.service.ShippingService; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.apache.commons.lang3.StringUtils; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.web.bind.annotation.*; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * @author linyuc 18 | * @date 2020/2/5 16:22 19 | */ 20 | @RestController 21 | @RequestMapping("shipping") 22 | @Api(tags = "收货地址相关接口") 23 | public class ShippingController { 24 | @Autowired 25 | private ShippingService shippingService; 26 | @GetMapping("list") 27 | @ApiOperation("查看收货地址列表") 28 | public Res> list(){ 29 | List shippingList = shippingService.getShippingList(UserUtils.getUserId()); 30 | if(shippingList == null){ 31 | return Res.errorMsg("请添加收获地址"); 32 | } 33 | return Res.success(shippingList); 34 | } 35 | 36 | /** 37 | * 用户生成订单时获取用户默认收货地址 38 | * @return 39 | */ 40 | @GetMapping("default") 41 | @ApiOperation("用户生成订单时获取用户默认收货地址") 42 | public Res defaultShipping(){ 43 | Shipping shipping = shippingService.getDefault(UserUtils.getUserId()); 44 | if(shipping == null){ 45 | return Res.errorMsg("请选择收货地址"); 46 | } 47 | return Res.success(shipping); 48 | } 49 | @PostMapping("save") 50 | @ApiOperation("保存收货地址信息") 51 | public Res save(@RequestBody Shipping shipping){ 52 | Integer userId = UserUtils.getUserId(); 53 | if("1".equals(shipping.getIsDefault())){ 54 | shippingService.updateDefault(userId); 55 | } 56 | shipping.setUserId(userId); 57 | int result = shippingService.save(shipping); 58 | if(result == 0){ 59 | Res.errorMsg("保存失败"); 60 | } 61 | return Res.successMsg("保存成功"); 62 | } 63 | @PutMapping("update") 64 | @ApiOperation("修改收货地址信息") 65 | public Res update(@RequestBody Shipping shipping){ 66 | if("1".equals(shipping.getIsDefault())){ 67 | shippingService.updateDefault(UserUtils.getUserId()); 68 | } 69 | int result = shippingService.update(shipping); 70 | if(result == 0){ 71 | return Res.errorMsg("修改失败"); 72 | } 73 | return Res.successMsg("修改成功"); 74 | } 75 | @DeleteMapping("delete") 76 | @ApiOperation("删除收货地址信息") 77 | public Res delete(Integer id){ 78 | Shipping shipping = new Shipping(); 79 | shipping.setId(id); 80 | shipping.setDelFlag(Const.DELETED); 81 | int result = shippingService.update(shipping); 82 | if(result == 0){ 83 | return Res.errorMsg("删除失败"); 84 | } 85 | return Res.successMsg("删除成功"); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/controller/ShopAdminController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.controller; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Res; 5 | import com.sell.modules.store.dto.QueryDTO; 6 | import com.sell.modules.store.entity.Delivery; 7 | import com.sell.modules.store.entity.Shop; 8 | import com.sell.modules.store.service.DeliveryService; 9 | import com.sell.modules.store.service.ShopService; 10 | import io.swagger.annotations.ApiOperation; 11 | import org.apache.commons.lang3.StringUtils; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | /** 16 | * 管理员端,骑手管理相关接口 17 | * @author linyuc 18 | * @Description TODO 19 | * @date 2022/2/28 23:02 20 | */ 21 | @RestController 22 | @RequestMapping("shopAdmin") 23 | public class ShopAdminController { 24 | 25 | @Autowired 26 | private ShopService shopService; 27 | 28 | @GetMapping("list") 29 | @ApiOperation("查找商家店铺列表") 30 | public Res> getUserList(QueryDTO dto){ 31 | return Res.success(shopService.queryShopList(dto)); 32 | } 33 | 34 | @PostMapping("saveOrUpdate") 35 | @ApiOperation("修改商家店铺信息") 36 | public Res saveOrUpdate(@RequestBody Shop shop){ 37 | if(shop.getId() == null){ 38 | return shopService.save(shop); 39 | } 40 | int result = shopService.updateSelective(shop); 41 | if(result < 1){ 42 | return Res.errorMsg("修改店铺失败"); 43 | } 44 | return Res.successMsg("修改店铺成功"); 45 | } 46 | 47 | @DeleteMapping("delete") 48 | @ApiOperation("批量删除店铺") 49 | public Res deleteUser(String ids){ 50 | if(StringUtils.isBlank(ids)){ 51 | return Res.errorMsg("传递的id参数不能为空"); 52 | } 53 | int result = shopService.deleteBatch(ids); 54 | if(result == 0){ 55 | return Res.errorMsg("删除失败"); 56 | } 57 | return Res.successMsg("删除成功"); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/controller/ShopCategoryController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.controller; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Const; 5 | import com.sell.common.Res; 6 | import com.sell.common.cache.IBaseCache; 7 | import com.sell.common.cache.RedisCache; 8 | import com.sell.common.utils.UserUtils; 9 | import com.sell.modules.store.dto.QueryDTO; 10 | import com.sell.modules.store.dto.QueryProductDTO; 11 | import com.sell.modules.store.entity.ProductCategory; 12 | import com.sell.modules.store.entity.ShopCategory; 13 | import com.sell.modules.store.service.ShopCategoryService; 14 | import io.swagger.annotations.Api; 15 | import io.swagger.annotations.ApiOperation; 16 | import org.apache.commons.lang3.StringUtils; 17 | import org.apache.shiro.authz.annotation.RequiresRoles; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.web.bind.annotation.*; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * @author linyuc 25 | * @date 2020/1/16 17:04 26 | */ 27 | @RestController 28 | @RequestMapping("shopCategory") 29 | @Api(tags = "商家分类相关接口") 30 | public class ShopCategoryController { 31 | @Autowired 32 | private IBaseCache iBaseCache; 33 | @Autowired 34 | private ShopCategoryService shopCategoryService; 35 | /** 36 | * 获取顶级分类 37 | */ 38 | @GetMapping("shop_top") 39 | @ApiOperation("获取第一级的商家分类") 40 | public Res getTopCategory(@RequestParam(defaultValue = "0") Integer categoryId){ 41 | List categoryList = iBaseCache.getShopTopCategoryList(categoryId); 42 | if(categoryList == null){ 43 | return Res.errorMsg("查找商铺分类失败"); 44 | } 45 | return Res.success(categoryList); 46 | } 47 | @GetMapping("del") 48 | public String del(){ 49 | iBaseCache.del(); 50 | return "删除"; 51 | } 52 | @GetMapping("shop") 53 | @ApiOperation("获取第二级的商家分类") 54 | public Res getSiblingCategory(@RequestParam(defaultValue = "0") Integer categoryId){ 55 | List categoryList = shopCategoryService.getSiblingCategory(categoryId); 56 | if(categoryList == null){ 57 | return Res.errorMsg("查找商铺分类失败"); 58 | } 59 | categoryList.add(0,new ShopCategory(categoryId,"全部")); 60 | return Res.success(categoryList); 61 | } 62 | 63 | /** 64 | * 查找商家分类列表 65 | * @param dto 66 | * @return 67 | */ 68 | @GetMapping("list") 69 | @ApiOperation("查找店铺分类列表") 70 | public Res> getCategoryList(QueryDTO dto){ 71 | return Res.success(shopCategoryService.getCategoryList(dto)); 72 | } 73 | @PostMapping("save") 74 | @RequiresRoles("admin") 75 | @ApiOperation("添加商品分类") 76 | public Res saveCategory(@RequestBody ShopCategory category){ 77 | int result = shopCategoryService.saveShopCategory(category.getName()); 78 | if(result > 0){ 79 | return Res.successMsg("添加商品分类成功"); 80 | } 81 | return Res.errorMsg("添加商品分类失败"); 82 | } 83 | 84 | @PutMapping("update") 85 | @RequiresRoles("admin") 86 | @ApiOperation("修改店铺分类") 87 | public Res updateCategory(@RequestBody ShopCategory category){ 88 | if(category.getId() == null && StringUtils.isBlank(category.getName())){ 89 | return Res.errorMsg("参数错误"); 90 | } 91 | int result = shopCategoryService.updateShopCategory(category); 92 | if(result > 0){ 93 | return Res.successMsg("修改成功"); 94 | } 95 | return Res.errorMsg("修改失败"); 96 | } 97 | 98 | @DeleteMapping("delete") 99 | @RequiresRoles("business") 100 | @ApiOperation("删除店铺分类") 101 | public Res deleteCategory(String ids){ 102 | if(StringUtils.isBlank(ids)){ 103 | return Res.errorMsg("传递的id参数失败"); 104 | } 105 | int result = shopCategoryService.deleteBatch(ids); 106 | if(result == 0){ 107 | return Res.errorMsg("删除失败"); 108 | } 109 | return Res.successMsg("删除成功"); 110 | } 111 | 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/controller/UserAdminController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.controller; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Res; 5 | import com.sell.modules.store.dto.QueryDTO; 6 | import com.sell.modules.sys.entity.User; 7 | import com.sell.modules.sys.service.UserService; 8 | import io.swagger.annotations.ApiOperation; 9 | import org.apache.commons.lang3.StringUtils; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | /** 14 | * 管理员端,用户管理相关接口 15 | * @author linyuc 16 | * @Description TODO 17 | * @date 2022/2/28 23:02 18 | */ 19 | @RestController 20 | @RequestMapping("userAdmin") 21 | public class UserAdminController { 22 | 23 | @Autowired 24 | private UserService userService; 25 | 26 | @GetMapping("list") 27 | @ApiOperation("查找普通用户列表") 28 | public Res> getUserList(QueryDTO dto){ 29 | return Res.success(userService.getUserList(dto)); 30 | } 31 | 32 | @PostMapping("update") 33 | @ApiOperation("修改普通用户") 34 | public Res update(@RequestBody User user){ 35 | int result = userService.update(user); 36 | if(result < 1){ 37 | return Res.errorMsg("修改用户失败"); 38 | } 39 | return Res.successMsg("修改用户成功"); 40 | } 41 | 42 | @DeleteMapping("delete") 43 | @ApiOperation("批量删除普通用户") 44 | public Res deleteUser(String ids){ 45 | if(StringUtils.isBlank(ids)){ 46 | return Res.errorMsg("传递的id参数不能为空"); 47 | } 48 | int result = userService.deleteBatch(ids); 49 | if(result == 0){ 50 | return Res.errorMsg("删除失败"); 51 | } 52 | return Res.successMsg("删除成功"); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dao/DeliveryMapper.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dao; 2 | 3 | import com.sell.modules.store.dto.QueryDTO; 4 | import com.sell.modules.store.entity.Delivery; 5 | import com.sell.modules.sys.entity.User; 6 | import org.apache.ibatis.annotations.Mapper; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author linyuc 12 | * @date 2019/12/20 11:50 13 | */ 14 | @Mapper 15 | public interface DeliveryMapper { 16 | int deleteByPrimaryKey(String id); 17 | 18 | int insert(Delivery record); 19 | 20 | int insertSelective(Delivery record); 21 | 22 | Delivery selectByPrimaryKey(String id); 23 | 24 | int updateByPrimaryKeySelective(Delivery record); 25 | 26 | int updateByPrimaryKey(Delivery record); 27 | 28 | int selectCount(); 29 | 30 | Delivery selectBest(Integer number); 31 | 32 | Delivery selectByUserId(Integer id); 33 | 34 | int updateTaskNumByUserId(Integer userId); 35 | 36 | /** 37 | * 查询骑手列表 38 | * @param dto 39 | * @return 40 | */ 41 | List selectDeliveryList(QueryDTO dto); 42 | /** 43 | * 批量假删 44 | * @param ids 45 | * @return 46 | */ 47 | int deleteBatch(String ids); 48 | 49 | List selectUserIdByDeliveryId(String ids); 50 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dao/OrderCommentMapper.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dao; 2 | 3 | import com.sell.modules.store.dto.QueryCommentDTO; 4 | import com.sell.modules.store.entity.OrderComment; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | @Mapper 11 | public interface OrderCommentMapper { 12 | int deleteByPrimaryKey(String id); 13 | 14 | int insert(OrderComment record); 15 | 16 | int insertSelective(OrderComment record); 17 | 18 | OrderComment selectByPrimaryKey(String id); 19 | 20 | int updateByPrimaryKeySelective(OrderComment record); 21 | 22 | int updateByPrimaryKey(OrderComment record); 23 | 24 | List selectOrderCommentList(QueryCommentDTO dto); 25 | 26 | int updateReplyByOrderId(@Param("orderNo") Long orderNo,@Param("reply") String reply); 27 | 28 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dao/OrderItemMapper.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dao; 2 | 3 | import com.sell.modules.store.entity.OrderItem; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author linyuc 10 | * @date 2020/03/01 00:13 11 | */ 12 | @Mapper 13 | public interface OrderItemMapper { 14 | int deleteByPrimaryKey(String id); 15 | 16 | int insert(OrderItem record); 17 | 18 | int insertSelective(OrderItem record); 19 | 20 | OrderItem selectByPrimaryKey(String id); 21 | 22 | int updateByPrimaryKeySelective(OrderItem record); 23 | 24 | int updateByPrimaryKey(OrderItem record); 25 | List selectListByOrderNo(String orderNo); 26 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dao/OrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dao; 2 | 3 | import com.sell.modules.store.dto.QueryOrderDTO; 4 | import com.sell.modules.store.entity.Order; 5 | import com.sell.modules.store.vo.DeliveryOrderVo; 6 | import com.sell.modules.store.vo.NewOrderVo; 7 | import com.sell.modules.store.vo.UserOrderVo; 8 | import org.apache.ibatis.annotations.Mapper; 9 | import org.apache.ibatis.annotations.Param; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @author linyuc 15 | * @date 2019/12/20 11:50 16 | */ 17 | @Mapper 18 | public interface OrderMapper { 19 | int deleteByPrimaryKey(String id); 20 | 21 | int insert(Order record); 22 | 23 | int insertSelective(Order record); 24 | 25 | Order selectByPrimaryKey(String id); 26 | 27 | int updateByPrimaryKeySelective(Order record); 28 | 29 | int updateByPrimaryKey(Order record); 30 | List selectNewOrderList(QueryOrderDTO dto); 31 | 32 | List selectUserOrderList(@Param("userId")Integer userId, @Param("deliveryId")Integer deliveryId, @Param("orderNo")String orderNo); 33 | 34 | /** 35 | * 5个小时内 36 | */ 37 | List selectDeliveryOrderList(@Param("deliveryId")Integer deliveryId, 38 | @Param("status")String status); 39 | String selectUserMobile(Long orderNo); 40 | String selectDeliveryMobile(Long orderNo); 41 | String selectUserId(Long orderNo); 42 | String selectShopId(Long orderNo); 43 | 44 | Order selectOrderByOrderNo(String orderNo); 45 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dao/OrderStatusMapper.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dao; 2 | 3 | import com.sell.modules.store.entity.OrderStatus; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author linyuc 10 | * @date 2020/03/01 00:13 11 | */ 12 | @Mapper 13 | public interface OrderStatusMapper { 14 | int deleteByPrimaryKey(String id); 15 | 16 | int insert(OrderStatus record); 17 | 18 | int insertSelective(OrderStatus record); 19 | 20 | OrderStatus selectByPrimaryKey(String id); 21 | 22 | int updateByPrimaryKeySelective(OrderStatus record); 23 | 24 | int updateByPrimaryKey(OrderStatus record); 25 | List selectList(Long orderNo); 26 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dao/ProductCategoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dao; 2 | 3 | import com.sell.modules.store.dto.QueryProductDTO; 4 | import com.sell.modules.store.entity.ProductCategory; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | public interface ProductCategoryMapper { 11 | int deleteByPrimaryKey(String id); 12 | 13 | int insert(ProductCategory record); 14 | 15 | int insertSelective(ProductCategory record); 16 | 17 | ProductCategory selectByPrimaryKey(String id); 18 | 19 | int updateByPrimaryKeySelective(ProductCategory record); 20 | 21 | int updateByPrimaryKey(ProductCategory record); 22 | 23 | List selectCategoryList(QueryProductDTO dto); 24 | /** 25 | * 批量假删 26 | * @param ids 27 | * @return 28 | */ 29 | int deleteBatch(String ids); 30 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dao/ProductMapper.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dao; 2 | 3 | import com.sell.modules.store.dto.QueryProductDTO; 4 | import com.sell.modules.store.entity.Product; 5 | import com.sell.modules.store.vo.ProductVo; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.apache.ibatis.annotations.Param; 8 | 9 | import java.util.List; 10 | 11 | @Mapper 12 | public interface ProductMapper { 13 | int deleteByPrimaryKey(String id); 14 | 15 | int insert(Product record); 16 | 17 | int insertSelective(Product record); 18 | 19 | Product selectByPrimaryKey(String id); 20 | 21 | int updateByPrimaryKeySelective(Product record); 22 | 23 | int updateByPrimaryKey(Product record); 24 | 25 | List selectProductListByCategory(Integer shopId); 26 | List selectProductList(QueryProductDTO dto); 27 | Integer checkStockByName(@Param("name")String name,@Param("num")Integer num); 28 | 29 | /** 30 | * 批量假删 31 | * @param ids 32 | * @return 33 | */ 34 | int deleteBatch(String ids); 35 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dao/ShippingMapper.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dao; 2 | 3 | import com.sell.modules.store.entity.Shipping; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author linyuc 10 | * @date 2020/02/05 16:14 11 | */ 12 | @Mapper 13 | public interface ShippingMapper { 14 | int deleteByPrimaryKey(String id); 15 | 16 | int insert(Shipping record); 17 | 18 | int insertSelective(Shipping record); 19 | 20 | Shipping selectByOrderNo(String orderNo); 21 | 22 | int updateByPrimaryKeySelective(Shipping record); 23 | 24 | int updateByPrimaryKey(Shipping record); 25 | 26 | List selectListByUserId(Integer userId); 27 | 28 | Shipping selectDefaultByUserId(Integer userId); 29 | 30 | void updateDefault(Integer userId); 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dao/ShopCategoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dao; 2 | 3 | import com.sell.modules.store.dto.QueryDTO; 4 | import com.sell.modules.store.dto.QueryProductDTO; 5 | import com.sell.modules.store.entity.ProductCategory; 6 | import com.sell.modules.store.entity.ShopCategory; 7 | import org.apache.ibatis.annotations.Mapper; 8 | 9 | import java.util.List; 10 | 11 | @Mapper 12 | public interface ShopCategoryMapper { 13 | int deleteByPrimaryKey(String id); 14 | 15 | int insert(ShopCategory record); 16 | 17 | int insertSelective(ShopCategory record); 18 | 19 | ShopCategory selectByPrimaryKey(Integer id); 20 | 21 | int updateByPrimaryKeySelective(ShopCategory record); 22 | 23 | int updateByPrimaryKey(ShopCategory record); 24 | 25 | List selectSiblingCategory(Integer id); 26 | List selectCategoryList(Integer id); 27 | 28 | List selectShopCategoryList(QueryDTO dto); 29 | /** 30 | * 批量假删 31 | * @param ids 32 | * @return 33 | */ 34 | int deleteBatch(String ids); 35 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dao/ShopMapper.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dao; 2 | 3 | import com.sell.modules.store.dto.QueryDTO; 4 | import com.sell.modules.store.dto.ShopCountDTO; 5 | import com.sell.modules.store.entity.Shop; 6 | 7 | import java.util.List; 8 | 9 | import com.sell.modules.store.vo.ShopVo; 10 | import org.apache.ibatis.annotations.Mapper; 11 | import org.apache.ibatis.annotations.Param; 12 | /** 13 | * @author linyuc 14 | * @date 2020/01/20 09:40 15 | */ 16 | @Mapper 17 | public interface ShopMapper { 18 | int deleteByPrimaryKey(String id); 19 | 20 | int insert(Shop record); 21 | 22 | int insertSelective(Shop record); 23 | 24 | Shop selectByPrimaryKey(Integer id); 25 | 26 | int updateByPrimaryKeySelective(Shop record); 27 | 28 | int updateByPrimaryKey(Shop record); 29 | 30 | List selectShopList(@Param("name") String name, @Param("categoryIds")List categoryIds, 31 | @Param("sort")String sort); 32 | String selectShopIdByUserId(String userId); 33 | /** 34 | * 获取店铺首页统计信息 35 | * @return dto 36 | */ 37 | ShopCountDTO selectShopCount(Integer shopId); 38 | 39 | /** 40 | * 查询最近12个月每个月的数据统计 41 | * @param shopId 42 | * @return 43 | */ 44 | List getLastYearCount(Integer shopId); 45 | 46 | List selectAdminShopList(QueryDTO dto); 47 | 48 | List selectUserIdByShopId(String ids); 49 | /** 50 | * 批量假删 51 | * @param ids 52 | * @return 53 | */ 54 | int deleteBatch(String ids); 55 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dto/QueryCommentDTO.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dto; 2 | 3 | import lombok.Data; 4 | import java.io.Serializable; 5 | 6 | /** 7 | * 订单评价查询dto 8 | * @author linyuc 9 | * @date 2021/11/10 10:41 10 | */ 11 | @Data 12 | public class QueryCommentDTO implements Serializable { 13 | 14 | private static final long serialVersionUID = 4230409002628279977L; 15 | 16 | private Integer shopId; 17 | private Integer userId; 18 | 19 | private String scoreType; 20 | 21 | private String isAnonymity; 22 | 23 | private String status; 24 | 25 | private int pageNum; 26 | 27 | private int pageSize; 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dto/QueryDTO.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author linyuc 9 | * @Description TODO 10 | * @date 2022/2/28 22:51 11 | */ 12 | @Data 13 | public class QueryDTO implements Serializable { 14 | private static final long serialVersionUID = -669994595343357950L; 15 | 16 | private String username; 17 | 18 | private String name; 19 | 20 | private String status; 21 | 22 | private int current; 23 | 24 | private int size; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dto/QueryOrderDTO.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author linyuc 9 | * @date 2021/12/9 16:32 10 | */ 11 | @Data 12 | public class QueryOrderDTO implements Serializable { 13 | private static final long serialVersionUID = -1984202400099317589L; 14 | 15 | private Long orderNo; 16 | 17 | private Integer shopId; 18 | 19 | private Long mobile; 20 | 21 | private String status; 22 | 23 | private int pageNum; 24 | 25 | private int pageSize; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dto/QueryProductDTO.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author linyuc 9 | * @date 2021/12/6 21:16 10 | */ 11 | @Data 12 | public class QueryProductDTO implements Serializable { 13 | private static final long serialVersionUID = 8826638126597745310L; 14 | 15 | private Integer categoryId; 16 | 17 | private String name; 18 | 19 | private String status; 20 | 21 | private Integer shopId; 22 | 23 | private int pageNum; 24 | 25 | private int pageSize; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/dto/ShopCountDTO.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.RequiredArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | import java.math.BigDecimal; 10 | 11 | /** 12 | * 店铺首页统计信息dto 13 | * @author linyuc 14 | * @date 2021/12/6 17:26 15 | */ 16 | @Data 17 | @AllArgsConstructor 18 | @Builder 19 | @RequiredArgsConstructor 20 | public class ShopCountDTO implements Serializable { 21 | 22 | private static final long serialVersionUID = -793036735405216847L; 23 | 24 | /** 25 | * 订单总数 26 | */ 27 | private int orderTotal; 28 | /** 29 | * 客户总数 30 | */ 31 | private int customerTotal; 32 | /** 33 | * 销售总额 34 | */ 35 | private BigDecimal salesTotal; 36 | /** 37 | * 商品总数 38 | */ 39 | private int productTotal; 40 | /** 41 | * 年月 42 | */ 43 | private String month; 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/entity/Delivery.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.Date; 10 | /** 11 | * @author linyuc 12 | */ 13 | @Data 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class Delivery { 17 | private Integer id; 18 | 19 | private Integer userId; 20 | 21 | private String trueName; 22 | 23 | private String mobile; 24 | 25 | private BigDecimal score; 26 | 27 | private Integer punctuality; 28 | 29 | private Integer dayTaskNum; 30 | 31 | private Integer monthTaskNum; 32 | 33 | private Integer totalTaskNum; 34 | 35 | private String status; 36 | 37 | private Date addTime; 38 | 39 | private String username; 40 | 41 | private String password; 42 | 43 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8") 44 | private Date createTime; 45 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/entity/Feedback.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * @author linyuc 10 | * @date 2020/3/12 23:21 11 | */ 12 | @Data 13 | public class Feedback implements Serializable { 14 | private static final long serialVersionUID = 6862768841930387646L; 15 | 16 | private Integer id; 17 | private Integer userId; 18 | private String content; 19 | /** 20 | * 反馈类别 21 | */ 22 | private String type; 23 | private Date createTime; 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/entity/Order.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | import java.io.Serializable; 10 | import java.math.BigDecimal; 11 | import java.util.Date; 12 | import java.util.List; 13 | 14 | /** 15 | * @author linyuc 16 | * @date 2020/03/01 00:35 17 | */ 18 | @Data 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | @Builder 22 | public class Order implements Serializable { 23 | private static final long serialVersionUID = 3515425295792740287L; 24 | private Integer id; 25 | 26 | private Long orderNo; 27 | 28 | private Integer userId; 29 | 30 | private Integer shippingId; 31 | 32 | private Integer shopId; 33 | 34 | private String shopName; 35 | 36 | private String shopLogo; 37 | 38 | private String shopMobile; 39 | 40 | private Integer deliveryId; 41 | 42 | private String deliveryName; 43 | 44 | private String deliveryMobile; 45 | 46 | private BigDecimal boxCost; 47 | 48 | private BigDecimal sendCost; 49 | 50 | private BigDecimal totalMoney; 51 | 52 | private BigDecimal payMoney; 53 | 54 | private String payType; 55 | 56 | private String remark; 57 | 58 | private Date completeTime; 59 | 60 | private String status; 61 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8") 62 | private Date createTime; 63 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8") 64 | private Date updateTime; 65 | 66 | //以下都是扩展用 67 | private String productName; 68 | private String number; 69 | //用来接收前端传来商品信息json字符串 70 | private String cartStr; 71 | //用来传给前端的商品列表 72 | private List orderItemList; 73 | private String shippingAddress; 74 | private String shippingName; 75 | //用来接收前端传来的 76 | private String bCost; 77 | private String sCost; 78 | private String money; 79 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/entity/OrderComment.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | import org.springframework.web.multipart.MultipartFile; 6 | 7 | import java.math.BigDecimal; 8 | import java.util.Date; 9 | /** 10 | * @author linyuc 11 | * @date 2020/03/01 00:35 12 | */ 13 | @Data 14 | public class OrderComment { 15 | private Integer id; 16 | 17 | private Long orderNo; 18 | 19 | private Integer userId; 20 | private Integer shopId; 21 | private Integer parentId; 22 | 23 | private String content; 24 | 25 | private String images; 26 | 27 | private BigDecimal score; 28 | 29 | private String status; 30 | private String reply; 31 | private String isAnonymity; 32 | 33 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8") 34 | private Date createTime; 35 | 36 | //用于接收前端传过来的值 37 | private MultipartFile file; 38 | 39 | private String scores; 40 | 41 | private String username; 42 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/entity/OrderItem.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.util.Date; 8 | 9 | /** 10 | * @author linyuc 11 | * @date 2020/03/01 00:13 12 | */ 13 | @Data 14 | public class OrderItem implements Serializable { 15 | private static final long serialVersionUID = 1023918481434137016L; 16 | 17 | private Integer id; 18 | 19 | private Long orderNo; 20 | 21 | private Integer shopId; 22 | 23 | private Integer productId; 24 | 25 | private String productName; 26 | 27 | private String productImg; 28 | 29 | private BigDecimal originPrice; 30 | 31 | private BigDecimal sellPrice; 32 | 33 | private Integer number; 34 | 35 | private BigDecimal totalPrice; 36 | 37 | private Date createTime; 38 | 39 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/entity/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | import lombok.Data; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * @author linyuc 11 | * @date 2020/03/01 00:13 12 | */ 13 | @Data 14 | @JsonIgnoreProperties({"id","orderNo","remark"}) 15 | public class OrderStatus { 16 | private Integer id; 17 | 18 | private Long orderNo; 19 | 20 | private String status; 21 | 22 | private String remark; 23 | 24 | @JsonFormat(pattern = "MM-dd HH:mm",timezone = "GMT+8") 25 | private Date createTime; 26 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/entity/Product.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import lombok.Data; 5 | import org.springframework.web.multipart.MultipartFile; 6 | 7 | import java.math.BigDecimal; 8 | import java.util.Date; 9 | /** 10 | * @author linyuc 11 | * @date 2020/01/20 16:36 12 | */ 13 | @Data 14 | @JsonIgnoreProperties({"shopId","createTime","updateTime","delFlag","file"}) 15 | public class Product { 16 | private Integer id; 17 | 18 | private Integer shopId; 19 | 20 | private Integer categoryId; 21 | 22 | private String name; 23 | 24 | private String logoImg; 25 | 26 | private String subImg; 27 | 28 | private String remark; 29 | 30 | private BigDecimal originPrice; 31 | 32 | private BigDecimal sellPrice; 33 | //折扣 34 | private BigDecimal discount; 35 | 36 | private Integer likes; 37 | //限购数量 38 | private Integer limitNum; 39 | 40 | private Integer totalSales; 41 | 42 | private Integer monthlySales; 43 | 44 | private Integer stock; 45 | 46 | private String status; 47 | 48 | private String delFlag; 49 | 50 | private Date createTime; 51 | 52 | private Date updateTime; 53 | //用来接收前端传来的图片、String类型的原价和售价 54 | private MultipartFile file; 55 | private String origin; 56 | private String sell; 57 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/entity/ProductCategory.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | import lombok.Data; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * @author linyc 11 | * @date 2020/01/16 17:47 12 | */ 13 | @Data 14 | @JsonIgnoreProperties({"parentId","shopId","sort","delFlag","updateTime"}) 15 | public class ProductCategory { 16 | private Integer id; 17 | 18 | private String parentId; 19 | 20 | private Integer shopId; 21 | 22 | private String name; 23 | 24 | private String status; 25 | 26 | private Integer sort; 27 | 28 | private String delFlag; 29 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8") 30 | private Date createTime; 31 | 32 | private Date updateTime; 33 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/entity/Shipping.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * @author linyuc 12 | * @date 2020/02/05 16:14 13 | */ 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @JsonIgnoreProperties({"userId","createTime","updateTime","delFlag"}) 18 | public class Shipping { 19 | private Integer id; 20 | 21 | private Integer userId; 22 | 23 | private String name; 24 | 25 | private String tel; 26 | 27 | private String province; 28 | 29 | private String city; 30 | 31 | private String county; 32 | 33 | private String areaCode; 34 | 35 | private String addressDetail; 36 | 37 | private String isDefault; 38 | 39 | private String delFlag; 40 | 41 | private Date createTime; 42 | 43 | private Date updateTime; 44 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/entity/Shop.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | import lombok.Data; 6 | import org.springframework.format.annotation.DateTimeFormat; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.Date; 10 | /** 11 | * @author linyuc 12 | * @date 2020/01/20 09:40 13 | */ 14 | @Data 15 | @JsonIgnoreProperties({"updateTime","delFlag"}) 16 | public class Shop { 17 | private Integer id; 18 | 19 | private Integer userId; 20 | 21 | private String name; 22 | 23 | private String mobile; 24 | 25 | private String logoImg; 26 | 27 | private String storeImg; 28 | 29 | private String address; 30 | 31 | private Integer categoryId; 32 | 33 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "GMT+8") 34 | @DateTimeFormat(pattern = "HH:mm") 35 | private Date openingTime; 36 | 37 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "GMT+8") 38 | @DateTimeFormat(pattern = "HH:mm") 39 | private Date closingTime; 40 | private String tags; 41 | 42 | private String notice; 43 | 44 | private BigDecimal sendCost; 45 | 46 | private BigDecimal deliveryCost; 47 | 48 | private BigDecimal boxCost; 49 | 50 | private Integer deliveryTime; 51 | 52 | private BigDecimal score; 53 | 54 | private BigDecimal foodScore; 55 | 56 | private BigDecimal packScore; 57 | 58 | private BigDecimal deliveryScore; 59 | 60 | private Integer totalSales; 61 | 62 | private Integer monthlySales; 63 | 64 | private String status; 65 | 66 | private String delFlag; 67 | 68 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8") 69 | private Date createTime; 70 | 71 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8") 72 | private Date updateTime; 73 | 74 | private String categoryName; 75 | 76 | private String username; 77 | 78 | private String password; 79 | 80 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/entity/ShopCategory.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.RequiredArgsConstructor; 9 | 10 | import java.util.Date; 11 | /** 12 | * @author linyc 13 | * @date 2020/01/16 17:47 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @RequiredArgsConstructor 18 | @JsonIgnoreProperties({"parentId","sort","delFlag"}) 19 | public class ShopCategory { 20 | private Integer id; 21 | 22 | private Integer parentId; 23 | 24 | private String name; 25 | 26 | private Integer sort; 27 | 28 | private Integer delFlag; 29 | 30 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8") 31 | private Date createTime; 32 | 33 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8") 34 | private Date updateTime; 35 | //返回给前端的 36 | private String text; 37 | public ShopCategory(Integer id, String text) { 38 | this.id = id; 39 | this.text = text; 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/DeliveryService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Res; 5 | import com.sell.modules.store.dto.QueryDTO; 6 | import com.sell.modules.store.entity.Delivery; 7 | import com.sell.modules.sys.entity.User; 8 | 9 | /** 10 | * @author linyuc 11 | * @date 2020/3/3 11:39 12 | */ 13 | public interface DeliveryService { 14 | 15 | boolean updateAssign(String orderNo); 16 | 17 | Delivery getBest(); 18 | 19 | Delivery getInfo(Integer deliveryId); 20 | 21 | int update(Delivery delivery); 22 | 23 | Res save(Delivery delivery); 24 | 25 | boolean updateTaskNum(Integer userId); 26 | /** 27 | * 查询普通用户列表 28 | * @param dto 29 | * @return 30 | */ 31 | PageInfo getDeliveryList(QueryDTO dto); 32 | /** 33 | * 批量假删 34 | * @param ids 35 | */ 36 | int deleteBatch(String ids); 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/FileService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service; 2 | 3 | /** 4 | * @author linyuc 5 | * @date 2019/12/20 11:49 6 | */ 7 | public interface FileService { 8 | // String upload(MultipartFile file, String path,String ftpPath); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/OrderCommentService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.modules.store.dto.QueryCommentDTO; 5 | import com.sell.modules.store.entity.OrderComment; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author linyuc 11 | * @date 2020/3/31 23:27 12 | */ 13 | public interface OrderCommentService { 14 | int save(OrderComment orderComment); 15 | 16 | PageInfo list(QueryCommentDTO dto); 17 | 18 | int update(Long orderNo,String reply); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/OrderItemService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service; 2 | 3 | import com.sell.modules.store.entity.OrderItem; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author linyuc 9 | * @date 2020/3/1 17:22 10 | */ 11 | public interface OrderItemService { 12 | int insert(OrderItem orderItem); 13 | List getList(String orderNo); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.modules.store.dto.QueryOrderDTO; 5 | import com.sell.modules.store.entity.Order; 6 | import com.sell.modules.store.vo.DeliveryOrderVo; 7 | import com.sell.modules.store.vo.NewOrderVo; 8 | import com.sell.modules.store.vo.UserOrderVo; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author linyuc 14 | * @date 2020/3/1 0:15 15 | */ 16 | public interface OrderService { 17 | boolean save(Order order); 18 | PageInfo getOrderList(QueryOrderDTO dto); 19 | int updateStatusByOrderNo(Long orderNo,String status); 20 | int update(Order order); 21 | PageInfo getUserOrderList(Integer userId, Integer deliveryId, String orderNo,String pageNum ); 22 | List getDeliveryOrderList(Integer deliveryId,String status); 23 | 24 | String getUserMobile(Long orderNo); 25 | String getDeliveryMobile(Long orderNo); 26 | String getUserId(Long orderNo); 27 | String getShopId(Long orderNo); 28 | Order getOrderDetail(String orderNo); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/OrderStatusService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service; 2 | 3 | import com.sell.modules.store.entity.OrderStatus; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author linyuc 9 | * @date 2020/3/1 18:30 10 | */ 11 | public interface OrderStatusService { 12 | boolean saveStatus(Long orderNo,String status); 13 | List getList(String orderNo); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/ProductCategoryService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.modules.store.dto.QueryProductDTO; 5 | import com.sell.modules.store.entity.ProductCategory; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author linyuc 11 | * @date 2020/1/16 18:50 12 | */ 13 | public interface ProductCategoryService { 14 | List getProductCategory(Integer shopId); 15 | 16 | /** 17 | * 商家查询自家店铺的商品分类 18 | * @param dto dto 19 | * @return 20 | */ 21 | PageInfo getCategoryList(QueryProductDTO dto); 22 | int saveProductCategory(String name); 23 | 24 | int updateProductCategory(ProductCategory category); 25 | 26 | /** 27 | * 批量假删 28 | * @param ids 29 | */ 30 | int deleteBatch(String ids); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.modules.store.dto.QueryProductDTO; 5 | import com.sell.modules.store.entity.Product; 6 | import com.sell.modules.store.vo.ProductVo; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author linyuc 12 | * @date 2020/1/20 16:34 13 | */ 14 | public interface ProductService { 15 | List getByCategory(Integer categoryId); 16 | int update(Product product); 17 | int saveProduct(Product product); 18 | PageInfo getProductList(QueryProductDTO dto); 19 | boolean checkStock(String name,Integer num); 20 | 21 | /** 22 | * 批量假删 23 | * @param ids 24 | */ 25 | int deleteBatch(String ids); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/RedisService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author linyuc 7 | * @date 2020/4/6 16:45 8 | */ 9 | public interface RedisService { 10 | // 加入元素 11 | void setValue(String key, Map value); 12 | // 加入元素 13 | void setValue(String key, String value); 14 | // 加入元素 15 | void setValue(String key, Object value); 16 | // 获取元素 17 | Object getMapValue(String key); 18 | // 获取元素 19 | Object getValue(String key); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/ShippingService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service; 2 | 3 | import com.sell.modules.store.entity.Shipping; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author linyuc 9 | * @date 2020/2/5 16:15 10 | */ 11 | public interface ShippingService { 12 | List getShippingList(Integer userId); 13 | int save(Shipping shipping); 14 | int update(Shipping shipping); 15 | Shipping getDefault(Integer userId); 16 | void updateDefault(Integer userId); 17 | Shipping getByOrderNo(String orderNo); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/ShopCategoryService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.modules.store.dto.QueryDTO; 5 | import com.sell.modules.store.dto.QueryProductDTO; 6 | import com.sell.modules.store.entity.ProductCategory; 7 | import com.sell.modules.store.entity.ShopCategory; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author linyuc 13 | * @date 2020/1/16 17:12 14 | */ 15 | public interface ShopCategoryService { 16 | 17 | List getSiblingCategory(Integer categoryId); 18 | PageInfo getCategoryList(QueryDTO dto); 19 | int saveShopCategory(String name); 20 | 21 | int updateShopCategory(ShopCategory category); 22 | 23 | /** 24 | * 批量假删 25 | * @param ids 26 | */ 27 | int deleteBatch(String ids); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/ShopService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Res; 5 | import com.sell.modules.store.dto.QueryDTO; 6 | import com.sell.modules.store.dto.ShopCountDTO; 7 | import com.sell.modules.store.entity.Delivery; 8 | import com.sell.modules.store.entity.Shop; 9 | import com.sell.modules.store.vo.ShopVo; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @author linyuc 15 | * @date 2020/1/20 10:04 16 | */ 17 | public interface ShopService { 18 | 19 | PageInfo getShopList(String name, Integer categoryId, Integer sortType,Integer pageNum); 20 | Shop getShopInfo(Integer id); 21 | int updateSelective(Shop shop); 22 | String getshopId(String userId); 23 | 24 | /** 25 | * 获取店铺首页统计信息 26 | * @return dto 27 | */ 28 | ShopCountDTO getShopCount(); 29 | /** 30 | * 查询最近12个月每个月的数据统计 31 | * @param shopId 32 | * @return 33 | */ 34 | List getLastYearCount(Integer shopId); 35 | /** 36 | * 管理端查询店铺列表 37 | */ 38 | PageInfo queryShopList(QueryDTO dto); 39 | /** 40 | * 批量假删 41 | * @param ids 42 | */ 43 | int deleteBatch(String ids); 44 | 45 | Res save(Shop delivery); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/impl/DeliveryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service.impl; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Const; 5 | import com.sell.common.Res; 6 | import com.sell.common.ResponseCode; 7 | import com.sell.modules.store.dao.DeliveryMapper; 8 | import com.sell.modules.store.dao.OrderMapper; 9 | import com.sell.modules.store.dto.QueryDTO; 10 | import com.sell.modules.store.entity.Delivery; 11 | import com.sell.modules.store.entity.Order; 12 | import com.sell.modules.store.service.DeliveryService; 13 | import com.sell.modules.sys.dao.UserMapper; 14 | import com.sell.modules.sys.entity.User; 15 | import com.sell.modules.sys.service.UserService; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.stereotype.Service; 18 | 19 | import java.util.List; 20 | import java.util.Random; 21 | import java.util.stream.Collectors; 22 | 23 | /** 24 | * @author linyuc 25 | * @date 2020/3/3 11:39 26 | */ 27 | @Service 28 | public class DeliveryServiceImpl implements DeliveryService { 29 | @Autowired 30 | private DeliveryMapper deliveryMapper; 31 | @Autowired 32 | private OrderMapper orderMapper; 33 | @Autowired 34 | private UserService userService; 35 | 36 | /** 37 | * 指派订单给骑手,匹配出相应的骑手,修改order表 38 | * @param orderNo 39 | * @return 40 | */ 41 | @Override 42 | public boolean updateAssign(String orderNo){ 43 | Delivery delivery = this.getBest(); 44 | Order order = new Order(); 45 | order.setOrderNo(Long.valueOf(orderNo)); 46 | order.setDeliveryId(delivery.getId()); 47 | order.setDeliveryName(delivery.getTrueName()); 48 | order.setStatus(Const.OrderStatus.SHOP_ACCEPT); 49 | int result = orderMapper.updateByPrimaryKeySelective(order); 50 | if(result >=1){ 51 | return true; 52 | } 53 | return false; 54 | } 55 | /** 56 | * 匹配最佳的骑手 57 | * @return Delivery 58 | */ 59 | @Override 60 | public Delivery getBest() { 61 | int count = deliveryMapper.selectCount(); 62 | //暂时使用随机匹配一个 63 | Random random = new Random(); 64 | int number = random.nextInt(count); 65 | return deliveryMapper.selectBest(number); 66 | } 67 | 68 | @Override 69 | public Delivery getInfo(Integer deliveryId) { 70 | return deliveryMapper.selectByUserId(deliveryId); 71 | } 72 | 73 | @Override 74 | public int update(Delivery delivery) { 75 | return deliveryMapper.updateByPrimaryKeySelective(delivery); 76 | } 77 | 78 | @Override 79 | public Res save(Delivery delivery) { 80 | delivery.setPassword("123456"); 81 | //先添加账号信息 82 | Res res = userService.insertRegister(delivery.getUsername(), delivery.getMobile(), delivery.getPassword(),3); 83 | if(res.getCode() == ResponseCode.ERROR.getCode()){ 84 | return res; 85 | } 86 | delivery.setUserId(res.getData()); 87 | deliveryMapper.insertSelective(delivery); 88 | return Res.successMsg("添加骑手账号成功"); 89 | } 90 | 91 | @Override 92 | public boolean updateTaskNum(Integer userId) { 93 | int result = deliveryMapper.updateTaskNumByUserId(userId); 94 | if(result == 1){ 95 | return true; 96 | } 97 | return false; 98 | } 99 | 100 | @Override 101 | public PageInfo getDeliveryList(QueryDTO dto) { 102 | Const.initPage(dto.getCurrent(),dto.getSize()); 103 | List list = deliveryMapper.selectDeliveryList(dto); 104 | return new PageInfo<>(list); 105 | } 106 | 107 | @Override 108 | public int deleteBatch(String ids) { 109 | List list = deliveryMapper.selectUserIdByDeliveryId(ids); 110 | String userIds = list.stream().map(String::valueOf).collect(Collectors.joining(",")); 111 | // 删除用户表对应用户 112 | userService.deleteBatch(userIds); 113 | return deliveryMapper.deleteBatch(ids); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/impl/FileServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service.impl; 2 | 3 | import com.sell.modules.store.service.FileService; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * @author linyuc 9 | * @date 2019/12/20 11:50 10 | */ 11 | @Service 12 | @Slf4j 13 | public class FileServiceImpl implements FileService { 14 | 15 | /** 16 | * 17 | * @param file 要上传的文件 18 | * @param path 路径 19 | * @return 返回上传完的文件名 20 | @Override 21 | public String upload(MultipartFile file, String path,String ftpPath){ 22 | String fileName = file.getOriginalFilename(); 23 | assert fileName != null; 24 | String fileExtensionName = fileName.substring(fileName.lastIndexOf(".")+1); 25 | String uploadFileName = UUID.randomUUID()+"."+fileExtensionName; 26 | log.info("开始上传文件,上传文件的文件名:{},上传的路径:{},新文件名:{}",fileName,path,uploadFileName); 27 | //该文件夹不存在就先创建 28 | File fileDir = new File(path); 29 | if(!fileDir.exists()){ 30 | //给权限 31 | fileDir.setWritable(true); 32 | fileDir.mkdirs(); 33 | } 34 | File targetFile = new File(path,uploadFileName); 35 | boolean b; 36 | try{ 37 | //先上传到tomcat服务器下的target下,再把target目录下的文件上传到ftp 38 | //file.transferTo(targetFile); 39 | //todo 将文件上传到我们的FTP服务器上 40 | b = FTPUtil.uploadFile(ftpPath,Lists.newArrayList(targetFile)); 41 | //已经上传到ftp服务器 42 | targetFile.delete(); 43 | //删除upload下面的文件,是tomcat服务器的文件夹,随着时间长,这个文件会越来越大 44 | }catch (IOException e){ 45 | log.error("上传文件到target异常",e); 46 | return null; 47 | } 48 | if(!b){ 49 | return null; 50 | } 51 | return targetFile.getName(); 52 | }*/ 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/impl/OrderCommentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service.impl; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Const; 5 | import com.sell.modules.store.dao.OrderCommentMapper; 6 | import com.sell.modules.store.dto.QueryCommentDTO; 7 | import com.sell.modules.store.entity.OrderComment; 8 | import com.sell.modules.store.service.OrderCommentService; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * @author linyuc 16 | * @date 2020/3/31 23:26 17 | */ 18 | @Service 19 | public class OrderCommentServiceImpl implements OrderCommentService { 20 | @Autowired 21 | private OrderCommentMapper orderCommentMapper; 22 | @Override 23 | public int save(OrderComment orderComment) { 24 | return orderCommentMapper.insertSelective(orderComment); 25 | } 26 | 27 | @Override 28 | public PageInfo list(QueryCommentDTO dto) { 29 | Const.initPage(dto.getPageNum(),dto.getPageSize()); 30 | List commentList = orderCommentMapper.selectOrderCommentList(dto); 31 | 32 | return new PageInfo<>(commentList); 33 | } 34 | 35 | @Override 36 | public int update(Long orderNo,String reply) { 37 | return orderCommentMapper.updateReplyByOrderId(orderNo,reply); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/impl/OrderItemServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service.impl; 2 | 3 | import com.sell.modules.store.dao.OrderItemMapper; 4 | import com.sell.modules.store.entity.OrderItem; 5 | import com.sell.modules.store.service.OrderItemService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author linyuc 13 | * @date 2020/3/1 17:22 14 | */ 15 | @Service 16 | public class OrderItemServiceImpl implements OrderItemService { 17 | @Autowired 18 | private OrderItemMapper orderItemMapper; 19 | @Override 20 | public int insert(OrderItem orderItem) { 21 | return orderItemMapper.insertSelective(orderItem); 22 | } 23 | 24 | @Override 25 | public List getList(String orderNo) { 26 | return orderItemMapper.selectListByOrderNo(orderNo); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/impl/OrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service.impl; 2 | 3 | import cn.hutool.core.date.DateUtil; 4 | import com.github.pagehelper.PageInfo; 5 | import com.sell.common.Const; 6 | import com.sell.modules.store.dao.OrderMapper; 7 | import com.sell.modules.store.dto.QueryOrderDTO; 8 | import com.sell.modules.store.entity.Order; 9 | import com.sell.modules.store.service.OrderService; 10 | import com.sell.modules.store.vo.Cart; 11 | import com.sell.modules.store.vo.DeliveryOrderVo; 12 | import com.sell.modules.store.vo.NewOrderVo; 13 | import com.sell.modules.store.vo.UserOrderVo; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.stereotype.Service; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | * @author linyuc 21 | * @date 2020/3/1 0:15 22 | */ 23 | @Service 24 | public class OrderServiceImpl implements OrderService { 25 | @Autowired 26 | private OrderMapper orderMapper; 27 | @Override 28 | public boolean save(Order order){ 29 | order.setPayType("1"); 30 | int result = orderMapper.insertSelective(order); 31 | if(result >= 1){ 32 | return true; 33 | } 34 | return false; 35 | } 36 | 37 | /** 38 | * 获取商家自己的订单列表 39 | 40 | */ 41 | @Override 42 | public PageInfo getOrderList(QueryOrderDTO dto) { 43 | Const.initPage(dto.getPageNum(), dto.getPageSize()); 44 | List orderList = orderMapper.selectNewOrderList(dto); 45 | return new PageInfo<>(orderList); 46 | } 47 | 48 | @Override 49 | public int updateStatusByOrderNo(Long orderNo,String status) { 50 | Order order = new Order(); 51 | order.setOrderNo(orderNo); 52 | order.setStatus(status); 53 | return orderMapper.updateByPrimaryKeySelective(order); 54 | } 55 | 56 | @Override 57 | public int update(Order order) { 58 | return orderMapper.updateByPrimaryKeySelective(order); 59 | } 60 | 61 | /** 62 | * 查询用户自己的订单列表 63 | */ 64 | @Override 65 | public PageInfo getUserOrderList(Integer userId,Integer deliveryId, String orderNo, String pageNum) { 66 | //先不分页 67 | /*int page = Const.PAGE_DEFAULT_NUM; 68 | if(!StringUtils.isBlank(pageNum)){ 69 | page = Integer.parseInt(pageNum); 70 | } 71 | PageHelper.startPage(page,Const.PAGE_DEFAULT_SIZE2);*/ 72 | List orderList = orderMapper.selectUserOrderList(userId,deliveryId,orderNo); 73 | //处理得到的商品信息和数量拼接成String字符串 74 | for(UserOrderVo order : orderList){ 75 | StringBuilder str = new StringBuilder(); 76 | for(Cart cart : order.getCarts()){ 77 | str.append(cart.getName()).append("×").append(cart.getNum()).append(","); 78 | } 79 | order.setCartStr(str.toString()); 80 | order.setCompleteTimeStr(DateUtil.formatDateTime(order.getCompleteTime())); 81 | } 82 | return new PageInfo<>(orderList); 83 | } 84 | 85 | /** 86 | * 获取骑手自己的订单,5个小时内 87 | */ 88 | @Override 89 | public List getDeliveryOrderList(Integer deliveryId, String status) { 90 | return orderMapper.selectDeliveryOrderList(deliveryId,status); 91 | } 92 | 93 | @Override 94 | public String getUserMobile(Long orderNo) { 95 | return orderMapper.selectUserMobile(orderNo); 96 | } 97 | 98 | @Override 99 | public String getDeliveryMobile(Long orderNo) { 100 | return orderMapper.selectDeliveryMobile(orderNo); 101 | } 102 | 103 | @Override 104 | public String getUserId(Long orderNo) { 105 | return orderMapper.selectUserId(orderNo); 106 | } 107 | 108 | @Override 109 | public String getShopId(Long orderNo) { 110 | return orderMapper.selectShopId(orderNo); 111 | } 112 | 113 | @Override 114 | public Order getOrderDetail(String orderNo) { 115 | return orderMapper.selectOrderByOrderNo(orderNo); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/impl/OrderStatusServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service.impl; 2 | 3 | import com.sell.modules.store.dao.OrderStatusMapper; 4 | import com.sell.modules.store.entity.OrderStatus; 5 | import com.sell.modules.store.service.OrderStatusService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author linyuc 13 | * @date 2020/3/1 18:30 14 | */ 15 | @Service 16 | public class OrderStatusServiceImpl implements OrderStatusService { 17 | @Autowired 18 | private OrderStatusMapper orderStatusMapper; 19 | @Override 20 | public boolean saveStatus(Long orderNo,String status) { 21 | OrderStatus orderStatus = new OrderStatus(); 22 | orderStatus.setOrderNo(orderNo); 23 | orderStatus.setStatus(status); 24 | int result = orderStatusMapper.insertSelective(orderStatus); 25 | if(result >= 1){ 26 | return true; 27 | } 28 | return false; 29 | } 30 | 31 | @Override 32 | public List getList(String orderNo) { 33 | return orderStatusMapper.selectList(Long.valueOf(orderNo)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/impl/ProductCategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service.impl; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Const; 5 | import com.sell.common.utils.UserUtils; 6 | import com.sell.modules.store.dao.ProductCategoryMapper; 7 | import com.sell.modules.store.dto.QueryProductDTO; 8 | import com.sell.modules.store.entity.ProductCategory; 9 | import com.sell.modules.store.service.ProductCategoryService; 10 | import org.apache.commons.lang3.StringUtils; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * @author linyuc 18 | * @date 2020/1/16 18:51 19 | */ 20 | @Service 21 | public class ProductCategoryServiceImpl implements ProductCategoryService { 22 | @Autowired 23 | private ProductCategoryMapper productCategoryMapper; 24 | 25 | /** 26 | * 查询指定商家的商品分类 27 | * @param shopId 28 | * @return 29 | */ 30 | @Override 31 | public List getProductCategory(Integer shopId){ 32 | QueryProductDTO dto = new QueryProductDTO(); 33 | dto.setShopId(shopId); 34 | return productCategoryMapper.selectCategoryList(dto); 35 | } 36 | 37 | @Override 38 | public PageInfo getCategoryList(QueryProductDTO dto) { 39 | Const.initPage(dto.getPageNum(),dto.getPageSize()); 40 | List list = productCategoryMapper.selectCategoryList(dto); 41 | return new PageInfo<>(list); 42 | } 43 | 44 | @Override 45 | public int saveProductCategory(String name){ 46 | if(StringUtils.isBlank(name)){ 47 | return -1; 48 | } 49 | ProductCategory productCategory = new ProductCategory(); 50 | //通过当前登录用户查找shopId 51 | productCategory.setShopId(UserUtils.getShopId()); 52 | productCategory.setName(name); 53 | return this.productCategoryMapper.insertSelective(productCategory); 54 | } 55 | @Override 56 | public int updateProductCategory(ProductCategory category){ 57 | return productCategoryMapper.updateByPrimaryKeySelective(category); 58 | } 59 | 60 | @Override 61 | public int deleteBatch(String ids) { 62 | return productCategoryMapper.deleteBatch(ids); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/impl/ProductServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service.impl; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Const; 5 | import com.sell.common.utils.UserUtils; 6 | import com.sell.modules.store.dao.ProductMapper; 7 | import com.sell.modules.store.dto.QueryProductDTO; 8 | import com.sell.modules.store.entity.Product; 9 | import com.sell.modules.store.service.ProductService; 10 | import com.sell.modules.store.vo.ProductVo; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * @author linyuc 18 | * @date 2020/1/20 16:35 19 | */ 20 | @Service 21 | public class ProductServiceImpl implements ProductService { 22 | @Autowired 23 | private ProductMapper productMapper; 24 | @Override 25 | public List getByCategory(Integer shopId){ 26 | return productMapper.selectProductListByCategory(shopId); 27 | } 28 | @Override 29 | public int update(Product product){ 30 | return productMapper.updateByPrimaryKeySelective(product); 31 | } 32 | @Override 33 | public int saveProduct(Product product){ 34 | product.setShopId(UserUtils.getUser().getShopId()); 35 | return productMapper.insertSelective(product); 36 | } 37 | @Override 38 | public PageInfo getProductList(QueryProductDTO dto){ 39 | Const.initPage(dto.getPageNum(),dto.getPageSize()); 40 | dto.setShopId(UserUtils.getShopId()); 41 | List productList = productMapper.selectProductList(dto); 42 | return new PageInfo<>(productList); 43 | } 44 | 45 | @Override 46 | public boolean checkStock(String name,Integer num) { 47 | Integer result = productMapper.checkStockByName(name, num); 48 | if(result >= 1){ 49 | return true; 50 | } 51 | return false; 52 | } 53 | 54 | @Override 55 | public int deleteBatch(String ids) { 56 | return productMapper.deleteBatch(ids); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/impl/RedisServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service.impl; 2 | 3 | import com.sell.modules.store.service.RedisService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.data.redis.core.RedisTemplate; 6 | import org.springframework.data.redis.core.StringRedisTemplate; 7 | import org.springframework.data.redis.core.ValueOperations; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.Map; 11 | import java.util.concurrent.TimeUnit; 12 | 13 | /** 14 | * @author linyuc 15 | * @date 2020/4/6 16:46 16 | */ 17 | @Service 18 | public class RedisServiceImpl implements RedisService { 19 | @Autowired 20 | private StringRedisTemplate stringRedisTemplate; 21 | @Autowired 22 | private RedisTemplate redisTemplate; 23 | 24 | 25 | @Override 26 | public void setValue(String key, Map value) { 27 | ValueOperations vo = redisTemplate.opsForValue(); 28 | vo.set(key, value); 29 | redisTemplate.expire(key, 1, TimeUnit.HOURS); // 这里指的是1小时后失效 30 | } 31 | 32 | @Override 33 | public Object getValue(String key) { 34 | ValueOperations vo = redisTemplate.opsForValue(); 35 | return vo.get(key); 36 | } 37 | 38 | @Override 39 | public void setValue(String key, String value) { 40 | ValueOperations vo = redisTemplate.opsForValue(); 41 | vo.set(key, value); 42 | redisTemplate.expire(key, 1, TimeUnit.HOURS); // 这里指的是1小时后失效 43 | } 44 | 45 | @Override 46 | public void setValue(String key, Object value) { 47 | ValueOperations vo = redisTemplate.opsForValue(); 48 | vo.set(key, value); 49 | redisTemplate.expire(key, 1, TimeUnit.HOURS); // 这里指的是1小时后失效 50 | } 51 | 52 | @Override 53 | public Object getMapValue(String key) { 54 | ValueOperations vo = redisTemplate.opsForValue(); 55 | return vo.get(key); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/impl/ShippingServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service.impl; 2 | 3 | import com.sell.common.Const; 4 | import com.sell.common.utils.CheckUtil; 5 | import com.sell.modules.store.dao.ShippingMapper; 6 | import com.sell.modules.store.entity.Shipping; 7 | import com.sell.modules.store.service.ShippingService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @author linyuc 15 | * @date 2020/2/5 16:16 16 | */ 17 | @Service 18 | public class ShippingServiceImpl implements ShippingService { 19 | @Autowired 20 | private ShippingMapper shippingMapper; 21 | @Override 22 | public List getShippingList(Integer userId) { 23 | return shippingMapper.selectListByUserId(userId); 24 | } 25 | 26 | @Override 27 | public int save(Shipping shipping) { 28 | shipping.setDelFlag(Const.NOT_DELETE); 29 | boolean b = CheckUtil.isMobile(shipping.getTel()); 30 | if(!b){ 31 | return 0; 32 | } 33 | return shippingMapper.insert(shipping); 34 | } 35 | 36 | @Override 37 | public int update(Shipping shipping) { 38 | return shippingMapper.updateByPrimaryKeySelective(shipping); 39 | } 40 | 41 | @Override 42 | public Shipping getDefault(Integer userId) { 43 | return shippingMapper.selectDefaultByUserId(userId); 44 | } 45 | 46 | /** 47 | * 改掉原来的默认地址 48 | */ 49 | @Override 50 | public void updateDefault(Integer userId) { 51 | shippingMapper.updateDefault(userId); 52 | } 53 | 54 | @Override 55 | public Shipping getByOrderNo(String orderNo) { 56 | return shippingMapper.selectByOrderNo(orderNo); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/impl/ShopCategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service.impl; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Const; 5 | import com.sell.modules.store.dao.ShopCategoryMapper; 6 | import com.sell.modules.store.dto.QueryDTO; 7 | import com.sell.modules.store.entity.ProductCategory; 8 | import com.sell.modules.store.entity.ShopCategory; 9 | import com.sell.modules.store.service.ShopCategoryService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * @author linyuc 17 | * @date 2020/1/16 17:13 18 | */ 19 | @Service 20 | public class ShopCategoryServiceImpl implements ShopCategoryService { 21 | @Autowired 22 | private ShopCategoryMapper shopCategoryMapper; 23 | @Override 24 | public List getSiblingCategory(Integer id){ 25 | return shopCategoryMapper.selectSiblingCategory(id); 26 | } 27 | 28 | @Override 29 | public PageInfo getCategoryList(QueryDTO dto) { 30 | Const.initPage(dto.getCurrent(),dto.getSize()); 31 | List list = shopCategoryMapper.selectShopCategoryList(dto); 32 | return new PageInfo<>(list); 33 | } 34 | 35 | @Override 36 | public int saveShopCategory(String name) { 37 | ShopCategory shopCategory = new ShopCategory(); 38 | shopCategory.setName(name); 39 | return shopCategoryMapper.insertSelective(shopCategory); 40 | } 41 | 42 | @Override 43 | public int updateShopCategory(ShopCategory category) { 44 | return shopCategoryMapper.updateByPrimaryKeySelective(category); 45 | } 46 | 47 | @Override 48 | public int deleteBatch(String ids) { 49 | return 0; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/service/impl/ShopServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.service.impl; 2 | 3 | import cn.hutool.core.date.DateUtil; 4 | import com.github.pagehelper.PageHelper; 5 | import com.github.pagehelper.PageInfo; 6 | import com.sell.common.Const; 7 | import com.sell.common.Res; 8 | import com.sell.common.ResponseCode; 9 | import com.sell.common.utils.UserUtils; 10 | import com.sell.modules.store.dao.ShopCategoryMapper; 11 | import com.sell.modules.store.dao.ShopMapper; 12 | import com.sell.modules.store.dto.QueryDTO; 13 | import com.sell.modules.store.dto.ShopCountDTO; 14 | import com.sell.modules.store.entity.Shop; 15 | import com.sell.modules.store.service.ShopService; 16 | import com.sell.modules.store.vo.ShopVo; 17 | import com.sell.modules.sys.service.UserService; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.stereotype.Service; 20 | 21 | import java.math.BigDecimal; 22 | import java.text.SimpleDateFormat; 23 | import java.util.*; 24 | import java.util.stream.Collectors; 25 | 26 | /** 27 | * @author linyuc 28 | * @date 2020/1/20 10:02 29 | */ 30 | @Service 31 | public class ShopServiceImpl implements ShopService { 32 | @Autowired 33 | private ShopMapper shopMapper; 34 | @Autowired 35 | private ShopCategoryMapper shopCategoryMapper; 36 | @Autowired 37 | private UserService userService; 38 | 39 | @Override 40 | public PageInfo getShopList(String name, Integer categoryId, Integer sortType,Integer pageNum){ 41 | String sort = Const.ShopList.ORDER_BY.get(sortType); 42 | //判断是否是顶级分类,如果是查找它的二级分类放到categoryIds里 43 | List categoryIds = new ArrayList<>(); 44 | if(categoryId != null){ 45 | categoryIds.add(categoryId); 46 | }else { 47 | categoryIds = null; 48 | } 49 | //给予选择的分页大小和分类 50 | PageHelper.startPage(pageNum,Const.PAGE_DEFAULT_SIZE2); 51 | List shopList = shopMapper.selectShopList(name, categoryIds, sort); 52 | return new PageInfo<>(shopList); 53 | } 54 | @Override 55 | public Shop getShopInfo(Integer id){ 56 | return shopMapper.selectByPrimaryKey(id); 57 | } 58 | @Override 59 | public int updateSelective(Shop shop){ 60 | return shopMapper.updateByPrimaryKeySelective(shop); 61 | } 62 | 63 | @Override 64 | public String getshopId(String userId) { 65 | return shopMapper.selectShopIdByUserId(userId); 66 | } 67 | 68 | @Override 69 | public ShopCountDTO getShopCount() { 70 | return shopMapper.selectShopCount(UserUtils.getShopId()); 71 | } 72 | 73 | @Override 74 | public List getLastYearCount(Integer shopId) { 75 | List list = shopMapper.getLastYearCount(shopId); 76 | //如果有某月份的数据为空进行处理 77 | if(list.size() < 12){ 78 | List monthList = list.stream().map(ShopCountDTO::getMonth).collect(Collectors.toList()); 79 | List allList = getLastSevMonth(); 80 | allList.removeAll(monthList); 81 | allList.forEach(month -> list.add(ShopCountDTO.builder().month(month) 82 | .salesTotal(new BigDecimal("0")).build())); 83 | return list.stream().sorted(Comparator.comparing(ShopCountDTO::getMonth)).collect(Collectors.toList()); 84 | } 85 | return list; 86 | } 87 | 88 | @Override 89 | public PageInfo queryShopList(QueryDTO dto) { 90 | Const.initPage(dto.getCurrent(),dto.getSize()); 91 | List list = shopMapper.selectAdminShopList(dto); 92 | return new PageInfo<>(list); 93 | } 94 | 95 | @Override 96 | public int deleteBatch(String ids) { 97 | List list = shopMapper.selectUserIdByShopId(ids); 98 | String userIds = list.stream().map(String::valueOf).collect(Collectors.joining(",")); 99 | // 删除用户表对应用户 100 | userService.deleteBatch(userIds); 101 | return shopMapper.deleteBatch(ids); 102 | } 103 | @Override 104 | public Res save(Shop shop) { 105 | shop.setPassword("123456"); 106 | //先添加账号信息 107 | Res res = userService.insertRegister(shop.getUsername(), shop.getMobile(), shop.getPassword(),2); 108 | if(res.getCode() == ResponseCode.ERROR.getCode()){ 109 | return res; 110 | } 111 | shop.setUserId(res.getData()); 112 | shop.setOpeningTime(DateUtil.parseTime("00:00:00")); 113 | shop.setClosingTime(DateUtil.parseTime("23:59:59")); 114 | shopMapper.insertSelective(shop); 115 | return Res.successMsg("添加商家店铺成功"); 116 | } 117 | 118 | List getLastSevMonth(){ 119 | List strings = new ArrayList<>(); 120 | SimpleDateFormat formatter = new SimpleDateFormat("yyyyMM"); 121 | Calendar calendar = Calendar.getInstance(); 122 | calendar.setTime(new Date()); 123 | strings.add(formatter.format(calendar.getTime())); 124 | for (int i = 0; i < 11; i++) { 125 | calendar.add(Calendar.MONTH, -1); 126 | strings.add(formatter.format(calendar.getTime())); 127 | } 128 | return strings; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/vo/Cart.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author linyuc 9 | * @date 2020/3/1 12:09 10 | */ 11 | @Data 12 | public class Cart implements Serializable { 13 | private static final long serialVersionUID = -4748335868054393795L; 14 | 15 | //num":1,"name":"饿了么宫廷套餐","logoImg":"http://sell.…7c5-44ea-ae4e-7c4797ef9993.png","sellPrice":155}]"}cart: "[{"num":1,"name":"饿了么宫廷套餐","logoImg":"http://sell.file.com/product/0372e42e-f509-43f5-a27b-5641c9eeb270.png","sellPrice":99},{"num":1,"name":"春节全家团员分享桶1", 16 | // "logoImg":"http://sell.file.com/product/7ad86273-07c5-44ea-ae4e-7c4797ef9993.png","sellPrice":155}]"__proto__: Object 17 | private String id; 18 | private Integer productId; 19 | private String name; 20 | private String logoImg; 21 | private Integer num; 22 | private String sellPrice; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/vo/DeliveryOrderVo.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | 8 | /** 9 | * @author linyuc 10 | * @date 2020/3/5 10:33 11 | */ 12 | @Data 13 | public class DeliveryOrderVo implements Serializable { 14 | private static final long serialVersionUID = 6144455599924303947L; 15 | 16 | private Integer id; 17 | private Long orderNo; 18 | private String userId; 19 | private String shopName; 20 | private String shopAddress; 21 | private String userAddress; 22 | private String username; 23 | private String mobile; 24 | private Integer deliveryTime; 25 | private BigDecimal deliveryCost; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/vo/NewOrderVo.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.vo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.math.BigDecimal; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 商家新的订单实体类 12 | * @author linyuc 13 | * @date 2020/3/2 14:08 14 | */ 15 | @JsonIgnoreProperties({"carts"}) 16 | @Data 17 | public class NewOrderVo implements Serializable { 18 | private static final long serialVersionUID = 4328147386951812730L; 19 | private String id; 20 | private Long orderNo; 21 | private String remark; 22 | private String username; 23 | private String deliveryName; 24 | private BigDecimal payMoney; 25 | private String status; 26 | private String address; 27 | private String cartStr; 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/vo/ProductVo.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.vo; 2 | 3 | import lombok.Data; 4 | import org.springframework.beans.factory.annotation.Value; 5 | 6 | import java.io.Serializable; 7 | import java.math.BigDecimal; 8 | 9 | /** 10 | * @author linyuc 11 | * @date 2020/1/20 16:51 12 | */ 13 | @Data 14 | public class ProductVo implements Serializable{ 15 | private static final long serialVersionUID = 2397081056042082197L; 16 | 17 | private Integer id; 18 | 19 | private Integer categoryId; 20 | 21 | private String categoryName; 22 | 23 | private String name; 24 | 25 | private String logoImg; 26 | 27 | private String remark; 28 | 29 | private BigDecimal originPrice; 30 | 31 | private BigDecimal sellPrice; 32 | //折扣 33 | private BigDecimal discount; 34 | //限购数量 35 | private Integer limitNum; 36 | 37 | private Integer monthlySales; 38 | //销售数量(返回给前端) 39 | private Integer sellNum = 0; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/vo/ShopVo.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | 7 | /** 8 | * @author linyuc 9 | * @date 2020/1/20 10:13 10 | */ 11 | @Data 12 | public class ShopVo { 13 | private String id; 14 | 15 | private String name; 16 | 17 | private String logoImg; 18 | 19 | private String address; 20 | 21 | private String tags; 22 | 23 | private BigDecimal sendCost; 24 | 25 | private BigDecimal deliveryCost; 26 | 27 | private Integer deliveryTime; 28 | 29 | private BigDecimal score; 30 | 31 | private Integer monthlySales; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/store/vo/UserOrderVo.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.store.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | import java.util.ArrayList; 8 | import java.util.Date; 9 | import java.util.List; 10 | 11 | /** 12 | * @author linyuc 13 | * @date 2020/3/3 15:20 14 | */ 15 | @Data 16 | public class UserOrderVo implements Serializable { 17 | private static final long serialVersionUID = -7552514319738161983L; 18 | 19 | private String id; 20 | private Long orderNo; 21 | private String shopId; 22 | private String shopLogo; 23 | private String shopName; 24 | private String status; 25 | private BigDecimal payMoney; 26 | private Date completeTime; 27 | private String cartStr; 28 | private String username; 29 | //扩展用 30 | private String completeTimeStr; 31 | private List carts = new ArrayList<>(); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/controller/FileController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.controller; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.sell.common.Const; 5 | import com.sell.common.Res; 6 | import com.sell.common.utils.FTPUtil; 7 | import com.sell.common.utils.PropertiesUtil; 8 | import com.sell.modules.store.service.FileService; 9 | import io.swagger.annotations.Api; 10 | import org.apache.commons.lang3.StringUtils; 11 | import org.apache.http.HttpRequest; 12 | import org.apache.ibatis.annotations.Param; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.web.bind.annotation.*; 15 | import org.springframework.web.multipart.MultipartFile; 16 | 17 | import javax.servlet.http.HttpServletRequest; 18 | import java.io.File; 19 | import java.math.BigDecimal; 20 | 21 | /** 22 | * @author linyuc 23 | * @date 2020/8/12 14:40 24 | * 模拟云盘 25 | */ 26 | @RestController 27 | @RequestMapping("file") 28 | @Api(tags = "文件上传相关接口") 29 | public class FileController { 30 | @Autowired 31 | private FTPUtil ftpUtil; 32 | @Autowired 33 | private FileService fileService; 34 | @PostMapping("upload") 35 | public Res upload(MultipartFile file, @RequestParam(defaultValue = "") String check)throws Exception{ 36 | if(file == null){ 37 | return Res.errorMsg("上传文件不能为空"); 38 | } 39 | /* if(!check.equals(Const.UPLOAD_CHECK)){ 40 | return Res.errorMsg("校验码错误"); 41 | }*/ 42 | Long start = System.currentTimeMillis(); 43 | boolean b = ftpUtil.uploadDailyFile(file.getOriginalFilename(),file.getInputStream(),Const.FTP_PATH_DAILY); 44 | Long end = System.currentTimeMillis(); 45 | System.out.println(end - start); 46 | if(b){ 47 | return Res.successMsg("上传文件成功"); 48 | } 49 | return Res.errorMsg("上传文件失败"); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/controller/LocationController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.controller; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Res; 5 | import com.sell.modules.sys.entity.Location; 6 | import com.sell.modules.sys.service.LocationService; 7 | import io.swagger.annotations.Api; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import java.math.BigDecimal; 15 | import java.util.List; 16 | 17 | /** 18 | * @author linyuc 19 | * @date 2020/9/2 18:03 20 | */ 21 | @RestController 22 | @RequestMapping("location") 23 | @Api(tags = "定位信息相关接口") 24 | public class LocationController { 25 | @Autowired 26 | private LocationService locationService; 27 | @PostMapping("save") 28 | public Res save(Location location){ 29 | System.out.println(location.toString()); 30 | location.setLat(new BigDecimal(location.getLatitude())); 31 | location.setLng(new BigDecimal(location.getLongitude())); 32 | int result = locationService.save(location); 33 | if(result == 0){ 34 | return Res.errorMsg("保存定位信息失败"); 35 | } 36 | return Res.successMsg("保存定位信息成功"); 37 | } 38 | @GetMapping("list") 39 | public Res> list(String pageNum){ 40 | PageInfo list = locationService.getList(pageNum); 41 | if(list.getSize() == 0){ 42 | return Res.errorMsg("未找到相关信息"); 43 | } 44 | return Res.success(list); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.controller; 2 | 3 | import com.sell.common.Const; 4 | import com.sell.common.Res; 5 | import com.sell.common.ResponseCode; 6 | import com.sell.common.utils.UserUtils; 7 | import com.sell.modules.sys.service.UserService; 8 | import io.swagger.annotations.Api; 9 | import org.apache.shiro.SecurityUtils; 10 | import org.apache.shiro.authc.*; 11 | import org.apache.shiro.subject.Subject; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | /** 19 | * @author linyuc 20 | * @date 2020/1/15 19:26 21 | */ 22 | @RestController 23 | @RequestMapping 24 | @Api(tags = "登录相关接口") 25 | public class LoginController { 26 | @Autowired 27 | private UserService userService; 28 | 29 | @GetMapping("login") 30 | public Res> login(String username, String password, String role){ 31 | UsernamePasswordToken token = new UsernamePasswordToken(username,password); 32 | Subject subject = SecurityUtils.getSubject(); 33 | Map info = new HashMap<>(); 34 | try { 35 | subject.login(token); 36 | if(!UserUtils.getRole().equals(role)){ 37 | subject.logout(); 38 | return Res.errorMsg("该账号角色与所登录角色不符!"); 39 | } 40 | /* //校验是否是商家账号 41 | if(Const.USER_ROLE_ADMIN.equals(UserUtils.getRole()) || Const.USER_ROLE_BUSINESS.equals(UserUtils.getRole())){ 42 | subject.logout(); 43 | return Res.errorMsg("该账号不是普通用户/骑手账号"); 44 | }*/ 45 | info.put("token",subject.getSession().getId()); 46 | info.put("userId",UserUtils.getUserId()); 47 | return Res.success("登录成功", info); 48 | }catch(UnknownAccountException | IncorrectCredentialsException e){ 49 | e.printStackTrace(); 50 | return Res.errorMsg("用户名或密码错误"); 51 | } catch (LockedAccountException e){ 52 | e.printStackTrace(); 53 | return Res.errorMsg("该账号已被禁用,请联系管理员"); 54 | }catch (AuthenticationException e){ 55 | e.printStackTrace(); 56 | return Res.errorMsg("登录异常,请联系管理员"); 57 | } 58 | } 59 | 60 | /** 61 | * 商家登录接口 62 | */ 63 | @GetMapping("business_login") 64 | public Res> shopLogin(String username, String password){ 65 | UsernamePasswordToken token = new UsernamePasswordToken(username,password); 66 | Subject subject = SecurityUtils.getSubject(); 67 | Map info = new HashMap<>(10); 68 | try { 69 | subject.login(token); 70 | //校验是否是商家账号 71 | if(Const.USER_ROLE_DELIVERY.equals(UserUtils.getRole()) || Const.USER_ROLE_CUSTOMER.equals(UserUtils.getRole())){ 72 | subject.logout(); 73 | return Res.errorMsg("该账号不是商家/管理员账号"); 74 | } 75 | info.put("token",subject.getSession().getId()); 76 | info.put("shopId",UserUtils.getShopId()); 77 | return Res.success("登录成功", info); 78 | }catch(UnknownAccountException | IncorrectCredentialsException e){ 79 | e.printStackTrace(); 80 | return Res.errorMsg("用户名或密码错误"); 81 | } catch (LockedAccountException e){ 82 | e.printStackTrace(); 83 | return Res.errorMsg("该账号已被禁用,请联系管理员"); 84 | }catch (AuthenticationException e){ 85 | e.printStackTrace(); 86 | return Res.errorMsg("登录异常,请联系管理员"); 87 | } 88 | } 89 | /** 90 | * 骑手登录接口 91 | */ 92 | @GetMapping("delivery_login") 93 | public Res> deliveryLogin(String username, String password){ 94 | UsernamePasswordToken token = new UsernamePasswordToken(username,password); 95 | Subject subject = SecurityUtils.getSubject(); 96 | Map info = new HashMap<>(10); 97 | try { 98 | subject.login(token); 99 | //校验是否是骑手账号 100 | if(!Const.USER_ROLE_DELIVERY.equals(UserUtils.getRole())){ 101 | subject.logout(); 102 | return Res.errorMsg("该账号不是骑手账号"); 103 | } 104 | info.put("token",subject.getSession().getId()); 105 | info.put("userId",UserUtils.getUser().getId()); 106 | return Res.success("登录成功", info); 107 | }catch(UnknownAccountException | IncorrectCredentialsException e){ 108 | e.printStackTrace(); 109 | return Res.errorMsg("用户名或密码错误"); 110 | } catch (LockedAccountException e){ 111 | e.printStackTrace(); 112 | return Res.errorMsg("该账号已被禁用,请联系管理员"); 113 | }catch (AuthenticationException e){ 114 | e.printStackTrace(); 115 | return Res.errorMsg("登录异常,请联系管理员"); 116 | } 117 | } 118 | 119 | @PostMapping("register") 120 | public Res register(String username, String mobile, String password){ 121 | return userService.insertRegister(username,mobile,password,1); 122 | } 123 | 124 | @GetMapping("/to_login") 125 | public Res toLogin(){ 126 | return Res.errorCodeMsg(ResponseCode.NEED_LOGIN.getCode(),"请先登录账号"); 127 | } 128 | @GetMapping("/unauthc") 129 | public Res unAuthor(){ 130 | return Res.errorCodeMsg(403,"当前用户没有操作权限"); 131 | } 132 | 133 | @GetMapping("/logout") 134 | public Res logout(){ 135 | Subject subject = SecurityUtils.getSubject(); 136 | subject.logout(); 137 | return Res.successMsg("退出成功"); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.controller; 2 | 3 | import com.sell.common.Res; 4 | import com.sell.modules.store.dao.ShopMapper; 5 | import com.sell.modules.store.service.ShopService; 6 | import com.sell.modules.sys.entity.User; 7 | import com.sell.modules.sys.security.WebSocket; 8 | import com.sell.modules.sys.service.UserService; 9 | import io.swagger.annotations.Api; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.GetMapping; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | /** 16 | * @author linyuc 17 | * @date 2019/12/30 9:23 18 | */ 19 | @RestController 20 | @RequestMapping("test") 21 | @Api(tags = "测试相关接口") 22 | public class TestController { 23 | @Autowired 24 | private UserService userService; 25 | @Autowired 26 | private WebSocket webSocket; 27 | 28 | 29 | @GetMapping("test") 30 | public Res test2() { 31 | return Res.successMsg("1111111"); 32 | } 33 | @GetMapping("sendAllWebSocket") 34 | public Res test1() { 35 | webSocket.sendAllMessage("清晨起来打开窗,心情美美哒~"); 36 | return Res.successMsg("websocket群体消息通知!"); 37 | } 38 | 39 | @GetMapping("sendOneWebSocket") 40 | public Res sendOneWebSocket() { 41 | webSocket.sendOneMessage("DPS007", "只要你乖给你买条gai!"); 42 | return Res.successMsg("websocket单人发送"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.controller; 2 | 3 | import com.sell.common.Const; 4 | import com.sell.common.Res; 5 | import com.sell.common.utils.FileUploadUtil; 6 | import com.sell.common.utils.UserUtils; 7 | import com.sell.modules.store.entity.Feedback; 8 | import com.sell.modules.store.service.OrderService; 9 | import com.sell.modules.store.service.OrderStatusService; 10 | import com.sell.modules.sys.dto.PasswordDTO; 11 | import com.sell.modules.sys.entity.User; 12 | import com.sell.modules.sys.security.WebSocket; 13 | import com.sell.modules.sys.service.UserService; 14 | import io.swagger.annotations.Api; 15 | import io.swagger.annotations.ApiOperation; 16 | import lombok.extern.slf4j.Slf4j; 17 | import org.apache.commons.lang3.StringUtils; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.web.bind.annotation.*; 20 | import org.springframework.web.multipart.MultipartFile; 21 | 22 | import java.io.IOException; 23 | 24 | /** 25 | * @author linyuc 26 | * @date 2019/12/18 15:10 27 | */ 28 | @Slf4j 29 | @RestController 30 | @CrossOrigin(origins="*",maxAge=3600) 31 | @RequestMapping("user") 32 | @Api(tags = "用户相关接口") 33 | public class UserController { 34 | @Autowired 35 | private UserService userService; 36 | @Autowired 37 | private OrderService orderService; 38 | @Autowired 39 | private OrderStatusService orderStatusService; 40 | @Autowired 41 | private WebSocket webSocket; 42 | @Autowired 43 | private FileUploadUtil fileUploadUtil; 44 | 45 | /** 46 | * 获取用户个人信息 47 | */ 48 | @GetMapping("info") 49 | @ApiOperation("获取用户个人信息") 50 | public Res info(){ 51 | User user = userService.selectByUsername(null,UserUtils.getUserId()); 52 | if(user == null){ 53 | return Res.errorMsg("找不到当前用户"); 54 | } 55 | return Res.success(user); 56 | } 57 | @PutMapping("update_head") 58 | @ApiOperation("修改个人头像") 59 | public Res updateHead(MultipartFile file) throws IOException { 60 | if(file == null){ 61 | return Res.errorMsg("上传头像为空"); 62 | } 63 | User user = new User(); 64 | user.setId(UserUtils.getUserId()); 65 | String url = fileUploadUtil.uploadFile(file); 66 | user.setHeadImg(url); 67 | int result = userService.update(user); 68 | if(result > 0){ 69 | return Res.errorMsg("修改头像成功"); 70 | } 71 | return Res.successMsg("修改头像失败"); 72 | } 73 | @PutMapping("update_mobile") 74 | @ApiOperation("修改手机号") 75 | public Res updateMobile(@RequestBody String mobile){ 76 | User user = new User(); 77 | user.setId(UserUtils.getUser().getId()); 78 | user.setMobile(mobile); 79 | return userService.updateMobile(user); 80 | } 81 | 82 | @PutMapping("update_name") 83 | @ApiOperation("修改用户名") 84 | public Res updateName(@RequestBody String username){ 85 | if(StringUtils.isBlank(username)){ 86 | return Res.errorMsg("用户名不能为空"); 87 | } 88 | return userService.updateUsername(User.builder() 89 | .id(UserUtils.getUserId()).username(username).build()); 90 | } 91 | 92 | @PutMapping("updatePwd") 93 | @ApiOperation("修改用户个人密码") 94 | public Res updatePassword(@RequestBody PasswordDTO dto){ 95 | return userService.updatePassword(dto); 96 | } 97 | 98 | /** 99 | * 未登录状态下忘记密码的重置密码 100 | * */ 101 | @PostMapping("rest_password") 102 | @ResponseBody 103 | public Res restPassword(String username,String passwordNew,String forgetToken){ 104 | return userService.restPassword(username,passwordNew,forgetToken); 105 | } 106 | @PostMapping("feedback") 107 | @ApiOperation("用户端-发送意见反馈") 108 | public Res feedback(@RequestBody Feedback feedback){ 109 | feedback.setUserId(UserUtils.getUserId()); 110 | int result = userService.saveFeedback(feedback); 111 | if(result == 0){ 112 | return Res.errorMsg("意见反馈失败"); 113 | } 114 | return Res.successMsg("意见反馈成功"); 115 | } 116 | @ApiOperation("用户确认收到餐操作") 117 | @PutMapping("sure") 118 | public Res fulfill(Long orderNo){ 119 | if(orderNo == null){ 120 | return Res.errorMsg("订单号参数错误"); 121 | } 122 | int result = orderService.updateStatusByOrderNo(orderNo, Const.OrderStatus.ACCOMPLISH); 123 | if(result == 0){ 124 | return Res.errorMsg("确认送达失败"); 125 | } 126 | boolean b2 = orderStatusService.saveStatus(orderNo,Const.OrderStatus.ACCOMPLISH); 127 | if(!b2){ 128 | return Res.errorMsg("确认送达失败"); 129 | } 130 | /* String shopId = orderService.getShopId(orderNo); 131 | webSocket.sendOneMessage(userId,"您有一条订单已送达,祝您用餐愉快"); 132 | webSocket.sendOneMessage(shopId,"您有一条订单已被骑手送达");*/ 133 | return Res.successMsg("确认送达成功"); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/dao/LocationMapper.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.dao; 2 | 3 | import com.sell.modules.sys.entity.Location; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | @Mapper 9 | public interface LocationMapper { 10 | int deleteByPrimaryKey(String id); 11 | 12 | int insert(Location record); 13 | 14 | int insertSelective(Location record); 15 | 16 | Location selectByPrimaryKey(String id); 17 | 18 | int updateByPrimaryKeySelective(Location record); 19 | 20 | int updateByPrimaryKey(Location record); 21 | 22 | List selectLocationList(); 23 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.dao; 2 | 3 | import com.sell.modules.store.dto.QueryDTO; 4 | import com.sell.modules.store.entity.Feedback; 5 | import com.sell.modules.sys.entity.Role; 6 | import com.sell.modules.sys.entity.User; 7 | import org.apache.ibatis.annotations.Mapper; 8 | import org.apache.ibatis.annotations.Param; 9 | 10 | import java.util.List; 11 | 12 | @Mapper 13 | public interface UserMapper { 14 | int insert(User record); 15 | 16 | int insertSelective(User record); 17 | int insertFeedback(Feedback feedback); 18 | 19 | User selectByPrimaryKey(Integer id); 20 | 21 | int updateByPrimaryKeySelective(User record); 22 | 23 | User selectByUsernameOrUserId(@Param("username") String username,@Param("userId") Integer userId); 24 | 25 | /** 26 | * 通过用户id获取对应角色信息 27 | * @param userId 28 | * @return 29 | */ 30 | Role selectRoleByUserId(String userId); 31 | 32 | /** 33 | * 查询用户列表 34 | * @param dto 35 | * @return 36 | */ 37 | List selectUserList(QueryDTO dto); 38 | 39 | /** 40 | * 添加普通用户的角色给用户 41 | */ 42 | int insertUserRole(@Param("userId")Integer userId,@Param("roleId")Integer roleId); 43 | 44 | int updateByPrimaryKey(User record); 45 | int checkUsername(String username); 46 | int checkMobile(String mobile); 47 | User selectLogin(@Param("username")String username,@Param("password")String password); 48 | int updatePasswordByUsername(@Param("username")String username,@Param("password")String password); 49 | int checkPassword(@Param("password")String password,@Param("userId")String userId); 50 | String selectUsernameByMobile(String phone); 51 | /** 52 | * 批量假删 53 | * @param ids 54 | * @return 55 | */ 56 | int deleteBatch(String ids); 57 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/dto/PasswordDTO.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author linyuc 9 | * @Description TODO 10 | * @date 2022/1/9 3:25 11 | */ 12 | @Data 13 | public class PasswordDTO implements Serializable { 14 | private static final long serialVersionUID = -4496599659421192593L; 15 | private String oldPassword; 16 | 17 | private String newPassword; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/entity/Location.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.math.BigDecimal; 6 | import java.util.Date; 7 | 8 | @Data 9 | public class Location { 10 | private String id; 11 | 12 | private Integer accuracy; 13 | 14 | private String locationType; 15 | 16 | private String address; 17 | 18 | private BigDecimal lat; 19 | 20 | private BigDecimal lng; 21 | 22 | private String info; 23 | 24 | private String message; 25 | 26 | private Date createTime; 27 | private long long1; 28 | 29 | private Long long2; 30 | 31 | //接收前端传值字段 32 | private String latitude; 33 | private String longitude; 34 | 35 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/entity/Permission.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 权限表,每个角色有哪些权限 9 | * @author linyuc 10 | * @date 2019/12/27 11:35 11 | */ 12 | @Data 13 | public class Permission implements Serializable { 14 | private static final long serialVersionUID = 6843973116522833281L; 15 | private String id; 16 | private String name; 17 | private String url; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/entity/Role.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.ArrayList; 7 | import java.util.HashSet; 8 | import java.util.List; 9 | import java.util.Set; 10 | 11 | /** 12 | * @author linyuc 13 | * @date 2019/12/27 11:28 14 | */ 15 | @Data 16 | public class Role implements Serializable { 17 | private static final long serialVersionUID = 2550610506071566713L; 18 | private String id; 19 | private String name; 20 | private List permissions = new ArrayList<>(); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.entity; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | import com.google.common.collect.Lists; 6 | import lombok.*; 7 | import org.apache.commons.lang3.StringUtils; 8 | 9 | import java.io.Serializable; 10 | import java.util.ArrayList; 11 | import java.util.Date; 12 | import java.util.List; 13 | 14 | /** 15 | * @author linyc 16 | * @date 2019/12/12 12:43 17 | */ 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @Builder 22 | @JsonIgnoreProperties({"openId","password","sex","updateTime"}) 23 | public class User implements Serializable { 24 | private static final long serialVersionUID = 7321352169002894594L; 25 | private Integer id; 26 | 27 | private Integer shopId; 28 | 29 | private Integer deliveryId; 30 | 31 | private String username; 32 | 33 | private String password; 34 | 35 | private String sex; 36 | 37 | private String mobile; 38 | 39 | private String headImg; 40 | 41 | private String status; 42 | 43 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8") 44 | private Date createTime; 45 | 46 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone = "GMT+8") 47 | private Date updateTime; 48 | 49 | private String[] roles; 50 | 51 | private List roleList = new ArrayList<>(); 52 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/security/AuthRealm.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.security; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.sell.common.Const; 5 | import com.sell.common.utils.CheckUtil; 6 | import com.sell.modules.sys.entity.Permission; 7 | import com.sell.modules.sys.entity.Role; 8 | import com.sell.modules.sys.entity.User; 9 | import com.sell.modules.sys.service.UserService; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.apache.shiro.authc.*; 12 | import org.apache.shiro.authz.AuthorizationInfo; 13 | import org.apache.shiro.authz.SimpleAuthorizationInfo; 14 | import org.apache.shiro.realm.AuthorizingRealm; 15 | import org.apache.shiro.subject.PrincipalCollection; 16 | import org.springframework.beans.BeanUtils; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.util.CollectionUtils; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | /** 24 | * 自定义Realm 25 | * @author linyuc 26 | * @date 2019/12/29 15:41 27 | */ 28 | @Slf4j 29 | public class AuthRealm extends AuthorizingRealm { 30 | 31 | @Autowired 32 | private UserService userService; 33 | /** 34 | * 授权 35 | */ 36 | @Override 37 | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { 38 | log.info("授权 doGetAuthorizationInfo"); 39 | //从session里拿user,查找该用户有哪些角色、权限 40 | Object o = principals.fromRealm(this.getClass().getName()).iterator().next(); 41 | //BeanUtils.copyProperties(o,user); 42 | //User user = userService.selectByUsername(null,o.toString()); 43 | User user = JSON.parseObject(o.toString(),User.class); 44 | /*之前里的方法 45 | User u = (User)principals.getPrimaryPrincipal(); 46 | User user = userService.selectByUsername(u.getUsername());*/ 47 | 48 | List permissionList = new ArrayList<>(); 49 | List roleList = user.getRoleList(); 50 | List roleNameList = new ArrayList<>(); 51 | if(!CollectionUtils.isEmpty(roleList)){ 52 | for(int i = 0;i permissions = role.getPermissions(); 58 | if(!CollectionUtils.isEmpty(permissions)){ 59 | for(int j = 0;j webSockets = new CopyOnWriteArraySet<>(); 27 | private static Map sessionPool = new HashMap<>(); 28 | 29 | @OnOpen 30 | public void onOpen(Session session, @PathParam(value = "id") String id) { 31 | this.session = session; 32 | webSockets.add(this); 33 | sessionPool.put(id, session); 34 | System.out.println("【websocket消息】用户:"+id+" 建立了新的连接,总数为:" + webSockets.size()); 35 | } 36 | 37 | @OnClose 38 | public void onClose() { 39 | webSockets.remove(this); 40 | System.out.println("【websocket消息】连接断开,总数为:" + webSockets.size()); 41 | } 42 | 43 | @OnMessage 44 | public void onMessage(String message) { 45 | System.out.println("【websocket消息】收到客户端消息:" + message); 46 | } 47 | 48 | // 此为广播消息 49 | public void sendAllMessage(String message) { 50 | for (WebSocket webSocket : webSockets) { 51 | System.out.println("【websocket消息】广播消息:" + message); 52 | try { 53 | webSocket.session.getAsyncRemote().sendText(message); 54 | } catch (Exception e) { 55 | e.printStackTrace(); 56 | } 57 | } 58 | } 59 | 60 | // 此为单点消息 61 | public void sendOneMessage(String id, String message) { 62 | 63 | Session session = sessionPool.get(id); 64 | if (session != null) { 65 | try { 66 | session.getAsyncRemote().sendText(message); 67 | } catch (Exception e) { 68 | e.printStackTrace(); 69 | } 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/service/LocationService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.modules.sys.entity.Location; 5 | 6 | /** 7 | * @author linyuc 8 | * @date 2020/9/2 18:02 9 | */ 10 | public interface LocationService { 11 | int save(Location location); 12 | PageInfo getList(String pageNum); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.sell.common.Res; 5 | import com.sell.modules.store.dto.QueryDTO; 6 | import com.sell.modules.store.entity.Feedback; 7 | import com.sell.modules.store.entity.ProductCategory; 8 | import com.sell.modules.sys.dto.PasswordDTO; 9 | import com.sell.modules.sys.entity.User; 10 | 11 | /** 12 | * @author linyuc 13 | * @date 2019/12/18 15:15 14 | */ 15 | public interface UserService { 16 | /** 17 | * 注册添加账号 18 | */ 19 | Res insertRegister(String username,String phone,String password, Integer roleId); 20 | Res updateMobile(User user); 21 | 22 | /** 23 | * 修改用户密码 24 | * @param dto dto 25 | * @return 26 | */ 27 | Res updatePassword(PasswordDTO dto); 28 | 29 | Res checkValid(String str, String type); 30 | 31 | Res restPassword(String username,String passwordNew,String forgetToken); 32 | 33 | 34 | User selectByUsername(String username, Integer userId); 35 | String selectUsernameByMobile(String mobile); 36 | 37 | int update(User user); 38 | int saveFeedback(Feedback feedback); 39 | 40 | Res updateUsername(User user); 41 | 42 | /** 43 | * 查询普通用户列表 44 | * @param dto 45 | * @return 46 | */ 47 | PageInfo getUserList(QueryDTO dto); 48 | /** 49 | * 批量假删 50 | * @param ids 51 | */ 52 | int deleteBatch(String ids); 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/sell/modules/sys/service/impl/LocationServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sell.modules.sys.service.impl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.sell.common.Const; 6 | import com.sell.modules.sys.dao.LocationMapper; 7 | import com.sell.modules.sys.entity.Location; 8 | import com.sell.modules.sys.service.LocationService; 9 | import org.apache.commons.lang3.StringUtils; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * @author linyuc 17 | * @date 2020/9/2 18:02 18 | */ 19 | @Service 20 | public class LocationServiceImpl implements LocationService { 21 | @Autowired 22 | private LocationMapper locationMapper; 23 | @Override 24 | public int save(Location location) { 25 | return locationMapper.insertSelective(location); 26 | } 27 | 28 | @Override 29 | public PageInfo getList(String pageNum) { 30 | int page = Const.PAGE_DEFAULT_NUM; 31 | if(!StringUtils.isBlank(pageNum)){ 32 | page = Integer.parseInt(pageNum); 33 | } 34 | PageHelper.startPage(page,Const.PAGE_DEFAULT_SIZE); 35 | List list = locationMapper.selectLocationList(); 36 | PageInfo pageResult = new PageInfo<>(list); 37 | return pageResult; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | myFile: 2 | path: /D:/file/ 3 | url: http://localhost:8086/file/ 4 | spring: 5 | datasource: 6 | druid: 7 | driver-class-name: com.mysql.cj.jdbc.Driver 8 | url: jdbc:mysql://localhost:3306/sell?serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true 9 | username: root 10 | password: lin123456 11 | #password: 123456 12 | initial-size: 10 13 | max-active: 100 14 | min-idle: 10 15 | max-wait: 60000 16 | pool-prepared-statements: true 17 | max-pool-prepared-statement-per-connection-size: 20 18 | time-between-eviction-runs-millis: 60000 19 | min-evictable-idle-time-millis: 300000 20 | test-while-idle: true 21 | test-on-borrow: false 22 | test-on-return: false 23 | stat-view-servlet: 24 | enabled: true 25 | url-pattern: /druid/* 26 | initialization-mode: always 27 | servlet: 28 | multipart: 29 | max-file-size: 10MB 30 | max-request-size: 10MB 31 | enabled: true 32 | jpa: 33 | show-sql: true 34 | # thymeleaf: 35 | # prefix: classpath:templates/ 36 | # suffix: .html 37 | # mode: HTML5 38 | # encoding: UTF-8 39 | # servlet: 40 | # content-type: text/html 41 | # cache: false 42 | redis: 43 | open: true # 是否开启redis缓存 true开启 false关闭 44 | database: 2 #有16个数据库,默认连接第几个 45 | host: localhost 46 | port: 6379 47 | # password: zongheng # 密码(默认为空) 48 | timeout: 60000ms # 连接超时时长(毫秒) 49 | jedis: 50 | pool: 51 | max-active: 100 # 连接池最大连接数(使用负值表示没有限制) 52 | max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) 53 | max-idle: 10 # 连接池中的最大空闲连接 54 | min-idle: 5 # 连接池中的最小空闲连接 55 | #七牛云配置 56 | qiniu: 57 | accessKey: 1 58 | secretKey: 1 59 | bucket: 1 60 | prefix: 1 61 | visitUrl: 1 -------------------------------------------------------------------------------- /src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | myFile: 2 | path: /docker/sell/file/ 3 | url: http://localhost:8086/file/ 4 | spring: 5 | datasource: 6 | druid: 7 | driver-class-name: com.mysql.cj.jdbc.Driver 8 | url: jdbc:mysql://localhost:3306/sell?serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true 9 | username: root 10 | password: root 11 | initial-size: 10 12 | max-active: 100 13 | min-idle: 10 14 | max-wait: 60000 15 | pool-prepared-statements: true 16 | max-pool-prepared-statement-per-connection-size: 20 17 | time-between-eviction-runs-millis: 60000 18 | min-evictable-idle-time-millis: 300000 19 | test-while-idle: true 20 | test-on-borrow: false 21 | test-on-return: false 22 | stat-view-servlet: 23 | enabled: true 24 | url-pattern: /druid/* 25 | initialization-mode: always 26 | servlet: 27 | multipart: 28 | max-file-size: 10MB 29 | max-request-size: 10MB 30 | enabled: true 31 | jpa: 32 | show-sql: true 33 | # thymeleaf: 34 | # prefix: classpath:templates/ 35 | # suffix: .html 36 | # mode: HTML5 37 | # encoding: UTF-8 38 | # servlet: 39 | # content-type: text/html 40 | # cache: false 41 | redis: 42 | open: true # 是否开启redis缓存 true开启 false关闭 43 | database: 0 #有16个数据库,默认连接第几个 44 | host: localhost 45 | port: 6379 46 | # password: zongheng # 密码(默认为空) 47 | timeout: 60000ms # 连接超时时长(毫秒) 48 | jedis: 49 | pool: 50 | max-active: 100 # 连接池最大连接数(使用负值表示没有限制) 51 | max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) 52 | max-idle: 10 # 连接池中的最大空闲连接 53 | min-idle: 5 # 连接池中的最小空闲连接 54 | qiniu: 55 | accessKey: 56 | secretKey: 57 | bucket: 58 | prefix: 59 | visitUrl: -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8086 3 | #mybatis三剑客配置 4 | mybatis: 5 | type-aliases-package: com.sell.modules.*.entity 6 | mapper-locations: classpath:mappers/*.xml 7 | #驼峰命名自动转换,打印sql语句 8 | configuration: 9 | map-underscore-to-camel-case: true 10 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 11 | mapper: 12 | identity: MYSQL 13 | not-empty: false 14 | pagehelper: 15 | helper-dialect: mysql 16 | reasonable: true 17 | support-methods-arguments: true 18 | params: count=countSql 19 | # 上传文件模式(本地:local,云:cloud) 20 | #uploadFileModel: cloud 21 | uploadFileModel: local 22 | spring: 23 | profiles: 24 | #active: prod 25 | active: dev 26 | -------------------------------------------------------------------------------- /src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | __ __ .__ __. ____ ____ ______ _______. _______ __ __ 2 | | | | | | \ | | \ \ / / / | / || ____|| | | | 3 | | | | | | \| | \ \/ / | ,----' | (----`| |__ | | | | 4 | | | | | | . ` | \_ _/ | | \ \ | __| | | | | 5 | | `----.| | | |\ | | | | `----. .----) | | |____ | `----.| `----. 6 | |_______||__| |__| \__| |__| \______| |_______/ |_______||_______||_______| from v1.0 7 | -------------------------------------------------------------------------------- /src/main/resources/init.sql: -------------------------------------------------------------------------------- 1 | select count(*) from sell_shop; -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | [%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n 7 | 8 | 9 | 10 | INFO 11 | 12 | 13 | 14 | 15 | 16 | ./logs/sell.log 17 | 18 | 19 | ./logs/sell.log.%d{yyyy-MM-dd}.gz 20 | 10 21 | 22 | 23 | [%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n 24 | 25 | 26 | 27 | 28 | 29 | 30 | ./logs/error.log 31 | 32 | ./logs/error.log.%d{yyyy-MM-dd}.gz 33 | 34 | 35 | 10 36 | 37 | 38 | [%d{HH:mm:ss.SSS}][%p][%c{40}][%t] %m%n 39 | 40 | 41 | ERROR 42 | ACCEPT 43 | DENY 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/main/resources/mappers/LocationMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | id, accuracy, location_type, address, lat, lng, info, message, create_time 19 | 20 | 26 | 27 | delete from sell_location 28 | where id = #{id,jdbcType=VARCHAR} 29 | 30 | 31 | insert into sell_location (id, accuracy, location_type, 32 | address, lat, lng, 33 | info, message, create_time 34 | ) 35 | values (#{id,jdbcType=VARCHAR}, #{accuracy,jdbcType=INTEGER}, #{locationType,jdbcType=VARCHAR}, 36 | #{address,jdbcType=VARCHAR}, #{lat,jdbcType=DECIMAL}, #{lng,jdbcType=DECIMAL}, 37 | #{info,jdbcType=VARCHAR}, #{message,jdbcType=VARCHAR}, now() 38 | ) 39 | 40 | 41 | insert into sell_location 42 | 43 | 44 | id, 45 | 46 | 47 | accuracy, 48 | 49 | 50 | location_type, 51 | 52 | 53 | address, 54 | 55 | 56 | lat, 57 | 58 | 59 | lng, 60 | 61 | 62 | info, 63 | 64 | 65 | message, 66 | 67 | create_time, 68 | 69 | 70 | 71 | #{id,jdbcType=VARCHAR}, 72 | 73 | 74 | #{accuracy,jdbcType=INTEGER}, 75 | 76 | 77 | #{locationType,jdbcType=VARCHAR}, 78 | 79 | 80 | #{address,jdbcType=VARCHAR}, 81 | 82 | 83 | #{lat,jdbcType=DECIMAL}, 84 | 85 | 86 | #{lng,jdbcType=DECIMAL}, 87 | 88 | 89 | #{info,jdbcType=VARCHAR}, 90 | 91 | 92 | #{message,jdbcType=VARCHAR}, 93 | 94 | now(), 95 | 96 | 97 | 98 | update sell_location 99 | 100 | 101 | accuracy = #{accuracy,jdbcType=INTEGER}, 102 | 103 | 104 | location_type = #{locationType,jdbcType=VARCHAR}, 105 | 106 | 107 | address = #{address,jdbcType=VARCHAR}, 108 | 109 | 110 | lat = #{lat,jdbcType=DECIMAL}, 111 | 112 | 113 | lng = #{lng,jdbcType=DECIMAL}, 114 | 115 | 116 | info = #{info,jdbcType=VARCHAR}, 117 | 118 | 119 | message = #{message,jdbcType=VARCHAR}, 120 | 121 | 122 | create_time = #{createTime,jdbcType=TIMESTAMP}, 123 | 124 | 125 | where id = #{id,jdbcType=VARCHAR} 126 | 127 | 128 | update sell_location 129 | set accuracy = #{accuracy,jdbcType=INTEGER}, 130 | location_type = #{locationType,jdbcType=VARCHAR}, 131 | address = #{address,jdbcType=VARCHAR}, 132 | lat = #{lat,jdbcType=DECIMAL}, 133 | lng = #{lng,jdbcType=DECIMAL}, 134 | info = #{info,jdbcType=VARCHAR}, 135 | message = #{message,jdbcType=VARCHAR}, 136 | create_time = #{createTime,jdbcType=TIMESTAMP} 137 | where id = #{id,jdbcType=VARCHAR} 138 | 139 | 143 | -------------------------------------------------------------------------------- /src/main/resources/mappers/OrderStatusMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | id, order_no, status, remark, create_time 15 | 16 | 22 | 23 | delete from sell_order_status 24 | where id = #{id,jdbcType=VARCHAR} 25 | 26 | 27 | insert into sell_order_status (id, order_no, status, 28 | remark, create_time) 29 | values (#{id,jdbcType=VARCHAR}, #{orderNo,jdbcType=BIGINT}, #{status,jdbcType=CHAR}, 30 | #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}) 31 | 32 | 33 | insert into sell_order_status 34 | 35 | 36 | id, 37 | 38 | 39 | order_no, 40 | 41 | 42 | status, 43 | 44 | 45 | remark, 46 | 47 | create_time, 48 | 49 | 50 | 51 | 52 | #{id,jdbcType=VARCHAR}, 53 | 54 | 55 | #{orderNo,jdbcType=BIGINT}, 56 | 57 | 58 | #{status,jdbcType=CHAR}, 59 | 60 | 61 | #{remark,jdbcType=VARCHAR}, 62 | 63 | now(), 64 | 65 | 66 | 67 | update sell_order_status 68 | 69 | 70 | order_no = #{orderNo,jdbcType=BIGINT}, 71 | 72 | 73 | status = #{status,jdbcType=CHAR}, 74 | 75 | 76 | remark = #{remark,jdbcType=VARCHAR}, 77 | 78 | 79 | create_time = #{createTime,jdbcType=TIMESTAMP}, 80 | 81 | 82 | where id = #{id,jdbcType=VARCHAR} 83 | 84 | 85 | update sell_order_status 86 | set order_no = #{orderNo,jdbcType=BIGINT}, 87 | status = #{status,jdbcType=CHAR}, 88 | remark = #{remark,jdbcType=VARCHAR}, 89 | create_time = #{createTime,jdbcType=TIMESTAMP} 90 | where id = #{id,jdbcType=VARCHAR} 91 | 92 | 98 | -------------------------------------------------------------------------------- /src/main/resources/mappers/ProductCategoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | id, parent_id, shop_id, name, status, sort, del_flag, create_time, update_time 19 | 20 | 26 | 27 | delete from sell_product_category 28 | where id = #{id,jdbcType=VARCHAR} 29 | 30 | 31 | insert into sell_product_category (id, parent_id, shop_id, 32 | name, status, sort) 33 | values (#{id,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, 34 | #{name,jdbcType=VARCHAR}, #{status,jdbcType=CHAR}, #{sort,jdbcType=INTEGER}) 35 | 36 | 37 | insert into sell_product_category 38 | 39 | 40 | id, 41 | 42 | 43 | parent_id, 44 | 45 | 46 | shop_id, 47 | 48 | 49 | name, 50 | 51 | 52 | status, 53 | 54 | 55 | sort 56 | 57 | 58 | 59 | 60 | #{id,jdbcType=VARCHAR}, 61 | 62 | 63 | #{parentId,jdbcType=VARCHAR}, 64 | 65 | 66 | #{shopId,jdbcType=VARCHAR}, 67 | 68 | 69 | #{name,jdbcType=VARCHAR}, 70 | 71 | 72 | #{status,jdbcType=CHAR}, 73 | 74 | 75 | #{sort,jdbcType=INTEGER} 76 | 77 | 78 | 79 | 80 | update sell_product_category 81 | 82 | 83 | parent_id = #{parentId,jdbcType=VARCHAR}, 84 | 85 | 86 | shop_id = #{shopId,jdbcType=VARCHAR}, 87 | 88 | 89 | name = #{name,jdbcType=VARCHAR}, 90 | 91 | 92 | status = #{status,jdbcType=CHAR}, 93 | 94 | 95 | sort = #{sort,jdbcType=INTEGER}, 96 | 97 | 98 | del_flag = #{delFlag,jdbcType=CHAR} 99 | 100 | 101 | where id = #{id,jdbcType=VARCHAR} 102 | 103 | 104 | update sell_product_category 105 | set parent_id = #{parentId,jdbcType=VARCHAR}, 106 | shop_id = #{shopId,jdbcType=VARCHAR}, 107 | name = #{name,jdbcType=VARCHAR}, 108 | status = #{status,jdbcType=CHAR}, 109 | sort = #{sort,jdbcType=INTEGER}, 110 | del_flag = #{delFlag,jdbcType=CHAR}, 111 | create_time = #{createTime,jdbcType=TIMESTAMP}, 112 | update_time = #{updateTime,jdbcType=TIMESTAMP} 113 | where id = #{id,jdbcType=VARCHAR} 114 | 115 | 123 | 124 | update sell_product_category set del_flag = 1 125 | where id in 126 | 127 | #{item} 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /src/main/resources/mappers/ShopCategoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id, parent_id, name, sort, del_flag, create_time, update_time 17 | 18 | 24 | 25 | delete from sell_shop_category 26 | where id = #{id,jdbcType=VARCHAR} 27 | 28 | 29 | insert into sell_shop_category (id, parent_id, name, 30 | sort, del_flag, create_time, 31 | update_time) 32 | values (#{id,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, 33 | #{sort,jdbcType=INTEGER}, #{delFlag,jdbcType=CHAR}, #{createTime,jdbcType=TIMESTAMP}, 34 | #{updateTime,jdbcType=TIMESTAMP}) 35 | 36 | 37 | insert into sell_shop_category 38 | 39 | 40 | id, 41 | 42 | 43 | parent_id, 44 | 45 | 46 | name, 47 | 48 | 49 | sort, 50 | 51 | 52 | del_flag, 53 | 54 | 55 | create_time, 56 | 57 | 58 | update_time, 59 | 60 | 61 | 62 | 63 | #{id,jdbcType=VARCHAR}, 64 | 65 | 66 | #{parentId,jdbcType=VARCHAR}, 67 | 68 | 69 | #{name,jdbcType=VARCHAR}, 70 | 71 | 72 | #{sort,jdbcType=INTEGER}, 73 | 74 | 75 | #{delFlag,jdbcType=CHAR}, 76 | 77 | 78 | #{createTime,jdbcType=TIMESTAMP}, 79 | 80 | 81 | #{updateTime,jdbcType=TIMESTAMP}, 82 | 83 | 84 | 85 | 86 | update sell_shop_category 87 | 88 | 89 | parent_id = #{parentId,jdbcType=VARCHAR}, 90 | 91 | 92 | name = #{name,jdbcType=VARCHAR}, 93 | 94 | 95 | sort = #{sort,jdbcType=INTEGER}, 96 | 97 | 98 | del_flag = #{delFlag,jdbcType=CHAR}, 99 | 100 | 101 | create_time = #{createTime,jdbcType=TIMESTAMP}, 102 | 103 | 104 | update_time = #{updateTime,jdbcType=TIMESTAMP}, 105 | 106 | 107 | where id = #{id,jdbcType=VARCHAR} 108 | 109 | 110 | update sell_shop_category 111 | set parent_id = #{parentId,jdbcType=VARCHAR}, 112 | name = #{name,jdbcType=VARCHAR}, 113 | sort = #{sort,jdbcType=INTEGER}, 114 | del_flag = #{delFlag,jdbcType=CHAR}, 115 | create_time = #{createTime,jdbcType=TIMESTAMP}, 116 | update_time = #{updateTime,jdbcType=TIMESTAMP} 117 | where id = #{id,jdbcType=VARCHAR} 118 | 119 | 125 | 129 | 130 | 138 | 139 | 140 | update sell_shop_category set del_flag = 1 141 | where id in 142 | 143 | #{item} 144 | 145 | 146 | -------------------------------------------------------------------------------- /src/main/resources/sell.properties: -------------------------------------------------------------------------------- 1 | 2 | ftp.serverIp=localhost 3 | ftp.user=admin 4 | ftp.pass=admin 5 | ftp.port=21 6 | ftp.prefix=http://localhost/ 7 | 8 | -------------------------------------------------------------------------------- /src/main/resources/templates/first.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | enenen 6 | 7 | 12 | 13 |

forward

14 |

${ha}

15 |

${ha}

16 |

${ha}

17 | 18 | var a = 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/templates/images/22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linycha/sell/62b387b488e7105c6afd90d041fac89592476f0f/src/main/resources/templates/images/22.png -------------------------------------------------------------------------------- /src/main/resources/templates/images/555.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linycha/sell/62b387b488e7105c6afd90d041fac89592476f0f/src/main/resources/templates/images/555.png -------------------------------------------------------------------------------- /src/main/resources/templates/images/商家端.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linycha/sell/62b387b488e7105c6afd90d041fac89592476f0f/src/main/resources/templates/images/商家端.png -------------------------------------------------------------------------------- /src/main/resources/templates/images/商家端2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linycha/sell/62b387b488e7105c6afd90d041fac89592476f0f/src/main/resources/templates/images/商家端2.jpg -------------------------------------------------------------------------------- /src/main/resources/templates/images/商家端3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linycha/sell/62b387b488e7105c6afd90d041fac89592476f0f/src/main/resources/templates/images/商家端3.png -------------------------------------------------------------------------------- /src/main/resources/templates/images/商家端5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linycha/sell/62b387b488e7105c6afd90d041fac89592476f0f/src/main/resources/templates/images/商家端5.png -------------------------------------------------------------------------------- /src/main/resources/templates/images/商家端6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linycha/sell/62b387b488e7105c6afd90d041fac89592476f0f/src/main/resources/templates/images/商家端6.png -------------------------------------------------------------------------------- /src/main/resources/templates/images/商家端7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linycha/sell/62b387b488e7105c6afd90d041fac89592476f0f/src/main/resources/templates/images/商家端7.png -------------------------------------------------------------------------------- /src/main/resources/templates/images/用户端.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linycha/sell/62b387b488e7105c6afd90d041fac89592476f0f/src/main/resources/templates/images/用户端.png -------------------------------------------------------------------------------- /src/main/resources/templates/images/用户端3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linycha/sell/62b387b488e7105c6afd90d041fac89592476f0f/src/main/resources/templates/images/用户端3.png -------------------------------------------------------------------------------- /src/main/resources/templates/images/用户端4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linycha/sell/62b387b488e7105c6afd90d041fac89592476f0f/src/main/resources/templates/images/用户端4.png -------------------------------------------------------------------------------- /src/main/resources/templates/images/骑手端.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linycha/sell/62b387b488e7105c6afd90d041fac89592476f0f/src/main/resources/templates/images/骑手端.png -------------------------------------------------------------------------------- /src/test/java/com/sell/DailyTest.java: -------------------------------------------------------------------------------- 1 | package com.sell; 2 | 3 | import com.sell.common.utils.FTPUtil; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | 6 | /** 7 | * @author linyuc 8 | * @date 2019/12/12 12:48 9 | */ 10 | //@SpringBootTest 11 | public class DailyTest { 12 | } 13 | --------------------------------------------------------------------------------