queue.logic.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. <?php
  2. /**
  3. * 队列
  4. *
  5. * 方法名需要和 QueueClient::push中第一个参数一致,如:
  6. * QueueClient::push('editGroupbuySaleCount',$groupbuy_info);
  7. * public function editGroupbuySaleCount($groupbuy_info){...}
  8. *
  9. */
  10. defined('InShopNC') or exit('Access Invalid!');
  11. require_once (BASE_ROOT_PATH . '/helper/push_sender.php');
  12. require_once (BASE_ROOT_PATH . '/helper/sms_helper.php');
  13. require_once (BASE_ROOT_PATH . '/helper/kdn_helper.php');
  14. require_once (BASE_ROOT_PATH . '/helper/statistics_helper.php');
  15. require_once (BASE_ROOT_PATH . '/helper/member_helper.php');
  16. require_once (BASE_ROOT_PATH . '/helper/account_helper.php');
  17. require_once (BASE_ROOT_PATH . '/helper/fcode/generator.php');
  18. require_once (BASE_ROOT_PATH . '/helper/memsg/message_sender.php');
  19. require_once (BASE_ROOT_PATH . '/helper/login_helper.php');
  20. require_once (BASE_ROOT_PATH . '/helper/fcode/mfcode.php');
  21. require_once (BASE_ROOT_PATH . '/helper/fcode/operator.php');
  22. require_once (BASE_ROOT_PATH . '/helper/user_session/fcode.php');
  23. require_once (BASE_ROOT_PATH . '/helper/stat_helper.php');
  24. require_once (BASE_ROOT_PATH . '/helper/message/publisher.php');
  25. require_once (BASE_ROOT_PATH . '/helper/search/tcp_client.php');
  26. require_once (BASE_ROOT_PATH . '/helper/ugc_helper.php');
  27. class queueLogic
  28. {
  29. /**
  30. * push app内容跳转类型
  31. * @var array
  32. */
  33. protected $go_type = array(
  34. '',//跳转到app首页
  35. 'bonus',//红包页
  36. );
  37. /**
  38. * 添加会员积分
  39. * @param unknown $member_info
  40. */
  41. public function addPoint($member_info)
  42. {
  43. $points_model = Model('points');
  44. $points_model->savePointsLog('login', array('pl_memberid' => $member_info['member_id'], 'pl_membername' => $member_info['member_name']), true);
  45. return callback(true);
  46. }
  47. /**
  48. * 添加会员经验值
  49. * @param unknown $member_info
  50. */
  51. public function addExppoint($member_info)
  52. {
  53. $exppoints_model = Model('exppoints');
  54. $exppoints_model->saveExppointsLog('login', array('exp_memberid' => $member_info['member_id'], 'exp_membername' => $member_info['member_name']), true);
  55. return callback(true);
  56. }
  57. /**
  58. * 更新抢购信息
  59. * @param unknown $groupbuy_info
  60. * @throws Exception
  61. */
  62. public function editGroupbuySaleCount($groupbuy_info)
  63. {
  64. $model_groupbuy = Model('groupbuy');
  65. $data = array();
  66. $data['buyer_count'] = array('exp', 'buyer_count+1');
  67. $data['buy_quantity'] = array('exp', 'buy_quantity+' . $groupbuy_info['quantity']);
  68. $update = $model_groupbuy->editGroupbuy($data, array('groupbuy_id' => $groupbuy_info['groupbuy_id']));
  69. if (!$update) {
  70. return callback(false, '更新抢购信息失败groupbuy_id:' . $groupbuy_info['groupbuy_id']);
  71. } else {
  72. return callback(true);
  73. }
  74. }
  75. /**
  76. * 更新使用的代金券状态
  77. * @param $input_voucher_list
  78. * @throws Exception
  79. */
  80. public function editVoucherState($voucher_list)
  81. {
  82. $model_voucher = Model('voucher');
  83. $send = new memsg\message_sender();
  84. foreach ($voucher_list as $store_id => $voucher_info) {
  85. $update = $model_voucher->editVoucher(array('voucher_state' => 2), array('voucher_id' => $voucher_info['voucher_id']), $voucher_info['voucher_owner_id']);
  86. if ($update) {
  87. // 发送用户店铺消息
  88. $send->set('member_id', $voucher_info['voucher_owner_id']);
  89. $send->set('code', 'voucher_use');
  90. $param = array();
  91. $param['voucher_code'] = $voucher_info['voucher_code'];
  92. $param['voucher_url'] = urlShop('member_voucher', 'index');
  93. $send->send($param);
  94. } else {
  95. return callback(false, '更新代金券状态失败vcode:' . $voucher_info['voucher_code']);
  96. }
  97. }
  98. return callback(true);
  99. }
  100. /**
  101. * 下单变更库存销量
  102. * @param unknown $goods_buy_quantity
  103. */
  104. public function createOrderUpdateStorage($goods_buy_quantity)
  105. {
  106. $model_goods = Model('goods');
  107. foreach ($goods_buy_quantity as $goods_id => $quantity) {
  108. $data = array();
  109. $data['goods_storage'] = array('exp', 'goods_storage-' . $quantity);
  110. $data['goods_salenum'] = array('exp', 'goods_salenum+' . $quantity);
  111. $result = $model_goods->editGoodsById($data, $goods_id);
  112. }
  113. if (!$result) {
  114. return callback(false, '变更商品库存与销量失败');
  115. } else {
  116. return callback(true);
  117. }
  118. }
  119. /**
  120. * 取消订单变更库存销量
  121. * @param unknown $goods_buy_quantity
  122. */
  123. public function cancelOrderUpdateStorage($goods_buy_quantity)
  124. {
  125. $model_goods = Model('goods');
  126. foreach ($goods_buy_quantity as $goods_id => $quantity) {
  127. $data = array();
  128. $data['goods_storage'] = array('exp', 'goods_storage+' . $quantity);
  129. $data['goods_salenum'] = array('exp', 'goods_salenum-' . $quantity);
  130. $result = $model_goods->editGoodsById($data, $goods_id);
  131. }
  132. if (!$result) {
  133. return callback(false, '变更商品库存与销量失败');
  134. } else {
  135. return callback(true);
  136. }
  137. }
  138. /**
  139. * 更新F码为使用状态
  140. * @param int $fc_id
  141. */
  142. public function updateGoodsFCode($fc_ids)
  143. {
  144. $update = Model('goods_fcode')->editGoodsFCode(array('fc_state' => 1), array('fc_id' => array('in',$fc_ids)));
  145. if (!$update) {
  146. return callback(false, '更新F码使用状态失败fc_ids:' . implode(',',$fc_ids));
  147. } else {
  148. return callback(true);
  149. } }
  150. /**
  151. * 删除购物车
  152. * @param unknown $cart
  153. */
  154. public function delCart($cart)
  155. {
  156. if (!is_array($cart['cart_ids']) || empty($cart['buyer_id'])) return callback(true);
  157. $del = Model('cart')->delCart('db', array('buyer_id' => $cart['buyer_id'], 'cart_id' => array('in', $cart['cart_ids'])));
  158. if (!$del) {
  159. return callback(false, '删除购物车数据失败');
  160. } else {
  161. return callback(true);
  162. }
  163. }
  164. /**
  165. * 根据商品id更新促销价格
  166. *
  167. * @param int /array $goods_commonid
  168. * @return boolean
  169. */
  170. public function updateGoodsPromotionPriceByGoodsId($goods_id)
  171. {
  172. $update = Model('goods')->editGoodsPromotionPrice(array('goods_id' => array('in', $goods_id)));
  173. if (!$update) {
  174. return callback(false, '根据商品ID更新促销价格失败');
  175. } else {
  176. return callback(true);
  177. }
  178. }
  179. /**
  180. * 根据商品公共id更新促销价格
  181. *
  182. * @param int /array $goods_commonid
  183. * @return boolean
  184. */
  185. public function updateGoodsPromotionPriceByGoodsCommonId($goods_commonid)
  186. {
  187. $update = Model('goods')->editGoodsPromotionPrice(array('goods_commonid' => array('in', $goods_commonid)));
  188. if (!$update) {
  189. return callback(false, '根据商品公共id更新促销价格失败');
  190. } else {
  191. return callback(true);
  192. }
  193. }
  194. /**
  195. * 发送店铺消息
  196. */
  197. public function sendStoreMsg($param)
  198. {
  199. $send = new sendStoreMsg();
  200. $send->set('code', $param['code']);
  201. $send->set('store_id', $param['store_id']);
  202. $send->send($param['param']);
  203. return callback(true);
  204. }
  205. /**
  206. * 发送会员消息
  207. */
  208. public function sendMemberMsg($param)
  209. {
  210. $send = new memsg\message_sender();
  211. $send->set('code', $param['code']);
  212. $send->set('member_id', $param['member_id']);
  213. $send->set('sms_param', $param['sms_param']);
  214. if (!empty($param['number']['mobile'])) $send->set('mobile', $param['number']['mobile']);
  215. if (!empty($param['number']['email'])) $send->set('email', $param['number']['email']);
  216. $send->send($param['param']);
  217. return callback(true);
  218. }
  219. /**
  220. * 生成商品F码
  221. */
  222. public function createGoodsFCode($param)
  223. {
  224. Log::record("createGoodsFCode {$param['goods_commonid']},{$param['fc_count']},{$param['fc_prefix']},{$param['fc_validate']}",Log::DEBUG);
  225. $gen = new fcode\generator($param['goods_commonid'],$param['fc_count'],$param['fc_prefix'],$param['fc_validate']);
  226. $url = $gen->make();
  227. Log::record("createGoodsFCode url={$url}",Log::DEBUG);
  228. return callback(true);
  229. }
  230. /**
  231. * 生成商品二维码
  232. */
  233. public function createGoodsQRCode($param)
  234. {
  235. if (empty($param['goodsid_array'])) {
  236. return callback(true);
  237. }
  238. // 生成商品二维码
  239. require_once(BASE_RESOURCE_PATH . DS . 'phpqrcode' . DS . 'index.php');
  240. $PhpQRCode = new PhpQRCode();
  241. $PhpQRCode->set('pngTempDir', BASE_UPLOAD_PATH . DS . ATTACH_STORE . DS . $param['store_id'] . DS);
  242. foreach ($param['goodsid_array'] as $goods_id) {
  243. // 生成商品二维码
  244. $PhpQRCode->set('date', urlShop('goods', 'index', array('goods_id' => $goods_id)));
  245. $PhpQRCode->set('pngTempName', $goods_id . '.png');
  246. $PhpQRCode->init();
  247. }
  248. return callback(true);
  249. }
  250. /**
  251. * 清理特殊商品促销信息
  252. */
  253. public function clearSpecialGoodsPromotion($param)
  254. {
  255. // 抢购
  256. Model('groupbuy')->delGroupbuy(array('goods_commonid' => $param['goods_commonid']));
  257. // 显示折扣
  258. Model('p_xianshi_goods')->delXianshiGoods(array('goods_id' => array('in', $param['goodsid_array'])));
  259. // 优惠套装
  260. Model('p_bundling')->delBundlingGoods(array('goods_id' => array('in', $param['goodsid_array'])));
  261. // 更新促销价格
  262. Model('goods')->editGoods(array('goods_promotion_price' => array('exp', 'goods_price'), 'goods_promotion_type' => 0), array('goods_commonid' => $param['goods_commonid']));
  263. return callback(true);
  264. }
  265. /**
  266. * 删除(买/卖家)订单全部数量缓存
  267. * @param array $data 订单信息
  268. * @return boolean
  269. */
  270. public function delOrderCountCache($order_info)
  271. {
  272. if (empty($order_info)) return callback(true);
  273. $model_order = Model('order');
  274. if ($order_info['order_id']) {
  275. $order_info = $model_order->getOrderInfo(array('order_id' => $order_info['order_id']), array(), 'buyer_id,store_id');
  276. }
  277. $model_order->delOrderCountCache('buyer', $order_info['buyer_id']);
  278. $model_order->delOrderCountCache('store', $order_info['store_id']);
  279. return callback(true);
  280. }
  281. /**
  282. * 发送兑换码
  283. * @param unknown $param
  284. * @return boolean
  285. */
  286. public function sendVrCode($param)
  287. {
  288. if (empty($param) && !is_array($param)) return callback(true);
  289. $condition = array();
  290. $condition['order_id'] = $param['order_id'];
  291. $condition['buyer_id'] = $param['buyer_id'];
  292. $condition['vr_state'] = 0;
  293. $condition['refund_lock'] = 0;
  294. $code_list = Model('vr_order')->getOrderCodeList($condition, 'vr_code,vr_indate');
  295. if (empty($code_list)) return callback(true);
  296. $content = '';
  297. foreach ($code_list as $v) {
  298. $content .= $v['vr_code'] . ',';
  299. }
  300. $tpl_info = Model('mail_templates')->getTplInfo(array('code' => 'send_vr_code'));
  301. $data = array();
  302. $data['site_name'] = C('site_name');
  303. $data['vr_code'] = rtrim($content, ',');
  304. $message = ncReplaceText($tpl_info['content'], $data);
  305. $sms = new Sms();
  306. $result = $sms->send($param["buyer_phone"], $message);
  307. if (!$result) {
  308. return callback(false, '兑换码发送失败order_id:' . $param['order_id']);
  309. } else {
  310. return callback(true);
  311. }
  312. }
  313. /**
  314. * 添加订单自提表内容
  315. */
  316. public function saveDeliveryOrder($param)
  317. {
  318. if (!is_array($param['order_sn_list'])) return callback(true);
  319. $data = array();
  320. $model_delivery_order = Model('delivery_order');
  321. foreach ($param['order_sn_list'] as $order_id => $v) {
  322. $data['order_id'] = $order_id;
  323. $data['order_sn'] = $v['order_sn'];
  324. $data['addtime'] = $v['add_time'];
  325. $data['dlyp_id'] = $param['dlyp_id'];
  326. $data['reciver_name'] = $param['reciver_name'];
  327. $data['reciver_telphone'] = $param['tel_phone'];
  328. $data['reciver_mobphone'] = $param['mob_phone'];
  329. $insert = $model_delivery_order->addDeliveryOrder($data);
  330. if (!$insert) {
  331. return callback(false, '保存自提站订单信息失败order_sn:' . $v['order_sn']);
  332. }
  333. }
  334. return callback(true);
  335. }
  336. /**
  337. * 发送提货码短信消息
  338. */
  339. public function sendPickupcode($param)
  340. {
  341. $dorder_info = Model('delivery_order')->getDeliveryOrderInfo(array('order_id' => $param['order_id']), 'reciver_mobphone');
  342. $tpl_info = Model('mail_templates')->getTplInfo(array('code' => 'send_pickup_code'));
  343. $data = array();
  344. $data['site_name'] = C('site_name');
  345. $data['pickup_code'] = $param['pickup_code'];
  346. $message = ncReplaceText($tpl_info['content'], $data);
  347. $sms = new Sms();
  348. $result = $sms->send($dorder_info['reciver_mobphone'], $message);
  349. if (!$result) {
  350. return callback(false, '发送提货码短信消息失败order_id:' . $param['order_id']);
  351. } else {
  352. return callback(true);
  353. }
  354. }
  355. /**
  356. * 刷新搜索索引
  357. */
  358. public function flushIndexer()
  359. {
  360. require_once(BASE_DATA_PATH . '/api/xs/lib/XS.php');
  361. $obj_doc = new XSDocument();
  362. $obj_xs = new XS(C('fullindexer.appname'));
  363. $obj_xs->index->flushIndex();
  364. }
  365. /**
  366. * 推送服务
  367. * @param $param array
  368. * 共有三个key : member_id , text, go_type
  369. * @return bool
  370. */
  371. public function upushSendMsg($param)
  372. {
  373. if (empty($param) || empty($param['member_id']) || empty($param['text'])) {
  374. Log::record("push info: 数据有误! param:" . json_encode($param) . "\t session:" . json_encode($_SESSION));
  375. return callback(false);
  376. }
  377. if (!isset($param['go_type'])) {
  378. $param['go_type'] = '';
  379. }
  380. if (!in_array($param['go_type'], $this->go_type)) {
  381. Log::record("push info: go_type参数有误! param:" . json_encode($param) . "\t session:" . json_encode($_SESSION));
  382. return callback(false);
  383. }
  384. $push = new push_sender();
  385. $push->send($param);
  386. return callback(true);
  387. }
  388. public function sendPushMessage($param)
  389. {
  390. $push = new push_sender();
  391. $push->send_message($param);
  392. return callback(true);
  393. }
  394. /**
  395. * 发短信
  396. * @param $param
  397. *
  398. * @return bool
  399. */
  400. public function sendSMS($param)
  401. {
  402. if (empty($param) || empty($param['mobile']) || empty($param['type'])) {
  403. Log::record("sms info: 数据有误! param:" . json_encode($param),Log::ERR);
  404. return callback(false);
  405. }
  406. try {
  407. $sms = new Sms();
  408. $status = $sms->send($param['mobile'], $param);
  409. Log::record("sms info: status:" . json_encode($status) . "\t param:" . json_encode($param),Log::DEBUG);
  410. } catch (Exception $e) {
  411. Log::record("sms info: fall error\treturn:" . $e->getMessage() . "\t param:" . json_encode($param),Log::ERR);
  412. }
  413. return callback(true);
  414. }
  415. public function sendBonusAndSMS($params)
  416. {
  417. $input_type = $params['member']['input_type'];
  418. if($input_type == 'mobiles') {
  419. $members = member_helper::from_mobiles($params['member']['data'],$error);
  420. }
  421. elseif($input_type == 'sql') {
  422. $members = member_helper::from_sql($params['member']['data']);
  423. }
  424. else {
  425. return callback(false,'sendBonusAndSMS 错误的人员输入类型.');
  426. }
  427. $fSendSms = $params['sms']['open'];
  428. $smscode = $params['sms']['template_id'];
  429. $rate = $params['bonus']['rate'];
  430. $bless = $params['bonus']['bless'];
  431. $amount = $params['bonus']['amount'];
  432. $chunks = array_chunk($members,1000);
  433. foreach ($chunks as $chunk)
  434. {
  435. $chunk = member_helper::exmembers($chunk,$params['member']['ex_lrlz'],$params['member']['ex_brand']);
  436. $ids = [];
  437. foreach ($chunk as $member) {
  438. $ids[] = $member['member_id'];
  439. }
  440. $ret = account_helper::add_bonus($rate,$amount,$ids,$bless);
  441. if($ret == false) continue;
  442. if($fSendSms)
  443. {
  444. $iconut = 0;
  445. $sms = new Sms();
  446. foreach ($chunk as $member)
  447. {
  448. $mobile = $member['member_mobile'];
  449. try {
  450. $status = $sms->send_oper($mobile, $smscode);
  451. Log::record("sms info: status:" . json_encode($status),Log::DEBUG);
  452. } catch (Exception $e) {
  453. Log::record("sms info: fall error\treturn:" . $e->getMessage(),Log::ERR);
  454. }
  455. ++$iconut;
  456. if($iconut == 10) {
  457. sleep(2);
  458. $iconut = 0;
  459. }
  460. }
  461. }
  462. }
  463. return callback(true);
  464. }
  465. public function sendPushOrSMS($params)
  466. {
  467. $input_type = $params['member']['input_type'];
  468. if($input_type == 'mobiles') {
  469. $members = member_helper::from_mobiles($params['member']['data'],$error);
  470. }
  471. elseif($input_type == 'sql') {
  472. $members = member_helper::from_sql($params['member']['data']);
  473. }
  474. else {
  475. return callback(false,'sendBonusAndSMS 错误的人员输入类型.');
  476. }
  477. $send_type = $params['send']['type'];
  478. $content = $params['send']['data'];
  479. $chunks = array_chunk($members,1000);
  480. foreach ($chunks as $chunk)
  481. {
  482. $chunk = member_helper::exmembers($chunk,$params['member']['ex_lrlz'],$params['member']['ex_brand']);
  483. if($send_type == 'sms')
  484. {
  485. $iconut = 0;
  486. $sms = new Sms();
  487. foreach ($chunk as $member)
  488. {
  489. try {
  490. $mobile = $member['member_mobile'];
  491. $status = $sms->send_oper($mobile, $content);
  492. Log::record("sms info: status:" . json_encode($status),Log::DEBUG);
  493. } catch (Exception $e) {
  494. Log::record("sms info: fall error\treturn:" . $e->getMessage(),Log::ERR);
  495. }
  496. ++$iconut;
  497. if($iconut == 10) {
  498. sleep(2);
  499. $iconut = 0;
  500. }
  501. }
  502. }
  503. elseif($send_type == 'push')
  504. {
  505. foreach ($chunk as $member) {
  506. push_helper::oper_push($member['member_id'], $content);
  507. }
  508. }
  509. else {
  510. }
  511. }
  512. return callback(true);
  513. }
  514. /**
  515. * 订阅快递鸟
  516. * @param $param
  517. *
  518. * @return bool
  519. */
  520. public function subscribeKDN($param)
  521. {
  522. if (empty($param) || empty($param['order_sn'])) {
  523. Log::record("kdn_helper: 数据有误! param:" . json_encode($param));
  524. return callback(false);
  525. }
  526. try {
  527. kdn_helper::subscribe($param['order_sn']);
  528. } catch (Exception $e) {
  529. Log::record("kdn_helper: fall error\treturn:" . $e->getMessage() . "\t param:" . json_encode($param));
  530. }
  531. return callback(true);
  532. }
  533. /**
  534. * 根据上传的通讯录生成好友关系
  535. */
  536. public function generateRelations($param)
  537. {
  538. if (empty($param["member_id"])) {
  539. return false;
  540. }
  541. try {
  542. Model("mobile_contacts")->genRelations($param["member_id"]);
  543. } catch (Exception $e) {
  544. Log::record("generateRelations: fall error\treturn:" . $e->getMessage());
  545. }
  546. return true;
  547. }
  548. public function savelog($param)
  549. {
  550. statistics_helper::instance()->add_logs($param);
  551. return callback(true);
  552. }
  553. public function click_goods($param)
  554. {
  555. $goods_id = intval($param['goods_id']);
  556. if($goods_id > 0) {
  557. $mod_goods = Model('goods');
  558. $mod_goods->editGoodsById(array('goods_click' => array('exp', 'goods_click + 1')), $goods_id);
  559. return callback(true);
  560. }
  561. else {
  562. return callback(false,"click_goods 错误的goods_id");
  563. }
  564. }
  565. public function invite_user_register($param)
  566. {
  567. $member_id = $param['member_id'];
  568. $relay_id = $param['relay_id'];
  569. $password = $param['password'];
  570. if($member_id < 0) {
  571. return callback(false,"invite_user_register 错误的member_id");
  572. }
  573. login_helper::onInvite($member_id,$relay_id,$password);
  574. return callback(true);
  575. }
  576. public function onPredeposit($param)
  577. {
  578. Log::record('queue::onPredeposit',Log::DEBUG);
  579. account_helper::onPredeposit($param['change_type'],$param['buyer_id'],$param['order_sn']);
  580. return callback(true);
  581. }
  582. public function onPaySuccess($param)
  583. {
  584. $pay_sn = $param['pay_sn'];
  585. account_helper::onPaySuccess($pay_sn);
  586. return callback(true);
  587. }
  588. public function reset_fcode($param)
  589. {
  590. $pay_sn = $param['pay_sn'];
  591. if(empty($pay_sn)) {
  592. return callback(false);
  593. }
  594. $num = \fcode\operator::reset($pay_sn);
  595. if($num > 0) {
  596. return callback(true);
  597. } else {
  598. return callback(false);
  599. }
  600. }
  601. public function onUseBonus($param)
  602. {
  603. stat_helper::onUseBonus($param);
  604. return callback(true);
  605. }
  606. public function onPublishSpecial($param)
  607. {
  608. $publisher = new message\publisher();
  609. $publisher->add_special($param['user_id'],$param['specials']);
  610. $specials = $param['specials'];
  611. $pub_count = 0;
  612. $pri_count = 0;
  613. foreach ($specials as $special)
  614. {
  615. if($special['type'] == 0) {
  616. $pub_count++;
  617. }
  618. else {
  619. $pri_count++;
  620. }
  621. }
  622. $result = search\relation_client::instance()->fetch_follow(array('user_id' => $param['user_id']));
  623. if($result['code'] == 200)
  624. {
  625. $follows = $result['data']['follows'];
  626. $pushor = new push_message();
  627. if($pri_count > 0 || $pub_count > 0) {
  628. $pushor->publish_special($follows,false,$pri_count);
  629. }
  630. }
  631. return callback(true);
  632. }
  633. public function onDelSpecial($param)
  634. {
  635. $publisher = new message\publisher();
  636. $publisher->del_special($param['user_id'],$param['specials']);
  637. return callback(true);
  638. }
  639. public function onUgcComment($param)
  640. {
  641. try
  642. {
  643. $special_id = intval($param['special_id']);
  644. $comment_id = intval($param['comment_id']);
  645. $senderid = intval($param['member_id']);
  646. if($comment_id > 0)
  647. {
  648. $mod = Model('ugc_comment');
  649. $comments = $mod->getCommentList(['comment_id' => $comment_id],'*',0);
  650. if(!empty($comments)) {
  651. $member_id = intval($comments['user_id']);
  652. }
  653. }
  654. else
  655. {
  656. $mod_special = Model('mb_special');
  657. $special_info = $mod_special->getMbSpecialByID($special_id,'*');
  658. if(empty($special_info)) {
  659. return callback(false);
  660. }
  661. $special = new ugc\special($special_info);
  662. $member_id = $special->memberid();
  663. }
  664. $sender = new member_info($senderid);
  665. $content = "{$sender->nickname()} 评论了您";
  666. push_helper::comment($member_id,$special_id,$content);
  667. return callback(true);
  668. }
  669. catch (Exception $ex)
  670. {
  671. return callback(false);
  672. }
  673. }
  674. public function onClickSpecial($param)
  675. {
  676. $special_id = intval($param['special_id']);
  677. if($special_id > 0) {
  678. Model()->table('mb_special')->where(['special_id' => $special_id])->update(['clicks' => ['exp', 'clicks + 1']]);
  679. }
  680. return callback(true);
  681. }
  682. }