From 48019a0446fc92d38f8331b6e4cf12365d05a14f Mon Sep 17 00:00:00 2001 From: 王彬 Date: Tue, 6 Apr 2021 23:04:30 +0800 Subject: [PATCH] test code --- build.gradle | 2 +- src/test/java/com/taover/repository/test/TestAutoconfigure.java | 376 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- src/test/resources/application.properties | 20 ++++++++++---------- 3 files changed, 384 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 9ed035c..531f91c 100644 --- a/build.gradle +++ b/build.gradle @@ -58,7 +58,7 @@ uploadArchives { authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD) } pom.project { - version '2.1.52' + version '2.2.1' artifactId ARTIFACT_Id groupId GROUP_ID packaging TYPE diff --git a/src/test/java/com/taover/repository/test/TestAutoconfigure.java b/src/test/java/com/taover/repository/test/TestAutoconfigure.java index 4ff3866..f39d24f 100644 --- a/src/test/java/com/taover/repository/test/TestAutoconfigure.java +++ b/src/test/java/com/taover/repository/test/TestAutoconfigure.java @@ -24,13 +24,383 @@ public class TestAutoconfigure { jdbcTemplateWrapperTenant = context.getBean(JdbcTemplateWrapperTenant.class); // testBroadCast(); -// testSelectSubQuery(); + //testSelectSubQuery(); //select子查询包含分片表 - testSelectShardingSubQuery(); + //testSelectShardingSubQuery(); //where中包含子查询 - testWhereSubquery(); + //testWhereSubquery(); + + //testWarePaymentSelectSql(); + //testExportPaymentDetailData(); + //testTenantWithRootUser(); + //testDayOrderInfoExcelData(); + //testDayOrderInfoAPI(); + //testWeekOrderInfoExcelData(); + //testOrderPrintExcelData(); + //testRefundCoreSqlForOrderList(); + //testSelectSqlForDeliveryExcel(); + //testDeliveryExpressNumber(); + //testDeliveryGoodsExcel(); + //testExcelSelectForSale(); + //testChannelPrintSelect(); + testWarePaymentExport(); } + private static void testWarePaymentExport() { + String sql = "SELECT wc.manager_nickname,cp.id as paymentId, wo.order_sn,wo.`upload_sn`,wo.consignee,wo.mobile," + + " wgbs.sku_unit_num as skuUnitNum, wgbs.unit, " + + " ifnull((SELECT wc.`refund_to_channel` FROM `wxorder_compensate` AS wc WHERE wc.`order_id` = cp.`order_id` LIMIT 1),0) AS refundToChannel, " + + " ifnull((SELECT wc.`refund_instructions` FROM `wxorder_compensate` AS wc WHERE wc.`order_id` = cp.`order_id` LIMIT 1),'') AS refundRemark, " + + " (SELECT wpb.`pay_result` from wxorder_ware_payment_batch wpb WHERE wpb.`batch_no`= cp.`pay_batch_no` ORDER BY wpb.`pay_result` asc LIMIT 1) as pay_result," + + "CONCAT(wo.province_name,wo.city_name,wo.district_name,wo.address) fullAddress,wo.`progress_delivery`,wo.`real_delivery_time`," + + "wo.`express_number`,wc.`name`,wc.wx_group_nickname,wog.`goods_name`,wog.`sku_name`,wog.`sku_code`," + + "wog.`goods_base_sku_price`,wog.`goods_number`, wog.`goods_base_sku_price`*wog.`goods_number` as goodsMoney," + + "wog.ware_shipping_price as shipping_price,wo.`customer_remark`,wo.`channel_remark`,wo.`control_status`,wog.`ware_refund_money` as refund_money, wog.ware_money_loss as moneyLoss, " + + "wog.`ware_money_paid` as money_paid,wo.`pay_time`,wo.`create_time`, wo.`latest_distribute_time`, " + + "cp.`deal_progress`, cp.`check_date`,cp.deal_check_date " + + " FROM `wxorder_ware_payment` cp " + + " INNER JOIN `wxorder_order` AS wo ON wo.`id`=cp.order_id " + + " INNER JOIN `wxorder_order_goods` wog ON wog.`order_id`=wo.id " + + " INNER JOIN `wxorder_goods_base_sku` wgbs ON wgbs.`id`=wog.goods_sku_id " + + " INNER JOIN `wxorder_ware` wc ON wc.`id`=wo.`ware_id` " + + "WHERE cp.id in (30617) " + + " and cp.tenant_id=16" + + " and wo.tenant_id=16" + + " and wog.tenant_id=16"; + System.out.println(jdbcTemplateWrapperTenant.queryForList(sql, 16L)); + } + + private static void testChannelPrintSelect() { + String sql = "select wxorder_order.id woId,if(locate('(规格:', wxorder_order_goods.channel_goods_name)>0,left(substring_index( wxorder_order_goods.channel_goods_name, '(规格:', -1), char_length(substring_index( wxorder_order_goods.channel_goods_name, '(规格:', -1)) -1),substring_index( wxorder_order_goods.channel_goods_name, '(规格:', -1)),(SELECT GROUP_CONCAT(wn.`name`) FROM wxorder_tag wt INNER JOIN `wxorder_name_tag` wn ON wn.`id`=wt.`tag_name_id` WHERE wn.`table_name`='wxorder_channel' AND wt.`tenant_id`=wxorder_order.tenant_id AND wt.`table_id`=wxorder_order.`channel_id`) as channelTag " + + " from wxorder_order inner join wxorder_order_goods on wxorder_order.id=wxorder_order_goods.order_id limit 10 "; + System.out.println(jdbcTemplateWrapperTenant.queryForList(sql, 16L)); + } + + private static void testExcelSelectForSale() { + String sql = " SELECT wxorder_order.tenant_id ," + + " IFNULL((select GROUP_CONCAT(wxorder_order_express.express_number) from wxorder_order_express AS wxorder_order_express where wxorder_order_express.order_id=wxorder_order.id and wxorder_order_express.tenant_id=16),'') AS express_number, " + + " wxorder_order.`refund_instructions`, wxorder_order.`refund_money`,wxorder_order.ware_refund_money, wxorder_order.`refund_type`, wxorder_order.`customer_network_name`, " + + "(SELECT sum(wc.`refund_money`) from `wxorder_compensate` as wc WHERE wc.order_id = wxorder_order.id)as compesateChannelRefundMoney, " + + "(SELECT sum(wc.`ware_refund_money`) from `wxorder_compensate` as wc WHERE wc.order_id = wxorder_order.id)as compesateWareRefundMoney, " + + " wxorder_order_wxtext.sender_payload, wxorder_excel_data.payload, " + + " wxorder_order.order_sn, wxorder_order.upload_sn, wxorder_order.control_status, wxorder_order.progress_delivery, wxorder_order.consignee, " + + " wxorder_order.mobile,wxorder_order.create_time, wxorder_order.province_name, wxorder_order.city_name, wxorder_order.district_name, wxorder_order.address, " + + " wxorder_order.money_paid, wxorder_order.shipping_price, " + + " wxorder_order.sender_name, wxorder_order.sender_mobile, " + + " wxorder_order.real_delivery_time, wxorder_order.pay_time, wxorder_order.expect_delivery_time, " + + " IF(wxorder_order_goods.goods_name=wxorder_order_goods.sku_name,group_concat(concat(wxorder_order_goods.goods_name,'*',wxorder_order_goods.goods_number) SEPARATOR '; '),group_concat(concat(wxorder_order_goods.goods_name,'(',wxorder_order_goods.sku_name,')','*',wxorder_order_goods.goods_number) SEPARATOR '; ')) groupGoodsDetail, sum(wxorder_order_goods.goods_number) sumGoodsNumber, " + + " wxorder_order.express_name, " + + " group_concat(wxorder_order_goods.goods_code separator '; ') goodsCode,group_concat(wxorder_order_goods.sku_code separator '; ') skuCode, " + + + " group_concat(wxorder_goods_base_sku.sku_unit_num separator '; ') skuUnitNum," + + " group_concat(wxorder_goods_base_sku.unit separator '; ') unit," + + + " wxorder_order.channel_remark, wxorder_order.customer_remark,wxorder_order.buyer_remark, wxorder_order.action_from, " + + " CONCAT(wxorder_order.province_name,wxorder_order.city_name, wxorder_order.district_name,wxorder_order.address) detailAddress, " + + " wxorder_channel.name 'channelName', wxorder_channel.contact_user,wxorder_channel.manager_nickname as managerNickname, wxorder_channel.wx_group_nickname 'wxGroupNickname' , " + + " wxorder_order.operate_refund_time refundTime,wxorder_order_goods.channel_goods_name , " + + " wxorder_channel.id 'channelId', wxorder_ware.name 'wareName' ,group_concat(wxorder_order_goods.channel_goods_price separator '; ') as channelGoodsPrice "; + sql += " FROM wxorder_order wxorder_order " + + " INNER JOIN wxorder_order_goods_origin wxorder_order_goods ON wxorder_order_goods.order_id=wxorder_order.id and wxorder_order.tenant_id=16 and wxorder_order_goods.tenant_id=16" + + " INNER JOIN wxorder_channel wxorder_channel ON wxorder_channel.id=wxorder_order.channel_id " + + " INNER JOIN wxorder_ware wxorder_ware ON wxorder_ware.id=wxorder_order.ware_id " + + " INNER JOIN wxorder_goods_base_sku as wxorder_goods_base_sku ON wxorder_goods_base_sku.id=wxorder_order_goods.goods_sku_id " + //修改处4:导出销售单 + + " LEFT JOIN wxorder_order_wxtext wxorder_order_wxtext ON wxorder_order_wxtext.id=wxorder_order.wxtext_order_id" + + " LEFT JOIN wxorder_excel_data ON wxorder_excel_data.id=wxorder_order.excel_data_id "; + sql += " WHERE wxorder_order.id in (208925) "; + System.out.println(jdbcTemplateWrapperTenant.queryForList(sql, 16L)); + } + + private static void testDeliveryGoodsExcel() { + String sql = "SELECT wxorder_order.order_sn,wxorder_order.upload_sn,wxorder_order.control_status," + + "wxorder_order.progress_delivery,wxorder_order.consignee,wxorder_order.mobile," + + "wxorder_order.province_name,wxorder_order.city_name,wxorder_order.district_name,wxorder_order.address," + + "wxorder_order.sender_name,wxorder_order.sender_mobile,wxorder_channel.sender_man," + + "wxorder_channel.sender_phone,wxorder_ware.sender_man,wxorder_ware.sender_phone," + + "wxorder_order.real_delivery_time,wxorder_order.expect_delivery_time,wxorder_order.create_time," + + "wxorder_order.pay_time,wxorder_order.channel_remark,wxorder_order.customer_remark,wxorder_order.buyer_remark," + + "wxorder_order.express_name, wxorder_order.latest_distribute_time, " + + "(select group_concat(wxorder_order_express.express_number) from wxorder_order_express where wxorder_order_express.order_goods_id = wxorder_order_goods.id and wxorder_order_express.tenant_id=16)as express_number,wxorder_order.action_from," + + "wxorder_order_goods.goods_name,wxorder_order_goods.sku_name,wxorder_order_goods.goods_number," + + "wxorder_order_goods.goods_code goodsCode,wxorder_order_goods.sku_code skuCode," + + "wxorder_order_goods.`goods_base_sku_price` AS goodsBasePrice," + + "`wxorder_order_goods`.`goods_base_sku_price`*`wxorder_order_goods`.`goods_number` AS basicPrice," + + "`wxorder_order_goods`.`refund_money`,`wxorder_order_goods`.`shipping_price`," + + "CONCAT(wxorder_order.province_name,wxorder_order.city_name,wxorder_order.district_name," + + "wxorder_order.address) detailAddress,wxorder_ware.NAME 'wareName',wxorder_channel.NAME 'channelName'," + + "wxorder_channel.manager_nickname 'managerNickname',wxorder_channel.wx_group_nickname 'wxGroupNickname'," + + "wxorder_order.operate_refund_time refundTime,wxorder_channel.id 'channelId',wxorder_order_goods.channel_goods_price as channelGoodsPrice,wxorder_order.customer_network_name as customerNetworkName, " + + "(SELECT group_concat(distinct(delivery_sn)) from wxorder_order_distribute_log odl where wxorder_order.id=odl.order_id and wxorder_order_goods.id=odl.order_goods_id and odl.tenant_id=16) delivery_sn_list "; + sql += " FROM wxorder_order wxorder_order " + + " INNER JOIN wxorder_channel wxorder_channel ON wxorder_order.channel_id = wxorder_channel.id and wxorder_order.tenant_id=16" + + " INNER JOIN wxorder_ware wxorder_ware ON wxorder_order.ware_id= wxorder_ware.id " + + " INNER JOIN wxorder_order_goods wxorder_order_goods ON wxorder_order.id = wxorder_order_goods.order_id and wxorder_order_goods.tenant_id=16" + + " INNER JOIN wxorder_goods_base_sku wxorder_goods_base_sku ON wxorder_goods_base_sku.id = wxorder_order_goods.goods_sku_id "; + sql += " WHERE wxorder_order.id in (208925) "; + System.out.println(jdbcTemplateWrapperTenant.queryForList(sql, 16L)); + } + + private static void testDeliveryExpressNumber() { + String sql = " SELECT " + + " wxorder_goods_base_sku.sku_unit_num as skuUnitNum , " + + " wxorder_goods_base_sku.unit, " + + " wxorder_order.order_sn, " + + " wxorder_order.customer_network_name, " + + " wxorder_order.upload_sn, " + + " wxorder_order.control_status, " + + " wxorder_order.progress_delivery, " + + " wxorder_order.consignee, " + + " wxorder_order.mobile, " + + " wxorder_order.province_name, " + + " wxorder_order.city_name," + + " wxorder_order.district_name, " + + " wxorder_order.address, " + + " wxorder_order.sender_name, " + + " wxorder_order.sender_mobile, " + + " wxorder_channel.sender_man," + + " wxorder_channel.sender_phone, " + + " wxorder_ware.sender_man, " + + " wxorder_ware.sender_phone, " + + " wxorder_order.real_delivery_time, " + + " wxorder_order.expect_delivery_time, " + + " wxorder_order.create_time, " + + " wxorder_order.pay_time, " + + " wxorder_order.channel_remark, " + + " wxorder_order.customer_remark, " + + " wxorder_order.buyer_remark, " + + " wxorder_order.express_name, " + + " wxorder_order.action_from, " + + " wxorder_order.latest_distribute_time, " + //+ " IF(wxorder_order_goods.goods_name= wxorder_order_goods.sku_name,(concat(wxorder_order_goods.goods_name, '*', wxorder_order_goods.goods_number)),(concat(wxorder_order_goods.goods_name, '(', wxorder_order_goods.sku_name, ')', '*', wxorder_order_goods.goods_number))) groupGoodsDetail, " + + " IF(wxorder_order_goods.goods_name= wxorder_order_goods.sku_name,wxorder_order_goods.goods_name,(concat(wxorder_order_goods.goods_name, '(', wxorder_order_goods.sku_name, ')'))) groupGoodsDetail, " + + " wxorder_order_goods.goods_code goodsCode, " + + " wxorder_order_goods.sku_code skuCode, " + + " wxorder_order_goods.goods_number orderGoodsNumber, " + + " wxorder_order_goods.channel_goods_name," + + " CONCAT(wxorder_order.province_name, wxorder_order.city_name, wxorder_order.district_name, wxorder_order.address) detailAddress, " + + " wxorder_ware.name 'wareName', " + + " wxorder_channel.name 'channelName', " + + " wxorder_channel.manager_nickname 'managerNickname', " + + " wxorder_channel.wx_group_nickname 'wxGroupNickname', " + + " wxorder_order.operate_refund_time refundTime, " + + " wxorder_channel.id 'channelId' ," + + " wxorder_order_goods.id order_goods_id, " + + " (SELECT group_concat(distinct(delivery_sn)) from wxorder_order_distribute_log odl where wxorder_order.id=odl.order_id and wxorder_order_goods.id=odl.order_goods_id and odl.tenant_id=16) delivery_sn_list "; + sql += " FROM wxorder_order wxorder_order " + + " INNER JOIN wxorder_channel wxorder_channel ON wxorder_order.channel_id = wxorder_channel.id and wxorder_order.tenant_id=16" + + " INNER JOIN wxorder_ware wxorder_ware ON wxorder_order.ware_id= wxorder_ware.id " + + " INNER JOIN wxorder_order_goods wxorder_order_goods ON wxorder_order.id = wxorder_order_goods.order_id and wxorder_order_goods.tenant_id=16" + + " INNER JOIN wxorder_goods_base_sku wxorder_goods_base_sku ON wxorder_goods_base_sku.id = wxorder_order_goods.goods_sku_id "; + sql += " WHERE wxorder_order.id in (208925) "; + System.out.println(jdbcTemplateWrapperTenant.queryForList(sql, 16L)); + } + + private static void testSelectSqlForDeliveryExcel() { + String sql = " SELECT IFNULL((select GROUP_CONCAT(wxorder_order_express.express_number) from wxorder_order_express AS wxorder_order_express where wxorder_order_express.order_id=wxorder_order.id and wxorder_order_express.tenant_id=16), '') AS express_number," + + " wxorder_order.order_sn, wxorder_order.upload_sn, wxorder_order.customer_network_name, " + + " wxorder_order.control_status, wxorder_order.progress_delivery, " + + " wxorder_order.consignee, wxorder_order.mobile, wxorder_order.province_name, wxorder_order.city_name, wxorder_order.district_name, wxorder_order.address, " + + " wxorder_order.sender_name, wxorder_order.sender_mobile, wxorder_channel.sender_man, wxorder_channel.sender_phone, wxorder_ware.sender_man, wxorder_ware.sender_phone, " + + " wxorder_order.real_delivery_time, wxorder_order.expect_delivery_time, wxorder_order.create_time, wxorder_order.pay_time, " + + " wxorder_order.channel_remark, wxorder_order.customer_remark,wxorder_order.buyer_remark, " + + " wxorder_order.express_name, wxorder_order.action_from, wxorder_order.latest_distribute_time,wxorder_order_goods.channel_goods_name , " + + " IF(wxorder_order_goods.goods_name=wxorder_order_goods.sku_name,group_concat(concat(wxorder_order_goods.goods_name,'*',wxorder_order_goods.goods_number) SEPARATOR '; '),group_concat(concat(wxorder_order_goods.goods_name,'(',wxorder_order_goods.sku_name,')','*',wxorder_order_goods.goods_number) SEPARATOR '; ')) groupGoodsDetail,GROUP_CONCAT(wxorder_order_goods.goods_code SEPARATOR '; ') goodsCode, " + + + " GROUP_CONCAT(wxorder_goods_base_sku.sku_unit_num SEPARATOR '; ') skuUnitNum, " + + " GROUP_CONCAT(wxorder_goods_base_sku.unit SEPARATOR '; ') unit, " + + + " GROUP_CONCAT(wxorder_order_goods.sku_code SEPARATOR '; ') skuCode, " + + " (SELECT group_concat(distinct(delivery_sn)) from wxorder_order_distribute_log odl where wxorder_order.id=odl.order_id and odl.tenant_id=16) delivery_sn_list, " + + " sum(wxorder_order_goods.goods_number) sumGoodsNumber, " + + " CONCAT(wxorder_order.province_name,wxorder_order.city_name, wxorder_order.district_name,wxorder_order.address) detailAddress, " + + " wxorder_ware.name 'wareName', wxorder_channel.name 'channelName' ,wxorder_channel.manager_nickname 'managerNickname',wxorder_channel.wx_group_nickname 'wxGroupNickname' ," + + " wxorder_order.operate_refund_time refundTime, " + + " wxorder_channel.id 'channelId' "; + sql += " FROM wxorder_order wxorder_order " + + " INNER JOIN wxorder_channel wxorder_channel ON wxorder_order.channel_id=wxorder_channel.id and wxorder_order.tenant_id=16" + + " INNER JOIN wxorder_ware wxorder_ware ON wxorder_order.ware_id=wxorder_ware.id and wxorder_ware.tenant_id=16" + + " INNER JOIN wxorder_order_goods wxorder_order_goods ON wxorder_order.id=wxorder_order_goods.order_id and wxorder_order_goods.tenant_id=16" + + " INNER JOIN wxorder_goods_base_sku wxorder_goods_base_sku ON wxorder_goods_base_sku.id=wxorder_order_goods.goods_sku_id "; + sql += " WHERE wxorder_order.id in (208925) and wxorder_order.tenant_id=16"; + System.out.println(jdbcTemplateWrapperTenant.queryForList(sql, 16L)); + } + + private static void testRefundCoreSqlForOrderList() { + String selectSql = " SELECT wxorder_order.refund_way refundWay,wxorder_order.refund_delivery_sn refundDeliverySn, " + + "(SELECT sum(wxorder_compensate.`ware_refund_money`) from `wxorder_compensate` where wxorder_compensate.`order_id` = wxorder_order.id) as wareRefundMoney," + + "(SELECT sum(wxorder_compensate.`refund_money`) from `wxorder_compensate` where wxorder_compensate.`order_id` = wxorder_order.id) as refundMoney, " + + " wxorder_order.operate_refund_time applyCompensateTime,wxorder_order.refund_instructions refundInstructions, wxorder_order.channel_id channelId, wxorder_channel.name channelName, wxorder_channel.platform_code platformCode, " + + " wxorder_order.pre_control_status as refundPreStatus, wxorder_order.ware_id wareId, wxorder_ware.name wareName, " + + " wxorder_order.id, wxorder_order.order_sn orderSn, wxorder_order.upload_sn uploadSn, wxorder_order.money_paid moneyPaid, " + + " wxorder_order.consignee, wxorder_order.mobile, wxorder_order.province_name provinceName, wxorder_order.city_name cityName, wxorder_order.district_name districtName, wxorder_order.address, " + + " wxorder_order.channel_remark channelRemark, wxorder_order.customer_remark customerRemark, wxorder_order.platform_customer_remark platformCustomerRemark, " + + " wxorder_order.sender_name senderName, wxorder_order.sender_mobile senderMobile, " + + " date_format(wxorder_order.create_time, '%Y-%m-%d %H:%i:%s') createTime, date_format(wxorder_order.real_delivery_time, '%Y-%m-%d %H:%i:%s') realDeliveryTime, " + + " wxorder_order.progress_distribute progressDistribute, wxorder_order.progress_delivery progressDelivery, wxorder_order.control_status controlStatus, " + + " wxorder_order.express_name expressName, wxorder_order.express_number expressNumber,wxorder_order.shipping_price shippingPrice," + + " wxorder_order.customer_network_name ," + + "(select count(*) from wxorder_compensate WHERE wxorder_compensate.order_id = wxorder_order.id) as compensateCountAll," + + "(select count(*) from wxorder_compensate WHERE wxorder_compensate.order_id = wxorder_order.id and wxorder_compensate.progress_status =2) as compensateCountDealed ," + + "(select count(*) from wxorder_channel_refund_payment where wxorder_channel_refund_payment.order_id = wxorder_order.id) as channelRefundPaymentStatus," + + "(select count(*) from wxorder_ware_refund_payment where wxorder_ware_refund_payment.order_id = wxorder_order.id) as wareRefundPaymentStatus "; + String whereSql = " WHERE wxorder_order.id=208925 "; + String fromSql = " FROM wxorder_order wxorder_order " + + " INNER JOIN wxorder_channel wxorder_channel ON wxorder_order.channel_id=wxorder_channel.id and wxorder_channel.tenant_id=16 and wxorder_order.tenant_id=16" + + " INNER JOIN wxorder_ware wxorder_ware ON wxorder_order.ware_id=wxorder_ware.id and wxorder_ware.tenant_id=16" + + " INNER JOIN wxorder_order_goods wxorder_order_goods ON wxorder_order.id=wxorder_order_goods.order_id and wxorder_order_goods.tenant_id=16"; + String otherSql = " GROUP BY wxorder_order.id "; + System.out.println(jdbcTemplateWrapperTenant.queryForList(selectSql+fromSql+whereSql+otherSql, 16L)); + } + + private static void testOrderPrintExcelData() { + String subQueryOrderSn = "select group_concat(wo.order_sn) " + + " from wxorder_order wo inner join wxorder_order_print_list_map woplm on wo.id=woplm.order_id " + + " where woplm.order_print_list_id=order_print_list.id and wo.tenant_id=16"; + String selectSql = " select ("+subQueryOrderSn+") orderSnList, " + + " order_print_list.consignee, order_print_list.mobile mobile, " + + " order_print_list.province_name provinceName, order_print_list.city_name cityName, order_print_list.district_name districtName," + + " order_print_list.address, order_print_list.channel_remark channelRemark, " + + " group_concat(wxorder_order_print_list_goods.goods_name, '(', wxorder_order_print_list_goods.sku_name, '*', wxorder_order_print_list_goods.goods_number, ')') groupConcatGoods, " + + " sum(wxorder_order_print_list_goods.goods_number) sumGoodsNumber, " + + " order_print_list.print_num printNum, order_print_list.print_task_id printTaskId, order_print_list.print_count printCount, " + + " order_print_list.status, order_print_list.waybill_code waybillCode, " + + " order_print_list.express_name expressName, order_print_list.create_time createTime, order_print_list.update_time updateTime, order_print_list.print_latest_time printLatestTime, " + + " order_print_list.template_url templateUrl, order_print_list.print_area_url printAreaUrl, " + + " ware.name wareName, channel.name channelName, channel.wx_group_nickname wxGroupNickname, channel.manager_nickname managerNickname "; + String fromSql = " from wxorder_order_print_list order_print_list" + + " inner join wxorder_ware ware on order_print_list.ware_id=ware.id " + + " inner join wxorder_channel channel on order_print_list.channel_id=channel.id" + + " left join wxorder_order_print_list_goods on wxorder_order_print_list_goods.order_print_list_id = order_print_list.id"; + String whereSql = " WHERE order_print_list.id in(467) "; + String otherSql = " GROUP BY order_print_list.id "; + + System.out.println(jdbcTemplateWrapperTenant.queryForList(selectSql+fromSql+whereSql+otherSql, 16L)); + } + + private static void testWeekOrderInfoExcelData() { + String sql = " SELECT wo.customer_network_name as customerNetworkName,wo.order_sn AS orderSn,wo.consignee AS consignee,wo.mobile AS mobile, wog.`goods_name` AS goodsName, wog.`sku_name` AS skuName, wog.`goods_number` AS saleNumber, " + + " concat(wo.province_name,wo.city_name,wo.district_name,wo.address) AS receiveAddress," + + " ww.name as wareName, ww.manager_nickname as wareManager, " + + " ifnull((select GROUP_CONCAT(wxorder_order_express.express_number separator ';') from wxorder_order_express AS wxorder_order_express where wxorder_order_express.order_id=wo.id and wxorder_order_express.tenant_id=16),0) AS expressNumber, " + + " wc.name as channelName, " + + " wog.goods_base_sku_price as costSinglePrice, " + + " wc.manager_nickname as channelManager, " + + " (wog.money_paid-wog.refund_money ) AS shouldReceiveMoney, " + + " (wog.refund_money ) AS channelRefund, " + + " (wog.ware_refund_money ) AS wareRefund, " + + " ( wog.goods_base_sku_price*wog.goods_number+wog.ware_shipping_price ) AS cost, " + + " wog.channel_goods_price as channelGoodsPrice, " + + " wog.money_paid as moneyPaid, " + + " wo.create_time as orderTime " + + " FROM `wxorder_order` wo " + + " INNER JOIN `wxorder_order_goods_origin` wog ON wo.id = wog.`order_id` and wo.tenant_id=16 and wog.tenant_id=16" + + " INNER JOIN wxorder_channel as wc on wc.id = wo.channel_id " + + " INNER JOIN wxorder_ware as ww on ww.id=wo.ware_id " + + " INNER JOIN wxorder_channel_goods as wcg on wcg.id = wog.channel_goods_id " + + " where wo.id=208925 ORDER BY saleNumber DESC "; + System.out.println(jdbcTemplateWrapperTenant.queryForList(sql, 16L)); + } + + private static void testDayOrderInfoAPI() { + String sql = "SELECT wo.customer_network_name as customerNetworkName,wo.order_sn AS orderSn, wog.`goods_name` AS goodsName, wog.`sku_name` AS skuName, wog.`goods_number` AS saleNumber," + // woe.order_goods_id woe.order_goods_origin_id + + " ifnull((SELECT sum(woe.`goods_number`) from `wxorder_order_express` as woe WHERE woe.order_goods_id = wog.id and woe.tenant_id=16),0) as deliveryGoodsNumber, " + + " ww.name as wareName, ww.manager_nickname as wareManager, " + + " wc.name as channelName, " + + " wog.goods_base_sku_price as costSinglePrice, " + + " wc.manager_nickname as channelManager," + + " (wog.money_paid-wog.refund_money) AS shouldReceiveMoney, " + + " wog.refund_money AS channelRefund, " + + " wog.ware_refund_money AS wareRefund, " + + " (wog.goods_base_sku_price*wog.goods_number+wog.ware_shipping_price) AS cost, " + + " wog.channel_goods_price as channelGoodsPrice, " + + " wog.money_paid as moneyPaid, " + + " wo.create_time as orderTime " + + " FROM `wxorder_order` wo " + + " INNER JOIN `wxorder_order_goods_origin` wog ON wo.id = wog.`order_id` and wo.tenant_id=16 and wog.tenant_id=16" + + " INNER JOIN wxorder_channel as wc on wc.id = wo.channel_id " + + " INNER JOIN wxorder_ware as ww on ww.id=wo.ware_id " + + " INNER JOIN wxorder_channel_goods as wcg on wcg.id = wog.channel_goods_id " + + " where wo.id=208925 "; + System.out.println(jdbcTemplateWrapperTenant.queryForList(sql, 16L)); + } + + private static void testDayOrderInfoExcelData() { + String sql = "SELECT wo.customer_network_name as customerNetworkName,wo.order_sn AS orderSn, wog.`goods_name` AS goodsName, wog.`sku_name` AS skuName, wog.`goods_number` AS saleNumber," + + " (SELECT sum(woe.`goods_number`) from `wxorder_order_express` as woe WHERE woe.order_goods_id = wog.id and woe.tenant_id=16)as deliveryGoodsNumber, " + + " ww.name as wareName, ww.manager_nickname as wareManager, " + + " wc.name as channelName, " + + " wog.goods_base_sku_price as costSinglePrice, " + + " wc.manager_nickname as channelManager," + + " (wog.money_paid-wog.refund_money) AS shouldReceiveMoney, " + + " wog.refund_money AS channelRefund, " + + " wog.ware_refund_money AS wareRefund, " + + " (wog.goods_base_sku_price*wog.goods_number+wog.ware_shipping_price) AS cost, " + + " wog.channel_goods_price as channelGoodsPrice, " + + " wog.money_paid as moneyPaid, " + + " wo.create_time as orderTime " + + " FROM `wxorder_order` wo " + + " INNER JOIN `wxorder_order_goods` wog ON wo.id = wog.`order_id` and wo.tenant_id=16 and wog.tenant_id=16 " + + " INNER JOIN wxorder_ware as ww on ww.id = wo.ware_id " + + " INNER JOIN wxorder_channel as wc on wc.id = wo.channel_id " + + " INNER JOIN wxorder_channel_goods as wcg on wcg.id = wog.channel_goods_id " + + " where wo.id=208925 "; + System.out.println(jdbcTemplateWrapperTenant.queryForList(sql, 16L)); + } + + private static void testTenantWithRootUser() { + String sql = "select tenant.id, tenant.name 'tenantName', users.id 'userId', users.mobile 'userMobile', users.type 'userType', date(tenant.create_time) 'createTime', " + + " (select group_concat(agent_nickname) from wxorder_agent_ssy agent_ssy where agent_ssy.tenant_id=tenant.id) 'agentSsyAgentNickname'" + + ", wv.name as versionName " + + " from wxorder_tenant tenant " + + " inner join wxorder_version wv on tenant.version_id=wv.id " + + " inner join wxorder_user users on tenant.id=users.tenant_id " + + " where 1=1 "; + System.out.println(jdbcTemplateWrapperTenant.queryForList(sql, 16L)); + } + + private static void testExportPaymentDetailData() { + String sql = "SELECT wc.manager_nickname,cp.id as paymentId, wo.order_sn,wo.`upload_sn`,wo.consignee,wo.mobile," + + " ifnull((SELECT wc.`refund_to_channel` FROM `wxorder_compensate` AS wc WHERE wc.`order_id` = cp.`order_id` LIMIT 1),0) AS refundToChannel, " + + " ifnull((SELECT wc.`refund_instructions` FROM `wxorder_compensate` AS wc WHERE wc.`order_id` = cp.`order_id` LIMIT 1),'') AS refundRemark, " + + " (SELECT wpb.`pay_result` from wxorder_ware_payment_batch wpb WHERE wpb.`batch_no`= cp.`pay_batch_no` ORDER BY wpb.`pay_result` asc LIMIT 1) as pay_result," + + "CONCAT(wo.province_name,wo.city_name,wo.district_name,wo.address) fullAddress,wo.`progress_delivery`,wo.`real_delivery_time`," + + "wo.`express_number`,wc.`name`,wc.wx_group_nickname,wog.`goods_name`,wog.`sku_name`,wog.`sku_code`," + + "wog.`goods_base_sku_price`,wog.`goods_number`, wog.`goods_base_sku_price`*wog.`goods_number` as goodsMoney," + + "wog.ware_shipping_price as shipping_price,wo.`customer_remark`,wo.`channel_remark`,wo.`control_status`,wog.`ware_refund_money` as refund_money, wog.ware_money_loss as moneyLoss, " + + "wog.`ware_money_paid` as money_paid,wo.`pay_time`,wo.`create_time`, wo.`latest_distribute_time`, " + + "cp.`deal_progress`, cp.`check_date`,cp.deal_check_date " + + " FROM `wxorder_ware_payment` cp " + + " INNER JOIN `wxorder_order` AS wo ON wo.`id`=cp.order_id " + + " INNER JOIN `wxorder_order_goods` wog ON wog.`order_id`=wo.id " + + " INNER JOIN `wxorder_ware` wc ON wc.`id`=wo.`ware_id` " + + "WHERE cp.id in (30617) " + + " and cp.tenant_id=16" + + " and wo.tenant_id=16" + + " and wog.tenant_id=16"; + System.out.println(jdbcTemplateWrapperTenant.queryForList(sql, 16L)); + } + + private static void testWarePaymentSelectSql() { + String sql = " select wxorder_ware_payment.id as id,wxorder_ware_payment.order_id as orderId,wxorder_ware_payment.deal_progress as dealProgress, " + + "wxorder_ware_payment.check_date as checkDate,wxorder_ware_payment.deal_check_date as dealCheckDate, " + + "wxorder_ware_payment.status_sysnotice_check as statusSysnoticeCheck,wxorder_ware_payment.tenant_id as tenantId, " + + "wxorder_ware_payment.pay_batch_no as payBatchNo,wxorder_order.consignee,wxorder_order.mobile,wxorder_order.province_name as provinceName," + + "wxorder_order.city_name as cityName,wxorder_order.district_name as districtName,wxorder_order.address,wxorder_order.create_time as createTime, " + + "wxorder_ware_payment.update_time as updateTime,wxorder_order.order_sn as orderSn,wxorder_order.ware_money_paid as moneyPaid, " + + "wxorder_order.ware_refund_money as refundMoney,wxorder_order.ware_shipping_price as shippingPrice, wxorder_order.ware_money_loss as moneyLoss, " + + "wxorder_order.real_delivery_time as realDeliveryTime,wxorder_order.latest_distribute_time as latestDistributeTime,wxorder_order.progress_delivery as progressDelivery, " + + "wxorder_order.pay_time as payTime,wxorder_order.control_status as controlStatus,wxorder_order.upload_sn as uploadSn, " + + "(select name from wxorder_ware where id = wxorder_order.ware_id ) as wareName, " + + "(SELECT settlement_type from wxorder_ware_payment_cycle WHERE `ware_id`= `wxorder_order`.`ware_id`) as settlementType, " + + "IF(`wxorder_ware_payment`.`deal_progress`!= 2, 0, (select FLOOR(sum(pay_result)/count(*)) from `wxorder_ware_payment_batch` WHERE wxorder_ware_payment_batch.batch_no= wxorder_ware_payment.`pay_batch_no`)) as payResult "; + sql += " FROM wxorder_ware_payment" + + " inner join wxorder_order on wxorder_ware_payment.order_id = wxorder_order.id and wxorder_ware_payment.tenant_id=16 and wxorder_order.tenant_id=16 " + + " limit 5; "; + System.out.println(jdbcTemplateWrapperTenant.queryForList(sql, 16L)); + } + private static void testSelectShardingSubQuery() { String sql = " select wc.name,(select count(*) from wxorder_order where) as 'sumOrderNum' from wxorder_channel wc limit 3; "; } diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index f501973..fcc419d 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -13,7 +13,7 @@ spring.gson.serialize-nulls=true spring.mvc.dispatch-options-request=true # shardingspere -spring.shardingsphere.datasource.names=ds1 +spring.shardingsphere.datasource.names=ds0 spring.shardingsphere.datasource.common.type=com.alibaba.druid.pool.DruidDataSource spring.shardingsphere.datasource.common.driver-class-name=com.mysql.cj.jdbc.Driver spring.shardingsphere.datasource.ds0.url=jdbc:mysql://rdsifmezqifmezqo.mysql.rds.aliyuncs.com:3306/bzyun_wxorder?characterEncoding=UTF-8 @@ -32,16 +32,16 @@ spring.shardingsphere.datasource.ds1.max-active=20 spring.shardingsphere.datasource.ds1.min-idle=5 spring.shardingsphere.datasource.ds1.max-wait=60000 -spring.shardingsphere.rules.sharding.tables.wxorder_order.actual-data-nodes=ds0.wxorder_order -spring.shardingsphere.rules.sharding.tables.wxorder_order.database-strategy.hint.database_hint.sharding-algorithm-name=database_hint -spring.shardingsphere.rules.sharding.tables.wxorder_order.table-strategy.hint.table_hint.sharding-algorithm-name=table_hint -spring.shardingsphere.rules.sharding.tables.wxorder_order.key-generate-strategy.column=id -spring.shardingsphere.rules.sharding.tables.wxorder_order.key-generate-strategy.key-generator-name=SNOWFLAKE-SELF +#spring.shardingsphere.rules.sharding.tables.wxorder_order.actual-data-nodes=ds0.wxorder_order +#spring.shardingsphere.rules.sharding.tables.wxorder_order.database-strategy.hint.database_hint.sharding-algorithm-name=database_hint +#spring.shardingsphere.rules.sharding.tables.wxorder_order.table-strategy.hint.table_hint.sharding-algorithm-name=table_hint +#spring.shardingsphere.rules.sharding.tables.wxorder_order.key-generate-strategy.column=id +#spring.shardingsphere.rules.sharding.tables.wxorder_order.key-generate-strategy.key-generator-name=SNOWFLAKE-SELF -spring.shardingsphere.rules.sharding.sharding-algorithms.database_hint.type=HINT -spring.shardingsphere.rules.sharding.sharding-algorithms.database_hint.algorithm-class-name=com.taover.repository.shardingsphere.ShardingDatabaseAlgorithmHint -spring.shardingsphere.rules.sharding.sharding-algorithms.table_hint.type=HINT -spring.shardingsphere.rules.sharding.sharding-algorithms.table_hint.algorithm-class-name=com.taover.repository.shardingsphere.ShardingTableAlgorithmHint +#spring.shardingsphere.rules.sharding.sharding-algorithms.database_hint.type=HINT +#spring.shardingsphere.rules.sharding.sharding-algorithms.database_hint.algorithm-class-name=com.taover.repository.shardingsphere.ShardingDatabaseAlgorithmHint +#spring.shardingsphere.rules.sharding.sharding-algorithms.table_hint.type=HINT +#spring.shardingsphere.rules.sharding.sharding-algorithms.table_hint.algorithm-class-name=com.taover.repository.shardingsphere.ShardingTableAlgorithmHint taover.sharding.workerId=1 taover.sharding.maxVibrationOffset=3 -- libgit2 0.21.2