public function doWebCustomer() { global $_W, $_GPC; $step = 1; if (isset($_GPC['step'])) { $step = intval($_GPC['step']); } $id = intval($_GPC['id']); $chips = biz_getChips($id); if (empty($chips) || $chips['deleted']) { message('无效认筹单', $this->createWebUrl('chips')); } $op = $_GPC['op']; if (!in_array($op, array('change', 'add', 'delete'))) { message('无效操作', $this->createWebUrl('chips')); } $url = $this->createWebUrl('customer', array('op' => $op, 'id' => $id)); if ($op == 'change') { $title = '认筹单换名'; } if ($op == 'add') { $title = '增加附属权益人'; } if (checksubmit('submit')) { if ($step == 1) { $user_info = biz_getCustomerByCardId($_GPC['cardid'], $_W['project']['projguid']); if (empty($user_info)) { $user_info = $_GPC['user']; $user_info['CardID'] = $_GPC['cardid']; $user_info['Country'] = '中国'; $user_info['Gender'] = '男'; } $step = 2; } else { if ($step == 2) { $user_info = $_GPC['user']; $customer = biz_getCustomerByCardId($user_info['CardID'], $_W['project']['projguid']); if ($op == 'change') { if (empty($customer)) { $customer = $user_info; biz_saveCustomer($customer, $_W['project']); } // 插入的数据 $data = array('cname' => $user_info['CstName'], 'cardid' => $user_info['CardID'], 'mobile' => $user_info['MobileTel'], 'grender' => $user_info['Gender']); $data['cid'] = $customer['CstGUID']; pdo_update('chips', $data, array('id' => $id)); message('认筹单换名成功!', $this->createWebUrl('chips')); } if ($op == 'add') { if (empty($customer)) { $customer = $user_info; biz_saveCustomer($customer, $_W['project']); } $result = biz_saveHolder($chips, $customer); if ($result['result']) { message('数据增加成功!', $this->createWebUrl('chips', array('id' => $id))); } else { message('数据保存出错:' . $result['msg'], $this->createWebUrl('customer', array('op' => 'add', 'id' => $id)), 'error'); } } } } } if ($step == 2) { $cardTypes = biz_getDictionary('CardType'); $khTypes = biz_getDictionary('kehuType'); } include $this->template('chips_change'); }
/** * 保存认筹信息,分开保存用户信息并新更 * @param $data * @return array */ function biz_saveChips($data) { global $_W; $result = array('result' => false, 'msg' => ''); if (isset($data['user'])) { $user = $data['user']; unset($data['user']); biz_saveCustomer($user, $_W['project']); $data['cid'] = $user['CstGUID']; $data['cname'] = $user['CstName']; $data['grender'] = $user['Gender']; $data['mobile'] = $user['MobileTel']; $data['cardid'] = $user['CardID']; } $state = false; if (empty($data['id'])) { $data['createid'] = $_W['uid']; $data['creator'] = $_W['username']; //记录操作用户部门ID? $data['StationCode'] = $_W['rights']['HierarchyCode']; $data['changetime'] = TIMESTAMP; $data['createtime'] = TIMESTAMP; $state = pdo_insert('chips', $data); } else { $data['changetime'] = TIMESTAMP; $params = array('id' => $data['id']); unset($data['id']); $state = pdo_update('chips', $data, $params); } $result['result'] = $state > 0; return $result; }