site.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /**
  3. * 志汇酒店营销版模块微站定义
  4. *
  5. * @author 武汉志汇科技
  6. * @url http://bbs.we7.cc/
  7. */
  8. defined('IN_IA') or exit('Access Denied');
  9. require 'inc/func/core.php';
  10. class Zh_jdgjbModuleSite extends Core {
  11. public function doMobileYjRefund(){
  12. global $_W, $_GPC;
  13. $money=$_GPC['money']*100;//退款金额
  14. $order_id=$_GPC['id'];
  15. include_once IA_ROOT . '/addons/zh_jdgjb/cert/WxPay.Api.php';
  16. load()->model('account');
  17. load()->func('communication');
  18. $refund_order =pdo_get('zh_jdgjb_order',array('id'=>$order_id));
  19. $WxPayApi = new WxPayApi();
  20. $input = new WxPayRefund();
  21. $path_cert = IA_ROOT . "/addons/zh_jdgjb/cert/".'apiclient_cert_' .$_W['uniacid'] . '.pem';
  22. $path_key = IA_ROOT . "/addons/zh_jdgjb/cert/".'apiclient_key_' . $_W['uniacid'] . '.pem';
  23. $account_info = $_W['account'];
  24. $res=pdo_get('zh_jdgjb_system',array('uniacid'=>$_W['uniacid']));
  25. $appid=$res['appid'];
  26. $key=$res['wxkey'];
  27. $mchid=$res['mchid'];
  28. $out_trade_no=$refund_order['out_trade_no'];
  29. $fee = $refund_order['total_cost'] * 100;
  30. $input->SetAppid($appid);
  31. $input->SetMch_id($mchid);
  32. $input->SetOp_user_id($mchid);
  33. $input->SetRefund_fee($money);
  34. $input->SetTotal_fee($fee);
  35. // $input->SetTransaction_id($refundid);
  36. $input->SetOut_refund_no($refund_order['order_no']);
  37. $input->SetOut_trade_no($out_trade_no);
  38. $result = $WxPayApi->refund($input, 6, $path_cert, $path_key, $key);
  39. if ($result['result_code'] == 'SUCCESS') {//退款成功
  40. //更改订单操作
  41. pdo_update('zh_jdgjb_order',array('ytyj_cost +='=>($money/100)),array('id'=>$order_id));
  42. return '1';
  43. }else{
  44. return '2';
  45. }
  46. }
  47. public function doMobileSelectJd(){
  48. global $_W, $_GPC;
  49. $sql =" select id,name from ".tablename('zh_jdgjb_seller')." where uniacid={$_W['uniacid']} and state=2 and name like '%{$_GPC['keywords']}%'";
  50. echo json_encode(pdo_fetchall($sql));
  51. }
  52. public function doMobileSelectUser(){
  53. global $_W, $_GPC;
  54. $sql =" select id,name from ".tablename('zh_jdgjb_user')." where uniacid={$_W['uniacid']} and openid like '%{$_GPC['keywords']}%'";
  55. echo json_encode(pdo_fetchall($sql));
  56. }
  57. public function doMobileNewOrder(){
  58. global $_W, $_GPC;
  59. $time=time();
  60. $time2=$time-10;
  61. if($_GPC['role']=='operator'){
  62. //查找商家ID;
  63. $seller=pdo_get('zh_jdgjb_account',array('weid'=>$_W['uniacid'],'uid'=>$_GPC['uid']));
  64. $seller_id=$seller['storeid'];
  65. $sql="SELECT * FROM ".tablename('zh_jdgjb_order')." WHERE uniacid=:uniacid and status=2 and seller_id=:seller_id and voice=1 union all SELECT * FROM ".tablename('zh_jdgjb_order')." WHERE status=1 and type=3 and seller_id=:seller_id and uniacid=:uniacid and voice=1";
  66. $res=pdo_fetch($sql,array(':uniacid'=>$_GPC['uniacid'],':seller_id'=>$seller_id));
  67. if($res){
  68. echo '1';
  69. }else{
  70. echo '2';
  71. }
  72. }else {
  73. $sql="SELECT * FROM ".tablename('zh_jdgjb_order')." WHERE status=2 and uniacid=:uniacid and voice=1 union all SELECT * FROM ".tablename('zh_jdgjb_order')." WHERE status=1 and type=3 and uniacid=:uniacid and voice=1";
  74. $res=pdo_fetch($sql,array(':uniacid'=>$_GPC['uniacid']));
  75. if($res){
  76. echo '1';
  77. }else{
  78. echo '2';
  79. }
  80. }
  81. }
  82. //删除充值活动
  83. public function doMobileDelCz(){
  84. global $_W,$_GPC;
  85. $res=pdo_delete('zh_jdgjb_czhd',array('id'=>$_GPC['id']));
  86. if($res){
  87. echo '1';
  88. }else{
  89. echo '2';
  90. }
  91. }
  92. //添加充值活动
  93. public function doMobileAddCz(){
  94. global $_W,$_GPC;
  95. for($i=0;$i<count($_GPC['list']);$i++){
  96. $data['full']=$_GPC['list'][$i]['full'];
  97. $data['reduction']=$_GPC['list'][$i]['reduction'];
  98. $data['uniacid']=$_W['uniacid'];
  99. pdo_insert('zh_jdgjb_czhd',$data);
  100. }
  101. }
  102. public function doMobileSelectUser2(){
  103. global $_W, $_GPC;
  104. $sql =" select id,name from ".tablename('zh_jdgjb_user')." where uniacid={$_W['uniacid']} and openid like '%{$_GPC['keywords']}%' and id not in (select user_id from".tablename('zh_jdgjb_seller')." where uniacid={$_W['uniacid']})";
  105. echo json_encode(pdo_fetchall($sql));
  106. }
  107. //获取一级
  108. public function doMobileGetYj(){
  109. global $_W,$_GPC;
  110. $user_id=$_GPC['user_id'];
  111. $sql=" select b.name as yj_name,c.name as fx_name,a.time from".tablename('zh_jdgjb_fxuser')." a left join ".tablename('zh_jdgjb_user')." b on a.fx_user=b.id left join ".tablename('zh_jdgjb_user')." c on a.user_id=c.id where a.user_id={$user_id}";
  112. $res=pdo_fetchall($sql);
  113. if($res){
  114. foreach ($res as &$value) {
  115. $value['time']=date("Y-m-d H:i:s",$value['time']);
  116. }
  117. }
  118. //$res=pdo_getall('cjdc_fxuser',array('user_id'=>$user_id));
  119. echo json_encode($res);
  120. }
  121. //获取二级
  122. public function doMobileGetEj(){
  123. global $_W,$_GPC;
  124. $user_id=$_GPC['user_id'];
  125. $fx=pdo_get('zh_jdgjb_user',array('id'=> $user_id),'name');
  126. $res=pdo_getall('zh_jdgjb_fxuser',array('user_id'=>$user_id),'fx_user');
  127. foreach ($res as $key => $value) {
  128. $sql=" select b.name as yj_name,a.time from".tablename('zh_jdgjb_fxuser')." a left join ".tablename('zh_jdgjb_user')." b on a.fx_user=b.id where a.user_id={$value['fx_user']}";
  129. $res2=pdo_fetchall($sql);
  130. if($res2){
  131. foreach ($res2 as $key2 => $value2) {
  132. $rst[$key2]['fx_name']=$fx['name'];
  133. $rst[$key2]['yj_name']=$value2['yj_name'];
  134. $rst[$key2]['time']=date("Y-m-d H:i:s",$value2['time']);
  135. }
  136. }
  137. }
  138. echo json_encode($rst);
  139. }
  140. }