订单拆分逻辑(关闭订单)

highway
wws 1 year ago
parent da486d7e20
commit 48496ffa9a

@ -168,4 +168,11 @@ public interface ProOrderMapper {
* @return
*/
int updateProOrderByOrderCode(ProOrder order);
/**
* codecode
* @param orderCode
* @return
*/
public String selectChildProOrderCodeByCode(String orderCode);
}

@ -155,6 +155,33 @@ public class ProOrderServiceImpl implements IProOrderService {
run = false;
}
}
// 关闭订单,判断是否拆分完成
ProOrder order = proOrderMapper.selectProOrderById(splitOrderDTO.getProduct().getId());
Long quantitySplit = order.getQuantitySplit();
Long quantity1 = order.getQuantity();
if (quantity1.equals(quantitySplit)) {
// 需要关闭订单的codeList
List<String> orderCodes = new ArrayList<>();
// 临时存放code
StringBuilder orderCode = new StringBuilder();
orderCode.append(order.getOrderCode());
while(true) {
orderCodes.add(orderCode.toString());
String selectOrderCode = proOrderMapper.selectChildProOrderCodeByCode(orderCode.toString());
if (selectOrderCode == null) {
break;
}
orderCode.setLength(0);
orderCode.append(selectOrderCode);
}
// 关闭订单
for (String code : orderCodes) {
remoteSapService.sapCloseOrder(code);
}
}
return success();
}

@ -137,6 +137,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where order_code = #{orderCode}
</select>
<select id="selectChildProOrderCodeByCode" resultType="java.lang.String">
select order_code from pro_order where parent_order = #{orderCode}
</select>
<insert id="insertProOrder" parameterType="ProOrder">
insert into pro_order
<trim prefix="(" suffix=")" suffixOverrides=",">

Loading…
Cancel
Save