} define('SHELF_ROW_NUM', 4); include_once ROOT_PATH . 'includes/lib_order.php'; $locktime = strtotime(date('Y-m-d') . ' ' . $_CFG['order_lock_time']); $sql = "SELECT o.order_id, o.user_id, o.shop_id, s.open_time, s.close_time FROM " . $ecs->table('order_info', 'o') . ',' . $ecs->table('shop', 's') . " WHERE o.shop_id = s.shop_id AND o.order_status=" . OS_UNCONFIRMED . " AND o.pay_status=" . PS_PAYED . " AND o.pay_time<={$locktime} AND s.status != 2 ORDER BY o.shop_id, o.user_id"; $query = $db->query($sql); $now = time(); $os = array('order_status' => OS_CONFIRMED, 'shipping_status' => SS_PREPARING, 'confirm_time' => $now); // 生成包裹 $shop_id = 0; $user_id = 0; while ($o = $db->fetch_array($query)) { if ($o['shop_id'] != $shop_id || $o['user_id'] != $user_id) { $shop_id = $o['shop_id']; $user_id = $o['user_id']; $pickup_time = get_order_pickup_time($locktime, 0, $o['open_time'], $o['close_time']); $pack_obj = array('shop_id' => $shop_id, 'user_id' => $user_id, 'start_time' => $pickup_time['start'], 'end_time' => $pickup_time['end'], 'expire_time' => $pickup_time['start'] + 3600 * intval($_CFG['shipping_limit_time']), 'create_date' => date('Ymd', $pickup_time['start'])); $db->autoExecute($ecs->table('pickup_pack'), $pack_obj); $pack_id = $db->insert_id(); } // 更新订单状态 $os['package_id'] = $pack_id; update_order($o['order_id'], $os); // 计算并发放积分 //$integral = integral_to_give($o); //log_account_change($order['user_id'], 0, 0, intval($integral['rank_points']), intval($integral['custom_points']), sprintf($_LANG['order_gift_integral'], $order['order_sn'])); // 发放红包 send_order_bonus($o['order_id']); } // 规划包裹位置 $pack_date = date('Ymd', $pickup_time['start']);
/** * 获取下单提醒说明文字 */ function order_attention($order, $shop) { global $_CFG; $ptime = get_order_pickup_time(0, 0, $shop['open_time'], $shop['close_time']); $tpl = new cls_template(); $tpl->assign('lock_time', $_CFG['order_lock_time']); $tpl->assign('pickup_start_time', date('Y-m-d H:i', $ptime['start'])); $tpl->assign('pickup_end_time', date('Y-m-d H:i', $ptime['end'])); $tpl->assign('limit_time', $_CFG['shipping_limit_time']); return $tpl->fetch('str:' . $_CFG['order_attention']); }
$modules[$i]['desc'] = 'ship_order_desc'; /* 作者 */ $modules[$i]['author'] = 'gy.wang'; /* 网址 */ $modules[$i]['website'] = ''; /* 版本号 */ $modules[$i]['version'] = '0.1.0'; /* 配置信息 */ $modules[$i]['config'] = array(); return; } $sql = "SELECT o.order_id, o.confirm_time, s.open_time, s.close_time FROM " . $ecs->table('order_info', 'o') . ',' . $ecs->table('shop', 's') . " WHERE o.shop_id = s.shop_id AND o.order_status = " . OS_CONFIRMED . " AND shipping_status = " . SS_PREPARING; $rs = $db->getAll($sql); $shipping_time = time(); foreach ($rs as $order) { $pickup_time = get_order_pickup_time(0, $order['confirm_time'], $order['open_time'], $order['close_time']); $db->autoExecute($ecs->table('order_info'), array('shipping_status' => SS_SHIPPED, 'shipping_time' => $shipping_time, 'receive_deadline' => $pickup_time['end']), 'UPDATE', 'order_id=' . $order['order_id']); } // 发送消息 $sql = "SELECT u.user_id, w.wxid, group_concat(o.order_sn) AS order_sn, count(o.order_id) AS order_count, sum(o.money_paid) AS order_amount FROM " . $ecs->table('order_info', 'o') . ',' . $ecs->table('users', 'u') . ', wxch_user w ' . " WHERE o.user_id = u.user_id AND u.user_id = w.uid AND o.order_status = " . OS_CONFIRMED . " AND o.shipping_status = " . SS_SHIPPED . " AND shipping_time = '{$shipping_time}' " . " GROUP BY o.user_id "; $query = $db->query($sql); include_once ROOT_PATH . '/includes/cls_wechat.php'; $wechat = new WechatApi(); $link = $_CFG['site_url'] . '/mobile/user.php'; $tmplid = 'nJ0TLLQ7D2t9AVQPGJuThvYVQRWsfBGlGAau8-V-hb0'; $param = array('first' => array('color' => '#0000ff'), 'keyword1' => array('color' => '#000000'), 'keyword2' => array('color' => '#000000'), 'keyword3' => array('color' => '#000000', 'value' => '中国药科大学江宁校区提货点'), "remark" => array('color' => '#0000ff', 'value' => "为了水果新鲜,请尽快取货哦,我们将为您保存48小时。\n如有任何问题可致电客服咨询:{$_CFG[service_phone]}")); while ($rs = $db->fetch_array($query)) { $param['first']['value'] = "最鲜蜂正在为您配送{$rs[order_count]}个水果订单,您可以于{$_CFG[shop_open_time]}至{$_CFG[shop_close_time]},凭取货二维码,到{$_CFG[shop_address]}取货。"; $param['keyword1']['value'] = $rs['order_sn']; $param['keyword2']['value'] = $rs['order_amount'] . '元'; $result = $wechat->send_template_msg($rs['wxid'], $tmplid, $param, $link);
$smarty->assign('default_payment', $payment_list[0]['pay_id']); } } /* 订单 支付 配送 状态语言项 */ //$order['order_status'] = $_LANG['os'][$order['order_status']]; //$order['pay_status'] = $_LANG['ps'][$order['pay_status']]; //$order['shipping_status'] = $_LANG['ss'][$order['shipping_status']]; $order['order_cs'] = get_order_custom_status($order); $order['order_cs_desc'] = $_LANG['cs'][$order['order_cs']]; $shop = get_shop($order['shop_id']); if ($order['order_cs'] == CS_UNPICK) { //获取取货码 $sql = "SELECT * FROM " . $ecs->table('pickup_code') . " WHERE user_id = {$user_id} AND status = 1 AND abandon_time > " . time() . " ORDER BY create_time ASC LIMIT 1"; $pcode = $db->getRow($sql); if (!empty($pcode)) { $ptime = get_order_pickup_time(NULL, $order['confirm_time'], $shop['open_time'], $shop['close_time']); $order['pickup_time_start'] = date('m/d H:i', $ptime['start']); $order['pickup_time_end'] = date('m/d H:i', $ptime['end']); $order['pickup_code'] = $pcode['code']; } } $smarty->assign('order', $order); $smarty->assign('shop', $shop); $smarty->assign('goods_list', $goods_list); $smarty->display('user_transaction.dwt'); } elseif ($action == 'cancel_order') { include_once ROOT_PATH . 'include/lib_transaction.php'; include_once ROOT_PATH . 'include/lib_order.php'; include_once ROOT_PATH . 'include/lib_clips.php'; $order_id = isset($_REQUEST['order_id']) ? intval($_REQUEST['order_id']) : 0; if (cancel_order($order_id, $user_id) && !$err->has_error()) {