首页 > 其他分享 >微信商家转账零钱优化版

微信商家转账零钱优化版

时间:2023-06-27 15:13:33浏览次数:38  
标签:转账 status return no 微信 batch 零钱 num out

配置文件

<?php
return [
    'abc'   => [
        "merchant_id"                    => env('POINT_ABC_MERCHANTID'),
        "app_id"                         => env('POINT_ABC_APP_ID'),
        "merchant_private_key_file_path" => sprintf(
            "file://%s/storage/keys/apiclient_ABC_key.pem",  # 证书的绝对路径
            BASE_PATH
        ),
        "platform_certificate_file_Path" => sprintf(
            "file://%s/storage/keys/platform_apiclient_ABC_key.pem",  
            BASE_PATH
        ),
        "merchant_certificate_serial"    => env('POINT_ABC_SERIAL')
    ],
    'opq' => [
        "merchant_id"                    => env('POINT_OPQ_MERCHANTID'),
        "app_id"                         => env('POINT_OPQ_APP_ID'),
        "merchant_private_key_file_path" => sprintf(
            "file://%s/storage/keys/apiclient_OPQ_key.pem",
            BASE_PATH
        ),
        "platform_certificate_file_Path" => sprintf(
            "file://%s/storage/keys/platform_apiclient_OPQ_key.pem",
            BASE_PATH
        ),
        "merchant_certificate_serial"    => env('POINT_OPQ_SERIAL'),
    ]
];

 

 

微信支付类

<?php


namespace App\Logic\Point;


use App\Helper\Helper;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Utils\ApplicationContext;
use WeChatPay\Builder;
use WeChatPay\Crypto\Rsa;
use WeChatPay\Util\PemUtil;

class WeChatPayUtils
{

    private $merchantId;
    private $appId;
    private $merchantCertificateSerial;
    private $merchantPrivateKeyFilePath;
    private $platformCertificateFilePath;

    /**
     * 初始化
     * @param string $name
     * @return WeChatPayUtils
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    public static function getInsance($name = 'abc')
    {
        $config = ApplicationContext::getContainer()
            ->get(ConfigInterface::class)
            ->get('pay');

        $o                              = new self();
        $o->merchantId                  = $config[$name]['merchant_id'];
        $o->appId                       = $config[$name]['app_id'];
        $o->merchantCertificateSerial   = $config[$name]['merchant_certificate_serial'];
        $o->merchantPrivateKeyFilePath  = $config[$name]['merchant_private_key_file_path'];
        $o->platformCertificateFilePath = $config[$name]['platform_certificate_file_Path'];

        return $o;
    }

    /**
     * 构造一个 APIv3 客户端实例
     * @return \WeChatPay\BuilderChainable
     */
    public function getBuilder()
    {
        # 从本地文件中加载「商户API私钥」,「商户API私钥」会用来生成请求的签名
        $merchantPrivateKeyInstance = Rsa::from($this->merchantPrivateKeyFilePath, Rsa::KEY_TYPE_PRIVATE);

        # 从本地文件中加载「微信支付平台证书」,用来验证微信支付应答的签名
        $platformPublicKeyInstance = Rsa::from($this->platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);

        # 从「微信支付平台证书」中获取「证书序列号」
        $platformCertificateSerial = PemUtil::parseCertificateSerialNo($this->platformCertificateFilePath);

        // 构造一个 APIv3 客户端实例
        return Builder::factory([
            'mchid'      => $this->merchantId,                # 商户号
            'serial'     => $this->merchantCertificateSerial, # 「商户API证书」的「证书序列号」
            'privateKey' => $merchantPrivateKeyInstance,      # 从本地文件中加载「商户API私钥」,「商户API私钥」会用来生成请求的签名
            'certs'      => [
                $platformCertificateSerial => $platformPublicKeyInstance,
            ],
        ]);
    }

    public function getEncryptor($realName)
    {
        $platformPublicKeyInstance = Rsa::from($this->platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);

        return Rsa::encrypt($realName, $platformPublicKeyInstance);
    }


    /**
     * 转账
     * @param $PayData
     * @param $url
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function payMent($PayData, $url)
    {
        $PayData['json']['appid'] = $this->appId;

        # 实名制
        $PayData['headers'] = [
            'Wechatpay-Serial' => $this->merchantCertificateSerial,   # 平台证书序列号
        ];

        $logger = Helper::getLogger();
        $logger->error("wx_pay_send_data", [
            'info' => json_encode($PayData, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
        ]);
        return self::getBuilder()->chain($url)->post($PayData);
    }


    /**
     * 查询订单批次详情
     * @param array $query
     * @param string $url
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function getPointCheckWXPayDetail(array $query, string $url)
    {
        return self::getBuilder()->chain($url)->get($query);
    }


    /**
     * 查询详情
     * @param string $url
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function getBatchDetailEveryLast(string $url)
    {
        return self::getBuilder()->chain($url)->get();
    }
}

 

逻辑层

class WeChatPay
{
    /**
     * @Inject
     * @var PointExchangeOrderRepository
     */
    private $order;

    /**
     * 支付转账
     * @param $batch_num
     * @return string[]
     * @throws \Hyperf\Mongodb\Exception\MongoDBException
     */
    public function payment($batch_num)
    {
        $Data = $this->order->downLoadFinances($batch_num);

        $Collection = 'point-log' . date('Y-m-d');

        $mongoDb = Helper::getMongoClient('point');

        if ($Data) {
            # 获取总额度
            $columns = array_column($Data, 'grant_money');

            $TotalMoney = array_sum($columns);

            $TotalCount = count($columns);

            $typeName = $Data[0]['user_type'] == 1 ? 'youyao' : 'youjiayi';

            # 初始化 支付类
            $instance = WeChatPayUtils::getInsance($typeName);

            $PayData ['json']['out_batch_no'] = $Data[0]['batch_num'];

            $PayData ['json']['batch_name'] = '批次名称';

            $PayData ['json']['batch_remark'] = '优驿医药科技(上海)有限公司';

            $PayData ['json']['total_amount'] = (int)bcmul((string)$TotalMoney, '100', 2);

            $PayData ['json']['total_num'] = (int)$TotalCount;

            $PointReviewProcess = [];

            foreach ($Data as $k => $datum) {
                if (!$datum['real_name']) {
                    return ['status'=>'warning','msg'=>'批次内有尚未完成实名制的用户'];
                }

                # 验证转账金额 次数
                $resRedisMoney = $this->checkUserTYperPaymentInfoRedis(
                    $datum['uid'],
                    $datum['user_type'],
                    $datum['grant_money']
                );

                if ($resRedisMoney['status'] == 'warning') {
                    return $resRedisMoney;
                }

                # 构建发送数据
                $PayData['json']['transfer_detail_list'][$k] = [

                        'out_detail_no'     => $datum['order_num'],
                        # 转账金额
                        'transfer_amount'   => (int) bcmul((string) $datum['grant_money'], '100', 2),

                        'transfer_remark'   => '优驿医药科技(上海)有限公司',

                        'openid'            => $datum['user_openid'],

                        'real_name'         => $instance->getEncryptor($datum['real_name']),    # 收款人姓名    大于2000必须实名制
                ];

                # 记录流程
                $PointReviewProcess[] = [
                    'order_num'      => $datum['order_num'],
                    'status'         => OrderStatus::POINTPAYING,
                    'operator_id'    => Db::raw("null"),
                    'operation_desc' => '转账中',
                    'created_at'     => date('Y-m-d H:i:s'),
                ];
            }

            try {
                $resp = $instance->payMent($PayData, "v3/transfer/batches");

                # 推送队列
                $wechatPayDelayQueue = new WechatPayDelayQueue();
                $wechatPayDelayQueue->setBatchNum($Data[0]['batch_num']);
                $nsq = make(Nsq::class);
                TaskManageLogic::create(0, $wechatPayDelayQueue, "wechat_pay_delay_queue")->push(60, $nsq);

                $body = (string)$resp->getBody();

                $this->order->updateBatch($batch_num, json_decode($body, true));

                PointReviewProcess::insert($PointReviewProcess);

                $mongoDb->insert($Collection, [
                    'cr_dt'         => date('Y-m-d H:i:s'),
                    'batch_num'     => $Data[0]['batch_num'],
                    'status'        => 'normal',
                    'response_code' => $resp->getStatusCode(),
                    'response_body' => $body,
                    'send_data'     => json_encode($PayData, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
                ]);

                return ['status' => 'success', 'msg' => ''];
            } catch (\Exception $e) {
                // 进行错误处理
                $Message = $e->getMessage();

                $code = $Phrase = $Body = $TraceAsString = '';

                if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
                    $r      = $e->getResponse();
                    $code   = $r->getStatusCode();
                    $Phrase = $r->getReasonPhrase();
                    $Body   = $r->getBody();
                }

                $mongoDb->insert($Collection, [
                    'cr_dt'         => date('Y-m-d H:i:s'),
                    'batch_num'     => $Data[0]['batch_num'],
                    'status'        => 'error',
                    'response_code' => $code . ' -- ' . $Phrase,
                    'response_body' => $Body . ' MSG:' . $Message,
                    'send_data'     => json_encode($PayData, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
                ]);
            }

            $msg = json_decode((string)$Body, true);
            return ['status' => 'warning', 'msg' => $msg['message']];
        } else {
            return ['status' => 'warning', 'msg' => '数据不存在'];
        }
    }


    /**
     * @param $uid
     * @param $user_type
     * @param $money
     * @return string[]
     */
    private function checkUserTYperPaymentInfoRedis($uid, $user_type, $money)
    {
        $containerRedis = ApplicationContext::getContainer();

        $redis = $containerRedis->get(PointPaymentRedis::class);

        $nextDay = strtotime('+1 day', strtotime(date('Y-m-d')));

        $ttl = $nextDay - time();

        $TotalMoneyTypeKey = 'point_payment:total_money:t_:' . $user_type . ':' . date("Ymd");  # 账户总额度

        $TotalNumTypeKey = 'point_payment:total_num:t_' . $user_type . ':' . date("Ymd");      # 账户总次数

        $UserMoneyTypeKey = 'point_payment:total_money:user' . $uid . $user_type . ':' . date("Ymd");    # 用户总额度

        $UserNumTypeKey = 'point_payment:total_num:user:' . $uid . $user_type . ':' . date("Ymd");        # 用户总次数


        $TotalNumTypeExc = $redis->get($TotalNumTypeKey);

        $UserNumTypeKeyExc = $redis->get($UserNumTypeKey);

        $TotalMoneyTypeExc = $redis->get($TotalMoneyTypeKey);

        $UserMoneyTypeExc = $redis->get($UserMoneyTypeKey);


        $TotalNumTypeRds = $TotalNumTypeExc ? $TotalNumTypeExc : 0;

        $UserNumTypeKeyRds = $UserNumTypeKeyExc ? $UserNumTypeKeyExc : 0;

        $TotalMoneyTypeRds = $TotalMoneyTypeExc ? $TotalMoneyTypeExc : 0;

        $UserMoneyTypeRds = $UserMoneyTypeExc ? $UserMoneyTypeExc : 0;

        # 账户当日转账总次数
        if (++$TotalNumTypeRds > env('GRANT_TOTALNUM_USER_TYPE')) {
            return ['status' => 'warning', 'msg' => '该账户已到达当日转账次数上限'];
        } else {
            # 当前用户转账总次数
            if (++$UserNumTypeKeyRds <= env('GRANT_NUM_USER')) {
                # 检查当日账户转账总金额
                if (($TotalMoneyTypeRds + $money) <= env('GRANT_TOTALMONEY_USER_TYPE')) {
                    # 检查当日用户转账总金额
                    if (($UserMoneyTypeRds + $money) <= env('GRANT_TOTALMONEY_USER')) {
                        # 设置缓存
                        # 账户总次数
                        //                        $TotalNumTypeRds ++;
                        $redis->set($TotalNumTypeKey, $TotalNumTypeRds);
                        $redis->expire($TotalNumTypeKey, $ttl);

                        # 用户总次数
                        //                        $UserNumTypeKeyRds ++;
                        $redis->set($UserNumTypeKey, $UserNumTypeKeyRds);
                        $redis->expire($UserNumTypeKey, $ttl);

                        # 账户总额度
                        $TotalMoneyTypeRds += $money;
                        $redis->set($TotalMoneyTypeKey, $TotalMoneyTypeRds);
                        $redis->expire($TotalMoneyTypeKey, $ttl);

                        # 用户总金额
                        $UserMoneyTypeRds += $money;
                        $redis->set($UserMoneyTypeKey, $UserMoneyTypeRds);
                        $redis->expire($UserMoneyTypeKey, $ttl);

                        return ['status' => 'success', 'msg' => ''];
                    } else {
                        return ['status' => 'warning', 'msg' => '该用户已到达当日转账总额度上限'];
                    }
                } else {
                    return ['status' => 'warning', 'msg' => '该账户已到达当日转账总额度上限'];
                }
            } else {
                return ['status' => 'warning', 'msg' => '该批次中用户超出当日转账次数,请择日重新提交转账申请!'];
            }
        }
    }


    /**
     * 查并确认订单
     * @throws \Hyperf\Mongodb\Exception\MongoDBException
     */
    public function pointCheckWXPayDetail(string $BatchNum)
    {
        $Data = $this->order->getPointReviewBatch($BatchNum);
        if (!$Data) {
            return json_encode(
                ['status'=>'fail', 'msg'=>'该批次单号:'.$BatchNum.' 不存在'],
                JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES
            );
        }

        try {
            $again = false;
            foreach ($Data as $datum) {
                $batch_num = $datum['batch_num'];

                $order_num = $datum['order_num'];

                $batch_id = $datum['batch_id'];

                $Collection = 'point-check-log' . date('Y-m-d');

                $mongoDb = Helper::getMongoClient('point');

                $typeName = $datum['user_type'] == 1 ? 'youyao' : 'youjiayi';

                # 初始化 支付类
                $instance = WeChatPayUtils::getInsance($typeName);

                $url = 'v3/transfer/batches/out-batch-no/' . $batch_num;

                $urlArr = [
                    'need_query_detail' => true,
                    'limit'             => 100,
                    'detail_status'     => 'ALL',
                ];

                $resp = $instance->getPointCheckWXPayDetail(['query' => $urlArr], $url);

                $body = (string)$resp->getBody();

                $bodyArr = json_decode($body, true);

                if ($bodyArr && $bodyArr['transfer_detail_list']) {
                    $PointReviewProcess = [];

                    Db::connection('qa')->beginTransaction();

                    foreach ($bodyArr['transfer_detail_list'] as $everyDetail) {
                        if ($everyDetail['detail_status'] === 'FAIL') {
                            # 查询 详细中每一份订单
                            $this->getBatchDetailEveryLast(
                                $typeName,
                                $everyDetail['out_detail_no'],
                                $bodyArr['transfer_batch']['out_batch_no']
                            );

                        } elseif ($everyDetail['detail_status'] === 'WAIT_PAY' ||
                            $everyDetail['detail_status'] === 'PROCESSING') {
                            # 告诉sdc 需要再次查询
                            $again = 'again';
                        } elseif ($everyDetail['detail_status'] === 'SUCCESS') {
                            # 更新转账成功
                            $this->order->updatePointReviewBatchByOrderNumSuccess(
                                $bodyArr['transfer_batch']['out_batch_no'],
                                $everyDetail['out_detail_no']
                            );

                            # 记录流程
                            $PointReviewProcess[] = [
                                'order_num'      => $everyDetail['out_detail_no'],
                                'status'         => OrderStatus::POINTPAYPASS,
                                'operator_id'    => Db::raw("null"),
                                'operation_desc' => '转账成功',
                                'created_at'     => date('Y-m-d H:i:s'),
                            ];

                            $mongoDb->insert($Collection, [
                                'batch_num'     => $bodyArr['transfer_batch']['out_batch_no'],
                                'cr_dt'         => date('Y-m-d H:i:s'),
                                'status'        => 'normal',
                                'response_code' => $resp->getStatusCode(),
                                'response_body' => $body,
                                'send_data'     => sprintf(
                                    "batch_num:%s order_num%s batch_id%s",
                                    $batch_num,
                                    $order_num,
                                    $batch_id
                                ),
                            ]);
                        }
                    }

                    if (count($PointReviewProcess) > 0) {
                        PointReviewProcess::insert($PointReviewProcess);
                    }
                    Db::connection('qa')->commit();
                }
            }
            return json_encode(
                ['status'=>$again, 'msg'=>''],
                JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES
            );

        } catch (\Exception $e) {
            // 进行错误处理
            echo $e->getMessage(), PHP_EOL;

            $Message = $e->getMessage();

            $code = $Phrase = $Body = $TraceAsString = '';

            if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
                $r      = $e->getResponse();
                $code   = $r->getStatusCode();
                $Phrase = $r->getReasonPhrase();
                $Body   = $r->getBody();
            }

            $mongoDb->insert($Collection, [
                'cr_dt'         => date('Y-m-d H:i:s'),
                'status'        => 'error',
                'response_code' => $code . ' -- ' . $Phrase,
                'response_body' => $Body . ' MSG:' . $Message,
                'send_data'     => '',
            ]);

            Db::connection('qa')->rollBack();
        }
    }


    /**
     * 查询批次内每一份订单失败原因
     * @param array $transfer_detail_list
     * @throws \Hyperf\Mongodb\Exception\MongoDBException
     */
    private function getBatchDetailEveryLast($typeName, $out_detail_no, $out_batch_no)
    {
        $Collection = 'point-every-last-log' . date('Y-m-d');

        $mongoDb = Helper::getMongoClient('point');

        $send_data = 'batch_num:'.$out_batch_no.' order_num'. $out_detail_no;

        try {
                $url = 'v3/transfer/batches/out-batch-no/'.$out_batch_no.'/details/out-detail-no/'.$out_detail_no;

                # 初始化 支付类
                $instance = WeChatPayUtils::getInsance($typeName);

                $resp = $instance->getBatchDetailEveryLast($url);

                $body = (string)$resp->getBody();

                $bodyArr = json_decode($body, true);

                $this->order->updatePointReviewBatchByOrderNumFail(
                    $out_batch_no,
                    $out_detail_no,
                    $bodyArr['fail_reason'] ?? ''
                );

                # 记录流程
                $PointReviewProcess = [
                    'order_num'      => $out_detail_no,
                    'status'         => OrderStatus::POINTPAYFAIL,
                    'operator_id'    => Db::raw("null"),
                    'operation_desc' => '转账失败:'. $bodyArr['fail_reason'],
                    'created_at'     => date('Y-m-d H:i:s'),
                ];
                PointReviewProcess::insert($PointReviewProcess);

                # 返积分   $order, $money_point, $service_point, $goods_num, $goods_id
//                $this->order->rejectByOrderId(
//                    $info,
//                    ($orderDetailInfo['money_point'] * $orderDetailInfo['goods_num']),
//                    ($orderDetailInfo['service_point'] * $orderDetailInfo['goods_num']),
//                    $orderDetailInfo['goods_num'],
//                    $orderDetailInfo['goods_id']
//                );

                $mongoDb->insert($Collection, [
                    'batch_num'     => $out_batch_no,
                    'cr_dt'         =>  date('Y-m-d H:i:s'),
                    'status'        =>  'normal',
                    'response_code' =>  $resp->getStatusCode(),
                    'response_body' =>  $body,
                    'send_data'     =>  $send_data
                ]);

        } catch (\Exception $e) {
            // 进行错误处理
            echo $e->getMessage(), PHP_EOL;

            $Message = $e->getMessage();

            $code = $Phrase = $Body = $TraceAsString = '';

            if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
                $r = $e->getResponse();
                $code = $r->getStatusCode();
                $Phrase = $r->getReasonPhrase();
                $Body = $r->getBody();
            }

            $mongoDb->insert($Collection, [
                'batch_num'     => $out_batch_no,
                'cr_dt'         =>  date('Y-m-d H:i:s'),
                'status'        =>  'error',
                'response_code' =>  $code.' -- '.$Phrase.' -- '.$TraceAsString,
                'response_body' =>  $Body.' MSG:'.$Message,
                'send_data'     =>  $send_data,
            ]);
        }
    }
}

 

标签:转账,status,return,no,微信,batch,零钱,num,out
From: https://www.cnblogs.com/G921123/p/17508905.html

相关文章

  • RAKsmart有奖问答,爆款免费领,前30名送随机微信红包!!!
    为更好的了解客户需求及RAKsmart自信不足,即日起,RAKsmart将推出有奖问卷调查,参与问卷调查即可领取SV1024MVPS使用一个月,同时,前30名参与问卷调查,可领取微信随机1~10元不等,送完即止,快来参与吧!活动时间:美国西岸圣何塞时间 06/26/2023~07/10/2023问卷调查地址:https://www.wenjuan.com/......
  • 微信小程序连接websocket随记
    微信小程序需要上报经纬度到服务器,采用workman作为Websocket服务,记录一下步骤:1、修改start_gateway.php文件//$gateway=newGateway("tcp://0.0.0.0:8282");$gateway=newGateway("websocket://0.0.0.0:8282");2、在小程序后台配置socket域名(开发-> 开发管理-> 开发设......
  • 企业微信添加机器人,并给机器人发送消息
    找一个企业微信的群聊,点击右上角的"...",添加群机器人。  创建一个机器人  填写机器人名字,添加机器人。    保存这里的webhook地址,后面给机器人发消息,就是给这个地址post消息。具体的配置文档,可以点这里的“配置说明”去了解。 下面介绍,使用py给机器人发......
  • 微信海量数据查询如何从1000ms降到100ms? 转载
    微信的多维指标监控平台,具备自定义维度、指标的监控能力,主要服务于用户自定义监控。作为框架级监控的补充,它承载着聚合前45亿/min、4万亿/天的数据量。当前,针对数据层的查询请求也达到了峰值40万/min,3亿/天。较大的查询请求使得数据查询遇到了性能瓶颈:查询平均耗时>1000ms,失败......
  • 微信小程序文件上传、下载
    微信小程序的附件上传下载。上传后并支持打开 1、wxml定义<view><van-uploaderclass="autoField"bind:after-read="afterRead......
  • uniapp微信小程序转支付宝小程序踩坑(持续更新)
    首先第一个,真有被折磨到!//微信正常使用,支付宝不行<imagesrc="https://static.dabapiao.com/images/coupon-index.png"mode=""/>//以下两种微信、支付宝都正常使用<imagesrc="https://static.dabapiao.com/images/coupon-index.png"mode="aspectFill&quo......
  • C#使用企业微信群机器人推送生产数据
      在日常的工作生产中,经常会有将将生产数据或者一些信息主动推送给相关的管理人员,我们公司在开发WMS系统时,为了仓库的储存安全,需要在危废品库存达到一定的储量时,自动通知仓管员去处理危废品,所以就需要程序自动的通过企业微信告知仓管员,这个时候就需要用到企业微信的机器人了。......
  • 关于微信IPAD协议8.0.37个人号开发过程/个微协议/IPAD协议/个人微信号开发/微信机器人
    GEWE框架是基于微信iPad8.0.37协议在设备上实现完整微信功能的协议。它提供了丰富的功能模块,包括登录模块和其他重要功能模块,使用户能够在设备上方便地使用微信。登录模块:登录模块是微信iPad8.0.37协议的核心,它提供了登录微信账号的功能。用户可以通过以下步骤完成登录:登录GEWE框......
  • uniapp项目嵌入微信公众号,授权登录
    1.创建公众号2.配置公众号信息=>公众号设置=>账号详情                          =>功能设置=>配置业务、js接口安全、网页授权域名               =>人员设置:绑定开发者微信号3.基本配......
  • 微信小程序开发《4. 事件》
    事件定义事件是视图层到逻辑层的通讯方式。事件可以将用户的行为反馈到逻辑层进行处理。事件可以绑定在组件上,当达到触发事件,就会执行逻辑层中对应的事件处理函数。事件对象可以携带额外信息,如id,dataset,touches。事件的使用方式在组件中绑定一个事件处理函数。如bindtap,当用户......