package cn.superdesk.uniorder.dto.receive.consumer.superdeskappservices;

import cn.superdesk.uniorder.dto.vo.unified.BaseApiModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;


/**
 * @Description: 这个只是楼闪送在用吗? 订单数据传输 JSONObject 非kafka 只是将要整改 放在这里而已
 * @Author: linjinyu
 * @CreateDate: 5/6/20 7:34 PM
 * @UpdateUser: linjinyu
 * @UpdateDate: 5/6/20 7:34 PM
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class UnifiedLnssOrderAdd extends BaseApiModel implements Serializable {

	private static final long serialVersionUID = -99863600305346571L;


	/**
	 * add 20200601 比对楼闪送代码 后添加 start
	 */
//	private String version;
//	private String timestamp;
//	private String charset;
//	private String nonce_str;
//	private String sign;
	/**
	 * add 20200601 比对楼闪送代码 后添加 end
	 */

	@JsonProperty("service_no")
	private String serviceNo;
	@JsonProperty("order_type")
	private String serviceName;
	@JsonProperty("orderSn")
	private String orderSn;

	/**
	 * 看代码,有可能是个空串
	 * if (StringUtils.isNotBlank(param.getEnterprise()) && param.getEnterpriseId() != null) {
	 * jsonParam.put("purchase_virt", String.format("%s_%d", param.getEnterprise(), param.getEnterpriseId()));
	 * } else {
	 * jsonParam.put("purchase_virt", "");
	 * }
	 */
	@JsonProperty("purchase_virt")
	private String purchaseVirt;
	/**
	 * jsonParam.put("purchase_user", String.format("%s_%d", headerParam.getUserName(), headerParam.getUserId()));
	 */
	/**
	 * purchase_user
	 */
	@JsonProperty("purchase_user")
	private String purchaseUser;


	/****************************************** add by linjinyu 20200903 ******************************************/

	/**
	 * 下单人信息
	 */
	private Long   purchaseVirtId;
	private String purchaseVirtName;

	@ApiModelProperty("下单人Id")
	private Long   purchaseUserId;
	@ApiModelProperty("下单人姓名")
	private String purchaseUserName;
	@ApiModelProperty("下单人联系电话")
	private String purchasePhone;

	/**
	 * 收货人信息
	 */
	@JsonProperty("recUserid")
	private Long   recUserId;
	private String recUserName;
	@JsonProperty("recUserphone")
	private String recUserPhone;
	private String recAddress;


	/****************************************** add by linjinyu 20200903 ******************************************/


	/**
	 * jsonParam.put("sale", String.format("%s_%d", saleParam.getSaleName(), saleParam.getSaleId()));
	 */
	private String     sale;
	/**
	 * 订单总金额
	 * //套价基础上算总价
	 * BigDecimal totalAmount = BigDecimal.ZERO;
	 * //amount=jsonGoods.stream().map(obj->((JSONObject)obj).getBigDecimal("price")).reduce(BigDecimal.ZERO, BigDecimal::add);
	 * for(int k=0;k<jsonGoods.size();k++){
	 * JSONObject obj = (JSONObject)jsonGoods.get(k);
	 * totalAmount = totalAmount.add(obj.getBigDecimal("price").multiply(obj.getBigDecimal("quantity")).setScale(2,BigDecimal.ROUND_HALF_UP));
	 * }
	 * totalAmount = totalAmount.add(param.getDeliveryAmount());//在加配送费
	 */
	private BigDecimal amount;
	/**
	 * 订单成本
	 * //套价基础上算成本价
	 * BigDecimal totalCostAmount = BigDecimal.ZERO;
	 * for(int c=0;c<jsonGoods.size();c++){
	 * JSONObject obj = (JSONObject)jsonGoods.get(c);
	 * //totalCostAmount = totalCostAmount.add(obj.getBigDecimal("cost_price").multiply(obj.getBigDecimal("getQuantity")).setScale(2,BigDecimal.ROUND_HALF_UP));
	 * <p>
	 * BigDecimal costPrice=obj.getBigDecimal("cost_price");
	 * Integer quantity=obj.getInteger("quantity");
	 * if(null!=costPrice && costPrice.compareTo(BigDecimal.ZERO) >= 0){//不为空 且大于等于0
	 * <p>
	 * BigDecimal tempCostPrice=costPrice.multiply(BigDecimal.valueOf(quantity));
	 * totalCostAmount=totalCostAmount.add(tempCostPrice.setScale(2,BigDecimal.ROUND_HALF_UP));
	 * }else{
	 * totalCostAmount=null;//有一个没有配置成本价 整体成本价为空
	 * break;
	 * }
	 * <p>
	 * }
	 */
	@JsonProperty("cost_amount")
	private BigDecimal costAmount;
	/**
	 * 配送费
	 */
	@JsonProperty("transport_amount")
	private BigDecimal transportAmount;
	//	transport_amount 	配送费 		有加总金额
	//	packing_amount       打包费  	 有加总金额
	//	deliveryPersonAmount 配送员配送费  没有加总金额
	//	saleDeliveryAmount   商户配送费    没有加总金额


	/**
	 * jsonParam.put("payment_type", param.getPaymentType() + 1);
	 */
	@JsonProperty("payment_type")
	private String payType;//1-款到发货,2-货到付款,3-月结
	/**
	 * jsonParam.put("pay_state", PayStatusEnum.NO_SALE.getKey());
	 */
	@JsonProperty("pay_state")
	private String payState;//1-已付款 2-付款
	@JsonProperty("appraise_state")
	private String appraiseState;//1-已评价,2-未评价
	/**
	 * if (param.getPaymentType().equals(PayTypeEnum.NOW_SALE.getKey())) {
	 * jsonParam.put("order_state", OrderStatusEnum.NO_SALE.getKey());
	 * jsonParam.put("order_state_name", OrderStatusEnum.NO_SALE.getDesc());
	 * } else {
	 * jsonParam.put("order_state", OrderStatusEnum.SALE.getKey());
	 * jsonParam.put("order_state_name", OrderStatusEnum.SALE.getDesc());
	 * }
	 */
	@JsonProperty("order_state")
	private String orderState;//自定义
	@JsonProperty("order_state_name")
	private String orderStateName;
	/**
	 * jsonParam.put("source_channel", 1);
	 */
	@JsonProperty("source_channel")
	private String sourceChannel;//例如:1-微信,2-APP,3-PC
	/**
	 * jsonParam.put("project_id", param.getProjectId());
	 */
	@JsonProperty("project_id")
	private String projectId;//项目ID 对应旧的org_id
	/**
	 * jsonParam.put("user_name", headerParam.getUserName());
	 */
	@JsonProperty("user_name")
	private String userName;
	/**
	 * jsonParam.put("user_id", headerParam.getUserId());
	 */
	@JsonProperty("user_id")
	private String userId;
	/**
	 * jsonParam.put("user_type", 1);
	 */
	@JsonProperty("user_type")
	private String userType;

	/**
	 * jsonParam.put("out_sn", "");
	 */
	@JsonProperty("out_sn")
	private String outSn;
	/**
	 * jsonParam.put("other_params", "");
	 */
	@JsonProperty("other_params")
	private String otherParams;
	/**
	 * jsonParam.put("settlement_type", "");
	 */
	@JsonProperty("settlement_type")
	private String settlementType;//1-个人 2-企业

	private List<UnifiedLnssOrderGoodsAdd> goods;


}
