【客户下单】前端系统Action数据封装
客户下单是在前端系统bos_fore中完成的,客户下单提交的数据将以webservice的形式发送给后台bos_management系统,由bos_management实现自动分单的业务逻辑。
将前端提交过来的”省市区”信息封装到后台Area中。在bos_fore系统中,添加OrderAction封装订单数据,基于webservice传递给后台系统。
手动封装Area数据,并将其关联到Order上,获取session中已经保存好的Customer,并将Customer关联到Order上。
@Namespace("/")
@ParentPackage("json-default")
@Controller
@Scope("prototype")
public class OrderAction extends BaseAction<Order>{
private String sendAreaInfo;//发件人省市区信息
private String recAreaInfo;//收件人省市区信息
public void setSendAreaInfo(String sendAreaInfo){
this.sendAreaInfo = sendAreaInfo;
}
public void setRecAreaInfo(String recAreaInfo){
this.recAreaInfo = recAreaInfo;
}
@Action(Value="order_add",results={@Result(name="success",type="redirect",location="index.html")})
public String add(){
//手动封装Area数据
Area sendArea = new Area();
String[] sendAreaData = sendAreaInfo.split("/");
sendArea.setProvince(sendAreaData[0]);
sendArea.setCity(sendAreaData[1]);
sendArea.setDistrict(sendAreaData[2]);
Area recArea = new Area();
String recAreaData = recArea.split("/");
recArea.setProvince(recAreaData[0]);
recArea.setCity(recAreaData[1]);
recArea.setDistrict(recAreaData[2]);
model.setSendArea(sendArea);
model.setRecArea(recArea);
//关联当前登录客户
Customer customer = (Customer)ServletActionContext.getRequest().getSession().getAttribute("customer");
model.setCustomer_id(customer.getId());
return SUCCESS;
}
}