package co.yixiang.yshop.module.order.service.storeaftersalesstatus;

import co.yixiang.yshop.module.order.dal.dataobject.storeaftersalesstatus.StoreAfterSalesStatusDO;
import co.yixiang.yshop.module.order.dal.mysql.storeaftersalesstatus.StoreAfterSalesStatusMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.time.LocalDateTime;

import static co.yixiang.yshop.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

/**
 * 售后订单操作详情 Service 实现类
 *
 * @author yshop
 */
@Service
@Validated
public class StoreAfterSalesStatusServiceImpl implements StoreAfterSalesStatusService {

    @Resource
    private StoreAfterSalesStatusMapper storeAfterSalesStatusMapper;


    /**
     * 添加订单操作记录
     * @param oid 售后id
     * @param changetype 操作状态
     * @param changeMessage 操作内容
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void create(Long uid,Long oid, Integer changetype, String changeMessage) {
        StoreAfterSalesStatusDO storeAfterSalesStatus = new StoreAfterSalesStatusDO();

        storeAfterSalesStatus.setStoreAfterSalesId(oid);
        storeAfterSalesStatus.setChangeType(changetype);
        storeAfterSalesStatus.setChangeMessage(changeMessage);
        storeAfterSalesStatus.setChangeTime(LocalDateTime.now());
        storeAfterSalesStatus.setOperator(getLoginUserId().toString());
        storeAfterSalesStatusMapper.insert(storeAfterSalesStatus);



    }

}
