|
@@ -14,6 +14,8 @@ import me.zhengjie.modules.dm.order.repository.DmOrderRecordRepository;
|
|
|
import me.zhengjie.modules.dm.order.service.DmOrderItemService;
|
|
|
import me.zhengjie.modules.dm.order.service.DmOrderPaymentService;
|
|
|
import me.zhengjie.modules.dm.order.service.DmOrderRecordService;
|
|
|
+import me.zhengjie.modules.dm.settlement.domain.DmSettlement;
|
|
|
+import me.zhengjie.modules.dm.settlement.service.DmSettlementService;
|
|
|
import me.zhengjie.modules.dm.user.domain.DmUser;
|
|
|
import me.zhengjie.modules.dm.user.service.DmUserService;
|
|
|
import me.zhengjie.modules.dm.user.service.dto.DmUserQueryCriteria;
|
|
@@ -42,6 +44,7 @@ public class CardRecordTask {
|
|
|
private final LogRepository logRepository;
|
|
|
private final DmOrderRecordRepository dmOrderRecordRepository;
|
|
|
private final DmUserService dmUserService;
|
|
|
+ private final DmSettlementService dmSettlementService;
|
|
|
// private final DmExpenseCalendarService dmExpenseCalendarService;
|
|
|
|
|
|
// public void run() throws ParseException, IOException {
|
|
@@ -226,6 +229,10 @@ public class CardRecordTask {
|
|
|
List<Map<String, Object>> list = dmOrderRecordRepository.selectOrderRecordBySeq(seq);
|
|
|
|
|
|
if(list.size() == 0) {
|
|
|
+ DmSettlement dmSettlement = new DmSettlement();
|
|
|
+ dmSettlement.setCardCode(attendance.getString("card"));
|
|
|
+ dmSettlement.setOrderTime(attendance.getTimestamp("createTime"));
|
|
|
+
|
|
|
DmOrderRecord dmExpenseCalendar = new DmOrderRecord();
|
|
|
|
|
|
dmExpenseCalendar.setSeq(attendance.getLong("seq"));
|
|
@@ -251,9 +258,11 @@ public class CardRecordTask {
|
|
|
* 对方未有dept字段 需要手动去数据库中查询 根据卡号查对应的 用户
|
|
|
*/
|
|
|
DmUser dmUser = dmUserService.queryUserByCardId(attendance.getString("card"));
|
|
|
+ dmSettlement.setDmUser(dmUser);
|
|
|
dmExpenseCalendar.setDept(dmUser.getDept());
|
|
|
String bh = UUID.randomUUID().toString();
|
|
|
dmExpenseCalendar.setBh(bh);//UUID 生成 与dm_order_item关联编号
|
|
|
+ dmSettlement.setBh(bh);
|
|
|
JSONArray item = attendance.getJSONArray("details");
|
|
|
/**
|
|
|
* 生成个map来统计数量
|
|
@@ -278,6 +287,14 @@ public class CardRecordTask {
|
|
|
dmOrderItem.setMoney(String.valueOf(userData.getDouble("amt")));//小计
|
|
|
dmOrderItem.setPjType("0");
|
|
|
dmOrderItem.setNum(map.get(dmOrderItem.getName()));
|
|
|
+ String foodName = dmSettlement.getFoodName() == null?"":","; //结算管理的
|
|
|
+ Integer foodNum = dmSettlement.getFoodNum() == null?0:dmSettlement.getFoodNum();
|
|
|
+ String foodPrice = dmSettlement.getFoodPrice() == null?"":",";
|
|
|
+ BigDecimal totalPrice = dmSettlement.getTotalPrice() == null?BigDecimal.ZERO:dmSettlement.getTotalPrice();
|
|
|
+ dmSettlement.setFoodName(foodName+dmOrderItem.getName());//结算管理 商品名称
|
|
|
+ dmSettlement.setFoodNum(foodNum+dmOrderItem.getNum());//结算管理 商品数量
|
|
|
+ dmSettlement.setTotalPrice(totalPrice.add(BigDecimal.valueOf(Double.valueOf(dmOrderItem.getPrice()))));//结算管理总价格
|
|
|
+ dmSettlement.setFoodPrice(foodPrice+dmOrderItem.getPrice());//结算管理 单价
|
|
|
dmOrderItemService.create(dmOrderItem);
|
|
|
}
|
|
|
JSONArray payment = attendance.getJSONArray("payments");
|
|
@@ -293,6 +310,7 @@ public class CardRecordTask {
|
|
|
dmOrderPaymentService.create(dmOrderPayment);
|
|
|
}
|
|
|
dmOrderRecordService.create(dmExpenseCalendar);
|
|
|
+ dmSettlementService.create(dmSettlement);
|
|
|
}else {
|
|
|
log.info("dmOrderRecord is not null. seq:"+seq);
|
|
|
}
|