Example #1
0
/**
 * 获取认筹单不同模板类型的打印原始数据
 * @param $chips
 * @param $templateType
 * @return array
 */
function biz_Print_getChipsData($chips, $templateType)
{
    $user = $chips['user'];
    if (!is_array($user)) {
    }
    $data = array('客户名称' => $chips['cname'], '二维码' => $chips['qrcode'], '客户性别' => $user['Gender'], '证件号码' => $user['CardID'], '手机号码' => $user['MobileTel'], '通讯地址' => $user['Address'], '邮编' => $user['PostCode'], '家庭电话' => $user['HomeTel'], '证件类型' => $user['CardType'], '国籍' => $user['Country'], '空' => '', '零' => '0');
    if (empty($data['国籍'])) {
        $data['国籍'] = '中国';
    }
    $res = biz_getChipsCustomerInfo($chips, true);
    $data['权益人'] = $res['name'];
    $data['权益人证件'] = $res['card'];
    $project = biz_getProject($chips['projguid']);
    $data['项目名称'] = $project['projname'];
    $printDate = TIMESTAMP;
    if ($templateType > 2) {
        $room = db_getRoomByGUID($chips['roomguid']);
        $build = db_getBuildingById($room['BldGUID']);
        $data['楼栋名称'] = $build['BldName'];
        $data['预售证号'] = $build['PreSaleNo'];
        $data['预售证日期大写'] = Date2Cn($build['PreSaleDate']);
        $data['房间名'] = $room['ShowCode'];
        $data['房间号'] = $room['Room'];
        $data['定金'] = number_format($chips['premoney'] + $chips['ordermoney'], 2);
        $data['定金大写'] = Num2Cny($chips['premoney'] + $chips['ordermoney']);
    }
    $data['代理公司'] = $chips['agency'];
    $data['业务员'] = $chips['salesman'];
    switch ($templateType) {
        case 1:
            $data['认筹书编号'] = $chips['ChipsNo'];
            $data['辅助代理'] = $chips['agencychild'];
            $intend = explode(',', $chips['intendroom']);
            $data['具体意向1'] = empty($intend[0]) ? '' : $intend[0];
            $data['具体意向2'] = empty($intend[1]) ? '' : $intend[1];
            $data['具体意向3'] = empty($intend[2]) ? '' : $intend[2];
            $data['备注'] = $chips['remark'];
            $printDate = $chips['printdate'];
            break;
        case 2:
            //只打印最后一次
            $item = biz_getBill($chips['qrcode'], 1, 1);
            $data['诚意金'] = number_format($item['Money'], 2);
            $data['诚意金大写'] = Num2Cny($item['Money']);
            $data['交款人'] = $item['Jkr'];
            $data['收款人'] = $item['Kpr'];
            $data['票据批次号'] = $item['BatchNo'];
            $data['票据编号'] = $item['InvoNo'];
            $printDate = $item['createtime'];
            break;
        case 3:
            $item = biz_getBill($chips['qrcode'], 2, 1);
            $data['交款人'] = $item['Jkr'];
            $data['收款人'] = $item['Kpr'];
            $data['票据批次号'] = $item['BatchNo'];
            $data['票据编号'] = $item['InvoNo'];
            $printDate = $item['createtime'];
            break;
        case 4:
            $data['建筑面积'] = $room['BldArea'];
            $data['套内面积'] = $room['TnArea'];
            $data['建筑单价'] = number_format($room['Price'], 2);
            $data['套内单价'] = number_format($room['TnPrice'], 2);
            $data['价格'] = number_format($room['Total'], 2);
            $data['成交价'] = number_format($room['RoomTotal'], 2);
            $data['成交价大写'] = Num2Cny($room['RoomTotal']);
            $data['折扣'] = $room['DiscntValue'];
            $data['认购书编号'] = $chips['ProtocolNO'];
            $pay = biz_unserializer($project, 'payform');
            $data['付款方式'] = $pay['Payform']['PayformName'];
            $sql = " select * from " . tablename('s_Fee') . " where TradeGUID =:qrcode ";
            $fees = pdo_fetchall($sql, array(':qrcode' => $chips['qrcode']), 'ItemName');
            if (isset($fees['首期'])) {
                $data['首期房款日期'] = date('Y年m月d日', strtotime($fees['首期']['lastDate']));
                $data['首期房款金额'] = number_format($fees['首期']['Amount'], 2);
                $data['首期房款百分比'] = $fees['首期']['Rate'];
                $data['定金+首期'] = number_format($fees['首期']['Amount'] + $chips['shouldpay'], 2);
            }
            if (isset($fees['银行按揭'])) {
                $data['按揭金额'] = number_format($fees['银行按揭']['Amount'], 2);
                $data['按揭百分比'] = $fees['银行按揭']['Rate'];
            }
            if (isset($fees['维修基金'])) {
                $data['维修基金'] = number_format($fees['维修基金']['Amount'], 2);
            }
            $data['备注'] = $chips['remark'];
            $printDate = $chips['QSDate'];
            break;
    }
    $date = getdate($printDate);
    $data['打印日期'] = date('Y年m月d日', $printDate);
    $data['打印日期-年'] = $date['year'];
    $data['打印日期-月'] = $date['mon'];
    $data['打印日期-日'] = $date['mday'];
    return $data;
}
Example #2
0
function erp_Write_Customer($chips)
{
    $write = false;
    $project = biz_getProject($chips['projguid']);
    $fields = array('CstGUID', 'CstName', 'CstType', 'KhFl', 'CardID', 'OfficeTel', 'HomeTel', 'MobileTel', 'PostCode', 'Address', 'CstType', 'Gender', 'CardType', 'WorkAddr', 'Country', 'CompanyPhone', 'signguid');
    //要检查客户是否已录入
    $info = biz_getChipsCustomerInfo($chips);
    $list = explode(',', $info['guid']);
    foreach ($list as $cid) {
        $customer = biz_getCustomerInfo(array('CstGUID' => $cid));
        if (empty($customer['erp'])) {
            //$customer['CreatedBy']=$chips['creator'];
            $customer['CstType'] = '个人';
            //$customer['KhFl']='普通客户';
            $customer['signguid'] = $chips['projguid'];
            $write = MsSql()->insertObject('p_Customer', array_elements($fields, $customer));
            // 生成CstAttach(客户项目对应表)
        }
        $exist = MsSql()->fetch('select * from p_CstAttach where ' . " CstGUID='{$cid}' and ProjGUID='{$chips['projguid']}'");
        if ($write && empty($exist)) {
            $attach = array('CstAttachGUID' => GUID(), 'CstGUID' => $cid, 'ProjGUID' => $chips['projguid'], 'BUGUID' => $project['BUGUID'], 'signguid' => $chips['projguid']);
            $write = MsSql()->insertObject('p_CstAttach', $attach);
            if ($write === false) {
                logging('写入p_CstAttach出错', $cid);
            }
        }
    }
    return $write;
}