package com.bohuikeji.delivery.backstage.service.impl;

import com.bohuikeji.delivery.backstage.entity.TCustomer;
import com.bohuikeji.delivery.backstage.mapper.TCustomerMapper;
import com.bohuikeji.delivery.backstage.service.ITCustomerService;
import com.bohuikeji.frame.module.admin.base.ServiceImplBase;
import com.bohuikeji.frame.module.admin.utils.NumberUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;


/**
 * <p>
 * 客户信息表 服务实现类
 * </p>
 *
 * @author 10552
 * @since 2019-08-22
 */
@Slf4j
@Service
public class TCustomerServiceImpl extends ServiceImplBase<TCustomerMapper, TCustomer> implements ITCustomerService {
    @Autowired
    ITCustomerService customerService;

    /**
     * 百度小程序登陆
     * @param registratMeth
     * @return
     */
    @Override
    public TCustomer saveCustomer(String registratMeth) {
        TCustomer customer=new TCustomer();
        String num= NumberUtils.getShort();
        customer.setCustomerName("客户"+num);
        customer.setCustomerPwd("000000");
        customer.setCustomerStatus("已激活");
        customer.setRegistratMeth(registratMeth);
        customer.setCreateTime(LocalDateTime.now());
        customerService.save(customer);
        log.info("@@@@@@@@@@@@新增用户Id:[{}]",customer.getCustomerId());
        return customer;
    }

    /**
     * 百度小程序登陆
     * @param registratMeth
     * @return
     */
    @Override
    public TCustomer savecodeCustomer(String registratMeth,String loginType) {
        TCustomer customer=new TCustomer();
        String num= NumberUtils.getShort();
        customer.setCustomerName("客户"+num);
        customer.setCustomerPwd("000000");
        customer.setCustomerStatus("已激活");
        customer.setRegistratMeth(registratMeth);
        customer.setCreateTime(LocalDateTime.now());
        customerService.save(customer);
        log.info("@@@@@@@@@@@@新增用户Id:[{}]",customer.getCustomerId());
        return customer;
    }

}
