예제 #1
0
 private function set_dingdan($pay_type = '', $dingdanzhui = '')
 {
     $uid = $this->members['uid'];
     $uphoto = $this->members['img'];
     $username = get_user_name($this->members);
     $insert_html = '';
     $this->dingdancode = $dingdancode = pay_get_dingdan_code($dingdanzhui);
     //订单号
     if (count($this->shoplist) > 1) {
         $dingdancode_tmp = 1;
         //多个商品相同订单
     } else {
         $dingdancode_tmp = 0;
         //单独商品订单
     }
     $ip = _get_ip_dizhi();
     //订单时间
     $time = sprintf("%.3f", microtime(true));
     $this->MoenyCount = 0;
     foreach ($this->shoplist as $key => $shop) {
         $ret_data = array();
         pay_get_shop_codes($shop['cart_gorenci'], $shop, $ret_data);
         $this->dingdan_query = $ret_data['query'];
         if (!$ret_data['query']) {
             $this->dingdan_query = false;
         }
         $codes = $ret_data['user_code'];
         //得到的购买码
         $codes_len = intval($ret_data['user_code_len']);
         //得到购买码个数
         $money = $codes_len * $shop['yunjiage'];
         //单条商品的总价格
         $this->MoenyCount += $money;
         //总价格
         $status = '未付款,未发货,未完成';
         $shop['canyurenshu'] = intval($shop['canyurenshu']) + $codes_len;
         $shop['goods_count_num'] = $codes_len;
         $this->shoplist[$key] = $shop;
         if ($codes_len) {
             $insert_html .= "('{$dingdancode}','{$dingdancode_tmp}','{$uid}','{$username}','{$uphoto}','{$shop['id']}','{$shop['title']}','{$shop['qishu']}','{$codes_len}','{$money}','{$codes}','{$pay_type}','{$ip}','{$status}','{$time}'),";
         }
     }
     $sql = "INSERT INTO `@#_member_go_record` (`code`,`code_tmp`,`uid`,`username`,`uphoto`,`shopid`,`shopname`,`shopqishu`,`gonumber`,`moneycount`,`goucode`,`pay_type`,`ip`,`status`,`time`) VALUES ";
     $sql .= trim($insert_html, ',');
     if (empty($insert_html)) {
         return false;
     }
     //$this->db->Query("set global max_allowed_packet = 2*1024*1024*10");
     return $this->db->Query($sql);
 }
예제 #2
0
  public function order_do_yg($vo){
	include C('PUBLIC_INCLUDE')."function.inc.php";
	//获得云码
	$codes = pay_get_shop_codes($vo['total_num'],$vo['sourceid']);
	if($codes['code_len']<$s_num){
	  $s_num = $codes['code_len'];
	}
	$model = M('shoplist');
	if($codes==false || $codes['code_len']==0){
	  $model->rollback();
	  $this->update_remark('云码不存在');
	  exit;
	}
	$data['id'] = $vo['sourceid'];
	$shop = $model->where($data)->find();
	//记录购买云码
	$mgrmodel = M('go_record');
	$mgr_data['member_id'] = $vo['member_id'];
	$mgr_data['member_name'] = $vo['member_name'];
	$mgr_data['order_id'] = $vo['id'];
	$mgr_data['shopid'] = $vo['sourceid'];
	$mgr_data['shopname'] = $shop['name'];
	$mgr_data['shopqishu'] = $shop['qishu'];
	$mgr_data['goucode'] = implode(',',$codes['codes']);
	$mgr_data['code_num'] = $codes['code_len'];
	$timearr = explode(' ',microtime());
	$mgr_data['ms'] = substr($timearr[0],2,3);
	$mgr_data['create_time'] = $timearr[1];
	$result = $mgrmodel->add($mgr_data);
	//echo $mgrmodel->getlastsql();
	if(!$result){
	  $model->rollback();
	  $this->update_remark('会员云码记录失败');
	  exit;
	}
	return $result;
  }
예제 #3
0
 /**
  * 购买产品
  */
 function buy_pay()
 {
     $s_id = $_POST['s_id'] = 1;
     $s_num = $_POST['s_num'] = 100;
     $member_id = 3;
     $member_name = '8yong8';
     $realname = '阿勇';
     $address_id = 7;
     $model = M('shoplist');
     $data['id'] = $s_id;
     $vo = $model->field('id,name,lit_pic,yunjiage,qishu,status')->where($data)->find();
     if ($vo['status'] == 2) {
         $this->error('此商品交易已完成');
     }
     if ($vo['status'] == 0) {
         $this->error('此商品交易关闭');
     }
     $time = time();
     $ip = _get_ip();
     $model->startTrans();
     //启用事务
     //获得云码
     $codes = pay_get_shop_codes($s_num, $vo['id']);
     if ($codes['code_len'] < $s_num) {
         $s_num = $codes['code_len'];
     }
     if ($codes == false || $codes['code_len'] == 0) {
         $this->error('下单失败');
         exit;
     }
     $pay = $vo['yunjiage'] * $s_num;
     $mwmodel = M('member_wallet');
     $mw_data['member_id'] = $member_id;
     $mw_vo = $mwmodel->where($mw_data)->find();
     if ($mw_vo['balance'] < $pay) {
         $this->error('余额不够');
     }
     $mamodel = M('member_address');
     $ma_data['id'] = $address_id;
     $address = $mamodel->where($ma_data)->find();
     //生成订单
     $omodel = M('order');
     $o_data['type'] = 2;
     $o_data['source'] = 'Shoplist';
     $o_data['sourceid'] = $s_id;
     $o_data['title'] = '购买' . $vo['name'];
     $goods[] = $vo;
     $o_data['goods'] = serialize($goods);
     $order_id = build_order_no($member_id);
     $o_data['order_id'] = $order_id;
     $o_data['payment_mode'] = 1;
     $o_data['payment_company'] = '网站余额';
     $o_data['pay_order_id'] = $order_id;
     $o_data['total_price'] = $pay;
     $o_data['total_num'] = $s_num;
     $o_data['member_id'] = $member_id;
     $o_data['member_name'] = $member_name;
     $o_data['realname'] = $realname;
     $o_data['address_id'] = $address_id;
     $o_data['recipient'] = $address['name'];
     $o_data['address'] = $address['address'];
     $o_data['postcode'] = $address['postcode'];
     $o_data['tel'] = $address['mobile'];
     $o_data['remark'] = $_POST['remark'] ? $_POST['remark'] : '';
     $o_data['ip'] = $ip;
     $o_data['create_time'] = $time;
     $o_data['pay_time'] = $time;
     $o_data['order_time'] = time() + 3600 * 24;
     $o_data['status'] = 1;
     $oid = $omodel->add($o_data);
     //echo $omodel->getlastsql();exit;
     if (!$oid) {
         $model->rollback();
         $this->error('订单生成失败');
         exit;
     }
     //扣除余额
     $result = $mwmodel->where($mw_data)->setDec('balance', $pay);
     if ($result) {
         //记录扣钱
         $rmodel = M('record');
         $rdata['member_id'] = $member_id;
         $rdata['member_name'] = $member_name;
         $rdata['realname'] = $realname;
         $rdata['payment_mode'] = 1;
         $rdata['payment_company'] = '网站余额';
         $rdata['pay_order_id'] = build_order_no($member_id);
         $rdata['order_id'] = $order_id;
         $rdata['pay_type'] = 2;
         $rdata['pay'] = $pay - 2 * $pay;
         $rdata['balance'] = $mw_vo['balance'] - $pay;
         $rdata['buyer'] = $member_name;
         $rdata['buyer'] = $member_name;
         $rdata['ip'] = $ip;
         $rdata['content'] = '购买' . $vo['name'] . '云码' . $s_num . '个';
         $rdata['create_time'] = $time;
         $rdata['pay_time'] = $time;
         $rdata['status'] = 1;
         $rid = $rmodel->add($rdata);
         if (!$rid) {
             $model->rollback();
             $this->error('财务订单生成失败');
             exit;
         }
         //记录购买云码
         $mgrmodel = M('go_record');
         $mgr_data['member_id'] = $member_id;
         $mgr_data['member_name'] = $member_name;
         $mgr_data['order_id'] = $oid;
         $mgr_data['shopid'] = $vo['id'];
         $mgr_data['shopname'] = $vo['name'];
         $mgr_data['shopqishu'] = $vo['qishu'];
         $mgr_data['goucode'] = implode(',', $codes['codes']);
         $mgr_data['code_num'] = $codes['code_len'];
         $timearr = explode(' ', microtime());
         $mgr_data['ms'] = substr($timearr[0], 2, 3);
         $mgr_data['create_time'] = $timearr[1];
         //$mgr_data['create_time'] = time();
         $result = $mgrmodel->add($mgr_data);
         //$model->rollback();
         //echo $mgrmodel->getlastsql();exit;
         if (!$result) {
             $model->rollback();
             $this->error('云码生成失败');
             exit;
         }
     }
     //修改商品信息
     $result = $model->where($data)->setInc('canyurenshu', $s_num);
     if ($result) {
         $result = $model->where($data)->setDec('shenyurenshu', $s_num);
     }
     if ($result) {
         $model->commit();
         echo 'ok';
     } else {
         $model->rollback();
         $this->error('新增失败3');
         exit;
     }
 }
예제 #4
0
 /**
  * 云够
  */
 public function order_do_yg($vo)
 {
     //获得云码
     $codes = pay_get_shop_codes($s_num, $vo['sourceid']);
     if ($codes['code_len'] < $s_num) {
         $s_num = $codes['code_len'];
     }
     if ($codes == false || $codes['code_len'] == 0) {
         $this->error('下单失败');
         exit;
     }
     $model = M('shoplist');
     $data['id'] = $vo['sourceid'];
     $shop = $model->where($data)->find();
     //记录购买云码
     $mgrmodel = M('go_record');
     $mgr_data['member_id'] = $vo['member_id'];
     $mgr_data['member_name'] = $vo['member_name'];
     $mgr_data['order_id'] = $vo['id'];
     $mgr_data['shopid'] = $vo['sourceid'];
     $mgr_data['shopname'] = $shop['name'];
     $mgr_data['shopqishu'] = $shop['qishu'];
     $mgr_data['goucode'] = implode(',', $codes['codes']);
     $mgr_data['code_num'] = $codes['code_len'];
     $timearr = explode(' ', microtime());
     $mgr_data['ms'] = substr($timearr[0], 2, 3);
     $mgr_data['create_time'] = $timearr[1];
     $result = $mgrmodel->add($mgr_data);
     return $result;
 }