wangzhuo 2 лет назад
Родитель
Сommit
a94ee04fef

+ 16 - 4
blade-service-api/blade-client-api/src/main/java/org/springblade/client/entity/CorpsDesc.java

@@ -319,13 +319,25 @@ public class CorpsDesc implements Serializable {
 	private String swiftCode;
 
 	private String cnaps;
-	//总返利
+
+	/**
+	 * 总返利
+	 */
 	private BigDecimal profitReturn;
-	//已用返利
+
+	/**
+	 * 已用返利
+	 */
 	private BigDecimal usedProfit;
-	//可用返利
+
+	/**
+	 * 可用返利
+	 */
 	private BigDecimal surplusProfit;
-	//本月待到账返利
+
+	/**
+	 * 本月待到账返利
+	 */
 	private BigDecimal monthProfit;
 
 	/**

+ 11 - 0
blade-service-api/blade-purchase-sales-api/src/main/java/org/springblade/purchase/sales/vo/OrderStatisticsVo.java

@@ -5,6 +5,7 @@ import lombok.Data;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 统计分析 发货客户,业务员统计
@@ -19,6 +20,11 @@ public class OrderStatisticsVo implements Serializable {
 	private static final long serialVersionUID = 1L;
 
 	/**
+	 * 销售主表id
+	 */
+	private Long id;
+
+	/**
 	 * 租户
 	 */
 	private String tenantId;
@@ -163,4 +169,9 @@ public class OrderStatisticsVo implements Serializable {
 	 */
 	private String month;
 
+	/**
+	 * 时间区间
+	 */
+	private List<String> date;
+
 }

+ 36 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/OrderServiceImpl.java

@@ -1642,6 +1642,42 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, LandOrder> implem
 			if (null != acct.getLandAmountD() && null != acct.getExtraAmountD() && null != acct.getLandAmountC() && null != acct.getExtraAmountC()) {
 				acct.setProfit(acct.getLandAmountD().add(acct.getExtraAmountD()).subtract(acct.getLandAmountC()).subtract(acct.getExtraAmountC()));
 			}
+
+			//重新拼接地址
+			LambdaQueryWrapper<OrderAddress> addressLambdaQueryWrapper = new LambdaQueryWrapper<>();
+			addressLambdaQueryWrapper.eq(OrderAddress::getOrderId, acct.getOrderId())
+				.eq(OrderAddress::getTenantId, AuthUtil.getTenantId())
+				.eq(OrderAddress::getIsDeleted, 0);
+
+			List<OrderAddress> addressList = orderAddressMapper.selectList(addressLambdaQueryWrapper);
+			int i = 1;
+			StringBuilder addressDetail = new StringBuilder();
+			StringBuilder unloadingPlace = new StringBuilder();
+			if (ObjectUtil.isNotEmpty(addressList)){
+				//装货地址
+				for(OrderAddress orderAddress : addressList){
+					if (orderAddress.getBillType() == 1 || orderAddress.getBillType() == 0){
+						if (StringUtil.isNotBlank(orderAddress.getCorpName())){
+							addressDetail.append(i).append(".").append(orderAddress.getCorpName()).append("\n");
+							i++;
+						}
+					}
+				}
+				i = 1;
+				//卸货地址
+				for(OrderAddress orderAddress : addressList){
+					if (orderAddress.getBillType() == 2){
+						if (StringUtil.isNotBlank(orderAddress.getCorpName())){
+							unloadingPlace.append(i).append(".").append(orderAddress.getCorpName()).append("\n");
+							i++;
+						}
+					}
+				}
+
+				acct.setAddressDetail(addressDetail.toString());
+				acct.setUnloadingPlace(unloadingPlace.toString());
+			}
+
 		});
 	}
 

+ 2 - 2
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/mapper/OrderMapper.java

@@ -304,7 +304,7 @@ public interface OrderMapper extends BaseMapper<Order> {
 	List<OrderStatisticsVo> brandProfit(IPage<OrderStatisticsVo> page, @Param("statisticsVo") OrderStatisticsVo statisticsVo, @Param("brand") String brand);
 
 	/**
-	 * 品牌利润对比统计
+	 * 品牌利润对比明细统计
 	 */
 	List<OrderStatisticsVo> brandProfitItem(IPage<OrderStatisticsVo> page, @Param("statisticsVo") OrderStatisticsVo statisticsVo, @Param("brand") String brand);
 
@@ -314,7 +314,7 @@ public interface OrderMapper extends BaseMapper<Order> {
 	List<BrandProfitExcel> brandProfitExport(@Param("statisticsVo") OrderStatisticsVo statisticsVo, @Param("brand") String brand);
 
 	/**
-	 * 发货规格统计统计
+	 * 发货规格统计
 	 */
 	List<OrderStatisticsVo> specificationsProfit(IPage<OrderStatisticsVo> page, @Param("statisticsVo") OrderStatisticsVo statisticsVo, @Param("brand") String brand, @Param("chargeMember") String chargeMember);
 

+ 47 - 40
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/mapper/OrderMapper.xml

@@ -1415,12 +1415,13 @@ ORDER BY
 
     <select id="corpStatisticsItem" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
         SELECT
-            BO.create_time as createTime,
+            BO.id as id,
+            BO.receipt_time as createTime,
             BO.order_no as orderNo,
             BOI.quantity AS quantity,
             BO.debit_amount AS amount,
             BOI.actualQuantity AS actualQuantity,
-            BOI.arrivalAmount AS arrivalAmount
+            Round(BOI.arrivalAmount,2) AS arrivalAmount
         FROM
             business_order BO
         LEFT JOIN (
@@ -1462,11 +1463,11 @@ ORDER BY
             <if test="statisticsVo.corpName != null and statisticsVo.corpName != ''">
                 AND BCD.cname = #{statisticsVo.corpName}
             </if>
-            <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
-                and BO.receipt_time &gt;= #{statisticsVo.beginTime}
+            <if test="statisticsVo.date != null and statisticsVo.date[0] !=null and statisticsVo.date[0] != ''">
+                and BO.receipt_time &gt;= #{statisticsVo.date[0]}
             </if>
-            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
-                and BO.receipt_time &lt;= #{statisticsVo.endTime}
+            <if test="statisticsVo.date != null and statisticsVo.date[1] !=null and statisticsVo.date[1] != ''">
+                and BO.receipt_time &lt;= #{statisticsVo.date[1]}
             </if>
         </where>
     </select>
@@ -1579,13 +1580,14 @@ ORDER BY
 
     <select id="salesmanStatisticsItem" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
         SELECT
-            BO.create_time as createTime,
+            BO.id as id,
+            BO.receipt_time as createTime,
             BO.order_no as orderNo,
             BOI.quantity AS quantity,
             BO.debit_amount AS amount,
             BOI.actualQuantity AS actualQuantity,
-            BOI.arrivalAmount AS arrivalAmount,
-            BO.debit_amount - BOI.purchaseAmount AS grossProfit
+            Round(BOI.arrivalAmount,2) AS arrivalAmount,
+            BO.debit_amount - Round(BOI.purchaseAmount,2) AS grossProfit
         FROM
         business_order BO
         LEFT JOIN (
@@ -1621,11 +1623,11 @@ ORDER BY
                     '${member}'
                 </foreach>
             </if>
-            <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
-                and BO.receipt_time &gt;= #{statisticsVo.beginTime}
+            <if test="statisticsVo.date != null and statisticsVo.date[0] !=null and statisticsVo.date[0] != ''">
+                and BO.receipt_time &gt;= #{statisticsVo.date[0]}
             </if>
-            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
-                and BO.receipt_time &lt;= #{statisticsVo.endTime}
+            <if test="statisticsVo.date != null and statisticsVo.date[1] !=null and statisticsVo.date[1] != ''">
+                and BO.receipt_time &lt;= #{statisticsVo.date[1]}
             </if>
         </where>
     </select>
@@ -1735,12 +1737,13 @@ ORDER BY
 
     <select id="salesmanProfitItem" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
         SELECT
-            BO.create_time as createTime,
+            BO.id as id,
+            BO.receipt_time as createTime,
             BO.order_no as orderNo,
             BOI.quantity AS quantity,
             BO.debit_amount AS amount,
             BOI.actualQuantity AS actualQuantity,
-            BOI.arrivalAmount AS arrivalAmount,
+            Round(BOI.arrivalAmount,2) AS arrivalAmount,
             BO.this_used_profit AS thisUsedProfit,
             BO.gross_profit AS netGrossProfit,
             BO.predict_ocean_freight AS predictOceanFreight
@@ -1778,11 +1781,11 @@ ORDER BY
                     '${member}'
                 </foreach>
             </if>
-            <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
-                and BO.receipt_time &gt;= #{statisticsVo.beginTime}
+            <if test="statisticsVo.date != null and statisticsVo.date[0] !=null and statisticsVo.date[0] != ''">
+                and BO.receipt_time &gt;= #{statisticsVo.date[0]}
             </if>
-            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
-                and BO.receipt_time &lt;= #{statisticsVo.endTime}
+            <if test="statisticsVo.date != null and statisticsVo.date[1] !=null and statisticsVo.date[1] != ''">
+                and BO.receipt_time &lt;= #{statisticsVo.date[1]}
             </if>
         </where>
     </select>
@@ -1895,12 +1898,13 @@ ORDER BY
 
     <select id="customerProfitItem" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
         SELECT
-            BO.create_time as createTime,
+            BO.id as id,
+            BO.receipt_time as createTime,
             BO.order_no as orderNo,
             BOI.quantity AS quantity,
             BO.debit_amount AS amount,
             BOI.actualQuantity AS actualQuantity,
-            BOI.arrivalAmount AS arrivalAmount,
+            Round(BOI.arrivalAmount,2) AS arrivalAmount,
             BO.this_used_profit AS thisUsedProfit,
             BO.gross_profit AS netGrossProfit,
             BO.predict_ocean_freight AS predictOceanFreight
@@ -1936,11 +1940,11 @@ ORDER BY
             <if test="statisticsVo.corpName != null and statisticsVo.corpName != ''">
                 AND BCD.cname like concat('%', #{statisticsVo.corpName}, '%')
             </if>
-            <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
-                and BO.receipt_time &gt;= #{statisticsVo.beginTime}
+            <if test="statisticsVo.date != null and statisticsVo.date[0] !=null and statisticsVo.date[0] != ''">
+                and BO.receipt_time &gt;= #{statisticsVo.date[0]}
             </if>
-            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
-                and BO.receipt_time &lt;= #{statisticsVo.endTime}
+            <if test="statisticsVo.date != null and statisticsVo.date[1] !=null and statisticsVo.date[1] != ''">
+                and BO.receipt_time &lt;= #{statisticsVo.date[1]}
             </if>
         </where>
     </select>
@@ -2051,12 +2055,13 @@ ORDER BY
 
     <select id="brandProfitItem" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
         SELECT
-            BO.create_time as createTime,
+            BO.id as id,
+            BO.receipt_time as createTime,
             BO.order_no as orderNo,
             BOI.quantity AS quantity,
             BO.debit_amount AS amount,
             BOI.actualQuantity AS actualQuantity,
-            BOI.arrivalAmount AS arrivalAmount,
+            Round(BOI.arrivalAmount,2) AS arrivalAmount,
             BO.this_used_profit AS thisUsedProfit,
             BO.gross_profit AS netGrossProfit,
             BO.predict_ocean_freight AS predictOceanFreight
@@ -2088,11 +2093,11 @@ ORDER BY
                     '${item}'
                 </foreach>
             </if>
-            <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
-                and BO.receipt_time &gt;= #{statisticsVo.beginTime}
+            <if test="statisticsVo.date != null and statisticsVo.date[0] !=null and statisticsVo.date[0] != ''">
+                and BO.receipt_time &gt;= #{statisticsVo.date[0]}
             </if>
-            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
-                and BO.receipt_time &lt;= #{statisticsVo.endTime}
+            <if test="statisticsVo.date != null and statisticsVo.date[1] !=null and statisticsVo.date[1] != ''">
+                and BO.receipt_time &lt;= #{statisticsVo.date[1]}
             </if>
         </where>
     </select>
@@ -2223,12 +2228,13 @@ ORDER BY
 
     <select id="specificationsProfitItem" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
         SELECT
-            BO.create_time as createTime,
+            BO.id as id,
+            BO.receipt_time as createTime,
             BO.order_no as orderNo,
             BOI.quantity AS quantity,
-            BOI.amount AS amount,
+            ROUND(BOI.amount,2) AS amount,
             BOI.actualQuantity AS actualQuantity,
-            BOI.arrivalAmount AS arrivalAmount
+            Round(BOI.arrivalAmount,2) AS arrivalAmount
         FROM
         business_order BO
         LEFT JOIN (
@@ -2275,11 +2281,11 @@ ORDER BY
             <if test="statisticsVo.typeNo != null and statisticsVo.typeNo != ''">
                 AND BGD.Typeno like concat('%', #{statisticsVo.typeNo}, '%')
             </if>
-            <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
-                and BO.receipt_time &gt;= #{statisticsVo.beginTime}
+            <if test="statisticsVo.date != null and statisticsVo.date[0] !=null and statisticsVo.date[0] != ''">
+                and BO.receipt_time &gt;= #{statisticsVo.date[0]}
             </if>
-            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
-                and BO.receipt_time &lt;= #{statisticsVo.endTime}
+            <if test="statisticsVo.date != null and statisticsVo.date[1] !=null and statisticsVo.date[1] != ''">
+                and BO.receipt_time &lt;= #{statisticsVo.date[1]}
             </if>
         </where>
     </select>
@@ -2745,12 +2751,13 @@ ORDER BY
 
     <select id="totalSummaryItem" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
         SELECT
-            BO.create_time as createTime,
+            BO.id as id,
+            BO.receipt_time as createTime,
             BO.order_no as orderNo,
             BOI.quantity AS quantity,
             BO.debit_amount AS amount,
             BOI.actualQuantity AS actualQuantity,
-            BOI.arrivalAmount AS arrivalAmount
+            Round(BOI.arrivalAmount,2) AS arrivalAmount
         FROM
         business_order BO
         LEFT JOIN (

+ 9 - 3
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/OrderItemsServiceImpl.java

@@ -296,9 +296,15 @@ public class OrderItemsServiceImpl extends ServiceImpl<OrderItemsMapper, OrderIt
 		String updateUserIds = "";//修改人id拼接
 		String createUserIds = "";//创建人id拼接
 		for (OrderItems items : orderItemsList){
-			itemIds = itemIds + items.getItemId() + ",";
-			updateUserIds = updateUserIds + items.getUpdateUser() + ",";
-			createUserIds = createUserIds + items.getCreateUser() + ",";
+			if (ObjectUtil.isNotEmpty(items.getItemId())){
+				itemIds = itemIds + items.getItemId() + ",";
+			}
+			if (ObjectUtil.isNotEmpty(items.getUpdateUser())){
+				updateUserIds = updateUserIds + items.getUpdateUser() + ",";
+			}
+			if (ObjectUtil.isNotEmpty(items.getCreateUser())){
+				createUserIds = createUserIds + items.getCreateUser() + ",";
+			}
 		}
 
 		//获得商品信息

+ 124 - 8
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/OrderServiceImpl.java

@@ -1364,11 +1364,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	@Transactional(rollbackFor = Exception.class)
 	@GlobalTransactional(rollbackFor = Exception.class)
 	public void checkPassCancel(Long id) {
-		//当销售订单完成采购订单、工厂发货、客户收货、财务收款、付款任意一个,撤销审核不能用
-		//生成的 采购订单、工厂发货、客户收货订单删除后,允许撤销
-		//撤销审核后,该条销售账单明细删除;内贸锁定库存释放;销售订单状态变为【录入】;销售订单允许重新编辑、删除,允许重新生成采购、客户收货
-		//积分 溢付款 返利 还原
-
 		//获得当前销售订单信息
 		Order orderMessage = baseMapper.selectById(id);
 		if (orderMessage == null){//判断销售订单是否为null
@@ -1380,22 +1375,143 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 			.eq(Order::getIsDeleted, 0)
 			.eq(Order::getTenantId, AuthUtil.getTenantId())
 			.eq(Order::getSrcId, orderMessage.getId()));
-		if (ObjectUtil.isNotEmpty(orderPurchase)){
+		if (ObjectUtil.isNotEmpty(orderPurchase)){//判断采购订单是否存在
 			throw new SecurityException("采购订单已存在,禁止撤销");
 		}
 
 		//根据订单号获得工厂发货
 		List<Delivery> deliveryList = deliveryClient.getOrderMessage(orderMessage.getOrderNo(), OrderTypeEnum.DOMESTIC.getType());
-		if (CollectionUtils.isNotEmpty(deliveryList)) {
+		if (CollectionUtils.isNotEmpty(deliveryList)) {//判断收发货是否存在
 			throw new SecurityException("收发货单据已存在,禁止撤销");
 		}
 
 		//获得财务收款信息
 		List<Settlement> settlementList = financeClient.selectSrcOrderNo(orderMessage.getOrderNo());
-		if (CollectionUtils.isNotEmpty(settlementList)) {
+		if (CollectionUtils.isNotEmpty(settlementList)) {//判断收款是否存在
 			throw new SecurityException("收款单据已存在,禁止撤销");
 		}
 
+		// 销售释放库存
+		if ("XS".equals(orderMessage.getBillType()) && orderMessage.getTradeType().equals(OrderTypeEnum.DOMESTIC.getType())) {
+			// ===========================Start 审核撤销释放库存=============================
+			// 获取此销售订单下,所有明细的库存
+			LambdaQueryWrapper<OrderItems> orderItemsLambdaQueryWrapper = new LambdaQueryWrapper<>();
+			orderItemsLambdaQueryWrapper
+				.eq(OrderItems::getGoodType, 0)
+				.eq(OrderItems::getPid, orderMessage.getId())
+				.eq(OrderItems::getIsDeleted, 0);
+			List<OrderItems> orderItems = orderItemsMapper.selectList(orderItemsLambdaQueryWrapper);
+			if (CollectionUtils.isNotEmpty(orderItems)) {
+				orderItems.forEach(e -> {
+					StockGoods stockGoods = new StockGoods();
+					stockGoods.setCorpId(e.getCorpId());
+					stockGoods.setGoodsId(e.getItemId());
+					stockGoods.setTenantId(SecureUtil.getTenantId());
+					List<StockGoods> listStockGoods = stockGoodsClient.postListStockByCondition(stockGoods);
+					if (listStockGoods.size() > 1 || CollectionUtils.isEmpty(listStockGoods)) {
+						throw new SecurityException("撤销失败:未查询到库存 或者 存在多条库存记录");
+					}
+					// 开始锁定库存,减少可用
+					StockGoods oneStock = stockGoodsClient.getOneStock(stockGoods);
+					if (oneStock == null) {
+						throw new SecurityException("撤销失败:未查询到库存信息");
+					}
+					// 原单据的订货数量
+					BigDecimal orderQuantity = e.getOrderQuantity();
+					// 可用库存
+					BigDecimal surplusRouteQuantity = oneStock.getSurplusRouteQuantity();
+					// 锁定库存
+					BigDecimal lockingQuantity = oneStock.getLockingQuantity();
+
+					// 判断比较大小
+					if (orderQuantity.compareTo(lockingQuantity) > 0) {
+						throw new SecurityException("撤销失败:原单据的" + oneStock.getCode() + "订货数量大于锁定库存,无法释放 库存");
+					}
+					// 增加可用库存
+					oneStock.setSurplusRouteQuantity(surplusRouteQuantity.add(orderQuantity));
+					// 减少锁定库存
+					oneStock.setLockingQuantity(lockingQuantity == null ? new BigDecimal("0") : lockingQuantity.subtract(orderQuantity));
+					// 更新库存
+					boolean r = stockGoodsClient.updateStock(oneStock);
+					if (!r) {
+						throw new SecurityException("撤销失败: " + oneStock.getCode() + "更新库存失败");
+					}
+
+					//删除明细
+					int res = orderItemsMapper.deleteById(e.getId());
+					if (res != 1){
+						throw new SecurityException("撤销失败,明细错误");
+					}
+				});
+			}
+		}
+
+		//返利还原
+		/**===========================start 撤销操作返利信息=============================*/
+		if ((orderMessage.getThisUsedProfit().compareTo(new BigDecimal("0")) == 0 || orderMessage.getThisUsedProfit() != null)
+			&& (orderMessage.getCreateProfit().compareTo(new BigDecimal("0")) == 0 || orderMessage.getCreateProfit() != null)) {
+			// 检查是否使用返利,如果使用返利
+			BasicCorpsProfitChange basicCorpsProfitChange = new BasicCorpsProfitChange();
+			basicCorpsProfitChange.setCorpId(orderMessage.getCorpId());
+			basicCorpsProfitChange.setOrderId(orderMessage.getId());
+			basicCorpsProfitChange.setOrderNo(orderMessage.getOrderNo());
+			basicCorpsProfitChange.setCreateTime(new Date());
+			basicCorpsProfitChange.setCreateUser(AuthUtil.getUserId());
+			// 有返利
+			if (orderMessage.getThisUsedProfit() != null && orderMessage.getThisUsedProfit().compareTo(BigDecimal.ZERO) > 0) {
+				// 增加客户的已用返利
+				basicCorpsProfitChange.setChangeUsedProfit(orderMessage.getThisUsedProfit());
+				// 减少客户的可用返利
+				basicCorpsProfitChange.setChangeSurplusProfit(orderMessage.getThisUsedProfit().negate());
+			}
+			// 检查是否含有产生返利,如果有, 需要增加客户的本月待到账返利
+			if (orderMessage.getCreateProfit() != null && orderMessage.getCreateProfit().compareTo(BigDecimal.ZERO) > 0) {
+				// 增加客户的月返利
+				basicCorpsProfitChange.setChangeMonthProfit(orderMessage.getCreateProfit());
+
+			}
+			// 新增返利变动记录
+			R save = corpsProfitChangeClient.save(basicCorpsProfitChange);
+			if (!save.isSuccess()) {
+				throw new SecurityException("保存返利变动记录失败");
+			}
+			// 修改客户返利
+			R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(orderMessage.getCorpId());
+			if (!corpMessage.isSuccess() || corpMessage.getData() == null) {
+				throw new SecurityException("未查到客户记录");
+			}
+			CorpsDesc corpsDesc = corpMessage.getData();
+			corpsDesc.setProfitReturn(basicCorpsProfitChange.getChangeProfitReturn() == null ? new BigDecimal("0").subtract(corpsDesc.getProfitReturn()) : basicCorpsProfitChange.getChangeProfitReturn().subtract(corpsDesc.getProfitReturn()));
+			corpsDesc.setUsedProfit(basicCorpsProfitChange.getChangeUsedProfit() == null ? new BigDecimal("0").subtract(corpsDesc.getUsedProfit()) : basicCorpsProfitChange.getChangeUsedProfit().subtract(corpsDesc.getUsedProfit()));
+			corpsDesc.setSurplusProfit(basicCorpsProfitChange.getChangeSurplusProfit() == null ? new BigDecimal("0").subtract(corpsDesc.getSurplusProfit()) : basicCorpsProfitChange.getChangeSurplusProfit().subtract(corpsDesc.getSurplusProfit()));
+			corpsDesc.setMonthProfit(basicCorpsProfitChange.getChangeMonthProfit() == null ? new BigDecimal("0").subtract(corpsDesc.getMonthProfit()) : basicCorpsProfitChange.getChangeMonthProfit().subtract(corpsDesc.getMonthProfit()));
+
+			if (corpsDesc.getProfitReturn().compareTo(new BigDecimal("0")) < 0) {
+				throw new SecurityException("修改客户返利失败:总返利不能为负数");
+			}
+			if (corpsDesc.getUsedProfit().compareTo(new BigDecimal("0")) < 0) {
+				throw new SecurityException("修改客户返利失败:已用返利不能为负数");
+			}
+			if (corpsDesc.getSurplusProfit().compareTo(new BigDecimal("0")) < 0) {
+				throw new SecurityException("修改客户返利失败:可用返利不能为负数");
+			}
+			if (corpsDesc.getMonthProfit().compareTo(new BigDecimal("0")) < 0) {
+				throw new SecurityException("修改客户返利失败:本月待到账返利不能为负数");
+			}
+			// 更新客户返利情况
+			R corpsUpdate = corpsDescClient.corpsUpdate(corpsDesc);
+			if (!corpsUpdate.isSuccess()) {
+				throw new SecurityException("更新客户返利信息失败");
+			}
+		}
+		/**===========================End撤销操作返利信息=============================*/
+
+		//删除审批记录
+		iCheckClient.deteleByBillId(orderMessage.getId());
+		orderMessage.setStatus(0);
+		orderMessage.setOrderStatus(OrderStatusEnum.ENTERING.getType());
+		baseMapper.updateById(orderMessage);
+
 	}
 
 	@Override