he.dujuan 2 gadi atpakaļ
vecāks
revīzija
b8d8db14b3

+ 10 - 1
eladmin-system/src/main/java/me/zhengjie/modules/dm/settlement/domain/DmSettlement.java

@@ -25,6 +25,7 @@ import javax.persistence.Entity;
 import javax.persistence.Table;
 
 import me.zhengjie.base.BaseEntity;
+import me.zhengjie.modules.dm.user.domain.DmUser;
 import org.hibernate.annotations.*;
 import java.sql.Timestamp;
 import java.math.BigDecimal;
@@ -52,7 +53,7 @@ public class DmSettlement extends BaseEntity implements Serializable {
 
     @Column(name = "food_price")
     @ApiModelProperty(value = "菜品单价")
-    private BigDecimal foodPrice;
+    private String foodPrice;
 
     @Column(name = "food_num")
     @ApiModelProperty(value = "点餐数量")
@@ -70,6 +71,14 @@ public class DmSettlement extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "结算卡号")
     private String cardCode;
 
+    @ApiModelProperty(value = "用户卡号")
+    @OneToOne(fetch = FetchType.LAZY)
+    @JoinColumn(name = "user_code",referencedColumnName = "user_number")
+    private DmUser dmUser;
+    @Column(name = "bh")
+    @ApiModelProperty(value = "订单编号")
+    private String bh;
+
     public void copy(DmSettlement source){
         BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
     }

+ 6 - 1
eladmin-system/src/main/java/me/zhengjie/modules/dm/settlement/service/dto/DmSettlementDto.java

@@ -21,6 +21,7 @@ import java.math.BigDecimal;
 import java.io.Serializable;
 import com.alibaba.fastjson.annotation.JSONField;
 import com.alibaba.fastjson.serializer.ToStringSerializer;
+import me.zhengjie.modules.dm.user.domain.DmUser;
 
 /**
 * @website https://el-admin.vip
@@ -40,7 +41,7 @@ public class DmSettlementDto implements Serializable {
     private String foodName;
 
     /** 菜品单价 */
-    private BigDecimal foodPrice;
+    private String foodPrice;
 
     /** 点餐数量 */
     private Integer foodNum;
@@ -65,4 +66,8 @@ public class DmSettlementDto implements Serializable {
 
     /** 结算卡号 */
     private String cardCode;
+    /** 用户*/
+    private DmUser dmUser;
+    /** 订单编号*/
+    private String bh;
 }

+ 3 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/settlement/service/dto/DmSettlementQueryCriteria.java

@@ -51,4 +51,7 @@ public class DmSettlementQueryCriteria{
     /** BETWEEN */
     @Query(type = Query.Type.BETWEEN)
     private List<Timestamp> orderTime;
+    /** 订单编号*/
+    @Query
+    private String bh;
 }

+ 2 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/settlement/service/impl/DmSettlementServiceImpl.java

@@ -100,7 +100,9 @@ public class DmSettlementServiceImpl implements DmSettlementService {
         List<Map<String, Object>> list = new ArrayList<>();
         for (DmSettlementDto dmSettlement : all) {
             Map<String,Object> map = new LinkedHashMap<>();
+            map.put("订单编号", dmSettlement.getBh());
             map.put("菜品名称", dmSettlement.getFoodName());
+            map.put("用户名称", dmSettlement.getDmUser().getName());
             map.put("菜品单价", dmSettlement.getFoodPrice());
             map.put("点餐数量", dmSettlement.getFoodNum());
             map.put("小计(点餐价格合计)", dmSettlement.getTotalPrice());

+ 18 - 0
eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/CardRecordTask.java

@@ -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);
                 }

+ 2 - 0
eladmin-system/src/main/java/me/zhengjie/modules/thirdparty/v1/OpenApiController.java

@@ -5,9 +5,11 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import me.zhengjie.annotation.AnonymousAccess;
+import me.zhengjie.annotation.Limit;
 import me.zhengjie.annotation.Log;
 import me.zhengjie.annotation.rest.AnonymousGetMapping;
 import me.zhengjie.annotation.rest.AnonymousPostMapping;
+import me.zhengjie.aspect.LimitType;
 import me.zhengjie.base.BaseResponse;
 import me.zhengjie.base.QueryPageParams;
 import me.zhengjie.domain.LocalStorage;