12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154 |
- <?php
- /**
- * 队列
- *
- * 方法名需要和 QueueClient::push中第一个参数一致,如:
- * QueueClient::push('editGroupbuySaleCount',$groupbuy_info);
- * public function editGroupbuySaleCount($groupbuy_info){...}
- *
- */
- defined('InShopNC') or exit('Access Invalid!');
- require_once(BASE_HELPER_PATH . '/push_sender.php');
- require_once(BASE_HELPER_PATH . '/sms_helper.php');
- require_once(BASE_HELPER_PATH . '/kdn_helper.php');
- require_once(BASE_HELPER_PATH . '/statistics_helper.php');
- require_once(BASE_HELPER_PATH . '/member_helper.php');
- require_once(BASE_HELPER_PATH . '/account_helper.php');
- require_once(BASE_HELPER_PATH . '/fcode/generator.php');
- require_once(BASE_HELPER_PATH . '/memsg/message_sender.php');
- require_once(BASE_HELPER_PATH . '/login_helper.php');
- require_once(BASE_HELPER_PATH . '/fcode/mfcode.php');
- require_once(BASE_HELPER_PATH . '/fcode/operator.php');
- require_once(BASE_HELPER_PATH . '/user_session/fcode.php');
- require_once(BASE_HELPER_PATH . '/stat_helper.php');
- require_once(BASE_HELPER_PATH . '/message/publisher.php');
- require_once(BASE_HELPER_PATH . '/search/tcp_client.php');
- require_once(BASE_HELPER_PATH . '/ugc_helper.php');
- require_once(BASE_HELPER_PATH . '/room_helper.php');
- require_once(BASE_HELPER_PATH . '/mcard/mcard.php');
- require_once(BASE_HELPER_PATH . '/util_helper.php');
- require_once(BASE_HELPER_PATH . '/third_author/signaturer.php');
- class queueLogic
- {
- /**
- * 添加会员积分
- * @param unknown $member_info
- */
- public function addPoint($member_info)
- {
- $points_model = Model('points');
- $points_model->savePointsLog('login', array('pl_memberid' => $member_info['member_id'], 'pl_membername' => $member_info['member_name']), true);
- return callback(true);
- }
- /**
- * 添加会员经验值
- * @param unknown $member_info
- */
- public function addExppoint($member_info)
- {
- $exppoints_model = Model('exppoints');
- $exppoints_model->saveExppointsLog('login', array('exp_memberid' => $member_info['member_id'], 'exp_membername' => $member_info['member_name']), true);
- return callback(true);
- }
- /**
- * 更新抢购信息
- * @param unknown $groupbuy_info
- * @throws Exception
- */
- public function editGroupbuySaleCount($groupbuy_info)
- {
- $model_groupbuy = Model('groupbuy');
- $data = array();
- $data['buyer_count'] = array('exp', 'buyer_count+1');
- $data['buy_quantity'] = array('exp', 'buy_quantity+' . $groupbuy_info['quantity']);
- $update = $model_groupbuy->editGroupbuy($data, array('groupbuy_id' => $groupbuy_info['groupbuy_id']));
- if (!$update) {
- return callback(false, '更新抢购信息失败groupbuy_id:' . $groupbuy_info['groupbuy_id']);
- } else {
- return callback(true);
- }
- }
- public function makeMemberMiniQrCode($params)
- {
- $member_id = intval($params['member_id']);
- $resp = thrid_author\signaturer::instance()->minicode("/pages/index/index?relay_id={$member_id}&channel=0",430);
- if(!empty($resp))
- {
- $passwd = util::passwd;
- $name = md5("{$member_id}.{$passwd}") . ".png";
- $save_path = BASE_UPLOAD_PATH . DS . ATTACH_MINI_QRCODE . DS . $name;
- $length = file_put_contents($save_path,$resp);
- if(!$length) {
- Log::record("Cannot write file: {$save_path}",Log::ERR);
- }
- }
- else {
- Log::record("request mini code error when member_id = {$member_id}",Log::ERR);
- }
- }
- //邀请好友成功后向,邀请者发送微信push消息。
- public function sendInviterSubMsg($params)
- {
- $inviter_id = $params['inviter_id'];
- $invitee_id = $params['invitee_id'];
- $mod_member = Model('member');
- $items = $mod_member->field('member_id,member_wxopenid,member_nickname,member_time')
- ->where(['member_id' => ['in',[$inviter_id,$invitee_id]]])
- ->select();
- foreach ($items as $item) {
- if($item['member_id'] == $inviter_id) {
- $inviter = $item;
- }
- else {
- $invitee = $item;
- }
- }
- if(empty($inviter) || empty($invitee) || empty($inviter['member_wxopenid'])) {
- return callback(false, '向邀请者发送微信push消息错误');
- }
- $tmpid = 'zBNktaey9EM2DcBzUNsjnAan2NvYpj_nKZDY__f9pGA'; //这个是
- $openid = $inviter['member_wxopenid'];
- $time = strftime('%Y年%m月%d日',$invitee['member_time']);
- $data = ['thing4' => ['value' => $invitee['member_nickname'] ], 'time3' => ['value' => "{$time}"]];
- $ret = thrid_author\signaturer::instance()->send_submsg($openid,$tmpid,'pages/index/index',$data);
- if($ret) {
- return callback(true, "向邀请者{$inviter_id}发送微信push消息成功");
- } else {
- return callback(false, "向邀请者{$inviter_id}发送微信push消息错误");
- }
- }
- /**
- * 更新使用的代金券状态
- * @param $input_voucher_list
- * @throws Exception
- */
- public function editVoucherState($voucher_list)
- {
- $model_voucher = Model('voucher');
- $send = new memsg\message_sender();
- foreach ($voucher_list as $store_id => $voucher_info) {
- $update = $model_voucher->editVoucher(['voucher_state' => 2], ['voucher_id' => $voucher_info['voucher_id']], $voucher_info['voucher_owner_id']);
- if ($update) {
- // 发送用户店铺消息
- $send->set('member_id', $voucher_info['voucher_owner_id']);
- $send->set('code', 'voucher_use');
- $param = array();
- $param['voucher_code'] = $voucher_info['voucher_code'];
- $param['voucher_url'] = urlShop('member_voucher', 'index');
- $send->send($param);
- } else {
- return callback(false, '更新代金券状态失败vcode:' . $voucher_info['voucher_code']);
- }
- }
- return callback(true);
- }
- /**
- * 下单变更库存销量
- * @param unknown $goods_buy_quantity
- */
- public function createOrderUpdateStorage($goods_buy_quantity)
- {
- $model_goods = Model('goods');
- foreach ($goods_buy_quantity as $goods_id => $quantity) {
- $data = array();
- $data['goods_storage'] = array('exp', 'goods_storage-' . $quantity);
- $data['goods_salenum'] = array('exp', 'goods_salenum+' . $quantity);
- $result = $model_goods->editGoodsById($data, $goods_id);
- }
- if (!$result) {
- return callback(false, '变更商品库存与销量失败');
- } else {
- return callback(true);
- }
- }
- /**
- * 取消订单变更库存销量
- * @param unknown $goods_buy_quantity
- */
- public function cancelOrderUpdateStorage($goods_buy_quantity)
- {
- $model_goods = Model('goods');
- foreach ($goods_buy_quantity as $goods_id => $quantity) {
- $data = array();
- $data['goods_storage'] = array('exp', 'goods_storage+' . $quantity);
- $data['goods_salenum'] = array('exp', 'goods_salenum-' . $quantity);
- $result = $model_goods->editGoodsById($data, $goods_id);
- }
- if (!$result) {
- return callback(false, '变更商品库存与销量失败');
- } else {
- return callback(true);
- }
- }
- /**
- * 更新F码为使用状态
- * @param int $fc_id
- */
- public function updateGoodsFCode($fc_ids)
- {
- $update = Model('goods_fcode')->editGoodsFCode(array('fc_state' => 1,'consume_time' => time()), array('fc_id' => array('in',$fc_ids)));
- if (!$update) {
- return callback(false, '更新F码使用状态失败fc_ids:' . implode(',',$fc_ids));
- } else {
- return callback(true);
- }
- }
- /**
- * 删除购物车
- * @param unknown $cart
- */
- public function delCart($cart)
- {
- if (!is_array($cart['cart_ids']) || empty($cart['buyer_id'])) return callback(true);
- $del = Model('cart')->delCart('db', array('buyer_id' => $cart['buyer_id'], 'cart_id' => array('in', $cart['cart_ids'])));
- if (!$del) {
- return callback(false, '删除购物车数据失败');
- } else {
- return callback(true);
- }
- }
- /**
- * 根据商品id更新促销价格
- *
- * @param int /array $goods_commonid
- * @return boolean
- */
- public function updateGoodsPromotionPriceByGoodsId($goods_id)
- {
- $update = Model('goods')->editGoodsPromotionPrice(array('goods_id' => array('in', $goods_id)));
- if (!$update) {
- return callback(false, '根据商品ID更新促销价格失败');
- } else {
- return callback(true);
- }
- }
- /**
- * 根据商品公共id更新促销价格
- *
- * @param int /array $goods_commonid
- * @return boolean
- */
- public function updateGoodsPromotionPriceByGoodsCommonId($goods_commonid)
- {
- $update = Model('goods')->editGoodsPromotionPrice(array('goods_commonid' => array('in', $goods_commonid)));
- if (!$update) {
- return callback(false, '根据商品公共id更新促销价格失败');
- } else {
- return callback(true);
- }
- }
- /**
- * 发送店铺消息
- */
- public function sendStoreMsg($param)
- {
- $send = new sendStoreMsg();
- $send->set('code', $param['code']);
- $send->set('store_id', $param['store_id']);
- $send->send($param['param']);
- return callback(true);
- }
- /**
- * 发送会员消息
- */
- public function sendMemberMsg($param)
- {
- $send = new memsg\message_sender();
- $send->set('code', $param['code']);
- $send->set('member_id', $param['member_id']);
- $send->set('sms_param', $param['sms_param']);
- if (!empty($param['number']['mobile'])) $send->set('mobile', $param['number']['mobile']);
- if (!empty($param['number']['email'])) $send->set('email', $param['number']['email']);
- $send->send($param['param']);
- return callback(true);
- }
- /**
- * 生成商品F码
- */
- public function createGoodsFCode($param)
- {
- Log::record("createGoodsFCode {$param['goods_commonid']},{$param['fc_count']},{$param['fc_prefix']},{$param['fc_validate']}",Log::DEBUG);
- $gen = new fcode\generator($param['goods_commonid'],$param['fc_count'],$param['fc_prefix'],$param['fc_validate']);
- $url = $gen->make();
- Log::record("createGoodsFCode url={$url}",Log::DEBUG);
- return callback(true);
- }
- /**
- * 生成商品二维码
- */
- public function createGoodsQRCode($param)
- {
- if (empty($param['goodsid_array'])) {
- return callback(true);
- }
- // 生成商品二维码
- require_once(BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php');
- $PhpQRCode = new PhpQRCode();
- $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $param['store_id'] . DS);
- foreach ($param['goodsid_array'] as $goods_id) {
- // 生成商品二维码
- $PhpQRCode->set('date', urlShop('goods', 'index', array('goods_id' => $goods_id)));
- $PhpQRCode->set('pngTempName', $goods_id . '.png');
- $PhpQRCode->init();
- }
- return callback(true);
- }
- /**
- * 清理特殊商品促销信息
- */
- public function clearSpecialGoodsPromotion($param)
- {
- // 抢购
- Model('groupbuy')->delGroupbuy(array('goods_commonid' => $param['goods_commonid']));
- // 显示折扣
- Model('p_xianshi_goods')->delXianshiGoods(array('goods_id' => array('in', $param['goodsid_array'])));
- // 优惠套装
- Model('p_bundling')->delBundlingGoods(array('goods_id' => array('in', $param['goodsid_array'])));
- // 更新促销价格
- Model('goods')->editGoods(array('goods_promotion_price' => array('exp', 'goods_price'), 'goods_promotion_type' => 0), array('goods_commonid' => $param['goods_commonid']));
- return callback(true);
- }
- /**
- * 删除(买/卖家)订单全部数量缓存
- * @param array $data 订单信息
- * @return boolean
- */
- public function delOrderCountCache($order_info)
- {
- if (empty($order_info)) return callback(true);
- $model_order = Model('order');
- if ($order_info['order_id']) {
- $order_info = $model_order->getOrderInfo(array('order_id' => $order_info['order_id']), array(), 'buyer_id,store_id');
- }
- $model_order->delOrderCountCache('buyer', $order_info['buyer_id']);
- $model_order->delOrderCountCache('store', $order_info['store_id']);
- return callback(true);
- }
- /**
- * 发送兑换码
- * @param unknown $param
- * @return boolean
- */
- public function sendVrCode($param)
- {
- if (empty($param) && !is_array($param)) return callback(true);
- $condition = array();
- $condition['order_id'] = $param['order_id'];
- $condition['buyer_id'] = $param['buyer_id'];
- $condition['vr_state'] = 0;
- $condition['refund_lock'] = 0;
- $code_list = Model('vr_order')->getOrderCodeList($condition, 'vr_code,vr_indate');
- if (empty($code_list)) return callback(true);
- $content = '';
- foreach ($code_list as $v) {
- $content .= $v['vr_code'] . ',';
- }
- $tpl_info = Model('mail_templates')->getTplInfo(array('code' => 'send_vr_code'));
- $data = array();
- $data['site_name'] = C('site_name');
- $data['vr_code'] = rtrim($content, ',');
- $message = ncReplaceText($tpl_info['content'], $data);
- $sms = new Sms();
- $result = $sms->send($param["buyer_phone"], $message);
- if (!$result) {
- return callback(false, '兑换码发送失败order_id:' . $param['order_id']);
- } else {
- return callback(true);
- }
- }
- /**
- * 添加订单自提表内容
- */
- public function saveDeliveryOrder($param)
- {
- if (!is_array($param['order_sn_list'])) return callback(true);
- $data = array();
- $model_delivery_order = Model('delivery_order');
- foreach ($param['order_sn_list'] as $order_id => $v) {
- $data['order_id'] = $order_id;
- $data['order_sn'] = $v['order_sn'];
- $data['addtime'] = $v['add_time'];
- $data['dlyp_id'] = $param['dlyp_id'];
- $data['reciver_name'] = $param['reciver_name'];
- $data['reciver_telphone'] = $param['tel_phone'];
- $data['reciver_mobphone'] = $param['mob_phone'];
- $insert = $model_delivery_order->addDeliveryOrder($data);
- if (!$insert) {
- return callback(false, '保存自提站订单信息失败order_sn:' . $v['order_sn']);
- }
- }
- return callback(true);
- }
- /**
- * 发送提货码短信消息
- */
- public function sendPickupcode($param)
- {
- $dorder_info = Model('delivery_order')->getDeliveryOrderInfo(array('order_id' => $param['order_id']), 'reciver_mobphone');
- $tpl_info = Model('mail_templates')->getTplInfo(array('code' => 'send_pickup_code'));
- $data = array();
- $data['site_name'] = C('site_name');
- $data['pickup_code'] = $param['pickup_code'];
- $message = ncReplaceText($tpl_info['content'], $data);
- $sms = new Sms();
- $result = $sms->send($dorder_info['reciver_mobphone'], $message);
- if (!$result) {
- return callback(false, '发送提货码短信消息失败order_id:' . $param['order_id']);
- } else {
- return callback(true);
- }
- }
- /**
- * 刷新搜索索引
- */
- public function flushIndexer()
- {
- require_once(BASE_DATA_PATH . '/api/xs/lib/XS.php');
- $obj_doc = new XSDocument();
- $obj_xs = new XS(C('fullindexer.appname'));
- $obj_xs->index->flushIndex();
- }
- /**
- * 推送服务
- * @param $param array
- * 共有三个key : member_id , text, go_type
- * @return bool
- */
- public function upushSendMsg($param)
- {
- if (empty($param) || empty($param['alias']) || empty($param['text'])) {
- Log::record("push info: 数据有误! param:" . json_encode($param) . "\t session:" . json_encode($_SESSION));
- return callback(false);
- }
- $push = new push_sender();
- $push->send($param);
- return callback(true);
- }
- public function sendPushMessage($param)
- {
- $push = new push_sender();
- $push->send_message($param);
- return callback(true);
- }
- /**
- * 发短信
- * @param $param
- *
- * @return bool
- */
- public function sendSMS($param)
- {
- if (empty($param) || empty($param['mobile']) || empty($param['type'])) {
- Log::record("sms info: 数据有误! param:" . json_encode($param),Log::ERR);
- return callback(false);
- }
- try {
- $sms = new Sms();
- $status = $sms->send($param['mobile'], $param);
- Log::record("sms info: status:" . json_encode($status) . "\t param:" . json_encode($param),Log::DEBUG);
- } catch (Exception $e) {
- Log::record("sms info: fall error\treturn:" . $e->getMessage() . "\t param:" . json_encode($param),Log::ERR);
- }
- return callback(true);
- }
- public function sendOperSMS($params)
- {
- if (empty($params) || empty($params['mobile']) || empty($params['type'])) {
- Log::record("sms info: 数据有误! param:" . json_encode($params),Log::ERR);
- return callback(false);
- }
- try
- {
- $datas = [];
- foreach ($params as $key => $val)
- {
- if($key == 'mobile') {
- $mobile = $val;
- }
- elseif ($key == 'type') {
- $type = $val;
- }
- else {
- $datas[$key] = $val;
- }
- }
- $sms = new Sms();
- $status = $sms->send_oper($mobile,$type,$datas);
- Log::record("sms info: status:" . json_encode($status) . "\t param:" . json_encode($params),Log::DEBUG);
- } catch (Exception $e) {
- Log::record("sms info: fall error\treturn:" . $e->getMessage() . "\t param:" . json_encode($params),Log::ERR);
- }
- return callback(true);
- }
- public function sendBonusAndSMS($params)
- {
- $input_type = $params['member']['input_type'];
- if($input_type == 'mobiles') {
- $members = member_helper::from_mobiles($params['member']['data'],$error);
- }
- elseif($input_type == 'sql') {
- $members = member_helper::from_sql($params['member']['data']);
- }
- else {
- return callback(false,'sendBonusAndSMS 错误的人员输入类型.');
- }
- $fSendSms = $params['sms']['open'];
- $smscode = $params['sms']['template_id'];
- $rate = $params['bonus']['rate'];
- $bless = $params['bonus']['bless'];
- $amount = $params['bonus']['amount'];
- $can_share = intval($params['bonus']['can_share']);
- $chunks = array_chunk($members,1000);
- foreach ($chunks as $chunk)
- {
- $chunk = member_helper::exmembers($chunk,$params['member']['ex_lrlz'],$params['member']['ex_brand']);
- $ids = [];
- foreach ($chunk as $member) {
- $ids[] = $member['member_id'];
- }
- $ret = account_helper::add_bonus($rate,$amount,$ids,$bless,$can_share);
- if($ret == false) continue;
- if($fSendSms)
- {
- $iconut = 0;
- $sms = new Sms();
- foreach ($chunk as $member)
- {
- $mobile = $member['member_mobile'];
- try {
- $status = $sms->send_oper($mobile, $smscode);
- Log::record("sms info: status:" . json_encode($status),Log::DEBUG);
- } catch (Exception $e) {
- Log::record("sms info: fall error\treturn:" . $e->getMessage(),Log::ERR);
- }
- ++$iconut;
- if($iconut == 10) {
- sleep(2);
- $iconut = 0;
- }
- }
- }
- }
- return callback(true);
- }
- public function sendPushOrSMS($params)
- {
- $input_type = $params['member']['input_type'];
- if($input_type == 'mobiles') {
- $members = member_helper::from_mobiles($params['member']['data'],$error);
- }
- elseif($input_type == 'sql') {
- $members = member_helper::from_sql($params['member']['data']);
- }
- else {
- return callback(false,'sendBonusAndSMS 错误的人员输入类型.');
- }
- $send_type = $params['send']['type'];
- $content = $params['send']['data'];
- $chunks = array_chunk($members,1000);
- foreach ($chunks as $chunk)
- {
- $chunk = member_helper::exmembers($chunk,$params['member']['ex_lrlz'],$params['member']['ex_brand']);
- if($send_type == 'sms')
- {
- $iconut = 0;
- $sms = new Sms();
- foreach ($chunk as $member)
- {
- try {
- $mobile = $member['member_mobile'];
- $status = $sms->send_oper($mobile, $content);
- Log::record("sms info: status:" . json_encode($status),Log::DEBUG);
- } catch (Exception $e) {
- Log::record("sms info: fall error\treturn:" . $e->getMessage(),Log::ERR);
- }
- ++$iconut;
- if($iconut == 10) {
- sleep(2);
- $iconut = 0;
- }
- }
- }
- elseif($send_type == 'push')
- {
- foreach ($chunk as $member) {
- push_helper::oper_push($member['member_id'], $content);
- }
- }
- else {
- }
- }
- return callback(true);
- }
- /**
- * 订阅快递鸟
- * @param $param
- *
- * @return bool
- */
- public function subscribeKDN($param)
- {
- if (empty($param) || empty($param['order_sn'])) {
- Log::record("kdn_helper: 数据有误! param:" . json_encode($param));
- return callback(false);
- }
- try {
- kdn_helper::subscribe($param['order_sn']);
- } catch (Exception $e) {
- Log::record("kdn_helper: fall error\treturn:" . $e->getMessage() . "\t param:" . json_encode($param));
- }
- return callback(true);
- }
- /**
- * 根据上传的通讯录生成好友关系
- */
- public function generateRelations($param)
- {
- if (empty($param["member_id"])) {
- return false;
- }
- try {
- Model("mobile_contacts")->genRelations($param["member_id"]);
- } catch (Exception $e) {
- Log::record("generateRelations: fall error\treturn:" . $e->getMessage());
- }
- return true;
- }
- public function savelog($param)
- {
- statistics_helper::instance()->add_logs($param);
- return callback(true);
- }
- public function click_goods($param)
- {
- $goods_id = intval($param['goods_id']);
- if($goods_id > 0) {
- $mod_goods = Model('goods');
- $mod_goods->editGoodsById(array('goods_click' => array('exp', 'goods_click + 1')), $goods_id);
- return callback(true);
- }
- else {
- return callback(false,"click_goods 错误的goods_id");
- }
- }
- public function reset_fcode($param)
- {
- $pay_sn = $param['pay_sn'];
- if(empty($pay_sn)) {
- return callback(false);
- }
- $num = \fcode\operator::reset($pay_sn);
- if($num > 0) {
- return callback(true);
- } else {
- return callback(false);
- }
- }
- public function onUseBonus($param)
- {
- stat_helper::onUseBonus($param);
- return callback(true);
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public function onAsyncRegister($param)
- {
- $user = $param['user'];
- $inviter = $param['inviter'];
- if($user < 0) {
- return callback(false,"onRegisterFromBonus 错误的member_id");
- }
- account_helper::onAsyncRegister($user,$inviter);
- return callback(true);
- }
- public function onAsyncStatus($param)
- {
- Log::record(__METHOD__,Log::DEBUG);
- account_helper::onAsyncStatus($param['member_id']);
- return callback(true);
- }
- public function onAsyncTopup($param)
- {
- Log::record(__METHOD__,Log::DEBUG);
- account_helper::onAsyncTopup($param['member_id']);
- return callback(true);
- }
- public function onPredeposit($param)
- {
- Log::record('queue::onPredeposit',Log::DEBUG);
- account_helper::onPredeposit($param['change_type'],$param['buyer_id'],$param['order_sn']);
- return callback(true);
- }
- public function onBonusChange($param)
- {
- Log::record('queue::onPredeposit',Log::DEBUG);
- account_helper::onPredeposit($param['change_type'],$param['buyer_id'],$param['order_sn']);
- return callback(true);
- }
- public function onAsyncOrderPaied($param)
- {
- $pay_sn = $param['pay_sn'];
- account_helper::onAsyncOrderPaied($pay_sn);
- return callback(true);
- }
- public function onAsyncOrderSended($param)
- {
- $pay_sn = $param['pay_sn'];
- $logistics_no = $param['logistics_no'];
- $logistics_company = $param['logistics_company'];
- account_helper::onAsyncOrderSended($pay_sn,$logistics_no,$logistics_company);
- return callback(true);
- }
- public function onAsyncOrderComplete($param)
- {
- $pay_sn = $param['pay_sn'];
- if(!empty($pay_sn)) {
- account_helper::onAsyncOrderComplete($pay_sn);
- }
- return callback(true);
- }
- public function onAsyncOrderCancel($param)
- {
- $pay_sn = $param['pay_sn'];
- $order_sn = $param['order_sn'];
- if(!empty($pay_sn) && !empty($order_sn)) {
- account_helper::onAsyncOrderCancel($pay_sn,$order_sn);
- }
- return callback(true);
- }
- public function onAsyncOrderEvaluate($param)
- {
- $pay_sn = $param['pay_sn'];
- if(!empty($pay_sn)) {
- account_helper::onAsyncOrderEvaluate($pay_sn);
- }
- return callback(true);
- }
- public function onAsyncBroadcastOrder($param)
- {
- $pay_sn = $param['pay_sn'];
- $amount = $param['amount'];
- $days = $param['days'];
- if(!empty($pay_sn) && !empty($amount)) {
- account_helper::onAsyncBroadcastOrder($pay_sn,$amount,$days);
- }
- return callback(true);
- }
- public function onAsyncBroadcastNormal($param)
- {
- $filters = $param['filters'];
- $oper_param = $param['oper_param'];
- $send_params = $param['send_params'];
- if(!empty($oper_param) && !empty($filters) && !empty($send_params)) {
- account_helper::onAsyncBroadcastNormal($filters,$oper_param,$send_params);
- }
- return callback(true);
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public function onAsyncUgcPublish($param)
- {
- $spid = $param['special_id'];
- account_helper::onAsyncUgcPublish($spid);
- return callback(true);
- }
- public function onAsyncUgcDel($param)
- {
- $spid = $param['special_id'];
- account_helper::onAsyncUgcDel($spid);
- return callback(true);
- }
- public function onAsyncUgcSubmit($param)
- {
- $spid = $param['special_id'];
- $user = $param['user_id'];
- account_helper::onAsyncUgcSubmit($spid,$user);
- return callback(true);
- }
- public function onAsyncUgcSupport($param)
- {
- $spid = $param['special_id'];
- $user = $param['user_id'];
- $comment_id = $param['comment_id'];
- account_helper::onAsyncUgcSupport($spid,$comment_id,$user);
- return callback(true);
- }
- public static function onAsyncUgcAppreciate($param)
- {
- $spid = $param['special_id'];
- $user = $param['user_id'];
- $rate = $param['rate'];
- $amount = $param['amount'];
- account_helper::onAsyncUgcAppreciate($spid,$user,$rate,$amount);
- return callback(true);
- }
- public function onAsyncUgcComment($param)
- {
- $special_id = intval($param['special_id']);
- $comment_id = intval($param['comment_id']);
- $user_id = intval($param['user_id']);
- account_helper::onAsyncUgcComment($special_id,$comment_id,$user_id);
- return callback(true);
- }
- public function onClickSpecial($param)
- {
- $special_id = intval($param['special_id']);
- if($special_id > 0) {
- Model()->table('mb_special')->where(['special_id' => $special_id])->update(['clicks' => ['exp', 'clicks + 1']]);
- }
- return callback(true);
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public function onAsyncBargain($param)
- {
- $type = $param['type'];
- $bargain_id = intval($param['bargain_id']);
- if(empty($type) || $bargain_id <= 0) {
- return callback(false);
- }
- else {
- account_helper::onAsyncBargain($type,$bargain_id);
- return callback(true);
- }
- }
- public function UpdateSotreLocation($param)
- {
- $store_id = intval($param['store_id']);
- if($store_id <= 0) {
- return callback(false);
- }
- else {
- $ret = geo_helper::instance()->update_store($store_id);
- return callback($ret);
- }
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public function OnUpdateRoom($param)
- {
- $roomid = intval($param['room_id']);
- if($roomid <= 0) {
- return callback(false);
- }
- else {
- Log::record("OnUpdateRoom Start",Log::DEBUG);
- $ret = room_helper::OnUpdateRoom($roomid);
- return callback($ret);
- }
- }
- public function OnGoodsConvert($params)
- {
- $appid = $params['appid'];
- $convert_sn = $params['convert_sn'];
- $return_url = $params['return_url'];
- $data['success'] = $params['success'] == true ? 1 : 0;
- $data['convert_sn'] = $params['convert_sn'];
- $data['appid'] = $params['appid'];
- if(empty($return_url) || empty($appid) || empty($convert_sn)) {
- return callback(false);
- }
- else {
- https_request($return_url,$data);
- return callback(true);
- }
- }
- //虚拟订单下单成功,回调事件.
- public function OnVrOrderSuccess($params)
- {
- $order_sn = $params['order_sn'];
- $model_order = Model('vr_order');
- $order = $model_order->getOrderInfo(['order_sn' => $order_sn]);
- $goods_id = $order['goods_id'];
- if($order['order_state'] == ORDER_STATE_NEW)
- {
- global $config;
- $handlers = $config['vgoods_handlers'];
- if(array_key_exists($goods_id,$handlers))
- {
- $handler = $handlers[$goods_id];
- $method = $handler['order_method'];
- if(!empty($method)) {
- $ret = $this->$method($order);
- if(!$ret) {
- return callback(false);
- }
- }
- }
- }
- return callback(true);
- }
- private function getTopcardAmound($goods_id)
- {
- global $config;
- $spec_card = $config['vgoods_spec_card'];
- if(array_key_exists($goods_id,$spec_card)) {
- return $spec_card[$goods_id];
- }
- else {
- return 0;
- }
- }
- private function OnReserveOilCard($order)
- {
- Log::record(__FUNCTION__,Log::DEBUG);
- $amount = $this->getTopcardAmound($order['goods_id']);
- $member_id = $order['buyer_id'];
- $order_id = $order['order_id'];
- $extra_info = json_decode($order['extra_info'],true);
- $card_no = $extra_info['input']['card_no'];
- $card_type = mtopcard\topcard_type($extra_info['input']['card_type']);
- $ret = mtopcard\cards_helper::reserve(mtopcard\OilCardPaper,$amount,$member_id,$card_no,$card_type,$order_id);
- return $ret;
- }
- private function OnReservePhoneCard($order)
- {
- Log::record(__FUNCTION__,Log::DEBUG);
- $amount = $this->getTopcardAmound($order['goods_id']);
- $member_id = $order['buyer_id'];
- $order_id = $order['order_id'];
- $extra_info = json_decode($order['extra_info'],true);
- $card_no = $extra_info['input']['card_no'];
- $card_type = mtopcard\topcard_type($extra_info['input']['card_type']);
- $ret = mtopcard\cards_helper::reserve(mtopcard\PhoneCardPaper,$amount,$member_id,$card_no,$card_type,$order_id);
- return $ret;
- }
- //虚拟订单取消回调事件.
- public function OnVrOrderCancel($params)
- {
- $order_sn = $params['order_sn'];
- $model_order = Model('vr_order');
- $order = $model_order->getOrderInfo(['order_sn' => $order_sn],'*',true);
- $goods_id = $order['goods_id'];
- global $config;
- $handlers = $config['vgoods_handlers'];
- if(array_key_exists($goods_id,$handlers))
- {
- $handler = $handlers[$goods_id];
- $method = $handler['cancel_method'];
- if(!empty($method)) {
- $this->$method($order);
- }
- }
- return callback(true);
- }
- private function OnCardKeyCancel($order)
- {
- $order_id = $order['order_id'];
- $mod_card = Model('card_key');
- $card = $mod_card->field('*')->where(['order_id' => $order_id])->select();
- if(empty($card)) {
- return callback(false,'订单取消,没找到对应的卡密.',['order_sn' => $order['order_sn']]);
- } else {
- CalcPrice::onCancelVrOrder($order);
- $card_id = $card[0]['card_id'];
- mtopcard\cards_helper::reuse($card_id);
- return callback(false,'订单取消,成功解除卡密.',['order_sn' => $order['order_sn']]);
- }
- }
- //虚拟订单支付成功回调事件.
- public function OnVrOrderPaidSuccess($params)
- {
- $order_sn = $params['order_sn'];
- $model_order = Model('vr_order');
- $order = $model_order->getOrderInfo(['order_sn' => $order_sn]);
- $goods_id = $order['goods_id'];
- global $config;
- $handlers = $config['vgoods_handlers'];
- if(array_key_exists($goods_id,$handlers))
- {
- $handler = $handlers[$goods_id];
- $method = $handler['paid_method'];
- if(!empty($method)) {
- $this->$method($order);
- }
- }
- return callback(true);
- }
- //支付成功完成会员卡操作.
- public function OnMCardPaidSuccess($order)
- {
- $order_sn = $order['order_sn'];
- if($order['order_state'] != ORDER_STATE_PAY) {
- Log::record("OnMCardOrderSuccess order_sn:{$order_sn} 状态错误",Log::ERR);
- return callback(false);
- }
- $extra_info = json_decode($order['extra_info'],true);
- $card_type = $extra_info['additional']['card_type'];
- if(empty($card_type)) {
- Log::record("OnMCardOrderSuccess order_sn:{$order_sn} 失败",Log::ERR);
- return callback(false);
- }
- else
- {
- $params = mcard\getConfig($card_type);
- if(empty($params)) {
- Log::record("OnMCardOrderSuccess order_sn:{$order_sn} card_type = {$card_type} 失败",Log::ERR);
- return callback(false);
- }
- $member_id = intval($order['buyer_id']);
- $usercards = new mcard\user_mcards($member_id);
- $ret = $usercards->addCard($params);
- if($ret) {
- $vrLogic = Logic('vr_order');
- $vrLogic->changeOrderStateSuccess($order['order_id']);
- return callback(false);
- } else {
- Log::record("OnMCardOrderSuccess order_sn:{$order_sn} addCard 失败",Log::ERR);
- return callback(false);
- }
- }
- }
- //虚拟商品完成回调事件....
- public function OnVrOrderComplete($params)
- {
- $order_sn = $params['order_sn'];
- $model_order = Model('vr_order');
- $order = $model_order->getOrderInfo(['order_sn' => $order_sn],'*',true);
- $goods_id = $order['goods_id'];
- global $config;
- $handlers = $config['vgoods_handlers'];
- if(array_key_exists($goods_id,$handlers))
- {
- $handler = $handlers[$goods_id];
- $method = $handler['complete_method'];
- if(!empty($method)) {
- $ret = $this->$method($order);
- if(!$ret) {
- return callback(false);
- }
- }
- }
- return callback(true);
- }
- private function OnCardKeyComplete($order)
- {
- $order_id = $order['order_id'];
- $mod_card = Model('card_key');
- $card = $mod_card->field('*')->where(['order_id' => $order_id])->select();
- if(empty($card)) {
- return callback(false,'充值失败',['order_sn' => $order['order_sn']]);
- } else {
- $card_id = $card[0]['card_id'];
- mtopcard\cards_helper::assign($card_id,'OnOilComplete');
- return callback(true,'充值成功',['order_sn' => $order['order_sn']]);
- }
- }
- }
|