示例#1
0
         }
     }
 }
 if ($flag) {
     //清理购物车
     $db->autoDelete('cart', '`business_account`=\'' . $cart['business_account'] . '\' and `account`=\'' . $_SESSION['account'] . '\'');
     $db->commit();
     $response['count']++;
     $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';
示例#2
0
 private function _partner($sn, $data)
 {
     global $db, $config;
     $account = explode('-', $sn);
     $account = $account[0];
     $account = $db->escape($account);
     //支付成功
     if ($config['partner_fee'] * 100 == $data->total_fee && $data->sign == tenpay_sign($data, $this->mch_key)) {
         //是否已是合伙人
         $get_level_id = 'select `level_id` from ' . $db->table('member') . ' where account = \'' . $account . '\' limit 1';
         $level_id = $db->fetchOne($get_level_id);
         if ($level_id == 0) {
             $update_member = 'update ' . $db->table('member') . ' set level_id = 1';
             $update_member .= ' where account = \'' . $account . '\' limit 1';
             $db->update($update_member);
             //赠送积分给合伙人
             add_memeber_exchange_log($account, 0, 0, $config['level_integral'], 0, 0, $account, '成为合伙人赠送积分');
             $get_path = 'select `path` from ' . $db->table('member') . ' where `account`=\'' . $account . '\'';
             $path = $db->fetchOne($get_path);
             distribution_settle($config['partner_fee'], $path, $account . '成为合伙人');
         }
     } else {
         //金额不正确或返回不正确
     }
 }
示例#3
0
 $sn = $db->escape($sn);
 //产品订单
 $get_order_info = 'select * 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'] == $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']);
             //如果是虚拟产品,则生成预约券