本文整理汇总了PHP中QueueClient::push方法的典型用法代码示例。如果您正苦于以下问题:PHP QueueClient::push方法的具体用法?PHP QueueClient::push怎么用?PHP QueueClient::push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueueClient
的用法示例。
在下文中一共展示了QueueClient::push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addRefundReturn
/**
* 增加退款退货
*
* @param
* @return int
*/
public function addRefundReturn($refund_array, $order = array(), $goods = array())
{
if (!empty($order) && is_array($order)) {
$refund_array['order_id'] = $order['order_id'];
$refund_array['order_sn'] = $order['order_sn'];
$refund_array['store_id'] = $order['store_id'];
$refund_array['store_name'] = $order['store_name'];
$refund_array['buyer_id'] = $order['buyer_id'];
$refund_array['buyer_name'] = $order['buyer_name'];
}
if (!empty($goods) && is_array($goods)) {
$refund_array['goods_id'] = $goods['goods_id'];
$refund_array['order_goods_id'] = $goods['rec_id'];
$refund_array['order_goods_type'] = $goods['goods_type'];
$refund_array['goods_name'] = $goods['goods_name'];
$refund_array['commis_rate'] = $goods['commis_rate'];
$refund_array['goods_image'] = $goods['goods_image'];
}
$refund_array['refund_sn'] = $this->getRefundsn($refund_array['store_id']);
$refund_id = $this->table('refund_return')->insert($refund_array);
// 发送商家提醒
$param = array();
if (intval($refund_array['refund_type']) == 1) {
// 退款
$param['code'] = 'refund';
} else {
// 退货
$param['code'] = 'return';
}
$param['store_id'] = $order['store_id'];
$type = $refund_array['order_lock'] == 2 ? '售前' : '售后';
$param['param'] = array('type' => $type, 'refund_sn' => $refund_array['refund_sn']);
QueueClient::push('sendStoreMsg', $param);
return $refund_id;
}
示例2: indexOp
/**
* 通知
*/
public function indexOp()
{
$strat_time = strtotime("-30 day");
// 只通知最近30天的记录
$model_arrtivalnotice = Model('arrival_notice');
$count = $model_arrtivalnotice->getArrivalNoticeCount(array());
$times = ceil($count / $this->_num);
if ($times == 0) {
return false;
}
for ($i = 0; $i <= $times; $i++) {
// 删除30天之前的记录
$model_arrtivalnotice->delArrivalNotice(array('an_addtime' => array('lt', $strat_time)));
$notice_list = $model_arrtivalnotice->getArrivalNoticeList(array(), '*', $i . ',' . $this->_num);
if (empty($notice_list)) {
continue;
}
// 查询商品是否已经上架
$goodsid_array = array();
foreach ($notice_list as $val) {
$goodsid_array[] = $val['goods_id'];
}
$goodsid_array = array_unique($goodsid_array);
$goods_list = Model('goods')->getGoodsOnlineList(array('goods_id' => array('in', $goodsid_array), 'goods_storage' => array('gt', 0)), 'goods_id');
if (empty($goods_list)) {
continue;
}
// 需要通知到货的商品
$goodsid_array = array();
foreach ($goods_list as $val) {
$goodsid_array[] = $val['goods_id'];
}
// 根据商品id重新查询需要通知的列表
$notice_list = $model_arrtivalnotice->getArrivalNoticeList(array('goods_id' => array('in', $goodsid_array)), '*');
if (empty($notice_list)) {
continue;
}
foreach ($notice_list as $val) {
$param = array();
$param['code'] = 'arrival_notice';
$param['member_id'] = $val['member_id'];
$param['param'] = array('goods_name' => $val['goods_name'], 'goods_url' => urlShop('goods', 'index', array('goods_id' => $val['goods_id'])));
QueueClient::push('sendMemberMsg', $param);
}
// 清楚发送成功的数据
$model_arrtivalnotice->delArrivalNotice(array('goods_id' => array('in', $goodsid_array)));
}
}
示例3: consult_replyOp
/**
* 回复咨询
*/
public function consult_replyOp()
{
$model_mallconsult = Model('mall_consult');
if (chksubmit()) {
$mc_id = intval($_POST['mc_id']);
$reply_content = trim($_POST['reply_content']);
if ($mc_id <= 0 || $reply_content == '') {
showMessage(L('param_error'));
}
$update['is_reply'] = 1;
$update['mc_reply'] = $reply_content;
$update['mc_reply_time'] = TIMESTAMP;
$update['admin_id'] = $this->admin_info['id'];
$update['admin_name'] = $this->admin_info['name'];
$result = $model_mallconsult->editMallConsult(array('mc_id' => $mc_id), $update);
if ($result) {
$consult_info = $model_mallconsult->getMallConsultInfo(array('mc_id' => $mc_id));
// 发送用户消息
$param = array();
$param['code'] = 'consult_mall_reply';
$param['member_id'] = $consult_info['member_id'];
$param['param'] = array('consult_url' => urlShop('member_mallconsult', 'mallconsult_info', array('id' => $mc_id)));
QueueClient::push('sendMemberMsg', $param);
showMessage('回复成功', urlAdmin('mall_consult', 'index'));
} else {
showMessage('回复失败');
}
}
$id = intval($_GET['id']);
if ($id <= 0) {
showMessage(L('param_error'));
}
$consult_info = $model_mallconsult->getMallConsultDetail($id);
Tpl::output('consult_info', $consult_info);
Tpl::showpage('mall_consult.reply');
}
示例4: receiveOp
/**
* 收货
*
*/
public function receiveOp()
{
$model_refund = Model('refund_return');
$model_trade = Model('trade');
$condition = array();
$condition['store_id'] = $_SESSION['store_id'];
$condition['refund_id'] = intval($_GET['return_id']);
$return_list = $model_refund->getReturnList($condition);
$return = $return_list[0];
Tpl::output('return', $return);
$return_delay = $model_trade->getMaxDay('return_delay');
//发货默认5天后才能选择没收到
$delay_time = time() - $return['delay_time'] - 60 * 60 * 24 * $return_delay;
Tpl::output('return_delay', $return_delay);
Tpl::output('return_confirm', $model_trade->getMaxDay('return_confirm'));
//卖家不处理收货时按同意并弃货处理
Tpl::output('delay_time', $delay_time);
if (chksubmit()) {
if ($return['seller_state'] != '2' || $return['goods_state'] != '2') {
//检查状态,防止页面刷新不及时造成数据错误
showDialog(Language::get('wrong_argument'), 'reload', 'error', 'CUR_DIALOG.close();');
}
$refund_array = array();
if ($_POST['return_type'] == '3' && $delay_time > 0) {
$refund_array['goods_state'] = '3';
} else {
$refund_array['receive_time'] = time();
$refund_array['receive_message'] = '确认收货完成';
$refund_array['refund_state'] = '2';
//状态:1为处理中,2为待管理员处理,3为已完成
$refund_array['goods_state'] = '4';
}
$state = $model_refund->editRefundReturn($condition, $refund_array);
if ($state) {
$this->recordSellerLog('退货确认收货,退货编号:' . $return['refund_sn']);
// 发送买家消息
$param = array();
$param['code'] = 'refund_return_notice';
$param['member_id'] = $return['buyer_id'];
$param['param'] = array('refund_url' => urlShop('member_return', 'view', array('return_id' => $return['refund_id'])), 'refund_sn' => $return['refund_sn']);
QueueClient::push('sendMemberMsg', sendMemberMsg);
showDialog(Language::get('nc_common_save_succ'), 'reload', 'succ', 'CUR_DIALOG.close();');
} else {
showDialog(Language::get('nc_common_save_fail'), 'reload', 'error', 'CUR_DIALOG.close();');
}
}
$express_list = rkcache('express', true);
if ($return['express_id'] > 0 && !empty($return['invoice_no'])) {
Tpl::output('e_name', $express_list[$return['express_id']]['e_name']);
Tpl::output('e_code', $express_list[$return['express_id']]['e_code']);
}
Tpl::showpage('store_return_receive', 'null_layout');
}
示例5: _updateGroupBuy
/**
* 更新抢购购买人数和数量
*/
private function _updateGroupBuy($goods_info)
{
if ($goods_info['ifgroupbuy'] && $goods_info['groupbuy_id']) {
$groupbuy_info = array();
$groupbuy_info['groupbuy_id'] = $goods_info['groupbuy_id'];
$groupbuy_info['quantity'] = $goods_info['quantity'];
QueueClient::push('editGroupbuySaleCount', $groupbuy_info);
}
}
示例6: _sendSMsg
private function _sendSMsg($code, $store_id, $param)
{
QueueClient::push('sendStoreMsg', array('code' => $code, 'store_id' => $store_id, 'param' => $param));
}
示例7: changePd
//.........这里部分代码省略.........
$data_pd['available_predeposit'] = array('exp', 'available_predeposit-' . $data['amount']);
$data_msg['av_amount'] = -$data['amount'];
$data_msg['freeze_amount'] = $data['amount'];
$data_msg['desc'] = $data_log['lg_desc'];
break;
case 'order_cancel':
$data_log['lg_av_amount'] = $data['amount'];
$data_log['lg_freeze_amount'] = -$data['amount'];
$data_log['lg_desc'] = '取消订单,解冻预存款,订单号: ' . $data['order_sn'];
$data_pd['freeze_predeposit'] = array('exp', 'freeze_predeposit-' . $data['amount']);
$data_pd['available_predeposit'] = array('exp', 'available_predeposit+' . $data['amount']);
$data_msg['av_amount'] = $data['amount'];
$data_msg['freeze_amount'] = -$data['amount'];
$data_msg['desc'] = $data_log['lg_desc'];
break;
case 'order_comb_pay':
$data_log['lg_freeze_amount'] = -$data['amount'];
$data_log['lg_desc'] = '下单,支付被冻结的预存款,订单号: ' . $data['order_sn'];
$data_pd['freeze_predeposit'] = array('exp', 'freeze_predeposit-' . $data['amount']);
$data_msg['av_amount'] = 0;
$data_msg['freeze_amount'] = $data['amount'];
$data_msg['desc'] = $data_log['lg_desc'];
break;
case 'recharge':
$data_log['lg_av_amount'] = $data['amount'];
$data_log['lg_desc'] = '充值,充值单号: ' . $data['pdr_sn'];
$data_log['lg_admin_name'] = $data['admin_name'];
$data_pd['available_predeposit'] = array('exp', 'available_predeposit+' . $data['amount']);
$data_msg['av_amount'] = $data['amount'];
$data_msg['freeze_amount'] = 0;
$data_msg['desc'] = $data_log['lg_desc'];
break;
case 'refund':
$data_log['lg_av_amount'] = $data['amount'];
$data_log['lg_desc'] = '确认退款,订单号: ' . $data['order_sn'];
$data_pd['available_predeposit'] = array('exp', 'available_predeposit+' . $data['amount']);
$data_msg['av_amount'] = $data['amount'];
$data_msg['freeze_amount'] = 0;
$data_msg['desc'] = $data_log['lg_desc'];
break;
case 'vr_refund':
$data_log['lg_av_amount'] = $data['amount'];
$data_log['lg_desc'] = '虚拟兑码退款成功,订单号: ' . $data['order_sn'];
$data_pd['available_predeposit'] = array('exp', 'available_predeposit+' . $data['amount']);
$data_msg['av_amount'] = $data['amount'];
$data_msg['freeze_amount'] = 0;
$data_msg['desc'] = $data_log['lg_desc'];
break;
case 'cash_apply':
$data_log['lg_av_amount'] = -$data['amount'];
$data_log['lg_freeze_amount'] = $data['amount'];
$data_log['lg_desc'] = '申请提现,冻结预存款,提现单号: ' . $data['order_sn'];
$data_pd['available_predeposit'] = array('exp', 'available_predeposit-' . $data['amount']);
$data_pd['freeze_predeposit'] = array('exp', 'freeze_predeposit+' . $data['amount']);
$data_msg['av_amount'] = -$data['amount'];
$data_msg['freeze_amount'] = $data['amount'];
$data_msg['desc'] = $data_log['lg_desc'];
break;
case 'cash_pay':
$data_log['lg_freeze_amount'] = -$data['amount'];
$data_log['lg_desc'] = '提现成功,提现单号: ' . $data['order_sn'];
$data_log['lg_admin_name'] = $data['admin_name'];
$data_pd['freeze_predeposit'] = array('exp', 'freeze_predeposit-' . $data['amount']);
$data_msg['av_amount'] = 0;
$data_msg['freeze_amount'] = -$data['amount'];
$data_msg['desc'] = $data_log['lg_desc'];
break;
case 'cash_del':
$data_log['lg_av_amount'] = $data['amount'];
$data_log['lg_freeze_amount'] = -$data['amount'];
$data_log['lg_desc'] = '取消提现申请,解冻预存款,提现单号: ' . $data['order_sn'];
$data_log['lg_admin_name'] = $data['admin_name'];
$data_pd['available_predeposit'] = array('exp', 'available_predeposit+' . $data['amount']);
$data_pd['freeze_predeposit'] = array('exp', 'freeze_predeposit-' . $data['amount']);
$data_msg['av_amount'] = $data['amount'];
$data_msg['freeze_amount'] = -$data['amount'];
$data_msg['desc'] = $data_log['lg_desc'];
break;
default:
throw new Exception('参数错误');
break;
}
$update = Model('member')->editMember(array('member_id' => $data['member_id']), $data_pd);
if (!$update) {
throw new Exception('操作失败');
}
$insert = $this->table('pd_log')->insert($data_log);
if (!$insert) {
throw new Exception('操作失败');
}
// 支付成功发送买家消息
$param = array();
$param['code'] = 'predeposit_change';
$param['member_id'] = $data['member_id'];
$data_msg['av_amount'] = ncPriceFormat($data_msg['av_amount']);
$data_msg['freeze_amount'] = ncPriceFormat($data_msg['freeze_amount']);
$param['param'] = $data_msg;
QueueClient::push('sendMemberMsg', $param);
return $insert;
}
示例8: editOp
/**
* 退货处理页
*
*/
public function editOp()
{
$model_refund = Model('refund_return');
$condition = array();
$condition['refund_id'] = intval($_GET['return_id']);
$return_list = $model_refund->getReturnList($condition);
$return = $return_list[0];
if (chksubmit()) {
if ($return['refund_state'] != '2') {
//检查状态,防止页面刷新不及时造成数据错误
showMessage(Language::get('nc_common_save_fail'));
}
$order_id = $return['order_id'];
$refund_array = array();
$refund_array['admin_time'] = time();
$refund_array['refund_state'] = '3';
//状态:1为处理中,2为待管理员处理,3为已完成
$refund_array['admin_message'] = $_POST['admin_message'];
$state = $model_refund->editOrderRefund($return);
if ($state) {
$model_refund->editRefundReturn($condition, $refund_array);
$this->log('退货确认,退货编号' . $return['refund_sn']);
// 发送买家消息
$param = array();
$param['code'] = 'refund_return_notice';
$param['member_id'] = $return['buyer_id'];
$param['param'] = array('refund_url' => urlShop('return_id', 'view', array('return_id' => $return['refund_id'])), 'refund_sn' => $return['refund_sn']);
QueueClient::push('sendMemberMsg', $param);
showMessage(Language::get('nc_common_save_succ'), 'index.php?act=return&op=return_manage');
} else {
showMessage(Language::get('nc_common_save_fail'));
}
}
Tpl::output('return', $return);
$info['buyer'] = array();
if (!empty($return['pic_info'])) {
$info = unserialize($return['pic_info']);
}
Tpl::output('pic_list', $info['buyer']);
Tpl::showpage('return.edit');
}
示例9: editOrder
/**
* 更改订单信息
*
* @param unknown_type $data
* @param unknown_type $condition
*/
public function editOrder($data, $condition, $limit = '')
{
$update = $this->table('order')->where($condition)->limit($limit)->update($data);
if ($update) {
//更新缓存
QueueClient::push('delOrderCountCache', $condition);
}
return $update;
}
示例10: recordStoreCost
/**
* 记录店铺费用
*
* @param $cost_price 费用金额
* @param $cost_remark 费用备注
*/
protected function recordStoreCost($cost_price, $cost_remark)
{
// 平台店铺不记录店铺费用
if (checkPlatformStore()) {
return false;
}
$model_store_cost = Model('store_cost');
$param = array();
$param['cost_store_id'] = $_SESSION['store_id'];
$param['cost_seller_id'] = $_SESSION['seller_id'];
$param['cost_price'] = $cost_price;
$param['cost_remark'] = $cost_remark;
$param['cost_state'] = 0;
$param['cost_time'] = TIMESTAMP;
$model_store_cost->addStoreCost($param);
// 发送店铺消息
$param = array();
$param['code'] = 'store_cost';
$param['store_id'] = $_SESSION['store_id'];
$param['param'] = array('price' => $cost_price, 'seller_name' => $_SESSION['seller_name'], 'remark' => $cost_remark);
QueueClient::push('sendStoreMsg', $param);
}
示例11: wxpayOp
/**
* 微信退款 v3-b12
*
*/
public function wxpayOp()
{
$result = array('state' => 'false', 'msg' => '参数错误,微信退款失败');
$refund_id = intval($_GET['refund_id']);
$model_refund = Model('vr_refund');
$condition = array();
$condition['refund_id'] = $refund_id;
$condition['refund_state'] = '1';
$detail_array = $model_refund->getDetailInfo($condition);
//退款详细
if (!empty($detail_array) && in_array($detail_array['refund_code'], array('wxpay', 'wx_jsapi', 'wx_saoma'))) {
$order = $model_refund->getPayDetailInfo($detail_array);
//退款订单详细
$refund_amount = $order['pay_refund_amount'];
//本次在线退款总金额
if ($refund_amount > 0) {
$wxpay = $order['payment_config'];
define('WXPAY_APPID', $wxpay['appid']);
define('WXPAY_MCHID', $wxpay['mchid']);
define('WXPAY_KEY', $wxpay['key']);
$total_fee = $order['pay_amount'] * 100;
//微信订单实际支付总金额(在线支付金额,单位为分)
$refund_fee = $refund_amount * 100;
//本次微信退款总金额(单位为分)
$api_file = BASE_PATH . DS . 'api' . DS . 'refund' . DS . 'wxpay' . DS . 'WxPay.Api.php';
include $api_file;
$input = new WxPayRefund();
$input->SetTransaction_id($order['trade_no']);
//微信订单号
$input->SetTotal_fee($total_fee);
$input->SetRefund_fee($refund_fee);
$input->SetOut_refund_no($detail_array['batch_no']);
//退款批次号
$input->SetOp_user_id(WxPayConfig::MCHID);
$data = WxPayApi::refund($input);
if (!empty($data) && $data['return_code'] == 'SUCCESS') {
//请求结果
if ($data['result_code'] == 'SUCCESS') {
//业务结果
$detail_array = array();
$detail_array['pay_amount'] = ncPriceFormat($data['refund_fee'] / 100);
$detail_array['pay_time'] = time();
$model_refund->editDetail(array('refund_id' => $refund_id), $detail_array);
$result['state'] = 'true';
$result['msg'] = '微信成功退款:' . $detail_array['pay_amount'];
$refund = $model_refund->getRefundInfo(array('refund_id' => $refund_id));
$consume_array = array();
$consume_array['member_id'] = $refund['buyer_id'];
$consume_array['member_name'] = $refund['buyer_name'];
$consume_array['consume_amount'] = $detail_array['pay_amount'];
$consume_array['consume_time'] = time();
$consume_array['consume_remark'] = '微信在线退款成功(到账有延迟),虚拟退款单号:' . $refund['refund_sn'];
QueueClient::push('addConsume', $consume_array);
} else {
$result['msg'] = '微信退款错误,' . $data['err_code_des'];
//错误描述
}
} else {
$result['msg'] = '微信接口错误,' . $data['return_msg'];
//返回信息
}
}
}
exit(json_encode($result));
}
示例12: _create_vr_order_bill
/**
* 生成所有店铺月订单出账单[虚拟订单]
*
* @param int $data
*/
private function _create_vr_order_bill($data){
$model_order = Model('vr_order');
$model_bill = Model('vr_bill');
$model_store = Model('store');
//批量插入order_bill表
$condition = array();
$condition['order_state'] = array('egt',ORDER_STATE_PAY);
$condition['payment_time'] = array(array('egt',$data['os_start_date']),array('elt',$data['os_end_date']),'and');
//取出有最终成交订单的店铺ID数量(ID不重复)
$order_info = $model_order->getOrderInfo($condition,'count(DISTINCT store_id) as store_count');
$store_count = $order_info['store_count'];
//分批生成该月份的店铺空结算表,每批生成300个店铺
$insert = false;
for ($i=0;$i<=$store_count;$i=$i+300){
$store_list = $model_order->getOrderList($condition,'','DISTINCT store_id','',"{$i},300");
if ($store_list){
//自动生成以月份为单位的空结算记录
$data_bill = array();
foreach($store_list as $store_info){
$data_bill['ob_no'] = $data['os_month'].$store_info['store_id'];
$data_bill['ob_start_date'] = $data['os_start_date'];
$data_bill['ob_end_date'] = $data['os_end_date'];
$data_bill['os_month'] = $data['os_month'];
$data_bill['ob_state'] = 0;
$data_bill['ob_store_id'] = $store_info['store_id'];
if (!$model_bill->getOrderBillInfo(array('ob_no'=>$data_bill['ob_no']))) {
$insert = $model_bill->addOrderBill($data_bill);
if (!$insert) {
throw new Exception('生成账单['.$data_bill['ob_no'].']失败');
}
//对已生成空账单进行销量、佣金统计
$update = $this->_calc_vr_order_bill($data_bill);
if (!$update){
throw new Exception('更新账单['.$data_bill['ob_no'].']失败');
}
// 发送店铺消息
$param = array();
$param['code'] = 'store_bill_affirm';
$param['store_id'] = $store_info['store_id'];
$param['param'] = array(
'state_time' => date('Y-m-d H:i:s', $data_bill['ob_start_date']),
'end_time' => date('Y-m-d H:i:s', $data_bill['ob_end_date']),
'bill_no' => $data_bill['ob_no']
);
QueueClient::push('sendStoreMsg', $param);
}
}
}
}
}
示例13: remind_renewalOp
/**
* 提醒续费
*/
public function remind_renewalOp()
{
$store_id = intval($_GET['store_id']);
$store_info = Model('store')->getStoreInfoByID($store_id);
if (!empty($store_info) && $store_info['store_end_time'] < TIMESTAMP + 864000 && cookie('remindRenewal' . $store_id) == null) {
// 发送商家消息
$param = array();
$param['code'] = 'store_expire';
$param['store_id'] = intval($_GET['store_id']);
$param['param'] = array();
QueueClient::push('sendStoreMsg', $param);
setNcCookie('remindRenewal' . $store_id, 1, 86400 * 10);
// 十天
showMessage('消息发送成功');
}
showMessage('消息发送失败');
}
示例14: updateOp
/**
* 购物车更新商品数量
*/
public function updateOp()
{
$cart_id = intval(abs($_GET['cart_id']));
$quantity = intval(abs($_GET['quantity']));
if (empty($cart_id) || empty($quantity)) {
exit(json_encode(array('msg' => Language::get('cart_update_buy_fail', 'UTF-8'))));
}
$model_cart = Model('cart');
$model_goods = Model('goods');
$logic_buy_1 = logic('buy_1');
//存放返回信息
$return = array();
$cart_info = $model_cart->getCartInfo(array('cart_id' => $cart_id, 'buyer_id' => $_SESSION['member_id']));
if ($cart_info['bl_id'] == '0') {
//普通商品
$goods_id = intval($cart_info['goods_id']);
$goods_info = $logic_buy_1->getGoodsOnlineInfo($goods_id, $quantity);
if (empty($goods_info)) {
$return['state'] = 'invalid';
$return['msg'] = '商品已被下架';
$return['subtotal'] = 0;
QueueClient::push('delCart', array('buyer_id' => $_SESSION['member_id'], 'cart_ids' => array($cart_id)));
exit(json_encode($return));
}
//抢购
$logic_buy_1->getGroupbuyInfo($goods_info);
//限时折扣
$logic_buy_1->getXianshiInfo($goods_info, $quantity);
$quantity = $goods_info['goods_num'];
if (intval($goods_info['goods_storage']) < $quantity) {
$return['state'] = 'shortage';
$return['msg'] = '库存不足';
$return['goods_num'] = $goods_info['goods_num'];
$return['goods_price'] = $goods_info['goods_price'];
$return['subtotal'] = $goods_info['goods_price'] * $quantity;
$model_cart->editCart(array('goods_num' => $goods_info['goods_storage']), array('cart_id' => $cart_id, 'buyer_id' => $_SESSION['member_id']));
exit(json_encode($return));
}
} else {
//优惠套装商品
$model_bl = Model('p_bundling');
$bl_goods_list = $model_bl->getBundlingGoodsList(array('bl_id' => $cart_info['bl_id']));
$goods_id_array = array();
foreach ($bl_goods_list as $goods) {
$goods_id_array[] = $goods['goods_id'];
}
$goods_list = $model_goods->getGoodsOnlineListAndPromotionByIdArray($goods_id_array);
//如果其中有商品下架,删除
if (count($goods_list) != count($goods_id_array)) {
$return['state'] = 'invalid';
$return['msg'] = '该优惠套装已经无效,建议您购买单个商品';
$return['subtotal'] = 0;
QueueClient::push('delCart', array('buyer_id' => $_SESSION['member_id'], 'cart_ids' => array($cart_id)));
exit(json_encode($return));
}
//如果有商品库存不足,更新购买数量到目前最大库存
foreach ($goods_list as $goods_info) {
if ($quantity > $goods_info['goods_storage']) {
$return['state'] = 'shortage';
$return['msg'] = '该优惠套装部分商品库存不足,建议您降低购买数量或购买库存足够的单个商品';
$return['goods_num'] = $goods_info['goods_storage'];
$return['goods_price'] = $cart_info['goods_price'];
$return['subtotal'] = $cart_info['goods_price'] * $quantity;
$model_cart->editCart(array('goods_num' => $goods_info['goods_storage']), array('cart_id' => $cart_id, 'buyer_id' => $_SESSION['member_id']));
exit(json_encode($return));
break;
}
}
$goods_info['goods_price'] = $cart_info['goods_price'];
}
$data = array();
$data['goods_num'] = $quantity;
$data['goods_price'] = $goods_info['goods_price'];
$update = $model_cart->editCart($data, array('cart_id' => $cart_id, 'buyer_id' => $_SESSION['member_id']));
if ($update) {
$return = array();
$return['state'] = 'true';
$return['subtotal'] = $goods_info['goods_price'] * $quantity;
$return['goods_price'] = $goods_info['goods_price'];
$return['goods_num'] = $quantity;
} else {
$return = array('msg' => Language::get('cart_update_buy_fail', 'UTF-8'));
}
exit(json_encode($return));
}
示例15: buyStep2
//.........这里部分代码省略.........
}
//取得商品最新在售信息
$goods_info = $model_cart->getGoodsOnlineInfo($goods_id, $quantity);
if (empty($goods_info)) {
return array('error' => '商品不存在');
}
//判断是不是正在抢购中,如果是则按抢购价格计算,购买数量若超过抢购规定的上限,则按抢购上限计算
$goods_info = $model_cart->getGroupbuyInfo($goods_info);
//如果未进行抢购,则再判断是否限时折扣中
if (!$goods_info['ifgroupbuy']) {
$goods_info = $model_cart->getXianshiInfo($goods_info, $quantity);
} else {
//这里记录一下抢购数量,订单完成后需要更新一下抢购表信息
$groupbuy_info = array();
$groupbuy_info['groupbuy_id'] = $goods_info['groupbuy_id'];
$groupbuy_info['quantity'] = $quantity;
}
//转成多维数组,方便统一使用购物车方法与模板
$store_cart_list = array();
$goods_list = array();
$goods_list[0] = $store_cart_list[$goods_info['store_id']][0] = $goods_info;
}
//商品金额计算(分别对每个商品/优惠套装小计、每个店铺小计)
list($store_cart_list, $store_goods_total) = $model_cart->calcCartList($store_cart_list);
//取得店铺优惠 - 满即送(赠品列表,店铺满送规则列表)
list($store_premiums_list, $store_mansong_rule_list) = $model_cart->getMansongRuleCartListByTotal($store_goods_total);
//重新计算店铺扣除满即送后商品实际支付金额
$store_final_goods_total = $model_cart->reCalcGoodsTotal($store_goods_total, $store_mansong_rule_list, 'mansong');
//得到有效的代金券
$input_voucher_list = $model_cart->reParseVoucherList($input_voucher_list, $store_goods_total, $member_id);
//重新计算店铺扣除优惠券送商品实际支付金额
$store_final_goods_total = $model_cart->reCalcGoodsTotal($store_final_goods_total, $input_voucher_list, 'voucher');
//计算每个店铺(所有店铺级优惠活动)总共优惠多少
$store_promotion_total = $this->getStorePromotionTotal($store_goods_total, $store_final_goods_total);
//计算每个店铺运费
list($need_calc_sid_list, $cancel_calc_sid_list) = $this->getStoreFreightDescList($store_final_goods_total);
$freight_list = $this->getStoreFreightList($goods_list, array_keys($cancel_calc_sid_list));
$store_freight_total = $this->calcStoreFreight($freight_list, $input_city_id);
//计算店铺最终订单实际支付金额(加上运费)
$store_final_order_total = $model_cart->reCalcGoodsTotal($store_final_goods_total, $store_freight_total, 'freight');
//计算店铺分类佣金
$store_gc_id_commis_rate_list = $this->getStoreGcidCommisRateList($goods_list);
//将赠品追加到购买列表(如果库存不足,则不送赠品)
$append_premiums_to_cart_list = $this->appendPremiumsToCartList($store_cart_list, $store_premiums_list, $store_mansong_rule_list, $member_id);
if (!empty($append_premiums_to_cart_list['error'])) {
return array('error' => $append_premiums_to_cart_list['error']);
} else {
list($store_cart_list, $goods_buy_quantity, $store_mansong_rule_list) = $append_premiums_to_cart_list;
}
//整理已经得出的固定数据,准备下单
$input = array();
$input['pay_name'] = $input_pay_name;
$input['if_offpay'] = $input_if_offpay;
$input['if_vat'] = $input_if_vat;
$input['pay_message'] = $post['pay_message'];
$input['address_info'] = $input_address_info;
$input['invoice_info'] = $input_invoice_info;
$input['voucher_list'] = $input_voucher_list;
$input['store_goods_total'] = $store_goods_total;
$input['store_final_order_total'] = $store_final_order_total;
$input['store_freight_total'] = $store_freight_total;
$input['store_promotion_total'] = $store_promotion_total;
$input['store_gc_id_commis_rate_list'] = $store_gc_id_commis_rate_list;
$input['store_mansong_rule_list'] = $store_mansong_rule_list;
$input['store_cart_list'] = $store_cart_list;
try {
//开始事务
$model_cart->beginTransaction();
//生成订单
list($pay_sn, $order_list) = $this->createOrder($input, $member_id, $member_name, $member_email);
//记录订单日志
$this->addOrderLog($order_list);
//变更库存和销量
$this->updateGoodsStorageNum($goods_buy_quantity);
//使用预存款支付
$this->pdPay($order_list, $post, $member_id, $member_name);
//提交事务
$model_cart->commit();
} catch (Exception $e) {
//回滚事务
$model_cart->rollback();
return array('error' => $e->getMessage());
}
//更新使用的代金券状态
if (!empty($input_voucher_list) && is_array($input_voucher_list)) {
QueueClient::push('editVoucherState', $input_voucher_list);
}
//更新抢购购买人数和数量
if (!empty($groupbuy_info) && is_array($groupbuy_info)) {
QueueClient::push('editGroupbuySaleCount', $groupbuy_info);
}
//更新收货人所在省份
QueueClient::push('editReciverProid', array('order_ids' => array_keys($order_list), 'area_id' => $input_city_id));
//删除购物车中的商品
if ($post['ifcart']) {
$model_cart->delCart('db', array('buyer_id' => $member_id, 'cart_id' => array('in', array_keys($input_buy_items))));
// QueueClient::push('delCart', array('buyer_id'=>$member_id,'cart_ids'=>array_keys($input_buy_items)));
}
return array('pay_sn' => $pay_sn);
}