Преглед на файлове

Merge branch 'feature/asyncOrder' into feature/payTemp

# Conflicts:
#	sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderService.java
qzy преди 2 седмици
родител
ревизия
6e70ef7625
променени са 26 файла, в които са добавени 433 реда и са изтрити 691 реда
  1. 11 439
      sp-core/sp-api/src/main/java/com/pj/api/dto/PaymentDto.java
  2. 4 2
      sp-core/sp-base/src/main/java/com/pj/current/config/SystemObject.java
  3. 5 0
      sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlement.java
  4. 0 9
      sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlementController.java
  5. 33 0
      sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlementMapper.xml
  6. 17 7
      sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlementService.java
  7. 9 0
      sp-service/level-one-server/src/main/java/com/pj/tb_import_order/TbImportOrder.java
  8. 2 1
      sp-service/level-one-server/src/main/java/com/pj/tb_import_order/TbImportOrderMapper.java
  9. 2 2
      sp-service/level-one-server/src/main/java/com/pj/tb_import_order/TbImportOrderMapper.xml
  10. 27 41
      sp-service/level-one-server/src/main/java/com/pj/tb_import_order/TbImportOrderService.java
  11. 7 1
      sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrder.java
  12. 4 1
      sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderAppController.java
  13. 13 0
      sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderController.java
  14. 79 13
      sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderService.java
  15. 1 1
      sp-service/level-one-server/src/main/resources/logback.xml
  16. 28 8
      sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersApiController.java
  17. 34 12
      sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersController.java
  18. 2 0
      sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersMapper.xml
  19. 29 1
      sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersService.java
  20. 4 0
      sp-service/payment-server/src/main/java/com/pj/bank_info/BankInfo.java
  21. 90 68
      sp-service/payment-server/src/main/java/com/pj/bank_info/BankInfoController.java
  22. 2 1
      sp-service/payment-server/src/main/java/com/pj/bank_info/BankInfoMapper.xml
  23. 9 7
      sp-service/payment-server/src/main/java/com/pj/xml/MessageXML.java
  24. 0 6
      sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserApiController.java
  25. 11 50
      sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserController.java
  26. 10 21
      sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserService.java

+ 11 - 439
sp-core/sp-api/src/main/java/com/pj/api/dto/PaymentDto.java

@@ -1,6 +1,8 @@
 package com.pj.api.dto;
 
 
+import lombok.Data;
+
 import java.io.Serializable;
 import java.math.BigDecimal;
 
@@ -8,8 +10,16 @@ import java.math.BigDecimal;
  * 银行报文数据(一级市场)
  * @author lbl
  */
+@Data
 public class PaymentDto implements Serializable {
-
+	/**
+	 * 通道代码
+	 */
+	private String channelNo;
+	/**
+	 * 申报编号
+	 */
+	private String trans;
 
 	private Long id;
 
@@ -222,443 +232,5 @@ public class PaymentDto implements Serializable {
 
 	private String tradeNos;
 
-	public String getTradeNos() {
-		return tradeNos;
-	}
-
-	public void setTradeNos(String tradeNos) {
-		this.tradeNos = tradeNos;
-	}
-
-	public String getOwnerName() {
-		return ownerName;
-	}
-
-	public void setOwnerName(String ownerName) {
-		this.ownerName = ownerName;
-	}
-
-	public String getOwnerIdtype() {
-		return ownerIdtype;
-	}
-
-	public void setOwnerIdtype(String ownerIdtype) {
-		this.ownerIdtype = ownerIdtype;
-	}
-
-	public String getBankAccount() {
-		return bankAccount;
-	}
-
-	public void setBankAccount(String bankAccount) {
-		this.bankAccount = bankAccount;
-	}
-
-	public String getBank() {
-		return bank;
-	}
-
-	public void setBank(String bank) {
-		this.bank = bank;
-	}
-
-	public String getOwnerTel() {
-		return ownerTel;
-	}
-
-	public void setOwnerTel(String ownerTel) {
-		this.ownerTel = ownerTel;
-	}
-
-	public String getCodeTs() {
-		return codeTs;
-	}
-
-	public void setCodeTs(String codeTs) {
-		this.codeTs = codeTs;
-	}
-
-	public String getGoodsName() {
-		return goodsName;
-	}
-
-	public void setGoodsName(String goodsName) {
-		this.goodsName = goodsName;
-	}
-
-	public String getGoodsUnit() {
-		return goodsUnit;
-	}
-
-	public void setGoodsUnit(String goodsUnit) {
-		this.goodsUnit = goodsUnit;
-	}
-
-	public Double getDeclPrice() {
-		return declPrice;
-	}
-
-	public void setDeclPrice(Double declPrice) {
-		this.declPrice = declPrice;
-	}
-
-	public Double getBuyQty() {
-		return buyQty;
-	}
-
-	public void setBuyQty(Double buyQty) {
-		this.buyQty = buyQty;
-	}
-
-	public Double getGrossWt() {
-		return grossWt;
-	}
-
-	public void setGrossWt(Double grossWt) {
-		this.grossWt = grossWt;
-	}
-
-	public Double getNetWt() {
-		return netWt;
-	}
-
-	public void setNetWt(Double netWt) {
-		this.netWt = netWt;
-	}
-
-	public String getBorderName() {
-		return borderName;
-	}
-
-	public void setBorderName(String borderName) {
-		this.borderName = borderName;
-	}
-
-	public String getBorderidno() {
-		return borderidno;
-	}
-
-	public void setBorderidno(String borderidno) {
-		this.borderidno = borderidno;
-	}
-
-	public String getPapersType() {
-		return papersType;
-	}
-
-	public void setPapersType(String papersType) {
-		this.papersType = papersType;
-	}
-
-	public String getBorderNationality() {
-		return borderNationality;
-	}
-
-	public void setBorderNationality(String borderNationality) {
-		this.borderNationality = borderNationality;
-	}
-
-	public String getBankCode() {
-		return bankCode;
-	}
-
-	public void setBankCode(String bankCode) {
-		this.bankCode = bankCode;
-	}
-
-	public String getBankName() {
-		return bankName;
-	}
-
-	public void setBankName(String bankName) {
-		this.bankName = bankName;
-	}
-
-	public String getBankNo() {
-		return bankNo;
-	}
-
-	public void setBankNo(String bankNo) {
-		this.bankNo = bankNo;
-	}
-
-	public String getBorderTel() {
-		return borderTel;
-	}
-
-	public void setBorderTel(String borderTel) {
-		this.borderTel = borderTel;
-	}
-
-	public BigDecimal getResalePrice() {
-		return resalePrice;
-	}
-
-	public void setResalePrice(BigDecimal resalePrice) {
-		this.resalePrice = resalePrice;
-	}
-
-	public String getTradeNo() {
-		return tradeNo;
-	}
-
-	public void setTradeNo(String tradeNo) {
-		this.tradeNo = tradeNo;
-	}
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public String getPlatSeqNo() {
-		return platSeqNo;
-	}
-
-	public void setPlatSeqNo(String platSeqNo) {
-		this.platSeqNo = platSeqNo;
-	}
-
-	public String getDeclareId() {
-		return declareId;
-	}
-
-	public void setDeclareId(String declareId) {
-		this.declareId = declareId;
-	}
-
-	public String getDeclareType() {
-		return declareType;
-	}
-
-	public void setDeclareType(String declareType) {
-		this.declareType = declareType;
-	}
-
-	public String getDeclareName() {
-		return declareName;
-	}
-
-	public void setDeclareName(String declareName) {
-		this.declareName = declareName;
-	}
-
-	public String getIdno() {
-		return idno;
-	}
-
-	public void setIdno(String idno) {
-		this.idno = idno;
-	}
-
-	public String getShopNo() {
-		return shopNo;
-	}
-
-	public void setShopNo(String shopNo) {
-		this.shopNo = shopNo;
-	}
-
-	public String getShopName() {
-		return shopName;
-	}
-
-	public void setShopName(String shopName) {
-		this.shopName = shopName;
-	}
-
-	public String getOrgPutrecNo() {
-		return orgPutrecNo;
-	}
-
-	public void setOrgPutrecNo(String orgPutrecNo) {
-		this.orgPutrecNo = orgPutrecNo;
-	}
-
-	public String getOrgName() {
-		return orgName;
-	}
-
-	public void setOrgName(String orgName) {
-		this.orgName = orgName;
-	}
-
-	public String getOrgScc() {
-		return orgScc;
-	}
-
-	public void setOrgScc(String orgScc) {
-		this.orgScc = orgScc;
-	}
-
-	public String getVeNo() {
-		return veNo;
-	}
-
-	public void setVeNo(String veNo) {
-		this.veNo = veNo;
-	}
-
-	public String getBtrnbBizModecd() {
-		return btrnbBizModecd;
-	}
-
-	public void setBtrnbBizModecd(String btrnbBizModecd) {
-		this.btrnbBizModecd = btrnbBizModecd;
-	}
-
-	public String getgFlow() {
-		return gFlow;
-	}
-
-	public void setgFlow(String gFlow) {
-		this.gFlow = gFlow;
-	}
-
-	public String getiEFlag() {
-		return iEFlag;
-	}
-
-	public void setiEFlag(String iEFlag) {
-		this.iEFlag = iEFlag;
-	}
-
-	public String getFieldCode() {
-		return fieldCode;
-	}
-
-	public void setFieldCode(String fieldCode) {
-		this.fieldCode = fieldCode;
-	}
-
-	public String getFieldName() {
-		return fieldName;
-	}
-
-	public void setFieldName(String fieldName) {
-		this.fieldName = fieldName;
-	}
-
-	public String getCustomsCode() {
-		return customsCode;
-	}
-
-	public void setCustomsCode(String customsCode) {
-		this.customsCode = customsCode;
-	}
-
-	public String getCarPool() {
-		return carPool;
-	}
-
-	public void setCarPool(String carPool) {
-		this.carPool = carPool;
-	}
-
-	public Double getSumAmt() {
-		return sumAmt;
-	}
-
-	public void setSumAmt(Double sumAmt) {
-		this.sumAmt = sumAmt;
-	}
-
-	public Double getSumGrossWt() {
-		return sumGrossWt;
-	}
-
-	public void setSumGrossWt(Double sumGrossWt) {
-		this.sumGrossWt = sumGrossWt;
-	}
-
-	public Double getSumNetWt() {
-		return sumNetWt;
-	}
-
-	public void setSumNetWt(Double sumNetWt) {
-		this.sumNetWt = sumNetWt;
-	}
-
-	public String getTrafMode() {
-		return trafMode;
-	}
-
-	public void setTrafMode(String trafMode) {
-		this.trafMode = trafMode;
-	}
-
-	public String getCurrCode() {
-		return currCode;
-	}
-
-	public void setCurrCode(String currCode) {
-		this.currCode = currCode;
-	}
-
-	public Long getPackNo() {
-		return packNo;
-	}
-
-	public void setPackNo(Long packNo) {
-		this.packNo = packNo;
-	}
-
-	public String getDeclTime() {
-		return declTime;
-	}
-
-	public void setDeclTime(String declTime) {
-		this.declTime = declTime;
-	}
-
-	public String getBillNo() {
-		return billNo;
-	}
-
-	public void setBillNo(String billNo) {
-		this.billNo = billNo;
-	}
-
-	public String getVoyageNo() {
-		return voyageNo;
-	}
-
-	public void setVoyageNo(String voyageNo) {
-		this.voyageNo = voyageNo;
-	}
-
-	public String getGoodsNames() {
-		return goodsNames;
-	}
-
-	public void setGoodsNames(String goodsNames) {
-		this.goodsNames = goodsNames;
-	}
-
-	public BigDecimal getTotalPrice() {
-		return totalPrice;
-	}
-
-	public void setTotalPrice(BigDecimal totalPrice) {
-		this.totalPrice = totalPrice;
-	}
-
-	public String getShopSccd() {
-		return shopSccd;
-	}
-
-	public void setShopSccd(String shopSccd) {
-		this.shopSccd = shopSccd;
-	}
-
-	public String getNationality() {
-		return nationality;
-	}
 
-	public void setNationality(String nationality) {
-		this.nationality = nationality;
-	}
 }

+ 4 - 2
sp-core/sp-base/src/main/java/com/pj/current/config/SystemObject.java

@@ -1,5 +1,6 @@
 package com.pj.current.config;
 
+import cn.hutool.core.util.RandomUtil;
 import com.pj.common.core.utils.DateUtils;
 import com.pj.sms.factory.SmsFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -9,6 +10,7 @@ import cn.hutool.crypto.SecureUtil;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.Random;
 
 /**
  * 有关当前项目的一些全局工具方法封装
@@ -62,8 +64,8 @@ public class SystemObject {
     // ===================================== 生成订单号工具类 ===================================================
 
     public static String getREFcode(String rex, Date date) {
-        return rex.concat(DateUtils.parseDateToStr("yyMMddHHmmssSSSS", date));
+        return rex.concat(DateUtils.parseDateToStr("yyMMddHHmmss", date))
+                .concat(RandomUtil.randomNumbers(3)+"0");
     }
 
-
 }

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

@@ -279,6 +279,11 @@ public class HtTradeSettlement extends Model<HtTradeSettlement> implements Seria
 	 */
 	private Date hzsConfirmTime;
 
+	/**
+	 * 上架总数
+	 */
+	private Integer upCount;
+
 
 	@TableField(exist = false)
 	private String sumUpPrice;

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

@@ -42,15 +42,6 @@ public class HtTradeSettlementController {
 		return AjaxJson.getSuccess();
 	}
 
-	/** 删 - 根据id列表 */
-	@RequestMapping("deleteByIds")
-	@SaCheckPermission(HtTradeSettlement.PERMISSION_CODE_DEL)
-	public AjaxJson deleteByIds(){
-		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
-		int line = SP.publicMapper.deleteByIds(HtTradeSettlement.TABLE_NAME, ids);
-		return AjaxJson.getByLine(line);
-	}
-
 	/** 改 */
 	@RequestMapping("update")
 	@SaCheckPermission(HtTradeSettlement.PERMISSION_CODE_EDIT)

+ 33 - 0
sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlementMapper.xml

@@ -58,6 +58,39 @@
 			<if test=' this.has("chargebacks") '> and chargebacks = #{chargebacks} </if>
 			<if test=' this.has("hzsConfirmStatus") '> and hzs_confirm_status = #{hzsConfirmStatus} </if>
 			<if test=' this.has("id") '> and id = #{id} </if>
+			<if test=' this.has("upStatus") '>
+				<if test='upStatus==1'>
+					and order_count=up_count
+				</if>
+				<if test='upStatus==2'>
+					and up_count=0
+				</if>
+				<if test='upStatus==3'>
+					and order_count &gt; up_count and up_count &gt; 0
+				</if>
+			 </if>
+			<if test=' this.has("saleStatus") '>
+				<if test='saleStatus==1'>
+					and order_count=on_sale_count
+				</if>
+				<if test='saleStatus==2'>
+					and on_sale_count=0
+				</if>
+				<if test='saleStatus==3'>
+					and order_count &gt; on_sale_count and on_sale_count &gt; 0
+				</if>
+			</if>
+			<if test=' this.has("beOrderStatus") '>
+				<if test='beOrderStatus==1'>
+					and order_count=be_order_count
+				</if>
+				<if test='beOrderStatus==2'>
+					and be_order_count=0
+				</if>
+				<if test='beOrderStatus==3'>
+					and order_count &gt; be_order_count and be_order_count &gt; 0
+				</if>
+			</if>
 		</where>
 		order by
 		<choose>

+ 17 - 7
sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlementService.java

@@ -1,12 +1,14 @@
 package com.pj.ht_trade_settlement;
 
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.RandomUtil;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.log.StaticLog;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pj.api.dto.*;
+import com.pj.common.core.utils.DateUtils;
 import com.pj.current.config.SystemObject;
 import com.pj.enummj.*;
 import com.pj.tb_goods.TbGoods;
@@ -71,8 +73,12 @@ public class HtTradeSettlementService extends ServiceImpl<HtTradeSettlementMappe
     /**
      * 删
      */
+    @Transactional
     void delete(Long id) {
         removeById(id);
+        SoMap soMap = new SoMap();
+        soMap.put("sale_main_id", id);
+        tbOrderMapper.deleteByMap(soMap);
     }
 
     /**
@@ -102,13 +108,13 @@ public class HtTradeSettlementService extends ServiceImpl<HtTradeSettlementMappe
      * 远程调用: 添加大订单时同时生成边民订单
      */
     public boolean tradeSettlementDto(TradeSettlementDto tradeSettlementDto) {
-        LambdaQueryWrapper<HtTradeSettlement>  wrapper = new LambdaQueryWrapper<>();
+        LambdaQueryWrapper<HtTradeSettlement> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(HtTradeSettlement::getPlatSeqNo, tradeSettlementDto.getPlatSeqNo());
         List<HtTradeSettlement> htTradeSettlements = htTradeSettlementMapper.selectList(wrapper);
         //删除已存在的大订单与小订单,保留航通送过来的最新记录
-        if(htTradeSettlements.size()>0) {
+        if (htTradeSettlements.size() > 0) {
             List<Long> idList = htTradeSettlements.stream().map(item -> item.getId()).collect(Collectors.toList());
-            LambdaQueryWrapper<TbOrder>  orderWrapper = new LambdaQueryWrapper<>();
+            LambdaQueryWrapper<TbOrder> orderWrapper = new LambdaQueryWrapper<>();
             orderWrapper.in(TbOrder::getSaleMainId, idList);
             int orderDelete = tbOrderMapper.delete(orderWrapper);
 
@@ -139,14 +145,18 @@ public class HtTradeSettlementService extends ServiceImpl<HtTradeSettlementMappe
         Date applyTime = new Date(Long.parseLong(tradeSettlementDto.getDeclTime()));
         htTradeSettlement.setDeclTime(DateUtil.format(applyTime, "yyyy-MM-dd HH:mm:ss")).setFinishStatus(0);
         BigDecimal totalPrice = BigDecimal.ZERO;
+        Date now = new Date();
+        String dateStr = DateUtils.parseDateToStr("yyMMddHHmm", now);
         for (BordersListDto item : bordersListDtoList) {//开始创建边民订单
             totalPrice = totalPrice.add(BigDecimal.valueOf(item.getBuyAmount()));
             TbOrder tbOrder = new TbOrder();
             //航通字段
             BeanUtils.copyProperties(item, tbOrder);
+            String tradeNo = "YJSCDD".concat(dateStr)
+                    .concat(RandomUtil.randomNumbers(5) + "0");
             tbOrder.setSaleMainId(htTradeSettlement.getId());
-            tbOrder.setCreateTime(new Date()).setPreNo(item.getPreNo())
-                    .setTradeNo(SystemObject.getREFcode("YJSCDD", new Date()))
+            tbOrder.setCreateTime(now).setPreNo(item.getPreNo())
+                    .setTradeNo(tradeNo)
                     .setTradeAreaId(tbTradeArea.getId()).setTradeAreaName(tbTradeArea.getName());
             tbOrder.setTotalWeight(item.getGrossWt()).setTotalPrice(item.getBuyAmount());
 
@@ -156,7 +166,7 @@ public class HtTradeSettlementService extends ServiceImpl<HtTradeSettlementMappe
             tbOrder.setFinishStatus(OrderStatus.ORDER_STATUS_ZERO.getCode());
             //申报单类型,用以后续判断当前订单是否是委托单
             tbOrder.setDeclareType(tradeSettlementDto.getDeclareType());
-
+            tbOrder.setGoodsNames(tradeSettlementDto.getGoodsNames());
             //008进口申报单
             List<TbImportOrder> importOrderList = tbImportOrderService.lambdaQuery().eq(TbImportOrder::getPlatSeqNo, item.getPreIeportNo()).list();
             if (importOrderList.size() > 0) {
@@ -198,7 +208,7 @@ public class HtTradeSettlementService extends ServiceImpl<HtTradeSettlementMappe
             //发送短信
             if (result == 1) {
                 String content = "您好,您的[边民互市订单]已经生成,订单商品是[" + tbOrder.getGoodsNames() + "]。请前往app进行交易确认";
-              // SystemObject.smsFactory.handler().sendSMS(tbPeople.getPhone(), content);
+                // SystemObject.smsFactory.handler().sendSMS(tbPeople.getPhone(), content);
             }
         }
         htTradeSettlement.setTotalPrice(totalPrice);

+ 9 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_import_order/TbImportOrder.java

@@ -107,4 +107,13 @@ public class TbImportOrder extends Model<TbImportOrder> implements Serializable
 	private Date judgeTime;
 
 	private Date createTime;
+
+	private String gGrossWt;
+
+	private String gLimit;
+
+	private String goodsNames;
+
+	private String peopleIdNo;
+	private String peopleName;
 }

+ 2 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_import_order/TbImportOrderMapper.java

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
 
 import com.pj.utils.so.*;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 /**
@@ -27,5 +28,5 @@ public interface TbImportOrderMapper extends BaseMapper <TbImportOrder> {
 	List<TbImportOrder> getList(SoMap so);
 
 
-    TbImportOrder findByManifestId(String manifestId);
+    TbImportOrder findByManifestId(@Param("manifestId") String manifestId,@Param("idCarNo") String idCarNo);
 }

+ 2 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_import_order/TbImportOrderMapper.xml

@@ -32,7 +32,7 @@
 			<if test=' this.has("payStatus") '> and pay_status = #{payStatus} </if>
 			<if test=' this.has("platSeqNo") '> and plat_seq_no like concat('%',#{platSeqNo},'%') </if>
 			<if test=' this.has("veNo") '> and ve_no like concat('%',#{veNo},'%') </if>
-
+			<if test=' this.has("declareName") '> and declare_name = #{declareName} </if>
 			<if test=' this.has("createTime") '> and create_time = #{createTime} </if>
 			<if test=' this.has("createBy") '> and create_by = #{createBy} </if>
 			<if test=' this.has("createName") '> and create_name = #{createName} </if>
@@ -44,7 +44,7 @@
 		order by create_time desc,id desc
 	</select>
     <select id="findByManifestId" resultType="com.pj.tb_import_order.TbImportOrder">
-		select * from tb_import_order where manifest_id=#{manifestId}
+		select * from tb_import_order where manifest_id=#{manifestId} and people_id_no=#{idCarNo}
 	</select>
 
 </mapper>

+ 27 - 41
sp-service/level-one-server/src/main/java/com/pj/tb_import_order/TbImportOrderService.java

@@ -100,9 +100,6 @@ public class TbImportOrderService extends ServiceImpl<TbImportOrderMapper, TbImp
 
         ImportOrderVo importOrderVo = new ImportOrderVo();
         BeanUtils.copyProperties(importOrder, importOrderVo);
-
-        importOrderVo.setGoodsNames(peopleOrder.getGoodsNames());
-        importOrderVo.setGLimit(peopleOrder.getGLimit());
         return importOrderVo;
     }
 
@@ -118,43 +115,32 @@ public class TbImportOrderService extends ServiceImpl<TbImportOrderMapper, TbImp
      * 远程调用 进口申报单同步
      */
     public boolean importOrderDto(HtImportOrderDto importOrderDto) {
-        TbImportOrder importOrder = tbImportOrderMapper.findByManifestId(importOrderDto.getManifestId());
-        if (importOrder == null) {
-            importOrder = new TbImportOrder();
-            importOrder.setCreateTime(new Date());
-        }
-        BeanUtils.copyProperties(importOrderDto, importOrder, "id");
-        boolean save = saveOrUpdate(importOrder);
-        long importOrderId = importOrder.getId();
-        if (save) {
-            //委托边民额度
-            List<HtIeportDeclBillsBpLimitDto> ieportDeclBillsBpLimitDtoList = JSON.parseArray(importOrderDto.getBorderPeopleLimitList(), HtIeportDeclBillsBpLimitDto.class);
-            ieportDeclBillsBpLimitDtoList.forEach(ieportDeclBillsBpLimitDto -> {
-                LambdaUpdateWrapper<TbOrder> wrapper = new LambdaUpdateWrapper<>();
-                wrapper.set(TbOrder::getLimitNo, ieportDeclBillsBpLimitDto.getLimitNo());
-                wrapper.set(TbOrder::getGLimit, ieportDeclBillsBpLimitDto.getgLimit());
-                wrapper.set(TbOrder::getGNo, ieportDeclBillsBpLimitDto.getgNo());
-                wrapper.set(TbOrder::getImportOrderId, importOrderId);
-                wrapper.eq(TbOrder::getPreIeportNo, ieportDeclBillsBpLimitDto.getPlatSeqNo());
-                boolean update = tbOrderService.update(wrapper);
-            });
-            //申报单商品信息
-            List<HtIeportDeclBillsGoodsDto> ieportDeclBillsGoodsDtoList = JSON.parseArray(importOrderDto.getGoodsList(), HtIeportDeclBillsGoodsDto.class);
-            ieportDeclBillsGoodsDtoList.forEach(ieportDeclBillsGoodsDto -> {
-                TbImportGoods importGoods = importGoodsMapper.findBySeqPlatNo(ieportDeclBillsGoodsDto.getPlatSeqNo());
-                if (importGoods == null) {
-                    importGoods = new TbImportGoods();
-                }
-                BeanUtils.copyProperties(ieportDeclBillsGoodsDto, importGoods, "id");
-                importGoods.setImportOrderId(importOrderId);
-                if (importGoods.getId() != null) {
-                    importGoodsMapper.updateById(importGoods);
-                } else {
-                    importGoodsMapper.insert(importGoods);
-                }
-
-            });
-        }
-        return save;
+        //委托边民额度
+        List<HtIeportDeclBillsBpLimitDto> ieportDeclBillsBpLimitDtoList = JSON.parseArray(importOrderDto.getBorderPeopleLimitList(), HtIeportDeclBillsBpLimitDto.class);
+        ieportDeclBillsBpLimitDtoList.forEach(ieportDeclBillsBpLimitDto -> {
+            String peopleIdCardNo = ieportDeclBillsBpLimitDto.getCiphertextIdno();
+            TbImportOrder importOrder = tbImportOrderMapper.findByManifestId(importOrderDto.getManifestId(), peopleIdCardNo);
+            if (importOrder == null) {
+                importOrder = new TbImportOrder();
+                importOrder.setCreateTime(new Date());
+            }
+            BeanUtils.copyProperties(importOrderDto, importOrder, "id");
+            importOrder.setGoodsNames(ieportDeclBillsBpLimitDto.getgName())
+                    .setGLimit(ieportDeclBillsBpLimitDto.getgLimit())
+                    .setPeopleIdNo(peopleIdCardNo)
+                    .setPeopleName(ieportDeclBillsBpLimitDto.getBorderName())
+                    .setGGrossWt(ieportDeclBillsBpLimitDto.getgGrossWt());
+            saveOrUpdate(importOrder);
+            long importOrderId = importOrder.getId();
+            LambdaUpdateWrapper<TbOrder> wrapper = new LambdaUpdateWrapper<>();
+            wrapper.set(TbOrder::getLimitNo, ieportDeclBillsBpLimitDto.getLimitNo());
+            wrapper.set(TbOrder::getGLimit, ieportDeclBillsBpLimitDto.getgLimit());
+            wrapper.set(TbOrder::getGNo, ieportDeclBillsBpLimitDto.getgNo());
+            wrapper.set(TbOrder::getImportOrderId, importOrderId);
+            wrapper.eq(TbOrder::getPreIeportNo, ieportDeclBillsBpLimitDto.getPlatSeqNo());
+            wrapper.eq(TbOrder::getIdno, peopleIdCardNo);
+            tbOrderService.update(wrapper);
+        });
+        return true;
     }
 }

+ 7 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrder.java

@@ -42,6 +42,7 @@ public class TbOrder extends Model<TbOrder> implements Serializable {
     public static final String PERMISSION_CODE_DEL = "tb-order-del";
     public static final String PERMISSION_CODE_EDIT_PRICE = "tb-order-edit-price";
 	public static final String PERMISSION_CODE_DEDUCTION = "tb-order-deduction";
+	public static final String PERMISSION_CODE_REFUND = "tb-order-refund";
 	public static final String PERMISSION_CODE_SEND009 = "tb-order-send009";
 	public static final String PERMISSION_CODE_SENDCXB001 = "tb-order-sendCXB001";
 
@@ -53,6 +54,11 @@ public class TbOrder extends Model<TbOrder> implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long id;
 
+	/**
+	 * 通道代码
+	 */
+	private String channelNo;
+
     /**
      * 订单号
      */
@@ -515,7 +521,7 @@ public class TbOrder extends Model<TbOrder> implements Serializable {
 
 
 	/**
-	 * (一级市场)订单扣款回执状态[0=初始值 1=扣款成功 2=扣款失败]
+	 * (一级市场)订单扣款回执状态[0=初始值 1=扣款成功 2=扣款失败,3=扣款中]
 	 */
 	private Integer Sxb010Status;
 	/**

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

@@ -215,6 +215,9 @@ public class TbOrderAppController {
 
 	@PostMapping("orderRefund")
     public AjaxJson orderRefund(@RequestParam("id")Long id) {
+		if (!StpAPPUserUtil.isLogin()){
+			return AjaxJson.getSuccess("请登录!");
+		}
         return AjaxJson.toAjax(tbOrderService.orderRefund(id));
     }
 
@@ -236,7 +239,7 @@ public class TbOrderAppController {
 
 	/** 收到银行退款回执 */
 	@PostMapping("rpc/chargebackFromBank")
-	public boolean chargebackFromBank(@RequestParam("tradeNo")String tradeNo, @RequestParam("SXB010Status")Integer SXB010Status, @RequestParam("note")String note) {
+	public boolean chargebackFromBank(@RequestParam("tradeNo")String tradeNo, @RequestParam("SXB023Status")Integer SXB010Status, @RequestParam("note")String note) {
 		boolean result = tbOrderService.chargebackFromBank(tradeNo, SXB010Status, note);
 		return result;
 	}

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

@@ -7,9 +7,11 @@ import java.util.List;
 import java.util.Map;
 
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.RandomUtil;
 import com.pj.api.dto.HtDeclareChargebackDto;
 import com.pj.api.dto.HtPassCardDTO;
 import com.pj.api.dto.OrderDto;
+import com.pj.current.satoken.StpAPPUserUtil;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -119,6 +121,12 @@ public class TbOrderController {
         return AjaxJson.getSuccess();
     }
 
+    @RequestMapping("orderRefund")
+    @SaCheckPermission(TbOrder.PERMISSION_CODE_REFUND)
+    public AjaxJson orderRefund(@RequestParam("id")Long id) {
+        return AjaxJson.toAjax(tbOrderService.orderRefund(id));
+    }
+
     /**
      * 撤销转售
      */
@@ -237,4 +245,9 @@ public class TbOrderController {
         return tbOrderService.orderFinish(htPassCardDTO);
     }
 
+    public static void main(String[] args) {
+        System.out.println(RandomUtil.randomString(32));
+    }
+
+
 }

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

@@ -453,7 +453,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         StaticLog.info("getPaymentData:{}", JSONUtil.toJsonStr(htTradeSettlement));
         PaymentDto paymentDto = new PaymentDto();
         BeanUtils.copyProperties(htTradeSettlement, paymentDto);
-
+        paymentDto.setId(tbOrder.getId());
         paymentDto.setTradeNo(tbOrder.getTradeNo());
         paymentDto.setCodeTs(tbOrder.getCodeTs());
         paymentDto.setBuyQty(tbOrder.getBuyQty());
@@ -559,6 +559,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
                     .setSxb010StatusTime(new Date());
         } else if (1 == SXB010Status) {//扣款成功
             tbOrder.setSxb010Status(1)
+                    .setRefundStatus(0)
                     .setSxb010StatusTime(new Date());
             //如果已经过了卡三,则补发送一次通关报文给银行
             if (tbOrder.getFinishStatus() == 1) {
@@ -725,11 +726,18 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
      */
     public boolean orderRefund(Long id) {
         TbOrder order = getById(id);
-        if (order.getPeopleConfirmStatus() != 1 || order.getSxb010Status() != 1 || order.getFinishStatus() == 1 || order.getRefundStatus() != 0)
-            throw new ServiceException("当前订单状态已改变,不可做退款操作,请刷新后操作!");
+        int refundStatus = order.getRefundStatus();
+        if (refundStatus == 1 || refundStatus == 3) {
+            StaticLog.error("\n---------退货退款失败:{}已退货退款", id);
+            throw new AjaxError("订单已退款或者退款中");
+        }
+        int sx010Status = order.getSxb010Status();
+        if (sx010Status != 1) {
+            StaticLog.error("\n---------退货退款失败:{}银行��边民的款未成功", id);
+            throw new AjaxError("银行扣边民的款未成功");
+        }
 
         PaymentDto paymentDto = this.getPaymentData(order);
-        StaticLog.info("\nsendSXB013(边民退货退款)——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
         paymentServerInterface.sendSXB013(paymentDto);
 
         LambdaUpdateWrapper<TbOrder> updateWrapper = new LambdaUpdateWrapper<>();
@@ -737,6 +745,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         updateWrapper.set(TbOrder::getRefundTime, new Date());//退款时间
         updateWrapper.eq(TbOrder::getId, id);
         boolean update = this.update(updateWrapper);
+        StaticLog.info("\nsendSXB013(边民退货退款)——PaymentDto——:{},{}", update, JSONUtil.toJsonStr(paymentDto));
 
         return update;
     }
@@ -748,19 +757,43 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         TbOrder tbOrder = getById(id);
         if (tbOrder == null) {
             StaticLog.error("\n---------补扣款失败:{}不存在", id);
-            return false;
+            throw new AjaxError("订单不存在");
+        }
+        if (tbOrder.getSxb010Status() == 1 && tbOrder.getRefundStatus() == 0) {
+            StaticLog.error("\n---------补扣款失败:{}已扣款", id);
+            throw new AjaxError("订单已扣款");
+        }
+        if (tbOrder.getSxb010Status() == 3) {
+            StaticLog.error("\n---------补扣款失败:{}退款中", id);
+            throw new AjaxError("订单退款中");
+        }
+        if (StrUtil.isEmpty(tbOrder.getGoodsNames())) {
+            StaticLog.error("\n---------无商品信息:{}", id);
+            throw new AjaxError("订单无商品信息");
+        }
+        Integer deductionCount = tbOrder.getDeductionCount() + 1;
+        if (tbOrder.getRefundStatus() != 0) {
+            String tradeNo = tbOrder.getTradeNo();
+            int len = tradeNo.length();
+            if (StrUtil.contains(tradeNo, "_")) {
+                tradeNo = tradeNo.substring(0, tradeNo.lastIndexOf("_"));
+            } else {
+                tradeNo = tradeNo.substring(0, len - 1);
+            }
+            tradeNo = tradeNo + deductionCount;
+            tbOrder.setTradeNo(tradeNo);
         }
-
         PaymentDto paymentDto = this.getPaymentData(tbOrder);
         StaticLog.info("\n---订单补扣款---sendSXB010——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
         paymentServerInterface.sendSXB010(paymentDto);
-
-        tbOrder.setDeductionCount(tbOrder.getDeductionCount() + 1);
-        tbOrder.setDeductionTime(new Date());
+        tbOrder.setDeductionCount(deductionCount);
+        tbOrder.setDeductionTime(new Date())
+                .setSxb010Status(3);
 
         return super.updateById(tbOrder);
     }
 
+
     /**
      * 订单补扣款——按车,并且未扣款
      */
@@ -768,15 +801,28 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(TbOrder::getVeNo, veNo);
         wrapper.eq(TbOrder::getSaleMainId, id);
-        wrapper.ne(TbOrder::getSxb010Status, 1).orderByDesc(TbOrder::getCreateTime);
+        wrapper.and(i -> i.ne(TbOrder::getSxb010Status, 1).ne(TbOrder::getSxb010Status, 3))
+                .orderByDesc(TbOrder::getCreateTime);
         List<TbOrder> tbOrders = tbOrderMapper.selectList(wrapper);
         if (!tbOrders.isEmpty()) {
             for (TbOrder tbOrder : tbOrders) {
+                Integer deductionCount = tbOrder.getDeductionCount() + 1;
+                if (tbOrder.getRefundStatus() != 0) {
+                    String tradeNo = tbOrder.getTradeNo();
+                    int len = tradeNo.length();
+                    if (StrUtil.contains(tradeNo, "_")) {
+                        tradeNo = tradeNo.substring(0, tradeNo.lastIndexOf("_"));
+                    } else {
+                        tradeNo = tradeNo.substring(0, len - 1);
+                    }
+                    tradeNo = tradeNo + deductionCount;
+                    tbOrder.setTradeNo(tradeNo);
+                }
                 PaymentDto paymentDto = this.getPaymentData(tbOrder);
                 StaticLog.info("\n---订单补扣款——按车---sendSXB010——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
                 paymentServerInterface.sendSXB010(paymentDto);
 
-                tbOrder.setDeductionCount(tbOrder.getDeductionCount() + 1);
+                tbOrder.setDeductionCount(deductionCount);
                 tbOrder.setDeductionTime(new Date());
             }
         }
@@ -793,7 +839,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         return tbOrders;
     }
 
-    /*-----           正常业务逻辑    rpc远程调用 -----*/
+    /*-----           正常业务逻辑👆👆    rpc远程调用👇👇 -----*/
 
     /**
      * 航通发起的退单
@@ -860,7 +906,10 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         if (2 == SXB013Status) {//退款失败
             tbOrder.setRefundStatus(2).setRefundReason(note).setRefundTime(new Date());
         } else if (1 == SXB013Status) {//退款成功
-            tbOrder.setRefundStatus(1).setRefundReason(note).setRefundTime(new Date());
+            tbOrder.setRefundStatus(1)
+                    .setRefundReason(note)
+                    .setSxb010Status(0)
+                    .setRefundTime(new Date());
         }
         return updateById(tbOrder);
     }
@@ -881,6 +930,9 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         PaymentDto paymentDto = new PaymentDto();
         paymentDto.setTradeNo(tbOrder.getTradeNo());
         paymentDto.setDeclTime(htTradeSettlement.getDeclTime());
+        paymentDto.setFieldCode(htTradeSettlement.getFieldCode());
+        paymentDto.setChannelNo(tbOrder.getChannelNo());
+        paymentDto.setTrans(tbOrder.getPlatSeqNo());
         StaticLog.info("\nsendCXB001——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
         paymentServerInterface.sendCXB001(paymentDto);
 
@@ -922,6 +974,10 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
                 //todo: 收到航通007报文即收到海关结关信息,转发结关信息给到银行
                 paymentDto.setTradeNo(tbOrder.getTradeNo());
                 paymentDto.setDeclTime(htTradeSettlement.getDeclTime());
+
+                paymentDto.setFieldCode(htTradeSettlement.getFieldCode());
+                paymentDto.setChannelNo(tbOrder.getChannelNo());
+                paymentDto.setTrans(tbOrder.getPlatSeqNo());
                 StaticLog.info("\nsendCXB001——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
                 log.info("log sendCXB001——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
                 paymentServerInterface.sendCXB001(paymentDto);
@@ -970,10 +1026,14 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
                 //收到007结关信息后边民即可上架订单,不需等收到打款给外籍商户的成功回执SXB017才能完成订单
                 tbOrder.setFinishTime(new Date());
                 tbOrder.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
+                tbOrder.setChannelNo(htPassCardDTO.getChannelNo());
 
                 //todo: 收到航通007报文即收到海关结关信息,转发结关信息给到银行
                 paymentDto.setTradeNo(tbOrder.getTradeNo());
                 paymentDto.setDeclTime(htPassCardDTO.getCheckTime());
+                paymentDto.setFieldCode(htPassCardDTO.getAreaNo());
+                paymentDto.setChannelNo(htPassCardDTO.getChannelNo());
+                paymentDto.setTrans(tbOrder.getPlatSeqNo());
                 StaticLog.info("\nsendCXB001——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
                 paymentServerInterface.sendCXB001(paymentDto);
             }
@@ -1159,6 +1219,9 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         if (i != 1) {
             throw new AjaxError("上架失败");
         }
+        HtTradeSettlement htTradeSettlement = htTradeSettlementService.getById(tbOrder.getSaleMainId());
+        htTradeSettlement.setUpCount(htTradeSettlement.getUpCount() + 1);
+        htTradeSettlementService.updateById(htTradeSettlement);
     }
 
     public void down(Long id) {
@@ -1171,6 +1234,9 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
         }
         db.setUpStatus(1);
         this.updateById(db);
+        HtTradeSettlement htTradeSettlement = htTradeSettlementService.getById(db.getSaleMainId());
+        htTradeSettlement.setUpCount(htTradeSettlement.getUpCount() - 1);
+        htTradeSettlementService.updateById(htTradeSettlement);
     }
 
     public List<OrderDto> getOrderListByMainIds(String mainIds) {

+ 1 - 1
sp-service/level-one-server/src/main/resources/logback.xml

@@ -2,7 +2,7 @@
 <configuration>
     <contextName>one</contextName>
     <property name="LOG_PATH" value="logs"/>
-    <property name="APP_DIR" value="pco"/>
+    <property name="APP_DIR" value="server"/>
     <property name="log.maxFileSize" value="10MB"/>
     <property name="log.maxFileCnt" value="90"/>
     <property name="log.totalSizeCap" value="10GB"/>

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

@@ -11,13 +11,11 @@ import com.pj.tb_orders.vo.OrderStaticsDTO;
 import com.pj.utils.sg.AjaxJson;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 
@@ -79,7 +77,7 @@ public class TbOrdersApiController {
     @RequestMapping("purchaserBuyOneLevelOrder")
     public AjaxJson purchaserBuyOneLevelOrder() {
         List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
-        List<TbOrders>  orders=  tbOrdersService.findByLevelOneOrderIds(ids);
+        List<TbOrders> orders = tbOrdersService.findByLevelOneOrderIds(ids);
         String orderIds = orders.stream().map(obj -> obj.getId() + "").collect(Collectors.joining(","));
         // 获取app登录用户
         APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
@@ -98,7 +96,7 @@ 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()){
+        if (orders.isEmpty()) {
             return AjaxJson.getError("订单不存在");
         }
         String orderIds = orders.stream().map(obj -> obj.getId() + "").collect(Collectors.joining(","));
@@ -125,9 +123,10 @@ public class TbOrdersApiController {
 
     /**
      * 获取在售订单
+     *
      * @return
      */
-  @RequestMapping("getOnSaleList")
+    @RequestMapping("getOnSaleList")
     public AjaxJson getOnSaleList() {
         SoMap so = SoMap.getRequestSoMap();
         List<TbOrders> list = tbOrdersService.getOnSaleList(so.startPage());
@@ -159,7 +158,7 @@ public class TbOrdersApiController {
     public AjaxJson getPurchaserStatistics() {
         SoMap so = SoMap.getRequestSoMap();
         APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
-        so.put("purchaserId",appLoginInfo.getFk());
+        so.put("purchaserId", appLoginInfo.getFk());
         List<OrderStaticsDTO> list = tbOrdersService.getPurchaserStatistics(so.startPage());
         return AjaxJson.getPageData(so.getDataCount(), list);
     }
@@ -234,6 +233,26 @@ public class TbOrdersApiController {
     }
 
 
+    @RequestMapping("deduction")
+    public AjaxJson deduction(Long id) {
+        if (!StpAPPUserUtil.isLogin()) {
+            return AjaxJson.getError("用户未登录");
+        }
+        TbOrders tbOrders = tbOrdersService.getById(id);
+        if (tbOrders == null) {
+            return AjaxJson.getError("订单不存在");
+        }
+        if (tbOrders.getIsPay() != 2) {
+            return AjaxJson.getError("订单无法执行补扣");
+        }
+        Long fkId = StpAPPUserUtil.getAPPLoginInfo().getFk();
+        if (!Objects.equals(fkId, tbOrders.getPurchaserId())) {
+            return AjaxJson.getError("您无权执行此操作");
+        }
+        tbOrdersService.deduction(id);
+        return AjaxJson.getSuccess();
+    }
+
     /**
      * 查 - 根据一级市场订单id查二级市场的转售金额
      */
@@ -246,6 +265,7 @@ public class TbOrdersApiController {
         return resalePrice;
     }
 
+
     /**
      * 采购商支付成功 ——> 边民缴税以及各服务费
      */

+ 34 - 12
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersController.java

@@ -2,6 +2,7 @@ package com.pj.tb_orders;
 
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import com.pj.api.consts.FeignFactory;
 import com.pj.api.dto.OrderDto;
@@ -41,17 +42,16 @@ public class TbOrdersController {
     TbOrdersService tbOrdersService;
 
 
-
     @RequestMapping("addOrderByResale")
     @SaCheckPermission(TbOrders.PERMISSION_CODE_EDIT_PRICE)
-    public AjaxJson addOrderByResale(Long id ) {
+    public AjaxJson addOrderByResale(Long id) {
         OrderDto orderDto = FeignFactory.levelOneServerInterface.getOrderDtoById(id);
         if (null == orderDto) throw new AjaxError("转售失败,请联系管理员!");
 
         //获取app登录用户
-        TbOrders db=tbOrdersService.findByLevelOneOrderId(id);
-        if (db!=null){
-            throw new AjaxError(orderDto.getTradeNo()+"已转售,请联系管理员处理");
+        TbOrders db = tbOrdersService.findByLevelOneOrderId(id);
+        if (db != null) {
+            throw new AjaxError(orderDto.getTradeNo() + "已转售,请联系管理员处理");
         }
         TbOrders orders = new TbOrders();
         orders.setResalePrice(orderDto.getUpPrice().doubleValue());
@@ -62,8 +62,8 @@ public class TbOrdersController {
         orders.setTradeAreaId(orderDto.getTradeAreaId());
         orders.setVeNo(orderDto.getVeNo())
                 .setGoodsUnit(orderDto.getGoodsUnit())
-                .setNetWet(orderDto.getNetWt()+"")
-                .setTotalWeight(orderDto.getTotalWeight()+"")
+                .setNetWet(orderDto.getNetWt() + "")
+                .setTotalWeight(orderDto.getTotalWeight() + "")
                 .setSinglePrice(orderDto.getDeclPrice().toString())
         ;
 
@@ -95,7 +95,6 @@ public class TbOrdersController {
     }
 
 
-
     @RequestMapping("addOrderByResaleBatch")
     @SaCheckPermission(TbOrders.PERMISSION_CODE_EDIT_PRICE)
     public AjaxJson addOrderByResaleBatch() {
@@ -186,15 +185,37 @@ public class TbOrdersController {
     }
 
 
-    /** 采购商补扣款 */
+    /**
+     * 采购商补扣款
+     */
     @RequestMapping("deduction")
     @SaCheckPermission(TbOrders.PERMISSION_CODE_DEDUCTION)
-    public AjaxJson deduction(Long id){
+    public AjaxJson deduction(Long id) {
         tbOrdersService.deduction(id);
         return AjaxJson.getSuccess();
     }
 
     /**
+     * 采购商补扣款
+     */
+    @RequestMapping("payBatch")
+    @SaCheckPermission(TbOrders.PERMISSION_CODE_DEDUCTION)
+    public AjaxJson payBatch() {
+        List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
+        if (ids.isEmpty()) {
+            return AjaxJson.getError("请选择需要补扣款的订单!");
+        }
+        List<TbOrders> orders = tbOrdersService.listByIds(ids);
+        List<TbOrders> checkList = orders.stream().filter(tbOrders -> tbOrders.getIsPay() == 1 || tbOrders.getIsPay() == 3).collect(Collectors.toList());
+        if (!checkList.isEmpty()) {
+            return AjaxJson.getError("扣款订单中存在已支付或正在支付订单!");
+        }
+        tbOrdersService.payBatch(orders);
+
+        return AjaxJson.getSuccess();
+    }
+
+    /**
      * 查 - 交易凭证
      */
     @RequestMapping("getSubPrint")
@@ -218,14 +239,15 @@ public class TbOrdersController {
      * 根据一级市场订单删除二级市场订单
      */
     @RequestMapping("rpc/removeOnSaleOrderByLevelOneOrderId")
-    public boolean removeOnSaleOrderByLevelOneOrderId(@RequestParam("levelOneOrderId")Long levelOneOrderId) {
+    public boolean removeOnSaleOrderByLevelOneOrderId(@RequestParam("levelOneOrderId") Long levelOneOrderId) {
         return tbOrdersService.removeOnSaleOrderByLevelOneOrderId(levelOneOrderId);
     }
+
     /**
      * 根据一级市场订单删除二级市场订单
      */
     @RequestMapping("rpc/removeOnSaleOrderByLevelOneOrderIds")
-    public boolean removeOnSaleOrderByLevelOneOrderId(@RequestParam("levelOneOrderIds")String levelOneOrderIds) {
+    public boolean removeOnSaleOrderByLevelOneOrderId(@RequestParam("levelOneOrderIds") String levelOneOrderIds) {
         return tbOrdersService.removeOnSaleOrderByLevelOneOrderIds(levelOneOrderIds);
     }
 }

+ 2 - 0
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersMapper.xml

@@ -58,6 +58,8 @@
 			<if test=' this.has("isDelivery") '> and is_delivery = #{isDelivery} </if>
 			<if test=' this.has("isPay") '> and is_pay = #{isPay} </if>
 			<if test=' this.has("payTax") '> and pay_tax = #{payTax} </if>
+			<if test=' this.has("beOrder") and beOrder==1'> and purchaser_id is null </if>
+			<if test=' this.has("beOrder") and beOrder==2'> and purchaser_id is not null </if>
 			<if test=' this.has("dateBegin") '>and date_format(create_time,'%Y-%m-%d') &gt;=#{dateBegin}</if>
 			<if test=' this.has("dateEnd") '>and date_format(create_time,'%Y-%m-%d') &lt;=#{dateEnd}</if>
 		</where>

+ 29 - 1
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersService.java

@@ -678,8 +678,15 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
             log.error("采购商补扣款失败:{}不存在", id);
             return false;
         }
-
+        if (tbOrders.getIsPay() == 1) {
+            log.error("订单已支付:{}", id);
+            return false;
+        }
         OrderDto orderOne = levelOneServerInterface.getOrderDtoById(tbOrders.getLevelOneOrderId());
+        if (StrUtil.isEmpty(orderOne.getGoodsNames())) {
+            log.error("采购商扣款失败:{} 订单未找到相关商品", tbOrders.getId());
+            return false;
+        }
         PaymentTwoDto paymentTwoDto = this.getPaymentData(tbOrders, orderOne);
         StaticLog.info("\n---采购商补扣款---sendMKT006_NoCommission——PaymentTwoDto——:{}", JSONUtil.toJsonStr(paymentTwoDto));
         paymentServerInterface.sendMKT006_NoCommission(paymentTwoDto);
@@ -776,4 +783,25 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
 
         return tbOrdersMapper.delete(wrapper) == ids.size();
     }
+
+
+    public void payBatch(List<TbOrders> orders) {
+        for (TbOrders tbOrders : orders) {
+            OrderDto orderOne = levelOneServerInterface.getOrderDtoById(tbOrders.getLevelOneOrderId());
+            if (StrUtil.isEmpty(orderOne.getGoodsNames())) {
+                log.error("采购商扣款失败:{} 订单未找到相关商品", tbOrders.getId());
+                throw new AjaxError(tbOrders.getOrderNo() + "找不到商品信息");
+            }
+            PaymentTwoDto paymentTwoDto = this.getPaymentData(tbOrders, orderOne);
+            StaticLog.info("\n---采购商扣款---sendMKT006_NoCommission——PaymentTwoDto——:{}", JSONUtil.toJsonStr(paymentTwoDto));
+            paymentServerInterface.sendMKT006_NoCommission(paymentTwoDto);
+            if (tbOrders.getIsPay() == 2) {
+                tbOrders.setDeductionCount(tbOrders.getDeductionCount() + 1);
+                tbOrders.setDeductionTime(new Date());
+            }
+            tbOrders.setIsPay(3)
+                    .setPayTime(new Date());
+        }
+        this.updateBatchById(orders);
+    }
 }

+ 4 - 0
sp-service/payment-server/src/main/java/com/pj/bank_info/BankInfo.java

@@ -123,4 +123,8 @@ public class BankInfo extends Model<BankInfo> implements Serializable {
 	private String title;
 	private String swiftCode;
 	private String abroad;
+	/**
+	 * 一级市场订单编号
+	 */
+	private String levelOneOrderId;
 }

+ 90 - 68
sp-service/payment-server/src/main/java/com/pj/bank_info/BankInfoController.java

@@ -3,6 +3,7 @@ package com.pj.bank_info;
 import java.util.ArrayList;
 import java.util.List;
 
+import cn.hutool.core.util.StrUtil;
 import com.pj.api.dto.BankInfoDto;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.BeanUtils;
@@ -15,81 +16,102 @@ import com.pj.project4sp.SP;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 
 
-
 /**
  * Controller: bank_info -- 银行回执信息表
+ *
  * @author lbl
  */
 @RestController
 @RequestMapping("/BankInfo/")
 public class BankInfoController {
 
-	/** 底层 Service 对象 */
-	@Autowired
-	BankInfoService bankInfoService;
-
-	/** 增 */
-	@RequestMapping("add")
-	@SaCheckPermission(BankInfo.PERMISSION_CODE_ADD)
-	public AjaxJson add(BankInfo b){
-		bankInfoService.add(b);
-		b = bankInfoService.getById(SP.publicMapper.getPrimarykey());
-		return AjaxJson.getSuccessData(b);
-	}
-
-	/** 删 */
-	@RequestMapping("delete")
-	@SaCheckPermission(BankInfo.PERMISSION_CODE_DEL)
-	public AjaxJson delete(Long id){
-		 bankInfoService.delete(id);
-		return AjaxJson.getSuccess();
-	}
-
-	/** 删 - 根据id列表 */
-	@RequestMapping("deleteByIds")
-	@SaCheckPermission(BankInfo.PERMISSION_CODE_DEL)
-	public AjaxJson deleteByIds(){
-		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
-		int line = SP.publicMapper.deleteByIds(BankInfo.TABLE_NAME, ids);
-		return AjaxJson.getByLine(line);
-	}
-
-	/** 改 */
-	@RequestMapping("update")
-	@SaCheckPermission(BankInfo.PERMISSION_CODE_EDIT)
-	public AjaxJson update(BankInfo b){
-		bankInfoService.update(b);
-		return AjaxJson.getSuccess();
-	}
-
-	/** 查 - 根据id */
-	@RequestMapping("getById")
-		@SaCheckPermission(BankInfo.PERMISSION_CODE)
-	public AjaxJson getById(Integer id){
-		BankInfo b = bankInfoService.getById(id);
-		return AjaxJson.getSuccessData(b);
-	}
-
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
-	@RequestMapping("getList")
-	public AjaxJson getList() {
-		SoMap so = SoMap.getRequestSoMap();
-		List<BankInfo> list = bankInfoService.getList(so.startPage());
-		return AjaxJson.getPageData(so.getDataCount(), list);
-	}
-
-	@PostMapping("rpc/getListBySource")
-	public List<BankInfoDto> getListBySource(@RequestParam("source") String source) {
-		SoMap so = new SoMap();
-		so.put("source", source);
-		List<BankInfo> list = bankInfoService.getList(so);
-		List<BankInfoDto> dtoList = new ArrayList<>();
-		list.forEach(item -> {
-			BankInfoDto dto = new BankInfoDto();
-			BeanUtils.copyProperties(item, dto);
-			dtoList.add(dto);
-		});
-		return dtoList;
-	}
+    /**
+     * 底层 Service 对象
+     */
+    @Autowired
+    BankInfoService bankInfoService;
+
+    /**
+     * 增
+     */
+    @RequestMapping("add")
+    @SaCheckPermission(BankInfo.PERMISSION_CODE_ADD)
+    public AjaxJson add(BankInfo b) {
+        bankInfoService.add(b);
+        b = bankInfoService.getById(SP.publicMapper.getPrimarykey());
+        return AjaxJson.getSuccessData(b);
+    }
+
+    /**
+     * 删
+     */
+    @RequestMapping("delete")
+    @SaCheckPermission(BankInfo.PERMISSION_CODE_DEL)
+    public AjaxJson delete(Long id) {
+        bankInfoService.delete(id);
+        return AjaxJson.getSuccess();
+    }
+
+    /**
+     * 删 - 根据id列表
+     */
+    @RequestMapping("deleteByIds")
+    @SaCheckPermission(BankInfo.PERMISSION_CODE_DEL)
+    public AjaxJson deleteByIds() {
+        List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
+        int line = SP.publicMapper.deleteByIds(BankInfo.TABLE_NAME, ids);
+        return AjaxJson.getByLine(line);
+    }
+
+    /**
+     * 改
+     */
+    @RequestMapping("update")
+    @SaCheckPermission(BankInfo.PERMISSION_CODE_EDIT)
+    public AjaxJson update(BankInfo b) {
+        bankInfoService.update(b);
+        return AjaxJson.getSuccess();
+    }
+
+    /**
+     * 查 - 根据id
+     */
+    @RequestMapping("getById")
+    @SaCheckPermission(BankInfo.PERMISSION_CODE)
+    public AjaxJson getById(Integer id) {
+        BankInfo b = bankInfoService.getById(id);
+        return AjaxJson.getSuccessData(b);
+    }
+
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    @RequestMapping("getList")
+    public AjaxJson getList() {
+        SoMap so = SoMap.getRequestSoMap();
+        String source = so.getString("source");
+        if (StrUtil.isNotEmpty(source)) {
+            source = StrUtil.subBefore(source, "_", false);
+            source = source.substring(0, source.length() - 1);
+            so.put("source", source);
+        }
+        List<BankInfo> list = bankInfoService.getList(so.startPage());
+        return AjaxJson.getPageData(so.getDataCount(), list);
+    }
+
+    @PostMapping("rpc/getListBySource")
+    public List<BankInfoDto> getListBySource(@RequestParam("source") String source) {
+        SoMap so = new SoMap();
+        so.put("source", source);
+        List<BankInfo> list = bankInfoService.getList(so);
+        List<BankInfoDto> dtoList = new ArrayList<>();
+        list.forEach(item -> {
+            BankInfoDto dto = new BankInfoDto();
+            BeanUtils.copyProperties(item, dto);
+            dtoList.add(dto);
+        });
+        return dtoList;
+    }
+
 
 }

+ 2 - 1
sp-service/payment-server/src/main/java/com/pj/bank_info/BankInfoMapper.xml

@@ -29,7 +29,8 @@
 			<if test=' this.has("bankCode") '> and bankCode = #{bankCode} </if>
 			<if test=' this.has("operation") '> and operation = #{operation} </if>
 			<if test=' this.has("code") '> and code = #{code} </if>
-			<if test=' this.has("source") '> and source = #{source} </if>
+			<if test=' this.has("source") '> and source like concat(#{source},'%') </if>
+			<if test=' this.has("levelOneOrderId") '> and level_one_order_id = #{levelOneOrderId} </if>
 			<if test=' this.has("result") '> and result = #{result} </if>
 			<if test=' this.has("note") '> and note = #{note} </if>
 			<if test=' this.has("createTime") '> and create_time = #{createTime} </if>

+ 9 - 7
sp-service/payment-server/src/main/java/com/pj/xml/MessageXML.java

@@ -22,14 +22,16 @@ public class MessageXML {
      * 结关报文:海关数据中心--->银行
      */
     public static String CXB001(PaymentDto paymentDto) {
-        paymentDto.setFieldCode("861501");
         String date = sdf.format(new Date());
         String payload =
                 "<payload xsi:type=\"responseDTO\">\n" +
                         "<code>200</code>\n" +                                 //回执代码
                         "<source>" + paymentDto.getTradeNo() + "</source>\n" + //订单编号
                         "<note>结关成功</note>\n" +                             //回执内容
-                        "<date>" + paymentDto.getDeclTime() + "</date>\n" +    //结关时间	YYYY-MM—DD HH:MM:DD SSS
+                        "<date>" + paymentDto.getDeclTime() + "</date>\n" +    //结关时间(过卡时间)	YYYY-MM—DD HH:MM:DD SSS
+                        "<trans>" + paymentDto.getTrans() + "</trans>\n" +       //申报编号
+                        "<station>" + paymentDto.getFieldCode() + "</station>\n" +   //监管场所代码
+                        "<channel>" + paymentDto.getChannelNo() + "</channel>\n" +   //卡口通道号
                 "</payload>";
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
                 "<message title=\"一级市场\" xsi:schemaLocation=\"\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
@@ -44,7 +46,7 @@ public class MessageXML {
                 "       </item>\n" +
                 "        <item>\n" +
                 "               <key>organization</key>\n" +
-                "              <value>" + paymentDto.getFieldCode() + "</value>\n" +//互市点机构代码
+                "              <value>861501</value>\n" +//互市点机构代码
                 "       </item>\n" +
                 "        <item>\n" +
                 "            <key>bankCode</key>\n" +
@@ -55,10 +57,10 @@ public class MessageXML {
                 "              <value>CXB001</value>\n" +
                 "       </item>\n" +
                 "</headers>\n" +
-                payload +
-                //"<plain>" +
-                //CryptoUtil.encrypt(payload)+
-                //"</plain>" +
+                //payload +
+                "<plain>" +
+                CryptoUtil.encrypt(payload)+
+                "</plain>" +
                 "</message>";
         StaticLog.info("\n --------发送报文--------CXB001--------" + "\n payload=" + payload +"\n xml=" + xml);
         return xml;

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

@@ -202,12 +202,6 @@ public class AppUserApiController {
      */
     @RequestMapping("delete")
     public AjaxJson delete(Long id){
-        AppUser appUser = new AppUser();
-        appUser.setId(id);
-        appUser.setDeleteStatus(DeleteStatus.DELETE_STATUS_OFF.getCode()); //被逻辑删除
-        appUser.setUpdateTime(new Date());
-        appUserService.update(appUser);
-
         return AjaxJson.getSuccess();
     }
 

+ 11 - 50
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserController.java

@@ -39,47 +39,10 @@ public class AppUserController {
     @Autowired
     AppUserService appUserService;
 
-    /**
-     * 增
-     */
-    @RequestMapping("add")
-    @SaCheckPermission(AppUser.PERMISSION_CODE_ADD)
-    public AjaxJson add(AppUser a) {
-        appUserService.add(a);
-        a = appUserService.getById(SP.publicMapper.getPrimarykey());
-        return AjaxJson.getSuccessData(a);
-    }
 
-    /**
-     * 删
-     */
-    @RequestMapping("delete")
-    @SaCheckPermission(AppUser.PERMISSION_CODE_DEL)
-    public AjaxJson delete(Long id) {
-        appUserService.delete(id);
-        return AjaxJson.getSuccess();
-    }
 
-    /**
-     * 删 - 根据id列表
-     */
-    @RequestMapping("deleteByIds")
-    @SaCheckPermission(AppUser.PERMISSION_CODE_DEL)
-    public AjaxJson deleteByIds() {
-        List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
-        int line = SP.publicMapper.deleteByIds(AppUser.TABLE_NAME, ids);
-        return AjaxJson.getByLine(line);
-    }
 
-    /**
-     * 改
-     */
-    @RequestMapping("update")
-    @SaCheckPermission(AppUser.PERMISSION_CODE_EDIT)
-    public AjaxJson update(AppUser a) {
-        appUserService.update(a);
-        return AjaxJson.getSuccess();
-    }
+
 
     /**
      * 修改密码
@@ -90,6 +53,15 @@ public class AppUserController {
         StaticLog.info("dto:", JSONUtil.toJsonStr(dto.getPassword()));
         return AjaxJson.toAjax(appUserService.pass(dto));
     }
+    /**
+     * 修改密码
+     */
+    @RequestMapping("updateRole")
+    @SaCheckPermission(AppUser.PERMISSION_CODE_EDIT)
+    public AjaxJson updateRole(long id, String userType) {
+        int line = SP.publicMapper.updateColumnById("app_user", "user_type", userType, id);
+        return AjaxJson.getByLine(line);
+    }
 
     /**
      * 查 - 根据id
@@ -112,18 +84,7 @@ public class AppUserController {
         return AjaxJson.getPageData(so.getDataCount(), list);
     }
 
-    /**
-     * 更换角色
-     * <p>
-     * 当前用户已登录,app点击该按钮时,从缓存获取用户类型与选择要更换的角色id做对比,相同则进入此方法,故在此不做用户角色权限过滤
-     *
-     * @param appRoleId
-     * @return
-     */
-    @RequestMapping("updateRole")
-    AjaxJson updateRole(@RequestParam("appRoleId") String appRoleId) {
-        return appUserService.updateRole(appRoleId);
-    }
+
 
     @RequestMapping("cleanFace")
     public AjaxJson cleanFace(@RequestParam("id") Long id) {

+ 10 - 21
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserService.java

@@ -107,20 +107,6 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
 
 
     /**
-     * 增
-     */
-    void add(AppUser t) {
-        save(t);
-    }
-
-    /**
-     * 删
-     */
-    void delete(Long id) {
-        removeById(id);
-    }
-
-    /**
      * 改
      */
     void update(AppUser a) {
@@ -648,7 +634,7 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
     }
 
 
-    public void authFace(Long loginId, MultipartFile file, Integer type) throws IOException{
+    public void authFace(Long loginId, MultipartFile file, Integer type) throws IOException {
         String img;
         try (InputStream is = file.getInputStream()) {
             img = Base64.encode(is);
@@ -656,9 +642,9 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
         } catch (IOException e) {
             throw new AjaxError("识别失败");
         }
-        byte[]images = ImageUtils.resizeByteImageBase64(img);
+        byte[] images = ImageUtils.resizeByteImageBase64(img);
         boolean hasPerson = faceFactory.handler().checkHasPerson(images);
-        if (!hasPerson){
+        if (!hasPerson) {
             throw new AjaxError("请正视摄像头");
         }
         if (type == 2) {
@@ -693,10 +679,10 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
      * @param img
      * @param type
      */
-    public void authFace(Long loginId, String img, Integer type)throws IOException {
-        byte[]byteImageBase64 = ImageUtils.resizeByteImageBase64(img);
+    public void authFace(Long loginId, String img, Integer type) throws IOException {
+        byte[] byteImageBase64 = ImageUtils.resizeByteImageBase64(img);
         boolean hasPerson = faceFactory.handler().checkHasPerson(byteImageBase64);
-        if (!hasPerson){
+        if (!hasPerson) {
             throw new AjaxError("请正视摄像头");
         }
         if (type == 2) {
@@ -716,8 +702,11 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
             }
             return;
         }
-        String faceId = RandomUtil.randomString(32);
         AppUser appUser = this.getById(loginId);
+        if (StrUtil.isNotEmpty(appUser.getFaceId()) && appUser.getFace() == 1) {
+            faceFactory.handler().deletePerson(appUser.getFaceId());
+        }
+        String faceId = RandomUtil.randomString(32);
         appUser.setFace(1);
         appUser.setFaceTime(new Date()).setFaceId(faceId);
         this.updateById(appUser);