张延森 před 3 roky
rodič
revize
b6016c8017

+ 10
- 2
pom.xml Zobrazit soubor

@@ -10,9 +10,9 @@
10 10
 	</parent>
11 11
 	<groupId>com.yunzhi</groupId>
12 12
 	<artifactId>shigongli</artifactId>
13
-	<version>0.0.1</version>
13
+	<version>2.0.0</version>
14 14
 	<name>shigongli</name>
15
-	<description>Demo project for Spring Boot</description>
15
+	<description>Shi Gong Li</description>
16 16
 
17 17
 	<properties>
18 18
 		<java.version>1.8</java.version>
@@ -116,6 +116,14 @@
116 116
 		</dependency>
117 117
 		<!--excel end-->
118 118
 
119
+		<!--image thumbnailator start-->
120
+		<dependency>
121
+			<groupId>net.coobird</groupId>
122
+			<artifactId>thumbnailator</artifactId>
123
+			<version>[0.4, 0.5)</version>
124
+		</dependency>
125
+		<!--image thumbnailator end-->
126
+
119 127
 		<!--weixin-miniapp start-->
120 128
 		<dependency>
121 129
 			<groupId>com.github.binarywang</groupId>

+ 8
- 0
src/main/java/com/yunzhi/shigongli/common/DateUtils.java Zobrazit soubor

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.shigongli.common;
2 2
 
3
+import java.time.DayOfWeek;
3 4
 import java.time.Duration;
4 5
 import java.time.LocalDateTime;
5 6
 import java.time.format.DateTimeFormatter;
@@ -19,4 +20,11 @@ public class DateUtils {
19 20
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formater);
20 21
         return dt.format(formatter);
21 22
     }
23
+
24
+    public static String weekDay(LocalDateTime dt) {
25
+        String[] week = new String[]{"一", "二", "三", "四", "五", "六", "日"};
26
+        DayOfWeek dayOfWeek = dt.getDayOfWeek();
27
+        int inx = dayOfWeek.getValue() - 1;
28
+        return String.format("星期%s", week[inx]);
29
+    }
22 30
 }

+ 105
- 0
src/main/java/com/yunzhi/shigongli/common/ImageUtils.java Zobrazit soubor

@@ -0,0 +1,105 @@
1
+package com.yunzhi.shigongli.common;
2
+
3
+import com.yunzhi.shigongli.vo.AMapWeather;
4
+import net.coobird.thumbnailator.Thumbnails;
5
+import net.coobird.thumbnailator.filters.Caption;
6
+import net.coobird.thumbnailator.geometry.Coordinate;
7
+import net.coobird.thumbnailator.geometry.Positions;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.stereotype.Component;
10
+
11
+import javax.imageio.ImageIO;
12
+import java.awt.*;
13
+import java.awt.image.BufferedImage;
14
+import java.io.IOException;
15
+import java.io.PipedInputStream;
16
+import java.io.PipedOutputStream;
17
+import java.net.MalformedURLException;
18
+import java.net.URL;
19
+import java.time.LocalDateTime;
20
+
21
+@Component
22
+public class ImageUtils {
23
+
24
+    @Autowired
25
+    OSSUtils ossUtils;
26
+
27
+    public String renderWeatherPic(AMapWeather.Live weather, String backImageUrl) throws IOException {
28
+        LocalDateTime now = LocalDateTime.now();
29
+        String area = weather.getAdcode();
30
+        String nmDate = DateUtils.toString(LocalDateTime.now(), "yyyyMMddHHmm");
31
+        String fname = String.format("weather-%s-%s.jpg", area, nmDate);
32
+
33
+        // 颜色
34
+        Color color = Color.white;
35
+
36
+        // 字体
37
+        String fontName = "Microsoft YaHei";
38
+
39
+        // 城市
40
+        Font font1 = new Font(fontName, Font.BOLD, 40);
41
+        Caption city = new Caption(weather.getCity(), font1, color, new Coordinate(124, 272 + 20), 0); // + 20 为字体大小的一半
42
+
43
+        // 天气现象
44
+        Font font2 = new Font(fontName, Font.BOLD, 40);
45
+        Caption wthName = new Caption(weather.getWeather(), font2, color, new Coordinate(378, 190 + 20), 0);
46
+
47
+        // 温度
48
+        Font font3 = new Font(fontName, Font.BOLD, 130);
49
+        Caption temperature = new Caption(weather.getTemperature() + "℃", font3, color, new Coordinate(84, 118 + 50), 0);
50
+
51
+        // 湿度
52
+        Font font4 = new Font(fontName, Font.BOLD, 32);
53
+        int y4 = 540 + 30;
54
+        Caption humidity = new Caption(weather.getHumidity() + "%", font4, color, new Coordinate(338, y4), 0);
55
+
56
+        // 风向
57
+        String wind = weather.getWinddirection() + "风 " + weather.getWindpower() + "级";
58
+        Caption winddirection = new Caption(wind, font4, color, new Coordinate(78, y4), 0);
59
+
60
+        // 日期
61
+        String dateStr = DateUtils.toString(now, "MM/dd");
62
+        String week = DateUtils.weekDay(now);
63
+        Caption date = new Caption(dateStr + " " + week, font4, color, new Coordinate(500, y4), 0);
64
+
65
+        // 绘制图片
66
+        PipedInputStream inputStream = new PipedInputStream();
67
+        PipedOutputStream out = new PipedOutputStream(inputStream);
68
+
69
+        new Thread(new Runnable() {
70
+            public void run () {
71
+                try {
72
+                    Thumbnails.of(new URL(backImageUrl))
73
+                            .crop(Positions.CENTER)
74
+                            .size(760, 600)
75
+                            .addFilter(city)
76
+                            .addFilter(wthName)
77
+                            .addFilter(temperature)
78
+                            .addFilter(humidity)
79
+                            .addFilter(winddirection)
80
+                            .addFilter(date)
81
+                            .outputQuality(0.92)
82
+                            .imageType(BufferedImage.TYPE_INT_ARGB)     // 预防 PNG 变黑的 BUG
83
+                            .toOutputStream(out);
84
+                }
85
+                catch (IOException e) {
86
+                    e.printStackTrace();
87
+                }
88
+                finally {
89
+                    try {
90
+                        out.close();
91
+                    } catch (IOException e) {
92
+                        e.printStackTrace();
93
+                    }
94
+                }
95
+            }
96
+        }).start();
97
+
98
+        String image = ossUtils.putObject(inputStream, fname);
99
+        inputStream.close();
100
+
101
+        return image;
102
+    }
103
+
104
+
105
+}

+ 8
- 0
src/main/java/com/yunzhi/shigongli/common/OSSUtils.java Zobrazit soubor

@@ -69,6 +69,13 @@ public class OSSUtils {
69 69
         return putFile(nwFName, inputStream);
70 70
     }
71 71
 
72
+    public String putObject(InputStream inputStream, String fName, String ... toDirs) {
73
+        String toDir = getUploadPath(toDirs);
74
+        String nwFName = toDir + fName;
75
+        nwFName = StringUtils.trim(nwFName,"/");
76
+        return putFile(nwFName, inputStream);
77
+    }
78
+
72 79
     private String formatFileName(String fName) {
73 80
         return StringUtils.ifNull(fName, StringUtils.random(16) + ".png");
74 81
     }
@@ -129,4 +136,5 @@ public class OSSUtils {
129 136
             throw new Exception(e.getMessage());
130 137
         }
131 138
     }
139
+
132 140
 }

+ 49
- 0
src/main/java/com/yunzhi/shigongli/common/Weather.java Zobrazit soubor

@@ -0,0 +1,49 @@
1
+package com.yunzhi.shigongli.common;
2
+
3
+import com.yunzhi.shigongli.vo.AMapWeather;
4
+import lombok.extern.slf4j.Slf4j;
5
+import org.springframework.beans.factory.annotation.Value;
6
+import org.springframework.http.HttpMethod;
7
+import org.springframework.http.HttpStatus;
8
+import org.springframework.http.ResponseEntity;
9
+import org.springframework.stereotype.Component;
10
+import org.springframework.web.client.RestTemplate;
11
+
12
+@Slf4j
13
+@Component
14
+public class Weather {
15
+
16
+    @Value("${amap.weather.api}")
17
+    String api;
18
+
19
+    public AMapWeather getWeather(String areaId) throws Exception {
20
+        RestTemplate restTemplate = new RestTemplate();
21
+
22
+        String url = String.format(api, areaId);
23
+
24
+        log.debug("请求高德天气接口: {}", url);
25
+
26
+        ResponseEntity<AMapWeather> response = restTemplate.exchange(url, HttpMethod.GET, null, AMapWeather.class);
27
+        if (null == response) {
28
+            throw new Exception("请求天气接口异常");
29
+        }
30
+
31
+        HttpStatus statusCode = response.getStatusCode();
32
+        boolean isSuccessful = statusCode.is2xxSuccessful();
33
+        if (!isSuccessful) {
34
+            log.error("请求天气接口[{}]出错, [{}]", url, statusCode.toString());
35
+            throw new Exception("请求天气接口失败: " + statusCode.getReasonPhrase());
36
+        }
37
+
38
+        AMapWeather result = response.getBody();
39
+
40
+        log.debug("高德天气接口返回: {}", result.toString());
41
+
42
+        if (!"1".equals(result.getStatus())) {
43
+            log.error("高德天气接口错误: {}", result.toString());
44
+            throw new Exception("请求天气接口错误: " + result.getInfocode());
45
+        }
46
+
47
+        return result;
48
+    }
49
+}

+ 18
- 7
src/main/java/com/yunzhi/shigongli/controller/TaHotelController.java Zobrazit soubor

@@ -105,13 +105,13 @@ public class TaHotelController extends BaseController {
105 105
     public ResponseBean taHotelUpdate(@ApiParam("对象ID") @PathVariable String id,
106 106
                                         @ApiParam("更新内容") @RequestBody TaHotel taHotel) throws Exception{
107 107
 
108
-        boolean exists = iTaHotelService.isExisted(TaHotel::getHotelName,
109
-                taHotel.getHotelName(),
110
-                TaHotel::getHotelId,
111
-                taHotel.getHotelId());
112
-        if (exists) {
113
-            return ResponseBean.error("民宿名称已存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
114
-        }
108
+//        boolean exists = iTaHotelService.isExisted(TaHotel::getHotelName,
109
+//                taHotel.getHotelName(),
110
+//                TaHotel::getHotelId,
111
+//                taHotel.getHotelId());
112
+//        if (exists) {
113
+//            return ResponseBean.error("民宿名称已存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
114
+//        }
115 115
 
116 116
         if (iTaHotelService.updateById(taHotel)){
117 117
             return ResponseBean.success(iTaHotelService.getById(id));
@@ -129,4 +129,15 @@ public class TaHotelController extends BaseController {
129 129
     public ResponseBean taHotelGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
130 130
         return ResponseBean.success(iTaHotelService.getById(id));
131 131
     }
132
+
133
+
134
+    /**
135
+     * 根据id查询对象
136
+     * @param id  实体ID
137
+     */
138
+    @RequestMapping(value="/wx/hotel/{id}",method= RequestMethod.GET)
139
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
140
+    public ResponseBean getWxDetail(@ApiParam("对象ID") @PathVariable String id) throws Exception{
141
+        return ResponseBean.success(iTaHotelService.getById(id));
142
+    }
132 143
 }

+ 10
- 3
src/main/java/com/yunzhi/shigongli/controller/TaOrderSubController.java Zobrazit soubor

@@ -47,10 +47,9 @@ public class TaOrderSubController extends BaseController {
47 47
      * @param pageSize
48 48
      * @return
49 49
      */
50
-    @RequestMapping(value="/{plat}/taOrderSub",method= RequestMethod.GET)
50
+    @RequestMapping(value="/admin/taOrderSub",method= RequestMethod.GET)
51 51
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
52
-    public ResponseBean taOrderSubList(@ApiParam(value = "客户端", allowableValues = "wx,admin") @PathVariable String plat,
53
-                                       @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
+    public ResponseBean taOrderSubList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
54 53
                                        @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
55 54
 
56 55
 		    IPage<TaOrderSub> pg = new Page<>(pageNum, pageSize);
@@ -172,4 +171,12 @@ public class TaOrderSubController extends BaseController {
172 171
 //    public ResponseBean taOrderSubGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
173 172
 //        return ResponseBean.success(iTaOrderSubService.getById(id));
174 173
 //    }
174
+
175
+    @GetMapping("/wx/orderSub")
176
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = TaOrderSub.class)
177
+    public ResponseBean getWxMyOrders(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
178
+                                      @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
179
+                                      @ApiParam("状态") @RequestParam(value ="status", required = false) Integer status) {
180
+        return ResponseBean.success(null);
181
+    }
175 182
 }

+ 60
- 11
src/main/java/com/yunzhi/shigongli/controller/TaRoomOrderController.java Zobrazit soubor

@@ -3,22 +3,24 @@ package com.yunzhi.shigongli.controller;
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
-import com.yunzhi.shigongli.common.BaseController;
7
-import com.yunzhi.shigongli.common.ResponseBean;
6
+import com.yunzhi.shigongli.common.*;
7
+import com.yunzhi.shigongli.entity.TaHotel;
8
+import com.yunzhi.shigongli.entity.TaRoom;
9
+import com.yunzhi.shigongli.service.ITaHotelService;
10
+import com.yunzhi.shigongli.service.ITaRoomService;
11
+import com.yunzhi.shigongli.vo.AMapWeather;
8 12
 import io.swagger.annotations.Api;
9 13
 import io.swagger.annotations.ApiOperation;
10 14
 import io.swagger.annotations.ApiParam;
11 15
 import org.slf4j.Logger;
12 16
 import org.slf4j.LoggerFactory;
13 17
 import org.springframework.beans.factory.annotation.Autowired;
14
-import org.springframework.web.bind.annotation.PathVariable;
15
-import org.springframework.web.bind.annotation.RequestBody;
16
-import org.springframework.web.bind.annotation.RequestMapping;
17
-import org.springframework.web.bind.annotation.RequestMethod;
18
-import org.springframework.web.bind.annotation.RequestParam;
18
+import org.springframework.beans.factory.annotation.Value;
19
+import org.springframework.web.bind.annotation.*;
19 20
 import com.yunzhi.shigongli.service.ITaRoomOrderService;
20 21
 import com.yunzhi.shigongli.entity.TaRoomOrder;
21
-import org.springframework.web.bind.annotation.RestController;
22
+
23
+import java.time.LocalDateTime;
22 24
 
23 25
 /**
24 26
  * <p>
@@ -39,6 +41,20 @@ public class TaRoomOrderController extends BaseController {
39 41
     @Autowired
40 42
     public ITaRoomOrderService iTaRoomOrderService;
41 43
 
44
+    @Autowired
45
+    public ITaRoomService iTaRoomService;
46
+
47
+    @Autowired
48
+    public ITaHotelService iTaHotelService;
49
+
50
+    @Autowired
51
+    public Weather weatherUtil;
52
+
53
+    @Autowired
54
+    public ImageUtils imageUtils;
55
+
56
+    @Value("${amap.weather.backImage}")
57
+    private String backImage;
42 58
 
43 59
     /**
44 60
      * 分页查询列表
@@ -64,11 +80,35 @@ public class TaRoomOrderController extends BaseController {
64 80
      * @param taRoomOrder 实体对象
65 81
      * @return
66 82
      */
67
-    @RequestMapping(value="/admin/taRoomOrder",method= RequestMethod.POST)
68
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean taRoomOrderAdd(@ApiParam("保存内容") @RequestBody TaRoomOrder taRoomOrder) throws Exception{
83
+    @RequestMapping(value="/wx/roomOrder",method= RequestMethod.POST)
84
+    @ApiOperation(value="房源订单", notes = "房源订单", httpMethod = "POST", response = ResponseBean.class)
85
+    public ResponseBean taRoomOrderAdd(@ApiParam("房源订单") @RequestBody TaRoomOrder taRoomOrder) throws Exception{
86
+
87
+        String roomId = taRoomOrder.getRoomId();
88
+        if (StringUtils.isEmpty(roomId)) {
89
+            return ResponseBean.error("房源不存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
90
+        }
91
+        TaRoom taRoom = iTaRoomService.getById(roomId);
92
+        if (null == taRoom || !Constants.STATUS_NORMAL.equals(taRoom.getStatus())) {
93
+            return ResponseBean.error("房源不存在或者状态异常", ResponseBean.ERROR_ILLEGAL_PARAMS);
94
+        }
95
+//        TaHotel taHotel = iTaHotelService.getById(taRoom.getHotelId());
96
+//        if (null == taHotel || !Constants.STATUS_NORMAL.equals(taHotel.getStatus())) {
97
+//            return ResponseBean.error("民宿不存在或者状态异常", ResponseBean.ERROR_ILLEGAL_PARAMS);
98
+//        }
99
+
100
+        // 地区暂时是南京市秦淮区
101
+        AMapWeather weather = weatherUtil.getWeather("320104");
102
+        AMapWeather.Live live = weather.getLives().get(0);
103
+        String image = imageUtils.renderWeatherPic(live, String.format(backImage, "晴"));
104
+
105
+        taRoomOrder.setHotelId(taRoom.getHotelId());
106
+        taRoomOrder.setSharePerson(getCurrentPerson().getPersonId());
107
+        taRoomOrder.setStatus(Constants.STATUS_READY);
108
+        taRoomOrder.setCreateDate(LocalDateTime.now());
70 109
 
71 110
         if (iTaRoomOrderService.save(taRoomOrder)){
111
+            taRoomOrder.setShareImage(image);
72 112
             return ResponseBean.success(taRoomOrder);
73 113
         }else {
74 114
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
@@ -116,4 +156,13 @@ public class TaRoomOrderController extends BaseController {
116 156
 //    public ResponseBean taRoomOrderGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117 157
 //        return ResponseBean.success(iTaRoomOrderService.getById(id));
118 158
 //    }
159
+
160
+    @GetMapping("/test-weather")
161
+    public ResponseBean testWeather() throws Exception {
162
+        AMapWeather weather = weatherUtil.getWeather("320105");
163
+
164
+        String image = imageUtils.renderWeatherPic(weather.getLives().get(0), "https://yz-shigongli.oss-cn-shanghai.aliyuncs.com/images/weather/background_%E6%99%B4.png");
165
+
166
+        return ResponseBean.success(image);
167
+    }
119 168
 }

+ 49
- 0
src/main/java/com/yunzhi/shigongli/controller/TaShopController.java Zobrazit soubor

@@ -130,6 +130,55 @@ public class TaShopController extends BaseController {
130 130
         }
131 131
     }
132 132
 
133
+
134
+    /**
135
+     * 商铺营业
136
+     * @param id  实体ID
137
+     * @return
138
+     */
139
+    @RequestMapping(value="/admin/taShop/{id}/on",method= RequestMethod.PUT)
140
+    @ApiOperation(value="商铺营业", notes = "商铺营业", httpMethod = "PUT", response = ResponseBean.class)
141
+    public ResponseBean publish(@ApiParam("对象ID") @PathVariable String id) throws Exception {
142
+
143
+        TaShop taShop = iTaShopService.getById(id);
144
+        taShop.setStatus(Constants.STATUS_NORMAL);
145
+
146
+        if (iTaShopService.updateById(taShop)){
147
+            TaResource taResource = taResourceService.getByTarget(Constants.TARGET_SHOP, id);
148
+            taResource.setStatus(taShop.getStatus());
149
+            taResourceService.updateById(taResource);
150
+
151
+            return ResponseBean.success(taShop);
152
+        }else {
153
+            return ResponseBean.error("发布失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
154
+        }
155
+    }
156
+
157
+    /**
158
+     * 商铺关闭
159
+     * @param id  实体ID
160
+     * @return
161
+     */
162
+    @RequestMapping(value="/admin/taShop/{id}/off",method= RequestMethod.PUT)
163
+    @ApiOperation(value="商铺关闭", notes = "商铺关闭", httpMethod = "PUT", response = ResponseBean.class)
164
+    public ResponseBean unPublish(@ApiParam("对象ID") @PathVariable String id) throws Exception {
165
+
166
+        TaShop taShop = iTaShopService.getById(id);
167
+        taShop.setStatus(Constants.STATUS_READY);
168
+
169
+        if (iTaShopService.updateById(taShop)){
170
+            TaResource taResource = taResourceService.getByTarget(Constants.TARGET_SHOP, id);
171
+            taResource.setStatus(taShop.getStatus());
172
+            taResourceService.updateById(taResource);
173
+
174
+            return ResponseBean.success(taShop);
175
+        }else {
176
+            return ResponseBean.error("取消发布失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
177
+        }
178
+    }
179
+
180
+
181
+
133 182
     /**
134 183
      * 根据id查询对象
135 184
      * @param id  实体ID

+ 2
- 2
src/main/java/com/yunzhi/shigongli/controller/TaTouristController.java Zobrazit soubor

@@ -68,14 +68,14 @@ public class TaTouristController extends BaseController {
68 68
     public ResponseBean taTouristList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
69 69
                                       @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
70 70
                                       @ApiParam("景点名称") @RequestParam(value ="touristName", required = false) String touristName,
71
-                                      @ApiParam("区位") @RequestParam(value ="cityId", required = false) String cityId) throws Exception{
71
+                                      @ApiParam("区位") @RequestParam(value ="areaId", required = false) String areaId) throws Exception{
72 72
 
73 73
         IPage<TaTourist> pg = new Page<>(pageNum, pageSize);
74 74
         QueryWrapper<TaTourist> queryWrapper = new QueryWrapper<>();
75 75
         queryWrapper.orderByDesc("weight");
76 76
         queryWrapper.orderByDesc("create_date");
77 77
 
78
-        IPage<TaTourist> result = iTaTouristService.getPagedBy(pg, touristName, cityId);
78
+        IPage<TaTourist> result = iTaTouristService.getPagedBy(pg, touristName, areaId);
79 79
         return ResponseBean.success(result);
80 80
     }
81 81
 

+ 1
- 1
src/main/java/com/yunzhi/shigongli/controller/TdCityController.java Zobrazit soubor

@@ -126,7 +126,7 @@ public class TdCityController extends BaseController {
126 126
 
127 127
         TdCity parent = iTdCityService.getById(tdCity.getAreaPId());
128 128
         if (null != parent) {
129
-            tdCity.setAreaPName(parent.getAreaPName());
129
+            tdCity.setAreaPName(parent.getAreaName());
130 130
         }
131 131
 
132 132
         return ResponseBean.success(tdCity);

+ 3
- 0
src/main/java/com/yunzhi/shigongli/entity/TaResource.java Zobrazit soubor

@@ -67,4 +67,7 @@ public class TaResource implements Serializable {
67 67
 
68 68
     @ApiModelProperty(value = "所属区")
69 69
     private String cityId;
70
+
71
+    @ApiModelProperty(value = "状态")
72
+    private Integer status;
70 73
 }

+ 0
- 1
src/main/java/com/yunzhi/shigongli/entity/TaRoom.java Zobrazit soubor

@@ -66,5 +66,4 @@ public class TaRoom implements Serializable {
66 66
     @ApiModelProperty(value = "创建时间")
67 67
     private LocalDateTime createDate;
68 68
 
69
-
70 69
 }

+ 5
- 1
src/main/java/com/yunzhi/shigongli/entity/TaRoomOrder.java Zobrazit soubor

@@ -2,6 +2,8 @@ package com.yunzhi.shigongli.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4 4
 import java.time.LocalDateTime;
5
+
6
+import com.baomidou.mybatisplus.annotation.TableField;
5 7
 import com.baomidou.mybatisplus.annotation.TableId;
6 8
 import java.io.Serializable;
7 9
 import io.swagger.annotations.ApiModel;
@@ -54,5 +56,7 @@ public class TaRoomOrder implements Serializable {
54 56
     @ApiModelProperty(value = "创建时间")
55 57
     private LocalDateTime createDate;
56 58
 
57
-
59
+    @ApiModelProperty(value = "分享图")
60
+    @TableField(exist = false)
61
+    private String shareImage;
58 62
 }

+ 4
- 0
src/main/java/com/yunzhi/shigongli/entity/TaTourist.java Zobrazit soubor

@@ -89,6 +89,10 @@ public class TaTourist implements Serializable {
89 89
     @TableField(exist = false)
90 90
     private Integer uvNum;
91 91
 
92
+    @ApiModelProperty(value = "所属区位名称")
93
+    @TableField(exist = false)
94
+    private String areaName;
95
+
92 96
     @ApiModelProperty(value = "图片列表")
93 97
     @TableField(exist = false)
94 98
     private List<TaImage> imageList;

+ 31
- 4
src/main/java/com/yunzhi/shigongli/service/impl/TaOrderServiceImpl.java Zobrazit soubor

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.shigongli.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
3 4
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
4 5
 import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
5 6
 import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
@@ -63,7 +64,11 @@ public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder>
63 64
     public WxPayMpOrderResult order(TaPerson person, OrderItem[] orderItems) throws Exception {
64 65
         LocalDateTime now = LocalDateTime.now();
65 66
 
66
-        // 先生成主订单
67
+        // 是否首单
68
+        TaOrder lastOrder = getPersonLastOrder(person.getPersonId());
69
+        boolean isFirstOrder = null == lastOrder;
70
+
71
+                // 先生成主订单
67 72
         TaOrder taOrder = new TaOrder();
68 73
         taOrder.setOrderId(getOrderNo());
69 74
         taOrder.setDescription("套餐");
@@ -73,7 +78,7 @@ public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder>
73 78
         taOrder.setCreateDate(now);
74 79
 
75 80
         // 子订单列表
76
-        Integer charge = createAndSaveOrderSubList(taOrder, orderItems);
81
+        Integer charge = createAndSaveOrderSubList(person, taOrder, orderItems, isFirstOrder);
77 82
         taOrder.setCharges(charge);
78 83
         save(taOrder);
79 84
 
@@ -145,7 +150,7 @@ public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder>
145 150
      * @return
146 151
      * @throws Exception
147 152
      */
148
-    private Integer createAndSaveOrderSubList(TaOrder taOrder, OrderItem[] orderItems) throws Exception {
153
+    private Integer createAndSaveOrderSubList(TaPerson taPerson, TaOrder taOrder, OrderItem[] orderItems, boolean isFirstOrder) throws Exception {
149 154
         LocalDateTime now = LocalDateTime.now();
150 155
 
151 156
         Integer totalCharge = 0;
@@ -187,6 +192,10 @@ public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder>
187 192
                 throw new Exception("订单中存在异常套餐, 请联系管理员");
188 193
             }
189 194
 
195
+            // 当前套餐的店铺是否当前下单人的推荐人
196
+            boolean isRecommend = Constants.RECOMMEND_SHOP.equals(taPerson.getFromType())
197
+                    && shopPackage.getShopId().equals(taPerson.getRecommender());
198
+
190 199
             orderSub.setPackageId(packageId);
191 200
 
192 201
             // 价格
@@ -204,9 +213,12 @@ public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder>
204 213
             // 返现设置
205 214
             orderSub.setCashback(shopPackage.getCashback());
206 215
 
216
+            // 新客户首次推荐店铺下单, 商铺不需要给平台分成
217
+            boolean needCommission = !isFirstOrder || !isRecommend;
218
+
207 219
             // 套餐分成设置
208 220
             TaShopPackageSetting packageSetting = packageSettingMapper.selectById(packageId);
209
-            if (null != packageSetting) {
221
+            if (null != packageSetting && needCommission) {
210 222
                 // 参与分成金额 = 总金额 - 返现金额
211 223
                 Integer charges = orderSub.getCharges() - orderSub.getCashback();
212 224
 
@@ -242,6 +254,21 @@ public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder>
242 254
         return totalCharge;
243 255
     }
244 256
 
257
+    /**
258
+     * 获取人员最近的一笔订单
259
+     * @param personId
260
+     * @return
261
+     */
262
+    private TaOrder getPersonLastOrder(String personId) {
263
+        LambdaQueryWrapper<TaOrder> queryWrapper = new LambdaQueryWrapper<>();
264
+        queryWrapper.eq(TaOrder::getPersonId, personId);
265
+        queryWrapper.gt(TaOrder::getStatus, Constants.STATUS_DELETED);
266
+        queryWrapper.orderByDesc(TaOrder::getCreateDate);
267
+        queryWrapper.last("limit 1");
268
+
269
+        return getOne(queryWrapper);
270
+    }
271
+
245 272
     /**
246 273
      * 生成并保存抽成表
247 274
      * @param orderSub

+ 64
- 0
src/main/java/com/yunzhi/shigongli/vo/AMapWeather.java Zobrazit soubor

@@ -0,0 +1,64 @@
1
+package com.yunzhi.shigongli.vo;
2
+
3
+
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * https://lbs.amap.com/api/webservice/guide/api/weatherinfo
12
+ */
13
+
14
+@ApiModel(description = "高德地图天气")
15
+@Data
16
+public class AMapWeather {
17
+
18
+    @ApiModelProperty("返回状态")
19
+    private String status;
20
+
21
+    @ApiModelProperty("返回结果总数目")
22
+    private String count;
23
+
24
+    @ApiModelProperty("返回的状态信息")
25
+    private String info;
26
+
27
+    @ApiModelProperty("返回状态说明,10000代表正确")
28
+    private String infocode;
29
+
30
+    @ApiModelProperty("实况天气数据信息")
31
+    private List<Live> lives;
32
+
33
+    @ApiModel(description = "实时天气")
34
+    @Data
35
+    public static class Live {
36
+
37
+        @ApiModelProperty("省份名")
38
+        private String province;
39
+
40
+        @ApiModelProperty("城市名")
41
+        private String city;
42
+
43
+        @ApiModelProperty("区域编码")
44
+        private String adcode;
45
+
46
+        @ApiModelProperty("天气现象(汉字描述)")
47
+        private String weather;
48
+
49
+        @ApiModelProperty("实时气温,单位:摄氏度")
50
+        private String temperature;
51
+
52
+        @ApiModelProperty("风向描述")
53
+        private String winddirection;
54
+
55
+        @ApiModelProperty("风力级别,单位:级")
56
+        private String windpower;
57
+
58
+        @ApiModelProperty("空气湿度")
59
+        private String humidity;
60
+
61
+        @ApiModelProperty("数据发布的时间")
62
+        private String reporttime;
63
+    }
64
+}

+ 3
- 0
src/main/java/com/yunzhi/shigongli/vo/ResourceFieldVO.java Zobrazit soubor

@@ -40,4 +40,7 @@ public class ResourceFieldVO {
40 40
 
41 41
     @ApiModelProperty(value = "所属区")
42 42
     private String cityId;
43
+
44
+    @ApiModelProperty(value = "状态")
45
+    private Integer status;
43 46
 }

+ 1
- 1
src/main/resources/application-dev.yml Zobrazit soubor

@@ -5,7 +5,7 @@ spring:
5 5
       max-file-size: 10MB
6 6
       max-request-size: 50MB
7 7
   datasource:
8
-    url: jdbc:mysql://rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com:3306/shigongli-v2?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
8
+    url: jdbc:mysql://rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com:3306/shigongli-v2-test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
9 9
     username: shigongli
10 10
     password: shigongli@123
11 11
 

+ 9
- 2
src/main/resources/application.yml Zobrazit soubor

@@ -18,6 +18,7 @@ interceptor:
18 18
       - /swagger-ui/**
19 19
       - /swagger-resources/**
20 20
       - /v2/**
21
+      - /test-weather
21 22
 
22 23
 ###
23 24
 mybatis-plus:
@@ -28,8 +29,8 @@ mybatis-plus:
28 29
 
29 30
 ###
30 31
 aliyun:
31
-  accessKeyId: LTAIGQtIi28MfXms
32
-  accessKeySecret: b6maakcdzEywmkhcK15rStx54hOiIA
32
+  accessKeyId: LTAI5tGjnZY6k799BHxhmqcm
33
+  accessKeySecret: eU1DmULbgHe2dnIg3P93634PO2vEh5
33 34
   oss:
34 35
     roleSessionName: shigongli
35 36
     accessKeyId: LTAI4G9zCefU1m7sKmmBnzTc
@@ -62,6 +63,12 @@ weixin:
62 63
     notifyUrl: https://sgl.njyunzhi.com/api/wxpay/notify/order
63 64
     refundNotifyUrl: https://sgl.njyunzhi.com/api/wxpay/notify/refund
64 65
 
66
+## 高德地图
67
+amap:
68
+  weather:
69
+    api: https://restapi.amap.com/v3/weather/weatherInfo?key=3be0a9567a794d2690d378476f057a6f&city=%s&extensions=base&output=JSON
70
+    backImage: https://yz-shigongli.oss-cn-shanghai.aliyuncs.com/images/weather/background_%s.png
71
+
65 72
 ###
66 73
 spring:
67 74
   application:

+ 4
- 2
src/main/resources/mapper/TaTouristMapper.xml Zobrazit soubor

@@ -7,11 +7,13 @@
7 7
             t.*,
8 8
             s.like_num,
9 9
             s.pv_num,
10
-            s.uv_num
10
+            s.uv_num,
11
+            m.area_name
11 12
         FROM
12 13
             ta_tourist t
13
-                LEFT JOIN ta_resource s ON s.target_type = 'tourist'
14
+            LEFT JOIN ta_resource s ON s.target_type = 'tourist'
14 15
                 AND s.target_id = t.tourist_id
16
+            LEFT JOIN td_city m on m.area_id = t.city_id
15 17
         WHERE
16 18
             t.`status` &gt; - 1
17 19
           <if test="touristName != null and touristName != ''">