where('id', $userrow['upid']); $uprow = $db->getone($csql); if (!is_array($uprow)) return; \web\cweb_ap::usercashoe($db, 20, $uprow['id'], $money * $bonusset[0]['percent'], $bonusset[0]['name']); if ($uprow['upid'] <= 0) return; if (!isset($bonusset[1])) return; $csql = new \ciy\sql('ap_user'); $csql->where('id', $uprow['upid']); $up2row = $db->getone($csql); if (!is_array($up2row)) return; \web\cweb_ap::usercashoe($db, 21, $up2row['id'], $money * $bonusset[1]['percent'], $bonusset[1]['name']); if ($up2row['upid'] <= 0) return; if (!isset($bonusset[2])) return; $csql = new \ciy\sql('ap_user'); $csql->where('id', $up2row['upid']); $up3row = $db->getone($csql); if (!is_array($up3row)) return; \web\cweb_ap::usercashoe($db, 22, $up3row['id'], $money * $bonusset[2]['percent'], $bonusset[2]['name']); //最高三级代理 } static function usercashie($db, $type, $userid, $money, $name = '') { $updata = array(); if ($money > 0) $updata['mymoney'] = array('mymoney+' . $money); else $updata['mymoney'] = array('mymoney' . $money); $csql = new \ciy\sql('ap_user'); $csql->where('id', $userid); if ($db->update($csql, $updata) === false) throw new \Exception('账户余额更新失败:' . $db->error); //直接打款 $updata = array(); $updata['cashtype'] = $type; $updata['iemoney'] = $money; $updata['vuser'] = $userid; $updata['name'] = $name; $updata['addtimes'] = tostamp(); $csql = new \ciy\sql('ap_cash_ie'); if ($db->insert($csql, $updata) === false) throw new \Exception('新建消费收支失败:' . $db->error); } static function usercashoe($db, $type, $userid, $money, $name = '') { $updata = array(); if ($money > 0) $updata['mycashmoney'] = array('mycashmoney+' . $money); else $updata['mycashmoney'] = array('mycashmoney' . $money); $csql = new \ciy\sql('ap_user'); $csql->where('id', $userid); if ($db->update($csql, $updata) === false) throw new \Exception('账户余额更新失败:' . $db->error); //直接打款 $updata = array(); $updata['cashtype'] = $type; $updata['oemoney'] = $money; $updata['vuser'] = $userid; $updata['name'] = $name; $updata['addtimes'] = tostamp(); $csql = new \ciy\sql('ap_cash_oe'); if ($db->insert($csql, $updata) === false) throw new \Exception('新建佣金收支失败:' . $db->error); } }