Explorar el Código

Merge remote-tracking branch 'origin/master'

小么熊🐻 hace 3 años
padre
commit
601f1bd10d

+ 64 - 0
twzd-admin/src/main/java/com/miaxis/pc/controller/extension/PcWxExtensionIncomeController.java

@@ -0,0 +1,64 @@
+package com.miaxis.pc.controller.extension;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.miaxis.common.core.controller.BaseController;
+import com.miaxis.common.core.domain.Response;
+import com.miaxis.common.core.domain.entity.UserInfo;
+import com.miaxis.extension.service.IWxExtensionIncomeService;
+import com.miaxis.extension.vo.ExtensionIncomeVo;
+import com.miaxis.spread.service.IWxSpreadRelationService;
+import com.miaxis.user.service.IUserInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author wwl
+ * @version 1.0
+ * @date 2021/11/29 15:58
+ */
+@RestController
+@RequestMapping("/extension/income")
+@Api(tags={"【PC-推广积分】"})
+@AllArgsConstructor
+public class PcWxExtensionIncomeController extends BaseController {
+
+    private final IWxExtensionIncomeService extensionIncomeService;
+
+    private final IUserInfoService userInfoService;
+
+    private final IWxSpreadRelationService wxSpreadRelationService;
+
+
+
+
+    /**
+     * 查询下级推广积分
+     */
+    @GetMapping(value = "/extensionPoints")
+    @ApiOperation("查询下级推广积分")
+    public Response<List<ExtensionIncomeVo>> getDownLevelPoints(String openid) {
+        List<ExtensionIncomeVo> list = userInfoService.getDownLevelPoints(openid);
+        return Response.success(list);
+    }
+
+
+
+    @GetMapping(value = "/info")
+    @ApiOperation("获取代理列表")
+    public Response<List<UserInfo>> getInfo(){
+        List<String> saleTypeList = new ArrayList<>();
+        saleTypeList.add("2");
+        saleTypeList.add("3");
+        return Response.success(userInfoService.list(new QueryWrapper<UserInfo>().in("sale_type",saleTypeList)));
+    }
+
+
+
+}

+ 16 - 2
twzd-admin/src/test/java/com/miaxis/test/NormalTest.java

@@ -7,11 +7,14 @@ import com.github.wxpay.sdk.WXPayUtil;
 import com.miaxis.TwzdApplication;
 import com.miaxis.common.config.WxPayConfigImpl;
 import com.miaxis.common.config.WxpayConfig;
+import com.miaxis.common.core.domain.entity.UserInfo;
 import com.miaxis.common.utils.XmlUtil;
 import com.miaxis.extension.service.IWxExtensionIncomeService;
 import com.miaxis.question.mapper.QuestionInfoMapper;
 import com.miaxis.question.vo.QuestionInfoExcelTypeVo;
 import com.miaxis.question.vo.QuestionInfoExcelVo;
+import com.miaxis.system.service.ISysUserService;
+import com.miaxis.user.service.IUserInfoService;
 import com.miaxis.wx.service.impl.WxGzhServiceImpl;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.poi.hssf.usermodel.*;
@@ -32,7 +35,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
-@ActiveProfiles("prod")
+@ActiveProfiles("prodtest")
 @SpringBootTest(classes = TwzdApplication.class)
 @RunWith(SpringRunner.class)
 public class NormalTest {
@@ -49,6 +52,11 @@ public class NormalTest {
 
     @Autowired
     IWxExtensionIncomeService wxExtensionIncomeService;
+    @Autowired
+    ISysUserService userService;
+
+    @Autowired
+    IUserInfoService userInfoService;
 
 
 
@@ -61,7 +69,13 @@ public class NormalTest {
     private String secret;
     @Test
     public void test666() throws Exception {
-        wxExtensionIncomeService.addExtensionIncomeBySourceId(null,"ovKTX5-FKLF6_sgTtCIXpG_lz3PY",100);
+
+        UserInfo userInfo = userService.getStudentByOpenId("ovKTX5-FKLF6_sgTtCIXpG_lz3PY");
+        userInfo.setAreaName("");
+        userInfo.setCityName("");
+        userInfo.setSchoolName("");
+        userInfoService.updateById(userInfo);
+
     }
 
 

+ 3 - 0
twzd-service/src/main/java/com/miaxis/extension/vo/ExtensionIncomeVo.java

@@ -33,4 +33,7 @@ public class ExtensionIncomeVo {
     @ApiModelProperty(value = "已结算推广积分")
     private Integer achievementSettled;
 
+    @ApiModelProperty(value = "推广人数")
+    private Integer extensionCount;
+
 }

+ 2 - 0
twzd-service/src/main/java/com/miaxis/wx/service/impl/WxForeverCodeServiceImpl.java

@@ -7,6 +7,7 @@ import com.miaxis.wx.mapper.WxForeverCodeMapper;
 import com.miaxis.wx.service.IWxForeverCodeService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.util.List;
@@ -30,6 +31,7 @@ public class WxForeverCodeServiceImpl extends ServiceImpl<WxForeverCodeMapper, W
      * @return 微信永久二维码口令
      */
     @Override
+    @Transactional
     public List<WxForeverCode> selectWxForeverCodeList(WxForeverCode wxForeverCode){
         List<WxForeverCode> wxForeverCodes = wxForeverCodeMapper.selectWxForeverCodeList(wxForeverCode);
         // 若目前无数据,则创建一个

+ 19 - 1
twzd-service/src/main/java/com/miaxis/wx/service/impl/WxGzhServiceImpl.java

@@ -138,6 +138,13 @@ public class WxGzhServiceImpl implements IWxGzhService {
                 }
                 else if (content.startsWith("你好")){
                     return MessageUtil.initText(fromUserName, toUserName, "你好啊");
+                }else if (content.startsWith("重置驾校")){
+                    UserInfo userInfo = userService.getStudentByOpenId(fromUserName);
+                    userInfo.setAreaName("");
+                    userInfo.setCityName("");
+                    userInfo.setSchoolName("");
+                    userInfoService.updateById(userInfo);
+                    return MessageUtil.initText(fromUserName, toUserName, "重置驾校成功,请重新生成二维码!");
                 }else {
                     return MessageUtil.initText(fromUserName, toUserName, "金牌车教,您的学车好伙伴!");
                 }
@@ -166,10 +173,19 @@ public class WxGzhServiceImpl implements IWxGzhService {
                         UserInfo parentUserInfo = userService.getStudentByOpenId(parentOpenid);
                         if (parentUserInfo != null && (parentUserInfo.getSaleType() ==1 || parentUserInfo.getSaleType() ==3 )){
                             userInfo.setSaleType(1);
+                            if (user!= null){
+                                user.setSaleType(1);
+                            }
+
                             if (!StringUtils.isEmpty(parentUserInfo.getSchoolName())){
                                 userInfo.setCityName(parentUserInfo.getCityName());
                                 userInfo.setSchoolName(parentUserInfo.getSchoolName());
                                 userInfo.setAreaName(parentUserInfo.getAreaName());
+                                if (user!= null){
+                                    user.setCityName(parentUserInfo.getCityName());
+                                    user.setSchoolName(parentUserInfo.getSchoolName());
+                                    user.setAreaName(parentUserInfo.getAreaName());
+                                }
                             }
                         }
                         result =  MessageUtil.initText(fromUserName,toUserName,subscribeEvent);
@@ -182,6 +198,8 @@ public class WxGzhServiceImpl implements IWxGzhService {
                         //保存用户信息
                        userInfoService.save(userInfo);
 
+                    }else{
+                        userInfoService.updateById(user);
                     }
                     return result;
 
@@ -229,7 +247,7 @@ public class WxGzhServiceImpl implements IWxGzhService {
                         //查询该用户的上级
                         UserInfo upUserInfo = userInfoService.getUpUserInfo(fromUserName);
                         //当用户销售类型为 普通用户(含驾校分成) 并且他的父级不是代理商(含驾校分成)时,且未填写驾校信息时则需要填写驾校信息
-                       if (userInfo.getSaleType() ==1 && upUserInfo.getSaleType()!=3 && StringUtils.isEmpty(userInfo.getSchoolName()) ){
+                       if (userInfo.getSaleType() ==1 && upUserInfo!= null &&upUserInfo.getSaleType()!=3 && StringUtils.isEmpty(userInfo.getSchoolName()) ){
                            return choseSchoolName(userInfo,fromUserName,toUserName);
                        }
                         String mediaId = wxMessageEvenService.gainTicketEvent(fromUserName, this.getGzhToken(), false, wxForeverCode);

+ 12 - 13
twzd-service/src/main/java/com/miaxis/wx/service/impl/WxMessageEvenServiceImpl.java

@@ -83,29 +83,28 @@ public class WxMessageEvenServiceImpl implements IWxMessageEvenService {
     public String scanSubscribeEvent(String fromUserName, String eventKey,String token,String userName) {
 
         String message = "";
+        //如果扫自己
+        if (fromUserName.equals(eventKey)){
+            //推送绑定模板信息到上级
+            return "不能成为自己的下级!";
+        }
         //判断是否存在父、子级推广关系
         List<WxSpreadRelation> spreadRelations = wxSpreadRelationService.list(new QueryWrapper<WxSpreadRelation>().eq("openid", fromUserName));
-        List<WxSpreadRelation> spreads = wxSpreadRelationService.list(new QueryWrapper<WxSpreadRelation>().eq("parent_openid", fromUserName));
+        //List<WxSpreadRelation> spreads = wxSpreadRelationService.list(new QueryWrapper<WxSpreadRelation>().eq("parent_openid", fromUserName));
         String openid = eventKey;
-        if (spreadRelations.isEmpty() && spreads.isEmpty()){
+        if ( spreadRelations.isEmpty()) {
             //保存推广关系表
             WxSpreadRelation wxSpreadRelation = new WxSpreadRelation();
             wxSpreadRelation.setOpenid(fromUserName);
             wxSpreadRelation.setParentOpenid(openid);
             wxSpreadRelationService.save(wxSpreadRelation);
 
-
-
             //推送绑定模板信息到上级
-            messageTemplateSend(openid,token,userName);
-
-
-
+            messageTemplateSend(openid, token, userName);
             message = "已成功绑定推广关系!";
-        }else if (!spreads.isEmpty()){
-            message = "已存在下级绑定关系!";
-        }else {
-            message = "已存在推广关系!";
+        }
+        else {
+            message =  "已存在上级绑定关系!";
         }
         return message;
     }
@@ -321,7 +320,7 @@ public class WxMessageEvenServiceImpl implements IWxMessageEvenService {
         keyword1.put("color","#173177");
         keyword2.put("value", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
         keyword2.put("color","#173177");
-        keyword3.put("value","此用户下单后您将获得对应抽成,"+"\n点击 我的->我要提现,即可提现到余额!"+"\n点击查看已绑定信息!");
+        keyword3.put("value","有新用户已成为你的下级!");
         keyword3.put("color","#173177");
         jsonObject.put("first",first);
         jsonObject.put("keyword1",keyword1);

+ 2 - 1
twzd-service/src/main/resources/mapper/user/UserInfoMapper.xml

@@ -71,7 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where openid = (select parent_openid from wx_spread_relation where openid = #{fromUserName})
     </select>
     <select id="getDownLevelPoints"  resultType="com.miaxis.extension.vo.ExtensionIncomeVo">
-        select openid,IFNULL(nick_name,'未知') as nick_name,IFNULL(head_image,'未知') as head_image,achievement,achievement_settled from user_info
+        select openid,IFNULL(nick_name,'未知') as nick_name,IFNULL(head_image,'未知') as head_image,achievement,achievement_settled,
+        (select count(1) from wx_spread_relation where parent_openid =t1.openid) as extension_count from user_info t1
         where openid in (select openid from wx_spread_relation where parent_openid = #{openid})
     </select>