Example #1
0
function biz_getAllCustomerField($guids, $field = 'CardID')
{
    $list = explode(',', $guids);
    $result = array();
    foreach ($list as $id) {
        $c = biz_getCustomerInfo(array('CstGUID' => $id));
        if (!empty($c)) {
            $result[] = $c[$field];
        }
    }
    return implode(',', $result);
}
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;
}