wuxw
2024-09-12 7935724516cb699835da888d59cd5b7bec5c6049
service-job/src/main/java/com/java110/job/smo/impl/MallInnerServiceSMOImpl.java
@@ -4,12 +4,15 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.core.log.LoggerFactory;
import com.java110.dto.MallDataDto;
import com.java110.dto.integral.DeductionIntegralDto;
import com.java110.dto.integral.GiftIntegralDto;
import com.java110.dto.mall.MallConfigDto;
import com.java110.dto.user.UserDto;
import com.java110.intf.job.IMallInnerServiceSMO;
import com.java110.job.adapt.hcIot.IotConstant;
import com.java110.job.adapt.hcIotNew.http.ISendIot;
import com.java110.job.mall.ISendMall;
import com.java110.utils.cache.MappingCache;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.vo.ResultVo;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +40,28 @@
    @Override
    public ResultVo postMall(@RequestBody JSONObject paramIn) {
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
        if (!"ON".equals(mallSwitch)) {
            return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
        }
        ResultVo resultVo = sendMallImpl.post("/mall/api/common.openCommonApi", paramIn);
        return resultVo;
    }
    @Override
    public ResultVo postMallData(@RequestBody MallDataDto mallDataDto) {
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
        if (!"ON".equals(mallSwitch)) {
            return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
        }
        JSONObject paramIn = mallDataDto.getData();
        paramIn.put("mallApiCode", mallDataDto.getMallApiCode());
        ResultVo resultVo = sendMallImpl.post("/mall/api/common.openCommonApi", paramIn);
        return resultVo;
    }
@@ -72,7 +97,7 @@
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
        if (!"ON".equals(mallSwitch)) {
           return new ResultVo(ResultVo.CODE_OK,ResultVo.MSG_OK);
            return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
        }
        JSONObject paramIn = new JSONObject();
@@ -87,4 +112,89 @@
        return resultVo;
    }
    @Override
    public double computeIntegralMoney(@RequestBody int quantity) {
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
        if (!"ON".equals(mallSwitch)) {
            return 0;
        }
        JSONObject paramIn = new JSONObject();
        paramIn.put("quantity", quantity);
        paramIn.put("mallApiCode", "computeIntegralMoneyBmoImpl");
        ResultVo resultVo = sendMallImpl.post("/mall/api/common.openCommonApi", paramIn);
        if (resultVo.getCode() != ResultVo.CODE_OK) {
            throw new IllegalArgumentException(resultVo.getMsg());
        }
        return Double.parseDouble(resultVo.getData().toString());
    }
    @Override
    public ResultVo sendUserIntegral(@RequestBody GiftIntegralDto giftIntegralDto) {
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
        if (!"ON".equals(mallSwitch)) {
            return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
        }
        JSONObject paramIn = new JSONObject();
        paramIn.put("link", giftIntegralDto.getLink());
        paramIn.put("integral", giftIntegralDto.getIntegral());
        paramIn.put("orderId", giftIntegralDto.getOrderId());
        paramIn.put("remark", giftIntegralDto.getRemark());
        paramIn.put("mallApiCode", "sendIntegralToUserBmoImpl");
        ResultVo resultVo = sendMallImpl.post("/mall/api/common.openCommonApi", paramIn);
        return resultVo;
    }
    @Override
    public ResultVo userIntegralToCommunity(@RequestBody DeductionIntegralDto deductionIntegralDto) {
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
        if (!"ON".equals(mallSwitch)) {
            return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
        }
        JSONObject paramIn = new JSONObject();
        paramIn.put("link", deductionIntegralDto.getLink());
        paramIn.put("integral", deductionIntegralDto.getIntegral());
        paramIn.put("communityId", deductionIntegralDto.getCommunityId());
        paramIn.put("remark", deductionIntegralDto.getRemark());
        paramIn.put("mallApiCode", "userIntegralToCommunity");
        ResultVo resultVo = sendMallImpl.post("/mall/api/common.openCommonApi", paramIn);
        return resultVo;
    }
    @Override
    public MallConfigDto getMallConfig(MallConfigDto mallConfigDto) {
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
        if (!"ON".equals(mallSwitch)) {
            return mallConfigDto;
        }
        JSONObject paramIn = BeanConvertUtil.beanCovertJson(mallConfigDto);
        paramIn.put("mallApiCode", "getMallConfig");
        ResultVo resultVo = sendMallImpl.post("/mall/api/common.openCommonApi", paramIn);
        if(resultVo.getCode() != 0){
            throw new IllegalArgumentException(resultVo.getMsg());
        }
        mallConfigDto = BeanConvertUtil.covertBean(resultVo.getData(),MallConfigDto.class);
        return mallConfigDto;
    }
}