本文整理汇总了PHP中syn_deal_status函数的典型用法代码示例。如果您正苦于以下问题:PHP syn_deal_status函数的具体用法?PHP syn_deal_status怎么用?PHP syn_deal_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了syn_deal_status函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_goods
/**
* 获取指定的产品
*/
function get_goods($id = 0, $preview = 0)
{
static $deal;
if ($deal) {
return $deal;
}
$deal = syn_deal_status($id);
if ($preview) {
$deal = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . intval($id) . " and is_delete = 0 ");
}
if ($deal) {
$static_deal = load_auto_cache("static_goods_info", array("id" => $deal['id']));
foreach ($static_deal as $k => $v) {
$deal[$k] = $v;
}
if ($GLOBALS['user_info']) {
if (app_conf("URL_MODEL") == 0) {
$deal['share_url'] .= "&r=" . base64_encode(intval($GLOBALS['user_info']['id']));
} else {
$deal['share_url'] .= "?r=" . base64_encode(intval($GLOBALS['user_info']['id']));
}
}
//查询抽奖号
$deal['lottery_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "lottery where deal_id = " . intval($deal['id']) . " and buyer_id <> 0 ")) + intval($deal['buy_count']);
//开始获取处理库存
$deal['stock'] = $deal['max_bought'] - $deal['buy_count'];
}
return $deal;
}
示例2: update
public function update()
{
B('FilterString');
$data = M("Deal")->create();
$log_info = M("Deal")->where("id=" . intval($data['id']))->getField("name");
//开始验证有效性
$this->assign("jumpUrl", "javascript:history.back(-1);");
if (!check_empty($data['name'])) {
$this->error(L("DEAL_NAME_EMPTY_TIP"));
}
if (!check_empty($data['sub_name'])) {
$this->error(L("DEAL_SUB_NAME_EMPTY_TIP"));
}
if ($data['cate_id'] == 0) {
$this->error(L("DEAL_CATE_EMPTY_TIP"));
}
if (D("Deal")->where("deal_sn='" . $data['deal_sn'] . "' and id<>" . $data['id'])->count() > 0) {
$this->error("借款编号已存在");
}
$loantype_list = load_auto_cache("loantype_list");
if (!in_array($data['repay_time_type'], $loantype_list[$data['loantype']]['repay_time_type'])) {
$this->error("还款方式不支持当前借款期限类型");
}
$data['update_time'] = TIME_UTC;
$data['publish_wait'] = 0;
$data['start_time'] = trim($data['start_time']) == '' ? 0 : to_timespan($data['start_time']);
$user_info = M("User")->getById($data['user_id']);
$old_imgdata_str = unserialize($user_info['view_info']);
$data['view_info'] = array();
foreach ($_REQUEST['key'] as $k => $v) {
if (isset($old_imgdata_str[$v])) {
$data['view_info'][$v] = $old_imgdata_str[$v];
}
}
$data['view_info'] = serialize($data['view_info']);
if ($data['deal_status'] == 4) {
if ($GLOBALS['db']->getOne("SELECT sum(money) FROM " . DB_PREFIX . "deal_load where deal_id=" . $data['id']) < floatval($data['borrow_amount'])) {
$this->error("未满标无法设置为还款状态!");
exit;
}
}
if ($data['agency_id'] != M("Deal")->where("id=" . $data['id'])->getField("agency_id")) {
$data['agency_status'] = 0;
}
// 更新数据
$list = M("Deal")->save($data);
if (false !== $list) {
M("DealCityLink")->where("deal_id=" . $data['id'])->delete();
foreach ($_REQUEST['city_id'] as $k => $v) {
if (intval($v) > 0) {
$deal_city_link['deal_id'] = $data['id'];
$deal_city_link['city_id'] = intval($v);
M("DealCityLink")->add($deal_city_link);
}
}
require_once APP_ROOT_PATH . "app/Lib/common.php";
if ($data['is_delete'] == 3) {
//发送失败短信通知
if (app_conf("SMS_ON") == 1) {
$user_info = D("User")->where("id=" . $data['user_id'])->find();
$deal_info = D("Deal")->where("id=" . $data['id'])->find();
$tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_SMS_DEAL_DELETE'");
$tmpl_content = $tmpl['content'];
$notice['user_name'] = $user_info["user_name"];
$notice['deal_name'] = $data['name'];
$notice['site_name'] = app_conf("SHOP_TITLE");
$notice['delete_msg'] = $data['delete_msg'];
$notice['deal_publish_time'] = to_date($deal_info['create_time'], "Y年m月d日");
$GLOBALS['tmpl']->assign("notice", $notice);
$msg = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content);
$msg_data['dest'] = $user_info['mobile'];
$msg_data['send_type'] = 0;
$msg_data['title'] = "审核失败通知";
$msg_data['content'] = addslashes($msg);
$msg_data['send_time'] = 0;
$msg_data['is_send'] = 0;
$msg_data['create_time'] = TIME_UTC;
$msg_data['user_id'] = $user_info['id'];
$msg_data['is_html'] = $tmpl['is_html'];
$GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data);
//插入
}
} else {
//成功提示
syn_deal_status($data['id']);
syn_deal_match($data['id']);
//发送电子协议邮件
require_once APP_ROOT_PATH . "app/Lib/deal.php";
send_deal_contract_email($data['id'], array(), $data['user_id']);
}
//成功提示
save_log("编号:" . $data['id'] . "," . $log_info . L("UPDATE_SUCCESS"), 1);
$this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $data['id'])));
$this->success(L("UPDATE_SUCCESS"));
} else {
//错误提示
$dbErr = M()->getDbError();
save_log("编号:" . $data['id'] . "," . $log_info . L("UPDATE_FAILED") . $dbErr, 0);
$this->error(L("UPDATE_FAILED") . $dbErr, 0);
}
//.........这里部分代码省略.........
示例3: getUcDoTransfer
/**
* 执行转让
*/
function getUcDoTransfer($id, $tid, $paypassword, $transfer_money)
{
$paypassword = strim($paypassword);
$id = intval($id);
$tid = intval($tid);
$transfer_money = floatval($transfer_money);
$status = array('status' => 0, 'show_err' => '');
if ($id == 0) {
$status['status'] = 0;
$status['show_err'] = "不存在的债权";
return $status;
}
if ($transfer_money <= 0) {
$status['status'] = 0;
$status['show_err'] = "转让金额必须大于0";
return $status;
}
$deal_id = $GLOBALS['db']->getOne("SELECT deal_id FROM " . DB_PREFIX . "deal_load WHERE id=" . $id);
if ($deal_id == 0) {
$status['status'] = 0;
$status['show_err'] = "不存在的债权";
return $status;
} else {
syn_deal_status($deal_id);
}
//判断支付密码是否正确
if ($paypassword == "") {
$status['status'] = 0;
$status['show_err'] = $GLOBALS['lang']['PAYPASSWORD_EMPTY'];
return $status;
}
if (md5($paypassword) != $GLOBALS['user_info']['paypassword']) {
$status['status'] = 0;
$status['show_err'] = $GLOBALS['lang']['PAYPASSWORD_ERROR'];
return $status;
}
$condition = ' AND dl.id=' . $id . ' AND d.deal_status = 4 and d.is_effect=1 and d.is_delete=0 and d.repay_time_type =1 and d.publish_wait=0 and dl.user_id=' . $GLOBALS['user_info']['id'] . " and d.next_repay_time - " . TIME_UTC . " + 24*3600 - 1 > 0 ";
$union_sql = " LEFT JOIN " . DB_PREFIX . "deal_load_transfer dlt ON dlt.deal_id = dl.deal_id and dlt.load_id=dl.id ";
$sql = 'SELECT dl.id as dlid,d.*,dl.money as load_money,dlt.status as tras_status,dlt.t_user_id,dlt.transfer_amount,dlt.create_time as tras_create_time FROM ' . DB_PREFIX . 'deal_load dl LEFT JOIN ' . DB_PREFIX . 'deal d ON d.id = dl.deal_id ' . $union_sql . ' WHERE 1=1 ' . $condition;
$transfer = $GLOBALS['db']->getRow($sql);
if ($transfer) {
//下个还款日
if (intval($transfer['next_repay_time']) == 0) {
$transfer['next_repay_time'] = next_replay_month($transfer['repay_start_time']);
}
if ($transfer['next_repay_time'] - TIME_UTC + 24 * 3600 - 1 < 0) {
$status['status'] = 0;
$status['show_err'] = "转让操作失败,有逾期未还款存在!";
return $status;
}
//还款日
$transfer['final_repay_time'] = next_replay_month($transfer['repay_start_time'], $transfer['repay_time']);
//剩余期数
if (intval($transfer['last_repay_time']) > 0) {
$transfer['how_much_month'] = how_much_month($transfer['last_repay_time'], $transfer['final_repay_time']);
} else {
$transfer['how_much_month'] = how_much_month($transfer['repay_start_time'], $transfer['final_repay_time']);
}
$transfer_rs = deal_transfer($transfer);
$transfer['month_repay_money'] = $transfer_rs['month_repay_money'];
$transfer['all_must_repay_money'] = $transfer_rs['all_must_repay_money'];
$transfer['left_benjin'] = $transfer_rs['left_benjin'];
//剩多少利息
$transfer['left_lixi'] = $transfer['all_must_repay_money'] - $transfer['left_benjin'];
//判断转让金额是否超出了可转让的界限
if (round($transfer_money, 2) > round(floatval($transfer['all_must_repay_money']), 2)) {
$status['status'] = 0;
$status['show_err'] = "转让金额不得大于最大转让金额";
return $status;
}
$transfer_data['create_time'] = TIME_UTC;
$transfer_data['create_date'] = to_date(TIME_UTC);
$transfer_data['deal_id'] = $transfer['id'];
$transfer_data['load_id'] = $id;
$transfer_data['user_id'] = $GLOBALS['user_info']['id'];
$transfer_data['transfer_number'] = $transfer['how_much_month'];
$transfer_data['last_repay_time'] = $transfer['final_repay_time'];
$transfer_data['load_money'] = $transfer['load_money'];
$transfer_data['status'] = 1;
$transfer_data['transfer_amount'] = $transfer_money;
$transfer_data['near_repay_time'] = $transfer['next_repay_time'];
if ($tid > 0) {
$GLOBALS['db']->autoExecute(DB_PREFIX . "deal_load_transfer", $transfer_data, "UPDATE", "id=" . $tid);
} else {
$GLOBALS['db']->autoExecute(DB_PREFIX . "deal_load_transfer", $transfer_data);
}
if ($GLOBALS['db']->affected_rows()) {
$status['status'] = 1;
$status['show_err'] = "转让操作成功";
return $status;
} else {
$status['status'] = 0;
$status['show_err'] = "转让操作失败";
return $status;
}
} else {
$status['status'] = 0;
//.........这里部分代码省略.........
示例4: autobid
function autobid()
{
$deal_list = $GLOBALS['db']->getAll("SELECT * FROM " . DB_PREFIX . "Deal limit 1000");
foreach ($deal_list as $v) {
syn_deal_status($v['id']);
}
}
示例5: index
public function index()
{
$add_order_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "add_order where time < " . time() . " and state=0");
if ($add_order_list) {
$deal_id_array = array();
foreach ($add_order_list as $key => $val) {
if (!in_array($val['deal_id'], $deal_id_array)) {
$deal_id_array[] = $val['deal_id'];
}
$tmp_deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $val['deal_id']);
$tmp_deal_item_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_item where id = " . $val['deal_item_id']);
for ($i = 0; $i < $val['num']; $i++) {
$tmp_num = rand(0, 50000);
$tmp_time = rand(100, 86000);
//获取导入用户
$tmp_user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where login_ip = '' limit " . $tmp_num . ",1");
$tmp_order_info = array();
$tmp_order_info['deal_id'] = $val['deal_id'];
$tmp_order_info['deal_item_id'] = $val['deal_item_id'];
$tmp_order_info['user_id'] = $tmp_user_info['id'];
$tmp_order_info['user_name'] = $tmp_user_info['user_name'];
$tmp_order_info['pay_time'] = $val['time'] + $tmp_time;
$tmp_order_info['total_price'] = $tmp_deal_item_info['delivery_fee'] + $tmp_deal_item_info['price'];
$tmp_order_info['delivery_fee'] = $tmp_deal_item_info['delivery_fee'];
$tmp_order_info['deal_price'] = $tmp_deal_item_info['price'];
$tmp_order_info['support_memo'] = '支持!加油!';
$tmp_order_info['payment_id'] = 35;
$tmp_order_info['credit_pay'] = 0;
$tmp_order_info['online_pay'] = $tmp_deal_item_info['delivery_fee'] + $tmp_deal_item_info['price'];
$tmp_order_info['deal_name'] = $tmp_deal_info['name'];
$tmp_order_info['order_status'] = 3;
$tmp_order_info['create_time'] = $val['time'] + $tmp_time;
$tmp_order_info['is_has_send_success'] = 1;
if ($tmp_deal_item_info['is_delivery'] == 1) {
$tmp_order_info['consignee'] = '杨小帆';
$tmp_order_info['mobile'] = '18601911314';
$tmp_order_info['province'] = '北京';
$tmp_order_info['city'] = '东城区';
$tmp_order_info['address'] = '朝阳门 银河SOHO D2座 5层 50538';
}
$GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $tmp_order_info);
}
$GLOBALS['db']->query("update " . DB_PREFIX . "add_order set state = 1 where id = " . $val['id']);
}
foreach ($deal_id_array as $k2 => $v2) {
$id = $v2;
$order_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order where deal_id = " . $id . " and order_status=3");
$item_array = array();
foreach ($order_list as $k => $v) {
$log_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_support_log where deal_id = " . $v['deal_id'] . " and user_id=" . $v['user_id'] . " and create_time='" . $v['pay_time'] . "' and deal_item_id=" . $v['deal_item_id']);
if ($log_list) {
} else {
$tmp_log_info = array();
$tmp_log_info['deal_id'] = $v['deal_id'];
$tmp_log_info['deal_item_id'] = $v['deal_item_id'];
$tmp_log_info['user_id'] = $v['user_id'];
$tmp_log_info['create_time'] = $v['pay_time'];
$tmp_log_info['price'] = $v['total_price'];
$GLOBALS['db']->autoExecute(DB_PREFIX . "deal_support_log", $tmp_log_info);
$tmp_log_id = $GLOBALS['db']->insert_id();
echo 'add log id = ' . $tmp_log_id . ' 。' . "<br>";
}
if (isset($item_array[$v['deal_item_id']])) {
$item_array[$v['deal_item_id']]['num'] += 1;
$item_array[$v['deal_item_id']]['total'] += $v['total_price'];
} else {
$item_array[$v['deal_item_id']] = array();
$item_array[$v['deal_item_id']]['num'] = 1;
$item_array[$v['deal_item_id']]['total'] = $v['total_price'];
}
}
foreach ($item_array as $ki => $vi) {
$GLOBALS['db']->query("update " . DB_PREFIX . "deal_item set support_count = " . intval($vi['num']) . ",support_amount = " . intval($vi['total']) . " where id = " . $ki);
echo 'update item num = ' . $vi['num'] . "<br>";
}
syn_deal_status($id);
syn_deal($id);
echo 'OK';
}
}
}
示例6: dtcontact
function dtcontact()
{
$win = 1;
$GLOBALS['tmpl']->assign("page_title", $GLOBALS['lang']['TT_CONTACT'] . ' - ' . $GLOBALS['lang']['TOOLS']);
$id = intval($_REQUEST['id']);
if ($id > 0) {
//先执行更新借贷信息
$deal_id = $GLOBALS['db']->getOne("SELECT deal_id FROM " . DB_PREFIX . "deal_load_transfer WHERE id=" . $id);
if ($deal_id == 0) {
echo "不存在的债权";
die;
} else {
syn_deal_status($deal_id);
}
$condition = ' AND dlt.id=' . $id . ' AND d.deal_status >= 4 and d.is_effect=1 and d.is_delete=0 and d.repay_time_type =1 and d.publish_wait=0 and (dlt.user_id=' . $GLOBALS['user_info']['id'] . ' or dlt.t_user_id = ' . $GLOBALS['user_info']['id'] . ') ';
$union_sql = " LEFT JOIN " . DB_PREFIX . "deal_load_transfer dlt ON dlt.deal_id = dl.deal_id ";
require APP_ROOT_PATH . "/app/Lib/deal_func.php";
$transfer = get_transfer($union_sql, $condition);
if ($transfer) {
$GLOBALS['tmpl']->assign('transfer', $transfer);
} else {
echo "不存在的债权";
die;
}
$GLOBALS['tmpl']->assign('SITE_URL', str_replace(array("https://", "http://"), "", SITE_DOMAIN));
$GLOBALS['tmpl']->assign('SITE_TITLE', app_conf("SITE_TITLE"));
$GLOBALS['tmpl']->assign('CURRENCY_UNIT', app_conf("CURRENCY_UNIT"));
$contract = $GLOBALS['tmpl']->fetch("str:" . get_contract($transfer['tcontract_id']));
$GLOBALS['tmpl']->assign('contract', $contract);
}
require APP_ROOT_PATH . "/system/utils/word.php";
$word = new word();
$word->start();
$wordname = "债权转让及受让协议.doc";
echo $GLOBALS['tmpl']->fetch("inc/tool/tcontact.html");
$word->save($wordname);
}
示例7: shop_update
//.........这里部分代码省略.........
$attr_cfg = $_REQUEST['stock_attr'];
$attr_str = $_REQUEST['stock_cfg'];
foreach ($stock_cfg as $row => $v) {
$stock_data = array();
$stock_data['deal_id'] = $data['id'];
$stock_data['stock_cfg'] = $v;
$stock_data['attr_str'] = $attr_str[$row];
$attr_cfg_data = array();
foreach ($attr_cfg as $attr_id => $cfg) {
$attr_cfg_data[$attr_id] = $cfg[$row];
}
$stock_data['attr_cfg'] = serialize($attr_cfg_data);
$sql = "select sum(oi.number) from " . DB_PREFIX . "deal_order_item as oi left join " . DB_PREFIX . "deal as d on d.id = oi.deal_id left join " . DB_PREFIX . "deal_order as do on oi.order_id = do.id where" . " do.pay_status = 2 and do.is_delete = 0 and d.id = " . $data['id'] . " and oi.attr_str like '%" . $attr_str[$row] . "%'";
$stock_data['buy_count'] = intval($GLOBALS['db']->getOne($sql));
M("AttrStock")->add($stock_data);
}
M("FreeDelivery")->where("deal_id=" . $data['id'])->delete();
if (intval($_REQUEST['free_delivery']) == 1) {
$delivery_ids = $_REQUEST['delivery_id'];
$free_counts = $_REQUEST['free_count'];
foreach ($delivery_ids as $k => $v) {
$free_conf = array();
$free_conf['delivery_id'] = $delivery_ids[$k];
$free_conf['free_count'] = $free_counts[$k];
$free_conf['deal_id'] = $data['id'];
M("FreeDelivery")->add($free_conf);
}
}
M("DealPayment")->where("deal_id=" . $data['id'])->delete();
if (intval($_REQUEST['define_payment']) == 1) {
$payment_ids = $_REQUEST['payment_id'];
foreach ($payment_ids as $k => $v) {
$payment_conf = array();
$payment_conf['payment_id'] = $payment_ids[$k];
$payment_conf['deal_id'] = $data['id'];
M("DealPayment")->add($payment_conf);
}
}
M("DealDelivery")->where("deal_id=" . $data['id'])->delete();
$delivery_ids = $_REQUEST['forbid_delivery_id'];
foreach ($delivery_ids as $k => $v) {
$delivery_conf = array();
$delivery_conf['delivery_id'] = $delivery_ids[$k];
$delivery_conf['deal_id'] = $data['id'];
M("DealDelivery")->add($delivery_conf);
}
//开始创建筛选项
M("DealFilter")->where("deal_id=" . $data['id'])->delete();
$filter = $_REQUEST['filter'];
foreach ($filter as $filter_group_id => $filter_value) {
$filter_data = array();
$filter_data['filter'] = $filter_value;
$filter_data['filter_group_id'] = $filter_group_id;
$filter_data['deal_id'] = $data['id'];
M("DealFilter")->add($filter_data);
// $filter_array = preg_split("/[ ,]/i",$filter_value);
// foreach($filter_array as $filter_item)
// {
// $filter_row = M("Filter")->where("filter_group_id = ".$filter_group_id." and name = '".$filter_item."'")->find();
// if(!$filter_row)
// {
// if(strim($filter_item)!='')
// {
// $filter_row = array();
// $filter_row['name'] = $filter_item;
// $filter_row['filter_group_id'] = $filter_group_id;
// M("Filter")->add($filter_row);
// }
//
// }
// }
}
M("DealLocationLink")->where("deal_id=" . $data['id'])->delete();
foreach ($_REQUEST['location_id'] as $location_id) {
$link_data = array();
$link_data['location_id'] = $location_id;
$link_data['deal_id'] = $data['id'];
M("DealLocationLink")->add($link_data);
}
//成功提示
syn_deal_status($data['id']);
syn_deal_match($data['id']);
syn_attr_stock_key($data['id']);
//对于商户请求操作
if (intval($_REQUEST['edit_type']) == 2 && $deal_submit_id > 0) {
//商户提交修改审核
/*同步商户发布表状态*/
$GLOBALS['db']->autoExecute(DB_PREFIX . "deal_submit", array("admin_check_status" => 1), "UPDATE", "id=" . $deal_submit_id);
// 1 通过 2 拒绝',
}
//成功提示
save_log($log_info . L("UPDATE_SUCCESS"), 1);
$this->success(L("UPDATE_SUCCESS"));
} else {
//错误提示
$dbErr = M()->getDbError();
save_log($log_info . L("UPDATE_FAILED") . $dbErr, 0);
$this->error(L("UPDATE_FAILED") . $dbErr, 0);
}
}
示例8: update_deal_vote
public function update_deal_vote()
{
B('FilterString');
$ajax = intval($_REQUEST['ajax']);
$data = M("DealVote")->create();
$data['moeny'] = format_price($data['money']);
//开始验证有效性
$this->assign("jumpUrl", u(MODULE_NAME . "/edit_deal_vote", array("id" => $data['id'])));
if (!check_empty($data['moeny'])) {
$this->error("请输入卖出金额");
}
$data['begin_time'] = trim($data['begin_time']) == '' ? 0 : to_timespan($data['begin_time']);
$data['end_time'] = trim($data['end_time']) == '' ? 0 : to_timespan($data['end_time']);
$data['create_time'] = get_gmtime();
// 更新数据
$this->deal_update(intval($data['deal_id']));
$list = M("DealVote")->save($data);
$log_info = "项目ID" . $data['deal_id'] . ":" . format_price($data['money']);
if (false !== $list) {
if ($data['virtual_person'] > 0) {
}
//成功提示
M("Deal")->where("id=" . $data['deal_id'])->setField("deal_extra_cache", "");
//end 处理图片
save_log($log_info . L("UPDATE_SUCCESS"), 1);
syn_deal($data['deal_id']);
syn_deal_status($data['deal_id']);
$this->success(L("UPDATE_SUCCESS"));
} else {
//错误提示
save_log($log_info . L("UPDATE_FAILED"), 0);
$this->error(L("UPDATE_FAILED"));
}
}
示例9: syn_deal_repay_status
/**
* 更新 用户回款 计划数据
* @param unknown_type $deal_id
* @param unknown_type $deal_repay_id
*/
function syn_deal_repay_status($deal_id, $deal_repay_id)
{
//has_repay 0未收到还款,1已收到还款
$deal_id = intval($deal_id);
$deal_repay_id = intval($deal_repay_id);
$deal = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "deal WHERE id=" . $deal_id);
$deal['url'] = url("index", "deal", array("id" => $deal['id']));
$deal["user"] = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "user WHERE id=" . $deal['user_id']);
//未还款记录数
$sql = "select count(*) from " . DB_PREFIX . "deal_load_repay where has_repay = 0 and deal_id = " . $deal_id . " and repay_id = " . $deal_repay_id;
$has_repay_0 = $GLOBALS['db']->getOne($sql);
//已经还款记录数
$sql = "select count(*) from " . DB_PREFIX . "deal_load_repay where has_repay = 1 and deal_id = " . $deal_id . " and repay_id = " . $deal_repay_id;
$has_repay_1 = $GLOBALS['db']->getOne($sql);
//第几期
$kk = $GLOBALS['db']->getOne("select l_key from " . DB_PREFIX . "deal_load_repay where deal_id = " . $deal_id . " and repay_id = " . $deal_repay_id);
//has_repay 0未还,1已还 2部分还款
if ($has_repay_0 == 0 && $has_repay_1 == 0 || $has_repay_0 == 0 && $has_repay_1 > 0) {
$deal_rs_sql = "select sum(true_interest_money) as total_true_interest_money," . "sum(true_self_money) as total_true_self_money," . "sum(true_repay_money) as total_true_repay_money," . "sum(true_repay_manage_money) as total_true_repay_manage_money," . "sum(repay_manage_impose_money) as total_repay_manage_impose_money, " . "sum(impose_money) as total_impose_money " . "from " . DB_PREFIX . "deal_load_repay where deal_id = " . $deal_id . " and repay_id = " . $deal_repay_id;
$deal_rs = $GLOBALS['db']->getRow($deal_rs_sql);
$last_Rs = $GLOBALS['db']->getRow("SELECT `status`,`true_repay_time`,`repay_time` from " . DB_PREFIX . "deal_load_repay where deal_id = " . $deal_id . " and repay_id = " . $deal_repay_id . " ORDER BY `true_repay_time` DESC");
$deal_repay_data['true_repay_money'] = $deal_rs['total_true_repay_money'];
$deal_repay_data['true_manage_money'] = $deal_rs['total_true_repay_manage_money'];
$deal_repay_data['manage_impose_money'] = $deal_rs['total_repay_manage_impose_money'];
$deal_repay_data['true_self_repay'] = $deal_rs['total_true_self_money'];
$deal_repay_data['impose_money'] = $deal_rs['total_impose_money'];
$deal_repay_data['true_interest_money'] = $deal_rs['total_true_interest_money'];
$deal_repay_data['true_repay_time'] = $last_Rs['true_repay_time'];
$deal_repay_data['true_repay_date'] = to_date($last_Rs['true_repay_time']);
$deal_repay_data['status'] = $last_Rs['status'];
$deal_repay_data['has_repay'] = 1;
//返佣金额
$rebate_rs = get_rebate_fee($deal['user_id'], "borrow");
$deal_repay_data['true_manage_money_rebate'] = floatval($deal_repay_data['true_manage_money']) * floatval($rebate_rs['rebate']) / 100;
$true_manage_money_rebate = $deal_repay_data['true_manage_money'] * floatval($rebate_rs['rebate']) / 100;
//借款者返佣
if ($true_manage_money_rebate != 0) {
/*ok*/
$reback_memo = sprintf($GLOBALS['lang']["BORROW_REBATE_LOG"], $deal["url"], $deal["name"], $deal["user"]["user_name"], intval($kk) + 1);
reback_rebate_money($deal['user_id'], $true_manage_money_rebate, "borrow", $reback_memo);
}
require_once APP_ROOT_PATH . "system/libs/user.php";
if ($last_Rs['status'] > 1) {
$impose_day = ceil(($last_Rs['true_repay_time'] - $last_Rs['repay_time'] + 24 * 3600 - 1) / 24 / 3600);
//VIP降级-逾期还款
$type = 2;
$type_info = 5;
$resultdate = syn_user_vip($deal['user_id'], $type, $type_info);
if ($impose_day < app_conf('YZ_IMPSE_DAY')) {
modify_account(array("point" => trim(app_conf('IMPOSE_POINT'))), $deal['user_id'], "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],第" . ($kk + 1) . "期,逾期还款", 11);
$repay_update_data['status'] = 2;
} else {
modify_account(array("point" => trim(app_conf('YZ_IMPOSE_POINT'))), $deal['user_id'], "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],第" . ($kk + 1) . "期,严重逾期", 11);
$repay_update_data['status'] = 3;
}
} elseif ($last_Rs['status'] == 1) {
//VIP升级 -正常还款
$type = 1;
$type_info = 3;
$resultdate = syn_user_vip($deal['user_id'], $type, $type_info);
} elseif ($last_Rs['status'] == 0) {
//VIP升级 -提前还款
$type = 1;
$type_info = 4;
$resultdate = syn_user_vip($deal['user_id'], $type, $type_info);
}
$GLOBALS['db']->autoExecute(DB_PREFIX . "deal_repay", $deal_repay_data, "UPDATE", "id = " . $deal_repay_id);
$last_repay_key = $kk;
//判断本借款是否还款完毕
if ($GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "deal_repay WHERE deal_id=" . $deal['id'] . " and l_key=" . $last_repay_key . " AND has_repay <> 1 ") == 0) {
//全部还完
if ($GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "deal_repay WHERE deal_id=" . $deal['id'] . " and has_repay=0 ") == 0) {
//判断获取的信用是否超过限制
if ($GLOBALS['db']->getOne("SELECT sum(point) FROM " . DB_PREFIX . "user_point_log WHERE `type`=6 AND user_id=" . $deal['user_id']) < (int) trim(app_conf('REPAY_SUCCESS_LIMIT'))) {
//获取上一次还款时间
$befor_repay_time = $GLOBALS['db']->getOne("SELECT MAX(create_time) FROM " . DB_PREFIX . "user_point_log WHERE `type`=6 AND user_id=" . $deal['user_id']);
$day = ceil(($last_Rs['true_repay_time'] - $befor_repay_time) / 24 / 3600);
//当天数大于等于间隔时间 获得信用
if ($day >= (int) trim(app_conf('REPAY_SUCCESS_DAY'))) {
modify_account(array("point" => trim(app_conf('REPAY_SUCCESS_POINT'))), $deal['user_id'], "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],还清借款", 4);
}
}
//用户获得额度
modify_account(array("quota" => trim(app_conf('USER_REPAY_QUOTA'))), $deal['user_id'], "[<a href='" . $deal['url'] . "' target='_blank'>" . $deal['name'] . "</a>],还清借款获得额度", 4);
}
}
sys_user_status(intval($GLOBALS['user_info']['id']), false, true);
syn_deal_status($deal_id);
syn_transfer_status(0, $deal_id);
} else {
if ($has_repay_0 > 0 && $has_repay_1 == 0) {
$sql = "update " . DB_PREFIX . "deal_repay set has_repay = 0 where id = " . $deal_repay_id;
} else {
$sql = "update " . DB_PREFIX . "deal_repay set has_repay = 2 where id = " . $deal_repay_id;
}
//.........这里部分代码省略.........
示例10: show_detail
public function show_detail()
{
require_once APP_ROOT_PATH . "app/Lib/common.php";
require_once APP_ROOT_PATH . "app/Lib/deal.php";
$id = intval($_REQUEST['id']);
syn_deal_status($id);
$deal_info = M("Deal")->getById($id);
$this->assign("deal_info", $deal_info);
$true_repay_money = M("DealLoadRepay")->where("deal_id=" . $id)->sum("repay_money");
$this->assign("true_repay_money", floatval($true_repay_money) + 1);
$count = D("DealLoad")->where('deal_id=' . $id)->order("id ASC")->count();
if (!empty($_REQUEST['listRows'])) {
$listRows = $_REQUEST['listRows'];
} else {
$listRows = '';
}
$p = new Page($count, $listRows);
if ($count > 0) {
$loan_list = D("DealLoad")->where('deal_id=' . $id)->order("id ASC")->limit($p->firstRow . ',' . $p->listRows)->findall();
$this->assign("loan_list", $loan_list);
}
$page = $p->show();
$this->assign("page", $page);
$this->display();
}
示例11: get_youhui
/**
* 获取指定的优惠券
*/
function get_youhui($id = 0, $preview = 0)
{
$time = get_gmtime();
if ($id > 0) {
syn_deal_status($id);
if ($preview == 0) {
$deal = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . intval($id) . " and is_effect = 1 and is_delete = 0 and is_shop = 2 ");
} else {
$deal = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . intval($id) . " and is_delete = 0 and is_shop = 2 ");
}
}
if ($deal) {
//格式化数据
$deal['origin_price_format'] = format_price($deal['origin_price']);
$deal['current_price_format'] = format_price($deal['current_price']);
if ($deal['origin_price'] > 0 && floatval($deal['discount']) == 0) {
//手动折扣
$deal['save_price'] = $deal['origin_price'] - $deal['current_price'];
} else {
$deal['save_price'] = $deal['origin_price'] * ((10 - $deal['discount']) / 10);
}
if ($deal['origin_price'] > 0 && floatval($deal['discount']) == 0) {
$deal['discount'] = round($deal['current_price'] / $deal['origin_price'] * 10, 2);
}
$deal['discount'] = round($deal['discount'], 2);
$deal['save_price_format'] = format_price($deal['save_price']);
//团购图片集
$img_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_gallery where deal_id=" . intval($deal['id']) . " order by sort asc");
foreach ($img_list as $k => $v) {
$img_list[$k]['origin_img'] = preg_replace("/\\/big\\//", "/origin/", $v['img']);
}
$deal['image_list'] = $img_list;
//商户信息
$deal['supplier_info'] = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier where id = " . intval($deal['supplier_id']));
$deal['supplier_address_info'] = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_location where supplier_id = " . intval($deal['supplier_id']) . " and is_main = 1");
//品牌信息
$deal['brand_info'] = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "brand where id = " . intval($deal['brand_id']));
//属性列表
$deal_attrs_res = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_attr where deal_id = " . intval($deal['id']) . " order by id asc");
if ($deal_attrs_res) {
foreach ($deal_attrs_res as $k => $v) {
$deal_attr[$v['goods_type_attr_id']]['name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "goods_type_attr where id = " . intval($v['goods_type_attr_id']));
$deal_attr[$v['goods_type_attr_id']]['attrs'][] = $v;
}
$deal['deal_attr_list'] = $deal_attr;
}
if ($deal['uname'] != '') {
$gurl = url("shop", "goods", array("id" => $deal['uname']));
} else {
$gurl = url("shop", "goods", array("id" => $deal['id']));
}
$deal['share_url'] = $gurl;
if ($GLOBALS['user_info']) {
if (app_conf("URL_MODEL") == 0) {
$deal['share_url'] .= "&r=" . base64_encode(intval($GLOBALS['user_info']['id']));
} else {
$deal['share_url'] .= "?r=" . base64_encode(intval($GLOBALS['user_info']['id']));
}
}
//查询抽奖号
$deal['lottery_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "lottery where deal_id = " . intval($deal['id']) . " and buyer_id <> 0 ")) + intval($deal['buy_count']);
//开始获取处理库存
$deal['stock'] = $deal['max_bought'] - $deal['buy_count'];
$deal['is_today'] = get_is_today($deal);
}
return $deal;
}
示例12: get_deal_show
/**
* 获取指定的团购产品
*/
function get_deal_show($id = 0, $cate_id = 0, $city_id = 0, $preview = 0)
{
$time = get_gmtime();
if ($id == 0) {
$sql = "select * from " . DB_PREFIX . "deal where is_shop = 0 and is_effect = 1 and is_delete = 0 and buy_type <> 1 and (" . $time . ">= begin_time or begin_time = 0 or notice = 1) and (" . $time . "<end_time or end_time = 0) and buy_status <> 2 ";
if ($cate_id > 0) {
$ids = load_auto_cache("deal_sub_parent_cate_ids", array("cate_id" => $cate_id));
$sql .= " and cate_id in (" . implode(",", $ids) . ")";
}
if ($city_id > 0) {
$ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id));
if ($ids) {
$sql .= " and city_id in (" . implode(",", $ids) . ")";
}
}
$sql .= " order by sort desc";
$deal = $GLOBALS['db']->getRow($sql);
}
$deal = syn_deal_status($id);
if ($deal) {
$static_deal = load_auto_cache("static_goods_info", array("id" => $deal['id']));
foreach ($static_deal as $k => $v) {
$deal[$k] = $v;
}
$deal['success_time_tip'] = sprintf($GLOBALS['lang']['SUCCESS_TIME_TIP'], $deal['success_time_format'], $deal['min_bought']);
$deal['deal_success_num'] = sprintf($GLOBALS['lang']['SUCCESS_BUY_COUNT'], $deal['buy_count']);
$deal['current_bought'] = $deal['buy_count'];
if ($deal['buy_status'] == 0) {
$deal['success_less'] = sprintf($GLOBALS['lang']['SUCCESS_LESS_BUY_COUNT'], $deal['min_bought'] - $deal['buy_count']);
}
if ($deal['uname'] != '') {
$durl = url("tuan", "deal", array("id" => $deal['uname']));
} else {
$durl = url("tuan", "deal", array("id" => $deal['id']));
}
$deal['share_url'] = get_domain() . $durl;
if ($GLOBALS['user_info']) {
if (app_conf("URL_MODEL") == 0) {
$deal['share_url'] .= "&r=" . base64_encode(intval($GLOBALS['user_info']['id']));
} else {
$deal['share_url'] .= "?r=" . base64_encode(intval($GLOBALS['user_info']['id']));
}
}
$deal['is_today'] = get_is_today($deal);
//查询抽奖号
$deal['lottery_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "lottery where deal_id = " . intval($deal['id']) . " and buyer_id <> 0 ")) + intval($deal['buy_count']);
}
return $deal;
}
示例13: order_paid_done
//.........这里部分代码省略.........
}
modify_statements($order_info['total_price'], 8, $order_info['order_sn'] . "订单成功付款");
//增加营业额
$balance_total = $GLOBALS['db']->getOne("select sum(balance_total_price)+sum(add_balance_price_total) from " . DB_PREFIX . "deal_order_item where order_id = " . $order_info['id']);
modify_statements($balance_total, 9, $order_info['order_sn'] . "订单成功付款");
//增加营业额中的成本
//生成抽奖
$lottery_list = $GLOBALS['db']->getAll("select d.id as did,doi.number from " . DB_PREFIX . "deal_order_item as doi left join " . DB_PREFIX . "deal_order as do on doi.order_id = do.id left join " . DB_PREFIX . "deal as d on doi.deal_id = d.id where d.is_lottery = 1 and do.id = " . $order_info['id']);
$lottery_user = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . intval($order_info['user_id']));
//如为首次抽奖,先为推荐人生成抽奖号
$lottery_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "lottery where user_id = " . intval($order_info['user_id']));
if ($lottery_count == 0 && $lottery_user['pid'] != 0) {
$lottery_puser = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . intval($lottery_user['pid']));
foreach ($lottery_list as $lottery) {
$k = 0;
do {
if ($k > 10) {
break;
}
$buy_count = $GLOBALS['db']->getOne("select buy_count from " . DB_PREFIX . "deal where id = " . $lottery['did']);
$max_sn = $buy_count - $lottery['number'] + intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "lottery where deal_id = " . intval($lottery['did']) . " and buyer_id <> 0 "));
//$max_sn = intval($GLOBALS['db']->getOne("select lottery_sn from ".DB_PREFIX."lottery where deal_id = '".$lottery['did']."' order by lottery_sn desc limit 1"));
$sn = $max_sn + 1;
$sn = str_pad($sn, "6", "0", STR_PAD_LEFT);
$sql = "insert into " . DB_PREFIX . "lottery (`lottery_sn`,`deal_id`,`user_id`,`mobile`,`create_time`,`buyer_id`) select '" . $sn . "','" . $lottery['did'] . "'," . $lottery_puser['id'] . ",'" . $lottery_puser['lottery_mobile'] . "'," . NOW_TIME . "," . $order_info['user_id'] . " from dual where not exists( select * from " . DB_PREFIX . "lottery where deal_id = " . $lottery['did'] . " and lottery_sn = '" . $sn . "')";
$GLOBALS['db']->query($sql);
send_lottery_sms(intval($GLOBALS['db']->insert_id()));
$k++;
} while (intval($GLOBALS['db']->insert_id()) == 0);
}
}
foreach ($lottery_list as $lottery) {
for ($i = 0; $i < $lottery['number']; $i++) {
$k = 0;
do {
if ($k > 10) {
break;
}
$buy_count = $GLOBALS['db']->getOne("select buy_count from " . DB_PREFIX . "deal where id = " . $lottery['did']);
$max_sn = $buy_count - $lottery['number'] + intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "lottery where deal_id = " . intval($lottery['did']) . " and buyer_id <> 0 "));
//$max_sn = intval($GLOBALS['db']->getOne("select lottery_sn from ".DB_PREFIX."lottery where deal_id = '".$lottery['did']."' order by lottery_sn desc limit 1"));
$sn = $max_sn + $i + 1;
$sn = str_pad($sn, "6", "0", STR_PAD_LEFT);
$sql = "insert into " . DB_PREFIX . "lottery (`lottery_sn`,`deal_id`,`user_id`,`mobile`,`create_time`,`buyer_id`) select '" . $sn . "','" . $lottery['did'] . "'," . $order_info['user_id'] . ",'" . $lottery_user['mobile'] . "'," . NOW_TIME . ",0 from dual where not exists( select * from " . DB_PREFIX . "lottery where deal_id = " . $lottery['did'] . " and lottery_sn = '" . $sn . "')";
$GLOBALS['db']->query($sql);
send_lottery_sms(intval($GLOBALS['db']->insert_id()));
$k++;
} while (intval($GLOBALS['db']->insert_id()) == 0);
}
}
send_msg($order_info['user_id'], "订单" . $order_info['order_sn'] . "付款成功", "orderitem", $order_goods_list[0]['id']);
}
} else {
//开始模拟事务回滚
foreach ($affect_attr_list as $k => $v) {
$sql = "update " . DB_PREFIX . "attr_stock set buy_count = buy_count - " . $v['number'] . " where deal_id = " . $v['deal_id'] . " and locate(attr_str,'" . $v['attr_str'] . "') > 0 ";
$GLOBALS['db']->query($sql);
//回滚已发的货量
}
foreach ($affect_list as $k => $v) {
$sql = "update " . DB_PREFIX . "deal set buy_count = buy_count - " . $v['num'] . ",user_count = user_count - 1 where id=" . $v['deal_id'];
$GLOBALS['db']->query($sql);
//回滚已发的货量
}
$GLOBALS['db']->query("update " . DB_PREFIX . "deal_order_item set refund_status = 2 where order_id = " . $order_info['id']);
//超出充值
require_once APP_ROOT_PATH . "system/model/user.php";
$msg = sprintf($GLOBALS['lang']['OUTOFSTOCK_INCHARGE'], $order_info['order_sn']);
modify_account(array('money' => $order_info['total_price'], 'score' => 0), $order_info['user_id'], $msg);
order_log($order_info['order_sn'] . "订单库存不足," . format_price($order_info['total_price']) . "已退到会员余额", $order_info['id']);
modify_statements("-" . $order_info['total_price'], 1, $order_info['order_sn'] . "订单库存不足");
modify_statements($order_info['total_price'], 2, $order_info['order_sn'] . "订单库存不足");
//将订单的extra_status 状态更新为2,并自动退款
$GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set extra_status = 2, after_sale = 1, refund_money = pay_amount where id = " . intval($order_info['id']));
update_order_cache($order_info['id']);
//记录退款的订单日志
$log['log_info'] = $msg;
$log['log_time'] = NOW_TIME;
$log['order_id'] = intval($order_info['id']);
$GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order_log", $log);
}
//同步所有未过期的团购状态
foreach ($goods_list as $item) {
syn_deal_status($item['deal_id'], true);
}
auto_over_status($order_id);
//自动结单
} else {
//订单充值
// $GLOBALS['db']->query("update ".DB_PREFIX."deal_order set order_status = 1 where id = ".$order_info['id']); //充值单自动结单
require_once APP_ROOT_PATH . "system/model/user.php";
$msg = sprintf($GLOBALS['lang']['USER_INCHARGE_DONE'], $order_info['order_sn']);
modify_account(array('money' => $order_info['total_price'] - $order_info['payment_fee'], 'score' => 0), $order_info['user_id'], $msg);
modify_statements("-" . $order_info['total_price'], 1, $order_info['order_sn'] . "会员充值");
modify_statements($order_info['total_price'], 2, $order_info['order_sn'] . "会员充值,含手续费");
send_msg($order_info['user_id'], "成功充值" . format_price($order_info['total_price'] - $order_info['payment_fee']), "notify", $order_id);
auto_over_status($order_id);
//自动结单
}
}
示例14: pay_order
function pay_order($order_id)
{
require_once APP_ROOT_PATH . "system/libs/user.php";
$order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $order_id);
if ($order_info['credit_pay'] + $order_info['online_pay'] >= $order_info['total_price']) {
if ($order_info['credit_pay'] + $order_info['online_pay'] > $order_info['total_price']) {
$more_money = $order_info['credit_pay'] + $order_info['online_pay'] - $order_info['total_price'];
modify_account(array("money" => $more_money), $order_info['user_id'], $order_info['deal_name'] . "超额支付,转存入会员帐户");
}
$order_info['pay_time'] = get_gmtime();
$GLOBALS['db']->query("update " . DB_PREFIX . "deal set support_count = support_count + 1,support_amount = support_amount + " . $order_info['deal_price'] . ",pay_amount = pay_amount + " . $order_info['total_price'] . ",delivery_fee_amount = delivery_fee_amount + " . $order_info['delivery_fee'] . " where id = " . $order_info['deal_id'] . " and is_effect = 1 and is_delete = 0 and begin_time < " . get_gmtime() . " and (end_time > " . get_gmtime() . " or end_time = 0)");
if ($GLOBALS['db']->affected_rows() > 0) {
//记录支持日志
$support_log['deal_id'] = $order_info['deal_id'];
$support_log['user_id'] = $order_info['user_id'];
$support_log['create_time'] = get_gmtime();
$support_log['price'] = $order_info['deal_price'];
$support_log['deal_item_id'] = $order_info['deal_item_id'];
$GLOBALS['db']->autoExecute(DB_PREFIX . "deal_support_log", $support_log);
$support_log_id = intval($GLOBALS['db']->insert_id());
$GLOBALS['db']->query("update " . DB_PREFIX . "deal_item set support_count = support_count + 1,support_amount = support_amount +" . $order_info['deal_price'] . " where (support_count + 1 <= limit_user or limit_user = 0) and id = " . $order_info['deal_item_id']);
if ($GLOBALS['db']->affected_rows() > 0) {
$result['status'] = 3;
$order_info['order_status'] = 3;
$deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $order_info['deal_id'] . " and is_effect = 1 and is_delete = 0");
//下单项目成功,准备加入准备队列
if ($deal_info['is_success'] == 0) {
//未成功的项止准备生成队列
$notify['user_id'] = $GLOBALS['user_info']['id'];
$notify['deal_id'] = $deal_info['id'];
$notify['create_time'] = get_gmtime();
$GLOBALS['db']->autoExecute(DB_PREFIX . "user_deal_notify", $notify, "INSERT", "", "SILENT");
}
//更新用户的支持数
$GLOBALS['db']->query("update " . DB_PREFIX . "user set support_count = support_count + 1 where id = " . $order_info['user_id']);
//同步项目状态
syn_deal_status($order_info['deal_id']);
syn_deal($order_info['deal_id']);
} else {
$result['status'] = 2;
$order_info['order_status'] = 2;
$order_info['is_refund'] = 1;
$GLOBALS['db']->query("update " . DB_PREFIX . "deal set support_count = support_count - 1,support_amount = support_amount - " . $order_info['deal_price'] . ",pay_amount = pay_amount - " . $order_info['total_price'] . ",delivery_fee_amount = delivery_fee_amount - " . $order_info['delivery_fee'] . " where id = " . $order_info['deal_id']);
$GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_support_log where id = " . $support_log_id);
modify_account(array("money" => $order_info['total_price']), $order_info['user_id'], $order_info['deal_name'] . "限额已满,转存入会员帐户");
}
} else {
$result['status'] = 1;
$order_info['order_status'] = 1;
$order_info['is_refund'] = 1;
modify_account(array("money" => $order_info['total_price']), $order_info['user_id'], $order_info['deal_name'] . "已过期,转存入会员帐户");
}
$GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set order_status = " . intval($order_info['order_status']) . ",pay_time = " . $order_info['pay_time'] . ",is_refund = " . $order_info['is_refund'] . " where id = " . $order_info['id']);
} else {
$result['status'] = 0;
$result['money'] = $order_info['total_price'] - $order_info['online_pay'] - $order_info['credit_pay'];
}
return $result;
}
示例15: youhui_update
public function youhui_update()
{
B('FilterString');
$data = M(MODULE_NAME)->create();
$log_info = M(MODULE_NAME)->where("id=" . intval($data['id']))->getField("name");
//开始验证有效性
$this->assign("jumpUrl", u(MODULE_NAME . "/youhui_edit", array("id" => $data['id'])));
if (!check_empty($data['name'])) {
$this->error(L("DEAL_YOUHUI_NAME_EMPTY_TIP"));
}
if (!check_empty($data['sub_name'])) {
$this->error(L("DEAL_YOUHUI_SUB_NAME_EMPTY_TIP"));
}
if ($data['cate_id'] == 0) {
$this->error(L("DEAL_YOUHUI_CATE_EMPTY_TIP"));
}
if ($data['city_id'] == 0) {
$this->error(L("DEAL_YOUHUI_CITY_EMPTY_TIP"));
}
if ($data['max_bought'] < 0) {
$this->error(L("DEAL_YOUHUI_MAX_BOUGHT_ERROR_TIP"));
}
if ($data['user_min_bought'] < 0) {
$this->error(L("DEAL_USER_MIN_BOUGHT_ERROR_TIP"));
}
if ($data['user_max_bought'] < 0) {
$this->error(L("DEAL_USER_MAX_BOUGHT_ERROR_TIP"));
}
if ($data['user_max_bought'] < $data['user_min_bought'] && $data['user_max_bought'] > 0) {
$this->error(L("DEAL_USER_MAX_MIN_BOUGHT_ERROR_TIP"));
}
$data['is_shop'] = 2;
$data['is_coupon'] = 1;
if (intval($data['is_coupon']) == 1 && intval($data['is_refund']) == 1) {
$data['expire_refund'] = intval($_REQUEST['expire_refund']);
$data['any_refund'] = intval($_REQUEST['any_refund']);
} else {
$data['expire_refund'] = 0;
$data['any_refund'] = 0;
}
$data['notice'] = intval($_REQUEST['notice']);
$data['begin_time'] = trim($data['begin_time']) == '' ? 0 : to_timespan($data['begin_time']);
$data['end_time'] = trim($data['end_time']) == '' ? 0 : to_timespan($data['end_time']);
$data['coupon_begin_time'] = trim($data['coupon_begin_time']) == '' ? 0 : to_timespan($data['coupon_begin_time']);
$data['coupon_end_time'] = trim($data['coupon_end_time']) == '' ? 0 : to_timespan($data['coupon_end_time']);
//将第一张图片设为团购图片
$imgs = $_REQUEST['img'];
foreach ($imgs as $k => $v) {
if ($v != '') {
$data['img'] = $v;
break;
}
}
$data['update_time'] = get_gmtime();
$data['publish_wait'] = 0;
// 更新数据
$list = M(MODULE_NAME)->save($data);
if (false !== $list) {
$GLOBALS['db']->query("update " . DB_PREFIX . "deal_coupon set expire_refund = " . $data['expire_refund'] . ",any_refund = " . $data['any_refund'] . ",supplier_id=" . $data['supplier_id'] . ",end_time=" . $data['coupon_end_time'] . ",begin_time=" . $data['coupon_begin_time'] . " where deal_id = " . $data['id']);
//开始处理图片
M("DealGallery")->where("deal_id=" . $data['id'])->delete();
$imgs = $_REQUEST['img'];
foreach ($imgs as $k => $v) {
if ($v != '') {
$img_data['deal_id'] = $data['id'];
$img_data['img'] = $v;
$img_data['sort'] = $k;
M("DealGallery")->add($img_data);
}
}
//end 处理图片
M("DealPayment")->where("deal_id=" . $data['id'])->delete();
if (intval($_REQUEST['define_payment']) == 1) {
$payment_ids = $_REQUEST['payment_id'];
foreach ($payment_ids as $k => $v) {
$payment_conf = array();
$payment_conf['payment_id'] = $payment_ids[$k];
$payment_conf['deal_id'] = $data['id'];
M("DealPayment")->add($payment_conf);
}
}
//成功提示
M("DealCateTypeDealLink")->where("deal_id=" . $data['id'])->delete();
foreach ($_REQUEST['deal_cate_type_id'] as $type_id) {
$link_data = array();
$link_data['deal_cate_type_id'] = $type_id;
$link_data['deal_id'] = $data['id'];
M("DealCateTypeDealLink")->add($link_data);
}
M("DealLocationLink")->where("deal_id=" . $data['id'])->delete();
foreach ($_REQUEST['location_id'] as $location_id) {
$link_data = array();
$link_data['location_id'] = $location_id;
$link_data['deal_id'] = $data['id'];
M("DealLocationLink")->add($link_data);
}
syn_deal_status($data['id']);
foreach ($_REQUEST['location_id'] as $location_id) {
recount_supplier_data_count($location_id, "daijin");
}
//.........这里部分代码省略.........