From a7000af6a1b3a6eb25ee0d31ca00595de79a7ec4 Mon Sep 17 00:00:00 2001 From: Burce Date: Tue, 29 Oct 2019 15:16:27 +0800 Subject: [PATCH 1/9] =?UTF-8?q?[=E6=8B=9B=E5=95=86][=E4=BB=BB=E5=8A=A1]?= =?UTF-8?q?=E4=B8=9A=E6=80=81=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/service/invest/impl/InvestBizServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java index a0c33044e..fb36dc3bc 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java @@ -516,6 +516,8 @@ public class InvestBizServiceImpl implements InvestBizService { LambdaQueryWrapper taskQueryWrapper = new LambdaQueryWrapper<>(); InvestPageResult investPage = new InvestPageResult<>(); taskQueryWrapper.apply(StringUtils.isNotBlank(taskParams.getOwner()), "`owner` REGEXP {0}", taskParams.getOwner()); + taskQueryWrapper.apply(Objects.nonNull(params.getBusinessId()), "`content` REGEXP {0}", + String.format("\"businessId\": %d", params.getBusinessId())); taskParams.setOwner(null); taskQueryWrapper.setEntity(taskParams); @@ -590,7 +592,7 @@ public class InvestBizServiceImpl implements InvestBizService { shop = new WxShop(); shop.setShopNumber(params.getShopNumber()); shop.setStatus(params.getShopStatus()); - shop.setBusinessId(params.getBusinessId()); + //shop.setBusinessId(params.getBusinessId()); } InvestTaskDto taskDto = new InvestTaskDto(); From 76b419be57c1510a3fcdb453679f8b10afc33305 Mon Sep 17 00:00:00 2001 From: Burce Date: Tue, 29 Oct 2019 15:23:29 +0800 Subject: [PATCH 2/9] =?UTF-8?q?[=E6=8B=9B=E5=95=86][=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E8=AE=B0=E5=BD=95]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iformall/service/invest/impl/InvestBizServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java index fb36dc3bc..a7e4c614a 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java @@ -921,7 +921,7 @@ public class InvestBizServiceImpl implements InvestBizService { } Collection recordList = entityPageList.getRecords(); - Map usersMap = getMap(userInfoService.getByIds(getIds(recordList, InvestOperateRecordEntity::getOperator)), MallUserInfo::getId); + Map usersMap = getMap(userInfoService.findList(new MallUserInfo()), MallUserInfo::getId); //品牌信息 List brands = brandService.listAsPage(null, 1, Integer.MAX_VALUE).getList(); From 335fa768b8fa9bef63273dbcb2c1517b06666ecd Mon Sep 17 00:00:00 2001 From: Burce Date: Tue, 29 Oct 2019 15:34:06 +0800 Subject: [PATCH 3/9] =?UTF-8?q?[=E6=8B=9B=E5=95=86][=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E6=8F=90=E9=86=92]=E6=97=B6=E9=97=B4=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/service/invest/impl/InvestBizServiceImpl.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java index a7e4c614a..12e637f15 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java @@ -659,9 +659,8 @@ public class InvestBizServiceImpl implements InvestBizService { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(InvestRemindEntity::getTenantId, InvestUserContext.getUser().getTenantId()); if (Objects.nonNull(params.getRemindDate())) { - queryWrapper.apply("date_format(begin_date,'%Y-%m-%d') >= {0} AND date_format(end_date,'%Y-%m-%d') < {1}" - , getDayStart(params.getRemindDate()) - , getDayEnd(params.getRemindDate())); + queryWrapper.apply("date_format(begin_date,'%Y-%m-%d') = {0}", getDayStart(params.getRemindDate())); + //queryWrapper.apply("date_format(end_date,'%Y-%m-%d') < {0}", getDayEnd(params.getRemindDate())); } queryWrapper.orderByDesc(InvestRemindEntity::getCreateDate); InvestPageResult recordPage = remindService.queryPage(remindPageQuery, queryWrapper); From f3bae56355836ff6b0d371a8db001b39c3664c00 Mon Sep 17 00:00:00 2001 From: Burce Date: Tue, 29 Oct 2019 16:15:26 +0800 Subject: [PATCH 4/9] =?UTF-8?q?[=E6=8B=9B=E5=95=86][=E4=BB=BB=E5=8A=A1]?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iformall/service/invest/event/InvestListener.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java b/mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java index af47da419..a8bf194bf 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java @@ -35,6 +35,7 @@ public class InvestListener implements ApplicationListener { LambdaQueryWrapper query = new LambdaQueryWrapper<>(); query.in(InvestTaskEntity::getTargetId, rentEventInfo.getTargetIds()); query.eq(InvestTaskEntity::getTargetType, EnumInvestType.RENT); + query.eq(InvestTaskEntity::getStatus, EnumTaskStatus.NEGOTIATING); List tasks = taskService.list(query); if (CollectionUtils.isEmpty(tasks)) { log.warn("receive InvestEvent , tasks is empty : {}", tasks); @@ -53,13 +54,13 @@ public class InvestListener implements ApplicationListener { status = EnumTaskStatus.FINISH; } - if (status == EnumTaskStatus.FINISH) { + //if (status != EnumTaskStatus.FINISH) { for (InvestTaskEntity task : tasks) { task.setStatus(status); task.setContent(InvestHelper.addContractId(task.getContent(),rentEventInfo.getRentId(),rentEventInfo.getContractType())); } taskService.updateBatchById(tasks); - } + //} } } From fa6f58a1306c3528a4161a61f27dc0d71d3908e2 Mon Sep 17 00:00:00 2001 From: Burce Date: Tue, 29 Oct 2019 16:43:25 +0800 Subject: [PATCH 5/9] =?UTF-8?q?[=E6=8B=9B=E5=95=86][=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E6=8F=90=E9=86=92]=E6=97=B6=E9=97=B4=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/service/invest/impl/InvestBizServiceImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java index 12e637f15..006bb3839 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java @@ -659,8 +659,9 @@ public class InvestBizServiceImpl implements InvestBizService { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(InvestRemindEntity::getTenantId, InvestUserContext.getUser().getTenantId()); if (Objects.nonNull(params.getRemindDate())) { - queryWrapper.apply("date_format(begin_date,'%Y-%m-%d') = {0}", getDayStart(params.getRemindDate())); - //queryWrapper.apply("date_format(end_date,'%Y-%m-%d') < {0}", getDayEnd(params.getRemindDate())); + queryWrapper.apply("date_format(begin_date,'%Y-%m-%d') = {0}", getDayStart(params.getRemindDate())) + .or() + .apply("date_format(end_date,'%Y-%m-%d') <= {0}", getDayEnd(params.getRemindDate())); } queryWrapper.orderByDesc(InvestRemindEntity::getCreateDate); InvestPageResult recordPage = remindService.queryPage(remindPageQuery, queryWrapper); From 305e09c96cb5089d7588568f7d776744efcef24c Mon Sep 17 00:00:00 2001 From: Burce Date: Tue, 29 Oct 2019 17:13:38 +0800 Subject: [PATCH 6/9] =?UTF-8?q?[=E6=8B=9B=E5=95=86][=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E6=8F=90=E9=86=92]=E6=97=B6=E9=97=B4=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/service/invest/impl/InvestBizServiceImpl.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java index 006bb3839..ed74b8fbe 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java @@ -659,9 +659,8 @@ public class InvestBizServiceImpl implements InvestBizService { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(InvestRemindEntity::getTenantId, InvestUserContext.getUser().getTenantId()); if (Objects.nonNull(params.getRemindDate())) { - queryWrapper.apply("date_format(begin_date,'%Y-%m-%d') = {0}", getDayStart(params.getRemindDate())) - .or() - .apply("date_format(end_date,'%Y-%m-%d') <= {0}", getDayEnd(params.getRemindDate())); + queryWrapper.apply("date_format(begin_date,'%Y-%m-%d') <= {0}", getDayStart(params.getRemindDate())) + .apply("date_format(end_date,'%Y-%m-%d') >= {0}", getDayEnd(params.getRemindDate())); } queryWrapper.orderByDesc(InvestRemindEntity::getCreateDate); InvestPageResult recordPage = remindService.queryPage(remindPageQuery, queryWrapper); From c168ad4af7d7897fdd761157222ad1093761e12b Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Tue, 29 Oct 2019 13:28:31 +0800 Subject: [PATCH 7/9] =?UTF-8?q?[=E5=81=9C=E8=BD=A6][=E6=96=B0=E5=A2=9E]:?= =?UTF-8?q?=E5=B0=9A=E5=AE=89=E5=81=9C=E8=BD=A6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iformall/utils/car/ShangAnUtil.java | 164 ++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 mallinkService/src/main/java/com/iformall/utils/car/ShangAnUtil.java diff --git a/mallinkService/src/main/java/com/iformall/utils/car/ShangAnUtil.java b/mallinkService/src/main/java/com/iformall/utils/car/ShangAnUtil.java new file mode 100644 index 000000000..aadaac57e --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/utils/car/ShangAnUtil.java @@ -0,0 +1,164 @@ +package com.iformall.utils.car; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.iformall.utils.DateUtils; +import org.apache.http.Consts; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicHeader; +import org.apache.http.protocol.HTTP; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * 尚安停车 + */ +public class ShangAnUtil { + + private final static Logger logger = LoggerFactory.getLogger(ShangAnUtil.class); + + public static final String KEY = "NzMFFDDJDIFACACCM2zAezDz"; + + public static final String PARK_NUMBER = "p190829183435"; + + public static final String URL = "http://www.p-share.com/shangan-yhq/web/api/outcoupon"; + + public static final String SUCCESS = "success"; + + public static final SimpleDateFormat dateInFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + + public static void main(String[] args) throws Exception { + String carNumber = "京XAZMF1"; + Date myDate = DateUtils.getHourTimeAfter(1, new Date()); + + String result = couponSend(URL, KEY, PARK_NUMBER, "1", myDate, carNumber, "1500"); + + JSONObject obj = JSON.parseObject(result); + } + + /** + * md5算法 + * @param data + * @return + * @throws NoSuchAlgorithmException + */ + + public static String md5(String data) throws NoSuchAlgorithmException { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(data.getBytes()); + StringBuffer buf = new StringBuffer(); + byte[] bits = md.digest(); + for(int i=0;i params = new HashMap<>(); + params.put("parkNum", parkNumber); + params.put("couponModeId", couponModelId); + params.put("couponDate", dateInFormat.format(couponDate)); + params.put("plate", plate); + params.put("position", position); + try { + String result = Proc(url, key, parkNumber, params); + return result; + } catch (Exception e) { + return null; + } + } + + private static String Proc(String url, String key, String parkNumber, Map paramMap) { + CloseableHttpClient httpClient = HttpClients.createDefault(); + + HttpPost httpPost = new HttpPost(url); + httpPost.addHeader(HTTP.CONTENT_TYPE,"application/json"); + httpPost.addHeader("Accept", "application/json"); + httpPost.addHeader("Accept-Encoding", "UTF-8"); + + String sign = null; + try{ + sign = getSign(key, parkNumber); + httpPost.addHeader("sign", sign); + }catch(NoSuchAlgorithmException e) { + logger.error(e.getLocalizedMessage()); + } + + String jsonstr = JSON.toJSONString(paramMap); + logger.info(jsonstr); + + try { + StringEntity se = new StringEntity(jsonstr, Consts.UTF_8); + se.setContentType("application/json"); + se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"UTF-8")); + httpPost.setEntity(se); + } catch (Exception e) { + logger.error(e.getMessage()); + } + + HttpResponse response = null; + try { + response = httpClient.execute(httpPost); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + } + + String result = null; + + //打印StatusLine + logger.debug("StatusLine: " + response.getStatusLine()); + try{ + //获取实体 + HttpEntity httpEntity= response.getEntity(); + result = EntityUtils.toString(httpEntity, "UTF-8"); + logger.debug(result); + } catch (Exception e) { + logger.error(e.getLocalizedMessage()); + } + + try { //关闭流并释放资源 + httpClient.close(); + } catch (IOException e) { + logger.error(e.getLocalizedMessage()); + } + + return result; + } + + + + +} + From 1cb6054fbaed54a75fb2ec475930d3bb093c881a Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Tue, 29 Oct 2019 16:35:31 +0800 Subject: [PATCH 8/9] =?UTF-8?q?[=E5=81=9C=E8=BD=A6][=E6=96=B0=E5=A2=9E]:?= =?UTF-8?q?=E5=B0=9A=E5=AE=89=E5=81=9C=E8=BD=A6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/iformall/utils/car/ShangAnUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/utils/car/ShangAnUtil.java b/mallinkService/src/main/java/com/iformall/utils/car/ShangAnUtil.java index aadaac57e..bd0d5452b 100644 --- a/mallinkService/src/main/java/com/iformall/utils/car/ShangAnUtil.java +++ b/mallinkService/src/main/java/com/iformall/utils/car/ShangAnUtil.java @@ -85,11 +85,11 @@ public class ShangAnUtil { return signValue; } - public static String couponSend(String url, String key, String parkNumber, String couponModelId, Date couponDate, String plate, String position) { + public static String couponSend(String url, String key, String parkNumber, String couponModelId, Date expireTime, String plate, String position) { Map params = new HashMap<>(); params.put("parkNum", parkNumber); params.put("couponModeId", couponModelId); - params.put("couponDate", dateInFormat.format(couponDate)); + params.put("endTime", dateInFormat.format(expireTime)); params.put("plate", plate); params.put("position", position); try { From 7246fa7ba59334f49f61757263217cf5e4748858 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Tue, 29 Oct 2019 17:11:41 +0800 Subject: [PATCH 9/9] =?UTF-8?q?[=E5=81=9C=E8=BD=A6][=E6=96=B0=E5=A2=9E]:?= =?UTF-8?q?=E5=B0=9A=E5=AE=89=E5=81=9C=E8=BD=A6=E6=8E=A5=E5=8F=A3=E5=8F=8A?= =?UTF-8?q?=E5=81=9C=E7=AE=80=E5=8D=95=E6=8E=A5=E5=8F=A3=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/controller/WxCarController.java | 49 +++++++++++++++++-- .../java/com/iformall/common/ErrorCode.java | 2 + .../com/iformall/enums/EnumCarVendor.java | 1 + .../com/iformall/enums/EnumCouponUnit.java | 37 ++++++++++++++ .../com/iformall/utils/car/ShangAnUtil.java | 11 ++++- .../java/com/iformall/utils/car/TJDUtil.java | 16 +++--- 6 files changed, 100 insertions(+), 16 deletions(-) create mode 100644 mallinkService/src/main/java/com/iformall/enums/EnumCouponUnit.java diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java index b9ae3c7dc..f957c6422 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java @@ -15,12 +15,14 @@ import com.iformall.exception.MallinkException; import com.iformall.service.*; import com.iformall.utils.car.DaHuaUtil; import com.iformall.utils.car.ETCPUtil; +import com.iformall.utils.car.ShangAnUtil; import com.iformall.utils.car.TJDUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; +import org.apache.tomcat.jni.Error; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -698,8 +700,11 @@ public class WxCarController extends BaseController { * 优免券领取 * 优免券不可退 */ - @ApiOperation(value = "停车券使用", notes = "ETCP:={\"etcpToken\":\"string(ETCP专用)\",\"carNumber\":\"string\",\"couponOrderId\"=\"String\"},输出\n{}\n" + - "TJD:{\"carNumber\":\"string\",\"tradeId\":\"string\",\"accountId\":\"string\",\"couponOrderId\":\"string\"}") + @ApiOperation(value = "停车券使用", + notes = "ETCP:={\"etcpToken\":\"string(ETCP专用)\",\"carNumber\":\"string\",\"couponOrderId\"=\"String\"},输出\n{}\n" + + "TJD:{\"carNumber\":\"string\",\"tradeId\":\"string\",\"accountId\":\"string\",\"couponOrderId\":\"string\"}" + + "ShangAn:{\"carNumber\":\"string\",\"couponOrderId\":\"string\"}" + ) @PostMapping("/getCoupon") public ResultData getCoupon(@RequestBody Map paramMap) { /// 1, get mall's park @@ -731,7 +736,7 @@ public class WxCarController extends BaseController { userCar = list.get(0); } - if (park.getVendorType() == EnumCarVendor.CAR_ETCP.getCode()) { + if (park.getVendorType().equals(EnumCarVendor.CAR_ETCP.getCode())) { String etcpToken = paramMap.get("etcpToken"); if (StringUtils.isBlank(etcpToken)) { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "etcpToken为空"); @@ -783,7 +788,7 @@ public class WxCarController extends BaseController { } else { return new ResultData(ErrorCode.ETCP_QUAN_SEND_FAIL.getCode(), retObj.getString("message")); } - } else if (park.getVendorType() == EnumCarVendor.CAR_TJD.getCode()) { + } else if (park.getVendorType().equals(EnumCarVendor.CAR_TJD.getCode())) { String tradeId = paramMap.get("tradeId"); String accountId = paramMap.get("accountId"); if (StringUtils.isBlank(tradeId)) { @@ -803,14 +808,48 @@ public class WxCarController extends BaseController { String key = objParams.getString(TJDUtil.TJD_ACCOUNT_KEY); String version = objParams.getString(TJDUtil.TJD_VERSION); + String amount = ""; + if (coupon.getUnit().equals(EnumCouponUnit.MONEY.getCode())) { + amount = coupon.getPriceStr(); + } else { + amount = String.valueOf(coupon.getPrice()* 60); + } + String ret = tjd.deductionForDetail(url, partner, key, version, - tradeId, accountId, userCar, coupon); + tradeId, accountId, String.valueOf(userCar.getId()), + coupon.getUnit().toString(), amount); JSONObject retObj = JSON.parseObject(ret); if (retObj.getString(TJDUtil.TJD_RETURN_CODE).equalsIgnoreCase(EnumTJDCode.SUCCESS.getMessage())) { return new ResultData(); } else { return new ResultData(ErrorCode.TJD_DEDUCE_FEE_FAIL.getCode(), "停车费抵扣失败"); } + } else if (park.getVendorType().equals(EnumCarVendor.CAR_SHANGAN.getCode())) { + WxCoupon coupon = couponService.getById(userCar.getCouponId()); + if (coupon == null) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "券为空"); + } + String params = park.getVendorParams(); + JSONObject objParams = JSON.parseObject(params); + String url = objParams.getString(ShangAnUtil.SHANGAN_URL); + String key = objParams.getString(ShangAnUtil.SHANGAN_KEY); + String parkNumber = objParams.getString(ShangAnUtil.SHANGAN_PARK_NUMBER); + + String couponModelId = coupon.getUnit().toString(); + String position = ""; + if (coupon.getUnit().equals(EnumCouponUnit.MONEY.getCode())) { + position = coupon.getPrice().toString(); + } else { + position = String.valueOf(coupon.getPrice()* 60); + } + + String ret = ShangAnUtil.couponSend(url, key, parkNumber, couponModelId, userCar.getExpiredTime(), carNumber, position); + JSONObject retObj = JSON.parseObject(ret); + if (retObj.getString(ShangAnUtil.SHANGAN_STATUS).equalsIgnoreCase(ShangAnUtil.SHANGAN_SUCCESS)) { + return new ResultData(); + } else { + return new ResultData(ErrorCode.SHANGAN_COUPON_FAIL.getCode(), retObj.getString(ShangAnUtil.SHANGAN_ERROR_CODE)); + } } return new ResultData(ErrorCode.CAR_VENDOR_NOT_SUPPORT.getCode(), "优免券领取失败"); } diff --git a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java index d90ae549a..f484b9c48 100644 --- a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java +++ b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java @@ -156,6 +156,8 @@ public enum ErrorCode{ TJD_STOP_FEE_FAIL(2062, "TJD停车费失败"), TJD_DEDUCE_FEE_FAIL(2063, "TJD停车费抵扣失败"), + SHANGAN_COUPON_FAIL(2070, "优惠券失败"), + /** * 游戏 diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCarVendor.java b/mallinkService/src/main/java/com/iformall/enums/EnumCarVendor.java index 55ad1c299..b440f1545 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumCarVendor.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCarVendor.java @@ -10,6 +10,7 @@ public enum EnumCarVendor { CAR_ETCP(1, "ETCP"), CAR_TJD(2, "TJD"), CAR_DAHUA(3, "DAHUA"), + CAR_SHANGAN(4, "ShangAn"), ; public static EnumCarVendor getEnum(Integer code) { diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCouponUnit.java b/mallinkService/src/main/java/com/iformall/enums/EnumCouponUnit.java new file mode 100644 index 000000000..0b36634e0 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCouponUnit.java @@ -0,0 +1,37 @@ +package com.iformall.enums; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumCouponUnit { + + // 0:rmb分 1:小时 + MONEY(0, "单位:分(人民币)"), + HOUR(1, "单位;小时") + ; + + public static EnumCouponUnit getEnum(Integer code) { + for (EnumCouponUnit value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumCouponUnit(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/utils/car/ShangAnUtil.java b/mallinkService/src/main/java/com/iformall/utils/car/ShangAnUtil.java index bd0d5452b..a81826dce 100644 --- a/mallinkService/src/main/java/com/iformall/utils/car/ShangAnUtil.java +++ b/mallinkService/src/main/java/com/iformall/utils/car/ShangAnUtil.java @@ -28,16 +28,23 @@ import java.util.Map; * 尚安停车 */ public class ShangAnUtil { - private final static Logger logger = LoggerFactory.getLogger(ShangAnUtil.class); + public static final String SHANGAN_URL = "url"; + public static final String SHANGAN_KEY = "key"; + public static final String SHANGAN_PARK_NUMBER = "parkNumber"; + public static final String KEY = "NzMFFDDJDIFACACCM2zAezDz"; public static final String PARK_NUMBER = "p190829183435"; public static final String URL = "http://www.p-share.com/shangan-yhq/web/api/outcoupon"; - public static final String SUCCESS = "success"; + public static final String SHANGAN_STATUS = "status"; + public static final String SHANGAN_SUCCESS = "success"; + public static final String SHANGAN_FAIL = "fail"; + public static final String SHANGAN_ERROR_CODE = "errorCode"; + public static final SimpleDateFormat dateInFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); diff --git a/mallinkService/src/main/java/com/iformall/utils/car/TJDUtil.java b/mallinkService/src/main/java/com/iformall/utils/car/TJDUtil.java index 62089fd95..4dc2c2507 100644 --- a/mallinkService/src/main/java/com/iformall/utils/car/TJDUtil.java +++ b/mallinkService/src/main/java/com/iformall/utils/car/TJDUtil.java @@ -3,8 +3,7 @@ package com.iformall.utils.car; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.iformall.domain.po.WxCoupon; -import com.iformall.domain.po.WxCouponOrder; +import com.iformall.enums.EnumCouponUnit; import com.iformall.utils.MapUtil; import org.apache.http.Consts; import org.apache.http.HttpEntity; @@ -378,7 +377,7 @@ public class TJDUtil { public static String deductionForDetail( String url, String partner, String key, String version, String tradeId, String accountId, - WxCouponOrder couponOrder, WxCoupon coupon) { + String couponOrderId, String couponType, String reduceAmount) { // 为指定订单抵扣停车费,如果此时车辆已经出场,返回isSuccess错误码为3,停简单系统不再接收此笔抵扣信息,对方系统 需要给用户发起退款。 String service = "parkhub.order.deductionForDetail"; Map paramMap = MapUtil.getOrderMap(); @@ -388,17 +387,16 @@ public class TJDUtil { JSONArray detailArr = new JSONArray(); JSONObject detailObj = new JSONObject(); - detailObj.put(TJD_OUT_TRADE_NO, String.valueOf(couponOrder.getId())); + detailObj.put(TJD_OUT_TRADE_NO, couponOrderId); detailObj.put(TJD_TYPE, TJD_TYPE_COUPON); detailObj.put(TJD_CHANNEL, "2204"); String memo = "会员优惠券"; - if (coupon.getUnit().equals(0)) { - detailObj.put(TJD_COUPON_TYPE, "0"); - detailObj.put(TJD_AMOUNT, coupon.getPriceStr()); + detailObj.put(TJD_COUPON_TYPE, couponType); + if (couponType.equals(String.valueOf(EnumCouponUnit.MONEY.getCode()))) { + detailObj.put(TJD_AMOUNT, reduceAmount); memo += "-金额"; } else { - detailObj.put(TJD_COUPON_TYPE, "1"); - detailObj.put(TJD_MINUTES, String.valueOf(coupon.getPrice()*60)); + detailObj.put(TJD_MINUTES, reduceAmount); memo += "-时长"; } detailObj.put(TJD_MEMO, memo);