Commit 1c6ceae9 by 吕明尚

专属保洁的开门操作更改请求方式

parent 17c989b3
......@@ -66,6 +66,12 @@
<artifactId>hutool-all</artifactId>
<version>5.8.16</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
......
......@@ -187,10 +187,6 @@ xss:
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
meituan:
developerId: 123456
signKey: abcdefghijklmnopqrstuvwxyz
appAuthToken: abcdefghijklmnopqrstuvwxyz
dianping:
appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
......
package share.web.controller.system;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.common.annotation.Log;
import share.system.service.MTService;
@RestController
@RequestMapping("/certificate")
@Api(tags = "首页-验券")
public class MTController {
@Autowired
private MTService mtService;
@GetMapping("/verificationVouchers")
//@Log(title = "执行验券")
public String verificationVouchers(String code, int num){
return mtService.verificationVouchers(code, num).getMsg();
}
@GetMapping("/revoke")
//@Log(title = "撤销验券")
public String revoke(String ERPId ,String ERPName ,String couponCode){
return mtService.revoke(ERPId, ERPName, couponCode).getMsg();
}
@GetMapping("/preparation")
//@Log(title = "验券准备")
public String preparation(String code){
return mtService.preparation(code).getMsg();
}
@GetMapping("/consume")
//@Log(title = "已验券码查询")
public String verified(String code){
return mtService.verified(code).getMsg();
}
}
......@@ -81,8 +81,8 @@ public class SRoomController extends BaseController {
* 专属保洁的开门操作
*/
@ApiOperation(value = "专属保洁的开门操作")
@RequestMapping(value = "/open/door", method = RequestMethod.POST)
public R<String> openDoor(@RequestBody Long id) {
@RequestMapping(value = "/open/door", method = RequestMethod.GET)
public R<String> openDoor(@RequestParam("id") Long id) {
return R.ok(sRoomService.openDoor(id));
}
......
......@@ -189,10 +189,6 @@ xss:
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
meituan:
developerId: 123456
signKey: abcdefghijklmnopqrstuvwxyz
appAuthToken: abcdefghijklmnopqrstuvwxyz
dianping:
appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
......
......@@ -58,21 +58,6 @@
<version>0.7</version>
</dependency>
<!--美团SDK引入加相关依赖开始-->
<dependency>
<groupId>MtOpJavaSDK</groupId>
<artifactId>MtOpJavaSDK</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/lib/MtOpJavaSDK/MtOpJavaSDK-1.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>MtOpJavaSDK-sources</groupId>
<artifactId>MtOpJavaSDK-sources</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/lib/MtOpJavaSDK/MtOpJavaSDK-1.0-SNAPSHOT-sources.jar</systemPath>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
......
##一、环境说明
美团开放平台Java版本SDK,支持jdk 1.8及以上版本。
##二、引入方式
下载jar包,添加到项目依赖中。SDK运行时需要依赖几个第三方库,如果您使用maven的话,直接添加以下依赖到pom.xml即可:
```xml
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b11</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
```
> 若您的项目中已包含上面的依赖,则忽略。
## 三、调用示例
以接口[门店本地验券历史](https://developer.meituan.com/docs/api/tuangou-coupon-queryLocalListByDate) 为例, DK提供了类***CouponQueryLocalListByDateRequest***来封装请求,您调用此接口的代码可以参考:
```java
Long developerId = 1111L;
String signKey = "xxxx";
String appAuthToken = "xxxxxxxxxxxxx";
//构造meituanClient,推荐使用单例方式,一个develoepr只使用一个实例
MeituanClient meituanClient = DefaultMeituanClient.builder(developerId, signKey).build();
//准备请求参数
CouponQueryLocalListByDateRequest request = new CouponQueryLocalListByDateRequest();
request.setDate("2020-12-15");
request.setOffset(0);
request.setLimit(10);
try {
//发起接口调用
MeituanResponse<CouponQueryLocalListByDateResponse> response = meituanClient.invokeApi(request, appAuthToken);
//判断是调用是否成功
if (response.isSuccess()) {
//调用成功,通过getData获取接口响应数据
CouponQueryLocalListByDateResponse localListByDateResponse = response.getData();
List<EOrders> eOrders = localListByDateResponse.getEOrders();
for(EOrders eOrder: eOrders) {
System.out.println(eOrder);
}
} else {
//调用失败,通过getCode和getMsg获取错误码和错误描述
System.out.println(response.getCode());
System.out.println(response.getMsg());
}
} catch (MtSdkException e) {
e.printStackTrace();
}
```
\ No newline at end of file
package share.system.service.impl;
import com.meituan.sdk.DefaultMeituanClient;
import com.meituan.sdk.MeituanClient;
import com.meituan.sdk.MeituanResponse;
import com.meituan.sdk.internal.exceptions.MtSdkException;
import com.meituan.sdk.model.tuangouNg.coupon.couponCancel.CouponCancelRequest;
import com.meituan.sdk.model.tuangouNg.coupon.couponCancel.CouponCancelResponse;
import com.meituan.sdk.model.tuangouNg.coupon.msSuperConsume.MsSuperConsumeRequest;
import com.meituan.sdk.model.tuangouNg.coupon.msSuperConsume.MsSuperConsumeResponse;
import com.meituan.sdk.model.tuangouNg.coupon.msSuperPrepare.MsSuperPrepareRequest;
import com.meituan.sdk.model.tuangouNg.coupon.msSuperPrepare.MsSuperPrepareResponse;
import com.meituan.sdk.model.tuangouNg.coupon.queryCouponById.QueryCouponByIdRequest;
import com.meituan.sdk.model.tuangouNg.coupon.queryCouponById.QueryCouponByIdResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import share.system.domain.SConsumer;
import share.system.domain.SConsumerCoupon;
import share.system.domain.SCoupon;
import share.system.domain.vo.FrontTokenComponent;
import share.system.service.ISConsumerCouponService;
import share.system.service.ISCouponService;
import share.system.service.MTService;
@Service
public class MTServiceImpl implements MTService {
@Value("${meituan.signKey}")
private String signKey;
@Value("${meituan.appAuthToken}")
private String appAuthToken;
@Value("${meituan.developerId}")
private Long developerId;
@Autowired
private ISCouponService isCouponService;
@Autowired
private ISConsumerCouponService isConsumerCouponService;
//执行验券
@Override
public MeituanResponse verificationVouchers(String code, int num) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
//验券准备
MeituanResponse preparation = preparation(code);
//验券准备失败
if (!preparation.isSuccess()) {
throw new RuntimeException(preparation.getMsg());
}
//返回验券准备数据
MsSuperPrepareResponse data = (MsSuperPrepareResponse) preparation.getData();
SCoupon sCoupon = isCouponService.selectSCouponByName(data.getDealTitle());
if (sCoupon == null) {
throw new RuntimeException("未找到对应的优惠券");
}
//执行验券
//developerId 服务商身份标识 signKey 服务商签名密钥
MeituanClient meituanClient = DefaultMeituanClient.builder(developerId, signKey).build();
MsSuperConsumeRequest msSuperConsumeRequest = new MsSuperConsumeRequest();
// msSuperConsumeRequest.setCode("002300340045");
// msSuperConsumeRequest.setNum(1);
msSuperConsumeRequest.setCode(code);
msSuperConsumeRequest.setNum(num);
MeituanResponse<MsSuperConsumeResponse> response = null;
try {
response = meituanClient.invokeApi(msSuperConsumeRequest, appAuthToken);
} catch (MtSdkException e) {
throw new RuntimeException(e);
}
//验券成功
if (response.isSuccess()) {
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setConsumerId(user.getId());
sConsumerCoupon.setCouponId(sCoupon.getId());
sConsumerCoupon.setCouponCode(code);
sConsumerCoupon.setName(sCoupon.getName());
sConsumerCoupon.setCouponType(sCoupon.getCouponType());
sConsumerCoupon.setStoreType(sCoupon.getStoreType());
sConsumerCoupon.setRoomType(sCoupon.getRoomType());
sConsumerCoupon.setMinDuration(sCoupon.getMinDuration());
sConsumerCoupon.setMaxDuration(sCoupon.getMaxDuration());
sConsumerCoupon.setDuration(sCoupon.getDuration());
sConsumerCoupon.setMinPrice(sCoupon.getMinPrice());
sConsumerCoupon.setSubPrice(sCoupon.getSubPrice());
sConsumerCoupon.setSourceType("3");
sConsumerCoupon.setPlatformType("2");
sConsumerCoupon.setStartDate(sCoupon.getStartDate());
sConsumerCoupon.setEndDate(sCoupon.getEndDate());
sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
} else {
return response;
}
return response;
}
//撤销验券
@Override
public MeituanResponse revoke(String ERPId, String ERPName, String couponCode) {
MeituanClient meituanClient = DefaultMeituanClient.builder(developerId, signKey).build();
CouponCancelRequest couponCancelRequest = new CouponCancelRequest();
couponCancelRequest.setEId(ERPId);
couponCancelRequest.setEName(ERPName);
couponCancelRequest.setType(1);
couponCancelRequest.setCouponCode(couponCode);
MeituanResponse<CouponCancelResponse> response = null;
try {
response = meituanClient.invokeApi(couponCancelRequest, appAuthToken);
} catch (MtSdkException e) {
throw new RuntimeException(e);
}
return response;
}
//验券准备
@Override
public MeituanResponse preparation(String code) {
MeituanClient meituanClient = DefaultMeituanClient.builder(developerId, signKey).build();
MsSuperPrepareRequest msSuperPrepareRequest = new MsSuperPrepareRequest();
msSuperPrepareRequest.setCode(code);
MeituanResponse<MsSuperPrepareResponse> response = null;
try {
response = meituanClient.invokeApi(msSuperPrepareRequest, appAuthToken);
} catch (MtSdkException e) {
throw new RuntimeException(e);
}
return response;
}
//已验券码查询
@Override
public MeituanResponse verified(String code) {
MeituanClient meituanClient = DefaultMeituanClient.builder(developerId, signKey).build();
QueryCouponByIdRequest queryCouponByIdRequest = new QueryCouponByIdRequest();
queryCouponByIdRequest.setCouponCode(code);
MeituanResponse<QueryCouponByIdResponse> response = null;
try {
response = meituanClient.invokeApi(queryCouponByIdRequest, appAuthToken);
} catch (MtSdkException e) {
throw new RuntimeException(e);
}
return response;
}
}
......@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dianping.openapi.sdk.api.customerauth.session.entity.CustomerKeyShopScopeResponseEntity;
import lombok.var;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.record.DVALRecord;
import org.bouncycastle.util.Store;
......@@ -287,11 +288,11 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
queryWrapper.eq(SCleanRecords::getStoreId, item.getId());
queryWrapper.ne(SCleanRecords::getStatus, 2);
SCleanRecords sCleanRecords = sCleanRecordsMapper.selectOne(queryWrapper);
if (ObjectUtils.isNotEmpty(sCleanRecords)) {
room.setRecordsStatus(sCleanRecords.getStatus());
}
});
});
return storeList;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment