package com.hfkj.config.device;

import com.alibaba.fastjson.JSONObject;
import com.hfkj.config.mqtt.MqttProviderService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * 4G音响设备
 * @className: SoundService
 * @author: HuRui
 * @date: 2022/12/23
 **/
@Component
public class SoundService {

    @Resource
    private MqttProviderService mqttProviderService;

    /**
     * 发送消息
     * @param clientID   设备客户端id
     * @param money      金额
     */
    public void sendPayMsg(String clientID, BigDecimal money) {
        JSONObject body = new JSONObject();
        body.put("msgid", System.currentTimeMillis());
        body.put("cmd", "voice");
        body.put("msg", "惠支付收款"+money+"元");
        body.put("money", money);
        mqttProviderService.publish(0,false,clientID+"/submsg", body.toJSONString());
    }

    /**
     * 获取设备信息
     * @param clientID
     */
    public void geSoundInfo(String clientID) {
        JSONObject body = new JSONObject();
        body.put("cmd", "getpara");
        body.put("full", "1");
        mqttProviderService.publish(0,false,clientID+"/submsg", body.toJSONString());
    }

}
