public function bind($mobile, $no, $name) { $members = CService::factory("Member")->queryMemberAnd($mobile, $no, $name); if (empty($members)) { $this->setError("can not find this member!"); return array(-1, null); } $arr = array(); foreach ($members as $key => $value) { $cards = D("Card")->getAllCards($value['id']); foreach ($cards as $card) { $info = array("card_id" => $card['card_number']); $club_id = ""; $clubs = array(); $contracts = D("Contract")->getAllContract($card['id']); foreach ($contracts as $contract) { $clbs = D("CardUseclub")->getAllUseClub($contract['card_type_id']); foreach ($clbs as $clb) { $clubs[] = $clb['id']; } } $clubs = array_unique($clubs); $club_id = implode(',', $clubs); $info['club_id'] = $club_id; $arr[] = $info; } } return array(0, $arr); }
public function queryPayBack($clubs, $start_time, $end_time, $sidx, $limit, $sord, $start) { $condition = array("ret" => 0, "club_id" => array("in", $clubs)); if (!empty($start_time) && !empty($end_time)) { $condition["create_time"] = array("between", "{$start_time},{$end_time}"); } else { if (!empty($start_time)) { $condition["create_time"] = array("gt", "{$start_time}"); } else { if (!empty($end_time)) { $condition["create_time"] = array("lt", "{$end_time}"); } } } $model = D("PayBack"); $objects = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); $count = $model->where($condition)->count(); foreach ($objects as $key => $value) { $objects[$key]['bill'] = CService::factory("Financial")->getBillProject("0,3,4,5", $value['contract_id']); } return array($count, $objects); }