xiaoyong931011
2021-07-21 9748895b0eb4fef89e6cb238f1dbd92b8c7fe106
Merge branch 'score-shop' of http://120.27.238.55:7000/r/xzx into score-shop
18 files modified
1 files added
227 ■■■■ changed files
gc-core/pom.xml 6 ●●●●● patch | view | raw | blame | history
gc-core/src/main/java/com/xzx/gc/common/utils/image/GraphicsUtils.java 1 ●●●● patch | view | raw | blame | history
gc-core/src/main/java/com/xzx/gc/common/utils/wxpay/WxUtil.java 23 ●●●●● patch | view | raw | blame | history
gc-core/src/main/resources/application.properties 2 ●●● patch | view | raw | blame | history
gc-order/src/main/java/com/xzx/gc/order/controller/ApiJhyOrderController.java 7 ●●●●● patch | view | raw | blame | history
gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderMapper.java 3 ●●●●● patch | view | raw | blame | history
gc-order/src/main/java/com/xzx/gc/order/service/DistribService.java 2 ●●● patch | view | raw | blame | history
gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java 32 ●●●●● patch | view | raw | blame | history
gc-order/src/main/java/com/xzx/gc/order/vo/JhyStatusCountVo.java 13 ●●●●● patch | view | raw | blame | history
gc-order/src/main/resources/mapper/order/JhyOrderMapper.xml 14 ●●●●● patch | view | raw | blame | history
gc-order/src/test/java/SpringTest.java 12 ●●●●● patch | view | raw | blame | history
gc-user/src/main/java/com/xzx/gc/user/controller/AdminDistribController.java 37 ●●●● patch | view | raw | blame | history
gc-user/src/main/java/com/xzx/gc/user/controller/ApiJhyInfoController.java 2 ●●● patch | view | raw | blame | history
gc-user/src/main/java/com/xzx/gc/user/mapper/AccountMapper.java 2 ●●●●● patch | view | raw | blame | history
gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java 3 ●●●● patch | view | raw | blame | history
gc-user/src/main/java/com/xzx/gc/user/service/PosterService.java 6 ●●●● patch | view | raw | blame | history
gc-user/src/main/resources/mapper/user/AccountMapper.xml 7 ●●●●● patch | view | raw | blame | history
gc-user/src/test/java/SpringTest.java 46 ●●●●● patch | view | raw | blame | history
gc-user/src/test/java/ThreadTest.java 9 ●●●●● patch | view | raw | blame | history
gc-core/pom.xml
@@ -170,6 +170,12 @@
            <!--<version>5.3</version>-->
        <!--</dependency>-->
        <!-- https://mvnrepository.com/artifact/com.github.jai-imageio/jai-imageio-core -->
        <dependency>
            <groupId>com.github.jai-imageio</groupId>
            <artifactId>jai-imageio-core</artifactId>
            <version>1.4.0</version>
        </dependency>
    </dependencies>
gc-core/src/main/java/com/xzx/gc/common/utils/image/GraphicsUtils.java
@@ -79,6 +79,7 @@
                }
            }
        } catch (Exception e) {
            log.error("报错:", e);
            return null;
        }
        log.debug("生成海报成功,路径:" + imgPath);
gc-core/src/main/java/com/xzx/gc/common/utils/wxpay/WxUtil.java
@@ -73,6 +73,9 @@
        return openid;
    }
    public  String generateAcode(String scene,String path,String imgName,String width){
        return generateAcode(scene, path, imgName, width, null);
    }
    /**
     * 生成小程序码
@@ -81,19 +84,25 @@
     * @param imgName  图片唯一名称
     * @return
     */
    public  String generateAcode(String scene,String path,String imgName,String width){
    public  String generateAcode(String scene,String path,String imgName,String width, Integer type){
        String urlPrefix=businessUtil.getViewUrl();
        String imgPath=Constants.IMG_UPLOAD_PATH+imgName;
        if(!FileUtil.exist(imgPath)){
            //调用二维码接口
            String url = StrFormatter.format("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={}", getAccessToken());
            cn.hutool.json.JSONObject obj = JSONUtil.createObj();
            //最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
            // 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
            //调用二维码接口
            String url = null;
            if (type == null) {
                // 该接口无数量限制,但是 scene 传参最大字符长度为32个字符
                url = StrFormatter.format("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={}", getAccessToken());
            obj.put("scene", scene);
            //必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index,
            // 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面
            obj.put("path", path);
            } else {
                // 该接口存在数量限制, 总共可生成10w个, 但参数是接在path后面
                url = StrFormatter.format("https://api.weixin.qq.com/wxa/getwxacode?access_token={}", getAccessToken());
                obj.put("path", path + "?" + scene );
            }
            //最小 280px,最大 1280px
            obj.put("width", width);
            obj.put("auto_color", false);
gc-core/src/main/resources/application.properties
@@ -11,7 +11,7 @@
#log
project.log.path=xzx/logs
project.log.path=/xzx/logs
logstash.server.url=localhost:4560
#spring
gc-order/src/main/java/com/xzx/gc/order/controller/ApiJhyOrderController.java
@@ -23,6 +23,7 @@
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@Slf4j
@RestController
@@ -82,4 +83,10 @@
        return Result.success();
    }
    @ApiOperation("订单状态数量")
    @PostMapping(value = "/orderStatusCnt")
    public JsonResult<Map<Integer, Integer>> orderStatusCnt(HttpServletRequest request) {
        return JsonResult.success(jhyOrderService.orderStatusCount(getUserId(request)));
    }
}
gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderMapper.java
@@ -3,6 +3,7 @@
import com.xzx.gc.entity.JhyOrder;
import com.xzx.gc.order.dto.JhyOrderListDto;
import com.xzx.gc.order.vo.JhyOrderListVo;
import com.xzx.gc.order.vo.JhyStatusCountVo;
import com.xzx.gc.util.GcMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@@ -13,4 +14,6 @@
public interface JhyOrderMapper extends GcMapper<JhyOrder> {
    List<JhyOrderListVo> selectJhyOrderList(@Param("record") JhyOrderListDto jhyOrderListDto);
    List<JhyStatusCountVo> selectOrderStatusCount(@Param("userId") String userId);
}
gc-order/src/main/java/com/xzx/gc/order/service/DistribService.java
@@ -99,7 +99,7 @@
                    // 根据订单总积分, 1:40比例,换算成环保币,返对应百分比
                    if (StrUtil.isNotBlank(coinStr) && !"0".equals(coinStr)) {
                        BigDecimal coinRatio = new BigDecimal(coinStr).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_DOWN);
                        BigDecimal totalCoin = totalScore.divide(new BigDecimal(40), 2, BigDecimal.ROUND_DOWN);
                        BigDecimal totalCoin = totalScore.divide(new BigDecimal(50), 2, BigDecimal.ROUND_DOWN);
                        BigDecimal returnCoin = totalCoin.multiply(coinRatio).setScale(2, BigDecimal.ROUND_DOWN);
                        totalReturnCoin = totalReturnCoin.add(returnCoin);
gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java
@@ -18,6 +18,7 @@
import com.xzx.gc.order.mapper.*;
import com.xzx.gc.order.vo.JhyOrderDetailsVo;
import com.xzx.gc.order.vo.JhyOrderListVo;
import com.xzx.gc.order.vo.JhyStatusCountVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -25,9 +26,7 @@
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Slf4j
@Service
@@ -172,6 +171,7 @@
            order.setStatus(JhyOrder.ORDER_STATUS_CANCEL);
        }
        order.setJhyId(null);
        jhyOrderMapper.updateByPrimaryKey(order);
    }
@@ -236,4 +236,30 @@
        distribService.distribRecord(order.getId(), order.getUserId());
    }
    public Map<Integer, Integer> orderStatusCount(String userId) {
        List<JhyStatusCountVo> count = jhyOrderMapper.selectOrderStatusCount(userId);
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 1; i < 6; i++) {
            if (CollUtil.isNotEmpty(count)) {
                boolean flag = false;
                for (JhyStatusCountVo jhyStatusCountVo : count) {
                    if (i == jhyStatusCountVo.getStatus()) {
                        map.put(i, jhyStatusCountVo.getCnt());
                        flag = true;
                        break;
                    }
                }
                if (flag) {
                    continue;
                }
            }
            map.put(i, 0);
        }
        return map;
    }
}
gc-order/src/main/java/com/xzx/gc/order/vo/JhyStatusCountVo.java
New file
@@ -0,0 +1,13 @@
package com.xzx.gc.order.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel(value = "JhyStatucCountVo", description = "")
public class JhyStatusCountVo {
    private Integer status;
    private Integer cnt;
}
gc-order/src/main/resources/mapper/order/JhyOrderMapper.xml
@@ -43,4 +43,18 @@
        group by a.id
        order by a.receiving_time desc, a.id desc
    </select>
    <select id="selectOrderStatusCount" resultType="com.xzx.gc.order.vo.JhyStatusCountVo">
        select
           status,
           count(1) cnt
        from xzx_jhy_order where status=1
        union  all
        select
           status,
           count(1) cnt
        from xzx_jhy_order
        where user_id=#{userId}
        group by status
    </select>
</mapper>
gc-order/src/test/java/SpringTest.java
@@ -22,6 +22,7 @@
import com.xzx.gc.common.utils.SpringUtil;
import com.xzx.gc.common.utils.gdmap.GdMapUtil;
import com.xzx.gc.common.utils.gdmap.GdTraceUtil;
import com.xzx.gc.common.utils.image.GraphicsUtils;
import com.xzx.gc.entity.*;
import com.xzx.gc.model.order.FenceDto;
import com.xzx.gc.model.user.AccountVo;
@@ -777,5 +778,16 @@
    }
    @Autowired
    private GraphicsUtils graphicsUtils;
    @Test
    public void haibaoTest() {
        String imageName = "/test.jpg";
        String path = "/Users/helius/Desktop/acode.jpg";
        String avatar = "https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132";
        String backgroundUrl = "/Users/helius/Desktop/user_share_poster_bg.png";
        graphicsUtils.generatePoster(imageName, path, avatar, backgroundUrl, "15200889645", 100, 340, 57, 94, 230, 160, 40);    }
}
gc-user/src/main/java/com/xzx/gc/user/controller/AdminDistribController.java
@@ -1,7 +1,9 @@
package com.xzx.gc.user.controller;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.xzx.gc.common.constant.CommonEnum;
import com.xzx.gc.common.constant.Constants;
import com.xzx.gc.common.dto.log.OperationAppLog;
@@ -106,33 +108,46 @@
    @ApiOperation(value="分銷系統管理--新增团长", notes="test: 仅0有正确返回")
    public JsonResult adddistrib(@RequestBody AdddistribDto model, HttpServletRequest request) {
        String id = model.getId();
        AccountInfo accountInfo = accountMapper.selectByPrimaryKey(id);
        if(ObjectUtil.isEmpty(accountInfo)){
            return JsonResult.failMessage("账户不存在!");
        }
        List<String> ids = StrUtil.split(id, ',');
//        AccountInfo accountInfo = accountMapper.selectByPrimaryKey(id);
        List<AccountInfo> accountInfos = accountMapper.selectAccountInfoByIds(ids);
        if (CollUtil.isNotEmpty(accountInfos)) {
            for (AccountInfo accountInfo : accountInfos) {
//                if(ObjectUtil.isEmpty(accountInfo)){
//                    return JsonResult.failMessage("账户不存在!");
//                }
        if(ObjectUtil.isEmpty(accountInfo.getIsHead())
                || accountInfo.getIsHead() == 1){
            return JsonResult.failMessage("账户不能重复添加!");
                    return JsonResult.failMessage(accountInfo.getAccountName() + "账户不能重复添加!");
        }
        if(ObjectUtil.isEmpty(accountInfo.getDelFlag())
                || accountInfo.getDelFlag() == 1){
            return JsonResult.failMessage("账户已删除!");
                    return JsonResult.failMessage(accountInfo.getAccountName() + "账户已删除!");
        }
        if(ObjectUtil.isEmpty(accountInfo.getIsProhibit())
                || accountInfo.getIsProhibit() == "1"){
            return JsonResult.failMessage("账户已冻结!");
                        || "1".equals(accountInfo.getIsProhibit())){
                    return JsonResult.failMessage(accountInfo.getAccountName() + "账户已冻结!");
        }
        //团员不能当团长
        String userId = accountInfo.getUserId();
        UserHeadRelate userHeadRelate = userHeadRelateMapper.selectMemberByUserId(userId);
        if(ObjectUtil.isNotEmpty(userHeadRelate)){
            return JsonResult.failMessage("账户不能申请成为团长!");
                    return JsonResult.failMessage(accountInfo.getAccountName() + "账户不能申请成为团长!");
        }
        distribService.adddistrib(model);
//                distribService.adddistrib(accountInfo.getAccountId());
                accountInfo.setIsHead(1);
                accountMapper.updateByPrimaryKey(accountInfo);
        OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request))
                    .methodName(Constants.USER_MODUL_NAME).operateAction("分銷系統管理--新增团长-"+id).build();
        mqUtil.sendApp(build);
            }
        return  JsonResult.success("操作成功!");
        } else {
            return JsonResult.failMessage("参数错误");
        }
    }
    @ApiOperation(value = "团长列表")
@@ -220,7 +235,7 @@
        List<List<String>> rows = new ArrayList<>();
        List<String> header=new ArrayList<>();
        //标题
        header=CollUtil.newArrayList( "团长名称", "手机号", "身份", "团员数量", "交易单数", "累计收益积分", "累计收益(元)", "累计订单重量(kg)","累计数量(家电)");
        header=CollUtil.newArrayList( "团长名称", "手机号", "身份", "团员数量", "交易单数", "累计积分收益", "累计环保币收益", "累计订单重量(kg)","累计订单数量(家电)");
        rows.add(header);
        Map<String, Object> stringObjectMap = distribService.distribDataExport(distribDataListDto);
        List<DistribDataListVo> distribDataListVos = (List<DistribDataListVo>) stringObjectMap.get("data");
gc-user/src/main/java/com/xzx/gc/user/controller/ApiJhyInfoController.java
@@ -58,7 +58,7 @@
                break;
            case 1:
                map.put("icon", "../../images/icon_team.png");
                map.put("name", "集物员订单列表");
                map.put("name", "集物员订单");
                map.put("path", "../../collectPersonnel/GCOrderForm/index");
                break;
            case 2:
gc-user/src/main/java/com/xzx/gc/user/mapper/AccountMapper.java
@@ -76,5 +76,7 @@
    String selectOrderExportByHeadUserId(@Param("accountId")String id, @Param("record")ExportDistribDataListDto distribDataListDto);
    String selectJDSLExportByHeadUserId(@Param("accountId")String id, @Param("record")ExportDistribDataListDto distribDataListDto);
    List<AccountInfo> selectAccountInfoByIds(@Param("list") List<String> list);
}
gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java
@@ -233,8 +233,7 @@
        return data;
    }
    public void adddistrib(AdddistribDto model) {
        String id = model.getId();
    public void adddistrib(String id) {
        AccountInfo accountInfo = accountMapper.selectByPrimaryKey(id);
        accountInfo.setIsHead(1);
        accountMapper.updateByPrimaryKey(accountInfo);
gc-user/src/main/java/com/xzx/gc/user/service/PosterService.java
@@ -34,10 +34,10 @@
    public Map<String,String> generate(UserInfo userInfo){
        //海报图名称
        String userId=userInfo.getUserId();
        String imageName="/user_" + userId + "_poster.jpg";
        String imageName="/user_" + userId + "_poster_1.jpg";
        //二维码图名称
        String imgName="/user_" + userId + "_acode.jpg";
        String s1 = wxUtil.generateAcode("poster=" + userInfo.getMobilePhone(), "pages/login/login", imgName, "800px");
        String imgName="/user_" + userId + "_acode_1.jpg";
        String s1 = wxUtil.generateAcode("poster=" + userInfo.getMobilePhone() +"&chiefId=" + userInfo.getUserId(), "pages/login/login", imgName, "800px", 1);
        if(StrUtil.isBlank(s1)){
            throw new RestException("生成分享海报失败");
        }
gc-user/src/main/resources/mapper/user/AccountMapper.xml
@@ -547,4 +547,11 @@
        )
    </select>
    <select id="selectAccountInfoByIds" resultType="com.xzx.gc.entity.AccountInfo">
        select * from xzx_account_info
        where account_id in
        <foreach collection="list" index="index" item="id" separator="," open="(" close=")">
            #{id}
        </foreach>
    </select>
</mapper>
gc-user/src/test/java/SpringTest.java
@@ -1,8 +1,11 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.StrFormatter;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import com.xzx.gc.GcUserApplication;
import com.xzx.gc.common.Result;
@@ -10,9 +13,11 @@
import com.xzx.gc.common.constant.Constants;
import com.xzx.gc.common.utils.RedisUtil;
import com.xzx.gc.common.utils.gdmap.GdTraceUtil;
import com.xzx.gc.common.utils.wxpay.WxUtil;
import com.xzx.gc.entity.*;
import com.xzx.gc.user.mapper.UserBatchMapper;
import com.xzx.gc.user.service.*;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +25,8 @@
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@@ -28,9 +35,10 @@
import java.util.stream.Collectors;
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {GcUserApplication.class})
@ActiveProfiles(profiles = {"temp"})
@ActiveProfiles(profiles = {"xc"})
public class SpringTest {
@@ -211,6 +219,42 @@
    }
    @Autowired
    private WxUtil wxUtil;
    @Test
    public void acodeTest() {
        String path = "pages/login/login?poster=18390984915&chiefId=YH1417670707298828288";
        String imgPath = "/Users/helius/Desktop/YH1417670707298828288_acode.jpg";
        String url = StrFormatter.format("https://api.weixin.qq.com/wxa/getwxacode?access_token={}", wxUtil.getAccessToken());
        cn.hutool.json.JSONObject obj = JSONUtil.createObj();
        obj.put("path", path);
        //最小 280px,最大 1280px
        obj.put("width", "800px");
        obj.put("auto_color", false);
        cn.hutool.json.JSONObject obj2 = JSONUtil.createObj();
        obj2.put("r", 0);
        obj2.put("g", 0);
        obj2.put("b", 0);
        obj.put("line_color", obj2);
        //是否需要透明底色,为 true 时,生成透明底色的小程序码
        obj.put("is_hyaline", false);
        try {
            InputStream inputStream = HttpRequest.post(url).body(obj.toString(), "application/json").execute().bodyStream();
            File file = new File(imgPath);
            FileUtil.writeFromStream(inputStream, file);
            long uploadUrl = FileUtil.size(file);
            //小于10kb重新生成
            if(uploadUrl<= Constants.MIN_FILE_SIZE){
                log.error("生成微信小程序码失败:图片大小异常:{}",uploadUrl);
            }
        } catch (Exception e) {
            log.error("生成微信小程序码失败",e);
        }
    }
}
gc-user/src/test/java/ThreadTest.java
@@ -1,8 +1,17 @@
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.core.text.StrFormatter;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import com.xzx.gc.common.constant.Constants;
import com.xzx.gc.common.utils.wxpay.WxUtil;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.File;
import java.io.InputStream;
import java.util.concurrent.*;
public class ThreadTest {