From 9d67b4462bf494a0b25c1b40be8198f71666131e Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 18 二月 2025 14:39:26 +0800
Subject: [PATCH] jtt808初始化
---
server/web/src/main/java/com/doumee/api/web/BusinessApi.java | 15 ++
server/services/src/main/java/com/doumee/dao/business/web/request/LocaltionDTO.java | 25 ++++
server/services/src/main/java/com/doumee/core/constants/Constants.java | 20 ---
server/services/src/main/java/com/doumee/dao/business/model/MemberRides.java | 3
server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java | 5
server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java | 154 +++++++++++++++++++++++++
server/services/src/main/java/com/doumee/service/business/GoodsorderService.java | 7 +
server/services/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java | 19 ++-
server/services/src/main/java/com/doumee/core/utils/PositionUtil.java | 72 ++++++++++++
server/services/src/main/java/com/doumee/dao/business/web/request/BackElecBikeRequest.java | 30 +++++
10 files changed, 323 insertions(+), 27 deletions(-)
diff --git a/server/services/src/main/java/com/doumee/core/constants/Constants.java b/server/services/src/main/java/com/doumee/core/constants/Constants.java
index 7de901b..8589721 100644
--- a/server/services/src/main/java/com/doumee/core/constants/Constants.java
+++ b/server/services/src/main/java/com/doumee/core/constants/Constants.java
@@ -1,6 +1,7 @@
package com.doumee.core.constants;
import ch.qos.logback.core.util.COWArrayList;
+import com.doumee.dao.business.web.request.LocaltionDTO;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.StringUtils;
@@ -214,11 +215,7 @@
//閽夐拤閫氱煡鍦板潃
public static final String DINGDING_URL = "DINGDING_URL";
//閽夐拤绛惧悕
- public static void main(String[] args) {
- double[][] polygon = {{120, 30}, {121, 30}, {121, 31}, {120, 31}}; // 缁忕含搴﹀垪琛ㄨ〃绀哄杈瑰舰椤剁偣
- boolean isInside = isPointInPolygon(122.5, 30.5, polygon);
- System.out.println("Is inside: " + isInside);
- }
+
//灏忕▼搴忔弧杞介璀�(%)鏈�澶у��
public static final String WARN_MAX = "WARN_MAX";
//灏忕▼搴忔弧杞介璀�(%)鏈�灏忓��
@@ -606,19 +603,6 @@
return Constants.formatDecimalNum(money).divide(new BigDecimal(100), 2, BigDecimal.ROUND_UP);
}
-
- public static boolean isPointInPolygon(double px, double py, double[]... polygon) {
- int i, j;
- boolean result = false;
- for (i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
- if ((polygon[i][1] > py) != (polygon[j][1] > py) &&
- (px < (polygon[j][0] - polygon[i][0]) * (py - polygon[i][1]) / (polygon[j][1] - polygon[i][1]) + polygon[i][0])) {
- result = !result;
- }
- }
- return result;
- }
-
}
diff --git a/server/services/src/main/java/com/doumee/core/utils/PositionUtil.java b/server/services/src/main/java/com/doumee/core/utils/PositionUtil.java
new file mode 100644
index 0000000..74294d2
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/core/utils/PositionUtil.java
@@ -0,0 +1,72 @@
+package com.doumee.core.utils;
+
+
+import com.doumee.dao.business.web.request.LocaltionDTO;
+
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 璁$畻璺濈
+ */
+public class PositionUtil {
+
+ /**
+ * 鍒ゆ柇鍧愭爣鐐规槸鍚﹀湪澶氳竟褰㈠尯鍩熷唴
+ *
+ * @param pointLon 瑕佸垽鏂殑鐐圭殑缁忓害
+ * @param pointLat 瑕佸垽鏂殑鐐圭殑绾害
+ * @return true锛氳寖鍥村唴; false锛氳寖鍥村
+ */
+ public static boolean isInPolygon(double pointLon, double pointLat, List<LocaltionDTO> list) {
+ if(list==null ||list.size()==0){
+ return false;
+ }
+ double[] lon = new double[list.size()];
+ double[] lat = new double[list.size()];
+ for (int i = 0; i < list.size(); i++) {
+ lon[i] = list.get(i).getLng() ==null?0:list.get(i).getLng();
+ lat[i] = list.get(i).getLat() ==null?0:list.get(i).getLat();
+ }
+ // 灏嗚鍒ゆ柇鐨勬í绾靛潗鏍囩粍鎴愪竴涓偣
+ Point2D.Double point = new Point2D.Double(pointLon, pointLat);
+ // 灏嗗尯鍩熷悇椤剁偣鐨勬í绾靛潗鏍囨斁鍒颁竴涓偣闆嗗悎閲岄潰
+ List<Point2D.Double> pointList = new ArrayList<>();
+ double polygonPointToX;
+ double polygonPointToY;
+ for (int i = 0; i < lon.length; i++) {
+ polygonPointToX = lon[i];
+ polygonPointToY = lat[i];
+ Point2D.Double polygonPoint = new Point2D.Double(polygonPointToX, polygonPointToY);
+ pointList.add(polygonPoint);
+ }
+ return check(point, pointList);
+ }
+
+ /**
+ * 鍧愭爣鐐规槸鍚﹀湪澶氳竟褰㈠唴
+ *
+ * @param point 瑕佸垽鏂殑鐐圭殑妯旱鍧愭爣
+ * @param polygon 缁勬垚鐨勯《鐐瑰潗鏍囬泦鍚�
+ */
+ private static boolean check(Point2D.Double point, List<Point2D.Double> polygon) {
+ GeneralPath generalPath = new GeneralPath();
+
+ Point2D.Double first = polygon.get(0);
+ // 閫氳繃绉诲姩鍒版寚瀹氬潗鏍囷紙浠ュ弻绮惧害鎸囧畾锛夛紝灏嗕竴涓偣娣诲姞鍒拌矾寰勪腑
+ generalPath.moveTo(first.x, first.y);
+ polygon.remove(0);
+ for (Point2D.Double d : polygon) {
+ // 閫氳繃缁樺埗涓�鏉′粠褰撳墠鍧愭爣鍒版柊鎸囧畾鍧愭爣锛堜互鍙岀簿搴︽寚瀹氾級鐨勭洿绾匡紝灏嗕竴涓偣娣诲姞鍒拌矾寰勪腑銆�
+ generalPath.lineTo(d.x, d.y);
+ }
+ // 灏嗗嚑浣曞杈瑰舰灏侀棴
+ generalPath.lineTo(first.x, first.y);
+ generalPath.closePath();
+ // 娴嬭瘯鎸囧畾鐨� Point2D 鏄惁鍦� Shape 鐨勮竟鐣屽唴銆�
+ return generalPath.contains(point);
+ }
+
+}
\ No newline at end of file
diff --git a/server/services/src/main/java/com/doumee/dao/business/model/MemberRides.java b/server/services/src/main/java/com/doumee/dao/business/model/MemberRides.java
index fd456a1..3728dac 100644
--- a/server/services/src/main/java/com/doumee/dao/business/model/MemberRides.java
+++ b/server/services/src/main/java/com/doumee/dao/business/model/MemberRides.java
@@ -164,6 +164,9 @@
@ApiModelProperty(value = "楠戣鏃堕暱")
@TableField(exist = false)
private Integer rideTime;
+ @ApiModelProperty(value = "鎺у埗鍣ㄧ紪鐮�")
+ @TableField(exist = false)
+ private String deviceSn;
@ApiModelProperty(value = "鎺掑簭鐮侊紙鍗囧簭锛�", example = "1")
@TableField(exist = false)
private Integer sortnum;
diff --git a/server/services/src/main/java/com/doumee/dao/business/web/request/BackElecBikeRequest.java b/server/services/src/main/java/com/doumee/dao/business/web/request/BackElecBikeRequest.java
new file mode 100644
index 0000000..2d06c79
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/dao/business/web/request/BackElecBikeRequest.java
@@ -0,0 +1,30 @@
+package com.doumee.dao.business.web.request;
+
+import com.doumee.core.annotation.excel.ExcelColumn;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * Created by IntelliJ IDEA.
+ *
+ * @Author : Rk
+ * @create 2023/10/9 11:04
+ */
+@Data
+@ApiModel("鐢佃溅绔欑偣杩樿溅璇锋眰鍙傛暟")
+public class BackElecBikeRequest {
+
+ @ApiModelProperty(value = "绾害")
+ private Double latitude;
+ @ApiModelProperty(value = "缁忓害")
+ private Double longitude;
+
+ @ApiModelProperty(value = "鐢ㄦ埛缂栫爜锛堝叧鑱攎ember琛級",hidden = true)
+ private String memberId;
+
+
+}
diff --git a/server/services/src/main/java/com/doumee/dao/business/web/request/LocaltionDTO.java b/server/services/src/main/java/com/doumee/dao/business/web/request/LocaltionDTO.java
new file mode 100644
index 0000000..67ef0d4
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/dao/business/web/request/LocaltionDTO.java
@@ -0,0 +1,25 @@
+package com.doumee.dao.business.web.request;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * Created by IntelliJ IDEA.
+ *
+ * @Author : Rk
+ * @create 2023/10/9 11:04
+ */
+@Data
+@ApiModel("瀹氫綅鍦板潃瀵硅薄鍙傛暟")
+public class LocaltionDTO {
+
+ @ApiModelProperty(value = "绾害")
+ private Double lat;
+ @ApiModelProperty(value = "缁忓害")
+ private Double lng;
+
+
+}
diff --git a/server/services/src/main/java/com/doumee/service/business/GoodsorderService.java b/server/services/src/main/java/com/doumee/service/business/GoodsorderService.java
index d2b4746..d7bd238 100644
--- a/server/services/src/main/java/com/doumee/service/business/GoodsorderService.java
+++ b/server/services/src/main/java/com/doumee/service/business/GoodsorderService.java
@@ -6,14 +6,17 @@
import com.doumee.core.model.PageWrap;
import com.doumee.dao.business.model.Bikes;
import com.doumee.dao.business.model.Goodsorder;
+import com.doumee.dao.business.model.MemberRides;
import com.doumee.dao.business.vo.GoodsorderExportVO;
import com.doumee.dao.business.vo.GoodsorderTotalDataVO;
+import com.doumee.dao.business.web.request.BackElecBikeRequest;
import com.doumee.dao.business.web.request.GoodsorderBackDTO;
import com.doumee.dao.business.web.request.GoodsorderCanBanlanceDTO;
import com.doumee.dao.business.web.response.HomeResponse;
import com.doumee.dao.business.web.response.GoodsorderDetailDTO;
import com.doumee.dao.business.web.response.RidesDetailResponse;
import com.wechat.pay.java.service.refund.model.RefundNotification;
+import io.swagger.models.auth.In;
import java.math.BigDecimal;
import java.util.List;
@@ -147,6 +150,7 @@
* @return
*/
void closeGoodsorder(Goodsorder order,int type );
+ void dealCloseGoodsorderBiz(Goodsorder goodsorder, int type, List<MemberRides> memberRides) ;
void closeGoodsorderDone(RefundNotification param);
void forceCloseGoodsorder(String orderId);
@@ -155,7 +159,7 @@
* @param orderId
*/
void backGoodsorder(GoodsorderBackDTO goodsorderBackDTO);
-
+ List<MemberRides> getMemberRidesForClose(String orderid );
/**
* 鑾峰彇鍙��娆句俊鎭�
* @param orderId
@@ -191,4 +195,5 @@
void autoCloseOrder();
void autoCancelRefunOrder();
+
}
diff --git a/server/services/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java
index 67e8f95..43b7c48 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java
@@ -89,6 +89,7 @@
private SystemDictDataBiz systemDictDataBiz;
+
@Autowired
private MemberMapper memberMapper;
@Autowired
@@ -531,7 +532,11 @@
if(r != null){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "璇ヨ鍗曞瓨鍦ㄩ��娆剧敵璇锋鍦ㄥ鐞嗕腑锛岃绋嶅悗鏌ョ湅璁㈠崟淇℃伅鍝");
}
- List<MemberRides> memberRides = getMemberRidesForClose(goodsorder.getId());
+ List<MemberRides> memberRides = getMemberRidesForClose(goodsorder.getId());//鎵撹溅楠戣璁板綍
+ dealCloseGoodsorderBiz(goodsorder,type,memberRides);
+ }
+ @Override
+ public void dealCloseGoodsorderBiz(Goodsorder goodsorder, int type, List<MemberRides> memberRides) {
//榛樿缁撶畻涓烘娂閲戦噾棰�
BigDecimal closeMoney = new BigDecimal(0.00);
if (!CollectionUtils.isEmpty(memberRides)){
@@ -563,7 +568,8 @@
closeGoodsorderDoneNoRefund(goodsorder,type,new BigDecimal(0),null,memberRides);
}
}
- public void closeGoodsorderDoneNoRefund(Goodsorder goodsorder,int type,BigDecimal refundMoney,String closeId,List<MemberRides> memberRides ) {
+
+ public void closeGoodsorderDoneNoRefund(Goodsorder goodsorder,int type,BigDecimal refundMoney,String closeId,List<MemberRides> memberRides) {
log.error("========================================"+JSONObject.toJSONString(goodsorder));
if(goodsorder ==null || Constants.formatIntegerNum(goodsorder.getStatus()) != Constants.GOODSORDER_STATUS.HAVING_PAY.getKey()){
return;
@@ -806,19 +812,20 @@
return ridesDetailResponse;
}
- private List<MemberRides> getMemberRidesForClose(String id) {
-
+ @Override
+ public List<MemberRides> getMemberRidesForClose(String id) {
MPJLambdaWrapper<MemberRides> wrapper = new MPJLambdaWrapper<>();
wrapper.eq(MemberRides::getOrdreId,id);
wrapper.ne(MemberRides::getStatus,Constants.MEMBER_RIDES_STATUS.LOCKING_DEFEAT.getKey());
wrapper.selectAll(MemberRides.class)
+ .select("select b.device_sn from bikes b where b.isdeleted=0 and b.code = t.bike_code limit 1",MemberRides::getDeviceSn)
.selectAs(BaseParam::getSortnum, MemberRides::getSortnum)
.selectAs(BaseParam::getName, MemberRides::getParamName);
wrapper.leftJoin(BaseParam.class, BaseParam::getId, MemberRides::getParamId);
wrapper.orderByDesc(BaseParam::getSortnum);
//鍙栨渶楂樿溅鍨嬩綔涓鸿浠锋柟妗�
//鏌ヨ鎵�鏈夐獞琛岃褰�
- List<MemberRides> memberRides = memberRidesJoinMapper.selectList(wrapper);
+ List<MemberRides> memberRides = memberRidesJoinMapper.selectJoinList(MemberRides.class,wrapper);
return memberRides;
}
@@ -1187,7 +1194,7 @@
@Override
public void autoCloseOrder( ) {
- Goodsorder goodsorder = new Goodsorder();
+ Goodsorder goodsorder = new Goodsorder();
goodsorder.setIsdeleted(Constants.ZERO);
goodsorder.setStatus(Constants.goodsorderStatus.pay);
List<Goodsorder> list = findList(goodsorder);
diff --git a/server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java b/server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
index 9dc3936..94b3265 100644
--- a/server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
+import com.doumee.dao.business.web.request.LocaltionDTO;
import com.doumee.dao.business.web.response.MiniProgrammeDTO;
import com.doumee.dao.system.SystemDictMapper;
import com.doumee.dao.system.model.SystemDict;
@@ -143,8 +144,8 @@
try {
if(miniProgrammeDTO.getParkLatLngList()!=null){
try {
- TypeReference typeReference = new TypeReference<List<Map<String,BigDecimal>>>(){};
- List<Map<String,BigDecimal>> response = JSONObject.parseObject(miniProgrammeDTO.getParkLatLngList(), typeReference.getType());
+ TypeReference typeReference = new TypeReference<List<LocaltionDTO>>(){};
+ List<LocaltionDTO> response = JSONObject.parseObject(miniProgrammeDTO.getParkLatLngList(), typeReference.getType());
}catch (Exception e){
e.printStackTrace();
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"杩愯惀鍖哄煙鍙傛暟瑙f瀽鏈夎锛�");
diff --git a/server/web/src/main/java/com/doumee/api/web/BusinessApi.java b/server/web/src/main/java/com/doumee/api/web/BusinessApi.java
index b5d65b1..b054b80 100644
--- a/server/web/src/main/java/com/doumee/api/web/BusinessApi.java
+++ b/server/web/src/main/java/com/doumee/api/web/BusinessApi.java
@@ -10,10 +10,12 @@
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.dao.business.model.*;
+import com.doumee.dao.business.web.request.BackElecBikeRequest;
import com.doumee.dao.business.web.request.RepairRequest;
import com.doumee.dao.business.web.response.MemberRidesDetailResponse;
import com.doumee.dao.business.web.response.RidesDetailResponse;
import com.doumee.dao.system.model.SystemDictData;
+import com.doumee.jtt808.web.service.Jtt808Service;
import com.doumee.service.business.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -22,6 +24,9 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import org.yzh.commons.model.APIResult;
+import org.yzh.protocol.t808.T0201_0500;
+import org.yzh.protocol.t808.T8500;
import java.util.List;
@@ -41,6 +46,8 @@
@Autowired
private GoodsorderService goodsorderService;
+ @Autowired
+ private Jtt808Service jtt808Service;
@Autowired
private RentSiteService rentSiteService;
@@ -188,4 +195,12 @@
public ApiResponse<SystemDictData> getSysDict(@RequestParam String dicCode, @RequestParam String label) {
return ApiResponse.success("鏌ヨ鎴愬姛",systemDictDataBiz.queryByCode(dicCode,label));
}
+
+ @ApiOperation(value = "鐢佃溅绔欑偣杩樿溅", notes = "鐢佃溅绔欑偣杩樿溅")
+ @PostMapping("/backElecBike")
+ public ApiResponse backElecBike(@RequestBody BackElecBikeRequest param) {
+ param.setMemberId(getMemberId());
+ jtt808Service.backElecBike(param);
+ return ApiResponse.success( null);
+ }
}
diff --git a/server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java b/server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java
index 1ae9388..f596927 100644
--- a/server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java
+++ b/server/web/src/main/java/com/doumee/jtt808/web/service/Jtt808Service.java
@@ -1,23 +1,177 @@
package com.doumee.jtt808.web.service;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.doumee.biz.system.SystemDictDataBiz;
+import com.doumee.core.constants.Constants;
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
+import com.doumee.core.utils.PositionUtil;
+import com.doumee.core.utils.StringTools;
+import com.doumee.core.wx.WxMiniUtilService;
+import com.doumee.dao.business.*;
+import com.doumee.dao.business.join.GoodsorderJoinMapper;
+import com.doumee.dao.business.join.MemberRidesJoinMapper;
+import com.doumee.dao.business.join.RefundJoinMapper;
+import com.doumee.dao.business.model.*;
+import com.doumee.dao.business.web.request.BackElecBikeRequest;
+import com.doumee.dao.business.web.request.LocaltionDTO;
import com.doumee.jtt808.web.endpoint.MessageManager;
+import com.doumee.service.business.GoodsorderService;
+import com.doumee.service.business.PricingRuleService;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.yzh.commons.model.APIResult;
import org.yzh.protocol.t808.T0201_0500;
import org.yzh.protocol.t808.T8500;
import reactor.core.publisher.Mono;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+
@Service
public class Jtt808Service {
@Autowired
private MessageManager messageManager;
+ @Autowired
+ private GoodsorderService goodsorderService;
+ @Autowired
+ private DiscountMemberMapper discountMemberMapper;
+
+ @Autowired
+ private DiscountLogMapper discountLogMapper;
+
+ @Autowired
+ GoodsorderJoinMapper goodsorderJoinMapper;
+
+ @Autowired
+ private SystemDictDataBiz systemDictDataBiz;
+
+ @Autowired
+ private MemberMapper memberMapper;
+ @Autowired
+ private BaseParamMapper baseParamMapper;
+ @Autowired
+ private RefundMapper refundMapper;
+
+ @Autowired
+ private RefundJoinMapper refundJoinMapper;
+ @Autowired
+ private SitesMapper sitesMapper;
+
+ @Autowired
+ private MemberRidesJoinMapper memberRidesJoinMapper;
+
+ @Autowired
+ private AdMapper adMapper;
+
+ @Autowired
+ private TransactionsMapper transactionsMapper;
+
+ @Autowired
+ private WxMiniUtilService wxMiniUtilService;
+
+ @Autowired
+ PricingRuleService pricingRuleService;
public APIResult<T0201_0500> bikeControl(@RequestBody T8500 request) {
Mono<APIResult<T0201_0500>> result = messageManager.requestR(request, T0201_0500.class);
APIResult<T0201_0500> data = result.block();
return data;
}
+ @Transactional(rollbackFor = {BusinessException.class})
+ public void backElecBike(BackElecBikeRequest param) {
+ if (param.getLatitude() == null || param.getLongitude() == null || StringUtils.isBlank(param.getMemberId())) {
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝瀹氫綅淇℃伅鏈夎锛岃纭瀹氫綅鏉冮檺宸插紑鍚紒");
+ }
+ Member member = memberMapper.selectById(param.getMemberId());
+ if (member == null) {
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鎮ㄧ殑璐﹀彿淇℃伅鏌ヨ澶辫触锛岃杩斿洖閲嶆柊杩涘叆灏忕▼搴忓啀璇曪紒");
+ }
+ Goodsorder gparam = new Goodsorder();
+ gparam.setMemberId(param.getMemberId());
+ gparam.setStatus(Constants.goodsorderStatus.pay);
+ Goodsorder goodsorder = goodsorderService.findOne(gparam);
+ if(Objects.isNull(goodsorder)){
+ throw new BusinessException(ResponseStatus.NO_UNCLOSEED_ORDER.getCode(),"鏃犻獞琛岃鍗曡褰�");
+ }
+ if(Constants.formatIntegerNum(goodsorder.getStatus()) != Constants.GOODSORDER_STATUS.HAVING_PAY.getKey() ){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヨ鍗曞綋鍓嶇姸鎬佷笉鏀寔缁撶畻鎿嶄綔锛岃灏濊瘯鍒锋柊鍒楄〃閲嶈瘯锛�" );
+ }
+ //鏌ヨ楠戣璁板綍
+ List<MemberRides> memberRides = goodsorderService.getMemberRidesForClose(goodsorder.getId());
+ if(memberRides!=null && memberRides.size()>0){
+ for (MemberRides rides : memberRides){
+ if(Constants.equalsInteger(rides.getStatus(),Constants.MEMBER_RIDES_STATUS.RIDES_RUNNING.getKey())){
+ if(StringUtils.isNotBlank(rides.getDeviceSn()) &&Constants.equalsInteger(rides.getType(),Constants.ONE) ){
+ Sites site = getBackSiteByPostion(param);//鏌ヨ鍋滆溅绔欑偣淇℃伅
+ //濡傛灉鏄數杞﹀苟涓旀槸楠戣涓� 杩涜鍏抽攣澶勭悊
+ lockBikes(rides.getDeviceSn(),Constants.ZERO);//鍙戣捣鍏抽攣鎸囦护璇锋眰
+ }
+ }
+ }
+ }
+ //璁㈠崟缁撶畻
+ Date date = new Date();
+ goodsorder.setEditDate(date);
+ goodsorder.setEditor(null);
+ goodsorderService.dealCloseGoodsorderBiz( goodsorder,Constants.REFUND_TYPE.NORMAL.getKey(),memberRides);
+
+ }
+
+ /**
+ * 鍙戣捣鍏抽攣銆佸紑閿佹寚浠よ姹�
+ * @param clientId
+ */
+ private void lockBikes(String clientId,int type) {
+ T8500 request = new T8500();
+ request.setType(type);//鍏抽攣
+ request.setClientId(StringTools.leftPad(clientId,12,'0'));
+ Mono<APIResult<T0201_0500>> result = messageManager.requestR(request, T0201_0500.class);
+ APIResult<T0201_0500> data = result.block();
+ if(!data.isSuccess()){
+ //濡傛灉寮�閿佸け璐ワ紝鍒欒繑鍥炲紓甯�
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝杩樿溅鍏抽攣澶辫触锛岃绋嶅悗閲嶈瘯锛屾垨鑰呰仈绯诲洯鍖虹鐞嗕汉鍛橈紒");
+ }
+ }
+
+ /**
+ * 鏌ヨ鍋滆溅绔欑偣淇℃伅
+ * @param param
+ * @return
+ */
+ private Sites getBackSiteByPostion(BackElecBikeRequest param) {
+ Sites site = null;//鏌ヨ鍋滆溅绔欑偣淇℃伅
+ List<Sites> sitesList = sitesMapper.selectList(new QueryWrapper<Sites>().lambda()
+ .eq(Sites::getStatus,Constants.ZERO)
+ .eq(Sites::getIsdeleted,Constants.ZERO)
+ .eq(Sites::getType,Constants.ONE));
+ if(sitesList ==null ||sitesList.size() ==0){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝璇锋寜鐓ц姹傚墠寰�鍋滆溅鐐瑰仠杞︼紒");
+ }
+ for(Sites sites :sitesList){
+ TypeReference typeReference = new TypeReference<List<LocaltionDTO>>(){};
+ List<LocaltionDTO> array = JSONObject.parseObject(sites.getElectronicFence(), typeReference.getType());
+ if(array == null || array.size() ==0){
+ continue;
+ }
+ if(PositionUtil.isInPolygon(param.getLongitude(),param.getLatitude(),array)){
+ //濡傛灉鍦ㄥ仠杞︾偣鑼冨洿鍐咃紱
+ site = sites;
+ break;
+ }
+ if(site ==null){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝璇锋寜鐓ц姹傚墠寰�鍋滆溅鐐瑰仠杞︼紒");
+ }
+ }
+ return site;
+ }
}
--
Gitblit v1.9.3