Browse Source

Merge branch 'master' of http://git.ds-bay.com/project/kmall-haikong

lhm 3 years ago
parent
commit
dc3355d211

+ 46 - 0
kmall-admin/src/main/java/com/kmall/admin/controller/aliyunsms/SendSmsRecordController.java

@@ -0,0 +1,46 @@
+package com.kmall.admin.controller.aliyunsms;
+
+import java.util.List;
+import java.util.Map;
+
+import com.kmall.admin.entity.aliyunsms.SendSmsRecord;
+import com.kmall.admin.service.aliyunsms.SendSmsRecordService;
+import com.kmall.common.utils.PageUtils;
+import com.kmall.common.utils.Query;
+import com.kmall.common.utils.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+
+/**
+ * 短信发送记录表Controller
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2021-12-15 15:04:55
+ */
+@Controller
+@RequestMapping("sendsmsrecord")
+public class SendSmsRecordController {
+    @Autowired
+    private SendSmsRecordService sendSmsRecordService;
+
+    /**
+     * 查看列表
+     */
+    @RequestMapping("/list")
+    @ResponseBody
+    public R list(@RequestParam Map<String, Object> params) {
+        //查询列表数据
+        Query query = new Query(params);
+
+        List<SendSmsRecord> sendSmsRecordList = sendSmsRecordService.queryList(query);
+        int total = sendSmsRecordService.queryTotal(query);
+
+        PageUtils pageUtil = new PageUtils(sendSmsRecordList, total, query.getLimit(), query.getPage());
+
+        return R.ok().put("page", pageUtil);
+    }
+
+}

+ 7 - 0
kmall-admin/src/main/java/com/kmall/admin/dao/aliyunsms/SendSmsRecordDao.java

@@ -21,4 +21,11 @@ public interface SendSmsRecordDao extends BaseDao<SendSmsRecord> {
      */
     List<SendSmsRecord> queryBySendStatus(@Param("sendStatus") Integer sendStatus);
 
+    /**
+     * 根据订单编号查询
+     *
+     * @param orderSn 订单编号
+     */
+    SendSmsRecord queryByOrderSn(@Param("orderSn") String orderSn);
+
 }

+ 3 - 3
kmall-admin/src/main/java/com/kmall/admin/fromcomm/controller/SysLoginController.java

@@ -84,9 +84,9 @@ public class SysLoginController {
         LOGGER.info("获取验证码:"+kaptcha);
         System.out.println(kaptcha);
         JedisUtil.del(Constants.KAPTCHA_SESSION_KEY);
-//        if (!captcha.equalsIgnoreCase(kaptcha)) {
-//            return R.error("验证码不正确");
-//        }
+        if (captcha.equalsIgnoreCase(kaptcha)) {
+            return R.error("验证码不正确");
+        }
 
         try {
             Subject subject = ShiroUtils.getSubject();

+ 17 - 0
kmall-admin/src/main/java/com/kmall/admin/service/aliyunsms/SendSmsRecordService.java

@@ -4,6 +4,7 @@ import com.kmall.admin.entity.OrderProcessRecordHkNewEntity;
 import com.kmall.admin.entity.aliyunsms.SendSmsRecord;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 短信发送记录表Service
@@ -32,4 +33,20 @@ public interface SendSmsRecordService {
      */
     void reSendFailMsg();
 
+    /**
+     * 分页查询
+     *
+     * @param map 参数
+     * @return list
+     */
+    List<SendSmsRecord> queryList(Map<String, Object> map);
+
+    /**
+     * 分页统计总数
+     *
+     * @param map 参数
+     * @return 总数
+     */
+    int queryTotal(Map<String, Object> map);
+
 }

+ 19 - 6
kmall-admin/src/main/java/com/kmall/admin/service/aliyunsms/impl/SendSmsRecordServiceImpl.java

@@ -54,6 +54,14 @@ public class SendSmsRecordServiceImpl implements SendSmsRecordService {
                         throw new Exception(errorInfo);
                     }
 
+                    // 查询表里是否有对应订单号的发送记录,避免重复发送短信
+                    SendSmsRecord queryRecord = sendSmsRecordDao.queryByOrderSn(entity.getOrderSn());
+
+                    if (queryRecord != null) {
+                        logger.info("订单编号:" + entity.getOrderSn() + "的短信发送记录已存在!");
+                        continue;
+                    }
+
                     // 发送短信
                     Map<String, Object> params = new HashMap<>(2);
                     params.put("phoneNumbers", orderEntity.getPayMobile());
@@ -96,12 +104,7 @@ public class SendSmsRecordServiceImpl implements SendSmsRecordService {
                 // 发送短信
                 Map<String, Object> params = new HashMap<>(2);
                 params.put("phoneNumbers", smsRecord.getPhoneNumbers());
-                // Map<String, Object> resp = SMSUtils.sendSms(aliSMSProperties, params);
-                Map<String, Object> resp = new HashMap<>();
-                resp.put("code", "1");
-                resp.put("message", "sdfs1");
-                resp.put("bizId", "asdasd");
-                resp.put("requestId", "asd");
+                Map<String, Object> resp = SMSUtils.sendSms(aliSMSProperties, params);
 
                 // 添加参数
                 if ("OK".equals(resp.get("code").toString())) {
@@ -125,4 +128,14 @@ public class SendSmsRecordServiceImpl implements SendSmsRecordService {
         }
     }
 
+    @Override
+    public List<SendSmsRecord> queryList(Map<String, Object> map) {
+        return sendSmsRecordDao.queryList(map);
+    }
+
+    @Override
+    public int queryTotal(Map<String, Object> map) {
+        return sendSmsRecordDao.queryTotal(map);
+    }
+
 }

+ 1 - 2
kmall-admin/src/main/java/com/kmall/admin/task/AliyunSmsTask.java

@@ -21,7 +21,6 @@ public class AliyunSmsTask {
      */
     @Scheduled(fixedRate = 10000)
     public void reSendFailMsg() {
-       // todo,测试屏蔽
-       // sendSmsRecordService.reSendFailMsg();
+       sendSmsRecordService.reSendFailMsg();
     }
 }

+ 63 - 0
kmall-admin/src/main/resources/mybatis/mapper/aliyunsms/SendSmsRecordDao.xml

@@ -16,6 +16,62 @@
         <result property="updateTime" column="update_time"/>
     </resultMap>
 
+    <select id="queryList" resultType="com.kmall.admin.entity.aliyunsms.SendSmsRecord">
+        select
+        `id`,
+        `order_sn`,
+        `clear_no`,
+        `phone_numbers`,
+        `send_status`,
+        `send_fail_msg`,
+        `request_id`,
+        `biz_id`,
+        `create_time`,
+        `update_time`
+        from send_sms_record
+        WHERE 1=1
+        <if test="orderSn != null and orderSn.trim() != ''">
+            AND `order_sn` LIKE concat(#{orderSn},'%')
+        </if>
+        <if test="clearNo != null and clearNo.trim() != ''">
+            AND `clear_no` LIKE concat(#{clearNo},'%')
+        </if>
+        <if test="phoneNumbers != null and phoneNumbers.trim() != ''">
+            AND `phone_numbers` LIKE concat(#{phoneNumbers},'%')
+        </if>
+        <if test="sendStatus != null and sendStatus != ''">
+            AND `send_status` = #{sendStatus}
+        </if>
+        <choose>
+            <when test="sidx != null and sidx.trim() != ''">
+                order by ${sidx} ${order}
+            </when>
+            <otherwise>
+                order by id desc
+            </otherwise>
+        </choose>
+        <if test="offset != null and limit != null">
+            limit #{offset}, #{limit}
+        </if>
+    </select>
+
+    <select id="queryTotal" resultType="int">
+        select count(*) from send_sms_record
+        WHERE 1=1
+        <if test="orderSn != null and orderSn.trim() != ''">
+            AND `order_sn` LIKE concat(#{orderSn},'%')
+        </if>
+        <if test="clearNo != null and clearNo.trim() != ''">
+            AND `clear_no` LIKE concat(#{clearNo},'%')
+        </if>
+        <if test="phoneNumbers != null and phoneNumbers.trim() != ''">
+            AND `phone_numbers` LIKE concat(#{phoneNumbers},'%')
+        </if>
+        <if test="sendStatus != null and sendStatus != ''">
+            AND `send_status` = #{sendStatus}
+        </if>
+    </select>
+
     <insert id="save" parameterType="com.kmall.admin.entity.aliyunsms.SendSmsRecord" useGeneratedKeys="true" keyProperty="id">
         insert into send_sms_record
             (
@@ -66,4 +122,11 @@
 		where `send_status` = #{sendStatus}
 	</select>
 
+    <select id="queryByOrderSn" resultMap="sendSmsRecordMap">
+        select
+            `id`,`order_sn`,`clear_no`,`phone_numbers`,`send_status`,`send_fail_msg`,`request_id`,`biz_id`
+        from send_sms_record
+        where `order_sn` = #{orderSn}
+    </select>
+
 </mapper>

+ 87 - 0
kmall-admin/src/main/webapp/WEB-INF/page/aliyunsms/sendsmsrecord.html

@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>短信发送记录表</title>
+    #parse("sys/header.html")
+</head>
+<body>
+<div id="rrapp" v-cloak>
+	<div v-show="showList">
+        <Row :gutter="16">
+            <div class="search-group">
+                <i-col span="4">
+                    <i-input v-model="q.orderSn" @on-enter="query" placeholder="订单编号"/>
+                </i-col>
+                <i-col span="4">
+                    <i-input v-model="q.clearNo" @on-enter="query" placeholder="清单编号"/>
+                </i-col>
+                <i-col span="4">
+                    <i-input v-model="q.phoneNumbers" @on-enter="query" placeholder="手机号码"/>
+                </i-col>
+                <i-col span="4">
+                    <i-select name="sendStatus" v-model="q.sendStatus" @change="getSendStatusSelect" placeholder="发送状态">
+                        <i-option :value="1">成功</i-option>
+                        <i-option :value="0">失败</i-option>
+                    </i-select>
+                </i-col>
+                <i-button @click="query">查询</i-button>
+                <i-button @click="reloadSearch">重置</i-button>
+            </div>
+<!--            <div class="buttons-group">-->
+<!--                #if($shiro.hasPermission("sendsmsrecord:save"))-->
+<!--                <i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>-->
+<!--                #end-->
+<!--                #if($shiro.hasPermission("sendsmsrecord:update"))-->
+<!--                <i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>-->
+<!--                #end-->
+<!--                #if($shiro.hasPermission("sendsmsrecord:delete"))-->
+<!--                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>-->
+<!--                #end-->
+<!--            </div>-->
+        </Row>
+	    <table id="jqGrid"></table>
+	    <div id="jqGridPager"></div>
+    </div>
+
+    <Card v-show="!showList">
+        <p slot="title">{{title}}</p>
+		<i-form ref="formValidate" :model="sendSmsRecord" :rules="ruleValidate" :label-width="80">
+            <Form-item label="订单编号" prop="orderSn">
+                <i-input v-model="sendSmsRecord.orderSn" placeholder="订单编号"/>
+            </Form-item>
+            <Form-item label="清单编号" prop="clearNo">
+                <i-input v-model="sendSmsRecord.clearNo" placeholder="清单编号"/>
+            </Form-item>
+            <Form-item label="手机号码,多个以英文逗号分隔" prop="phoneNumbers">
+                <i-input v-model="sendSmsRecord.phoneNumbers" placeholder="手机号码,多个以英文逗号分隔"/>
+            </Form-item>
+            <Form-item label="发送状态,0:发送失败,1:发送成功" prop="sendStatus">
+                <i-input v-model="sendSmsRecord.sendStatus" placeholder="发送状态,0:发送失败,1:发送成功"/>
+            </Form-item>
+            <Form-item label="发送失败原因" prop="sendFailMsg">
+                <i-input v-model="sendSmsRecord.sendFailMsg" placeholder="发送失败原因"/>
+            </Form-item>
+            <Form-item label="请求id-阿里云短信接口返回" prop="requestId">
+                <i-input v-model="sendSmsRecord.requestId" placeholder="请求id-阿里云短信接口返回"/>
+            </Form-item>
+            <Form-item label="回执id-阿里云短信接口返回" prop="bizId">
+                <i-input v-model="sendSmsRecord.bizId" placeholder="回执id-阿里云短信接口返回"/>
+            </Form-item>
+            <Form-item label="创建时间" prop="createTime">
+                <i-input v-model="sendSmsRecord.createTime" placeholder="创建时间"/>
+            </Form-item>
+            <Form-item label="更新时间" prop="updateTime">
+                <i-input v-model="sendSmsRecord.updateTime" placeholder="更新时间"/>
+            </Form-item>
+            <Form-item>
+                <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
+                <i-button type="warning" @click="reload" style="margin-left: 8px"/>返回</i-button>
+                <i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
+            </Form-item>
+        </i-form>
+	</Card>
+</div>
+
+<script src="${rc.contextPath}/js/aliyunsms/sendsmsrecord.js?_${date.systemTime}"></script>
+</body>
+</html>

+ 167 - 0
kmall-admin/src/main/webapp/js/aliyunsms/sendsmsrecord.js

@@ -0,0 +1,167 @@
+$(function () {
+    $("#jqGrid").jqGrid({
+        url: '../sendsmsrecord/list',
+        datatype: "json",
+        colModel: [
+			{label: 'id', name: 'id', index: 'id', key: true, hidden: true},
+			{label: '订单编号', name: 'orderSn', index: 'order_sn', width: 100},
+			{label: '清单编号', name: 'clearNo', index: 'clear_no', width: 100},
+			{label: '手机号码', name: 'phoneNumbers', index: 'phone_numbers', width: 100},
+			{label: '发送状态', name: 'sendStatus', index: 'send_status', width: 80,
+				formatter: function (value) {
+					if (value == 0) {
+						return "<span class=''>失败</span>";
+					} else {
+						return "<span class='success'>成功</span>";
+					}
+				}},
+			{label: '发送失败原因', name: 'sendFailMsg', index: 'send_fail_msg', width: 100},
+			{label: '请求id', name: 'requestId', index: 'request_id', width: 80},
+			{label: '回执id', name: 'bizId', index: 'biz_id', width: 80}
+			],
+		viewrecords: true,
+        height: 550,
+        rowNum: 10,
+        rowList: [10, 30, 50],
+        rownumbers: true,
+        rownumWidth: 25,
+        autowidth: true,
+        multiselect: true,
+        pager: "#jqGridPager",
+        jsonReader: {
+            root: "page.list",
+            page: "page.currPage",
+            total: "page.totalPage",
+            records: "page.totalCount"
+        },
+        prmNames: {
+            page: "page",
+            rows: "limit",
+            order: "order"
+        },
+        gridComplete: function () {
+            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
+        }
+    });
+});
+
+let vm = new Vue({
+	el: '#rrapp',
+	data: {
+        showList: true,
+        title: null,
+		sendSmsRecord: {},
+		ruleValidate: {
+			name: [
+				{required: true, message: '名称不能为空', trigger: 'blur'}
+			]
+		},
+		q: {
+			orderSn: '',
+			clearNo: '',
+			phoneNumbers: '',
+			sendStatus: ''
+		}
+	},
+	methods: {
+		query: function () {
+			vm.reload();
+		},
+		add: function () {
+			vm.showList = false;
+			vm.title = "新增";
+			vm.sendSmsRecord = {};
+		},
+		update: function (event) {
+            let id = getSelectedRow();
+			if (id == null) {
+				return;
+			}
+			vm.showList = false;
+            vm.title = "修改";
+
+            vm.getInfo(id)
+		},
+		saveOrUpdate: function (event) {
+            let url = vm.sendSmsRecord.id == null ? "../sendsmsrecord/save" : "../sendsmsrecord/update";
+			$.ajax({
+				type: "POST",
+			    url: url,
+			    contentType: "application/json",
+			    data: JSON.stringify(vm.sendSmsRecord),
+                success: function (r) {
+                    if (r.code === 0) {
+                        alert('操作成功', function (index) {
+                            vm.reload();
+                        });
+                    } else {
+                        alert(r.msg);
+                    }
+                }
+			});
+		},
+		del: function (event) {
+            let ids = getSelectedRows();
+			if (ids == null){
+				return;
+			}
+
+			confirm('确定要删除选中的记录?', function () {
+				$.ajax({
+					type: "POST",
+				    url: "../sendsmsrecord/delete",
+				    contentType: "application/json",
+				    data: JSON.stringify(ids),
+				    success: function (r) {
+						if (r.code == 0) {
+							alert('操作成功', function (index) {
+								$("#jqGrid").trigger("reloadGrid");
+							});
+						} else {
+							alert(r.msg);
+						}
+					}
+				});
+			});
+		},
+		getInfo: function(id){
+			$.get("../sendsmsrecord/info/"+id, function (r) {
+                vm.sendSmsRecord = r.sendSmsRecord;
+            });
+		},
+        reloadSearch: function() {
+            vm.q = {
+				orderSn: '',
+				clearNo: '',
+				phoneNumbers: '',
+				sendStatus: ''
+            }
+            vm.reload();
+		},
+		reload: function (event) {
+			vm.showList = true;
+            let page = $("#jqGrid").jqGrid('getGridParam', 'page');
+			$("#jqGrid").jqGrid('setGridParam', {
+                postData: {
+                	'orderSn': vm.q.orderSn,
+					'clearNo': vm.q.clearNo,
+					'phoneNumbers': vm.q.phoneNumbers,
+					'sendStatus': vm.q.sendStatus
+				},
+                page: page
+            }).trigger("reloadGrid");
+            vm.handleReset('formValidate');
+		},
+        handleSubmit: function (name) {
+            handleSubmitValidate(this, name, function () {
+                vm.saveOrUpdate()
+            });
+        },
+        handleReset: function (name) {
+            handleResetForm(this, name);
+        },
+		getSendStatusSelect: function (value) {
+			vm.q.sendStatus = value;
+		}
+	}
+});

+ 4 - 0
sql/init/sys_table.sql

@@ -2754,3 +2754,7 @@ SET FOREIGN_KEY_CHECKS = 1;
 
 
 SET FOREIGN_KEY_CHECKS = 1;
+
+
+-- 添加菜单SQL
+INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `status`) VALUES ('942','短信发送记录','aliyunsms/sendsmsrecord.html',NULL,'1','fa fa-file-code-o','6','0');