From fbd28e1f5e117ef8f95eb72b4180cf5190f00833 Mon Sep 17 00:00:00 2001 From: xhxu Date: Sat, 25 Jul 2020 11:24:37 +0800 Subject: [PATCH] =?UTF-8?q?sql=20=E5=8A=A0=20mapper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iformall/domain/po/WxCUser.java | 2 + .../iformall/domain/po/WxCUserBasicInfo.java | 10 ++++ .../service/WxCUserBasicInfoService.java | 1 + .../impl/WxCUserBasicInfoServiceImpl.java | 11 ++++ .../main/resources/mapper/WxBillAllMapper.xml | 18 +----- .../mapper/WxCUserBasicInfoMapper.xml | 16 +++-- .../main/resources/mapper/WxCUserMapper.xml | 9 ++- .../resources/mapper/WxCardInfoMapper.xml | 8 +-- .../resources/mapper/WxCardSpendMapper.xml | 6 +- .../mapper/WxCouponActionLogMapper.xml | 2 +- .../resources/mapper/WxCouponOrderMapper.xml | 60 +++++++------------ .../mapper/WxCreditHistoryMapper.xml | 2 +- .../main/resources/mapper/WxOrderMapper.xml | 6 +- .../resources/mapper/WxOrderPressMapper.xml | 2 +- 14 files changed, 78 insertions(+), 75 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCUser.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCUser.java index d28ea195d..4447020e2 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCUser.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCUser.java @@ -26,6 +26,8 @@ public class WxCUser extends TenantEntity { protected Long id; + @io.swagger.annotations.ApiModelProperty(value="userId",name="userId") + private Long userId; @io.swagger.annotations.ApiModelProperty(value="微信openId",name="openId") private String openId; @io.swagger.annotations.ApiModelProperty(value="微信unionId",name="unionId") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java index ceed2dd95..b7aa7055b 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java @@ -28,6 +28,8 @@ public class WxCUserBasicInfo extends TenantEntity { @JsonIgnore protected Date scoreDate; + private String finalTenantId; + @Excel(name="姓名",width = 20,orderNum = "1") @NotNull @io.swagger.annotations.ApiModelProperty(value="用户姓名",name="name") @@ -120,6 +122,14 @@ public class WxCUserBasicInfo extends TenantEntity { @TableField(exist = false) private Date endTime; + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="操作人类型 枚举:EnumUserType",name="operatorType") + private Integer operatorType; + + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="操作人ID",name="operatorId") + private Long operatorId; + public String getAddressStr() { if (address == null) return null; diff --git a/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java b/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java index ff0fdeab5..66ac5a842 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java @@ -151,5 +151,6 @@ public interface WxCUserBasicInfoService { ResultData updateStatus(WxCUserBasicInfo wxCUserBasicInfo); + WxCUserBasicInfo getByObject(WxCUserBasicInfo wxCUserBasicInfo); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java index 7a2c5349c..9fc729a40 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java @@ -871,6 +871,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { } } + // update 昵称 { // check c_user 是否存在 @@ -1021,5 +1022,15 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { wxCUserBasicInfoMapper.updateById(wxCUserBasicInfo); return new ResultData(); } + + @Override + public WxCUserBasicInfo getByObject(WxCUserBasicInfo wxCUserBasicInfo) { + try { + return wxCUserBasicInfoMapper.selectOne(new QueryWrapper(wxCUserBasicInfo)); + } catch (Exception e) { + logger.error("NOT found: " + e.getMessage()); + } + return null; + } } diff --git a/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml b/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml index 74677ba3d..a794feb14 100644 --- a/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillAllMapper.xml @@ -995,14 +995,7 @@ ifnull(round( (select sum(ss.money) from ( - select ms.subsidy money,mm.id - from wx_merchant_subsidy ms - left join wx_coupon_order co on co.id = ms.coupon_order_id - left join wx_coupon c on c.id = co.coupon_id - left join wx_merchant mm on mm.id = ms.merchant_id - left join wx_card_spend cs on cs.order_id = ms.order_id - left join wx_c_user cu on cu.id = cs.owner_id - where ms.status = 0 + select subsidy money,merchant_id id from wx_merchant_subsidy where status = 0 union all select receive_pay money,merchant_id id from wx_bill_rent_deposit where status = 3 union all @@ -1039,14 +1032,7 @@ )/100,2),0)- ifnull(round( (select sum(ss.money) from ( - select ms.subsidy money,mm.id - from wx_merchant_subsidy ms - left join wx_coupon_order co on co.id = ms.coupon_order_id - left join wx_coupon c on c.id = co.coupon_id - left join wx_merchant mm on mm.id = ms.merchant_id - left join wx_card_spend cs on cs.order_id = ms.order_id - left join wx_c_user cu on cu.id = cs.owner_id - where ms.order_type in(3,0) and ms.status = 0 + select subsidy money,merchant_id id from wx_merchant_subsidy where order_type in(3,0) and status = 0 union all select receive_pay money,merchant_id id from wx_bill_rent_deposit where status = 3 union all diff --git a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml index 6021edd5d..f83f58412 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml @@ -15,6 +15,7 @@ + @@ -28,7 +29,7 @@ `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`, - `create_date`,`update_date`,`tenant_id`,`parent_tenant_id`,`name`,`nick_name`,`credit`,`active_time`,`act_record` + `create_date`,`update_date`,`tenant_id`,`parent_tenant_id`,`final_tenant_id`,`name`,`nick_name`,`credit`,`active_time`,`act_record` ,(select level from wx_level_config where poins >= points and tenant_id=wcubi.tenant_id order by points desc limit 1 ) level,status @@ -47,6 +48,9 @@ and `parent_tenant_id` = #{parentTenantId} + + and `final_tenant_id` = #{finalTenantId} + and `phone` like concat('%', #{phone},'%') @@ -231,7 +235,7 @@ select from wx_c_user_basic_info cub - inner join wx_c_user cu on cu.id = cub.id + inner join wx_c_user cu on cu.user_id = cub.id where cub.status = 0 and cu.phone is not null AND DATE_FORMAT(cub.birthdate,'%m-%d') >= #{begin} AND DATE_FORMAT(cub.birthdate,'%m-%d') <= #{end} @@ -554,7 +558,7 @@ - select id,credit from wx_c_user_basic_info cub where not exists (select * from wx_c_user c where c.id=cub.id) and cub.credit is null + select id,credit from wx_c_user_basic_info cub where not exists (select * from wx_c_user c where c.user_id=cub.id) and cub.credit is null \ No newline at end of file diff --git a/mallinkService/src/main/resources/mapper/WxCUserMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml index b00fab155..39bdf87dd 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml @@ -3,6 +3,7 @@ + @@ -49,7 +50,7 @@ - `id`,`tenant_id`,`parent_tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`, + `id`,`user_id`,`tenant_id`,`parent_tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`, `city`,`province`,`language`,`country_code`,`register_ip`,`verify_code_phone`, `qrcode_source`,`scene`,`scene_address`,`session_key`,`score`, `update_date`,`create_date`,`app_id`,`token`,`expire_time`,`latitude`, `longitude`, @@ -66,6 +67,10 @@ and `id` = #{id} + + and `user_id` = #{userId} + + and `tenant_id` = #{tenantId} @@ -311,7 +316,7 @@ diff --git a/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml b/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml index d2c7e28b4..77f29538f 100644 --- a/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml @@ -411,7 +411,7 @@ left join wx_coupon c on c.id = co.coupon_id left join wx_merchant m on m.id = cs.merchant_id left join wx_merchant_subsidy ms on ms.order_id = cs.order_id - left join wx_c_user ou on ou.id = co.owner_id + left join wx_c_user_basic_info ou on ou.id = co.owner_id order by cs.create_date DESC @@ -428,7 +428,7 @@ left join wx_coupon c on c.id = co.coupon_id left join wx_merchant m on m.id = cs.merchant_id left join wx_merchant_subsidy ms on ms.order_id = cs.order_id - left join wx_c_user ou on ou.id = co.owner_id + left join wx_c_user_basic_info ou on ou.id = co.owner_id group by cs.merchant_id @@ -445,7 +445,7 @@ left join wx_coupon c on c.id = co.coupon_id left join wx_merchant m on m.id = cs.merchant_id left join wx_merchant_subsidy ms on ms.order_id = cs.order_id - left join wx_c_user ou on ou.id = co.owner_id + left join wx_c_user_basic_info ou on ou.id = co.owner_id group by cs.owner_id diff --git a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml index 604c699f5..f26652927 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml @@ -313,7 +313,7 @@ LEFT JOIN wx_coupon_send cs ON cal.channel_id = cs.id LEFT JOIN wx_coupon_order co ON cal.coupon_order_id = co.id LEFT JOIN wx_coupon c ON cal.coupon_id = c.id - LEFT JOIN wx_c_user cu ON cu.id = co.c_user_id + LEFT JOIN wx_c_user_basic_info cu ON cu.id = co.c_user_id LEFT JOIN wx_merchant_b_user mbu ON concat(mbu.merchant_id,'') = JSON_EXTRACT(cs.conditions , '$.id') WHERE cal.channel_type = #{channelType} AND cs.conditions -> '$.id' = concat(#{merchantId},'') diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml index 9cc65084b..29eec0839 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml @@ -747,7 +747,8 @@ - co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, + co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id, + co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund,c.business,c.subsidy_type,ms.subsidy subsidy_num, bu.name, bu.phone as bphone, cu.phone, @@ -756,46 +757,31 @@ select from wx_coupon c, wx_coupon_order co - left join wx_c_user cu on cu.id = co.c_user_id + left join wx_c_user_basic_info cu on cu.id = co.c_user_id left join wx_merchant_b_user bu on co.b_user_id = bu.id left join wx_merchant m on m.id = bu.merchant_id left join wx_merchant_subsidy ms on co.id = ms.coupon_order_id and ms.type = 1 @@ -913,7 +899,7 @@ select - from wx_coupon_order co,wx_coupon c,wx_c_user cu,wx_merchant_b_user bu + from wx_coupon_order co,wx_coupon c,wx_c_user_basic_info cu,wx_merchant_b_user bu where co.coupon_id = c.id and cu.id = co.c_user_id and bu.id = co.b_user_id diff --git a/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml b/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml index aacd0cdc4..3ec5cb34d 100644 --- a/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCreditHistoryMapper.xml @@ -164,7 +164,7 @@ credit.ticket_number ticketNumber, case when credit.operator_type=4 then (select name from mall_user_info where id=credit.operator_id) when credit.operator_type=3 then (select name from wx_merchant_b_user where id=credit.operator_id) - when credit.operator_type=1 then (select nick_name from wx_c_user where id=credit.operator_id) + when credit.operator_type=1 then (select nick_name from wx_c_user_basic_info where id=credit.operator_id) else '' end operator, credit.change_purpose changePurpose FROM diff --git a/mallinkService/src/main/resources/mapper/WxOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxOrderMapper.xml index 8c72b2cc6..af777d8bf 100644 --- a/mallinkService/src/main/resources/mapper/WxOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxOrderMapper.xml @@ -427,7 +427,7 @@ o.`id`,o.`order_number`,o.`tenant_id`,o.`parent_tenant_id`,o.`c_user_id`,o.`coupon_channel_id`,o.`product_id`,o.`type`, o.`payment_type`,o.`payment`,o.`payment_time`,o.`order_status`,o.`create_date`,o.`update_date`,o.`detail`, m.name as merchant_name, bu.name, bu.phone as bphone, - cu.phone, cu.nick_name, cubi.name c_user_name + cubi.phone, cubi.nick_name, cubi.name c_user_name select from wx_order_press op - left join wx_c_user cu on cu.id = op.user_id + left join wx_c_user_basic_info cu on cu.id = op.user_id where op.`order_id` = #{orderId} order by op.`create_date` desc