'use strict'
/**
 * 订单表
 */
module.exports = function (db, DataTypes) {
	return db.define('oorder', {
		merchantId: {type: DataTypes.STRING, field: 'merchant_id', allowNull: true, defaultValue:'',comment:'商户id, 为了兼容司机宝' },
		channelOrderNo: {type: DataTypes.STRING, field: 'order_id', allowNull: true, comment:'订单ID' },
    type: { type: DataTypes.INTEGER, field: 'type', allowNull: true, defaultValue:0, comment:'订单类型'},
		busiType: {type: DataTypes.STRING, field: 'busi_type', allowNull: true,defaultValue:'', comment:'业务类型 1个体户 2...暂不知道' },
    busiId: { type: DataTypes.STRING, field: 'busi_id', allowNull: false,defaultValue:'', comment:'业务id'},
		productId: {type: DataTypes.BIGINT, field: 'product_id', allowNull: true,defaultValue:0, comment:'产品id'},
		price: { type: DataTypes.BIGINT, field: 'price', allowNull: true, defaultValue:0,comment:'订单价格'},
    status: {type: DataTypes.INTEGER, field: 'status', allowNull: true,  defaultValue:'0',comment:'订单状态 1待分配 2待完善信息' },
		processStatus: { type: DataTypes.STRING, field: 'process_status', allowNull: true, defaultValue:'0', comment:'业务状态 关联o_order_process表'},
    assignTime: {type: DataTypes.DATE, field: 'assign_time', allowNull: true, defaultValue:null, comment:'分配时间' },
    assignUserId: {type: DataTypes.BIGINT, field: 'assign_user_id', allowNull: true, defaultValue:'0', comment:'分配人id' },
    deliverId: {type: DataTypes.STRING, field: 'deliver_id', allowNull: true, defaultValue:'', comment:'交付商id common微服务下' },
    desc: {type: DataTypes.STRING, field: 'desc', allowNull: true, defaultValue:'', comment:'订单信息' },
    bdId: {type: DataTypes.STRING, field: 'bd_id', allowNull: true, defaultValue:'', comment:'业务员id' },
    bdPath: {type: DataTypes.BIGINT, field: 'bd_path', allowNull: true, defaultValue:'', comment:'业务员权限路径' },
    serviceItems: {type: DataTypes.STRING, field: 'service_items', allowNull: true, defaultValue:'', comment:'服务项json' },
    serviceRemark: {type: DataTypes.STRING, field: 'service_remark', allowNull: true, defaultValue:'', comment:'服务信息备注' },
    sourceId: {type: DataTypes.BIGINT, field: 'source_id', allowNull: true, defaultValue:0, comment:'来源id' },
    sourceNo: {type: DataTypes.STRING, field: 'source_no', allowNull: true, defaultValue:'', comment:'来源订单号' },
    createdAt: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
    updatedAt: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
    deletedAt: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true }
	},
	{
		timestamps: true,
		underscore: true,
    paranoid: true,
    version: true,
		tableName: 'o_order',
		comment: '订单表',
	});
}

