コード例 #1
0
ファイル: Wechat.class.php プロジェクト: Winsen1990/easyilife
 private function _pay_order($sn, $data)
 {
     global $db, $log;
     //产品订单
     $get_order_info = 'select `amount`,`account`,`business_account`,`product_amount`,`mobile`,`delivery_fee` from ' . $db->table('order') . ' where `order_sn`=\'' . $sn . '\'';
     $order = $db->fetchRow($get_order_info);
     add_order_log($sn, $order['account'], 3, "在线支付");
     if ($order && $order['amount'] * 100 == $data->total_fee && $data->sign == tenpay_sign($data, $this->mch_key)) {
         //验证订单金额正确
         //1. 设置订单为已付款
         $order_data = array('status' => 3, 'pay_time' => time());
         $flag = $db->autoUpdate('order', $order_data, '`order_sn`=\'' . $sn . '\' and `status`<>3');
         if ($flag && $db->get_affect_rows()) {
             $log->record($sn . '支付成功');
             //2. 订单结算
             $get_path = 'select `path` from ' . $db->table('member') . ' where `account`=\'' . $order['account'] . '\'';
             $path = $db->fetchOne($get_path);
             distribution_settle($order['reward_amount'], $path, $sn);
             //3. 新增商家收入
             $business_income = $order['product_amount'] + $order['delivery_fee'] - $order['reward_amount'];
             if (add_business_exchange($order['business_account'], 0, $business_income, $order['account'], '用户在线支付')) {
                 add_business_trade($order['business_account'], $business_income, $sn);
             } else {
                 //增加商家收入失败
             }
             $get_order_detail = 'select `product_sn`,`product_name`,`count`,`is_virtual`,`attributes` from ' . $db->table('order_detail') . ' where `order_sn`=\'' . $sn . '\'';
             $order_detail = $db->fetchAll($get_order_detail);
             foreach ($order_detail as $od) {
                 //扣减库存
                 consume_inventory($od['product_sn'], $od['attributes'], $od['count']);
                 //如果是虚拟产品,则生成预约券
                 if ($od['is_virtual']) {
                     $get_virtual_contents = 'select `content`,`count`,`total` from ' . $db->table('virtual_content') . ' where `product_sn`=\'' . $od['product_sn'] . '\'';
                     $virtual_contents = $db->fetchAll($get_virtual_contents);
                     $virtual_content = '';
                     if ($virtual_contents) {
                         $virtual_content = serialize($virtual_contents);
                     }
                     add_order_content($order['business_account'], $order['account'], $order['mobile'], $sn, $od['product_sn'], $od['product_name'], $virtual_content, 2);
                 }
             }
             //如果会员购买了activity=4的产品,则升级
             $check_can_levelup = 'select am.`activity_id` from ' . $db->table('activity_mapper') . ' as am left join ' . $db->table('order_detail') . ' using (`product_sn`) where `order_sn`=\'' . $sn . '\' and `activity_id`=4';
             if ($db->fetchOne($check_can_levelup)) {
                 $member_data = array('level_id' => 1);
                 $db->autoUpdate('member', $member_data, '`account`=\'' . $order['account'] . '\'');
             }
         }
     } else {
         //金额不正确
     }
 }
コード例 #2
0
ファイル: order.php プロジェクト: Winsen1990/easyilife
 $response = array('error' => 1, 'msg' => '');
 if ($order_sn == '') {
     $response['msg'] = '订单编号为空';
 } else {
     $order_sn = $db->escape($order_sn);
     $check_order_sn = 'select `order_sn` from ' . $db->table('order') . ' where `order_sn`=\'' . $order_sn . '\' and `account`=\'' . $_SESSION['account'] . '\'';
     $order_sn = $db->fetchOne($check_order_sn);
     if ($order_sn) {
         $data = array('status' => 7);
         if ($db->autoUpdate('order', $data, '`order_sn`=\'' . $order_sn . '\'')) {
             add_order_log($order_sn, $_SESSION['account'], 7, '用户确认收货');
             //将款项打到商家账户中
             //读取担保交易记录,并将款项打入到商家的余额中
             $get_trade = 'select `id`,`business_account`,`trade` from ' . $db->table('trade') . ' where `remark`=\'' . $order_sn . '\' and `status`=0';
             $trade = $db->fetchRow($get_trade);
             if (add_business_exchange($trade['business_account'], $trade['trade'], -1 * $trade['trade'], $_SESSION['account'], '用户确认收货')) {
                 $trade_status = array('status' => 1, 'solve_time' => time());
                 $db->autoUpdate('trade', $trade_status, '`id`=' . $trade['id']);
             }
             //读取佣金,将佣金发放到用户账户里
             $get_member_rewards = 'select `id`,`remark`,`integral`,`account`,`reward` from ' . $db->table('member_reward') . ' where `status`=0 and `assoc`=\'' . $order_sn . '\'';
             $member_rewards = $db->fetchAll($get_member_rewards);
             if ($member_rewards) {
                 foreach ($member_rewards as $reward) {
                     if (add_memeber_exchange_log($reward['account'], 0, $reward['reward'], $reward['integral'], -1 * $reward['integral'], -1 * $reward['reward'], $_SESSION['account'], $order_sn . '奖金发放')) {
                         $reward_status = array('status' => 1, 'solve_time' => time());
                         $db->autoUpdate('member_reward', $reward_status, '`id`=' . $reward['id']);
                     }
                 }
             }
             $response['error'] = 0;
コード例 #3
0
ファイル: checkout.php プロジェクト: Winsen1990/easyilife
     $response['error'] = 0;
     $_SESSION['order_sn'] = $order_sn;
     //订单结算
     if ($status == 4) {
         $log->record('计算三级分销');
         //计算三级分销
         $log->record('计算分销奖金:' . $cart['total_reward']);
         distribution_settle($cart['total_reward'], $user_info['path'], $order_sn);
         //计算赠送积分
         if ($total_integral_given) {
             add_memeber_exchange_log($_SESSION['account'], 0, 0, 0, $cart['total_integral_given'], 0, 'settle', '系统结算');
             add_member_reward($_SESSION['account'], 0, $cart['total_integral_given'], '订单' . $order_sn . '赠送积分');
         }
         //计入商家收入
         $business_income = $cart['total_product_amount'] + $cart['total_delivery_fee'] - $cart['total_reward'];
         if (add_business_exchange($cart['business_account'], 0, $business_income, $_SESSION['account'], $order_sn . '支付成功')) {
             add_business_trade($cart['business_account'], $business_income, $order_sn);
         } else {
             //增加商家收入失败
             $log->record($order_sn . '计入商家收入失败');
         }
         //如果会员购买了activity=4的产品,则升级
         $check_can_levelup = 'select am.`activity_id` from ' . $db->table('activity_mapper') . ' as am left join ' . $db->table('order_detail') . ' using (`product_sn`) where `order_sn`=\'' . $order_sn . '\' and `activity_id`=4';
         if ($db->fetchOne($check_can_levelup)) {
             $member_data = array('level_id' => 1);
             $db->autoUpdate('member', $member_data, '`account`=\'' . $_SESSION['account'] . '\'');
         }
     }
 } else {
     $db->rollback();
     $response['msg'] = '提交订单信息失败,请稍后再试';
コード例 #4
0
 $order = $db->fetchRow($get_order_info);
 add_order_log($sn, $order['account'], 3, "在线支付");
 if ($order && $order['amount'] == $total_fee) {
     //验证订单金额正确
     //1. 设置订单为已付款
     $order_data = array('status' => 3, 'pay_time' => time());
     $flag = $db->autoUpdate('order', $order_data, '`order_sn`=\'' . $sn . '\' and `status`<3');
     if ($flag && $db->get_affect_rows()) {
         $log->record($sn . '支付成功');
         //2. 订单结算
         $get_path = 'select `path` from ' . $db->table('member') . ' where `account`=\'' . $order['account'] . '\'';
         $path = $db->fetchOne($get_path);
         distribution_settle($order['reward_amount'], $path, $sn);
         //3. 新增商家收入
         $business_income = $order['product_amount'] + $order['delivery_fee'] - $order['reward_amount'];
         if (add_business_exchange($order['business_account'], 0, $business_income, $order['account'], '用户在线支付')) {
             add_business_trade($order['business_account'], $business_income, $sn);
         } else {
             //增加商家收入失败
         }
         $get_order_detail = 'select `product_sn`,`product_name`,`count`,`is_virtual`,`attributes` from ' . $db->table('order_detail') . ' where `order_sn`=\'' . $sn . '\'';
         $order_detail = $db->fetchAll($get_order_detail);
         foreach ($order_detail as $od) {
             //状态变为已发货
             $delivery = false;
             //扣减库存
             consume_inventory($od['product_sn'], $od['attributes'], $od['count']);
             //如果是虚拟产品,则生成预约券
             if ($od['is_virtual']) {
                 $get_virtual_contents = 'select `content`,`count`,`total` from ' . $db->table('virtual_content') . ' where `product_sn`=\'' . $od['product_sn'] . '\'';
                 $virtual_contents = $db->fetchAll($get_virtual_contents);