Compare commits
	
		
			3 Commits
		
	
	
		
			923f62c64f
			...
			5cadd2e17d
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								
								 | 
						5cadd2e17d | |
| 
							
							
								
								 | 
						4ebf60c66e | |
| 
							
							
								
								 | 
						162014c18a | 
| 
						 | 
					@ -59,6 +59,8 @@ import org.springframework.stereotype.Service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.math.BigDecimal;
 | 
					import java.math.BigDecimal;
 | 
				
			||||||
import java.math.RoundingMode;
 | 
					import java.math.RoundingMode;
 | 
				
			||||||
 | 
					import java.text.ParseException;
 | 
				
			||||||
 | 
					import java.text.SimpleDateFormat;
 | 
				
			||||||
import java.time.LocalDate;
 | 
					import java.time.LocalDate;
 | 
				
			||||||
import java.time.LocalDateTime;
 | 
					import java.time.LocalDateTime;
 | 
				
			||||||
import java.time.LocalTime;
 | 
					import java.time.LocalTime;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,4 +16,9 @@ import java.util.List;
 | 
				
			||||||
public class StageRefundParam extends OrderRefundParam {
 | 
					public class StageRefundParam extends OrderRefundParam {
 | 
				
			||||||
    @NotNull(message = "交易ID不能为空")
 | 
					    @NotNull(message = "交易ID不能为空")
 | 
				
			||||||
    private Long tradeId;
 | 
					    private Long tradeId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @NotNull(message = "交易地点")
 | 
				
			||||||
 | 
					    private String  merchant;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private String remark;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -109,7 +109,7 @@ public class OrderPlaceMobileBusinessImplV3 implements OrderPlaceMobileBusiness
 | 
				
			||||||
   @Autowired
 | 
					   @Autowired
 | 
				
			||||||
   @Lazy
 | 
					   @Lazy
 | 
				
			||||||
   protected OrderDeliveryService orderDeliveryService;
 | 
					   protected OrderDeliveryService orderDeliveryService;
 | 
				
			||||||
//   @Autowired
 | 
					   //   @Autowired
 | 
				
			||||||
//   @Lazy
 | 
					//   @Lazy
 | 
				
			||||||
//   protected OrderPreBookService orderPreBookService;
 | 
					//   protected OrderPreBookService orderPreBookService;
 | 
				
			||||||
   @Autowired
 | 
					   @Autowired
 | 
				
			||||||
| 
						 | 
					@ -390,12 +390,14 @@ public class OrderPlaceMobileBusinessImplV3 implements OrderPlaceMobileBusiness
 | 
				
			||||||
              stagePayDTO.getCouponId(),
 | 
					              stagePayDTO.getCouponId(),
 | 
				
			||||||
              stagePayDTO.getSourceType(),
 | 
					              stagePayDTO.getSourceType(),
 | 
				
			||||||
              null,
 | 
					              null,
 | 
				
			||||||
               null,
 | 
					              null,
 | 
				
			||||||
              stagePayDTO.getOpenid(),
 | 
					              stagePayDTO.getOpenid(),
 | 
				
			||||||
              custInfo,
 | 
					              custInfo,
 | 
				
			||||||
              stagePayDTO);
 | 
					              stagePayDTO);
 | 
				
			||||||
      unifyPayDTO.setAmount(stagePayDTO.getAmount());
 | 
					      unifyPayDTO.setAmount(stagePayDTO.getAmount());
 | 
				
			||||||
      unifyPayDTO.setRemark("驿站支付");
 | 
					      unifyPayDTO.setRemark(stagePayDTO.getRemark()+"支付");
 | 
				
			||||||
 | 
					      //处理设备sn码问题
 | 
				
			||||||
 | 
					      unifyPayDTO.setMachineSn( stagePayDTO.getMerchant());
 | 
				
			||||||
      return payApi.pay(unifyPayDTO);
 | 
					      return payApi.pay(unifyPayDTO);
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,4 +21,6 @@ public class StagePayMobileDTO extends OrderPayMobileDTO{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   @ApiModelProperty("sourceType")
 | 
					   @ApiModelProperty("sourceType")
 | 
				
			||||||
   private Integer sourceType;
 | 
					   private Integer sourceType;
 | 
				
			||||||
 | 
					   @ApiModelProperty("设备sn")
 | 
				
			||||||
 | 
					   private String merchant;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,15 @@
 | 
				
			||||||
 | 
					package com.bonus.canteen.core.reportforms.beans;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import lombok.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Data
 | 
				
			||||||
 | 
					public class CanteenOrg {
 | 
				
			||||||
 | 
					    private Long orgId;         // org_id
 | 
				
			||||||
 | 
					    private String orgName;     // org_name
 | 
				
			||||||
 | 
					    private String orgFullName; // org_full_name
 | 
				
			||||||
 | 
					    private Long superId;       // super_id
 | 
				
			||||||
 | 
					    private List<CanteenOrg> children; // 子节点
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,27 @@
 | 
				
			||||||
 | 
					package com.bonus.canteen.core.reportforms.beans;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.bonus.common.core.web.domain.BaseEntity;
 | 
				
			||||||
 | 
					import lombok.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Data
 | 
				
			||||||
 | 
					public class CanteenRecord  extends BaseEntity {
 | 
				
			||||||
 | 
					    private Long orgId;                  // 主键ID
 | 
				
			||||||
 | 
					    private String orgName;
 | 
				
			||||||
 | 
					    private String custName;          // 姓名
 | 
				
			||||||
 | 
					    private String custId;            // 用户编号
 | 
				
			||||||
 | 
					    private String orgFullName;       // 所属组织
 | 
				
			||||||
 | 
					    private String flowTypeName;      // 消费情况
 | 
				
			||||||
 | 
					    private String consumeSource;     // 订单类型
 | 
				
			||||||
 | 
					    private String ordDate;             // 就餐日期
 | 
				
			||||||
 | 
					    private Double amount;            // 订单金额
 | 
				
			||||||
 | 
					    private String phone;             // 用户手机号
 | 
				
			||||||
 | 
					    private String ordTime;             // 下单时间
 | 
				
			||||||
 | 
					    private String remark;            // 备注
 | 
				
			||||||
 | 
					    private String startPayTime;
 | 
				
			||||||
 | 
					    private String endPayTime;
 | 
				
			||||||
 | 
					    private String flowType;
 | 
				
			||||||
 | 
					    private  String[] selectedOrg;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,31 @@
 | 
				
			||||||
 | 
					package com.bonus.canteen.core.reportforms.beans;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import lombok.Data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.math.BigDecimal;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Data
 | 
				
			||||||
 | 
					public class OrgConsume {
 | 
				
			||||||
 | 
					    private Long orgId;
 | 
				
			||||||
 | 
					    private String orgName;            // 食堂名字
 | 
				
			||||||
 | 
					    private BigDecimal reserveAmount = BigDecimal.ZERO;  // APP预定金额
 | 
				
			||||||
 | 
					    private BigDecimal canteenAmount = BigDecimal.ZERO;  // 食堂消费
 | 
				
			||||||
 | 
					    private BigDecimal superAmount = BigDecimal.ZERO;    // 超市消费
 | 
				
			||||||
 | 
					    private BigDecimal deductionAmount = BigDecimal.ZERO;    // 补扣消费
 | 
				
			||||||
 | 
					    //H5消费
 | 
				
			||||||
 | 
					    private BigDecimal h5Amount = BigDecimal.ZERO;
 | 
				
			||||||
 | 
					    private BigDecimal amount= BigDecimal.ZERO;   //详情中都用这个字段做消费
 | 
				
			||||||
 | 
					    private String startPayTime;//开始支付时间
 | 
				
			||||||
 | 
					    private String endPayTime;//结束支付时间
 | 
				
			||||||
 | 
					    private String custName;
 | 
				
			||||||
 | 
					    private String custNameLike;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private String flowId;
 | 
				
			||||||
 | 
					    private Integer flowType;
 | 
				
			||||||
 | 
					    private String payTime;
 | 
				
			||||||
 | 
					    private String orgFullName;
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 1:APP预定 2:驿站消费 3:食堂消费 4:超市消费
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private Integer conSource;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,142 @@
 | 
				
			||||||
 | 
					package com.bonus.canteen.core.reportforms.controller;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.beans.CanteenOrg;
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.beans.CanteenRecord;
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.beans.OrgConsume;
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.service.reportformsService;
 | 
				
			||||||
 | 
					import com.bonus.common.core.web.controller.BaseController;
 | 
				
			||||||
 | 
					import com.bonus.common.core.web.page.TableDataInfo;
 | 
				
			||||||
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
 | 
					import org.slf4j.LoggerFactory;
 | 
				
			||||||
 | 
					import org.springframework.web.bind.annotation.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Resource;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static com.bonus.common.core.utils.PageUtils.startPage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@RestController
 | 
				
			||||||
 | 
					@RequestMapping({"/api/v2/report"})
 | 
				
			||||||
 | 
					public class reportformsController extends BaseController {
 | 
				
			||||||
 | 
					    private static final Logger log = LoggerFactory.getLogger(reportformsController.class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Resource
 | 
				
			||||||
 | 
					    private reportformsService service;
 | 
				
			||||||
 | 
					    @PostMapping("/consume/list")
 | 
				
			||||||
 | 
					    public List<OrgConsume> list(@RequestBody OrgConsume orgConsume) {
 | 
				
			||||||
 | 
					        return service.getOrgConsumeList(orgConsume);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @GetMapping("/consume/peoplelist")
 | 
				
			||||||
 | 
					    public TableDataInfo peoplelist(CanteenRecord orgConsume) {
 | 
				
			||||||
 | 
					        startPage();
 | 
				
			||||||
 | 
					        List<CanteenRecord> peoplelist = service.getPeoplelist(orgConsume);
 | 
				
			||||||
 | 
					        return getDataTable(peoplelist);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 食堂预订餐接口查询
 | 
				
			||||||
 | 
					     * 通过区域名称查询
 | 
				
			||||||
 | 
					     * @param orgConsume
 | 
				
			||||||
 | 
					     * @return
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @PostMapping("/consume/listByArea")
 | 
				
			||||||
 | 
					    /*public List<OrgConsume> listByArea(@RequestBody OrgConsume orgConsume) {
 | 
				
			||||||
 | 
					        //区域
 | 
				
			||||||
 | 
					        String orgName = orgConsume.getOrgName();
 | 
				
			||||||
 | 
					        // 去掉里面的“食堂”字样
 | 
				
			||||||
 | 
					        if (orgName != null) {
 | 
				
			||||||
 | 
					            orgName = orgName.replace("食堂", "");
 | 
				
			||||||
 | 
					            orgConsume.setOrgName(orgName);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if(orgConsume.getConSource() == 1){
 | 
				
			||||||
 | 
					            if ("运检后勤".equals(orgName)) {
 | 
				
			||||||
 | 
					                orgName = "运检分公司";
 | 
				
			||||||
 | 
					                orgConsume.setOrgName(orgName);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return service.getlistByH5list(orgConsume);
 | 
				
			||||||
 | 
					        } else if (orgConsume.getConSource() == 3) {
 | 
				
			||||||
 | 
					            //如果是送变电工业园食堂  修改成sbd工业园
 | 
				
			||||||
 | 
					            if ("送变电工业园".equals(orgName)) {
 | 
				
			||||||
 | 
					                orgName = "sbd工业园";
 | 
				
			||||||
 | 
					                orgConsume.setOrgName(orgName);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return service.getlistByArealist(orgConsume);
 | 
				
			||||||
 | 
					        } else if (orgConsume.getConSource() ==4 ) {
 | 
				
			||||||
 | 
					            if ("送变电工业园".equals(orgName)) {
 | 
				
			||||||
 | 
					                orgName = "sbd工业园";
 | 
				
			||||||
 | 
					                orgConsume.setOrgName(orgName);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return service.getlistBySuperlist(orgConsume);
 | 
				
			||||||
 | 
					        }else if (orgConsume.getConSource() ==5){
 | 
				
			||||||
 | 
					            if ("送变电工业园".equals(orgName)) {
 | 
				
			||||||
 | 
					                orgName = "sbd工业园";
 | 
				
			||||||
 | 
					                orgConsume.setOrgName(orgName);
 | 
				
			||||||
 | 
					                return service.getDeductionlist(orgConsume);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (orgConsume.getConSource() ==2 ) {
 | 
				
			||||||
 | 
					            //驿站消费
 | 
				
			||||||
 | 
					            return service.getlistByOtherlist(orgConsume);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }*/
 | 
				
			||||||
 | 
					    public List<OrgConsume> listByArea(@RequestBody OrgConsume orgConsume) {
 | 
				
			||||||
 | 
					        String orgName = orgConsume.getOrgName();
 | 
				
			||||||
 | 
					        Integer conSource = orgConsume.getConSource();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 统一处理机构名称
 | 
				
			||||||
 | 
					        if (orgName != null) {
 | 
				
			||||||
 | 
					            orgName = orgName.replace("食堂", "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 特殊机构名称处理
 | 
				
			||||||
 | 
					            if ("运检后勤".equals(orgName) && conSource == 1) {
 | 
				
			||||||
 | 
					                orgName = "运检分公司";
 | 
				
			||||||
 | 
					            } else if ("送变电工业园".equals(orgName) && (conSource == 3 || conSource == 4 || conSource == 5)) {
 | 
				
			||||||
 | 
					                orgName = "sbd工业园";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            orgConsume.setOrgName(orgName);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 根据数据源类型路由到不同的服务方法
 | 
				
			||||||
 | 
					        switch (conSource) {
 | 
				
			||||||
 | 
					            case 1:
 | 
				
			||||||
 | 
					                return service.getlistByH5list(orgConsume);
 | 
				
			||||||
 | 
					            case 2:
 | 
				
			||||||
 | 
					                return service.getlistByOtherlist(orgConsume);
 | 
				
			||||||
 | 
					            case 3:
 | 
				
			||||||
 | 
					                return service.getlistByArealist(orgConsume);
 | 
				
			||||||
 | 
					            case 4:
 | 
				
			||||||
 | 
					                return service.getlistBySuperlist(orgConsume);
 | 
				
			||||||
 | 
					            case 5:
 | 
				
			||||||
 | 
					                return service.getDeductionlist(orgConsume);
 | 
				
			||||||
 | 
					            default:
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 超市预订餐接口查询
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @PostMapping("/consume/listBySuper")
 | 
				
			||||||
 | 
					    public List<OrgConsume> listBySuper(@RequestBody OrgConsume orgConsume) {
 | 
				
			||||||
 | 
					        return service.getlistBySuperlist(orgConsume);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * H5预订餐详情查询
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @PostMapping("/consume/listByH5")
 | 
				
			||||||
 | 
					    public List<OrgConsume> listByH5(@RequestBody OrgConsume orgConsume) {
 | 
				
			||||||
 | 
					        return service.getlistByH5list(orgConsume);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 组织结构后台
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @GetMapping("/tree")
 | 
				
			||||||
 | 
					    public List<CanteenOrg> getOrgTree() {
 | 
				
			||||||
 | 
					        return service.getOrgTree();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,46 @@
 | 
				
			||||||
 | 
					package com.bonus.canteen.core.reportforms.mapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.menu.vo.AppletReserveCanteenVO;
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.menu.vo.AppletWeekCanteenVO;
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.beans.CanteenOrg;
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.beans.CanteenRecord;
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.beans.OrgConsume;
 | 
				
			||||||
 | 
					import org.apache.ibatis.annotations.MapKey;
 | 
				
			||||||
 | 
					import org.apache.ibatis.annotations.Mapper;
 | 
				
			||||||
 | 
					import org.apache.ibatis.annotations.Param;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.math.BigDecimal;
 | 
				
			||||||
 | 
					import java.time.LocalDate;
 | 
				
			||||||
 | 
					import java.util.Collection;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					import java.util.Set;
 | 
				
			||||||
 | 
					import java.util.stream.DoubleStream;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Mapper
 | 
				
			||||||
 | 
					public interface OrgConsumeMapper {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   List<Map<String, Object>> selectConsumeRecords(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   List<Map<String, Object>> selectReserveRecords(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   List<Map<String, String>> selectAreaOrgMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   List<OrgConsume> getlistByArealist(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   List<OrgConsume> getlistBySuperlist(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   List<OrgConsume> getlistByH5list(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   List<OrgConsume>  getlistByOtherlist(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   BigDecimal yzSumMoney(OrgConsume neworgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   List<OrgConsume>  getlistConsmerlist(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   List<CanteenRecord> getPeoplelist(CanteenRecord orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   List<CanteenOrg> selectAllOrgs();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   List<OrgConsume>  getDeductionlist(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,228 @@
 | 
				
			||||||
 | 
					package com.bonus.canteen.core.reportforms.service.impl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.beans.CanteenOrg;
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.beans.CanteenRecord;
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.beans.OrgConsume;
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.mapper.OrgConsumeMapper;
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.service.reportformsService;
 | 
				
			||||||
 | 
					import com.bonus.common.houqin.utils.SM4EncryptUtils;
 | 
				
			||||||
 | 
					import org.springframework.stereotype.Service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.Resource;
 | 
				
			||||||
 | 
					import java.math.BigDecimal;
 | 
				
			||||||
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Service
 | 
				
			||||||
 | 
					public class reportformsServiceImpl implements reportformsService {
 | 
				
			||||||
 | 
					    @Resource
 | 
				
			||||||
 | 
					    private OrgConsumeMapper mapper;
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<OrgConsume> getOrgConsumeList(OrgConsume orgConsume) {
 | 
				
			||||||
 | 
					            // 查询食堂、超市的所有数据信息
 | 
				
			||||||
 | 
					            List<Map<String, Object>> consumeRecords = mapper.selectConsumeRecords(orgConsume);
 | 
				
			||||||
 | 
					            //查询预订的订单信息
 | 
				
			||||||
 | 
					            List<Map<String, Object>> reserveRecords = mapper.selectReserveRecords(orgConsume);
 | 
				
			||||||
 | 
					            //查询区域关联的字段信息
 | 
				
			||||||
 | 
					            List<Map<String, String>> areaOrgMaps = mapper.selectAreaOrgMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // area -> org 映射
 | 
				
			||||||
 | 
					            Map<String, String> areaToOrg = new HashMap<>();
 | 
				
			||||||
 | 
					            for (Map<String, String> map : areaOrgMaps) {
 | 
				
			||||||
 | 
					                areaToOrg.put(map.get("area_name"), map.get("org_name"));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 初始化结果
 | 
				
			||||||
 | 
					            Map<String, OrgConsume> resultMap = new HashMap<>();
 | 
				
			||||||
 | 
					            for (Map<String, Object> r : reserveRecords) {
 | 
				
			||||||
 | 
					                String orgName = (String) r.get("orgName");
 | 
				
			||||||
 | 
					                BigDecimal reserveAmount = (r.get("reserveAmount") != null) ?
 | 
				
			||||||
 | 
					                        new BigDecimal(r.get("reserveAmount").toString()) : BigDecimal.ZERO;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                OrgConsume oc = new OrgConsume();
 | 
				
			||||||
 | 
					                oc.setOrgName(orgName);
 | 
				
			||||||
 | 
					                oc.setReserveAmount(reserveAmount);
 | 
				
			||||||
 | 
					                resultMap.put(orgName, oc);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            // 合并消费记录
 | 
				
			||||||
 | 
					            for (Map<String, Object> c : consumeRecords) {
 | 
				
			||||||
 | 
					                String areaName = (String) c.get("areaName");
 | 
				
			||||||
 | 
					                String conSource = (String) c.get("conSource");
 | 
				
			||||||
 | 
					                BigDecimal amount = (c.get("amount") != null) ?
 | 
				
			||||||
 | 
					                        new BigDecimal(c.get("amount").toString()).abs() : BigDecimal.ZERO;
 | 
				
			||||||
 | 
					                String orgName = areaToOrg.get(areaName);
 | 
				
			||||||
 | 
					                if (orgName == null) {
 | 
				
			||||||
 | 
					                    continue; // 没有映射关系,跳过
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                OrgConsume oc = resultMap.getOrDefault(orgName, new OrgConsume());
 | 
				
			||||||
 | 
					                oc.setOrgName(orgName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if ("canteen".equals(conSource)) {
 | 
				
			||||||
 | 
					                    oc.setCanteenAmount(oc.getCanteenAmount().add(amount));
 | 
				
			||||||
 | 
					                } else if ("super".equals(conSource)) {
 | 
				
			||||||
 | 
					                    oc.setSuperAmount(oc.getSuperAmount().add(amount));
 | 
				
			||||||
 | 
					                }else if("station".equals(conSource)){
 | 
				
			||||||
 | 
					                    //
 | 
				
			||||||
 | 
					                    //驿站支付sql查询无法达到目标,从子表重新查询
 | 
				
			||||||
 | 
					                   // oc.setH5Amount(oc.getH5Amount().add(amount));
 | 
				
			||||||
 | 
					                    OrgConsume neworgConsume = new OrgConsume();
 | 
				
			||||||
 | 
					                    neworgConsume.setStartPayTime(orgConsume.getStartPayTime());
 | 
				
			||||||
 | 
					                    neworgConsume.setEndPayTime(orgConsume.getEndPayTime());
 | 
				
			||||||
 | 
					                    neworgConsume.setOrgName(orgName.replace("食堂", ""));
 | 
				
			||||||
 | 
					                    List<OrgConsume> orgConsumes = getlistByOtherlist(neworgConsume);
 | 
				
			||||||
 | 
					                    BigDecimal othersum = orgConsumes.stream().map(OrgConsume::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
 | 
				
			||||||
 | 
					                    oc.setH5Amount(othersum);
 | 
				
			||||||
 | 
					                }else if("deduction".equals(conSource)){
 | 
				
			||||||
 | 
					                    oc.setDeductionAmount(oc.getDeductionAmount().add(amount));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                resultMap.put(orgName, oc);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            //处理驿站退款情况逻辑
 | 
				
			||||||
 | 
					           //  int yzsum = mapper.yzSumMoney(orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return new ArrayList<>(resultMap.values());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<OrgConsume> getlistByArealist(OrgConsume orgConsume) {
 | 
				
			||||||
 | 
					        List<OrgConsume> orgConsumes = mapper.getlistByArealist(orgConsume)
 | 
				
			||||||
 | 
					                .stream()
 | 
				
			||||||
 | 
					                .peek(c -> {
 | 
				
			||||||
 | 
					                    if (c.getCustName() != null && !c.getCustName().isEmpty()) {
 | 
				
			||||||
 | 
					                        try {
 | 
				
			||||||
 | 
					                            c.setCustName(SM4EncryptUtils.sm4Decrypt(c.getCustName()));
 | 
				
			||||||
 | 
					                        } catch (Exception e) {
 | 
				
			||||||
 | 
					                            e.printStackTrace();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                .collect(Collectors.toList());
 | 
				
			||||||
 | 
					        return orgConsumes;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<OrgConsume> getlistBySuperlist(OrgConsume orgConsume) {
 | 
				
			||||||
 | 
					        List<OrgConsume> orgConsumes = mapper.getlistBySuperlist(orgConsume)
 | 
				
			||||||
 | 
					                .stream()
 | 
				
			||||||
 | 
					                .peek(c -> {
 | 
				
			||||||
 | 
					                    if (c.getCustName() != null && !c.getCustName().isEmpty()) {
 | 
				
			||||||
 | 
					                        try {
 | 
				
			||||||
 | 
					                            c.setCustName(SM4EncryptUtils.sm4Decrypt(c.getCustName()));
 | 
				
			||||||
 | 
					                        } catch (Exception e) {
 | 
				
			||||||
 | 
					                            e.printStackTrace();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                .collect(Collectors.toList());
 | 
				
			||||||
 | 
					        return orgConsumes;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<OrgConsume> getDeductionlist(OrgConsume orgConsume) {
 | 
				
			||||||
 | 
					        List<OrgConsume> orgConsumes = mapper.getDeductionlist(orgConsume)
 | 
				
			||||||
 | 
					                .stream()
 | 
				
			||||||
 | 
					                .peek(c -> {
 | 
				
			||||||
 | 
					                    if (c.getCustName() != null && !c.getCustName().isEmpty()) {
 | 
				
			||||||
 | 
					                        try {
 | 
				
			||||||
 | 
					                            c.setCustName(SM4EncryptUtils.sm4Decrypt(c.getCustName()));
 | 
				
			||||||
 | 
					                        } catch (Exception e) {
 | 
				
			||||||
 | 
					                            e.printStackTrace();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                .collect(Collectors.toList());
 | 
				
			||||||
 | 
					        return orgConsumes;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<OrgConsume> getlistByH5list(OrgConsume orgConsume) {
 | 
				
			||||||
 | 
					        List<OrgConsume> orgConsumes = mapper.getlistByH5list(orgConsume)
 | 
				
			||||||
 | 
					                .stream()
 | 
				
			||||||
 | 
					                .peek(c -> {
 | 
				
			||||||
 | 
					                    if (c.getCustName() != null && !c.getCustName().isEmpty()) {
 | 
				
			||||||
 | 
					                        try {
 | 
				
			||||||
 | 
					                            c.setCustName(SM4EncryptUtils.sm4Decrypt(c.getCustName()));
 | 
				
			||||||
 | 
					                        } catch (Exception e) {
 | 
				
			||||||
 | 
					                           e.printStackTrace();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                .collect(Collectors.toList());
 | 
				
			||||||
 | 
					        return orgConsumes;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<OrgConsume> getlistByOtherlist(OrgConsume orgConsume) {
 | 
				
			||||||
 | 
					        List<OrgConsume> orgConsumes = mapper.getlistByOtherlist(orgConsume)
 | 
				
			||||||
 | 
					                .stream()
 | 
				
			||||||
 | 
					                .peek(c -> {
 | 
				
			||||||
 | 
					                    if (c.getCustName() != null && !c.getCustName().isEmpty()) {
 | 
				
			||||||
 | 
					                        try {
 | 
				
			||||||
 | 
					                            c.setCustName(SM4EncryptUtils.sm4Decrypt(c.getCustName()));
 | 
				
			||||||
 | 
					                        } catch (Exception e) {
 | 
				
			||||||
 | 
					                            e.printStackTrace();
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                .collect(Collectors.toList());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 如果列表为空,直接返回
 | 
				
			||||||
 | 
					        if (orgConsumes == null || orgConsumes.isEmpty()) {
 | 
				
			||||||
 | 
					            return orgConsumes;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					// 去重退款记录(flowType=130,payTime相同保留第一次)
 | 
				
			||||||
 | 
					        Set<String> seenPayTimes = new HashSet<>();
 | 
				
			||||||
 | 
					        orgConsumes.removeIf(c -> c.getFlowType() == 130 && !seenPayTimes.add(c.getPayTime()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return orgConsumes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<CanteenRecord> getPeoplelist(CanteenRecord orgConsume) {
 | 
				
			||||||
 | 
					        if(orgConsume.getCustName() != null){
 | 
				
			||||||
 | 
					            // 解密
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                orgConsume.setCustName(SM4EncryptUtils.sm4Encrypt(orgConsume.getCustName()));
 | 
				
			||||||
 | 
					            }catch (Exception e){
 | 
				
			||||||
 | 
					                e.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        List<CanteenRecord> list = mapper.getPeoplelist(orgConsume);
 | 
				
			||||||
 | 
					        for (CanteenRecord c : list) {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                if (c.getCustName() != null && !c.getCustName().isEmpty()) {
 | 
				
			||||||
 | 
					                    c.setCustName(SM4EncryptUtils.sm4Decrypt(c.getCustName()));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if (c.getPhone() != null) {
 | 
				
			||||||
 | 
					                    String phone = SM4EncryptUtils.sm4Decrypt(c.getPhone());
 | 
				
			||||||
 | 
					                    if (phone.length() == 11) {
 | 
				
			||||||
 | 
					                        phone = phone.substring(0, 3) + "****" + phone.substring(7);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    c.setPhone(phone);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (Exception e) {
 | 
				
			||||||
 | 
					                e.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return list;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<CanteenOrg> getOrgTree() {
 | 
				
			||||||
 | 
					        List<CanteenOrg> all = mapper.selectAllOrgs();
 | 
				
			||||||
 | 
					        return buildTree(all, -1L); // 假设顶级 super_id = 0
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private List<CanteenOrg> buildTree(List<CanteenOrg> list, Long parentId) {
 | 
				
			||||||
 | 
					        List<CanteenOrg> tree = new ArrayList<>();
 | 
				
			||||||
 | 
					        for (CanteenOrg org : list) {
 | 
				
			||||||
 | 
					            if (org.getSuperId().equals(parentId)) {
 | 
				
			||||||
 | 
					                org.setChildren(buildTree(list, org.getOrgId()));
 | 
				
			||||||
 | 
					                tree.add(org);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return tree;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					package com.bonus.canteen.core.reportforms.service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.beans.CanteenOrg;
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.beans.CanteenRecord;
 | 
				
			||||||
 | 
					import com.bonus.canteen.core.reportforms.beans.OrgConsume;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface reportformsService {
 | 
				
			||||||
 | 
					    List<OrgConsume> getOrgConsumeList(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    List<OrgConsume> getlistByArealist(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    List<OrgConsume> getlistBySuperlist(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    List<OrgConsume> getlistByH5list(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    List<OrgConsume> getlistByOtherlist(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    List<CanteenRecord> getPeoplelist(CanteenRecord orgConsume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    List<CanteenOrg> getOrgTree();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    List<OrgConsume> getDeductionlist(OrgConsume orgConsume);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue