package shop.alien.job.feign;

import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import shop.alien.entity.result.R;

import java.util.Map;

@FeignClient(url = "${feign.alienStore.url}", name = "alien-store")
public interface AlienStoreFeign {

    @GetMapping("/websocket/sendMsgToClientByPhoneId")
    JSONObject sendMsgToClientByPhoneId(
            @RequestParam(value = "messageReceiverId") String messageReceiverId,
            @RequestParam(value = "webSocketVoStr") String webSocketVoStr);

    /**
     * 转账
     *
     * @param name
     * @param idCard
     * @param phone
     * @param money
     * @return
     */
    @GetMapping("/ali/pay")
    JSONObject aliPay(
            @RequestParam(value = "name") String name,
            @RequestParam(value = "idCard") String idCard,
            @RequestParam(value = "phone") String phone,
            @RequestParam(value = "money") String money
    );

    /**
     * 删除附近商家
     *
     * @param flag
     * @param content
     * @return
     */
    @GetMapping("/near/me/delMer")
    JSONObject delMer(
            @RequestParam(value = "flag") Boolean flag,
            @RequestParam(value = "content") String content
    );

    /**
     * 处理退款
     * @param outTradeNo 订单编号
     * @param refundAmount 退款金额
     * @param refundReason 退款原因
     * @return
     */
    @GetMapping("/ali/processRefund")
    public String processRefund(@RequestParam(value = "outTradeNo") String outTradeNo,
                                   @RequestParam(value = "refundAmount") String refundAmount,
                                   @RequestParam(value = "refundReason") String refundReason,
                                   @RequestParam(value = "partialRefundCode") String partialRefundCode);

    /**
     * 退款接口
     * @param params 退款参数（包含订单号、退款金额等）
     * @return 退款结果
     */
    @RequestMapping("payment/refunds")
    public R refunds(@RequestBody Map<String, String> params);

}
