qzy 1 month ago
parent
commit
1c4890d73b

+ 15 - 0
sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlementApi.java

@@ -5,6 +5,7 @@ import com.pj.api.dto.TradeSettlementDto;
 import com.pj.current.dto.APPLoginUserInfo;
 import com.pj.current.satoken.StpAPPUserUtil;
 import com.pj.project4sp.SP;
+import com.pj.tb_order.TbOrderService;
 import com.pj.utils.sg.AjaxJson;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 
@@ -30,6 +32,8 @@ public class HtTradeSettlementApi {
      */
     @Autowired
     HtTradeSettlementService htTradeSettlementService;
+    @Resource
+    private TbOrderService tbOrderService;
 
     /**
      * 查 - 根据id
@@ -40,6 +44,17 @@ public class HtTradeSettlementApi {
         HtTradeSettlement h = htTradeSettlementService.getById(id);
         return AjaxJson.getSuccessData(h);
     }
+   @RequestMapping("getByIds")
+    public AjaxJson getByIds() {
+        StpAPPUserUtil.isLogin();
+       List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
+        List<HtTradeSettlement> list = htTradeSettlementService.listByIds(ids);
+        list.forEach(htTradeSettlement -> {
+           double upPrice= tbOrderService.sumUpPrice(htTradeSettlement.getId());
+           htTradeSettlement.setSumUpPrice(upPrice+"");
+        });
+        return AjaxJson.getSuccessData(list);
+    }
 
     /**
      * 查集合 - 根据条件(参数为空时代表忽略指定条件)

+ 2 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderMapper.java

@@ -31,4 +31,6 @@ public interface TbOrderMapper extends BaseMapper <TbOrder> {
 	ConfirmVo getConfirmStatus(Long orderId);
 
 	List<TbOrder> getOnSaleList(SoMap so);
+
+    double sumUpPrice(Long htTradeSettlementId);
 }

+ 3 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderMapper.xml

@@ -203,6 +203,9 @@
 		order by up_time desc
 
 	</select>
+    <select id="sumUpPrice" resultType="java.lang.Double">
+		select sum(up_price) from tb_order where sale_main_id=#{htTradeSettlementId}
+	</select>
 
 
 </mapper>

+ 4 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderService.java

@@ -1212,4 +1212,8 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         this.updateBatchById(orders);
         htTradeSettlementService.updateById(htTradeSettlement);
     }
+
+    public double sumUpPrice(Long htTradeSettlementId) {
+        return tbOrderMapper.sumUpPrice(htTradeSettlementId);
+    }
 }

+ 3 - 0
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersApiController.java

@@ -98,6 +98,9 @@ public class TbOrdersApiController {
         List<OrderDto> orderDtos = FeignFactory.levelOneServerInterface.getOrderListByMainIds(ids);
         List<Long> leveloneOrderIds = orderDtos.stream().map(OrderDto::getId).collect(Collectors.toList());
         List<TbOrders> orders = tbOrdersService.findByLevelOneOrderIds(leveloneOrderIds);
+        if (orders.isEmpty()){
+            return AjaxJson.getError("订单不存在");
+        }
         String orderIds = orders.stream().map(obj -> obj.getId() + "").collect(Collectors.joining(","));
         APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
         return AjaxJson.toAjax(tbOrdersService.purchaserBuy(orderIds, appLoginInfo.getFk()));

+ 2 - 2
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserApiController.java

@@ -1,5 +1,6 @@
 package com.pj.project.app_user;
 
+import cn.hutool.core.util.StrUtil;
 import com.pj.api.consts.FeignFactory;
 import com.pj.api.dto.AppUserDto;
 import com.pj.api.dto.PeopleDto;
@@ -97,8 +98,7 @@ public class AppUserApiController {
 
     @PostMapping("faceImg")
     public AjaxJson faceImg(String img, Integer type)  throws IOException {
-        if (img == null || img.isEmpty()) return AjaxJson.getError("人脸信息为空!");
-
+        if (StrUtil.isEmpty(img)) return AjaxJson.getError("人脸信息为空!");
         appUserService.authFace(StpAPPUserUtil.getAPPLoginInfo().getLoginId(), img, type);
         return AjaxJson.getSuccess();
     }

+ 4 - 0
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserService.java

@@ -657,6 +657,10 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
             throw new AjaxError("识别失败");
         }
         byte[]images = ImageUtils.resizeByteImageBase64(img);
+        boolean hasPerson = faceFactory.handler().checkHasPerson(images);
+        if (!hasPerson){
+            throw new AjaxError("请正视摄像头");
+        }
         if (type == 2) {
             AppUser db = getById(loginId);
             VerifyVO result = faceFactory.handler().verify(db.getFaceId(), images);

+ 31 - 10
sp-service/sp-admin/src/main/java/com/pj/project4sp/face/handler/impl/TencenFaceHandlerImpl.java

@@ -59,7 +59,7 @@ public class TencenFaceHandlerImpl implements IFaceHandler {
 
     @Override
     public VerifyVO verify(String faceId, byte[] imageBytes) {
-       String base64Images= Base64.getEncoder().encodeToString(imageBytes);
+        String base64Images = Base64.getEncoder().encodeToString(imageBytes);
         return verify(faceId, base64Images);
     }
 
@@ -106,7 +106,7 @@ public class TencenFaceHandlerImpl implements IFaceHandler {
         req.setImage(imageBase);
         // 返回的resp是一个CreatePersonResponse的实例,与请求对象对应
         try {
-            CreatePersonResponse response=   client.CreatePerson(req);
+            CreatePersonResponse response = client.CreatePerson(req);
         } catch (TencentCloudSDKException e) {
             e.printStackTrace();
         }
@@ -115,7 +115,7 @@ public class TencenFaceHandlerImpl implements IFaceHandler {
 
     @Override
     public void createPersonByBase(String faceId, String name, byte[] imageBase) {
-        String base64Images= Base64.getEncoder().encodeToString(imageBase);
+        String base64Images = Base64.getEncoder().encodeToString(imageBase);
         createPersonByBase(faceId, name, base64Images);
     }
 
@@ -139,7 +139,8 @@ public class TencenFaceHandlerImpl implements IFaceHandler {
         // 实例化一个请求对象,每个接口都会对应一个request对象
         DetectFaceRequest req = new DetectFaceRequest();
         req.setMaxFaceNum(1L);
-        req.setMinFaceSize(1L);
+        req.setNeedFaceAttributes(1L);
+        req.setNeedQualityDetection(1L);
         req.setImage(img);
         // 返回的resp是一个DetectFaceResponse的实例,与请求对象对应
         DetectFaceResponse resp = null;
@@ -155,20 +156,40 @@ public class TencenFaceHandlerImpl implements IFaceHandler {
         // 输出json格式的字符串回包
         log.info(AbstractModel.toJsonString(resp));
         FaceInfo[] faceInfos = resp.getFaceInfos();
-        if (faceInfos.length>1){
+        if (faceInfos.length > 1) {
             throw new AjaxError("存在多个人脸");
         }
-        FaceInfo faceInfo=faceInfos[0];
-       Long score= faceInfo.getFaceQualityInfo().getScore();
-        if (score == null || score < 70) {
-            throw new AjaxError("请正视摄像头");
+        FaceInfo faceInfo = faceInfos[0];
+        Long score = faceInfo.getFaceQualityInfo().getScore();
+        if (score == null || score < 80) {
+            FaceQualityInfo faceQualityInfo = faceInfo.getFaceQualityInfo();
+            Long brightness = faceQualityInfo.getBrightness();
+            if (brightness == null || brightness < 30) {
+                throw new AjaxError("光线不足");
+            }
+            if (brightness > 70) {
+                throw new AjaxError("光线太亮");
+            }
+            FaceQualityCompleteness completeness = faceQualityInfo.getCompleteness();
+            if (completeness.getMouth() == null || completeness.getMouth() < 50) {
+                throw new AjaxError("请露出嘴巴");
+            }
+            if (completeness.getChin()==null||completeness.getChin()<70) {
+                throw new AjaxError("请露出下巴");
+            }
+            FaceAttributesInfo faceAttributesInfo = faceInfo.getFaceAttributesInfo();
+            if (!faceAttributesInfo.getEyeOpen()) {
+                throw new AjaxError("请睁开眼");
+            }
+
         }
+
         return true;
     }
 
     @Override
     public boolean checkHasPerson(byte[] imageBase) {
-        String base64Images= Base64.getEncoder().encodeToString(imageBase);
+        String base64Images = Base64.getEncoder().encodeToString(imageBase);
         return checkHasPerson(base64Images);
     }