wx_verify_code_sms.lsc 2.36 KB
<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:ns1="leaf.application.action" xmlns:p="uncertain.proc" xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
    <a:init-procedure>
<s:server-script import="app/app_login_check.js"><![CDATA[
    importPackage(Packages.com.hand.hls.hlcm.emay);
function send_sms() {
    try {
        if($ctx.parameter.mobile) {
            // step2 生成短信
            var verify_code_sms_bm = $bm('wx.WX100.wx_verify_code_sms');
            verify_code_sms_bm.insert({
                phone_number: $ctx.parameter.mobile
            });
            var sms_list_bm = $bm('sys.SYS401.sys_sms_list');
            var md5_check_id = $ctx.parameter.md5_check_id;
            if ($ctx.parameter.sms_id) {
                var sms_list_result = sms_list_bm.queryAsMap({
                    sms_id: $ctx.parameter.sms_id
                });
                var sms_list_records = sms_list_result.getChildren();
                for (var i = 0; i < sms_list_records.length; i++) {
                    var Phones = sms_list_records[i].phone_number;
                    var content = sms_list_records[i].text;
                    var sms_id = sms_list_records[i].sms_id;
                    try {
                        var example = new Example();
                        var result = example.setSingleSms(content, Phones);
                        var req_response = result.toString();
                    } catch (e) {
                        println("抛出异常:" + e);
                    }

                    // 发送短信后,逻辑处理
                    $bm('nt.sys_sms_list').update({
                        sms_id: sms_id,
                        req_response: req_response
                    });
                }
            }
            $ctx.parameter.return_status = '0';
            $ctx.parameter.return_message = '执行成功';
        }
    } catch (e) {
        $ctx.success = "true";
        $ctx.parameter.return_status = '1';
        $ctx.parameter.return_message = String(e);
    }
    var result = {
        code: $ctx.parameter.return_status,
        message: $ctx.parameter.return_message,
        checkId:md5_check_id
    };
    $ctx.parameter.json = JSON.stringify(result);

}
send_sms();
]]></s:server-script>
</a:init-procedure>
<a:service-output output="/parameter/@json"/>
    </a:service>