From a1e163f9e222fe0a649d50fc3197956b4ed56b91 Mon Sep 17 00:00:00 2001 From: Xia Kaixiang Date: Tue, 12 Nov 2019 15:44:52 +0800 Subject: [PATCH] =?utf8?q?=E5=95=86=E6=88=B7=E5=BD=93=E5=A4=A9=E7=BB=9F?= =?utf8?q?=E8=AE=A1=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../controller/SettleReportController.java | 38 ++++ .../system/service/SettleReportService.java | 4 + .../service/impl/SettleReportServiceImpl.java | 61 +++++- payapi/src/main/resources/data.sql | 8 + .../system/report/shoptodaybusiness.html | 190 ++++++++++++++++++ 5 files changed, 295 insertions(+), 6 deletions(-) create mode 100644 payapi/src/main/resources/templates/system/report/shoptodaybusiness.html diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/controller/SettleReportController.java b/payapi/src/main/java/com/supwisdom/dlpay/system/controller/SettleReportController.java index c7cb46bd..749fae7a 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/system/controller/SettleReportController.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/controller/SettleReportController.java @@ -156,4 +156,42 @@ public class SettleReportController { } + /** + * ==================================================== + * 商户当天统计表 + * ==================================================== + */ + @GetMapping("/report/shoptodaybusiness") + public String shopTodayBusinessReport(ModelMap map) { + String settledate = settleReportService.getSystemSettledate(); + map.addAttribute("mindate", DateUtil.parseToDateFormat(settledate)); + return "system/report/shoptodaybusiness"; + } + + @GetMapping("/report/selectshoptodaytree") + @PreAuthorize("hasPermission('/report/shoptodaybusiness','')") + @ResponseBody + public List searchShopTodayTree() { + return settleReportService.getSystemNormalShopTree(); + } + + @GetMapping("/report/shoptodaybusinesslist") + @PreAuthorize("hasPermission('/report/shoptodaybusiness','')") + @ResponseBody + public PageResult getShopTodayBusinessData(@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.getShopTodayBusinessShowInfos(DateUtil.unParseToDateFormat(startdate), DateUtil.unParseToDateFormat(enddate), shopid, noDealShow); + } catch (Exception e) { + e.printStackTrace(); + return new PageResult<>(99, "系统查询异常"); + } + } + } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/service/SettleReportService.java b/payapi/src/main/java/com/supwisdom/dlpay/system/service/SettleReportService.java index 6b60bca9..2b704ebe 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/system/service/SettleReportService.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/service/SettleReportService.java @@ -28,4 +28,8 @@ public interface SettleReportService { @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) PageResult getShopBusinessShowInfos(String startdate, String enddate, String shopid, boolean nodealshow); + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) + PageResult getShopTodayBusinessShowInfos(String startdate, String enddate, String shopid, boolean nodealshow); + } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/SettleReportServiceImpl.java b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/SettleReportServiceImpl.java index 7aaac690..4d3a830b 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/SettleReportServiceImpl.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/SettleReportServiceImpl.java @@ -5,20 +5,26 @@ 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.framework.util.*; import com.supwisdom.dlpay.system.bean.*; import com.supwisdom.dlpay.system.service.SettleReportService; import com.supwisdom.dlpay.util.EnumCheck; +import org.hibernate.query.internal.NativeQueryImpl; +import org.hibernate.transform.Transformers; +import org.hibernate.type.DoubleType; +import org.hibernate.type.LongType; +import org.hibernate.type.StringType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; import java.util.ArrayList; +import java.util.Date; import java.util.List; @Service @@ -34,6 +40,9 @@ public class SettleReportServiceImpl implements SettleReportService { @Autowired private ShopDao shopDao; + @PersistenceContext + private EntityManager entityManager; + private EnumCheck shoptypeCheck = new EnumCheck<>(); @Override @@ -190,10 +199,14 @@ public class SettleReportServiceImpl implements SettleReportService { @Override public PageResult getShopBusinessShowInfos(String startdate, String enddate, String shopid, boolean nodealshow) { - List businessInfos = voucherDao.getShopBusinessInfos(Integer.valueOf(startdate), Integer.valueOf(enddate)); + List businessInfos = voucherDao.getShopBusinessInfos(Integer.valueOf(startdate), Integer.valueOf(enddate)); //根据凭证统计历史的数据 if (StringUtil.isEmpty(businessInfos) && !nodealshow) { return new PageResult<>(99, "无数据"); //无交易记录 } + return new PageResult<>(getShopBusinessShowBean(businessInfos, shopid, nodealshow)); + } + + private List getShopBusinessShowBean(List businessInfos, String shopid, boolean nodealshow) { List shopAllList = shopDao.getNormalShops(); List result = new ArrayList<>(0); List shopList = getShopBusinessSelectShops(shopAllList, shopid); @@ -252,6 +265,42 @@ public class SettleReportServiceImpl implements SettleReportService { result.add(bean); } } - return new PageResult<>(result); + return result; + } + + + @Override + public PageResult getShopTodayBusinessShowInfos(String startdate, String enddate, String shopid, boolean nodealshow){ + List businessInfos = getTodayShopbusiness(startdate, enddate); //根据流水统计当天的数据 + if (StringUtil.isEmpty(businessInfos) && !nodealshow) { + return new PageResult<>(99, "无数据"); //无交易记录 + } + return new PageResult<>(getShopBusinessShowBean(businessInfos, shopid, nodealshow)); + } + + private List getTodayShopbusiness(String startdate, String enddate) { + StringBuffer sql = new StringBuffer("select tt.shopaccno,tt.summary,count(distinct tt.refno) as transcnt,sum(tt.dramt) as dramt,sum(tt.cramt) as cramt \n" + + "from ( \n" + + " select t.draccno as shopaccno,t.summary,t.refno,t.amount as dramt,0.0 as cramt \n" + + " from tb_userdtl_debitcredit t left join tb_transactionmain a on t.refno=a.refno \n" + + " where a. status='success' and t.drsubjno=:subjno and a.accdate>=:startdate and a.accdate<=:enddate \n" + + " union all \n" + + " select t.craccno as shopaccno,t.summary,t.refno,0.0 as dramt,t.amount as cramt \n" + + " from tb_userdtl_debitcredit t left join tb_transactionmain a on t.refno=a.refno \n" + + " where a. status='success' and t.crsubjno=:subjno and a.accdate>=:startdate and a.accdate<=:enddate \n" + + ") tt group by tt.shopaccno,tt.summary "); + Query query = entityManager.createNativeQuery(sql.toString()); + query.setParameter("subjno", Subject.SUBJNO_MACHANT_INCOME); //商户收入科目 + query.setParameter("startdate", DateUtil.unParseToDateFormat(startdate)); + query.setParameter("enddate", DateUtil.unParseToDateFormat(enddate)); + query.unwrap(NativeQueryImpl.class) + .addScalar("shopaccno", StringType.INSTANCE) + .addScalar("summary", StringType.INSTANCE) + .addScalar("transcnt", LongType.INSTANCE) + .addScalar("dramt", DoubleType.INSTANCE) + .addScalar("cramt", DoubleType.INSTANCE) + .setResultTransformer(Transformers.aliasToBean(ShopBusinessInfo.class)); + List list = query.getResultList(); + return list; } } diff --git a/payapi/src/main/resources/data.sql b/payapi/src/main/resources/data.sql index 446650b4..cefb0072 100644 --- a/payapi/src/main/resources/data.sql +++ b/payapi/src/main/resources/data.sql @@ -75,6 +75,8 @@ INSERT INTO "tb_function" ("id", "createtime", "isleaf", "lastsaved", "menuicon" VALUES (36, NULL, 1, NULL, '', '/shop/shopcheck', '商户审批', 2, 7, '{tenantid}'); INSERT INTO "tb_function" ("id", "createtime", "isleaf", "lastsaved", "menuicon", "menuurl", "name", "ordernum", "parentid", tenantid) VALUES (37, NULL, 1, NULL, '', '/user/card', '市民卡查询', 1, 19, '{tenantid}'); +INSERT INTO "tb_function" ("id", "createtime", "isleaf", "lastsaved", "menuicon", "menuurl", "name", "ordernum", "parentid", tenantid) +VALUES (38, NULL, 1, NULL, '', '/report/shoptodaybusiness', '商户当天统计表', 4, 20, '{tenantid}'); INSERT INTO "tb_role_function" ("id", "functionid", "roleid", tenantid) @@ -141,6 +143,8 @@ INSERT INTO "tb_role_function" ("id", "functionid", "roleid", tenantid) VALUES ('ff8080816db87e27016db88be41a0014', 36, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); INSERT INTO "tb_role_function" ("id", "functionid", "roleid", tenantid) VALUES ('ff8080816db87e27016db88be41f0015', 37, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); +INSERT INTO "tb_role_function" ("id", "functionid", "roleid", tenantid) +VALUES ('4028ee9f6e5d95d8016e5d99e8d50012', 38, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); INSERT INTO "tb_resource" ("id", "code", "function_id", "name", "uri", tenantid) @@ -297,6 +301,8 @@ INSERT INTO "tb_resource" ("id", "code", "function_id", "name", "uri", tenantid) VALUES (89, '', 36, '审核', '/shop/docheckshop', '{tenantid}'); INSERT INTO "tb_resource" ("id", "code", "function_id", "name", "uri", tenantid) VALUES (90, '', 37, '查询', '/user/card', '{tenantid}'); +INSERT INTO "tb_resource" ("id", "code", "function_id", "name", "uri", tenantid) +VALUES (91, '', 38, '查询', '/report/shoptodaybusiness', '{tenantid}'); INSERT INTO "tb_permission" ("id", "resid", "role_func_id", "roleid", tenantid) @@ -453,6 +459,8 @@ INSERT INTO "tb_permission" ("id", "resid", "role_func_id", "roleid", "tenantid VALUES ('ff8080816db87e27016db94468da008a', 89, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); INSERT INTO "tb_permission" ("id", "resid", "role_func_id", "roleid", "tenantid") VALUES ('ff8080816db87e27016db9446fda008b', 90, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); +INSERT INTO "tb_permission" ("id", "resid", "role_func_id", "roleid", "tenantid") +VALUES ('4028ee9f6e5d95d8016e5d99e8dd0013', 91, NULL, 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '{tenantid}'); INSERT INTO "tb_subject" ("subjid","subjno", "balflag", "displayflag", "endflag", "fsubjno", "opendate", "subjlevel", "subjname", "subjtype", "tenantid") diff --git a/payapi/src/main/resources/templates/system/report/shoptodaybusiness.html b/payapi/src/main/resources/templates/system/report/shoptodaybusiness.html new file mode 100644 index 00000000..c01ddbf2 --- /dev/null +++ b/payapi/src/main/resources/templates/system/report/shoptodaybusiness.html @@ -0,0 +1,190 @@ +
+
+

商户当天统计表

+ + 报表中心 + 商户当天统计表 + +
+
+
+ + +
+
+ +
+ +
+
-
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+
+ + + + + \ No newline at end of file -- 2.17.1