示例#1
0
 private function pay_bag()
 {
     $time = time();
     $uid = $this->members['uid'];
     $fufen = System::load_app_config("user_fufen", '', 'member');
     $query_1 = $this->set_dingdan('账户', 'A');
     /*会员购买过账户剩余金额*/
     $Money = $this->members['money'] - $this->MoenyCount + $this->fufen_to_money;
     $query_fufen = true;
     $pay_zhifu_name = '账户';
     if ($this->fufen_to_money) {
         $myfufen = $this->members['score'] - $this->fufen;
         $query_fufen = $this->db->Query("UPDATE `@#_member` SET `score`='{$myfufen}' WHERE (`uid`='{$uid}')");
         $pay_zhifu_name = '福分';
         $this->MoenyCount = $this->fufen;
     }
     //添加用户经验
     $jingyan = $this->members['jingyan'] + $fufen['z_shoppay'];
     $query_jingyan = $this->db->Query("UPDATE `@#_member` SET `jingyan`='{$jingyan}' WHERE (`uid`='{$uid}')");
     //经验值
     //更新用户账户金额
     $query_2 = $this->db->Query("UPDATE `@#_member` SET `money`='{$Money}' WHERE (`uid`='{$uid}')");
     //金额
     $query_3 = $info = $this->db->GetOne("SELECT * FROM  `@#_member` WHERE (`uid`='{$uid}') LIMIT 1");
     $query_4 = $this->db->Query("INSERT INTO `@#_member_account` (`uid`, `type`, `pay`, `content`, `money`, `time`) VALUES ('{$uid}', '-1', '{$pay_zhifu_name}', '购买了商品', '{$this->MoenyCount}', '{$time}')");
     $query_5 = true;
     $query_insert = true;
     $goods_count_num = 0;
     foreach ($this->shoplist as $shop) {
         if ($shop['canyurenshu'] >= $shop['zongrenshu'] && $shop['maxqishu'] >= $shop['qishu']) {
             $this->db->Query("UPDATE `@#_shoplist` SET `canyurenshu`=`zongrenshu`,`shenyurenshu` = '0' where `id` = '{$shop['id']}'");
         } else {
             $sellnum = $this->db->GetOne("select sum(gonumber) as sellnum from `@#_member_go_record` where `shopid` = '{$shop['id']}'");
             $sellnum = $sellnum['sellnum'];
             $shenyurenshu = $shop['zongrenshu'] - $sellnum;
             $query = $this->db->Query("UPDATE `@#_shoplist` SET `canyurenshu` = '{$sellnum}',`shenyurenshu` = '{$shenyurenshu}' WHERE `id`='{$shop['id']}'");
             // $shenyurenshu = $shop['zongrenshu'] - $shop['canyurenshu'];
             // $query = $this->db->Query("UPDATE `@#_shoplist` SET `canyurenshu` = '$shop[canyurenshu]',`shenyurenshu` = '$shenyurenshu' WHERE `id`='$shop[id]'");
             if (!$query) {
                 $query_5 = false;
             }
         }
         $goods_count_num += $shop['goods_count_num'];
     }
     //添加福分
     if (!$this->fufen_to_money) {
         $mygoscore = $fufen['f_shoppay'] * $goods_count_num;
         $mygoscore_text = "购买了{$goods_count_num}人次商品";
         $myscore = $this->members['score'] + $mygoscore;
         $query_add_fufen_1 = $this->db->Query("UPDATE `@#_member` SET `score`= '{$myscore}' WHERE (`uid`='{$uid}')");
         $query_add_fufen_2 = $this->db->Query("INSERT INTO `@#_member_account` (`uid`, `type`, `pay`, `content`, `money`, `time`) VALUES ('{$uid}', '1', '福分', '{$mygoscore_text}', '{$mygoscore}', '{$time}')");
         $query_fufen = $query_add_fufen_1 && $query_add_fufen_2;
     }
     $dingdancode = $this->dingdancode;
     $query_6 = $this->db->Query("UPDATE `@#_member_go_record` SET `status`='已付款,未发货,未完成' WHERE `code`='{$dingdancode}' and `uid` = '{$uid}'");
     $query_7 = $this->dingdan_query;
     $query_8 = $this->db->Query("UPDATE `@#_caches` SET `value`=`value` + {$goods_count_num} WHERE `key`='goods_count_num'");
     $this->goods_count_num = $goods_count_num;
     if ($query_fufen && $query_jingyan && $query_1 && $query_2 && $query_3 && $query_4 && $query_5 && $query_6 && $query_7 && $query_insert && $query_8) {
         if ($info['money'] == $Money) {
             $this->db->Autocommit_commit();
             foreach ($this->shoplist as $shop) {
                 if ($shop['canyurenshu'] >= $shop['zongrenshu'] && $shop['maxqishu'] >= $shop['qishu']) {
                     $this->db->Autocommit_start();
                     $query_insert = pay_insert_shop($shop, 'add');
                     if (!$query_insert) {
                         $this->db->Autocommit_rollback();
                     } else {
                         $this->db->Autocommit_commit();
                     }
                     $this->db->Query("UPDATE `@#_shoplist` SET `canyurenshu`=`zongrenshu`,`shenyurenshu` = '0' where `id` = '{$shop['id']}'");
                 }
             }
             return true;
         } else {
             $this->db->Autocommit_rollback();
             return false;
         }
     } else {
         $this->db->Autocommit_rollback();
         return false;
     }
 }
示例#2
0
 public function goods_one_ok()
 {
     $gid = intval($this->segment(4));
     $ginfo = $this->db->GetOne("select * from `@#_shoplist` where `id` = '{$gid}' limit 1");
     if (!$ginfo) {
         _message("没有找到这个商品");
     }
     $jinri_time = time();
     if ($ginfo['xsjx_time'] != '0') {
         _message("限时揭晓商品不能手动揭晓");
     }
     if ($ginfo['shenyurenshu'] != '0') {
         _message("该商品还有剩余人数,不能手动揭晓!");
     }
     if ($ginfo['shenyurenshu'] == '0' && (empty($ginfo['q_uid']) || $ginfo['q_uid'] == '')) {
         System::load_app_fun("pay", "pay");
         $this->db->Autocommit_start();
         $ok = pay_insert_shop($ginfo);
         if (!$ok) {
             $this->db->Autocommit_rollback();
             _message("揭晓失败!");
         } else {
             $this->db->Autocommit_commit();
             _message("揭晓成功!");
         }
     }
 }
示例#3
0
 private function pay_bag()
 {
     $time = time();
     $uid = $this->members['uid'];
     $query_1 = $this->set_dingdan('账户', 'A');
     //夺宝币
     $fufen = System::load_app_config("user_fufen", '', 'member');
     if ($this->fufen) {
         if ($fufen['fufen_yuan']) {
             $fufen_dikou = intval($this->fufen / $fufen['fufen_yuan']);
         } else {
             $fufen_dikou = 0;
         }
     } else {
         $fufen_dikou = 0;
     }
     $Money = $this->members['money'] - $this->MoenyCount + $fufen_dikou;
     //还剩金额
     $query_fufen = true;
     $pay_zhifu_name = '账户';
     if ($fufen_dikou) {
         $myfufen = $this->members['score'] - $this->fufen;
         $query_fufen = $this->db->Query("UPDATE `@#_member` SET `score`='{$myfufen}' WHERE (`uid`='{$uid}')");
         $pay_zhifu_name = '夺宝币';
         $this->MoenyCount = $this->fufen;
     } else {
         $myscore = $this->members['score'] + $fufen['f_shoppay'];
         $query_add_fufen_1 = $this->db->Query("UPDATE `@#_member` SET `score`= '{$myscore}' WHERE (`uid`='{$uid}')");
         $query_add_fufen_2 = $this->db->Query("INSERT INTO `@#_member_account` (`uid`, `type`, `pay`, `content`, `money`, `time`) VALUES ('{$uid}', '1', '夺宝币', '购买了商品', '{$fufen['f_shoppay']}', '{$time}')");
         $query_fufen = $query_add_fufen_1 && $query_add_fufen_2;
     }
     $jingyan = $this->members['jingyan'] + $fufen['z_shoppay'];
     $query_jingyan = $this->db->Query("UPDATE `@#_member` SET `jingyan`='{$jingyan}' WHERE (`uid`='{$uid}')");
     //经验值
     $query_2 = $this->db->Query("UPDATE `@#_member` SET `money`='{$Money}' WHERE (`uid`='{$uid}')");
     //金额
     $query_3 = $info = $this->db->GetOne("SELECT * FROM  `@#_member` WHERE (`uid`='{$uid}') LIMIT 1");
     $query_4 = $this->db->Query("INSERT INTO `@#_member_account` (`uid`, `type`, `pay`, `content`, `money`, `time`) VALUES ('{$uid}', '-1', '{$pay_zhifu_name}', '购买了商品', '{$this->MoenyCount}', '{$time}')");
     $query_5 = true;
     $query_insert = true;
     $goods_count_num = 0;
     foreach ($this->shoplist as $shop) {
         if ($shop['canyurenshu'] >= $shop['zongrenshu'] && $shop['maxqishu'] >= $shop['qishu']) {
             $this->db->Query("UPDATE `@#_shoplist` SET `canyurenshu`=`zongrenshu`,`shenyurenshu` = '0' where `id` = '{$shop['id']}'");
         } else {
             $shenyurenshu = $shop['zongrenshu'] - $shop['canyurenshu'];
             $query = $this->db->Query("UPDATE `@#_shoplist` SET `canyurenshu` = '{$shop['canyurenshu']}',`shenyurenshu` = '{$shenyurenshu}' WHERE `id`='{$shop['id']}'");
             if (!$query) {
                 $query_5 = false;
             }
         }
         $goods_count_num += $shop['goods_count_num'];
     }
     $dingdancode = $this->dingdancode;
     $query_6 = $this->db->Query("UPDATE `@#_member_go_record` SET `status`='已付款,未发货' WHERE `code`='{$dingdancode}' and `uid` = '{$uid}'");
     $query_7 = $this->dingdan_query;
     $query_8 = $this->db->Query("UPDATE `@#_caches` SET `value`=`value` + {$goods_count_num} WHERE `key`='goods_count_num'");
     $this->goods_count_num = $goods_count_num;
     if ($query_fufen && $query_jingyan && $query_1 && $query_2 && $query_3 && $query_4 && $query_5 && $query_6 && $query_7 && $query_insert && $query_8) {
         if ($info['money'] == $Money) {
             $this->db->Autocommit_commit();
             foreach ($this->shoplist as $shop) {
                 if ($shop['canyurenshu'] >= $shop['zongrenshu'] && $shop['maxqishu'] >= $shop['qishu']) {
                     $this->db->Autocommit_start();
                     $query_insert = pay_insert_shop($shop, 'add');
                     if (!$query_insert) {
                         $this->db->Autocommit_rollback();
                     } else {
                         $this->db->Autocommit_commit();
                     }
                     $this->db->Query("UPDATE `@#_shoplist` SET `canyurenshu`=`zongrenshu`,`shenyurenshu` = '0' where `id` = '{$shop['id']}'");
                 }
             }
             return true;
         } else {
             $this->db->Autocommit_rollback();
             return false;
         }
     } else {
         $this->db->Autocommit_rollback();
         return false;
     }
 }