$days = isset($_GET["days"]) ? $_GET["days"] : 0;
 $zjtype = isset($_GET["zjtype"]) ? $_GET["zjtype"] : 0;
 function GetTJRowUS($zd, $table, $where)
 {
     $sql = "select {$zd} from {$table} where {$where}";
     $result = mysql_query($sql);
     while ($row = mysql_fetch_assoc($result)) {
         $TJRow[] = $row[$zd];
     }
     return $TJRow;
 }
 $usidarrid = GetTJRowUS('cj_id', 'choujiang', "status in (1,4) and name='{$usname}' and (step1_time+604800<{$CCtimes} or step4_time+864000<{$CCtimes})");
 if (!empty($usidarrid)) {
     foreach ($usidarrid as $cjusid) {
         Autochoujiang('step1_time', 7, 1, $cjusid, -2, 'choujiang');
         Autochoujiang('step4_time', 10, 4, $cjusid, 5, 'choujiang');
     }
 }
 $where = '';
 if ($state == 0) {
     $where = 'and 1=1';
 } else {
     $where = $where . " and a.status={$state}";
 }
 if ($aid != 0) {
     $where = $where . " and a.cj_gid={$aid}";
 }
 if ($searchkey != "" && $searchtype != 0) {
     switch ($searchtype) {
         case 1:
             $sotype = 'b.num_iid';
 //已登录
 function GetTJRowUS($zd, $table, $where)
 {
     $sql = "select {$zd} from {$table} where {$where}";
     $result = mysql_query($sql);
     while ($row = mysql_fetch_assoc($result)) {
         $TJRow[] = $row[$zd];
     }
     return $TJRow;
 }
 if (GetCount('duihuan', "id={$aid} and create_user_id={$usidse} and xianshi>2 and xianshi<>5")) {
     $usidarrid = GetTJRowUS('cj_id', 'user_duihuan', "status in (1,4) and cj_gid={$aid}");
     if (!empty($usidarrid)) {
         foreach ($usidarrid as $cjusid) {
             Autochoujiang('step1_time', 7, 1, $cjusid, -2, 'user_duihuan');
             Autochoujiang('step4_time', 10, 4, $cjusid, 5, 'user_duihuan');
         }
     }
     $usidarr = GetTJRowUS('cj_id', 'user_duihuan', "status in (1,3,4,-4,-5) and cj_gid={$aid}");
     if (empty($usidarr)) {
         $sql = "select * from  duihuan where id={$aid}";
         $result = mysql_query($sql);
         $usrow = mysql_fetch_assoc($result);
         $cymoney = $usrow['coupon_price'] * $usrow['num'];
         $mingxiC = "您发布编号ID为:" . $usrow['id'] . "的兑换活动圆满结束,结算完成," . $cymoney . "元全部解冻";
         if (Zbkupdate('duihuan', array('xianshi' => 5, 'lasttime' => $CCtimes), "create_user_id={$usidse} and id={$aid}")) {
             $countjs = Kmoney($usname, $cymoney, $mingxiC, 'balance', 1, 1, 0);
             $arry['id'] = 219;
             //终止成功
             $arry['msg'] = "结算成功,活动圆满成功";
         } else {