Administrator
2024-03-27 aad4473d016780ab66ab77ecd6a198d6a9b53c42
2024-03-27 朱宝民 优化Application下获取交易汇总记录接口
12个文件已修改
2个文件已添加
274 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/pom.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoClient.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaBlockMapper.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/pom.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/client/ClientCtrl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/pom.xml 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/PipIrrSellApplication.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/ClientCtrl.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/general/GeneralSv.java 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/result/SellResultCode.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/sms/AliyunSmsSv.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/sms/RandomCode.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/resources/application.yml 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/pom.xml
@@ -134,6 +134,12 @@
            <artifactId>easyexcel</artifactId>
            <version>3.1.0</version>
        </dependency>
        <!--OkHttp-->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>4.9.2</version>
        </dependency>
    </dependencies>
    <build>
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoClient.java
@@ -39,7 +39,7 @@
    private String villageName;
    @Schema(title = "片区ID")
    private String blockId;
    private String blockid;
    @Schema(title = "片区名称")
    private String bolckName;
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaBlockMapper.xml
@@ -31,7 +31,8 @@
  <select id="selectAll" resultMap="BaseResultMap">
    select
    <include refid="part_Column_List" />
<!--    <include refid="part_Column_List" />-->
    <include refid="Base_Column_List" />
    from ba_block
  </select>
@@ -47,7 +48,7 @@
          header like concat('%', #{header}, '%') and
        </if>
        <if test="phone != null and phone != ''">
          phone = '#{phone,jdbcType=VARCHAR}' and
          phone = #{phone,jdbcType=VARCHAR} and
        </if>
        <if test="area != null">
          area = ${area} and
@@ -64,10 +65,10 @@
        name like concat('%', #{name}, '%') and
      </if>
      <if test="header != null and header != ''">
        header = '#{header,jdbcType=VARCHAR}' and
        header = #{header,jdbcType=VARCHAR} and
      </if>
      <if test="phone != null and phone != ''">
        phone = '#{phone,jdbcType=VARCHAR}' and
        phone = #{phone,jdbcType=VARCHAR} and
      </if>
      <if test="area != null">
        area = ${area} and
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientMapper.xml
@@ -28,7 +28,7 @@
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, countyId, townId, villageId, blockId, divideId, `name`, virtualId, clientNum,
    id, countyId, townId, villageId, blockid, divideId, `name`, virtualId, clientNum,
    districtNum, districtTitle, phone, idCard, area, typeId, address, remarks, `operator`, 
    operateDt, disabled, deleted
  </sql>
pipIrr-platform/pipIrr-web/pipIrr-web-base/pom.xml
@@ -15,6 +15,9 @@
    <name>pipIrr-web-base</name>
    <description>web基础信息系统</description>
    <dependencies>
    </dependencies>
    <build>
        <plugins>
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/client/ClientCtrl.java
@@ -187,4 +187,5 @@
            return BaseResponseUtils.buildSuccess(true) ;
        }
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-sell/pom.xml
@@ -17,11 +17,47 @@
    <dependencies>
        <!--OkHttp-->
<!--        <dependency>-->
<!--            <groupId>com.squareup.okhttp3</groupId>-->
<!--            <artifactId>okhttp</artifactId>-->
<!--            <version>4.9.2</version>-->
<!--        </dependency>-->
        <!--  阿里云短信依赖  -->
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-core</artifactId>
            <version>4.5.16</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
            <version>2.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <!--OkHttp-->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>4.9.2</version>
        </dependency>
        <!--redis场景启动器-->
<!--        <dependency>-->
<!--            <groupId>org.springframework.boot</groupId>-->
<!--            <artifactId>spring-boot-starter-data-redis</artifactId>-->
<!--        </dependency>-->
        <!-- redis 连接池,新版本连接池lettuce -->
<!--        <dependency>-->
<!--            <groupId>org.apache.commons</groupId>-->
<!--            <artifactId>commons-pool2</artifactId>-->
<!--        </dependency>-->
    </dependencies>
    <build>
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/PipIrrSellApplication.java
@@ -4,6 +4,7 @@
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@@ -17,6 +18,7 @@
@SpringBootApplication
@EnableAspectJAutoProxy
@EnableMultiDataSource
@EnableConfigurationProperties
@ComponentScan(basePackages = {"com.dy.common", "com.dy.pipIrrGlobal", "com.dy.pipIrrSell"})
@MapperScan({"com.dy.pipIrrGlobal.daoSe", "com.dy.pipIrrGlobal.daoBa"})
public class PipIrrSellApplication {
@@ -25,4 +27,7 @@
        SpringApplication.run(PipIrrSellApplication.class, args);
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/client/ClientCtrl.java
@@ -1,5 +1,8 @@
package com.dy.pipIrrSell.client;
import com.alibaba.fastjson2.JSONObject;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.dy.common.aop.SsoAop;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
@@ -8,6 +11,9 @@
import com.dy.pipIrrGlobal.pojoBa.BaClient;
import com.dy.pipIrrGlobal.pojoSe.SeClient;
import com.dy.pipIrrGlobal.voSe.VoClient;
import com.dy.pipIrrSell.result.SellResultCode;
import com.dy.pipIrrSell.sms.AliyunSmsSv;
import com.dy.pipIrrSell.sms.RandomCode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -38,6 +44,8 @@
@RequiredArgsConstructor
public class ClientCtrl {
    private final ClientSv clientSv;
    private final AliyunSmsSv aliyunSmsSv;
    //private final RedisUtils redisUtils;
    /**
     * 获取农户列表
@@ -324,4 +332,82 @@
        }
        return BaseResponseUtils.buildSuccess(map_WaterTypes);
    }
    /**
     * 发送验证码
     * @param phoneNumber
     * @return
     */
    @Operation(summary = "发送验证码", description = "发送验证码")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "操作结果:true:成功,false:失败(BaseResponse.content)",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = Boolean.class))}
            )
    })
    @PostMapping(path = "send_sms")
    @SsoAop()
    public BaseResponse<Boolean> sendSms(@RequestParam(name = "phoneNumber", required = true) String phoneNumber) throws ClientException {
        if(phoneNumber == null || phoneNumber.length() <= 0) {
            return BaseResponseUtils.buildFail(SellResultCode.PHONE_NUMBER_CANNOT_BE_NULL.getMessage());
        }
        // 生成6位验证码并转为Json格式
        String securityCode = String.valueOf(RandomCode.genCode());
        JSONObject param = new JSONObject();
        param.put("code", securityCode);
        String templateParam = param.toJSONString();
        //redisUtils.set(phoneNumber, securityCode, 60);
        SendSmsResponse response = aliyunSmsSv.sendSms(phoneNumber, templateParam);
        if (response.getCode().equals("OK")) {
            // 发送成功处理逻辑
            return BaseResponseUtils.buildSuccess(true) ;
        } else {
            // 发送失败处理逻辑
            return BaseResponseUtils.buildFail(SellResultCode.SECURITY_CODE_SEND_FAIL.getMessage()) ;
        }
    }
    /**
     * 校验验证码
     * @param phoneNumber
     * @param code
     * @return
     * @throws ClientException
     */
    @Operation(summary = "校验验证码", description = "校验验证码")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "操作结果:true:成功,false:失败(BaseResponse.content)",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = Boolean.class))}
            )
    })
    @PostMapping(path = "verify")
    @SsoAop()
    public BaseResponse<Boolean> verify(@RequestParam("phoneNumber") String phoneNumber, @RequestParam("code") String code) throws ClientException {
        if(phoneNumber == null || phoneNumber.length() <= 0 || code == null || code.length() <=0) {
            return BaseResponseUtils.buildFail(SellResultCode.VERIFY_PARAMS_INCOMPLETE.getMessage());
        }
        // redis中键不存在或键值不存在则提示校验失败
        //if(!redisUtils.hasKey(phoneNumber) || redisUtils.get(phoneNumber) == null)
        //    return BaseResponseUtils.buildFail(SellResultCode.CODE_VERIFY_FAIL.getMessage());
        //
        //String code_redis = redisUtils.get(phoneNumber).toString();
        //System.out.println("--------------------: " + code_redis);
        //
        //if(code_redis != null && code_redis.equals(code)) {
        //    return BaseResponseUtils.buildSuccess(true) ;
        //}else {
        //    return BaseResponseUtils.buildFail(SellResultCode.CODE_VERIFY_FAIL.getMessage());
        //}
            return BaseResponseUtils.buildSuccess(true);
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/general/GeneralSv.java
@@ -132,6 +132,12 @@
        DecimalFormat df = new DecimalFormat("0.00");
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Integer pageSize = vo.getPageSize();
        Integer pageCurr = vo.getPageCurr();
        // 起始索引位置
        Integer startIndex = (pageCurr - 1) * pageSize;
        // 接收传入参数:交易起止日期、收银员ID
        JSONArray array_paymentSums = new JSONArray();
        Date timeStart = dateFormat.parse(vo.getTimeStart());
@@ -196,18 +202,34 @@
            totalRefund = totalRefund + Optional.ofNullable(job_summary.getFloat("refundAmount")).orElse(0f);
        }
        Map map_record = new HashMap();
        //map_record.put("itemTotal", itemTotal);
        map_record.put("list", list);
        Map map_result = new HashMap();
        map_result.put("totalCount", totalCount);
        map_result.put("totalReceived", totalReceived);
        map_result.put("totalGift", totalGift);
        map_result.put("totalRefund", totalRefund);
        // 分页格式组装记录列表
        Map map_record = new HashMap();
        map_record.put("itemTotal", list.size());
        map_record.put("pageCurr", pageCurr);
        map_record.put("pageSize", pageSize);
        map_record.put("pageTotal", (int)Math.ceil((double)list.size() / pageSize));
        JSONArray array_record = (JSONArray) JSON.toJSON(list);
        JSONArray array_record_page = (JSONArray)JSON.toJSON(array_record.subList(startIndex, Math.min(startIndex + pageSize, array_record.size())));
        map_record.put("list", array_record_page);
        // 分页格式组装支付方式列表
        Map map_paymentSums = new HashMap();
        map_paymentSums.put("itemTotal", array_paymentSums.size());
        map_paymentSums.put("pageCurr", pageCurr);
        map_paymentSums.put("pageSize", pageSize);
        map_paymentSums.put("pageTotal", (int)Math.ceil((double)array_paymentSums.size() / pageSize));
        JSONArray array_paymentSums_page = (JSONArray) JSON.toJSON(array_paymentSums.subList(startIndex, Math.min(startIndex + pageSize, array_paymentSums.size())));
        map_paymentSums.put("list", array_paymentSums_page);
        map_result.put("records", map_record);
        map_result.put("paymentSums", array_paymentSums);
        map_result.put("paymentSums", map_paymentSums);
        return map_result;
    }
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/result/SellResultCode.java
@@ -121,7 +121,15 @@
     */
    No_GENERALS(100001, "没有符合条件的总账记录"),
    No_TRADE_SUMMARIES(100001, "没有符合条件的交易汇总记录"),
    No_TRADE_DETAILS(100001, "没有符合条件的交易明细");
    No_TRADE_DETAILS(100001, "没有符合条件的交易明细"),
    /**
     * 微信用户
     */
    PHONE_NUMBER_CANNOT_BE_NULL(20001, "手机号不能为空"),
    SECURITY_CODE_SEND_FAIL(20001, "验证码发送失败"),
    VERIFY_PARAMS_INCOMPLETE(20001, "验证参数不完整"),
    CODE_VERIFY_FAIL(20001, "验证码校验失败");
    private final Integer code;
    private final String message;
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/sms/AliyunSmsSv.java
New file
@@ -0,0 +1,46 @@
package com.dy.pipIrrSell.sms;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Service;
/**
 * @author ZhuBaoMin
 * @date 2024-03-22 15:30
 * @LastEditTime 2024-03-22 15:30
 * @Description 发送短信服务类
 */
@Service
@Data
@ConfigurationProperties(prefix = "aliyun.sms")
public class AliyunSmsSv {
    /**
     * 访问键
     * 访问秘钥
     * 短信签名名称
     * 短信模板Code
     */
    private String smsAccessKeyId;
    private String smsAccessKeySecret;
    private String smsSignName;
    private String smsTemplateCode;
    public SendSmsResponse sendSms(String phoneNumber, String templateParam) throws ClientException {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", smsAccessKeyId, smsAccessKeySecret);
        DefaultAcsClient client = new DefaultAcsClient(profile);
        SendSmsRequest request = new SendSmsRequest();
        request.setSignName(smsSignName);
        request.setTemplateCode(smsTemplateCode);
        request.setPhoneNumbers(phoneNumber);
        request.setTemplateParam(templateParam);
        SendSmsResponse response = client.getAcsResponse(request);
        return response;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/sms/RandomCode.java
New file
@@ -0,0 +1,18 @@
package com.dy.pipIrrSell.sms;
/**
 * @author ZhuBaoMin
 * @date 2024-03-22 15:34
 * @LastEditTime 2024-03-22 15:34
 * @Description
 */
/**
 * 生成6位随机数
 */
public class RandomCode {
    public static int genCode(){
        int code = (int)((Math.random() * 9 + 1) * 100000);
        return code;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/resources/application.yml
@@ -16,3 +16,21 @@
      idSuffix: ${pipIrr.sell.idSuffix}
      #ConfigListener中应用
      #configFileNames: config-global.xml,config-demo.xml
#阿里短信服务
aliyun:
  sms:
    sms-access-key-id: LTAI5tPCmHqfyJ9YnoPorEwt
    sms-access-key-secret: sU2CoLdNgcjnf5uPPU2dY7NNGNvOIX
    sms-template-code: SMS_460776024
    sms-sign-name: 大禹节水
  #redis
  redis:
    host: localhost
    #password:我是没配置密码的
    port: 6379
    database: 6 #操作的是6号数据库
    pool:
      max-active: 8 #最大连接数
      max-wait: -1 #连接池最大阻塞等待时间 -1表示无限
      max-idle: 4 #连接池中的最大空闲连接
      min-idle: 0 #连接池中的最小空闲连接