|
@@ -2,6 +2,9 @@ package com.huijy.web.controller.api;
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.huijy.common.annotation.LoginMember;
|
|
|
import com.huijy.common.annotation.UnLogin;
|
|
|
import com.huijy.common.config.RuoYiConfig;
|
|
@@ -17,6 +20,7 @@ import com.huijy.management.service.*;
|
|
|
import com.huijy.management.vo.WxPhoneFrom;
|
|
|
import com.huijy.system.service.ISysDictDataService;
|
|
|
import com.huijy.weixin.config.WxMaConfiguration;
|
|
|
+import com.huijy.weixin.config.WxMaProperties;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
@@ -67,6 +71,7 @@ public class ApiIndexController extends ApiAbstractController {
|
|
|
@Autowired
|
|
|
private IShopRoomOrderService orderService;
|
|
|
|
|
|
+ private static WxMaProperties wxMaProperties;
|
|
|
|
|
|
//绑定手机号
|
|
|
@PostMapping("/bindMobile")
|
|
@@ -292,31 +297,6 @@ public class ApiIndexController extends ApiAbstractController {
|
|
|
return AjaxResult.error("店铺信息不允许更新");
|
|
|
}
|
|
|
|
|
|
- //更新门店坐标
|
|
|
- @PostMapping("/updateLatLng")
|
|
|
- @ApiOperation("更新门店坐标")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "shopId", value = "商铺id", required = true, paramType = "body"),
|
|
|
- @ApiImplicitParam(name = "lat", value = "坐标的lat", paramType = "body"),
|
|
|
- @ApiImplicitParam(name = "lng", value = "坐标的lng", paramType = "body")
|
|
|
- })
|
|
|
- public AjaxResult storeApply(@ApiIgnore @LoginMember Member member, @RequestBody Map params) {
|
|
|
- String lat = (String) params.get("lat");
|
|
|
- String lng = (String) params.get("lng");
|
|
|
- Integer shopId = (Integer) params.get("shopId");
|
|
|
- if (shopId == null || shopId <= 0) {
|
|
|
- return AjaxResult.error("店铺id不能为空");
|
|
|
- }
|
|
|
- Shop shop = shopService.selectShopByShopId(shopId.longValue());
|
|
|
- if (shop == null) {
|
|
|
- return AjaxResult.error("获取店铺信息出错");
|
|
|
- }
|
|
|
- shop.setLat(lat);
|
|
|
- shop.setLng(lng);
|
|
|
- shopService.updateShop(shop);
|
|
|
- return AjaxResult.success();
|
|
|
- }
|
|
|
-
|
|
|
//门店数据上报
|
|
|
@PostMapping("/pushRecord")
|
|
|
@ApiOperation("门店数据上报")
|
|
@@ -349,6 +329,7 @@ public class ApiIndexController extends ApiAbstractController {
|
|
|
}
|
|
|
|
|
|
//酒店列表
|
|
|
+ @UnLogin
|
|
|
@GetMapping("/hotelList")
|
|
|
@ApiOperation("酒店列表")
|
|
|
public AjaxResult hotelList() {
|
|
@@ -376,6 +357,7 @@ public class ApiIndexController extends ApiAbstractController {
|
|
|
}
|
|
|
|
|
|
//酒店详情
|
|
|
+ @UnLogin
|
|
|
@GetMapping("/hotelDetail")
|
|
|
@ApiOperation("酒店详情")
|
|
|
public AjaxResult hotelDetail(Long shopId) {
|
|
@@ -387,6 +369,15 @@ public class ApiIndexController extends ApiAbstractController {
|
|
|
return AjaxResult.success(shop);
|
|
|
}
|
|
|
|
|
|
+ //首页数据
|
|
|
+ @UnLogin
|
|
|
+ @PostMapping("/home")
|
|
|
+ @ApiOperation("首页数据")
|
|
|
+ public AjaxResult home() {
|
|
|
+
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
//酒店预订
|
|
|
@PostMapping("/hotelBook")
|
|
|
@ApiOperation("酒店预订")
|
|
@@ -407,7 +398,16 @@ public class ApiIndexController extends ApiAbstractController {
|
|
|
@PostMapping("/orderDeal")
|
|
|
@ApiOperation("商家订单处理")
|
|
|
public AjaxResult orderDeal(@RequestBody ShopRoomOrder order) {
|
|
|
- return AjaxResult.success(orderService.updateShopRoomOrder(order));
|
|
|
+ order.setCreateTime(null);
|
|
|
+ int row = orderService.updateShopRoomOrder(order);
|
|
|
+ //发送小程序订阅消息
|
|
|
+ if (row > 0 && order.getState() == 1) {
|
|
|
+ sendMessage("酒店预订成功通知", order);
|
|
|
+ }
|
|
|
+ if (row > 0 && order.getState() == 2) {
|
|
|
+ sendMessage("酒店预订失败通知", order);
|
|
|
+ }
|
|
|
+ return AjaxResult.success(row);
|
|
|
}
|
|
|
|
|
|
//商家订单删除
|
|
@@ -437,8 +437,7 @@ public class ApiIndexController extends ApiAbstractController {
|
|
|
return AjaxResult.success(resultObj);
|
|
|
}
|
|
|
|
|
|
- //
|
|
|
-
|
|
|
+ //根据标记物类型分页获取标记物信息
|
|
|
@GetMapping("/getPageMarker")
|
|
|
@ApiOperation("根据标记物类型分页获取标记物信息")
|
|
|
@ApiImplicitParams({
|
|
@@ -503,4 +502,31 @@ public class ApiIndexController extends ApiAbstractController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //订阅消息
|
|
|
+ private String sendMessage(String type, ShopRoomOrder order) {
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(HttpUtil.get("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + WxMaConfiguration.getMaService().getWxMaConfig().getAppid() + "&secret=" + WxMaConfiguration.getMaService().getWxMaConfig().getSecret()));
|
|
|
+ JSONObject body = new JSONObject();
|
|
|
+ body.set("touser", order.getOpenid());
|
|
|
+ JSONObject content = new JSONObject();
|
|
|
+ if (type.equals("酒店预订成功通知")) {
|
|
|
+ body.set("template_id", "Lh41ftWaZxG8mycje0XQLpylac30ftS4nAXM28iwi8I");
|
|
|
+ content.set("thing4", new JSONObject().set("value", order.getName()));
|
|
|
+ content.set("phone_number5", new JSONObject().set("value", order.getPhone()));
|
|
|
+ content.set("time2", new JSONObject().set("value", order.getMin()));
|
|
|
+ }
|
|
|
+ if (type.equals("酒店预订失败通知")) {
|
|
|
+ body.set("template_id", "iEMHyeeuqs-MFa1J4QgT7n0mfnOb-h93oc21b1O3pK8");
|
|
|
+ content.set("thing2", new JSONObject().set("value", order.getMin().substring(5, 10) + "至" + order.getMax().substring(5, 10)));
|
|
|
+ content.set("thing3", new JSONObject().set("value", order.getShopRoom().getTitle()));
|
|
|
+ content.set("thing5", new JSONObject().set("value", "入住的时间段酒店客房已满,无法安排入住"));
|
|
|
+ }
|
|
|
+ content.set("thing1", new JSONObject().set("value", order.getShopName()));
|
|
|
+ body.set("data", content);
|
|
|
+ String result = HttpUtil.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + jsonObject.getStr("access_token"), body.toString());
|
|
|
+ System.out.println("订单信息:" + content.toString());
|
|
|
+ System.out.println("订单信息:" + order.toString());
|
|
|
+ System.out.println("小程序订阅消息:" + result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|