package com.hzs.activity.pick.provider;

import com.hzs.activity.pick.IAcPickServiceApi;
import com.hzs.activity.pick.param.AcPickQueryParam;
import com.hzs.activity.pick.service.IAcPickService;
import com.hzs.common.core.domain.R;
import com.hzs.common.domain.activity.pick.ext.AcPickExt;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 提货相关dubbo服务入口
 */
@Slf4j
@DubboService
public class AcPickProviderApi implements IAcPickServiceApi {

    @Autowired
    private IAcPickService iAcPickService;

    @Override
    public R<?> handlePickOrder(Long pkMember, String orderCode) {
        try {
            if (iAcPickService.callbackPickOrder(pkMember, orderCode)) {
                return R.ok();
            }
        } catch (Exception e) {
            log.error("提货订单回调处理异常", e);
        }
        return R.fail();
    }

    @Override
    public R<List<AcPickExt>> queryList(Long pkMember, Integer pickType, Integer pkCountry) {
        return R.ok(iAcPickService.queryList(AcPickQueryParam.builder().pkMember(pkMember).pickType(pickType).build(), pkCountry));
    }

}
