From 2ba192b439ff6420ef134f8a758e5e3bb1d1d52d Mon Sep 17 00:00:00 2001 From: Xia Kaixiang Date: Thu, 13 Jun 2019 18:26:09 +0800 Subject: [PATCH] =?utf8?q?=E5=95=86=E6=88=B7=E8=90=A5=E4=B8=9A=E6=83=85?= =?utf8?q?=E5=86=B5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../dlpay/framework/dao/VoucherDao.java | 6 + .../dlpay/framework/domain/TVoucher.java | 4 +- .../dlpay/system/bean/ShopBusinessInfo.java | 60 ++++++ .../system/bean/ShopBusinessShowBean.java | 67 +++++++ .../dlpay/system/bean/TreeSelectNode.java | 9 + .../controller/SettleReportController.java | 43 ++++- .../system/service/SettleReportService.java | 7 + .../service/impl/SettleReportServiceImpl.java | 137 +++++++++++++- .../templates/system/report/shopbusiness.html | 179 ++++++++++++++++++ .../templates/system/report/subjectday.html | 2 +- 10 files changed, 500 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/supwisdom/dlpay/system/bean/ShopBusinessInfo.java create mode 100644 src/main/java/com/supwisdom/dlpay/system/bean/ShopBusinessShowBean.java create mode 100644 src/main/resources/templates/system/report/shopbusiness.html diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherDao.java index d8b831ee..02f5bada 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherDao.java +++ b/src/main/java/com/supwisdom/dlpay/framework/dao/VoucherDao.java @@ -3,6 +3,7 @@ package com.supwisdom.dlpay.framework.dao; import com.supwisdom.dlpay.framework.data.ExistBean; import com.supwisdom.dlpay.framework.data.MerchBean; import com.supwisdom.dlpay.framework.domain.TVoucher; +import com.supwisdom.dlpay.system.bean.ShopBusinessInfo; import com.supwisdom.dlpay.system.bean.SubjectDetailShowBean; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -11,10 +12,12 @@ import org.springframework.data.jpa.repository.Lock; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; import javax.persistence.LockModeType; import java.util.List; +@Repository public interface VoucherDao extends JpaRepository { @Query(value = "select count(t.voucherid) as existed from TB_VOUCHER t where t.POSTFLAG=0 ", nativeQuery = true) @@ -45,4 +48,7 @@ public interface VoucherDao extends JpaRepository { "from TVoucher a,TVoucherEntry b where a.voucherid=b.voucherid and a.postflag=1 and a.voucherdate>=:startdate and a.voucherdate<=:enddate and b.subjno=:subjno order by a.voucherdate,a.voucherno ", countQuery = "select count(a.voucherdate) from TVoucher a,TVoucherEntry b where a.voucherid=b.voucherid and a.postflag=1 and a.voucherdate>=:startdate and a.voucherdate<=:enddate and b.subjno=:subjno ") Page getSubjectDetailInfos(@Param("startdate") Integer startdate, @Param("enddate") Integer enddate, @Param("subjno") String subjno, Pageable pageable); + + @Query("select new com.supwisdom.dlpay.system.bean.ShopBusinessInfo(b.accno,b.summary,sum(a.transcnt),sum(b.dramt),sum(b.cramt)) from TVoucher a,TVoucherEntry b where a.voucherid=b.voucherid and a.postflag=1 and a.sourcetype<>'jiekuan' and b.subjno='2004' and a.voucherdate>=:startdate and a.voucherdate<=:enddate group by b.accno,b.summary ") + List getShopBusinessInfos(@Param("startdate") Integer startdate, @Param("enddate") Integer enddate); } diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucher.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucher.java index cd137433..b85e4e07 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucher.java +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TVoucher.java @@ -41,8 +41,8 @@ public class TVoucher { @Column(name="ATTACHMENTS", precision = 1) private Integer attachments; - @Column(name="SOURCETYPE", length = 20) - private String sourcetype; + @Column(name="SOURCETYPE", nullable = false, length = 20) + private String sourcetype; //auto-自动生成;hand-手工凭证;jiekuan-解款凭证(商户营业额不会统计解款凭证) @Column(name="SIGNFLAG", precision = 1) private Integer signflag; diff --git a/src/main/java/com/supwisdom/dlpay/system/bean/ShopBusinessInfo.java b/src/main/java/com/supwisdom/dlpay/system/bean/ShopBusinessInfo.java new file mode 100644 index 00000000..f7c2434c --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/system/bean/ShopBusinessInfo.java @@ -0,0 +1,60 @@ +package com.supwisdom.dlpay.system.bean; + +public class ShopBusinessInfo { + private String shopaccno; + private String summary; + private Long transcnt; + private Double dramt; + private Double cramt; + + public ShopBusinessInfo() { + } + + public ShopBusinessInfo(String shopaccno, String summary, Long transcnt, Double dramt, Double cramt) { + this.shopaccno = shopaccno; + this.summary = summary; + this.transcnt = transcnt; + this.dramt = dramt; + this.cramt = cramt; + } + + public String getShopaccno() { + return shopaccno; + } + + public void setShopaccno(String shopaccno) { + this.shopaccno = shopaccno; + } + + public String getSummary() { + return summary; + } + + public void setSummary(String summary) { + this.summary = summary; + } + + public Long getTranscnt() { + return transcnt; + } + + public void setTranscnt(Long transcnt) { + this.transcnt = transcnt; + } + + public Double getDramt() { + return dramt; + } + + public void setDramt(Double dramt) { + this.dramt = dramt; + } + + public Double getCramt() { + return cramt; + } + + public void setCramt(Double cramt) { + this.cramt = cramt; + } +} diff --git a/src/main/java/com/supwisdom/dlpay/system/bean/ShopBusinessShowBean.java b/src/main/java/com/supwisdom/dlpay/system/bean/ShopBusinessShowBean.java new file mode 100644 index 00000000..0d793e19 --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/system/bean/ShopBusinessShowBean.java @@ -0,0 +1,67 @@ +package com.supwisdom.dlpay.system.bean; + +public class ShopBusinessShowBean { + private String shopid; + private String shopname; + private String fshopid; + private String shopaccno; + private String summary; + private Long transcnt; + private Double transamt; + + public String getShopid() { + return shopid; + } + + public void setShopid(String shopid) { + this.shopid = shopid; + } + + public String getShopname() { + return shopname; + } + + public void setShopname(String shopname) { + this.shopname = shopname; + } + + public String getFshopid() { + return fshopid; + } + + public void setFshopid(String fshopid) { + this.fshopid = fshopid; + } + + public String getShopaccno() { + return shopaccno; + } + + public void setShopaccno(String shopaccno) { + this.shopaccno = shopaccno; + } + + public String getSummary() { + return summary; + } + + public void setSummary(String summary) { + this.summary = summary; + } + + public Long getTranscnt() { + return transcnt; + } + + public void setTranscnt(Long transcnt) { + this.transcnt = transcnt; + } + + public Double getTransamt() { + return transamt; + } + + public void setTransamt(Double transamt) { + this.transamt = transamt; + } +} diff --git a/src/main/java/com/supwisdom/dlpay/system/bean/TreeSelectNode.java b/src/main/java/com/supwisdom/dlpay/system/bean/TreeSelectNode.java index 47ceff29..87b6fd2e 100644 --- a/src/main/java/com/supwisdom/dlpay/system/bean/TreeSelectNode.java +++ b/src/main/java/com/supwisdom/dlpay/system/bean/TreeSelectNode.java @@ -9,6 +9,7 @@ public class TreeSelectNode { private boolean checked; private List children; + private String pId; //扩展 父级ID private String accno; //扩展:商户账号 public String getId() { @@ -51,6 +52,14 @@ public class TreeSelectNode { this.children = children; } + public String getpId() { + return pId; + } + + public void setpId(String pId) { + this.pId = pId; + } + public String getAccno() { return accno; } diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/SettleReportController.java b/src/main/java/com/supwisdom/dlpay/system/controller/SettleReportController.java index 71c00d9d..c7cb46bd 100644 --- a/src/main/java/com/supwisdom/dlpay/system/controller/SettleReportController.java +++ b/src/main/java/com/supwisdom/dlpay/system/controller/SettleReportController.java @@ -1,12 +1,11 @@ package com.supwisdom.dlpay.system.controller; import com.supwisdom.dlpay.api.bean.BaseResp; -import com.supwisdom.dlpay.api.bean.JsonResult; -import com.supwisdom.dlpay.framework.domain.TSubject; import com.supwisdom.dlpay.framework.util.DateUtil; import com.supwisdom.dlpay.framework.util.PageResult; import com.supwisdom.dlpay.framework.util.StringUtil; import com.supwisdom.dlpay.framework.util.WebConstant; +import com.supwisdom.dlpay.system.bean.ShopBusinessShowBean; import com.supwisdom.dlpay.system.bean.SubjectDayShowBean; import com.supwisdom.dlpay.system.bean.SubjectDetailShowBean; import com.supwisdom.dlpay.system.bean.TreeSelectNode; @@ -19,6 +18,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +import java.util.Date; import java.util.List; @Controller @@ -117,4 +117,43 @@ public class SettleReportController { return settleReportService.getSystemShowSubjectTree(); } + /** + * ==================================================== + * 商户营业情况表 + * ==================================================== + */ + @GetMapping("/report/shopbusiness") + public String shopBusinessReport(ModelMap map) { + String settledate = settleReportService.getSystemSettledate(); + map.addAttribute("maxdate", DateUtil.parseToDateFormat(DateUtil.getNewDay(settledate, -1))); + return "system/report/shopbusiness"; + } + + @GetMapping("/report/shopbusinesslist") + @PreAuthorize("hasPermission('/report/shopbusiness','')") + @ResponseBody + public PageResult getShopbusinessData(@RequestParam(value = "startdate", required = false) String startdate, + @RequestParam(value = "enddate", required = false) String enddate, + @RequestParam(value = "shopid", required = false) String shopid, + @RequestParam(value = "nodealshow", required = false, defaultValue = "false") Boolean noDealShow){ + try { + BaseResp resp = new BaseResp(); + if (!checkReportDate(startdate, enddate, resp)) { + return new PageResult<>(99, resp.getRetmsg()); + } + return settleReportService.getShopBusinessShowInfos(DateUtil.unParseToDateFormat(startdate), DateUtil.unParseToDateFormat(enddate), shopid, noDealShow); + } catch (Exception e) { + e.printStackTrace(); + return new PageResult<>(99, "系统查询异常"); + } + } + + @GetMapping("/report/selectshoptree") + @PreAuthorize("hasPermission('/report/shopbusiness','')") + @ResponseBody + public List searchShopTree() { + return settleReportService.getSystemNormalShopTree(); + } + + } diff --git a/src/main/java/com/supwisdom/dlpay/system/service/SettleReportService.java b/src/main/java/com/supwisdom/dlpay/system/service/SettleReportService.java index 7abff584..6b60bca9 100644 --- a/src/main/java/com/supwisdom/dlpay/system/service/SettleReportService.java +++ b/src/main/java/com/supwisdom/dlpay/system/service/SettleReportService.java @@ -1,6 +1,7 @@ package com.supwisdom.dlpay.system.service; import com.supwisdom.dlpay.framework.util.PageResult; +import com.supwisdom.dlpay.system.bean.ShopBusinessShowBean; import com.supwisdom.dlpay.system.bean.SubjectDayShowBean; import com.supwisdom.dlpay.system.bean.SubjectDetailShowBean; import com.supwisdom.dlpay.system.bean.TreeSelectNode; @@ -21,4 +22,10 @@ public interface SettleReportService { @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) List getSystemShowSubjectTree(); + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) + List getSystemNormalShopTree(); + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) + PageResult getShopBusinessShowInfos(String startdate, String enddate, String shopid, boolean nodealshow); } diff --git a/src/main/java/com/supwisdom/dlpay/system/service/impl/SettleReportServiceImpl.java b/src/main/java/com/supwisdom/dlpay/system/service/impl/SettleReportServiceImpl.java index 8bce060e..dc1128f6 100644 --- a/src/main/java/com/supwisdom/dlpay/system/service/impl/SettleReportServiceImpl.java +++ b/src/main/java/com/supwisdom/dlpay/system/service/impl/SettleReportServiceImpl.java @@ -1,18 +1,14 @@ package com.supwisdom.dlpay.system.service.impl; -import com.supwisdom.dlpay.framework.dao.SettleCtlDao; -import com.supwisdom.dlpay.framework.dao.SubjectDao; -import com.supwisdom.dlpay.framework.dao.SubjectdayDao; -import com.supwisdom.dlpay.framework.dao.VoucherDao; +import com.supwisdom.dlpay.framework.dao.*; import com.supwisdom.dlpay.framework.domain.TSettlectl; +import com.supwisdom.dlpay.framework.domain.TShop; import com.supwisdom.dlpay.framework.domain.TSubject; import com.supwisdom.dlpay.framework.util.DateUtil; +import com.supwisdom.dlpay.framework.util.MoneyUtil; import com.supwisdom.dlpay.framework.util.PageResult; import com.supwisdom.dlpay.framework.util.StringUtil; -import com.supwisdom.dlpay.system.bean.SubjectDayInfo; -import com.supwisdom.dlpay.system.bean.SubjectDayShowBean; -import com.supwisdom.dlpay.system.bean.SubjectDetailShowBean; -import com.supwisdom.dlpay.system.bean.TreeSelectNode; +import com.supwisdom.dlpay.system.bean.*; import com.supwisdom.dlpay.system.service.SettleReportService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; @@ -33,6 +29,8 @@ public class SettleReportServiceImpl implements SettleReportService { private VoucherDao voucherDao; @Autowired private SubjectDao subjectDao; + @Autowired + private ShopDao shopDao; @Override public String getSystemSettledate() { @@ -81,7 +79,7 @@ public class SettleReportServiceImpl implements SettleReportService { @Override public PageResult getSubjectDetailInfos(String startdate, String enddate, String subjno, int pageNo, int pageSize) { Pageable pageable = PageRequest.of(pageNo - 1, pageSize); - Page page = voucherDao.getSubjectDetailInfos(Integer.valueOf(startdate),Integer.valueOf(enddate),subjno,pageable); + Page page = voucherDao.getSubjectDetailInfos(Integer.valueOf(startdate), Integer.valueOf(enddate), subjno, pageable); return new PageResult<>(page); } @@ -130,4 +128,125 @@ public class SettleReportServiceImpl implements SettleReportService { } return result; } + + @Override + public List getSystemNormalShopTree() { + List shopList = shopDao.getNormalShops(); + return getShopSelectTree(shopList, 0); + } + + private List getShopSelectTree(List shopList, int fshopid) { + List result = new ArrayList<>(0); + if (!StringUtil.isEmpty(shopList)) { + for (TShop shop : shopList) { + if (fshopid == shop.getFshopid()) { + TreeSelectNode node = new TreeSelectNode(); + node.setId(shop.getShopid().toString()); + node.setName(shop.getShopname()); + node.setOpen(shop.getShoptype() == 0); + node.setChecked(false); + node.setAccno(shop.getShopaccno() == null ? "" : shop.getShopaccno()); + node.setpId(String.valueOf(fshopid)); + List children = getShopSelectTree(shopList, shop.getShopid()); + node.setChildren(StringUtil.isEmpty(children) ? null : children); + result.add(node); + } + } + } + return result; + } + + private List getShopBusinessSelectShops(List shopList, String shopid) { + if (StringUtil.isEmpty(shopid)) return shopList; + + int select_shopid = Integer.parseInt(shopid); //单选 + List result = new ArrayList<>(0); + for (TShop shop : shopList) { + if (select_shopid == shop.getShopid()) { + result.add(shop); + break; + } + } + if (StringUtil.isEmpty(result)) return result; //shopid 不存在 + result.addAll(getChildrenShopByShopid(shopList, select_shopid)); //子商户 + return result; + } + + private List getChildrenShopByShopid(List shopList, int fshopid) { + List result = new ArrayList<>(0); + for (TShop shop : shopList) { + if (fshopid == shop.getFshopid()) { + result.add(shop); + result.addAll(getChildrenShopByShopid(shopList, shop.getShopid())); + } + } + return result; + } + + @Override + public PageResult getShopBusinessShowInfos(String startdate, String enddate, String shopid, boolean nodealshow) { + List businessInfos = voucherDao.getShopBusinessInfos(Integer.valueOf(startdate), Integer.valueOf(enddate)); + if (StringUtil.isEmpty(businessInfos) && !nodealshow) { + return new PageResult<>(99, "无数据"); //无交易记录 + } + List shopAllList = shopDao.getNormalShops(); + List result = new ArrayList<>(0); + List shopList = getShopBusinessSelectShops(shopAllList, shopid); + for (TShop shop : shopList) { + ShopBusinessShowBean bean = new ShopBusinessShowBean(); + bean.setShopid(shop.getShopid().toString()); + bean.setShopname(shop.getShopname()); + bean.setFshopid(shop.getFshopid() == null ? "0" : shop.getFshopid().toString()); + bean.setShopaccno(shop.getShopaccno() == null ? "" : shop.getShopaccno()); + bean.setSummary(""); + if (StringUtil.isEmpty(shop.getShopaccno())) { + //商户组,计算该组下所有的交易额 + long transcnt = 0; + double transamt = 0; + List childrenShops = getChildrenShopByShopid(shopAllList,shop.getShopid().intValue()); //子商户列表 + for (TShop child : childrenShops) { + if(!StringUtil.isEmpty(child.getShopaccno())){ + for(ShopBusinessInfo info:businessInfos){ + if(child.getShopaccno().equals(info.getShopaccno())){ + transcnt += info.getTranscnt(); + transamt += (info.getCramt() - info.getDramt()); + } + } + } + } + bean.setTranscnt(transcnt); + bean.setTransamt(MoneyUtil.formatYuan(transamt)); + } else { + //末级商户 + long transcnt = 0; + double transamt = 0; + for (ShopBusinessInfo info : businessInfos) { + if (shop.getShopaccno().equals(info.getShopaccno())) { + transcnt += info.getTranscnt(); + transamt += (info.getCramt() - info.getDramt()); + + ShopBusinessShowBean temp = new ShopBusinessShowBean(); + temp.setShopid(info.getShopaccno()); + temp.setShopname(""); + temp.setFshopid(shop.getShopid().toString()); + temp.setShopaccno(info.getShopaccno()); + temp.setSummary(info.getSummary()); + temp.setTranscnt(info.getTranscnt()); + temp.setTransamt(info.getCramt() - info.getDramt()); + result.add(temp); + } + } + + bean.setTranscnt(transcnt); + bean.setTransamt(MoneyUtil.formatYuan(transamt)); + } + + if (bean.getTranscnt() == 0 && MoneyUtil.moneyEqual(bean.getTransamt(), 0)) { + if (nodealshow) result.add(bean); //显示未交易商户 + } else { + result.add(bean); + } + } + return new PageResult<>(result); + } } diff --git a/src/main/resources/templates/system/report/shopbusiness.html b/src/main/resources/templates/system/report/shopbusiness.html new file mode 100644 index 00000000..47ac3190 --- /dev/null +++ b/src/main/resources/templates/system/report/shopbusiness.html @@ -0,0 +1,179 @@ +
+
+

商户营业情况表

+ + 结算中心 + 商户营业情况表 + +
+
+
+ + +
+
+ +
+ +
+
-
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/src/main/resources/templates/system/report/subjectday.html b/src/main/resources/templates/system/report/subjectday.html index 43acfa0f..f376baf6 100644 --- a/src/main/resources/templates/system/report/subjectday.html +++ b/src/main/resources/templates/system/report/subjectday.html @@ -96,7 +96,7 @@ if (d.subjlevel == 1) { return '' + d.subjname + ''; } else { - return '    ' + d.subjname + ''; + return '     ' + d.subjname + ''; } } -- 2.17.1