developrelease_toaliyun_real
| @@ -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<String, String> 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(), "优免券领取失败"); | |||
| } | |||
| @@ -156,6 +156,8 @@ public enum ErrorCode{ | |||
| TJD_STOP_FEE_FAIL(2062, "TJD停车费失败"), | |||
| TJD_DEDUCE_FEE_FAIL(2063, "TJD停车费抵扣失败"), | |||
| SHANGAN_COUPON_FAIL(2070, "优惠券失败"), | |||
| /** | |||
| * 游戏 | |||
| @@ -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) { | |||
| @@ -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; | |||
| } | |||
| } | |||
| @@ -35,6 +35,7 @@ public class InvestListener implements ApplicationListener<InvestEvent> { | |||
| LambdaQueryWrapper<InvestTaskEntity> query = new LambdaQueryWrapper<>(); | |||
| query.in(InvestTaskEntity::getTargetId, rentEventInfo.getTargetIds()); | |||
| query.eq(InvestTaskEntity::getTargetType, EnumInvestType.RENT); | |||
| query.eq(InvestTaskEntity::getStatus, EnumTaskStatus.NEGOTIATING); | |||
| List<InvestTaskEntity> 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<InvestEvent> { | |||
| 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); | |||
| } | |||
| //} | |||
| } | |||
| } | |||
| @@ -516,6 +516,8 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| LambdaQueryWrapper<InvestTaskEntity> taskQueryWrapper = new LambdaQueryWrapper<>(); | |||
| InvestPageResult<InvestTaskVo> 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(); | |||
| @@ -657,9 +659,8 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| LambdaQueryWrapper<InvestRemindEntity> 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())) | |||
| .apply("date_format(end_date,'%Y-%m-%d') >= {0}", getDayEnd(params.getRemindDate())); | |||
| } | |||
| queryWrapper.orderByDesc(InvestRemindEntity::getCreateDate); | |||
| InvestPageResult<InvestRemindEntity> recordPage = remindService.queryPage(remindPageQuery, queryWrapper); | |||
| @@ -919,7 +920,7 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| } | |||
| Collection<InvestOperateRecordEntity> recordList = entityPageList.getRecords(); | |||
| Map<Long, MallUserInfo> usersMap = getMap(userInfoService.getByIds(getIds(recordList, InvestOperateRecordEntity::getOperator)), MallUserInfo::getId); | |||
| Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(new MallUserInfo()), MallUserInfo::getId); | |||
| //品牌信息 | |||
| List<WxBrand> brands = brandService.listAsPage(null, 1, Integer.MAX_VALUE).getList(); | |||
| @@ -0,0 +1,171 @@ | |||
| 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 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 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"); | |||
| 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<bits.length;i++){ | |||
| int a = bits[i]; | |||
| if(a<0) a+=256; | |||
| if(a<16) buf.append("0"); | |||
| buf.append(Integer.toHexString(a)); | |||
| } | |||
| return buf.toString(); | |||
| } | |||
| /** | |||
| * 签名 | |||
| * @param key | |||
| * @param parkNumber | |||
| * @return | |||
| * @throws NoSuchAlgorithmException | |||
| */ | |||
| public static String getSign(String key, String parkNumber) throws NoSuchAlgorithmException { | |||
| String signValue = md5(key + parkNumber).toUpperCase(); | |||
| logger.debug("sign: " + signValue); | |||
| return signValue; | |||
| } | |||
| public static String couponSend(String url, String key, String parkNumber, String couponModelId, Date expireTime, String plate, String position) { | |||
| Map<String, String> params = new HashMap<>(); | |||
| params.put("parkNum", parkNumber); | |||
| params.put("couponModeId", couponModelId); | |||
| params.put("endTime", dateInFormat.format(expireTime)); | |||
| 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<String, String> 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; | |||
| } | |||
| } | |||
| @@ -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<String, String> 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); | |||