/** * 增加退款退货 * * @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']); Uk86QueueClient::push('sendStoreMsg', $param); return $refund_id; }
/** * 入列 * @param string $key * @param array $value */ public static function push($key, $value) { if (!C('queue.open')) { uk86_Logic('queue')->{$key}($value); return; } if (!is_object(self::$queuedb)) { self::$queuedb = new Uk86QueueDB(); } return self::$queuedb->push(serialize(array($key => $value))); }
/** * 通知 */ 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' => uk86_urlShop('goods', 'index', array('goods_id' => $val['goods_id']))); Uk86QueueClient::push('sendMemberMsg', $param); } // 清楚发送成功的数据 $model_arrtivalnotice->delArrivalNotice(array('goods_id' => array('in', $goodsid_array))); } }
/** * 回复咨询 */ public function consult_replyOp() { $model_mallconsult = Model('mall_consult'); if (uk86_chksubmit()) { $mc_id = intval($_POST['mc_id']); $reply_content = trim($_POST['reply_content']); if ($mc_id <= 0 || $reply_content == '') { uk86_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' => uk86_urlShop('member_mallconsult', 'mallconsult_info', array('id' => $mc_id))); Uk86QueueClient::push('sendMemberMsg', $param); uk86_showMessage('回复成功', uk86_urlAdmin('mall_consult', 'index')); } else { uk86_showMessage('回复失败'); } } $id = intval($_GET['id']); if ($id <= 0) { uk86_showMessage(L('param_error')); } $consult_info = $model_mallconsult->getMallConsultDetail($id); Tpl::output('consult_info', $consult_info); Tpl::showpage('mall_consult.reply'); }
/** * 退款处理页 * */ public function editOp() { $model_refund = Model('refund_return'); $condition = array(); $condition['refund_id'] = intval($_GET['refund_id']); $refund_list = $model_refund->getRefundList($condition); $refund = $refund_list[0]; if (uk86_chksubmit()) { if ($refund['refund_state'] != '2') { //检查状态,防止页面刷新不及时造成数据错误 uk86_showMessage(Uk86Language::uk86_get('nc_common_save_fail')); } $order_id = $refund['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($refund); if ($state) { $model_refund->editRefundReturn($condition, $refund_array); // 发送买家消息 $param = array(); $param['code'] = 'refund_return_notice'; $param['member_id'] = $refund['buyer_id']; $param['param'] = array('refund_url' => uk86_urlShop('member_refund', 'view', array('refund_id' => $refund['refund_id'])), 'refund_sn' => $refund['refund_sn']); Uk86QueueClient::push('sendMemberMsg', $param); $this->log('退款确认,退款编号' . $refund['refund_sn']); uk86_showMessage(Uk86Language::uk86_get('nc_common_save_succ'), 'index.php?act=refund&op=refund_manage'); } else { uk86_showMessage(Uk86Language::uk86_get('nc_common_save_fail')); } } Tpl::output('refund', $refund); $info['buyer'] = array(); if (!empty($refund['pic_info'])) { $info = unserialize($refund['pic_info']); } Tpl::output('pic_list', $info['buyer']); Tpl::showpage('refund.edit'); }
/** * 过期修改状态 */ public function editExpireXianshi($condition) { $condition['end_time'] = array('lt', TIMESTAMP); // 更新商品促销价格 $xianshigoods_list = Model('p_xianshi_goods')->getXianshiGoodsList($condition); if (!empty($xianshigoods_list)) { $goodsid_array = array(); foreach ($xianshigoods_list as $val) { $goodsid_array[] = $val['goods_id']; } // 更新商品促销价格,需要考虑抢购是否在进行中 Uk86QueueClient::push('updateGoodsPromotionPriceByGoodsId', $goodsid_array); } $condition['state'] = self::XIANSHI_STATE_NORMAL; $updata = array(); $update['state'] = self::XIANSHI_STATE_CLOSE; $this->editXianshi($update, $condition); return true; }
/** * 生成所有店铺月订单出账单 * * @param int $data */ private function _create_order_bill($data) { $model_order = Model('order'); $model_bill = Model('bill'); $model_store = Model('store'); //批量插件order_bill表 // $condition = array(); // $condition['order_state'] = ORDER_STATE_SUCCESS; // $condition['finnshed_time'] = array(array('egt',$data['os_start_date']),array('elt',$data['os_end_date']),'and'); // 取出有最终成交订单的店铺ID数量(ID不重复) // $store_count = $model_order->getOrderInfo($condition,array(),'count(DISTINCT store_id) as c'); // $store_count = $store_count['c']; //取店铺表数量(因为可能存在无订单,但有店铺活动费用,所以不再从订单表取店铺数量) $store_count = $model_store->getStoreCount(array()); //分批生成该月份的店铺空结算表,每批生成300个店铺 $insert = false; for ($i = 0; $i <= $store_count; $i = $i + 300) { // $store_list = $model_order->getOrderList($condition,'','DISTINCT store_id','',"{$i},300"); $store_list = $model_store->getStoreList(array(), null, '', '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) { $update = $this->_calc_order_bill($data_bill); if (!$update) { uk86_showMessage('生成账单[' . $data['os_month'] . ']失败', '', 'html', 'error'); } // 发送店铺消息 $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']); Uk86QueueClient::push('sendStoreMsg', $param); } else { uk86_showMessage('生成账单[' . $data['os_month'] . ']失败', '', 'html', 'error'); } } } } } }
/** * 提醒续费 */ 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 && uk86_cookie('remindRenewal' . $store_id) == null) { // 发送商家消息 $param = array(); $param['code'] = 'store_expire'; $param['store_id'] = intval($_GET['store_id']); $param['param'] = array(); Uk86QueueClient::push('sendStoreMsg', $param); uk86_setNcCookie('remindRenewal' . $store_id, 1, 86400 * 10); // 十天 uk86_showMessage('消息发送成功'); } uk86_showMessage('消息发送失败'); }
/** * 插入订单表信息 * @param array $data * @return int 返回 insert_id */ public function addOrder($data) { $insert = $this->table('order')->insert($data); if ($insert) { //更新缓存 Uk86QueueClient::push('delOrderCountCache', array('buyer_id' => $data['buyer_id'], 'store_id' => $data['store_id'])); } return $insert; }
/** * 预存款支付,依次循环每个订单 * 如果预存款足够就单独支付了该订单,如果不足就暂时冻结,等API支付成功了再彻底扣除 */ public function pdPay($order_list, $input, $buyer_info) { $member_id = $buyer_info['member_id']; $member_name = $buyer_info['member_name']; // $model_payment = Model('payment'); // $pd_payment_info = $model_payment->getPaymentOpenInfo(array('payment_code'=>'predeposit')); // if (empty($pd_payment_info)) return; $available_pd_amount = floatval($buyer_info['available_predeposit']); if ($available_pd_amount <= 0) { return; } $model_order = Model('order'); $model_pd = Model('predeposit'); foreach ($order_list as $order_info) { //货到付款的订单、已经充值卡支付的订单跳过 if ($order_info['payment_code'] == 'offline') { continue; } if ($order_info['order_state'] == ORDER_STATE_PAY) { continue; } $order_amount = floatval($order_info['order_amount']) - floatval($order_info['rcb_amount']); $data_pd = array(); $data_pd['member_id'] = $member_id; $data_pd['member_name'] = $member_name; $data_pd['amount'] = $order_amount; $data_pd['order_sn'] = $order_info['order_sn']; if ($available_pd_amount >= $order_amount) { //预存款立即支付,订单支付完成 $model_pd->changePd('order_pay', $data_pd); $available_pd_amount -= $order_amount; //支付被冻结的充值卡 $rcb_amount = floatval($order_info['rcb_amount']); if ($rcb_amount > 0) { $data_pd = array(); $data_pd['member_id'] = $member_id; $data_pd['member_name'] = $member_name; $data_pd['amount'] = $rcb_amount; $data_pd['order_sn'] = $order_info['order_sn']; $model_pd->changeRcb('order_comb_pay', $data_pd); } //记录订单日志(已付款) $data = array(); $data['order_id'] = $order_info['order_id']; $data['log_role'] = 'buyer'; $data['log_msg'] = L('order_log_pay'); $data['log_orderstate'] = ORDER_STATE_PAY; $insert = $model_order->addOrderLog($data); if (!$insert) { throw new Exception('记录订单预存款支付日志出现错误'); } //订单状态 置为已支付 $data_order = array(); $data_order['order_state'] = ORDER_STATE_PAY; $data_order['payment_time'] = TIMESTAMP; $data_order['payment_code'] = 'predeposit'; $data_order['pd_amount'] = $order_amount; $result = $model_order->editOrder($data_order, array('order_id' => $order_info['order_id'])); if (!$result) { throw new Exception('订单更新失败'); } // 发送商家提醒 $param = array(); $param['code'] = 'new_order'; $param['store_id'] = $order_info['store_id']; $param['param'] = array('order_sn' => $order_info['order_sn']); Uk86QueueClient::push('sendStoreMsg', $param); } else { //暂冻结预存款,后面还需要 API彻底完成支付 if ($available_pd_amount > 0) { $data_pd['amount'] = $available_pd_amount; $model_pd->changePd('order_freeze', $data_pd); //预存款支付金额保存到订单 $data_order = array(); $data_order['pd_amount'] = $available_pd_amount; $result = $model_order->editOrder($data_order, array('order_id' => $order_info['order_id'])); $available_pd_amount = 0; if (!$result) { throw new Exception('订单更新失败'); } } } } }
/** * 取件通知 */ public function arrive_pointOp() { $order_id = intval($_GET['order_id']); if ($order_id <= 0) { showDialog(L('wrong_argument')); } $pickup_code = $this->createPickupCode(); // 更新提货订单表数据 $update = array(); $update['dlyo_pickup_code'] = $pickup_code; Model('delivery_order')->editDeliveryOrderArrive($update, array('order_id' => $order_id, 'dlyp_id' => $_SESSION['dlyp_id'])); // 更新订单扩展表数据 Model('order')->editOrderCommon($update, array('order_id' => $order_id)); // 发送短信提醒 Uk86QueueClient::push('sendPickupcode', array('pickup_code' => $pickup_code, 'order_id' => $order_id)); showDialog('操作成功', 'reload', 'succ'); }
/** * 审核页 * */ public function editOp() { $model_vr_refund = Model('vr_refund'); $condition = array(); $condition['refund_id'] = intval($_GET['refund_id']); $refund_list = $model_vr_refund->getRefundList($condition); $refund = $refund_list[0]; if (uk86_chksubmit()) { if ($refund['admin_state'] != '1') { //检查状态,防止页面刷新不及时造成数据错误 uk86_showMessage(Uk86Language::uk86_get('nc_common_save_fail')); } $refund['admin_time'] = time(); $refund['admin_state'] = '2'; if ($_POST['admin_state'] == '3') { $refund['admin_state'] = '3'; } $refund['admin_message'] = $_POST['admin_message']; $state = $model_vr_refund->editOrderRefund($refund); if ($state) { // 发送买家消息 $param = array(); $param['code'] = 'refund_return_notice'; $param['member_id'] = $refund['buyer_id']; $param['param'] = array('refund_url' => uk86_urlShop('member_vr_refund', 'view', array('refund_id' => $refund['refund_id'])), 'refund_sn' => $refund['refund_sn']); Uk86QueueClient::push('sendMemberMsg', $param); $this->log('虚拟订单退款审核,退款编号' . $refund['refund_sn']); uk86_showMessage(Uk86Language::uk86_get('nc_common_save_succ'), 'index.php?act=vr_refund&op=refund_manage'); } else { uk86_showMessage(Uk86Language::uk86_get('nc_common_save_fail')); } } Tpl::output('refund', $refund); $code_array = explode(',', $refund['code_sn']); Tpl::output('code_array', $code_array); Tpl::showpage('vr_refund.edit'); }
/** * 发送店铺消息 * @param string $code * @param int $store_id * @param array $param */ private function _sendStoreMsg($code, $store_id, $param) { Uk86QueueClient::push('sendStoreMsg', array('code' => $code, 'store_id' => $store_id, 'param' => $param)); }
/** * 退款审核页 * */ public function editOp() { $model_refund = Model('refund_return'); $condition = array(); $condition['store_id'] = $_SESSION['store_id']; $condition['refund_id'] = intval($_GET['refund_id']); $refund_list = $model_refund->getRefundList($condition); $refund = $refund_list[0]; if (uk86_chksubmit()) { $reload = 'index.php?act=store_refund&lock=1'; if ($refund['order_lock'] == '2') { $reload = 'index.php?act=store_refund&lock=2'; } if ($refund['seller_state'] != '1') { //检查状态,防止页面刷新不及时造成数据错误 showDialog(Uk86Language::uk86_get('wrong_argument'), $reload, 'error'); } $order_id = $refund['order_id']; $refund_array = array(); $refund_array['seller_time'] = time(); $refund_array['seller_state'] = $_POST['seller_state']; //卖家处理状态:1为待审核,2为同意,3为不同意 $refund_array['seller_message'] = $_POST['seller_message']; if ($refund_array['seller_state'] == '3') { $refund_array['refund_state'] = '3'; //状态:1为处理中,2为待管理员处理,3为已完成 } else { $refund_array['seller_state'] = '2'; $refund_array['refund_state'] = '2'; } $state = $model_refund->editRefundReturn($condition, $refund_array); if ($state) { if ($refund_array['seller_state'] == '3' && $refund['order_lock'] == '2') { $model_refund->editOrderUnlock($order_id); //订单解锁 } $this->recordSellerLog('退款处理,退款编号:' . $refund['refund_sn']); // 发送买家消息 $param = array(); $param['code'] = 'refund_return_notice'; $param['member_id'] = $refund['buyer_id']; $param['param'] = array('refund_url' => uk86_urlShop('member_refund', 'view', array('refund_id' => $refund['refund_id'])), 'refund_sn' => $refund['refund_sn']); Uk86QueueClient::push('sendMemberMsg', $param); showDialog(Uk86Language::uk86_get('nc_common_save_succ'), $reload, 'succ'); } else { showDialog(Uk86Language::uk86_get('nc_common_save_fail'), $reload, 'error'); } } Tpl::output('refund', $refund); $info['buyer'] = array(); if (!empty($refund['pic_info'])) { $info = unserialize($refund['pic_info']); } Tpl::output('pic_list', $info['buyer']); $model_member = Model('member'); $member = $model_member->getMemberInfoByID($refund['buyer_id']); Tpl::output('member', $member); $condition = array(); $condition['order_id'] = $refund['order_id']; $model_refund->getRightOrderList($condition, $refund['order_goods_id']); Tpl::showpage('store_refund_edit'); }
/** * 删除 * @param array $condition * @return bool * */ public function delXianshiGoods($condition) { $xianshi_goods_list = $this->getXianshiGoodsList($condition, null, '', 'goods_id'); $result = $this->where($condition)->delete(); if ($result) { if (!empty($xianshi_goods_list)) { foreach ($xianshi_goods_list as $val) { // 删除商品限时折扣缓存 $this->_dGoodsXianshiCache($val['goods_id']); // 插入对列 更新促销价格 Uk86QueueClient::push('updateGoodsPromotionPriceByGoodsId', $val['goods_id']); } } } return $result; }
/** * 变更预存款 * @param unknown $change_type * @param unknown $data * @throws Exception * @return unknown */ public function changePd($change_type, $data = array()) { $data_log = array(); $data_pd = array(); $data_msg = array(); $data_log['lg_member_id'] = $data['member_id']; $data_log['lg_member_name'] = $data['member_name']; $data_log['lg_add_time'] = TIMESTAMP; $data_log['lg_type'] = $change_type; $data_msg['time'] = date('Y-m-d H:i:s'); $data_msg['pd_url'] = uk86_urlShop('predeposit', 'pd_log_list'); switch ($change_type) { case 'order_pay': $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 'order_freeze': $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_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'] = uk86_ncPriceFormat($data_msg['av_amount']); $data_msg['freeze_amount'] = uk86_ncPriceFormat($data_msg['freeze_amount']); $param['param'] = $data_msg; Uk86QueueClient::push('sendMemberMsg', $param); return $insert; }
/** * 记录店铺费用 * * @param $cost_price 费用金额 * @param $cost_remark 费用备注 */ protected function recordStoreCost($cost_price, $cost_remark) { // 平台店铺不记录店铺费用 if (uk86_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); Uk86QueueClient::push('sendStoreMsg', $param); }
/** * 保存商品(商品发布第二步使用) */ public function save_goodsOp() { if (uk86_chksubmit()) { // 验证表单 $obj_validate = new Uk86Validate(); $obj_validate->validateparam = array(array("input" => $_POST["g_name"], "require" => "true", "message" => L('store_goods_index_goods_name_null')), array("input" => $_POST["g_price"], "require" => "true", "validator" => "Double", "message" => L('store_goods_index_goods_price_null'))); $error = $obj_validate->uk86_validate(); if ($error != '') { uk86_showMessage(L('error') . $error, uk86_urlShop('seller_center'), 'html', 'error'); } $model_goods = Model('goods'); $model_type = Model('type'); // 分类信息 $goods_class = Model('goods_class')->getGoodsClassLineForTag(intval($_POST['cate_id'])); $common_array = array(); $common_array['goods_name'] = $_POST['g_name']; $common_array['goods_jingle'] = $_POST['g_jingle']; $common_array['gc_id'] = intval($_POST['cate_id']); $common_array['gc_id_1'] = intval($goods_class['gc_id_1']); $common_array['gc_id_2'] = intval($goods_class['gc_id_2']); $common_array['gc_id_3'] = intval($goods_class['gc_id_3']); $common_array['gc_name'] = $_POST['cate_name']; $common_array['brand_id'] = $_POST['b_id']; $common_array['brand_name'] = $_POST['b_name']; $common_array['type_id'] = intval($_POST['type_id']); $common_array['goods_image'] = $_POST['image_path']; $common_array['goods_price'] = floatval($_POST['g_price']); $common_array['goods_marketprice'] = floatval($_POST['g_marketprice']); $common_array['goods_costprice'] = floatval($_POST['g_costprice']); $common_array['goods_discount'] = floatval($_POST['g_discount']); $common_array['goods_serial'] = $_POST['g_serial']; $common_array['goods_storage_alarm'] = intval($_POST['g_alarm']); $common_array['goods_attr'] = serialize($_POST['attr']); $common_array['goods_body'] = $_POST['g_body']; $common_array['store_mentioning'] = intval($_POST['g_mentioning']); $common_array['store_floor_id'] = intval($_POST['store_floor_id']); //楼层id $common_array['store_floor_name'] = $_POST['store_floor_name']; //楼层名称 // 序列化保存手机端商品描述数据 if ($_POST['m_body'] != '') { $_POST['m_body'] = str_replace('"', '"', $_POST['m_body']); $_POST['m_body'] = json_decode($_POST['m_body'], true); if (!empty($_POST['m_body'])) { $_POST['m_body'] = serialize($_POST['m_body']); } else { $_POST['m_body'] = ''; } } $common_array['mobile_body'] = $_POST['m_body']; $common_array['goods_commend'] = intval($_POST['g_commend']); $common_array['goods_state'] = $this->store_info['store_state'] != 1 ? 0 : intval($_POST['g_state']); // 店铺关闭时,商品下架 $common_array['goods_addtime'] = TIMESTAMP; $common_array['goods_selltime'] = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60; $common_array['goods_verify'] = C('goods_verify') == 1 ? 10 : 1; $common_array['store_id'] = $_SESSION['store_id']; $common_array['store_name'] = $_SESSION['store_name']; $common_array['spec_name'] = is_array($_POST['spec']) ? serialize($_POST['sp_name']) : serialize(null); $common_array['spec_value'] = is_array($_POST['spec']) ? serialize($_POST['sp_val']) : serialize(null); $common_array['goods_vat'] = intval($_POST['g_vat']); $common_array['areaid_1'] = intval($_POST['province_id']); $common_array['areaid_2'] = intval($_POST['city_id']); $common_array['transport_id'] = $_POST['freight'] == '0' ? '0' : intval($_POST['transport_id']); // 运费模板 $common_array['transport_title'] = $_POST['transport_title']; $common_array['goods_freight'] = floatval($_POST['g_freight']); //查询店铺商品分类 $goods_stcids_arr = array(); if (!empty($_POST['sgcate_id'])) { $sgcate_id_arr = array(); foreach ($_POST['sgcate_id'] as $k => $v) { $sgcate_id_arr[] = intval($v); } $sgcate_id_arr = array_unique($sgcate_id_arr); $store_goods_class = Model('store_goods_class')->getStoreGoodsClassList(array('store_id' => $_SESSION['store_id'], 'stc_id' => array('in', $sgcate_id_arr), 'stc_state' => '1')); if (!empty($store_goods_class)) { foreach ($store_goods_class as $k => $v) { if ($v['stc_id'] > 0) { $goods_stcids_arr[] = $v['stc_id']; } if ($v['stc_parent_id'] > 0) { $goods_stcids_arr[] = $v['stc_parent_id']; } } $goods_stcids_arr = array_unique($goods_stcids_arr); sort($goods_stcids_arr); } } if (empty($goods_stcids_arr)) { $common_array['goods_stcids'] = ''; } else { $common_array['goods_stcids'] = ',' . implode(',', $goods_stcids_arr) . ','; // 首尾需要加, } $common_array['plateid_top'] = intval($_POST['plate_top']) > 0 ? intval($_POST['plate_top']) : ''; $common_array['plateid_bottom'] = intval($_POST['plate_bottom']) > 0 ? intval($_POST['plate_bottom']) : ''; $common_array['is_virtual'] = intval($_POST['is_gv']); $common_array['virtual_indate'] = $_POST['g_vindate'] != '' ? strtotime($_POST['g_vindate']) + 24 * 60 * 60 - 1 : 0; // 当天的最后一秒结束 $common_array['virtual_limit'] = intval($_POST['g_vlimit']) > 10 || intval($_POST['g_vlimit']) < 0 ? 10 : intval($_POST['g_vlimit']); $common_array['virtual_invalid_refund'] = intval($_POST['g_vinvalidrefund']); $common_array['is_fcode'] = intval($_POST['is_fc']); $common_array['is_appoint'] = intval($_POST['is_appoint']); // 只有库存为零的商品可以预约 $common_array['appoint_satedate'] = $common_array['is_appoint'] == 1 ? strtotime($_POST['g_saledate']) : ''; // 预约商品的销售时间 $common_array['is_presell'] = $common_array['goods_state'] == 1 ? intval($_POST['is_presell']) : 0; // 只有出售中的商品可以预售 $common_array['presell_deliverdate'] = $common_array['is_presell'] == 1 ? strtotime($_POST['g_deliverdate']) : ''; // 预售商品的发货时间 $common_array['is_own_shop'] = in_array($_SESSION['store_id'], model('store')->getOwnShopIds()) ? 1 : 0; // 保存数据 $common_id = $model_goods->addGoodsCommon($common_array); if ($common_id) { // 生成的商品id(SKU) $goodsid_array = array(); require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $_SESSION['store_id'] . DS); // 商品规格 if (is_array($_POST['spec'])) { foreach ($_POST['spec'] as $value) { $goods = array(); $goods['goods_commonid'] = $common_id; $goods['goods_name'] = $common_array['goods_name'] . ' ' . implode(' ', $value['sp_value']); $goods['goods_jingle'] = $common_array['goods_jingle']; $goods['store_id'] = $common_array['store_id']; $goods['store_name'] = $_SESSION['store_name']; $goods['gc_id'] = $common_array['gc_id']; $goods['gc_id_1'] = $common_array['gc_id_1']; $goods['gc_id_2'] = $common_array['gc_id_2']; $goods['gc_id_3'] = $common_array['gc_id_3']; $goods['brand_id'] = $common_array['brand_id']; $goods['goods_price'] = $value['price']; $goods['goods_promotion_price'] = $value['price']; $goods['goods_marketprice'] = $value['marketprice'] == 0 ? $common_array['goods_marketprice'] : $value['marketprice']; $goods['goods_serial'] = $value['sku']; $goods['goods_storage_alarm'] = intval($value['alarm']); $goods['goods_spec'] = serialize($value['sp_value']); $goods['goods_storage'] = $value['stock']; $goods['goods_image'] = $common_array['goods_image']; $goods['goods_state'] = $common_array['goods_state']; $goods['goods_verify'] = $common_array['goods_verify']; $goods['goods_addtime'] = TIMESTAMP; $goods['goods_edittime'] = TIMESTAMP; $goods['areaid_1'] = $common_array['areaid_1']; $goods['areaid_2'] = $common_array['areaid_2']; $goods['color_id'] = intval($value['color']); $goods['transport_id'] = $common_array['transport_id']; $goods['goods_freight'] = $common_array['goods_freight']; $goods['goods_vat'] = $common_array['goods_vat']; $goods['goods_commend'] = $common_array['goods_commend']; $goods['goods_stcids'] = $common_array['goods_stcids']; $goods['is_virtual'] = $common_array['is_virtual']; $goods['virtual_indate'] = $common_array['virtual_indate']; $goods['virtual_limit'] = $common_array['virtual_limit']; $goods['virtual_invalid_refund'] = $common_array['virtual_invalid_refund']; $goods['is_fcode'] = $common_array['is_fcode']; $goods['is_appoint'] = $common_array['is_appoint']; $goods['is_presell'] = $common_array['is_presell']; $goods['is_own_shop'] = $common_array['is_own_shop']; $goods['store_mentioning'] = $common_array['store_mentioning']; $goods['store_floor_id'] = $common_array['store_floor_id']; //楼层id $goods['store_floor_name'] = $common_array['store_floor_name']; //楼层名称 $goods_id = $model_goods->addGoods($goods); $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr'])); $goodsid_array[] = $goods_id; // 生成商品二维码 $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } } else { $goods = array(); $goods['goods_commonid'] = $common_id; $goods['goods_name'] = $common_array['goods_name']; $goods['goods_jingle'] = $common_array['goods_jingle']; $goods['store_id'] = $common_array['store_id']; $goods['store_name'] = $_SESSION['store_name']; $goods['gc_id'] = $common_array['gc_id']; $goods['gc_id_1'] = $common_array['gc_id_1']; $goods['gc_id_2'] = $common_array['gc_id_2']; $goods['gc_id_3'] = $common_array['gc_id_3']; $goods['brand_id'] = $common_array['brand_id']; $goods['goods_price'] = $common_array['goods_price']; $goods['goods_promotion_price'] = $common_array['goods_price']; $goods['goods_marketprice'] = $common_array['goods_marketprice']; $goods['goods_serial'] = $common_array['goods_serial']; $goods['goods_storage_alarm'] = $common_array['goods_storage_alarm']; $goods['goods_spec'] = serialize(null); $goods['goods_storage'] = intval($_POST['g_storage']); $goods['goods_image'] = $common_array['goods_image']; $goods['goods_state'] = $common_array['goods_state']; $goods['goods_verify'] = $common_array['goods_verify']; $goods['goods_addtime'] = TIMESTAMP; $goods['goods_edittime'] = TIMESTAMP; $goods['areaid_1'] = $common_array['areaid_1']; $goods['areaid_2'] = $common_array['areaid_2']; $goods['color_id'] = 0; $goods['transport_id'] = $common_array['transport_id']; $goods['goods_freight'] = $common_array['goods_freight']; $goods['goods_vat'] = $common_array['goods_vat']; $goods['goods_commend'] = $common_array['goods_commend']; $goods['goods_stcids'] = $common_array['goods_stcids']; $goods['is_virtual'] = $common_array['is_virtual']; $goods['virtual_indate'] = $common_array['virtual_indate']; $goods['virtual_limit'] = $common_array['virtual_limit']; $goods['virtual_invalid_refund'] = $common_array['virtual_invalid_refund']; $goods['is_fcode'] = $common_array['is_fcode']; $goods['is_appoint'] = $common_array['is_appoint']; $goods['is_presell'] = $common_array['is_presell']; $goods['is_own_shop'] = $common_array['is_own_shop']; $goods['store_mentioning'] = $common_array['store_mentioning']; $goods_id = $model_goods->addGoods($goods); $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr'])); $goodsid_array[] = $goods_id; } // 生成商品二维码 if (!empty($goodsid_array)) { //QueueClient::push('createGoodsQRCode', array('store_id' => $_SESSION['store_id'], 'goodsid_array' => $goodsid_array)); $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } // 商品加入上架队列 if (isset($_POST['starttime'])) { $selltime = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60; if ($selltime > TIMESTAMP) { $this->addcron(array('exetime' => $selltime, 'exeid' => $common_id, 'type' => 1), true); } } // 记录日志 $this->recordSellerLog('添加商品,平台货号:' . $common_id); // 生成F码 if ($common_array['is_fcode'] == 1) { Uk86QueueClient::push('createGoodsFCode', array('goods_commonid' => $common_id, 'fc_count' => intval($_POST['g_fccount']), 'fc_prefix' => $_POST['g_fcprefix'])); } uk86_redirect(uk86_urlShop('store_goods_add', 'add_step_three', array('commonid' => $common_id))); } else { uk86_showMessage(L('store_goods_index_goods_add_fail'), uk86_getReferer(), 'html', 'error'); } } }
/** * 商品咨询回复内容的保存处理 */ public function reply_saveOp() { $consult_id = intval($_POST['consult_id']); if ($consult_id <= 0) { showDialog(L('wrong_argument')); } $consult = Model('consult'); $update = array(); $update['consult_reply'] = $_POST['content']; $condtion = array(); $condtion['store_id'] = $_SESSION['store_id']; $condtion['consult_id'] = $consult_id; $state = $consult->editConsult($condtion, $update); if ($state) { $consult_info = $consult->getConsultInfo(array('consult_id' => $consult_id)); // 发送用户消息 $param = array(); $param['code'] = 'consult_goods_reply'; $param['member_id'] = $consult_info['member_id']; $param['param'] = array('goods_name' => $consult_info['goods_name'], 'consult_url' => uk86_urlShop('member_consult', 'my_consult')); Uk86QueueClient::push('sendMemberMsg', $param); showDialog(Uk86Language::uk86_get('nc_common_op_succ'), 'reload', 'succ', empty($_GET['inajax']) ? '' : 'CUR_DIALOG.close();'); } else { showDialog(Uk86Language::uk86_get('nc_common_op_fail')); } }
/** * 编辑商品保存 */ public function edit_save_goodsOp() { $common_id = intval($_POST['commonid']); if (!uk86_chksubmit() || $common_id <= 0) { showDialog(L('store_goods_index_goods_edit_fail'), uk86_urlShop('store_goods_online', 'index')); } // 验证表单 $obj_validate = new Uk86Validate(); $obj_validate->validateparam = array(array("input" => $_POST["g_name"], "require" => "true", "message" => L('store_goods_index_goods_name_null')), array("input" => $_POST["g_price"], "require" => "true", "validator" => "Double", "message" => L('store_goods_index_goods_price_null'))); $error = $obj_validate->uk86_validate(); if ($error != '') { showDialog(L('error') . $error, uk86_urlShop('store_goods_online', 'index')); } $gc_id = intval($_POST['cate_id']); // 验证商品分类是否存在且商品分类是否为最后一级 $data = Model('goods_class')->getGoodsClassForCacheModel(); if (!isset($data[$gc_id]) || isset($data[$gc_id]['child']) || isset($data[$gc_id]['childchild'])) { showDialog(L('store_goods_index_again_choose_category1')); } // 三方店铺验证是否绑定了该分类 if (!uk86_checkPlatformStore()) { //商品分类 by ukshop. com 提供批量显示所有分类插件 $model_bind_class = Model('store_bind_class'); $goods_class = Model('goods_class')->getGoodsClassForCacheModel(); $where['store_id'] = $_SESSION['store_id']; $class_2 = $goods_class[$gc_id]['gc_parent_id']; $class_1 = $goods_class[$class_2]['gc_parent_id']; $where['class_1'] = $class_1; $where['class_2'] = $class_2; $where['class_3'] = $gc_id; $bind_info = $model_bind_class->getStoreBindClassInfo($where); if (empty($bind_info)) { $where['class_3'] = 0; $bind_info = $model_bind_class->getStoreBindClassInfo($where); if (empty($bind_info)) { $where['class_2'] = 0; $where['class_3'] = 0; $bind_info = $model_bind_class->getStoreBindClassInfo($where); if (empty($bind_info)) { $where['class_1'] = 0; $where['class_2'] = 0; $where['class_3'] = 0; $bind_info = $model_bind_class->getStoreBindClassInfo($where); if (empty($bind_info)) { showDialog(L('store_goods_index_again_choose_category2')); } } } } } // 分类信息 $goods_class = Model('goods_class')->getGoodsClassLineForTag(intval($_POST['cate_id'])); $model_goods = Model('goods'); $update_common = array(); $update_common['goods_name'] = $_POST['g_name']; $update_common['goods_jingle'] = $_POST['g_jingle']; $update_common['gc_id'] = $gc_id; $update_common['gc_id_1'] = intval($goods_class['gc_id_1']); $update_common['gc_id_2'] = intval($goods_class['gc_id_2']); $update_common['gc_id_3'] = intval($goods_class['gc_id_3']); $update_common['gc_name'] = $_POST['cate_name']; $update_common['brand_id'] = $_POST['b_id']; $update_common['brand_name'] = $_POST['b_name']; $update_common['type_id'] = intval($_POST['type_id']); $update_common['goods_image'] = $_POST['image_path']; $update_common['goods_price'] = floatval($_POST['g_price']); $update_common['goods_marketprice'] = floatval($_POST['g_marketprice']); $update_common['goods_costprice'] = floatval($_POST['g_costprice']); $update_common['goods_discount'] = floatval($_POST['g_discount']); $update_common['goods_serial'] = $_POST['g_serial']; $update_common['goods_storage_alarm'] = intval($_POST['g_alarm']); $update_common['store_mentioning'] = intval($_POST['g_mentioning']); $update_common['goods_attr'] = serialize($_POST['attr']); $update_common['goods_body'] = $_POST['g_body']; $update_common['store_floor_id'] = intval($_POST['store_floor_id']); //楼层id $update_common['store_floor_name'] = $_POST['store_floor_name']; //楼层名称 // 序列化保存手机端商品描述数据 if ($_POST['m_body'] != '') { $_POST['m_body'] = str_replace('"', '"', $_POST['m_body']); $_POST['m_body'] = json_decode($_POST['m_body'], true); if (!empty($_POST['m_body'])) { $_POST['m_body'] = serialize($_POST['m_body']); } else { $_POST['m_body'] = ''; } } $update_common['mobile_body'] = $_POST['m_body']; $update_common['goods_commend'] = intval($_POST['g_commend']); $update_common['goods_state'] = $this->store_info['store_state'] != 1 ? 0 : intval($_POST['g_state']); // 店铺关闭时,商品下架 $update_common['goods_selltime'] = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60; $update_common['goods_verify'] = C('goods_verify') == 1 ? 10 : 1; $update_common['spec_name'] = is_array($_POST['spec']) ? serialize($_POST['sp_name']) : serialize(null); $update_common['spec_value'] = is_array($_POST['spec']) ? serialize($_POST['sp_val']) : serialize(null); $update_common['goods_vat'] = intval($_POST['g_vat']); $update_common['areaid_1'] = intval($_POST['province_id']); $update_common['areaid_2'] = intval($_POST['city_id']); $update_common['transport_id'] = $_POST['freight'] == '0' ? '0' : intval($_POST['transport_id']); // 运费模板 $update_common['transport_title'] = $_POST['transport_title']; $update_common['goods_freight'] = floatval($_POST['g_freight']); //查询店铺商品分类 $goods_stcids_arr = array(); if (!empty($_POST['sgcate_id'])) { $sgcate_id_arr = array(); foreach ($_POST['sgcate_id'] as $k => $v) { $sgcate_id_arr[] = intval($v); } $sgcate_id_arr = array_unique($sgcate_id_arr); $store_goods_class = Model('store_goods_class')->getStoreGoodsClassList(array('store_id' => $_SESSION['store_id'], 'stc_id' => array('in', $sgcate_id_arr), 'stc_state' => '1')); if (!empty($store_goods_class)) { foreach ($store_goods_class as $k => $v) { if ($v['stc_id'] > 0) { $goods_stcids_arr[] = $v['stc_id']; } if ($v['stc_parent_id'] > 0) { $goods_stcids_arr[] = $v['stc_parent_id']; } } $goods_stcids_arr = array_unique($goods_stcids_arr); sort($goods_stcids_arr); } } if (empty($goods_stcids_arr)) { $update_common['goods_stcids'] = ''; } else { $update_common['goods_stcids'] = ',' . implode(',', $goods_stcids_arr) . ','; } $update_common['plateid_top'] = intval($_POST['plate_top']) > 0 ? intval($_POST['plate_top']) : ''; $update_common['plateid_bottom'] = intval($_POST['plate_bottom']) > 0 ? intval($_POST['plate_bottom']) : ''; $update_common['is_virtual'] = intval($_POST['is_gv']); $update_common['virtual_indate'] = $_POST['g_vindate'] != '' ? strtotime($_POST['g_vindate']) + 24 * 60 * 60 - 1 : 0; // 当天的最后一秒结束 $update_common['virtual_limit'] = intval($_POST['g_vlimit']) > 10 || intval($_POST['g_vlimit']) < 0 ? 10 : intval($_POST['g_vlimit']); $update_common['virtual_invalid_refund'] = intval($_POST['g_vinvalidrefund']); $update_common['is_fcode'] = intval($_POST['is_fc']); $update_common['is_appoint'] = intval($_POST['is_appoint']); // 只有库存为零的商品可以预约 $update_common['appoint_satedate'] = $update_common['is_appoint'] == 1 ? strtotime($_POST['g_saledate']) : ''; // 预约商品的销售时间 $update_common['is_presell'] = $update_common['goods_state'] == 1 ? intval($_POST['is_presell']) : 0; // 只有出售中的商品可以预售 $update_common['presell_deliverdate'] = $update_common['is_presell'] == 1 ? strtotime($_POST['g_deliverdate']) : ''; // 预售商品的发货时间 $update_common['is_own_shop'] = in_array($_SESSION['store_id'], model('store')->getOwnShopIds()) ? 1 : 0; // 开始事务 Model()->beginTransaction(); $model_gift = Model('goods_gift'); // 清除原有规格数据 $model_type = Model('type'); $model_type->delGoodsAttr(array('goods_commonid' => $common_id)); // 生成商品二维码 require_once BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php'; $PhpQRCode = new PhpQRCode(); $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $_SESSION['store_id'] . DS); // 更新商品规格 $goodsid_array = array(); $colorid_array = array(); if (is_array($_POST['spec'])) { foreach ($_POST['spec'] as $value) { $goods_info = $model_goods->getGoodsInfo(array('goods_id' => $value['goods_id'], 'goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id']), 'goods_id'); if (!empty($goods_info)) { $goods_id = $goods_info['goods_id']; $update = array(); $update['goods_commonid'] = $common_id; $update['goods_name'] = $update_common['goods_name'] . ' ' . implode(' ', $value['sp_value']); $update['goods_jingle'] = $update_common['goods_jingle']; $update['store_id'] = $_SESSION['store_id']; $update['store_name'] = $_SESSION['store_name']; $update['gc_id'] = $update_common['gc_id']; $update['gc_id_1'] = $update_common['gc_id_1']; $update['gc_id_2'] = $update_common['gc_id_2']; $update['gc_id_3'] = $update_common['gc_id_3']; $update['brand_id'] = $update_common['brand_id']; $update['goods_price'] = $value['price']; $update['goods_marketprice'] = $value['marketprice'] == 0 ? $update_common['goods_marketprice'] : $value['marketprice']; $update['goods_serial'] = $value['sku']; $update['goods_storage_alarm'] = intval($value['alarm']); $update['goods_spec'] = serialize($value['sp_value']); $update['goods_storage'] = $value['stock']; $update['goods_state'] = $update_common['goods_state']; $update['goods_verify'] = $update_common['goods_verify']; $update['goods_edittime'] = TIMESTAMP; $update['areaid_1'] = $update_common['areaid_1']; $update['areaid_2'] = $update_common['areaid_2']; $update['color_id'] = intval($value['color']); $update['transport_id'] = $update_common['transport_id']; $update['goods_freight'] = $update_common['goods_freight']; $update['goods_vat'] = $update_common['goods_vat']; $update['goods_commend'] = $update_common['goods_commend']; $update['goods_stcids'] = $update_common['goods_stcids']; $update['is_virtual'] = $update_common['is_virtual']; $update['virtual_indate'] = $update_common['virtual_indate']; $update['virtual_limit'] = $update_common['virtual_limit']; $update['virtual_invalid_refund'] = $update_common['virtual_invalid_refund']; $update['is_fcode'] = $update_common['is_fcode']; $update['is_appoint'] = $update_common['is_appoint']; $update['is_presell'] = $update_common['is_presell']; $update['store_mentioning'] = $update_common['store_mentioning']; $update['store_floor_id'] = $update_common['store_floor_id']; //楼层id $update['store_floor_name'] = $update_common['store_floor_name']; //楼层名称 // 虚拟商品不能有赠品 if ($update_common['is_virtual'] == 1) { $update['have_gift'] = 0; $model_gift->delGoodsGift(array('goods_id' => $goods_id)); } $update['is_own_shop'] = $update_common['is_own_shop']; $model_goods->editGoodsById($update, $goods_id); // 生成商品二维码 $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } else { $insert = array(); $insert['goods_commonid'] = $common_id; $insert['goods_name'] = $update_common['goods_name'] . ' ' . implode(' ', $value['sp_value']); $insert['goods_jingle'] = $update_common['goods_jingle']; $insert['store_id'] = $_SESSION['store_id']; $insert['store_name'] = $_SESSION['store_name']; $insert['gc_id'] = $update_common['gc_id']; $insert['gc_id_1'] = $update_common['gc_id_1']; $insert['gc_id_2'] = $update_common['gc_id_2']; $insert['gc_id_3'] = $update_common['gc_id_3']; $insert['brand_id'] = $update_common['brand_id']; $insert['goods_price'] = $value['price']; $insert['goods_promotion_price'] = $value['price']; $insert['goods_marketprice'] = $value['marketprice'] == 0 ? $update_common['goods_marketprice'] : $value['marketprice']; $insert['goods_serial'] = $value['sku']; $insert['goods_storage_alarm'] = intval($value['alarm']); $insert['goods_spec'] = serialize($value['sp_value']); $insert['goods_storage'] = $value['stock']; $insert['goods_image'] = $update_common['goods_image']; $insert['goods_state'] = $update_common['goods_state']; $insert['goods_verify'] = $update_common['goods_verify']; $insert['goods_addtime'] = TIMESTAMP; $insert['goods_edittime'] = TIMESTAMP; $insert['areaid_1'] = $update_common['areaid_1']; $insert['areaid_2'] = $update_common['areaid_2']; $insert['color_id'] = intval($value['color']); $insert['transport_id'] = $update_common['transport_id']; $insert['goods_freight'] = $update_common['goods_freight']; $insert['goods_vat'] = $update_common['goods_vat']; $insert['store_mentioning'] = $update_common['store_mentioning']; $insert['goods_commend'] = $update_common['goods_commend']; $insert['goods_stcids'] = $update_common['goods_stcids']; $insert['is_virtual'] = $update_common['is_virtual']; $insert['virtual_indate'] = $update_common['virtual_indate']; $insert['virtual_limit'] = $update_common['virtual_limit']; $insert['virtual_invalid_refund'] = $update_common['virtual_invalid_refund']; $insert['is_fcode'] = $update_common['is_fcode']; $insert['is_appoint'] = $update_common['is_appoint']; $insert['is_presell'] = $update_common['is_presell']; $insert['is_own_shop'] = $update_common['is_own_shop']; $goods_id = $model_goods->addGoods($insert); // 生成商品二维码 $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } $goodsid_array[] = intval($goods_id); $colorid_array[] = intval($value['color']); $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr'])); } } else { $goods_info = $model_goods->getGoodsInfo(array('goods_spec' => serialize(null), 'goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id']), 'goods_id'); if (!empty($goods_info)) { $goods_id = $goods_info['goods_id']; $update = array(); $update['goods_commonid'] = $common_id; $update['goods_name'] = $update_common['goods_name']; $update['goods_jingle'] = $update_common['goods_jingle']; $update['store_id'] = $_SESSION['store_id']; $update['store_name'] = $_SESSION['store_name']; $update['gc_id'] = $update_common['gc_id']; $update['gc_id_1'] = $update_common['gc_id_1']; $update['gc_id_2'] = $update_common['gc_id_2']; $update['gc_id_3'] = $update_common['gc_id_3']; $update['brand_id'] = $update_common['brand_id']; $update['goods_price'] = $update_common['goods_price']; $update['goods_marketprice'] = $update_common['goods_marketprice']; $update['goods_serial'] = $update_common['goods_serial']; $update['goods_storage_alarm'] = $update_common['goods_storage_alarm']; $update['goods_spec'] = serialize(null); $update['goods_storage'] = intval($_POST['g_storage']); $update['goods_state'] = $update_common['goods_state']; $update['goods_verify'] = $update_common['goods_verify']; $update['goods_edittime'] = TIMESTAMP; $update['areaid_1'] = $update_common['areaid_1']; $update['areaid_2'] = $update_common['areaid_2']; $update['color_id'] = 0; $update['transport_id'] = $update_common['transport_id']; $update['goods_freight'] = $update_common['goods_freight']; $update['goods_vat'] = $update_common['goods_vat']; $update['goods_commend'] = $update_common['goods_commend']; $update['goods_stcids'] = $update_common['goods_stcids']; $update['is_virtual'] = $update_common['is_virtual']; $update['virtual_indate'] = $update_common['virtual_indate']; $update['virtual_limit'] = $update_common['virtual_limit']; $update['virtual_invalid_refund'] = $update_common['virtual_invalid_refund']; $update['is_fcode'] = $update_common['is_fcode']; $update['is_appoint'] = $update_common['is_appoint']; $update['is_presell'] = $update_common['is_presell']; $update['store_mentioning'] = $update_common['store_mentioning']; if ($update_common['is_virtual'] == 1) { $update['have_gift'] = 0; $model_gift->delGoodsGift(array('goods_id' => $goods_id)); } $update['is_own_shop'] = $update_common['is_own_shop']; $model_goods->editGoodsById($update, $goods_id); // 生成商品二维码 $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } else { $insert = array(); $insert['goods_commonid'] = $common_id; $insert['goods_name'] = $update_common['goods_name']; $insert['goods_jingle'] = $update_common['goods_jingle']; $insert['store_id'] = $_SESSION['store_id']; $insert['store_name'] = $_SESSION['store_name']; $insert['gc_id'] = $update_common['gc_id']; $insert['gc_id_1'] = $update_common['gc_id_1']; $insert['gc_id_2'] = $update_common['gc_id_2']; $insert['gc_id_3'] = $update_common['gc_id_3']; $insert['brand_id'] = $update_common['brand_id']; $insert['goods_price'] = $update_common['goods_price']; $insert['goods_promotion_price'] = $update_common['goods_price']; $insert['goods_marketprice'] = $update_common['goods_marketprice']; $insert['goods_serial'] = $update_common['goods_serial']; $insert['goods_storage_alarm'] = $update_common['goods_storage_alarm']; $insert['goods_spec'] = serialize(null); $insert['goods_storage'] = intval($_POST['g_storage']); $insert['goods_image'] = $update_common['goods_image']; $insert['goods_state'] = $update_common['goods_state']; $insert['goods_verify'] = $update_common['goods_verify']; $insert['goods_addtime'] = TIMESTAMP; $insert['goods_edittime'] = TIMESTAMP; $insert['areaid_1'] = $update_common['areaid_1']; $insert['areaid_2'] = $update_common['areaid_2']; $insert['color_id'] = 0; $insert['transport_id'] = $update_common['transport_id']; $insert['goods_freight'] = $update_common['goods_freight']; $insert['goods_vat'] = $update_common['goods_vat']; $insert['goods_commend'] = $update_common['goods_commend']; $insert['goods_stcids'] = $update_common['goods_stcids']; $insert['is_virtual'] = $update_common['is_virtual']; $insert['virtual_indate'] = $update_common['virtual_indate']; $insert['virtual_limit'] = $update_common['virtual_limit']; $insert['virtual_invalid_refund'] = $update_common['virtual_invalid_refund']; $insert['is_fcode'] = $update_common['is_fcode']; $insert['is_appoint'] = $update_common['is_appoint']; $insert['is_presell'] = $update_common['is_presell']; $insert['is_own_shop'] = $update_common['is_own_shop']; $insert['store_mentioning'] = $update_common['store_mentioning']; $goods_id = $model_goods->addGoods($insert); } $goodsid_array[] = intval($goods_id); $colorid_array[] = 0; $model_type->addGoodsType($goods_id, $common_id, array('cate_id' => $_POST['cate_id'], 'type_id' => $_POST['type_id'], 'attr' => $_POST['attr'])); } // 生成商品二维码 if (!empty($goodsid_array)) { //Uk86QueueClient::push('createGoodsQRCode', array('store_id' => $_SESSION['store_id'], 'goodsid_array' => $goodsid_array)); // 生成商品二维码 $PhpQRCode->set('date', WAP_SITE_URL . '/tmpl/product_detail.html?goods_id=' . $goods_id); $PhpQRCode->set('pngTempName', $goods_id . '.png'); $PhpQRCode->init(); } // 清理商品数据 $model_goods->delGoods(array('goods_id' => array('not in', $goodsid_array), 'goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id'])); // 清理商品图片表 $colorid_array = array_unique($colorid_array); $model_goods->delGoodsImages(array('goods_commonid' => $common_id, 'color_id' => array('not in', $colorid_array))); // 更新商品默认主图 $default_image_list = $model_goods->getGoodsImageList(array('goods_commonid' => $common_id, 'is_default' => 1), 'color_id,goods_image'); if (!empty($default_image_list)) { foreach ($default_image_list as $val) { $model_goods->editGoods(array('goods_image' => $val['goods_image']), array('goods_commonid' => $common_id, 'color_id' => $val['color_id'])); } } // 商品加入上架队列 if (isset($_POST['starttime'])) { $selltime = strtotime($_POST['starttime']) + intval($_POST['starttime_H']) * 3600 + intval($_POST['starttime_i']) * 60; if ($selltime > TIMESTAMP) { $this->addcron(array('exetime' => $selltime, 'exeid' => $common_id, 'type' => 1), true); } } // 添加操作日志 $this->recordSellerLog('编辑商品,平台货号:' . $common_id); if ($update_common['is_virtual'] == 1 || $update_common['is_fcode'] == 1 || $update_common['is_presell'] == 1) { // 如果是特殊商品清理促销活动,抢购、限时折扣、组合销售 Uk86QueueClient::push('clearSpecialGoodsPromotion', array('goods_commonid' => $common_id, 'goodsid_array' => $goodsid_array)); } else { // 更新商品促销价格 Uk86QueueClient::push('updateGoodsPromotionPriceByGoodsCommonId', $common_id); } // 生成F码 if ($update_common['is_fcode'] == 1) { Uk86QueueClient::push('createGoodsFCode', array('goods_commonid' => $common_id, 'fc_count' => intval($_POST['g_fccount']), 'fc_prefix' => $_POST['g_fcprefix'])); } $return = $model_goods->editGoodsCommon($update_common, array('goods_commonid' => $common_id, 'store_id' => $_SESSION['store_id'])); if ($return) { //提交事务 Model()->commit(); showDialog(L('nc_common_op_succ'), $_POST['ref_url'], 'succ'); } else { //回滚事务 Model()->rollback(); showDialog(L('store_goods_index_goods_edit_fail'), uk86_urlShop('store_goods_online', 'index')); } }
/** * 支付订单 * @param array $order_info * @param string $role 操作角色 buyer、seller、admin、system 分别代表买家、商家、管理员、系统 * @param string $post * @return array */ public function changeOrderStatePay($order_info, $role, $post) { try { $model_vr_order = Model('vr_order'); $model_vr_order->beginTransaction(); $model_pd = Model('predeposit'); //下单,支付被冻结的充值卡 $rcb_amount = floatval($order_info['rcb_amount']); if ($rcb_amount > 0) { $data_pd = array(); $data_pd['member_id'] = $order_info['buyer_id']; $data_pd['member_name'] = $order_info['buyer_name']; $data_pd['amount'] = $rcb_amount; $data_pd['order_sn'] = $order_info['order_sn']; $model_pd->changeRcb('order_comb_pay', $data_pd); } //下单,支付被冻结的预存款 $pd_amount = floatval($order_info['pd_amount']); if ($pd_amount > 0) { $data_pd = array(); $data_pd['member_id'] = $order_info['buyer_id']; $data_pd['member_name'] = $order_info['buyer_name']; $data_pd['amount'] = $pd_amount; $data_pd['order_sn'] = $order_info['order_sn']; $model_pd->changePd('order_comb_pay', $data_pd); } //更新订单状态 $update_order = array(); $update_order['order_state'] = ORDER_STATE_PAY; $update_order['payment_time'] = $post['payment_time'] ? strtotime($post['payment_time']) : TIMESTAMP; $update_order['payment_code'] = $post['payment_code']; $update_order['trade_no'] = $post['trade_no']; $update = $model_vr_order->editOrder($update_order, array('order_id' => $order_info['order_id'])); if (!$update) { throw new Exception(L('nc_common_save_fail')); } //发放兑换码 $insert = $model_vr_order->addOrderCode($order_info); if (!$insert) { throw new Exception('兑换码发送失败'); } // 支付成功发送买家消息 $param = array(); $param['code'] = 'order_payment_success'; $param['member_id'] = $order_info['buyer_id']; $param['param'] = array('order_sn' => $order_info['order_sn'], 'order_url' => uk86_urlShop('member_vr_order', 'show_order', array('order_id' => $order_info['order_id']))); Uk86QueueClient::push('sendMemberMsg', $param); // 支付成功发送店铺消息 $param = array(); $param['code'] = 'new_order'; $param['store_id'] = $order_info['store_id']; $param['param'] = array('order_sn' => $order_info['order_sn']); Uk86QueueClient::push('sendStoreMsg', $param); $model_vr_order->commit(); return uk86_callback(true, '更新成功'); } catch (Exception $e) { $model_vr_order->rollback(); return uk86_callback(false, $e->getMessage()); } }
/** * 发送兑换码到手机 */ public function resendOp() { if (!uk86_chksubmit()) { Tpl::showpage('member_vr_order.resend', 'null_layout'); exit; } if (!preg_match('/^[\\d]{11}$/', $_POST['buyer_phone'])) { showDialog('请正确填写手机号'); } $order_id = intval($_POST['order_id']); if ($order_id <= 0) { showDialog('参数错误'); } $model_vr_order = Model('vr_order'); $condition = array(); $condition['order_id'] = $order_id; $condition['buyer_id'] = $_SESSION['member_id']; $order_info = $model_vr_order->getOrderInfo($condition); if (empty($order_info) && $order_info['order_state'] != ORDER_STATE_PAY) { showDialog('订单信息发生错误'); } if ($order_info['vr_send_times'] >= 5) { showDialog('您发送的次数过多,无法发送'); } //发送兑换码到手机 $param = array('order_id' => $order_id, 'buyer_id' => $_SESSION['member_id'], 'buyer_phone' => $order_info['buyer_phone']); Uk86QueueClient::push('sendVrCode', $param); $model_vr_order->editOrder(array('vr_send_times' => array('exp', 'vr_send_times+1')), array('order_id' => $order_id)); showDialog('发送成功', '', 'succ', "DialogManager.close('vr_code_resend');"); }
/** * 订单后续其它处理 * */ private function _createOrderStep6() { $ifcart = $this->_post_data['ifcart']; $goods_buy_quantity = $this->_order_data['goods_buy_quantity']; $input_voucher_list = $this->_order_data['input_voucher_list']; $store_cart_list = $this->_order_data['store_cart_list']; $input_buy_items = $this->_order_data['input_buy_items']; $order_list = $this->_order_data['order_list']; $input_address_info = $this->_order_data['input_address_info']; $notice_list = $this->_order_data['notice_list']; $fc_id = $this->_order_data['fc_id']; $ifgroupbuy = $this->_order_data['ifgroupbuy']; //变更库存和销量 Uk86QueueClient::push('createOrderUpdateStorage', $goods_buy_quantity); //更新使用的卡券包状态 if (!empty($input_voucher_list) && is_array($input_voucher_list)) { Uk86QueueClient::push('editVoucherState', $input_voucher_list); } //更新F码使用状态 if ($fc_id) { Model('free')->where(array('fcode_id' => $fc_id))->update(array('free_state' => 1)); Uk86QueueClient::push('updateGoodsFCode', $fc_id); } //更新抢购购买人数和数量 if ($ifgroupbuy) { foreach ($store_cart_list as $goods_list) { foreach ($goods_list as $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['goods_num']; Uk86QueueClient::push('editGroupbuySaleCount', $groupbuy_info); } } } } //删除购物车中的商品 $this->delCart($ifcart, $this->_member_info['member_id'], array_keys($input_buy_items)); @uk86_setNcCookie('cart_goods_num', '', -3600); //保存订单自提点信息 if (C('delivery_isuse') && intval($input_address_info['dlyp_id'])) { $data = array(); $data['mob_phone'] = $input_address_info['mob_phone']; $data['tel_phone'] = $input_address_info['tel_phone']; $data['reciver_name'] = $input_address_info['true_name']; $data['dlyp_id'] = $input_address_info['dlyp_id']; foreach ($order_list as $v) { $data['order_sn_list'][$v['order_id']]['order_sn'] = $v['order_sn']; $data['order_sn_list'][$v['order_id']]['add_time'] = $v['add_time']; } Uk86QueueClient::push('saveDeliveryOrder', $data); } //发送提醒类信息 if (!empty($notice_list)) { foreach ($notice_list as $code => $value) { Uk86QueueClient::push('sendStoreMsg', array('code' => $code, 'store_id' => key($value), 'param' => current($value))); } } }
/** * 添加会员经验值 * @param unknown $member_info */ public function addExppoint($member_info) { if (empty($member_info)) { return; } //一天内只有第一次登录赠送经验值 if (trim(@date('Y-m-d', $member_info['member_login_time'])) == trim(date('Y-m-d'))) { return; } //加入队列 $queue_content = array(); $queue_content['member_id'] = $member_info['member_id']; $queue_content['member_name'] = $member_info['member_name']; Uk86QueueClient::push('addExppoint', $queue_content); }
public function complain_verifyOp() { $complain_id = intval($_POST['complain_id']); $complain_info = $this->get_complain_info($complain_id); if (intval($complain_info['complain_state']) === self::STATE_NEW) { $model_complain = Model('complain'); $update_array = array(); $update_array['complain_state'] = self::STATE_APPEAL; $update_array['complain_handle_datetime'] = time(); $update_array['complain_handle_member_id'] = $this->get_admin_id(); $update_array['complain_active'] = self::STATE_ACTIVE; $where_array = array(); $where_array['complain_id'] = $complain_id; if ($model_complain->updateComplain($update_array, $where_array)) { $this->log(L('complain_verify_success') . '[' . $complain_id . ']', 1); // 发送商家消息 $param = array(); $param['code'] = 'complain'; $param['store_id'] = $complain_info['accused_id']; $param['param'] = array('complain_id' => $complain_id); Uk86QueueClient::push('sendStoreMsg', $param); uk86_showMessage(Uk86Language::uk86_get('complain_verify_success'), 'index.php?act=complain&op=complain_new_list'); } else { uk86_showMessage(Uk86Language::uk86_get('complain_verify_fail'), 'index.php?act=complain&op=complain_new_list'); } } else { uk86_showMessage(Uk86Language::uk86_get('param_error'), ''); } }
/** * 生成所有店铺月订单出账单[虚拟订单] * * @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']); Uk86QueueClient::push('sendStoreMsg', $param); } } } } }
/** * 变更预存款 * @param unknown $change_type * @param unknown $data * @throws Exception * @return unknown */ public function changePa($change_type, $data = array(), $refund = array()) { $data_log = array(); $data_pd = array(); $data_msg = array(); $data_log['lg_member_id'] = $data['member_id']; $data_log['lg_member_name'] = $data['member_name']; $data_log['lg_add_time'] = TIMESTAMP; $data_log['lg_type'] = $change_type; $data_msg['time'] = date('Y-m-d H:i:s'); $data_msg['pd_url'] = uk86_urlShop('predeposit', 'pd_log_list'); switch ($change_type) { 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; default: throw new Exception('参数错误'); break; } //转到第三方退款api $update = $this->_api_refund($data['payment_code'], $refund); 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'] = uk86_ncPriceFormat($data_msg['av_amount']); $data_msg['freeze_amount'] = uk86_ncPriceFormat($data_msg['freeze_amount']); $param['param'] = $data_msg; Uk86QueueClient::push('sendMemberMsg', $param); return $insert; }
/** * 更新抢购购买人数和数量 */ 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']; Uk86QueueClient::push('editGroupbuySaleCount', $groupbuy_info); } }
/** * 账单付款 * */ public function bill_payOp() { if (!preg_match('/^20\\d{5,12}$/', $_GET['ob_no'])) { uk86_showMessage('参数错误', '', 'html', 'error'); } $model_bill = Model('bill'); $condition = array(); $condition['ob_no'] = $_GET['ob_no']; $condition['ob_state'] = BILL_STATE_SYSTEM_CHECK; $bill_info = $model_bill->getOrderBillInfo($condition); if (!$bill_info) { uk86_showMessage('参数错误', '', 'html', 'error'); } if (uk86_chksubmit()) { if (!preg_match('/^20\\d{2}-\\d{2}-\\d{2}$/', $_POST['pay_date'])) { uk86_showMessage('参数错误', '', 'html', 'error'); } $input = array(); $input['ob_pay_content'] = $_POST['pay_content']; $input['ob_pay_date'] = strtotime($_POST['pay_date']); $input['ob_state'] = BILL_STATE_SUCCESS; $update = $model_bill->editOrderBill($input, $condition); if ($update) { $model_store_cost = Model('store_cost'); $cost_condition = array(); $cost_condition['cost_store_id'] = $bill_info['ob_store_id']; $cost_condition['cost_state'] = 0; $cost_condition['cost_time'] = array('between', "{$bill_info['ob_start_date']},{$bill_info['ob_end_date']}"); $model_store_cost->editStoreCost(array('cost_state' => 1), $cost_condition); // 发送店铺消息 $param = array(); $param['code'] = 'store_bill_gathering'; $param['store_id'] = $bill_info['ob_store_id']; $param['param'] = array('bill_no' => $bill_info['ob_no']); Uk86QueueClient::push('sendStoreMsg', $param); $this->log('账单付款,账单号:' . $_GET['ob_no'], 1); uk86_showMessage('保存成功', 'index.php?act=bill&op=show_statis&os_month=' . $bill_info['os_month']); } else { $this->log('账单付款,账单号:' . $_GET['ob_no'], 1); uk86_showMessage('保存失败', '', 'html', 'error'); } } else { Tpl::showpage('bill.pay'); } }
/** * 收到货款 * @param array $order_info * @param string $role 操作角色 buyer、seller、admin、system 分别代表买家、商家、管理员、系统 * @param string $user 操作人 * @return array */ public function changeOrderReceivePay($order_list, $role, $user = '', $post = array()) { $model_order = Model('order'); try { $model_order->beginTransaction(); $data = array(); $data['api_pay_state'] = 1; // ukshop $update = $model_order->editOrderPay($data, array('pay_sn' => $order_list[0]['pay_sn'])); //$update = $model_order->editOrderPay($data,array('pay_sn'=>$order_info['pay_sn'])); if (!$update) { throw new Exception('更新支付单状态失败'); } $model_pd = Model('predeposit'); foreach ($order_list as $order_info) { $order_id = $order_info['order_id']; if ($order_info['order_state'] != ORDER_STATE_NEW) { continue; } //下单,支付被冻结的充值卡 $rcb_amount = floatval($order_info['rcb_amount']); if ($rcb_amount > 0) { $data_pd = array(); $data_pd['member_id'] = $order_info['buyer_id']; $data_pd['member_name'] = $order_info['buyer_name']; $data_pd['amount'] = $rcb_amount; $data_pd['order_sn'] = $order_info['order_sn']; $model_pd->changeRcb('order_comb_pay', $data_pd); } //下单,支付被冻结的预存款 $pd_amount = floatval($order_info['pd_amount']); if ($pd_amount > 0) { $data_pd = array(); $data_pd['member_id'] = $order_info['buyer_id']; $data_pd['member_name'] = $order_info['buyer_name']; $data_pd['amount'] = $pd_amount; $data_pd['order_sn'] = $order_info['order_sn']; $model_pd->changePd('order_comb_pay', $data_pd); } } //更新订单状态 $update_order = array(); $update_order['order_state'] = ORDER_STATE_PAY; $update_order['payment_time'] = $post['payment_time'] ? strtotime($post['payment_time']) : TIMESTAMP; $update_order['payment_code'] = $post['payment_code']; //$update_order['trade_no'] = $post['trade_no']; order表并没有trade_no字段 $update = $model_order->editOrder($update_order, array('pay_sn' => $order_info['pay_sn'], 'order_state' => ORDER_STATE_NEW)); if (!$update) { throw new Exception('操作失败'); } $model_order->commit(); } catch (Exception $e) { $model_order->rollback(); return uk86_callback(false, $e->getMessage()); } foreach ($order_list as $order_info) { //防止重复发送消息 if ($order_info['order_state'] != ORDER_STATE_NEW) { continue; } $order_id = $order_info['order_id']; // 支付成功发送买家消息 $param = array(); $param['code'] = 'order_payment_success'; $param['member_id'] = $order_info['buyer_id']; $param['param'] = array('order_sn' => $order_info['order_sn'], 'order_url' => uk86_urlShop('member_order', 'show_order', array('order_id' => $order_info['order_id']))); Uk86QueueClient::push('sendMemberMsg', $param); // 支付成功发送店铺消息 $param = array(); $param['code'] = 'new_order'; $param['store_id'] = $order_info['store_id']; $param['param'] = array('order_sn' => $order_info['order_sn']); Uk86QueueClient::push('sendStoreMsg', $param); //添加订单日志 $data = array(); $data['order_id'] = $order_id; $data['log_role'] = $role; $data['log_user'] = $user; $data['log_msg'] = '收到了货款 ( 支付平台交易号 : ' . $post['trade_no'] . ' )'; $data['log_orderstate'] = ORDER_STATE_PAY; $model_order->addOrderLog($data); } return uk86_callback(true, '操作成功'); }