//#import $owl_create_site_order:services/modelService.jsx
//#import $owl_orgs:services/modelService.jsx
//#import @include/checklogin.jsx
//#import $owl_website:services/modelService.jsx
//#import Util.js


function main(){
    var env = checklogin();
    if(!env){
        // notLogin();
        return;
    }
    var uid = env.loginId;
    var params = JSON.parse($body);
    var sitetype = params.sitetype;
    var bclient = params.bclient;
    var warehouse = params.warehouse;
    var phone = params.phone;
    var email = params.email;
    var name = params.name;
    var description = params.description;
    var ip = $.getClientIp();
    var totalprice = params.totalprice;
    var siteOrder = {
        createUserId:uid,
        uid:uid,
        sitetype:sitetype,
        warehouse:warehouse,
        bclient:bclient,
        phone:phone,
        email:email,
        siteName:name,
        siteTitle:name,
        totalprice:totalprice,
        createTime:new Date().getTime(),
        description:description,
        paystate:"unpaid",
        processstate:"unprocessed",
        ip:ip
    }

    owl_create_site_orderService.add(siteOrder);
    var ret={
        state:'ok',
        orderId:siteOrder.id
    }
    out.print(JSON.stringify(ret));
    return;
}

main();