2024-03-27 朱宝民 优化Application下获取交易汇总记录接口
| | |
| | | <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> |
| | |
| | | private String villageName; |
| | | |
| | | @Schema(title = "片区ID") |
| | | private String blockId; |
| | | private String blockid; |
| | | @Schema(title = "片区名称") |
| | | private String bolckName; |
| | | |
| | |
| | | |
| | | <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> |
| | | |
| | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | </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> |
| | |
| | | operateDt, disabled, deleted |
| | | ) |
| | | values (#{id,jdbcType=BIGINT}, #{countyid,jdbcType=BIGINT}, #{townid,jdbcType=BIGINT}, |
| | | #{villageid,jdbcType=BIGINT}, #{blockid,jdbcType=BIGINT}, #{divideid,jdbcType=BIGINT}, |
| | | #{villageid,jdbcType=BIGINT}, #{blockid,jdbcType=BIGINT}, #{divideid,jdbcType=BIGINT}, |
| | | #{name,jdbcType=VARCHAR}, #{virtualid,jdbcType=BIGINT}, #{clientnum,jdbcType=VARCHAR}, |
| | | #{districtnum,jdbcType=BIGINT}, #{districttitle,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, |
| | | #{idcard,jdbcType=VARCHAR}, #{area,jdbcType=DOUBLE}, #{typeid,jdbcType=BIGINT}, |
| | |
| | | <name>pipIrr-web-base</name> |
| | | <description>web基础信息系统</description> |
| | | |
| | | <dependencies> |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <plugins> |
| | |
| | | return BaseResponseUtils.buildSuccess(true) ; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | <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> |
| | |
| | | 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; |
| | | |
| | |
| | | @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 { |
| | |
| | | SpringApplication.run(PipIrrSellApplication.class, args); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | @RequiredArgsConstructor |
| | | public class ClientCtrl { |
| | | private final ClientSv clientSv; |
| | | private final AliyunSmsSv aliyunSmsSv; |
| | | //private final RedisUtils redisUtils; |
| | | |
| | | /** |
| | | * 获取农户列表 |
| | |
| | | } |
| | | 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); |
| | | } |
| | | } |
| | |
| | | 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()); |
| | |
| | | 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; |
| | | } |
| | |
| | | */ |
| | | 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; |
New file |
| | |
| | | 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; |
| | | } |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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 #连接池中的最小空闲连接 |