package com.uas.platform.b2b.event;

import com.uas.platform.b2b.model.*;
import com.uas.platform.core.model.Constant;

import java.util.Date;
import java.util.List;

/**
 * 买家修改收料通知的数量时生成消息事件
 *
 *
 */
public class SaleSendRefuseReleaseEvent extends SaveReleaseEvent<PagingReleaseDetail, SaleSend> {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	public SaleSendRefuseReleaseEvent(List<SaleSend> savedList) {
        super(savedList);
    }

    /**
     * 生成对应消息记录
     *
     * @param send
     * @return
     */
    @Override
	public PagingReleaseDetail release(SaleSend send) {
        Long emUU = send.getCustUserUU();
        String emName = "操作员";
        if (null != send.getCustUser()) {
            emName = send.getCustUser().getUserName();
        }
        Long enUU = send.getCustUU();
        Date date = new Date();
        String codeValue = send.getCode();
        String from = "ERP";
        String type = "修改发货数量";
        String title = "B2B商务提醒";
        Short toVendor = Constant.YES;
        Short isReply = Constant.NO;
        String category = "sale";  // 对接收方来说，该单据类型
        String table = "sale$send";
        Long sourceId = send.getId();
        String url = "#/sale/send" + send.getId();
        Short orderStatus = 0;
        String context = send.getCustomer().getEnName() + "的" + emName + "拒收了您送货单（" + codeValue + "）的产品！";
        PagingRelease release = new PagingRelease(emUU, emName, enUU, date, codeValue, from, title, context, type, isReply, category, table, sourceId, orderStatus, toVendor, url);
        Long vendUU = send.getEnUU();
        // 发货单未记录录入人uu
        Long vendUserUU = 1L;
        String vendUserName = send.getRecorder();
        PagingReleaseDetail releaseDetail = new PagingReleaseDetail(vendUU, vendUserUU, vendUserName);
        releaseDetail.setPagingRelease(release);
        return releaseDetail;
    }
}
